@verentis/cli 0.2.18 → 0.2.20

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/README.md CHANGED
@@ -213,16 +213,17 @@ repositories:
213
213
  ```bash
214
214
  verentis create application my-app
215
215
  verentis create engine my-python-engine
216
- verentis create bundle sample-data
217
- verentis create canvas-component starter-widgets
218
216
  ```
219
217
 
220
- The initial mappings are `@verentis/template-application`,
221
- `@verentis/template-engine`, `@verentis/template-bundle`, and
222
- `@verentis/template-canvas-component`. Use `--package` for a compatible
223
- third-party template, `--version` to pin it, and `--registry` for a private
224
- npm registry. Templates are installed with `npm pack --ignore-scripts` and
225
- support `{{name}}` and `{{type}}` substitutions.
218
+ The supported mappings are `@verentis/template-application` and
219
+ `@verentis/template-engine`. Use `--package` for a compatible third-party
220
+ template, `--version` to pin it, and `--registry` for a private npm registry.
221
+ Templates are installed with `npm pack --ignore-scripts` and support
222
+ `{{name}}` and `{{type}}` substitutions.
223
+
224
+ Package manifests must declare both `metadata.package-id` (the immutable
225
+ Marketplace coordinate) and `metadata.name` (the runtime/install identity).
226
+ Commands that accept `publisher/package` references use the package ID.
226
227
 
