@siglume/api-sdk 0.10.0 → 0.10.2

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/index.js CHANGED
@@ -340,10 +340,8 @@ var init_webhooks = __esm({
340
340
  "subscription.cancelled",
341
341
  "subscription.paused",
342
342
  "subscription.reinstated",
343
- "refund.issued",
344
343
  "payment.succeeded",
345
344
  "payment.failed",
346
- "payment.disputed",
347
345
  "capability.published",
348
346
  "capability.delisted",
349
347
  "execution.completed",
@@ -561,18 +559,6 @@ function camelCaseFromCapabilityKey(capabilityKey) {
561
559
  }
562
560
  return `${words.map((word) => word[0].toUpperCase() + word.slice(1)).join("")}App`;
563
561
  }
564
- function buildDefaultI18n(manifestPayload) {
565
- const job = String(manifestPayload.job_to_be_done ?? "").trim();
566
- const shortDescription = String(
567
- manifestPayload.short_description ?? manifestPayload.job_to_be_done ?? manifestPayload.name ?? ""
568
- ).trim();
569
- return {
570
- job_to_be_done_en: job,
571
- job_to_be_done_ja: job,
572
- short_description_en: shortDescription,
573
- short_description_ja: shortDescription
574
- };
575
- }
576
562
  function buildRegistrationStubSource(manifestPayload, toolManualPayload) {
577
563
  const capabilityKey = String(manifestPayload.capability_key ?? "generated-registration");
578
564
  const jobToBeDone = String(
@@ -1639,6 +1625,7 @@ function parseListing(data) {
1639
1625
  price_value_minor: Number(data.price_value_minor ?? 0),
1640
1626
  currency: String(data.currency ?? "USD"),
1641
1627
  short_description: stringOrNull2(data.short_description),
1628
+ description: stringOrNull2(data.description),
1642
1629
  docs_url: stringOrNull2(data.docs_url),
1643
1630
  support_contact: stringOrNull2(data.support_contact),
1644
1631
  seller_display_name: stringOrNull2(data.seller_display_name),
@@ -1663,19 +1650,6 @@ function parseBundleMember(data) {
1663
1650
  link_id: stringOrNull2(data.link_id)
1664
1651
  };
1665
1652
  }
1666
- function parseConnectedAccountProvider(data) {
1667
- return {
1668
- provider_key: String(data.provider_key ?? ""),
1669
- display_name: String(data.display_name ?? ""),
1670
- auth_type: String(data.auth_type ?? "oauth2"),
1671
- refresh_supported: Boolean(data.refresh_supported ?? false),
1672
- pkce_required: Boolean(data.pkce_required ?? false),
1673
- default_scopes: Array.isArray(data.default_scopes) ? data.default_scopes.filter((s) => typeof s === "string") : [],
1674
- available_scopes: Array.isArray(data.available_scopes) ? data.available_scopes.filter((s) => typeof s === "string") : [],
1675
- scope_separator: String(data.scope_separator ?? " "),
1676
- notes: stringOrNull2(data.notes)
1677
- };
1678
- }
1679
1653
  function parseConnectedAccountLifecycle(data) {
1680
1654
  return {
1681
1655
  connected_account_id: String(data.connected_account_id ?? ""),
@@ -2717,50 +2691,6 @@ function parseMarketProposalActionResult(execution) {
2717
2691
  raw: { ...execution.raw }
2718
2692
  };
2719
2693
  }
2720
- function parseRefund(data) {
2721
- return {
2722
- refund_id: String(data.refund_id ?? data.id ?? ""),
2723
- receipt_id: String(data.receipt_id ?? ""),
2724
- owner_user_id: stringOrNull2(data.owner_user_id) ?? void 0,
2725
- payment_mandate_id: stringOrNull2(data.payment_mandate_id) ?? void 0,
2726
- usage_event_id: stringOrNull2(data.usage_event_id) ?? void 0,
2727
- chain_receipt_id: stringOrNull2(data.chain_receipt_id) ?? void 0,
2728
- amount_minor: Number(data.amount_minor ?? 0),
2729
- currency: String(data.currency ?? "USD"),
2730
- status: String(data.status ?? "issued"),
2731
- reason_code: String(data.reason_code ?? "customer-request"),
2732
- note: stringOrNull2(data.note) ?? void 0,
2733
- idempotency_key: stringOrNull2(data.idempotency_key) ?? void 0,
2734
- on_chain_tx_hash: stringOrNull2(data.on_chain_tx_hash) ?? void 0,
2735
- metadata: toRecord2(data.metadata),
2736
- idempotent_replay: Boolean(data.idempotent_replay ?? false),
2737
- created_at: stringOrNull2(data.created_at) ?? void 0,
2738
- updated_at: stringOrNull2(data.updated_at) ?? void 0,
2739
- raw: { ...data }
2740
- };
2741
- }
2742
- function parseDispute(data) {
2743
- return {
2744
- dispute_id: String(data.dispute_id ?? data.id ?? ""),
2745
- receipt_id: String(data.receipt_id ?? ""),
2746
- owner_user_id: stringOrNull2(data.owner_user_id) ?? void 0,
2747
- payment_mandate_id: stringOrNull2(data.payment_mandate_id) ?? void 0,
2748
- usage_event_id: stringOrNull2(data.usage_event_id) ?? void 0,
2749
- external_dispute_id: stringOrNull2(data.external_dispute_id) ?? void 0,
2750
- status: String(data.status ?? "open"),
2751
- reason_code: String(data.reason_code ?? "manual-review"),
2752
- description: stringOrNull2(data.description) ?? void 0,
2753
- evidence: toRecord2(data.evidence),
2754
- response_decision: stringOrNull2(data.response_decision) ?? void 0,
2755
- response_note: stringOrNull2(data.response_note) ?? void 0,
2756
- responded_at: stringOrNull2(data.responded_at) ?? void 0,
2757
- metadata: toRecord2(data.metadata),
2758
- idempotent_replay: Boolean(data.idempotent_replay ?? false),
2759
- created_at: stringOrNull2(data.created_at) ?? void 0,
2760
- updated_at: stringOrNull2(data.updated_at) ?? void 0,
2761
- raw: { ...data }
2762
- };
2763
- }
2764
2694
  function cloneJsonLike(value) {
2765
2695
  if (Array.isArray(value)) {
2766
2696
  return value.map((item) => cloneJsonLike(item));
@@ -2845,10 +2775,13 @@ var init_client = __esm({
2845
2775
  async auto_register(manifest, tool_manual, options = {}) {
2846
2776
  const manifestPayload = coerceMapping(manifest, "manifest");
2847
2777
  const toolManualPayload = coerceMapping(tool_manual, "tool_manual");
2778
+ const toolManualForRequest = { ...toolManualPayload };
2779
+ const embeddedInputFormSpec = toolManualForRequest.input_form_spec;
2780
+ delete toolManualForRequest.input_form_spec;
2781
+ const inputFormSpec = options.input_form_spec ?? embeddedInputFormSpec;
2848
2782
  const payload = {
2849
- i18n: buildDefaultI18n(manifestPayload),
2850
2783
  manifest: { ...manifestPayload },
2851
- tool_manual: { ...toolManualPayload }
2784
+ tool_manual: toolManualForRequest
2852
2785
  };
2853
2786
  if (options.source_url) {
2854
2787
  payload.source_url = options.source_url;
@@ -2867,14 +2800,11 @@ var init_client = __esm({
2867
2800
  )
2868
2801
  } : coerceMapping(options.oauth_credentials, "oauth_credentials");
2869
2802
  }
2870
- if (options.metadata) {
2871
- payload.metadata = coerceMapping(options.metadata, "metadata");
2872
- }
2873
2803
  if (options.source_context) {
2874
2804
  payload.source_context = coerceMapping(options.source_context, "source_context");
2875
2805
  }
2876
- if (options.input_form_spec) {
2877
- payload.input_form_spec = coerceMapping(options.input_form_spec, "input_form_spec");
2806
+ if (inputFormSpec !== void 0 && inputFormSpec !== null) {
2807
+ payload.input_form_spec = coerceMapping(inputFormSpec, "input_form_spec");
2878
2808
  }
2879
2809
  for (const fieldName of [
2880
2810
  "capability_key",
@@ -2925,7 +2855,11 @@ var init_client = __esm({
2925
2855
  if (!listing_id) {
2926
2856
  throw new SiglumeClientError("Siglume auto-register response did not include listing_id.");
2927
2857
  }
2928
- this.pendingConfirmations.set(listing_id, { manifest: manifestPayload, tool_manual: toolManualPayload });
2858
+ this.pendingConfirmations.set(listing_id, {
2859
+ manifest: manifestPayload,
2860
+ tool_manual: toRecord2(payload.tool_manual),
2861
+ input_form_spec: toRecord2(payload.input_form_spec)
2862
+ });
2929
2863
  return {
2930
2864
  listing_id,
2931
2865
  status: String(data.status ?? "draft"),
@@ -3073,11 +3007,6 @@ var init_client = __esm({
3073
3007
  // ----- end bundles -------------------------------------------------------
3074
3008
  // ----- Connected accounts (v0.7 track 3) ---------------------------------
3075
3009
  // `resolve()` is intentionally NOT wrapped: runtime-only, never over the wire.
3076
- async list_connected_account_providers() {
3077
- const [data] = await this.request("GET", "/me/connected-accounts/providers");
3078
- const items = Array.isArray(data.items) ? data.items : [];
3079
- return items.filter((item) => isRecord2(item)).map(parseConnectedAccountProvider);
3080
- }
3081
3010
  async start_connected_account_oauth(input) {
3082
3011
  const body = {
3083
3012
  listing_id: input.listing_id,
@@ -3114,8 +3043,17 @@ var init_client = __esm({
3114
3043
  const body = {
3115
3044
  provider_key: input.provider_key,
3116
3045
  client_id: input.client_id,
3117
- client_secret: input.client_secret
3046
+ client_secret: input.client_secret,
3047
+ authorize_url: input.authorize_url,
3048
+ token_url: input.token_url
3118
3049
  };
3050
+ if (input.revoke_url !== void 0) body.revoke_url = input.revoke_url;
3051
+ if (input.display_name !== void 0) body.display_name = input.display_name;
3052
+ if (input.scope_separator !== void 0) body.scope_separator = input.scope_separator;
3053
+ if (input.token_endpoint_auth !== void 0) body.token_endpoint_auth = input.token_endpoint_auth;
3054
+ if (input.pkce_required !== void 0) body.pkce_required = input.pkce_required;
3055
+ if (input.refresh_supported !== void 0) body.refresh_supported = input.refresh_supported;
3056
+ if (input.available_scopes !== void 0) body.available_scopes = input.available_scopes;
3119
3057
  if (input.required_scopes !== void 0) body.required_scopes = input.required_scopes;
3120
3058
  const [data] = await this.request("PUT", `/market/capabilities/${listing_id}/oauth-credentials`, {
3121
3059
  json_body: body
@@ -4520,105 +4458,6 @@ ${details}` : summary;
4520
4458
  fetchNext: next_cursor ? (cursor) => this.list_support_cases({ ...options, cursor }) : void 0
4521
4459
  });
4522
4460
  }
4523
- async issue_partial_refund(options) {
4524
- const receipt_id = String(options.receipt_id ?? "").trim();
4525
- const idempotency_key = String(options.idempotency_key ?? "").trim();
4526
- if (!receipt_id) {
4527
- throw new SiglumeClientError("receipt_id is required.");
4528
- }
4529
- if (!idempotency_key) {
4530
- throw new SiglumeClientError("idempotency_key is required.");
4531
- }
4532
- if (!Number.isFinite(options.amount_minor)) {
4533
- throw new SiglumeClientError("amount_minor must be a finite number.");
4534
- }
4535
- const amount_minor = Math.trunc(options.amount_minor);
4536
- if (amount_minor <= 0) {
4537
- throw new SiglumeClientError("amount_minor must be positive.");
4538
- }
4539
- if (typeof options.original_amount_minor === "number" && amount_minor > Math.trunc(options.original_amount_minor)) {
4540
- throw new SiglumeClientError("amount_minor cannot exceed the original receipt amount.");
4541
- }
4542
- const [data] = await this.request("POST", "/market/refunds", {
4543
- json_body: {
4544
- receipt_id,
4545
- amount_minor,
4546
- reason_code: options.reason ?? "customer-request",
4547
- note: options.note,
4548
- idempotency_key
4549
- }
4550
- });
4551
- return parseRefund(data);
4552
- }
4553
- async issue_full_refund(options) {
4554
- const receipt_id = String(options.receipt_id ?? "").trim();
4555
- if (!receipt_id) {
4556
- throw new SiglumeClientError("receipt_id is required.");
4557
- }
4558
- const provided_key = String(options.idempotency_key ?? "").trim();
4559
- const idempotency_key = provided_key || `full-refund:${receipt_id}`;
4560
- const [data] = await this.request("POST", "/market/refunds", {
4561
- json_body: {
4562
- receipt_id,
4563
- reason_code: options.reason ?? "customer-request",
4564
- note: options.note,
4565
- idempotency_key
4566
- }
4567
- });
4568
- return parseRefund(data);
4569
- }
4570
- async list_refunds(options = {}) {
4571
- const [data] = await this.requestAny("GET", "/market/refunds", {
4572
- params: {
4573
- receipt_id: options.receipt_id,
4574
- limit: Math.max(1, Math.min(Math.trunc(options.limit ?? 50), 100))
4575
- }
4576
- });
4577
- if (!Array.isArray(data)) {
4578
- throw new SiglumeClientError("Expected refunds to be returned as an array.");
4579
- }
4580
- return data.filter((item) => isRecord2(item)).map(parseRefund);
4581
- }
4582
- async get_refund(refund_id) {
4583
- const [data] = await this.request("GET", `/market/refunds/${refund_id}`);
4584
- return parseRefund(data);
4585
- }
4586
- async get_refunds_for_receipt(receipt_id, options = {}) {
4587
- return this.list_refunds({ receipt_id, limit: options.limit });
4588
- }
4589
- async list_disputes(options = {}) {
4590
- const [data] = await this.requestAny("GET", "/market/disputes", {
4591
- params: {
4592
- receipt_id: options.receipt_id,
4593
- limit: Math.max(1, Math.min(Math.trunc(options.limit ?? 50), 100))
4594
- }
4595
- });
4596
- if (!Array.isArray(data)) {
4597
- throw new SiglumeClientError("Expected disputes to be returned as an array.");
4598
- }
4599
- return data.filter((item) => isRecord2(item)).map(parseDispute);
4600
- }
4601
- async get_dispute(dispute_id) {
4602
- const [data] = await this.request("GET", `/market/disputes/${dispute_id}`);
4603
- return parseDispute(data);
4604
- }
4605
- async respond_to_dispute(options) {
4606
- const dispute_id = String(options.dispute_id ?? "").trim();
4607
- if (!dispute_id) {
4608
- throw new SiglumeClientError("dispute_id is required.");
4609
- }
4610
- if (!isRecord2(options.evidence)) {
4611
- throw new SiglumeClientError("evidence must be an object.");
4612
- }
4613
- const [data] = await this.request("POST", `/market/disputes/${dispute_id}/respond`, {
4614
- json_body: {
4615
- response: options.response,
4616
- evidence: toRecord2(options.evidence),
4617
- note: options.note
4618
- }
4619
- });
4620
- return parseDispute(data);
4621
- }
4622
4461
  async create_webhook_subscription(options) {
4623
4462
  const normalizedEventTypes = options.event_types.map((item) => String(item).trim()).filter((item) => item.length > 0);
4624
4463
  if (normalizedEventTypes.length === 0) {
@@ -6484,42 +6323,6 @@ function toRecord3(value) {
6484
6323
  init_metering();
6485
6324
  init_operations();
6486
6325
 
6487
- // src/refunds.ts
6488
- init_client();
6489
- var RefundClient = class {
6490
- client;
6491
- constructor(options) {
6492
- this.client = new SiglumeClient(options);
6493
- }
6494
- close() {
6495
- this.client.close();
6496
- }
6497
- async issue_partial_refund(options) {
6498
- return this.client.issue_partial_refund(options);
6499
- }
6500
- async issue_full_refund(options) {
6501
- return this.client.issue_full_refund(options);
6502
- }
6503
- async list_refunds(options = {}) {
6504
- return this.client.list_refunds(options);
6505
- }
6506
- async get_refund(refund_id) {
6507
- return this.client.get_refund(refund_id);
6508
- }
6509
- async get_refunds_for_receipt(receipt_id, options = {}) {
6510
- return this.client.get_refunds_for_receipt(receipt_id, options);
6511
- }
6512
- async list_disputes(options = {}) {
6513
- return this.client.list_disputes(options);
6514
- }
6515
- async get_dispute(dispute_id) {
6516
- return this.client.get_dispute(dispute_id);
6517
- }
6518
- async respond_to_dispute(options) {
6519
- return this.client.respond_to_dispute(options);
6520
- }
6521
- };
6522
-
6523
6326
  // src/types.ts
6524
6327
  var PermissionClass = {
6525
6328
  READ_ONLY: "read-only",
@@ -6573,26 +6376,6 @@ var SettlementMode = {
6573
6376
  POLYGON_MANDATE: "polygon_mandate",
6574
6377
  EMBEDDED_WALLET_CHARGE: "embedded_wallet_charge"
6575
6378
  };
6576
- var RefundReason = {
6577
- CUSTOMER_REQUEST: "customer-request",
6578
- DUPLICATE: "duplicate",
6579
- FRAUDULENT: "fraudulent",
6580
- SERVICE_FAILURE: "service-failure",
6581
- GOODWILL: "goodwill"
6582
- };
6583
- var DisputeResponse = {
6584
- ACCEPT: "accept",
6585
- CONTEST: "contest"
6586
- };
6587
- var RefundStatus = {
6588
- ISSUED: "issued",
6589
- FAILED: "failed"
6590
- };
6591
- var DisputeStatus = {
6592
- OPEN: "open",
6593
- ACCEPTED: "accepted",
6594
- CONTESTED: "contested"
6595
- };
6596
6379
 
6597
6380
  // src/testing/recorder.ts
6598
6381
  var CASSETTE_VERSION = 1;
@@ -7014,16 +6797,24 @@ function coerceToolManual2(manual) {
7014
6797
  }
7015
6798
  function checkSchemaForbiddenRecursive(schema, rootField2, pushIssue, path = "") {
7016
6799
  for (const keyword of COMPOSITION_KEYWORDS) {
7017
- if (keyword in schema) {
7018
- const location = path ? `${rootField2}.${path}.${keyword}` : `${rootField2}.${keyword}`;
7019
- pushIssue(
7020
- issue(
7021
- "INPUT_SCHEMA",
7022
- `Composition keyword '${keyword}' is not allowed in beta${path ? ` at ${path}` : ""}`,
7023
- location
7024
- )
7025
- );
6800
+ if (!(keyword in schema)) {
6801
+ continue;
6802
+ }
6803
+ const branches = schema[keyword];
6804
+ const location = path ? `${rootField2}.${path}.${keyword}` : `${rootField2}.${keyword}`;
6805
+ if (!Array.isArray(branches) || branches.length === 0) {
6806
+ pushIssue(issue("INPUT_SCHEMA", `${keyword} must be a non-empty array`, location));
6807
+ continue;
7026
6808
  }
6809
+ branches.forEach((branch, index) => {
6810
+ const branchPath = path ? `${path}.${keyword}[${index}]` : `${keyword}[${index}]`;
6811
+ const branchLocation = `${rootField2}.${branchPath}`;
6812
+ if (!isRecord2(branch)) {
6813
+ pushIssue(issue("INPUT_SCHEMA", `${keyword}[${index}] must be an object`, branchLocation));
6814
+ return;
6815
+ }
6816
+ checkSchemaForbiddenRecursive(branch, rootField2, pushIssue, branchPath);
6817
+ });
7027
6818
  }
7028
6819
  for (const forbidden of INPUT_SCHEMA_FORBIDDEN_KEYS) {
7029
6820
  if (forbidden in schema) {
@@ -8890,8 +8681,6 @@ export {
8890
8681
  DEFAULT_OPERATION_AGENT_ID,
8891
8682
  DEFAULT_SIGLUME_API_BASE,
8892
8683
  DEFAULT_WEBHOOK_TOLERANCE_SECONDS,
8893
- DisputeResponse,
8894
- DisputeStatus,
8895
8684
  Environment,
8896
8685
  ExecutionKind,
8897
8686
  InMemoryWebhookDedupe,
@@ -8902,9 +8691,6 @@ export {
8902
8691
  PriceModel,
8903
8692
  RecordMode,
8904
8693
  Recorder,
8905
- RefundClient,
8906
- RefundReason,
8907
- RefundStatus,
8908
8694
  SettlementMode,
8909
8695
  SiglumeAPIError,
8910
8696
  SiglumeAssistError,