@wildo-ai/wildo-module-client 1.1.9 → 1.1.11
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/esm/services/lockfile-repair.service.d.ts +65 -1
- package/dist/esm/services/lockfile-repair.service.d.ts.map +1 -1
- package/dist/esm/services/lockfile-repair.service.js +101 -5
- package/dist/esm/services/lockfile-repair.service.js.map +1 -1
- package/dist/esm/services/registry-server-client.d.ts +23 -1
- package/dist/esm/services/registry-server-client.d.ts.map +1 -1
- package/dist/esm/services/registry-server-client.js +44 -1
- package/dist/esm/services/registry-server-client.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/__tests__/lockfile-repair.service.test.ts +5 -5
- package/src/__tests__/registry-lockfile.service.test.ts +3 -2
- package/src/__tests__/registry-server-client.test.ts +44 -0
- package/src/services/lockfile-repair.service.ts +155 -4
- package/src/services/registry-server-client.ts +52 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildo-ai/wildo-module-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "Module-registry runtime services consumed by wildo-cli and the dev companion (Phase 0.5 skeleton)",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Wildo AI",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test:watch": "vitest"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@wildo-ai/platform-config-lib": "1.1.
|
|
33
|
+
"@wildo-ai/platform-config-lib": "1.1.11"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^24.0.15",
|
|
@@ -51,14 +51,14 @@ const validEntry = (overrides: Record<string, unknown> = {}) => ({
|
|
|
51
51
|
|
|
52
52
|
describe('LockfileRepairService.inspect', () => {
|
|
53
53
|
it('returns ok+empty when the lockfile does not exist', async () => {
|
|
54
|
-
const report = await LockfileRepairService.inspect(saasRoot);
|
|
54
|
+
const report = await LockfileRepairService.inspect(saasRoot, { workspaceBuildPolicy: {} });
|
|
55
55
|
expect(report.ok).toBe(true);
|
|
56
56
|
expect(report.findings).toEqual([]);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
it('reports envelope-malformed on top-level Zod failure', async () => {
|
|
60
60
|
await writeEnvelope({ schemaVersion: 1, generatedAt: '2026', sections: {} });
|
|
61
|
-
const report = await LockfileRepairService.inspect(saasRoot);
|
|
61
|
+
const report = await LockfileRepairService.inspect(saasRoot, { workspaceBuildPolicy: {} });
|
|
62
62
|
expect(report.ok).toBe(false);
|
|
63
63
|
expect(report.findings[0].kind).toBe('envelope-malformed');
|
|
64
64
|
});
|
|
@@ -69,7 +69,7 @@ describe('LockfileRepairService.inspect', () => {
|
|
|
69
69
|
generatedAt: '2026-05-05T12:00:00.000Z',
|
|
70
70
|
sections: { modules: { installed: 'not-an-object' } },
|
|
71
71
|
});
|
|
72
|
-
const report = await LockfileRepairService.inspect(saasRoot);
|
|
72
|
+
const report = await LockfileRepairService.inspect(saasRoot, { workspaceBuildPolicy: {} });
|
|
73
73
|
expect(report.ok).toBe(false);
|
|
74
74
|
expect(report.findings[0].kind).toBe('modules-section-malformed');
|
|
75
75
|
});
|
|
@@ -80,7 +80,7 @@ describe('LockfileRepairService.inspect', () => {
|
|
|
80
80
|
generatedAt: '2026-05-05T12:00:00.000Z',
|
|
81
81
|
sections: { modules: { installed: { 'acme/billing': validEntry() } } },
|
|
82
82
|
});
|
|
83
|
-
const report = await LockfileRepairService.inspect(saasRoot);
|
|
83
|
+
const report = await LockfileRepairService.inspect(saasRoot, { workspaceBuildPolicy: {} });
|
|
84
84
|
expect(report.ok).toBe(true); // warnings only
|
|
85
85
|
expect(report.findings).toHaveLength(1);
|
|
86
86
|
expect(report.findings[0]).toMatchObject({
|
|
@@ -100,7 +100,7 @@ describe('LockfileRepairService.inspect', () => {
|
|
|
100
100
|
generatedAt: '2026-05-05T12:00:00.000Z',
|
|
101
101
|
sections: { modules: { installed: { 'acme/billing': validEntry() } } },
|
|
102
102
|
});
|
|
103
|
-
const report = await LockfileRepairService.inspect(saasRoot);
|
|
103
|
+
const report = await LockfileRepairService.inspect(saasRoot, { workspaceBuildPolicy: {} });
|
|
104
104
|
expect(report.findings).toEqual([]);
|
|
105
105
|
});
|
|
106
106
|
});
|
|
@@ -105,8 +105,9 @@ describe('RegistryLockfileService', () => {
|
|
|
105
105
|
expect(after.sections.i18n).toEqual(original.sections.i18n);
|
|
106
106
|
expect(after.sections.future).toEqual(original.sections.future);
|
|
107
107
|
expect(after.sections.modules.installed['acme/billing'].version).toBe('2.0.0');
|
|
108
|
-
// generatedAt
|
|
109
|
-
|
|
108
|
+
// The fixture was written with the retired `generatedAt`; the write drops it rather than refresh it
|
|
109
|
+
// (#1765: the envelope carries no timestamp).
|
|
110
|
+
expect(after).not.toHaveProperty('generatedAt');
|
|
110
111
|
});
|
|
111
112
|
|
|
112
113
|
it('rejects an invalid module entry with a Zod parse error and never writes the section', async () => {
|
|
@@ -15,7 +15,9 @@ import {
|
|
|
15
15
|
RegistryAuthForbiddenError,
|
|
16
16
|
RegistryAuthRequiredError,
|
|
17
17
|
RegistryCredentialRejectedError,
|
|
18
|
+
RegistryDomainTakenError,
|
|
18
19
|
RegistryMalformedPayloadError,
|
|
20
|
+
RegistryRefusalCode,
|
|
19
21
|
RegistryModuleNotFoundError,
|
|
20
22
|
RegistryRateLimitedError,
|
|
21
23
|
RegistryUnexpectedStatusError,
|
|
@@ -439,3 +441,45 @@ describe('RegistryServerClient.yank / unyank (#1758)', () => {
|
|
|
439
441
|
}
|
|
440
442
|
});
|
|
441
443
|
});
|
|
444
|
+
|
|
445
|
+
describe('RegistryServerClient domains (#2024)', () => {
|
|
446
|
+
const conflict = (code?: string) => JSON.stringify({ error: { type: 'CONFLICT', customMessageReference: 'conflict', ...(code ? { details: { code } } : {}) } });
|
|
447
|
+
|
|
448
|
+
it('creates a domain with the visibility asked for, under the key, and returns the registry\'s record', async () => {
|
|
449
|
+
let seen: { url?: string; method?: string; body?: unknown; auth?: string } = {};
|
|
450
|
+
svc = await startServer(async (req, res) => {
|
|
451
|
+
let raw = '';
|
|
452
|
+
for await (const chunk of req) raw += chunk;
|
|
453
|
+
seen = { url: req.url, method: req.method, body: JSON.parse(raw), auth: req.headers.authorization };
|
|
454
|
+
res.writeHead(201, { 'content-type': 'application/json' });
|
|
455
|
+
res.end(JSON.stringify({ domain: { _id: 'd1', domain: 'wildo', defaultVisibility: 'PUBLIC', ownerOrganizationId: 'o1' } }));
|
|
456
|
+
});
|
|
457
|
+
const created = await RegistryServerClient.createDomain({ baseUrl: svc.baseUrl, authToken: 'sk_org_k' }, { domain: 'wildo', defaultVisibility: 'PUBLIC' });
|
|
458
|
+
expect(created).toEqual({ domain: 'wildo', defaultVisibility: 'PUBLIC' });
|
|
459
|
+
expect(seen).toEqual({ url: '/v1/registry/domains', method: 'POST', body: { domain: 'wildo', defaultVisibility: 'PUBLIC' }, auth: 'Bearer sk_org_k' });
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
it('types a registered slug as taken only on the registry\'s own code; any other 409 is unexpected', async () => {
|
|
463
|
+
for (const [body, expected] of [[conflict(RegistryRefusalCode.DOMAIN_TAKEN), RegistryDomainTakenError], [conflict(), RegistryUnexpectedStatusError], ['', RegistryUnexpectedStatusError]] as const) {
|
|
464
|
+
svc = await startServer((_req, res) => {
|
|
465
|
+
res.writeHead(409, { 'content-type': 'application/json' });
|
|
466
|
+
res.end(body);
|
|
467
|
+
});
|
|
468
|
+
const error = await RegistryServerClient.createDomain({ baseUrl: svc.baseUrl, authToken: 'k' }, { domain: 'wildo', defaultVisibility: 'PUBLIC' }).catch((err: unknown) => err);
|
|
469
|
+
expect(error, body).toBeInstanceOf(expected);
|
|
470
|
+
await svc.close();
|
|
471
|
+
svc = null;
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
it('lists the key organization\'s domains', async () => {
|
|
476
|
+
let path: string | undefined;
|
|
477
|
+
svc = await startServer((req, res) => {
|
|
478
|
+
path = req.url;
|
|
479
|
+
res.writeHead(200, { 'content-type': 'application/json' });
|
|
480
|
+
res.end(JSON.stringify({ domains: [{ domain: 'wildo', defaultVisibility: 'RESTRICTED', ownerOrganizationId: 'o1' }] }));
|
|
481
|
+
});
|
|
482
|
+
expect(await RegistryServerClient.listMyDomains({ baseUrl: svc.baseUrl, authToken: 'k' })).toEqual([{ domain: 'wildo', defaultVisibility: 'RESTRICTED' }]);
|
|
483
|
+
expect(path).toBe('/v1/registry/my-domains');
|
|
484
|
+
});
|
|
485
|
+
});
|
|
@@ -20,21 +20,60 @@ import * as path from 'node:path';
|
|
|
20
20
|
import { z } from 'zod';
|
|
21
21
|
import { formatZodIssuesAsSingleLine } from './_zod-issue-formatting';
|
|
22
22
|
import {
|
|
23
|
+
PROVIDER_VENDOR_PINS_MANIFEST,
|
|
23
24
|
RegistryModulesLockSectionSchema,
|
|
24
25
|
getWildoSaasLockPath,
|
|
26
|
+
withoutRetiredLockfileEnvelopeKeys,
|
|
25
27
|
type RegistryModulesLockEntry,
|
|
26
28
|
type RegistryModulesLockSection,
|
|
27
29
|
} from '@wildo-ai/platform-config-lib';
|
|
28
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Why a provider module's install-script name cannot simply be written back into the application's root
|
|
33
|
+
* `package.json` → `pnpm.onlyBuiltDependencies` (#2809). Each is the application's own policy, which the install
|
|
34
|
+
* (#2801) also refuses to override, and pnpm 10.6.4 reads it as follows (measured in #2801):
|
|
35
|
+
*/
|
|
36
|
+
export enum ApplicationInstallScriptPolicy {
|
|
37
|
+
/** The allow-list lives in `pnpm-workspace.yaml`, and a list in `package.json` would REPLACE it. */
|
|
38
|
+
WORKSPACE_ALLOW_LIST = 'workspace-allow-list',
|
|
39
|
+
/** A `neverBuiltDependencies` list names the package, and pnpm refuses to install with both lists. */
|
|
40
|
+
NEVER_BUILT_LIST = 'never-built-list',
|
|
41
|
+
/**
|
|
42
|
+
* The application declares an allow-list AND a `neverBuiltDependencies` list (in either file): pnpm 10.6.4 refuses to
|
|
43
|
+
* install at all (`ERR_PNPM_CONFIG_CONFLICT_BUILT_DEPENDENCIES`, measured in #2809's review), so writing a name changes
|
|
44
|
+
* nothing until the application keeps one of them.
|
|
45
|
+
*/
|
|
46
|
+
CONFLICTING_LISTS = 'conflicting-lists',
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The install-script policy `pnpm-workspace.yaml` declares, each list `undefined` when the file does not declare it.
|
|
51
|
+
* Supplied by the caller, which owns the YAML reading (`wildo-cli`'s `readWorkspaceBuildPolicy`, the reader the install
|
|
52
|
+
* uses), so the inspector and the install judge one policy the same way.
|
|
53
|
+
*/
|
|
54
|
+
export interface WorkspaceBuildPolicy {
|
|
55
|
+
onlyBuiltDependencies?: readonly string[];
|
|
56
|
+
neverBuiltDependencies?: readonly string[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface LockfileRepairInspectOptions {
|
|
60
|
+
/**
|
|
61
|
+
* Required rather than defaulted: without it, a name missing from `package.json` could look restorable when the
|
|
62
|
+
* application keeps its list in `pnpm-workspace.yaml`, and `--fix` would then replace that list.
|
|
63
|
+
*/
|
|
64
|
+
workspaceBuildPolicy: WorkspaceBuildPolicy;
|
|
65
|
+
}
|
|
66
|
+
|
|
29
67
|
/**
|
|
30
68
|
* Permissive envelope schema used by repair only — it accepts any
|
|
31
69
|
* `sections.*` payload without delegating to per-section schemas
|
|
32
70
|
* so the repair flow can isolate "envelope is malformed" from
|
|
33
|
-
* "envelope is fine but modules section is malformed".
|
|
71
|
+
* "envelope is fine but modules section is malformed". Applied after
|
|
72
|
+
* `withoutRetiredLockfileEnvelopeKeys`, like every lockfile reader, so a
|
|
73
|
+
* file written before the envelope lost its `generatedAt` still parses.
|
|
34
74
|
*/
|
|
35
75
|
const RelaxedEnvelopeSchema = z.strictObject({
|
|
36
76
|
schemaVersion: z.literal(2),
|
|
37
|
-
generatedAt: z.iso.datetime({ offset: true }),
|
|
38
77
|
sections: z.record(z.string(), z.unknown()),
|
|
39
78
|
});
|
|
40
79
|
|
|
@@ -56,6 +95,41 @@ export type LockfileRepairFinding =
|
|
|
56
95
|
kind: 'module-file-missing';
|
|
57
96
|
moduleId: string;
|
|
58
97
|
filePath: string;
|
|
98
|
+
}
|
|
99
|
+
| {
|
|
100
|
+
/** A vendor pin the module's recorded wiring wrote (#2789) is gone from the root `pnpm.overrides`: restorable. */
|
|
101
|
+
severity: 'warn';
|
|
102
|
+
kind: 'vendor-pin-missing';
|
|
103
|
+
moduleId: string;
|
|
104
|
+
name: string;
|
|
105
|
+
version: string;
|
|
106
|
+
}
|
|
107
|
+
| {
|
|
108
|
+
/** A recorded vendor pin the application moved since install: its decision, reported and never overwritten. */
|
|
109
|
+
severity: 'warn';
|
|
110
|
+
kind: 'vendor-pin-moved';
|
|
111
|
+
moduleId: string;
|
|
112
|
+
name: string;
|
|
113
|
+
version: string;
|
|
114
|
+
found: string;
|
|
115
|
+
}
|
|
116
|
+
| {
|
|
117
|
+
/**
|
|
118
|
+
* An install-script name the module's recorded wiring wrote (#2801), not held by the application, that the
|
|
119
|
+
* application's allow-list no longer carries: restorable into `package.json` → `pnpm.onlyBuiltDependencies`.
|
|
120
|
+
*/
|
|
121
|
+
severity: 'warn';
|
|
122
|
+
kind: 'only-built-missing';
|
|
123
|
+
moduleId: string;
|
|
124
|
+
name: string;
|
|
125
|
+
}
|
|
126
|
+
| {
|
|
127
|
+
/** A recorded install-script name the application's own policy does not allow, and `--fix` must not write: reported only. */
|
|
128
|
+
severity: 'warn';
|
|
129
|
+
kind: 'only-built-blocked';
|
|
130
|
+
moduleId: string;
|
|
131
|
+
name: string;
|
|
132
|
+
policy: ApplicationInstallScriptPolicy;
|
|
59
133
|
};
|
|
60
134
|
|
|
61
135
|
export interface LockfileRepairReport {
|
|
@@ -75,6 +149,79 @@ async function fileExists(absPath: string): Promise<boolean> {
|
|
|
75
149
|
}
|
|
76
150
|
}
|
|
77
151
|
|
|
152
|
+
/** The `pnpm` section of the application's root manifest, `{}` when the manifest is absent or not JSON (nothing to compare). */
|
|
153
|
+
async function readRootPnpmSection(saasRoot: string): Promise<{ overrides?: unknown; onlyBuiltDependencies?: unknown; neverBuiltDependencies?: unknown }> {
|
|
154
|
+
try {
|
|
155
|
+
const section = (JSON.parse(await fs.readFile(path.join(saasRoot, PROVIDER_VENDOR_PINS_MANIFEST), 'utf8')) as { pnpm?: unknown }).pnpm;
|
|
156
|
+
return section !== null && typeof section === 'object' && !Array.isArray(section) ? section : {};
|
|
157
|
+
} catch {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function asRecord(value: unknown): Record<string, unknown> {
|
|
163
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function asNames(value: unknown): string[] | undefined {
|
|
167
|
+
return Array.isArray(value) ? value.filter((name): name is string => typeof name === 'string') : undefined;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Each install-script name a provider module's recorded wiring WROTE (#2801; a held name is the application's own), judged
|
|
172
|
+
* as pnpm 10.6.4 will judge it, with the same precedence the install uses (`onlyBuiltStates` in `wildo-cli`):
|
|
173
|
+
* - an allow-list AND a `neverBuiltDependencies` list, in either file → pnpm installs nothing, so a name the allow-list
|
|
174
|
+
* lacks is blocked by `CONFLICTING_LISTS` and never written;
|
|
175
|
+
* - `package.json` carries an allow-list → it is the one pnpm reads (it replaces a workspace list), so a name it lacks is
|
|
176
|
+
* `only-built-missing`, restorable there;
|
|
177
|
+
* - otherwise a `pnpm-workspace.yaml` allow-list → a name it lacks is blocked by `WORKSPACE_ALLOW_LIST`;
|
|
178
|
+
* - otherwise a `neverBuiltDependencies` list (`package.json` first, as the install reads it) → a name it lists is blocked
|
|
179
|
+
* by `NEVER_BUILT_LIST`; any other name's script runs, so nothing is reported;
|
|
180
|
+
* - otherwise no policy at all → pnpm runs no script, and the name is `only-built-missing`: restoring it writes the list
|
|
181
|
+
* the install wrote.
|
|
182
|
+
*/
|
|
183
|
+
function collectOnlyBuiltFindings(
|
|
184
|
+
moduleId: string,
|
|
185
|
+
entry: RegistryModulesLockEntry,
|
|
186
|
+
pnpmSection: { onlyBuiltDependencies?: unknown; neverBuiltDependencies?: unknown },
|
|
187
|
+
workspace: WorkspaceBuildPolicy,
|
|
188
|
+
findings: LockfileRepairFinding[],
|
|
189
|
+
): void {
|
|
190
|
+
const wiring = entry.registration?.providerWiring;
|
|
191
|
+
const held = new Set(wiring?.heldOnlyBuiltDependencies ?? []);
|
|
192
|
+
const wrote = (wiring?.onlyBuiltDependencies ?? []).filter((name) => !held.has(name));
|
|
193
|
+
if (wrote.length === 0) return;
|
|
194
|
+
const manifestList = asNames(pnpmSection.onlyBuiltDependencies);
|
|
195
|
+
const never = asNames(pnpmSection.neverBuiltDependencies) ?? workspace.neverBuiltDependencies;
|
|
196
|
+
const allowList = manifestList ?? workspace.onlyBuiltDependencies;
|
|
197
|
+
for (const name of wrote) {
|
|
198
|
+
if (allowList !== undefined && never !== undefined) {
|
|
199
|
+
if (!allowList.includes(name)) findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.CONFLICTING_LISTS });
|
|
200
|
+
} else if (manifestList !== undefined) {
|
|
201
|
+
if (!manifestList.includes(name)) findings.push({ severity: 'warn', kind: 'only-built-missing', moduleId, name });
|
|
202
|
+
} else if (workspace.onlyBuiltDependencies !== undefined) {
|
|
203
|
+
if (!workspace.onlyBuiltDependencies.includes(name)) {
|
|
204
|
+
findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.WORKSPACE_ALLOW_LIST });
|
|
205
|
+
}
|
|
206
|
+
} else if (never !== undefined) {
|
|
207
|
+
if (never.includes(name)) findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.NEVER_BUILT_LIST });
|
|
208
|
+
} else {
|
|
209
|
+
findings.push({ severity: 'warn', kind: 'only-built-missing', moduleId, name });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Each vendor pin a provider module's recorded wiring wrote (#2789), against the root overrides: missing (restorable by
|
|
216
|
+
* `--fix`), or moved by the application (reported only: a pin the application set is its own).
|
|
217
|
+
*/
|
|
218
|
+
function collectVendorPinFindings(moduleId: string, entry: RegistryModulesLockEntry, overrides: Record<string, unknown>, findings: LockfileRepairFinding[]): void {
|
|
219
|
+
for (const [name, version] of Object.entries(entry.registration?.providerWiring?.vendorPins ?? {})) {
|
|
220
|
+
if (!Object.hasOwn(overrides, name)) findings.push({ severity: 'warn', kind: 'vendor-pin-missing', moduleId, name, version });
|
|
221
|
+
else if (overrides[name] !== version) findings.push({ severity: 'warn', kind: 'vendor-pin-moved', moduleId, name, version, found: String(overrides[name]) });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
78
225
|
export const LockfileRepairService = {
|
|
79
226
|
/** Compute the lockfile path for a saas root. */
|
|
80
227
|
pathFor(saasRoot: string): string {
|
|
@@ -84,7 +231,7 @@ export const LockfileRepairService = {
|
|
|
84
231
|
/**
|
|
85
232
|
* Read the envelope + run every diagnostic. Read-only.
|
|
86
233
|
*/
|
|
87
|
-
async inspect(saasRoot: string): Promise<LockfileRepairReport> {
|
|
234
|
+
async inspect(saasRoot: string, options: LockfileRepairInspectOptions): Promise<LockfileRepairReport> {
|
|
88
235
|
const lockfilePath = getWildoSaasLockPath(saasRoot);
|
|
89
236
|
const findings: LockfileRepairFinding[] = [];
|
|
90
237
|
|
|
@@ -124,7 +271,7 @@ export const LockfileRepairService = {
|
|
|
124
271
|
return { lockfilePath, ok: false, findings };
|
|
125
272
|
}
|
|
126
273
|
|
|
127
|
-
const envelopeParsed = RelaxedEnvelopeSchema.safeParse(parsedJson);
|
|
274
|
+
const envelopeParsed = RelaxedEnvelopeSchema.safeParse(withoutRetiredLockfileEnvelopeKeys(parsedJson));
|
|
128
275
|
if (!envelopeParsed.success) {
|
|
129
276
|
findings.push({
|
|
130
277
|
severity: 'error',
|
|
@@ -154,8 +301,12 @@ export const LockfileRepairService = {
|
|
|
154
301
|
}
|
|
155
302
|
const modules: RegistryModulesLockSection = parsed.data;
|
|
156
303
|
|
|
304
|
+
const pnpmSection = await readRootPnpmSection(saasRoot);
|
|
305
|
+
const rootOverrides = asRecord(pnpmSection.overrides);
|
|
157
306
|
for (const [moduleId, entry] of Object.entries(modules.installed)) {
|
|
158
307
|
await this.collectEntryFindings(saasRoot, moduleId, entry, findings);
|
|
308
|
+
collectVendorPinFindings(moduleId, entry, rootOverrides, findings);
|
|
309
|
+
collectOnlyBuiltFindings(moduleId, entry, pnpmSection, options.workspaceBuildPolicy, findings);
|
|
159
310
|
}
|
|
160
311
|
|
|
161
312
|
const ok = findings.every((f) => f.severity !== 'error');
|
|
@@ -25,7 +25,12 @@ import {
|
|
|
25
25
|
RegistryAuthForbiddenError,
|
|
26
26
|
RegistryAuthRequiredError,
|
|
27
27
|
RegistryCredentialRejectedError,
|
|
28
|
+
RegistryArtifactVisibilitySchema,
|
|
29
|
+
RegistryDomainTakenError,
|
|
28
30
|
RegistryError,
|
|
31
|
+
RegistryRefusalCode,
|
|
32
|
+
hasRegistryRefusalCode,
|
|
33
|
+
type RegistryArtifactVisibility,
|
|
29
34
|
RegistryRateLimitedError,
|
|
30
35
|
isRegistryError,
|
|
31
36
|
isRegistryReleaseStateConflictBody,
|
|
@@ -386,8 +391,55 @@ export const RegistryServerClient = {
|
|
|
386
391
|
): Promise<{ latest: string | null }> {
|
|
387
392
|
return changeYankState(options, args, RegistryYankVerb.UNYANK);
|
|
388
393
|
},
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Register a domain for the key's organization (#2024). Domains are first come, first served, and every module
|
|
397
|
+
* published into one inherits its `defaultVisibility`. A slug already registered throws `RegistryDomainTakenError`
|
|
398
|
+
* whoever holds it; `listMyDomains` tells whether that is the caller's own organization.
|
|
399
|
+
*/
|
|
400
|
+
async createDomain(
|
|
401
|
+
options: RegistryServerClientOptions,
|
|
402
|
+
args: { domain: string; defaultVisibility: RegistryArtifactVisibility },
|
|
403
|
+
): Promise<RegistryDomainRecord> {
|
|
404
|
+
const url = joinUrl(options.baseUrl, '/v1/registry/domains');
|
|
405
|
+
const action = `create domain ${args.domain}`;
|
|
406
|
+
const res = await fetchWithTimeout(url, {
|
|
407
|
+
method: 'POST',
|
|
408
|
+
headers: { ...authHeaders(options), 'content-type': 'application/json' },
|
|
409
|
+
body: JSON.stringify({ domain: args.domain, defaultVisibility: args.defaultVisibility }),
|
|
410
|
+
timeoutMs: options.timeoutMs,
|
|
411
|
+
diagnosticLabel: DIAGNOSTIC_LABEL,
|
|
412
|
+
});
|
|
413
|
+
if (res.status === 409) {
|
|
414
|
+
// Only the registry's own code means "the slug is registered"; a bare 409 is shared by other refusals.
|
|
415
|
+
const body = await res.json().catch(() => undefined);
|
|
416
|
+
if (hasRegistryRefusalCode(body, RegistryRefusalCode.DOMAIN_TAKEN)) throw new RegistryDomainTakenError(args.domain);
|
|
417
|
+
throw new RegistryUnexpectedStatusError(options.baseUrl, res.status, res.statusText, action);
|
|
418
|
+
}
|
|
419
|
+
await refuseUnlessOk(res, options, action);
|
|
420
|
+
const parsed = RegistryCreateDomainResponseSchema.safeParse(await parseJsonOrThrow(res, options.baseUrl, action, options.timeoutMs));
|
|
421
|
+
if (!parsed.success) throw new RegistryMalformedPayloadError(options.baseUrl, action, formatZodIssuesAsSingleLine(parsed.error));
|
|
422
|
+
return parsed.data.domain;
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
/** The domains the key's organization owns (#2024). Needs a key holding the domain LIST role. */
|
|
426
|
+
async listMyDomains(options: RegistryServerClientOptions): Promise<RegistryDomainRecord[]> {
|
|
427
|
+
const url = joinUrl(options.baseUrl, '/v1/registry/my-domains');
|
|
428
|
+
const action = 'list domains';
|
|
429
|
+
const res = await fetchWithTimeout(url, { method: 'GET', headers: authHeaders(options), timeoutMs: options.timeoutMs, diagnosticLabel: DIAGNOSTIC_LABEL });
|
|
430
|
+
await refuseUnlessOk(res, options, action);
|
|
431
|
+
const parsed = RegistryListDomainsResponseSchema.safeParse(await parseJsonOrThrow(res, options.baseUrl, action, options.timeoutMs));
|
|
432
|
+
if (!parsed.success) throw new RegistryMalformedPayloadError(options.baseUrl, action, formatZodIssuesAsSingleLine(parsed.error));
|
|
433
|
+
return parsed.data.domains;
|
|
434
|
+
},
|
|
389
435
|
} as const;
|
|
390
436
|
|
|
437
|
+
/** A registry domain as the registry answers it: the slug and the visibility its modules inherit. */
|
|
438
|
+
const RegistryDomainRecordSchema = z.object({ domain: z.string().min(1), defaultVisibility: RegistryArtifactVisibilitySchema });
|
|
439
|
+
export type RegistryDomainRecord = z.infer<typeof RegistryDomainRecordSchema>;
|
|
440
|
+
const RegistryCreateDomainResponseSchema = z.object({ domain: RegistryDomainRecordSchema });
|
|
441
|
+
const RegistryListDomainsResponseSchema = z.object({ domains: z.array(RegistryDomainRecordSchema) });
|
|
442
|
+
|
|
391
443
|
const RegistryYankResponseSchema = z.object({ ok: z.literal(true), latest: z.string().nullable().optional() });
|
|
392
444
|
|
|
393
445
|
async function changeYankState(
|