@siglume/api-sdk 2.0.4 → 3.0.0

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.
@@ -1506,12 +1506,6 @@ function parseListing(data) {
1506
1506
  seller_display_name: stringOrNull(data.seller_display_name),
1507
1507
  seller_homepage_url: stringOrNull(data.seller_homepage_url),
1508
1508
  seller_social_url: stringOrNull(data.seller_social_url),
1509
- publisher_type: stringOrNull(data.publisher_type),
1510
- publisher_company_id: stringOrNull(data.publisher_company_id),
1511
- company_id: stringOrNull(data.company_id),
1512
- company_name: stringOrNull(data.company_name),
1513
- company_publish_status: stringOrNull(data.company_publish_status),
1514
- company_terms_version: stringOrNull(data.company_terms_version),
1515
1509
  review_status: stringOrNull(data.review_status),
1516
1510
  review_note: stringOrNull(data.review_note),
1517
1511
  submission_blockers: Array.isArray(data.submission_blockers) ? data.submission_blockers.filter((item) => typeof item === "string") : [],
@@ -1521,29 +1515,6 @@ function parseListing(data) {
1521
1515
  raw: { ...data }
1522
1516
  };
1523
1517
  }
1524
- function parseCompanyPublisher(data) {
1525
- const wallets = Array.isArray(data.settlement_wallets) ? data.settlement_wallets.filter((item) => isRecord(item)) : [];
1526
- return {
1527
- company_id: String(data.company_id ?? data.id ?? ""),
1528
- name: String(data.name ?? ""),
1529
- status: String(data.status ?? ""),
1530
- description: stringOrNull(data.description),
1531
- is_founder: Boolean(data.is_founder ?? false),
1532
- membership_role: stringOrNull(data.membership_role),
1533
- membership_status: stringOrNull(data.membership_status),
1534
- can_publish: Boolean(data.can_publish ?? true),
1535
- can_approve: Boolean(data.can_approve ?? false),
1536
- approval_required: Boolean(data.approval_required ?? false),
1537
- paid_listing_allowed: Boolean(data.paid_listing_allowed ?? false),
1538
- disabled_reasons: Array.isArray(data.disabled_reasons) ? data.disabled_reasons.filter((item) => typeof item === "string") : [],
1539
- company_terms_version: stringOrNull(data.company_terms_version),
1540
- active_listing_count: Number(data.active_listing_count ?? 0),
1541
- pending_approval_count: Number(data.pending_approval_count ?? 0),
1542
- settlement_wallet_ready: Boolean(data.settlement_wallet_ready ?? false),
1543
- settlement_wallets: wallets.map((item) => ({ ...item })),
1544
- raw: { ...data }
1545
- };
1546
- }
1547
1518
  function parseCapabilitySaveState(data) {
1548
1519
  return {
1549
1520
  capability_key: String(data.capability_key ?? ""),
@@ -2458,9 +2429,6 @@ var init_client = __esm({
2458
2429
  "support_contact",
2459
2430
  "seller_homepage_url",
2460
2431
  "seller_social_url",
2461
- "publisher_type",
2462
- "company_id",
2463
- "publisher_company_id",
2464
2432
  "store_vertical",
2465
2433
  "jurisdiction",
2466
2434
  "price_model",
@@ -2534,25 +2502,6 @@ var init_client = __esm({
2534
2502
  );
2535
2503
  }
2536
2504
  }
2537
- const explicitPublisherType = payload.publisher_type !== void 0 && payload.publisher_type !== null;
2538
- const companyId = String(payload.company_id ?? "").trim() || String(payload.publisher_company_id ?? "").trim();
2539
- const publisherType = String(payload.publisher_type ?? "user").trim().toLowerCase();
2540
- if (publisherType !== "user" && publisherType !== "company") {
2541
- throw new SiglumeClientError("AppManifest.publisher_type must be 'user' or 'company'.");
2542
- }
2543
- if (publisherType === "company" && !companyId) {
2544
- throw new SiglumeClientError("AppManifest.company_id is required when publisher_type='company'.");
2545
- }
2546
- if (publisherType === "user" && companyId) {
2547
- throw new SiglumeClientError("AppManifest.company_id cannot be combined with publisher_type='user'.");
2548
- }
2549
- if (explicitPublisherType || companyId) {
2550
- payload.publisher_type = publisherType;
2551
- }
2552
- if (companyId) {
2553
- payload.company_id = companyId;
2554
- payload.publisher_company_id = companyId;
2555
- }
2556
2505
  validateManifestPersistenceContract(payload);
2557
2506
  if (payload.manifest && typeof payload.manifest === "object") {
2558
2507
  delete payload.manifest.version;
@@ -2660,25 +2609,6 @@ var init_client = __esm({
2660
2609
  const [data] = await this.request("GET", `/market/capabilities/${listing_id}`);
2661
2610
  return parseListing(data);
2662
2611
  }
2663
- async list_company_publishers() {
2664
- const [data] = await this.request("GET", "/market/company-publishers");
2665
- return Array.isArray(data.items) ? data.items.filter((item) => isRecord(item)).map(parseCompanyPublisher) : [];
2666
- }
2667
- async request_company_publish_approval(listing_id, note) {
2668
- const [data] = await this.request("POST", `/market/capabilities/${listing_id}/company-publish-approval`, {
2669
- json_body: note ? { note } : {}
2670
- });
2671
- return parseListing(data);
2672
- }
2673
- async decide_company_publish_approval(listing_id, options) {
2674
- const [data] = await this.request("POST", `/market/capabilities/${listing_id}/company-publish-approval/decision`, {
2675
- json_body: {
2676
- decision: options.decision,
2677
- ...options.reason ? { reason: options.reason } : {}
2678
- }
2679
- });
2680
- return parseListing(data);
2681
- }
2682
2612
  async get_capability_state(capability_key, save_key = "default") {
2683
2613
  const [data] = await this.request("GET", `/market/capability-state/${capability_key}/${save_key}`);
2684
2614
  return parseCapabilitySaveState(data);
@@ -6937,12 +6867,7 @@ function ensureManifestPublisherIdentity(project) {
6937
6867
  const sellerHomepageUrl = String(manifestPayload.seller_homepage_url ?? "").trim();
6938
6868
  const sellerSocialUrl = String(manifestPayload.seller_social_url ?? "").trim();
6939
6869
  const jurisdiction = String(manifestPayload.jurisdiction ?? "").trim();
6940
- const companyId = String(manifestPayload.company_id ?? "").trim() || String(manifestPayload.publisher_company_id ?? "").trim();
6941
- const publisherType = String(manifestPayload.publisher_type ?? "user").trim().toLowerCase();
6942
6870
  const issues = [];
6943
- if (companyId && publisherType !== "company") {
6944
- issues.push('manifest.company_id requires manifest.publisher_type to be "company"');
6945
- }
6946
6871
  if (!docsUrl) {
6947
6872
  issues.push("manifest.docs_url is required");
6948
6873
  } else if (looksLikePlaceholder(docsUrl)) {
@@ -7102,108 +7027,23 @@ ${errors.map((error) => `- ${error}`).join("\n")}`
7102
7027
  }
7103
7028
  return preflight;
7104
7029
  }
7105
- function companyNameSlug(value) {
7106
- return value.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
7107
- }
7108
7030
  async function runRegistration(path = ".", options = {}, deps = {}) {
7109
7031
  const project = await loadProject(path);
7110
- let requestedCompanyId = String(options.company_id ?? "").trim();
7111
- const requestedCompanySlug = String(options.company_slug ?? "").trim();
7112
- let companyPublisherCandidates = null;
7113
- if (requestedCompanySlug) {
7114
- if (requestedCompanyId) {
7115
- throw new SiglumeProjectError("--company and --company-slug cannot be combined.");
7116
- }
7117
- const slug = companyNameSlug(requestedCompanySlug);
7118
- if (!slug && requestedCompanySlug !== requestedCompanyId) {
7119
- throw new SiglumeProjectError(`Company slug ${requestedCompanySlug} is not slug-compatible; use --company <company_id> instead.`);
7120
- }
7121
- }
7122
- if (requestedCompanyId) {
7123
- project.manifest = {
7124
- ...project.manifest,
7125
- publisher_type: "company",
7126
- company_id: requestedCompanyId,
7127
- publisher_company_id: requestedCompanyId
7128
- };
7129
- }
7130
7032
  ensureExplicitToolManual(project);
7131
7033
  ensureManifestPublisherIdentity(project);
7132
7034
  ensureRuntimeValidationReady(project);
7133
7035
  const client = await createClient(deps);
7134
- if (requestedCompanySlug) {
7135
- const slug = companyNameSlug(requestedCompanySlug);
7136
- companyPublisherCandidates = await client.list_company_publishers();
7137
- const matches = companyPublisherCandidates.filter(
7138
- (item) => companyNameSlug(item.name || item.company_id) === slug || item.company_id === requestedCompanySlug
7139
- );
7140
- if (matches.length === 0) {
7141
- throw new SiglumeProjectError(`Company slug ${requestedCompanySlug} is not available to this API key.`);
7142
- }
7143
- if (matches.length > 1) {
7144
- throw new SiglumeProjectError(`Company slug ${requestedCompanySlug} is ambiguous; use --company <company_id> instead.`);
7145
- }
7146
- const match = matches[0];
7147
- if (!match) {
7148
- throw new SiglumeProjectError(`Company slug ${requestedCompanySlug} is not available to this API key.`);
7149
- }
7150
- if (match.can_publish === false) {
7151
- const disabledReasons = match.disabled_reasons ?? [];
7152
- const reasons = disabledReasons.length > 0 ? disabledReasons.join(", ") : "company publisher is disabled";
7153
- throw new SiglumeProjectError(`Company ${match.company_id} cannot publish: ${reasons}.`);
7154
- }
7155
- requestedCompanyId = match.company_id;
7156
- project.manifest = {
7157
- ...project.manifest,
7158
- publisher_type: "company",
7159
- company_id: requestedCompanyId,
7160
- publisher_company_id: requestedCompanyId
7161
- };
7162
- }
7163
7036
  const preflight = await registrationPreflight(project, client);
7164
- let companyPublisherPreflight = null;
7165
- const companyId = String(project.manifest.company_id ?? "").trim() || String(project.manifest.publisher_company_id ?? "").trim();
7166
- const publisherType = String(project.manifest.publisher_type ?? "user").toLowerCase();
7167
- if (publisherType === "company") {
7168
- if (!companyId) {
7169
- throw new SiglumeProjectError("Company registration requires --company <company_id> or manifest.company_id.");
7170
- }
7171
- const companies = companyPublisherCandidates ?? await client.list_company_publishers();
7172
- companyPublisherCandidates = companies;
7173
- const company = companies.find((item) => item.company_id === companyId);
7174
- if (!company) {
7175
- throw new SiglumeProjectError(`Company ${companyId} is not available to this API key.`);
7176
- }
7177
- if (company.can_publish === false) {
7178
- const disabledReasons = company.disabled_reasons ?? [];
7179
- const reasons = disabledReasons.length > 0 ? disabledReasons.join(", ") : "company publisher is disabled";
7180
- throw new SiglumeProjectError(`Company ${companyId} cannot publish: ${reasons}.`);
7181
- }
7182
- companyPublisherPreflight = company;
7183
- }
7184
7037
  let developerPortalPreflight = null;
7185
7038
  if (String(project.manifest.price_model ?? "free").toLowerCase() !== "free") {
7186
- if (publisherType === "company") {
7187
- const company = companyPublisherPreflight;
7188
- if (!company) {
7189
- throw new SiglumeProjectError(`Company ${companyId} is not available to this API key.`);
7190
- }
7191
- if (company.settlement_wallet_ready !== true) {
7192
- throw new SiglumeProjectError(
7193
- `Paid company registration requires a verified company settlement wallet for ${company.name}. Open the company settings and complete settlement readiness before registering.`
7194
- );
7195
- }
7196
- developerPortalPreflight = { company_publisher: toJsonable(company) };
7197
- } else {
7198
- const portal = await client.get_developer_portal();
7199
- const verifiedDestination = portal.payout_readiness?.verified_destination;
7200
- if (verifiedDestination !== true) {
7201
- throw new SiglumeProjectError(
7202
- "Paid API registration requires a verified Polygon payout destination. Open https://siglume.com/owner/credits/payout and confirm the embedded-wallet payout token, or call GET /v1/market/developer/portal until payout_readiness.verified_destination is true."
7203
- );
7204
- }
7205
- developerPortalPreflight = toJsonable(portal);
7039
+ const portal = await client.get_developer_portal();
7040
+ const verifiedDestination = portal.payout_readiness?.verified_destination;
7041
+ if (verifiedDestination !== true) {
7042
+ throw new SiglumeProjectError(
7043
+ "Paid API registration requires a verified Polygon payout destination. Open https://siglume.com/owner/credits/payout and confirm the embedded-wallet payout token, or call GET /v1/market/developer/portal until payout_readiness.verified_destination is true."
7044
+ );
7206
7045
  }
7046
+ developerPortalPreflight = toJsonable(portal);
7207
7047
  }
7208
7048
  const receipt = await client.auto_register(project.manifest, project.tool_manual, {
7209
7049
  runtime_validation: project.runtime_validation
@@ -7272,14 +7112,6 @@ async function getUsageReport(options, deps = {}) {
7272
7112
  count: items.length
7273
7113
  };
7274
7114
  }
7275
- async function listCompanyPublishersReport(deps = {}) {
7276
- const client = await createClient(deps);
7277
- const companies = await client.list_company_publishers();
7278
- return {
7279
- companies: companies.map((item) => toJsonable(item)),
7280
- count: companies.length
7281
- };
7282
- }
7283
7115
  async function diffJsonFiles(oldPath, newPath) {
7284
7116
  const oldPayload = await loadJsonDocument(oldPath);
7285
7117
  const newPayload = await loadJsonDocument(newPath);
@@ -8348,24 +8180,6 @@ function renderOperationTable(operations) {
8348
8180
  ...rows.map((row) => row.map((cell, index) => cell.padEnd(widths[index] ?? cell.length)).join(" "))
8349
8181
  ];
8350
8182
  }
8351
- function renderCompanyTable(companies) {
8352
- const rows = companies.map((item) => [
8353
- String(item.company_id ?? item.id ?? ""),
8354
- String(item.name ?? ""),
8355
- String(item.membership_role ?? (item.is_founder ? "founder" : "")),
8356
- String(item.settlement_wallet_ready === true ? "ready" : "not_ready"),
8357
- String(item.pending_approval_count ?? 0)
8358
- ]);
8359
- const headers = ["company_id", "name", "role", "settlement", "pending"];
8360
- const widths = headers.map(
8361
- (header, index) => Math.max(header.length, ...rows.map((row) => row[index]?.length ?? 0))
8362
- );
8363
- return [
8364
- headers.map((header, index) => header.padEnd(widths[index] ?? header.length)).join(" "),
8365
- widths.map((width) => "-".repeat(width)).join(" "),
8366
- ...rows.map((row) => row.map((cell, index) => cell.padEnd(widths[index] ?? cell.length)).join(" "))
8367
- ];
8368
- }
8369
8183
  async function runCli(argv, deps = {}) {
8370
8184
  const stdout = deps.stdout;
8371
8185
  const stderr = deps.stderr ?? console.error;
@@ -8521,21 +8335,7 @@ async function runCli(argv, deps = {}) {
8521
8335
  }
8522
8336
  if (report.runtime_validation_path) emit(stdout, `runtime_validation_path: ${String(report.runtime_validation_path)}`);
8523
8337
  });
8524
- program.command("companies").description("List Siglume companies available for company-name publishing.").option("--json", "emit machine-readable JSON", false).action(async (options) => {
8525
- const report = await listCompanyPublishersReport(deps);
8526
- if (options.json) {
8527
- emit(stdout, renderJson(report));
8528
- return;
8529
- }
8530
- const companies = Array.isArray(report.companies) ? report.companies.filter((item) => Boolean(item && typeof item === "object")) : [];
8531
- if (companies.length === 0) {
8532
- emit(stdout, "No company publishers available for this API key.");
8533
- return;
8534
- }
8535
- emit(stdout, "Company publishers");
8536
- renderCompanyTable(companies).forEach((line) => emit(stdout, line));
8537
- });
8538
- program.command("register").option("--confirm", "explicitly confirm the registration; this is the default unless --draft-only is set", false).option("--draft-only", "create or refresh the draft without confirming publication", false).option("--submit-review", "legacy alias: publish immediately if your environment still routes through submit-review", false).option("--company <companyId>", "publish under a Siglume company name; revenue is split equally among active members", "").option("--company-slug <slug>", "publish under a Siglume company by matching the slugified company name", "").option("--json", "emit machine-readable JSON", false).argument("[path]", ".", "project path").action(async (path, options) => {
8338
+ program.command("register").option("--confirm", "explicitly confirm the registration; this is the default unless --draft-only is set", false).option("--draft-only", "create or refresh the draft without confirming publication", false).option("--submit-review", "legacy alias: publish immediately if your environment still routes through submit-review", false).option("--json", "emit machine-readable JSON", false).argument("[path]", ".", "project path").action(async (path, options) => {
8539
8339
  const draftOnly = Boolean(options.draftOnly);
8540
8340
  if (draftOnly && options.confirm) {
8541
8341
  throw new SiglumeProjectError("--draft-only cannot be combined with --confirm.");
@@ -8547,9 +8347,7 @@ async function runCli(argv, deps = {}) {
8547
8347
  const report = await runRegistration(path, {
8548
8348
  confirm: shouldConfirm,
8549
8349
  draft_only: draftOnly,
8550
- submit_review: options.submitReview,
8551
- company_id: options.company,
8552
- company_slug: options.companySlug
8350
+ submit_review: options.submitReview
8553
8351
  }, deps);
8554
8352
  if (options.json) {
8555
8353
  emit(stdout, renderJson(report));