@milaboratories/pl-middle-layer 2.10.1 → 2.11.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/dist/block_registry/registry-v2-provider.cjs +8 -1
- package/dist/block_registry/registry-v2-provider.cjs.map +1 -1
- package/dist/block_registry/registry-v2-provider.d.ts.map +1 -1
- package/dist/block_registry/registry-v2-provider.js +8 -1
- package/dist/block_registry/registry-v2-provider.js.map +1 -1
- package/dist/index.cjs +24 -0
- package/dist/index.d.ts +11 -4
- package/dist/index.js +4 -2
- package/dist/js_render/bundle_bytecode_cache.cjs +6 -1
- package/dist/js_render/bundle_bytecode_cache.cjs.map +1 -1
- package/dist/js_render/bundle_bytecode_cache.js +6 -1
- package/dist/js_render/bundle_bytecode_cache.js.map +1 -1
- package/dist/js_render/column_registry.cjs +17 -0
- package/dist/js_render/column_registry.cjs.map +1 -1
- package/dist/js_render/column_registry.js +16 -1
- package/dist/js_render/column_registry.js.map +1 -1
- package/dist/js_render/computable_context.cjs +1 -1
- package/dist/js_render/computable_context.js +1 -1
- package/dist/js_render/context.cjs +3 -2
- package/dist/js_render/context.cjs.map +1 -1
- package/dist/js_render/context.js +3 -2
- package/dist/js_render/context.js.map +1 -1
- package/dist/js_render/index.cjs +1 -1
- package/dist/js_render/index.cjs.map +1 -1
- package/dist/js_render/index.js +1 -1
- package/dist/js_render/index.js.map +1 -1
- package/dist/js_render/service_injectors.cjs +2 -9
- package/dist/js_render/service_injectors.cjs.map +1 -1
- package/dist/js_render/service_injectors.js +2 -9
- package/dist/js_render/service_injectors.js.map +1 -1
- package/dist/middle_layer/block.cjs +48 -0
- package/dist/middle_layer/block.cjs.map +1 -1
- package/dist/middle_layer/block.js +51 -4
- package/dist/middle_layer/block.js.map +1 -1
- package/dist/middle_layer/block_pack_description.cjs +80 -0
- package/dist/middle_layer/block_pack_description.cjs.map +1 -0
- package/dist/middle_layer/block_pack_description.d.ts +36 -0
- package/dist/middle_layer/block_pack_description.d.ts.map +1 -0
- package/dist/middle_layer/block_pack_description.js +78 -0
- package/dist/middle_layer/block_pack_description.js.map +1 -0
- package/dist/middle_layer/build_stamp.cjs +1 -1
- package/dist/middle_layer/build_stamp.js +1 -1
- package/dist/middle_layer/index.cjs +11 -0
- package/dist/middle_layer/index.d.ts +8 -2
- package/dist/middle_layer/index.js +3 -1
- package/dist/middle_layer/legacy_project_holds.cjs +61 -0
- package/dist/middle_layer/legacy_project_holds.cjs.map +1 -0
- package/dist/middle_layer/legacy_project_holds.js +61 -0
- package/dist/middle_layer/legacy_project_holds.js.map +1 -0
- package/dist/middle_layer/middle_layer.cjs +18 -21
- package/dist/middle_layer/middle_layer.cjs.map +1 -1
- package/dist/middle_layer/middle_layer.d.ts +13 -3
- package/dist/middle_layer/middle_layer.d.ts.map +1 -1
- package/dist/middle_layer/middle_layer.js +18 -21
- package/dist/middle_layer/middle_layer.js.map +1 -1
- package/dist/middle_layer/pool_columns.cjs +160 -0
- package/dist/middle_layer/pool_columns.cjs.map +1 -0
- package/dist/middle_layer/pool_columns.d.ts +59 -0
- package/dist/middle_layer/pool_columns.d.ts.map +1 -0
- package/dist/middle_layer/pool_columns.js +157 -0
- package/dist/middle_layer/pool_columns.js.map +1 -0
- package/dist/middle_layer/pool_frame.cjs +82 -0
- package/dist/middle_layer/pool_frame.cjs.map +1 -0
- package/dist/middle_layer/pool_frame.d.ts +37 -0
- package/dist/middle_layer/pool_frame.d.ts.map +1 -0
- package/dist/middle_layer/pool_frame.js +81 -0
- package/dist/middle_layer/pool_frame.js.map +1 -0
- package/dist/middle_layer/pool_table.cjs +66 -0
- package/dist/middle_layer/pool_table.cjs.map +1 -0
- package/dist/middle_layer/pool_table.d.ts +27 -0
- package/dist/middle_layer/pool_table.d.ts.map +1 -0
- package/dist/middle_layer/pool_table.js +66 -0
- package/dist/middle_layer/pool_table.js.map +1 -0
- package/dist/middle_layer/project.cjs +83 -2
- package/dist/middle_layer/project.cjs.map +1 -1
- package/dist/middle_layer/project.d.ts +69 -3
- package/dist/middle_layer/project.d.ts.map +1 -1
- package/dist/middle_layer/project.js +84 -3
- package/dist/middle_layer/project.js.map +1 -1
- package/dist/middle_layer/rich_column_query.cjs +180 -0
- package/dist/middle_layer/rich_column_query.cjs.map +1 -0
- package/dist/middle_layer/rich_column_query.d.ts +34 -0
- package/dist/middle_layer/rich_column_query.d.ts.map +1 -0
- package/dist/middle_layer/rich_column_query.js +176 -0
- package/dist/middle_layer/rich_column_query.js.map +1 -0
- package/dist/model/args.cjs +23 -0
- package/dist/model/args.cjs.map +1 -1
- package/dist/model/args.js +24 -2
- package/dist/model/args.js.map +1 -1
- package/dist/model/args_derivation.cjs +60 -2
- package/dist/model/args_derivation.cjs.map +1 -1
- package/dist/model/args_derivation.d.ts +73 -3
- package/dist/model/args_derivation.d.ts.map +1 -1
- package/dist/model/args_derivation.js +60 -3
- package/dist/model/args_derivation.js.map +1 -1
- package/dist/model/block_params_model.cjs +42 -0
- package/dist/model/block_params_model.cjs.map +1 -0
- package/dist/model/block_params_model.d.ts +45 -0
- package/dist/model/block_params_model.d.ts.map +1 -0
- package/dist/model/block_params_model.js +42 -0
- package/dist/model/block_params_model.js.map +1 -0
- package/dist/model/index.d.ts +3 -1
- package/dist/model/project_helper.cjs +50 -6
- package/dist/model/project_helper.cjs.map +1 -1
- package/dist/model/project_helper.d.ts +25 -1
- package/dist/model/project_helper.d.ts.map +1 -1
- package/dist/model/project_helper.js +51 -7
- package/dist/model/project_helper.js.map +1 -1
- package/dist/mutator/block-pack/block_pack.cjs +1 -1
- package/dist/mutator/block-pack/block_pack.js +1 -1
- package/dist/mutator/project.cjs +4 -0
- package/dist/mutator/project.cjs.map +1 -1
- package/dist/mutator/project.d.ts +1 -1
- package/dist/mutator/project.d.ts.map +1 -1
- package/dist/mutator/project.js +4 -0
- package/dist/mutator/project.js.map +1 -1
- package/package.json +9 -9
- package/src/block_registry/registry-v2-provider.test.ts +23 -0
- package/src/block_registry/registry-v2-provider.ts +11 -1
- package/src/index.ts +2 -0
- package/src/js_render/bundle_bytecode_cache.ts +15 -4
- package/src/js_render/column_registry.ts +24 -3
- package/src/js_render/context.ts +4 -3
- package/src/js_render/index.ts +3 -2
- package/src/js_render/service_injectors.ts +2 -11
- package/src/middle_layer/block.ts +61 -2
- package/src/middle_layer/block_pack_description.test.ts +235 -0
- package/src/middle_layer/block_pack_description.ts +143 -0
- package/src/middle_layer/index.ts +9 -1
- package/src/middle_layer/legacy_project_holds.test.ts +133 -0
- package/src/middle_layer/legacy_project_holds.ts +73 -0
- package/src/middle_layer/middle_layer.ts +23 -26
- package/src/middle_layer/pool_columns.test.ts +217 -0
- package/src/middle_layer/pool_columns.ts +250 -0
- package/src/middle_layer/pool_frame.test.ts +144 -0
- package/src/middle_layer/pool_frame.ts +127 -0
- package/src/middle_layer/pool_table.test.ts +182 -0
- package/src/middle_layer/pool_table.ts +98 -0
- package/src/middle_layer/project.ts +128 -5
- package/src/middle_layer/rich_column_query.test.ts +311 -0
- package/src/middle_layer/rich_column_query.ts +214 -0
- package/src/model/args.test.ts +23 -1
- package/src/model/args.ts +29 -1
- package/src/model/args_derivation.test.ts +129 -12
- package/src/model/args_derivation.ts +112 -8
- package/src/model/block_params_model.test.ts +194 -0
- package/src/model/block_params_model.ts +117 -0
- package/src/model/index.ts +6 -0
- package/src/model/project_helper.ts +101 -20
- package/src/mutator/project.ts +5 -0
- package/src/pool/result_pool_markers.test.ts +47 -0
- package/src/test/fake_project.ts +33 -6
|
@@ -17,6 +17,7 @@ let es_toolkit = require("es-toolkit");
|
|
|
17
17
|
function parseArgsDeriveResult(value) {
|
|
18
18
|
if (typeof value !== "object" || value === null) throw new Error(`Args derivation returned ${value === null ? "null" : typeof value}`);
|
|
19
19
|
const error = "error" in value ? value.error : void 0;
|
|
20
|
+
const issues = "issues" in value ? value.issues : void 0;
|
|
20
21
|
if (error !== void 0) {
|
|
21
22
|
if (!(0, es_toolkit.isString)(error)) throw new Error(`Args derivation error is ${typeof error}, not a string`);
|
|
22
23
|
const args = "args" in value ? value.args : void 0;
|
|
@@ -24,10 +25,12 @@ function parseArgsDeriveResult(value) {
|
|
|
24
25
|
type: "absent",
|
|
25
26
|
error: new Error(error)
|
|
26
27
|
};
|
|
28
|
+
const errors = argsErrorsOf(issues, error);
|
|
27
29
|
return {
|
|
28
30
|
type: "blocked",
|
|
29
31
|
args,
|
|
30
|
-
errors
|
|
32
|
+
errors,
|
|
33
|
+
issues: issuesWithErrors(issues, errors)
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
36
|
const args = "value" in value ? value.value : void 0;
|
|
@@ -37,7 +40,44 @@ function parseArgsDeriveResult(value) {
|
|
|
37
40
|
};
|
|
38
41
|
return {
|
|
39
42
|
type: "runnable",
|
|
40
|
-
args
|
|
43
|
+
args,
|
|
44
|
+
issues: readableIssues(issues)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Reads the result of the model's `__pl_prerunArgs_derive` callback.
|
|
49
|
+
*
|
|
50
|
+
* A model built before args issues returns `{ value }` for prerun args and `{ error }` for none.
|
|
51
|
+
* A newer model adds the issues, and returns `{ error, issues }` when they include errors. An
|
|
52
|
+
* `{ error }` without issues is a lambda that threw.
|
|
53
|
+
*
|
|
54
|
+
* @throws when `value` is not an object, or carries an `error` that is not a string
|
|
55
|
+
*/
|
|
56
|
+
function parsePrerunArgsDeriveResult(value) {
|
|
57
|
+
if (typeof value !== "object" || value === null) throw new Error(`Prerun args derivation returned ${value === null ? "null" : typeof value}`);
|
|
58
|
+
const error = "error" in value ? value.error : void 0;
|
|
59
|
+
const issues = "issues" in value ? value.issues : void 0;
|
|
60
|
+
if (error !== void 0) {
|
|
61
|
+
if (!(0, es_toolkit.isString)(error)) throw new Error(`Prerun args derivation error is ${typeof error}, not a string`);
|
|
62
|
+
if (issues === void 0) return {
|
|
63
|
+
type: "failed",
|
|
64
|
+
error
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
type: "blocked",
|
|
68
|
+
error,
|
|
69
|
+
issues: readableIssues(issues)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const args = "value" in value ? value.value : void 0;
|
|
73
|
+
if (args === void 0) return {
|
|
74
|
+
type: "skipped",
|
|
75
|
+
issues: readableIssues(issues)
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
type: "staged",
|
|
79
|
+
args,
|
|
80
|
+
issues: readableIssues(issues)
|
|
41
81
|
};
|
|
42
82
|
}
|
|
43
83
|
/** The args an args derivation produced; `undefined` when it produced none. */
|
|
@@ -143,11 +183,29 @@ function parseArgsErrorsRecord(value) {
|
|
|
143
183
|
function isError(issue) {
|
|
144
184
|
return issue.severity === "error";
|
|
145
185
|
}
|
|
186
|
+
/** The issues of a derivation result; none when they cannot be read. */
|
|
187
|
+
function readableIssues(issues) {
|
|
188
|
+
if (issues === void 0) return [];
|
|
189
|
+
try {
|
|
190
|
+
return (0, _milaboratories_pl_model_common.parseArgsIssues)(issues);
|
|
191
|
+
} catch {
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Every issue of a derivation whose `argsIssues()` found errors: the readable issues when they
|
|
197
|
+
* hold the errors, otherwise the errors that stood in for them.
|
|
198
|
+
*/
|
|
199
|
+
function issuesWithErrors(issues, errors) {
|
|
200
|
+
const readable = readableIssues(issues);
|
|
201
|
+
return readable.some(isError) ? readable : [...errors, ...readable];
|
|
202
|
+
}
|
|
146
203
|
exports.argsErrorsFieldChange = argsErrorsFieldChange;
|
|
147
204
|
exports.argsErrorsOfBlock = argsErrorsOfBlock;
|
|
148
205
|
exports.argsFingerprint = argsFingerprint;
|
|
149
206
|
exports.derivedArgsValue = derivedArgsValue;
|
|
150
207
|
exports.parseArgsDeriveResult = parseArgsDeriveResult;
|
|
208
|
+
exports.parsePrerunArgsDeriveResult = parsePrerunArgsDeriveResult;
|
|
151
209
|
exports.readArgsErrorsField = readArgsErrorsField;
|
|
152
210
|
|
|
153
211
|
//# sourceMappingURL=args_derivation.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args_derivation.cjs","names":["isString","createHash","canonicalJsonBytes","cachedDeserialize","BLOCK_STORAGE_FACADE_VERSION","parseArgsIssues"],"sources":["../../src/model/args_derivation.ts"],"sourcesContent":["import { parseArgsIssues, type ArgsIssue } from \"@milaboratories/pl-model-common\";\nimport { cachedDeserialize, canonicalJsonBytes } from \"@milaboratories/ts-helpers\";\nimport { isString } from \"es-toolkit\";\nimport { createHash } from \"node:crypto\";\nimport { BLOCK_STORAGE_FACADE_VERSION } from \"@platforma-sdk/model\";\n\n/**\n * What the args derivation of a block with model API version 2 made of the block's storage.\n *\n * - `runnable`: the block has args and may run with them.\n * - `blocked`: the block has args, but its `argsIssues()` found errors in them, so it must not run.\n * `errors` is never empty.\n * - `absent`: the block has no args, because `args()` threw or returned nothing.\n */\nexport type DerivedArgs =\n | { readonly type: \"runnable\"; readonly args: unknown }\n | { readonly type: \"blocked\"; readonly args: unknown; readonly errors: readonly ArgsIssue[] }\n | { readonly type: \"absent\"; readonly error: Error };\n\n/**\n * What a block's `inputsValid` field holds: the errors found in the block's current args, and the\n * fingerprint of the args they were found in. Every args derivation that produces args writes\n * it, with no errors when the block may run.\n *\n * A middle layer that predates args issues never writes or deletes the field, so after it edits\n * the block, the field can be missing or outlive the args it was computed for. The fingerprint\n * tells such a stale field apart: it no longer matches the current args, and says nothing of them.\n */\nexport type ArgsErrorsRecord = {\n /** {@link argsFingerprint} of the current args the errors were found in. */\n readonly argsFingerprint: string;\n /** The errors; empty when the block may run with the args. */\n readonly errors: readonly ArgsIssue[];\n};\n\n/** How a block's `inputsValid` field must change to hold what an args derivation found. */\nexport type ArgsErrorsFieldChange =\n | { readonly type: \"keep\" }\n | { readonly type: \"write\"; readonly data: Uint8Array }\n | { readonly type: \"delete\" };\n\n/**\n * Reads the result of the model's `__pl_args_derive` callback.\n *\n * A model built before args issues returns `{ value }` for args and `{ error }` for none; both\n * read as they did then. A newer model adds the args issues, and returns `{ error, args, issues }`\n * when its `argsIssues()` found errors. Args that are `undefined` are no args, whatever\n * `argsIssues()` said.\n *\n * @throws when `value` is not an object, or carries an `error` that is not a string\n */\nexport function parseArgsDeriveResult(value: unknown): DerivedArgs {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(`Args derivation returned ${value === null ? \"null\" : typeof value}`);\n }\n\n const error = \"error\" in value ? value.error : undefined;\n if (error !== undefined) {\n if (!isString(error)) throw new Error(`Args derivation error is ${typeof error}, not a string`);\n const args = \"args\" in value ? value.args : undefined;\n if (args === undefined) return { type: \"absent\", error: new Error(error) };\n const issues = \"issues\" in value ? value.issues : undefined;\n return { type: \"blocked\", args, errors: argsErrorsOf(issues, error) };\n }\n\n const args = \"value\" in value ? value.value : undefined;\n if (args === undefined) return { type: \"absent\", error: new Error(\"args() returned no args\") };\n return { type: \"runnable\", args };\n}\n\n/** The args an args derivation produced; `undefined` when it produced none. */\nexport function derivedArgsValue(derived: DerivedArgs): unknown {\n return derived.type === \"absent\" ? undefined : derived.args;\n}\n\n/**\n * Identifies a value of a block's current args by its content: the SHA-256 of its canonical JSON,\n * in hex. Args that encode to the same JSON, whatever the key order, share a fingerprint.\n */\nexport function argsFingerprint(args: unknown): string {\n return createHash(\"sha256\").update(canonicalJsonBytes(args)).digest(\"hex\");\n}\n\n/**\n * What a block's `inputsValid` field must become after an args derivation, given the field as it\n * is now.\n *\n * The field holds a {@link ArgsErrorsRecord} as canonical JSON, and exists while the block has\n * args: with the errors its `argsIssues()` found in them, and with none when it found none. A\n * field already holding the same record is kept as it is, so that readers of the project are not\n * woken by a write that changes nothing.\n */\nexport function argsErrorsFieldChange(\n current: { readonly value?: Uint8Array } | undefined,\n derived: DerivedArgs,\n): ArgsErrorsFieldChange {\n if (derived.type === \"absent\")\n return current === undefined ? { type: \"keep\" } : { type: \"delete\" };\n const record: ArgsErrorsRecord = {\n argsFingerprint: argsFingerprint(derived.args),\n errors: derived.type === \"blocked\" ? derived.errors : [],\n };\n const data = canonicalJsonBytes(record);\n if (current?.value !== undefined && Buffer.compare(current.value, data) === 0) {\n return { type: \"keep\" };\n }\n return { type: \"write\", data };\n}\n\n/**\n * The errors a block's `inputsValid` field, as {@link argsErrorsFieldChange} writes it, records\n * for the block's current args.\n *\n * A field that is missing, cannot be read, or was written for other args records none: the args\n * were written by a middle layer that does not know the field. Such a middle layer refuses every\n * block whose `argsIssues()` could find errors, so it wrote args only for blocks whose `args()`\n * throws instead, and those args may run, as they always could. No current args hold no errors:\n * without args the block may not run anyway.\n *\n * @param data - Content of the field; `undefined` when there is none, or while it is not loaded\n * @param currentArgs - The block's current args as decoded from its `currentArgs` field;\n * `undefined` when the block has none\n */\nexport function readArgsErrorsField(\n data: Uint8Array | undefined,\n currentArgs: unknown,\n): readonly ArgsIssue[] {\n if (currentArgs === undefined || data === undefined) return [];\n let record: ArgsErrorsRecord;\n try {\n record = parseArgsErrorsRecord(cachedDeserialize(data));\n } catch {\n return [];\n }\n return record.argsFingerprint === argsFingerprint(currentArgs) ? record.errors : [];\n}\n\n/**\n * The errors found in a block's current args, read from its `inputsValid` field as\n * {@link readArgsErrorsField} reads it.\n *\n * Only a block with model API version 2 has args errors. An earlier model tells whether the block\n * may run by itself, and a field left over from a later model version does not apply to it: such\n * a block has none.\n */\nexport function argsErrorsOfBlock(block: {\n /** Model API version of the block's current block pack. */\n readonly modelAPIVersion: number | undefined;\n /** The block's `inputsValid` field; `undefined` when there is none. */\n readonly inputsValid: { readonly value?: Uint8Array } | undefined;\n /** The block's current args; `undefined` when it has none. */\n readonly currentArgs: unknown;\n}): readonly ArgsIssue[] {\n const { modelAPIVersion, inputsValid, currentArgs } = block;\n if (modelAPIVersion !== BLOCK_STORAGE_FACADE_VERSION) return [];\n return readArgsErrorsField(inputsValid?.value, currentArgs);\n}\n\n// Internals\n\n/**\n * The errors among the issues of a derivation whose `argsIssues()` found errors. Issues that\n * cannot be read, or that hold no error, give way to `error`, the joined messages the model\n * reported.\n */\nfunction argsErrorsOf(issues: unknown, error: string): readonly ArgsIssue[] {\n try {\n const errors = parseArgsIssues(issues).filter(isError);\n if (errors.length > 0) return errors;\n } catch {\n // An older or broken model: `error` alone tells why the block must not run.\n }\n return [{ severity: \"error\", message: error }];\n}\n\n/**\n * Reads a {@link ArgsErrorsRecord} from decoded field content. Issues other than errors are\n * dropped.\n *\n * @throws when `value` is not an object carrying a string fingerprint and a list of issues\n */\nfunction parseArgsErrorsRecord(value: unknown): ArgsErrorsRecord {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(\"Args errors record must be an object\");\n }\n const fingerprint = \"argsFingerprint\" in value ? value.argsFingerprint : undefined;\n if (!isString(fingerprint)) throw new Error(\"Args errors record must carry a fingerprint\");\n const errors = parseArgsIssues(\"errors\" in value ? value.errors : undefined).filter(isError);\n return { argsFingerprint: fingerprint, errors };\n}\n\nfunction isError(issue: ArgsIssue): boolean {\n return issue.severity === \"error\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmDA,SAAgB,sBAAsB,OAA6B;CACjE,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,MAAM,IAAI,MAAM,4BAA4B,UAAU,OAAO,SAAS,OAAO,OAAO;CAGtF,MAAM,QAAQ,WAAW,QAAQ,MAAM,QAAQ,KAAA;CAC/C,IAAI,UAAU,KAAA,GAAW;EACvB,IAAI,EAAA,GAACA,WAAAA,SAAAA,CAAS,KAAK,GAAG,MAAM,IAAI,MAAM,4BAA4B,OAAO,MAAM,eAAe;EAC9F,MAAM,OAAO,UAAU,QAAQ,MAAM,OAAO,KAAA;EAC5C,IAAI,SAAS,KAAA,GAAW,OAAO;GAAE,MAAM;GAAU,OAAO,IAAI,MAAM,KAAK;EAAE;EAEzE,OAAO;GAAE,MAAM;GAAW;GAAM,QAAQ,aADzB,YAAY,QAAQ,MAAM,SAAS,KAAA,GACW,KAAK;EAAE;CACtE;CAEA,MAAM,OAAO,WAAW,QAAQ,MA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B,aAAa,gBAAgB;CACtD,IAAI,oBAAoBC,qBAAAA,8BAA8B,OAAO,CAAC;CAC9D,OAAO,oBAAoB,aAAa,OAAO,WAAW;AAC5D;;;;;;AASA,SAAS,aAAa,QAAiB,OAAqC;CAC1E,IAAI;EACF,MAAM,UAAA,GAASC,gCAAAA,gBAAAA,CAAgB,MAAM,CAAC,CAAC,OAAO,OAAO;EACrD,IAAI,OAAO,SAAS,GAAG,OAAO;CAChC,QAAQ,CAER;CACA,OAAO,CAAC;EAAE,UAAU;EAAS,SAAS;CAAM,CAAC;AAC/C;;;;;;;AAQA,SAAS,sBAAsB,OAAkC;CAC/D,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,MAAM,IAAI,MAAM,sCAAsC;CAExD,MAAM,cAAc,qBAAqB,QAAQ,MAAM,kBAAkB,KAAA;CACzE,IAAI,EAAA,GAACL,WAAAA,SAAAA,CAAS,WAAW,GAAG,MAAM,IAAI,MAAM,6CAA6C;CAEzF,OAAO;EAAE,iBAAiB;EAAa,SAAA,GADxBK,gCAAAA,gBAAAA,CAAgB,YAAY,QAAQ,MAAM,SAAS,KAAA,CAAS,CAAC,CAAC,OAAO,OACxC;CAAE;AAChD;AAEA,SAAS,QAAQ,OAA2B;CAC1C,OAAO,MAAM,aAAa;AAC5B"}
|
|
1
|
+
{"version":3,"file":"args_derivation.cjs","names":["isString","createHash","canonicalJsonBytes","cachedDeserialize","BLOCK_STORAGE_FACADE_VERSION","parseArgsIssues"],"sources":["../../src/model/args_derivation.ts"],"sourcesContent":["import { parseArgsIssues, type ArgsIssue, type BlockId } from \"@milaboratories/pl-model-common\";\nimport { cachedDeserialize, canonicalJsonBytes } from \"@milaboratories/ts-helpers\";\nimport { isString } from \"es-toolkit\";\nimport { createHash } from \"node:crypto\";\nimport { BLOCK_STORAGE_FACADE_VERSION } from \"@platforma-sdk/model\";\n\n/**\n * What the args derivation of a block with model API version 2 made of the block's storage.\n *\n * - `runnable`: the block has args and may run with them. `issues` holds the warnings its\n * `argsIssues()` found, if any.\n * - `blocked`: the block has args, but its `argsIssues()` found errors in them, so it must not run.\n * `errors` is never empty; `issues` holds every issue found, warnings included.\n * - `absent`: the block has no args, because `args()` threw or returned nothing.\n */\nexport type DerivedArgs =\n | { readonly type: \"runnable\"; readonly args: unknown; readonly issues: readonly ArgsIssue[] }\n | {\n readonly type: \"blocked\";\n readonly args: unknown;\n readonly errors: readonly ArgsIssue[];\n readonly issues: readonly ArgsIssue[];\n }\n | { readonly type: \"absent\"; readonly error: Error };\n\n/**\n * What the prerun args derivation of a block with model API version 2 made of the block's storage.\n *\n * - `staged`: the block has prerun args and is staged with them. `issues` holds the warnings.\n * - `skipped`: its `prerunArgs()` returned nothing, so the block is not staged.\n * - `blocked`: the issues found in the prerun args (or, for a block without its own\n * `prerunArgs()`, in its args) include errors, so the block is not staged. `error` joins the\n * error messages; `issues` holds every issue found.\n * - `failed`: the lambda that builds the prerun args threw, or the derivation itself failed.\n *\n * Whenever the block is not staged, its staging keeps what an earlier derivation rendered.\n */\nexport type DerivedPrerunArgs =\n | { readonly type: \"staged\"; readonly args: unknown; readonly issues: readonly ArgsIssue[] }\n | { readonly type: \"skipped\"; readonly issues: readonly ArgsIssue[] }\n | { readonly type: \"blocked\"; readonly error: string; readonly issues: readonly ArgsIssue[] }\n | { readonly type: \"failed\"; readonly error: string };\n\n/** A reference in a block's args to a block it cannot read from. */\nexport type MissingBlockReference = {\n /** The block the reference names. */\n readonly blockId: BlockId;\n /**\n * `unknown-block`: the project has no such block; `not-above`: the block is the referring block\n * itself or below it.\n */\n readonly reason: \"unknown-block\" | \"not-above\";\n};\n\n/**\n * What keeps a block with model API version 2 from running or from being staged, found by running\n * its args and prerun args derivations on its current storage. Nothing is written.\n */\nexport type BlockReadiness = {\n /** What `args()` and `argsIssues()` make of the current storage. */\n readonly args:\n | { readonly type: \"runnable\" | \"blocked\"; readonly issues: readonly ArgsIssue[] }\n | { readonly type: \"absent\"; readonly error: string };\n /** What the block's prerun args derivation makes of the current storage. */\n readonly prerun: DerivedPrerunArgsSummary;\n /** References in the derived args to blocks the block cannot read from. */\n readonly missingReferences: readonly MissingBlockReference[];\n};\n\n/** {@link DerivedPrerunArgs} without the args. */\nexport type DerivedPrerunArgsSummary =\n | { readonly type: \"staged\" | \"skipped\"; readonly issues: readonly ArgsIssue[] }\n | { readonly type: \"blocked\"; readonly error: string; readonly issues: readonly ArgsIssue[] }\n | { readonly type: \"failed\"; readonly error: string };\n\n/**\n * What a block's `inputsValid` field holds: the errors found in the block's current args, and the\n * fingerprint of the args they were found in. Every args derivation that produces args writes\n * it, with no errors when the block may run.\n *\n * A middle layer that predates args issues never writes or deletes the field, so after it edits\n * the block, the field can be missing or outlive the args it was computed for. The fingerprint\n * tells such a stale field apart: it no longer matches the current args, and says nothing of them.\n */\nexport type ArgsErrorsRecord = {\n /** {@link argsFingerprint} of the current args the errors were found in. */\n readonly argsFingerprint: string;\n /** The errors; empty when the block may run with the args. */\n readonly errors: readonly ArgsIssue[];\n};\n\n/** How a block's `inputsValid` field must change to hold what an args derivation found. */\nexport type ArgsErrorsFieldChange =\n | { readonly type: \"keep\" }\n | { readonly type: \"write\"; readonly data: Uint8Array }\n | { readonly type: \"delete\" };\n\n/**\n * Reads the result of the model's `__pl_args_derive` callback.\n *\n * A model built before args issues returns `{ value }` for args and `{ error }` for none; both\n * read as they did then. A newer model adds the args issues, and returns `{ error, args, issues }`\n * when its `argsIssues()` found errors. Args that are `undefined` are no args, whatever\n * `argsIssues()` said.\n *\n * @throws when `value` is not an object, or carries an `error` that is not a string\n */\nexport function parseArgsDeriveResult(value: unknown): DerivedArgs {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(`Args derivation returned ${value === null ? \"null\" : typeof value}`);\n }\n\n const error = \"error\" in value ? value.error : undefined;\n const issues = \"issues\" in value ? value.issues : undefined;\n if (error !== undefined) {\n if (!isString(error)) throw new Error(`Args derivation error is ${typeof error}, not a string`);\n const args = \"args\" in value ? value.args : undefined;\n if (args === undefined) return { type: \"absent\", error: new Error(error) };\n const errors = argsErrorsOf(issues, error);\n return { type: \"blocked\", args, errors, issues: issuesWithErrors(issues, errors) };\n }\n\n const args = \"value\" in value ? value.value : undefined;\n if (args === undefined) return { type: \"absent\", error: new Error(\"args() returned no args\") };\n return { type: \"runnable\", args, issues: readableIssues(issues) };\n}\n\n/**\n * Reads the result of the model's `__pl_prerunArgs_derive` callback.\n *\n * A model built before args issues returns `{ value }` for prerun args and `{ error }` for none.\n * A newer model adds the issues, and returns `{ error, issues }` when they include errors. An\n * `{ error }` without issues is a lambda that threw.\n *\n * @throws when `value` is not an object, or carries an `error` that is not a string\n */\nexport function parsePrerunArgsDeriveResult(value: unknown): DerivedPrerunArgs {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(`Prerun args derivation returned ${value === null ? \"null\" : typeof value}`);\n }\n\n const error = \"error\" in value ? value.error : undefined;\n const issues = \"issues\" in value ? value.issues : undefined;\n if (error !== undefined) {\n if (!isString(error))\n throw new Error(`Prerun args derivation error is ${typeof error}, not a string`);\n if (issues === undefined) return { type: \"failed\", error };\n return { type: \"blocked\", error, issues: readableIssues(issues) };\n }\n\n const args = \"value\" in value ? value.value : undefined;\n if (args === undefined) return { type: \"skipped\", issues: readableIssues(issues) };\n return { type: \"staged\", args, issues: readableIssues(issues) };\n}\n\n/** The args an args derivation produced; `undefined` when it produced none. */\nexport function derivedArgsValue(derived: DerivedArgs): unknown {\n return derived.type === \"absent\" ? undefined : derived.args;\n}\n\n/**\n * Identifies a value of a block's current args by its content: the SHA-256 of its canonical JSON,\n * in hex. Args that encode to the same JSON, whatever the key order, share a fingerprint.\n */\nexport function argsFingerprint(args: unknown): string {\n return createHash(\"sha256\").update(canonicalJsonBytes(args)).digest(\"hex\");\n}\n\n/**\n * What a block's `inputsValid` field must become after an args derivation, given the field as it\n * is now.\n *\n * The field holds a {@link ArgsErrorsRecord} as canonical JSON, and exists while the block has\n * args: with the errors its `argsIssues()` found in them, and with none when it found none. A\n * field already holding the same record is kept as it is, so that readers of the project are not\n * woken by a write that changes nothing.\n */\nexport function argsErrorsFieldChange(\n current: { readonly value?: Uint8Array } | undefined,\n derived: DerivedArgs,\n): ArgsErrorsFieldChange {\n if (derived.type === \"absent\")\n return current === undefined ? { type: \"keep\" } : { type: \"delete\" };\n const record: ArgsErrorsRecord = {\n argsFingerprint: argsFingerprint(derived.args),\n errors: derived.type === \"blocked\" ? derived.errors : [],\n };\n const data = canonicalJsonBytes(record);\n if (current?.value !== undefined && Buffer.compare(current.value, data) === 0) {\n return { type: \"keep\" };\n }\n return { type: \"write\", data };\n}\n\n/**\n * The errors a block's `inputsValid` field, as {@link argsErrorsFieldChange} writes it, records\n * for the block's current args.\n *\n * A field that is missing, cannot be read, or was written for other args records none: the args\n * were written by a middle layer that does not know the field. Such a middle layer refuses every\n * block whose `argsIssues()` could find errors, so it wrote args only for blocks whose `args()`\n * throws instead, and those args may run, as they always could. No current args hold no errors:\n * without args the block may not run anyway.\n *\n * @param data - Content of the field; `undefined` when there is none, or while it is not loaded\n * @param currentArgs - The block's current args as decoded from its `currentArgs` field;\n * `undefined` when the block has none\n */\nexport function readArgsErrorsField(\n data: Uint8Array | undefined,\n currentArgs: unknown,\n): readonly ArgsIssue[] {\n if (currentArgs === undefined || data === undefined) return [];\n let record: ArgsErrorsRecord;\n try {\n record = parseArgsErrorsRecord(cachedDeserialize(data));\n } catch {\n return [];\n }\n return record.argsFingerprint === argsFingerprint(currentArgs) ? record.errors : [];\n}\n\n/**\n * The errors found in a block's current args, read from its `inputsValid` field as\n * {@link readArgsErrorsField} reads it.\n *\n * Only a block with model API version 2 has args errors. An earlier model tells whether the block\n * may run by itself, and a field left over from a later model version does not apply to it: such\n * a block has none.\n */\nexport function argsErrorsOfBlock(block: {\n /** Model API version of the block's current block pack. */\n readonly modelAPIVersion: number | undefined;\n /** The block's `inputsValid` field; `undefined` when there is none. */\n readonly inputsValid: { readonly value?: Uint8Array } | undefined;\n /** The block's current args; `undefined` when it has none. */\n readonly currentArgs: unknown;\n}): readonly ArgsIssue[] {\n const { modelAPIVersion, inputsValid, currentArgs } = block;\n if (modelAPIVersion !== BLOCK_STORAGE_FACADE_VERSION) return [];\n return readArgsErrorsField(inputsValid?.value, currentArgs);\n}\n\n// Internals\n\n/**\n * The errors among the issues of a derivation whose `argsIssues()` found errors. Issues that\n * cannot be read, or that hold no error, give way to `error`, the joined messages the model\n * reported.\n */\nfunction argsErrorsOf(issues: unknown, error: string): readonly ArgsIssue[] {\n try {\n const errors = parseArgsIssues(issues).filter(isError);\n if (errors.length > 0) return errors;\n } catch {\n // An older or broken model: `error` alone tells why the block must not run.\n }\n return [{ severity: \"error\", message: error }];\n}\n\n/**\n * Reads a {@link ArgsErrorsRecord} from decoded field content. Issues other than errors are\n * dropped.\n *\n * @throws when `value` is not an object carrying a string fingerprint and a list of issues\n */\nfunction parseArgsErrorsRecord(value: unknown): ArgsErrorsRecord {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(\"Args errors record must be an object\");\n }\n const fingerprint = \"argsFingerprint\" in value ? value.argsFingerprint : undefined;\n if (!isString(fingerprint)) throw new Error(\"Args errors record must carry a fingerprint\");\n const errors = parseArgsIssues(\"errors\" in value ? value.errors : undefined).filter(isError);\n return { argsFingerprint: fingerprint, errors };\n}\n\nfunction isError(issue: ArgsIssue): boolean {\n return issue.severity === \"error\";\n}\n\n/** The issues of a derivation result; none when they cannot be read. */\nfunction readableIssues(issues: unknown): readonly ArgsIssue[] {\n if (issues === undefined) return [];\n try {\n return parseArgsIssues(issues);\n } catch {\n return [];\n }\n}\n\n/**\n * Every issue of a derivation whose `argsIssues()` found errors: the readable issues when they\n * hold the errors, otherwise the errors that stood in for them.\n */\nfunction issuesWithErrors(issues: unknown, errors: readonly ArgsIssue[]): readonly ArgsIssue[] {\n const readable = readableIssues(issues);\n return readable.some(isError) ? readable : [...errors, ...readable];\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA2GA,SAAgB,sBAAsB,OAA6B;CACjE,IA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"}
|
|
@@ -1,21 +1,91 @@
|
|
|
1
|
-
import { ArgsIssue } from "@milaboratories/pl-model-common";
|
|
1
|
+
import { ArgsIssue, BlockId } from "@milaboratories/pl-model-common";
|
|
2
2
|
/**
|
|
3
3
|
* What the args derivation of a block with model API version 2 made of the block's storage.
|
|
4
4
|
*
|
|
5
|
-
* - `runnable`: the block has args and may run with them.
|
|
5
|
+
* - `runnable`: the block has args and may run with them. `issues` holds the warnings its
|
|
6
|
+
* `argsIssues()` found, if any.
|
|
6
7
|
* - `blocked`: the block has args, but its `argsIssues()` found errors in them, so it must not run.
|
|
7
|
-
* `errors` is never empty.
|
|
8
|
+
* `errors` is never empty; `issues` holds every issue found, warnings included.
|
|
8
9
|
* - `absent`: the block has no args, because `args()` threw or returned nothing.
|
|
9
10
|
*/
|
|
10
11
|
export type DerivedArgs = {
|
|
11
12
|
readonly type: "runnable";
|
|
12
13
|
readonly args: unknown;
|
|
14
|
+
readonly issues: readonly ArgsIssue[];
|
|
13
15
|
} | {
|
|
14
16
|
readonly type: "blocked";
|
|
15
17
|
readonly args: unknown;
|
|
16
18
|
readonly errors: readonly ArgsIssue[];
|
|
19
|
+
readonly issues: readonly ArgsIssue[];
|
|
17
20
|
} | {
|
|
18
21
|
readonly type: "absent";
|
|
19
22
|
readonly error: Error;
|
|
20
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* What the prerun args derivation of a block with model API version 2 made of the block's storage.
|
|
26
|
+
*
|
|
27
|
+
* - `staged`: the block has prerun args and is staged with them. `issues` holds the warnings.
|
|
28
|
+
* - `skipped`: its `prerunArgs()` returned nothing, so the block is not staged.
|
|
29
|
+
* - `blocked`: the issues found in the prerun args (or, for a block without its own
|
|
30
|
+
* `prerunArgs()`, in its args) include errors, so the block is not staged. `error` joins the
|
|
31
|
+
* error messages; `issues` holds every issue found.
|
|
32
|
+
* - `failed`: the lambda that builds the prerun args threw, or the derivation itself failed.
|
|
33
|
+
*
|
|
34
|
+
* Whenever the block is not staged, its staging keeps what an earlier derivation rendered.
|
|
35
|
+
*/
|
|
36
|
+
export type DerivedPrerunArgs = {
|
|
37
|
+
readonly type: "staged";
|
|
38
|
+
readonly args: unknown;
|
|
39
|
+
readonly issues: readonly ArgsIssue[];
|
|
40
|
+
} | {
|
|
41
|
+
readonly type: "skipped";
|
|
42
|
+
readonly issues: readonly ArgsIssue[];
|
|
43
|
+
} | {
|
|
44
|
+
readonly type: "blocked";
|
|
45
|
+
readonly error: string;
|
|
46
|
+
readonly issues: readonly ArgsIssue[];
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: "failed";
|
|
49
|
+
readonly error: string;
|
|
50
|
+
};
|
|
51
|
+
/** A reference in a block's args to a block it cannot read from. */
|
|
52
|
+
export type MissingBlockReference = {
|
|
53
|
+
/** The block the reference names. */
|
|
54
|
+
readonly blockId: BlockId;
|
|
55
|
+
/**
|
|
56
|
+
* `unknown-block`: the project has no such block; `not-above`: the block is the referring block
|
|
57
|
+
* itself or below it.
|
|
58
|
+
*/
|
|
59
|
+
readonly reason: "unknown-block" | "not-above";
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* What keeps a block with model API version 2 from running or from being staged, found by running
|
|
63
|
+
* its args and prerun args derivations on its current storage. Nothing is written.
|
|
64
|
+
*/
|
|
65
|
+
export type BlockReadiness = {
|
|
66
|
+
/** What `args()` and `argsIssues()` make of the current storage. */
|
|
67
|
+
readonly args: {
|
|
68
|
+
readonly type: "runnable" | "blocked";
|
|
69
|
+
readonly issues: readonly ArgsIssue[];
|
|
70
|
+
} | {
|
|
71
|
+
readonly type: "absent";
|
|
72
|
+
readonly error: string;
|
|
73
|
+
};
|
|
74
|
+
/** What the block's prerun args derivation makes of the current storage. */
|
|
75
|
+
readonly prerun: DerivedPrerunArgsSummary;
|
|
76
|
+
/** References in the derived args to blocks the block cannot read from. */
|
|
77
|
+
readonly missingReferences: readonly MissingBlockReference[];
|
|
78
|
+
};
|
|
79
|
+
/** {@link DerivedPrerunArgs} without the args. */
|
|
80
|
+
export type DerivedPrerunArgsSummary = {
|
|
81
|
+
readonly type: "staged" | "skipped";
|
|
82
|
+
readonly issues: readonly ArgsIssue[];
|
|
83
|
+
} | {
|
|
84
|
+
readonly type: "blocked";
|
|
85
|
+
readonly error: string;
|
|
86
|
+
readonly issues: readonly ArgsIssue[];
|
|
87
|
+
} | {
|
|
88
|
+
readonly type: "failed";
|
|
89
|
+
readonly error: string;
|
|
90
|
+
};
|
|
21
91
|
//# sourceMappingURL=args_derivation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args_derivation.d.ts","names":[],"sources":["../../src/model/args_derivation.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"args_derivation.d.ts","names":[],"sources":["../../src/model/args_derivation.ts"],"mappings":";;;;;;;;;;YAeY;WACG;WAA2B;WAAwB,iBAAiB;;WAEpE;WACA;WACA,iBAAiB;WACjB,iBAAiB;;WAEjB;WAAyB,OAAO;;;;;;;;;;;;;;YAcnC;WACG;WAAyB;WAAwB,iBAAiB;;WAClE;WAA0B,iBAAiB;;WAC3C;WAA0B;WAAwB,iBAAiB;;WACnE;WAAyB;;;YAG5B;;WAED,SAAS;;;;;WAKT;;;;;;YAOC;;WAED;aACM;aAAuC,iBAAiB;;aACxD;aAAyB;;;WAE/B,QAAQ;;WAER,4BAA4B;;;YAI3B;WACG;WAAqC,iBAAiB;;WACtD;WAA0B;WAAwB,iBAAiB;;WACnE;WAAyB"}
|
|
@@ -17,6 +17,7 @@ import { isString } from "es-toolkit";
|
|
|
17
17
|
function parseArgsDeriveResult(value) {
|
|
18
18
|
if (typeof value !== "object" || value === null) throw new Error(`Args derivation returned ${value === null ? "null" : typeof value}`);
|
|
19
19
|
const error = "error" in value ? value.error : void 0;
|
|
20
|
+
const issues = "issues" in value ? value.issues : void 0;
|
|
20
21
|
if (error !== void 0) {
|
|
21
22
|
if (!isString(error)) throw new Error(`Args derivation error is ${typeof error}, not a string`);
|
|
22
23
|
const args = "args" in value ? value.args : void 0;
|
|
@@ -24,10 +25,12 @@ function parseArgsDeriveResult(value) {
|
|
|
24
25
|
type: "absent",
|
|
25
26
|
error: new Error(error)
|
|
26
27
|
};
|
|
28
|
+
const errors = argsErrorsOf(issues, error);
|
|
27
29
|
return {
|
|
28
30
|
type: "blocked",
|
|
29
31
|
args,
|
|
30
|
-
errors
|
|
32
|
+
errors,
|
|
33
|
+
issues: issuesWithErrors(issues, errors)
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
36
|
const args = "value" in value ? value.value : void 0;
|
|
@@ -37,7 +40,44 @@ function parseArgsDeriveResult(value) {
|
|
|
37
40
|
};
|
|
38
41
|
return {
|
|
39
42
|
type: "runnable",
|
|
40
|
-
args
|
|
43
|
+
args,
|
|
44
|
+
issues: readableIssues(issues)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Reads the result of the model's `__pl_prerunArgs_derive` callback.
|
|
49
|
+
*
|
|
50
|
+
* A model built before args issues returns `{ value }` for prerun args and `{ error }` for none.
|
|
51
|
+
* A newer model adds the issues, and returns `{ error, issues }` when they include errors. An
|
|
52
|
+
* `{ error }` without issues is a lambda that threw.
|
|
53
|
+
*
|
|
54
|
+
* @throws when `value` is not an object, or carries an `error` that is not a string
|
|
55
|
+
*/
|
|
56
|
+
function parsePrerunArgsDeriveResult(value) {
|
|
57
|
+
if (typeof value !== "object" || value === null) throw new Error(`Prerun args derivation returned ${value === null ? "null" : typeof value}`);
|
|
58
|
+
const error = "error" in value ? value.error : void 0;
|
|
59
|
+
const issues = "issues" in value ? value.issues : void 0;
|
|
60
|
+
if (error !== void 0) {
|
|
61
|
+
if (!isString(error)) throw new Error(`Prerun args derivation error is ${typeof error}, not a string`);
|
|
62
|
+
if (issues === void 0) return {
|
|
63
|
+
type: "failed",
|
|
64
|
+
error
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
type: "blocked",
|
|
68
|
+
error,
|
|
69
|
+
issues: readableIssues(issues)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const args = "value" in value ? value.value : void 0;
|
|
73
|
+
if (args === void 0) return {
|
|
74
|
+
type: "skipped",
|
|
75
|
+
issues: readableIssues(issues)
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
type: "staged",
|
|
79
|
+
args,
|
|
80
|
+
issues: readableIssues(issues)
|
|
41
81
|
};
|
|
42
82
|
}
|
|
43
83
|
/** The args an args derivation produced; `undefined` when it produced none. */
|
|
@@ -143,6 +183,23 @@ function parseArgsErrorsRecord(value) {
|
|
|
143
183
|
function isError(issue) {
|
|
144
184
|
return issue.severity === "error";
|
|
145
185
|
}
|
|
146
|
-
|
|
186
|
+
/** The issues of a derivation result; none when they cannot be read. */
|
|
187
|
+
function readableIssues(issues) {
|
|
188
|
+
if (issues === void 0) return [];
|
|
189
|
+
try {
|
|
190
|
+
return parseArgsIssues(issues);
|
|
191
|
+
} catch {
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Every issue of a derivation whose `argsIssues()` found errors: the readable issues when they
|
|
197
|
+
* hold the errors, otherwise the errors that stood in for them.
|
|
198
|
+
*/
|
|
199
|
+
function issuesWithErrors(issues, errors) {
|
|
200
|
+
const readable = readableIssues(issues);
|
|
201
|
+
return readable.some(isError) ? readable : [...errors, ...readable];
|
|
202
|
+
}
|
|
203
|
+
export { argsErrorsFieldChange, argsErrorsOfBlock, argsFingerprint, derivedArgsValue, parseArgsDeriveResult, parsePrerunArgsDeriveResult, readArgsErrorsField };
|
|
147
204
|
|
|
148
205
|
//# sourceMappingURL=args_derivation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args_derivation.js","names":[],"sources":["../../src/model/args_derivation.ts"],"sourcesContent":["import { parseArgsIssues, type ArgsIssue } from \"@milaboratories/pl-model-common\";\nimport { cachedDeserialize, canonicalJsonBytes } from \"@milaboratories/ts-helpers\";\nimport { isString } from \"es-toolkit\";\nimport { createHash } from \"node:crypto\";\nimport { BLOCK_STORAGE_FACADE_VERSION } from \"@platforma-sdk/model\";\n\n/**\n * What the args derivation of a block with model API version 2 made of the block's storage.\n *\n * - `runnable`: the block has args and may run with them.\n * - `blocked`: the block has args, but its `argsIssues()` found errors in them, so it must not run.\n * `errors` is never empty.\n * - `absent`: the block has no args, because `args()` threw or returned nothing.\n */\nexport type DerivedArgs =\n | { readonly type: \"runnable\"; readonly args: unknown }\n | { readonly type: \"blocked\"; readonly args: unknown; readonly errors: readonly ArgsIssue[] }\n | { readonly type: \"absent\"; readonly error: Error };\n\n/**\n * What a block's `inputsValid` field holds: the errors found in the block's current args, and the\n * fingerprint of the args they were found in. Every args derivation that produces args writes\n * it, with no errors when the block may run.\n *\n * A middle layer that predates args issues never writes or deletes the field, so after it edits\n * the block, the field can be missing or outlive the args it was computed for. The fingerprint\n * tells such a stale field apart: it no longer matches the current args, and says nothing of them.\n */\nexport type ArgsErrorsRecord = {\n /** {@link argsFingerprint} of the current args the errors were found in. */\n readonly argsFingerprint: string;\n /** The errors; empty when the block may run with the args. */\n readonly errors: readonly ArgsIssue[];\n};\n\n/** How a block's `inputsValid` field must change to hold what an args derivation found. */\nexport type ArgsErrorsFieldChange =\n | { readonly type: \"keep\" }\n | { readonly type: \"write\"; readonly data: Uint8Array }\n | { readonly type: \"delete\" };\n\n/**\n * Reads the result of the model's `__pl_args_derive` callback.\n *\n * A model built before args issues returns `{ value }` for args and `{ error }` for none; both\n * read as they did then. A newer model adds the args issues, and returns `{ error, args, issues }`\n * when its `argsIssues()` found errors. Args that are `undefined` are no args, whatever\n * `argsIssues()` said.\n *\n * @throws when `value` is not an object, or carries an `error` that is not a string\n */\nexport function parseArgsDeriveResult(value: unknown): DerivedArgs {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(`Args derivation returned ${value === null ? \"null\" : typeof value}`);\n }\n\n const error = \"error\" in value ? value.error : undefined;\n if (error !== undefined) {\n if (!isString(error)) throw new Error(`Args derivation error is ${typeof error}, not a string`);\n const args = \"args\" in value ? value.args : undefined;\n if (args === undefined) return { type: \"absent\", error: new Error(error) };\n const issues = \"issues\" in value ? value.issues : undefined;\n return { type: \"blocked\", args, errors: argsErrorsOf(issues, error) };\n }\n\n const args = \"value\" in value ? value.value : undefined;\n if (args === undefined) return { type: \"absent\", error: new Error(\"args() returned no args\") };\n return { type: \"runnable\", args };\n}\n\n/** The args an args derivation produced; `undefined` when it produced none. */\nexport function derivedArgsValue(derived: DerivedArgs): unknown {\n return derived.type === \"absent\" ? undefined : derived.args;\n}\n\n/**\n * Identifies a value of a block's current args by its content: the SHA-256 of its canonical JSON,\n * in hex. Args that encode to the same JSON, whatever the key order, share a fingerprint.\n */\nexport function argsFingerprint(args: unknown): string {\n return createHash(\"sha256\").update(canonicalJsonBytes(args)).digest(\"hex\");\n}\n\n/**\n * What a block's `inputsValid` field must become after an args derivation, given the field as it\n * is now.\n *\n * The field holds a {@link ArgsErrorsRecord} as canonical JSON, and exists while the block has\n * args: with the errors its `argsIssues()` found in them, and with none when it found none. A\n * field already holding the same record is kept as it is, so that readers of the project are not\n * woken by a write that changes nothing.\n */\nexport function argsErrorsFieldChange(\n current: { readonly value?: Uint8Array } | undefined,\n derived: DerivedArgs,\n): ArgsErrorsFieldChange {\n if (derived.type === \"absent\")\n return current === undefined ? { type: \"keep\" } : { type: \"delete\" };\n const record: ArgsErrorsRecord = {\n argsFingerprint: argsFingerprint(derived.args),\n errors: derived.type === \"blocked\" ? derived.errors : [],\n };\n const data = canonicalJsonBytes(record);\n if (current?.value !== undefined && Buffer.compare(current.value, data) === 0) {\n return { type: \"keep\" };\n }\n return { type: \"write\", data };\n}\n\n/**\n * The errors a block's `inputsValid` field, as {@link argsErrorsFieldChange} writes it, records\n * for the block's current args.\n *\n * A field that is missing, cannot be read, or was written for other args records none: the args\n * were written by a middle layer that does not know the field. Such a middle layer refuses every\n * block whose `argsIssues()` could find errors, so it wrote args only for blocks whose `args()`\n * throws instead, and those args may run, as they always could. No current args hold no errors:\n * without args the block may not run anyway.\n *\n * @param data - Content of the field; `undefined` when there is none, or while it is not loaded\n * @param currentArgs - The block's current args as decoded from its `currentArgs` field;\n * `undefined` when the block has none\n */\nexport function readArgsErrorsField(\n data: Uint8Array | undefined,\n currentArgs: unknown,\n): readonly ArgsIssue[] {\n if (currentArgs === undefined || data === undefined) return [];\n let record: ArgsErrorsRecord;\n try {\n record = parseArgsErrorsRecord(cachedDeserialize(data));\n } catch {\n return [];\n }\n return record.argsFingerprint === argsFingerprint(currentArgs) ? record.errors : [];\n}\n\n/**\n * The errors found in a block's current args, read from its `inputsValid` field as\n * {@link readArgsErrorsField} reads it.\n *\n * Only a block with model API version 2 has args errors. An earlier model tells whether the block\n * may run by itself, and a field left over from a later model version does not apply to it: such\n * a block has none.\n */\nexport function argsErrorsOfBlock(block: {\n /** Model API version of the block's current block pack. */\n readonly modelAPIVersion: number | undefined;\n /** The block's `inputsValid` field; `undefined` when there is none. */\n readonly inputsValid: { readonly value?: Uint8Array } | undefined;\n /** The block's current args; `undefined` when it has none. */\n readonly currentArgs: unknown;\n}): readonly ArgsIssue[] {\n const { modelAPIVersion, inputsValid, currentArgs } = block;\n if (modelAPIVersion !== BLOCK_STORAGE_FACADE_VERSION) return [];\n return readArgsErrorsField(inputsValid?.value, currentArgs);\n}\n\n// Internals\n\n/**\n * The errors among the issues of a derivation whose `argsIssues()` found errors. Issues that\n * cannot be read, or that hold no error, give way to `error`, the joined messages the model\n * reported.\n */\nfunction argsErrorsOf(issues: unknown, error: string): readonly ArgsIssue[] {\n try {\n const errors = parseArgsIssues(issues).filter(isError);\n if (errors.length > 0) return errors;\n } catch {\n // An older or broken model: `error` alone tells why the block must not run.\n }\n return [{ severity: \"error\", message: error }];\n}\n\n/**\n * Reads a {@link ArgsErrorsRecord} from decoded field content. Issues other than errors are\n * dropped.\n *\n * @throws when `value` is not an object carrying a string fingerprint and a list of issues\n */\nfunction parseArgsErrorsRecord(value: unknown): ArgsErrorsRecord {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(\"Args errors record must be an object\");\n }\n const fingerprint = \"argsFingerprint\" in value ? value.argsFingerprint : undefined;\n if (!isString(fingerprint)) throw new Error(\"Args errors record must carry a fingerprint\");\n const errors = parseArgsIssues(\"errors\" in value ? value.errors : undefined).filter(isError);\n return { argsFingerprint: fingerprint, errors };\n}\n\nfunction isError(issue: ArgsIssue): boolean {\n return issue.severity === \"error\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmDA,SAAgB,sBAAsB,OAA6B;CACjE,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,MAAM,IAAI,MAAM,4BAA4B,UAAU,OAAO,SAAS,OAAO,OAAO;CAGtF,MAAM,QAAQ,WAAW,QAAQ,MAAM,QAAQ,KAAA;CAC/C,IAAI,UAAU,KAAA,GAAW;EACvB,IAAI,CAAC,SAAS,KAAK,GAAG,MAAM,IAAI,MAAM,4BAA4B,OAAO,MAAM,eAAe;EAC9F,MAAM,OAAO,UAAU,QAAQ,MAAM,OAAO,KAAA;EAC5C,IAAI,SAAS,KAAA,GAAW,OAAO;GAAE,MAAM;GAAU,OAAO,IAAI,MAAM,KAAK;EAAE;EAEzE,OAAO;GAAE,MAAM;GAAW;GAAM,QAAQ,aADzB,YAAY,QAAQ,MAAM,SAAS,KAAA,GACW,KAAK;EAAE;CACtE;CAEA,MAAM,OAAO,WAAW,QAAQ,MAAM,QAAQ,KAAA;CAC9C,IAAI,SAAS,KAAA,GAAW,OAAO;EAAE,MAAM;EAAU,uBAAO,IAAI,MAAM,yBAAyB;CAAE;CAC7F,OAAO;EAAE,MAAM;EAAY;CAAK;AAClC;;AAGA,SAAgB,iBAAiB,SAA+B;CAC9D,OAAO,QAAQ,SAAS,WAAW,KAAA,IAAY,QAAQ;AACzD;;;;;AAMA,SAAgB,gBAAgB,MAAuB;CACrD,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,mBAAmB,IAAI,CAAC,CAAC,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AExD,MAAM,cAAc,qBAAqB,QAAQ,MAAM,kBAAkB,KAAA;CACzE,IAAI,CAAC,SAAS,WAAW,GAAG,MAAM,IAAI,MAAM,6CAA6C;CAEzF,OAAO;EAAE,iBAAiB;EAAa,QADxB,gBAAgB,YAAY,QAAQ,MAAM,SAAS,KAAA,CAAS,CAAC,CAAC,OAAO,OACxC;CAAE;AAChD;AAEA,SAAS,QAAQ,OAA2B;CAC1C,OAAO,MAAM,aAAa;AAC5B"}
|
|
1
|
+
{"version":3,"file":"args_derivation.js","names":[],"sources":["../../src/model/args_derivation.ts"],"sourcesContent":["import { parseArgsIssues, type ArgsIssue, type BlockId } from \"@milaboratories/pl-model-common\";\nimport { cachedDeserialize, canonicalJsonBytes } from \"@milaboratories/ts-helpers\";\nimport { isString } from \"es-toolkit\";\nimport { createHash } from \"node:crypto\";\nimport { BLOCK_STORAGE_FACADE_VERSION } from \"@platforma-sdk/model\";\n\n/**\n * What the args derivation of a block with model API version 2 made of the block's storage.\n *\n * - `runnable`: the block has args and may run with them. `issues` holds the warnings its\n * `argsIssues()` found, if any.\n * - `blocked`: the block has args, but its `argsIssues()` found errors in them, so it must not run.\n * `errors` is never empty; `issues` holds every issue found, warnings included.\n * - `absent`: the block has no args, because `args()` threw or returned nothing.\n */\nexport type DerivedArgs =\n | { readonly type: \"runnable\"; readonly args: unknown; readonly issues: readonly ArgsIssue[] }\n | {\n readonly type: \"blocked\";\n readonly args: unknown;\n readonly errors: readonly ArgsIssue[];\n readonly issues: readonly ArgsIssue[];\n }\n | { readonly type: \"absent\"; readonly error: Error };\n\n/**\n * What the prerun args derivation of a block with model API version 2 made of the block's storage.\n *\n * - `staged`: the block has prerun args and is staged with them. `issues` holds the warnings.\n * - `skipped`: its `prerunArgs()` returned nothing, so the block is not staged.\n * - `blocked`: the issues found in the prerun args (or, for a block without its own\n * `prerunArgs()`, in its args) include errors, so the block is not staged. `error` joins the\n * error messages; `issues` holds every issue found.\n * - `failed`: the lambda that builds the prerun args threw, or the derivation itself failed.\n *\n * Whenever the block is not staged, its staging keeps what an earlier derivation rendered.\n */\nexport type DerivedPrerunArgs =\n | { readonly type: \"staged\"; readonly args: unknown; readonly issues: readonly ArgsIssue[] }\n | { readonly type: \"skipped\"; readonly issues: readonly ArgsIssue[] }\n | { readonly type: \"blocked\"; readonly error: string; readonly issues: readonly ArgsIssue[] }\n | { readonly type: \"failed\"; readonly error: string };\n\n/** A reference in a block's args to a block it cannot read from. */\nexport type MissingBlockReference = {\n /** The block the reference names. */\n readonly blockId: BlockId;\n /**\n * `unknown-block`: the project has no such block; `not-above`: the block is the referring block\n * itself or below it.\n */\n readonly reason: \"unknown-block\" | \"not-above\";\n};\n\n/**\n * What keeps a block with model API version 2 from running or from being staged, found by running\n * its args and prerun args derivations on its current storage. Nothing is written.\n */\nexport type BlockReadiness = {\n /** What `args()` and `argsIssues()` make of the current storage. */\n readonly args:\n | { readonly type: \"runnable\" | \"blocked\"; readonly issues: readonly ArgsIssue[] }\n | { readonly type: \"absent\"; readonly error: string };\n /** What the block's prerun args derivation makes of the current storage. */\n readonly prerun: DerivedPrerunArgsSummary;\n /** References in the derived args to blocks the block cannot read from. */\n readonly missingReferences: readonly MissingBlockReference[];\n};\n\n/** {@link DerivedPrerunArgs} without the args. */\nexport type DerivedPrerunArgsSummary =\n | { readonly type: \"staged\" | \"skipped\"; readonly issues: readonly ArgsIssue[] }\n | { readonly type: \"blocked\"; readonly error: string; readonly issues: readonly ArgsIssue[] }\n | { readonly type: \"failed\"; readonly error: string };\n\n/**\n * What a block's `inputsValid` field holds: the errors found in the block's current args, and the\n * fingerprint of the args they were found in. Every args derivation that produces args writes\n * it, with no errors when the block may run.\n *\n * A middle layer that predates args issues never writes or deletes the field, so after it edits\n * the block, the field can be missing or outlive the args it was computed for. The fingerprint\n * tells such a stale field apart: it no longer matches the current args, and says nothing of them.\n */\nexport type ArgsErrorsRecord = {\n /** {@link argsFingerprint} of the current args the errors were found in. */\n readonly argsFingerprint: string;\n /** The errors; empty when the block may run with the args. */\n readonly errors: readonly ArgsIssue[];\n};\n\n/** How a block's `inputsValid` field must change to hold what an args derivation found. */\nexport type ArgsErrorsFieldChange =\n | { readonly type: \"keep\" }\n | { readonly type: \"write\"; readonly data: Uint8Array }\n | { readonly type: \"delete\" };\n\n/**\n * Reads the result of the model's `__pl_args_derive` callback.\n *\n * A model built before args issues returns `{ value }` for args and `{ error }` for none; both\n * read as they did then. A newer model adds the args issues, and returns `{ error, args, issues }`\n * when its `argsIssues()` found errors. Args that are `undefined` are no args, whatever\n * `argsIssues()` said.\n *\n * @throws when `value` is not an object, or carries an `error` that is not a string\n */\nexport function parseArgsDeriveResult(value: unknown): DerivedArgs {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(`Args derivation returned ${value === null ? \"null\" : typeof value}`);\n }\n\n const error = \"error\" in value ? value.error : undefined;\n const issues = \"issues\" in value ? value.issues : undefined;\n if (error !== undefined) {\n if (!isString(error)) throw new Error(`Args derivation error is ${typeof error}, not a string`);\n const args = \"args\" in value ? value.args : undefined;\n if (args === undefined) return { type: \"absent\", error: new Error(error) };\n const errors = argsErrorsOf(issues, error);\n return { type: \"blocked\", args, errors, issues: issuesWithErrors(issues, errors) };\n }\n\n const args = \"value\" in value ? value.value : undefined;\n if (args === undefined) return { type: \"absent\", error: new Error(\"args() returned no args\") };\n return { type: \"runnable\", args, issues: readableIssues(issues) };\n}\n\n/**\n * Reads the result of the model's `__pl_prerunArgs_derive` callback.\n *\n * A model built before args issues returns `{ value }` for prerun args and `{ error }` for none.\n * A newer model adds the issues, and returns `{ error, issues }` when they include errors. An\n * `{ error }` without issues is a lambda that threw.\n *\n * @throws when `value` is not an object, or carries an `error` that is not a string\n */\nexport function parsePrerunArgsDeriveResult(value: unknown): DerivedPrerunArgs {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(`Prerun args derivation returned ${value === null ? \"null\" : typeof value}`);\n }\n\n const error = \"error\" in value ? value.error : undefined;\n const issues = \"issues\" in value ? value.issues : undefined;\n if (error !== undefined) {\n if (!isString(error))\n throw new Error(`Prerun args derivation error is ${typeof error}, not a string`);\n if (issues === undefined) return { type: \"failed\", error };\n return { type: \"blocked\", error, issues: readableIssues(issues) };\n }\n\n const args = \"value\" in value ? value.value : undefined;\n if (args === undefined) return { type: \"skipped\", issues: readableIssues(issues) };\n return { type: \"staged\", args, issues: readableIssues(issues) };\n}\n\n/** The args an args derivation produced; `undefined` when it produced none. */\nexport function derivedArgsValue(derived: DerivedArgs): unknown {\n return derived.type === \"absent\" ? undefined : derived.args;\n}\n\n/**\n * Identifies a value of a block's current args by its content: the SHA-256 of its canonical JSON,\n * in hex. Args that encode to the same JSON, whatever the key order, share a fingerprint.\n */\nexport function argsFingerprint(args: unknown): string {\n return createHash(\"sha256\").update(canonicalJsonBytes(args)).digest(\"hex\");\n}\n\n/**\n * What a block's `inputsValid` field must become after an args derivation, given the field as it\n * is now.\n *\n * The field holds a {@link ArgsErrorsRecord} as canonical JSON, and exists while the block has\n * args: with the errors its `argsIssues()` found in them, and with none when it found none. A\n * field already holding the same record is kept as it is, so that readers of the project are not\n * woken by a write that changes nothing.\n */\nexport function argsErrorsFieldChange(\n current: { readonly value?: Uint8Array } | undefined,\n derived: DerivedArgs,\n): ArgsErrorsFieldChange {\n if (derived.type === \"absent\")\n return current === undefined ? { type: \"keep\" } : { type: \"delete\" };\n const record: ArgsErrorsRecord = {\n argsFingerprint: argsFingerprint(derived.args),\n errors: derived.type === \"blocked\" ? derived.errors : [],\n };\n const data = canonicalJsonBytes(record);\n if (current?.value !== undefined && Buffer.compare(current.value, data) === 0) {\n return { type: \"keep\" };\n }\n return { type: \"write\", data };\n}\n\n/**\n * The errors a block's `inputsValid` field, as {@link argsErrorsFieldChange} writes it, records\n * for the block's current args.\n *\n * A field that is missing, cannot be read, or was written for other args records none: the args\n * were written by a middle layer that does not know the field. Such a middle layer refuses every\n * block whose `argsIssues()` could find errors, so it wrote args only for blocks whose `args()`\n * throws instead, and those args may run, as they always could. No current args hold no errors:\n * without args the block may not run anyway.\n *\n * @param data - Content of the field; `undefined` when there is none, or while it is not loaded\n * @param currentArgs - The block's current args as decoded from its `currentArgs` field;\n * `undefined` when the block has none\n */\nexport function readArgsErrorsField(\n data: Uint8Array | undefined,\n currentArgs: unknown,\n): readonly ArgsIssue[] {\n if (currentArgs === undefined || data === undefined) return [];\n let record: ArgsErrorsRecord;\n try {\n record = parseArgsErrorsRecord(cachedDeserialize(data));\n } catch {\n return [];\n }\n return record.argsFingerprint === argsFingerprint(currentArgs) ? record.errors : [];\n}\n\n/**\n * The errors found in a block's current args, read from its `inputsValid` field as\n * {@link readArgsErrorsField} reads it.\n *\n * Only a block with model API version 2 has args errors. An earlier model tells whether the block\n * may run by itself, and a field left over from a later model version does not apply to it: such\n * a block has none.\n */\nexport function argsErrorsOfBlock(block: {\n /** Model API version of the block's current block pack. */\n readonly modelAPIVersion: number | undefined;\n /** The block's `inputsValid` field; `undefined` when there is none. */\n readonly inputsValid: { readonly value?: Uint8Array } | undefined;\n /** The block's current args; `undefined` when it has none. */\n readonly currentArgs: unknown;\n}): readonly ArgsIssue[] {\n const { modelAPIVersion, inputsValid, currentArgs } = block;\n if (modelAPIVersion !== BLOCK_STORAGE_FACADE_VERSION) return [];\n return readArgsErrorsField(inputsValid?.value, currentArgs);\n}\n\n// Internals\n\n/**\n * The errors among the issues of a derivation whose `argsIssues()` found errors. Issues that\n * cannot be read, or that hold no error, give way to `error`, the joined messages the model\n * reported.\n */\nfunction argsErrorsOf(issues: unknown, error: string): readonly ArgsIssue[] {\n try {\n const errors = parseArgsIssues(issues).filter(isError);\n if (errors.length > 0) return errors;\n } catch {\n // An older or broken model: `error` alone tells why the block must not run.\n }\n return [{ severity: \"error\", message: error }];\n}\n\n/**\n * Reads a {@link ArgsErrorsRecord} from decoded field content. Issues other than errors are\n * dropped.\n *\n * @throws when `value` is not an object carrying a string fingerprint and a list of issues\n */\nfunction parseArgsErrorsRecord(value: unknown): ArgsErrorsRecord {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(\"Args errors record must be an object\");\n }\n const fingerprint = \"argsFingerprint\" in value ? value.argsFingerprint : undefined;\n if (!isString(fingerprint)) throw new Error(\"Args errors record must carry a fingerprint\");\n const errors = parseArgsIssues(\"errors\" in value ? value.errors : undefined).filter(isError);\n return { argsFingerprint: fingerprint, errors };\n}\n\nfunction isError(issue: ArgsIssue): boolean {\n return issue.severity === \"error\";\n}\n\n/** The issues of a derivation result; none when they cannot be read. */\nfunction readableIssues(issues: unknown): readonly ArgsIssue[] {\n if (issues === undefined) return [];\n try {\n return parseArgsIssues(issues);\n } catch {\n return [];\n }\n}\n\n/**\n * Every issue of a derivation whose `argsIssues()` found errors: the readable issues when they\n * hold the errors, otherwise the errors that stood in for them.\n */\nfunction issuesWithErrors(issues: unknown, errors: readonly ArgsIssue[]): readonly ArgsIssue[] {\n const readable = readableIssues(issues);\n return readable.some(isError) ? readable : [...errors, ...readable];\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA2GA,SAAgB,sBAAsB,OAA6B;CACjE,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,MAAM,IAAI,MAAM,4BAA4B,UAAU,OAAO,SAAS,OAAO,OAAO;CAGtF,MAAM,QAAQ,WAAW,QAAQ,MAAM,QAAQ,KAAA;CAC/C,MAAM,SAAS,YAAY,QAAQ,MAAM,SAAS,KAAA;CAClD,IAAI,UAAU,KAAA,GAAW;EACvB,IAAI,CAAC,SAAS,KAAK,GAAG,MAAM,IAAI,MAAM,4BAA4B,OAAO,MAAM,eAAe;EAC9F,MAAM,OAAO,UAAU,QAAQ,MAAM,OAAO,KAAA;EAC5C,IAAI,SAAS,KAAA,GAAW,OAAO;GAAE,MAAM;GAAU,OAAO,IAAI,MAAM,KAAK;EAAE;EACzE,MAAM,SAAS,aAAa,QAAQ,KAAK;EACzC,OAAO;GAAE,MAAM;GAAW;GAAM;GAAQ,QAAQ,iBAAiB,QAAQ,MAAM;EAAE;CACnF;CAEA,MAAM,OAA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,QAAQ,MAAM,SAAS,KAAA,CAAS,CAAC,CAAC,OAAO,OACxC;CAAE;AAChD;AAEA,SAAS,QAAQ,OAA2B;CAC1C,OAAO,MAAM,aAAa;AAC5B;;AAGA,SAAS,eAAe,QAAuC;CAC7D,IAAI,WAAW,KAAA,GAAW,OAAO,CAAC;CAClC,IAAI;EACF,OAAO,gBAAgB,MAAM;CAC/B,QAAQ;EACN,OAAO,CAAC;CACV;AACF;;;;;AAMA,SAAS,iBAAiB,QAAiB,QAAoD;CAC7F,MAAM,WAAW,eAAe,MAAM;CACtC,OAAO,SAAS,KAAK,OAAO,IAAI,WAAW,CAAC,GAAG,QAAQ,GAAG,QAAQ;AACpE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
let _platforma_sdk_model = require("@platforma-sdk/model");
|
|
2
|
+
let _milaboratories_pl_errors = require("@milaboratories/pl-errors");
|
|
3
|
+
// src/model/block_params_model.ts
|
|
4
|
+
/** No template entries: live params already name the blocks of the project. */
|
|
5
|
+
const NO_BLOCK_IDS = /* @__PURE__ */ new Map();
|
|
6
|
+
/**
|
|
7
|
+
* The {@link BlockParamsModel} of block `blockId` with model `config`.
|
|
8
|
+
*
|
|
9
|
+
* @throws {ModelAPIVersionMismatchError} when the block is not on BlockModelV3: such a model has
|
|
10
|
+
* no storage facade and no params
|
|
11
|
+
*/
|
|
12
|
+
function blockParamsModel(helper, blockId, config) {
|
|
13
|
+
if (config.modelAPIVersion !== _platforma_sdk_model.BLOCK_STORAGE_FACADE_VERSION) throw new _milaboratories_pl_errors.ModelAPIVersionMismatchError(blockId, _platforma_sdk_model.BLOCK_STORAGE_FACADE_VERSION, config.modelAPIVersion);
|
|
14
|
+
const callbacks = config.blockLifecycleCallbacks;
|
|
15
|
+
return {
|
|
16
|
+
givesParams: callbacks[_platforma_sdk_model.BlockStorageFacadeCallbacks.InitializationParamsDerive] !== void 0 && callbacks[_platforma_sdk_model.BlockStorageFacadeCallbacks.StorageInitialFromParams] !== void 0,
|
|
17
|
+
paramsOf: ({ dataVersion, data }) => helper.deriveTemplateParamsFromStorage(config, JSON.stringify((0, _platforma_sdk_model.createBlockStorage)(data, dataVersion))),
|
|
18
|
+
dataOf: (params) => {
|
|
19
|
+
const storage = helper.getInitialStorageFromParamsInVM(config, params, NO_BLOCK_IDS);
|
|
20
|
+
if (storage.error !== void 0) return storage;
|
|
21
|
+
return parseVersionedData(storage.value);
|
|
22
|
+
},
|
|
23
|
+
appliesParams: callbacks[_platforma_sdk_model.BlockStorageFacadeCallbacks.StorageApplyParams] !== void 0,
|
|
24
|
+
applyParams: ({ dataVersion, data }, params) => {
|
|
25
|
+
const storage = helper.applyParamsInVM(config, JSON.stringify((0, _platforma_sdk_model.createBlockStorage)(data, dataVersion)), params);
|
|
26
|
+
if (storage.error !== void 0) return storage;
|
|
27
|
+
return parseVersionedData(storage.value);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** The data and its version out of a block storage the model built, as JSON text. */
|
|
32
|
+
function parseVersionedData(storageJson) {
|
|
33
|
+
const storage = JSON.parse(storageJson);
|
|
34
|
+
if (!(0, _platforma_sdk_model.isBlockStorage)(storage) || typeof storage.__dataVersion !== "string") return { error: /* @__PURE__ */ new Error("The block's model built its data in an unknown storage format") };
|
|
35
|
+
return { value: {
|
|
36
|
+
dataVersion: storage.__dataVersion,
|
|
37
|
+
data: storage.__data
|
|
38
|
+
} };
|
|
39
|
+
}
|
|
40
|
+
exports.blockParamsModel = blockParamsModel;
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=block_params_model.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_params_model.cjs","names":["BLOCK_STORAGE_FACADE_VERSION","ModelAPIVersionMismatchError","BlockStorageFacadeCallbacks","createBlockStorage","isBlockStorage"],"sources":["../../src/model/block_params_model.ts"],"sourcesContent":["import type { BlockId } from \"@milaboratories/pl-model-common\";\nimport { ModelAPIVersionMismatchError } from \"@milaboratories/pl-errors\";\nimport type { BlockConfig, ResultOrError } from \"@platforma-sdk/model\";\nimport {\n BLOCK_STORAGE_FACADE_VERSION,\n BlockStorageFacadeCallbacks,\n createBlockStorage,\n isBlockStorage,\n} from \"@platforma-sdk/model\";\nimport type { ProjectHelper } from \"./project_helper\";\n\n/** A block's data with the version of the block's data model it is written in. */\nexport type VersionedBlockData = {\n dataVersion: string;\n data: unknown;\n};\n\n/**\n * A block's model as functions between its kind's initialization params and its data: the data\n * model's `init(params)`, its inverse `templateParams(data)` and, when the block declares it,\n * `applyParams(data, params)`. Each runs the block's own model code in the VM, each call on its\n * own; no block is created and nothing is read from or written to the project.\n */\nexport interface BlockParamsModel {\n /**\n * Whether the model has both functions. A model built before blocks gave params has neither\n * callback; its calls answer with an error.\n */\n readonly givesParams: boolean;\n\n /**\n * `templateParams(data)`: the params the block's model derives from `data`. The data is not\n * migrated first (the SDK does not), so it should be in the version {@link dataOf} produces.\n */\n paramsOf(data: VersionedBlockData): ResultOrError<unknown>;\n\n /**\n * `init(params)`: the data the block's model builds from `params`, after the kind's parser has\n * accepted them, with the version of the data model it is in. References in `params` are taken\n * as they are: they name blocks of this project.\n */\n dataOf(params: unknown): ResultOrError<VersionedBlockData>;\n\n /**\n * Whether the block declares `applyParams`, putting its params onto live data\n * itself. For such a block {@link dataOf} is `applyParams(defaults, params)`.\n */\n readonly appliesParams: boolean;\n\n /**\n * `applyParams(data, params)`: `data` with `params` put onto it by the block's own model, after\n * the kind's parser has accepted them, with the version of the data model it is in. The model\n * refuses data at another version than its current one, the version {@link dataOf} produces.\n * A model that does not apply params ({@link appliesParams} false) answers with an error.\n */\n applyParams(data: VersionedBlockData, params: unknown): ResultOrError<VersionedBlockData>;\n}\n\n/** No template entries: live params already name the blocks of the project. */\nconst NO_BLOCK_IDS: ReadonlyMap<string, string> = new Map();\n\n/**\n * The {@link BlockParamsModel} of block `blockId` with model `config`.\n *\n * @throws {ModelAPIVersionMismatchError} when the block is not on BlockModelV3: such a model has\n * no storage facade and no params\n */\nexport function blockParamsModel(\n helper: ProjectHelper,\n blockId: BlockId,\n config: BlockConfig,\n): BlockParamsModel {\n if (config.modelAPIVersion !== BLOCK_STORAGE_FACADE_VERSION)\n throw new ModelAPIVersionMismatchError(\n blockId,\n BLOCK_STORAGE_FACADE_VERSION,\n config.modelAPIVersion,\n );\n const callbacks = config.blockLifecycleCallbacks;\n return {\n givesParams:\n callbacks[BlockStorageFacadeCallbacks.InitializationParamsDerive] !== undefined &&\n callbacks[BlockStorageFacadeCallbacks.StorageInitialFromParams] !== undefined,\n\n paramsOf: ({ dataVersion, data }) =>\n helper.deriveTemplateParamsFromStorage(\n config,\n JSON.stringify(createBlockStorage(data, dataVersion)),\n ),\n\n dataOf: (params) => {\n const storage = helper.getInitialStorageFromParamsInVM(config, params, NO_BLOCK_IDS);\n if (storage.error !== undefined) return storage;\n return parseVersionedData(storage.value);\n },\n\n appliesParams: callbacks[BlockStorageFacadeCallbacks.StorageApplyParams] !== undefined,\n\n applyParams: ({ dataVersion, data }, params) => {\n const storage = helper.applyParamsInVM(\n config,\n JSON.stringify(createBlockStorage(data, dataVersion)),\n params,\n );\n if (storage.error !== undefined) return storage;\n return parseVersionedData(storage.value);\n },\n };\n}\n\n/** The data and its version out of a block storage the model built, as JSON text. */\nfunction parseVersionedData(storageJson: string): ResultOrError<VersionedBlockData> {\n const storage: unknown = JSON.parse(storageJson);\n if (!isBlockStorage(storage) || typeof storage.__dataVersion !== \"string\")\n return { error: new Error(\"The block's model built its data in an unknown storage format\") };\n return { value: { dataVersion: storage.__dataVersion, data: storage.__data } };\n}\n"],"mappings":";;;;AA2DA,MAAM,+BAA4C,IAAI,IAAI;;;;;;;AAQ1D,SAAgB,iBACd,QACA,SACA,QACkB;CAClB,IAAI,OAAO,oBAAoBA,qBAAAA,8BAC7B,MAAM,IAAIC,0BAAAA,6BACR,SACAD,qBAAAA,8BACA,OAAO,eACT;CACF,MAAM,YAAY,OAAO;CACzB,OAAO;EACL,aACE,UAAUE,qBAAAA,4BAA4B,gCAAgC,KAAA,KACtE,UAAUA,qBAAAA,4BAA4B,8BAA8B,KAAA;EAEtE,WAAW,EAAE,aAAa,WACxB,OAAO,gCACL,QACA,KAAK,WAAA,GAAUC,qBAAAA,mBAAAA,CAAmB,MAAM,WAAW,CAAC,CACtD;EAEF,SAAS,WAAW;GAClB,MAAM,UAAU,OAAO,gCAAgC,QAAQ,QAAQ,YAAY;GACnF,IAAI,QAAQ,UAAU,KAAA,GAAW,OAAO;GACxC,OAAO,mBAAmB,QAAQ,KAAK;EACzC;EAEA,eAAe,UAAUD,qBAAAA,4BAA4B,wBAAwB,KAAA;EAE7E,cAAc,EAAE,aAAa,QAAQ,WAAW;GAC9C,MAAM,UAAU,OAAO,gBACrB,QACA,KAAK,WAAA,GAAUC,qBAAAA,mBAAAA,CAAmB,MAAM,WAAW,CAAC,GACpD,MACF;GACA,IAAI,QAAQ,UAAU,KAAA,GAAW,OAAO;GACxC,OAAO,mBAAmB,QAAQ,KAAK;EACzC;CACF;AACF;;AAGA,SAAS,mBAAmB,aAAwD;CAClF,MAAM,UAAmB,KAAK,MAAM,WAAW;CAC/C,IAAI,EAAA,GAACC,qBAAAA,eAAAA,CAAe,OAAO,KAAK,OAAO,QAAQ,kBAAkB,UAC/D,OAAO,EAAE,uBAAO,IAAI,MAAM,+DAA+D,EAAE;CAC7F,OAAO,EAAE,OAAO;EAAE,aAAa,QAAQ;EAAe,MAAM,QAAQ;CAAO,EAAE;AAC/E"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import "./project_helper.js";
|
|
2
|
+
import { BlockConfig, ResultOrError } from "@platforma-sdk/model";
|
|
3
|
+
import { BlockId } from "@milaboratories/pl-model-common";
|
|
4
|
+
/** A block's data with the version of the block's data model it is written in. */
|
|
5
|
+
export type VersionedBlockData = {
|
|
6
|
+
dataVersion: string;
|
|
7
|
+
data: unknown;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A block's model as functions between its kind's initialization params and its data: the data
|
|
11
|
+
* model's `init(params)`, its inverse `templateParams(data)` and, when the block declares it,
|
|
12
|
+
* `applyParams(data, params)`. Each runs the block's own model code in the VM, each call on its
|
|
13
|
+
* own; no block is created and nothing is read from or written to the project.
|
|
14
|
+
*/
|
|
15
|
+
export interface BlockParamsModel {
|
|
16
|
+
/**
|
|
17
|
+
* Whether the model has both functions. A model built before blocks gave params has neither
|
|
18
|
+
* callback; its calls answer with an error.
|
|
19
|
+
*/
|
|
20
|
+
readonly givesParams: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* `templateParams(data)`: the params the block's model derives from `data`. The data is not
|
|
23
|
+
* migrated first (the SDK does not), so it should be in the version {@link dataOf} produces.
|
|
24
|
+
*/
|
|
25
|
+
paramsOf(data: VersionedBlockData): ResultOrError<unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* `init(params)`: the data the block's model builds from `params`, after the kind's parser has
|
|
28
|
+
* accepted them, with the version of the data model it is in. References in `params` are taken
|
|
29
|
+
* as they are: they name blocks of this project.
|
|
30
|
+
*/
|
|
31
|
+
dataOf(params: unknown): ResultOrError<VersionedBlockData>;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the block declares `applyParams`, putting its params onto live data
|
|
34
|
+
* itself. For such a block {@link dataOf} is `applyParams(defaults, params)`.
|
|
35
|
+
*/
|
|
36
|
+
readonly appliesParams: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* `applyParams(data, params)`: `data` with `params` put onto it by the block's own model, after
|
|
39
|
+
* the kind's parser has accepted them, with the version of the data model it is in. The model
|
|
40
|
+
* refuses data at another version than its current one, the version {@link dataOf} produces.
|
|
41
|
+
* A model that does not apply params ({@link appliesParams} false) answers with an error.
|
|
42
|
+
*/
|
|
43
|
+
applyParams(data: VersionedBlockData, params: unknown): ResultOrError<VersionedBlockData>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=block_params_model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_params_model.d.ts","names":[],"sources":["../../src/model/block_params_model.ts"],"mappings":";;;;YAYY;EACV;EACA;;;;;;;;iBASe;;;;;WAKN;;;;;EAMT,SAAS,MAAM,qBAAqB;;;;;;EAOpC,OAAO,kBAAkB,cAAc;;;;;WAM9B;;;;;;;EAQT,YAAY,MAAM,oBAAoB,kBAAkB,cAAc"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { BLOCK_STORAGE_FACADE_VERSION, BlockStorageFacadeCallbacks, createBlockStorage, isBlockStorage } from "@platforma-sdk/model";
|
|
2
|
+
import { ModelAPIVersionMismatchError } from "@milaboratories/pl-errors";
|
|
3
|
+
// src/model/block_params_model.ts
|
|
4
|
+
/** No template entries: live params already name the blocks of the project. */
|
|
5
|
+
const NO_BLOCK_IDS = /* @__PURE__ */ new Map();
|
|
6
|
+
/**
|
|
7
|
+
* The {@link BlockParamsModel} of block `blockId` with model `config`.
|
|
8
|
+
*
|
|
9
|
+
* @throws {ModelAPIVersionMismatchError} when the block is not on BlockModelV3: such a model has
|
|
10
|
+
* no storage facade and no params
|
|
11
|
+
*/
|
|
12
|
+
function blockParamsModel(helper, blockId, config) {
|
|
13
|
+
if (config.modelAPIVersion !== BLOCK_STORAGE_FACADE_VERSION) throw new ModelAPIVersionMismatchError(blockId, BLOCK_STORAGE_FACADE_VERSION, config.modelAPIVersion);
|
|
14
|
+
const callbacks = config.blockLifecycleCallbacks;
|
|
15
|
+
return {
|
|
16
|
+
givesParams: callbacks[BlockStorageFacadeCallbacks.InitializationParamsDerive] !== void 0 && callbacks[BlockStorageFacadeCallbacks.StorageInitialFromParams] !== void 0,
|
|
17
|
+
paramsOf: ({ dataVersion, data }) => helper.deriveTemplateParamsFromStorage(config, JSON.stringify(createBlockStorage(data, dataVersion))),
|
|
18
|
+
dataOf: (params) => {
|
|
19
|
+
const storage = helper.getInitialStorageFromParamsInVM(config, params, NO_BLOCK_IDS);
|
|
20
|
+
if (storage.error !== void 0) return storage;
|
|
21
|
+
return parseVersionedData(storage.value);
|
|
22
|
+
},
|
|
23
|
+
appliesParams: callbacks[BlockStorageFacadeCallbacks.StorageApplyParams] !== void 0,
|
|
24
|
+
applyParams: ({ dataVersion, data }, params) => {
|
|
25
|
+
const storage = helper.applyParamsInVM(config, JSON.stringify(createBlockStorage(data, dataVersion)), params);
|
|
26
|
+
if (storage.error !== void 0) return storage;
|
|
27
|
+
return parseVersionedData(storage.value);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** The data and its version out of a block storage the model built, as JSON text. */
|
|
32
|
+
function parseVersionedData(storageJson) {
|
|
33
|
+
const storage = JSON.parse(storageJson);
|
|
34
|
+
if (!isBlockStorage(storage) || typeof storage.__dataVersion !== "string") return { error: /* @__PURE__ */ new Error("The block's model built its data in an unknown storage format") };
|
|
35
|
+
return { value: {
|
|
36
|
+
dataVersion: storage.__dataVersion,
|
|
37
|
+
data: storage.__data
|
|
38
|
+
} };
|
|
39
|
+
}
|
|
40
|
+
export { blockParamsModel };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=block_params_model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_params_model.js","names":[],"sources":["../../src/model/block_params_model.ts"],"sourcesContent":["import type { BlockId } from \"@milaboratories/pl-model-common\";\nimport { ModelAPIVersionMismatchError } from \"@milaboratories/pl-errors\";\nimport type { BlockConfig, ResultOrError } from \"@platforma-sdk/model\";\nimport {\n BLOCK_STORAGE_FACADE_VERSION,\n BlockStorageFacadeCallbacks,\n createBlockStorage,\n isBlockStorage,\n} from \"@platforma-sdk/model\";\nimport type { ProjectHelper } from \"./project_helper\";\n\n/** A block's data with the version of the block's data model it is written in. */\nexport type VersionedBlockData = {\n dataVersion: string;\n data: unknown;\n};\n\n/**\n * A block's model as functions between its kind's initialization params and its data: the data\n * model's `init(params)`, its inverse `templateParams(data)` and, when the block declares it,\n * `applyParams(data, params)`. Each runs the block's own model code in the VM, each call on its\n * own; no block is created and nothing is read from or written to the project.\n */\nexport interface BlockParamsModel {\n /**\n * Whether the model has both functions. A model built before blocks gave params has neither\n * callback; its calls answer with an error.\n */\n readonly givesParams: boolean;\n\n /**\n * `templateParams(data)`: the params the block's model derives from `data`. The data is not\n * migrated first (the SDK does not), so it should be in the version {@link dataOf} produces.\n */\n paramsOf(data: VersionedBlockData): ResultOrError<unknown>;\n\n /**\n * `init(params)`: the data the block's model builds from `params`, after the kind's parser has\n * accepted them, with the version of the data model it is in. References in `params` are taken\n * as they are: they name blocks of this project.\n */\n dataOf(params: unknown): ResultOrError<VersionedBlockData>;\n\n /**\n * Whether the block declares `applyParams`, putting its params onto live data\n * itself. For such a block {@link dataOf} is `applyParams(defaults, params)`.\n */\n readonly appliesParams: boolean;\n\n /**\n * `applyParams(data, params)`: `data` with `params` put onto it by the block's own model, after\n * the kind's parser has accepted them, with the version of the data model it is in. The model\n * refuses data at another version than its current one, the version {@link dataOf} produces.\n * A model that does not apply params ({@link appliesParams} false) answers with an error.\n */\n applyParams(data: VersionedBlockData, params: unknown): ResultOrError<VersionedBlockData>;\n}\n\n/** No template entries: live params already name the blocks of the project. */\nconst NO_BLOCK_IDS: ReadonlyMap<string, string> = new Map();\n\n/**\n * The {@link BlockParamsModel} of block `blockId` with model `config`.\n *\n * @throws {ModelAPIVersionMismatchError} when the block is not on BlockModelV3: such a model has\n * no storage facade and no params\n */\nexport function blockParamsModel(\n helper: ProjectHelper,\n blockId: BlockId,\n config: BlockConfig,\n): BlockParamsModel {\n if (config.modelAPIVersion !== BLOCK_STORAGE_FACADE_VERSION)\n throw new ModelAPIVersionMismatchError(\n blockId,\n BLOCK_STORAGE_FACADE_VERSION,\n config.modelAPIVersion,\n );\n const callbacks = config.blockLifecycleCallbacks;\n return {\n givesParams:\n callbacks[BlockStorageFacadeCallbacks.InitializationParamsDerive] !== undefined &&\n callbacks[BlockStorageFacadeCallbacks.StorageInitialFromParams] !== undefined,\n\n paramsOf: ({ dataVersion, data }) =>\n helper.deriveTemplateParamsFromStorage(\n config,\n JSON.stringify(createBlockStorage(data, dataVersion)),\n ),\n\n dataOf: (params) => {\n const storage = helper.getInitialStorageFromParamsInVM(config, params, NO_BLOCK_IDS);\n if (storage.error !== undefined) return storage;\n return parseVersionedData(storage.value);\n },\n\n appliesParams: callbacks[BlockStorageFacadeCallbacks.StorageApplyParams] !== undefined,\n\n applyParams: ({ dataVersion, data }, params) => {\n const storage = helper.applyParamsInVM(\n config,\n JSON.stringify(createBlockStorage(data, dataVersion)),\n params,\n );\n if (storage.error !== undefined) return storage;\n return parseVersionedData(storage.value);\n },\n };\n}\n\n/** The data and its version out of a block storage the model built, as JSON text. */\nfunction parseVersionedData(storageJson: string): ResultOrError<VersionedBlockData> {\n const storage: unknown = JSON.parse(storageJson);\n if (!isBlockStorage(storage) || typeof storage.__dataVersion !== \"string\")\n return { error: new Error(\"The block's model built its data in an unknown storage format\") };\n return { value: { dataVersion: storage.__dataVersion, data: storage.__data } };\n}\n"],"mappings":";;;;AA2DA,MAAM,+BAA4C,IAAI,IAAI;;;;;;;AAQ1D,SAAgB,iBACd,QACA,SACA,QACkB;CAClB,IAAI,OAAO,oBAAoB,8BAC7B,MAAM,IAAI,6BACR,SACA,8BACA,OAAO,eACT;CACF,MAAM,YAAY,OAAO;CACzB,OAAO;EACL,aACE,UAAU,4BAA4B,gCAAgC,KAAA,KACtE,UAAU,4BAA4B,8BAA8B,KAAA;EAEtE,WAAW,EAAE,aAAa,WACxB,OAAO,gCACL,QACA,KAAK,UAAU,mBAAmB,MAAM,WAAW,CAAC,CACtD;EAEF,SAAS,WAAW;GAClB,MAAM,UAAU,OAAO,gCAAgC,QAAQ,QAAQ,YAAY;GACnF,IAAI,QAAQ,UAAU,KAAA,GAAW,OAAO;GACxC,OAAO,mBAAmB,QAAQ,KAAK;EACzC;EAEA,eAAe,UAAU,4BAA4B,wBAAwB,KAAA;EAE7E,cAAc,EAAE,aAAa,QAAQ,WAAW;GAC9C,MAAM,UAAU,OAAO,gBACrB,QACA,KAAK,UAAU,mBAAmB,MAAM,WAAW,CAAC,GACpD,MACF;GACA,IAAI,QAAQ,UAAU,KAAA,GAAW,OAAO;GACxC,OAAO,mBAAmB,QAAQ,KAAK;EACzC;CACF;AACF;;AAGA,SAAS,mBAAmB,aAAwD;CAClF,MAAM,UAAmB,KAAK,MAAM,WAAW;CAC/C,IAAI,CAAC,eAAe,OAAO,KAAK,OAAO,QAAQ,kBAAkB,UAC/D,OAAO,EAAE,uBAAO,IAAI,MAAM,+DAA+D,EAAE;CAC7F,OAAO,EAAE,OAAO;EAAE,aAAa,QAAQ;EAAe,MAAM,QAAQ;CAAO,EAAE;AAC/E"}
|
package/dist/model/index.d.ts
CHANGED
|
@@ -5,5 +5,7 @@ import { TemplateExportProblem } from "./template_export.js";
|
|
|
5
5
|
import { ProjectTemplateExportOutcome, locationOf, stringifyProjectTemplateV1 } from "./template_serializer.js";
|
|
6
6
|
import { EnvelopeData, EnvelopeFolder, EnvelopeFolderId, EnvelopeFolderProject, EnvelopeFolderTemplate, EnvelopeMode, EnvelopePayload, EnvelopePayloadKind, EnvelopeProject, EnvelopeSchemaVersion, EnvelopeSchemaVersionCurrent, HiddenFieldPrefix, ProjectFieldUuid, ShareAudience, ShareFolderOptions, ShareHidden, ShareId, ShareOptions, ShareOutcome, ShareProjectsOptions, ShareReplaceOption, ShareTemplateOptions, SharedEnvelopeResourceType, SharingOutboxField, SharingOutboxResourceType, SharingStateField, SharingStateResourceType, asShareId, canGrantToEveryone, canImpersonate, decodeEnvelopeData, envelopeFolderRoot, envelopeProjectMap, hiddenField, hiddenFieldShareId, isHiddenField, newEnvelopeFolderId, newProjectFieldUuid, newShareId, normalizeEnvelopeData } from "./sharing_model.js";
|
|
7
7
|
import { BlockPackExplicit, BlockPackSpecAny, BlockPackSpecPrepared, FrontendFromFolder, FrontendFromFolderData, FrontendFromFolderResourceType, FrontendFromLocalTgz, FrontendFromLocalTgzData, FrontendFromLocalTgzResourceType, FrontendFromUrl, FrontendFromUrlData, FrontendFromUrlResourceType, FrontendSpec } from "./block_pack_spec.js";
|
|
8
|
+
import { BlockReadiness, DerivedPrerunArgsSummary, MissingBlockReference } from "./args_derivation.js";
|
|
9
|
+
import { BlockParamsModel, VersionedBlockData } from "./block_params_model.js";
|
|
8
10
|
import { TemplateParseOutcome, parseProjectTemplateV1Yaml } from "./template_parser.js";
|
|
9
|
-
export { type AppliedEntry, BlockArgsAuthorKeyPrefix, BlockPackExplicit, type BlockPackProvider, BlockPackSpecAny, BlockPackSpecPrepared, EnvelopeData, EnvelopeFolder, EnvelopeFolderId, EnvelopeFolderProject, EnvelopeFolderTemplate, EnvelopeMode, EnvelopePayload, EnvelopePayloadKind, EnvelopeProject, EnvelopeSchemaVersion, EnvelopeSchemaVersionCurrent, type ExactResolution, FrontendFromFolder, FrontendFromFolderData, FrontendFromFolderResourceType, FrontendFromLocalTgz, FrontendFromLocalTgzData, FrontendFromLocalTgzResourceType, FrontendFromUrl, FrontendFromUrlData, FrontendFromUrlResourceType, FrontendSpec, HiddenFieldPrefix, type KindResolution, ProjectCreatedTimestamp, type ProjectField, ProjectFieldUuid, ProjectLastModifiedTimestamp, type ProjectListEntry, ProjectMetaKey, ProjectResourceType, ProjectStructureAuthorKey, ProjectStructureKey, type ProjectTemplateExportOutcome, type ResolvedEntry, SchemaVersionCurrent, SchemaVersionKey, ShareAudience, ShareFolderOptions, ShareHidden, ShareId, ShareOptions, ShareOutcome, ShareProjectsOptions, ShareReplaceOption, ShareTemplateOptions, SharedEnvelopeResourceType, SharingOutboxField, SharingOutboxResourceType, SharingStateField, SharingStateResourceType, type TemplateApplyProblem, type TemplateApplyReport, TemplateEntryRejected, type TemplateExportProblem, type TemplateParseOutcome, type TemplateResolveOutcome, asShareId, canGrantToEveryone, canImpersonate, decodeEnvelopeData, envelopeFolderRoot, envelopeProjectMap, hiddenField, hiddenFieldShareId, isHiddenField, locationOf, newEnvelopeFolderId, newProjectFieldUuid, newShareId, normalizeEnvelopeData, parseBlockPackName, parseProjectTemplateV1Yaml, resolveTemplateEntries, stringifyProjectTemplateV1 };
|
|
11
|
+
export { type AppliedEntry, BlockArgsAuthorKeyPrefix, BlockPackExplicit, type BlockPackProvider, BlockPackSpecAny, BlockPackSpecPrepared, type BlockParamsModel, type BlockReadiness, type DerivedPrerunArgsSummary, EnvelopeData, EnvelopeFolder, EnvelopeFolderId, EnvelopeFolderProject, EnvelopeFolderTemplate, EnvelopeMode, EnvelopePayload, EnvelopePayloadKind, EnvelopeProject, EnvelopeSchemaVersion, EnvelopeSchemaVersionCurrent, type ExactResolution, FrontendFromFolder, FrontendFromFolderData, FrontendFromFolderResourceType, FrontendFromLocalTgz, FrontendFromLocalTgzData, FrontendFromLocalTgzResourceType, FrontendFromUrl, FrontendFromUrlData, FrontendFromUrlResourceType, FrontendSpec, HiddenFieldPrefix, type KindResolution, type MissingBlockReference, ProjectCreatedTimestamp, type ProjectField, ProjectFieldUuid, ProjectLastModifiedTimestamp, type ProjectListEntry, ProjectMetaKey, ProjectResourceType, ProjectStructureAuthorKey, ProjectStructureKey, type ProjectTemplateExportOutcome, type ResolvedEntry, SchemaVersionCurrent, SchemaVersionKey, ShareAudience, ShareFolderOptions, ShareHidden, ShareId, ShareOptions, ShareOutcome, ShareProjectsOptions, ShareReplaceOption, ShareTemplateOptions, SharedEnvelopeResourceType, SharingOutboxField, SharingOutboxResourceType, SharingStateField, SharingStateResourceType, type TemplateApplyProblem, type TemplateApplyReport, TemplateEntryRejected, type TemplateExportProblem, type TemplateParseOutcome, type TemplateResolveOutcome, type VersionedBlockData, asShareId, canGrantToEveryone, canImpersonate, decodeEnvelopeData, envelopeFolderRoot, envelopeProjectMap, hiddenField, hiddenFieldShareId, isHiddenField, locationOf, newEnvelopeFolderId, newProjectFieldUuid, newShareId, normalizeEnvelopeData, parseBlockPackName, parseProjectTemplateV1Yaml, resolveTemplateEntries, stringifyProjectTemplateV1 };
|