Mirror of https://github.com/roostorg/coop github.com/roostorg/coop
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Vulnerabilities] Upgrade Kysely to latest (#214)

* [Vulnerabilities] Upgrade Kysely to latest

* fix lint

* code review

authored by

Juan Mrad and committed by
GitHub
ffc58854 b88b1640

+39 -42
+8 -8
db/package-lock.json
··· 13 13 "@roostorg/db-migrator": "^1.0.9", 14 14 "cassandra-driver": "^4.8.0", 15 15 "csv-parse": "^5.0.4", 16 - "kysely": "^0.26.3", 16 + "kysely": "^0.28.16", 17 17 "latlon-geohash": "^1.1.0", 18 18 "lodash": "^4.18.1", 19 19 "pg": "^8.7.1", ··· 783 783 } 784 784 }, 785 785 "node_modules/kysely": { 786 - "version": "0.26.3", 787 - "resolved": "https://registry.npmjs.org/kysely/-/kysely-0.26.3.tgz", 788 - "integrity": "sha512-yWSgGi9bY13b/W06DD2OCDDHQmq1kwTGYlQ4wpZkMOJqMGCstVCFIvxCCVG4KfY1/3G0MhDAcZsip/Lw8/vJWw==", 786 + "version": "0.28.16", 787 + "resolved": "https://registry.npmjs.org/kysely/-/kysely-0.28.16.tgz", 788 + "integrity": "sha512-3i5pmOiZvMDj00qhrIVbH0AnioVTx22DMP7Vn5At4yJO46iy+FM8Y/g61ltenLVSo3fiO8h8Q3QOFgf/gQ72ww==", 789 789 "license": "MIT", 790 790 "engines": { 791 - "node": ">=14.0.0" 791 + "node": ">=20.0.0" 792 792 } 793 793 }, 794 794 "node_modules/latlon-geohash": { ··· 2071 2071 } 2072 2072 }, 2073 2073 "kysely": { 2074 - "version": "0.26.3", 2075 - "resolved": "https://registry.npmjs.org/kysely/-/kysely-0.26.3.tgz", 2076 - "integrity": "sha512-yWSgGi9bY13b/W06DD2OCDDHQmq1kwTGYlQ4wpZkMOJqMGCstVCFIvxCCVG4KfY1/3G0MhDAcZsip/Lw8/vJWw==" 2074 + "version": "0.28.16", 2075 + "resolved": "https://registry.npmjs.org/kysely/-/kysely-0.28.16.tgz", 2076 + "integrity": "sha512-3i5pmOiZvMDj00qhrIVbH0AnioVTx22DMP7Vn5At4yJO46iy+FM8Y/g61ltenLVSo3fiO8h8Q3QOFgf/gQ72ww==" 2077 2077 }, 2078 2078 "latlon-geohash": { 2079 2079 "version": "1.1.0",
+1 -1
db/package.json
··· 15 15 "@roostorg/db-migrator": "^1.0.9", 16 16 "cassandra-driver": "^4.8.0", 17 17 "csv-parse": "^5.0.4", 18 - "kysely": "^0.26.3", 18 + "kysely": "^0.28.16", 19 19 "latlon-geohash": "^1.1.0", 20 20 "lodash": "^4.18.1", 21 21 "pg": "^8.7.1",
+5 -5
server/package-lock.json
··· 70 70 "ioredis": "^5.2.4", 71 71 "jsonwebtoken": "^9.0.3", 72 72 "knex": "^2.3.0", 73 - "kysely": "0.26.1", 73 + "kysely": "^0.28.16", 74 74 "latlon-geohash": "^2.0.0", 75 75 "lodash": "^4.18.1", 76 76 "lru_map": "^0.4.1", ··· 17667 17667 } 17668 17668 }, 17669 17669 "node_modules/kysely": { 17670 - "version": "0.26.1", 17671 - "resolved": "https://registry.npmjs.org/kysely/-/kysely-0.26.1.tgz", 17672 - "integrity": "sha512-FVRomkdZofBu3O8SiwAOXrwbhPZZr8mBN5ZeUWyprH29jzvy6Inzqbd0IMmGxpd4rcOCL9HyyBNWBa8FBqDAdg==", 17670 + "version": "0.28.16", 17671 + "resolved": "https://registry.npmjs.org/kysely/-/kysely-0.28.16.tgz", 17672 + "integrity": "sha512-3i5pmOiZvMDj00qhrIVbH0AnioVTx22DMP7Vn5At4yJO46iy+FM8Y/g61ltenLVSo3fiO8h8Q3QOFgf/gQ72ww==", 17673 17673 "license": "MIT", 17674 17674 "engines": { 17675 - "node": ">=14.0.0" 17675 + "node": ">=20.0.0" 17676 17676 } 17677 17677 }, 17678 17678 "node_modules/latlon-geohash": {
+1 -1
server/package.json
··· 84 84 "ioredis": "^5.2.4", 85 85 "jsonwebtoken": "^9.0.3", 86 86 "knex": "^2.3.0", 87 - "kysely": "0.26.1", 87 + "kysely": "^0.28.16", 88 88 "latlon-geohash": "^2.0.0", 89 89 "lodash": "^4.18.1", 90 90 "lru_map": "^0.4.1",
+15 -11
server/services/analyticsQueries/RuleActionInsights.ts
··· 16 16 type Integration, 17 17 } from '../../services/signalsService/index.js'; 18 18 import { jsonParse, type JsonOf } from '../../utils/encoding.js'; 19 - import { 20 - type Excluding, 21 - type FixSingleTableReturnedRowType, 22 - } from '../../utils/kysely.js'; 23 19 import { getUtcDateOnlyString, YEAR_MS } from '../../utils/time.js'; 24 20 import { type ConditionSetWithResultAsLogged } from '../analyticsLoggers/ruleExecutionLoggingUtils.js'; 25 21 import { 26 22 warehouseDateToDate, 27 23 warehouseDateToDateOnlyString, 28 - type RuleExecutionsRow, 29 24 type WarehouseDate, 30 25 type DataWarehousePublicSchema, 31 26 } from '../../storage/dataWarehouse/warehouseSchema.js'; ··· 38 33 itemTypeName: string; 39 34 itemTypeId: string; 40 35 userId: string | null; 36 + userTypeId: string | null; 41 37 content: JsonOf<NormalizedItemData> | undefined; 42 38 environment: RuleEnvironment; 43 39 policyIds: readonly string[]; ··· 291 287 ) 292 288 .exhaustive(); 293 289 294 - // Cast to this; justified by where clause on ITEM_DATA above. 295 - type ResultRow = FixSingleTableReturnedRowType< 296 - typeof finalQuery, 297 - Excluding<RuleExecutionsRow, 'ITEM_DATA', null> 298 - >; 290 + type ResultRow = { 291 + date: WarehouseDate; 292 + ts: WarehouseDate; 293 + result: JsonOf<ConditionSetWithResultAsLogged> | null; 294 + contentId: string; 295 + itemTypeName: string; 296 + itemTypeId: string; 297 + userId: string | null; 298 + userTypeId: string | null; 299 + content: JsonOf<NormalizedItemData>; 300 + environment: RuleEnvironment; 301 + policyIds: readonly string[]; 302 + }; 299 303 300 - return (await finalQuery.$narrowType<ResultRow>().execute()).map((it) => ({ 304 + return (await finalQuery.$castTo<ResultRow>().execute()).map((it) => ({ 301 305 ...it, 302 306 date: warehouseDateToDate(it.date), 303 307 ts: warehouseDateToDate(it.ts),
+3 -7
server/services/moderationConfigService/modules/ActionOperations.ts
··· 9 9 } from '../../../utils/errors.js'; 10 10 import { 11 11 type FixKyselyRowCorrelation, 12 - type FixSingleTableReturnedRowType, 12 + 13 13 } from '../../../utils/kysely.js'; 14 14 import { assertUnreachable } from '../../../utils/misc.js'; 15 15 import { type ModerationConfigServicePg } from '../dbTypes.js'; ··· 76 76 // eslint-disable-next-line no-useless-catch 77 77 try { 78 78 const actionRow = 79 - (await query.executeTakeFirstOrThrow()) as FixSingleTableReturnedRowType< 80 - typeof query 81 - >; 79 + (await query.executeTakeFirstOrThrow()) as ActionDbResult; 82 80 83 81 return this.#dbResultToAction(actionRow); 84 82 } catch (e) { ··· 102 100 .where('org_id', '=', orgId) 103 101 .$if(ids !== undefined, (qb) => qb.where('id', 'in', ids!)); 104 102 105 - const results = (await query.execute()) as FixSingleTableReturnedRowType< 106 - typeof query 107 - >[]; 103 + const results = (await query.execute()) as ActionDbResult[]; 108 104 109 105 return results.map((it) => this.#dbResultToAction(it)); 110 106 }
+3 -7
server/services/moderationConfigService/modules/PolicyOperations.ts
··· 15 15 import { 16 16 isUniqueViolationError, 17 17 type FixKyselyRowCorrelation, 18 - type FixSingleTableReturnedRowType, 18 + 19 19 } from '../../../utils/kysely.js'; 20 20 import { removeUndefinedKeys } from '../../../utils/misc.js'; 21 21 import { type ModerationConfigServicePg } from '../dbTypes.js'; ··· 61 61 .selectFrom('public.policies') 62 62 .select(policyDbSelection) 63 63 .where('org_id', '=', orgId); 64 - const results = (await query.execute()) as FixSingleTableReturnedRowType< 65 - typeof query 66 - >[]; 64 + const results = (await query.execute()) as PolicyDbResult[]; 67 65 68 66 return results.map((it) => this.#dbResultToPolicy(it)); 69 67 } ··· 81 79 .where('org_id', '=', orgId) 82 80 .where('id', '=', policyId); 83 81 const result = 84 - (await query.executeTakeFirst()) as FixSingleTableReturnedRowType< 85 - typeof query 86 - >; 82 + (await query.executeTakeFirst()) as PolicyDbResult; 87 83 88 84 return this.#dbResultToPolicy(result); 89 85 }
+3 -2
server/test/stubs/makeMockWarehouseKyselyDialect.ts
··· 84 84 85 85 createAdapter() { 86 86 return { 87 + supportsCreateIfNotExists: false, 87 88 supportsTransactionalDdl: false, 88 89 supportsReturning: false, 89 - acquireMigrationLock(_db: Kysely<unknown>) { 90 + async acquireMigrationLock(): Promise<void> { 90 91 throw new Error('Migrations with kysely not supported in test dialect.'); 91 92 }, 92 - releaseMigrationLock(_db: Kysely<unknown>) { 93 + async releaseMigrationLock(): Promise<void> { 93 94 throw new Error('Migrations with kysely not supported in test dialect.'); 94 95 }, 95 96 };