@forgeax/engine-pack 0.1.23 → 0.1.24
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/__tests__/material-cook-receipt-layer-plan.unit.test.d.ts +2 -0
- package/dist/__tests__/material-cook-receipt-layer-plan.unit.test.d.ts.map +1 -0
- package/dist/__tests__/pack-authoring-gateway.unit.test.d.ts +2 -0
- package/dist/__tests__/pack-authoring-gateway.unit.test.d.ts.map +1 -0
- package/dist/__tests__/pack-authoring.unit.test.d.ts +2 -0
- package/dist/__tests__/pack-authoring.unit.test.d.ts.map +1 -0
- package/dist/__tests__/pack-scanner.unit.test.d.ts +2 -0
- package/dist/__tests__/pack-scanner.unit.test.d.ts.map +1 -0
- package/dist/build.d.ts +3 -3
- package/dist/build.d.ts.map +1 -1
- package/dist/build.mjs +331 -290
- 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 +11 -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 +69 -26
- 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 +50 -3
- 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 +8 -8
- package/dist/scanner.d.ts.map +1 -1
- package/dist/scanner.mjs +29 -31
- 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__/{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 +8 -8
- package/src/catalog-builder.ts +3 -3
- package/src/cli-asset.ts +5 -5
- package/src/evidence/material-cook.ts +79 -3
- package/src/evidence/source-inventory.ts +3 -3
- package/src/index.ts +4 -1
- package/src/material-cook.ts +1 -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 +26 -28
- package/src/schema/material-cook.schema.json +4 -1
- package/src/scriptable-pack-node.ts +25 -25
- package/src/scriptable-pack.ts +3 -2
- 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/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
|
@@ -100,7 +100,7 @@ export type PackAuthoringErrorCode =
|
|
|
100
100
|
| 'pack-guid-collision'
|
|
101
101
|
| 'pack-parent-not-found'
|
|
102
102
|
| 'pack-parent-cycle'
|
|
103
|
-
| 'pack-parent-
|
|
103
|
+
| 'pack-parent-has-no-parameters'
|
|
104
104
|
| 'pack-parameter-invalid'
|
|
105
105
|
| 'pack-content-dependency-stalled'
|
|
106
106
|
| 'pack-output-reference-missing'
|
|
@@ -601,7 +601,7 @@ interface PackDefinitionBase {
|
|
|
601
601
|
readonly sceneComponents?: readonly ScriptablePackSceneComponentInput[];
|
|
602
602
|
}
|
|
603
603
|
|
|
604
|
-
export type
|
|
604
|
+
export type ScriptablePackDefinition<
|
|
605
605
|
TParameters extends readonly PackParameterDefinition[] | undefined = undefined,
|
|
606
606
|
> = PackDefinitionBase &
|
|
607
607
|
(TParameters extends readonly PackParameterDefinition[]
|
|
@@ -613,17 +613,13 @@ export type ParameterizedPackDefinition<
|
|
|
613
613
|
readonly build: (context: PackBuildContextWithoutParameters) => PackBuildResult;
|
|
614
614
|
});
|
|
615
615
|
|
|
616
|
-
export type PackDefinition =
|
|
617
|
-
| ParameterizedPackDefinition<undefined>
|
|
618
|
-
| ParameterizedPackDefinition<readonly [PackParameterDefinition, ...PackParameterDefinition[]]>;
|
|
619
|
-
|
|
620
616
|
export type PackParameterList = readonly [PackParameterDefinition, ...PackParameterDefinition[]];
|
|
621
617
|
type NonEmptyParameters = PackParameterList;
|
|
622
618
|
type NoParameterPackInput = PackDefinitionBase & {
|
|
623
619
|
readonly parameters?: never;
|
|
624
620
|
readonly build: (context: PackBuildContextWithoutParameters) => PackBuildResult;
|
|
625
621
|
};
|
|
626
|
-
type
|
|
622
|
+
type ScriptablePackDefinitionInput<TParameters extends NonEmptyParameters> = PackDefinitionBase & {
|
|
627
623
|
readonly parameters: TParameters;
|
|
628
624
|
readonly build: (context: PackBuildContextWithParameters<TParameters>) => PackBuildResult;
|
|
629
625
|
};
|
|
@@ -646,10 +642,8 @@ export function definePackageId(value: string | PackageId): PackageId {
|
|
|
646
642
|
}
|
|
647
643
|
|
|
648
644
|
function cloneDefinition(
|
|
649
|
-
definition:
|
|
650
|
-
|
|
651
|
-
| ParameterizedPackDefinition<undefined>,
|
|
652
|
-
): ParameterizedPackDefinition<NonEmptyParameters> | ParameterizedPackDefinition<undefined> {
|
|
645
|
+
definition: ScriptablePackDefinition<NonEmptyParameters> | ScriptablePackDefinition<undefined>,
|
|
646
|
+
): ScriptablePackDefinition<NonEmptyParameters> | ScriptablePackDefinition<undefined> {
|
|
653
647
|
const parameters =
|
|
654
648
|
'parameters' in definition
|
|
655
649
|
? Object.freeze(
|
|
@@ -680,52 +674,50 @@ function cloneDefinition(
|
|
|
680
674
|
packageId: definition.packageId.slice() as PackageId,
|
|
681
675
|
...(parameters === undefined ? {} : { parameters }),
|
|
682
676
|
...(sceneComponents === undefined ? {} : { sceneComponents }),
|
|
683
|
-
}) as
|
|
677
|
+
}) as ScriptablePackDefinition<NonEmptyParameters> | ScriptablePackDefinition<undefined>;
|
|
684
678
|
}
|
|
685
679
|
|
|
686
680
|
/**
|
|
687
681
|
* Define the only executable authoring shape. A missing `parameters` property
|
|
688
682
|
* is meaningful: its build context has no `values` member.
|
|
689
683
|
*/
|
|
690
|
-
export function definePack(
|
|
691
|
-
definition: NoParameterPackInput,
|
|
692
|
-
): ParameterizedPackDefinition<undefined>;
|
|
684
|
+
export function definePack(definition: NoParameterPackInput): ScriptablePackDefinition<undefined>;
|
|
693
685
|
export function definePack<const TParameters extends NonEmptyParameters>(
|
|
694
|
-
definition:
|
|
695
|
-
):
|
|
686
|
+
definition: ScriptablePackDefinitionInput<TParameters>,
|
|
687
|
+
): ScriptablePackDefinition<TParameters>;
|
|
696
688
|
export function definePack(
|
|
697
|
-
definition: NoParameterPackInput |
|
|
698
|
-
):
|
|
689
|
+
definition: NoParameterPackInput | ScriptablePackDefinitionInput<NonEmptyParameters>,
|
|
690
|
+
): ScriptablePackDefinition<NonEmptyParameters> | ScriptablePackDefinition<undefined> {
|
|
699
691
|
const validated = validatePackDefinition(definition);
|
|
700
692
|
if (!validated.ok) throw Object.assign(new TypeError(validated.error.hint), validated.error);
|
|
701
693
|
return cloneDefinition(
|
|
702
694
|
validated.value as
|
|
703
|
-
|
|
|
704
|
-
|
|
|
695
|
+
| ScriptablePackDefinition<NonEmptyParameters>
|
|
696
|
+
| ScriptablePackDefinition<undefined>,
|
|
705
697
|
);
|
|
706
698
|
}
|
|
707
699
|
|
|
708
700
|
/** Union used only at orchestration boundaries that accept either source form. */
|
|
709
|
-
export type
|
|
710
|
-
|
|
|
711
|
-
|
|
|
701
|
+
export type AnyScriptablePackDefinition =
|
|
702
|
+
| ScriptablePackDefinition<PackParameterList>
|
|
703
|
+
| ScriptablePackDefinition<undefined>;
|
|
712
704
|
|
|
713
|
-
export interface
|
|
705
|
+
export interface ScriptablePackSourceMeta {
|
|
714
706
|
readonly schemaVersion: '2.0.0';
|
|
715
|
-
readonly kind: '
|
|
707
|
+
readonly kind: 'scriptable-pack-source';
|
|
716
708
|
readonly packageId: string;
|
|
717
709
|
readonly source: string;
|
|
718
710
|
readonly parameters?: readonly Readonly<Record<string, unknown>>[];
|
|
719
711
|
}
|
|
720
712
|
|
|
721
713
|
/** Ephemeral scan evidence; it intentionally contains no output GUID table. */
|
|
722
|
-
export function
|
|
723
|
-
definition:
|
|
714
|
+
export function projectScriptablePackMeta(
|
|
715
|
+
definition: AnyScriptablePackDefinition,
|
|
724
716
|
sourcePath: string,
|
|
725
|
-
):
|
|
717
|
+
): ScriptablePackSourceMeta {
|
|
726
718
|
return {
|
|
727
719
|
schemaVersion: '2.0.0',
|
|
728
|
-
kind: '
|
|
720
|
+
kind: 'scriptable-pack-source',
|
|
729
721
|
packageId: PackageId.format(definition.packageId),
|
|
730
722
|
source: sourcePath,
|
|
731
723
|
...('parameters' in definition
|
|
@@ -753,7 +745,7 @@ export function validatePackDefinition(
|
|
|
753
745
|
value: unknown,
|
|
754
746
|
sourcePath?: string,
|
|
755
747
|
): Result<
|
|
756
|
-
|
|
748
|
+
ScriptablePackDefinition<NonEmptyParameters> | ScriptablePackDefinition<undefined>,
|
|
757
749
|
PackAuthoringError
|
|
758
750
|
> {
|
|
759
751
|
if (!isRecord(value))
|
|
@@ -818,7 +810,7 @@ export function validatePackDefinition(
|
|
|
818
810
|
...(value.name === undefined ? {} : { name: value.name }),
|
|
819
811
|
...(sceneComponents.value === undefined ? {} : { sceneComponents: sceneComponents.value }),
|
|
820
812
|
build: value.build,
|
|
821
|
-
}) as
|
|
813
|
+
}) as ScriptablePackDefinition<undefined>,
|
|
822
814
|
);
|
|
823
815
|
}
|
|
824
816
|
const parameters = validateParameterDefinitions(value.parameters);
|
|
@@ -831,19 +823,19 @@ export function validatePackDefinition(
|
|
|
831
823
|
...(sceneComponents.value === undefined ? {} : { sceneComponents: sceneComponents.value }),
|
|
832
824
|
parameters: parameters.value,
|
|
833
825
|
build: value.build,
|
|
834
|
-
}) as
|
|
826
|
+
}) as ScriptablePackDefinition<NonEmptyParameters>,
|
|
835
827
|
);
|
|
836
828
|
}
|
|
837
829
|
|
|
838
|
-
export function
|
|
839
|
-
value:
|
|
840
|
-
): value is
|
|
830
|
+
export function hasPackParameters(
|
|
831
|
+
value: ScriptablePackDefinition | unknown,
|
|
832
|
+
): value is ScriptablePackDefinition<NonEmptyParameters> {
|
|
841
833
|
return isRecord(value) && Array.isArray(value.parameters) && value.parameters.length > 0;
|
|
842
834
|
}
|
|
843
835
|
|
|
844
836
|
/** Resolve defaults plus a sparse instance override with shallow replacement. */
|
|
845
837
|
export function resolvePackParameterValues(
|
|
846
|
-
definition:
|
|
838
|
+
definition: ScriptablePackDefinition<NonEmptyParameters>,
|
|
847
839
|
overrides: unknown = {},
|
|
848
840
|
inheritedValues?: Readonly<Record<string, PackParameterValue>>,
|
|
849
841
|
): Result<PackParameterValues<NonEmptyParameters>, PackAuthoringError> {
|
|
@@ -1045,9 +1037,7 @@ function parsePackJsonAsset(
|
|
|
1045
1037
|
}
|
|
1046
1038
|
|
|
1047
1039
|
/** Parse the two mutually exclusive v3 pack.json branches. */
|
|
1048
|
-
export function
|
|
1049
|
-
value: unknown,
|
|
1050
|
-
): Result<ParsedPackJson, PackAuthoringError> {
|
|
1040
|
+
export function parsePackSourceJson(value: unknown): Result<ParsedPackJson, PackAuthoringError> {
|
|
1051
1041
|
if (!isRecord(value))
|
|
1052
1042
|
return jsonError('$', 'a v3 pack.json object', value, 'document is not an object');
|
|
1053
1043
|
if (value.schemaVersion !== '3.0.0')
|
|
@@ -1127,9 +1117,6 @@ export function parseParameterizedPackJson(
|
|
|
1127
1117
|
});
|
|
1128
1118
|
}
|
|
1129
1119
|
|
|
1130
|
-
export const parsePackJson = parseParameterizedPackJson;
|
|
1131
|
-
export const parsePackAuthoringJson = parseParameterizedPackJson;
|
|
1132
|
-
|
|
1133
1120
|
export interface DirectPackAssetProjection extends DirectPackJsonAsset {
|
|
1134
1121
|
readonly guid: string;
|
|
1135
1122
|
readonly sourceKey: string;
|
|
@@ -1144,7 +1131,7 @@ export interface DirectPackProjection {
|
|
|
1144
1131
|
export function projectDirectPackJson(
|
|
1145
1132
|
value: ParsedDirectPackJson | DirectPackJson,
|
|
1146
1133
|
): Result<DirectPackProjection, PackAuthoringError> {
|
|
1147
|
-
const parsed = 'format' in value ? ok(value) :
|
|
1134
|
+
const parsed = 'format' in value ? ok(value) : parsePackSourceJson(value);
|
|
1148
1135
|
if (!parsed.ok) return parsed;
|
|
1149
1136
|
if (parsed.value.format !== 'direct') {
|
|
1150
1137
|
return failure(
|
|
@@ -1238,9 +1225,9 @@ export async function resolvePackParameterInheritance(
|
|
|
1238
1225
|
if (current.format === 'direct') {
|
|
1239
1226
|
return failure(
|
|
1240
1227
|
authoringError(
|
|
1241
|
-
'pack-parent-
|
|
1242
|
-
'a
|
|
1243
|
-
'direct packs cannot be instance parents; point the instance at a
|
|
1228
|
+
'pack-parent-has-no-parameters',
|
|
1229
|
+
'a ScriptablePack source with parameters as the parent',
|
|
1230
|
+
'direct packs cannot be instance parents; point the instance at a ScriptablePack source with parameters',
|
|
1244
1231
|
{ packageId: currentId },
|
|
1245
1232
|
),
|
|
1246
1233
|
);
|
|
@@ -1251,7 +1238,7 @@ export async function resolvePackParameterInheritance(
|
|
|
1251
1238
|
if (descriptors.value.length === 0) {
|
|
1252
1239
|
return failure(
|
|
1253
1240
|
authoringError(
|
|
1254
|
-
'pack-parent-
|
|
1241
|
+
'pack-parent-has-no-parameters',
|
|
1255
1242
|
'the parent source to declare a non-empty parameter list',
|
|
1256
1243
|
'use clone for an independent zero-parameter Pack instead of creating an empty instance',
|
|
1257
1244
|
{ packageId: currentId },
|
|
@@ -1263,7 +1250,7 @@ export async function resolvePackParameterInheritance(
|
|
|
1263
1250
|
packageId: current.packageId,
|
|
1264
1251
|
parameters: descriptors.value as NonEmptyParameters,
|
|
1265
1252
|
build: () => ok({}),
|
|
1266
|
-
} as
|
|
1253
|
+
} as ScriptablePackDefinition<NonEmptyParameters>;
|
|
1267
1254
|
const values = resolvePackParameterValues(definition);
|
|
1268
1255
|
if (!values.ok) return values;
|
|
1269
1256
|
return ok({
|
|
@@ -1280,7 +1267,7 @@ export async function resolvePackParameterInheritance(
|
|
|
1280
1267
|
authoringError(
|
|
1281
1268
|
'pack-parent-not-found',
|
|
1282
1269
|
'the parent packageId to resolve in the source index',
|
|
1283
|
-
'inspect the parent locator or recreate the instance from a live
|
|
1270
|
+
'inspect the parent locator or recreate the instance from a live ScriptablePack with parameters',
|
|
1284
1271
|
{ packageId: currentId, parent: PackageId.format(current.parent) },
|
|
1285
1272
|
),
|
|
1286
1273
|
);
|
|
@@ -1310,7 +1297,7 @@ export async function resolvePackParameterInheritance(
|
|
|
1310
1297
|
packageId: resolvedParent.value.rootPackageId,
|
|
1311
1298
|
parameters: descriptors as NonEmptyParameters,
|
|
1312
1299
|
build: () => ok({}),
|
|
1313
|
-
} as
|
|
1300
|
+
} as ScriptablePackDefinition<NonEmptyParameters>;
|
|
1314
1301
|
const values = resolvePackParameterValues(
|
|
1315
1302
|
definition,
|
|
1316
1303
|
current.values,
|
|
@@ -1331,7 +1318,7 @@ export async function resolvePackParameterInheritance(
|
|
|
1331
1318
|
|
|
1332
1319
|
export const resolvePackInheritance = resolvePackParameterInheritance;
|
|
1333
1320
|
|
|
1334
|
-
export const
|
|
1321
|
+
export const PACK_AUTHORING_OPERATION_IDS = [
|
|
1335
1322
|
'asset.list',
|
|
1336
1323
|
'asset.inspect',
|
|
1337
1324
|
'asset.resolve',
|
|
@@ -1344,12 +1331,12 @@ export const PARAMETERIZED_PACK_OPERATION_IDS = [
|
|
|
1344
1331
|
'asset-source.cold-cook',
|
|
1345
1332
|
] as const;
|
|
1346
1333
|
|
|
1347
|
-
export type
|
|
1334
|
+
export type PackAuthoringOperationId = (typeof PACK_AUTHORING_OPERATION_IDS)[number];
|
|
1348
1335
|
|
|
1349
|
-
export interface
|
|
1336
|
+
export interface PackAuthoringOperation {
|
|
1350
1337
|
readonly requestId: string;
|
|
1351
1338
|
readonly expectedRevision?: string;
|
|
1352
|
-
readonly operation:
|
|
1339
|
+
readonly operation: PackAuthoringOperationId;
|
|
1353
1340
|
readonly subject?: string;
|
|
1354
1341
|
readonly sourcePath?: string;
|
|
1355
1342
|
readonly targetPath?: string;
|
|
@@ -1370,10 +1357,10 @@ export interface ParameterizedPackOperation {
|
|
|
1370
1357
|
readonly require?: 'identity' | 'present' | 'ready';
|
|
1371
1358
|
}
|
|
1372
1359
|
|
|
1373
|
-
export type
|
|
1360
|
+
export type PackAuthoringResolutionStatus = 'identity' | 'present' | 'ready';
|
|
1374
1361
|
|
|
1375
|
-
export interface
|
|
1376
|
-
readonly operation:
|
|
1362
|
+
export interface PackAuthoringOperationResult {
|
|
1363
|
+
readonly operation: PackAuthoringOperationId;
|
|
1377
1364
|
readonly requestId: string;
|
|
1378
1365
|
readonly sourcePath?: string;
|
|
1379
1366
|
readonly targetPath?: string;
|
|
@@ -1383,7 +1370,7 @@ export interface ParameterizedPackOperationResult {
|
|
|
1383
1370
|
readonly sourceKey?: string;
|
|
1384
1371
|
readonly guid?: string;
|
|
1385
1372
|
readonly format?: 'pack.ts' | 'pack.json' | 'direct' | 'instance';
|
|
1386
|
-
readonly status?:
|
|
1373
|
+
readonly status?: PackAuthoringResolutionStatus;
|
|
1387
1374
|
readonly kind?: string;
|
|
1388
1375
|
readonly parameters?: readonly Readonly<Record<string, unknown>>[];
|
|
1389
1376
|
readonly values?: Readonly<Record<string, unknown>>;
|
|
@@ -1391,21 +1378,21 @@ export interface ParameterizedPackOperationResult {
|
|
|
1391
1378
|
readonly parentChain?: readonly string[];
|
|
1392
1379
|
readonly assets?: readonly Readonly<Record<string, unknown>>[];
|
|
1393
1380
|
readonly sources?: readonly Readonly<Record<string, unknown>>[];
|
|
1394
|
-
readonly capabilities?: readonly
|
|
1381
|
+
readonly capabilities?: readonly PackAuthoringOperationId[];
|
|
1395
1382
|
readonly snapshot?: {
|
|
1396
1383
|
readonly sourceCount: number;
|
|
1397
1384
|
readonly assetCount: number;
|
|
1398
1385
|
};
|
|
1399
1386
|
}
|
|
1400
1387
|
|
|
1401
|
-
export interface
|
|
1402
|
-
execute(operation:
|
|
1388
|
+
export interface PackAuthoringGatewayPort<TResult = unknown> {
|
|
1389
|
+
execute(operation: PackAuthoringOperation): Promise<Result<TResult, PackAuthoringError>>;
|
|
1403
1390
|
}
|
|
1404
1391
|
|
|
1405
1392
|
/** One idempotent gateway wrapper shared by Editor and CLI adapters. */
|
|
1406
|
-
export function
|
|
1407
|
-
port:
|
|
1408
|
-
):
|
|
1393
|
+
export function createPackAuthoringGateway<TResult = unknown>(
|
|
1394
|
+
port: PackAuthoringGatewayPort<TResult>,
|
|
1395
|
+
): PackAuthoringGatewayPort<TResult> {
|
|
1409
1396
|
const requests = new Map<
|
|
1410
1397
|
string,
|
|
1411
1398
|
{ fingerprint: string; result: Promise<Result<TResult, PackAuthoringError>> }
|
|
@@ -1478,15 +1465,13 @@ export function createParameterizedPackAuthoringGateway<TResult = unknown>(
|
|
|
1478
1465
|
};
|
|
1479
1466
|
}
|
|
1480
1467
|
|
|
1481
|
-
export const
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
) as readonly {
|
|
1489
|
-
id: ParameterizedPackOperationId;
|
|
1468
|
+
export const PACK_AUTHORING_OPERATION_DESCRIPTORS = PACK_AUTHORING_OPERATION_IDS.map((id) => ({
|
|
1469
|
+
id,
|
|
1470
|
+
domain: id.startsWith('asset-source.') ? 'session' : 'asset',
|
|
1471
|
+
readOnly: id.startsWith('asset.'),
|
|
1472
|
+
requiresRevision: !id.startsWith('asset.') && id !== 'asset-source.create',
|
|
1473
|
+
})) as readonly {
|
|
1474
|
+
id: PackAuthoringOperationId;
|
|
1490
1475
|
domain: 'asset' | 'session';
|
|
1491
1476
|
readOnly: boolean;
|
|
1492
1477
|
requiresRevision: boolean;
|
package/src/scanner.ts
CHANGED
|
@@ -12,19 +12,19 @@ import { PACK_ERROR_HINTS } from '@forgeax/engine-types';
|
|
|
12
12
|
import { PackError } from './errors.js';
|
|
13
13
|
import { isValidAssetGuidString, PackageId } from './guid.js';
|
|
14
14
|
import {
|
|
15
|
-
type
|
|
16
|
-
|
|
17
|
-
parseParameterizedPackJson,
|
|
15
|
+
type AnyScriptablePackDefinition,
|
|
16
|
+
parsePackSourceJson,
|
|
18
17
|
projectDirectPackJson,
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
projectScriptablePackMeta,
|
|
19
|
+
type ScriptablePackSourceMeta,
|
|
20
|
+
} from './pack-authoring.js';
|
|
21
21
|
import { validateProducerContract, validateProducerOutputs } from './producer-contract.js';
|
|
22
22
|
import { resolveAssetSource } from './resolve-asset-source.js';
|
|
23
23
|
import { validateMeta, validatePack } from './schema-compiled.js';
|
|
24
24
|
import type { ScriptablePackSourceClosureEntry } from './scriptable-pack.js';
|
|
25
25
|
import {
|
|
26
26
|
inventoryScriptablePackSource,
|
|
27
|
-
|
|
27
|
+
loadScriptablePack,
|
|
28
28
|
type ScriptablePackModuleExecutor,
|
|
29
29
|
} from './scriptable-pack-node.js';
|
|
30
30
|
|
|
@@ -85,8 +85,8 @@ export interface ScanInventory {
|
|
|
85
85
|
export interface ScriptablePackInventoryDeclaration {
|
|
86
86
|
readonly sourcePath: string;
|
|
87
87
|
readonly sourceRevision: string;
|
|
88
|
-
readonly meta:
|
|
89
|
-
readonly definition: Readonly<
|
|
88
|
+
readonly meta: ScriptablePackSourceMeta;
|
|
89
|
+
readonly definition: Readonly<AnyScriptablePackDefinition>;
|
|
90
90
|
readonly sourceClosure: readonly ScriptablePackSourceClosureEntry[];
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -125,7 +125,7 @@ export interface LegacyPackInventoryDocument {
|
|
|
125
125
|
readonly assets: readonly PackInventoryAsset[];
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
export interface
|
|
128
|
+
export interface PackSourceInventoryDocument {
|
|
129
129
|
readonly schemaVersion: '3.0.0';
|
|
130
130
|
readonly packageId: string;
|
|
131
131
|
readonly assets?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
@@ -133,9 +133,7 @@ export interface ParameterizedPackInventoryDocument {
|
|
|
133
133
|
readonly values?: Readonly<Record<string, unknown>>;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
export type PackInventoryDocument =
|
|
137
|
-
| LegacyPackInventoryDocument
|
|
138
|
-
| ParameterizedPackInventoryDocument;
|
|
136
|
+
export type PackInventoryDocument = LegacyPackInventoryDocument | PackSourceInventoryDocument;
|
|
139
137
|
|
|
140
138
|
export interface PackInventoryAsset {
|
|
141
139
|
readonly guid: string;
|
|
@@ -164,11 +162,11 @@ export type ScanSourceDeclaration =
|
|
|
164
162
|
readonly value: PackInventoryDocument;
|
|
165
163
|
}
|
|
166
164
|
| {
|
|
167
|
-
readonly format: 'pack.ts
|
|
165
|
+
readonly format: 'pack.ts';
|
|
168
166
|
readonly sourcePath: string;
|
|
169
167
|
readonly sourceRevision: string;
|
|
170
|
-
readonly value:
|
|
171
|
-
readonly definition:
|
|
168
|
+
readonly value: ScriptablePackSourceMeta;
|
|
169
|
+
readonly definition: AnyScriptablePackDefinition;
|
|
172
170
|
readonly sourceClosure: readonly ScriptablePackSourceClosureEntry[];
|
|
173
171
|
};
|
|
174
172
|
|
|
@@ -370,7 +368,7 @@ async function scanValidated(
|
|
|
370
368
|
const guidToPath = new Map<string, string>();
|
|
371
369
|
const packRefs = new Map<string, string[]>(); // guid -> refs[]
|
|
372
370
|
const packageIdToPath = new Map<string, string>();
|
|
373
|
-
const packageKind = new Map<string, 'legacy' | 'direct' | 'instance' | '
|
|
371
|
+
const packageKind = new Map<string, 'legacy' | 'direct' | 'instance' | 'scriptable'>();
|
|
374
372
|
const instanceParents: {
|
|
375
373
|
readonly path: string;
|
|
376
374
|
readonly packageId: string;
|
|
@@ -380,7 +378,7 @@ async function scanValidated(
|
|
|
380
378
|
function registerPackage(
|
|
381
379
|
packageId: string | undefined,
|
|
382
380
|
path: string,
|
|
383
|
-
kind: 'legacy' | 'direct' | 'instance' | '
|
|
381
|
+
kind: 'legacy' | 'direct' | 'instance' | 'scriptable',
|
|
384
382
|
): PackError | undefined {
|
|
385
383
|
if (packageId === undefined) return undefined;
|
|
386
384
|
const normalized = packageId.toLowerCase();
|
|
@@ -402,7 +400,7 @@ async function scanValidated(
|
|
|
402
400
|
const { raw, parsed } = loaded.value;
|
|
403
401
|
|
|
404
402
|
if (record(parsed) && parsed.schemaVersion === '3.0.0') {
|
|
405
|
-
const authoring =
|
|
403
|
+
const authoring = parsePackSourceJson(parsed);
|
|
406
404
|
if (!authoring.ok) {
|
|
407
405
|
return packErr(
|
|
408
406
|
makePackError('pack-malformed-pack', {
|
|
@@ -457,7 +455,7 @@ async function scanValidated(
|
|
|
457
455
|
sourcePath: packPath,
|
|
458
456
|
sourceRevision: `sha256:${createHash('sha256').update(raw).digest('hex')}`,
|
|
459
457
|
sourceText: raw,
|
|
460
|
-
value: parsed as unknown as
|
|
458
|
+
value: parsed as unknown as PackSourceInventoryDocument,
|
|
461
459
|
});
|
|
462
460
|
continue;
|
|
463
461
|
}
|
|
@@ -662,7 +660,7 @@ async function scanValidated(
|
|
|
662
660
|
}
|
|
663
661
|
}
|
|
664
662
|
|
|
665
|
-
//
|
|
663
|
+
// ScriptablePack source identity enters the package registry. Its outputs are
|
|
666
664
|
// intentionally absent until the dynamic build worklist evaluates it.
|
|
667
665
|
for (const sourcePath of scriptablePaths) {
|
|
668
666
|
let source: string;
|
|
@@ -680,7 +678,7 @@ async function scanValidated(
|
|
|
680
678
|
...(opts.scriptablePack ?? {}),
|
|
681
679
|
...(capture === undefined ? { metadataOnly: true } : {}),
|
|
682
680
|
};
|
|
683
|
-
const loaded = await
|
|
681
|
+
const loaded = await loadScriptablePack(sourcePath, loaderOptions);
|
|
684
682
|
if (!loaded.ok) {
|
|
685
683
|
const diagnostic = loaded.error.detail.diagnostic;
|
|
686
684
|
return packErr(
|
|
@@ -712,12 +710,12 @@ async function scanValidated(
|
|
|
712
710
|
const packageCollision = registerPackage(
|
|
713
711
|
PackageId.format(loaded.value.packageId),
|
|
714
712
|
sourcePath,
|
|
715
|
-
'
|
|
713
|
+
'scriptable',
|
|
716
714
|
);
|
|
717
715
|
if (packageCollision !== undefined) return packErr(packageCollision);
|
|
718
|
-
const meta =
|
|
716
|
+
const meta = projectScriptablePackMeta(loaded.value, sourcePath);
|
|
719
717
|
capture?.declarations.set(sourcePath, {
|
|
720
|
-
format: 'pack.ts
|
|
718
|
+
format: 'pack.ts',
|
|
721
719
|
sourcePath,
|
|
722
720
|
sourceRevision: `sha256:${createHash('sha256').update(source).digest('hex')}`,
|
|
723
721
|
value: meta,
|
|
@@ -749,15 +747,15 @@ async function scanValidated(
|
|
|
749
747
|
);
|
|
750
748
|
}
|
|
751
749
|
const kind = packageKind.get(parentId);
|
|
752
|
-
if (kind !== '
|
|
750
|
+
if (kind !== 'scriptable' && kind !== 'instance') {
|
|
753
751
|
return packErr(
|
|
754
752
|
makePackError('pack-malformed-pack', {
|
|
755
753
|
path: instance.path,
|
|
756
|
-
reason: 'pack-parent-
|
|
754
|
+
reason: 'pack-parent-has-no-parameters',
|
|
757
755
|
ajvErrors: [
|
|
758
756
|
{
|
|
759
757
|
instancePath: '/parent',
|
|
760
|
-
message: `parent ${instance.parent} is not a
|
|
758
|
+
message: `parent ${instance.parent} is not a ScriptablePack source with parameters`,
|
|
761
759
|
},
|
|
762
760
|
],
|
|
763
761
|
}),
|
|
@@ -849,7 +847,7 @@ export async function scanInventory(
|
|
|
849
847
|
const declaration = declarations.get(sourcePath);
|
|
850
848
|
if (declaration?.format !== 'pack.json') continue;
|
|
851
849
|
if (declaration.value.schemaVersion === '3.0.0') {
|
|
852
|
-
const parsed =
|
|
850
|
+
const parsed = parsePackSourceJson(declaration.value);
|
|
853
851
|
if (!parsed.ok) {
|
|
854
852
|
return packErr(
|
|
855
853
|
makePackError('pack-malformed-pack', {
|
|
@@ -107,7 +107,10 @@
|
|
|
107
107
|
"derivedInterface": {
|
|
108
108
|
"type": "object",
|
|
109
109
|
"required": ["layoutIdentity"],
|
|
110
|
-
"properties": {
|
|
110
|
+
"properties": {
|
|
111
|
+
"layoutIdentity": { "type": "string", "minLength": 1 },
|
|
112
|
+
"layerPlanIdentity": { "type": "string", "minLength": 1 }
|
|
113
|
+
},
|
|
111
114
|
"additionalProperties": false
|
|
112
115
|
},
|
|
113
116
|
"publicationGeneration": { "type": "integer", "minimum": 1 }
|