@platforma-sdk/block-tools 2.11.2 → 2.11.4

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.
Files changed (89) hide show
  1. package/bin/run.js +9 -5
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.js +13 -13
  4. package/dist/cli.js.map +1 -1
  5. package/dist/cli.mjs +845 -981
  6. package/dist/cli.mjs.map +1 -1
  7. package/dist/cmd/build-meta.d.ts +2 -9
  8. package/dist/cmd/build-model.d.ts +2 -10
  9. package/dist/cmd/list-overview-snapshots.d.ts +2 -9
  10. package/dist/cmd/mark-stable.d.ts +2 -13
  11. package/dist/cmd/pack.d.ts +2 -9
  12. package/dist/cmd/publish.d.ts +2 -12
  13. package/dist/cmd/refresh-registry.d.ts +2 -9
  14. package/dist/cmd/restore-overview-from-snapshot.d.ts +2 -10
  15. package/dist/cmd/structure/check.d.ts +2 -10
  16. package/dist/cmd/structure/init.d.ts +2 -18
  17. package/dist/cmd/structure/refresh.d.ts +10 -11
  18. package/dist/cmd/update-deps.d.ts +2 -6
  19. package/dist/cmd/upload-package-v1.d.ts +2 -14
  20. package/dist/config-BmJWc8sR.js +3 -0
  21. package/dist/config-BmJWc8sR.js.map +1 -0
  22. package/dist/{config-DpfTzcgG.mjs → config-CiC347sB.mjs} +453 -398
  23. package/dist/config-CiC347sB.mjs.map +1 -0
  24. package/dist/index.js +1 -1
  25. package/dist/index.mjs +15 -15
  26. package/dist/registry_v1/config_schema.d.ts +7 -7
  27. package/dist/registry_v1/flags.d.ts +2 -4
  28. package/dist/structure/cli/run-structure.d.ts +1 -1
  29. package/dist/structure/engine/discovery.d.ts +2 -3
  30. package/dist/structure/rules/block-package-json.d.ts +3 -3
  31. package/dist/structure/rules/shared/pascal-case.d.ts +1 -0
  32. package/dist/v2/index.d.ts +1 -0
  33. package/dist/v2/model/block_components.d.ts +11 -0
  34. package/dist/v2/model/block_meta.d.ts +7 -0
  35. package/dist/v2/resolve_to_registry.d.ts +37 -0
  36. package/dist/v2/source_package.d.ts +12 -0
  37. package/package.json +9 -24
  38. package/src/cli.test.ts +56 -0
  39. package/src/cli.ts +50 -0
  40. package/src/cmd/build-meta.ts +11 -22
  41. package/src/cmd/build-model.ts +16 -33
  42. package/src/cmd/list-overview-snapshots.ts +24 -28
  43. package/src/cmd/mark-stable.ts +35 -55
  44. package/src/cmd/pack.ts +11 -22
  45. package/src/cmd/publish.test.ts +35 -0
  46. package/src/cmd/publish.ts +55 -49
  47. package/src/cmd/refresh-registry.ts +22 -26
  48. package/src/cmd/restore-overview-from-snapshot.ts +24 -34
  49. package/src/cmd/structure/check.ts +19 -28
  50. package/src/cmd/structure/init.ts +40 -47
  51. package/src/cmd/structure/refresh.ts +45 -36
  52. package/src/cmd/update-deps.ts +22 -12
  53. package/src/cmd/upload-package-v1.ts +42 -60
  54. package/src/registry_v1/flags.ts +7 -7
  55. package/src/structure/__tests__/discovery-shortname.test.ts +3 -0
  56. package/src/structure/__tests__/facade-end-state.test.ts +195 -0
  57. package/src/structure/__tests__/model-package-json.snapshot.test.ts +1 -1
  58. package/src/structure/cli/run-structure.ts +2 -2
  59. package/src/structure/engine/__tests__/discovery.test.ts +22 -26
  60. package/src/structure/engine/discovery.ts +12 -30
  61. package/src/structure/rules/block-package-json.ts +146 -64
  62. package/src/structure/rules/block.ts +40 -5
  63. package/src/structure/rules/model-package-json.ts +6 -1
  64. package/src/structure/rules/shared/pascal-case.ts +16 -0
  65. package/src/structure/rules/software-package-json.ts +6 -1
  66. package/src/structure/rules/test-package-json.ts +5 -1
  67. package/src/structure/rules/ui-package-json.ts +5 -1
  68. package/src/structure/rules/workflow-package-json.ts +5 -1
  69. package/src/structure/templates/static/block/src/AGENTS.ts +5 -0
  70. package/src/structure/templates/static/block/src/agents-extra.ts +8 -0
  71. package/src/structure/templates/static/block/src/block-extra.ts +9 -0
  72. package/src/structure/templates/static/block/tsconfig.json +4 -0
  73. package/src/structure/templates/text/block/src/index.tpl.ts +55 -0
  74. package/src/v2/from_pack_v2.test.ts +142 -0
  75. package/src/v2/index.ts +1 -0
  76. package/src/v2/model/block_components.ts +33 -0
  77. package/src/v2/model/block_meta.ts +18 -0
  78. package/src/v2/model/content_conversion.ts +0 -1
  79. package/src/v2/resolve_to_registry.ts +84 -0
  80. package/src/v2/source_package.ts +34 -1
  81. package/bin/dev.cmd +0 -3
  82. package/bin/dev.js +0 -6
  83. package/dist/cmd/index.d.ts +0 -28
  84. package/dist/config-DpfTzcgG.mjs.map +0 -1
  85. package/dist/config-xxVy3IQR.js +0 -3
  86. package/dist/config-xxVy3IQR.js.map +0 -1
  87. package/src/cmd/index.ts +0 -31
  88. package/src/structure/templates/static/block/index.d.ts +0 -6
  89. package/src/structure/templates/static/block/index.js +0 -8
package/dist/cli.mjs CHANGED
@@ -1,391 +1,120 @@
1
- import { H as e, K as t, O as n, U as r, _ as i, _t as a, b as o, et as s, n as c, p as l, rt as ee } from "./config-DpfTzcgG.mjs";
2
- import { Args as u, Command as d, Flags as f } from "@oclif/core";
3
- import p from "node:path";
4
- import m from "node:fs";
1
+ import { H as e, O as t, Q as n, Tt as r, W as i, Y as a, _ as o, b as s, n as c, p as l, q as u, st as d, ut as ee } from "./config-CiC347sB.mjs";
2
+ import { Command as f, Option as p } from "commander";
3
+ import m from "node:path";
4
+ import h from "node:fs";
5
5
  import { BlockPackManifest as te, StableChannel as ne, overrideDescriptionVersion as re, overrideManifestVersion as ie } from "@milaboratories/pl-model-middle-layer";
6
- import { OclifLoggerAdapter as h } from "@milaboratories/ts-helpers-oclif";
6
+ import { ConsoleLoggerAdapter as g } from "@milaboratories/ts-helpers";
7
7
  import ae, { parse as oe, parseDocument as se, stringify as ce } from "yaml";
8
8
  import { setTimeout as le } from "node:timers/promises";
9
9
  import { confirm as ue, input as de, select as fe } from "@inquirer/prompts";
10
10
  //#region src/cmd/build-meta.ts
11
- var pe = class e extends d {
12
- static description = "Extracts meta information from blocks package.json and outputs meta.json with embedded binary and textual information linked from the meta section.";
13
- static flags = {
14
- modulePath: f.string({
15
- char: "i",
16
- summary: "input module path",
17
- helpValue: "<path>",
18
- default: "."
19
- }),
20
- destination: f.string({
21
- char: "o",
22
- summary: "output meta.json file",
23
- helpValue: "<path>",
24
- required: !0
25
- })
26
- };
27
- async run() {
28
- let { flags: t } = await this.parse(e), n = p.resolve(t.modulePath), i = await s(await ee((await r(n)).meta, n));
29
- await m.promises.writeFile(p.resolve(t.destination), JSON.stringify(i));
30
- }
31
- };
11
+ function pe() {
12
+ let e = new f("build-meta").description("Extracts meta information from blocks package.json and outputs meta.json with embedded binary and textual information linked from the meta section.");
13
+ return e.option("-i, --modulePath <path>", "input module path", "."), e.requiredOption("-o, --destination <path>", "output meta.json file"), e.action(async (e) => {
14
+ let t = m.resolve(e.modulePath), n = await d(await ee((await a(t)).meta, t));
15
+ await h.promises.writeFile(m.resolve(e.destination), JSON.stringify(n));
16
+ }), e;
17
+ }
32
18
  //#endregion
33
19
  //#region src/cmd/build-model.ts
34
20
  async function me(e) {
35
21
  try {
36
- return await m.promises.readFile(e, "utf8");
22
+ return await h.promises.readFile(e, "utf8");
37
23
  } catch (e) {
38
24
  if (e instanceof Error && "code" in e && e.code === "ENOENT") return;
39
25
  throw e;
40
26
  }
41
27
  }
42
- var he = class e extends d {
43
- static description = "Extracts and outputs block model JSON from pre-built block model module";
44
- static flags = {
45
- modulePath: f.string({
46
- char: "i",
47
- summary: "input module path",
48
- helpValue: "<path>",
49
- default: "."
50
- }),
51
- sourceBundle: f.string({
52
- char: "b",
53
- summary: "bundled model code to embed into the model for callback-based rendering to work",
54
- helpValue: "<path>",
55
- default: "./dist/bundle.js"
56
- }),
57
- destination: f.string({
58
- char: "o",
59
- summary: "output model file",
60
- helpValue: "<path>",
61
- default: "./dist/model.json"
62
- })
63
- };
64
- async run() {
65
- let { flags: t } = await this.parse(e), { model: n, platforma: r } = a(p.resolve(t.modulePath));
66
- if (n ||= r, !n) throw Error("\"model\" export not found");
67
- let { config: i } = n;
28
+ function he() {
29
+ let e = new f("build-model").description("Extracts and outputs block model JSON from pre-built block model module");
30
+ return e.option("-i, --modulePath <path>", "input module path", "."), e.option("-b, --sourceBundle <path>", "bundled model code to embed into the model for callback-based rendering to work", "./dist/bundle.js"), e.option("-o, --destination <path>", "output model file", "./dist/model.json"), e.action(async (e) => {
31
+ let { model: t, platforma: n } = r(m.resolve(e.modulePath));
32
+ if (t ||= n, !t) throw Error("\"model\" export not found");
33
+ let { config: i } = t;
68
34
  if (!i) throw Error("Malformed \"model\" object, check it is created with \"BlockModel\" and \".done()\" is executed as the call in the chain.");
69
35
  if (!("outputs" in i) || !("sections" in i)) throw Error("\"config\" has unexpected structure");
70
- let o = await me(t.sourceBundle);
71
- o !== void 0 && (i.code = {
36
+ let a = await me(e.sourceBundle);
37
+ a !== void 0 && (i.code = {
72
38
  type: "plain",
73
- content: o
74
- }), await m.promises.writeFile(p.resolve(t.destination), JSON.stringify(i));
75
- }
76
- }, ge = class e extends d {
77
- static description = "List all available global overview snapshots in the registry";
78
- static flags = {
79
- registry: f.string({
80
- char: "r",
81
- summary: "full address of the registry",
82
- helpValue: "<address>",
83
- env: "PL_REGISTRY",
84
- required: !0
85
- }),
86
- json: f.boolean({
87
- summary: "output in JSON format",
88
- default: !1
89
- })
90
- };
91
- async run() {
92
- let { flags: t } = await this.parse(e), n = await new o(i(t.registry), new h(this)).listGlobalOverviewSnapshots();
93
- if (t.json) this.log(JSON.stringify(n, null, 2));
94
- else if (n.length === 0) this.log("No snapshots found.");
95
- else {
96
- this.log(`Found ${n.length} snapshot(s):\n`);
97
- for (let e of n) this.log(` ${e.timestamp}`), this.log(` Path: ${e.path}`), this.log("");
98
- }
99
- }
100
- }, _e = class e extends d {
101
- static description = "Mark target block stable";
102
- static flags = {
103
- modulePath: f.string({
104
- char: "i",
105
- summary: "input module path",
106
- helpValue: "<path>",
107
- default: "."
108
- }),
109
- channel: f.string({
110
- char: "c",
111
- hidden: !0,
112
- summary: "custom channel",
113
- helpValue: "<channel name>",
114
- default: ne
115
- }),
116
- "version-override": f.file({
117
- char: "v",
118
- summary: "override package version"
119
- }),
120
- registry: f.string({
121
- char: "r",
122
- summary: "full address of the registry",
123
- helpValue: "<address>",
124
- env: "PL_REGISTRY",
125
- required: !0
126
- }),
127
- refresh: f.boolean({
128
- summary: "refresh repository after adding the package",
129
- default: !0,
130
- allowNo: !0,
131
- env: "PL_REGISTRY_REFRESH"
132
- }),
133
- unmark: f.boolean({
134
- summary: "reverses meaning of this command, flag can be used to remove \"stable\" flag from the package",
135
- default: !1
136
- })
137
- };
138
- async run() {
139
- let { flags: t } = await this.parse(e), n = await r(p.resolve(t.modulePath));
140
- t["version-override"] && (n = re(n, t["version-override"]));
141
- let a = new o(i(t.registry), new h(this));
142
- t.unmark ? await a.removePackageFromChannel(n.id, t.channel) : await a.addPackageToChannel(n.id, t.channel), t.refresh && await a.updateIfNeeded();
143
- }
144
- }, ve = class n extends d {
145
- static description = "Builds block pack and outputs a block pack manifest consolidating all references assets into a single folder";
146
- static flags = {
147
- modulePath: f.string({
148
- char: "i",
149
- summary: "input module path",
150
- helpValue: "<path>",
151
- default: "."
152
- }),
153
- destinationPath: f.string({
154
- char: "o",
155
- summary: "output folder",
156
- helpValue: "<path>",
157
- default: "./block-pack"
158
- })
159
- };
160
- async run() {
161
- let { flags: r } = await this.parse(n);
162
- await t(await e(p.resolve(r.modulePath)), p.resolve(r.destinationPath));
163
- }
164
- };
39
+ content: a
40
+ }), await h.promises.writeFile(m.resolve(e.destination), JSON.stringify(i));
41
+ }), e;
42
+ }
43
+ //#endregion
44
+ //#region src/cmd/pack.ts
45
+ function ge() {
46
+ let e = new f("pack").description("Builds block pack and outputs a block pack manifest consolidating all references assets into a single folder");
47
+ return e.option("-i, --modulePath <path>", "input module path", "."), e.option("-o, --destinationPath <path>", "output folder", "./block-pack"), e.action(async (e) => {
48
+ await n(await u(m.resolve(e.modulePath)), m.resolve(e.destinationPath));
49
+ }), e;
50
+ }
165
51
  //#endregion
166
52
  //#region src/cmd/publish.ts
