cabloy 5.1.220 → 5.1.221

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.
Files changed (49) hide show
  1. package/.cabloy-version +1 -1
  2. package/.github/workflows/agent-governance.yml +2 -2
  3. package/.github/workflows/create-cabloy.yml +2 -2
  4. package/.github/workflows/docs-pages.yml +2 -2
  5. package/.github/workflows/playwright-e2e.yml +4 -4
  6. package/.github/workflows/vona-cov-pg.yml +2 -2
  7. package/.github/workflows/vona-test-crud.yml +2 -2
  8. package/.github/workflows/vona-test-mysql.yml +2 -2
  9. package/.github/workflows/vona-test-pg.yml +2 -2
  10. package/.github/workflows/vona-test-sqlite3.yml +2 -2
  11. package/.github/workflows/vona-tsc.yml +2 -2
  12. package/.github/workflows/zova-ui.yml +2 -2
  13. package/CHANGELOG.md +11 -0
  14. package/package.json +4 -3
  15. package/repo-docs/frontend/openapi-sdk-guide.md +2 -0
  16. package/repo-docs/reference/repo-scripts.md +5 -1
  17. package/scripts/generateOpenapiIsolated.ts +18 -1
  18. package/scripts/runIsolatedTest.test.ts +9 -1
  19. package/scripts/runIsolatedTest.ts +81 -18
  20. package/scripts/strictGenerationDiagnostics.test.ts +1009 -0
  21. package/scripts/strictGenerationDiagnostics.ts +61 -0
  22. package/vona/package.original.json +3 -2
  23. package/vona/packages-cli/cli/package.json +1 -1
  24. package/vona/packages-cli/cli-set-api/package.json +1 -1
  25. package/vona/packages-cli/cli-set-api/src/lib/bean/cli.bin.dev.ts +14 -4
  26. package/vona/packages-cli/cli-set-api/src/lib/bean/toolsBin/generateEntryFiles.ts +6 -1
  27. package/vona/packages-cli/cli-set-api/src/lib/bean/toolsBin/generateVonaMeta.ts +2 -10
  28. package/vona/packages-cli/cli-set-api/src/lib/bean/toolsBin/validateGenerationPaths.ts +27 -0
  29. package/vona/packages-cli/cli-set-api/test/binDevLifecycle.test.ts +1 -1
  30. package/vona/packages-cli/cli-set-api/test/strictGenerationPrivacy.test.ts +439 -0
  31. package/vona/packages-vona/vona/package.json +1 -1
  32. package/vona/packages-vona/vona-core/package.json +1 -1
  33. package/vona/packages-vona/vona-core/src/lib/core/logger/appLogger.ts +10 -2
  34. package/vona/packages-vona/vona-core/src/lib/core/logger/diagnosticLogger.test.ts +268 -68
  35. package/vona/packages-vona/vona-core/src/lib/core/testFreshness.ts +3 -9
  36. package/vona/packages-vona/vona-core/src/lib/core/testStrictMode.ts +9 -0
  37. package/vona/packages-vona/vona-mock/package.json +1 -1
  38. package/vona/pnpm-lock.yaml +542 -236
  39. package/vona/src/suite-vendor/a-vona/modules/a-core/package.json +1 -1
  40. package/vona/src/suite-vendor/a-vona/modules/a-ormdialect/package.json +1 -1
  41. package/vona/src/suite-vendor/a-vona/modules/a-ormdialect/src/index.ts +11 -0
  42. package/vona/src/suite-vendor/a-vona/modules/a-ormdialect/src/lib/protectedSqliteRegistry.ts +356 -0
  43. package/vona/src/suite-vendor/a-vona/package.json +1 -1
  44. package/zova/package.original.json +3 -2
  45. package/zova/packages-cli/cli/package.json +2 -2
  46. package/zova/packages-cli/cli-set-front/package.json +1 -1
  47. package/zova/packages-cli/cli-set-front/src/lib/common/restDependencyVersions.ts +22 -1
  48. package/zova/packages-cli/cli-set-front/test/restDependencies.test.ts +137 -0
  49. package/zova/pnpm-lock.yaml +442 -564
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vona-module-a-core",
3
- "version": "5.1.62",
3
+ "version": "5.1.63",
4
4
  "gitHead": "a79189b882c17af5911573896a781bbb0046d37d",
