@platforma-sdk/block-tools 2.5.59 → 2.5.61

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 CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var O=Object.defineProperty;var L=(o,e,t)=>e in o?O(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var r=(o,e,t)=>L(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@oclif/core"),d=require("node:path"),m=require("node:fs");require("zod");require("mime-types");require("tar");require("@milaboratories/resolve-helper");const i=require("./config-BJeRGQPb.js"),k=require("@milaboratories/pl-model-middle-layer");require("@milaboratories/ts-helpers");require("canonicalize");require("lru-cache");require("undici");require("@milaboratories/pl-http");const F=require("@milaboratories/ts-helpers-oclif"),C=require("yaml"),f=class f extends a.Command{async run(){const{flags:e}=await this.parse(f),t=d.resolve(e.modulePath),s=await i.loadPackDescriptionRaw(t),n=await i.BlockPackMetaEmbedAbsoluteBase64.parseAsync(i.BlockPackMetaDescription(t).parse(s.meta));await m.promises.writeFile(d.resolve(e.destination),JSON.stringify(n))}};r(f,"description","Extracts meta information from blocks package.json and outputs meta.json with embedded binary and textual information linked from the meta section."),r(f,"flags",{modulePath:a.Flags.string({char:"i",summary:"input module path",helpValue:"<path>",default:"."}),destination:a.Flags.string({char:"o",summary:"output meta.json file",helpValue:"<path>",required:!0})});let b=f;async function x(o){try{return await m.promises.readFile(o,"utf8")}catch(e){if(e.code==="ENOENT")return;throw e}}const g=class g extends a.Command{async run(){const{flags:e}=await this.parse(g),t=d.resolve(e.modulePath);let{model:s,platforma:n}=require(t);if(s||(s=n),!s)throw new Error('"model" export not found');const{config:l}=s;if(!l)throw new Error('Malformed "model" object, check it is created with "BlockModel" and ".done()" is executed as the call in the chain.');if(!("canRun"in l||"inputsValid"in l)||!("outputs"in l)||!("sections"in l))throw new Error('"config" has unexpected structure');const u=await x(e.sourceBundle);u!==void 0&&(l.code={type:"plain",content:u}),await m.promises.writeFile(d.resolve(e.destination),JSON.stringify(l))}};r(g,"description","Extracts and outputs block model JSON from pre-built block model module"),r(g,"flags",{modulePath:a.Flags.string({char:"i",summary:"input module path",helpValue:"<path>",default:"."}),sourceBundle:a.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:a.Flags.string({char:"o",summary:"output model file",helpValue:"<path>",default:"./dist/model.json"})});let P=g;const h=class h extends a.Command{async run(){const{flags:e}=await this.parse(h);let t=await i.loadPackDescriptionRaw(d.resolve(e.modulePath));e["version-override"]&&(t=k.overrideDescriptionVersion(t,e["version-override"]));const s=i.storageByUrl(e.registry),n=new i.BlockRegistryV2(s,new F.OclifLoggerAdapter(this));e.unmark?await n.removePackageFromChannel(t.id,e.channel):await n.addPackageToChannel(t.id,e.channel),e.refresh&&await n.updateIfNeeded()}};r(h,"description","Mark target block stable"),r(h,"flags",{modulePath:a.Flags.string({char:"i",summary:"input module path",helpValue:"<path>",default:"."}),channel:a.Flags.string({char:"c",hidden:!0,summary:"custom channel",helpValue:"<channel name>",default:k.StableChannel}),"version-override":a.Flags.file({char:"v",summary:"override package version"}),registry:a.Flags.string({char:"r",summary:"full address of the registry",helpValue:"<address>",env:"PL_REGISTRY",required:!0}),refresh:a.Flags.boolean({summary:"refresh repository after adding the package",default:!0,allowNo:!0,env:"PL_REGISTRY_REFRESH"}),unmark:a.Flags.boolean({summary:'reverses meaning of this command, flag can be used to remove "stable" flag from the package',default:!1})});let R=h;const p=class p extends a.Command{async run(){const{flags:e}=await this.parse(p),t=await i.loadPackDescription(d.resolve(e.modulePath));await i.buildBlockPackDist(t,d.resolve(e.destinationPath))}};r(p,"description","Builds block pack and outputs a block pack manifest consolidating all references assets into a single folder"),r(p,"flags",{modulePath:a.Flags.string({char:"i",summary:"input module path",helpValue:"<path>",default:"."}),destinationPath:a.Flags.string({char:"o",summary:"output folder",helpValue:"<path>",default:"./block-pack"})});let E=p;const y=class y extends a.Command{async run(){const{flags:e}=await this.parse(y),t=d.resolve(e.manifest);let s=k.BlockPackManifest.parse(JSON.parse(await m.promises.readFile(t,{encoding:"utf-8"})));const n=d.dirname(t);this.log(`Manifest root = ${n}`),e["version-override"]&&(s=k.overrideManifestVersion(s,e["version-override"]));const l=i.storageByUrl(e.registry),u=new i.BlockRegistryV2(l,new F.OclifLoggerAdapter(this));await u.publishPackage(s,async c=>Buffer.from(await m.promises.readFile(d.resolve(n,c)))),e.refresh&&await u.updateIfNeeded()}};r(y,"description","Publishes the block package and refreshes the registry (for v2 block-pack schema)"),r(y,"flags",{registry:a.Flags.string({char:"r",summary:"full address of the registry",helpValue:"<address>",env:"PL_REGISTRY",required:!0}),manifest:a.Flags.file({char:"m",summary:"manifest file path",exists:!0,default:`./block-pack/${i.ManifestFileName}`}),"version-override":a.Flags.file({char:"v",summary:"override package version"}),refresh:a.Flags.boolean({summary:"refresh repository after adding the package",default:!0,allowNo:!0,env:"PL_REGISTRY_REFRESH"})});let N=y;const w=class w extends a.Command{async run(){const{flags:e}=await this.parse(w),t=i.storageByUrl(e.registry);await new i.BlockRegistryV2(t,new F.OclifLoggerAdapter(this)).updateIfNeeded(e.mode)}};r(w,"description","Refresh overview files based on published but not proecessed artefacts"),r(w,"flags",{registry:a.Flags.string({char:"r",summary:"full address of the registry",helpValue:"<address>",env:"PL_REGISTRY",required:!0}),mode:a.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"})});let q=w;function I(o){const e=o.match(/(?<destName>[^\/\\]+)=(?<src>.*)/);if(e){const{src:t,destName:s}=e.groups;return{src:t,destName:s}}else return{src:o,destName:d.basename(o)}}const T=a.Flags.custom({summary:"target files to upload",helpValue:"file_path | package_name=file_path",parse:async o=>I(o)}),G=["registry","organization","package","version"],v=class v extends a.Command{async run(){const{flags:e}=await this.parse(v),t=i.PlRegPackageConfigDataShard.parse({});for(const c of G)e[c]&&(t[c]=e[c]);e.meta&&(e.meta.endsWith(".json")?t.meta=JSON.parse(await m.promises.readFile(e.meta,{encoding:"utf-8"})):e.meta.endsWith(".yaml")&&(t.meta=C.parse(await m.promises.readFile(e.meta,{encoding:"utf-8"}))));for(const c of e.file)t.files[c.destName]=c.src;const s=await i.getConfig(t);this.log(C.stringify(s.conf));const n=s.createRegistry(new F.OclifLoggerAdapter(this)),l=s.fullPackageName,u=n.constructNewPackage(l);for(const[c,V]of Object.entries(s.conf.files)){this.log(`Uploading ${V} -> ${c} ...`);const A=await m.promises.readFile(V);await u.addFile(c,A)}this.log("Uploading meta information..."),await u.writeMeta(s.conf.meta),await u.finish(),e.refresh&&await n.updateIfNeeded()}};r(v,"description","Uploads V1 package and refreshes the registry"),r(v,"flags",{registry:a.Flags.string({char:"r",summary:"full address of the registry or alias from .pl.reg",helpValue:"<address|alias>",env:"PL_REGISTRY"}),organization:a.Flags.string({char:"o",summary:"target organisation",env:"PL_PACKAGE_ORGANIZATION"}),package:a.Flags.string({char:"p",summary:"target package",env:"PL_PACKAGE_NAME"}),version:a.Flags.string({char:"v",summary:"target version",env:"PL_PACKAGE_VERSION"}),meta:a.Flags.file({char:"m",summary:"json file containing meta information to associate with tha package",exists:!0}),file:T({char:"f",summary:"package files",multiple:!0,default:[]}),refresh:a.Flags.boolean({summary:"refresh repository after adding the package",default:!0,allowNo:!0,env:"PL_REGISTRY_REFRESH"})});let S=v;const j={"build-meta":b,"build-model":P,"mark-stable":R,pack:E,publish:N,"refresh-registry":q,"upload-package-v1":S};exports.COMMANDS=j;
1
+ "use strict";var O=Object.defineProperty;var L=(o,e,t)=>e in o?O(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var r=(o,e,t)=>L(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@oclif/core"),d=require("node:path"),m=require("node:fs");require("zod");require("mime-types");require("tar");require("@milaboratories/resolve-helper");const i=require("./config-DPNjt6Gf.js"),k=require("@milaboratories/pl-model-middle-layer");require("@milaboratories/ts-helpers");require("canonicalize");require("lru-cache");require("undici");require("@milaboratories/pl-http");const F=require("@milaboratories/ts-helpers-oclif"),C=require("yaml"),f=class f extends a.Command{async run(){const{flags:e}=await this.parse(f),t=d.resolve(e.modulePath),s=await i.loadPackDescriptionRaw(t),n=await i.BlockPackMetaEmbedAbsoluteBase64.parseAsync(i.BlockPackMetaDescription(t).parse(s.meta));await m.promises.writeFile(d.resolve(e.destination),JSON.stringify(n))}};r(f,"description","Extracts meta information from blocks package.json and outputs meta.json with embedded binary and textual information linked from the meta section."),r(f,"flags",{modulePath:a.Flags.string({char:"i",summary:"input module path",helpValue:"<path>",default:"."}),destination:a.Flags.string({char:"o",summary:"output meta.json file",helpValue:"<path>",required:!0})});let b=f;async function x(o){try{return await m.promises.readFile(o,"utf8")}catch(e){if(e.code==="ENOENT")return;throw e}}const g=class g extends a.Command{async run(){const{flags:e}=await this.parse(g),t=d.resolve(e.modulePath);let{model:s,platforma:n}=require(t);if(s||(s=n),!s)throw new Error('"model" export not found');const{config:l}=s;if(!l)throw new Error('Malformed "model" object, check it is created with "BlockModel" and ".done()" is executed as the call in the chain.');if(!("canRun"in l||"inputsValid"in l)||!("outputs"in l)||!("sections"in l))throw new Error('"config" has unexpected structure');const u=await x(e.sourceBundle);u!==void 0&&(l.code={type:"plain",content:u}),await m.promises.writeFile(d.resolve(e.destination),JSON.stringify(l))}};r(g,"description","Extracts and outputs block model JSON from pre-built block model module"),r(g,"flags",{modulePath:a.Flags.string({char:"i",summary:"input module path",helpValue:"<path>",default:"."}),sourceBundle:a.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:a.Flags.string({char:"o",summary:"output model file",helpValue:"<path>",default:"./dist/model.json"})});let P=g;const h=class h extends a.Command{async run(){const{flags:e}=await this.parse(h);let t=await i.loadPackDescriptionRaw(d.resolve(e.modulePath));e["version-override"]&&(t=k.overrideDescriptionVersion(t,e["version-override"]));const s=i.storageByUrl(e.registry),n=new i.BlockRegistryV2(s,new F.OclifLoggerAdapter(this));e.unmark?await n.removePackageFromChannel(t.id,e.channel):await n.addPackageToChannel(t.id,e.channel),e.refresh&&await n.updateIfNeeded()}};r(h,"description","Mark target block stable"),r(h,"flags",{modulePath:a.Flags.string({char:"i",summary:"input module path",helpValue:"<path>",default:"."}),channel:a.Flags.string({char:"c",hidden:!0,summary:"custom channel",helpValue:"<channel name>",default:k.StableChannel}),"version-override":a.Flags.file({char:"v",summary:"override package version"}),registry:a.Flags.string({char:"r",summary:"full address of the registry",helpValue:"<address>",env:"PL_REGISTRY",required:!0}),refresh:a.Flags.boolean({summary:"refresh repository after adding the package",default:!0,allowNo:!0,env:"PL_REGISTRY_REFRESH"}),unmark:a.Flags.boolean({summary:'reverses meaning of this command, flag can be used to remove "stable" flag from the package',default:!1})});let R=h;const p=class p extends a.Command{async run(){const{flags:e}=await this.parse(p),t=await i.loadPackDescription(d.resolve(e.modulePath));await i.buildBlockPackDist(t,d.resolve(e.destinationPath))}};r(p,"description","Builds block pack and outputs a block pack manifest consolidating all references assets into a single folder"),r(p,"flags",{modulePath:a.Flags.string({char:"i",summary:"input module path",helpValue:"<path>",default:"."}),destinationPath:a.Flags.string({char:"o",summary:"output folder",helpValue:"<path>",default:"./block-pack"})});let E=p;const y=class y extends a.Command{async run(){const{flags:e}=await this.parse(y),t=d.resolve(e.manifest);let s=k.BlockPackManifest.parse(JSON.parse(await m.promises.readFile(t,{encoding:"utf-8"})));const n=d.dirname(t);this.log(`Manifest root = ${n}`),e["version-override"]&&(s=k.overrideManifestVersion(s,e["version-override"]));const l=i.storageByUrl(e.registry),u=new i.BlockRegistryV2(l,new F.OclifLoggerAdapter(this));await u.publishPackage(s,async c=>Buffer.from(await m.promises.readFile(d.resolve(n,c)))),e.refresh&&await u.updateIfNeeded()}};r(y,"description","Publishes the block package and refreshes the registry (for v2 block-pack schema)"),r(y,"flags",{registry:a.Flags.string({char:"r",summary:"full address of the registry",helpValue:"<address>",env:"PL_REGISTRY",required:!0}),manifest:a.Flags.file({char:"m",summary:"manifest file path",exists:!0,default:`./block-pack/${i.ManifestFileName}`}),"version-override":a.Flags.file({char:"v",summary:"override package version"}),refresh:a.Flags.boolean({summary:"refresh repository after adding the package",default:!0,allowNo:!0,env:"PL_REGISTRY_REFRESH"})});let N=y;const w=class w extends a.Command{async run(){const{flags:e}=await this.parse(w),t=i.storageByUrl(e.registry);await new i.BlockRegistryV2(t,new F.OclifLoggerAdapter(this)).updateIfNeeded(e.mode)}};r(w,"description","Refresh overview files based on published but not proecessed artefacts"),r(w,"flags",{registry:a.Flags.string({char:"r",summary:"full address of the registry",helpValue:"<address>",env:"PL_REGISTRY",required:!0}),mode:a.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"})});let q=w;function I(o){const e=o.match(/(?<destName>[^\/\\]+)=(?<src>.*)/);if(e){const{src:t,destName:s}=e.groups;return{src:t,destName:s}}else return{src:o,destName:d.basename(o)}}const T=a.Flags.custom({summary:"target files to upload",helpValue:"file_path | package_name=file_path",parse:async o=>I(o)}),G=["registry","organization","package","version"],v=class v extends a.Command{async run(){const{flags:e}=await this.parse(v),t=i.PlRegPackageConfigDataShard.parse({});for(const c of G)e[c]&&(t[c]=e[c]);e.meta&&(e.meta.endsWith(".json")?t.meta=JSON.parse(await m.promises.readFile(e.meta,{encoding:"utf-8"})):e.meta.endsWith(".yaml")&&(t.meta=C.parse(await m.promises.readFile(e.meta,{encoding:"utf-8"}))));for(const c of e.file)t.files[c.destName]=c.src;const s=await i.getConfig(t);this.log(C.stringify(s.conf));const n=s.createRegistry(new F.OclifLoggerAdapter(this)),l=s.fullPackageName,u=n.constructNewPackage(l);for(const[c,V]of Object.entries(s.conf.files)){this.log(`Uploading ${V} -> ${c} ...`);const A=await m.promises.readFile(V);await u.addFile(c,A)}this.log("Uploading meta information..."),await u.writeMeta(s.conf.meta),await u.finish(),e.refresh&&await n.updateIfNeeded()}};r(v,"description","Uploads V1 package and refreshes the registry"),r(v,"flags",{registry:a.Flags.string({char:"r",summary:"full address of the registry or alias from .pl.reg",helpValue:"<address|alias>",env:"PL_REGISTRY"}),organization:a.Flags.string({char:"o",summary:"target organisation",env:"PL_PACKAGE_ORGANIZATION"}),package:a.Flags.string({char:"p",summary:"target package",env:"PL_PACKAGE_NAME"}),version:a.Flags.string({char:"v",summary:"target version",env:"PL_PACKAGE_VERSION"}),meta:a.Flags.file({char:"m",summary:"json file containing meta information to associate with tha package",exists:!0}),file:T({char:"f",summary:"package files",multiple:!0,default:[]}),refresh:a.Flags.boolean({summary:"refresh repository after adding the package",default:!0,allowNo:!0,env:"PL_REGISTRY_REFRESH"})});let S=v;const j={"build-meta":b,"build-model":P,"mark-stable":R,pack:E,publish:N,"refresh-registry":q,"upload-package-v1":S};exports.COMMANDS=j;
2
2
  //# sourceMappingURL=cli.js.map
