@vrplatform/kysely 1.3.45-42039308465 → 1.3.45-42164113976
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.
|
@@ -3,7 +3,7 @@ type UseTestKyselyOptions = UseLocalKyselyOptions & {
|
|
|
3
3
|
/**
|
|
4
4
|
* Force a private database even when the worker shares one. Required by specs
|
|
5
5
|
* that model several regions at once, where two handles must be two distinct
|
|
6
|
-
* physical databases.
|
|
6
|
+
* physical databases, or that run a worker over every tenant's rows.
|
|
7
7
|
*/
|
|
8
8
|
isolated?: boolean;
|
|
9
9
|
};
|
|
@@ -11,15 +11,13 @@ declare global {
|
|
|
11
11
|
var __vrplatformSharedKysely: Promise<LocalKysely> | undefined;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* tenant and
|
|
14
|
+
* Each worker process shares one database, locally and on CI: specs isolate by
|
|
15
|
+
* tenant, and booting PGlite per spec file made the suite about 65 % slower.
|
|
16
|
+
* A spec that reads rows of other tenants is a bug in that spec.
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* VR_TEST_SHARED_KYSELY overrides either way; `isolated: true` opts a single
|
|
22
|
-
* call out when a spec genuinely needs two physical databases at once.
|
|
18
|
+
* VR_TEST_SHARED_KYSELY=0 restores one database per file; `isolated: true` opts
|
|
19
|
+
* a single call out when a spec genuinely needs its own physical database, such
|
|
20
|
+
* as two regions at once or a worker that drains every tenant.
|
|
23
21
|
*/
|
|
24
22
|
export declare function resolveSharedKysely(env: Record<string, string | undefined>): boolean;
|
|
25
23
|
export declare function useTestAutoCleanupKysely(args?: UseTestKyselyOptions): Promise<LocalKysely>;
|
package/build/main/test/index.js
CHANGED
|
@@ -6,20 +6,16 @@ exports.useLocalKyselyResource = useLocalKyselyResource;
|
|
|
6
6
|
const bun_test_1 = require("bun:test");
|
|
7
7
|
const local_1 = require("../local");
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* tenant and
|
|
9
|
+
* Each worker process shares one database, locally and on CI: specs isolate by
|
|
10
|
+
* tenant, and booting PGlite per spec file made the suite about 65 % slower.
|
|
11
|
+
* A spec that reads rows of other tenants is a bug in that spec.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* VR_TEST_SHARED_KYSELY overrides either way; `isolated: true` opts a single
|
|
17
|
-
* call out when a spec genuinely needs two physical databases at once.
|
|
13
|
+
* VR_TEST_SHARED_KYSELY=0 restores one database per file; `isolated: true` opts
|
|
14
|
+
* a single call out when a spec genuinely needs its own physical database, such
|
|
15
|
+
* as two regions at once or a worker that drains every tenant.
|
|
18
16
|
*/
|
|
19
17
|
function resolveSharedKysely(env) {
|
|
20
|
-
|
|
21
|
-
return env.VR_TEST_SHARED_KYSELY !== '0';
|
|
22
|
-
return !(env.CI || env.GITHUB_ACTIONS);
|
|
18
|
+
return env.VR_TEST_SHARED_KYSELY !== '0';
|
|
23
19
|
}
|
|
24
20
|
const sharedKysely = resolveSharedKysely(process.env);
|
|
25
21
|
function acquireKysely(args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["test/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["test/index.ts"],"names":[],"mappings":";;AA6BA,kDAIC;AAcD,4DAUC;AAMD,wDA2BC;AA1FD,uCAAoC;AACpC,oCAIkB;AAelB;;;;;;;;GAQG;AACH,SAAgB,mBAAmB,CACjC,GAAuC;IAEvC,OAAO,GAAG,CAAC,qBAAqB,KAAK,GAAG,CAAC;AAC3C,CAAC;AAED,MAAM,YAAY,GAAG,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAEtD,SAAS,aAAa,CAAC,IAA2B;IAChD,IAAI,CAAC,YAAY,IAAI,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KAAK,UAAU,EAAE,CAAC;gBACjC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC7B,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CACY,CAAC;AAClB,CAAC","sourcesContent":["import { afterAll } from 'bun:test';\nimport {\n type LocalKysely,\n type UseLocalKyselyOptions,\n useLocalKysely,\n} from '../local';\n\ntype UseTestKyselyOptions = UseLocalKyselyOptions & {\n /**\n * Force a private database even when the worker shares one. Required by specs\n * that model several regions at once, where two handles must be two distinct\n * physical databases, or that run a worker over every tenant's rows.\n */\n isolated?: boolean;\n};\n\ndeclare global {\n var __vrplatformSharedKysely: Promise<LocalKysely> | undefined;\n}\n\n/**\n * Each worker process shares one database, locally and on CI: specs isolate by\n * tenant, and booting PGlite per spec file made the suite about 65 % slower.\n * A spec that reads rows of other tenants is a bug in that spec.\n *\n * VR_TEST_SHARED_KYSELY=0 restores one database per file; `isolated: true` opts\n * a single call out when a spec genuinely needs its own physical database, such\n * as two regions at once or a worker that drains every tenant.\n */\nexport function resolveSharedKysely(\n env: Record<string, string | undefined>\n): boolean {\n return env.VR_TEST_SHARED_KYSELY !== '0';\n}\n\nconst sharedKysely = resolveSharedKysely(process.env);\n\nfunction acquireKysely(args?: UseTestKyselyOptions): Promise<LocalKysely> {\n if (!sharedKysely || args?.isolated) return useLocalKysely(args);\n globalThis.__vrplatformSharedKysely ??= useLocalKysely(args);\n return globalThis.__vrplatformSharedKysely;\n}\n\nfunction ownsKysely(args?: UseTestKyselyOptions): boolean {\n return !sharedKysely || Boolean(args?.isolated);\n}\n\nexport async function useTestAutoCleanupKysely(args?: UseTestKyselyOptions) {\n const kysely = await acquireKysely(args);\n\n if (ownsKysely(args)) {\n afterAll(async () => {\n await kysely.destroy();\n });\n }\n\n return kysely;\n}\n\ntype ReturnType = LocalKysely & {\n [Symbol.dispose]: () => Promise<void>;\n};\n\nexport async function useLocalKyselyResource(\n args?: UseTestKyselyOptions\n): Promise<ReturnType> {\n const kysely = await acquireKysely(args);\n\n return new Proxy(\n {},\n {\n get(_target, prop) {\n // somehow not working if using Symbol.dispose\n if (prop === Symbol.asyncDispose) {\n return async () => {\n if (!ownsKysely(args)) return;\n await kysely.destroy();\n };\n }\n if (prop === 'kysely') {\n return kysely;\n }\n const member: unknown = Reflect.get(kysely, prop);\n if (typeof member === 'function') {\n return member.bind(kysely);\n }\n return member;\n },\n }\n ) as ReturnType;\n}\n"]}
|
|
@@ -3,7 +3,7 @@ type UseTestKyselyOptions = UseLocalKyselyOptions & {
|
|
|
3
3
|
/**
|
|
4
4
|
* Force a private database even when the worker shares one. Required by specs
|
|
5
5
|
* that model several regions at once, where two handles must be two distinct
|
|
6
|
-
* physical databases.
|
|
6
|
+
* physical databases, or that run a worker over every tenant's rows.
|
|
7
7
|
*/
|
|
8
8
|
isolated?: boolean;
|
|
9
9
|
};
|
|
@@ -11,15 +11,13 @@ declare global {
|
|
|
11
11
|
var __vrplatformSharedKysely: Promise<LocalKysely> | undefined;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* tenant and
|
|
14
|
+
* Each worker process shares one database, locally and on CI: specs isolate by
|
|
15
|
+
* tenant, and booting PGlite per spec file made the suite about 65 % slower.
|
|
16
|
+
* A spec that reads rows of other tenants is a bug in that spec.
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* VR_TEST_SHARED_KYSELY overrides either way; `isolated: true` opts a single
|
|
22
|
-
* call out when a spec genuinely needs two physical databases at once.
|
|
18
|
+
* VR_TEST_SHARED_KYSELY=0 restores one database per file; `isolated: true` opts
|
|
19
|
+
* a single call out when a spec genuinely needs its own physical database, such
|
|
20
|
+
* as two regions at once or a worker that drains every tenant.
|
|
23
21
|
*/
|
|
24
22
|
export declare function resolveSharedKysely(env: Record<string, string | undefined>): boolean;
|
|
25
23
|
export declare function useTestAutoCleanupKysely(args?: UseTestKyselyOptions): Promise<LocalKysely>;
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { afterAll } from 'bun:test';
|
|
2
2
|
import { useLocalKysely, } from '../local';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* tenant and
|
|
4
|
+
* Each worker process shares one database, locally and on CI: specs isolate by
|
|
5
|
+
* tenant, and booting PGlite per spec file made the suite about 65 % slower.
|
|
6
|
+
* A spec that reads rows of other tenants is a bug in that spec.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* VR_TEST_SHARED_KYSELY overrides either way; `isolated: true` opts a single
|
|
12
|
-
* call out when a spec genuinely needs two physical databases at once.
|
|
8
|
+
* VR_TEST_SHARED_KYSELY=0 restores one database per file; `isolated: true` opts
|
|
9
|
+
* a single call out when a spec genuinely needs its own physical database, such
|
|
10
|
+
* as two regions at once or a worker that drains every tenant.
|
|
13
11
|
*/
|
|
14
12
|
export function resolveSharedKysely(env) {
|
|
15
|
-
|
|
16
|
-
return env.VR_TEST_SHARED_KYSELY !== '0';
|
|
17
|
-
return !(env.CI || env.GITHUB_ACTIONS);
|
|
13
|
+
return env.VR_TEST_SHARED_KYSELY !== '0';
|
|
18
14
|
}
|
|
19
15
|
const sharedKysely = resolveSharedKysely(process.env);
|
|
20
16
|
function acquireKysely(args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["test/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAGL,cAAc,GACf,MAAM,UAAU,CAAC;AAelB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["test/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAGL,cAAc,GACf,MAAM,UAAU,CAAC;AAelB;;;;;;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AC;gBACzB,CAAC,CAAC;YACJ,CAAC;YACD,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtB,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,MAAM,MAAM,GAAY,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAClD,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;gBACjC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC7B,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CACY,CAAC;AAClB,CAAC","sourcesContent":["import { afterAll } from 'bun:test';\nimport {\n type LocalKysely,\n type UseLocalKyselyOptions,\n useLocalKysely,\n} from '../local';\n\ntype UseTestKyselyOptions = UseLocalKyselyOptions & {\n /**\n * Force a private database even when the worker shares one. Required by specs\n * that model several regions at once, where two handles must be two distinct\n * physical databases, or that run a worker over every tenant's rows.\n */\n isolated?: boolean;\n};\n\ndeclare global {\n var __vrplatformSharedKysely: Promise<LocalKysely> | undefined;\n}\n\n/**\n * Each worker process shares one database, locally and on CI: specs isolate by\n * tenant, and booting PGlite per spec file made the suite about 65 % slower.\n * A spec that reads rows of other tenants is a bug in that spec.\n *\n * VR_TEST_SHARED_KYSELY=0 restores one database per file; `isolated: true` opts\n * a single call out when a spec genuinely needs its own physical database, such\n * as two regions at once or a worker that drains every tenant.\n */\nexport function resolveSharedKysely(\n env: Record<string, string | undefined>\n): boolean {\n return env.VR_TEST_SHARED_KYSELY !== '0';\n}\n\nconst sharedKysely = resolveSharedKysely(process.env);\n\nfunction acquireKysely(args?: UseTestKyselyOptions): Promise<LocalKysely> {\n if (!sharedKysely || args?.isolated) return useLocalKysely(args);\n globalThis.__vrplatformSharedKysely ??= useLocalKysely(args);\n return globalThis.__vrplatformSharedKysely;\n}\n\nfunction ownsKysely(args?: UseTestKyselyOptions): boolean {\n return !sharedKysely || Boolean(args?.isolated);\n}\n\nexport async function useTestAutoCleanupKysely(args?: UseTestKyselyOptions) {\n const kysely = await acquireKysely(args);\n\n if (ownsKysely(args)) {\n afterAll(async () => {\n await kysely.destroy();\n });\n }\n\n return kysely;\n}\n\ntype ReturnType = LocalKysely & {\n [Symbol.dispose]: () => Promise<void>;\n};\n\nexport async function useLocalKyselyResource(\n args?: UseTestKyselyOptions\n): Promise<ReturnType> {\n const kysely = await acquireKysely(args);\n\n return new Proxy(\n {},\n {\n get(_target, prop) {\n // somehow not working if using Symbol.dispose\n if (prop === Symbol.asyncDispose) {\n return async () => {\n if (!ownsKysely(args)) return;\n await kysely.destroy();\n };\n }\n if (prop === 'kysely') {\n return kysely;\n }\n const member: unknown = Reflect.get(kysely, prop);\n if (typeof member === 'function') {\n return member.bind(kysely);\n }\n return member;\n },\n }\n ) as ReturnType;\n}\n"]}
|