@forgeax/engine-pack 0.1.23 → 0.1.25
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 +12 -6
- package/dist/build.d.ts +4 -4
- package/dist/build.d.ts.map +1 -1
- package/dist/build.mjs +390 -294
- package/dist/build.mjs.map +1 -1
- package/dist/cli-asset.mjs +33 -35
- package/dist/cli-asset.mjs.map +1 -1
- package/dist/evidence/material-cook.d.ts +26 -0
- package/dist/evidence/material-cook.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +121 -27
- package/dist/index.mjs.map +1 -1
- package/dist/material-cook.d.ts +1 -1
- package/dist/material-cook.d.ts.map +1 -1
- package/dist/material-cook.mjs +102 -4
- package/dist/material-cook.mjs.map +1 -1
- package/dist/{parameterized-pack-node.d.ts → pack-authoring-node.d.ts} +7 -7
- package/dist/pack-authoring-node.d.ts.map +1 -0
- package/dist/{parameterized-pack-node.mjs → pack-authoring-node.mjs} +59 -63
- package/dist/pack-authoring-node.mjs.map +1 -0
- package/dist/{parameterized-pack.d.ts → pack-authoring.d.ts} +28 -31
- package/dist/pack-authoring.d.ts.map +1 -0
- package/dist/pack-authoring.mjs +1137 -0
- package/dist/pack-authoring.mjs.map +1 -0
- package/dist/runtime.mjs +1 -1
- package/dist/runtime.mjs.map +1 -1
- package/dist/scanner.d.ts +11 -9
- package/dist/scanner.d.ts.map +1 -1
- package/dist/scanner.mjs +36 -34
- package/dist/scanner.mjs.map +1 -1
- package/dist/schema.mjs +1 -1
- package/dist/schema.mjs.map +1 -1
- package/dist/scriptable-pack-node.d.ts +4 -4
- package/dist/scriptable-pack-node.d.ts.map +1 -1
- package/dist/scriptable-pack-node.mjs +18 -20
- package/dist/scriptable-pack-node.mjs.map +1 -1
- package/dist/scriptable-pack.d.ts +3 -2
- package/dist/scriptable-pack.d.ts.map +1 -1
- package/dist/scriptable-pack.mjs +19 -23
- package/dist/scriptable-pack.mjs.map +1 -1
- package/package.json +2 -7
- package/schema/pack.schema.json +1 -1
- package/src/__tests__/material-cook-receipt-layer-plan.unit.test.ts +16 -0
- package/src/__tests__/material-cook-schema.unit.test.ts +62 -0
- package/src/__tests__/material-declaration-boundary.unit.test.ts +35 -0
- package/src/__tests__/material-surface-consumer-census.test.ts +24 -0
- package/src/__tests__/material-surface-publication.unit.test.ts +159 -0
- package/src/__tests__/material-surface-wire.unit.test.ts +30 -0
- package/src/__tests__/{parameterized-pack-authoring-gateway.unit.test.ts → pack-authoring-gateway.unit.test.ts} +9 -9
- package/src/__tests__/{parameterized-pack.unit.test.ts → pack-authoring.unit.test.ts} +10 -10
- package/src/__tests__/{parameterized-pack-scanner.unit.test.ts → pack-scanner.unit.test.ts} +6 -6
- package/src/__tests__/scanner-inventory.contract.test.ts +2 -4
- package/src/__tests__/scanner-inventory.test.ts +7 -6
- package/src/__tests__/scriptable-pack-cli.integration.test.ts +1 -1
- package/src/build.ts +10 -8
- package/src/catalog-builder.ts +3 -3
- package/src/cli-asset.ts +5 -5
- package/src/evidence/material-cook.ts +170 -7
- package/src/evidence/source-inventory.ts +3 -3
- package/src/index.ts +6 -1
- package/src/material-cook.ts +3 -0
- package/src/{parameterized-pack-node.ts → pack-authoring-node.ts} +71 -73
- package/src/{parameterized-pack.ts → pack-authoring.ts} +59 -74
- package/src/scanner.ts +33 -31
- package/src/schema/material-cook.schema.json +47 -1
- package/src/scriptable-pack-node.ts +25 -25
- package/src/scriptable-pack.ts +3 -2
- package/dist/__tests__/ai-recovery.unit.test.d.ts +0 -2
- package/dist/__tests__/ai-recovery.unit.test.d.ts.map +0 -1
- package/dist/__tests__/artifact-path.test.d.ts +0 -2
- package/dist/__tests__/artifact-path.test.d.ts.map +0 -1
- package/dist/__tests__/asset-evidence-error-hints.test.d.ts +0 -2
- package/dist/__tests__/asset-evidence-error-hints.test.d.ts.map +0 -1
- package/dist/__tests__/asset-evidence-lifecycle.test.d.ts +0 -2
- package/dist/__tests__/asset-evidence-lifecycle.test.d.ts.map +0 -1
- package/dist/__tests__/asset-evidence-schema.test.d.ts +0 -2
- package/dist/__tests__/asset-evidence-schema.test.d.ts.map +0 -1
- package/dist/__tests__/atlas-cli-region-mismatch.test.d.ts +0 -2
- package/dist/__tests__/atlas-cli-region-mismatch.test.d.ts.map +0 -1
- package/dist/__tests__/atlas-error-code-owner.test-d.d.ts +0 -2
- package/dist/__tests__/atlas-error-code-owner.test-d.d.ts.map +0 -1
- package/dist/__tests__/cli-asset-evidence.integration.test.d.ts +0 -2
- package/dist/__tests__/cli-asset-evidence.integration.test.d.ts.map +0 -1
- package/dist/__tests__/cli.unit.test.d.ts +0 -2
- package/dist/__tests__/cli.unit.test.d.ts.map +0 -1
- package/dist/__tests__/evidence-source-inventory.unit.test.d.ts +0 -2
- package/dist/__tests__/evidence-source-inventory.unit.test.d.ts.map +0 -1
- package/dist/__tests__/guid-collision.unit.test.d.ts +0 -2
- package/dist/__tests__/guid-collision.unit.test.d.ts.map +0 -1
- package/dist/__tests__/guid-validator-surface.unit.test.d.ts +0 -2
- package/dist/__tests__/guid-validator-surface.unit.test.d.ts.map +0 -1
- package/dist/__tests__/inventory-schema.test.d.ts +0 -2
- package/dist/__tests__/inventory-schema.test.d.ts.map +0 -1
- package/dist/__tests__/material-cook-dependencies.unit.test.d.ts +0 -2
- package/dist/__tests__/material-cook-dependencies.unit.test.d.ts.map +0 -1
- package/dist/__tests__/material-cook-receipt.unit.test.d.ts +0 -2
- package/dist/__tests__/material-cook-receipt.unit.test.d.ts.map +0 -1
- package/dist/__tests__/material-cook-schema.unit.test.d.ts +0 -2
- package/dist/__tests__/material-cook-schema.unit.test.d.ts.map +0 -1
- package/dist/__tests__/mesh-bin-consumer-surface.unit.test.d.ts +0 -2
- package/dist/__tests__/mesh-bin-consumer-surface.unit.test.d.ts.map +0 -1
- package/dist/__tests__/mesh-bin-contract.unit.test.d.ts +0 -2
- package/dist/__tests__/mesh-bin-contract.unit.test.d.ts.map +0 -1
- package/dist/__tests__/meta-schema-optional.test.d.ts +0 -2
- package/dist/__tests__/meta-schema-optional.test.d.ts.map +0 -1
- package/dist/__tests__/meta-source-overrides.unit.test.d.ts +0 -2
- package/dist/__tests__/meta-source-overrides.unit.test.d.ts.map +0 -1
- package/dist/__tests__/native-cooker-registry.test.d.ts +0 -2
- package/dist/__tests__/native-cooker-registry.test.d.ts.map +0 -1
- package/dist/__tests__/offline-evidence-artifact-verification-owner.test-d.d.ts +0 -2
- package/dist/__tests__/offline-evidence-artifact-verification-owner.test-d.d.ts.map +0 -1
- package/dist/__tests__/offline-evidence.integration.test.d.ts +0 -2
- package/dist/__tests__/offline-evidence.integration.test.d.ts.map +0 -1
- package/dist/__tests__/owner-chain.integration.test.d.ts +0 -2
- package/dist/__tests__/owner-chain.integration.test.d.ts.map +0 -1
- package/dist/__tests__/pack-v2-fixture-migration.test.d.ts +0 -2
- package/dist/__tests__/pack-v2-fixture-migration.test.d.ts.map +0 -1
- package/dist/__tests__/pack-v2-schema.test.d.ts +0 -2
- package/dist/__tests__/pack-v2-schema.test.d.ts.map +0 -1
- package/dist/__tests__/pack.unit.test.d.ts +0 -2
- package/dist/__tests__/pack.unit.test.d.ts.map +0 -1
- package/dist/__tests__/package-finalizer.contract.test.d.ts +0 -2
- package/dist/__tests__/package-finalizer.contract.test.d.ts.map +0 -1
- package/dist/__tests__/parameterized-pack-authoring-gateway.unit.test.d.ts +0 -2
- package/dist/__tests__/parameterized-pack-authoring-gateway.unit.test.d.ts.map +0 -1
- package/dist/__tests__/parameterized-pack-scanner.unit.test.d.ts +0 -2
- package/dist/__tests__/parameterized-pack-scanner.unit.test.d.ts.map +0 -1
- package/dist/__tests__/parameterized-pack.unit.test.d.ts +0 -2
- package/dist/__tests__/parameterized-pack.unit.test.d.ts.map +0 -1
- package/dist/__tests__/producer-contract-schema.unit.test.d.ts +0 -2
- package/dist/__tests__/producer-contract-schema.unit.test.d.ts.map +0 -1
- package/dist/__tests__/resolve-asset-source.test.d.ts +0 -2
- package/dist/__tests__/resolve-asset-source.test.d.ts.map +0 -1
- package/dist/__tests__/runtime-projection.unit.test.d.ts +0 -2
- package/dist/__tests__/runtime-projection.unit.test.d.ts.map +0 -1
- package/dist/__tests__/runtime.browser.test.d.ts +0 -2
- package/dist/__tests__/runtime.browser.test.d.ts.map +0 -1
- package/dist/__tests__/scanner-blacklist.test.d.ts +0 -2
- package/dist/__tests__/scanner-blacklist.test.d.ts.map +0 -1
- package/dist/__tests__/scanner-inventory.contract.test.d.ts +0 -2
- package/dist/__tests__/scanner-inventory.contract.test.d.ts.map +0 -1
- package/dist/__tests__/scanner-inventory.test.d.ts +0 -2
- package/dist/__tests__/scanner-inventory.test.d.ts.map +0 -1
- package/dist/__tests__/scanner-mount-cycle.test.d.ts +0 -2
- package/dist/__tests__/scanner-mount-cycle.test.d.ts.map +0 -1
- package/dist/__tests__/scriptable-pack-cli.integration.test.d.ts +0 -2
- package/dist/__tests__/scriptable-pack-cli.integration.test.d.ts.map +0 -1
- package/dist/__tests__/scriptable-pack-ddc-key.unit.test.d.ts +0 -2
- package/dist/__tests__/scriptable-pack-ddc-key.unit.test.d.ts.map +0 -1
- package/dist/__tests__/topology-actions.unit.test.d.ts +0 -2
- package/dist/__tests__/topology-actions.unit.test.d.ts.map +0 -1
- package/dist/__tests__/topology.unit.test.d.ts +0 -2
- package/dist/__tests__/topology.unit.test.d.ts.map +0 -1
- package/dist/parameterized-pack-node.d.ts.map +0 -1
- package/dist/parameterized-pack-node.mjs.map +0 -1
- package/dist/parameterized-pack.d.ts.map +0 -1
|
@@ -5,26 +5,26 @@ import type { AssetGuid as EngineAssetGuid, Result } from '@forgeax/engine-types
|
|
|
5
5
|
import { err, ok } from '@forgeax/engine-types';
|
|
6
6
|
import { AssetGuid, isValidAssetGuidString, isValidPackSourceKey, PackageId } from './guid.js';
|
|
7
7
|
import {
|
|
8
|
-
type
|
|
9
|
-
|
|
8
|
+
type AnyScriptablePackDefinition,
|
|
9
|
+
createPackAuthoringGateway,
|
|
10
10
|
type DirectPackJsonAsset,
|
|
11
11
|
type PackAuthoringError,
|
|
12
12
|
type PackAuthoringErrorCode,
|
|
13
|
+
type PackAuthoringGatewayPort,
|
|
14
|
+
type PackAuthoringOperation,
|
|
15
|
+
type PackAuthoringOperationResult,
|
|
16
|
+
type PackAuthoringResolutionStatus,
|
|
13
17
|
type PackParameterDefinition,
|
|
14
18
|
type PackParameterInheritanceSubject,
|
|
15
|
-
|
|
16
|
-
type ParameterizedPackOperation,
|
|
17
|
-
type ParameterizedPackOperationResult,
|
|
18
|
-
type ParameterizedPackResolutionStatus,
|
|
19
|
-
parseParameterizedPackJson,
|
|
19
|
+
parsePackSourceJson,
|
|
20
20
|
projectDirectPackJson,
|
|
21
21
|
type ResolvedPackParameterInheritance,
|
|
22
22
|
resolvePackParameterInheritance,
|
|
23
23
|
validatePackDefinition,
|
|
24
|
-
} from './
|
|
24
|
+
} from './pack-authoring.js';
|
|
25
25
|
import { type ScanInventory, scanInventory } from './scanner.js';
|
|
26
26
|
|
|
27
|
-
export interface
|
|
27
|
+
export interface PackAuthoringMaterializedAsset {
|
|
28
28
|
readonly packageId: string;
|
|
29
29
|
readonly sourceKey: string;
|
|
30
30
|
readonly guid: string;
|
|
@@ -35,13 +35,13 @@ export interface ParameterizedPackMaterializedAsset {
|
|
|
35
35
|
readonly artifactsReady?: boolean;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export interface
|
|
38
|
+
export interface FileSystemPackAuthoringOptions {
|
|
39
39
|
readonly gameRoot: string;
|
|
40
40
|
readonly scanRoots?: readonly string[];
|
|
41
41
|
/** Current-generation rows only; this callback is never called by mutations. */
|
|
42
42
|
readonly materialized?: () =>
|
|
43
|
-
| readonly
|
|
44
|
-
| Promise<readonly
|
|
43
|
+
| readonly PackAuthoringMaterializedAsset[]
|
|
44
|
+
| Promise<readonly PackAuthoringMaterializedAsset[]>;
|
|
45
45
|
/** Build owner callback; the gateway itself does not own DDC or Catalog state. */
|
|
46
46
|
readonly rebuild?: (
|
|
47
47
|
sourcePath: string,
|
|
@@ -69,7 +69,7 @@ interface SubjectBase {
|
|
|
69
69
|
|
|
70
70
|
interface SourceSubject extends SubjectBase {
|
|
71
71
|
readonly format: 'source';
|
|
72
|
-
readonly definition:
|
|
72
|
+
readonly definition: AnyScriptablePackDefinition;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
interface DirectSubject extends SubjectBase {
|
|
@@ -145,7 +145,7 @@ function pathError(
|
|
|
145
145
|
| 'pack-source-not-found'
|
|
146
146
|
| 'pack-source-write-failed'
|
|
147
147
|
| 'pack-source-revision-conflict',
|
|
148
|
-
operation:
|
|
148
|
+
operation: PackAuthoringOperation,
|
|
149
149
|
expected: string,
|
|
150
150
|
hint: string,
|
|
151
151
|
detail: Readonly<Record<string, unknown>> = {},
|
|
@@ -157,7 +157,7 @@ function pathError(
|
|
|
157
157
|
function confinedPath(
|
|
158
158
|
gameRoot: string,
|
|
159
159
|
candidate: unknown,
|
|
160
|
-
operation:
|
|
160
|
+
operation: PackAuthoringOperation,
|
|
161
161
|
): Result<ConfinedPath, PackAuthoringError> {
|
|
162
162
|
if (typeof candidate !== 'string' || candidate.length === 0 || isAbsolute(candidate)) {
|
|
163
163
|
return err(
|
|
@@ -217,7 +217,7 @@ function parsePackageId(value: unknown): PackageId | undefined {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
function serializedParameters(
|
|
220
|
-
definition:
|
|
220
|
+
definition: AnyScriptablePackDefinition,
|
|
221
221
|
): readonly Readonly<Record<string, unknown>>[] | undefined {
|
|
222
222
|
if (!('parameters' in definition)) return undefined;
|
|
223
223
|
return definition.parameters.map((parameter) => ({
|
|
@@ -233,8 +233,8 @@ function serializedParameters(
|
|
|
233
233
|
|
|
234
234
|
function sourceResult(
|
|
235
235
|
subject: Subject,
|
|
236
|
-
operation:
|
|
237
|
-
):
|
|
236
|
+
operation: PackAuthoringOperation,
|
|
237
|
+
): PackAuthoringOperationResult {
|
|
238
238
|
const base = {
|
|
239
239
|
operation: operation.operation,
|
|
240
240
|
requestId: operation.requestId,
|
|
@@ -277,7 +277,7 @@ function sourceResult(
|
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
function scanFailure(operation:
|
|
280
|
+
function scanFailure(operation: PackAuthoringOperation, cause: unknown): PackAuthoringError {
|
|
281
281
|
const value =
|
|
282
282
|
cause !== null && typeof cause === 'object' ? (cause as Record<string, unknown>) : {};
|
|
283
283
|
const detail = value.detail !== null && typeof value.detail === 'object' ? value.detail : {};
|
|
@@ -285,7 +285,7 @@ function scanFailure(operation: ParameterizedPackOperation, cause: unknown): Pac
|
|
|
285
285
|
const code: PackAuthoringErrorCode =
|
|
286
286
|
reason === 'pack-parent-not-found' ||
|
|
287
287
|
reason === 'pack-parent-cycle' ||
|
|
288
|
-
reason === 'pack-parent-
|
|
288
|
+
reason === 'pack-parent-has-no-parameters'
|
|
289
289
|
? reason
|
|
290
290
|
: value.code === 'pack-guid-collision'
|
|
291
291
|
? 'pack-guid-collision'
|
|
@@ -300,15 +300,15 @@ function scanFailure(operation: ParameterizedPackOperation, cause: unknown): Pac
|
|
|
300
300
|
);
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
function scanRoots(options:
|
|
303
|
+
function scanRoots(options: FileSystemPackAuthoringOptions): readonly string[] {
|
|
304
304
|
return options.scanRoots === undefined || options.scanRoots.length === 0
|
|
305
305
|
? [resolve(options.gameRoot)]
|
|
306
306
|
: options.scanRoots.map((root) => resolve(options.gameRoot, root));
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
async function readMaterialized(
|
|
310
|
-
options:
|
|
311
|
-
operation:
|
|
310
|
+
options: FileSystemPackAuthoringOptions,
|
|
311
|
+
operation: PackAuthoringOperation,
|
|
312
312
|
): Promise<Result<readonly MaterializedAsset[], PackAuthoringError>> {
|
|
313
313
|
let rawRows: unknown;
|
|
314
314
|
try {
|
|
@@ -350,7 +350,7 @@ async function readMaterialized(
|
|
|
350
350
|
),
|
|
351
351
|
);
|
|
352
352
|
}
|
|
353
|
-
const row = rawRow as unknown as
|
|
353
|
+
const row = rawRow as unknown as PackAuthoringMaterializedAsset;
|
|
354
354
|
const parsedPackageId = parsePackageId(row.packageId);
|
|
355
355
|
if (parsedPackageId === undefined) {
|
|
356
356
|
return err(
|
|
@@ -474,8 +474,8 @@ async function readMaterialized(
|
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
async function createSnapshot(
|
|
477
|
-
options:
|
|
478
|
-
operation:
|
|
477
|
+
options: FileSystemPackAuthoringOptions,
|
|
478
|
+
operation: PackAuthoringOperation,
|
|
479
479
|
): Promise<Result<GatewaySnapshot, PackAuthoringError>> {
|
|
480
480
|
const scanned =
|
|
481
481
|
options.inventory === undefined
|
|
@@ -486,7 +486,7 @@ async function createSnapshot(
|
|
|
486
486
|
const directAssets: DirectAuthorAsset[] = [];
|
|
487
487
|
for (const [sourcePath, declaration] of scanned.value.declarations) {
|
|
488
488
|
const relativePath = relative(resolve(options.gameRoot), sourcePath).split(sep).join('/');
|
|
489
|
-
if (declaration.format === 'pack.ts
|
|
489
|
+
if (declaration.format === 'pack.ts') {
|
|
490
490
|
subjects.set(packageKey(declaration.definition.packageId), {
|
|
491
491
|
format: 'source',
|
|
492
492
|
packageId: declaration.definition.packageId,
|
|
@@ -497,7 +497,7 @@ async function createSnapshot(
|
|
|
497
497
|
continue;
|
|
498
498
|
}
|
|
499
499
|
if (declaration.format !== 'pack.json' || declaration.value.schemaVersion !== '3.0.0') continue;
|
|
500
|
-
const parsed =
|
|
500
|
+
const parsed = parsePackSourceJson(declaration.value);
|
|
501
501
|
if (!parsed.ok) return err(parsed.error);
|
|
502
502
|
if (parsed.value.format === 'direct') {
|
|
503
503
|
const projected = projectDirectPackJson(parsed.value);
|
|
@@ -637,7 +637,7 @@ async function resolveInstance(
|
|
|
637
637
|
function subjectFor(
|
|
638
638
|
gameRoot: string,
|
|
639
639
|
snapshot: GatewaySnapshot,
|
|
640
|
-
operation:
|
|
640
|
+
operation: PackAuthoringOperation,
|
|
641
641
|
): Result<Subject, PackAuthoringError> {
|
|
642
642
|
if (operation.sourcePath !== undefined) {
|
|
643
643
|
const confined = confinedPath(gameRoot, operation.sourcePath, operation);
|
|
@@ -748,8 +748,8 @@ function subjectFor(
|
|
|
748
748
|
async function inspectAsset(
|
|
749
749
|
gameRoot: string,
|
|
750
750
|
snapshot: GatewaySnapshot,
|
|
751
|
-
operation:
|
|
752
|
-
): Promise<Result<
|
|
751
|
+
operation: PackAuthoringOperation,
|
|
752
|
+
): Promise<Result<PackAuthoringOperationResult, PackAuthoringError>> {
|
|
753
753
|
const selected = subjectFor(gameRoot, snapshot, operation);
|
|
754
754
|
if (!selected.ok) return selected;
|
|
755
755
|
const subject = selected.value;
|
|
@@ -852,8 +852,8 @@ async function inspectAsset(
|
|
|
852
852
|
|
|
853
853
|
function listAssets(
|
|
854
854
|
snapshot: GatewaySnapshot,
|
|
855
|
-
operation:
|
|
856
|
-
):
|
|
855
|
+
operation: PackAuthoringOperation,
|
|
856
|
+
): PackAuthoringOperationResult {
|
|
857
857
|
const assets = snapshotAssets(snapshot)
|
|
858
858
|
.map((asset) => ({
|
|
859
859
|
packageId: asset.packageId,
|
|
@@ -936,8 +936,8 @@ function assetForPair(
|
|
|
936
936
|
async function resolveAsset(
|
|
937
937
|
gameRoot: string,
|
|
938
938
|
snapshot: GatewaySnapshot,
|
|
939
|
-
operation:
|
|
940
|
-
): Promise<Result<
|
|
939
|
+
operation: PackAuthoringOperation,
|
|
940
|
+
): Promise<Result<PackAuthoringOperationResult, PackAuthoringError>> {
|
|
941
941
|
if (
|
|
942
942
|
operation.require !== undefined &&
|
|
943
943
|
operation.require !== 'identity' &&
|
|
@@ -1125,7 +1125,7 @@ async function resolveAsset(
|
|
|
1125
1125
|
(candidate) =>
|
|
1126
1126
|
candidate.packageId === packageKey(packageId) && candidate.sourceKey === sourceKey,
|
|
1127
1127
|
);
|
|
1128
|
-
const requirement:
|
|
1128
|
+
const requirement: PackAuthoringResolutionStatus = operation.require ?? 'identity';
|
|
1129
1129
|
if (requirement === 'present' && materialized === undefined) {
|
|
1130
1130
|
return err(
|
|
1131
1131
|
makeError(
|
|
@@ -1174,8 +1174,8 @@ async function resolveAsset(
|
|
|
1174
1174
|
|
|
1175
1175
|
async function verify(
|
|
1176
1176
|
snapshot: GatewaySnapshot,
|
|
1177
|
-
operation:
|
|
1178
|
-
): Promise<Result<
|
|
1177
|
+
operation: PackAuthoringOperation,
|
|
1178
|
+
): Promise<Result<PackAuthoringOperationResult, PackAuthoringError>> {
|
|
1179
1179
|
for (const subject of snapshot.subjects.values()) {
|
|
1180
1180
|
if (subject.format === 'instance') {
|
|
1181
1181
|
const resolved = await resolveInstance(snapshot, subject);
|
|
@@ -1232,7 +1232,7 @@ async function verify(
|
|
|
1232
1232
|
|
|
1233
1233
|
function packageIdFromOperation(
|
|
1234
1234
|
snapshot: GatewaySnapshot,
|
|
1235
|
-
operation:
|
|
1235
|
+
operation: PackAuthoringOperation,
|
|
1236
1236
|
): Result<PackageId, PackAuthoringError> {
|
|
1237
1237
|
const value =
|
|
1238
1238
|
operation.packageId === undefined
|
|
@@ -1264,8 +1264,8 @@ function packageIdFromOperation(
|
|
|
1264
1264
|
}
|
|
1265
1265
|
|
|
1266
1266
|
async function readConfined(
|
|
1267
|
-
options:
|
|
1268
|
-
operation:
|
|
1267
|
+
options: FileSystemPackAuthoringOptions,
|
|
1268
|
+
operation: PackAuthoringOperation,
|
|
1269
1269
|
sourcePath: unknown,
|
|
1270
1270
|
): Promise<
|
|
1271
1271
|
Result<ConfinedPath & { readonly source: string; readonly revision: string }, PackAuthoringError>
|
|
@@ -1297,7 +1297,7 @@ async function readConfined(
|
|
|
1297
1297
|
}
|
|
1298
1298
|
|
|
1299
1299
|
function revisionConflict(
|
|
1300
|
-
operation:
|
|
1300
|
+
operation: PackAuthoringOperation,
|
|
1301
1301
|
path: string,
|
|
1302
1302
|
actual: string,
|
|
1303
1303
|
): PackAuthoringError {
|
|
@@ -1322,7 +1322,7 @@ function directJson(
|
|
|
1322
1322
|
return { schemaVersion: '3.0.0', packageId: PackageId.format(packageId), assets };
|
|
1323
1323
|
}
|
|
1324
1324
|
|
|
1325
|
-
function
|
|
1325
|
+
function packSourceScaffold(
|
|
1326
1326
|
packageId: PackageId,
|
|
1327
1327
|
parameters: readonly PackParameterDefinition[] | undefined,
|
|
1328
1328
|
): string {
|
|
@@ -1359,12 +1359,12 @@ function replacePackageIdLiteral(source: string, packageId: string): string | un
|
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
1361
|
async function inspectAfterWrite(
|
|
1362
|
-
operation:
|
|
1362
|
+
operation: PackAuthoringOperation,
|
|
1363
1363
|
path: ConfinedPath,
|
|
1364
1364
|
source: string,
|
|
1365
1365
|
packageId: PackageId,
|
|
1366
|
-
extra: Partial<
|
|
1367
|
-
): Promise<Result<
|
|
1366
|
+
extra: Partial<PackAuthoringOperationResult> = {},
|
|
1367
|
+
): Promise<Result<PackAuthoringOperationResult, PackAuthoringError>> {
|
|
1368
1368
|
return ok({
|
|
1369
1369
|
operation: operation.operation,
|
|
1370
1370
|
requestId: operation.requestId,
|
|
@@ -1377,9 +1377,9 @@ async function inspectAfterWrite(
|
|
|
1377
1377
|
}
|
|
1378
1378
|
|
|
1379
1379
|
async function executeRaw(
|
|
1380
|
-
options:
|
|
1381
|
-
operation:
|
|
1382
|
-
): Promise<Result<
|
|
1380
|
+
options: FileSystemPackAuthoringOptions,
|
|
1381
|
+
operation: PackAuthoringOperation,
|
|
1382
|
+
): Promise<Result<PackAuthoringOperationResult, PackAuthoringError>> {
|
|
1383
1383
|
if (operation.operation === 'asset.list' || operation.operation === 'asset.inspect') {
|
|
1384
1384
|
const snapshot = await createSnapshot(options, operation);
|
|
1385
1385
|
if (!snapshot.ok) return snapshot;
|
|
@@ -1443,7 +1443,7 @@ async function executeRaw(
|
|
|
1443
1443
|
);
|
|
1444
1444
|
}
|
|
1445
1445
|
let source: string;
|
|
1446
|
-
let extra: Partial<
|
|
1446
|
+
let extra: Partial<PackAuthoringOperationResult> = { format };
|
|
1447
1447
|
if (format === 'pack.json') {
|
|
1448
1448
|
if (
|
|
1449
1449
|
operation.parameters !== undefined ||
|
|
@@ -1455,13 +1455,13 @@ async function executeRaw(
|
|
|
1455
1455
|
makeError(
|
|
1456
1456
|
'pack-parameter-invalid',
|
|
1457
1457
|
'direct create to contain assets only',
|
|
1458
|
-
'use pack.ts for a
|
|
1458
|
+
'use pack.ts for a ScriptablePack source or create-instance for parent+values',
|
|
1459
1459
|
{ requestId: operation.requestId },
|
|
1460
1460
|
),
|
|
1461
1461
|
);
|
|
1462
1462
|
}
|
|
1463
1463
|
const assets = operation.initialAssets ?? {};
|
|
1464
|
-
const parsed =
|
|
1464
|
+
const parsed = parsePackSourceJson(directJson(identity.value, assets));
|
|
1465
1465
|
if (!parsed.ok) return err(parsed.error);
|
|
1466
1466
|
if (parsed.value.format !== 'direct') {
|
|
1467
1467
|
return err(
|
|
@@ -1523,7 +1523,7 @@ async function executeRaw(
|
|
|
1523
1523
|
}
|
|
1524
1524
|
parameters = validated.value.parameters;
|
|
1525
1525
|
}
|
|
1526
|
-
source =
|
|
1526
|
+
source = packSourceScaffold(identity.value, parameters);
|
|
1527
1527
|
const serialized =
|
|
1528
1528
|
parameters === undefined
|
|
1529
1529
|
? undefined
|
|
@@ -1532,7 +1532,7 @@ async function executeRaw(
|
|
|
1532
1532
|
packageId: identity.value,
|
|
1533
1533
|
parameters,
|
|
1534
1534
|
build: () => ok({}),
|
|
1535
|
-
} as
|
|
1535
|
+
} as AnyScriptablePackDefinition);
|
|
1536
1536
|
extra = {
|
|
1537
1537
|
format,
|
|
1538
1538
|
...(serialized === undefined ? {} : { parameters: serialized }),
|
|
@@ -1626,7 +1626,7 @@ async function executeRaw(
|
|
|
1626
1626
|
),
|
|
1627
1627
|
);
|
|
1628
1628
|
}
|
|
1629
|
-
const parsed =
|
|
1629
|
+
const parsed = parsePackSourceJson(parsedValue);
|
|
1630
1630
|
if (!parsed.ok) return err(parsed.error);
|
|
1631
1631
|
source = `${JSON.stringify(
|
|
1632
1632
|
parsed.value.format === 'direct'
|
|
@@ -1688,7 +1688,7 @@ async function executeRaw(
|
|
|
1688
1688
|
makeError(
|
|
1689
1689
|
'pack-parent-not-found',
|
|
1690
1690
|
'a parent packageId for the new instance',
|
|
1691
|
-
'pass parentPackageId or parent and point it at a
|
|
1691
|
+
'pass parentPackageId or parent and point it at a ScriptablePack source with parameters',
|
|
1692
1692
|
{ requestId: operation.requestId },
|
|
1693
1693
|
),
|
|
1694
1694
|
);
|
|
@@ -1711,7 +1711,7 @@ async function executeRaw(
|
|
|
1711
1711
|
makeError(
|
|
1712
1712
|
'pack-parent-not-found',
|
|
1713
1713
|
'the parent packageId to exist in the current Source Index',
|
|
1714
|
-
'inspect the Source Index and choose a
|
|
1714
|
+
'inspect the Source Index and choose a ScriptablePack parent with parameters',
|
|
1715
1715
|
{ requestId: operation.requestId, parent: parentText },
|
|
1716
1716
|
),
|
|
1717
1717
|
);
|
|
@@ -1719,8 +1719,8 @@ async function executeRaw(
|
|
|
1719
1719
|
if (parent.format === 'source' && !('parameters' in parent.definition)) {
|
|
1720
1720
|
return err(
|
|
1721
1721
|
makeError(
|
|
1722
|
-
'pack-parent-
|
|
1723
|
-
'a non-empty
|
|
1722
|
+
'pack-parent-has-no-parameters',
|
|
1723
|
+
'a ScriptablePack source with a non-empty parameter list as the parent',
|
|
1724
1724
|
'use asset-source.clone for a zero-parameter Pack',
|
|
1725
1725
|
{ requestId: operation.requestId, parent: parentText },
|
|
1726
1726
|
),
|
|
@@ -1729,8 +1729,8 @@ async function executeRaw(
|
|
|
1729
1729
|
if (parent.format === 'direct') {
|
|
1730
1730
|
return err(
|
|
1731
1731
|
makeError(
|
|
1732
|
-
'pack-parent-
|
|
1733
|
-
'a
|
|
1732
|
+
'pack-parent-has-no-parameters',
|
|
1733
|
+
'a ScriptablePack source or instance with parameters as the parent',
|
|
1734
1734
|
'direct Packs cannot be instance parents',
|
|
1735
1735
|
{ requestId: operation.requestId, parent: parentText },
|
|
1736
1736
|
),
|
|
@@ -1836,7 +1836,7 @@ async function executeRaw(
|
|
|
1836
1836
|
),
|
|
1837
1837
|
);
|
|
1838
1838
|
}
|
|
1839
|
-
const parsed =
|
|
1839
|
+
const parsed = parsePackSourceJson(json);
|
|
1840
1840
|
if (!parsed.ok) return err(parsed.error);
|
|
1841
1841
|
if (parsed.value.format !== 'instance') {
|
|
1842
1842
|
return err(
|
|
@@ -1946,23 +1946,21 @@ async function executeRaw(
|
|
|
1946
1946
|
return err(
|
|
1947
1947
|
makeError(
|
|
1948
1948
|
'pack-parameter-invalid',
|
|
1949
|
-
'a supported
|
|
1950
|
-
'use one of
|
|
1949
|
+
'a supported Pack authoring operation',
|
|
1950
|
+
'use one of PACK_AUTHORING_OPERATION_IDS',
|
|
1951
1951
|
{ requestId: operation.requestId, operation: operation.operation },
|
|
1952
1952
|
),
|
|
1953
1953
|
);
|
|
1954
1954
|
}
|
|
1955
1955
|
|
|
1956
|
-
export function
|
|
1957
|
-
options:
|
|
1958
|
-
):
|
|
1956
|
+
export function createFileSystemPackAuthoringPort(
|
|
1957
|
+
options: FileSystemPackAuthoringOptions,
|
|
1958
|
+
): PackAuthoringGatewayPort<PackAuthoringOperationResult> {
|
|
1959
1959
|
return { execute: (operation) => executeRaw(options, operation) };
|
|
1960
1960
|
}
|
|
1961
1961
|
|
|
1962
|
-
export function
|
|
1963
|
-
options:
|
|
1964
|
-
):
|
|
1965
|
-
return
|
|
1966
|
-
createFileSystemParameterizedPackAuthoringPort(options),
|
|
1967
|
-
);
|
|
1962
|
+
export function createFileSystemPackAuthoringGateway(
|
|
1963
|
+
options: FileSystemPackAuthoringOptions,
|
|
1964
|
+
): PackAuthoringGatewayPort<PackAuthoringOperationResult> {
|
|
1965
|
+
return createPackAuthoringGateway(createFileSystemPackAuthoringPort(options));
|
|
1968
1966
|
}
|