@wildo-ai/wildo-module-client 1.1.10 → 1.1.12
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/index.js.map +1 -1
- package/dist/esm/services/_http-client.js.map +1 -1
- package/dist/esm/services/_zod-issue-formatting.js.map +1 -1
- package/dist/esm/services/index.js.map +1 -1
- package/dist/esm/services/lockfile-repair.service.d.ts +51 -0
- package/dist/esm/services/lockfile-repair.service.d.ts.map +1 -1
- package/dist/esm/services/lockfile-repair.service.js +95 -4
- package/dist/esm/services/lockfile-repair.service.js.map +1 -1
- package/dist/esm/services/module-adopter.service.js.map +1 -1
- package/dist/esm/services/module-packager.service.d.ts +8 -8
- package/dist/esm/services/module-packager.service.js +8 -8
- package/dist/esm/services/module-packager.service.js.map +1 -1
- package/dist/esm/services/provider-materialization-hook.js.map +1 -1
- package/dist/esm/services/provider-sync-runner.d.ts +8 -9
- package/dist/esm/services/provider-sync-runner.d.ts.map +1 -1
- package/dist/esm/services/provider-sync-runner.js +6 -7
- package/dist/esm/services/provider-sync-runner.js.map +1 -1
- package/dist/esm/services/registry-companion-client.js.map +1 -1
- package/dist/esm/services/registry-lockfile.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 +62 -5
- package/dist/esm/services/registry-server-client.js.map +1 -1
- package/dist/esm/services/types.d.ts.map +1 -1
- package/dist/esm/services/types.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/__tests__/registry-lockfile.service.test.ts +3 -2
- package/src/__tests__/registry-server-client.test.ts +126 -3
- package/src/services/lockfile-repair.service.ts +132 -3
- package/src/services/module-packager.service.ts +8 -8
- package/src/services/provider-sync-runner.ts +8 -9
- package/src/services/registry-server-client.ts +74 -3
- package/dist/tsconfig.tsbuildinfo +0 -1
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.12",
|
|
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,18 +30,18 @@
|
|
|
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.12"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^24.0.15",
|
|
37
|
-
"rimraf": "^6.
|
|
37
|
+
"rimraf": "^6.1.4",
|
|
38
38
|
"tsc-alias": "1.8.16",
|
|
39
39
|
"tsc-watch": "7.2.1",
|
|
40
40
|
"typescript": "5.9.3",
|
|
41
|
-
"vitest": "^1.
|
|
41
|
+
"vitest": "^4.1.12"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"zod": "^4.
|
|
44
|
+
"zod": "^4.6.6"
|
|
45
45
|
},
|
|
46
46
|
"repository": {
|
|
47
47
|
"type": "git",
|
|
@@ -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 () => {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* `platform-module-registry`.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { createServer, type Server } from 'node:http';
|
|
10
|
+
import { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http';
|
|
11
11
|
import { createHash } from 'node:crypto';
|
|
12
12
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
13
13
|
import {
|
|
@@ -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,
|
|
@@ -34,8 +36,8 @@ interface TestServer {
|
|
|
34
36
|
|
|
35
37
|
async function startServer(
|
|
36
38
|
handler: (
|
|
37
|
-
req:
|
|
38
|
-
res:
|
|
39
|
+
req: IncomingMessage,
|
|
40
|
+
res: ServerResponse,
|
|
39
41
|
) => void | Promise<void>,
|
|
40
42
|
): Promise<TestServer> {
|
|
41
43
|
return new Promise((resolve) => {
|
|
@@ -439,3 +441,124 @@ 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
|
+
});
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* A refusal with no typed meaning names what the registry said (#3388). Every route goes through `refuseUnlessOk` or,
|
|
489
|
+
* for a 409, through the same reader, so search (a 400), info (a 500) and a yank 409 stand for all of them.
|
|
490
|
+
*/
|
|
491
|
+
describe('RegistryServerClient names the registry\'s reason for a refusal (#3388)', () => {
|
|
492
|
+
const answer = async (status: number, body: string, contentType = 'application/json') => {
|
|
493
|
+
svc = await startServer((_req, res) => {
|
|
494
|
+
res.writeHead(status, { 'content-type': contentType });
|
|
495
|
+
res.end(body);
|
|
496
|
+
});
|
|
497
|
+
return svc.baseUrl;
|
|
498
|
+
};
|
|
499
|
+
const refusedFilter = JSON.stringify({
|
|
500
|
+
error: {
|
|
501
|
+
type: 'VALIDATION', message: 'validation', correlationId: 'corr-search',
|
|
502
|
+
details: { message: 'invalid search filter' },
|
|
503
|
+
validationErrors: { kind: 'Invalid option: expected one of "feature"|"provider"', maturity: { code: 'declared_refusal', params: { refusalCode: 'x' } } },
|
|
504
|
+
},
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it('carries the reason, the refused fields and the correlation id of a 400 with a body', async () => {
|
|
508
|
+
const baseUrl = await answer(400, refusedFilter);
|
|
509
|
+
const error = await RegistryServerClient.search({ baseUrl }, { domain: 'acme', query: '' }).catch((err: unknown) => err);
|
|
510
|
+
expect(error).toBeInstanceOf(RegistryUnexpectedStatusError);
|
|
511
|
+
expect((error as Error).message).toBe(
|
|
512
|
+
`Registry "search" failed with HTTP 400 Bad Request at ${baseUrl}: invalid search filter; `
|
|
513
|
+
+ 'kind: Invalid option: expected one of "feature"|"provider"; maturity: declared_refusal {"refusalCode":"x"} '
|
|
514
|
+
+ '(VALIDATION, correlation id corr-search).',
|
|
515
|
+
);
|
|
516
|
+
expect((error as RegistryUnexpectedStatusError).refusal).toMatchObject({ reason: 'invalid search filter', correlationId: 'corr-search', type: 'VALIDATION' });
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
it('reports the status alone for a 400 with an empty body', async () => {
|
|
520
|
+
const baseUrl = await answer(400, '');
|
|
521
|
+
const error = await RegistryServerClient.search({ baseUrl }, { domain: 'acme', query: '' }).catch((err: unknown) => err);
|
|
522
|
+
expect((error as Error).message).toBe(`Registry "search" failed with HTTP 400 Bad Request at ${baseUrl}.`);
|
|
523
|
+
expect((error as RegistryUnexpectedStatusError).refusal).toBeUndefined();
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it('quotes a body that is not the registry\'s envelope', async () => {
|
|
527
|
+
const baseUrl = await answer(500, 'upstream exploded', 'text/plain');
|
|
528
|
+
const error = await RegistryServerClient.info({ baseUrl }, { domain: 'acme', moduleId: 'acme/billing' }).catch((err: unknown) => err);
|
|
529
|
+
expect((error as Error).message).toBe(`Registry "info acme/billing" failed with HTTP 500 Internal Server Error at ${baseUrl}: the response said: upstream exploded.`);
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
it('keeps the reason of a yank 409 that is not the release-state refusal', async () => {
|
|
533
|
+
const baseUrl = await answer(409, JSON.stringify({ error: { type: 'CONFLICT', message: 'conflict', details: { message: 'gave up after lost optimistic checks', code: 'version_conflict' } } }));
|
|
534
|
+
const error = await RegistryServerClient.yank({ baseUrl }, { domain: 'acme', moduleId: 'acme/billing', version: '1.0.0' }).catch((err: unknown) => err);
|
|
535
|
+
expect(error).toBeInstanceOf(RegistryUnexpectedStatusError);
|
|
536
|
+
expect((error as Error).message).toMatch(/HTTP 409 Conflict at .*: gave up after lost optimistic checks \(version_conflict\)\.$/);
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
it('bounds a refused download\'s body by the request budget: a body that never ends does not hold the call', async () => {
|
|
540
|
+
// A transfer clears its response timer when the headers arrive and arms its idle timer only when the transfer is
|
|
541
|
+
// read (#1763), so reading the REFUSAL's body needs a deadline of its own (#3388 review F1).
|
|
542
|
+
let hanging: ServerResponse | undefined;
|
|
543
|
+
svc = await startServer((_req, res) => {
|
|
544
|
+
hanging = res;
|
|
545
|
+
res.writeHead(500, { 'content-type': 'application/json' });
|
|
546
|
+
res.write('{"error":');
|
|
547
|
+
});
|
|
548
|
+
const started = Date.now();
|
|
549
|
+
const error = await RegistryServerClient.download(
|
|
550
|
+
{ baseUrl: svc.baseUrl, timeoutMs: 300 },
|
|
551
|
+
{ domain: 'acme', moduleId: 'acme/billing', version: '1.0.0', expectedDigest: `sha256:${'a'.repeat(64)}` },
|
|
552
|
+
).catch((err: unknown) => err);
|
|
553
|
+
expect(error).toBeInstanceOf(RegistryUnexpectedStatusError);
|
|
554
|
+
expect((error as RegistryUnexpectedStatusError).refusal).toBeUndefined();
|
|
555
|
+
expect(Date.now() - started).toBeLessThan(3_000);
|
|
556
|
+
hanging?.destroy();
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
it('keeps the reason of a domain-create 409 that is not a taken slug', async () => {
|
|
560
|
+
const baseUrl = await answer(409, JSON.stringify({ error: { type: 'CONFLICT', message: 'conflict', details: { message: 'something else' } } }));
|
|
561
|
+
const error = await RegistryServerClient.createDomain({ baseUrl, authToken: 'k' }, { domain: 'wildo', defaultVisibility: 'PUBLIC' }).catch((err: unknown) => err);
|
|
562
|
+
expect((error as Error).message).toMatch(/HTTP 409 Conflict at .*: something else \(CONFLICT\)\.$/);
|
|
563
|
+
});
|
|
564
|
+
});
|
|
@@ -20,21 +20,45 @@ import * as path from 'node:path';
|
|
|
20
20
|
import { z } from 'zod';
|
|
21
21
|
import { formatZodIssuesAsSingleLine } from './_zod-issue-formatting';
|
|
22
22
|
import {
|
|
23
|
+
readApplicationPnpmSettings,
|
|
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
|
|
33
|
+
* `onlyBuiltDependencies` (#2809). Each is the application's own policy, which the install (#2801) also refuses to
|
|
34
|
+
* override, and pnpm reads it as follows (measured on 10.6.4 in #2801 and #2808, and again on 10.34.9 in #3014: a
|
|
35
|
+
* `package.json` list still replaces the workspace file's, and both lists together still refuse the install).
|
|
36
|
+
*
|
|
37
|
+
* A third member, `workspace-allow-list` (an allow-list kept in `pnpm-workspace.yaml`, which a `package.json` list would
|
|
38
|
+
* replace), was RETIRED by #2808: the install and the repair now write the workspace file, so that list is the one
|
|
39
|
+
* they extend.
|
|
40
|
+
*/
|
|
41
|
+
export enum ApplicationInstallScriptPolicy {
|
|
42
|
+
/** A `neverBuiltDependencies` list names the package, and pnpm refuses to install with both lists. */
|
|
43
|
+
NEVER_BUILT_LIST = 'never-built-list',
|
|
44
|
+
/**
|
|
45
|
+
* The application declares an allow-list AND a `neverBuiltDependencies` list (in either file): pnpm (10.6.4 and 10.34.9) refuses to
|
|
46
|
+
* install at all (`ERR_PNPM_CONFIG_CONFLICT_BUILT_DEPENDENCIES`, measured in #2809's review), so writing a name changes
|
|
47
|
+
* nothing until the application keeps one of them.
|
|
48
|
+
*/
|
|
49
|
+
CONFLICTING_LISTS = 'conflicting-lists',
|
|
50
|
+
}
|
|
51
|
+
|
|
29
52
|
/**
|
|
30
53
|
* Permissive envelope schema used by repair only — it accepts any
|
|
31
54
|
* `sections.*` payload without delegating to per-section schemas
|
|
32
55
|
* so the repair flow can isolate "envelope is malformed" from
|
|
33
|
-
* "envelope is fine but modules section is malformed".
|
|
56
|
+
* "envelope is fine but modules section is malformed". Applied after
|
|
57
|
+
* `withoutRetiredLockfileEnvelopeKeys`, like every lockfile reader, so a
|
|
58
|
+
* file written before the envelope lost its `generatedAt` still parses.
|
|
34
59
|
*/
|
|
35
60
|
const RelaxedEnvelopeSchema = z.strictObject({
|
|
36
61
|
schemaVersion: z.literal(2),
|
|
37
|
-
generatedAt: z.iso.datetime({ offset: true }),
|
|
38
62
|
sections: z.record(z.string(), z.unknown()),
|
|
39
63
|
});
|
|
40
64
|
|
|
@@ -56,6 +80,41 @@ export type LockfileRepairFinding =
|
|
|
56
80
|
kind: 'module-file-missing';
|
|
57
81
|
moduleId: string;
|
|
58
82
|
filePath: string;
|
|
83
|
+
}
|
|
84
|
+
| {
|
|
85
|
+
/** A vendor pin the module's recorded wiring wrote (#2789) is gone from the application's overrides: restorable. */
|
|
86
|
+
severity: 'warn';
|
|
87
|
+
kind: 'vendor-pin-missing';
|
|
88
|
+
moduleId: string;
|
|
89
|
+
name: string;
|
|
90
|
+
version: string;
|
|
91
|
+
}
|
|
92
|
+
| {
|
|
93
|
+
/** A recorded vendor pin the application moved since install: its decision, reported and never overwritten. */
|
|
94
|
+
severity: 'warn';
|
|
95
|
+
kind: 'vendor-pin-moved';
|
|
96
|
+
moduleId: string;
|
|
97
|
+
name: string;
|
|
98
|
+
version: string;
|
|
99
|
+
found: string;
|
|
100
|
+
}
|
|
101
|
+
| {
|
|
102
|
+
/**
|
|
103
|
+
* An install-script name the module's recorded wiring wrote (#2801), not held by the application, that the
|
|
104
|
+
* application's allow-list no longer carries: restorable into `onlyBuiltDependencies` in `pnpm-workspace.yaml`.
|
|
105
|
+
*/
|
|
106
|
+
severity: 'warn';
|
|
107
|
+
kind: 'only-built-missing';
|
|
108
|
+
moduleId: string;
|
|
109
|
+
name: string;
|
|
110
|
+
}
|
|
111
|
+
| {
|
|
112
|
+
/** A recorded install-script name the application's own policy does not allow, and `--fix` must not write: reported only. */
|
|
113
|
+
severity: 'warn';
|
|
114
|
+
kind: 'only-built-blocked';
|
|
115
|
+
moduleId: string;
|
|
116
|
+
name: string;
|
|
117
|
+
policy: ApplicationInstallScriptPolicy;
|
|
59
118
|
};
|
|
60
119
|
|
|
61
120
|
export interface LockfileRepairReport {
|
|
@@ -75,6 +134,72 @@ async function fileExists(absPath: string): Promise<boolean> {
|
|
|
75
134
|
}
|
|
76
135
|
}
|
|
77
136
|
|
|
137
|
+
/**
|
|
138
|
+
* The application's effective pnpm settings (#2808), as pnpm 10 reads them: `pnpm-workspace.yaml`, or `package.json` →
|
|
139
|
+
* `pnpm` for a setting an older application still keeps there. A file the helper cannot read faithfully THROWS
|
|
140
|
+
* (`PnpmSettingsFormatError`, naming the line): reading it as empty would report every recorded pin as missing, and a
|
|
141
|
+
* `--fix` would then write into a file it cannot read.
|
|
142
|
+
*/
|
|
143
|
+
function readEffectivePnpmSettings(saasRoot: string): { overrides?: unknown; onlyBuiltDependencies?: unknown; neverBuiltDependencies?: unknown } {
|
|
144
|
+
return readApplicationPnpmSettings(saasRoot);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function asRecord(value: unknown): Record<string, unknown> {
|
|
148
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function asNames(value: unknown): string[] | undefined {
|
|
152
|
+
return Array.isArray(value) ? value.filter((name): name is string => typeof name === 'string') : undefined;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Each install-script name a provider module's recorded wiring WROTE (#2801; a held name is the application's own), judged
|
|
157
|
+
* as pnpm 10 (10.6.4 through 10.34.9, #3014) will judge it against the application's EFFECTIVE policy (#2808: wherever pnpm reads it), with the same
|
|
158
|
+
* precedence the install uses (`onlyBuiltStates` in `wildo-cli`):
|
|
159
|
+
* - an allow-list AND a `neverBuiltDependencies` list → pnpm installs nothing, so a name the allow-list lacks is blocked
|
|
160
|
+
* by `CONFLICTING_LISTS` and never written;
|
|
161
|
+
* - an allow-list → a name it lacks is `only-built-missing`, restorable into `pnpm-workspace.yaml`;
|
|
162
|
+
* - otherwise a `neverBuiltDependencies` list → a name it lists is blocked by `NEVER_BUILT_LIST`; any other name's
|
|
163
|
+
* script runs, so nothing is reported;
|
|
164
|
+
* - otherwise no policy at all → pnpm runs no script, and the name is `only-built-missing`: restoring it writes the list
|
|
165
|
+
* the install wrote.
|
|
166
|
+
*/
|
|
167
|
+
function collectOnlyBuiltFindings(
|
|
168
|
+
moduleId: string,
|
|
169
|
+
entry: RegistryModulesLockEntry,
|
|
170
|
+
settings: { onlyBuiltDependencies?: unknown; neverBuiltDependencies?: unknown },
|
|
171
|
+
findings: LockfileRepairFinding[],
|
|
172
|
+
): void {
|
|
173
|
+
const wiring = entry.registration?.providerWiring;
|
|
174
|
+
const held = new Set(wiring?.heldOnlyBuiltDependencies ?? []);
|
|
175
|
+
const wrote = (wiring?.onlyBuiltDependencies ?? []).filter((name) => !held.has(name));
|
|
176
|
+
if (wrote.length === 0) return;
|
|
177
|
+
const allowList = asNames(settings.onlyBuiltDependencies);
|
|
178
|
+
const never = asNames(settings.neverBuiltDependencies);
|
|
179
|
+
for (const name of wrote) {
|
|
180
|
+
if (allowList !== undefined && never !== undefined) {
|
|
181
|
+
if (!allowList.includes(name)) findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.CONFLICTING_LISTS });
|
|
182
|
+
} else if (allowList !== undefined) {
|
|
183
|
+
if (!allowList.includes(name)) findings.push({ severity: 'warn', kind: 'only-built-missing', moduleId, name });
|
|
184
|
+
} else if (never !== undefined) {
|
|
185
|
+
if (never.includes(name)) findings.push({ severity: 'warn', kind: 'only-built-blocked', moduleId, name, policy: ApplicationInstallScriptPolicy.NEVER_BUILT_LIST });
|
|
186
|
+
} else {
|
|
187
|
+
findings.push({ severity: 'warn', kind: 'only-built-missing', moduleId, name });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Each vendor pin a provider module's recorded wiring wrote (#2789), against the root overrides: missing (restorable by
|
|
194
|
+
* `--fix`), or moved by the application (reported only: a pin the application set is its own).
|
|
195
|
+
*/
|
|
196
|
+
function collectVendorPinFindings(moduleId: string, entry: RegistryModulesLockEntry, overrides: Record<string, unknown>, findings: LockfileRepairFinding[]): void {
|
|
197
|
+
for (const [name, version] of Object.entries(entry.registration?.providerWiring?.vendorPins ?? {})) {
|
|
198
|
+
if (!Object.hasOwn(overrides, name)) findings.push({ severity: 'warn', kind: 'vendor-pin-missing', moduleId, name, version });
|
|
199
|
+
else if (overrides[name] !== version) findings.push({ severity: 'warn', kind: 'vendor-pin-moved', moduleId, name, version, found: String(overrides[name]) });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
78
203
|
export const LockfileRepairService = {
|
|
79
204
|
/** Compute the lockfile path for a saas root. */
|
|
80
205
|
pathFor(saasRoot: string): string {
|
|
@@ -124,7 +249,7 @@ export const LockfileRepairService = {
|
|
|
124
249
|
return { lockfilePath, ok: false, findings };
|
|
125
250
|
}
|
|
126
251
|
|
|
127
|
-
const envelopeParsed = RelaxedEnvelopeSchema.safeParse(parsedJson);
|
|
252
|
+
const envelopeParsed = RelaxedEnvelopeSchema.safeParse(withoutRetiredLockfileEnvelopeKeys(parsedJson));
|
|
128
253
|
if (!envelopeParsed.success) {
|
|
129
254
|
findings.push({
|
|
130
255
|
severity: 'error',
|
|
@@ -154,8 +279,12 @@ export const LockfileRepairService = {
|
|
|
154
279
|
}
|
|
155
280
|
const modules: RegistryModulesLockSection = parsed.data;
|
|
156
281
|
|
|
282
|
+
const pnpmSettings = readEffectivePnpmSettings(saasRoot);
|
|
283
|
+
const rootOverrides = asRecord(pnpmSettings.overrides);
|
|
157
284
|
for (const [moduleId, entry] of Object.entries(modules.installed)) {
|
|
158
285
|
await this.collectEntryFindings(saasRoot, moduleId, entry, findings);
|
|
286
|
+
collectVendorPinFindings(moduleId, entry, rootOverrides, findings);
|
|
287
|
+
collectOnlyBuiltFindings(moduleId, entry, pnpmSettings, findings);
|
|
159
288
|
}
|
|
160
289
|
|
|
161
290
|
const ok = findings.every((f) => f.severity !== 'error');
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `ModulePackagerService` —
|
|
2
|
+
* `ModulePackagerService` — staging logic for module
|
|
3
3
|
* publishing.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Layout:
|
|
6
6
|
* - Published artifacts are zip archives staged under
|
|
7
7
|
* `<saasRoot>/.wildo-saas/generated/modules-artifacts/<module.id>/`.
|
|
8
8
|
* - The staged folder is the source of the artifact. It must
|
|
9
9
|
* include the `wildo.module.json` manifest, copied source
|
|
10
10
|
* files, and dependency declarations.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* This service ships the staging-folder primitives (path resolution,
|
|
13
13
|
* stage-fresh, copy-source-tree, write-manifest, compute-digest).
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* `wildo registry publish` calls these and the zip step; install
|
|
15
|
+
* consumes the same digest.
|
|
16
16
|
*
|
|
17
17
|
* Hard contracts:
|
|
18
18
|
* - Staging is always a fresh tree per call (`stageFresh`
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* from a previous failed stage MUST NOT leak into the digest.
|
|
22
22
|
* - The staged tree is a CHILD of `<saasRoot>/.wildo-saas/`,
|
|
23
23
|
* never reaches outside `saasRoot`.
|
|
24
|
-
* - Boundary enforcement
|
|
24
|
+
* - Boundary enforcement lives in this service: the
|
|
25
25
|
* staging primitive rejects file paths that escape the
|
|
26
26
|
* declared `boundaries.<layer>` allow-list, so a publish
|
|
27
27
|
* can never claim app surface it doesn't own.
|
|
@@ -112,7 +112,7 @@ function isPathInside(child: string, parent: string): boolean {
|
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
114
|
* Verify a candidate file path is contained inside one of the
|
|
115
|
-
* manifest's declared `boundaries
|
|
115
|
+
* manifest's declared `boundaries`. Returns the resolved
|
|
116
116
|
* absolute path on success; throws `RegistryBoundaryViolationError`
|
|
117
117
|
* otherwise.
|
|
118
118
|
*/
|
|
@@ -162,7 +162,7 @@ export const ModulePackagerService = {
|
|
|
162
162
|
/**
|
|
163
163
|
* Copy a single file from the app source into the staging tree.
|
|
164
164
|
* Path is verified against the manifest's declared boundaries
|
|
165
|
-
*
|
|
165
|
+
* — files outside `boundaries.*` are rejected with
|
|
166
166
|
* `RegistryBoundaryViolationError`. The relative path INSIDE the
|
|
167
167
|
* staging root mirrors the relative path inside the saas root,
|
|
168
168
|
* so callers don't need to translate paths between the two
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `runProviderSync` —
|
|
2
|
+
* `runProviderSync` — the real shell-out to
|
|
3
3
|
* `wildo config sync --domain config`.
|
|
4
4
|
*
|
|
5
5
|
* Module-registry install/update/remove/adopt flows mutate app
|
|
6
6
|
* source. When that source changes provider implementations,
|
|
7
7
|
* provider companion exports, or provider scopes, the
|
|
8
8
|
* provider-runtime delivery layer must regenerate its outputs
|
|
9
|
-
*
|
|
9
|
+
* The canonical command is owned by the provider
|
|
10
10
|
* workstream — module-registry MUST delegate, not fork.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* `runProviderMaterializationHook` is a no-op that records intent;
|
|
13
|
+
* this is the real
|
|
14
14
|
* `child_process.spawn`-based runner that:
|
|
15
15
|
* - resolves the `wildo` CLI binary from the saas root's
|
|
16
16
|
* `node_modules/.bin/wildo` (the workspace's own version);
|
|
@@ -21,10 +21,9 @@
|
|
|
21
21
|
* (`companion-discovery` / `runtime-import-reachability` /
|
|
22
22
|
* `invalid-scope` / `unknown`) so callers report repairable
|
|
23
23
|
* failures with first-class UX rather than generic install
|
|
24
|
-
* noise
|
|
25
|
-
* WIP Seams §1).
|
|
24
|
+
* noise.
|
|
26
25
|
*
|
|
27
|
-
* Hard contract
|
|
26
|
+
* Hard contract: the runner NEVER writes provider runtime
|
|
28
27
|
* artifacts itself. It only invokes the provider workstream's
|
|
29
28
|
* canonical command. Tests assert no provider artifact is touched
|
|
30
29
|
* by this code path.
|
|
@@ -61,7 +60,7 @@ export interface ProviderSyncRunnerInput {
|
|
|
61
60
|
log?: RegistryClientLogger;
|
|
62
61
|
/**
|
|
63
62
|
* Override the wildo CLI binary path. Defaults to
|
|
64
|
-
* `<saasRoot>/node_modules/.bin/wildo`.
|
|
63
|
+
* `<saasRoot>/node_modules/.bin/wildo`. Tests override
|
|
65
64
|
* this to point at a stub script.
|
|
66
65
|
*/
|
|
67
66
|
wildoBinPath?: string;
|
|
@@ -72,7 +71,7 @@ export interface ProviderSyncRunnerInput {
|
|
|
72
71
|
timeoutMs?: number;
|
|
73
72
|
/**
|
|
74
73
|
* If true, do NOT actually shell out — log the intent and
|
|
75
|
-
* resolve as `mode: 'dry-run'`. Used by the
|
|
74
|
+
* resolve as `mode: 'dry-run'`. Used by the smoke
|
|
76
75
|
* command which intentionally cannot rely on a working
|
|
77
76
|
* `wildo` binary in the smoke sandbox.
|
|
78
77
|
*/
|
|
@@ -25,10 +25,18 @@ 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,
|
|
37
|
+
parseRegistryRefusalBody,
|
|
38
|
+
readRegistryRefusal,
|
|
39
|
+
readRegistryRefusalBody,
|
|
32
40
|
RegistryMalformedPayloadError,
|
|
33
41
|
RegistryModuleNotFoundError,
|
|
34
42
|
RegistryUnexpectedStatusError,
|
|
@@ -78,6 +86,14 @@ export interface RegistryServerClientOptions {
|
|
|
78
86
|
timeoutMs?: number;
|
|
79
87
|
}
|
|
80
88
|
|
|
89
|
+
/**
|
|
90
|
+
* The deadline a refusal's body is read under: the request's own budget when the caller set one, else the reader's
|
|
91
|
+
* default. Needed for a download above all, whose response timer is already cleared when its headers arrive (#3388).
|
|
92
|
+
*/
|
|
93
|
+
function refusalBodyBounds(options: RegistryServerClientOptions): { timeoutMs?: number } {
|
|
94
|
+
return options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {};
|
|
95
|
+
}
|
|
96
|
+
|
|
81
97
|
function authHeaders(options: RegistryServerClientOptions): Record<string, string> {
|
|
82
98
|
return options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {};
|
|
83
99
|
}
|
|
@@ -86,6 +102,12 @@ function authHeaders(options: RegistryServerClientOptions): Record<string, strin
|
|
|
86
102
|
* Throw the typed error for a non-2xx response, after releasing its body (#1763 review: an unread body
|
|
87
103
|
* holds the connection until garbage collection). A 401 is told apart by whether a key was SENT — "log
|
|
88
104
|
* in" and "your key no longer works" are different remedies (#1759 review).
|
|
105
|
+
*
|
|
106
|
+
* A status with no typed meaning READS its body instead of discarding it (#3388): the registry's reason, the
|
|
107
|
+
* fields a schema refusal names and the correlation id travel there, and an error carrying only `HTTP 400` sent
|
|
108
|
+
* the operator to the server's logs for what the answer already said. The typed branches still discard theirs:
|
|
109
|
+
* each already names its remedy, and the engine strips the context of an authentication, authorization or
|
|
110
|
+
* not-found refusal at the wire, so those bodies carry no reason to report.
|
|
89
111
|
*/
|
|
90
112
|
async function refuseUnlessOk(
|
|
91
113
|
res: Response,
|
|
@@ -99,7 +121,9 @@ async function refuseUnlessOk(
|
|
|
99
121
|
else if (res.status === 401) error = options.authToken ? new RegistryCredentialRejectedError(options.baseUrl) : new RegistryAuthRequiredError(options.baseUrl);
|
|
100
122
|
else if (res.status === 403) error = new RegistryAuthForbiddenError(action);
|
|
101
123
|
else if (res.status === 429) error = new RegistryRateLimitedError(options.baseUrl, action, parseRetryAfterSeconds(res.headers.get('retry-after')));
|
|
102
|
-
else
|
|
124
|
+
else {
|
|
125
|
+
throw new RegistryUnexpectedStatusError(options.baseUrl, res.status, res.statusText, action, await readRegistryRefusal(res, refusalBodyBounds(options)));
|
|
126
|
+
}
|
|
103
127
|
await res.body?.cancel().catch(() => undefined);
|
|
104
128
|
throw error;
|
|
105
129
|
}
|
|
@@ -386,8 +410,55 @@ export const RegistryServerClient = {
|
|
|
386
410
|
): Promise<{ latest: string | null }> {
|
|
387
411
|
return changeYankState(options, args, RegistryYankVerb.UNYANK);
|
|
388
412
|
},
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Register a domain for the key's organization (#2024). Domains are first come, first served, and every module
|
|
416
|
+
* published into one inherits its `defaultVisibility`. A slug already registered throws `RegistryDomainTakenError`
|
|
417
|
+
* whoever holds it; `listMyDomains` tells whether that is the caller's own organization.
|
|
418
|
+
*/
|
|
419
|
+
async createDomain(
|
|
420
|
+
options: RegistryServerClientOptions,
|
|
421
|
+
args: { domain: string; defaultVisibility: RegistryArtifactVisibility },
|
|
422
|
+
): Promise<RegistryDomainRecord> {
|
|
423
|
+
const url = joinUrl(options.baseUrl, '/v1/registry/domains');
|
|
424
|
+
const action = `create domain ${args.domain}`;
|
|
425
|
+
const res = await fetchWithTimeout(url, {
|
|
426
|
+
method: 'POST',
|
|
427
|
+
headers: { ...authHeaders(options), 'content-type': 'application/json' },
|
|
428
|
+
body: JSON.stringify({ domain: args.domain, defaultVisibility: args.defaultVisibility }),
|
|
429
|
+
timeoutMs: options.timeoutMs,
|
|
430
|
+
diagnosticLabel: DIAGNOSTIC_LABEL,
|
|
431
|
+
});
|
|
432
|
+
if (res.status === 409) {
|
|
433
|
+
// Only the registry's own code means "the slug is registered"; a bare 409 is shared by other refusals.
|
|
434
|
+
const body = await readRegistryRefusalBody(res, refusalBodyBounds(options));
|
|
435
|
+
if (hasRegistryRefusalCode(body, RegistryRefusalCode.DOMAIN_TAKEN)) throw new RegistryDomainTakenError(args.domain);
|
|
436
|
+
throw new RegistryUnexpectedStatusError(options.baseUrl, res.status, res.statusText, action, parseRegistryRefusalBody(body));
|
|
437
|
+
}
|
|
438
|
+
await refuseUnlessOk(res, options, action);
|
|
439
|
+
const parsed = RegistryCreateDomainResponseSchema.safeParse(await parseJsonOrThrow(res, options.baseUrl, action, options.timeoutMs));
|
|
440
|
+
if (!parsed.success) throw new RegistryMalformedPayloadError(options.baseUrl, action, formatZodIssuesAsSingleLine(parsed.error));
|
|
441
|
+
return parsed.data.domain;
|
|
442
|
+
},
|
|
443
|
+
|
|
444
|
+
/** The domains the key's organization owns (#2024). Needs a key holding the domain LIST role. */
|
|
445
|
+
async listMyDomains(options: RegistryServerClientOptions): Promise<RegistryDomainRecord[]> {
|
|
446
|
+
const url = joinUrl(options.baseUrl, '/v1/registry/my-domains');
|
|
447
|
+
const action = 'list domains';
|
|
448
|
+
const res = await fetchWithTimeout(url, { method: 'GET', headers: authHeaders(options), timeoutMs: options.timeoutMs, diagnosticLabel: DIAGNOSTIC_LABEL });
|
|
449
|
+
await refuseUnlessOk(res, options, action);
|
|
450
|
+
const parsed = RegistryListDomainsResponseSchema.safeParse(await parseJsonOrThrow(res, options.baseUrl, action, options.timeoutMs));
|
|
451
|
+
if (!parsed.success) throw new RegistryMalformedPayloadError(options.baseUrl, action, formatZodIssuesAsSingleLine(parsed.error));
|
|
452
|
+
return parsed.data.domains;
|
|
453
|
+
},
|
|
389
454
|
} as const;
|
|
390
455
|
|
|
456
|
+
/** A registry domain as the registry answers it: the slug and the visibility its modules inherit. */
|
|
457
|
+
const RegistryDomainRecordSchema = z.object({ domain: z.string().min(1), defaultVisibility: RegistryArtifactVisibilitySchema });
|
|
458
|
+
export type RegistryDomainRecord = z.infer<typeof RegistryDomainRecordSchema>;
|
|
459
|
+
const RegistryCreateDomainResponseSchema = z.object({ domain: RegistryDomainRecordSchema });
|
|
460
|
+
const RegistryListDomainsResponseSchema = z.object({ domains: z.array(RegistryDomainRecordSchema) });
|
|
461
|
+
|
|
391
462
|
const RegistryYankResponseSchema = z.object({ ok: z.literal(true), latest: z.string().nullable().optional() });
|
|
392
463
|
|
|
393
464
|
async function changeYankState(
|
|
@@ -410,9 +481,9 @@ async function changeYankState(
|
|
|
410
481
|
if (res.status === 409) {
|
|
411
482
|
// Only the release-state refusal is the no-op; a 409 for anything else (the registry giving up after
|
|
412
483
|
// lost optimistic checks) is a FAILED yank and must not be reported as done (#1758 re-review R3).
|
|
413
|
-
const body = await res
|
|
484
|
+
const body = await readRegistryRefusalBody(res, refusalBodyBounds(options));
|
|
414
485
|
if (isRegistryReleaseStateConflictBody(body)) throw new RegistryYankStateConflictError(args.moduleId, args.version, verb);
|
|
415
|
-
throw new RegistryUnexpectedStatusError(options.baseUrl, res.status, res.statusText, action);
|
|
486
|
+
throw new RegistryUnexpectedStatusError(options.baseUrl, res.status, res.statusText, action, parseRegistryRefusalBody(body));
|
|
416
487
|
}
|
|
417
488
|
// A 404 names the module or the version; the sanitized envelope does not say which.
|
|
418
489
|
await refuseUnlessOk(res, options, action, () => new RegistryVersionNotFoundError(args.moduleId, args.version));
|