@seed-hypermedia/cli 0.0.9 → 0.0.11

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 (2) hide show
  1. package/dist/index.js +29 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -72606,8 +72606,19 @@ async function createCapability2(input, signer) {
72606
72606
  unsigned.sig = await signObject(signer, unsigned);
72607
72607
  return toPublishInput(encode4(unsigned));
72608
72608
  }
72609
+ async function resolveCapability2(client, targetAccount, signerAccount) {
72610
+ if (targetAccount === signerAccount)
72611
+ return;
72612
+ const targetId = unpackHmId(`hm://${targetAccount}`);
72613
+ if (!targetId)
72614
+ return;
72615
+ const caps = await client.request("ListCapabilities", { targetId });
72616
+ const match = caps.capabilities.find((c) => c.delegate === signerAccount && (c.role === "WRITER" || c.role === "AGENT"));
72617
+ return match?.id;
72618
+ }
72609
72619
  var init_capability = __esm(() => {
72610
72620
  init_src();
72621
+ init_hm_types();
72611
72622
  init_base58();
72612
72623
  init_signing();
72613
72624
  });
@@ -138323,6 +138334,7 @@ __export(exports_src2, {
138323
138334
  resolveHypermediaUrl: () => resolveHypermediaUrl,
138324
138335
  resolveFileLinksInBlocks: () => resolveFileLinksInBlocks2,
138325
138336
  resolveDocumentState: () => resolveDocumentState2,
138337
+ resolveCapability: () => resolveCapability2,
138326
138338
  pushSpanToAnnotation: () => pushSpanToAnnotation2,
138327
138339
  processFulltextDocument: () => processFulltextDocument2,
138328
138340
  pdfToBlocks: () => pdfToBlocks2,
@@ -165698,7 +165710,7 @@ function registerDocumentCommands(program2) {
165698
165710
  process.exit(1);
165699
165711
  }
165700
165712
  });