5
5
  "description": "",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vona-module-a-ormdialect",
3
- "version": "5.1.20",
3
+ "version": "5.1.21",
4
4
  "gitHead": "a79189b882c17af5911573896a781bbb0046d37d",
5
5
  "description": "",
6
6
  "keywords": [
@@ -1 +1,12 @@
1
1
  export * from './.metadata/index.ts';
2
+ export { createProtectedSqliteRegistry } from './lib/protectedSqliteRegistry.ts';
3
+ export type {
4
+ ProtectedSqliteRegistry,
5
+ ProtectedSqliteRegistryCloseResult,
6
+ ProtectedSqliteRegistryLookupOutcome,
7
+ ProtectedSqliteRegistryLookupResult,
8
+ ProtectedSqliteRegistryOptions,
9
+ ProtectedSqliteRegistryPrepareResult,
10
+ ProtectedSqliteRegistryRow,
11
+ ProtectedSqliteRegistrySnapshot,
12
+ } from './lib/protectedSqliteRegistry.ts';
@@ -0,0 +1,356 @@
1
+ import { createRequire } from 'node:module';
2
+ import path from 'node:path';
3
+ import { getRequestBoundary } from 'vona';
4
+
5
+ const MAX_NAME_BYTES = 256;
6
+ const MAX_CONFIG_BYTES = 65_536;
7
+ const LOOKUP_BUDGET_MS = 1_000;
8
+ const PRIVATE_TIMEOUT_MS = 100;
9
+
10
+ export const PROTECTED_SQLITE_REGISTRY_SQL = `SELECT
11
+ CASE WHEN typeof(id) = 'integer' AND id > 0 AND id <= 9007199254740991 THEN id ELSE NULL END AS id,
12
+ CASE WHEN typeof(name) = 'text' AND length(CAST(name AS BLOB)) <= 256 THEN name ELSE NULL END AS name,
13
+ CASE WHEN typeof(disabled) = 'integer' AND disabled IN (0, 1) THEN disabled ELSE NULL END AS disabled,
14
+ CASE WHEN typeof(isolate) = 'integer' AND isolate IN (0, 1) THEN isolate ELSE NULL END AS isolate,
15
+ CASE
16
+ WHEN config IS NULL THEN NULL
17
+ WHEN typeof(config) = 'text' AND length(CAST(config AS BLOB)) <= 65536 THEN config
18
+ ELSE NULL
19
+ END AS config,
20
+ CASE
21
+ WHEN typeof(id) = 'integer' AND id > 0 AND id <= 9007199254740991
22
+ AND typeof(name) = 'text' AND length(CAST(name AS BLOB)) <= 256
23
+ AND typeof(disabled) = 'integer' AND disabled IN (0, 1)
24
+ AND typeof(isolate) = 'integer' AND isolate IN (0, 1)
25
+ AND (config IS NULL OR (typeof(config) = 'text' AND length(CAST(config AS BLOB)) <= 65536))
26
+ THEN 1
27
+ ELSE 0
28
+ END AS __protected_valid
29
+ FROM aInstance
30
+ WHERE name COLLATE BINARY = ?
31
+ AND deleted = 0
32
+ LIMIT 2`;
33
+
34
+ type ProtectedSqliteState = 'new' | 'ready' | 'faulted' | 'closed';
35
+
36
+ type ProtectedSqlitePrepareOutcome =
37
+ | 'ready'
38
+ | 'already_prepared'
39
+ | 'boundary_required'
40
+ | 'unsupported'
41
+ | 'unavailable';
42
+
43
+ export interface ProtectedSqliteRegistryOptions {
44
+ readonly filename: string;
45
+ }
46
+
47
+ export interface ProtectedSqliteRegistryRow {
48
+ readonly id: number;
49
+ readonly name: string;
50
+ readonly disabled: boolean;
51
+ readonly isolate: boolean;
52
+ readonly config: string | null;
53
+ }
54
+
55
+ export interface ProtectedSqliteRegistryPrepareResult {
56
+ readonly outcome: ProtectedSqlitePrepareOutcome;
57
+ }
58
+
59
+ export type ProtectedSqliteRegistryLookupOutcome =
60
+ | 'found'
61
+ | 'missing'
62
+ | 'duplicate'
63
+ | 'disabled'
64
+ | 'invalid_input'
65
+ | 'expired'
66
+ | 'boundary_required'
67
+ | 'reentrant'
68
+ | 'unavailable';
69
+
70
+ export type ProtectedSqliteRegistryLookupResult =
71
+ | Readonly<{
72
+ readonly outcome: 'found';
73
+ readonly row: ProtectedSqliteRegistryRow;
74
+ }>
75
+ | Readonly<{ readonly outcome: Exclude<ProtectedSqliteRegistryLookupOutcome, 'found'> }>;
76
+
77
+ export interface ProtectedSqliteRegistryCloseResult {
78
+ readonly outcome: 'closed' | 'close_failed';
79
+ }
80
+
81
+ export interface ProtectedSqliteRegistrySnapshot {
82
+ readonly state: ProtectedSqliteState;
83
+ readonly active: boolean;
84
+ readonly closing: boolean;
85
+ }
86
+
87
+ export interface ProtectedSqliteRegistry {
88
+ readonly prepare: () => ProtectedSqliteRegistryPrepareResult;
89
+ readonly lookup: (name: string, deadlineAt?: number) => ProtectedSqliteRegistryLookupResult;
90
+ readonly close: () => Promise<ProtectedSqliteRegistryCloseResult>;
91
+ readonly snapshot: () => ProtectedSqliteRegistrySnapshot;
92
+ }
93
+
94
+ interface ProtectedSqliteStatement {
95
+ all(name: string): readonly unknown[];
96
+ }
97
+
98
+ interface ProtectedSqliteDatabase {
99
+ pragma(sql: string, options?: Readonly<{ readonly simple: true }>): unknown;
100
+ prepare(sql: string): ProtectedSqliteStatement;
101
+ close(): void;
102
+ }
103
+
104
+ interface ProtectedSqliteOpenOptions {
105
+ readonly readonly: true;
106
+ readonly fileMustExist: true;
107
+ readonly timeout: 100;
108
+ }
109
+
110
+ type ProtectedSqliteOpen = (
111
+ filename: string,
112
+ options: ProtectedSqliteOpenOptions,
113
+ ) => ProtectedSqliteDatabase;
114
+
115
+ interface ProtectedSqliteDependencies {
116
+ readonly open: ProtectedSqliteOpen;
117
+ readonly now: () => number;
118
+ readonly hasRequestBoundary: () => boolean;
119
+ }
120
+
121
+ const productionDependencies: ProtectedSqliteDependencies = Object.freeze({
122
+ open: openNativeSqlite,
123
+ now: () => performance.now(),
124
+ hasRequestBoundary: () => getRequestBoundary() !== undefined,
125
+ });
126
+
127
+ export function createProtectedSqliteRegistry(
128
+ options: ProtectedSqliteRegistryOptions,
129
+ ): ProtectedSqliteRegistry {
130
+ return createProtectedSqliteRegistryInternal(options, productionDependencies);
131
+ }
132
+
133
+ // This seam is intentionally not exported by the package barrel. It makes lifecycle and
134
+ // diagnostic-containment tests deterministic without accepting an alternate production driver.
135
+ export function createProtectedSqliteRegistryForTest(
136
+ options: unknown,
137
+ dependencies: Readonly<
138
+ Partial<ProtectedSqliteDependencies> & { readonly open: ProtectedSqliteOpen }
139
+ >,
140
+ ): ProtectedSqliteRegistry {
141
+ return createProtectedSqliteRegistryInternal(options, {
142
+ open: dependencies.open,
143
+ now: dependencies.now ?? (() => performance.now()),
144
+ hasRequestBoundary:
145
+ dependencies.hasRequestBoundary ?? (() => getRequestBoundary() !== undefined),
146
+ });
147
+ }
148
+
149
+ export function createProtectedSqliteRegistryInternal(
150
+ options: unknown,
151
+ dependencies: ProtectedSqliteDependencies,
152
+ ): ProtectedSqliteRegistry {
153
+ const filename = readSupportedFilename(options);
154
+ let state: ProtectedSqliteState = 'new';
155
+ let attempted = false;
156
+ let active = false;
157
+ let closing = false;
158
+ let database: ProtectedSqliteDatabase | undefined;
159
+ let statement: ProtectedSqliteStatement | undefined;
160
+ let closePromise: Promise<ProtectedSqliteRegistryCloseResult> | undefined;
161
+ let closeResolve: ((result: ProtectedSqliteRegistryCloseResult) => void) | undefined;
162
+
163
+ const unavailable = (outcome: Exclude<ProtectedSqliteRegistryLookupOutcome, 'found'>) =>
164
+ Object.freeze({ outcome }) as ProtectedSqliteRegistryLookupResult;
165
+
166
+ const finalizeClose = (): ProtectedSqliteRegistryCloseResult => {
167
+ if (!database) {
168
+ state = 'closed';
169
+ return Object.freeze({ outcome: 'closed' });
170
+ }
171
+ try {
172
+ database.close();
173
+ } catch {
174
+ state = 'faulted';
175
+ return Object.freeze({ outcome: 'close_failed' });
176
+ }
177
+ database = undefined;
178
+ statement = undefined;
179
+ state = 'closed';
180
+ return Object.freeze({ outcome: 'closed' });
181
+ };
182
+
183
+ const settleDeferredClose = () => {
184
+ if (!closeResolve) return;
185
+ const resolve = closeResolve;
186
+ closeResolve = undefined;
187
+ resolve(finalizeClose());
188
+ };
189
+
190
+ const prepare = (): ProtectedSqliteRegistryPrepareResult => {
191
+ if (dependencies.hasRequestBoundary()) return Object.freeze({ outcome: 'boundary_required' });
192
+ if (closing || state === 'closed') return Object.freeze({ outcome: 'unavailable' });
193
+ if (attempted) return Object.freeze({ outcome: 'already_prepared' });
194
+ attempted = true;
195
+ if (!filename) {
196
+ state = 'faulted';
197
+ return Object.freeze({ outcome: 'unsupported' });
198
+ }
199
+ try {
200
+ database = dependencies.open(filename, {
201
+ readonly: true,
202
+ fileMustExist: true,
203
+ timeout: PRIVATE_TIMEOUT_MS,
204
+ });
205
+ const journalMode = database.pragma('journal_mode', { simple: true });
206
+ const busyTimeout = database.pragma('busy_timeout', { simple: true });
207
+ if (journalMode !== 'wal' || busyTimeout !== PRIVATE_TIMEOUT_MS) throw new Error();
208
+ statement = database.prepare(PROTECTED_SQLITE_REGISTRY_SQL);
209
+ const probe = statement.all('');
210
+ if (
211
+ !Array.isArray(probe) ||
212
+ probe.length > 2 ||
213
+ probe.some(row => !isValidProjectionRow(row))
214
+ ) {
215
+ throw new Error();
216
+ }
217
+ state = 'ready';
218
+ return Object.freeze({ outcome: 'ready' });
219
+ } catch {
220
+ state = 'faulted';
221
+ return Object.freeze({ outcome: 'unavailable' });
222
+ }
223
+ };
224
+
225
+ const lookup = (name: string, deadlineAt = dependencies.now() + LOOKUP_BUDGET_MS) => {
226
+ if (!dependencies.hasRequestBoundary()) return unavailable('boundary_required');
227
+ if (state !== 'ready' || closing || !database || !statement) return unavailable('unavailable');
228
+ if (!isBoundedText(name, MAX_NAME_BYTES)) {
229
+ return unavailable('invalid_input');
230
+ }
231
+ if (!Number.isFinite(deadlineAt) || dependencies.now() >= deadlineAt) {
232
+ return unavailable('expired');
233
+ }
234
+ if (active) return unavailable('reentrant');
235
+ active = true;
236
+ try {
237
+ const rows = statement.all(name);
238
+ if (closing || dependencies.now() >= deadlineAt) return unavailable('expired');
239
+ if (!Array.isArray(rows)) {
240
+ state = 'faulted';
241
+ return unavailable('unavailable');
242
+ }
243
+ if (rows.length > 2) {
244
+ state = 'faulted';
245
+ return unavailable('unavailable');
246
+ }
247
+ if (rows.length === 0) return unavailable('missing');
248
+ if (rows.length === 2) return unavailable('duplicate');
249
+ const row = rows[0];
250
+ if (!isValidProjectionRow(row)) {
251
+ state = 'faulted';
252
+ return unavailable('unavailable');
253
+ }
254
+ const projected = row as Record<string, unknown>;
255
+ if (projected.disabled === 1) return unavailable('disabled');
256
+ const result = Object.freeze({
257
+ outcome: 'found' as const,
258
+ row: Object.freeze({
259
+ id: projected.id as number,
260
+ name: projected.name as string,
261
+ disabled: projected.disabled === 1,
262
+ isolate: projected.isolate === 1,
263
+ config: projected.config as string | null,
264
+ }),
265
+ });
266
+ return result;
267
+ } catch {
268
+ state = 'faulted';
269
+ return unavailable('unavailable');
270
+ } finally {
271
+ active = false;
272
+ if (closing) settleDeferredClose();
273
+ }
274
+ };
275
+
276
+ const close = () => {
277
+ if (closePromise) return closePromise;
278
+ closing = true;
279
+ if (active) {
280
+ closePromise = new Promise<ProtectedSqliteRegistryCloseResult>(resolve => {
281
+ closeResolve = resolve;
282
+ });
283
+ } else {
284
+ closePromise = Promise.resolve(finalizeClose());
285
+ }
286
+ return closePromise;
287
+ };
288
+
289
+ return Object.freeze({
290
+ prepare,
291
+ lookup,
292
+ close,
293
+ snapshot: () => Object.freeze({ state, active, closing }),
294
+ });
295
+ }
296
+
297
+ function readSupportedFilename(options: unknown): string | undefined {
298
+ try {
299
+ if (!options || typeof options !== 'object' || Array.isArray(options)) return undefined;
300
+ const prototype = Object.getPrototypeOf(options);
301
+ if (prototype !== Object.prototype && prototype !== null) return undefined;
302
+ const keys = Reflect.ownKeys(options);
303
+ if (keys.length !== 1 || keys[0] !== 'filename') return undefined;
304
+ const descriptor = Object.getOwnPropertyDescriptor(options, 'filename');
305
+ if (!descriptor || !Object.hasOwn(descriptor, 'value')) return undefined;
306
+ const filename: unknown = descriptor.value;
307
+ if (
308
+ typeof filename !== 'string' ||
309
+ !filename.isWellFormed() ||
310
+ !path.isAbsolute(filename) ||
311
+ filename.includes('\0')
312
+ ) {
313
+ return undefined;
314
+ }
315
+ return filename;
316
+ } catch {
317
+ return undefined;
318
+ }
319
+ }
320
+
321
+ function isBoundedText(value: unknown, maxBytes: number): value is string {
322
+ return (
323
+ typeof value === 'string' &&
324
+ value.isWellFormed() &&
325
+ Buffer.byteLength(value, 'utf8') <= maxBytes
326
+ );
327
+ }
328
+
329
+ function isValidProjectionRow(row: unknown): boolean {
330
+ if (!row || typeof row !== 'object') return false;
331
+ const projected = row as Record<string, unknown>;
332
+ if (projected.__protected_valid !== 1) return false;
333
+ if (
334
+ typeof projected.id !== 'number' ||
335
+ !Number.isSafeInteger(projected.id) ||
336
+ projected.id <= 0
337
+ ) {
338
+ return false;
339
+ }
340
+ if (!isBoundedText(projected.name, MAX_NAME_BYTES)) return false;
341
+ if (projected.disabled !== 0 && projected.disabled !== 1) return false;
342
+ if (projected.isolate !== 0 && projected.isolate !== 1) return false;
343
+ return projected.config === null || isBoundedText(projected.config, MAX_CONFIG_BYTES);
344
+ }
345
+
346
+ function openNativeSqlite(
347
+ filename: string,
348
+ options: ProtectedSqliteOpenOptions,
349
+ ): ProtectedSqliteDatabase {
350
+ const require = createRequire(import.meta.url);
351
+ const BetterSqlite3 = require('better-sqlite3') as new (
352
+ filename: string,
353
+ options: ProtectedSqliteOpenOptions,
354
+ ) => ProtectedSqliteDatabase;
355
+ return new BetterSqlite3(filename, options);
356
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vona-suite-a-vona",
3
- "version": "5.1.102",
3
+ "version": "5.1.103",
4
4
  "gitHead": "a79189b882c17af5911573896a781bbb0046d37d",
5
5
  "description": "",
6
6
  "author": "",
@@ -14,7 +14,7 @@
14
14
  "url": "git+https://github.com/zovajs/zova.git"
15
15
  },
16
16
  "type": "module",
17
- "packageManager": "pnpm@11.5.2",
17
+ "packageManager": "pnpm@12.14.0",
18
18
  "scripts": {
19
19
  "zova": "node ./packages-cli/cli/src/bin/zova.ts",
20
20
  "dev": "npm run dev:ssr:admin",
@@ -96,6 +96,7 @@
96
96
  "oxlint": "^1.77.0"
97
97
  },
98
98
  "engines": {
99
- "node": ">=22.12.0"
99
+ "node": ">=24.4.0",
100
+ "pnpm": ">=11.5.2"
100
101
  }
101
102
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-cli",
3
- "version": "1.2.116",
3
+ "version": "1.2.117",
4
4
  "gitHead": "6f675a8cc46d596142c591c28a40cc4d82fcc6cc",
5
5
  "description": "zova cli",
6
6
  "keywords": [
@@ -44,7 +44,7 @@
44
44
  "@cabloy/process-helper": "^3.1.8",
45
45
  "fs-extra": "^11.3.5",
46
46
  "semver": "^7.6.2",
47
- "zova-cli-set-front": "^1.2.114"
47
+ "zova-cli-set-front": "^1.2.115"
48
48
  },
49
49
  "devDependencies": {
50
50
  "clean-package": "^2.2.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-cli-set-front",
3
- "version": "1.2.114",
3
+ "version": "1.2.115",
4
4
  "gitHead": "6f675a8cc46d596142c591c28a40cc4d82fcc6cc",
5
5
  "description": "zova cli-set-front",
6
6
  "keywords": [
@@ -29,7 +29,7 @@ export async function extractRestDependencyVersions(
29
29
  ): Promise<Record<string, string>> {
30
30
  const lockfilePath = path.join(projectPath, 'pnpm-lock.yaml');
31
31
  const lockfileContent = await fse.readFile(lockfilePath, 'utf8');
32
- const parsedLockfile = yaml.parse(lockfileContent) as ParsedLockfile;
32
+ const parsedLockfile = parseWorkspaceLockfile(lockfileContent);
33
33
  const depsVersion: Record<string, string> = {};
34
34
 
35
35
  for (const dep of deps) {
@@ -66,6 +66,27 @@ export async function extractRestDependencyVersions(
66
66
  return depsVersion;
67
67
  }
68
68
 
69
+ function parseWorkspaceLockfile(content: string): ParsedLockfile {
70
+ const documents = yaml.parseAllDocuments(content);
71
+ for (const document of documents) {
72
+ if (document.errors.length) throw document.errors[0];
73
+ }
74
+
75
+ // pnpm 12 places the workspace lock after its package-manager/config dependency lock.
76
+ const document = documents.findLast(({ contents }) => {
77
+ return (
78
+ contents !== null &&
79
+ !(yaml.isScalar(contents) && contents.value === null && contents.source === '')
80
+ );
81
+ });
82
+ if (!document || !yaml.isMap(document.contents) || !yaml.isMap(document.get('importers', true))) {
83
+ throw new Error(
84
+ 'Invalid pnpm-lock.yaml: expected a workspace document with an importers mapping.',
85
+ );
86
+ }
87
+ return document.toJS() as ParsedLockfile;
88
+ }
89
+
69
90
  function getPackageDependencyRangeFromLock(
70
91
  parsedLockfile: ParsedLockfile,
71
92
  packageName: string,
@@ -238,6 +238,143 @@ import Alias = Existing.Value;
238
238
  });
239
239
 
240
240
  describe('extractRestDependencyVersions', () => {
241
+ const managementLockfile = `---
242
+ lockfileVersion: '9.0'
243
+ importers:
244
+ .:
245
+ configDependencies: {}
246
+ packageManagerDependencies:
247
+ pnpm:
248
+ specifier: 12.14.0
249
+ version: 12.14.0
250
+ dependencies:
251
+ root-package:
252
+ version: 99.0.0
253
+ management-only:
254
+ version: 99.0.0
255
+ `;
256
+ const workspaceLockfile = `lockfileVersion: '9.0'
257
+ importers:
258
+ .:
259
+ dependencies:
260
+ root-package:
261
+ version: 1.2.3
262
+ alias-package:
263
+ specifier: npm:@scope/package@^2.0.0
264
+ version: '@scope/package@2.0.4'
265
+ src/module/example:
266
+ dependencies:
267
+ owned-package:
268
+ version: 3.1.7(vue@3.5.42)
269
+ `;
270
+
271
+ for (const trailingDocument of ['', '---\n# empty document\n']) {
272
+ it(`uses the workspace document of a pnpm 12 lockfile${trailingDocument ? ' with a trailing empty document' : ''}`, async () => {
273
+ await withFixture(async projectPath => {
274
+ await writeLockfile(
275
+ projectPath,
276
+ `${managementLockfile}---\n${workspaceLockfile}${trailingDocument}`,
277
+ );
278
+ assert.deepEqual(
279
+ await extractRestDependencyVersions(
280
+ projectPath,
281
+ ['root-package', 'alias-package', 'owned-package'],
282
+ ['src/module/example'],
283
+ ),
284
+ {
285
+ 'root-package': '^1.2.3',
286
+ 'alias-package': 'npm:@scope/package@^2.0.0',
287
+ 'owned-package': '^3.1.7',
288
+ },
289
+ );
290
+ for (const dependency of ['management-only', 'pnpm']) {
291
+ await assert.rejects(
292
+ extractRestDependencyVersions(projectPath, [dependency]),
293
+ /Unable to resolve REST dependency version/,
294
+ );
295
+ }
296
+ });
297
+ });
298
+ }
299
+
300
+ it('accepts a single workspace document with an explicit start marker', async () => {
301
+ await withFixture(async projectPath => {
302
+ await writeLockfile(projectPath, `---\n${workspaceLockfile}`);
303
+ assert.deepEqual(await extractRestDependencyVersions(projectPath, ['root-package']), {
304
+ 'root-package': '^1.2.3',
305
+ });
306
+ });
307
+ });
308
+
309
+ for (const [label, invalidDocument, code] of [
310
+ ['malformed YAML', 'importers: [\n', 'BAD_INDENT'],
311
+ ['duplicate keys', 'importers: {}\nimporters: {}\n', 'DUPLICATE_KEY'],
312
+ ]) {
313
+ for (const position of ['management', 'workspace']) {
314
+ it(`rejects ${label} in the ${position} document before installed-package fallback`, async () => {
315
+ await withFixture(async projectPath => {
316
+ const content =
317
+ position === 'management'
318
+ ? `${invalidDocument}---\n${workspaceLockfile}`
319
+ : `${managementLockfile}---\n${invalidDocument}`;
320
+ await writeLockfile(projectPath, content);
321
+ await writePackage(projectPath, 'node_modules/root-package', { version: '5.0.0' });
322
+ await assert.rejects(extractRestDependencyVersions(projectPath, ['root-package']), {
323
+ name: 'YAMLParseError',
324
+ code,
325
+ });
326
+ });
327
+ });
328
+ }
329
+ }
330
+
331
+ for (const [label, invalidDocument] of [
332
+ ['empty', ''],
333
+ ['comment-only', '# no lockfile\n'],
334
+ ['empty marked', '---\n# no lockfile\n'],
335
+ ['null', 'null\n'],
336
+ ['tilde null', '~\n'],
337
+ ['empty string', '""\n'],
338
+ ['scalar', 'invalid\n'],
339
+ ['sequence', '- invalid\n'],
340
+ ['missing importers', "lockfileVersion: '9.0'\n"],
341
+ ['null importers', 'importers: null\n'],
342
+ ['scalar importers', 'importers: invalid\n'],
343
+ ['sequence importers', 'importers: []\n'],
344
+ ]) {
345
+ it(`rejects a ${label} workspace document`, async () => {
346
+ await withFixture(async projectPath => {
347
+ await writePackage(projectPath, 'node_modules/root-package', { version: '5.0.0' });
348
+ await writeLockfile(projectPath, invalidDocument);
349
+ await assert.rejects(
350
+ extractRestDependencyVersions(projectPath, ['root-package']),
351
+ /Invalid pnpm-lock.yaml: expected a workspace document with an importers mapping/,
352
+ );
353
+ if (
354
+ invalidDocument.trim() &&
355
+ !invalidDocument.startsWith('#') &&
356
+ !invalidDocument.startsWith('---')
357
+ ) {
358
+ await writeLockfile(projectPath, `${workspaceLockfile}---\n${invalidDocument}`);
359
+ await assert.rejects(
360
+ extractRestDependencyVersions(projectPath, ['root-package']),
361
+ /Invalid pnpm-lock.yaml: expected a workspace document with an importers mapping/,
362
+ );
363
+ }
364
+ });
365
+ });
366
+ }
367
+
368
+ it('allows installed-package fallback with an empty workspace importer map', async () => {
369
+ await withFixture(async projectPath => {
370
+ await writeLockfile(projectPath, `${managementLockfile}---\nimporters: {}\n`);
371
+ await writePackage(projectPath, 'node_modules/root-package', { version: '5.0.0' });
372
+ assert.deepEqual(await extractRestDependencyVersions(projectPath, ['root-package']), {
373
+ 'root-package': '^5.0.0',
374
+ });
375
+ });
376
+ });
377
+
241
378
  it('uses the root importer range when the dependency is declared there', async () => {
242
379
  await withFixture(async projectPath => {
243
380
  await writeLockfile(