167
- function ye(e, t) {
53
+ function _e(e, t) {
168
54
  let n = { ...e };
169
- for (let e in t) t[e] && typeof t[e] == "object" && !Array.isArray(t[e]) && n[e] && typeof n[e] == "object" && !Array.isArray(n[e]) ? n[e] = ye(n[e], t[e]) : n[e] = t[e];
55
+ for (let e in t) t[e] && typeof t[e] == "object" && !Array.isArray(t[e]) && n[e] && typeof n[e] == "object" && !Array.isArray(n[e]) ? n[e] = _e(n[e], t[e]) : n[e] = t[e];
170
56
  return n;
171
57
  }
172
- var be = class e extends d {
173
- static description = "Publishes the block package and refreshes the registry (for v2 block-pack schema)";
174
- static flags = {
175
- registry: f.string({
176
- char: "r",
177
- summary: "full address of the registry",
178
- helpValue: "<address>",
179
- env: "PL_REGISTRY",
180
- required: !0
181
- }),
182
- manifest: f.file({
183
- char: "m",
184
- summary: "manifest file path",
185
- exists: !0,
186
- default: `./block-pack/${n}`
187
- }),
188
- "version-override": f.file({
189
- char: "v",
190
- summary: "override package version"
191
- }),
192
- refresh: f.boolean({
193
- summary: "refresh repository after adding the package",
194
- default: !0,
195
- allowNo: !0,
196
- env: "PL_REGISTRY_REFRESH"
197
- }),
198
- unstable: f.boolean({
199
- summary: "do not add the published package to stable channel",
200
- default: !1,
201
- env: "PL_PUBLISH_UNSTABLE"
202
- })
203
- };
204
- async run() {
205
- let { flags: t } = await this.parse(e), n = p.resolve(t.manifest), r = JSON.parse(await m.promises.readFile(n, { encoding: "utf-8" })), a = te.parse(r);
206
- a = ye(r, a);
207
- let s = p.dirname(n);
208
- this.log(`Manifest root = ${s}`), t["version-override"] && (a = ie(a, t["version-override"]));
209
- let c = new o(i(t.registry), new h(this));
210
- await c.publishPackage(a, async (e) => Buffer.from(await m.promises.readFile(p.resolve(s, e)))), t.unstable || (this.log(`Adding package to ${ne} channel...`), await c.addPackageToChannel(a.description.id, ne)), t.refresh && await c.updateIfNeeded();
211
- }
212
- }, xe = class e extends d {
213
- static description = "Refresh overview files based on published but not proecessed artefacts";
214
- static flags = {
215
- registry: f.string({
216
- char: "r",
217
- summary: "full address of the registry",
218
- helpValue: "<address>",
219
- env: "PL_REGISTRY",
220
- required: !0
221
- }),
222
- mode: f.string({
223
- char: "m",
224
- summary: "refresh mode (allowed valiues: \"force\", \"normal\", \"dry-run\")",
225
- helpValue: "<mode>",
226
- options: [
227
- "force",
228
- "normal",
229
- "dry-run"
230
- ],
231
- env: "PL_REGISTRY_REFRESH_DRY_RUN",
232
- default: "normal"
233
- })
234
- };
235
- async run() {
236
- let { flags: t } = await this.parse(e);
237
- await new o(i(t.registry), new h(this)).updateIfNeeded(t.mode);
238
- }
239
- }, Se = class e extends d {
240
- static description = "Restore global overview from a snapshot";
241
- static flags = {
242
- registry: f.string({
243
- char: "r",
244
- summary: "full address of the registry",
245
- helpValue: "<address>",
246
- env: "PL_REGISTRY",
247
- required: !0
248
- }),
249
- snapshot: f.string({
250
- char: "s",
251
- summary: "snapshot timestamp ID to restore from",
252
- helpValue: "<timestamp>",
253
- required: !0
254
- }),
255
- "skip-confirmation": f.boolean({
256
- summary: "skip confirmation prompt (use with caution)",
257
- default: !1
258
- })
259
- };
260
- async run() {
261
- let { flags: t } = await this.parse(e), n = new o(i(t.registry), new h(this)), r = await n.listGlobalOverviewSnapshots();
262
- if (r.find((e) => e.timestamp === t.snapshot) || this.error(`Snapshot '${t.snapshot}' not found. Available snapshots:\n${r.map((e) => ` - ${e.timestamp}`).join("\n") || " (none)"}`), !t["skip-confirmation"]) {
263
- let e = (await import("node:readline")).createInterface({
264
- input: process.stdin,
265
- output: process.stdout
266
- }), n = await new Promise((n) => {
267
- e.question(`⚠️ This will overwrite the current global overview with snapshot '${t.snapshot}'.\nAre you sure you want to continue? (y/N): `, n);
268
- });
269
- if (e.close(), n.toLowerCase() !== "y" && n.toLowerCase() !== "yes") {
270
- this.log("Restore cancelled.");
271
- return;
272
- }
273
- }
274
- try {
275
- await n.restoreGlobalOverviewFromSnapshot(t.snapshot), this.log(`✅ Successfully restored global overview from snapshot '${t.snapshot}'`);
276
- } catch (e) {
277
- this.error(`Failed to restore from snapshot: ${String(e)}`);
278
- }
279
- }
280
- }, Ce = class extends d {
281
- static description = "[DEPRECATED] Use `block-tools structure refresh --update-deps-only`. This alias delegates to it.";
282
- static examples = ["<%= config.bin %> <%= command.id %>"];
283
- async run() {
284
- this.warn("`block-tools update-deps` is deprecated and will be removed in a future release. Use `block-tools structure refresh --update-deps-only` instead. Delegating now."), await this.config.runCommand("structure:refresh", ["--update-deps-only"]);
285
- }
286
- };
58
+ function ve() {
59
+ let n = new f("publish").description("Publishes the block package and refreshes the registry (for v2 block-pack schema)");
60
+ return n.addOption(new p("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), n.addOption(new p("--registry-serve-url <url>", "CDN serve URL written into block-pack/published.json (npm-consumed blocks)").env("PL_REGISTRY_SERVE_URL").makeOptionMandatory()), n.option("-m, --manifest <path>", "manifest file path", `./block-pack/${t}`), n.option("-v, --version-override <path>", "override package version"), n.addOption(new p("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), n.option("--no-refresh", "do not refresh repository after adding the package"), n.addOption(new p("--unstable", "do not add the published package to stable channel").default(!1).env("PL_PUBLISH_UNSTABLE")), n.action(async (t) => {
61
+ let n = new g(), r = m.resolve(t.manifest), a = JSON.parse(await h.promises.readFile(r, { encoding: "utf-8" })), c = te.parse(a);
62
+ c = _e(a, c);
63
+ let l = m.dirname(r);
64
+ n.info(`Manifest root = ${l}`), t.versionOverride && (c = ie(c, t.versionOverride));
65
+ let u = new s(o(t.registry), n);
66
+ await u.publishPackage(c, async (e) => Buffer.from(await h.promises.readFile(m.resolve(l, e)))), t.unstable || (n.info(`Adding package to ${ne} channel...`), await u.addPackageToChannel(c.description.id, ne)), await i(l, e({
67
+ registryUrl: t.registryServeUrl,
68
+ id: c.description.id
69
+ })), n.info(`Wrote published coordinates to ${m.resolve(l, "published.json")}`), t.refresh && await u.updateIfNeeded();
70
+ }), n;
71
+ }
287
72
  //#endregion
288
- //#region src/registry_v1/flags.ts
289
- function we(e) {
290
- let t = e.match(/(?<destName>[^/\\]+)=(?<src>.*)/);
291
- if (t) {
292
- let { src: e, destName: n } = t.groups;
293
- return {
294
- src: e,
295
- destName: n
296
- };
297
- } else return {
298
- src: e,
299
- destName: p.basename(e)
300
- };
73
+ //#region src/cmd/refresh-registry.ts
74
+ function ye() {
75
+ let e = new f("refresh-registry").description("Refresh overview files based on published but not proecessed artefacts");
76
+ return e.addOption(new p("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new p("-m, --mode <mode>", "refresh mode (allowed valiues: \"force\", \"normal\", \"dry-run\")").choices([
77
+ "force",
78
+ "normal",
79
+ "dry-run"
80
+ ]).env("PL_REGISTRY_REFRESH_DRY_RUN").default("normal")), e.action(async (e) => {
81
+ await new s(o(e.registry), new g()).updateIfNeeded(e.mode);
82
+ }), e;
301
83
  }
302
- var Te = f.custom({
303
- summary: "target files to upload",
304
- helpValue: "file_path | package_name=file_path",
305
- parse: async (e) => we(e)
306
- }), Ee = [
307
- "registry",
308
- "organization",
309
- "package",
310
- "version"
311
- ], De = class e extends d {
312
- static description = "Uploads V1 package and refreshes the registry";
313
- static flags = {
314
- registry: f.string({
315
- char: "r",
316
- summary: "full address of the registry or alias from .pl.reg",
317
- helpValue: "<address|alias>",
318
- env: "PL_REGISTRY"
319
- }),
320
- organization: f.string({
321
- char: "o",
322
- summary: "target organisation",
323
- env: "PL_PACKAGE_ORGANIZATION"
324
- }),
325
- package: f.string({
326
- char: "p",
327
- summary: "target package",
328
- env: "PL_PACKAGE_NAME"
329
- }),
330
- version: f.string({
331
- char: "v",
332
- summary: "target version",
333
- env: "PL_PACKAGE_VERSION"
334
- }),
335
- meta: f.file({
336
- char: "m",
337
- summary: "json file containing meta information to associate with tha package",
338
- exists: !0
339
- }),
340
- file: Te({
341
- char: "f",
342
- summary: "package files",
343
- multiple: !0,
344
- default: []
345
- }),
346
- refresh: f.boolean({
347
- summary: "refresh repository after adding the package",
348
- default: !0,
349
- allowNo: !0,
350
- env: "PL_REGISTRY_REFRESH"
351
- })
352
- };
353
- async run() {
354
- let { flags: t } = await this.parse(e), n = l.parse({});
355
- for (let e of Ee) t[e] && (n[e] = t[e]);
356
- t.meta && (t.meta.endsWith(".json") ? n.meta = JSON.parse(await m.promises.readFile(t.meta, { encoding: "utf-8" })) : t.meta.endsWith(".yaml") && (n.meta = ae.parse(await m.promises.readFile(t.meta, { encoding: "utf-8" }))));
357
- for (let e of t.file) n.files[e.destName] = e.src;
358
- let r = await c(n);
359
- this.log(ae.stringify(r.conf));
360
- let i = r.createRegistry(new h(this)), a = r.fullPackageName, o = i.constructNewPackage(a);
361
- for (let [e, t] of Object.entries(r.conf.files)) {
362
- this.log(`Uploading ${t} -> ${e} ...`);
363
- let n = await m.promises.readFile(t);
364
- await o.addFile(e, n);
365
- }
366
- this.log("Uploading meta information..."), await o.writeMeta(r.conf.meta), await o.finish(), t.refresh && await i.updateIfNeeded();
367
- }
368
- }, Oe = class {
84
+ //#endregion
85
+ //#region src/cmd/mark-stable.ts
86
+ function be() {
87
+ let e = new f("mark-stable").description("Mark target block stable");
88
+ return e.option("-i, --modulePath <path>", "input module path", "."), e.addOption(new p("-c, --channel <channel name>", "custom channel").default(ne).hideHelp()), e.option("-v, --version-override <path>", "override package version"), e.addOption(new p("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.addOption(new p("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), e.option("--no-refresh", "do not refresh repository after adding the package"), e.option("--unmark", "reverses meaning of this command, flag can be used to remove \"stable\" flag from the package", !1), e.action(async (e) => {
89
+ let t = await a(m.resolve(e.modulePath));
90
+ e.versionOverride && (t = re(t, e.versionOverride));
91
+ let n = new s(o(e.registry), new g());
92
+ e.unmark ? await n.removePackageFromChannel(t.id, e.channel) : await n.addPackageToChannel(t.id, e.channel), e.refresh && await n.updateIfNeeded();
93
+ }), e;
94
+ }
95
+ //#endregion
96
+ //#region src/structure/engine/fs/node.ts
97
+ var xe = class {
369
98
  constructor(e) {
370
99
  this.root = e;
371
100
  }
372
101
  abs(e) {
373
- return p.resolve(this.root, e);
102
+ return m.resolve(this.root, e);
374
103
  }
375
104
  read(e) {
376
- return m.readFileSync(this.abs(e), "utf-8");
105
+ return h.readFileSync(this.abs(e), "utf-8");
377
106
  }
378
107
  write(e, t) {
379
108
  let n = this.abs(e);
380
- m.mkdirSync(p.dirname(n), { recursive: !0 }), m.writeFileSync(n, t, "utf-8");
109
+ h.mkdirSync(m.dirname(n), { recursive: !0 }), h.writeFileSync(n, t, "utf-8");
381
110
  }
382
111
  writeBinary(e, t) {
383
112
  let n = this.abs(e);
384
- m.mkdirSync(p.dirname(n), { recursive: !0 }), m.writeFileSync(n, t);
113
+ h.mkdirSync(m.dirname(n), { recursive: !0 }), h.writeFileSync(n, t);
385
114
  }
386
115
  exists(e) {
387
116
  try {
388
- return m.statSync(this.abs(e)), !0;
117
+ return h.statSync(this.abs(e)), !0;
389
118
  } catch {
390
119
  return !1;
391
120
  }
@@ -393,15 +122,15 @@ var Te = f.custom({
393
122
  list(e) {
394
123
  let t = this.abs(e);
395
124
  try {
396
- if (!m.statSync(t).isDirectory()) return [];
125
+ if (!h.statSync(t).isDirectory()) return [];
397
126
  } catch {
398
127
  return [];
399
128
  }
400
129
  let n = [];
401
130
  function r(e, t) {
402
- let i = m.readdirSync(t, { withFileTypes: !0 });
131
+ let i = h.readdirSync(t, { withFileTypes: !0 });
403
132
  for (let a of i) {
404
- let i = e ? `${e}/${a.name}` : a.name, o = p.join(t, a.name);
133
+ let i = e ? `${e}/${a.name}` : a.name, o = m.join(t, a.name);
405
134
  a.isDirectory() ? r(i, o) : a.isFile() && n.push(i);
406
135
  }
407
136
  }
@@ -410,7 +139,7 @@ var Te = f.custom({
410
139
  listDir(e) {
411
140
  let t = this.abs(e), n;
412
141
  try {
413
- n = m.readdirSync(t, { withFileTypes: !0 });
142
+ n = h.readdirSync(t, { withFileTypes: !0 });
414
143
  } catch {
415
144
  return [];
416
145
  }
@@ -421,48 +150,48 @@ var Te = f.custom({
421
150
  }
422
151
  move(e, t) {
423
152
  let n = this.abs(e), r = this.abs(t);
424
- m.mkdirSync(p.dirname(r), { recursive: !0 }), m.renameSync(n, r);
153
+ h.mkdirSync(m.dirname(r), { recursive: !0 }), h.renameSync(n, r);
425
154
  }
426
155
  delete(e) {
427
- m.rmSync(this.abs(e), {
156
+ h.rmSync(this.abs(e), {
428
157
  recursive: !0,
429
158
  force: !0
430
159
  });
431
160
  }
432
- }, ke = class {
161
+ }, Se = class {
433
162
  constructor(e) {
434
163
  this.root = e;
435
164
  }
436
165
  staticRead(e) {
437
- return m.readFileSync(p.resolve(this.root, "static", e), "utf-8");
166
+ return h.readFileSync(m.resolve(this.root, "static", e), "utf-8");
438
167
  }
439
168
  staticReadBinary(e) {
440
- return m.readFileSync(p.resolve(this.root, "static", e));
169
+ return h.readFileSync(m.resolve(this.root, "static", e));
441
170
  }
442
171
  textRead(e) {
443
- return m.readFileSync(p.resolve(this.root, "text", e), "utf-8");
172
+ return h.readFileSync(m.resolve(this.root, "text", e), "utf-8");
444
173
  }
445
174
  };
446
- function Ae(e, t) {
175
+ function Ce(e, t) {
447
176
  return e.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (e, n) => t[n] ?? `\${${n}}`);
448
177
  }
449
178
  //#endregion
450
179
  //#region src/structure/engine/flatten.ts
451
- var je = ["default", "init"];
452
- function Me(e, t) {
180
+ var we = ["default", "init"];
181
+ function Te(e, t) {
453
182
  if (!e) return t;
454
183
  if (!t) return e;
455
184
  let n = e.endsWith("/") ? e.slice(0, -1) : e, r = t.startsWith("/") ? t.slice(1) : t;
456
185
  return r ? `${n}/${r}` : n;
457
186
  }
458
- function Ne(e, t) {
187
+ function Ee(e, t) {
459
188
  return e.filter((e) => e.scope === t).slice().sort((e, t) => e.path.localeCompare(t.path));
460
189
  }
461
- function Pe(e, t) {
190
+ function De(e, t) {
462
191
  let n = [];
463
192
  function r(e, i, a, o, s) {
464
193
  if (e.kind === "scope") {
465
- let n = Ne(t.modules, e.scope);
194
+ let n = Ee(t.modules, e.scope);
466
195
  for (let t of n) for (let n of e.children) r(n, e.scope, t.path, o, s);
467
196
  return;
468
197
  }
@@ -475,14 +204,14 @@ function Pe(e, t) {
475
204
  for (let t of e.children) r(t, i, a, o, e.modes);
476
205
  return;
477
206
  }
478
- if (i === void 0 || a === void 0) throw Error(`flatten: leaf '${Ie(e)}' is not inside a scope() frame`);
207
+ if (i === void 0 || a === void 0) throw Error(`flatten: leaf '${ke(e)}' is not inside a scope() frame`);
479
208
  if (e.kind === "rename") {
480
209
  n.push({
481
210
  leaf: e,
482
211
  scope: i,
483
212
  modulePath: a,
484
- resolvedPath: Me(a, e.from),
485
- resolvedTo: Me(a, e.to),
213
+ resolvedPath: Te(a, e.from),
214
+ resolvedTo: Te(a, e.to),
486
215
  triggers: o,
487
216
  modes: s
488
217
  });
@@ -492,15 +221,15 @@ function Pe(e, t) {
492
221
  leaf: e,
493
222
  scope: i,
494
223
  modulePath: a,
495
- resolvedPath: Me(a, Fe(e)),
224
+ resolvedPath: Te(a, Oe(e)),
496
225
  triggers: o,
497
226
  modes: s
498
227
  });
499
228
  }
500
- for (let t of e.children) r(t, void 0, void 0, [], je);
229
+ for (let t of e.children) r(t, void 0, void 0, [], we);
501
230
  return n;
502
231
  }
503
- function Fe(e) {
232
+ function Oe(e) {
504
233
  switch (e.kind) {
505
234
  case "fixed":
506
235
  case "managed":
@@ -510,63 +239,63 @@ function Fe(e) {
510
239
  case "rename": return e.from;
511
240
  }
512
241
  }
513
- function Ie(e) {
242
+ function ke(e) {
514
243
  return e.kind === "rename" ? `rename ${e.from} -> ${e.to}` : `${e.kind} ${e.path}`;
515
244
  }
516
245
  //#endregion
517
246
  //#region src/structure/engine/glob.ts
518
- var Le = /[.+^${}()|[\]\\]/g;
519
- function Re(e) {
247
+ var Ae = /[.+^${}()|[\]\\]/g;
248
+ function je(e) {
520
249
  let t = "";
521
250
  for (let n = 0; n < e.length; n++) {
522
251
  let r = e[n];
523
- r === "*" ? e[n + 1] === "*" ? (n++, e[n + 1] === "/" ? (n++, t += "(?:.*/)?") : t += ".*") : t += "[^/]*" : r === "?" ? t += "[^/]" : t += r.replace(Le, "\\$&");
252
+ r === "*" ? e[n + 1] === "*" ? (n++, e[n + 1] === "/" ? (n++, t += "(?:.*/)?") : t += ".*") : t += "[^/]*" : r === "?" ? t += "[^/]" : t += r.replace(Ae, "\\$&");
524
253
  }
525
254
  return RegExp(`^${t}$`);
526
255
  }
527
- function ze(e, t) {
528
- return Re(e).test(t);
256
+ function Me(e, t) {
257
+ return je(e).test(t);
529
258
  }
530
259
  //#endregion
531
260
  //#region src/structure/engine/builders.ts
532
- var g, _;
533
- function Be(e) {
534
- if (!g) throw Error(`${e}() called outside defineStructure(). Builders must run inside the lambda passed to defineStructure(...).`);
535
- return g;
261
+ var _, v;
262
+ function Ne(e) {
263
+ if (!_) throw Error(`${e}() called outside defineStructure(). Builders must run inside the lambda passed to defineStructure(...).`);
264
+ return _;
536
265
  }
537
- function v(e, t) {
538
- let n = Be(e);
266
+ function y(e, t) {
267
+ let n = Ne(e);
539
268
  n.stack[n.stack.length - 1].push(t);
540
269
  }
541
- function Ve(e, t) {
542
- let n = _;
543
- _ = e;
270
+ function Pe(e, t) {
271
+ let n = v;
272
+ v = e;
544
273
  try {
545
274
  return t();
546
275
  } finally {
547
- _ = n;
276
+ v = n;
548
277
  }
549
278
  }
550
- function He() {
551
- return _;
279
+ function Fe() {
280
+ return v;
552
281
  }
553
- function Ue(e) {
554
- if (g) throw Error("defineStructure() cannot be called from inside another defineStructure().");
282
+ function Ie(e) {
283
+ if (_) throw Error("defineStructure() cannot be called from inside another defineStructure().");
555
284
  let t = [], n = {
556
285
  root: t,
557
286
  stack: [t],
558
287
  inScope: !1
559
288
  };
560
- g = n;
289
+ _ = n;
561
290
  try {
562
291
  if (e(), n.stack.length !== 1) throw Error(`defineStructure: builder body left ${n.stack.length - 1} unclosed group frame(s)`);
563
292
  let r = { children: t };
564
- return We(r), r;
293
+ return Le(r), r;
565
294
  } finally {
566
- g = void 0;
295
+ _ = void 0;
567
296
  }
568
297
  }
569
- function We(e) {
298
+ function Le(e) {
570
299
  let t = /* @__PURE__ */ new Map();
571
300
  function n(e, r) {
572
301
  if (e.kind === "scope") {
@@ -589,8 +318,8 @@ function We(e) {
589
318
  throw Error(`defineStructure validation: path '${t}' under scope '${e}' is declared as both seed and ${n}. Seeds are block-author territory (written once at init, untouched thereafter); engine-managed primitives (fixed/managed/scaffold) rewrite on every refresh. The two contracts cannot coexist on the same path.`);
590
319
  }
591
320
  }
592
- function y(e, t) {
593
- let n = Be("scope");
321
+ function b(e, t) {
322
+ let n = Ne("scope");
594
323
  if (n.inScope) throw Error("scope() cannot nest. Already inside a scope.");
595
324
  let r = {
596
325
  kind: "scope",
@@ -604,22 +333,22 @@ function y(e, t) {
604
333
  n.stack.pop(), n.inScope = !1;
605
334
  }
606
335
  }
607
- var Ge;
608
- function Ke(e) {
609
- Ge = e;
336
+ var Re;
337
+ function ze(e) {
338
+ Re = e;
610
339
  }
611
- function b(e, t, n) {
612
- qe(e, t), n && qe((t) => !e(t), n);
340
+ function x(e, t, n) {
341
+ Be(e, t), n && Be((t) => !e(t), n);
613
342
  }
614
- function qe(e, t) {
615
- if (g) {
616
- Je(e, t);
343
+ function Be(e, t) {
344
+ if (_) {
345
+ Ve(e, t);
617
346
  return;
618
347
  }
619
- if (!(Ge?.(e, t) ?? !1)) throw Error("when() called outside defineStructure() and outside any managed(...) body. Place this call inside one of the two.");
348
+ if (!(Re?.(e, t) ?? !1)) throw Error("when() called outside defineStructure() and outside any managed(...) body. Place this call inside one of the two.");
620
349
  }
621
- function Je(e, t) {
622
- let n = g, r = {
350
+ function Ve(e, t) {
351
+ let n = _, r = {
623
352
  kind: "when",
624
353
  trigger: e,
625
354
  children: []
@@ -631,11 +360,11 @@ function Je(e, t) {
631
360
  n.stack.pop();
632
361
  }
633
362
  }
634
- function x(e) {
363
+ function S(e) {
635
364
  return (t) => t.filesMatch(e);
636
365
  }
637
- function Ye(e, t, n) {
638
- let r = Be(e), i = {
366
+ function He(e, t, n) {
367
+ let r = Ne(e), i = {
639
368
  kind: "mode",
640
369
  modes: t,
641
370
  children: []
@@ -647,70 +376,70 @@ function Ye(e, t, n) {
647
376
  r.stack.pop();
648
377
  }
649
378
  }
650
- function Xe(e) {
651
- Ye("onInitOrUpdate", ["init", "updateDeps"], e);
379
+ function Ue(e) {
380
+ He("onInitOrUpdate", ["init", "updateDeps"], e);
652
381
  }
653
- function S(e, t) {
654
- v("fixed", {
382
+ function C(e, t) {
383
+ y("fixed", {
655
384
  kind: "fixed",
656
385
  path: e,
657
386
  content: t
658
387
  });
659
388
  }
660
- function C(e, t, n) {
661
- v("managed", {
389
+ function w(e, t, n) {
390
+ y("managed", {
662
391
  kind: "managed",
663
392
  path: e,
664
393
  initial: t,
665
394
  body: n
666
395
  });
667
396
  }
668
- function Ze(e, t) {
669
- v("scaffold", {
397
+ function T(e, t) {
398
+ y("scaffold", {
670
399
  kind: "scaffold",
671
400
  path: e,
672
401
  initial: t
673
402
  });
674
403
  }
675
- function w(e, t) {
676
- v("seed", {
404
+ function E(e, t) {
405
+ y("seed", {
677
406
  kind: "seed",
678
407
  path: e,
679
408
  initial: t
680
409
  });
681
410
  }
682
- function T(e) {
683
- v("remove", {
411
+ function D(e) {
412
+ y("remove", {
684
413
  kind: "remove",
685
414
  path: e
686
415
  });
687
416
  }
688
- function E(e) {
417
+ function O(e) {
689
418
  return {
690
419
  kind: "file",
691
420
  path: e
692
421
  };
693
422
  }
694
- function Qe(e) {
423
+ function We(e) {
695
424
  return {
696
425
  kind: "binary",
697
426
  path: e
698
427
  };
699
428
  }
700
- function $e(e) {
429
+ function Ge(e) {
701
430
  return {
702
431
  kind: "text",
703
432
  value: e
704
433
  };
705
434
  }
706
- function D(e, t) {
435
+ function k(e, t) {
707
436
  return {
708
437
  kind: "tpl",
709
438
  path: e,
710
439
  vars: t
711
440
  };
712
441
  }
713
- function O(e) {
442
+ function A(e) {
714
443
  return {
715
444
  kind: "generate",
716
445
  fn: e
@@ -718,69 +447,69 @@ function O(e) {
718
447
  }
719
448
  //#endregion
720
449
  //#region src/structure/engine/parsers/json.ts
721
- function et(e) {
450
+ function Ke(e) {
722
451
  return JSON.parse(e);
723
452
  }
724
- var tt = 100, nt = 2;
725
- function rt(e) {
726
- return e.length === 0 ? "[]" : "[" + e.map(it).join(", ") + "]";
453
+ var qe = 100, Je = 2;
454
+ function Ye(e) {
455
+ return e.length === 0 ? "[]" : "[" + e.map(Xe).join(", ") + "]";
727
456
  }
728
- function it(e) {
729
- if (Array.isArray(e)) return rt(e);
730
- if (A(e)) {
457
+ function Xe(e) {
458
+ if (Array.isArray(e)) return Ye(e);
459
+ if (M(e)) {
731
460
  let t = Object.entries(e);
732
- return t.length === 0 ? "{}" : "{ " + t.map(([e, t]) => `${JSON.stringify(e)}: ${it(t)}`).join(", ") + " }";
461
+ return t.length === 0 ? "{}" : "{ " + t.map(([e, t]) => `${JSON.stringify(e)}: ${Xe(t)}`).join(", ") + " }";
733
462
  }
734
463
  return JSON.stringify(e);
735
464
  }
736
- function at(e, t, n, r) {
737
- let i = t + nt, a = " ".repeat(i);
465
+ function Ze(e, t, n, r) {
466
+ let i = t + Je, a = " ".repeat(i);
738
467
  if (Array.isArray(e)) {
739
- let o = rt(e);
740
- if (n + o.length + r <= tt) return o;
468
+ let o = Ye(e);
469
+ if (n + o.length + r <= qe) return o;
741
470
  let s = e.length - 1;
742
- return "[\n" + e.map((e, t) => a + at(e, i, i, t === s ? 0 : 1)).join(",\n") + "\n" + " ".repeat(t) + "]";
471
+ return "[\n" + e.map((e, t) => a + Ze(e, i, i, t === s ? 0 : 1)).join(",\n") + "\n" + " ".repeat(t) + "]";
743
472
  }
744
- if (A(e)) {
473
+ if (M(e)) {
745
474
  let n = Object.entries(e);
746
475
  if (n.length === 0) return "{}";
747
476
  let r = n.length - 1;
748
477
  return "{\n" + n.map(([e, t], n) => {
749
478
  let o = `${a}${JSON.stringify(e)}: `;
750
- return o + at(t, i, o.length, n === r ? 0 : 1);
479
+ return o + Ze(t, i, o.length, n === r ? 0 : 1);
751
480
  }).join(",\n") + "\n" + " ".repeat(t) + "}";
752
481
  }
753
482
  return JSON.stringify(e);
754
483
  }
755
- function ot(e, t) {
756
- return t?.collapse ? at(JSON.parse(JSON.stringify(e ?? null)), 0, 0, 0) + "\n" : JSON.stringify(e, null, 2) + "\n";
484
+ function Qe(e, t) {
485
+ return t?.collapse ? Ze(JSON.parse(JSON.stringify(e ?? null)), 0, 0, 0) + "\n" : JSON.stringify(e, null, 2) + "\n";
757
486
  }
758
- function k(e) {
487
+ function j(e) {
759
488
  return e === "" || e === void 0 ? [] : e.split(".");
760
489
  }
761
- function A(e) {
490
+ function M(e) {
762
491
  return typeof e == "object" && !!e && !Array.isArray(e);
763
492
  }
764
- function st(e, t) {
765
- let n = k(t), r = e;
493
+ function $e(e, t) {
494
+ let n = j(t), r = e;
766
495
  for (let e of n) {
767
- if (!A(r)) return;
496
+ if (!M(r)) return;
768
497
  r = r[e];
769
498
  }
770
499
  return r;
771
500
  }
772
- function ct(e, t) {
773
- let n = k(t);
501
+ function et(e, t) {
502
+ let n = j(t);
774
503
  if (n.length === 0) return !0;
775
504
  let r = e;
776
505
  for (let e = 0; e < n.length - 1; e++) {
777
- if (!A(r)) return !1;
506
+ if (!M(r)) return !1;
778
507
  r = r[n[e]];
779
508
  }
780
- return A(r) ? n[n.length - 1] in r : !1;
509
+ return M(r) ? n[n.length - 1] in r : !1;
781
510
  }
782
- function lt(e, t, n) {
783
- let r = k(t);
511
+ function tt(e, t, n) {
512
+ let r = j(t);
784
513
  if (r.length === 0) throw Error("setAtPath: jsonPath must be non-empty");
785
514
  let i = e;
786
515
  for (let e = 0; e < r.length - 1; e++) {
@@ -788,22 +517,22 @@ function lt(e, t, n) {
788
517
  if (n === void 0) {
789
518
  let e = {};
790
519
  i[t] = e, i = e;
791
- } else if (A(n)) i = n;
520
+ } else if (M(n)) i = n;
792
521
  else throw Error(`setAtPath: cannot descend into non-object at '${r.slice(0, e + 1).join(".")}'`);
793
522
  }
794
523
  i[r[r.length - 1]] = n;
795
524
  }
796
- function ut(e, t) {
797
- let n = k(t);
525
+ function nt(e, t) {
526
+ let n = j(t);
798
527
  if (n.length === 0) throw Error("deleteAtPath: jsonPath must be non-empty");
799
528
  let r = e;
800
529
  for (let e = 0; e < n.length - 1; e++) {
801
- if (!A(r)) return;
530
+ if (!M(r)) return;
802
531
  r = r[n[e]];
803
532
  }
804
- A(r) && delete r[n[n.length - 1]];
533
+ M(r) && delete r[n[n.length - 1]];
805
534
  }
806
- function dt(e, t) {
535
+ function rt(e, t) {
807
536
  let n = new Set(t), r = Object.keys(e), i = /* @__PURE__ */ new Map();
808
537
  i.set("", []);
809
538
  let a = "";
@@ -818,72 +547,72 @@ function dt(e, t) {
818
547
  }
819
548
  //#endregion
820
549
  //#region src/structure/engine/parsers/lines.ts
821
- function ft(e) {
550
+ function it(e) {
822
551
  let t = e.split("\n");
823
552
  return t.length > 0 && t[t.length - 1] === "" && t.pop(), t;
824
553
  }
825
- function pt(e) {
554
+ function at(e) {
826
555
  return e.join("\n") + "\n";
827
556
  }
828
- function mt(e) {
557
+ function ot(e) {
829
558
  return e.replace(/(^|\s)#.*$/, "$1").trim();
830
559
  }
831
- function ht(e, t) {
832
- let n = mt(e);
560
+ function st(e, t) {
561
+ let n = ot(e);
833
562
  return n === "" ? !1 : n === t.trim();
834
563
  }
835
- function gt(e, t) {
836
- for (let n of e) if (ht(n, t)) return !0;
564
+ function ct(e, t) {
565
+ for (let n of e) if (st(n, t)) return !0;
837
566
  return !1;
838
567
  }
839
568
  //#endregion
840
569
  //#region src/structure/engine/content-rules.ts
841
- function _t(e, t) {
570
+ function lt(e, t) {
842
571
  return e === "sdk:" ? t ? "workspace:*" : "catalog:" : e;
843
572
  }
844
- var vt = [
573
+ var ut = [
845
574
  "dependencies",
846
575
  "devDependencies",
847
576
  "peerDependencies",
848
577
  "optionalDependencies"
849
578
  ];
850
- function yt(e, t) {
851
- if (P(e)) for (let n of vt) {
579
+ function dt(e, t) {
580
+ if (I(e)) for (let n of ut) {
852
581
  let r = e[n];
853
- if (P(r)) for (let e of Object.keys(r)) r[e] === "sdk:" && (r[e] = t ? "workspace:*" : "catalog:");
582
+ if (I(r)) for (let e of Object.keys(r)) r[e] === "sdk:" && (r[e] = t ? "workspace:*" : "catalog:");
854
583
  }
855
584
  }
856
- var j;
857
- function bt(e) {
858
- if (!j) throw Error(`${e}() only valid inside a managed(...) body. Move this call inside managed(path, initial, () => {...}).`);
859
- return j;
585
+ var N;
586
+ function ft(e) {
587
+ if (!N) throw Error(`${e}() only valid inside a managed(...) body. Move this call inside managed(path, initial, () => {...}).`);
588
+ return N;
860
589
  }
861
- function M(e) {
862
- let t = bt(e);
590
+ function P(e) {
591
+ let t = ft(e);
863
592
  if (t.kind !== "json") throw Error(`${e}() requires a JSON-managed body; got '${t.kind}'.`);
864
593
  return t;
865
594
  }
866
- function N(e) {
867
- let t = bt(e);
595
+ function F(e) {
596
+ let t = ft(e);
868
597
  if (t.kind !== "yaml") throw Error(`${e}() requires a YAML-managed body; got '${t.kind}'.`);
869
598
  return t;
870
599
  }
871
- function xt(e) {
872
- let t = bt(e);
600
+ function pt(e) {
601
+ let t = ft(e);
873
602
  if (t.kind !== "lines") throw Error(`${e}() requires a lines-managed body; got '${t.kind}'.`);
874
603
  return t;
875
604
  }
876
- function St(e, t) {
877
- let n = e.ctx ?? He();
605
+ function mt(e, t) {
606
+ let n = e.ctx ?? Fe();
878
607
  if (!n) throw Error(`${t}() needs a RunContext but none is active. Pass { ctx } via the with-managed-* helper or run inside engine.run(...).`);
879
608
  return n;
880
609
  }
881
- function P(e) {
610
+ function I(e) {
882
611
  return typeof e == "object" && !!e && !Array.isArray(e);
883
612
  }
884
- function Ct(e, t, n = {}) {
885
- if (j) throw Error("Nested managed(...) body — engine bug.");
886
- j = {
613
+ function ht(e, t, n = {}) {
614
+ if (N) throw Error("Nested managed(...) body — engine bug.");
615
+ N = {
887
616
  kind: "json",
888
617
  obj: e,
889
618
  ctx: n.ctx,
@@ -892,12 +621,12 @@ function Ct(e, t, n = {}) {
892
621
  try {
893
622
  return t(n.ctx ?? n.triggerContext?.ctx), e;
894
623
  } finally {
895
- j = void 0;
624
+ N = void 0;
896
625
  }
897
626
  }
898
- function wt(e, t, n = {}) {
899
- if (j) throw Error("Nested managed(...) body — engine bug.");
900
- j = {
627
+ function gt(e, t, n = {}) {
628
+ if (N) throw Error("Nested managed(...) body — engine bug.");
629
+ N = {
901
630
  kind: "yaml",
902
631
  doc: e,
903
632
  ctx: n.ctx,
@@ -908,12 +637,12 @@ function wt(e, t, n = {}) {
908
637
  try {
909
638
  return t(n.ctx ?? n.triggerContext?.ctx), e;
910
639
  } finally {
911
- j = void 0;
640
+ N = void 0;
912
641
  }
913
642
  }
914
- function Tt(e, t, n = {}) {
915
- if (j) throw Error("Nested managed(...) body — engine bug.");
916
- j = {
643
+ function _t(e, t, n = {}) {
644
+ if (N) throw Error("Nested managed(...) body — engine bug.");
645
+ N = {
917
646
  kind: "lines",
918
647
  lines: e,
919
648
  ctx: n.ctx,
@@ -922,163 +651,170 @@ function Tt(e, t, n = {}) {
922
651
  try {
923
652
  return t(n.ctx ?? n.triggerContext?.ctx), e;
924
653
  } finally {
925
- j = void 0;
654
+ N = void 0;
926
655
  }
927
656
  }
928
- Ke((e, t) => {
929
- if (!j) return !1;
930
- let n = j.triggerContext;
657
+ ze((e, t) => {
658
+ if (!N) return !1;
659
+ let n = N.triggerContext;
931
660
  if (!n) throw Error("when() inside a managed(...) body requires a triggerContext. The runner supplies it via the `triggerContext` opt to with-managed-*; ensure your test/test helper passes one.");
932
661
  return e(n) && t(), !0;
933
662
  });
934
- function F(e, t) {
935
- lt(M("ensureField").obj, e, t);
663
+ function L(e, t) {
664
+ tt(P("ensureField").obj, e, t);
936
665
  }
937
- function Et(e, t) {
938
- let n = M("removeField").obj;
939
- ct(n, e) && (t && !t(st(n, e)) || ut(n, e));
666
+ function vt(e, t) {
667
+ let n = P("removeField").obj;
668
+ et(n, e) && (t && !t($e(n, e)) || nt(n, e));
940
669
  }
941
- function I(e, t) {
942
- F(`scripts.${e}`, t);
670
+ function yt(e, t) {
671
+ let n = P("requireField").obj;
672
+ if (!et(n, e)) throw Error(t ?? `requireField: missing field '${e}'`);
943
673
  }
944
- function L(e) {
945
- Et(`scripts.${e}`);
674
+ function R(e, t) {
675
+ L(`scripts.${e}`, t);
946
676
  }
947
- var Dt = [
677
+ function z(e) {
678
+ vt(`scripts.${e}`);
679
+ }
680
+ var bt = [
948
681
  "dependencies",
949
682
  "devDependencies",
950
683
  "peerDependencies",
951
684
  "optionalDependencies"
952
685
  ];
953
- function R(e, t, n, r) {
954
- let i = M(e), a = i.obj, o = n === "sdk:" ? _t(n, St(i, e).isSdkInternal) : n;
955
- for (let e of Dt) {
686
+ function B(e, t, n, r) {
687
+ let i = P(e), a = i.obj, o = n === "sdk:" ? lt(n, mt(i, e).isSdkInternal) : n;
688
+ for (let e of bt) {
956
689
  if (e === r) continue;
957
690
  let n = a[e];
958
- P(n) && t in n && delete n[t];
691
+ I(n) && t in n && delete n[t];
959
692
  }
960
- let s = a[r], c = P(s) ? s : {};
961
- c[t] = o, P(s) || (a[r] = c);
693
+ let s = a[r], c = I(s) ? s : {};
694
+ c[t] = o, I(s) || (a[r] = c);
962
695
  }
963
- function z(e, t) {
964
- R("ensureDep", e, t, "dependencies");
696
+ function V(e, t) {
697
+ B("ensureDep", e, t, "dependencies");
965
698
  }
966
- function B(e, t) {
967
- R("ensureDevDep", e, t, "devDependencies");
699
+ function H(e, t) {
700
+ B("ensureDevDep", e, t, "devDependencies");
968
701
  }
969
- function Ot(e, t) {
970
- R("ensurePeerDep", e, t, "peerDependencies");
702
+ function xt(e, t) {
703
+ B("ensurePeerDep", e, t, "peerDependencies");
971
704
  }
972
- function V(e) {
973
- let t = M("removeDep").obj;
974
- for (let n of Dt) {
705
+ function U(e) {
706
+ let t = P("removeDep").obj;
707
+ for (let n of bt) {
975
708
  let r = t[n];
976
- P(r) && e in r && delete r[e];
709
+ I(r) && e in r && delete r[e];
977
710
  }
978
711
  }
979
- function H(e) {
980
- for (let [t, n] of Object.entries(e)) B(t, n);
712
+ function W(e) {
713
+ for (let [t, n] of Object.entries(e)) H(t, n);
981
714
  }
982
- function U(e) {
983
- for (let [t, n] of Object.entries(e)) Ot(t, n);
715
+ function G(e) {
716
+ for (let [t, n] of Object.entries(e)) xt(t, n);
984
717
  }
985
- function kt(e, t, n) {
986
- let r = St(M(e), e);
987
- for (let i of r.modules) i.scope === t && R(e, i.name, "workspace:*", n);
718
+ function St(e, t, n) {
719
+ let r = mt(P(e), e);
720
+ for (let i of r.modules) i.scope === t && B(e, i.name, "workspace:*", n);
988
721
  }
989
- function W(e) {
990
- kt("ensureWorkspaceScopeDeps", e, "dependencies");
722
+ function Ct(e) {
723
+ St("ensureWorkspaceScopeDeps", e, "dependencies");
991
724
  }
992
- function At(e) {
993
- let t = M("pruneKeysMatching").obj;
725
+ function wt(e) {
726
+ St("ensureWorkspaceScopeDevDeps", e, "devDependencies");
727
+ }
728
+ function Tt(e) {
729
+ let t = P("pruneKeysMatching").obj;
994
730
  for (let n of Object.keys(t)) e(n, t[n]) && delete t[n];
995
731
  }
996
- function jt(e, t) {
997
- let n = dt(e, t);
732
+ function Et(e, t) {
733
+ let n = rt(e, t);
998
734
  for (let t of Object.keys(e)) delete e[t];
999
735
  for (let t of Object.keys(n)) e[t] = n[t];
1000
736
  }
1001
- function G(e) {
1002
- jt(M("enforceFieldOrder").obj, e);
737
+ function K(e) {
738
+ Et(P("enforceFieldOrder").obj, e);
1003
739
  }
1004
- function Mt(e, t) {
740
+ function Dt(e, t) {
1005
741
  let n = Object.keys(e).sort(), r = {};
1006
742
  for (let t of n) r[t] = e[t];
1007
743
  for (let t of Object.keys(e)) delete e[t];
1008
- for (let i of n) e[i] = r[i], t && P(e[i]) && Mt(e[i], !0);
744
+ for (let i of n) e[i] = r[i], t && I(e[i]) && Dt(e[i], !0);
1009
745
  }
1010
- function K(e = "", t = {}) {
746
+ function q(e = "", t = {}) {
1011
747
  let n = t.recursive ?? !1;
1012
748
  if (e === "" && !n) return;
1013
- let r = M("enforceAlphabeticalOrder").obj;
749
+ let r = P("enforceAlphabeticalOrder").obj;
1014
750
  if (e === "") {
1015
- Mt(r, !0);
751
+ Dt(r, !0);
1016
752
  return;
1017
753
  }
1018
- let i = st(r, e);
1019
- P(i) && Mt(i, n);
754
+ let i = $e(r, e);
755
+ I(i) && Dt(i, n);
1020
756
  }
1021
- function Nt() {
1022
- let e = N("ensureWorkspaceModulePaths"), t = St(e, "ensureWorkspaceModulePaths").modules.filter((e) => e.path !== "").map((e) => e.path).sort(), n = e.doc.toJSON()?.packages;
757
+ function Ot() {
758
+ let e = F("ensureWorkspaceModulePaths"), t = mt(e, "ensureWorkspaceModulePaths").modules.filter((e) => e.path !== "").map((e) => e.path).sort(), n = e.doc.toJSON()?.packages;
1023
759
  Array.isArray(n) && n.length === t.length && n.every((e, n) => e === t[n]) || e.doc.setIn(["packages"], t);
1024
760
  }
1025
- function Pt(e, t) {
761
+ function kt(e, t) {
1026
762
  let n = e.doc.getIn(["catalog", t]);
1027
763
  return typeof n == "string" ? n : void 0;
1028
764
  }
1029
- function Ft(e, t) {
1030
- let n = N("ensureCatalogVersion");
1031
- Pt(n, e) === void 0 && n.doc.setIn(["catalog", e], t);
765
+ function At(e, t) {
766
+ let n = F("ensureCatalogVersion");
767
+ kt(n, e) === void 0 && n.doc.setIn(["catalog", e], t);
1032
768
  }
1033
- function It(e) {
1034
- let t = N("ensureCatalogLatest");
769
+ function jt(e) {
770
+ let t = F("ensureCatalogLatest");
1035
771
  if (!t.getLatestVersion) return;
1036
772
  let n = t.getLatestVersion(e);
1037
- n !== void 0 && Pt(t, e) !== n && t.doc.setIn(["catalog", e], n);
773
+ n !== void 0 && kt(t, e) !== n && t.doc.setIn(["catalog", e], n);
1038
774
  }
1039
- function Lt(e, t) {
1040
- let n = N("pinCatalogToDependencyOf");
775
+ function Mt(e, t) {
776
+ let n = F("pinCatalogToDependencyOf");
1041
777
  if (!n.getDerivedDependencyPin) return;
1042
778
  let r = n.getDerivedDependencyPin(e);
1043
- r !== void 0 && Pt(n, e) !== r && n.doc.setIn(["catalog", e], r);
779
+ r !== void 0 && kt(n, e) !== r && n.doc.setIn(["catalog", e], r);
1044
780
  }
1045
- function Rt(e) {
1046
- let t = N("ensureCatalogAbsent");
781
+ function Nt(e) {
782
+ let t = F("ensureCatalogAbsent");
1047
783
  t.doc.hasIn(["catalog", e]) && t.doc.deleteIn(["catalog", e]);
1048
784
  }
1049
- function zt(e) {
1050
- let t = xt("ensureGitignoreEntries");
1051
- for (let n of e) gt(t.lines, n) || t.lines.push(n);
785
+ function Pt(e) {
786
+ let t = pt("ensureGitignoreEntries");
787
+ for (let n of e) ct(t.lines, n) || t.lines.push(n);
1052
788
  }
1053
789
  //#endregion
1054
790
  //#region src/structure/engine/parsers/yaml.ts
1055
- function Bt(e) {
791
+ function Ft(e) {
1056
792
  return se(e);
1057
793
  }
1058
- function Vt(e) {
794
+ function It(e) {
1059
795
  return e.toString();
1060
796
  }
1061
- var Ht = ".structure";
1062
- function Ut(e, t = 0) {
1063
- if (e < t) throw new Wt(e, t);
797
+ var Lt = ".structure";
798
+ function Rt(e, t = 0) {
799
+ if (e < t) throw new zt(e, t);
1064
800
  }
1065
- var Wt = class extends Error {
801
+ var zt = class extends Error {
1066
802
  constructor(e, t) {
1067
803
  super(`Block .structure version is ${e}, below floor ${t}. Bootstrap via the legacy-migration skill, then re-run.`), this.version = e, this.floor = t, this.name = "StructureVersionFloorError";
1068
804
  }
1069
805
  };
1070
- function Gt(e, t = 1) {
806
+ function Bt(e, t = 1) {
1071
807
  let n = { version: t };
1072
- e.write(Ht, JSON.stringify(n));
808
+ e.write(Lt, JSON.stringify(n));
1073
809
  }
1074
810
  //#endregion
1075
811
  //#region src/structure/engine/runner.ts
1076
- var Kt = class extends Error {
812
+ var Vt = class extends Error {
1077
813
  constructor(e) {
1078
814
  super(`Post-run recheck: rule set not idempotent. Failing item: ${e.primitive} '${e.path}' (scope=${e.scope}, action=${e.action}). Engine bug.`), this.failing = e, this.name = "RecheckError";
1079
815
  }
1080
816
  };
1081
- function qt(e, t, n, r) {
817
+ function Ht(e, t, n, r) {
1082
818
  switch (e.kind) {
1083
819
  case "text": return e.value;
1084
820
  case "file":
@@ -1086,10 +822,10 @@ function qt(e, t, n, r) {
1086
822
  return n.staticRead(e.path);
1087
823
  case "tpl":
1088
824
  if (!n) throw Error(`tpl('${e.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);
1089
- return Ae(n.textRead(e.path), typeof e.vars == "function" ? e.vars(r) : e.vars);
825
+ return Ce(n.textRead(e.path), typeof e.vars == "function" ? e.vars(r) : e.vars);
1090
826
  case "generate": {
1091
827
  let n = e.fn(r);
1092
- if (t.endsWith(".json")) return yt(n, r.isSdkInternal), ot(n, { collapse: !t.endsWith("package.json") });
828
+ if (t.endsWith(".json")) return dt(n, r.isSdkInternal), Qe(n, { collapse: !t.endsWith("package.json") });
1093
829
  if (t.endsWith(".yaml") || t.endsWith(".yml")) return ce(n);
1094
830
  if (typeof n != "string") throw Error(`generate() for '${t}' must return a string for non-JSON/YAML files; got ${typeof n}`);
1095
831
  return n;
@@ -1097,36 +833,36 @@ function qt(e, t, n, r) {
1097
833
  case "binary": throw Error(`binary('${e.path}') cannot be resolved to a string; it is only valid inside seed()/scaffold(), which copy it verbatim via fs.writeBinary.`);
1098
834
  }
1099
835
  }
1100
- function Jt(e, t, n, r, i) {
836
+ function Ut(e, t, n, r, i) {
1101
837
  if (n.kind === "binary") {
1102
838
  if (!r) throw Error(`binary('${n.path}'): no TemplateProvider configured. Pass opts.templates to engine.run(...).`);
1103
839
  e.writeBinary(t, r.staticReadBinary(n.path));
1104
840
  return;
1105
841
  }
1106
- e.write(t, qt(n, t, r, i));
842
+ e.write(t, Ht(n, t, r, i));
1107
843
  }
1108
- function Yt(e, t, n, r, i, a) {
844
+ function Wt(e, t, n, r, i, a) {
1109
845
  let o = e.split("/").pop() ?? e;
1110
846
  if (e.endsWith(".json")) {
1111
- let i = et(t);
847
+ let i = Ke(t);
1112
848
  if (typeof i != "object" || !i || Array.isArray(i)) throw Error(`managed: parsed value at '${e}' is not a JSON object`);
1113
- return Ct(i, n, { triggerContext: r }), ot(i, { collapse: o !== "package.json" });
849
+ return ht(i, n, { triggerContext: r }), Qe(i, { collapse: o !== "package.json" });
1114
850
  }
1115
851
  if (e.endsWith(".yaml") || e.endsWith(".yml")) {
1116
- let e = Bt(t);
1117
- return wt(e, n, {
852
+ let e = Ft(t);
853
+ return gt(e, n, {
1118
854
  triggerContext: r,
1119
855
  getLatestVersion: i,
1120
856
  getDerivedDependencyPin: a
1121
- }), Vt(e);
857
+ }), It(e);
1122
858
  }
1123
859
  if (o === ".gitignore" || o.endsWith(".gitignore")) {
1124
- let e = ft(t);
1125
- return Tt(e, n, { triggerContext: r }), pt(e);
860
+ let e = it(t);
861
+ return _t(e, n, { triggerContext: r }), at(e);
1126
862
  }
1127
863
  throw Error(`managed('${e}'): unsupported file kind. Only .json, .yaml, .yml, .gitignore are dispatched.`);
1128
864
  }
1129
- function Xt(e) {
865
+ function Gt(e) {
1130
866
  let t = e.list(""), n = /* @__PURE__ */ new Set();
1131
867
  for (let e of t) {
1132
868
  n.add(e);
@@ -1135,37 +871,37 @@ function Xt(e) {
1135
871
  }
1136
872
  return n;
1137
873
  }
1138
- function Zt(e, t) {
874
+ function Kt(e, t) {
1139
875
  let n = t === "" ? t : t.endsWith("/") ? t.slice(0, -1) : t;
1140
876
  return e.has(n);
1141
877
  }
1142
- function Qt(e, t, n) {
878
+ function qt(e, t, n) {
1143
879
  return {
1144
880
  ctx: t,
1145
881
  version: t.version,
1146
- pathExists: (t) => Zt(e, t),
1147
- pathMissing: (t) => !Zt(e, t),
882
+ pathExists: (t) => Kt(e, t),
883
+ pathMissing: (t) => !Kt(e, t),
1148
884
  filesMatch: (t) => {
1149
885
  let r = n ? `${n}/${t}` : t;
1150
- for (let t of e) if (ze(r, t)) return !0;
886
+ for (let t of e) if (Me(r, t)) return !0;
1151
887
  return !1;
1152
888
  }
1153
889
  };
1154
890
  }
1155
- function $t(e, t) {
891
+ function Jt(e, t) {
1156
892
  for (let n of e.triggers) if (!n(t)) return !1;
1157
893
  return !0;
1158
894
  }
1159
- function en(e, t) {
895
+ function Yt(e, t) {
1160
896
  return t ? "init" : e.updateDepsOnly ? "updateDeps" : "default";
1161
897
  }
1162
- function tn(e, t) {
898
+ function Xt(e, t) {
1163
899
  return e.filter((e) => e.modes.includes(t));
1164
900
  }
1165
- function nn(e, t, n, r, i, a) {
901
+ function Zt(e, t, n, r, i, a) {
1166
902
  let o = e.leaf;
1167
903
  if (o.kind === "fixed") {
1168
- let i = qt(o.content, e.resolvedPath, r, a);
904
+ let i = Ht(o.content, e.resolvedPath, r, a);
1169
905
  return t.exists(e.resolvedPath) ? t.read(e.resolvedPath) === i ? void 0 : (n || t.write(e.resolvedPath, i), {
1170
906
  scope: e.scope,
1171
907
  path: e.resolvedPath,
@@ -1178,13 +914,13 @@ function nn(e, t, n, r, i, a) {
1178
914
  action: "create"
1179
915
  });
1180
916
  }
1181
- if (o.kind === "scaffold") return t.exists(e.resolvedPath) ? void 0 : (n || Jt(t, e.resolvedPath, o.initial, r, a), {
917
+ if (o.kind === "scaffold") return t.exists(e.resolvedPath) ? void 0 : (n || Ut(t, e.resolvedPath, o.initial, r, a), {
1182
918
  scope: e.scope,
1183
919
  path: e.resolvedPath,
1184
920
  primitive: "scaffold",
1185
921
  action: "create"
1186
922
  });
1187
- if (o.kind === "seed") return !i || t.exists(e.resolvedPath) ? void 0 : (n || Jt(t, e.resolvedPath, o.initial, r, a), {
923
+ if (o.kind === "seed") return !i || t.exists(e.resolvedPath) ? void 0 : (n || Ut(t, e.resolvedPath, o.initial, r, a), {
1188
924
  scope: e.scope,
1189
925
  path: e.resolvedPath,
1190
926
  primitive: "seed",
@@ -1207,58 +943,58 @@ function nn(e, t, n, r, i, a) {
1207
943
  });
1208
944
  }
1209
945
  }
1210
- function rn(e, t, n, r, i, a, o, s) {
946
+ function Qt(e, t, n, r, i, a, o, s) {
1211
947
  if (e.leaf.kind !== "managed") return;
1212
- let c = e.leaf, l = e.resolvedPath, ee = t.exists(l), u, d = !1;
1213
- ee ? u = t.read(l) : (u = qt(c.initial, l, i, s), d = !0);
1214
- let f = Yt(l, u, c.body, r, a, o);
1215
- if (d) return n || t.write(l, f), {
948
+ let c = e.leaf, l = e.resolvedPath, u = t.exists(l), d, ee = !1;
949
+ u ? d = t.read(l) : (d = Ht(c.initial, l, i, s), ee = !0);
950
+ let f = Wt(l, d, c.body, r, a, o);
951
+ if (ee) return n || t.write(l, f), {
1216
952
  scope: e.scope,
1217
953
  path: l,
1218
954
  primitive: "managed",
1219
955
  action: "create"
1220
956
  };
1221
- if (f !== u) return n || t.write(l, f), {
957
+ if (f !== d) return n || t.write(l, f), {
1222
958
  scope: e.scope,
1223
959
  path: l,
1224
960
  primitive: "managed",
1225
961
  action: "update"
1226
962
  };
1227
963
  }
1228
- function an(e, t, n, r, i, a, o, s) {
1229
- let c = tn(e, en(n, a)), l = [], ee = Xt(t);
964
+ function $t(e, t, n, r, i, a, o, s) {
965
+ let c = Xt(e, Yt(n, a)), l = [], u = Gt(t);
1230
966
  for (let e of c) {
1231
- if (e.leaf.kind === "managed" || !$t(e, Qt(ee, n, e.modulePath))) continue;
1232
- let o = nn(e, t, r, i, a, n);
967
+ if (e.leaf.kind === "managed" || !Jt(e, qt(u, n, e.modulePath))) continue;
968
+ let o = Zt(e, t, r, i, a, n);
1233
969
  o && l.push(o);
1234
970
  }
1235
- let u = Xt(t);
971
+ let d = Gt(t);
1236
972
  for (let e of c) {
1237
973
  if (e.leaf.kind !== "managed") continue;
1238
- let a = Qt(u, n, e.modulePath);
1239
- if (!$t(e, a)) continue;
1240
- let c = rn(e, t, r, a, i, o, s, n);
974
+ let a = qt(d, n, e.modulePath);
975
+ if (!Jt(e, a)) continue;
976
+ let c = Qt(e, t, r, a, i, o, s, n);
1241
977
  c && l.push(c);
1242
978
  }
1243
979
  return l;
1244
980
  }
1245
- function on(e, t, n, r = {}) {
1246
- return Ve(n, () => {
1247
- let i = Pe(e, n), a = !!r.initMode, o = an(i, t, n, n.dryRun, r.templates, a, r.registryLookup, r.derivedPinLookup);
981
+ function en(e, t, n, r = {}) {
982
+ return Pe(n, () => {
983
+ let i = De(e, n), a = !!r.initMode, o = $t(i, t, n, n.dryRun, r.templates, a, r.registryLookup, r.derivedPinLookup);
1248
984
  if (!n.dryRun && !n.updateDepsOnly && !a) {
1249
- Gt(t);
985
+ Bt(t);
1250
986
  let i = {
1251
987
  ...r.rediscover ? r.rediscover(t) : n,
1252
988
  dryRun: !0
1253
- }, a = an(Pe(e, i), t, i, !0, r.templates, !1, r.registryLookup, r.derivedPinLookup).filter((e) => e.path !== Ht);
1254
- if (a.length > 0) throw new Kt(a[0]);
989
+ }, a = $t(De(e, i), t, i, !0, r.templates, !1, r.registryLookup, r.derivedPinLookup).filter((e) => e.path !== Lt);
990
+ if (a.length > 0) throw new Vt(a[0]);
1255
991
  }
1256
- return a && !n.dryRun && Gt(t), { changes: o };
992
+ return a && !n.dryRun && Bt(t), { changes: o };
1257
993
  });
1258
994
  }
1259
995
  //#endregion
1260
996
  //#region src/structure/engine/discovery.ts
1261
- var sn = [
997
+ var tn = [
1262
998
  "root",
1263
999
  "block",
1264
1000
  "model",
@@ -1266,12 +1002,12 @@ var sn = [
1266
1002
  "workflow",
1267
1003
  "test",
1268
1004
  "software"
1269
- ], cn = class extends Error {
1005
+ ], nn = class extends Error {
1270
1006
  constructor(e, t) {
1271
1007
  super(e), this.path = t, this.name = "DiscoveryError";
1272
1008
  }
1273
1009
  };
1274
- function ln(e) {
1010
+ function rn(e) {
1275
1011
  let t = /* @__PURE__ */ new Set();
1276
1012
  for (let n of [
1277
1013
  e.dependencies,
@@ -1281,66 +1017,60 @@ function ln(e) {
1281
1017
  ]) if (n) for (let e of Object.keys(n)) t.add(e);
1282
1018
  return t;
1283
1019
  }
1284
- function un(e) {
1020
+ function an(e) {
1285
1021
  return e === "" || e === ".";
1286
1022
  }
1287
- function dn(e, t) {
1288
- let n = e.pkg["block-scope"];
1289
- if (typeof n == "string") {
1290
- if (!sn.includes(n)) throw new cn(`package.json "block-scope" must be one of ${sn.join(", ")}, got '${n}'`, e.path);
1291
- return n;
1023
+ function on(e) {
1024
+ let t = e.pkg["block-scope"];
1025
+ if (typeof t == "string") {
1026
+ if (!tn.includes(t)) throw new nn(`package.json "block-scope" must be one of ${tn.join(", ")}, got '${t}'`, e.path);
1027
+ return t;
1292
1028
  }
1293
- if (un(e.path)) return "root";
1294
- let r = ln(e.pkg);
1029
+ if (an(e.path)) return "root";
1030
+ if (e.pkg.block !== void 0) return "block";
1031
+ let n = rn(e.pkg);
1295
1032
  if (e.pkg["block-software"] !== void 0) return "software";
1296
- if (r.has("@platforma-sdk/package-builder")) {
1297
- for (let e of r) if (/^@platforma-open\/.*runenv/.test(e)) return "software";
1298
- }
1299
- if (r.has("@platforma-sdk/workflow-tengo")) return "workflow";
1300
- if ((r.has("@platforma-sdk/ui-vue") || r.has("vue")) && !e.pkg.main) return "ui";
1301
- if (r.has("@platforma-sdk/block-tools")) {
1302
- if ([...r].filter((e) => t.has(e) && (e.endsWith(".model") || e.endsWith(".ui") || e.endsWith(".workflow"))).length >= 2) return "block";
1303
- let n = e.pkg.files;
1304
- if (Array.isArray(n) && n.length === 2 && n.includes("index.d.ts") && n.includes("index.js")) return "block";
1305
- }
1306
- if (r.has("@platforma-sdk/model") && e.pkg.main) return "model";
1307
- if (r.has("@platforma-sdk/test")) return "test";
1308
- }
1309
- function fn(e) {
1310
- let t = /* @__PURE__ */ new Set();
1311
- for (let n of e) typeof n.pkg.name == "string" && t.add(n.pkg.name);
1312
- let n = [];
1313
- for (let r of e) {
1314
- let e = dn(r, t);
1315
- if (!e) throw new cn(`Unclassified workspace package at '${r.path}'. Add a top-level "block-scope" string to its package.json.`, r.path);
1316
- n.push({
1033
+ if (n.has("@platforma-sdk/package-builder")) {
1034
+ for (let e of n) if (/^@platforma-open\/.*runenv/.test(e)) return "software";
1035
+ }
1036
+ if (n.has("@platforma-sdk/workflow-tengo")) return "workflow";
1037
+ if ((n.has("@platforma-sdk/ui-vue") || n.has("vue")) && !e.pkg.main) return "ui";
1038
+ if (n.has("@platforma-sdk/model") && e.pkg.main) return "model";
1039
+ if (n.has("@platforma-sdk/test")) return "test";
1040
+ }
1041
+ function sn(e) {
1042
+ let t = [];
1043
+ for (let n of e) {
1044
+ let e = on(n);
1045
+ if (!e) throw new nn(`Unclassified workspace package at '${n.path}'. Add a top-level "block-scope" string to its package.json.`, n.path);
1046
+ t.push({
1317
1047
  scope: e,
1318
- name: r.pkg.name ?? r.path,
1319
- path: un(r.path) ? "" : r.path
1048
+ name: n.pkg.name ?? n.path,
1049
+ path: an(n.path) ? "" : n.path
1320
1050
  });
1321
1051
  }
1322
- return n;
1052
+ return t;
1323
1053
  }
1324
1054
  //#endregion
1325
1055
  //#region src/structure/engine/ctx.ts
1326
- function q(e, t) {
1056
+ function J(e, t) {
1327
1057
  return e.modules.filter((e) => e.scope === t);
1328
1058
  }
1329
- function pn(e, t) {
1330
- let n = q(e, t);
1059
+ function cn(e, t) {
1060
+ let n = J(e, t);
1331
1061
  if (n.length === 0) throw Error(`findModule: expected one '${t}' module, found none`);
1332
1062
  if (n.length > 1) throw Error(`findModule: expected exactly one '${t}' module, found ${n.length}`);
1333
1063
  return n[0];
1334
1064
  }
1335
- function mn(e, t) {
1336
- return { [pn(e, t).name]: "workspace:*" };
1065
+ function ln(e, t) {
1066
+ return { [cn(e, t).name]: "workspace:*" };
1337
1067
  }
1338
- function hn(e, t) {
1068
+ function un(e, t) {
1339
1069
  let n = {};
1340
- for (let r of q(e, t)) n[r.name] = "workspace:*";
1070
+ for (let r of J(e, t)) n[r.name] = "workspace:*";
1341
1071
  return n;
1342
1072
  }
1343
- function gn(e) {
1073
+ function dn(e) {
1344
1074
  let t = e.facadeName, n = [
1345
1075
  {
1346
1076
  scope: "root",
@@ -1379,7 +1109,7 @@ function gn(e) {
1379
1109
  path: "software"
1380
1110
  }), n;
1381
1111
  }
1382
- function _n(e) {
1112
+ function fn(e) {
1383
1113
  return {
1384
1114
  isSdkInternal: e.isSdkInternal ?? !1,
1385
1115
  updateDepsOnly: e.updateDepsOnly ?? !1,
@@ -1391,41 +1121,41 @@ function _n(e) {
1391
1121
  }
1392
1122
  //#endregion
1393
1123
  //#region src/structure/engine/discovery-fs.ts
1394
- var J = class extends Error {
1124
+ var Y = class extends Error {
1395
1125
  constructor(e) {
1396
1126
  super(e), this.name = "StructureCliError";
1397
1127
  }
1398
1128
  };
1399
- function vn(e, t) {
1129
+ function pn(e, t) {
1400
1130
  return e === "" ? t : `${e}/${t}`;
1401
1131
  }
1402
- function yn(e, t) {
1132
+ function mn(e, t) {
1403
1133
  try {
1404
1134
  return JSON.parse(e.read(t));
1405
1135
  } catch {
1406
1136
  return;
1407
1137
  }
1408
1138
  }
1409
- function bn(e) {
1410
- if (e.includes("*")) throw new J(`pnpm-workspace.yaml 'packages:' entry '${e}' contains a glob. The structurer requires literal package paths — replace the glob with one entry per package directory.`);
1139
+ function hn(e) {
1140
+ if (e.includes("*")) throw new Y(`pnpm-workspace.yaml 'packages:' entry '${e}' contains a glob. The structurer requires literal package paths — replace the glob with one entry per package directory.`);
1411
1141
  let t = e.replace(/^\.\//, "").replace(/\/$/, "");
1412
1142
  return t === "." ? "" : t;
1413
1143
  }
1414
- function xn(e) {
1144
+ function gn(e) {
1415
1145
  let t;
1416
1146
  try {
1417
1147
  t = e.read("pnpm-workspace.yaml");
1418
1148
  } catch {
1419
- throw new J("No pnpm-workspace.yaml found. This directory is empty or unrecognisable as a block — run 'block-tools structure init' instead, or pass --sdk-internal for an in-monorepo block.");
1149
+ throw new Y("No pnpm-workspace.yaml found. This directory is empty or unrecognisable as a block — run 'block-tools structure init' instead, or pass --sdk-internal for an in-monorepo block.");
1420
1150
  }
1421
1151
  let n = oe(t) ?? {}, r = Array.isArray(n.packages) ? n.packages : [], i = new Set([""]);
1422
1152
  for (let t of r) {
1423
- let n = bn(t);
1153
+ let n = hn(t);
1424
1154
  (n === "" || e.exists(n)) && i.add(n);
1425
1155
  }
1426
1156
  let a = [];
1427
1157
  for (let t of i) {
1428
- let n = yn(e, vn(t, "package.json"));
1158
+ let n = mn(e, pn(t, "package.json"));
1429
1159
  n && a.push({
1430
1160
  path: t,
1431
1161
  pkg: n
@@ -1433,7 +1163,7 @@ function xn(e) {
1433
1163
  }
1434
1164
  return a;
1435
1165
  }
1436
- function Sn(e) {
1166
+ function _n(e) {
1437
1167
  let t = [], n = new Set([
1438
1168
  "node_modules",
1439
1169
  ".turbo",
@@ -1445,7 +1175,7 @@ function Sn(e) {
1445
1175
  let o = e.listDir(i);
1446
1176
  for (let s of o) {
1447
1177
  if (!s.isDirectory || n.has(s.name)) continue;
1448
- let o = vn(i, s.name), c = yn(e, vn(o, "package.json"));
1178
+ let o = pn(i, s.name), c = mn(e, pn(o, "package.json"));
1449
1179
  c && t.push({
1450
1180
  path: o,
1451
1181
  pkg: c
@@ -1454,11 +1184,11 @@ function Sn(e) {
1454
1184
  }
1455
1185
  return r("", 1), t;
1456
1186
  }
1457
- function Cn(e) {
1187
+ function vn(e) {
1458
1188
  let t = e.indexOf("/");
1459
- if (!e.startsWith("@") || t < 0) throw new J(`Cannot parse block name '${e}': expected '@npm-org/org-scope.short-name'.`);
1189
+ if (!e.startsWith("@") || t < 0) throw new Y(`Cannot parse block name '${e}': expected '@npm-org/org-scope.short-name'.`);
1460
1190
  let n = e.slice(0, t), r = e.slice(t + 1), i = r.indexOf(".");
1461
- if (i < 0) throw new J(`Cannot parse block name '${e}': base name '${r}' has no '.' separating org-scope from short-name.`);
1191
+ if (i < 0) throw new Y(`Cannot parse block name '${e}': base name '${r}' has no '.' separating org-scope from short-name.`);
1462
1192
  return {
1463
1193
  facadeName: e,
1464
1194
  baseName: r,
@@ -1467,23 +1197,23 @@ function Cn(e) {
1467
1197
  shortName: r.slice(i + 1)
1468
1198
  };
1469
1199
  }
1470
- function wn(e) {
1200
+ function yn(e) {
1471
1201
  try {
1472
- let t = JSON.parse(e.read(Ht));
1202
+ let t = JSON.parse(e.read(Lt));
1473
1203
  return typeof t.version == "number" ? t.version : 0;
1474
1204
  } catch {
1475
1205
  return 0;
1476
1206
  }
1477
1207
  }
1478
- function Tn(e) {
1479
- let { fs: t, isSdkInternal: n } = e, r = n ? Sn(t) : xn(t);
1480
- if (r.length === 0) throw new J("No workspace packages found. Run 'block-tools structure init' to scaffold a block.");
1481
- let i = fn(r), a = wn(t);
1482
- Ut(a, 0);
1208
+ function bn(e) {
1209
+ let { fs: t, isSdkInternal: n } = e, r = n ? _n(t) : gn(t);
1210
+ if (r.length === 0) throw new Y("No workspace packages found. Run 'block-tools structure init' to scaffold a block.");
1211
+ let i = sn(r), a = yn(t);
1212
+ Rt(a, 0);
1483
1213
  let o = i.find((e) => e.scope === "block") ?? i.find((e) => e.scope === "root");
1484
- if (!o) throw new J("Could not find a 'block' (or root-as-block) package to derive BlockVars from.");
1485
- let s = Cn(o.name.replace(/\.block$/, ""));
1486
- return _n({
1214
+ if (!o) throw new Y("Could not find a 'block' (or root-as-block) package to derive BlockVars from.");
1215
+ let s = vn(o.name.replace(/\.block$/, ""));
1216
+ return fn({
1487
1217
  isSdkInternal: n,
1488
1218
  updateDepsOnly: e.updateDepsOnly ?? !1,
1489
1219
  modules: i,
@@ -1494,7 +1224,7 @@ function Tn(e) {
1494
1224
  }
1495
1225
  //#endregion
1496
1226
  //#region src/structure/rules/shared/key-order.ts
1497
- var Y = [
1227
+ var X = [
1498
1228
  "name",
1499
1229
  "version",
1500
1230
  "private",
@@ -1518,7 +1248,7 @@ var Y = [
1518
1248
  ];
1519
1249
  //#endregion
1520
1250
  //#region src/structure/rules/root-package-json.ts
1521
- function En(e) {
1251
+ function xn(e) {
1522
1252
  return {
1523
1253
  version: "1.0.0",
1524
1254
  private: !0,
@@ -1551,88 +1281,88 @@ function En(e) {
1551
1281
  packageManager: "pnpm@9.12.0"
1552
1282
  };
1553
1283
  }
1554
- function Dn() {
1555
- F("packageManager", "pnpm@9.12.0"), Et("name"), I("fmt", "turbo run fmt"), I("check", "turbo run check"), I("build", "turbo run build"), I("build:dev", "env PL_PKG_DEV=local turbo run build"), I("test", "env PL_PKG_DEV=local turbo run test --concurrency 1"), I("test:dry-run", "env PL_PKG_DEV=local turbo run test --dry-run=json"), I("mark-stable", "turbo run mark-stable"), I("do-pack", "turbo run do-pack"), I("watch", "turbo watch build"), I("changeset", "changeset"), I("version-packages", "changeset version"), I("update-sdk", "block-tools structure refresh --update-deps-only"), L("update"), I("upgrade-sdk", "block-tools structure refresh --update-deps-only && pnpm i && block-tools structure refresh && pnpm i && pnpm fmt"), H({
1284
+ function Sn() {
1285
+ L("packageManager", "pnpm@9.12.0"), vt("name"), R("fmt", "turbo run fmt"), R("check", "turbo run check"), R("build", "turbo run build"), R("build:dev", "env PL_PKG_DEV=local turbo run build"), R("test", "env PL_PKG_DEV=local turbo run test --concurrency 1"), R("test:dry-run", "env PL_PKG_DEV=local turbo run test --dry-run=json"), R("mark-stable", "turbo run mark-stable"), R("do-pack", "turbo run do-pack"), R("watch", "turbo watch build"), R("changeset", "changeset"), R("version-packages", "changeset version"), R("update-sdk", "block-tools structure refresh --update-deps-only"), z("update"), R("upgrade-sdk", "block-tools structure refresh --update-deps-only && pnpm i && block-tools structure refresh && pnpm i && pnpm fmt"), W({
1556
1286
  "@changesets/cli": "catalog:",
1557
1287
  "@milaboratories/ts-builder": "sdk:",
1558
1288
  "@platforma-sdk/block-tools": "sdk:",
1559
1289
  shx: "catalog:",
1560
1290
  turbo: "catalog:"
1561
- }), U({
1291
+ }), G({
1562
1292
  oxlint: "*",
1563
1293
  oxfmt: "*"
1564
- }), At((e, t) => {
1294
+ }), Tt((e, t) => {
1565
1295
  if (!/^(\/\/|--)/.test(e) || typeof t != "object" || !t) return !1;
1566
1296
  let n = t;
1567
1297
  return n.pnpm !== void 0 || n.overrides !== void 0;
1568
- }), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...Y]);
1298
+ }), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1569
1299
  }
1570
1300
  //#endregion
1571
1301
  //#region src/structure/engine/registry-client.ts
1572
- var On = 2, kn = 500, An = 3e4;
1573
- function jn(e) {
1302
+ var Cn = 2, wn = 500, Tn = 3e4;
1303
+ function En(e) {
1574
1304
  if (!e) return null;
1575
1305
  let t = Number(e);
1576
1306
  if (Number.isFinite(t) && t > 0) return t * 1e3;
1577
1307
  let n = Date.parse(e);
1578
1308
  return Number.isNaN(n) ? null : Math.max(0, n - Date.now());
1579
1309
  }
1580
- async function Mn(e) {
1310
+ async function Dn(e) {
1581
1311
  for (let t = 1;; t++) {
1582
1312
  let n;
1583
1313
  try {
1584
- n = await fetch(e, { signal: AbortSignal.timeout(An) });
1314
+ n = await fetch(e, { signal: AbortSignal.timeout(Tn) });
1585
1315
  } catch (e) {
1586
- if (t > On) throw e;
1587
- await le(kn * 2 ** (t - 1) * (.8 + .4 * Math.random()));
1316
+ if (t > Cn) throw e;
1317
+ await le(wn * 2 ** (t - 1) * (.8 + .4 * Math.random()));
1588
1318
  continue;
1589
1319
  }
1590
1320
  if (n.ok) return n;
1591
- if (!(n.status === 429 || n.status >= 500) || t > On) throw Error(`registry returned HTTP ${n.status}`);
1592
- let r = jn(n.headers.get("retry-after"));
1321
+ if (!(n.status === 429 || n.status >= 500) || t > Cn) throw Error(`registry returned HTTP ${n.status}`);
1322
+ let r = En(n.headers.get("retry-after"));
1593
1323
  if (r != null) {
1594
1324
  await le(r);
1595
1325
  continue;
1596
1326
  }
1597
- await le(kn * 2 ** (t - 1) * (.8 + .4 * Math.random()));
1327
+ await le(wn * 2 ** (t - 1) * (.8 + .4 * Math.random()));
1598
1328
  }
1599
1329
  }
1600
- function Nn() {
1330
+ function On() {
1601
1331
  return {
1602
1332
  async getLatestVersion(e) {
1603
- let t = (await (await Mn(`https://registry.npmjs.org/-/package/${e}/dist-tags`)).json()).latest;
1333
+ let t = (await (await Dn(`https://registry.npmjs.org/-/package/${e}/dist-tags`)).json()).latest;
1604
1334
  if (!t) throw Error("no 'latest' dist-tag in registry response");
1605
1335
  return t;
1606
1336
  },
1607
1337
  async getDeclaredDependency(e, t, n) {
1608
- let r = await (await Mn(`https://registry.npmjs.org/${e}/${t}`)).json();
1338
+ let r = await (await Dn(`https://registry.npmjs.org/${e}/${t}`)).json();
1609
1339
  return r.dependencies?.[n] ?? r.peerDependencies?.[n];
1610
1340
  }
1611
1341
  };
1612
1342
  }
1613
- async function Pn(e, t) {
1343
+ async function kn(e, t) {
1614
1344
  let n = await Promise.all(t.map(async (t) => [t, await e.getLatestVersion(t)]));
1615
1345
  return new Map(n);
1616
1346
  }
1617
- function Fn(e) {
1347
+ function An(e) {
1618
1348
  return (t) => e.get(t);
1619
1349
  }
1620
- var In = [/^@platforma-sdk\//, /^@milaboratories\//];
1621
- function Ln(e) {
1622
- return In.some((t) => t.test(e));
1350
+ var jn = [/^@platforma-sdk\//, /^@milaboratories\//];
1351
+ function Mn(e) {
1352
+ return jn.some((t) => t.test(e));
1623
1353
  }
1624
- async function Rn(e, t = Nn()) {
1625
- return e.length === 0 ? () => void 0 : Fn(await Pn(t, e));
1354
+ async function Nn(e, t = On()) {
1355
+ return e.length === 0 ? () => void 0 : An(await kn(t, e));
1626
1356
  }
1627
- function zn(e) {
1357
+ function Pn(e) {
1628
1358
  return /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(e);
1629
1359
  }
1630
- async function Bn(e, t = Nn()) {
1360
+ async function Fn(e, t = On()) {
1631
1361
  if (e.length === 0) return () => void 0;
1632
1362
  let n = await Promise.all(e.map(async (e) => {
1633
1363
  let n = await t.getDeclaredDependency(e.of, e.ofVersion ?? "latest", e.entry);
1634
1364
  if (n === void 0) throw Error(`derived catalog pin '${e.entry}': package '${e.of}'${e.ofVersion ? `@${e.ofVersion}` : " (latest)"} declares no dependency '${e.entry}'. A derived pin requires the source to declare the dep as an exact version.`);
1635
- if (!zn(n)) throw Error(`derived catalog pin '${e.entry}': package '${e.of}'${e.ofVersion ? `@${e.ofVersion}` : " (latest)"} declares '${e.entry}: ${n}', which is not an exact version. A derived pin requires an exact ('x.y.z') source dependency so the catalog can pin to it precisely.`);
1365
+ if (!Pn(n)) throw Error(`derived catalog pin '${e.entry}': package '${e.of}'${e.ofVersion ? `@${e.ofVersion}` : " (latest)"} declares '${e.entry}: ${n}', which is not an exact version. A derived pin requires an exact ('x.y.z') source dependency so the catalog can pin to it precisely.`);
1636
1366
  return [e.entry, n];
1637
1367
  })), r = new Map(n);
1638
1368
  return (e) => r.get(e);
@@ -1640,7 +1370,7 @@ async function Bn(e, t = Nn()) {
1640
1370
  //#endregion
1641
1371
  //#region src/structure/rules/shared/retired-deps.ts
1642
1372
  // @vitejs/plugin-vue — bundled by ts-builder's internal vite config.
1643
- var Vn = [
1373
+ var In = [
1644
1374
  "vite",
1645
1375
  "tsup",
1646
1376
  "vue-tsc",
@@ -1648,12 +1378,12 @@ var Vn = [
1648
1378
  "vite-plugin-dts",
1649
1379
  "@platforma-sdk/eslint-config"
1650
1380
  ];
1651
- function Hn() {
1652
- for (let e of Vn) V(e);
1381
+ function Ln() {
1382
+ for (let e of In) U(e);
1653
1383
  }
1654
1384
  //#endregion
1655
1385
  //#region src/structure/rules/root-pnpm-workspace.ts
1656
- var X = [
1386
+ var Z = [
1657
1387
  "@platforma-sdk/model",
1658
1388
  "@platforma-sdk/ui-vue",
1659
1389
  "@platforma-sdk/workflow-tengo",
@@ -1663,32 +1393,32 @@ var X = [
1663
1393
  "@platforma-sdk/package-builder",
1664
1394
  "@milaboratories/ts-builder",
1665
1395
  "@milaboratories/ts-configs"
1666
- ], Un = "0.0.0-init-must-fetch";
1667
- for (let e of X) if (!Ln(e)) throw Error(`SDK_CATALOG_PACKAGES entry '${e}' matches no catalog bump pattern; its placeholder would never be resolved to npm latest on init. Add it to CATALOG_BUMP_PATTERNS or move it to the infra floor.`);
1668
- var Wn = {
1396
+ ], Rn = "0.0.0-init-must-fetch";
1397
+ for (let e of Z) if (!Mn(e)) throw Error(`SDK_CATALOG_PACKAGES entry '${e}' matches no catalog bump pattern; its placeholder would never be resolved to npm latest on init. Add it to CATALOG_BUMP_PATTERNS or move it to the infra floor.`);
1398
+ var zn = {
1669
1399
  turbo: "~2.8.11",
1670
1400
  shx: "~0.4.0",
1671
1401
  "@changesets/cli": "~2.29.8",
1672
1402
  vitest: "~4.0.18"
1673
- }, Gn = [{
1403
+ }, Bn = [{
1674
1404
  entry: "vue",
1675
1405
  of: "@platforma-sdk/ui-vue"
1676
- }], Kn = "@platforma-open/milaboratories.runenv-python-3", qn = "1.8.2";
1677
- function Jn(e) {
1406
+ }], Vn = "@platforma-open/milaboratories.runenv-python-3", Hn = "1.8.2";
1407
+ function Un(e) {
1678
1408
  let t = e.modules.filter((e) => e.path !== "").map((e) => e.path).sort(), n = {};
1679
- for (let e of X) n[e] = Un;
1680
- return Object.assign(n, Wn), e.modules.some((e) => e.scope === "software") && (n[Kn] = qn), {
1409
+ for (let e of Z) n[e] = Rn;
1410
+ return Object.assign(n, zn), e.modules.some((e) => e.scope === "software") && (n[Vn] = Hn), {
1681
1411
  packages: t,
1682
1412
  catalog: n
1683
1413
  };
1684
1414
  }
1685
- function Yn() {
1686
- Nt();
1687
- for (let e of Vn) Rt(e);
1415
+ function Wn() {
1416
+ Ot();
1417
+ for (let e of In) Nt(e);
1688
1418
  }
1689
1419
  //#endregion
1690
1420
  //#region src/structure/rules/root-gitignore.ts
1691
- var Xn = [
1421
+ var Gn = [
1692
1422
  ".test_auth.json",
1693
1423
  "node_modules/",
1694
1424
  "dist/",
@@ -1703,52 +1433,92 @@ var Xn = [
1703
1433
  ".vscode/sftp.json",
1704
1434
  "test-dry-run.json"
1705
1435
  ];
1706
- function Zn() {
1707
- zt(Xn);
1436
+ function Kn() {
1437
+ Pt(Gn);
1708
1438
  }
1709
1439
  //#endregion
1710
1440
  //#region src/structure/rules/root.ts
1711
- function Qn() {
1712
- y("root", () => {
1713
- b(({ ctx: e }) => !e.isSdkInternal, () => {
1714
- S("turbo.json", E("root/turbo.json")), S(".vscode/settings.json", E("root/.vscode/settings.json")), C("package.json", O((e) => En(e)), () => {
1715
- Dn();
1716
- }), C("pnpm-workspace.yaml", O((e) => Jn(e)), () => {
1717
- Yn();
1718
- }), C(".gitignore", E("root/.gitignore"), () => {
1719
- Zn();
1441
+ function qn() {
1442
+ b("root", () => {
1443
+ x(({ ctx: e }) => !e.isSdkInternal, () => {
1444
+ C("turbo.json", O("root/turbo.json")), C(".vscode/settings.json", O("root/.vscode/settings.json")), w("package.json", A((e) => xn(e)), () => {
1445
+ Sn();
1446
+ }), w("pnpm-workspace.yaml", A((e) => Un(e)), () => {
1447
+ Wn();
1448
+ }), w(".gitignore", O("root/.gitignore"), () => {
1449
+ Kn();
1720
1450
  });
1721
1451
  });
1722
1452
  });
1723
1453
  }
1724
1454
  //#endregion
1725
1455
  //#region src/structure/rules/root-ci.ts
1726
- function $n(e) {
1456
+ function Jn(e) {
1727
1457
  return e.split(/[-_]+/).filter((e) => e.length > 0).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
1728
1458
  }
1729
- function er() {
1730
- y("root", () => {
1731
- b(({ ctx: e }) => !e.isSdkInternal, () => {
1732
- S(".github/workflows/build.yaml", D("workflows/build.tpl.yaml", (e) => {
1459
+ function Yn() {
1460
+ b("root", () => {
1461
+ x(({ ctx: e }) => !e.isSdkInternal, () => {
1462
+ C(".github/workflows/build.yaml", k("workflows/build.tpl.yaml", (e) => {
1733
1463
  let t = e.blockVars.shortName;
1734
1464
  return {
1735
- appName: `Block: ${$n(t)}`,
1465
+ appName: `Block: ${Jn(t)}`,
1736
1466
  appNameSlug: `block-${t}`
1737
1467
  };
1738
- })), S(".github/workflows/mark-stable.yaml", D("workflows/mark-stable.tpl.yaml", (e) => ({ appName: `Block: ${$n(e.blockVars.shortName)} - Mark Stable` })));
1468
+ })), C(".github/workflows/mark-stable.yaml", k("workflows/mark-stable.tpl.yaml", (e) => ({ appName: `Block: ${Jn(e.blockVars.shortName)} - Mark Stable` })));
1739
1469
  });
1740
1470
  });
1741
1471
  }
1742
1472
  //#endregion
1743
1473
  //#region src/structure/rules/block-package-json.ts
1744
- function tr(e) {
1474
+ var Xn = {
1475
+ "@platforma-open": {
1476
+ s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1",
1477
+ serveUrl: "https://blocks.pl-open.science"
1478
+ },
1479
+ "@milaboratories": {
1480
+ s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1",
1481
+ serveUrl: "https://block.registry.platforma.bio/releases"
1482
+ }
1483
+ }, Zn = {
1484
+ s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1",
1485
+ serveUrl: "https://blocks.pl-open.science"
1486
+ }, Qn = {
1487
+ s3: "s3://milab-euce1-prod-pkgs-s3-block-registry/aux/dev/?region=eu-central-1",
1488
+ serveUrl: "https://aux-blocks.pl-open.science"
1489
+ };
1490
+ function $n(e, t) {
1491
+ let n = t ? Qn : Xn[e] ?? Zn;
1492
+ return `block-tools publish -r ${n.s3} --registry-serve-url ${n.serveUrl}`;
1493
+ }
1494
+ function er(e) {
1745
1495
  let t = {};
1746
- for (let n of q(e, "workflow")) t.workflow = `${n.name}/dist/tengo/tpl/main.plj.gz`;
1747
- for (let n of q(e, "model")) t.model = `${n.name}/dist/model.json`;
1748
- for (let n of q(e, "ui")) t.ui = `${n.name}/dist`;
1496
+ for (let n of J(e, "workflow")) t.workflow = `${n.name}/dist/tengo/tpl/main.plj.gz`;
1497
+ for (let n of J(e, "model")) t.model = `${n.name}/dist/model.json`;
1498
+ for (let n of J(e, "ui")) t.ui = `${n.name}/dist`;
1749
1499
  return t;
1750
1500
  }
1751
- function nr(e) {
1501
+ function tr(e, t) {
1502
+ return {
1503
+ build: "ts-builder build --target block-facade && block-tools pack",
1504
+ check: "ts-builder type-check --target block-facade",
1505
+ prepublishOnly: $n(e, t),
1506
+ "do-pack": "pnpm pack && shx mv *.tgz package.tgz"
1507
+ };
1508
+ }
1509
+ var nr = {
1510
+ "@milaboratories/ts-builder": "sdk:",
1511
+ "@milaboratories/ts-configs": "sdk:",
1512
+ "@platforma-sdk/block-tools": "sdk:",
1513
+ "@platforma-sdk/model": "sdk:",
1514
+ shx: "catalog:",
1515
+ typescript: "catalog:"
1516
+ }, rr = { ".": {
1517
+ sources: "./src/index.ts",
1518
+ types: "./dist/index.d.ts",
1519
+ default: "./dist/index.js"
1520
+ } };
1521
+ function ir(e) {
1752
1522
  if (Object.keys(e.components).length === 0) throw Error("block.components is empty — no workflow/model/ui module was discovered");
1753
1523
  let t = e.meta, n = [
1754
1524
  ["block.meta.title", t.title],
@@ -1760,13 +1530,14 @@ function nr(e) {
1760
1530
  ];
1761
1531
  for (let [e, t] of n) if (typeof t != "string" || t === "") throw Error(`required block field '${e}' is empty`);
1762
1532
  }
1763
- function rr(e) {
1533
+ function ar(e) {
1764
1534
  let t = e.blockVars, n = {
1765
- ...mn(e, "model"),
1766
- ...mn(e, "ui"),
1767
- ...mn(e, "workflow")
1535
+ ...nr,
1536
+ ...un(e, "model"),
1537
+ ...un(e, "ui"),
1538
+ ...un(e, "workflow")
1768
1539
  }, r = {
1769
- components: tr(e),
1540
+ components: er(e),
1770
1541
  meta: {
1771
1542
  title: t.shortName,
1772
1543
  description: `${t.shortName} block`,
@@ -1778,45 +1549,55 @@ function rr(e) {
1778
1549
  }
1779
1550
  }
1780
1551
  };
1781
- return nr(r), {
1552
+ return ir(r), {
1782
1553
  name: `${t.facadeName}.block`,
1783
1554
  version: "1.0.0",
1784
- files: ["index.d.ts", "index.js"],
1785
- scripts: {
1786
- build: "shx rm -rf ./block-pack && block-tools pack",
1787
- "mark-stable": "block-tools mark-stable -r 's3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1'",
1788
- prepublishOnly: "block-tools pack && block-tools publish -r 's3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1'",
1789
- "do-pack": "shx rm -f *.tgz && block-tools pack && pnpm pack && shx mv *.tgz package.tgz"
1790
- },
1791
- dependencies: n,
1792
- devDependencies: {
1793
- "@platforma-sdk/block-tools": "sdk:",
1794
- shx: "catalog:"
1795
- },
1555
+ type: "module",
1556
+ files: ["dist", "block-pack"],
1557
+ main: "./dist/index.js",
1558
+ module: "./dist/index.js",
1559
+ types: "./dist/index.d.ts",
1560
+ exports: rr,
1561
+ scripts: tr(t.npmOrg, e.isSdkInternal),
1562
+ dependencies: {},
1563
+ devDependencies: n,
1796
1564
  block: r
1797
1565
  };
1798
1566
  }
1799
- function ir(e) {
1800
- F("files", ["index.d.ts", "index.js"]), I("build", "shx rm -rf ./block-pack && block-tools pack"), I("mark-stable", "block-tools mark-stable -r 's3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1'"), I("prepublishOnly", "block-tools pack && block-tools publish -r 's3://milab-euce1-prod-pkgs-s3-block-registry/pub/releases/?region=eu-central-1'"), I("do-pack", "shx rm -f *.tgz && block-tools pack && pnpm pack && shx mv *.tgz package.tgz"), W("model"), W("ui"), W("workflow"), B("@platforma-sdk/block-tools", "sdk:"), B("shx", "catalog:"), F("block.components", tr(e)), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...Y]);
1567
+ function or(e) {
1568
+ let t = e.blockVars;
1569
+ L("type", "module"), L("files", ["dist", "block-pack"]), L("main", "./dist/index.js"), L("module", "./dist/index.js"), L("types", "./dist/index.d.ts"), L("exports", rr);
1570
+ let n = tr(t.npmOrg, e.isSdkInternal);
1571
+ for (let [e, t] of Object.entries(n)) R(e, t);
1572
+ z("mark-stable"), wt("model"), wt("ui"), wt("workflow"), H("@milaboratories/ts-builder", "sdk:"), H("@milaboratories/ts-configs", "sdk:"), H("@platforma-sdk/block-tools", "sdk:"), H("@platforma-sdk/model", "sdk:"), H("shx", "catalog:"), H("typescript", "catalog:"), L("block.components", er(e)), yt("version", "facade package.json must carry a 'version' (the facade publishes)"), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1573
+ }
1574
+ //#endregion
1575
+ //#region src/structure/rules/shared/pascal-case.ts
1576
+ function sr(e) {
1577
+ let t = e.split(/[^A-Za-z0-9]+/).filter((e) => e.length > 0).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("");
1578
+ return /^[0-9]/.test(t) ? `_${t}` : t;
1801
1579
  }
1802
1580
  //#endregion
1803
1581
  //#region src/structure/rules/block.ts
1804
- function ar() {
1805
- y("block", () => {
1806
- S("index.js", E("block/index.js")), S("index.d.ts", E("block/index.d.ts")), w("logos/block-logo.png", Qe("block/logos/block-logo.png")), w("logos/organization-logo.png", Qe("block/logos/organization-logo.png")), C("package.json", O((e) => rr(e)), (e) => {
1807
- ir(e);
1582
+ function cr() {
1583
+ b("block", () => {
1584
+ D("index.js"), D("index.d.ts"), C("src/index.ts", k("block/src/index.tpl.ts", (e) => ({
1585
+ facadeName: e.blockVars.facadeName,
1586
+ pascalName: sr(e.blockVars.shortName)
1587
+ }))), C("src/AGENTS.ts", O("block/src/AGENTS.ts")), T("src/block-extra.ts", O("block/src/block-extra.ts")), T("src/agents-extra.ts", O("block/src/agents-extra.ts")), C("tsconfig.json", O("block/tsconfig.json")), E("logos/block-logo.png", We("block/logos/block-logo.png")), E("logos/organization-logo.png", We("block/logos/organization-logo.png")), w("package.json", A((e) => ar(e)), (e) => {
1588
+ or(e);
1808
1589
  });
1809
1590
  });
1810
1591
  }
1811
1592
  //#endregion
1812
1593
  //#region src/structure/rules/shared/colocated-tests.ts
1813
- var Z = "src/**/*.test.ts";
1594
+ var Q = "src/**/*.test.ts";
1814
1595
  //#endregion
1815
1596
  //#region src/structure/rules/model-package-json.ts
1816
- function or(e) {
1597
+ function lr(e) {
1817
1598
  return {
1818
1599
  name: `${e.blockVars.facadeName}.model`,
1819
- version: "1.0.0",
1600
+ private: !0,
1820
1601
  type: "module",
1821
1602
  main: "dist/index.cjs",
1822
1603
  module: "dist/index.js",
@@ -1847,40 +1628,40 @@ function or(e) {
1847
1628
  }
1848
1629
  };
1849
1630
  }
1850
- function sr() {
1851
- F("type", "module"), F("main", "dist/index.cjs"), F("module", "dist/index.js"), F("types", "dist/index.d.ts"), F("exports", {
1631
+ function ur() {
1632
+ L("private", !0), L("type", "module"), L("main", "dist/index.cjs"), L("module", "dist/index.js"), L("types", "dist/index.d.ts"), L("exports", {
1852
1633
  ".": {
1853
1634
  types: "./dist/index.d.ts",
1854
1635
  sources: "./src/index.ts",
1855
1636
  import: "./dist/index.js"
1856
1637
  },
1857
1638
  "./dist/*": "./dist/*"
1858
- }), I("fmt", "ts-builder format"), I("watch", "ts-builder build --target block-model --watch"), I("build", "ts-builder build --target block-model && block-tools build-model"), I("check", "ts-builder check --target block-model"), z("@platforma-sdk/model", "sdk:"), H({
1639
+ }), R("fmt", "ts-builder format"), R("watch", "ts-builder build --target block-model --watch"), R("build", "ts-builder build --target block-model && block-tools build-model"), R("check", "ts-builder check --target block-model"), V("@platforma-sdk/model", "sdk:"), W({
1859
1640
  "@milaboratories/ts-builder": "sdk:",
1860
1641
  "@milaboratories/ts-configs": "sdk:",
1861
1642
  "@platforma-sdk/block-tools": "sdk:"
1862
- }), U({
1643
+ }), G({
1863
1644
  "@types/node": "*",
1864
1645
  typescript: "*"
1865
- }), b(({ ctx: e }) => !e.isSdkInternal, () => b(x(Z), () => {
1866
- I("test", "vitest run --passWithNoTests"), B("vitest", "catalog:"), B("@types/node", "*");
1867
- }, () => V("vitest"))), Hn(), Et("tsup"), L("lint"), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...Y]);
1646
+ }), x(({ ctx: e }) => !e.isSdkInternal, () => x(S(Q), () => {
1647
+ R("test", "vitest run --passWithNoTests"), H("vitest", "catalog:"), H("@types/node", "*");
1648
+ }, () => U("vitest"))), Ln(), vt("tsup"), z("lint"), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1868
1649
  }
1869
1650
  //#endregion
1870
1651
  //#region src/structure/rules/model.ts
1871
- function cr() {
1872
- y("model", () => {
1873
- b(x(Z), () => S("tsconfig.json", E("model/tsconfig.node.json")), () => S("tsconfig.json", E("model/tsconfig.json"))), S(".oxlintrc.json", E("model/.oxlintrc.json")), S(".oxfmtrc.json", E("model/.oxfmtrc.json")), w("src/index.ts", E("model/src/index.ts")), C("package.json", O((e) => or(e)), () => {
1874
- sr();
1652
+ function dr() {
1653
+ b("model", () => {
1654
+ x(S(Q), () => C("tsconfig.json", O("model/tsconfig.node.json")), () => C("tsconfig.json", O("model/tsconfig.json"))), C(".oxlintrc.json", O("model/.oxlintrc.json")), C(".oxfmtrc.json", O("model/.oxfmtrc.json")), E("src/index.ts", O("model/src/index.ts")), w("package.json", A((e) => lr(e)), () => {
1655
+ ur();
1875
1656
  });
1876
1657
  });
1877
1658
  }
1878
1659
  //#endregion
1879
1660
  //#region src/structure/rules/ui-package-json.ts
1880
- function lr(e) {
1661
+ function fr(e) {
1881
1662
  return {
1882
1663
  name: `${e.blockVars.facadeName}.ui`,
1883
- version: "1.0.0",
1664
+ private: !0,
1884
1665
  type: "module",
1885
1666
  scripts: {
1886
1667
  fmt: "ts-builder format",
@@ -1892,7 +1673,7 @@ function lr(e) {
1892
1673
  dependencies: {
1893
1674
  "@platforma-sdk/ui-vue": "sdk:",
1894
1675
  vue: "catalog:",
1895
- ...mn(e, "model")
1676
+ ...ln(e, "model")
1896
1677
  },
1897
1678
  devDependencies: {
1898
1679
  "@milaboratories/ts-builder": "sdk:",
@@ -1904,32 +1685,32 @@ function lr(e) {
1904
1685
  }
1905
1686
  };
1906
1687
  }
1907
- function ur() {
1908
- F("type", "module"), I("fmt", "ts-builder format"), I("dev", "ts-builder serve --target block-ui"), I("watch", "ts-builder build --target block-ui --watch"), I("build", "ts-builder build --target block-ui"), I("check", "ts-builder check --target block-ui"), z("@platforma-sdk/ui-vue", "sdk:"), z("vue", "catalog:"), W("model"), H({
1688
+ function pr() {
1689
+ L("private", !0), L("type", "module"), R("fmt", "ts-builder format"), R("dev", "ts-builder serve --target block-ui"), R("watch", "ts-builder build --target block-ui --watch"), R("build", "ts-builder build --target block-ui"), R("check", "ts-builder check --target block-ui"), V("@platforma-sdk/ui-vue", "sdk:"), V("vue", "catalog:"), Ct("model"), W({
1909
1690
  "@milaboratories/ts-builder": "sdk:",
1910
1691
  "@milaboratories/ts-configs": "sdk:"
1911
- }), Hn(), L("preview"), L("lint"), U({
1692
+ }), Ln(), z("preview"), z("lint"), G({
1912
1693
  "@types/node": "*",
1913
1694
  typescript: "*"
1914
- }), b(({ ctx: e }) => !e.isSdkInternal, () => b(x(Z), () => {
1915
- I("test", "vitest run --passWithNoTests"), B("vitest", "catalog:"), B("@types/node", "*");
1916
- }, () => V("vitest"))), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...Y]);
1695
+ }), x(({ ctx: e }) => !e.isSdkInternal, () => x(S(Q), () => {
1696
+ R("test", "vitest run --passWithNoTests"), H("vitest", "catalog:"), H("@types/node", "*");
1697
+ }, () => U("vitest"))), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1917
1698
  }
1918
1699
  //#endregion
1919
1700
  //#region src/structure/rules/ui.ts
1920
- function dr() {
1921
- y("ui", () => {
1922
- b(x(Z), () => S("tsconfig.json", E("ui/tsconfig.node.json")), () => S("tsconfig.json", E("ui/tsconfig.json"))), S(".oxlintrc.json", E("ui/.oxlintrc.json")), S(".oxfmtrc.json", E("ui/.oxfmtrc.json")), Ze("index.html", E("ui/index.html")), w("src/main.ts", E("ui/src/main.ts")), w("src/app.ts", D("ui/src/app.tpl.ts", (e) => ({ modelPkg: `${e.blockVars.facadeName}.model` }))), w("src/MainPage.vue", D("ui/src/MainPage.tpl.vue", (e) => ({ shortName: e.blockVars.shortName }))), C("package.json", O((e) => lr(e)), () => {
1923
- ur();
1701
+ function mr() {
1702
+ b("ui", () => {
1703
+ x(S(Q), () => C("tsconfig.json", O("ui/tsconfig.node.json")), () => C("tsconfig.json", O("ui/tsconfig.json"))), C(".oxlintrc.json", O("ui/.oxlintrc.json")), C(".oxfmtrc.json", O("ui/.oxfmtrc.json")), T("index.html", O("ui/index.html")), E("src/main.ts", O("ui/src/main.ts")), E("src/app.ts", k("ui/src/app.tpl.ts", (e) => ({ modelPkg: `${e.blockVars.facadeName}.model` }))), E("src/MainPage.vue", k("ui/src/MainPage.tpl.vue", (e) => ({ shortName: e.blockVars.shortName }))), w("package.json", A((e) => fr(e)), () => {
1704
+ pr();
1924
1705
  });
1925
1706
  });
1926
1707
  }
1927
1708
  //#endregion
1928
1709
  //#region src/structure/rules/workflow-package-json.ts
1929
- function fr(e) {
1710
+ function hr(e) {
1930
1711
  return {
1931
1712
  name: `${e.blockVars.facadeName}.workflow`,
1932
- version: "1.0.0",
1713
+ private: !0,
1933
1714
  type: "module",
1934
1715
  scripts: {
1935
1716
  build: "shx rm -rf dist && pl-tengo build",
@@ -1938,7 +1719,7 @@ function fr(e) {
1938
1719
  },
1939
1720
  dependencies: {
1940
1721
  "@platforma-sdk/workflow-tengo": "sdk:",
1941
- ...hn(e, "software")
1722
+ ...un(e, "software")
1942
1723
  },
1943
1724
  devDependencies: {
1944
1725
  "@platforma-sdk/tengo-builder": "sdk:",
@@ -1947,34 +1728,33 @@ function fr(e) {
1947
1728
  }
1948
1729
  };
1949
1730
  }
1950
- function pr() {
1951
- F("type", "module"), I("build", "shx rm -rf dist && pl-tengo build"), I("check", "pl-tengo check"), I("format", "/usr/bin/env emacs --script ./format.el || echo 'No emacs.'"), b(({ ctx: e }) => !e.isSdkInternal, () => b(x(Z), () => {
1952
- I("test", "vitest run --passWithNoTests"), H({ vitest: "catalog:" });
1953
- }, () => V("vitest"))), z("@platforma-sdk/workflow-tengo", "sdk:"), W("software"), H({
1731
+ function gr() {
1732
+ L("private", !0), L("type", "module"), R("build", "shx rm -rf dist && pl-tengo build"), R("check", "pl-tengo check"), R("format", "/usr/bin/env emacs --script ./format.el || echo 'No emacs.'"), x(({ ctx: e }) => !e.isSdkInternal, () => x(S(Q), () => {
1733
+ R("test", "vitest run --passWithNoTests"), W({ vitest: "catalog:" });
1734
+ }, () => U("vitest"))), V("@platforma-sdk/workflow-tengo", "sdk:"), Ct("software"), W({
1954
1735
  "@platforma-sdk/tengo-builder": "sdk:",
1955
1736
  "@platforma-sdk/test": "sdk:",
1956
1737
  shx: "catalog:"
1957
- }), Hn(), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...Y]);
1738
+ }), Ln(), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
1958
1739
  }
1959
1740
  //#endregion
1960
1741
  //#region src/structure/rules/workflow.ts
1961
- function mr() {
1962
- y("workflow", () => {
1963
- S("format.el", E("workflow/format.el")), b(({ ctx: e }) => !e.isSdkInternal, () => b(x(Z), () => {
1964
- S("tsconfig.json", E("workflow/tsconfig.json")), Ze("vitest.config.mts", E("workflow/vitest.config.mts"));
1742
+ function _r() {
1743
+ b("workflow", () => {
1744
+ C("format.el", O("workflow/format.el")), x(({ ctx: e }) => !e.isSdkInternal, () => x(S(Q), () => {
1745
+ C("tsconfig.json", O("workflow/tsconfig.json")), T("vitest.config.mts", O("workflow/vitest.config.mts"));
1965
1746
  }, () => {
1966
- T("tsconfig.json"), T("vitest.config.mts");
1967
- })), T("index.js"), T("index.d.ts"), w("src/main.tpl.tengo", D("workflow/src/main.tpl.tengo", (e) => ({ shortName: e.blockVars.shortName }))), C("package.json", O((e) => fr(e)), () => {
1968
- pr();
1747
+ D("tsconfig.json"), D("vitest.config.mts");
1748
+ })), D("index.js"), D("index.d.ts"), E("src/main.tpl.tengo", k("workflow/src/main.tpl.tengo", (e) => ({ shortName: e.blockVars.shortName }))), w("package.json", A((e) => hr(e)), () => {
1749
+ gr();
1969
1750
  });
1970
1751
  });
1971
1752
  }
1972
1753
  //#endregion
1973
1754
  //#region src/structure/rules/test-package-json.ts
1974
- function hr(e) {
1755
+ function vr(e) {
1975
1756
  return {
1976
1757
  name: `${e.blockVars.facadeName}.test`,
1977
- version: "1.0.0",
1978
1758
  private: !0,
1979
1759
  type: "module",
1980
1760
  scripts: {
@@ -1991,26 +1771,26 @@ function hr(e) {
1991
1771
  }
1992
1772
  };
1993
1773
  }
1994
- function gr() {
1995
- F("type", "module"), I("fmt", "ts-builder format"), I("check", "ts-builder check --target block-test"), I("test", "vitest run --passWithNoTests"), L("lint"), H({
1774
+ function yr() {
1775
+ L("private", !0), L("type", "module"), R("fmt", "ts-builder format"), R("check", "ts-builder check --target block-test"), R("test", "vitest run --passWithNoTests"), z("lint"), W({
1996
1776
  "@platforma-sdk/test": "sdk:",
1997
1777
  "@milaboratories/ts-builder": "sdk:",
1998
1778
  "@milaboratories/ts-configs": "sdk:",
1999
1779
  vitest: "catalog:"
2000
- }), U({ typescript: "*" }), V("@types/node"), Hn(), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...Y]);
1780
+ }), G({ typescript: "*" }), U("@types/node"), Ln(), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
2001
1781
  }
2002
1782
  //#endregion
2003
1783
  //#region src/structure/rules/test.ts
2004
- function _r() {
2005
- y("test", () => {
2006
- S("tsconfig.json", E("test/tsconfig.json")), S(".oxlintrc.json", E("test/.oxlintrc.json")), S(".oxfmtrc.json", E("test/.oxfmtrc.json")), Ze("vitest.config.mts", E("test/vitest.config.mts")), w("src/demo.test.ts", $e("import { expect, test } from \"vitest\";\n\ntest(\"scaffolded block sanity check\", () => {\n expect(true).toBe(true);\n});\n")), C("package.json", O((e) => hr(e)), () => {
2007
- gr();
1784
+ function br() {
1785
+ b("test", () => {
1786
+ C("tsconfig.json", O("test/tsconfig.json")), C(".oxlintrc.json", O("test/.oxlintrc.json")), C(".oxfmtrc.json", O("test/.oxfmtrc.json")), T("vitest.config.mts", O("test/vitest.config.mts")), E("src/demo.test.ts", Ge("import { expect, test } from \"vitest\";\n\ntest(\"scaffolded block sanity check\", () => {\n expect(true).toBe(true);\n});\n")), w("package.json", A((e) => vr(e)), () => {
1787
+ yr();
2008
1788
  });
2009
1789
  });
2010
1790
  }
2011
1791
  //#endregion
2012
1792
  //#region src/structure/rules/software-package-json.ts
2013
- function vr() {
1793
+ function xr() {
2014
1794
  return { entrypoints: { main: { binary: {
2015
1795
  artifact: {
2016
1796
  type: "python",
@@ -2025,10 +1805,10 @@ function vr() {
2025
1805
  cmd: ["python", "{pkg}/main.py"]
2026
1806
  } } } };
2027
1807
  }
2028
- function yr(e) {
1808
+ function Sr(e) {
2029
1809
  return {
2030
1810
  name: `${e.blockVars.facadeName}.software`,
2031
- version: "1.0.0",
1811
+ private: !0,
2032
1812
  type: "module",
2033
1813
  description: "Block Software",
2034
1814
  files: ["./dist/**/*"],
@@ -2038,56 +1818,56 @@ function yr(e) {
2038
1818
  changeset: "changeset",
2039
1819
  "version-packages": "changeset version"
2040
1820
  },
2041
- "block-software": vr(),
1821
+ "block-software": xr(),
2042
1822
  devDependencies: {
2043
1823
  "@platforma-open/milaboratories.runenv-python-3": "catalog:",
2044
1824
  "@platforma-sdk/package-builder": "sdk:"
2045
1825
  }
2046
1826
  };
2047
1827
  }
2048
- function br() {
2049
- F("type", "module"), F("files", ["./dist/**/*"]), I("build", "pl-pkg build"), I("prepublishOnly", "pl-pkg prepublish"), I("changeset", "changeset"), I("version-packages", "changeset version"), H({
1828
+ function Cr() {
1829
+ L("private", !0), L("type", "module"), L("files", ["./dist/**/*"]), R("build", "pl-pkg build"), R("prepublishOnly", "pl-pkg prepublish"), R("changeset", "changeset"), R("version-packages", "changeset version"), W({
2050
1830
  "@platforma-open/milaboratories.runenv-python-3": "catalog:",
2051
1831
  "@platforma-sdk/package-builder": "sdk:"
2052
- }), K("dependencies"), K("devDependencies"), K("peerDependencies"), K("optionalDependencies"), G([...Y]);
1832
+ }), q("dependencies"), q("devDependencies"), q("peerDependencies"), q("optionalDependencies"), K([...X]);
2053
1833
  }
2054
1834
  //#endregion
2055
1835
  //#region src/structure/rules/software.ts
2056
- var xr = "import sys\n\nprint(\"Hello from Python, \" + sys.argv[1] + \"!\")\n", Sr = "# No dependencies specified for this script\n";
2057
- function Cr() {
2058
- y("software", () => {
2059
- w("src/main.py", $e(xr)), w("src/requirements.txt", $e(Sr)), C("package.json", O((e) => yr(e)), () => {
2060
- br();
1836
+ var wr = "import sys\n\nprint(\"Hello from Python, \" + sys.argv[1] + \"!\")\n", Tr = "# No dependencies specified for this script\n";
1837
+ function Er() {
1838
+ b("software", () => {
1839
+ E("src/main.py", Ge(wr)), E("src/requirements.txt", Ge(Tr)), w("package.json", A((e) => Sr(e)), () => {
1840
+ Cr();
2061
1841
  });
2062
1842
  });
2063
1843
  }
2064
- function wr() {
2065
- y("model", () => {
2066
- T("eslint.config.mjs"), T("vite.config.mts");
2067
- }), y("ui", () => {
2068
- T("eslint.config.mjs"), T("vite.config.ts"), T("tsconfig.app.json"), T("tsconfig.node.json");
2069
- }), y("test", () => {
2070
- T("eslint.config.mjs");
2071
- }), y("root", () => {
2072
- T(".prettierrc"), C("package.json", O((e) => En(e)), () => {
2073
- L("pretty"), V("@platforma-sdk/blocks-deps-updater");
1844
+ function Dr() {
1845
+ b("model", () => {
1846
+ D("eslint.config.mjs"), D("vite.config.mts");
1847
+ }), b("ui", () => {
1848
+ D("eslint.config.mjs"), D("vite.config.ts"), D("tsconfig.app.json"), D("tsconfig.node.json");
1849
+ }), b("test", () => {
1850
+ D("eslint.config.mjs");
1851
+ }), b("root", () => {
1852
+ D(".prettierrc"), w("package.json", A((e) => xn(e)), () => {
1853
+ z("pretty"), U("@platforma-sdk/blocks-deps-updater");
2074
1854
  });
2075
1855
  });
2076
1856
  }
2077
1857
  //#endregion
2078
1858
  //#region src/structure/rules/root-catalog-bump.ts
2079
- function Tr() {
2080
- Xe(() => {
2081
- y("root", () => {
2082
- b(({ ctx: e }) => !e.isSdkInternal, () => {
2083
- C("pnpm-workspace.yaml", O((e) => Jn(e)), (e) => {
2084
- for (let e of X) It(e);
2085
- for (let e of Gn) Lt(e.entry, {
1859
+ function Or() {
1860
+ Ue(() => {
1861
+ b("root", () => {
1862
+ x(({ ctx: e }) => !e.isSdkInternal, () => {
1863
+ w("pnpm-workspace.yaml", A((e) => Un(e)), (e) => {
1864
+ for (let e of Z) jt(e);
1865
+ for (let e of Bn) Mt(e.entry, {
2086
1866
  of: e.of,
2087
1867
  ofVersion: e.ofVersion
2088
1868
  });
2089
- for (let [e, t] of Object.entries(Wn)) Ft(e, t);
2090
- e.modules.some((e) => e.scope === "software") && Ft(Kn, qn);
1869
+ for (let [e, t] of Object.entries(zn)) At(e, t);
1870
+ e.modules.some((e) => e.scope === "software") && At(Vn, Hn);
2091
1871
  });
2092
1872
  });
2093
1873
  });
@@ -2095,25 +1875,25 @@ function Tr() {
2095
1875
  }
2096
1876
  //#endregion
2097
1877
  //#region src/structure/structure-definition.ts
2098
- var Er = Ue(() => {
2099
- Qn(), er(), ar(), cr(), dr(), mr(), _r(), Cr(), wr(), Tr();
1878
+ var kr = Ie(() => {
1879
+ qn(), Yn(), cr(), dr(), mr(), _r(), br(), Er(), Dr(), Or();
2100
1880
  });
2101
1881
  //#endregion
2102
1882
  //#region src/structure/cli/run-structure.ts
2103
- async function Dr() {
2104
- return Rn(X.filter(Ln));
1883
+ async function Ar() {
1884
+ return Nn(Z.filter(Mn));
2105
1885
  }
2106
- async function Or(e) {
2107
- let t = p.resolve(e.blockPath), n = e.mode === "check", r = new Oe(t), i = new ke(e.templatesRoot), a = on(Er, r, Tn({
1886
+ async function jr(e) {
1887
+ let t = m.resolve(e.blockPath), n = e.mode === "check", r = new xe(t), i = new Se(e.templatesRoot), a = en(kr, r, bn({
2108
1888
  fs: r,
2109
1889
  isSdkInternal: e.isSdkInternal,
2110
1890
  updateDepsOnly: e.updateDepsOnly,
2111
1891
  dryRun: n
2112
1892
  }), {
2113
1893
  templates: i,
2114
- registryLookup: e.updateDepsOnly ? await Dr() : void 0,
2115
- derivedPinLookup: e.updateDepsOnly ? await Bn(Gn) : void 0,
2116
- rediscover: () => Tn({
1894
+ registryLookup: e.updateDepsOnly ? await Ar() : void 0,
1895
+ derivedPinLookup: e.updateDepsOnly ? await Fn(Bn) : void 0,
1896
+ rediscover: () => bn({
2117
1897
  fs: r,
2118
1898
  isSdkInternal: e.isSdkInternal,
2119
1899
  updateDepsOnly: !1,
@@ -2125,61 +1905,188 @@ async function Or(e) {
2125
1905
  changes: a.changes
2126
1906
  };
2127
1907
  }
2128
- function kr(e, t) {
1908
+ function Mr(e, t) {
2129
1909
  if (t.length === 0) return ` ${e}: up to date (0 changes)`;
2130
1910
  let n = t.map((e) => ` ${e.action.padEnd(6)} ${e.primitive.padEnd(8)} ${e.path} [${e.scope}]`);
2131
1911
  return ` ${e}: ${t.length} change(s)\n${n.join("\n")}`;
2132
1912
  }
2133
1913
  //#endregion
1914
+ //#region src/cmd/structure/refresh.ts
1915
+ async function Nr(e) {
1916
+ for (let t of e.paths) {
1917
+ let n = await jr({
1918
+ blockPath: t,
1919
+ isSdkInternal: e.isSdkInternal,
1920
+ updateDepsOnly: e.updateDepsOnly,
1921
+ mode: "refresh",
1922
+ templatesRoot: e.templatesRoot,
1923
+ log: (t) => e.logger.info(t)
1924
+ });
1925
+ e.logger.info(Mr(t, n.changes));
1926
+ }
1927
+ }
1928
+ function Pr(e) {
1929
+ let t = new f("refresh").description("Bring block(s) up to date with the canonical structure. Applies rules, writes files, bumps .structure version. Default mode is offline; --update-deps-only fires only catalog-bump rules (network).");
1930
+ return t.argument("[paths...]", "block path(s); defaults to the current directory"), t.option("--sdk-internal", "block(s) live inside the SDK monorepo; skip root-scope rules"), t.option("--update-deps-only", "fire ONLY catalog-bump rules (npm network). Follow with `pnpm install` then a plain refresh."), t.action(async (t, n) => {
1931
+ let r = t.length > 0 ? t : ["."], i = m.join(e, "src", "structure", "templates");
1932
+ await Nr({
1933
+ paths: r,
1934
+ isSdkInternal: !!n.sdkInternal,
1935
+ updateDepsOnly: !!n.updateDepsOnly,
1936
+ templatesRoot: i,
1937
+ logger: new g()
1938
+ });
1939
+ }), t;
1940
+ }
1941
+ //#endregion
1942
+ //#region src/cmd/update-deps.ts
1943
+ function Fr(e) {
1944
+ let t = new f("update-deps").description("[DEPRECATED] Use `block-tools structure refresh --update-deps-only`. This alias delegates to it.");
1945
+ return t.action(async () => {
1946
+ let t = new g();
1947
+ t.warn("`block-tools update-deps` is deprecated and will be removed in a future release. Use `block-tools structure refresh --update-deps-only` instead. Delegating now."), await Nr({
1948
+ paths: ["."],
1949
+ isSdkInternal: !1,
1950
+ updateDepsOnly: !0,
1951
+ templatesRoot: m.join(e, "src", "structure", "templates"),
1952
+ logger: t
1953
+ });
1954
+ }), t;
1955
+ }
1956
+ //#endregion
1957
+ //#region src/cmd/list-overview-snapshots.ts
1958
+ function Ir() {
1959
+ let e = new f("list-overview-snapshots").description("List all available global overview snapshots in the registry");
1960
+ return e.addOption(new p("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.option("--json", "output in JSON format", !1), e.action(async (e) => {
1961
+ let t = new g(), n = await new s(o(e.registry), t).listGlobalOverviewSnapshots();
1962
+ if (e.json) t.info(JSON.stringify(n, null, 2));
1963
+ else if (n.length === 0) t.info("No snapshots found.");
1964
+ else {
1965
+ t.info(`Found ${n.length} snapshot(s):\n`);
1966
+ for (let e of n) t.info(` ${e.timestamp}`), t.info(` Path: ${e.path}`), t.info("");
1967
+ }
1968
+ }), e;
1969
+ }
1970
+ //#endregion
1971
+ //#region src/cmd/restore-overview-from-snapshot.ts
1972
+ function Lr() {
1973
+ let e = new f("restore-overview-from-snapshot").description("Restore global overview from a snapshot");
1974
+ return e.addOption(new p("-r, --registry <address>", "full address of the registry").env("PL_REGISTRY").makeOptionMandatory()), e.requiredOption("-s, --snapshot <timestamp>", "snapshot timestamp ID to restore from"), e.option("--skip-confirmation", "skip confirmation prompt (use with caution)", !1), e.action(async (e) => {
1975
+ let t = new g(), n = new s(o(e.registry), t), r = await n.listGlobalOverviewSnapshots();
1976
+ if (!r.find((t) => t.timestamp === e.snapshot)) throw Error(`Snapshot '${e.snapshot}' not found. Available snapshots:\n${r.map((e) => ` - ${e.timestamp}`).join("\n") || " (none)"}`);
1977
+ if (!e.skipConfirmation) {
1978
+ let n = (await import("node:readline")).createInterface({
1979
+ input: process.stdin,
1980
+ output: process.stdout
1981
+ }), r = await new Promise((t) => {
1982
+ n.question(`⚠️ This will overwrite the current global overview with snapshot '${e.snapshot}'.\nAre you sure you want to continue? (y/N): `, t);
1983
+ });
1984
+ if (n.close(), r.toLowerCase() !== "y" && r.toLowerCase() !== "yes") {
1985
+ t.info("Restore cancelled.");
1986
+ return;
1987
+ }
1988
+ }
1989
+ try {
1990
+ await n.restoreGlobalOverviewFromSnapshot(e.snapshot), t.info(`✅ Successfully restored global overview from snapshot '${e.snapshot}'`);
1991
+ } catch (e) {
1992
+ throw Error(`Failed to restore from snapshot: ${String(e)}`);
1993
+ }
1994
+ }), e;
1995
+ }
1996
+ //#endregion
1997
+ //#region src/registry_v1/flags.ts
1998
+ function Rr(e) {
1999
+ let t = e.match(/(?<destName>[^/\\]+)=(?<src>.*)/);
2000
+ if (t) {
2001
+ let { src: e, destName: n } = t.groups;
2002
+ return {
2003
+ src: e,
2004
+ destName: n
2005
+ };
2006
+ } else return {
2007
+ src: e,
2008
+ destName: m.basename(e)
2009
+ };
2010
+ }
2011
+ function zr(e, t) {
2012
+ return new p(e, t).argParser((e, t) => [...t ?? [], Rr(e)]).default([]);
2013
+ }
2014
+ //#endregion
2015
+ //#region src/cmd/upload-package-v1.ts
2016
+ var Br = [
2017
+ "registry",
2018
+ "organization",
2019
+ "package",
2020
+ "version"
2021
+ ];
2022
+ function Vr() {
2023
+ let e = new f("upload-package-v1").description("Uploads V1 package and refreshes the registry");
2024
+ return e.addOption(new p("-r, --registry <address|alias>", "full address of the registry or alias from .pl.reg").env("PL_REGISTRY")), e.addOption(new p("-o, --organization <organization>", "target organisation").env("PL_PACKAGE_ORGANIZATION")), e.addOption(new p("-p, --package <package>", "target package").env("PL_PACKAGE_NAME")), e.addOption(new p("-v, --version <version>", "target version").env("PL_PACKAGE_VERSION")), e.option("-m, --meta <path>", "json file containing meta information to associate with tha package"), e.addOption(zr("-f, --file <file>", "package files")), e.addOption(new p("--refresh", "refresh repository after adding the package").default(!0).env("PL_REGISTRY_REFRESH")), e.option("--no-refresh", "do not refresh repository after adding the package"), e.action(async (e) => {
2025
+ let t = new g(), n = l.parse({});
2026
+ for (let t of Br) e[t] && (n[t] = e[t]);
2027
+ e.meta && (e.meta.endsWith(".json") ? n.meta = JSON.parse(await h.promises.readFile(e.meta, { encoding: "utf-8" })) : e.meta.endsWith(".yaml") && (n.meta = ae.parse(await h.promises.readFile(e.meta, { encoding: "utf-8" }))));
2028
+ for (let t of e.file) n.files[t.destName] = t.src;
2029
+ let r = await c(n);
2030
+ t.info(ae.stringify(r.conf));
2031
+ let i = r.createRegistry(t), a = r.fullPackageName, o = i.constructNewPackage(a);
2032
+ for (let [e, n] of Object.entries(r.conf.files)) {
2033
+ t.info(`Uploading ${n} -> ${e} ...`);
2034
+ let r = await h.promises.readFile(n);
2035
+ await o.addFile(e, r);
2036
+ }
2037
+ t.info("Uploading meta information..."), await o.writeMeta(r.conf.meta), await o.finish(), e.refresh && await i.updateIfNeeded();
2038
+ }), e;
2039
+ }
2040
+ //#endregion
2134
2041
  //#region src/cmd/structure/check.ts
2135
- var Ar = class e extends d {
2136
- static description = "Check block(s) against the canonical structure (read-only). Exits non-zero if any diff would land — used as the CI gate.";
2137
- static examples = ["<%= config.bin %> <%= command.id %> ./my-block", "<%= config.bin %> <%= command.id %> --sdk-internal etc/blocks/*"];
2138
- static strict = !1;
2139
- static flags = { "sdk-internal": f.boolean({ description: "block(s) live inside the SDK monorepo; skip root-scope rules" }) };
2140
- async run() {
2141
- let { argv: t, flags: n } = await this.parse(e), r = t.length > 0 ? t : ["."], i = p.join(this.config.root, "src", "structure", "templates"), a = !1;
2142
- for (let e of r) {
2143
- let t = await Or({
2042
+ function Hr(e) {
2043
+ let t = new f("check").description("Check block(s) against the canonical structure (read-only). Exits non-zero if any diff would land — used as the CI gate.");
2044
+ return t.argument("[paths...]", "block path(s); defaults to the current directory"), t.option("--sdk-internal", "block(s) live inside the SDK monorepo; skip root-scope rules"), t.action(async (t, n) => {
2045
+ let r = new g(), i = t.length > 0 ? t : ["."], a = m.join(e, "src", "structure", "templates"), o = !1;
2046
+ for (let e of i) {
2047
+ let t = await jr({
2144
2048
  blockPath: e,
2145
- isSdkInternal: n["sdk-internal"],
2049
+ isSdkInternal: !!n.sdkInternal,
2146
2050
  updateDepsOnly: !1,
2147
2051
  mode: "check",
2148
- templatesRoot: i,
2149
- log: (e) => this.log(e)
2052
+ templatesRoot: a,
2053
+ log: (e) => r.info(e)
2150
2054
  });
2151
- this.log(kr(e, t.changes)), t.changes.length > 0 && (a = !0);
2055
+ r.info(Mr(e, t.changes)), t.changes.length > 0 && (o = !0);
2152
2056
  }
2153
- a && this.error("Structure check failed: one or more blocks are out of date. Run `structure refresh`.", { exit: 1 });
2154
- }
2155
- }, Q = ["python"], jr = class extends Error {
2057
+ if (o) throw Error("Structure check failed: one or more blocks are out of date. Run `structure refresh`.");
2058
+ }), t;
2059
+ }
2060
+ //#endregion
2061
+ //#region src/structure/init-block-constructor.ts
2062
+ var $ = ["python"], Ur = class extends Error {
2156
2063
  constructor(e) {
2157
2064
  super(`Missing required flag --${e} in --non-interactive mode. Supply every BlockVars flag, or drop --non-interactive to be prompted.`), this.name = "InitFlagError";
2158
2065
  }
2159
2066
  };
2160
- async function $(e, t, n, r) {
2067
+ async function Wr(e, t, n, r) {
2161
2068
  if (e !== void 0 && e !== "") return e;
2162
- if (n) throw new jr(t);
2069
+ if (n) throw new Ur(t);
2163
2070
  return r();
2164
2071
  }
2165
- async function Mr(e) {
2166
- let t = await $(e.npmOrg, "npm-org", e.nonInteractive, () => de({
2072
+ async function Gr(e) {
2073
+ let t = await Wr(e.npmOrg, "npm-org", e.nonInteractive, () => de({
2167
2074
  message: "npm org (e.g. @platforma-open):",
2168
2075
  default: "@platforma-open"
2169
- })), n = await $(e.orgScope, "org-scope", e.nonInteractive, () => de({ message: "org scope (e.g. my-org):" })), r = await $(e.shortName, "short-name", e.nonInteractive, () => de({ message: "block short name (e.g. mixcr-clonotyping):" })), i;
2076
+ })), n = await Wr(e.orgScope, "org-scope", e.nonInteractive, () => de({ message: "org scope (e.g. my-org):" })), r = await Wr(e.shortName, "short-name", e.nonInteractive, () => de({ message: "block short name (e.g. mixcr-clonotyping):" })), i;
2170
2077
  i = e.withSoftware === void 0 ? e.nonInteractive ? !1 : await ue({
2171
2078
  message: "Include a software module?",
2172
2079
  default: !1
2173
2080
  }) : e.withSoftware;
2174
2081
  let a;
2175
2082
  if (i) {
2176
- if (a = await $(e.platform, "platform", e.nonInteractive, () => fe({
2083
+ if (a = await Wr(e.platform, "platform", e.nonInteractive, () => fe({
2177
2084
  message: "Software platform:",
2178
- choices: Q.map((e) => ({
2085
+ choices: $.map((e) => ({
2179
2086
  name: e,
2180
2087
  value: e
2181
2088
  }))
2182
- })), !Q.includes(a)) throw Error(`Unsupported --platform '${a}'. Only ${Q.join(", ")} ${Q.length === 1 ? "is" : "are"} supported at v1.`);
2089
+ })), !$.includes(a)) throw Error(`Unsupported --platform '${a}'. Only ${$.join(", ")} ${$.length === 1 ? "is" : "are"} supported at v1.`);
2183
2090
  } else if (e.platform) throw Error("--platform was given but software is disabled (--no-software).");
2184
2091
  return {
2185
2092
  facadeName: `${t}/${n}.${r}`,
@@ -2190,20 +2097,20 @@ async function Mr(e) {
2190
2097
  softwarePlatform: a
2191
2098
  };
2192
2099
  }
2193
- async function Nr(e) {
2194
- let t = e.vars, n = gn(t), r = new Oe(e.blockPath), i = new ke(e.templatesRoot), a = _n({
2100
+ async function Kr(e) {
2101
+ let t = e.vars, n = dn(t), r = new xe(e.blockPath), i = new Se(e.templatesRoot), a = fn({
2195
2102
  blockVars: t,
2196
2103
  modules: n,
2197
2104
  isSdkInternal: !1,
2198
2105
  version: 1,
2199
2106
  dryRun: !1
2200
- }), o = X.filter(Ln), s, c;
2107
+ }), o = Z.filter(Mn), s, c;
2201
2108
  try {
2202
- s = await Rn(o), c = await Bn(Gn);
2109
+ s = await Nn(o), c = await Fn(Bn);
2203
2110
  } catch (e) {
2204
2111
  throw Error(`init requires network access to resolve SDK catalog versions from npm, but the registry lookup failed: ${e instanceof Error ? e.message : String(e)}`);
2205
2112
  }
2206
- return on(Er, r, a, {
2113
+ return en(kr, r, a, {
2207
2114
  templates: i,
2208
2115
  initMode: !0,
2209
2116
  registryLookup: s,
@@ -2211,83 +2118,40 @@ async function Nr(e) {
2211
2118
  }), e.log(`Initialised block '${t.facadeName}'${t.softwarePlatform ? ` (software: ${t.softwarePlatform})` : " (no software)"} at ${e.blockPath}`), t;
2212
2119
  }
2213
2120
  //#endregion
2214
- //#region src/cmd/index.ts
2215
- var Pr = {
2216
- "build-meta": pe,
2217
- "build-model": he,
2218
- "list-overview-snapshots": ge,
2219
- "mark-stable": _e,
2220
- pack: ve,
2221
- publish: be,
2222
- "refresh-registry": xe,
2223
- "restore-overview-from-snapshot": Se,
2224
- "update-deps": Ce,
2225
- "upload-package-v1": De,
2226
- "structure:check": Ar,
2227
- "structure:init": class e extends d {
2228
- static description = "Scaffold a fresh Platforma block from the canonical structure. Missing flags are prompted unless --non-interactive.";
2229
- static examples = ["<%= config.bin %> <%= command.id %> --npm-org @platforma-open --org-scope my-org --short-name demo --no-software --non-interactive", "<%= config.bin %> <%= command.id %> ./demo --npm-org @platforma-open --org-scope my-org --short-name demo --with-software --platform python --non-interactive"];
2230
- static args = { path: u.string({ description: "target directory (default: <short-name> under the current directory)" }) };
2231
- static flags = {
2232
- "npm-org": f.string({ description: "npm org, e.g. @platforma-open" }),
2233
- "org-scope": f.string({ description: "org scope, e.g. my-org" }),
2234
- "short-name": f.string({ description: "block short name, e.g. mixcr-clonotyping" }),
2235
- "with-software": f.boolean({ description: "include a software module" }),
2236
- "no-software": f.boolean({ description: "omit the software module" }),
2237
- platform: f.string({
2238
- description: "software platform (single-valued)",
2239
- options: [...Q]
2240
- }),
2241
- "non-interactive": f.boolean({ description: "error on any missing flag instead of prompting" })
2242
- };
2243
- async run() {
2244
- let { args: t, flags: n } = await this.parse(e);
2245
- n["with-software"] && n["no-software"] && this.error("--with-software and --no-software are mutually exclusive.");
2246
- let r = n["with-software"] ? !0 : n["no-software"] ? !1 : void 0, i = await Mr({
2247
- npmOrg: n["npm-org"],
2248
- orgScope: n["org-scope"],
2249
- shortName: n["short-name"],
2250
- withSoftware: r,
2251
- platform: n.platform,
2252
- nonInteractive: n["non-interactive"]
2253
- });
2254
- await Nr({
2255
- vars: i,
2256
- blockPath: t.path ? p.resolve(t.path) : p.resolve(process.cwd(), i.shortName),
2257
- templatesRoot: p.join(this.config.root, "src", "structure", "templates"),
2258
- log: (e) => this.log(e)
2259
- });
2260
- }
2261
- },
2262
- "structure:refresh": class e extends d {
2263
- static description = "Bring block(s) up to date with the canonical structure. Applies rules, writes files, bumps .structure version. Default mode is offline; --update-deps-only fires only catalog-bump rules (network).";
2264
- static examples = [
2265
- "<%= config.bin %> <%= command.id %> ./my-block",
2266
- "<%= config.bin %> <%= command.id %> --sdk-internal etc/blocks/*",
2267
- "<%= config.bin %> <%= command.id %> --update-deps-only"
2268
- ];
2269
- static strict = !1;
2270
- static flags = {
2271
- "sdk-internal": f.boolean({ description: "block(s) live inside the SDK monorepo; skip root-scope rules" }),
2272
- "update-deps-only": f.boolean({ description: "fire ONLY catalog-bump rules (npm network). Follow with `pnpm install` then a plain refresh." })
2273
- };
2274
- async run() {
2275
- let { argv: t, flags: n } = await this.parse(e), r = t.length > 0 ? t : ["."], i = p.join(this.config.root, "src", "structure", "templates");
2276
- for (let e of r) {
2277
- let t = await Or({
2278
- blockPath: e,
2279
- isSdkInternal: n["sdk-internal"],
2280
- updateDepsOnly: n["update-deps-only"],
2281
- mode: "refresh",
2282
- templatesRoot: i,
2283
- log: (e) => this.log(e)
2284
- });
2285
- this.log(kr(e, t.changes));
2286
- }
2287
- }
2288
- }
2289
- };
2121
+ //#region src/cmd/structure/init.ts
2122
+ function qr(e) {
2123
+ let t = new f("init").description("Scaffold a fresh Platforma block from the canonical structure. Missing flags are prompted unless --non-interactive.");
2124
+ return t.argument("[path]", "target directory (default: <short-name> under the current directory)"), t.option("--npm-org <org>", "npm org, e.g. @platforma-open"), t.option("--org-scope <scope>", "org scope, e.g. my-org"), t.option("--short-name <name>", "block short name, e.g. mixcr-clonotyping"), t.option("--with-software", "include a software module"), t.option("--no-software", "omit the software module"), t.addOption(new p("--platform <platform>", "software platform (single-valued)").choices([...$])), t.option("--non-interactive", "error on any missing flag instead of prompting"), t.action(async (t, n) => {
2125
+ let r = new g(), i = n.withSoftware === !0, a = n.software === !1;
2126
+ if (i && a) throw Error("--with-software and --no-software are mutually exclusive.");
2127
+ let o = i ? !0 : a ? !1 : void 0, s = await Gr({
2128
+ npmOrg: n.npmOrg,
2129
+ orgScope: n.orgScope,
2130
+ shortName: n.shortName,
2131
+ withSoftware: o,
2132
+ platform: n.platform,
2133
+ nonInteractive: n.nonInteractive
2134
+ });
2135
+ await Kr({
2136
+ vars: s,
2137
+ blockPath: t ? m.resolve(t) : m.resolve(process.cwd(), s.shortName),
2138
+ templatesRoot: m.join(e, "src", "structure", "templates"),
2139
+ log: (e) => r.info(e)
2140
+ });
2141
+ }), t;
2142
+ }
2143
+ //#endregion
2144
+ //#region src/cli.ts
2145
+ function Jr(e = process.cwd()) {
2146
+ let t = new f();
2147
+ t.name("block-tools").description("Utility to manipulate Platforma Blocks and Block Registry"), t.addCommand(pe()), t.addCommand(he()), t.addCommand(ge()), t.addCommand(ve()), t.addCommand(ye()), t.addCommand(be()), t.addCommand(Fr(e)), t.addCommand(Ir()), t.addCommand(Lr()), t.addCommand(Vr());
2148
+ let n = new f("structure").description("Manage block scaffolding against the canonical structure (check / init / refresh)");
2149
+ return n.addCommand(Hr(e)), n.addCommand(qr(e)), n.addCommand(Pr(e)), t.addCommand(n), t;
2150
+ }
2151
+ async function Yr(e, t) {
2152
+ await Jr(t).parseAsync(e);
2153
+ }
2290
2154
  //#endregion
2291
- export { Pr as COMMANDS };
2155
+ export { Jr as buildProgram, Yr as run };
2292
2156
 
2293
2157
  //# sourceMappingURL=cli.mjs.map