165701
- doc.command("create").description("Create a new document from markdown, JSON blocks, or PDF").option("-f, --file <path>", "Input file (format detected by extension: .md, .json, .pdf)").option("-p, --path <path>", 'Document path (e.g. "my-document")').option("--name <value>", "Document title (overrides frontmatter)").option("--summary <value>", "Document summary").option("--display-author <value>", 'Display author name (e.g. "Jane Doe")').option("--display-publish-time <value>", "Display publish time (YYYY-MM-DD)").option("--icon <value>", "Document icon (ipfs:// or file:// URL)").option("--cover <value>", "Cover image (ipfs:// or file:// URL)").option("--site-url <value>", "Site URL").option("--layout <value>", 'Document layout (e.g. "Seed/Experimental/Newspaper")').option("--show-outline", "Show document outline").option("--no-show-outline", "Hide document outline").option("--show-activity", "Show document activity").option("--no-show-activity", "Hide document activity").option("--content-width <value>", "Content width (S, M, L)").option("--seed-experimental-logo <value>", "Experimental logo (ipfs:// or file:// URL)").option("--seed-experimental-home-order <value>", "Home ordering (UpdatedFirst, CreatedFirst)").option("--import-categories <value>", "Import categories (comma-separated)").option("--import-tags <value>", "Import tags (comma-separated)").option("--grobid-url <url>", "GROBID server URL for PDF extraction").option("--dry-run", "Preview extracted content without publishing").option("--force", "Overwrite existing document at the same path (creates new lineage)").option("-k, --key <name>", "Signing key name or account ID").action(async (options2, cmd) => {
165713
+ doc.command("create").description("Create a new document from markdown, JSON blocks, or PDF").option("-f, --file <path>", "Input file (format detected by extension: .md, .json, .pdf)").option("-p, --path <path>", 'Document path (e.g. "my-document")').option("--name <value>", "Document title (overrides frontmatter)").option("--summary <value>", "Document summary").option("--display-author <value>", 'Display author name (e.g. "Jane Doe")').option("--display-publish-time <value>", "Display publish time (YYYY-MM-DD)").option("--icon <value>", "Document icon (ipfs:// or file:// URL)").option("--cover <value>", "Cover image (ipfs:// or file:// URL)").option("--site-url <value>", "Site URL").option("--layout <value>", 'Document layout (e.g. "Seed/Experimental/Newspaper")').option("--show-outline", "Show document outline").option("--no-show-outline", "Hide document outline").option("--show-activity", "Show document activity").option("--no-show-activity", "Hide document activity").option("--content-width <value>", "Content width (S, M, L)").option("--seed-experimental-logo <value>", "Experimental logo (ipfs:// or file:// URL)").option("--seed-experimental-home-order <value>", "Home ordering (UpdatedFirst, CreatedFirst)").option("--import-categories <value>", "Import categories (comma-separated)").option("--import-tags <value>", "Import tags (comma-separated)").option("--grobid-url <url>", "GROBID server URL for PDF extraction").option("--dry-run", "Preview extracted content without publishing").option("--force", "Overwrite existing document at the same path (creates new lineage)").option("-k, --key <name>", "Signing key name or account ID").option("-a, --account <uid>", "Target space/account UID (publish under a different account using a capability)").action(async (options2, cmd) => {
165702
165714
  const globalOpts = cmd.optsWithGlobals();
165703
165715
  const dev = !!globalOpts.dev;
165704
165716
  try {
@@ -165730,7 +165742,14 @@ function registerDocumentCommands(program2) {
165730
165742
  }
165731
165743
  const client = getClient(globalOpts);
165732
165744
  const key = resolveKey(options2.key, dev);
165733
- const account = key.accountId;
165745
+ const account = options2.account || key.accountId;
165746
+ let capability;
165747
+ if (options2.account && options2.account !== key.accountId) {
165748
+ capability = await resolveCapability2(client, options2.account, key.accountId);
165749
+ if (!capability) {
165750
+ throw new Error(`No WRITER or AGENT capability found for key ${key.accountId} on account ${options2.account}. ` + `Use "account capabilities hm://${options2.account}" to check available capabilities.`);
165751
+ }
165752
+ }
165734
165753
  const { metadata: resolvedMeta, blobs: metaBlobs } = await resolveMetadataFileLinks(metadata);
165735
165754
  const rawPath = options2.path || slugify2(resolvedMeta.name || "Untitled");
165736
165755
  const path = rawPath.startsWith("/") ? rawPath : `/${rawPath}`;
@@ -165768,7 +165787,8 @@ function registerDocumentCommands(program2) {
165768
165787
  path,
165769
165788
  genesis: genesisBlock.cid.toString(),
165770
165789
  version: changeBlock.cid.toString(),
165771
- generation
165790
+ generation,
165791
+ capability
165772
165792
  }, signer);
165773
165793
  await client.publish({
165774
165794
  blobs: [
@@ -165856,6 +165876,7 @@ function registerDocumentCommands(program2) {
165856
165876
  const depCids = state.heads.map((h2) => CID.parse(h2));
165857
165877
  const newDepth = state.headDepth + 1;
165858
165878
  const signer = createSignerFromKey(key);
165879
+ const capability = await resolveCapability2(client, docAccount, key.accountId);
165859
165880
  const { unsignedBytes, ts } = createChangeOps({ ops, genesisCid, deps: depCids, depth: newDepth });
165860
165881
  const changeBlock = await createChange(unsignedBytes, signer);
165861
165882
  const generation = Number(ts);
@@ -165864,7 +165885,8 @@ function registerDocumentCommands(program2) {
165864
165885
  path: docPath,
165865
165886
  genesis: state.genesis,
165866
165887
  version: changeBlock.cid.toString(),
165867
- generation
165888
+ generation,
165889
+ capability
165868
165890
  }, signer);
165869
165891
  await client.publish({
165870
165892
  blobs: [
@@ -165898,11 +165920,13 @@ function registerDocumentCommands(program2) {
165898
165920
  }
165899
165921
  const doc2 = resource.document;
165900
165922
  const generation = doc2.generationInfo ? Number(doc2.generationInfo.generation) : 0;
165923
+ const capability = await resolveCapability2(client, unpacked.uid, key.accountId);
165901
165924
  const refInput = await createTombstoneRef({
165902
165925
  space: unpacked.uid,
165903
165926
  path: hmIdPathToEntityQueryPath3(unpacked.path),
165904
165927
  genesis: doc2.genesis,
165905
- generation
165928
+ generation,
165929
+ capability
165906
165930
  }, signer);
165907
165931
  await client.publish(refInput);
165908
165932
  if (!globalOpts.quiet)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-hypermedia/cli",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/seed-hypermedia/seed.git",