@di-framework/cli-plugin-platform 6.2.0 → 6.3.0
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/README.md +10 -0
- package/dist/args.d.ts +8 -0
- package/dist/args.js +73 -28
- package/dist/assets/platform/README.md +68 -19
- package/dist/assets/platform/index.ts.tmpl +1 -1
- package/dist/assets/platform/tsconfig.json +2 -2
- package/dist/assets/sqlite/BUILD-INFO.txt +1 -1
- package/dist/build.js +17 -4
- package/dist/bundle.d.ts +85 -0
- package/dist/bundle.js +608 -0
- package/dist/command.js +85 -3
- package/dist/console/cluster.d.ts +4 -2
- package/dist/console/cluster.js +38 -40
- package/dist/controller/client.d.ts +47 -0
- package/dist/controller/client.js +157 -0
- package/dist/controller/commands.d.ts +48 -0
- package/dist/controller/commands.js +584 -0
- package/dist/controller/credentials.d.ts +63 -0
- package/dist/controller/credentials.js +156 -0
- package/dist/controller/index.d.ts +6 -0
- package/dist/controller/index.js +6 -0
- package/dist/controller/oidc.d.ts +54 -0
- package/dist/controller/oidc.js +121 -0
- package/dist/controller/registry.d.ts +15 -0
- package/dist/controller/registry.js +47 -0
- package/dist/controller/schema.d.ts +157 -0
- package/dist/controller/schema.js +1 -0
- package/dist/controller/sse.d.ts +12 -0
- package/dist/controller/sse.js +61 -0
- package/dist/controller/trust.d.ts +14 -0
- package/dist/controller/trust.js +39 -0
- package/dist/deploy.d.ts +8 -1
- package/dist/deploy.js +89 -2
- package/dist/deps.d.ts +4 -0
- package/dist/destroy.js +26 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/manifest.d.ts +45 -1
- package/dist/manifest.js +197 -4
- package/dist/pglite.d.ts +12 -2
- package/dist/pglite.js +19 -11
- package/dist/publish.d.ts +7 -1
- package/dist/publish.js +33 -1
- package/dist/service.d.ts +34 -0
- package/dist/service.js +156 -145
- package/dist/target.d.ts +7 -1
- package/dist/target.js +19 -0
- package/dist/workload.d.ts +17 -1
- package/dist/workload.js +44 -11
- package/package.json +1 -1
package/dist/pglite.d.ts
CHANGED
|
@@ -112,6 +112,13 @@ export declare const STALE_STAGING_MS: number;
|
|
|
112
112
|
export declare function pullPgliteComponent(image: string, io: CliIo, deps: WasmcloudDeps, cwd: string, component?: PinnedComponent): Promise<ResolvedPglite>;
|
|
113
113
|
/** Set to `1` to let `deploy` or a CI build use a local, unverified provider. */
|
|
114
114
|
export declare const ALLOW_LOCAL_PGLITE_ENV = "DI_FRAMEWORK_ALLOW_LOCAL_PGLITE";
|
|
115
|
+
/**
|
|
116
|
+
* Options for resolving PGlite components.
|
|
117
|
+
*
|
|
118
|
+
* Note: `buildComponent(..., { deploy: true })` enforces the deploy-time refusal of unverified
|
|
119
|
+
* local providers, whereas calling the lower-level `publishComponent` API directly publishes an
|
|
120
|
+
* already-built `.wasm` without re-running provider resolution.
|
|
121
|
+
*/
|
|
115
122
|
export type ResolvePgliteOptions = {
|
|
116
123
|
/** A deploy ships the provider, so a local file needs the explicit opt-in. */
|
|
117
124
|
deploy?: boolean;
|
|
@@ -120,6 +127,9 @@ export type ResolvePgliteOptions = {
|
|
|
120
127
|
* The provider to compose: `DI_FRAMEWORK_PGLITE_WASM`, then `pglite.wasm`, then the
|
|
121
128
|
* digest-pinned `pglite.image`. Local files are only checked to be WebAssembly, and are
|
|
122
129
|
* refused in a deploy or on CI without `DI_FRAMEWORK_ALLOW_LOCAL_PGLITE=1`.
|
|
130
|
+
* Note that `buildComponent(..., { deploy: true })` enforces this deploy-time refusal, whereas
|
|
131
|
+
* calling the lower-level `publishComponent` API directly publishes an already-built `.wasm`
|
|
132
|
+
* without re-running provider resolution.
|
|
123
133
|
*/
|
|
124
134
|
export declare function resolvePgliteComponent(config: PgliteConfig, io: CliIo, deps: WasmcloudDeps, projectRoot: string, options?: ResolvePgliteOptions): Promise<ResolvedPglite>;
|
|
125
135
|
/**
|
|
@@ -130,8 +140,8 @@ export declare function resolvePgliteComponent(config: PgliteConfig, io: CliIo,
|
|
|
130
140
|
export declare function resolvePgliteEncryption(config: PgliteEncryptionConfig, io: CliIo, deps: WasmcloudDeps, projectRoot: string, options?: ResolvePgliteOptions): Promise<ResolvedPglite>;
|
|
131
141
|
/**
|
|
132
142
|
* Members of one workload share one storage directory, mounted at each member's own
|
|
133
|
-
* `storageMount`. Two members whose `dataDir` is the same path relative to their mount
|
|
134
|
-
* would open
|
|
143
|
+
* `storageMount`. Two members whose `dataDir` is the same or a nested path relative to their mount
|
|
144
|
+
* would open overlapping database directories from separate instances, which exclusivity cannot stop.
|
|
135
145
|
*/
|
|
136
146
|
export declare function assertDistinctPgliteRoots(workload: string, members: Iterable<{
|
|
137
147
|
applicationName: string;
|
package/dist/pglite.js
CHANGED
|
@@ -314,13 +314,16 @@ export async function pullPgliteComponent(image, io, deps, cwd, component = PGLI
|
|
|
314
314
|
}
|
|
315
315
|
/** Set to `1` to let `deploy` or a CI build use a local, unverified provider. */
|
|
316
316
|
export const ALLOW_LOCAL_PGLITE_ENV = 'DI_FRAMEWORK_ALLOW_LOCAL_PGLITE';
|
|
317
|
+
function isCiEnv(value) {
|
|
318
|
+
return Boolean(value && value !== '0' && value.toLowerCase() !== 'false');
|
|
319
|
+
}
|
|
317
320
|
function readLocalProvider(local, origin, config, io, deps, options, component = PGLITE_PROVIDER) {
|
|
318
321
|
if (!existsSync(local))
|
|
319
322
|
throw failure('WASMCLOUD_PGLITE_PROVIDER_MISSING', `${component.label} ${local} (from ${origin}) does not exist`, { path: local });
|
|
320
323
|
let context;
|
|
321
324
|
if (options.deploy)
|
|
322
325
|
context = 'deploy';
|
|
323
|
-
else if (deps.env.CI)
|
|
326
|
+
else if (isCiEnv(deps.env.CI))
|
|
324
327
|
context = 'CI';
|
|
325
328
|
if (context !== undefined && deps.env[ALLOW_LOCAL_PGLITE_ENV] !== '1')
|
|
326
329
|
throw failure('WASMCLOUD_PGLITE_LOCAL_REFUSED', `Refusing the unverified local ${component.label} ${local} (from ${origin}) in ${context}; ` +
|
|
@@ -336,6 +339,9 @@ function readLocalProvider(local, origin, config, io, deps, options, component =
|
|
|
336
339
|
* The provider to compose: `DI_FRAMEWORK_PGLITE_WASM`, then `pglite.wasm`, then the
|
|
337
340
|
* digest-pinned `pglite.image`. Local files are only checked to be WebAssembly, and are
|
|
338
341
|
* refused in a deploy or on CI without `DI_FRAMEWORK_ALLOW_LOCAL_PGLITE=1`.
|
|
342
|
+
* Note that `buildComponent(..., { deploy: true })` enforces this deploy-time refusal, whereas
|
|
343
|
+
* calling the lower-level `publishComponent` API directly publishes an already-built `.wasm`
|
|
344
|
+
* without re-running provider resolution.
|
|
339
345
|
*/
|
|
340
346
|
export async function resolvePgliteComponent(config, io, deps, projectRoot, options = {}) {
|
|
341
347
|
const fromEnv = deps.env[PGLITE_WASM_ENV]?.trim();
|
|
@@ -358,22 +364,25 @@ export async function resolvePgliteEncryption(config, io, deps, projectRoot, opt
|
|
|
358
364
|
return readLocalProvider(config.wasm, 'pglite.encryption.wasm', config, io, deps, options, PGLITE_ENCFS);
|
|
359
365
|
return pullPgliteComponent(config.image, io, deps, projectRoot, PGLITE_ENCFS);
|
|
360
366
|
}
|
|
367
|
+
function rootsOverlap(a, b) {
|
|
368
|
+
return a === b || a === '' || b === '' || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
|
|
369
|
+
}
|
|
361
370
|
/**
|
|
362
371
|
* Members of one workload share one storage directory, mounted at each member's own
|
|
363
|
-
* `storageMount`. Two members whose `dataDir` is the same path relative to their mount
|
|
364
|
-
* would open
|
|
372
|
+
* `storageMount`. Two members whose `dataDir` is the same or a nested path relative to their mount
|
|
373
|
+
* would open overlapping database directories from separate instances, which exclusivity cannot stop.
|
|
365
374
|
*/
|
|
366
375
|
export function assertDistinctPgliteRoots(workload, members) {
|
|
367
|
-
const owners =
|
|
376
|
+
const owners = [];
|
|
368
377
|
for (const member of members) {
|
|
369
378
|
if (member.workload !== workload || member.pglite === undefined)
|
|
370
379
|
continue;
|
|
371
380
|
const root = posix.relative(member.pglite.storageMount, member.pglite.dataDir);
|
|
372
|
-
const previous = owners.
|
|
381
|
+
const previous = owners.find((entry) => rootsOverlap(root, entry.root));
|
|
373
382
|
if (previous !== undefined)
|
|
374
|
-
throw new CommandFailure('WASMCLOUD_PGLITE_DATA_DIR_CONFLICT', `${workload}: ${previous} and ${member.applicationName} would open the same PGlite database ` +
|
|
383
|
+
throw new CommandFailure('WASMCLOUD_PGLITE_DATA_DIR_CONFLICT', `${workload}: ${previous.name} and ${member.applicationName} would open the same PGlite database ` +
|
|
375
384
|
`(<workload storage>/${root || '.'}); members share one storage directory, so give each a different dataDir relative to its storageMount`, 2, { workload, root });
|
|
376
|
-
owners.
|
|
385
|
+
owners.push({ root, name: member.applicationName });
|
|
377
386
|
}
|
|
378
387
|
}
|
|
379
388
|
/** Tag fragment of the tenant host image that honours the exclusive opt-in (#140). */
|
|
@@ -413,11 +422,10 @@ export async function warnIfHostIgnoresExclusive(project, connection, io, deps)
|
|
|
413
422
|
return;
|
|
414
423
|
}
|
|
415
424
|
const images = await hostImages(connection, hostgroup, deps, project.projectRoot);
|
|
416
|
-
if (images
|
|
425
|
+
if (images !== undefined && images.length > 0 && images.every(hasExclusiveTag))
|
|
417
426
|
return;
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
: `runs ${images[0]}`;
|
|
427
|
+
const nonExclusive = images?.find((img) => !hasExclusiveTag(img));
|
|
428
|
+
const seen = nonExclusive === undefined ? 'could not read its host image' : `runs ${nonExclusive}`;
|
|
421
429
|
io.stderr.write(`Warning: ${project.applicationName} embeds PGlite and is marked exclusive, but host group ${hostgroup} ` +
|
|
422
430
|
`${seen}, which does not look like the exclusive build (tagged *${EXCLUSIVE_HOST_IMAGE_MARKER}, set with the platform's tenantHostImage). ${risk}.\n`);
|
|
423
431
|
}
|
package/dist/publish.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CliIo, CommandFailure } from '@di-framework/cli-extension';
|
|
2
2
|
import type { WasmcloudDeps } from './deps.js';
|
|
3
3
|
import type { WasmcloudProject } from './project.js';
|
|
4
4
|
import type { ClusterConnection } from './target.js';
|
|
@@ -11,5 +11,11 @@ export type PublishedImage = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare function contentDigest(filePath: string): string;
|
|
13
13
|
export declare function ociReference(registry: string, repository: string, digest: string): string;
|
|
14
|
+
export declare function countCoreWasmModules(wasmBytes: Uint8Array): number;
|
|
15
|
+
export declare function reportCoreInstanceCost(wasmBytes: Uint8Array, io: CliIo, hostPoolSize?: number): {
|
|
16
|
+
coreModules: number;
|
|
17
|
+
maxConcurrentInvocations: number;
|
|
18
|
+
};
|
|
19
|
+
export declare function plainHttpRegistryFailure(pushReference: string, target: string, exitCode?: number): CommandFailure;
|
|
14
20
|
export declare function publishComponent(project: WasmcloudProject, connection: ClusterConnection, io: CliIo, deps: WasmcloudDeps, deploymentDigest: string): Promise<PublishedImage>;
|
|
15
21
|
export declare function projectRelativePath(projectRoot: string, path: string): string;
|
package/dist/publish.js
CHANGED
|
@@ -1,22 +1,51 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { isAbsolute, join, relative, sep } from 'node:path';
|
|
4
|
+
import { CommandFailure } from '@di-framework/cli-extension';
|
|
4
5
|
import { registryReferenceHost, registryUsesPlainHttp } from './registry.js';
|
|
5
6
|
import { toolFailed } from './support.js';
|
|
7
|
+
const CORE_WASM_MAGIC = Buffer.from([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]);
|
|
8
|
+
const PLAIN_HTTP_RESPONSE_RE = /server gave HTTP response to HTTPS client/i;
|
|
6
9
|
export function contentDigest(filePath) {
|
|
7
10
|
return createHash('sha256').update(readFileSync(filePath)).digest('hex');
|
|
8
11
|
}
|
|
9
12
|
export function ociReference(registry, repository, digest) {
|
|
10
13
|
return `${registryReferenceHost(registry)}/${repository}:sha256-${digest}`;
|
|
11
14
|
}
|
|
15
|
+
export function countCoreWasmModules(wasmBytes) {
|
|
16
|
+
const buf = Buffer.from(wasmBytes.buffer, wasmBytes.byteOffset, wasmBytes.byteLength);
|
|
17
|
+
let count = 0;
|
|
18
|
+
let offset = buf.indexOf(CORE_WASM_MAGIC, 0);
|
|
19
|
+
while (offset !== -1) {
|
|
20
|
+
count += 1;
|
|
21
|
+
offset = buf.indexOf(CORE_WASM_MAGIC, offset + CORE_WASM_MAGIC.length);
|
|
22
|
+
}
|
|
23
|
+
return Math.max(1, count);
|
|
24
|
+
}
|
|
25
|
+
export function reportCoreInstanceCost(wasmBytes, io, hostPoolSize = 100) {
|
|
26
|
+
const coreModules = countCoreWasmModules(wasmBytes);
|
|
27
|
+
const maxConcurrentInvocations = Math.floor(hostPoolSize / coreModules);
|
|
28
|
+
if (coreModules > 1) {
|
|
29
|
+
io.stdout.write(`Component instantiates ${coreModules} core WebAssembly modules per invocation (~${maxConcurrentInvocations} concurrent invocations at default WASH_CORE_INSTANCES=${hostPoolSize}).\n`);
|
|
30
|
+
}
|
|
31
|
+
if (maxConcurrentInvocations <= 10) {
|
|
32
|
+
io.stderr.write(`Warning: component requires ${coreModules} core instances per invocation, leaving at most ${maxConcurrentInvocations} concurrent invocations against the host's default WASH_CORE_INSTANCES=${hostPoolSize}; increase WASH_CORE_INSTANCES on the host if higher concurrency is needed.\n`);
|
|
33
|
+
}
|
|
34
|
+
return { coreModules, maxConcurrentInvocations };
|
|
35
|
+
}
|
|
36
|
+
export function plainHttpRegistryFailure(pushReference, target, exitCode = 1) {
|
|
37
|
+
return new CommandFailure('WASMCLOUD_TOOL_FAILED', `oras push failed with exit code ${exitCode}: ${pushReference} answered with plain HTTP to an HTTPS client; prefix the registry push URL with "http://" or set "insecure = true" under [targets.${target}.registry] in di-framework.deploy.toml`, 3, { command: 'oras push', exitCode, target, reference: pushReference });
|
|
38
|
+
}
|
|
12
39
|
export async function publishComponent(project, connection, io, deps, deploymentDigest) {
|
|
13
|
-
const
|
|
40
|
+
const wasmBytes = readFileSync(project.outputPath);
|
|
41
|
+
const artifactDigest = createHash('sha256').update(wasmBytes).digest('hex');
|
|
14
42
|
const pushReference = ociReference(connection.registry.push, project.witName, deploymentDigest);
|
|
15
43
|
const pullReference = ociReference(connection.registry.pull, project.witName, deploymentDigest);
|
|
16
44
|
const configPath = join(project.projectRoot, '.di-framework', 'oci-config.json');
|
|
17
45
|
const componentPath = projectRelativePath(project.projectRoot, project.outputPath);
|
|
18
46
|
const projectConfigPath = projectRelativePath(project.projectRoot, configPath);
|
|
19
47
|
io.stdout.write(`Publishing ${componentPath} as ${pushReference}...\n`);
|
|
48
|
+
reportCoreInstanceCost(wasmBytes, io);
|
|
20
49
|
const transportArgs = registryUsesPlainHttp(connection.registry) ? ['--plain-http'] : [];
|
|
21
50
|
const existing = await deps.runCaptured('oras', ['manifest', 'fetch', ...transportArgs, '--descriptor', pushReference], { cwd: project.projectRoot });
|
|
22
51
|
if (existing.exitCode === 0) {
|
|
@@ -29,6 +58,9 @@ export async function publishComponent(project, connection, io, deps, deployment
|
|
|
29
58
|
reference: pushReference,
|
|
30
59
|
};
|
|
31
60
|
}
|
|
61
|
+
if (PLAIN_HTTP_RESPONSE_RE.test(existing.stderr)) {
|
|
62
|
+
throw plainHttpRegistryFailure(pushReference, connection.target, existing.exitCode);
|
|
63
|
+
}
|
|
32
64
|
const pushed = await deps.runner('oras', [
|
|
33
65
|
'push',
|
|
34
66
|
...transportArgs,
|
package/dist/service.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type CliIo, type JsonValue } from '@di-framework/cli-extension';
|
|
2
2
|
import { type WasmcloudDeps } from './deps.js';
|
|
3
|
+
import { type DeployEnvironment } from './manifest.js';
|
|
3
4
|
export declare const BACKING_SERVICE_API_VERSION = "platform.di-framework.dev/v1alpha1";
|
|
4
5
|
export declare const BACKING_SERVICE_KIND = "BackingService";
|
|
5
6
|
export declare const BACKING_SERVICE_RESOURCE = "backingservices.platform.di-framework.dev";
|
|
@@ -38,6 +39,7 @@ export type ServiceCreateOptions = {
|
|
|
38
39
|
/** Egress only: hosts the workload may reach. */
|
|
39
40
|
destinations?: string[];
|
|
40
41
|
target?: string;
|
|
42
|
+
env?: DeployEnvironment;
|
|
41
43
|
namespace?: string;
|
|
42
44
|
context?: string;
|
|
43
45
|
wait: boolean;
|
|
@@ -46,6 +48,7 @@ export type ServiceCreateOptions = {
|
|
|
46
48
|
export type ServiceNameOptions = {
|
|
47
49
|
name?: string;
|
|
48
50
|
target?: string;
|
|
51
|
+
env?: DeployEnvironment;
|
|
49
52
|
namespace?: string;
|
|
50
53
|
context?: string;
|
|
51
54
|
};
|
|
@@ -123,6 +126,27 @@ export declare function parseServiceNameArgs(args: readonly string[], command: s
|
|
|
123
126
|
export declare function parseServiceListArgs(args: readonly string[]): ServiceListOptions;
|
|
124
127
|
export declare function summarizeService(document: BackingServiceDocument): ServiceSummary;
|
|
125
128
|
export declare function runWasmcloudServiceCreate(args: readonly string[], io: CliIo, deps?: WasmcloudDeps): Promise<{
|
|
129
|
+
data: {
|
|
130
|
+
wait: boolean;
|
|
131
|
+
ready: string;
|
|
132
|
+
createdAt: string;
|
|
133
|
+
resource: {
|
|
134
|
+
apiVersion: string;
|
|
135
|
+
kind: string;
|
|
136
|
+
};
|
|
137
|
+
destinations?: string[] | undefined;
|
|
138
|
+
deletionPolicy?: "Retain" | "Delete" | undefined;
|
|
139
|
+
parameters?: import("./controller/schema.js").ServiceParameters | undefined;
|
|
140
|
+
name: string;
|
|
141
|
+
type: import("./controller/schema.js").ControllerServiceType;
|
|
142
|
+
className: string;
|
|
143
|
+
env: import("./controller/index.js").Env;
|
|
144
|
+
account: string;
|
|
145
|
+
namespace: string;
|
|
146
|
+
target: string;
|
|
147
|
+
};
|
|
148
|
+
text: string;
|
|
149
|
+
} | {
|
|
126
150
|
data: {
|
|
127
151
|
resource: {
|
|
128
152
|
apiVersion: string;
|
|
@@ -160,6 +184,16 @@ export declare function runWasmcloudServiceGet(args: readonly string[], _io: Cli
|
|
|
160
184
|
text: string;
|
|
161
185
|
}>;
|
|
162
186
|
export declare function runWasmcloudServiceDelete(args: readonly string[], io: CliIo, deps?: WasmcloudDeps): Promise<{
|
|
187
|
+
data: {
|
|
188
|
+
name: string;
|
|
189
|
+
env: DeployEnvironment;
|
|
190
|
+
account: string;
|
|
191
|
+
namespace: string;
|
|
192
|
+
target: string;
|
|
193
|
+
deleted: boolean;
|
|
194
|
+
};
|
|
195
|
+
text: string;
|
|
196
|
+
} | {
|
|
163
197
|
data: {
|
|
164
198
|
deletionPolicy?: string | undefined;
|
|
165
199
|
name: string;
|