@platforma-sdk/block-tools 2.7.22 → 2.7.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/{config-BQmQyP3s.mjs → config-C-EJTl6j.mjs} +13 -10
- package/dist/{config-BQmQyP3s.mjs.map → config-C-EJTl6j.mjs.map} +1 -1
- package/dist/{config-9u25nZDR.js → config-CZwHml_R.js} +3 -3
- package/dist/{config-9u25nZDR.js.map → config-CZwHml_R.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/io/folder_reader.d.ts +4 -1
- package/dist/v2/model/block_components.d.ts +57 -57
- package/dist/v2/model/block_description.d.ts +850 -850
- package/dist/v2/model/block_meta.d.ts +66 -66
- package/dist/v2/registry/registry_reader.d.ts +3 -1
- package/package.json +6 -6
- package/src/io/folder_reader.ts +7 -4
- package/src/v2/registry/registry_reader.ts +8 -2
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./config-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./config-CZwHml_R.js`);let t=require(`@oclif/core`),n=require(`node:path`);n=e.Ct(n);let r=require(`node:fs`);r=e.Ct(r);let i=require(`@milaboratories/pl-model-middle-layer`),a=require(`@milaboratories/ts-helpers-oclif`),o=require(`yaml`);o=e.Ct(o);let s=require(`@platforma-sdk/blocks-deps-updater`);var c=class i extends t.Command{static description=`Extracts meta information from blocks package.json and outputs meta.json with embedded binary and textual information linked from the meta section.`;static flags={modulePath:t.Flags.string({char:`i`,summary:`input module path`,helpValue:`<path>`,default:`.`}),destination:t.Flags.string({char:`o`,summary:`output meta.json file`,helpValue:`<path>`,required:!0})};async run(){let{flags:t}=await this.parse(i),a=n.default.resolve(t.modulePath),o=await e.Y(a),s=await e.st.parseAsync(e.ot(a).parse(o.meta));await r.default.promises.writeFile(n.default.resolve(t.destination),JSON.stringify(s))}};async function l(e){try{return await r.default.promises.readFile(e,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}}var u=class e extends t.Command{static description=`Extracts and outputs block model JSON from pre-built block model module`;static flags={modulePath:t.Flags.string({char:`i`,summary:`input module path`,helpValue:`<path>`,default:`.`}),sourceBundle:t.Flags.string({char:`b`,summary:`bundled model code to embed into the model for callback-based rendering to work`,helpValue:`<path>`,default:`./dist/bundle.js`}),destination:t.Flags.string({char:`o`,summary:`output model file`,helpValue:`<path>`,default:`./dist/model.json`})};async run(){let{flags:t}=await this.parse(e),i=n.default.resolve(t.modulePath),{model:a,platforma:o}=require(i);if(a||=o,!a)throw Error(`"model" export not found`);let{config:s}=a;if(!s)throw Error(`Malformed "model" object, check it is created with "BlockModel" and ".done()" is executed as the call in the chain.`);if(!(`outputs`in s)||!(`sections`in s))throw Error(`"config" has unexpected structure`);let c=await l(t.sourceBundle);c!==void 0&&(s.code={type:`plain`,content:c}),await r.default.promises.writeFile(n.default.resolve(t.destination),JSON.stringify(s))}},d=class n extends t.Command{static description=`List all available global overview snapshots in the registry`;static flags={registry:t.Flags.string({char:`r`,summary:`full address of the registry`,helpValue:`<address>`,env:`PL_REGISTRY`,required:!0}),json:t.Flags.boolean({summary:`output in JSON format`,default:!1})};async run(){let{flags:t}=await this.parse(n),r=await new e.b(e._(t.registry),new a.OclifLoggerAdapter(this)).listGlobalOverviewSnapshots();if(t.json)this.log(JSON.stringify(r,null,2));else if(r.length===0)this.log(`No snapshots found.`);else{this.log(`Found ${r.length} snapshot(s):\n`);for(let e of r)this.log(` ${e.timestamp}`),this.log(` Path: ${e.path}`),this.log(``)}}},f=class r extends t.Command{static description=`Mark target block stable`;static flags={modulePath:t.Flags.string({char:`i`,summary:`input module path`,helpValue:`<path>`,default:`.`}),channel:t.Flags.string({char:`c`,hidden:!0,summary:`custom channel`,helpValue:`<channel name>`,default:i.StableChannel}),"version-override":t.Flags.file({char:`v`,summary:`override package version`}),registry:t.Flags.string({char:`r`,summary:`full address of the registry`,helpValue:`<address>`,env:`PL_REGISTRY`,required:!0}),refresh:t.Flags.boolean({summary:`refresh repository after adding the package`,default:!0,allowNo:!0,env:`PL_REGISTRY_REFRESH`}),unmark:t.Flags.boolean({summary:`reverses meaning of this command, flag can be used to remove "stable" flag from the package`,default:!1})};async run(){let{flags:t}=await this.parse(r),o=await e.Y(n.default.resolve(t.modulePath));t[`version-override`]&&(o=(0,i.overrideDescriptionVersion)(o,t[`version-override`]));let s=new e.b(e._(t.registry),new a.OclifLoggerAdapter(this));t.unmark?await s.removePackageFromChannel(o.id,t.channel):await s.addPackageToChannel(o.id,t.channel),t.refresh&&await s.updateIfNeeded()}},p=class r extends t.Command{static description=`Builds block pack and outputs a block pack manifest consolidating all references assets into a single folder`;static flags={modulePath:t.Flags.string({char:`i`,summary:`input module path`,helpValue:`<path>`,default:`.`}),destinationPath:t.Flags.string({char:`o`,summary:`output folder`,helpValue:`<path>`,default:`./block-pack`})};async run(){let{flags:t}=await this.parse(r);await e.Q(await e.J(n.default.resolve(t.modulePath)),n.default.resolve(t.destinationPath))}};function m(e,t){let n={...e};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]=m(n[e],t[e]):n[e]=t[e];return n}var h=class o extends t.Command{static description=`Publishes the block package and refreshes the registry (for v2 block-pack schema)`;static flags={registry:t.Flags.string({char:`r`,summary:`full address of the registry`,helpValue:`<address>`,env:`PL_REGISTRY`,required:!0}),manifest:t.Flags.file({char:`m`,summary:`manifest file path`,exists:!0,default:`./block-pack/${e.F}`}),"version-override":t.Flags.file({char:`v`,summary:`override package version`}),refresh:t.Flags.boolean({summary:`refresh repository after adding the package`,default:!0,allowNo:!0,env:`PL_REGISTRY_REFRESH`}),unstable:t.Flags.boolean({summary:`do not add the published package to stable channel`,default:!1,env:`PL_PUBLISH_UNSTABLE`})};async run(){let{flags:t}=await this.parse(o),s=n.default.resolve(t.manifest),c=JSON.parse(await r.default.promises.readFile(s,{encoding:`utf-8`})),l=i.BlockPackManifest.parse(c);l=m(c,l);let u=n.default.dirname(s);this.log(`Manifest root = ${u}`),t[`version-override`]&&(l=(0,i.overrideManifestVersion)(l,t[`version-override`]));let d=new e.b(e._(t.registry),new a.OclifLoggerAdapter(this));await d.publishPackage(l,async e=>Buffer.from(await r.default.promises.readFile(n.default.resolve(u,e)))),t.unstable||(this.log(`Adding package to ${i.StableChannel} channel...`),await d.addPackageToChannel(l.description.id,i.StableChannel)),t.refresh&&await d.updateIfNeeded()}},g=class n extends t.Command{static description=`Refresh overview files based on published but not proecessed artefacts`;static flags={registry:t.Flags.string({char:`r`,summary:`full address of the registry`,helpValue:`<address>`,env:`PL_REGISTRY`,required:!0}),mode:t.Flags.string({char:`m`,summary:`refresh mode (allowed valiues: "force", "normal", "dry-run")`,helpValue:`<mode>`,options:[`force`,`normal`,`dry-run`],env:`PL_REGISTRY_REFRESH_DRY_RUN`,default:`normal`})};async run(){let{flags:t}=await this.parse(n);await new e.b(e._(t.registry),new a.OclifLoggerAdapter(this)).updateIfNeeded(t.mode)}},_=class n extends t.Command{static description=`Restore global overview from a snapshot`;static flags={registry:t.Flags.string({char:`r`,summary:`full address of the registry`,helpValue:`<address>`,env:`PL_REGISTRY`,required:!0}),snapshot:t.Flags.string({char:`s`,summary:`snapshot timestamp ID to restore from`,helpValue:`<timestamp>`,required:!0}),"skip-confirmation":t.Flags.boolean({summary:`skip confirmation prompt (use with caution)`,default:!1})};async run(){let{flags:t}=await this.parse(n),r=new e.b(e._(t.registry),new a.OclifLoggerAdapter(this)),i=await r.listGlobalOverviewSnapshots();if(i.find(e=>e.timestamp===t.snapshot)||this.error(`Snapshot '${t.snapshot}' not found. Available snapshots:\n${i.map(e=>` - ${e.timestamp}`).join(`
|
|
2
2
|
`)||` (none)`}`),!t[`skip-confirmation`]){let e=(await import(`node:readline`)).createInterface({input:process.stdin,output:process.stdout}),n=await new Promise(n=>{e.question(`⚠️ This will overwrite the current global overview with snapshot '${t.snapshot}'.\nAre you sure you want to continue? (y/N): `,n)});if(e.close(),n.toLowerCase()!==`y`&&n.toLowerCase()!==`yes`){this.log(`Restore cancelled.`);return}}try{await r.restoreGlobalOverviewFromSnapshot(t.snapshot),this.log(`✅ Successfully restored global overview from snapshot '${t.snapshot}'`)}catch(e){this.error(`Failed to restore from snapshot: ${String(e)}`)}}};function v(e){let t=e.match(/(?<destName>[^/\\]+)=(?<src>.*)/);if(t){let{src:e,destName:n}=t.groups;return{src:e,destName:n}}else return{src:e,destName:n.default.basename(e)}}var y=t.Flags.custom({summary:`target files to upload`,helpValue:`file_path | package_name=file_path`,parse:async e=>v(e)}),b=[`registry`,`organization`,`package`,`version`],x={"build-meta":c,"build-model":u,"list-overview-snapshots":d,"mark-stable":f,pack:p,publish:h,"refresh-registry":g,"restore-overview-from-snapshot":_,"upload-package-v1":class n extends t.Command{static description=`Uploads V1 package and refreshes the registry`;static flags={registry:t.Flags.string({char:`r`,summary:`full address of the registry or alias from .pl.reg`,helpValue:`<address|alias>`,env:`PL_REGISTRY`}),organization:t.Flags.string({char:`o`,summary:`target organisation`,env:`PL_PACKAGE_ORGANIZATION`}),package:t.Flags.string({char:`p`,summary:`target package`,env:`PL_PACKAGE_NAME`}),version:t.Flags.string({char:`v`,summary:`target version`,env:`PL_PACKAGE_VERSION`}),meta:t.Flags.file({char:`m`,summary:`json file containing meta information to associate with tha package`,exists:!0}),file:y({char:`f`,summary:`package files`,multiple:!0,default:[]}),refresh:t.Flags.boolean({summary:`refresh repository after adding the package`,default:!0,allowNo:!0,env:`PL_REGISTRY_REFRESH`})};async run(){let{flags:t}=await this.parse(n),i=e.p.parse({});for(let e of b)t[e]&&(i[e]=t[e]);t.meta&&(t.meta.endsWith(`.json`)?i.meta=JSON.parse(await r.default.promises.readFile(t.meta,{encoding:`utf-8`})):t.meta.endsWith(`.yaml`)&&(i.meta=o.default.parse(await r.default.promises.readFile(t.meta,{encoding:`utf-8`}))));for(let e of t.file)i.files[e.destName]=e.src;let s=await e.n(i);this.log(o.default.stringify(s.conf));let c=s.createRegistry(new a.OclifLoggerAdapter(this)),l=s.fullPackageName,u=c.constructNewPackage(l);for(let[e,t]of Object.entries(s.conf.files)){this.log(`Uploading ${t} -> ${e} ...`);let n=await r.default.promises.readFile(t);await u.addFile(e,n)}this.log(`Uploading meta information...`),await u.writeMeta(s.conf.meta),await u.finish(),t.refresh&&await c.updateIfNeeded()}},"update-deps":class extends t.Command{static description=`Updates @platforma-sdk and @milaboratories packages in pnpm-workspace.yaml catalog to their latest versions from npm registry.`;static examples=[`<%= config.bin %> <%= command.id %>`];async run(){await(0,s.updatePackages)()}}};exports.COMMANDS=x;
|
|
3
3
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ct as e, F as t, J as n, Q as r, Y as i, _ as a, b as o, n as s, ot as c, p as l, st as u } from "./config-
|
|
1
|
+
import { Ct as e, F as t, J as n, Q as r, Y as i, _ as a, b as o, n as s, ot as c, p as l, st as u } from "./config-C-EJTl6j.mjs";
|
|
2
2
|
import { Command as d, Flags as f } from "@oclif/core";
|
|
3
3
|
import p from "node:path";
|
|
4
4
|
import m from "node:fs";
|
|
@@ -1342,11 +1342,11 @@ var bn = class {
|
|
|
1342
1342
|
}
|
|
1343
1343
|
listCacheTimestamp = 0;
|
|
1344
1344
|
listCache = void 0;
|
|
1345
|
-
async listBlockPacks() {
|
|
1345
|
+
async listBlockPacks(e) {
|
|
1346
1346
|
if (this.listCache !== void 0 && Date.now() - this.listCacheTimestamp <= this.ops.cacheBlockListFor) return this.listCache;
|
|
1347
1347
|
try {
|
|
1348
1348
|
return await O(async () => {
|
|
1349
|
-
let
|
|
1349
|
+
let t = Q.parse(JSON.parse(Buffer.from(await this.v2RootFolderReader.readFile(Qt, { signal: e?.signal })).toString())), n = await Promise.all(t.packages.map(async (e) => {
|
|
1350
1350
|
let t = await Promise.all(Object.entries(e.latestByChannel).map(async ([e, t]) => [e, {
|
|
1351
1351
|
id: t.description.id,
|
|
1352
1352
|
meta: await this.embedMetaContent(t.description.id, t.manifestSha256, !0, t.description.meta),
|
|
@@ -1364,7 +1364,7 @@ var bn = class {
|
|
|
1364
1364
|
allVersions: e.allVersionsWithChannels
|
|
1365
1365
|
};
|
|
1366
1366
|
}));
|
|
1367
|
-
return this.listCache =
|
|
1367
|
+
return this.listCache = n, this.listCacheTimestamp = Date.now(), n;
|
|
1368
1368
|
}, D);
|
|
1369
1369
|
} catch (e) {
|
|
1370
1370
|
if (this.listCache !== void 0 && Date.now() - this.listCacheTimestamp <= this.ops.keepStaleBlockListFor) return this.listCache;
|
|
@@ -1499,9 +1499,12 @@ var wn = class e {
|
|
|
1499
1499
|
constructor(e, t) {
|
|
1500
1500
|
this.rootUrl = e, this.httpDispatcher = t;
|
|
1501
1501
|
}
|
|
1502
|
-
async readFile(e) {
|
|
1503
|
-
let
|
|
1504
|
-
|
|
1502
|
+
async readFile(e, t) {
|
|
1503
|
+
let n = await ye(new URL(e, this.rootUrl), {
|
|
1504
|
+
dispatcher: this.httpDispatcher,
|
|
1505
|
+
signal: t?.signal
|
|
1506
|
+
});
|
|
1507
|
+
return Buffer.from(await n.body.arrayBuffer());
|
|
1505
1508
|
}
|
|
1506
1509
|
relativeReader(t) {
|
|
1507
1510
|
return t.endsWith("/") || (t += "/"), new e(new URL(t, this.rootUrl), this.httpDispatcher);
|
|
@@ -1514,9 +1517,9 @@ var wn = class e {
|
|
|
1514
1517
|
constructor(e, t) {
|
|
1515
1518
|
this.rootUrl = e, this.root = t;
|
|
1516
1519
|
}
|
|
1517
|
-
async readFile(t) {
|
|
1518
|
-
let
|
|
1519
|
-
return await r.readFile(n);
|
|
1520
|
+
async readFile(t, n) {
|
|
1521
|
+
let i = e.join(this.root, ...t.split(k.sep));
|
|
1522
|
+
return await r.readFile(i, { signal: n?.signal });
|
|
1520
1523
|
}
|
|
1521
1524
|
relativeReader(n) {
|
|
1522
1525
|
return n.endsWith("/") || (n += "/"), new t(new URL(n, this.rootUrl), e.join(this.root, ...n.split(k.sep)));
|
|
@@ -1706,4 +1709,4 @@ async function $n(e) {
|
|
|
1706
1709
|
//#endregion
|
|
1707
1710
|
export { Ze as $, Z as A, nn as B, q as C, je as Ct, Qt as D, fn as E, K as F, on as G, sn as H, tn as I, ot as J, an as K, ln as L, gn as M, hn as N, $t as O, Zt as P, tt as Q, rn as R, J as S, Oe as St, dn as T, X as U, cn as V, Y as W, rt as X, at as Y, it as Z, Cn as _, Re as _t, Ln as a, Ue as at, _n as b, N as bt, An as c, Ge as ct, jn as d, Ne as dt, Qe as et, Mn as f, Ie as ft, xn as g, Pe as gt, Sn as h, M as ht, Vn as i, qe as it, Q as j, un as k, Pn as l, Ke as lt, On as m, Fe as mt, $n as n, Ye as nt, zn as o, He as ot, Nn as p, Le as pt, P as q, Bn as r, Je as rt, Rn as s, We as st, Qn as t, Xe as tt, Fn as u, Me as ut, bn as v, Be as vt, pn as w, mn as x, ze as xt, yn as y, Ve as yt, en as z };
|
|
1708
1711
|
|
|
1709
|
-
//# sourceMappingURL=config-
|
|
1712
|
+
//# sourceMappingURL=config-C-EJTl6j.mjs.map
|