@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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import _usingCtx from "../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/usingCtx.js";
|
|
2
|
+
import { buildColumnRegistry, hasAxisFilters, resolveColumnSpec, resolvePFrameColumnById } from "../js_render/column_registry.js";
|
|
3
|
+
import { poolView } from "./pool_columns.js";
|
|
4
|
+
import { PoolEntryGuard, extractPObjectId } from "@milaboratories/pl-model-common";
|
|
5
|
+
import { Computable } from "@milaboratories/computable";
|
|
6
|
+
// src/middle_layer/pool_frame.ts
|
|
7
|
+
/**
|
|
8
|
+
* What keeps the column `id` stands for from being read; `undefined` for a column ready to read.
|
|
9
|
+
* Its readiness is that of its leaf, the exported column the id comes down to.
|
|
10
|
+
*/
|
|
11
|
+
function poolColumnProblem(registry, id) {
|
|
12
|
+
const leafId = extractPObjectId(id);
|
|
13
|
+
const leaf = registry.resolve(leafId);
|
|
14
|
+
if (leaf === void 0) return { issue: "unknown" };
|
|
15
|
+
if (resolveColumnSpec(registry, leafId) === void 0) return { issue: "notReady" };
|
|
16
|
+
const data = leaf.accessor.traverseOrError({
|
|
17
|
+
field: `${leaf.name}.data`,
|
|
18
|
+
assertFieldType: "Input",
|
|
19
|
+
allowPermanentAbsence: true
|
|
20
|
+
});
|
|
21
|
+
if (data === void 0) return { issue: leaf.accessor.getInputsLocked() ? "noData" : "notReady" };
|
|
22
|
+
if (!data.ok) return {
|
|
23
|
+
issue: "failed",
|
|
24
|
+
message: data.error.message
|
|
25
|
+
};
|
|
26
|
+
if (!data.value.getIsReadyOrError()) return { issue: "notReady" };
|
|
27
|
+
const error = data.value.getError();
|
|
28
|
+
if (error !== void 0) return {
|
|
29
|
+
issue: "failed",
|
|
30
|
+
message: error.getDataAsString() ?? "the data is an error"
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A PFrame over columns of a project's result pool, by the ids {@link poolColumns} lists, with no
|
|
35
|
+
* block involved: what reads the values of a pool column. Each column of the frame has the id it
|
|
36
|
+
* was asked by, so values read from it are named after that id, and the spec that id gives, the
|
|
37
|
+
* one {@link poolColumns} lists: an overridden id renames axes in the frame too.
|
|
38
|
+
*
|
|
39
|
+
* Every column must be ready: an unknown column, one whose data is missing, still being calculated
|
|
40
|
+
* or failed, and one whose id filters an axis are refused, and nothing is built.
|
|
41
|
+
*
|
|
42
|
+
* The frame is made when the value is first asked for and lives as long as the computable's state:
|
|
43
|
+
* `resetState()` releases it. Ask for the value once.
|
|
44
|
+
*/
|
|
45
|
+
function poolFrame(prjEntry, ids, env) {
|
|
46
|
+
return Computable.make((ctx) => {
|
|
47
|
+
try {
|
|
48
|
+
var _usingCtx$1 = _usingCtx();
|
|
49
|
+
const registry = buildColumnRegistry({ upstreamBlockCtxes: poolView(ctx, prjEntry, void 0) ?? [] });
|
|
50
|
+
const unique = [...new Set(ids)];
|
|
51
|
+
const refused = unique.flatMap((columnId) => {
|
|
52
|
+
if (hasAxisFilters(columnId)) return [{
|
|
53
|
+
columnId,
|
|
54
|
+
issue: "filtered"
|
|
55
|
+
}];
|
|
56
|
+
const problem = poolColumnProblem(registry, columnId);
|
|
57
|
+
return problem === void 0 ? [] : [{
|
|
58
|
+
columnId,
|
|
59
|
+
...problem
|
|
60
|
+
}];
|
|
61
|
+
});
|
|
62
|
+
if (refused.length > 0) return {
|
|
63
|
+
type: "refused",
|
|
64
|
+
refused
|
|
65
|
+
};
|
|
66
|
+
const guard = _usingCtx$1.u(new PoolEntryGuard(env.driverKit.pFrameDriver.createPFrame(unique.map((id) => resolvePFrameColumnById(registry, id)))));
|
|
67
|
+
ctx.addOnDestroy(guard.entry.unref);
|
|
68
|
+
return {
|
|
69
|
+
type: "ok",
|
|
70
|
+
handle: guard.keep().key
|
|
71
|
+
};
|
|
72
|
+
} catch (_) {
|
|
73
|
+
_usingCtx$1.e = _;
|
|
74
|
+
} finally {
|
|
75
|
+
_usingCtx$1.d();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export { poolColumnProblem, poolFrame };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=pool_frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool_frame.js","names":[],"sources":["../../src/middle_layer/pool_frame.ts"],"sourcesContent":["import { Computable } from \"@milaboratories/computable\";\nimport type { PlTreeEntry, PlTreeNodeAccessor } from \"@milaboratories/pl-tree\";\nimport {\n extractPObjectId,\n PoolEntryGuard,\n type ColumnRegistry,\n type ColumnUniversalId,\n type PFrameHandle,\n} from \"@milaboratories/pl-model-common\";\nimport {\n buildColumnRegistry,\n hasAxisFilters,\n resolveColumnSpec,\n resolvePFrameColumnById,\n} from \"../js_render/column_registry\";\nimport type { InternalPFrameDriver } from \"../pool/driver\";\nimport { poolView } from \"./pool_columns\";\n\n/**\n * Why a column of the result pool cannot be read:\n * - `unknown`: no block of the project exports a column with this id;\n * - `noData`: the column has a spec but no data, e.g. it comes from a block's pre-run only, or its\n * block has not run;\n * - `notReady`: its spec or data is still being calculated;\n * - `failed`: its data is an error.\n */\nexport type PoolColumnIssue = \"unknown\" | \"noData\" | \"notReady\" | \"failed\";\n\n/** What keeps a column of the result pool from being read, as {@link poolColumnProblem} says. */\nexport interface PoolColumnProblem {\n readonly issue: PoolColumnIssue;\n /** The error of a `failed` column. */\n readonly message?: string;\n}\n\n/**\n * What keeps the column `id` stands for from being read; `undefined` for a column ready to read.\n * Its readiness is that of its leaf, the exported column the id comes down to.\n */\nexport function poolColumnProblem(\n registry: ColumnRegistry<PlTreeNodeAccessor>,\n id: ColumnUniversalId,\n): PoolColumnProblem | undefined {\n const leafId = extractPObjectId(id);\n const leaf = registry.resolve(leafId);\n if (leaf === undefined) return { issue: \"unknown\" };\n if (resolveColumnSpec(registry, leafId) === undefined) return { issue: \"notReady\" };\n const data = leaf.accessor.traverseOrError({\n field: `${leaf.name}.data`,\n assertFieldType: \"Input\",\n allowPermanentAbsence: true,\n });\n // A result list still open may get the field yet.\n if (data === undefined) return { issue: leaf.accessor.getInputsLocked() ? \"noData\" : \"notReady\" };\n if (!data.ok) return { issue: \"failed\", message: data.error.message };\n if (!data.value.getIsReadyOrError()) return { issue: \"notReady\" };\n const error = data.value.getError();\n if (error !== undefined)\n return { issue: \"failed\", message: error.getDataAsString() ?? \"the data is an error\" };\n return undefined;\n}\n\n/**\n * Why {@link poolFrame} refused a column: a {@link PoolColumnIssue}, or `filtered` for an id that\n * filters an axis, whose values would be those of the whole column it filters.\n */\nexport type PoolFrameIssue = PoolColumnIssue | \"filtered\";\n\n/** A column {@link poolFrame} refused, and why. */\nexport interface PoolFrameRefusal {\n readonly columnId: ColumnUniversalId;\n readonly issue: PoolFrameIssue;\n /** The error of a `failed` column. */\n readonly message?: string;\n}\n\n/**\n * What {@link poolFrame} computes: the handle of the frame, or, with nothing built, the columns it\n * refused.\n */\nexport type PoolFrame =\n | { readonly type: \"ok\"; readonly handle: PFrameHandle }\n | { readonly type: \"refused\"; readonly refused: readonly PoolFrameRefusal[] };\n\n/** What {@link poolFrame} uses besides the project tree: the driver that builds the frame. */\nexport type PoolFrameEnv = {\n readonly driverKit: { readonly pFrameDriver: Pick<InternalPFrameDriver, \"createPFrame\"> };\n};\n\n/**\n * A PFrame over columns of a project's result pool, by the ids {@link poolColumns} lists, with no\n * block involved: what reads the values of a pool column. Each column of the frame has the id it\n * was asked by, so values read from it are named after that id, and the spec that id gives, the\n * one {@link poolColumns} lists: an overridden id renames axes in the frame too.\n *\n * Every column must be ready: an unknown column, one whose data is missing, still being calculated\n * or failed, and one whose id filters an axis are refused, and nothing is built.\n *\n * The frame is made when the value is first asked for and lives as long as the computable's state:\n * `resetState()` releases it. Ask for the value once.\n */\nexport function poolFrame(\n prjEntry: PlTreeEntry,\n ids: readonly ColumnUniversalId[],\n env: PoolFrameEnv,\n): Computable<PoolFrame> {\n return Computable.make((ctx): PoolFrame => {\n const registry = buildColumnRegistry({\n upstreamBlockCtxes: poolView(ctx, prjEntry, undefined) ?? [],\n });\n const unique = [...new Set(ids)];\n const refused = unique.flatMap((columnId): PoolFrameRefusal[] => {\n if (hasAxisFilters(columnId)) return [{ columnId, issue: \"filtered\" }];\n const problem = poolColumnProblem(registry, columnId);\n return problem === undefined ? [] : [{ columnId, ...problem }];\n });\n if (refused.length > 0) return { type: \"refused\", refused };\n\n using guard = new PoolEntryGuard(\n env.driverKit.pFrameDriver.createPFrame(\n unique.map((id) => resolvePFrameColumnById(registry, id)),\n ),\n );\n ctx.addOnDestroy(guard.entry.unref);\n return { type: \"ok\", handle: guard.keep().key };\n });\n}\n"],"mappings":";;;;;;;;;;AAuCA,SAAgB,kBACd,UACA,IAC+B;CAC/B,MAAM,SAAS,iBAAiB,EAAE;CAClC,MAAM,OAAO,SAAS,QAAQ,MAAM;CACpC,IAAI,SAAS,KAAA,GAAW,OAAO,EAAE,OAAO,UAAU;CAClD,IAAI,kBAAkB,UAAU,MAAM,MAAM,KAAA,GAAW,OAAO,EAAE,OAAO,WAAW;CAClF,MAAM,OAAO,KAAK,SAAS,gBAAgB;EACzC,OAAO,GAAG,KAAK,KAAK;EACpB,iBAAiB;EACjB,uBAAuB;CACzB,CAAC;CAED,IAAI,SAAS,KAAA,GAAW,OAAO,EAAE,OAAO,KAAK,SAAS,gBAAgB,IAAI,WAAW,WAAW;CAChG,IAAI,CAAC,KAAK,IAAI,OAAO;EAAE,OAAO;EAAU,SAAS,KAAK,MAAM;CAAQ;CACpE,IAAI,CAAC,KAAK,MAAM,kBAAkB,GAAG,OAAO,EAAE,OAAO,WAAW;CAChE,MAAM,QAAQ,KAAK,MAAM,SAAS;CAClC,IAAI,UAAU,KAAA,GACZ,OAAO;EAAE,OAAO;EAAU,SAAS,MAAM,gBAAgB,KAAK;CAAuB;AAEzF;;;;;;;;;;;;;AAyCA,SAAgB,UACd,UACA,KACA,KACuB;CACvB,OAAO,WAAW,MAAM,QAAmB;;;GACzC,MAAM,WAAW,oBAAoB,EACnC,oBAAoB,SAAS,KAAK,UAAU,KAAA,CAAS,KAAK,CAAC,EAC7D,CAAC;GACD,MAAM,SAAS,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC;GAC/B,MAAM,UAAU,OAAO,SAAS,aAAiC;IAC/D,IAAI,eAAe,QAAQ,GAAG,OAAO,CAAC;KAAE;KAAU,OAAO;IAAW,CAAC;IACrE,MAAM,UAAU,kBAAkB,UAAU,QAAQ;IACpD,OAAO,YAAY,KAAA,IAAY,CAAC,IAAI,CAAC;KAAE;KAAU,GAAG;IAAQ,CAAC;GAC/D,CAAC;GACD,IAAI,QAAQ,SAAS,GAAG,OAAO;IAAE,MAAM;IAAW;GAAQ;GAE1D,MAAM,QAAA,YAAA,EAAQ,IAAI,eAChB,IAAI,UAAU,aAAa,aACzB,OAAO,KAAK,OAAO,wBAAwB,UAAU,EAAE,CAAC,CAC1D,CACF,CAAA;GACA,IAAI,aAAa,MAAM,MAAM,KAAK;GAClC,OAAO;IAAE,MAAM;IAAM,QAAQ,MAAM,KAAK,CAAC,CAAC;GAAI;;;;;;CAChD,CAAC;AACH"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const require_usingCtx = require("../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/usingCtx.cjs");
|
|
2
|
+
const require_column_registry = require("../js_render/column_registry.cjs");
|
|
3
|
+
const require_spec_override_collapse = require("../js_render/spec_override_collapse.cjs");
|
|
4
|
+
const require_pool_columns = require("./pool_columns.cjs");
|
|
5
|
+
const require_pool_frame = require("./pool_frame.cjs");
|
|
6
|
+
const require_rich_column_query = require("./rich_column_query.cjs");
|
|
7
|
+
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
8
|
+
let _milaboratories_computable = require("@milaboratories/computable");
|
|
9
|
+
// src/middle_layer/pool_table.ts
|
|
10
|
+
/**
|
|
11
|
+
* A table over columns of a project's result pool, built by the PFrame driver from `def`, whose
|
|
12
|
+
* columns are pool column ids (those {@link poolColumns} lists, discovered, filtered and
|
|
13
|
+
* overridden ids included): what a block's model gets from `createPTableV2` over the same
|
|
14
|
+
* columns, with no block involved. Each column of a join entry is built into the query its id
|
|
15
|
+
* stands for, with the qualifications of a discovered column, by {@link richTableDef}.
|
|
16
|
+
*
|
|
17
|
+
* Every column must be ready, and so must each linker column a discovered id reads; readiness is
|
|
18
|
+
* that of the exported column an id comes down to. An unknown column, or one whose data is
|
|
19
|
+
* missing, still being calculated or failed, is refused and nothing is built, where a block's
|
|
20
|
+
* model would get an empty column instead.
|
|
21
|
+
*
|
|
22
|
+
* The table is made when the value is first asked for and lives as long as the computable's state:
|
|
23
|
+
* `resetState()` releases it. Ask for the value once. Asking again after the project changed
|
|
24
|
+
* builds a new table and releases the first; {@link Computable.isChanged} tells whether that
|
|
25
|
+
* would happen, i.e. whether what the table was built from may have changed (any change of the
|
|
26
|
+
* project's structure counts too).
|
|
27
|
+
*/
|
|
28
|
+
function poolTable(prjEntry, def, env) {
|
|
29
|
+
return _milaboratories_computable.Computable.make((ctx) => {
|
|
30
|
+
try {
|
|
31
|
+
var _usingCtx$1 = require_usingCtx.default();
|
|
32
|
+
const registry = require_column_registry.buildColumnRegistry({ upstreamBlockCtxes: require_pool_columns.poolView(ctx, prjEntry, void 0) ?? [] });
|
|
33
|
+
const refused = [...new Set((0, _milaboratories_pl_model_common.collectSpecQueryColumns)(def.query).flatMap(require_rich_column_query.richColumnReferences))].flatMap((columnId) => {
|
|
34
|
+
const problem = require_pool_frame.poolColumnProblem(registry, columnId);
|
|
35
|
+
return problem === void 0 ? [] : [{
|
|
36
|
+
columnId,
|
|
37
|
+
...problem
|
|
38
|
+
}];
|
|
39
|
+
});
|
|
40
|
+
if (refused.length > 0) return {
|
|
41
|
+
type: "refused",
|
|
42
|
+
refused
|
|
43
|
+
};
|
|
44
|
+
const specOf = (leaf) => {
|
|
45
|
+
const spec = require_column_registry.resolveColumnSpec(registry, leaf);
|
|
46
|
+
return spec !== void 0 && (0, _milaboratories_pl_model_common.isPColumnSpec)(spec) ? spec : void 0;
|
|
47
|
+
};
|
|
48
|
+
const guard = _usingCtx$1.u(new _milaboratories_pl_model_common.PoolEntryGuard(env.driverKit.pFrameDriver.createPTableV2((0, _milaboratories_pl_model_common.mapPTableDefV2)(require_rich_column_query.richTableDef(def, specOf), {
|
|
49
|
+
column: (id) => require_column_registry.resolvePColumnById(registry, id),
|
|
50
|
+
node: require_spec_override_collapse.collapseSpecOverrideNode
|
|
51
|
+
}))));
|
|
52
|
+
ctx.addOnDestroy(guard.entry.unref);
|
|
53
|
+
return {
|
|
54
|
+
type: "ok",
|
|
55
|
+
handle: guard.keep().key
|
|
56
|
+
};
|
|
57
|
+
} catch (_) {
|
|
58
|
+
_usingCtx$1.e = _;
|
|
59
|
+
} finally {
|
|
60
|
+
_usingCtx$1.d();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.poolTable = poolTable;
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=pool_table.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool_table.cjs","names":["Computable","buildColumnRegistry","poolView","collectSpecQueryColumns","richColumnReferences","poolColumnProblem","resolveColumnSpec","isPColumnSpec","PoolEntryGuard","mapPTableDefV2","richTableDef","resolvePColumnById","collapseSpecOverrideNode"],"sources":["../../src/middle_layer/pool_table.ts"],"sourcesContent":["import { Computable } from \"@milaboratories/computable\";\nimport type { PlTreeEntry } from \"@milaboratories/pl-tree\";\nimport {\n collectSpecQueryColumns,\n isPColumnSpec,\n mapPTableDefV2,\n PoolEntryGuard,\n type ColumnUniversalId,\n type PObjectId,\n type PTableDefV2,\n type PTableHandle,\n} from \"@milaboratories/pl-model-common\";\nimport {\n buildColumnRegistry,\n resolveColumnSpec,\n resolvePColumnById,\n} from \"../js_render/column_registry\";\nimport { collapseSpecOverrideNode } from \"../js_render/spec_override_collapse\";\nimport type { InternalPFrameDriver } from \"../pool/driver\";\nimport { poolView } from \"./pool_columns\";\nimport { poolColumnProblem, type PoolColumnIssue } from \"./pool_frame\";\nimport { richColumnReferences, richTableDef } from \"./rich_column_query\";\n\n/** Why {@link poolTable} refused a column (see {@link PoolColumnIssue}). */\nexport type PoolTableIssue = PoolColumnIssue;\n\n/** A column {@link poolTable} refused, and why. */\nexport interface PoolTableRefusal {\n /** The id the table names the column by, or the id of a linker column it reads. */\n readonly columnId: ColumnUniversalId;\n readonly issue: PoolTableIssue;\n /** The error of a `failed` column. */\n readonly message?: string;\n}\n\n/**\n * What {@link poolTable} computes: the handle of the table, or, with nothing built, the columns\n * it refused.\n */\nexport type PoolTable =\n | { readonly type: \"ok\"; readonly handle: PTableHandle }\n | { readonly type: \"refused\"; readonly refused: readonly PoolTableRefusal[] };\n\n/** What {@link poolTable} uses besides the project tree: the driver that builds the table. */\nexport type PoolTableEnv = {\n readonly driverKit: { readonly pFrameDriver: Pick<InternalPFrameDriver, \"createPTableV2\"> };\n};\n\n/**\n * A table over columns of a project's result pool, built by the PFrame driver from `def`, whose\n * columns are pool column ids (those {@link poolColumns} lists, discovered, filtered and\n * overridden ids included): what a block's model gets from `createPTableV2` over the same\n * columns, with no block involved. Each column of a join entry is built into the query its id\n * stands for, with the qualifications of a discovered column, by {@link richTableDef}.\n *\n * Every column must be ready, and so must each linker column a discovered id reads; readiness is\n * that of the exported column an id comes down to. An unknown column, or one whose data is\n * missing, still being calculated or failed, is refused and nothing is built, where a block's\n * model would get an empty column instead.\n *\n * The table is made when the value is first asked for and lives as long as the computable's state:\n * `resetState()` releases it. Ask for the value once. Asking again after the project changed\n * builds a new table and releases the first; {@link Computable.isChanged} tells whether that\n * would happen, i.e. whether what the table was built from may have changed (any change of the\n * project's structure counts too).\n */\nexport function poolTable(\n prjEntry: PlTreeEntry,\n def: PTableDefV2<ColumnUniversalId>,\n env: PoolTableEnv,\n): Computable<PoolTable> {\n return Computable.make((ctx): PoolTable => {\n const registry = buildColumnRegistry({\n upstreamBlockCtxes: poolView(ctx, prjEntry, undefined) ?? [],\n });\n const ids = [...new Set(collectSpecQueryColumns(def.query).flatMap(richColumnReferences))];\n const refused = ids.flatMap((columnId): PoolTableRefusal[] => {\n const problem = poolColumnProblem(registry, columnId);\n return problem === undefined ? [] : [{ columnId, ...problem }];\n });\n if (refused.length > 0) return { type: \"refused\", refused };\n\n const specOf = (leaf: PObjectId) => {\n const spec = resolveColumnSpec(registry, leaf);\n return spec !== undefined && isPColumnSpec(spec) ? spec : undefined;\n };\n using guard = new PoolEntryGuard(\n env.driverKit.pFrameDriver.createPTableV2(\n mapPTableDefV2(richTableDef(def, specOf), {\n column: (id) => resolvePColumnById(registry, id),\n node: collapseSpecOverrideNode,\n }),\n ),\n );\n ctx.addOnDestroy(guard.entry.unref);\n return { type: \"ok\", handle: guard.keep().key };\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,SAAgB,UACd,UACA,KACA,KACuB;CACvB,OAAOA,2BAAAA,WAAW,MAAM,QAAmB;;;GACzC,MAAM,WAAWC,wBAAAA,oBAAoB,EACnC,oBAAoBC,qBAAAA,SAAS,KAAK,UAAU,KAAA,CAAS,KAAK,CAAC,EAC7D,CAAC;GAED,MAAM,UAAU,CADH,GAAG,IAAI,KAAA,GAAIC,gCAAAA,wBAAAA,CAAwB,IAAI,KAAK,CAAC,CAAC,QAAQC,0BAAAA,oBAAoB,CAAC,CACtE,CAAC,CAAC,SAAS,aAAiC;IAC5D,MAAM,UAAUC,mBAAAA,kBAAkB,UAAU,QAAQ;IACpD,OAAO,YAAY,KAAA,IAAY,CAAC,IAAI,CAAC;KAAE;KAAU,GAAG;IAAQ,CAAC;GAC/D,CAAC;GACD,IAAI,QAAQ,SAAS,GAAG,OAAO;IAAE,MAAM;IAAW;GAAQ;GAE1D,MAAM,UAAU,SAAoB;IAClC,MAAM,OAAOC,wBAAAA,kBAAkB,UAAU,IAAI;IAC7C,OAAO,SAAS,KAAA,MAAA,GAAaC,gCAAAA,cAAAA,CAAc,IAAI,IAAI,OAAO,KAAA;GAC5D;GACA,MAAM,QAAA,YAAA,EAAQ,IAAIC,gCAAAA,eAChB,IAAI,UAAU,aAAa,gBAAA,GACzBC,gCAAAA,eAAAA,CAAeC,0BAAAA,aAAa,KAAK,MAAM,GAAG;IACxC,SAAS,OAAOC,wBAAAA,mBAAmB,UAAU,EAAE;IAC/C,MAAMC,+BAAAA;GACR,CAAC,CACH,CACF,CAAA;GACA,IAAI,aAAa,MAAM,MAAM,KAAK;GAClC,OAAO;IAAE,MAAM;IAAM,QAAQ,MAAM,KAAK,CAAC,CAAC;GAAI;;;;;;CAChD,CAAC;AACH"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "../pool/driver.js";
|
|
2
|
+
import { PoolColumnIssue } from "./pool_frame.js";
|
|
3
|
+
import { ColumnUniversalId, PTableDefV2, PTableHandle } from "@milaboratories/pl-model-common";
|
|
4
|
+
import { Computable } from "@milaboratories/computable";
|
|
5
|
+
import "@milaboratories/pl-tree";
|
|
6
|
+
/** Why {@link poolTable} refused a column (see {@link PoolColumnIssue}). */
|
|
7
|
+
export type PoolTableIssue = PoolColumnIssue;
|
|
8
|
+
/** A column {@link poolTable} refused, and why. */
|
|
9
|
+
export interface PoolTableRefusal {
|
|
10
|
+
/** The id the table names the column by, or the id of a linker column it reads. */
|
|
11
|
+
readonly columnId: ColumnUniversalId;
|
|
12
|
+
readonly issue: PoolTableIssue;
|
|
13
|
+
/** The error of a `failed` column. */
|
|
14
|
+
readonly message?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* What {@link poolTable} computes: the handle of the table, or, with nothing built, the columns
|
|
18
|
+
* it refused.
|
|
19
|
+
*/
|
|
20
|
+
export type PoolTable = {
|
|
21
|
+
readonly type: "ok";
|
|
22
|
+
readonly handle: PTableHandle;
|
|
23
|
+
} | {
|
|
24
|
+
readonly type: "refused";
|
|
25
|
+
readonly refused: readonly PoolTableRefusal[];
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=pool_table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool_table.d.ts","names":[],"sources":["../../src/middle_layer/pool_table.ts"],"mappings":";;;;;;YAwBY,iBAAiB;;iBAGZ;;WAEN,UAAU;WACV,OAAO;;WAEP;;;;;;YAOC;WACG;WAAqB,QAAQ;;WAC7B;WAA0B,kBAAkB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _usingCtx from "../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/usingCtx.js";
|
|
2
|
+
import { buildColumnRegistry, resolveColumnSpec, resolvePColumnById } from "../js_render/column_registry.js";
|
|
3
|
+
import { collapseSpecOverrideNode } from "../js_render/spec_override_collapse.js";
|
|
4
|
+
import { poolView } from "./pool_columns.js";
|
|
5
|
+
import { poolColumnProblem } from "./pool_frame.js";
|
|
6
|
+
import { richColumnReferences, richTableDef } from "./rich_column_query.js";
|
|
7
|
+
import { PoolEntryGuard, collectSpecQueryColumns, isPColumnSpec, mapPTableDefV2 } from "@milaboratories/pl-model-common";
|
|
8
|
+
import { Computable } from "@milaboratories/computable";
|
|
9
|
+
// src/middle_layer/pool_table.ts
|
|
10
|
+
/**
|
|
11
|
+
* A table over columns of a project's result pool, built by the PFrame driver from `def`, whose
|
|
12
|
+
* columns are pool column ids (those {@link poolColumns} lists, discovered, filtered and
|
|
13
|
+
* overridden ids included): what a block's model gets from `createPTableV2` over the same
|
|
14
|
+
* columns, with no block involved. Each column of a join entry is built into the query its id
|
|
15
|
+
* stands for, with the qualifications of a discovered column, by {@link richTableDef}.
|
|
16
|
+
*
|
|
17
|
+
* Every column must be ready, and so must each linker column a discovered id reads; readiness is
|
|
18
|
+
* that of the exported column an id comes down to. An unknown column, or one whose data is
|
|
19
|
+
* missing, still being calculated or failed, is refused and nothing is built, where a block's
|
|
20
|
+
* model would get an empty column instead.
|
|
21
|
+
*
|
|
22
|
+
* The table is made when the value is first asked for and lives as long as the computable's state:
|
|
23
|
+
* `resetState()` releases it. Ask for the value once. Asking again after the project changed
|
|
24
|
+
* builds a new table and releases the first; {@link Computable.isChanged} tells whether that
|
|
25
|
+
* would happen, i.e. whether what the table was built from may have changed (any change of the
|
|
26
|
+
* project's structure counts too).
|
|
27
|
+
*/
|
|
28
|
+
function poolTable(prjEntry, def, env) {
|
|
29
|
+
return Computable.make((ctx) => {
|
|
30
|
+
try {
|
|
31
|
+
var _usingCtx$1 = _usingCtx();
|
|
32
|
+
const registry = buildColumnRegistry({ upstreamBlockCtxes: poolView(ctx, prjEntry, void 0) ?? [] });
|
|
33
|
+
const refused = [...new Set(collectSpecQueryColumns(def.query).flatMap(richColumnReferences))].flatMap((columnId) => {
|
|
34
|
+
const problem = poolColumnProblem(registry, columnId);
|
|
35
|
+
return problem === void 0 ? [] : [{
|
|
36
|
+
columnId,
|
|
37
|
+
...problem
|
|
38
|
+
}];
|
|
39
|
+
});
|
|
40
|
+
if (refused.length > 0) return {
|
|
41
|
+
type: "refused",
|
|
42
|
+
refused
|
|
43
|
+
};
|
|
44
|
+
const specOf = (leaf) => {
|
|
45
|
+
const spec = resolveColumnSpec(registry, leaf);
|
|
46
|
+
return spec !== void 0 && isPColumnSpec(spec) ? spec : void 0;
|
|
47
|
+
};
|
|
48
|
+
const guard = _usingCtx$1.u(new PoolEntryGuard(env.driverKit.pFrameDriver.createPTableV2(mapPTableDefV2(richTableDef(def, specOf), {
|
|
49
|
+
column: (id) => resolvePColumnById(registry, id),
|
|
50
|
+
node: collapseSpecOverrideNode
|
|
51
|
+
}))));
|
|
52
|
+
ctx.addOnDestroy(guard.entry.unref);
|
|
53
|
+
return {
|
|
54
|
+
type: "ok",
|
|
55
|
+
handle: guard.keep().key
|
|
56
|
+
};
|
|
57
|
+
} catch (_) {
|
|
58
|
+
_usingCtx$1.e = _;
|
|
59
|
+
} finally {
|
|
60
|
+
_usingCtx$1.d();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export { poolTable };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=pool_table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool_table.js","names":[],"sources":["../../src/middle_layer/pool_table.ts"],"sourcesContent":["import { Computable } from \"@milaboratories/computable\";\nimport type { PlTreeEntry } from \"@milaboratories/pl-tree\";\nimport {\n collectSpecQueryColumns,\n isPColumnSpec,\n mapPTableDefV2,\n PoolEntryGuard,\n type ColumnUniversalId,\n type PObjectId,\n type PTableDefV2,\n type PTableHandle,\n} from \"@milaboratories/pl-model-common\";\nimport {\n buildColumnRegistry,\n resolveColumnSpec,\n resolvePColumnById,\n} from \"../js_render/column_registry\";\nimport { collapseSpecOverrideNode } from \"../js_render/spec_override_collapse\";\nimport type { InternalPFrameDriver } from \"../pool/driver\";\nimport { poolView } from \"./pool_columns\";\nimport { poolColumnProblem, type PoolColumnIssue } from \"./pool_frame\";\nimport { richColumnReferences, richTableDef } from \"./rich_column_query\";\n\n/** Why {@link poolTable} refused a column (see {@link PoolColumnIssue}). */\nexport type PoolTableIssue = PoolColumnIssue;\n\n/** A column {@link poolTable} refused, and why. */\nexport interface PoolTableRefusal {\n /** The id the table names the column by, or the id of a linker column it reads. */\n readonly columnId: ColumnUniversalId;\n readonly issue: PoolTableIssue;\n /** The error of a `failed` column. */\n readonly message?: string;\n}\n\n/**\n * What {@link poolTable} computes: the handle of the table, or, with nothing built, the columns\n * it refused.\n */\nexport type PoolTable =\n | { readonly type: \"ok\"; readonly handle: PTableHandle }\n | { readonly type: \"refused\"; readonly refused: readonly PoolTableRefusal[] };\n\n/** What {@link poolTable} uses besides the project tree: the driver that builds the table. */\nexport type PoolTableEnv = {\n readonly driverKit: { readonly pFrameDriver: Pick<InternalPFrameDriver, \"createPTableV2\"> };\n};\n\n/**\n * A table over columns of a project's result pool, built by the PFrame driver from `def`, whose\n * columns are pool column ids (those {@link poolColumns} lists, discovered, filtered and\n * overridden ids included): what a block's model gets from `createPTableV2` over the same\n * columns, with no block involved. Each column of a join entry is built into the query its id\n * stands for, with the qualifications of a discovered column, by {@link richTableDef}.\n *\n * Every column must be ready, and so must each linker column a discovered id reads; readiness is\n * that of the exported column an id comes down to. An unknown column, or one whose data is\n * missing, still being calculated or failed, is refused and nothing is built, where a block's\n * model would get an empty column instead.\n *\n * The table is made when the value is first asked for and lives as long as the computable's state:\n * `resetState()` releases it. Ask for the value once. Asking again after the project changed\n * builds a new table and releases the first; {@link Computable.isChanged} tells whether that\n * would happen, i.e. whether what the table was built from may have changed (any change of the\n * project's structure counts too).\n */\nexport function poolTable(\n prjEntry: PlTreeEntry,\n def: PTableDefV2<ColumnUniversalId>,\n env: PoolTableEnv,\n): Computable<PoolTable> {\n return Computable.make((ctx): PoolTable => {\n const registry = buildColumnRegistry({\n upstreamBlockCtxes: poolView(ctx, prjEntry, undefined) ?? [],\n });\n const ids = [...new Set(collectSpecQueryColumns(def.query).flatMap(richColumnReferences))];\n const refused = ids.flatMap((columnId): PoolTableRefusal[] => {\n const problem = poolColumnProblem(registry, columnId);\n return problem === undefined ? [] : [{ columnId, ...problem }];\n });\n if (refused.length > 0) return { type: \"refused\", refused };\n\n const specOf = (leaf: PObjectId) => {\n const spec = resolveColumnSpec(registry, leaf);\n return spec !== undefined && isPColumnSpec(spec) ? spec : undefined;\n };\n using guard = new PoolEntryGuard(\n env.driverKit.pFrameDriver.createPTableV2(\n mapPTableDefV2(richTableDef(def, specOf), {\n column: (id) => resolvePColumnById(registry, id),\n node: collapseSpecOverrideNode,\n }),\n ),\n );\n ctx.addOnDestroy(guard.entry.unref);\n return { type: \"ok\", handle: guard.keep().key };\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,SAAgB,UACd,UACA,KACA,KACuB;CACvB,OAAO,WAAW,MAAM,QAAmB;;;GACzC,MAAM,WAAW,oBAAoB,EACnC,oBAAoB,SAAS,KAAK,UAAU,KAAA,CAAS,KAAK,CAAC,EAC7D,CAAC;GAED,MAAM,UAAU,CADH,GAAG,IAAI,IAAI,wBAAwB,IAAI,KAAK,CAAC,CAAC,QAAQ,oBAAoB,CAAC,CACtE,CAAC,CAAC,SAAS,aAAiC;IAC5D,MAAM,UAAU,kBAAkB,UAAU,QAAQ;IACpD,OAAO,YAAY,KAAA,IAAY,CAAC,IAAI,CAAC;KAAE;KAAU,GAAG;IAAQ,CAAC;GAC/D,CAAC;GACD,IAAI,QAAQ,SAAS,GAAG,OAAO;IAAE,MAAM;IAAW;GAAQ;GAE1D,MAAM,UAAU,SAAoB;IAClC,MAAM,OAAO,kBAAkB,UAAU,IAAI;IAC7C,OAAO,SAAS,KAAA,KAAa,cAAc,IAAI,IAAI,OAAO,KAAA;GAC5D;GACA,MAAM,QAAA,YAAA,EAAQ,IAAI,eAChB,IAAI,UAAU,aAAa,eACzB,eAAe,aAAa,KAAK,MAAM,GAAG;IACxC,SAAS,OAAO,mBAAmB,UAAU,EAAE;IAC/C,MAAM;GACR,CAAC,CACH,CACF,CAAA;GACA,IAAI,aAAa,MAAM,MAAM,KAAK;GAClC,OAAO;IAAE,MAAM;IAAM,QAAQ,MAAM,KAAK,CAAC,CAAC;GAAI;;;;;;CAChD,CAAC;AACH"}
|
|
@@ -12,13 +12,18 @@ const require_block = require("./block.cjs");
|
|
|
12
12
|
const require_block_action_context = require("./block_action_context.cjs");
|
|
13
13
|
const require_block_status_tree = require("./block_status_tree.cjs");
|
|
14
14
|
const require_active_cfg = require("./active_cfg.cjs");
|
|
15
|
+
const require_pool_columns = require("./pool_columns.cjs");
|
|
16
|
+
const require_pool_frame = require("./pool_frame.cjs");
|
|
17
|
+
const require_pool_table = require("./pool_table.cjs");
|
|
15
18
|
const require_navigation_states = require("./navigation_states.cjs");
|
|
16
19
|
const require_project_overview_light = require("./project_overview_light.cjs");
|
|
17
20
|
const require_migration = require("../mutator/migration.cjs");
|
|
21
|
+
const require_block_params_model = require("../model/block_params_model.cjs");
|
|
18
22
|
let _platforma_sdk_model = require("@platforma-sdk/model");
|
|
19
23
|
let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
|
|
20
24
|
let node_fs_promises = require("node:fs/promises");
|
|
21
25
|
node_fs_promises = require_runtime.__toESM(node_fs_promises, 1);
|
|
26
|
+
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
22
27
|
let _milaboratories_computable = require("@milaboratories/computable");
|
|
23
28
|
let node_timers_promises = require("node:timers/promises");
|
|
24
29
|
let _milaboratories_pl_client = require("@milaboratories/pl-client");
|
|
@@ -39,6 +44,7 @@ function stringifyForDump(object) {
|
|
|
39
44
|
/** Releases what the computables of a block hold. */
|
|
40
45
|
function resetBlockState(computables) {
|
|
41
46
|
computables.fullState.resetState();
|
|
47
|
+
computables.readiness.resetState();
|
|
42
48
|
computables.dependencies.resetState();
|
|
43
49
|
computables.dependents.resetState();
|
|
44
50
|
}
|
|
@@ -320,10 +326,14 @@ var Project = class Project {
|
|
|
320
326
|
/**
|
|
321
327
|
* Update block to new block pack, optionally resetting args and ui state to
|
|
322
328
|
* initial values
|
|
329
|
+
*
|
|
330
|
+
* @throws ModelAPIVersionMismatchError when `ops.requireModelAPIVersion` differs from the
|
|
331
|
+
* model API version of the new block pack; nothing is changed
|
|
323
332
|
* */
|
|
324
|
-
async updateBlockPack(blockId, blockPackSpec, resetArgs = false, author) {
|
|
333
|
+
async updateBlockPack(blockId, blockPackSpec, resetArgs = false, author, ops = {}) {
|
|
325
334
|
const preparedBp = await this.env.bpPreparer.prepare(blockPackSpec);
|
|
326
335
|
const blockCfg = (0, _platforma_sdk_model.extractConfig)(preparedBp.config);
|
|
336
|
+
if (ops.requireModelAPIVersion !== void 0 && blockCfg.modelAPIVersion !== ops.requireModelAPIVersion) throw new _milaboratories_pl_errors.ModelAPIVersionMismatchError(blockId, ops.requireModelAPIVersion, blockCfg.modelAPIVersion);
|
|
327
337
|
this.env.runtimeCapabilities.throwIfIncompatible(blockCfg.featureFlags);
|
|
328
338
|
require_required_capabilities.throwIfMissingServerCapabilities(this.env.pl, preparedBp.requiredCapabilities);
|
|
329
339
|
const cachedBp = await require_template_cache.cacheBlockPackTemplate(this.env.pl, preparedBp, { preparer: this.env.bpPreparer });
|
|
@@ -379,13 +389,17 @@ var Project = class Project {
|
|
|
379
389
|
* Renders production part of the block starting all connected heavy computations.
|
|
380
390
|
* Upstream blocks of the specified block will be started automatically if in
|
|
381
391
|
* stale state.
|
|
392
|
+
*
|
|
393
|
+
* @returns the ids of the blocks whose production was started, in project order; empty when
|
|
394
|
+
* the block and the blocks above it were up to date and nothing was started
|
|
382
395
|
* */
|
|
383
396
|
async runBlock(blockId) {
|
|
384
|
-
await require_project.withProject(this.env.projectHelper, this.env.pl, this.rid, (mut) => mut.renderProduction([blockId], true), {
|
|
397
|
+
const started = await require_project.withProject(this.env.projectHelper, this.env.pl, this.rid, (mut) => [...mut.renderProduction([blockId], true)].map(_milaboratories_pl_model_common.asBlockId), {
|
|
385
398
|
name: "runBlock",
|
|
386
399
|
lockId: this.projectLockId
|
|
387
400
|
});
|
|
388
401
|
await this.refreshAfterWrite();
|
|
402
|
+
return started;
|
|
389
403
|
}
|
|
390
404
|
/**
|
|
391
405
|
* Stops the block if it is running by destroying its production state. All
|
|
@@ -508,6 +522,23 @@ var Project = class Project {
|
|
|
508
522
|
lockId: this.projectLockId
|
|
509
523
|
});
|
|
510
524
|
}
|
|
525
|
+
/**
|
|
526
|
+
* The block's model as functions between its kind's params and its data: `init(params)` and
|
|
527
|
+
* `templateParams(data)` of the model of the block's current pack (see {@link BlockParamsModel}).
|
|
528
|
+
* One read transaction finds the model; each call of the result then runs it in the VM on its
|
|
529
|
+
* own, with no block created and nothing written. A caller writes what it computed with
|
|
530
|
+
* {@link mutateBlockStorage}.
|
|
531
|
+
*
|
|
532
|
+
* @throws when the project has no such block
|
|
533
|
+
* @throws {ModelAPIVersionMismatchError} when the block is not on BlockModelV3
|
|
534
|
+
*/
|
|
535
|
+
async getBlockParamsModel(blockId) {
|
|
536
|
+
const config = await require_project.withProject(this.env.projectHelper, this.env.pl, this.rid, (prj) => prj.getBlockConfig(blockId), {
|
|
537
|
+
name: "getBlockParamsModel",
|
|
538
|
+
lockId: this.projectLockId
|
|
539
|
+
});
|
|
540
|
+
return require_block_params_model.blockParamsModel(this.env.projectHelper, blockId, config);
|
|
541
|
+
}
|
|
511
542
|
/** Update block settings */
|
|
512
543
|
async setBlockSettings(blockId, newValue) {
|
|
513
544
|
await require_project.withProjectAuthored(this.env.projectHelper, this.env.pl, this.rid, void 0, (mut) => {
|
|
@@ -587,6 +618,7 @@ var Project = class Project {
|
|
|
587
618
|
}, v.overview?.blocks ?? [])
|
|
588
619
|
};
|
|
589
620
|
} }).withPreCalculatedValueTree(),
|
|
621
|
+
readiness: require_block.blockReadiness(this.projectTree.entry(), (0, _milaboratories_pl_model_common.asBlockId)(blockId), this.env),
|
|
590
622
|
dependencies,
|
|
591
623
|
dependents
|
|
592
624
|
};
|
|
@@ -692,6 +724,55 @@ var Project = class Project {
|
|
|
692
724
|
return this.getBlockComputables(blockId).fullState;
|
|
693
725
|
}
|
|
694
726
|
/**
|
|
727
|
+
* Returns a computable of what keeps the block from running or from being staged: the issues
|
|
728
|
+
* its model finds in its current data and the references to blocks it cannot read from (see
|
|
729
|
+
* {@link BlockReadiness}). The block's model runs when the value is asked for, not before, and
|
|
730
|
+
* again only after the project changed. `undefined` for a block not on model API version 2.
|
|
731
|
+
*/
|
|
732
|
+
getBlockReadiness(blockId) {
|
|
733
|
+
return this.getBlockComputables(blockId).readiness;
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Returns a computable of the project's result-pool columns, specs and refs with no data: as the
|
|
737
|
+
* block `query.viewAs` sees them (the block and the blocks above it), or as the last block sees
|
|
738
|
+
* them, which is every block's, and filtered by the selectors a block model passes to
|
|
739
|
+
* `ColumnsCollection.filter`. Nothing is computed before the value is asked for, and the
|
|
740
|
+
* computable is not kept by the project: each call makes a new one.
|
|
741
|
+
*/
|
|
742
|
+
getPoolColumns(query = {}) {
|
|
743
|
+
return require_pool_columns.poolColumns(this.projectTree.entry(), query, this.env);
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Returns a computable of the result-pool columns `ids` stand for, in their order, as the block
|
|
747
|
+
* `viewAs` sees the pool (default: every block's); `undefined` for an id that is no column of
|
|
748
|
+
* it. Each id is looked up directly, so it finds a column {@link getPoolColumns} leaves out for
|
|
749
|
+
* having the same spec as another (see {@link poolColumnsById}). Not kept by the project.
|
|
750
|
+
*/
|
|
751
|
+
getPoolColumnsById(ids, viewAs) {
|
|
752
|
+
return require_pool_columns.poolColumnsById(this.projectTree.entry(), ids, viewAs);
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Returns a computable of a PFrame over result-pool columns of the project, by their ids (see
|
|
756
|
+
* {@link poolFrame}): what the values of a pool column are read from. A column that is unknown,
|
|
757
|
+
* not ready, without data or failed, or whose id filters an axis, is refused, and nothing is
|
|
758
|
+
* built. The frame is built when the value is asked for and released by the computable's
|
|
759
|
+
* `resetState()`; the computable is not kept by the project, so its owner must reset it.
|
|
760
|
+
*/
|
|
761
|
+
createPoolFrame(ids) {
|
|
762
|
+
return require_pool_frame.poolFrame(this.projectTree.entry(), ids, this.env);
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Returns a computable of a table over result-pool columns of the project, built by the PFrame
|
|
766
|
+
* driver from `def`, whose columns are the ids {@link getPoolColumns} lists, discovered ones
|
|
767
|
+
* included (see {@link poolTable}): the query of a rich id is built on the host. An unknown
|
|
768
|
+
* column, or one whose data is missing or not ready, is refused, and nothing is built. The table is built when the value is asked for and released by the
|
|
769
|
+
* computable's `resetState()`; the computable is not kept by the project, so its owner must
|
|
770
|
+
* reset it.
|
|
771
|
+
*/
|
|
772
|
+
createPoolTable(def) {
|
|
773
|
+
return require_pool_table.poolTable(this.projectTree.entry(), def, this.env);
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
695
776
|
* Returns a computable, that can be used to retrieve and watch path of the
|
|
696
777
|
* folder containing frontend code.
|
|
697
778
|
* */
|