@metamesh/generator-sdk 0.5.2 → 0.6.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/CHANGELOG.md +6 -0
- package/README.md +146 -149
- package/dist/authoring.d.ts +57 -0
- package/dist/authoring.d.ts.map +1 -0
- package/dist/authoring.js +33 -0
- package/dist/authoring.js.map +1 -0
- package/dist/contracts.d.ts +31 -99
- package/dist/contracts.d.ts.map +1 -1
- package/dist/execute-generator.d.ts +22 -28
- package/dist/execute-generator.d.ts.map +1 -1
- package/dist/execute-generator.js +27 -32
- package/dist/execute-generator.js.map +1 -1
- package/dist/generated-parts.d.ts +1 -2
- package/dist/generated-parts.d.ts.map +1 -1
- package/dist/generated-parts.js +7 -31
- package/dist/generated-parts.js.map +1 -1
- package/dist/generator-module.d.ts +18 -40
- package/dist/generator-module.d.ts.map +1 -1
- package/dist/generator-module.js +4 -111
- package/dist/generator-module.js.map +1 -1
- package/dist/generator-package/constants.d.ts +2 -2
- package/dist/generator-package/constants.js +2 -2
- package/dist/generator-package/schemas/definition.schema.d.ts +3 -0
- package/dist/generator-package/schemas/definition.schema.d.ts.map +1 -1
- package/dist/generator-package/schemas/manifest.schema.d.ts +5 -8422
- package/dist/generator-package/schemas/manifest.schema.d.ts.map +1 -1
- package/dist/generator-package/schemas/parameter.schema.d.ts +7 -0
- package/dist/generator-package/schemas/parameter.schema.d.ts.map +1 -1
- package/dist/generator-package/schemas/parameter.schema.js +2 -0
- package/dist/generator-package/schemas/parameter.schema.js.map +1 -1
- package/dist/generator-package/schemas/preset.schema.d.ts +2 -13
- package/dist/generator-package/schemas/preset.schema.d.ts.map +1 -1
- package/dist/generator-package/schemas/preset.schema.js.map +1 -1
- package/dist/generator-package/validate-definition.d.ts.map +1 -1
- package/dist/generator-package/validate-definition.js +18 -0
- package/dist/generator-package/validate-definition.js.map +1 -1
- package/dist/generator-package/validate-manifest.d.ts.map +1 -1
- package/dist/generator-package/validate-manifest.js +2 -13
- package/dist/generator-package/validate-manifest.js.map +1 -1
- package/dist/generator-services.d.ts +1 -1
- package/dist/generator-services.d.ts.map +1 -1
- package/dist/index.d.ts +8 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/parameter-contracts.d.ts +121 -0
- package/dist/parameter-contracts.d.ts.map +1 -0
- package/dist/parameter-contracts.js +2 -0
- package/dist/parameter-contracts.js.map +1 -0
- package/dist/parameters/issues.d.ts +14 -0
- package/dist/parameters/issues.d.ts.map +1 -0
- package/dist/parameters/issues.js +262 -0
- package/dist/parameters/issues.js.map +1 -0
- package/dist/parameters/preparation.d.ts +13 -0
- package/dist/parameters/preparation.d.ts.map +1 -0
- package/dist/parameters/preparation.js +35 -0
- package/dist/parameters/preparation.js.map +1 -0
- package/dist/parameters/recovery.d.ts +10 -0
- package/dist/parameters/recovery.d.ts.map +1 -0
- package/dist/parameters/recovery.js +124 -0
- package/dist/parameters/recovery.js.map +1 -0
- package/dist/parameters/strict.d.ts +30 -0
- package/dist/parameters/strict.d.ts.map +1 -0
- package/dist/parameters/strict.js +116 -0
- package/dist/parameters/strict.js.map +1 -0
- package/dist/parameters/values.d.ts +13 -0
- package/dist/parameters/values.d.ts.map +1 -0
- package/dist/parameters/values.js +73 -0
- package/dist/parameters/values.js.map +1 -0
- package/dist/parameters.d.ts +7 -69
- package/dist/parameters.d.ts.map +1 -1
- package/dist/parameters.js +5 -592
- package/dist/parameters.js.map +1 -1
- package/dist/parse-generator-module.d.ts +29 -0
- package/dist/parse-generator-module.d.ts.map +1 -0
- package/dist/parse-generator-module.js +137 -0
- package/dist/parse-generator-module.js.map +1 -0
- package/dist/runtime.d.ts +10 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -0
- package/dist/worker-contracts.d.ts +80 -0
- package/dist/worker-contracts.d.ts.map +1 -0
- package/dist/worker-contracts.js +12 -0
- package/dist/worker-contracts.js.map +1 -0
- package/package.json +14 -1
- package/dist/prepared-generator-module.d.ts +0 -24
- package/dist/prepared-generator-module.d.ts.map +0 -1
- package/dist/prepared-generator-module.js +0 -124
- package/dist/prepared-generator-module.js.map +0 -1
package/dist/generator-module.js
CHANGED
|
@@ -1,119 +1,12 @@
|
|
|
1
1
|
import { GENERATOR_PACKAGE_FORMAT_VERSION } from "./generator-package/constants.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const hasExactExports = (value) => {
|
|
5
|
-
const names = Object.keys(value).sort();
|
|
6
|
-
return (names.length === EXPORT_NAMES.length &&
|
|
7
|
-
names.every((name, index) => name === EXPORT_NAMES[index]));
|
|
8
|
-
};
|
|
9
|
-
function moduleProblem(value, definition) {
|
|
10
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
11
|
-
return "must be an object";
|
|
12
|
-
}
|
|
13
|
-
const candidate = value;
|
|
14
|
-
if (!hasExactExports(candidate)) {
|
|
15
|
-
const names = Object.keys(candidate).sort();
|
|
16
|
-
const missing = EXPORT_NAMES.filter((name) => !names.includes(name));
|
|
17
|
-
const extra = names.filter((name) => !EXPORT_NAMES.some((expected) => expected === name));
|
|
18
|
-
const display = (values) => values
|
|
19
|
-
.slice(0, 20)
|
|
20
|
-
.map((name) => name.slice(0, 100))
|
|
21
|
-
.join(", ");
|
|
22
|
-
return `must export exactly ${EXPORT_NAMES.join(", ")}. Missing: ${display(missing) || "none"}. Unexpected: ${display(extra) || "none"}${extra.length > 20 ? ", …" : ""}`;
|
|
23
|
-
}
|
|
24
|
-
if (candidate.formatVersion !== GENERATOR_PACKAGE_FORMAT_VERSION) {
|
|
25
|
-
return `formatVersion must be ${GENERATOR_PACKAGE_FORMAT_VERSION}`;
|
|
26
|
-
}
|
|
27
|
-
if (candidate.generatorId !== definition.id) {
|
|
28
|
-
return `generatorId must be ${JSON.stringify(definition.id)}`;
|
|
29
|
-
}
|
|
30
|
-
if (candidate.version !== definition.version) {
|
|
31
|
-
return `version must be ${JSON.stringify(definition.version)}`;
|
|
32
|
-
}
|
|
33
|
-
if (typeof candidate.validate !== "function")
|
|
34
|
-
return "validate must be a function";
|
|
35
|
-
if (typeof candidate.generate !== "function")
|
|
36
|
-
return "generate must be a function";
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
function requireSynchronousArray(value, operation) {
|
|
40
|
-
if (!Array.isArray(value)) {
|
|
41
|
-
throw new TypeError(`Generator ${operation}() must return an array synchronously.`);
|
|
42
|
-
}
|
|
43
|
-
return value;
|
|
44
|
-
}
|
|
45
|
-
function assembleCanonicalModule(definition, validate, generate) {
|
|
2
|
+
/** Codec-free authoring helper. Hosts check metadata and callback results. */
|
|
3
|
+
export function defineGeneratorModule({ definition, prepare, build, }) {
|
|
46
4
|
return Object.freeze({
|
|
47
5
|
formatVersion: GENERATOR_PACKAGE_FORMAT_VERSION,
|
|
48
|
-
generate,
|
|
49
6
|
generatorId: definition.id,
|
|
50
|
-
validate,
|
|
51
7
|
version: definition.version,
|
|
8
|
+
prepare,
|
|
9
|
+
build,
|
|
52
10
|
});
|
|
53
11
|
}
|
|
54
|
-
function checkedCanonicalModule(definition, validate, generate) {
|
|
55
|
-
return assembleCanonicalModule(definition, (parameters, services) => requireSynchronousArray(validate(parameters, services), "validate"), (parameters, context, services) => requireSynchronousArray(generate(parameters, context, services), "generate"));
|
|
56
|
-
}
|
|
57
|
-
function strictModule(definition, canonical) {
|
|
58
|
-
const codec = createParamCodec(definition);
|
|
59
|
-
return Object.freeze({
|
|
60
|
-
formatVersion: canonical.formatVersion,
|
|
61
|
-
generate(parameters, context, services) {
|
|
62
|
-
return canonical.generate(codec.parse(parameters), context, services);
|
|
63
|
-
},
|
|
64
|
-
generatorId: canonical.generatorId,
|
|
65
|
-
validate(parameters, services) {
|
|
66
|
-
return canonical.validate(codec.parse(parameters), services);
|
|
67
|
-
},
|
|
68
|
-
version: canonical.version,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Creates the complete compiled-module surface from one typed definition.
|
|
73
|
-
*
|
|
74
|
-
* The returned callbacks accept canonical parameters so this authoring helper stays small in
|
|
75
|
-
* self-contained release bundles. Hosts use `parseGeneratorModule()` at untrusted boundaries.
|
|
76
|
-
*/
|
|
77
|
-
export function defineGeneratorModule({ definition, generate, validate, }) {
|
|
78
|
-
return assembleCanonicalModule(definition, validate, generate);
|
|
79
|
-
}
|
|
80
|
-
/** Checks an evaluated ESM namespace against its authoritative manifest definition. */
|
|
81
|
-
export function isGeneratorModule(value, definition) {
|
|
82
|
-
try {
|
|
83
|
-
return moduleProblem(value, definition) === undefined;
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Parses an evaluated ESM namespace and snapshots both invocation lanes.
|
|
91
|
-
*
|
|
92
|
-
* The canonical lane is for host-prepared `GeneratorParams`; the strict lane is the only lane that
|
|
93
|
-
* accepts boundary `ParameterValues` and decodes them before invoking evaluated code. Function
|
|
94
|
-
* result values remain host-validated because JavaScript cannot prove them without execution.
|
|
95
|
-
*/
|
|
96
|
-
export function parseGeneratorModule(value, definition) {
|
|
97
|
-
let problem;
|
|
98
|
-
try {
|
|
99
|
-
problem = moduleProblem(value, definition);
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
problem = "exports could not be inspected";
|
|
103
|
-
}
|
|
104
|
-
if (problem !== undefined)
|
|
105
|
-
throw new Error(`Invalid Generator module: ${problem}.`);
|
|
106
|
-
try {
|
|
107
|
-
const candidate = value;
|
|
108
|
-
const validate = candidate.validate;
|
|
109
|
-
const generate = candidate.generate;
|
|
110
|
-
if (typeof validate !== "function" || typeof generate !== "function")
|
|
111
|
-
throw new TypeError();
|
|
112
|
-
const canonical = checkedCanonicalModule(definition, validate, generate);
|
|
113
|
-
return Object.freeze({ canonical, strict: strictModule(definition, canonical) });
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
throw new Error("Invalid Generator module: exports could not be read.");
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
12
|
//# sourceMappingURL=generator-module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator-module.js","sourceRoot":"","sources":["../src/generator-module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generator-module.js","sourceRoot":"","sources":["../src/generator-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAiCpF,8EAA8E;AAC9E,MAAM,UAAU,qBAAqB,CAA0D,EAC7F,UAAU,EACV,OAAO,EACP,KAAK,GACyC;IAC9C,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,aAAa,EAAE,gCAAgC;QAC/C,WAAW,EAAE,UAAU,CAAC,EAAE;QAC1B,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,OAAO;QACP,KAAK;KACN,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const METAMESH_RUNTIME_VERSION = "
|
|
2
|
-
export declare const GENERATOR_PACKAGE_FORMAT_VERSION =
|
|
1
|
+
export declare const METAMESH_RUNTIME_VERSION = "2.0.0";
|
|
2
|
+
export declare const GENERATOR_PACKAGE_FORMAT_VERSION = 2;
|
|
3
3
|
export declare const MAX_GENERATOR_PACKAGE_BYTES: number;
|
|
4
4
|
/** Portable metadata limits enforced before package content reaches Studio. */
|
|
5
5
|
export declare const MAX_GENERATOR_ID_LENGTH = 120;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const METAMESH_RUNTIME_VERSION = "
|
|
2
|
-
export const GENERATOR_PACKAGE_FORMAT_VERSION =
|
|
1
|
+
export const METAMESH_RUNTIME_VERSION = "2.0.0";
|
|
2
|
+
export const GENERATOR_PACKAGE_FORMAT_VERSION = 2;
|
|
3
3
|
export const MAX_GENERATOR_PACKAGE_BYTES = 5 * 1024 * 1024;
|
|
4
4
|
/** Portable metadata limits enforced before package content reaches Studio. */
|
|
5
5
|
export const MAX_GENERATOR_ID_LENGTH = 120;
|
|
@@ -31,6 +31,7 @@ export declare const generatorDefinitionSchema: z.ZodObject<{
|
|
|
31
31
|
max: z.ZodOptional<z.ZodNumber>;
|
|
32
32
|
step: z.ZodOptional<z.ZodNumber>;
|
|
33
33
|
default: z.ZodNumber;
|
|
34
|
+
integer: z.ZodOptional<z.ZodBoolean>;
|
|
34
35
|
role: z.ZodOptional<z.ZodLiteral<"curve-resolution">>;
|
|
35
36
|
id: z.ZodString;
|
|
36
37
|
label: z.ZodString;
|
|
@@ -44,6 +45,7 @@ export declare const generatorDefinitionSchema: z.ZodObject<{
|
|
|
44
45
|
max: z.ZodNumber;
|
|
45
46
|
step: z.ZodNumber;
|
|
46
47
|
default: z.ZodNumber;
|
|
48
|
+
integer: z.ZodOptional<z.ZodBoolean>;
|
|
47
49
|
role: z.ZodOptional<z.ZodLiteral<"curve-resolution">>;
|
|
48
50
|
id: z.ZodString;
|
|
49
51
|
label: z.ZodString;
|
|
@@ -141,6 +143,7 @@ export declare const generatorDefinitionSchema: z.ZodObject<{
|
|
|
141
143
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
142
144
|
items: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
143
145
|
type: z.ZodLiteral<"number">;
|
|
146
|
+
integer: z.ZodOptional<z.ZodBoolean>;
|
|
144
147
|
min: z.ZodOptional<z.ZodNumber>;
|
|
145
148
|
max: z.ZodOptional<z.ZodNumber>;
|
|
146
149
|
step: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.schema.d.ts","sourceRoot":"","sources":["../../../src/generator-package/schemas/definition.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,oBAAoB;;;;;kBAK/B,CAAC;AAEH,eAAO,MAAM,yBAAyB
|
|
1
|
+
{"version":3,"file":"definition.schema.d.ts","sourceRoot":"","sources":["../../../src/generator-package/schemas/definition.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,oBAAoB;;;;;kBAK/B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAOpC,CAAC;AAEH,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,GACpD,SAAS,YAAY,CAAC,IAAI,CAAC,EAAE,GAC7B,CAAC,SAAS,MAAM,GACd;IAAE,QAAQ,EAAE,GAAG,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GACnD,CAAC,CAAC;AAER,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC;AACjF,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC"}
|