@contractspec/lib.contracts 1.56.0 → 1.57.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.
Files changed (216) hide show
  1. package/dist/_virtual/{rolldown_runtime.js → _rolldown/runtime.js} +3 -3
  2. package/dist/app-config/events.d.ts +27 -27
  3. package/dist/app-config/lifecycle-contracts.d.ts +54 -54
  4. package/dist/app-config/runtime.js +3 -3
  5. package/dist/app-config/validation.js +3 -3
  6. package/dist/capabilities/capabilities.d.ts +0 -1
  7. package/dist/capabilities/capabilities.js +20 -20
  8. package/dist/capabilities/context.d.ts +0 -1
  9. package/dist/capabilities/context.js +1 -1
  10. package/dist/capabilities/guards.d.ts +0 -1
  11. package/dist/capabilities/index.d.ts +2 -1
  12. package/dist/capabilities/index.js +2 -1
  13. package/dist/capabilities/meeting-recorder.d.ts +10 -0
  14. package/dist/capabilities/meeting-recorder.js +82 -0
  15. package/dist/capabilities/validation.d.ts +0 -1
  16. package/dist/client/react/drivers/rn-reusables.d.ts +0 -1
  17. package/dist/client/react/drivers/shadcn.d.ts +0 -1
  18. package/dist/client/react/form-render.js +3 -3
  19. package/dist/contract-registry/schemas.d.ts +4 -4
  20. package/dist/data-views/registry.d.ts +0 -1
  21. package/dist/data-views/spec.d.ts +0 -1
  22. package/dist/docs/commands/docsGenerate.command.d.ts +19 -19
  23. package/dist/docs/commands/docsPublish.command.d.ts +13 -13
  24. package/dist/docs/contracts.d.ts +103 -103
  25. package/dist/docs/events/docsGenerated.event.d.ts +13 -13
  26. package/dist/docs/events/docsPublished.event.d.ts +15 -15
  27. package/dist/docs/forms/docsSearch.form.d.ts +4 -4
  28. package/dist/docs/index.d.ts +0 -1
  29. package/dist/docs/queries/contractReference.query.d.ts +47 -47
  30. package/dist/docs/queries/docsIndex.query.d.ts +57 -57
  31. package/dist/docs/tech/llm/llm-integration.docblock.d.ts +0 -1
  32. package/dist/docs/tech/mcp-endpoints.docblock.js +5 -0
  33. package/dist/events.d.ts +0 -1
  34. package/dist/examples/index.d.ts +0 -1
  35. package/dist/examples/registry.d.ts +0 -1
  36. package/dist/examples/schema.d.ts +14 -14
  37. package/dist/experiments/spec.d.ts +2 -5
  38. package/dist/features/index.d.ts +0 -1
  39. package/dist/features/types.d.ts +2 -6
  40. package/dist/forms/forms.d.ts +1 -2
  41. package/dist/forms/forms.js +1 -2
  42. package/dist/index.d.ts +42 -2
  43. package/dist/index.js +36 -1
  44. package/dist/install.d.ts +2 -5
  45. package/dist/integrations/docs/integrations.docblock.js +19 -1
  46. package/dist/integrations/index.d.ts +26 -1
  47. package/dist/integrations/index.js +20 -1
  48. package/dist/integrations/meeting-recorder/contracts/index.d.ts +10 -0
  49. package/dist/integrations/meeting-recorder/contracts/index.js +12 -0
  50. package/dist/integrations/meeting-recorder/contracts/meetings.d.ts +458 -0
  51. package/dist/integrations/meeting-recorder/contracts/meetings.js +149 -0
  52. package/dist/integrations/meeting-recorder/contracts/transcripts.d.ts +173 -0
  53. package/dist/integrations/meeting-recorder/contracts/transcripts.js +156 -0
  54. package/dist/integrations/meeting-recorder/contracts/webhooks.d.ts +92 -0
  55. package/dist/integrations/meeting-recorder/contracts/webhooks.js +82 -0
  56. package/dist/integrations/meeting-recorder/meeting-recorder.capability.d.ts +7 -0
  57. package/dist/integrations/meeting-recorder/meeting-recorder.capability.js +21 -0
  58. package/dist/integrations/meeting-recorder/meeting-recorder.feature.d.ts +11 -0
  59. package/dist/integrations/meeting-recorder/meeting-recorder.feature.js +67 -0
  60. package/dist/integrations/meeting-recorder/models.d.ts +407 -0
  61. package/dist/integrations/meeting-recorder/models.js +295 -0
  62. package/dist/integrations/meeting-recorder/telemetry.d.ts +16 -0
  63. package/dist/integrations/meeting-recorder/telemetry.js +42 -0
  64. package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
  65. package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
  66. package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
  67. package/dist/integrations/openbanking/models.d.ts +55 -55
  68. package/dist/integrations/operations.d.ts +102 -102
  69. package/dist/integrations/providers/analytics-reader.d.ts +107 -0
  70. package/dist/integrations/providers/analytics-reader.js +0 -0
  71. package/dist/integrations/providers/analytics-writer.d.ts +10 -0
  72. package/dist/integrations/providers/analytics-writer.js +0 -0
  73. package/dist/integrations/providers/analytics.d.ts +49 -0
  74. package/dist/integrations/providers/analytics.js +0 -0
  75. package/dist/integrations/providers/database.d.ts +15 -0
  76. package/dist/integrations/providers/database.js +0 -0
  77. package/dist/integrations/providers/fal.d.ts +8 -0
  78. package/dist/integrations/providers/fal.js +94 -0
  79. package/dist/integrations/providers/fathom.d.ts +8 -0
  80. package/dist/integrations/providers/fathom.js +114 -0
  81. package/dist/integrations/providers/fireflies.d.ts +8 -0
  82. package/dist/integrations/providers/fireflies.js +98 -0
  83. package/dist/integrations/providers/gradium.d.ts +8 -0
  84. package/dist/integrations/providers/gradium.js +92 -0
  85. package/dist/integrations/providers/granola.d.ts +8 -0
  86. package/dist/integrations/providers/granola.js +71 -0
  87. package/dist/integrations/providers/index.d.ts +19 -1
  88. package/dist/integrations/providers/index.js +13 -1
  89. package/dist/integrations/providers/jira.d.ts +8 -0
  90. package/dist/integrations/providers/jira.js +90 -0
  91. package/dist/integrations/providers/linear.d.ts +8 -0
  92. package/dist/integrations/providers/linear.js +85 -0
  93. package/dist/integrations/providers/meeting-recorder.d.ts +132 -0
  94. package/dist/integrations/providers/meeting-recorder.js +0 -0
  95. package/dist/integrations/providers/notion.d.ts +8 -0
  96. package/dist/integrations/providers/notion.js +91 -0
  97. package/dist/integrations/providers/posthog.d.ts +8 -0
  98. package/dist/integrations/providers/posthog.js +107 -0
  99. package/dist/integrations/providers/project-management.d.ts +35 -0
  100. package/dist/integrations/providers/project-management.js +0 -0
  101. package/dist/integrations/providers/registry.d.ts +0 -1
  102. package/dist/integrations/providers/registry.js +24 -0
  103. package/dist/integrations/providers/supabase-postgres.d.ts +8 -0
  104. package/dist/integrations/providers/supabase-postgres.js +73 -0
  105. package/dist/integrations/providers/supabase-vector.d.ts +8 -0
  106. package/dist/integrations/providers/supabase-vector.js +93 -0
  107. package/dist/integrations/providers/tldv.d.ts +8 -0
  108. package/dist/integrations/providers/tldv.js +98 -0
  109. package/dist/integrations/runtime.js +0 -1
  110. package/dist/integrations/spec.d.ts +1 -1
  111. package/dist/jobs/queue.d.ts +0 -1
  112. package/dist/knowledge/binding.d.ts +1 -3
  113. package/dist/knowledge/operations.d.ts +66 -66
  114. package/dist/llm/exporters.d.ts +0 -1
  115. package/dist/llm/exporters.js +0 -1
  116. package/dist/llm/prompts.d.ts +0 -1
  117. package/dist/llm/types.d.ts +0 -1
  118. package/dist/onboarding-base.d.ts +29 -29
  119. package/dist/openapi.d.ts +0 -1
  120. package/dist/operations/operation.d.ts +19 -43
  121. package/dist/operations/registry.d.ts +0 -1
  122. package/dist/operations/registry.js +2 -2
  123. package/dist/operations/report/getContractVerificationStatus.d.ts +10 -10
  124. package/dist/ownership.d.ts +41 -88
  125. package/dist/policy/guards.d.ts +0 -1
  126. package/dist/policy/guards.js +3 -3
  127. package/dist/policy/index.d.ts +0 -1
  128. package/dist/policy/spec.d.ts +0 -1
  129. package/dist/policy/validation.d.ts +0 -1
  130. package/dist/product-intent/contract-patch-intent.d.ts +103 -0
  131. package/dist/product-intent/contract-patch-intent.js +33 -0
  132. package/dist/product-intent/contract-spec-patch.d.ts +89 -0
  133. package/dist/product-intent/contract-spec-patch.js +27 -0
  134. package/dist/product-intent/evidence.d.ts +17 -0
  135. package/dist/product-intent/evidence.js +13 -0
  136. package/dist/product-intent/findings.d.ts +60 -0
  137. package/dist/product-intent/findings.js +17 -0
  138. package/dist/product-intent/impact-report.d.ts +60 -0
  139. package/dist/product-intent/impact-report.js +27 -0
  140. package/dist/product-intent/index.d.ts +16 -0
  141. package/dist/product-intent/index.js +17 -0
  142. package/dist/product-intent/insights.d.ts +65 -0
  143. package/dist/product-intent/insights.js +23 -0
  144. package/dist/product-intent/opportunity-brief.d.ts +195 -0
  145. package/dist/product-intent/opportunity-brief.js +42 -0
  146. package/dist/product-intent/problems.d.ts +62 -0
  147. package/dist/product-intent/problems.js +22 -0
  148. package/dist/product-intent/registry.d.ts +32 -0
  149. package/dist/product-intent/registry.js +49 -0
  150. package/dist/product-intent/runtime.d.ts +103 -0
  151. package/dist/product-intent/runtime.js +101 -0
  152. package/dist/product-intent/spec.d.ts +676 -0
  153. package/dist/product-intent/spec.js +53 -0
  154. package/dist/product-intent/task-pack.d.ts +101 -0
  155. package/dist/product-intent/task-pack.js +34 -0
  156. package/dist/product-intent/tickets.d.ts +70 -0
  157. package/dist/product-intent/tickets.js +24 -0
  158. package/dist/product-intent/types.d.ts +12 -0
  159. package/dist/product-intent/types.js +13 -0
  160. package/dist/product-intent/ui-wireframe.d.ts +103 -0
  161. package/dist/product-intent/ui-wireframe.js +33 -0
  162. package/dist/registry-utils.d.ts +0 -1
  163. package/dist/registry-utils.js +3 -3
  164. package/dist/resources.js +1 -1
  165. package/dist/schema-to-markdown.d.ts +0 -1
  166. package/dist/server/contracts-adapter-input.js +2 -2
  167. package/dist/server/graphql-pothos.d.ts +0 -1
  168. package/dist/server/mcp/createMcpServer.d.ts +0 -1
  169. package/dist/server/rest-express.d.ts +0 -1
  170. package/dist/server/rest-generic.js +3 -3
  171. package/dist/server/rest-next-app.d.ts +0 -1
  172. package/dist/tests/spec.d.ts +0 -2
  173. package/dist/themes.d.ts +0 -1
  174. package/dist/translations/registry.d.ts +0 -1
  175. package/dist/translations/spec.d.ts +0 -1
  176. package/dist/translations/validation.d.ts +0 -1
  177. package/dist/types.d.ts +5 -12
  178. package/dist/versioning/types.d.ts +0 -1
  179. package/dist/versioning/utils.d.ts +0 -1
  180. package/dist/workflow/adapters/memory-store.d.ts +0 -1
  181. package/dist/workflow/context.d.ts +0 -1
  182. package/dist/workflow/context.js +2 -2
  183. package/dist/workflow/runner.d.ts +1 -2
  184. package/dist/workspace-config/contractsrc-schema.d.ts +0 -1
  185. package/dist/workspace-config/contractsrc-types.d.ts +1 -3
  186. package/package.json +110 -32
  187. package/dist/integrations/providers/impls/elevenlabs-voice.d.ts +0 -20
  188. package/dist/integrations/providers/impls/elevenlabs-voice.js +0 -95
  189. package/dist/integrations/providers/impls/gcs-storage.d.ts +0 -24
  190. package/dist/integrations/providers/impls/gcs-storage.js +0 -88
  191. package/dist/integrations/providers/impls/gmail-inbound.d.ts +0 -26
  192. package/dist/integrations/providers/impls/gmail-inbound.js +0 -200
  193. package/dist/integrations/providers/impls/gmail-outbound.d.ts +0 -18
  194. package/dist/integrations/providers/impls/gmail-outbound.js +0 -105
  195. package/dist/integrations/providers/impls/google-calendar.d.ts +0 -23
  196. package/dist/integrations/providers/impls/google-calendar.js +0 -154
  197. package/dist/integrations/providers/impls/index.d.ts +0 -15
  198. package/dist/integrations/providers/impls/index.js +0 -16
  199. package/dist/integrations/providers/impls/mistral-embedding.d.ts +0 -23
  200. package/dist/integrations/providers/impls/mistral-embedding.js +0 -41
  201. package/dist/integrations/providers/impls/mistral-llm.d.ts +0 -31
  202. package/dist/integrations/providers/impls/mistral-llm.js +0 -247
  203. package/dist/integrations/providers/impls/postmark-email.d.ts +0 -19
  204. package/dist/integrations/providers/impls/postmark-email.js +0 -55
  205. package/dist/integrations/providers/impls/powens-client.d.ts +0 -124
  206. package/dist/integrations/providers/impls/powens-client.js +0 -171
  207. package/dist/integrations/providers/impls/powens-openbanking.d.ts +0 -27
  208. package/dist/integrations/providers/impls/powens-openbanking.js +0 -218
  209. package/dist/integrations/providers/impls/provider-factory.d.ts +0 -26
  210. package/dist/integrations/providers/impls/provider-factory.js +0 -146
  211. package/dist/integrations/providers/impls/qdrant-vector.d.ts +0 -24
  212. package/dist/integrations/providers/impls/qdrant-vector.js +0 -69
  213. package/dist/integrations/providers/impls/stripe-payments.d.ts +0 -28
  214. package/dist/integrations/providers/impls/stripe-payments.js +0 -202
  215. package/dist/integrations/providers/impls/twilio-sms.d.ts +0 -20
  216. package/dist/integrations/providers/impls/twilio-sms.js +0 -58