227
228
  ```bash
228
229
  verentis publisher create --name acme --display-name "Acme Inc."
package/dist/index.js CHANGED
@@ -316,7 +316,9 @@ var SCOPES = {
316
316
  packageCreate: "marketplace.package.create",
317
317
  packagePublish: "marketplace.package.publish",
318
318
  installCreate: "marketplace.install.create",
319
- installDelete: "marketplace.install.delete"
319
+ installDelete: "marketplace.install.delete",
320
+ resourceReadAll: "resources.resource.read-all",
321
+ resourceUpdate: "resources.resource.update"
320
322
  };
321
323
 
322
324
  // src/api/scopes.ts
@@ -815,22 +817,16 @@ function registerApiKey(program2) {
815
817
  var execFileAsync = promisify(execFile);
816
818
  var TEMPLATE_PACKAGES = {
817
819
  application: "@verentis/template-application",
818
- engine: "@verentis/template-engine",
819
- bundle: "@verentis/template-bundle",
820
- "canvas-component": "@verentis/template-canvas-component"
820
+ engine: "@verentis/template-engine"
821
821
  };
822
822
  function normalizeTemplateType(value) {
823
823
  const normalized = value.trim().toLowerCase().replace(/[_\s]+/g, "-");
824
- if (normalized === "canvas" || normalized === "component" || normalized === "canvas-pack") {
825
- return "canvas-component";
826
- }
827
824
  if (normalized === "app") return "application";
828
825
  if (normalized === "execution-engine") return "engine";
829
- if (normalized === "bundle") return "bundle";
830
- if (normalized === "application" || normalized === "engine" || normalized === "canvas-component") {
826
+ if (normalized === "application" || normalized === "engine") {
831
827
  return normalized;
832
828
  }
833
- throw new Error(`Unknown template type '${value}' \u2014 use application, engine, bundle or canvas-component.`);
829
+ throw new Error(`Unknown template type '${value}' \u2014 use application or engine.`);
834
830
  }
835
831
  async function createFromTemplate(typeValue, name, destination, options = {}) {
836
832
  const type = normalizeTemplateType(typeValue);
@@ -982,7 +978,9 @@ async function loadManifest(path) {
982
978
  if (!manifest || typeof manifest !== "object") throw new Error(`Failed to parse manifest at ${path}.`);
983
979
  if (!manifest.kind) throw new Error(`Manifest at ${path} is missing 'kind'.`);
984
980
  if (!manifest.metadata?.name) throw new Error(`Manifest at ${path} is missing 'metadata.name'.`);
981
+ if (!manifest.metadata?.["package-id"]) throw new Error(`Manifest at ${path} is missing 'metadata.package-id'.`);
985
982
  if (!manifest.metadata?.version) throw new Error(`Manifest at ${path} is missing 'metadata.version'.`);
983
+ validatePackageName(manifest.metadata["package-id"], "package ID");
986
984
  const kind = normalizeKind(manifest.kind);
987
985
  const launchKindError = validateLaunchManifestKind(kind, manifest.spec);
988
986
  if (launchKindError) throw new Error(`Invalid manifest at ${path}: ${launchKindError}.`);
@@ -1147,6 +1145,11 @@ function validateManifest(manifest) {
1147
1145
  for (const field of ["name", "display-name", "version"]) {
1148
1146
  if (!meta[field]) error(`metadata.${field} is required`);
1149
1147
  }
1148
+ if (!meta["package-id"]) {
1149
+ error("metadata.package-id is required");
1150
+ } else if (!NAME_PATTERN.test(meta["package-id"])) {
1151
+ error("metadata.package-id must use lowercase letters, digits and internal hyphens");
1152
+ }
1150
1153
  const spec = manifest.spec ?? {};
1151
1154
  validateManifestIcons(meta, spec, issues);
1152
1155
  const launchKindError = validateLaunchManifestKind(kind, spec);
@@ -1854,6 +1857,7 @@ kind: Application
1854
1857
 
1855
1858
  metadata:
1856
1859
  name: ${name}
1860
+ package-id: ${name}
1857
1861
  display-name: ${titleCase(name)}
1858
1862
  description: ""
1859
1863
  icon: layout-dashboard
@@ -1905,6 +1909,7 @@ kind: ExecutionEngine
1905
1909
 
1906
1910
  metadata:
1907
1911
  name: ${name}
1912
+ package-id: ${name}
1908
1913
  display-name: ${titleCase(name)}
1909
1914
  description: ""
1910
1915
  icon: lucide:terminal
@@ -1941,6 +1946,7 @@ kind: Bundle
1941
1946
 
1942
1947
  metadata:
1943
1948
  name: ${name}
1949
+ package-id: ${name}
1944
1950
  display-name: ${titleCase(name)}
1945
1951
  description: ""
1946
1952
  version: 0.1.0
@@ -2058,18 +2064,19 @@ async function requireMyPublisher(api) {
2058
2064
  }
2059
2065
  return publisher;
2060
2066
  }
2061
- async function findPackageByName(api, publisherId, name) {
2067
+ async function findPackageByPackageId(api, publisherId, packageId) {
2062
2068
  const page = await api.request("GET", `/v1/publishers/${publisherId}/packages`, {
2063
2069
  scopes: [SCOPES.packageRead],
2064
2070
  query: { PageNo: 1, PageSize: 100 }
2065
2071
  });
2066
- return pageItems2(page).find((pkg) => pkg.name === name) ?? null;
2072
+ return pageItems2(page).find((pkg) => pkg.packageId === packageId) ?? null;
2067
2073
  }
2068
2074
  async function createPackage(api, input) {
2069
2075
  return api.request("POST", "/v1/packages", {
2070
2076
  scopes: [SCOPES.packageCreate],
2071
2077
  body: {
2072
2078
  publisherId: input.publisherId,
2079
+ packageId: input.packageId,
2073
2080
  name: input.name,
2074
2081
  displayName: input.displayName,
2075
2082
  kind: input.kind,
@@ -2102,19 +2109,19 @@ async function downloadTarball(api, packageId, version, workspaceId) {
2102
2109
  });
2103
2110
  }
2104
2111
  async function resolvePackageRef(api, ref) {
2105
- const [publisherName, packageName] = ref.includes("/") ? ref.split("/", 2) : [void 0, ref];
2112
+ const [publisherName, packageId] = ref.includes("/") ? ref.split("/", 2) : [void 0, ref];
2106
2113
  if (!publisherName) {
2107
2114
  const me = await requireMyPublisher(api);
2108
- const pkg2 = await findPackageByName(api, me.id, packageName);
2109
- if (!pkg2) throw new Error(`Package '${packageName}' not found under your publisher '${me.name}'.`);
2115
+ const pkg2 = await findPackageByPackageId(api, me.id, packageId);
2116
+ if (!pkg2) throw new Error(`Package '${packageId}' not found under your publisher '${me.name}'.`);
2110
2117
  return { package: pkg2, publisherName: me.name };
2111
2118
  }
2112
2119
  const page = await api.request("GET", "/v1/packages", {
2113
2120
  scopes: [SCOPES.packageReadAll],
2114
- query: { SearchText: packageName, PageNo: 1, PageSize: 100 }
2121
+ query: { SearchText: packageId, PageNo: 1, PageSize: 100 }
2115
2122
  });
2116
- const pkg = pageItems2(page).find((p) => p.name === packageName && p.publisherName === publisherName);
2117
- if (!pkg) throw new Error(`Package '${publisherName}/${packageName}' not found (or not visible to you).`);
2123
+ const pkg = pageItems2(page).find((p) => p.packageId === packageId && p.publisherName === publisherName);
2124
+ if (!pkg) throw new Error(`Package '${publisherName}/${packageId}' not found (or not visible to you).`);
2118
2125
  return { package: pkg, publisherName };
2119
2126
  }
2120
2127
 
@@ -2581,6 +2588,10 @@ async function pack(options) {
2581
2588
  }
2582
2589
  let manifest = overlay ? applyOverlay(base, overlay) : base;
2583
2590
  let overrideApplied = overlayPath !== void 0 || options.bumpVersion === true;
2591
+ if (options.name !== void 0) {
2592
+ manifest = { ...manifest, metadata: { ...manifest.metadata, "package-id": options.name } };
2593
+ overrideApplied = true;
2594
+ }
2584
2595
  if (options.version !== void 0) {
2585
2596
  manifest = { ...manifest, metadata: { ...manifest.metadata, version: options.version } };
2586
2597
  overrideApplied = true;
@@ -2590,9 +2601,11 @@ async function pack(options) {
2590
2601
  if (launchKindError) throw new Error(`Invalid manifest: ${launchKindError}.`);
2591
2602
  const marketplaceErrors = validateMarketplaceSection(manifest.marketplace);
2592
2603
  if (marketplaceErrors.length > 0) throw new Error(`Invalid marketplace section: ${marketplaceErrors.join(" ")}`);
2593
- const name = (options.name ?? manifest.packaging?.name ?? manifest.metadata.name).toLowerCase();
2604
+ const packageId = manifest.metadata["package-id"].toLowerCase();
2605
+ const name = manifest.metadata.name.toLowerCase();
2594
2606
  const publisher = options.publisher.toLowerCase();
2595
- validatePackageName(name, "package name");
2607
+ validatePackageName(packageId, "package ID");
2608
+ validatePackageName(name, "runtime name");
2596
2609
  validatePackageName(publisher, "publisher name");
2597
2610
  const version = manifest.metadata.version;
2598
2611
  const payloadFiles = await resolvePayloadFiles(projectDir, manifestPath, manifest);
@@ -2638,6 +2651,7 @@ async function pack(options) {
2638
2651
  const digestsJson = JSON.stringify({ algorithm: "sha256", entries: digests }, null, 2);
2639
2652
  await writeFile(join(staging, ".verentis", "digests.json"), digestsJson);
2640
2653
  const packageYaml = [
2654
+ `package-id: ${packageId}`,
2641
2655
  `name: ${name}`,
2642
2656
  `publisher: ${publisher}`,
2643
2657
  `version: ${version}`,
@@ -2655,7 +2669,7 @@ async function pack(options) {
2655
2669
  const outDir = resolve(options.outDir ?? projectDir);
2656
2670
  await mkdir(outDir, { recursive: true });
2657
2671
  const environmentSuffix = options.env ? `-${options.env}` : "";
2658
- const outFile = join(outDir, `${name}${environmentSuffix}-${version}.vpkg`);
2672
+ const outFile = join(outDir, `${packageId}${environmentSuffix}-${version}.vpkg`);
2659
2673
  const entries = [
2660
2674
  "manifest.yaml",
2661
2675
  ".verentis/package.yaml",
@@ -2668,6 +2682,7 @@ async function pack(options) {
2668
2682
  await tar.create({ gzip: true, file: outFile, cwd: staging, portable: true, mtime: /* @__PURE__ */ new Date(0) }, entries);
2669
2683
  return {
2670
2684
  outFile,
2685
+ packageId,
2671
2686
  name,
2672
2687
  publisher,
2673
2688
  version,
@@ -2752,6 +2767,9 @@ async function readVpkg(vpkgPath) {
2752
2767
  throw new Error("Invalid package: missing .verentis/digests.json.");
2753
2768
  });
2754
2769
  const metadata = parse(packageYaml);
2770
+ if (!metadata?.["package-id"]) {
2771
+ throw new Error("Invalid package: .verentis/package.yaml is missing package-id.");
2772
+ }
2755
2773
  const declared = JSON.parse(digestsJson);
2756
2774
  const files2 = await listFiles(staging, "files/**/*");
2757
2775
  const catalogFiles = await listFiles(staging, "catalog/**/*");
@@ -2828,7 +2846,7 @@ async function readJsonIfExists(path) {
2828
2846
 
2829
2847
  // src/commands/pack.ts
2830
2848
  function registerPack(program2) {
2831
- program2.command("pack [dir]").description("Build a signed .vpkg from a project directory").option("--manifest <path>", "manifest path (default: auto-detected in the project directory)").option("--publisher <name>", "publisher name (default: packaging.publisher in the manifest)").option("--name <name>", "override the package name").option("--env <name>", "merge a per-environment overlay (environments/<name>.yaml) before packing").option("--overlay <path>", "merge an explicit overlay file before packing (wins over --env)").option("--set-version <version>", "override metadata.version (e.g. a CI-derived build number)").option("--bump-version", "increment metadata.version.patch and update the manifest").option("--bump", "alias for --bump-version").option("--out <dir>", "output directory (default: the project directory)").option("--key <name>", "signing key name (default: the configured default key)").option("--no-sign", "produce an unsigned package").option("--encrypt", "seal the payload (AES-256-GCM); requires at least one recipient").option("--recipient <id=base64key...>", "additional X25519 recipient (repeatable)", collectRecipients, []).action(async (dir, options) => {
2849
+ program2.command("pack [dir]").description("Build a signed .vpkg from a project directory").option("--manifest <path>", "manifest path (default: auto-detected in the project directory)").option("--publisher <name>", "publisher name (default: packaging.publisher in the manifest)").option("--name <name>", "override metadata.package-id").option("--env <name>", "merge a per-environment overlay (environments/<name>.yaml) before packing").option("--overlay <path>", "merge an explicit overlay file before packing (wins over --env)").option("--set-version <version>", "override metadata.version (e.g. a CI-derived build number)").option("--bump-version", "increment metadata.version.patch and update the manifest").option("--bump", "alias for --bump-version").option("--out <dir>", "output directory (default: the project directory)").option("--key <name>", "signing key name (default: the configured default key)").option("--no-sign", "produce an unsigned package").option("--encrypt", "seal the payload (AES-256-GCM); requires at least one recipient").option("--recipient <id=base64key...>", "additional X25519 recipient (repeatable)", collectRecipients, []).action(async (dir, options) => {
2832
2850
  const projectDir = resolve(dir ?? ".");
2833
2851
  const manifestPath = options.manifest ? resolve(options.manifest) : await findManifest(projectDir);
2834
2852
  const manifest = await loadManifest(manifestPath);
@@ -2871,7 +2889,7 @@ function registerPack(program2) {
2871
2889
  signingKey,
2872
2890
  encryptFor
2873
2891
  });
2874
- console.log(`Packed ${result.publisher}/${result.name}@${result.version} (${result.kind})`);
2892
+ console.log(`Packed ${result.publisher}/${result.packageId}@${result.version} (${result.kind})`);
2875
2893
  console.log(` ${result.outFile}`);
2876
2894
  console.log(` ${result.files.length} payload file(s), tree digest ${result.treeDigest.slice(0, 16)}\u2026, ${result.signed ? "signed" : "UNSIGNED"}${result.encrypted ? ", ENCRYPTED" : ""}`);
2877
2895
  if (result.catalog) console.log(` ${result.catalogFiles.length} plaintext catalog file(s)`);
@@ -2884,7 +2902,7 @@ function registerPack(program2) {
2884
2902
  });
2885
2903
  program2.command("verify <vpkg>").description("Verify the digests (and, when possible, the developer signature) of a .vpkg").option("--key <name>", "verify the developer signature against a local key").action(async (vpkgPath, options) => {
2886
2904
  const contents = await readVpkg(resolve(vpkgPath));
2887
- console.log(`${contents.metadata.publisher}/${contents.metadata.name}@${contents.metadata.version} (${contents.metadata.kind})`);
2905
+ console.log(`${contents.metadata.publisher}/${contents.metadata["package-id"]}@${contents.metadata.version} (${contents.metadata.kind})`);
2888
2906
  console.log(` payload files: ${contents.files.length}, catalog files: ${contents.catalogFiles.length}, tree digest ${contents.treeDigest.slice(0, 16)}\u2026`);
2889
2907
  if (contents.catalog) {
2890
2908
  const docs = Number(!!contents.catalog.readme) + Number(!!contents.catalog.changelog);
@@ -2934,9 +2952,9 @@ function registerPackage(program2) {
2934
2952
  params: { publisherId: publisher.id },
2935
2953
  query: { PageNo: 1, PageSize: 100 }
2936
2954
  });
2937
- output(pageItems(page), { name: "Name", kind: "Kind", visibility: "Visibility", latestPublishedVersion: "Latest", id: "Id" }, options, page);
2955
+ output(pageItems(page), { packageId: "Package", name: "Runtime", kind: "Kind", visibility: "Visibility", latestPublishedVersion: "Latest", id: "Id" }, options, page);
2938
2956
  });
2939
- pkgCmd.command("info <ref>").description("Show package details (ref: 'name' or 'publisher/name')").option("--json", "output JSON").action(async (ref, options) => {
2957
+ pkgCmd.command("info <ref>").description("Show package details (ref: 'package-id' or 'publisher/package-id')").option("--json", "output JSON").action(async (ref, options) => {
2940
2958
  const api = await createApiClient();
2941
2959
  const { package: pkg } = await resolvePackageRef(api, ref);
2942
2960
  const detail = await call(api, marketplace.getPackage, { params: { id: pkg.id } });
@@ -3215,21 +3233,22 @@ function registerRegistry(program2) {
3215
3233
  if (publisher.name !== contents.metadata.publisher) {
3216
3234
  throw new Error(`Package declares publisher '${contents.metadata.publisher}' but you are '${publisher.name}'.`);
3217
3235
  }
3218
- let pkg = await findPackageByName(api, publisher.id, contents.metadata.name);
3236
+ let pkg = await findPackageByPackageId(api, publisher.id, contents.metadata["package-id"]);
3219
3237
  if (!pkg) {
3220
3238
  const visibility = options.visibility === "Public" ? "Public" : "Private";
3221
3239
  const id = await createPackage(api, {
3222
3240
  publisherId: publisher.id,
3241
+ packageId: contents.metadata["package-id"],
3223
3242
  name: contents.metadata.name,
3224
3243
  displayName: contents.metadata["display-name"] ?? contents.metadata.name,
3225
3244
  kind: contents.metadata.kind,
3226
3245
  visibility
3227
3246
  });
3228
- console.log(`Created package ${publisher.name}/${contents.metadata.name} (${visibility.toLowerCase()}).`);
3247
+ console.log(`Created package ${publisher.name}/${contents.metadata["package-id"]} (${visibility.toLowerCase()}).`);
3229
3248
  pkg = { id };
3230
3249
  }
3231
3250
  const version = await uploadVersion(api, pkg.id, selectedPath);
3232
- console.log(`Published ${publisher.name}/${contents.metadata.name}@${version.version} \u2192 ${version.status}`);
3251
+ console.log(`Published ${publisher.name}/${contents.metadata["package-id"]}@${version.version} \u2192 ${version.status}`);
3233
3252
  if (version.status === "Submitted") {
3234
3253
  console.log("The version is queued for moderation; it becomes installable once approved and published.");
3235
3254
  }
@@ -3246,7 +3265,7 @@ function registerRegistry(program2) {
3246
3265
  const effectiveVersion = version ?? pkg.latestPublishedVersion ?? void 0;
3247
3266
  if (!effectiveVersion) throw new Error(`Package '${ref}' has no published version.`);
3248
3267
  const res = await downloadTarball(api, pkg.id, effectiveVersion, options.workspace);
3249
- const outPath = resolve(options.out ?? `${pkg.name}-${effectiveVersion}.vpkg`);
3268
+ const outPath = resolve(options.out ?? `${pkg.packageId}-${effectiveVersion}.vpkg`);
3250
3269
  if (!res.body) throw new Error("Empty download response.");
3251
3270
  await pipeline(Readable.fromWeb(res.body), createWriteStream(outPath));
3252
3271
  console.log(`Downloaded ${ref}@${effectiveVersion} \u2192 ${outPath}`);
@@ -3264,7 +3283,7 @@ function registerRegistry(program2) {
3264
3283
  }
3265
3284
  for (const pkg of items) {
3266
3285
  const version = pkg.latestPublishedVersion ? `@${pkg.latestPublishedVersion}` : " (no published version)";
3267
- console.log(`${pkg.publisherName}/${pkg.name}${version} \u2014 ${pkg.displayName} [${pkg.kind}, ${pkg.visibility.toLowerCase()}]`);
3286
+ console.log(`${pkg.publisherName}/${pkg.packageId}${version} \u2014 ${pkg.displayName} [${pkg.kind}, ${pkg.visibility.toLowerCase()}]`);
3268
3287
  }
3269
3288
  });
3270
3289
  program2.command("install <ref> [version]").description("Install a package into a workspace").option("--workspace <workspaceId>", "target workspace (default: configured default workspace)").option("--path <path>", "install path override (bundles)").option("--branch <branch>", "workspace branch", "main").option("--sealed", "install as a sealed tarball instead of extracting").action(async (ref, version, options) => {
@@ -3274,9 +3293,13 @@ function registerRegistry(program2) {
3274
3293
  const api = await createApiClient();
3275
3294
  const { package: pkg } = await resolvePackageRef(api, ref);
3276
3295
  const installationId = await api.request("POST", "/v1/installations", {
3277
- // Marketplace forwards this token to Node for the extraction, so it needs
3278
- // the node scope and must be bound to the target workspace.
3279
- scopes: [SCOPES.installCreate, "node.node.create"],
3296
+ // Marketplace forwards this workspace-bound token to Node for extraction
3297
+ // and to Resource for the administrator's consent decision.
3298
+ scopes: [
3299
+ SCOPES.installCreate,
3300
+ "node.node.create",
3301
+ ...pkg.kind === "Application" ? [SCOPES.resourceReadAll, SCOPES.resourceUpdate] : []
3302
+ ],
3280
3303
  tokenWorkspaceId: workspaceId,
3281
3304
  body: {
3282
3305
  workspaceId,