@siglume/api-sdk 0.10.0 → 0.10.1

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),
@@ -2739,50 +2726,6 @@ function parseMarketProposalActionResult(execution) {
2739
2726
  raw: { ...execution.raw }
2740
2727
  };
2741
2728
  }
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
2729
  function cloneJsonLike(value) {
2787
2730
  if (Array.isArray(value)) {
2788
2731
  return value.map((item) => cloneJsonLike(item));
@@ -2868,7 +2811,6 @@ var init_client = __esm({
2868
2811
  const manifestPayload = coerceMapping(manifest, "manifest");
2869
2812
  const toolManualPayload = coerceMapping(tool_manual, "tool_manual");
2870
2813
  const payload = {
2871
- i18n: buildDefaultI18n(manifestPayload),
2872
2814
  manifest: { ...manifestPayload },
2873
2815
  tool_manual: { ...toolManualPayload }
2874
2816
  };
@@ -2889,9 +2831,6 @@ var init_client = __esm({
2889
2831
  )
2890
2832
  } : coerceMapping(options.oauth_credentials, "oauth_credentials");
2891
2833
  }
2892
- if (options.metadata) {
2893
- payload.metadata = coerceMapping(options.metadata, "metadata");
2894
- }
2895
2834
  if (options.source_context) {
2896
2835
  payload.source_context = coerceMapping(options.source_context, "source_context");
2897
2836
  }
@@ -4542,105 +4481,6 @@ ${details}` : summary;
4542
4481
  fetchNext: next_cursor ? (cursor) => this.list_support_cases({ ...options, cursor }) : void 0
4543
4482
  });
4544
4483
  }
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
4484
  async create_webhook_subscription(options) {
4645
4485
  const normalizedEventTypes = options.event_types.map((item) => String(item).trim()).filter((item) => item.length > 0);
4646
4486
  if (normalizedEventTypes.length === 0) {
@@ -5274,8 +5114,6 @@ __export(src_exports, {
5274
5114
  DEFAULT_OPERATION_AGENT_ID: () => DEFAULT_OPERATION_AGENT_ID,
5275
5115
  DEFAULT_SIGLUME_API_BASE: () => DEFAULT_SIGLUME_API_BASE,
5276
5116
  DEFAULT_WEBHOOK_TOLERANCE_SECONDS: () => DEFAULT_WEBHOOK_TOLERANCE_SECONDS,
5277
- DisputeResponse: () => DisputeResponse,
5278
- DisputeStatus: () => DisputeStatus,
5279
5117
  Environment: () => Environment,
5280
5118
  ExecutionKind: () => ExecutionKind,
5281
5119
  InMemoryWebhookDedupe: () => InMemoryWebhookDedupe,
@@ -5286,9 +5124,6 @@ __export(src_exports, {
5286
5124
  PriceModel: () => PriceModel,
5287
5125
  RecordMode: () => RecordMode,
5288
5126
  Recorder: () => Recorder,
5289
- RefundClient: () => RefundClient,
5290
- RefundReason: () => RefundReason,
5291
- RefundStatus: () => RefundStatus,
5292
5127
  SettlementMode: () => SettlementMode,
5293
5128
  SiglumeAPIError: () => SiglumeAPIError,
5294
5129
  SiglumeAssistError: () => SiglumeAssistError,
@@ -6592,42 +6427,6 @@ function toRecord3(value) {
6592
6427
  init_metering();
6593
6428
  init_operations();
6594
6429
 
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
6430
  // src/types.ts
6632
6431
  var PermissionClass = {
6633
6432
  READ_ONLY: "read-only",
@@ -6681,26 +6480,6 @@ var SettlementMode = {
6681
6480
  POLYGON_MANDATE: "polygon_mandate",
6682
6481
  EMBEDDED_WALLET_CHARGE: "embedded_wallet_charge"
6683
6482
  };
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
6483
 
6705
6484
  // src/testing/recorder.ts
6706
6485
  var CASSETTE_VERSION = 1;