package/dist/cli.mjs CHANGED
@@ -8,7 +8,7 @@ import "zod";
8
8
  import "mime-types";
9
9
  import "tar";
10
10
  import "@milaboratories/resolve-helper";
11
- import { l as L, B as T, a as Y, s as V, b as x, c as j, d as D, M, P as q, g as B } from "./config-7hVPHpfZ.mjs";
11
+ import { l as L, B as T, a as Y, s as V, b as x, c as j, d as D, M, P as q, g as B } from "./config-Bg6-2Pd-.mjs";
12
12
  import { StableChannel as J, overrideDescriptionVersion as H, BlockPackManifest as _, overrideManifestVersion as $ } from "@milaboratories/pl-model-middle-layer";
13
13
  import "@milaboratories/ts-helpers";
14
14
  import "canonicalize";
@@ -1664,7 +1664,7 @@ class $n {
1664
1664
  try {
1665
1665
  const r = this.toAbsolutePath(e);
1666
1666
  return (await K.promises.readdir(r, { recursive: !0, withFileTypes: !0 })).filter((s) => s.isFile()).map(
1667
- (s) => B.relative(r, B.resolve(s.path, s.name)).split(B.sep).join(U.sep)
1667
+ (s) => B.relative(r, B.resolve(s.parentPath, s.name)).split(B.sep).join(U.sep)
1668
1668
  );
1669
1669
  } catch (r) {
1670
1670
  if (r.code == "ENOENT") return [];
@@ -1932,4 +1932,4 @@ export {
1932
1932
  _r as y,
1933
1933
  ss as z
1934
1934
  };
1935
- //# sourceMappingURL=config-7hVPHpfZ.mjs.map
1935
+ //# sourceMappingURL=config-Bg6-2Pd-.mjs.map