@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.cjs CHANGED
@@ -362,10 +362,8 @@ var init_webhooks = __esm({
362
362
  "subscription.cancelled",
363
363
  "subscription.paused",
364
364
  "subscription.reinstated",
365
- "refund.issued",
366
365
  "payment.succeeded",
367
366
  "payment.failed",
368
- "payment.disputed",
369
367
  "capability.published",
370
368
  "capability.delisted",
371
369
  "execution.completed",
@@ -583,18 +581,6 @@ function camelCaseFromCapabilityKey(capabilityKey) {
583
581
  }
584
582
  return `${words.map((word) => word[0].toUpperCase() + word.slice(1)).join("")}App`;
585
583
  }
586
- function buildDefaultI18n(manifestPayload) {
587
- const job = String(manifestPayload.job_to_be_done ?? "").trim();
588
- const shortDescription = String(
589
- manifestPayload.short_description ?? manifestPayload.job_to_be_done ?? manifestPayload.name ?? ""
590
- ).trim();
591
- return {
592
- job_to_be_done_en: job,
593
- job_to_be_done_ja: job,
594
- short_description_en: shortDescription,
595
- short_description_ja: shortDescription
596
- };
597
- }
598
584
  function buildRegistrationStubSource(manifestPayload, toolManualPayload) {
599
585
  const capabilityKey = String(manifestPayload.capability_key ?? "generated-registration");
600
586
  const jobToBeDone = String(
@@ -1661,6 +1647,7 @@ function parseListing(data) {
1661
1647
  price_value_minor: Number(data.price_value_minor ?? 0),
1662
1648
  currency: String(data.currency ?? "USD"),
1663
1649
  short_description: stringOrNull2(data.short_description),
1650
+ description: stringOrNull2(data.description),
1664
1651
  docs_url: stringOrNull2(data.docs_url),
1665
1652
  support_contact: stringOrNull2(data.support_contact),
1666
1653
  seller_display_name: stringOrNull2(data.seller_display_name),
@@ -1685,19 +1672,6 @@ function parseBundleMember(data) {
1685
1672
  link_id: stringOrNull2(data.link_id)
1686
1673
  };
1687
1674
  }
1688
- function parseConnectedAccountProvider(data) {
1689
- return {
1690
- provider_key: String(data.provider_key ?? ""),
1691
- display_name: String(data.display_name ?? ""),
1692
- auth_type: String(data.auth_type ?? "oauth2"),
1693
- refresh_supported: Boolean(data.refresh_supported ?? false),
1694
- pkce_required: Boolean(data.pkce_required ?? false),
1695
- default_scopes: Array.isArray(data.default_scopes) ? data.default_scopes.filter((s) => typeof s === "string") : [],
1696
- available_scopes: Array.isArray(data.available_scopes) ? data.available_scopes.filter((s) => typeof s === "string") : [],
1697
- scope_separator: String(data.scope_separator ?? " "),
1698
- notes: stringOrNull2(data.notes)
1699
- };
1700
- }
1701
1675
  function parseConnectedAccountLifecycle(data) {
1702
1676
  return {
1703
1677
  connected_account_id: String(data.connected_account_id ?? ""),
@@ -2739,50 +2713,6 @@ function parseMarketProposalActionResult(execution) {
2739
2713
  raw: { ...execution.raw }
2740
2714
  };
2741
2715
  }
2742
- function parseRefund(data) {
2743
- return {
2744
- refund_id: String(data.refund_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
- chain_receipt_id: stringOrNull2(data.chain_receipt_id) ?? void 0,
2750
- amount_minor: Number(data.amount_minor ?? 0),
2751
- currency: String(data.currency ?? "USD"),
2752
- status: String(data.status ?? "issued"),
2753
- reason_code: String(data.reason_code ?? "customer-request"),
2754
- note: stringOrNull2(data.note) ?? void 0,
2755
- idempotency_key: stringOrNull2(data.idempotency_key) ?? void 0,
2756
- on_chain_tx_hash: stringOrNull2(data.on_chain_tx_hash) ?? 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
- function parseDispute(data) {
2765
- return {
2766
- dispute_id: String(data.dispute_id ?? data.id ?? ""),
2767
- receipt_id: String(data.receipt_id ?? ""),
2768
- owner_user_id: stringOrNull2(data.owner_user_id) ?? void 0,
2769
- payment_mandate_id: stringOrNull2(data.payment_mandate_id) ?? void 0,
2770
- usage_event_id: stringOrNull2(data.usage_event_id) ?? void 0,
2771
- external_dispute_id: stringOrNull2(data.external_dispute_id) ?? void 0,
2772
- status: String(data.status ?? "open"),
2773
- reason_code: String(data.reason_code ?? "manual-review"),
2774
- description: stringOrNull2(data.description) ?? void 0,
2775
- evidence: toRecord2(data.evidence),
2776
- response_decision: stringOrNull2(data.response_decision) ?? void 0,
2777
- response_note: stringOrNull2(data.response_note) ?? void 0,
2778
- responded_at: stringOrNull2(data.responded_at) ?? void 0,
2779
- metadata: toRecord2(data.metadata),
2780
- idempotent_replay: Boolean(data.idempotent_replay ?? false),
2781
- created_at: stringOrNull2(data.created_at) ?? void 0,
2782
- updated_at: stringOrNull2(data.updated_at) ?? void 0,
2783
- raw: { ...data }
2784
- };
2785
- }
2786
2716
  function cloneJsonLike(value) {
2787
2717
  if (Array.isArray(value)) {
2788
2718
  return value.map((item) => cloneJsonLike(item));
@@ -2867,10 +2797,13 @@ var init_client = __esm({
2867
2797
  async auto_register(manifest, tool_manual, options = {}) {
2868
2798
  const manifestPayload = coerceMapping(manifest, "manifest");
2869
2799
  const toolManualPayload = coerceMapping(tool_manual, "tool_manual");
2800
+ const toolManualForRequest = { ...toolManualPayload };
2801
+ const embeddedInputFormSpec = toolManualForRequest.input_form_spec;
2802
+ delete toolManualForRequest.input_form_spec;
2803
+ const inputFormSpec = options.input_form_spec ?? embeddedInputFormSpec;
2870
2804
  const payload = {
2871
- i18n: buildDefaultI18n(manifestPayload),
2872
2805
  manifest: { ...manifestPayload },
2873
- tool_manual: { ...toolManualPayload }
2806
+ tool_manual: toolManualForRequest
2874
2807
  };
2875
2808
  if (options.source_url) {
2876
2809
  payload.source_url = options.source_url;
@@ -2889,14 +2822,11 @@ var init_client = __esm({
2889
2822
  )
2890
2823
  } : coerceMapping(options.oauth_credentials, "oauth_credentials");
2891
2824
  }
2892
- if (options.metadata) {
2893
- payload.metadata = coerceMapping(options.metadata, "metadata");
2894
- }
2895
2825
  if (options.source_context) {
2896
2826
  payload.source_context = coerceMapping(options.source_context, "source_context");
2897
2827
  }
2898
- if (options.input_form_spec) {
2899
- payload.input_form_spec = coerceMapping(options.input_form_spec, "input_form_spec");
2828
+ if (inputFormSpec !== void 0 && inputFormSpec !== null) {
2829
+ payload.input_form_spec = coerceMapping(inputFormSpec, "input_form_spec");
2900
2830
  }
2901
2831
  for (const fieldName of [
2902
2832
  "capability_key",
@@ -2947,7 +2877,11 @@ var init_client = __esm({
2947
2877
  if (!listing_id) {
2948
2878
  throw new SiglumeClientError("Siglume auto-register response did not include listing_id.");
2949
2879
  }
2950
- this.pendingConfirmations.set(listing_id, { manifest: manifestPayload, tool_manual: toolManualPayload });
2880
+ this.pendingConfirmations.set(listing_id, {
2881
+ manifest: manifestPayload,
2882
+ tool_manual: toRecord2(payload.tool_manual),
2883
+ input_form_spec: toRecord2(payload.input_form_spec)
2884
+ });
2951
2885
  return {
2952
2886
  listing_id,
2953
2887
  status: String(data.status ?? "draft"),
@@ -3095,11 +3029,6 @@ var init_client = __esm({
3095
3029
  // ----- end bundles -------------------------------------------------------
3096
3030
  // ----- Connected accounts (v0.7 track 3) ---------------------------------
3097
3031
  // `resolve()` is intentionally NOT wrapped: runtime-only, never over the wire.
3098
- async list_connected_account_providers() {
3099
- const [data] = await this.request("GET", "/me/connected-accounts/providers");
3100
- const items = Array.isArray(data.items) ? data.items : [];
3101
- return items.filter((item) => isRecord2(item)).map(parseConnectedAccountProvider);
3102
- }
3103
3032
  async start_connected_account_oauth(input) {
3104
3033
  const body = {
3105
3034
  listing_id: input.listing_id,
@@ -3136,8 +3065,17 @@ var init_client = __esm({
3136
3065
  const body = {
3137
3066
  provider_key: input.provider_key,
3138
3067
  client_id: input.client_id,
3139
- client_secret: input.client_secret
3068
+ client_secret: input.client_secret,
3069
+ authorize_url: input.authorize_url,
3070
+ token_url: input.token_url
3140
3071
  };
3072
+ if (input.revoke_url !== void 0) body.revoke_url = input.revoke_url;
3073
+ if (input.display_name !== void 0) body.display_name = input.display_name;
3074
+ if (input.scope_separator !== void 0) body.scope_separator = input.scope_separator;
3075
+ if (input.token_endpoint_auth !== void 0) body.token_endpoint_auth = input.token_endpoint_auth;
3076
+ if (input.pkce_required !== void 0) body.pkce_required = input.pkce_required;
3077
+ if (input.refresh_supported !== void 0) body.refresh_supported = input.refresh_supported;
3078
+ if (input.available_scopes !== void 0) body.available_scopes = input.available_scopes;
3141
3079
  if (input.required_scopes !== void 0) body.required_scopes = input.required_scopes;
3142
3080
  const [data] = await this.request("PUT", `/market/capabilities/${listing_id}/oauth-credentials`, {
3143
3081
  json_body: body
@@ -4542,105 +4480,6 @@ ${details}` : summary;
4542
4480
  fetchNext: next_cursor ? (cursor) => this.list_support_cases({ ...options, cursor }) : void 0
4543
4481
  });
4544
4482
  }
4545
- async issue_partial_refund(options) {
4546
- const receipt_id = String(options.receipt_id ?? "").trim();
4547
- const idempotency_key = String(options.idempotency_key ?? "").trim();
4548
- if (!receipt_id) {
4549
- throw new SiglumeClientError("receipt_id is required.");
4550
- }
4551
- if (!idempotency_key) {
4552
- throw new SiglumeClientError("idempotency_key is required.");
4553
- }
4554
- if (!Number.isFinite(options.amount_minor)) {
4555
- throw new SiglumeClientError("amount_minor must be a finite number.");
4556
- }
4557
- const amount_minor = Math.trunc(options.amount_minor);
4558
- if (amount_minor <= 0) {
4559
- throw new SiglumeClientError("amount_minor must be positive.");
4560
- }
4561
- if (typeof options.original_amount_minor === "number" && amount_minor > Math.trunc(options.original_amount_minor)) {
4562
- throw new SiglumeClientError("amount_minor cannot exceed the original receipt amount.");
4563
- }
4564
- const [data] = await this.request("POST", "/market/refunds", {
4565
- json_body: {
4566
- receipt_id,
4567
- amount_minor,
4568
- reason_code: options.reason ?? "customer-request",
4569
- note: options.note,
4570
- idempotency_key
4571
- }
4572
- });
4573
- return parseRefund(data);
4574
- }
4575
- async issue_full_refund(options) {
4576
- const receipt_id = String(options.receipt_id ?? "").trim();
4577
- if (!receipt_id) {
4578
- throw new SiglumeClientError("receipt_id is required.");
4579
- }
4580
- const provided_key = String(options.idempotency_key ?? "").trim();
4581
- const idempotency_key = provided_key || `full-refund:${receipt_id}`;
4582
- const [data] = await this.request("POST", "/market/refunds", {
4583
- json_body: {
4584
- receipt_id,
4585
- reason_code: options.reason ?? "customer-request",
4586
- note: options.note,
4587
- idempotency_key
4588
- }
4589
- });
4590
- return parseRefund(data);
4591
- }
4592
- async list_refunds(options = {}) {
4593
- const [data] = await this.requestAny("GET", "/market/refunds", {
4594
- params: {
4595
- receipt_id: options.receipt_id,
4596
- limit: Math.max(1, Math.min(Math.trunc(options.limit ?? 50), 100))
4597
- }
4598
- });
4599
- if (!Array.isArray(data)) {
4600
- throw new SiglumeClientError("Expected refunds to be returned as an array.");
4601
- }
4602
- return data.filter((item) => isRecord2(item)).map(parseRefund);
4603
- }
4604
- async get_refund(refund_id) {
4605
- const [data] = await this.request("GET", `/market/refunds/${refund_id}`);
4606
- return parseRefund(data);
4607
- }
4608
- async get_refunds_for_receipt(receipt_id, options = {}) {
4609
- return this.list_refunds({ receipt_id, limit: options.limit });
4610
- }
4611
- async list_disputes(options = {}) {
4612
- const [data] = await this.requestAny("GET", "/market/disputes", {
4613
- params: {
4614
- receipt_id: options.receipt_id,
4615
- limit: Math.max(1, Math.min(Math.trunc(options.limit ?? 50), 100))
4616
- }
4617
- });
4618
- if (!Array.isArray(data)) {
4619
- throw new SiglumeClientError("Expected disputes to be returned as an array.");
4620
- }
4621
- return data.filter((item) => isRecord2(item)).map(parseDispute);
4622
- }
4623
- async get_dispute(dispute_id) {
4624
- const [data] = await this.request("GET", `/market/disputes/${dispute_id}`);
4625
- return parseDispute(data);
4626
- }
4627
- async respond_to_dispute(options) {
4628
- const dispute_id = String(options.dispute_id ?? "").trim();
4629
- if (!dispute_id) {
4630
- throw new SiglumeClientError("dispute_id is required.");
4631
- }
4632
- if (!isRecord2(options.evidence)) {
4633
- throw new SiglumeClientError("evidence must be an object.");
4634
- }
4635
- const [data] = await this.request("POST", `/market/disputes/${dispute_id}/respond`, {
4636
- json_body: {
4637
- response: options.response,
4638
- evidence: toRecord2(options.evidence),
4639
- note: options.note
4640
- }
4641
- });
4642
- return parseDispute(data);
4643
- }
4644
4483
  async create_webhook_subscription(options) {
4645
4484
  const normalizedEventTypes = options.event_types.map((item) => String(item).trim()).filter((item) => item.length > 0);
4646
4485
  if (normalizedEventTypes.length === 0) {
@@ -5274,8 +5113,6 @@ __export(src_exports, {
5274
5113
  DEFAULT_OPERATION_AGENT_ID: () => DEFAULT_OPERATION_AGENT_ID,
5275
5114
  DEFAULT_SIGLUME_API_BASE: () => DEFAULT_SIGLUME_API_BASE,
5276
5115
  DEFAULT_WEBHOOK_TOLERANCE_SECONDS: () => DEFAULT_WEBHOOK_TOLERANCE_SECONDS,
5277
- DisputeResponse: () => DisputeResponse,
5278
- DisputeStatus: () => DisputeStatus,
5279
5116
  Environment: () => Environment,
5280
5117
  ExecutionKind: () => ExecutionKind,
5281
5118
  InMemoryWebhookDedupe: () => InMemoryWebhookDedupe,
@@ -5286,9 +5123,6 @@ __export(src_exports, {
5286
5123
  PriceModel: () => PriceModel,
5287
5124
  RecordMode: () => RecordMode,
5288
5125
  Recorder: () => Recorder,
5289
- RefundClient: () => RefundClient,
5290
- RefundReason: () => RefundReason,
5291
- RefundStatus: () => RefundStatus,
5292
5126
  SettlementMode: () => SettlementMode,
5293
5127
  SiglumeAPIError: () => SiglumeAPIError,
5294
5128
  SiglumeAssistError: () => SiglumeAssistError,
@@ -6592,42 +6426,6 @@ function toRecord3(value) {
6592
6426
  init_metering();
6593
6427
  init_operations();
6594
6428
 
6595
- // src/refunds.ts
6596
- init_client();
6597
- var RefundClient = class {
6598
- client;
6599
- constructor(options) {
6600
- this.client = new SiglumeClient(options);
6601
- }
6602
- close() {
6603
- this.client.close();
6604
- }
6605
- async issue_partial_refund(options) {
6606
- return this.client.issue_partial_refund(options);
6607
- }
6608
- async issue_full_refund(options) {
6609
- return this.client.issue_full_refund(options);
6610
- }
6611
- async list_refunds(options = {}) {
6612
- return this.client.list_refunds(options);
6613
- }
6614
- async get_refund(refund_id) {
6615
- return this.client.get_refund(refund_id);
6616
- }
6617
- async get_refunds_for_receipt(receipt_id, options = {}) {
6618
- return this.client.get_refunds_for_receipt(receipt_id, options);
6619
- }
6620
- async list_disputes(options = {}) {
6621
- return this.client.list_disputes(options);
6622
- }
6623
- async get_dispute(dispute_id) {
6624
- return this.client.get_dispute(dispute_id);
6625
- }
6626
- async respond_to_dispute(options) {
6627
- return this.client.respond_to_dispute(options);
6628
- }
6629
- };
6630
-
6631
6429
  // src/types.ts
6632
6430
  var PermissionClass = {
6633
6431
  READ_ONLY: "read-only",
@@ -6681,26 +6479,6 @@ var SettlementMode = {
6681
6479
  POLYGON_MANDATE: "polygon_mandate",
6682
6480
  EMBEDDED_WALLET_CHARGE: "embedded_wallet_charge"
6683
6481
  };
6684
- var RefundReason = {
6685
- CUSTOMER_REQUEST: "customer-request",
6686
- DUPLICATE: "duplicate",
6687
- FRAUDULENT: "fraudulent",
6688
- SERVICE_FAILURE: "service-failure",
6689
- GOODWILL: "goodwill"
6690
- };
6691
- var DisputeResponse = {
6692
- ACCEPT: "accept",
6693
- CONTEST: "contest"
6694
- };
6695
- var RefundStatus = {
6696
- ISSUED: "issued",
6697
- FAILED: "failed"
6698
- };
6699
- var DisputeStatus = {
6700
- OPEN: "open",
6701
- ACCEPTED: "accepted",
6702
- CONTESTED: "contested"
6703
- };
6704
6482
 
6705
6483
  // src/testing/recorder.ts
6706
6484
  var CASSETTE_VERSION = 1;
@@ -7122,16 +6900,24 @@ function coerceToolManual2(manual) {
7122
6900
  }
7123
6901
  function checkSchemaForbiddenRecursive(schema, rootField2, pushIssue, path = "") {
7124
6902
  for (const keyword of COMPOSITION_KEYWORDS) {
7125
- if (keyword in schema) {
7126
- const location = path ? `${rootField2}.${path}.${keyword}` : `${rootField2}.${keyword}`;
7127
- pushIssue(
7128
- issue(
7129
- "INPUT_SCHEMA",
7130
- `Composition keyword '${keyword}' is not allowed in beta${path ? ` at ${path}` : ""}`,
7131
- location
7132
- )
7133
- );
6903
+ if (!(keyword in schema)) {
6904
+ continue;
6905
+ }
6906
+ const branches = schema[keyword];
6907
+ const location = path ? `${rootField2}.${path}.${keyword}` : `${rootField2}.${keyword}`;
6908
+ if (!Array.isArray(branches) || branches.length === 0) {
6909
+ pushIssue(issue("INPUT_SCHEMA", `${keyword} must be a non-empty array`, location));
6910
+ continue;
7134
6911
  }
6912
+ branches.forEach((branch, index) => {
6913
+ const branchPath = path ? `${path}.${keyword}[${index}]` : `${keyword}[${index}]`;
6914
+ const branchLocation = `${rootField2}.${branchPath}`;
6915
+ if (!isRecord2(branch)) {
6916
+ pushIssue(issue("INPUT_SCHEMA", `${keyword}[${index}] must be an object`, branchLocation));
6917
+ return;
6918
+ }
6919
+ checkSchemaForbiddenRecursive(branch, rootField2, pushIssue, branchPath);
6920
+ });
7135
6921
  }
7136
6922
  for (const forbidden of INPUT_SCHEMA_FORBIDDEN_KEYS) {
7137
6923
  if (forbidden in schema) {