corsair 0.1.23 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/db/index.d.ts +6 -6
- package/dist/db/index.js +12 -12
- package/dist/db/kysely/database.d.ts.map +1 -1
- package/dist/db/kysely/database.js +2 -0
- package/dist/db/kysely/sqlite-date-plugin.d.ts +6 -0
- package/dist/db/kysely/sqlite-date-plugin.d.ts.map +1 -0
- package/dist/db/kysely/sqlite-date-plugin.js +42 -0
- package/dist/db.d.ts +1 -0
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +1 -0
- package/dist/tsup.config.d.ts.map +1 -1
- package/dist/tsup.config.js +1 -0
- package/package.json +1 -1
package/dist/db/index.d.ts
CHANGED
|
@@ -5,21 +5,21 @@ export declare const CorsairIntegrationsSchema: z.ZodObject<{
|
|
|
5
5
|
updated_at: z.ZodDate;
|
|
6
6
|
name: z.ZodString;
|
|
7
7
|
config: z.ZodEffects<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>, Record<string, unknown>, Record<string, unknown> | null>;
|
|
8
|
-
dek: z.ZodOptional<z.ZodString
|
|
8
|
+
dek: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
10
|
id: string;
|
|
11
11
|
created_at: Date;
|
|
12
12
|
updated_at: Date;
|
|
13
13
|
name: string;
|
|
14
14
|
config: Record<string, unknown>;
|
|
15
|
-
dek?: string | undefined;
|
|
15
|
+
dek?: string | null | undefined;
|
|
16
16
|
}, {
|
|
17
17
|
id: string;
|
|
18
18
|
created_at: Date;
|
|
19
19
|
updated_at: Date;
|
|
20
20
|
name: string;
|
|
21
21
|
config: Record<string, unknown> | null;
|
|
22
|
-
dek?: string | undefined;
|
|
22
|
+
dek?: string | null | undefined;
|
|
23
23
|
}>;
|
|
24
24
|
export type CorsairIntegration = z.infer<typeof CorsairIntegrationsSchema>;
|
|
25
25
|
export declare const CorsairAccountsSchema: z.ZodObject<{
|
|
@@ -29,7 +29,7 @@ export declare const CorsairAccountsSchema: z.ZodObject<{
|
|
|
29
29
|
tenant_id: z.ZodString;
|
|
30
30
|
integration_id: z.ZodString;
|
|
31
31
|
config: z.ZodEffects<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>, Record<string, unknown>, Record<string, unknown> | null>;
|
|
32
|
-
dek: z.ZodOptional<z.ZodString
|
|
32
|
+
dek: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
33
|
}, "strip", z.ZodTypeAny, {
|
|
34
34
|
id: string;
|
|
35
35
|
created_at: Date;
|
|
@@ -37,7 +37,7 @@ export declare const CorsairAccountsSchema: z.ZodObject<{
|
|
|
37
37
|
config: Record<string, unknown>;
|
|
38
38
|
tenant_id: string;
|
|
39
39
|
integration_id: string;
|
|
40
|
-
dek?: string | undefined;
|
|
40
|
+
dek?: string | null | undefined;
|
|
41
41
|
}, {
|
|
42
42
|
id: string;
|
|
43
43
|
created_at: Date;
|
|
@@ -45,7 +45,7 @@ export declare const CorsairAccountsSchema: z.ZodObject<{
|
|
|
45
45
|
config: Record<string, unknown> | null;
|
|
46
46
|
tenant_id: string;
|
|
47
47
|
integration_id: string;
|
|
48
|
-
dek?: string | undefined;
|
|
48
|
+
dek?: string | null | undefined;
|
|
49
49
|
}>;
|
|
50
50
|
export type CorsairAccount = z.infer<typeof CorsairAccountsSchema>;
|
|
51
51
|
export declare const CorsairEntitiesSchema: z.ZodObject<{
|
package/dist/db/index.js
CHANGED
|
@@ -4,23 +4,23 @@ import { z } from 'zod';
|
|
|
4
4
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
5
5
|
export const CorsairIntegrationsSchema = z.object({
|
|
6
6
|
id: z.string(),
|
|
7
|
-
created_at: z.date(),
|
|
8
|
-
updated_at: z.date(),
|
|
7
|
+
created_at: z.coerce.date(),
|
|
8
|
+
updated_at: z.coerce.date(),
|
|
9
9
|
name: z.string(),
|
|
10
10
|
// Coerce DB null to empty object
|
|
11
11
|
config: z
|
|
12
12
|
.record(z.unknown())
|
|
13
13
|
.nullable()
|
|
14
14
|
.transform((v) => v ?? {}),
|
|
15
|
-
dek: z.string().
|
|
15
|
+
dek: z.string().nullish(),
|
|
16
16
|
});
|
|
17
17
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
18
18
|
// Corsair Accounts
|
|
19
19
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
20
20
|
export const CorsairAccountsSchema = z.object({
|
|
21
21
|
id: z.string(),
|
|
22
|
-
created_at: z.date(),
|
|
23
|
-
updated_at: z.date(),
|
|
22
|
+
created_at: z.coerce.date(),
|
|
23
|
+
updated_at: z.coerce.date(),
|
|
24
24
|
tenant_id: z.string(),
|
|
25
25
|
// references integrations.id
|
|
26
26
|
integration_id: z.string(),
|
|
@@ -29,15 +29,15 @@ export const CorsairAccountsSchema = z.object({
|
|
|
29
29
|
.record(z.unknown())
|
|
30
30
|
.nullable()
|
|
31
31
|
.transform((v) => v ?? {}),
|
|
32
|
-
dek: z.string().
|
|
32
|
+
dek: z.string().nullish(),
|
|
33
33
|
});
|
|
34
34
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
35
35
|
// Corsair Entities
|
|
36
36
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
37
37
|
export const CorsairEntitiesSchema = z.object({
|
|
38
38
|
id: z.string(),
|
|
39
|
-
created_at: z.date(),
|
|
40
|
-
updated_at: z.date(),
|
|
39
|
+
created_at: z.coerce.date(),
|
|
40
|
+
updated_at: z.coerce.date(),
|
|
41
41
|
// references accounts.id (which provides tenant scoping)
|
|
42
42
|
account_id: z.string(),
|
|
43
43
|
entity_id: z.string(),
|
|
@@ -54,8 +54,8 @@ export const CorsairEntitiesSchema = z.object({
|
|
|
54
54
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
55
55
|
export const CorsairEventsSchema = z.object({
|
|
56
56
|
id: z.string(),
|
|
57
|
-
created_at: z.date(),
|
|
58
|
-
updated_at: z.date(),
|
|
57
|
+
created_at: z.coerce.date(),
|
|
58
|
+
updated_at: z.coerce.date(),
|
|
59
59
|
// references accounts.id (which provides tenant scoping)
|
|
60
60
|
account_id: z.string(),
|
|
61
61
|
event_type: z.string(),
|
|
@@ -71,8 +71,8 @@ export const CorsairEventsSchema = z.object({
|
|
|
71
71
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
72
72
|
export const CorsairPermissionsSchema = z.object({
|
|
73
73
|
id: z.string(),
|
|
74
|
-
created_at: z.date(),
|
|
75
|
-
updated_at: z.date(),
|
|
74
|
+
created_at: z.coerce.date(),
|
|
75
|
+
updated_at: z.coerce.date(),
|
|
76
76
|
/** 32-byte hex-encoded secure random token, single-use. Embedded in the review URL. */
|
|
77
77
|
token: z.string(),
|
|
78
78
|
/** Plugin identifier, e.g. 'github' */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../db/kysely/database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,MAAM,EAAkC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../db/kysely/database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,MAAM,EAAkC,MAAM,QAAQ,CAAC;AAEhE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EACX,cAAc,EACd,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,qBAAqB,GAAG;IACnC,oBAAoB,EAAE,kBAAkB,CAAC;IACzC,gBAAgB,EAAE,cAAc,CAAC;IACjC,gBAAgB,EAAE,aAAa,CAAC;IAChC,cAAc,EAAE,YAAY,CAAC;IAC7B,mBAAmB,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAC9C,mBAAmB,CAAC,UAAU,CAAC,CAC/B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC7B,IAAI,GACJ,qBAAqB,GACrB,MAAM,CAAC,qBAAqB,CAAC,CAAC;AA6BjC,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,oBAAoB,GACzB,eAAe,CAuBjB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Kysely, PostgresDialect, SqliteDialect } from 'kysely';
|
|
2
|
+
import { SqliteDatePlugin } from './sqlite-date-plugin.js';
|
|
2
3
|
function isPgPool(input) {
|
|
3
4
|
return (typeof input.query === 'function' &&
|
|
4
5
|
typeof input.connect === 'function');
|
|
@@ -20,6 +21,7 @@ export function createCorsairDatabase(input) {
|
|
|
20
21
|
if (isBetterSqlite3(input)) {
|
|
21
22
|
const db = new Kysely({
|
|
22
23
|
dialect: new SqliteDialect({ database: input }),
|
|
24
|
+
plugins: [new SqliteDatePlugin()],
|
|
23
25
|
});
|
|
24
26
|
return { db };
|
|
25
27
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type KyselyPlugin, type PluginTransformQueryArgs, type PluginTransformResultArgs, type QueryResult, type RootOperationNode, type UnknownRow } from 'kysely';
|
|
2
|
+
export declare class SqliteDatePlugin implements KyselyPlugin {
|
|
3
|
+
transformQuery(args: PluginTransformQueryArgs): RootOperationNode;
|
|
4
|
+
transformResult(args: PluginTransformResultArgs): Promise<QueryResult<UnknownRow>>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=sqlite-date-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-date-plugin.d.ts","sourceRoot":"","sources":["../../../db/kysely/sqlite-date-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAE9B,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAEf,MAAM,QAAQ,CAAC;AAwChB,qBAAa,gBAAiB,YAAW,YAAY;IACpD,cAAc,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB;IAI3D,eAAe,CACpB,IAAI,EAAE,yBAAyB,GAC7B,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;CAGnC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { OperationNodeTransformer, } from 'kysely';
|
|
2
|
+
function serializeValue(v) {
|
|
3
|
+
if (v instanceof Date)
|
|
4
|
+
return v.toISOString();
|
|
5
|
+
if (v !== null && typeof v === 'object' && !Buffer.isBuffer(v))
|
|
6
|
+
return JSON.stringify(v);
|
|
7
|
+
return v;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Kysely plugin for SQLite (better-sqlite3) that serializes JavaScript values
|
|
11
|
+
* that the driver cannot bind natively:
|
|
12
|
+
*
|
|
13
|
+
* - Date → ISO 8601 string (better-sqlite3 rejects Date objects)
|
|
14
|
+
* - plain object / array → JSON string (stored as TEXT, read back via parseJsonLike)
|
|
15
|
+
*
|
|
16
|
+
* Handles both ValueNode (WHERE clauses, complex expressions) and
|
|
17
|
+
* PrimitiveValueListNode (INSERT/UPDATE with all-primitive rows — Kysely's
|
|
18
|
+
* performance fast-path that bypasses ValueNode entirely).
|
|
19
|
+
*
|
|
20
|
+
* Applied only to the SQLite Kysely instance in createCorsairDatabase, so it
|
|
21
|
+
* has no effect on Postgres connections.
|
|
22
|
+
*/
|
|
23
|
+
class SqliteSerializingTransformer extends OperationNodeTransformer {
|
|
24
|
+
transformValue(node) {
|
|
25
|
+
const serialized = serializeValue(node.value);
|
|
26
|
+
return serialized === node.value ? node : { ...node, value: serialized };
|
|
27
|
+
}
|
|
28
|
+
transformPrimitiveValueList(node) {
|
|
29
|
+
const serialized = node.values.map(serializeValue);
|
|
30
|
+
const changed = serialized.some((v, i) => v !== node.values[i]);
|
|
31
|
+
return changed ? { ...node, values: serialized } : node;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const transformer = new SqliteSerializingTransformer();
|
|
35
|
+
export class SqliteDatePlugin {
|
|
36
|
+
transformQuery(args) {
|
|
37
|
+
return transformer.transformNode(args.node);
|
|
38
|
+
}
|
|
39
|
+
async transformResult(args) {
|
|
40
|
+
return args.result;
|
|
41
|
+
}
|
|
42
|
+
}
|
package/dist/db.d.ts
CHANGED
|
@@ -14,5 +14,6 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export { sql } from 'kysely';
|
|
16
16
|
export * from './db/index';
|
|
17
|
+
export { createCorsairDatabase } from './db/kysely/database';
|
|
17
18
|
export type { CorsairDatabase, CorsairDatabaseInput, CorsairKyselyDatabase, } from './db/kysely/database';
|
|
18
19
|
//# sourceMappingURL=db.d.ts.map
|
package/dist/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../db.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,YAAY,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACrB,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../db.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,YAAY,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACrB,MAAM,sBAAsB,CAAC"}
|
package/dist/db.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsup.config.d.ts","sourceRoot":"","sources":["../tsup.config.ts"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"tsup.config.d.ts","sourceRoot":"","sources":["../tsup.config.ts"],"names":[],"mappings":";AAEA,wBA8BG"}
|
package/dist/tsup.config.js
CHANGED