@platforma-sdk/block-tools 2.7.25 → 2.8.1
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/cli.js +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/config-C8wPuCgh.js +3 -0
- package/dist/config-C8wPuCgh.js.map +1 -0
- package/dist/{config-C-EJTl6j.mjs → config-CzNlwcwn.mjs} +354 -338
- package/dist/config-CzNlwcwn.mjs.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/v2/model/block_components.d.ts +57 -57
- package/dist/v2/model/block_description.d.ts +11671 -5147
- package/dist/v2/model/block_meta.d.ts +3081 -805
- package/package.json +8 -7
- package/src/v2/build_dist.ts +51 -0
- package/dist/config-C-EJTl6j.mjs.map +0 -1
- package/dist/config-CZwHml_R.js +0 -3
- package/dist/config-CZwHml_R.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/block-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "Utility to manipulate Platforma Blocks and Block Registry",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"bin": {
|
|
@@ -32,13 +32,14 @@
|
|
|
32
32
|
"undici": "~7.16.0",
|
|
33
33
|
"yaml": "^2.8.0",
|
|
34
34
|
"zod": "~3.25.76",
|
|
35
|
-
"@milaboratories/pl-model-common": "1.42.0",
|
|
36
|
-
"@milaboratories/pl-http": "1.2.4",
|
|
37
|
-
"@milaboratories/pl-model-middle-layer": "1.19.4",
|
|
38
35
|
"@milaboratories/resolve-helper": "1.1.3",
|
|
39
|
-
"@milaboratories/
|
|
36
|
+
"@milaboratories/pl-http": "1.2.4",
|
|
37
|
+
"@milaboratories/pl-model-backend": "1.3.1",
|
|
38
|
+
"@milaboratories/pl-model-common": "1.42.0",
|
|
39
|
+
"@milaboratories/pl-model-middle-layer": "1.20.0",
|
|
40
40
|
"@milaboratories/ts-helpers": "1.8.2",
|
|
41
|
-
"@platforma-sdk/blocks-deps-updater": "2.2.0"
|
|
41
|
+
"@platforma-sdk/blocks-deps-updater": "2.2.0",
|
|
42
|
+
"@milaboratories/ts-helpers-oclif": "1.1.41"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
@@ -54,8 +55,8 @@
|
|
|
54
55
|
"vite-plugin-dts": "^4.5.3",
|
|
55
56
|
"vitest": "^4.1.3",
|
|
56
57
|
"@milaboratories/build-configs": "2.0.0",
|
|
57
|
-
"@milaboratories/ts-builder": "1.4.0",
|
|
58
58
|
"@milaboratories/oclif-index": "1.1.1",
|
|
59
|
+
"@milaboratories/ts-builder": "1.5.0",
|
|
59
60
|
"@milaboratories/ts-configs": "1.2.3"
|
|
60
61
|
},
|
|
61
62
|
"oclif": {
|
package/src/v2/build_dist.ts
CHANGED
|
@@ -3,12 +3,44 @@ import type {
|
|
|
3
3
|
ManifestFileInfo,
|
|
4
4
|
} from "@milaboratories/pl-model-middle-layer";
|
|
5
5
|
import { BlockPackManifest, BlockPackManifestFile } from "@milaboratories/pl-model-middle-layer";
|
|
6
|
+
import type { CompiledTemplateV3 } from "@milaboratories/pl-model-backend";
|
|
6
7
|
import type { BlockPackDescriptionAbsolute } from "./model";
|
|
7
8
|
import { BlockPackDescriptionConsolidateToFolder } from "./model";
|
|
8
9
|
import fsp from "node:fs/promises";
|
|
9
10
|
import path from "node:path";
|
|
11
|
+
import { gunzipSync } from "node:zlib";
|
|
10
12
|
import { calculateSha256 } from "../util";
|
|
11
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Returns the capability tokens the workflow's compiled template declares
|
|
16
|
+
* it needs (via `TemplateDataV3.requiredCapabilities`, populated by
|
|
17
|
+
* tengo-builder at compile time). Returns `undefined` for v2 packs, for
|
|
18
|
+
* malformed packs, or when the template carries no requirements — fail-
|
|
19
|
+
* safe so the worst case is "block installs anywhere", the pre-WASM
|
|
20
|
+
* status quo.
|
|
21
|
+
*/
|
|
22
|
+
async function workflowRequiredCapabilities(
|
|
23
|
+
descriptionRelative: BlockPackDescriptionManifest,
|
|
24
|
+
dst: string,
|
|
25
|
+
): Promise<string[] | undefined> {
|
|
26
|
+
// After BlockPackDescriptionConsolidateToFolder runs, components.workflow.main
|
|
27
|
+
// is always a {type: "relative", path: ...} reference into dst.
|
|
28
|
+
const main = descriptionRelative.components.workflow.main;
|
|
29
|
+
const bytes = await fsp.readFile(path.resolve(dst, main.path));
|
|
30
|
+
|
|
31
|
+
let parsed: unknown;
|
|
32
|
+
try {
|
|
33
|
+
const json = gunzipSync(bytes).toString("utf-8");
|
|
34
|
+
parsed = JSON.parse(json);
|
|
35
|
+
} catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const pack = parsed as Partial<CompiledTemplateV3>;
|
|
40
|
+
if (pack.type !== "pl.tengo-template.v3" || !pack.template) return undefined;
|
|
41
|
+
return pack.template.requiredCapabilities;
|
|
42
|
+
}
|
|
43
|
+
|
|
12
44
|
export async function buildBlockPackDist(
|
|
13
45
|
description: BlockPackDescriptionAbsolute,
|
|
14
46
|
dst: string,
|
|
@@ -17,6 +49,25 @@ export async function buildBlockPackDist(
|
|
|
17
49
|
const files: string[] = [];
|
|
18
50
|
const descriptionRelative: BlockPackDescriptionManifest =
|
|
19
51
|
await BlockPackDescriptionConsolidateToFolder(dst, files).parseAsync(description);
|
|
52
|
+
|
|
53
|
+
// Per-block capability detection: mirror the workflow's
|
|
54
|
+
// compile-time-computed `requiredCapabilities` onto the published
|
|
55
|
+
// manifest meta, so only blocks that actually need a feature force the
|
|
56
|
+
// customer to run a backend advertising it. Tengo-builder is the
|
|
57
|
+
// source of truth here — it populates the field when it embeds wasm
|
|
58
|
+
// bytes (or any future feature artifact); block-tools just propagates
|
|
59
|
+
// upward.
|
|
60
|
+
//
|
|
61
|
+
// See docs/text/work/projects/webassembly-libraries-tengo/README.md,
|
|
62
|
+
// "Capability declaration: detected from main.plj.gz, not the SDK release".
|
|
63
|
+
const workflowCapabilities = await workflowRequiredCapabilities(descriptionRelative, dst);
|
|
64
|
+
if (workflowCapabilities && workflowCapabilities.length > 0) {
|
|
65
|
+
descriptionRelative.meta = {
|
|
66
|
+
...descriptionRelative.meta,
|
|
67
|
+
requiredCapabilities: workflowCapabilities,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
20
71
|
const filesForManifest = await Promise.all(
|
|
21
72
|
files.map(async (f): Promise<ManifestFileInfo> => {
|
|
22
73
|
const bytes = await fsp.readFile(path.resolve(dst, f));
|