@@ -1,202 +0,0 @@
1
- import Stripe from "stripe";
2
-
3
- //#region src/integrations/providers/impls/stripe-payments.ts
4
- const API_VERSION = "2026-01-28.clover";
5
- var StripePaymentsProvider = class {
6
- stripe;
7
- constructor(options) {
8
- this.stripe = options.stripe ?? new Stripe(options.apiKey, { apiVersion: API_VERSION });
9
- }
10
- async createCustomer(input) {
11
- const customer = await this.stripe.customers.create({
12
- email: input.email,
13
- name: input.name,
14
- description: input.description,
15
- metadata: input.metadata
16
- });
17
- return this.toCustomer(customer);
18
- }
19
- async getCustomer(customerId) {
20
- const customer = await this.stripe.customers.retrieve(customerId);
21
- if (customer.deleted) return null;
22
- return this.toCustomer(customer);
23
- }
24
- async createPaymentIntent(input) {
25
- const intent = await this.stripe.paymentIntents.create({
26
- amount: input.amount.amount,
27
- currency: input.amount.currency,
28
- customer: input.customerId,
29
- description: input.description,
30
- capture_method: input.captureMethod ?? "automatic",
31
- confirmation_method: input.confirmationMethod ?? "automatic",
32
- automatic_payment_methods: { enabled: true },
33
- metadata: input.metadata,
34
- return_url: input.returnUrl,
35
- statement_descriptor: input.statementDescriptor
36
- });
37
- return this.toPaymentIntent(intent);
38
- }
39
- async capturePayment(paymentIntentId, input) {
40
- const intent = await this.stripe.paymentIntents.capture(paymentIntentId, input?.amount ? { amount_to_capture: input.amount.amount } : void 0);
41
- return this.toPaymentIntent(intent);
42
- }
43
- async cancelPaymentIntent(paymentIntentId) {
44
- const intent = await this.stripe.paymentIntents.cancel(paymentIntentId);
45
- return this.toPaymentIntent(intent);
46
- }
47
- async refundPayment(input) {
48
- const refund = await this.stripe.refunds.create({
49
- payment_intent: input.paymentIntentId,
50
- amount: input.amount?.amount,
51
- reason: mapRefundReason(input.reason),
52
- metadata: input.metadata
53
- });
54
- const paymentIntentId = typeof refund.payment_intent === "string" ? refund.payment_intent : refund.payment_intent?.id ?? "";
55
- return {
56
- id: refund.id,
57
- paymentIntentId,
58
- amount: {
59
- amount: refund.amount ?? 0,
60
- currency: refund.currency?.toUpperCase() ?? "USD"
61
- },
62
- status: mapRefundStatus(refund.status),
63
- reason: refund.reason ?? void 0,
64
- metadata: this.toMetadata(refund.metadata),
65
- createdAt: refund.created ? /* @__PURE__ */ new Date(refund.created * 1e3) : void 0
66
- };
67
- }
68
- async listInvoices(query) {
69
- const requestedStatus = query?.status?.[0];
70
- const stripeStatus = requestedStatus && requestedStatus !== "deleted" ? requestedStatus : void 0;
71
- return (await this.stripe.invoices.list({
72
- customer: query?.customerId,
73
- status: stripeStatus,
74
- limit: query?.limit,
75
- starting_after: query?.startingAfter
76
- })).data.map((invoice) => this.toInvoice(invoice));
77
- }
78
- async listTransactions(query) {
79
- return (await this.stripe.charges.list({
80
- customer: query?.customerId,
81
- payment_intent: query?.paymentIntentId,
82
- limit: query?.limit,
83
- starting_after: query?.startingAfter
84
- })).data.map((charge) => ({
85
- id: charge.id,
86
- paymentIntentId: typeof charge.payment_intent === "string" ? charge.payment_intent : charge.payment_intent?.id,
87
- amount: {
88
- amount: charge.amount,
89
- currency: charge.currency?.toUpperCase() ?? "USD"
90
- },
91
- type: "capture",
92
- status: mapChargeStatus(charge.status),
93
- description: charge.description ?? void 0,
94
- createdAt: /* @__PURE__ */ new Date(charge.created * 1e3),
95
- metadata: this.mergeMetadata(this.toMetadata(charge.metadata), { balanceTransaction: typeof charge.balance_transaction === "string" ? charge.balance_transaction : void 0 })
96
- }));
97
- }
98
- toCustomer(customer) {
99
- const metadata = this.toMetadata(customer.metadata);
100
- const updatedAtValue = metadata?.updatedAt;
101
- return {
102
- id: customer.id,
103
- email: customer.email ?? void 0,
104
- name: customer.name ?? void 0,
105
- metadata,
106
- createdAt: customer.created ? /* @__PURE__ */ new Date(customer.created * 1e3) : void 0,
107
- updatedAt: updatedAtValue ? new Date(updatedAtValue) : void 0
108
- };
109
- }
110
- toPaymentIntent(intent) {
111
- const metadata = this.toMetadata(intent.metadata);
112
- return {
113
- id: intent.id,
114
- amount: this.toMoney(intent.amount_received ?? intent.amount ?? 0, intent.currency),
115
- status: mapPaymentIntentStatus(intent.status),
116
- customerId: typeof intent.customer === "string" ? intent.customer : intent.customer?.id,
117
- description: intent.description ?? void 0,
118
- clientSecret: intent.client_secret ?? void 0,
119
- metadata,
120
- createdAt: /* @__PURE__ */ new Date(intent.created * 1e3),
121
- updatedAt: intent.canceled_at != null ? /* @__PURE__ */ new Date(intent.canceled_at * 1e3) : /* @__PURE__ */ new Date(intent.created * 1e3)
122
- };
123
- }
124
- toInvoice(invoice) {
125
- const metadata = this.toMetadata(invoice.metadata);
126
- return {
127
- id: invoice.id,
128
- number: invoice.number ?? void 0,
129
- status: invoice.status ?? "draft",
130
- amountDue: this.toMoney(invoice.amount_due ?? 0, invoice.currency),
131
- amountPaid: this.toMoney(invoice.amount_paid ?? 0, invoice.currency),
132
- customerId: typeof invoice.customer === "string" ? invoice.customer : invoice.customer?.id,
133
- dueDate: invoice.due_date ? /* @__PURE__ */ new Date(invoice.due_date * 1e3) : void 0,
134
- hostedInvoiceUrl: invoice.hosted_invoice_url ?? void 0,
135
- metadata,
136
- createdAt: invoice.created ? /* @__PURE__ */ new Date(invoice.created * 1e3) : void 0,
137
- updatedAt: invoice.status_transitions?.finalized_at ? /* @__PURE__ */ new Date(invoice.status_transitions.finalized_at * 1e3) : void 0
138
- };
139
- }
140
- toMoney(amount, currency) {
141
- return {
142
- amount,
143
- currency: currency?.toUpperCase() ?? "USD"
144
- };
145
- }
146
- toMetadata(metadata) {
147
- if (!metadata) return void 0;
148
- const entries = Object.entries(metadata).filter((entry) => typeof entry[1] === "string");
149
- if (entries.length === 0) return void 0;
150
- return Object.fromEntries(entries);
151
- }
152
- mergeMetadata(base, extras) {
153
- const filteredExtras = Object.entries(extras).filter((entry) => typeof entry[1] === "string");
154
- if (!base && filteredExtras.length === 0) return;
155
- return {
156
- ...base ?? {},
157
- ...Object.fromEntries(filteredExtras)
158
- };
159
- }
160
- };
161
- function mapRefundReason(reason) {
162
- if (!reason) return void 0;
163
- return [
164
- "duplicate",
165
- "fraudulent",
166
- "requested_by_customer"
167
- ].includes(reason) ? reason : void 0;
168
- }
169
- function mapPaymentIntentStatus(status) {
170
- switch (status) {
171
- case "requires_payment_method": return "requires_payment_method";
172
- case "requires_confirmation": return "requires_confirmation";
173
- case "requires_action":
174
- case "requires_capture": return "requires_action";
175
- case "processing": return "processing";
176
- case "succeeded": return "succeeded";
177
- case "canceled": return "canceled";
178
- default: return "requires_payment_method";
179
- }
180
- }
181
- function mapRefundStatus(status) {
182
- switch (status) {
183
- case "pending":
184
- case "succeeded":
185
- case "failed":
186
- case "canceled": return status;
187
- default: return "pending";
188
- }
189
- }
190
- function mapChargeStatus(status) {
191
- switch (status) {
192
- case "pending":
193
- case "processing": return "pending";
194
- case "succeeded": return "succeeded";
195
- case "failed":
196
- case "canceled": return "failed";
197
- default: return "pending";
198
- }
199
- }
200
-
201
- //#endregion
202
- export { StripePaymentsProvider };
@@ -1,20 +0,0 @@
1
- import { SendSmsInput, SmsDeliveryStatus, SmsMessage, SmsProvider } from "../sms.js";
2
- import Twilio from "twilio";
3
-
4
- //#region src/integrations/providers/impls/twilio-sms.d.ts
5
- type TwilioClient = ReturnType<typeof Twilio>;
6
- interface TwilioSmsProviderOptions {
7
- accountSid: string;
8
- authToken: string;
9
- fromNumber?: string;
10
- client?: TwilioClient;
11
- }
12
- declare class TwilioSmsProvider implements SmsProvider {
13
- private readonly client;
14
- private readonly fromNumber?;
15
- constructor(options: TwilioSmsProviderOptions);
16
- sendSms(input: SendSmsInput): Promise<SmsMessage>;
17
- getDeliveryStatus(messageId: string): Promise<SmsDeliveryStatus>;
18
- }
19
- //#endregion
20
- export { TwilioSmsProvider, TwilioSmsProviderOptions };
@@ -1,58 +0,0 @@
1
- import Twilio from "twilio";
2
-
3
- //#region src/integrations/providers/impls/twilio-sms.ts
4
- var TwilioSmsProvider = class {
5
- client;
6
- fromNumber;
7
- constructor(options) {
8
- this.client = options.client ?? Twilio(options.accountSid, options.authToken);
9
- this.fromNumber = options.fromNumber;
10
- }
11
- async sendSms(input) {
12
- const message = await this.client.messages.create({
13
- to: input.to,
14
- from: input.from ?? this.fromNumber,
15
- body: input.body
16
- });
17
- return {
18
- id: message.sid,
19
- to: message.to ?? input.to,
20
- from: message.from ?? input.from ?? this.fromNumber ?? "",
21
- body: message.body ?? input.body,
22
- status: mapStatus(message.status),
23
- sentAt: message.dateCreated ? new Date(message.dateCreated) : void 0,
24
- deliveredAt: message.status === "delivered" && message.dateUpdated ? new Date(message.dateUpdated) : void 0,
25
- price: message.price ? Number(message.price) : void 0,
26
- priceCurrency: message.priceUnit ?? void 0,
27
- errorCode: message.errorCode ? String(message.errorCode) : void 0,
28
- errorMessage: message.errorMessage ?? void 0
29
- };
30
- }
31
- async getDeliveryStatus(messageId) {
32
- const message = await this.client.messages(messageId).fetch();
33
- return {
34
- status: mapStatus(message.status),
35
- errorCode: message.errorCode ? String(message.errorCode) : void 0,
36
- errorMessage: message.errorMessage ?? void 0,
37
- updatedAt: message.dateUpdated ? new Date(message.dateUpdated) : /* @__PURE__ */ new Date()
38
- };
39
- }
40
- };
41
- function mapStatus(status) {
42
- switch (status) {
43
- case "queued":
44
- case "accepted":
45
- case "scheduled": return "queued";
46
- case "sending":
47
- case "processing": return "sending";
48
- case "sent": return "sent";
49
- case "delivered": return "delivered";
50
- case "undelivered": return "undelivered";
51
- case "failed":
52
- case "canceled": return "failed";
53
- default: return "queued";
54
- }
55
- }
56
-
57
- //#endregion
58
- export { TwilioSmsProvider };