digital-tools 2.1.3 → 2.3.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 (294) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +2 -0
  3. package/dist/client.d.ts +109 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +69 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/define.d.ts +2 -2
  8. package/dist/define.d.ts.map +1 -1
  9. package/dist/define.js +21 -11
  10. package/dist/define.js.map +1 -1
  11. package/dist/function-ref.d.ts +229 -0
  12. package/dist/function-ref.d.ts.map +1 -0
  13. package/dist/function-ref.js +28 -0
  14. package/dist/function-ref.js.map +1 -0
  15. package/dist/function-sugar.d.ts +57 -0
  16. package/dist/function-sugar.d.ts.map +1 -0
  17. package/dist/function-sugar.js +79 -0
  18. package/dist/function-sugar.js.map +1 -0
  19. package/dist/index.d.ts +10 -3
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +24 -4
  22. package/dist/index.js.map +1 -1
  23. package/dist/providers/analytics/mixpanel.d.ts.map +1 -1
  24. package/dist/providers/analytics/mixpanel.js +21 -18
  25. package/dist/providers/analytics/mixpanel.js.map +1 -1
  26. package/dist/providers/calendar/cal-com.d.ts.map +1 -1
  27. package/dist/providers/calendar/cal-com.js +10 -10
  28. package/dist/providers/calendar/cal-com.js.map +1 -1
  29. package/dist/providers/calendar/google-calendar.d.ts.map +1 -1
  30. package/dist/providers/calendar/google-calendar.js +4 -4
  31. package/dist/providers/calendar/google-calendar.js.map +1 -1
  32. package/dist/providers/crm/hubspot.d.ts.map +1 -1
  33. package/dist/providers/crm/hubspot.js +107 -85
  34. package/dist/providers/crm/hubspot.js.map +1 -1
  35. package/dist/providers/development/github.d.ts.map +1 -1
  36. package/dist/providers/development/github.js +40 -43
  37. package/dist/providers/development/github.js.map +1 -1
  38. package/dist/providers/ecommerce/shopify.d.ts.map +1 -1
  39. package/dist/providers/ecommerce/shopify.js +79 -62
  40. package/dist/providers/ecommerce/shopify.js.map +1 -1
  41. package/dist/providers/email/resend.d.ts.map +1 -1
  42. package/dist/providers/email/resend.js +20 -16
  43. package/dist/providers/email/resend.js.map +1 -1
  44. package/dist/providers/email/sendgrid.d.ts.map +1 -1
  45. package/dist/providers/email/sendgrid.js +12 -9
  46. package/dist/providers/email/sendgrid.js.map +1 -1
  47. package/dist/providers/finance/stripe.d.ts.map +1 -1
  48. package/dist/providers/finance/stripe.js +44 -42
  49. package/dist/providers/finance/stripe.js.map +1 -1
  50. package/dist/providers/forms/typeform.d.ts.map +1 -1
  51. package/dist/providers/forms/typeform.js +68 -58
  52. package/dist/providers/forms/typeform.js.map +1 -1
  53. package/dist/providers/knowledge/notion.d.ts.map +1 -1
  54. package/dist/providers/knowledge/notion.js +75 -41
  55. package/dist/providers/knowledge/notion.js.map +1 -1
  56. package/dist/providers/marketing/mailchimp.d.ts.map +1 -1
  57. package/dist/providers/marketing/mailchimp.js +74 -61
  58. package/dist/providers/marketing/mailchimp.js.map +1 -1
  59. package/dist/providers/media/cloudinary.d.ts.map +1 -1
  60. package/dist/providers/media/cloudinary.js +30 -28
  61. package/dist/providers/media/cloudinary.js.map +1 -1
  62. package/dist/providers/messaging/slack.d.ts.map +1 -1
  63. package/dist/providers/messaging/slack.js +75 -58
  64. package/dist/providers/messaging/slack.js.map +1 -1
  65. package/dist/providers/messaging/twilio-sms.d.ts.map +1 -1
  66. package/dist/providers/messaging/twilio-sms.js +33 -15
  67. package/dist/providers/messaging/twilio-sms.js.map +1 -1
  68. package/dist/providers/project-management/linear.d.ts.map +1 -1
  69. package/dist/providers/project-management/linear.js +31 -27
  70. package/dist/providers/project-management/linear.js.map +1 -1
  71. package/dist/providers/spreadsheet/google-sheets.d.ts.map +1 -1
  72. package/dist/providers/spreadsheet/google-sheets.js +21 -18
  73. package/dist/providers/spreadsheet/google-sheets.js.map +1 -1
  74. package/dist/providers/spreadsheet/xlsx.d.ts.map +1 -1
  75. package/dist/providers/spreadsheet/xlsx.js +4 -4
  76. package/dist/providers/spreadsheet/xlsx.js.map +1 -1
  77. package/dist/providers/storage/index.js +1 -0
  78. package/dist/providers/storage/index.js.map +1 -1
  79. package/dist/providers/storage/s3.d.ts.map +1 -1
  80. package/dist/providers/storage/s3.js +36 -27
  81. package/dist/providers/storage/s3.js.map +1 -1
  82. package/dist/providers/support/zendesk.d.ts.map +1 -1
  83. package/dist/providers/support/zendesk.js +24 -25
  84. package/dist/providers/support/zendesk.js.map +1 -1
  85. package/dist/providers/tasks/todoist.d.ts.map +1 -1
  86. package/dist/providers/tasks/todoist.js +18 -18
  87. package/dist/providers/tasks/todoist.js.map +1 -1
  88. package/dist/providers/video-conferencing/google-meet.d.ts.map +1 -1
  89. package/dist/providers/video-conferencing/google-meet.js +11 -11
  90. package/dist/providers/video-conferencing/google-meet.js.map +1 -1
  91. package/dist/providers/video-conferencing/jitsi.js +14 -14
  92. package/dist/providers/video-conferencing/jitsi.js.map +1 -1
  93. package/dist/providers/video-conferencing/teams.d.ts.map +1 -1
  94. package/dist/providers/video-conferencing/teams.js +9 -7
  95. package/dist/providers/video-conferencing/teams.js.map +1 -1
  96. package/dist/providers/video-conferencing/zoom.d.ts.map +1 -1
  97. package/dist/providers/video-conferencing/zoom.js +26 -24
  98. package/dist/providers/video-conferencing/zoom.js.map +1 -1
  99. package/dist/tools/data.d.ts.map +1 -1
  100. package/dist/tools/data.js +5 -12
  101. package/dist/tools/data.js.map +1 -1
  102. package/dist/tools/index.d.ts +1 -0
  103. package/dist/tools/index.d.ts.map +1 -1
  104. package/dist/tools/index.js +1 -0
  105. package/dist/tools/index.js.map +1 -1
  106. package/dist/tools/system.d.ts +289 -0
  107. package/dist/tools/system.d.ts.map +1 -0
  108. package/dist/tools/system.js +752 -0
  109. package/dist/tools/system.js.map +1 -0
  110. package/dist/tools/web.d.ts.map +1 -1
  111. package/dist/tools/web.js +22 -10
  112. package/dist/tools/web.js.map +1 -1
  113. package/dist/track-record.d.ts +101 -0
  114. package/dist/track-record.d.ts.map +1 -0
  115. package/dist/track-record.js +17 -0
  116. package/dist/track-record.js.map +1 -0
  117. package/dist/types.d.ts +210 -9
  118. package/dist/types.d.ts.map +1 -1
  119. package/dist/verb-registration.d.ts +122 -0
  120. package/dist/verb-registration.d.ts.map +1 -0
  121. package/dist/verb-registration.js +176 -0
  122. package/dist/verb-registration.js.map +1 -0
  123. package/dist/worker.d.ts +93 -0
  124. package/dist/worker.d.ts.map +1 -0
  125. package/dist/worker.js +315 -0
  126. package/dist/worker.js.map +1 -0
  127. package/dist/wrap.d.ts +89 -0
  128. package/dist/wrap.d.ts.map +1 -0
  129. package/dist/wrap.js +225 -0
  130. package/dist/wrap.js.map +1 -0
  131. package/package.json +31 -14
  132. package/src/client.ts +136 -0
  133. package/src/define.ts +30 -24
  134. package/src/function-ref.ts +264 -0
  135. package/src/function-sugar.ts +134 -0
  136. package/src/index.ts +132 -10
  137. package/src/providers/analytics/mixpanel.ts +19 -18
  138. package/src/providers/calendar/cal-com.ts +29 -18
  139. package/src/providers/calendar/google-calendar.ts +20 -14
  140. package/src/providers/crm/hubspot.ts +225 -99
  141. package/src/providers/development/github.ts +206 -135
  142. package/src/providers/ecommerce/shopify.ts +250 -89
  143. package/src/providers/email/resend.ts +101 -28
  144. package/src/providers/email/sendgrid.ts +12 -9
  145. package/src/providers/finance/stripe.ts +128 -49
  146. package/src/providers/forms/typeform.ts +74 -58
  147. package/src/providers/knowledge/notion.ts +340 -88
  148. package/src/providers/marketing/mailchimp.ts +86 -70
  149. package/src/providers/media/cloudinary.ts +99 -41
  150. package/src/providers/messaging/slack.ts +283 -85
  151. package/src/providers/messaging/twilio-sms.ts +35 -15
  152. package/src/providers/project-management/linear.ts +143 -55
  153. package/src/providers/spreadsheet/google-sheets.ts +222 -56
  154. package/src/providers/spreadsheet/xlsx.ts +47 -16
  155. package/src/providers/storage/s3.ts +119 -47
  156. package/src/providers/support/zendesk.ts +196 -46
  157. package/src/providers/tasks/todoist.ts +20 -26
  158. package/src/providers/video-conferencing/google-meet.ts +17 -20
  159. package/src/providers/video-conferencing/jitsi.ts +14 -14
  160. package/src/providers/video-conferencing/teams.ts +14 -13
  161. package/src/providers/video-conferencing/zoom.ts +54 -49
  162. package/src/tools/data.ts +6 -16
  163. package/src/tools/index.ts +1 -0
  164. package/src/tools/system.ts +887 -0
  165. package/src/tools/web.ts +22 -10
  166. package/src/track-record.ts +106 -0
  167. package/src/types.ts +241 -13
  168. package/src/verb-registration.ts +197 -0
  169. package/src/worker.ts +370 -0
  170. package/src/wrap.ts +260 -0
  171. package/test/client.test.ts +146 -0
  172. package/test/communication-tools-extended.test.ts +734 -0
  173. package/test/data-tools-extended.test.ts +743 -0
  174. package/test/define-extended.test.ts +819 -0
  175. package/test/define.test.ts +150 -41
  176. package/test/entities.test.ts +623 -0
  177. package/test/extended-entities.test.ts +1228 -0
  178. package/test/provider-implementations.test.ts +725 -0
  179. package/test/provider-registry-extended.test.ts +583 -0
  180. package/test/providers/google-sheets.test.ts +851 -0
  181. package/test/providers/helpers.ts +554 -0
  182. package/test/providers/hubspot.test.ts +576 -0
  183. package/test/providers/slack.test.ts +932 -0
  184. package/test/providers/stripe.test.ts +701 -0
  185. package/test/providers.test.ts +578 -0
  186. package/test/system-tools-extended.test.ts +632 -0
  187. package/test/system.test.ts +673 -0
  188. package/test/tools.test.ts +15 -11
  189. package/test/types.test.ts +402 -0
  190. package/test/verb-registration.test.ts +395 -0
  191. package/test/web-tools.test.ts +553 -0
  192. package/test/worker-extended.test.ts +699 -0
  193. package/test/worker.test.ts +576 -0
  194. package/test/wrap.test.ts +366 -0
  195. package/tsconfig.json +3 -13
  196. package/vitest.config.ts +37 -0
  197. package/wrangler.jsonc +9 -0
  198. package/.turbo/turbo-build.log +0 -4
  199. package/LICENSE +0 -21
  200. package/dist/providers/voice/vapi.d.ts +0 -27
  201. package/dist/providers/voice/vapi.d.ts.map +0 -1
  202. package/dist/providers/voice/vapi.js +0 -440
  203. package/dist/providers/voice/vapi.js.map +0 -1
  204. package/src/define.js +0 -259
  205. package/src/entities/advertising.js +0 -999
  206. package/src/entities/ai.js +0 -756
  207. package/src/entities/analytics.js +0 -1588
  208. package/src/entities/automation.js +0 -601
  209. package/src/entities/communication.js +0 -1150
  210. package/src/entities/crm.js +0 -1386
  211. package/src/entities/design.js +0 -546
  212. package/src/entities/development.js +0 -2212
  213. package/src/entities/document.js +0 -874
  214. package/src/entities/ecommerce.js +0 -1429
  215. package/src/entities/experiment.js +0 -1039
  216. package/src/entities/finance.js +0 -3478
  217. package/src/entities/forms.js +0 -1892
  218. package/src/entities/hr.js +0 -661
  219. package/src/entities/identity.js +0 -997
  220. package/src/entities/index.js +0 -282
  221. package/src/entities/infrastructure.js +0 -1153
  222. package/src/entities/knowledge.js +0 -1438
  223. package/src/entities/marketing.js +0 -1610
  224. package/src/entities/media.js +0 -1634
  225. package/src/entities/notification.js +0 -1199
  226. package/src/entities/presentation.js +0 -1274
  227. package/src/entities/productivity.js +0 -1317
  228. package/src/entities/project-management.js +0 -1136
  229. package/src/entities/recruiting.js +0 -736
  230. package/src/entities/shipping.js +0 -509
  231. package/src/entities/signature.js +0 -1102
  232. package/src/entities/site.js +0 -222
  233. package/src/entities/spreadsheet.js +0 -1341
  234. package/src/entities/storage.js +0 -1198
  235. package/src/entities/support.js +0 -1166
  236. package/src/entities/video-conferencing.js +0 -1750
  237. package/src/entities/video.js +0 -950
  238. package/src/entities.js +0 -1663
  239. package/src/index.js +0 -74
  240. package/src/providers/analytics/index.js +0 -17
  241. package/src/providers/analytics/mixpanel.js +0 -255
  242. package/src/providers/calendar/cal-com.js +0 -303
  243. package/src/providers/calendar/google-calendar.js +0 -335
  244. package/src/providers/calendar/index.js +0 -20
  245. package/src/providers/crm/hubspot.js +0 -566
  246. package/src/providers/crm/index.js +0 -17
  247. package/src/providers/development/github.js +0 -472
  248. package/src/providers/development/index.js +0 -17
  249. package/src/providers/ecommerce/index.js +0 -17
  250. package/src/providers/ecommerce/shopify.js +0 -378
  251. package/src/providers/email/index.js +0 -20
  252. package/src/providers/email/resend.js +0 -258
  253. package/src/providers/email/sendgrid.js +0 -161
  254. package/src/providers/finance/index.js +0 -17
  255. package/src/providers/finance/stripe.js +0 -549
  256. package/src/providers/forms/index.js +0 -17
  257. package/src/providers/forms/typeform.js +0 -500
  258. package/src/providers/index.js +0 -123
  259. package/src/providers/knowledge/index.js +0 -17
  260. package/src/providers/knowledge/notion.js +0 -389
  261. package/src/providers/marketing/index.js +0 -17
  262. package/src/providers/marketing/mailchimp.js +0 -443
  263. package/src/providers/media/cloudinary.js +0 -318
  264. package/src/providers/media/index.js +0 -17
  265. package/src/providers/messaging/index.js +0 -20
  266. package/src/providers/messaging/slack.js +0 -393
  267. package/src/providers/messaging/twilio-sms.js +0 -249
  268. package/src/providers/project-management/index.js +0 -17
  269. package/src/providers/project-management/linear.js +0 -575
  270. package/src/providers/registry.js +0 -86
  271. package/src/providers/spreadsheet/google-sheets.js +0 -375
  272. package/src/providers/spreadsheet/index.js +0 -20
  273. package/src/providers/spreadsheet/xlsx.js +0 -423
  274. package/src/providers/storage/index.js +0 -24
  275. package/src/providers/storage/s3.js +0 -419
  276. package/src/providers/support/index.js +0 -17
  277. package/src/providers/support/zendesk.js +0 -373
  278. package/src/providers/tasks/index.js +0 -17
  279. package/src/providers/tasks/todoist.js +0 -286
  280. package/src/providers/types.js +0 -9
  281. package/src/providers/video-conferencing/google-meet.js +0 -286
  282. package/src/providers/video-conferencing/index.js +0 -31
  283. package/src/providers/video-conferencing/jitsi.js +0 -254
  284. package/src/providers/video-conferencing/teams.js +0 -270
  285. package/src/providers/video-conferencing/zoom.js +0 -332
  286. package/src/registry.js +0 -128
  287. package/src/tools/communication.js +0 -184
  288. package/src/tools/data.js +0 -205
  289. package/src/tools/index.js +0 -11
  290. package/src/tools/web.js +0 -137
  291. package/src/types.js +0 -10
  292. package/test/define.test.js +0 -306
  293. package/test/registry.test.js +0 -357
  294. package/test/tools.test.js +0 -363
@@ -1,549 +0,0 @@
1
- /**
2
- * Stripe Finance Provider
3
- *
4
- * Concrete implementation of FinanceProvider using Stripe API.
5
- *
6
- * @packageDocumentation
7
- */
8
- import { defineProvider } from '../registry.js';
9
- const STRIPE_API_URL = 'https://api.stripe.com/v1';
10
- /**
11
- * Stripe provider info
12
- */
13
- export const stripeInfo = {
14
- id: 'finance.stripe',
15
- name: 'Stripe',
16
- description: 'Stripe payment processing and invoicing platform',
17
- category: 'finance',
18
- website: 'https://stripe.com',
19
- docsUrl: 'https://stripe.com/docs/api',
20
- requiredConfig: ['apiKey'],
21
- optionalConfig: ['webhookSecret'],
22
- };
23
- /**
24
- * Create Stripe finance provider
25
- */
26
- export function createStripeProvider(config) {
27
- let apiKey;
28
- /**
29
- * Helper to make Stripe API requests
30
- */
31
- async function stripeRequest(endpoint, options = {}) {
32
- const { method = 'GET', body, params } = options;
33
- const url = new URL(`${STRIPE_API_URL}${endpoint}`);
34
- // Add query params for GET requests
35
- if (params && method === 'GET') {
36
- Object.entries(params).forEach(([key, value]) => {
37
- if (value !== undefined) {
38
- url.searchParams.append(key, value);
39
- }
40
- });
41
- }
42
- const headers = {
43
- Authorization: `Bearer ${apiKey}`,
44
- };
45
- let requestBody;
46
- if (body && method !== 'GET') {
47
- // Stripe uses form-encoded data
48
- const params = new URLSearchParams();
49
- Object.entries(body).forEach(([key, value]) => {
50
- params.append(key, String(value));
51
- });
52
- requestBody = params.toString();
53
- headers['Content-Type'] = 'application/x-www-form-urlencoded';
54
- }
55
- const response = await fetch(url.toString(), {
56
- method,
57
- headers,
58
- body: requestBody,
59
- });
60
- if (!response.ok) {
61
- const error = await response.json().catch(() => ({}));
62
- throw new Error(error?.error?.message || `Stripe API error: ${response.status}`);
63
- }
64
- return response.json();
65
- }
66
- /**
67
- * Convert Stripe nested params to form format
68
- */
69
- function flattenParams(obj, prefix = '') {
70
- const result = {};
71
- for (const [key, value] of Object.entries(obj)) {
72
- const fullKey = prefix ? `${prefix}[${key}]` : key;
73
- if (value === null || value === undefined) {
74
- continue;
75
- }
76
- else if (Array.isArray(value)) {
77
- value.forEach((item, index) => {
78
- if (typeof item === 'object' && item !== null) {
79
- Object.assign(result, flattenParams(item, `${fullKey}[${index}]`));
80
- }
81
- else {
82
- result[`${fullKey}[${index}]`] = String(item);
83
- }
84
- });
85
- }
86
- else if (typeof value === 'object') {
87
- Object.assign(result, flattenParams(value, fullKey));
88
- }
89
- else {
90
- result[fullKey] = String(value);
91
- }
92
- }
93
- return result;
94
- }
95
- /**
96
- * Make Stripe API request with nested params support
97
- */
98
- async function stripeRequestWithParams(endpoint, options = {}) {
99
- const { method = 'GET', data, params } = options;
100
- const url = new URL(`${STRIPE_API_URL}${endpoint}`);
101
- // Add query params for GET requests
102
- if (params && method === 'GET') {
103
- Object.entries(params).forEach(([key, value]) => {
104
- if (value !== undefined) {
105
- url.searchParams.append(key, value);
106
- }
107
- });
108
- }
109
- const headers = {
110
- Authorization: `Bearer ${apiKey}`,
111
- };
112
- let requestBody;
113
- if (data && method !== 'GET') {
114
- // Flatten nested objects for Stripe's form format
115
- const flatParams = flattenParams(data);
116
- requestBody = new URLSearchParams(flatParams).toString();
117
- headers['Content-Type'] = 'application/x-www-form-urlencoded';
118
- }
119
- const response = await fetch(url.toString(), {
120
- method,
121
- headers,
122
- body: requestBody,
123
- });
124
- if (!response.ok) {
125
- const error = await response.json().catch(() => ({}));
126
- throw new Error(error?.error?.message || `Stripe API error: ${response.status}`);
127
- }
128
- return response.json();
129
- }
130
- return {
131
- info: stripeInfo,
132
- async initialize(cfg) {
133
- apiKey = cfg.apiKey;
134
- if (!apiKey) {
135
- throw new Error('Stripe API key is required');
136
- }
137
- },
138
- async healthCheck() {
139
- const start = Date.now();
140
- try {
141
- // Use balance endpoint to verify API key
142
- await stripeRequest('/balance');
143
- return {
144
- healthy: true,
145
- latencyMs: Date.now() - start,
146
- message: 'Connected',
147
- checkedAt: new Date(),
148
- };
149
- }
150
- catch (error) {
151
- return {
152
- healthy: false,
153
- latencyMs: Date.now() - start,
154
- message: error instanceof Error ? error.message : 'Unknown error',
155
- checkedAt: new Date(),
156
- };
157
- }
158
- },
159
- async dispose() {
160
- // No cleanup needed
161
- },
162
- async createInvoice(invoice) {
163
- const data = {
164
- customer: invoice.customerId,
165
- currency: invoice.currency || 'usd',
166
- auto_advance: false, // Don't auto-finalize
167
- };
168
- if (invoice.dueDate) {
169
- data.due_date = Math.floor(invoice.dueDate.getTime() / 1000);
170
- }
171
- if (invoice.memo) {
172
- data.description = invoice.memo;
173
- }
174
- // Create the invoice
175
- const stripeInvoice = await stripeRequestWithParams('/invoices', {
176
- method: 'POST',
177
- data,
178
- });
179
- // Add line items
180
- for (const item of invoice.lineItems) {
181
- await stripeRequestWithParams('/invoiceitems', {
182
- method: 'POST',
183
- data: {
184
- customer: invoice.customerId,
185
- invoice: stripeInvoice.id,
186
- description: item.description,
187
- quantity: item.quantity,
188
- unit_amount: Math.round(item.unitPrice * 100), // Convert to cents
189
- currency: invoice.currency || 'usd',
190
- },
191
- });
192
- }
193
- // Retrieve updated invoice with line items
194
- const updatedInvoice = await stripeRequest(`/invoices/${stripeInvoice.id}`);
195
- return {
196
- id: updatedInvoice.id,
197
- number: updatedInvoice.number || updatedInvoice.id,
198
- customerId: updatedInvoice.customer,
199
- status: mapStripeInvoiceStatus(updatedInvoice.status),
200
- currency: updatedInvoice.currency,
201
- subtotal: updatedInvoice.subtotal / 100,
202
- tax: updatedInvoice.tax ? updatedInvoice.tax / 100 : undefined,
203
- total: updatedInvoice.total / 100,
204
- amountDue: updatedInvoice.amount_due / 100,
205
- amountPaid: updatedInvoice.amount_paid / 100,
206
- dueDate: updatedInvoice.due_date ? new Date(updatedInvoice.due_date * 1000) : undefined,
207
- paidAt: updatedInvoice.status_transitions?.paid_at
208
- ? new Date(updatedInvoice.status_transitions.paid_at * 1000)
209
- : undefined,
210
- url: updatedInvoice.hosted_invoice_url,
211
- createdAt: new Date(updatedInvoice.created * 1000),
212
- };
213
- },
214
- async getInvoice(invoiceId) {
215
- try {
216
- const invoice = await stripeRequest(`/invoices/${invoiceId}`);
217
- return {
218
- id: invoice.id,
219
- number: invoice.number || invoice.id,
220
- customerId: invoice.customer,
221
- status: mapStripeInvoiceStatus(invoice.status),
222
- currency: invoice.currency,
223
- subtotal: invoice.subtotal / 100,
224
- tax: invoice.tax ? invoice.tax / 100 : undefined,
225
- total: invoice.total / 100,
226
- amountDue: invoice.amount_due / 100,
227
- amountPaid: invoice.amount_paid / 100,
228
- dueDate: invoice.due_date ? new Date(invoice.due_date * 1000) : undefined,
229
- paidAt: invoice.status_transitions?.paid_at
230
- ? new Date(invoice.status_transitions.paid_at * 1000)
231
- : undefined,
232
- url: invoice.hosted_invoice_url,
233
- createdAt: new Date(invoice.created * 1000),
234
- };
235
- }
236
- catch (error) {
237
- return null;
238
- }
239
- },
240
- async updateInvoice(invoiceId, updates) {
241
- const data = {};
242
- if (updates.dueDate) {
243
- data.due_date = Math.floor(updates.dueDate.getTime() / 1000);
244
- }
245
- if (updates.memo) {
246
- data.description = updates.memo;
247
- }
248
- const invoice = await stripeRequestWithParams(`/invoices/${invoiceId}`, {
249
- method: 'POST',
250
- data,
251
- });
252
- return {
253
- id: invoice.id,
254
- number: invoice.number || invoice.id,
255
- customerId: invoice.customer,
256
- status: mapStripeInvoiceStatus(invoice.status),
257
- currency: invoice.currency,
258
- subtotal: invoice.subtotal / 100,
259
- tax: invoice.tax ? invoice.tax / 100 : undefined,
260
- total: invoice.total / 100,
261
- amountDue: invoice.amount_due / 100,
262
- amountPaid: invoice.amount_paid / 100,
263
- dueDate: invoice.due_date ? new Date(invoice.due_date * 1000) : undefined,
264
- paidAt: invoice.status_transitions?.paid_at
265
- ? new Date(invoice.status_transitions.paid_at * 1000)
266
- : undefined,
267
- url: invoice.hosted_invoice_url,
268
- createdAt: new Date(invoice.created * 1000),
269
- };
270
- },
271
- async listInvoices(options = {}) {
272
- const params = {};
273
- if (options.limit) {
274
- params.limit = String(options.limit);
275
- }
276
- if (options.cursor) {
277
- params.starting_after = options.cursor;
278
- }
279
- if (options.customerId) {
280
- params.customer = options.customerId;
281
- }
282
- if (options.status) {
283
- params.status = options.status;
284
- }
285
- const response = await stripeRequest('/invoices', { params });
286
- return {
287
- items: response.data.map((invoice) => ({
288
- id: invoice.id,
289
- number: invoice.number || invoice.id,
290
- customerId: invoice.customer,
291
- status: mapStripeInvoiceStatus(invoice.status),
292
- currency: invoice.currency,
293
- subtotal: invoice.subtotal / 100,
294
- tax: invoice.tax ? invoice.tax / 100 : undefined,
295
- total: invoice.total / 100,
296
- amountDue: invoice.amount_due / 100,
297
- amountPaid: invoice.amount_paid / 100,
298
- dueDate: invoice.due_date ? new Date(invoice.due_date * 1000) : undefined,
299
- paidAt: invoice.status_transitions?.paid_at
300
- ? new Date(invoice.status_transitions.paid_at * 1000)
301
- : undefined,
302
- url: invoice.hosted_invoice_url,
303
- createdAt: new Date(invoice.created * 1000),
304
- })),
305
- hasMore: response.has_more,
306
- nextCursor: response.has_more ? response.data[response.data.length - 1]?.id : undefined,
307
- };
308
- },
309
- async sendInvoice(invoiceId) {
310
- try {
311
- // First finalize the invoice if it's a draft
312
- const invoice = await stripeRequest(`/invoices/${invoiceId}`);
313
- if (invoice.status === 'draft') {
314
- await stripeRequestWithParams(`/invoices/${invoiceId}/finalize`, {
315
- method: 'POST',
316
- });
317
- }
318
- // Send the invoice
319
- await stripeRequestWithParams(`/invoices/${invoiceId}/send`, {
320
- method: 'POST',
321
- });
322
- return true;
323
- }
324
- catch (error) {
325
- return false;
326
- }
327
- },
328
- async voidInvoice(invoiceId) {
329
- try {
330
- await stripeRequestWithParams(`/invoices/${invoiceId}/void`, {
331
- method: 'POST',
332
- });
333
- return true;
334
- }
335
- catch (error) {
336
- return false;
337
- }
338
- },
339
- async createPayment(payment) {
340
- const data = {
341
- amount: Math.round(payment.amount * 100), // Convert to cents
342
- currency: payment.currency,
343
- payment_method: payment.paymentMethod,
344
- confirm: true,
345
- };
346
- if (payment.customerId) {
347
- data.customer = payment.customerId;
348
- }
349
- if (payment.description) {
350
- data.description = payment.description;
351
- }
352
- // For Stripe, we create a PaymentIntent
353
- const intent = await stripeRequestWithParams('/payment_intents', {
354
- method: 'POST',
355
- data,
356
- });
357
- return {
358
- id: intent.id,
359
- amount: intent.amount / 100,
360
- currency: intent.currency,
361
- status: mapStripePaymentStatus(intent.status),
362
- customerId: intent.customer || undefined,
363
- invoiceId: intent.invoice || undefined,
364
- paymentMethod: payment.paymentMethod,
365
- description: intent.description,
366
- createdAt: new Date(intent.created * 1000),
367
- };
368
- },
369
- async getPayment(paymentId) {
370
- try {
371
- const intent = await stripeRequest(`/payment_intents/${paymentId}`);
372
- return {
373
- id: intent.id,
374
- amount: intent.amount / 100,
375
- currency: intent.currency,
376
- status: mapStripePaymentStatus(intent.status),
377
- customerId: intent.customer || undefined,
378
- invoiceId: intent.invoice || undefined,
379
- paymentMethod: intent.payment_method || 'unknown',
380
- description: intent.description,
381
- createdAt: new Date(intent.created * 1000),
382
- };
383
- }
384
- catch (error) {
385
- return null;
386
- }
387
- },
388
- async listPayments(options = {}) {
389
- const params = {};
390
- if (options.limit) {
391
- params.limit = String(options.limit);
392
- }
393
- if (options.cursor) {
394
- params.starting_after = options.cursor;
395
- }
396
- if (options.customerId) {
397
- params.customer = options.customerId;
398
- }
399
- const response = await stripeRequest('/payment_intents', { params });
400
- return {
401
- items: response.data.map((intent) => ({
402
- id: intent.id,
403
- amount: intent.amount / 100,
404
- currency: intent.currency,
405
- status: mapStripePaymentStatus(intent.status),
406
- customerId: intent.customer || undefined,
407
- invoiceId: intent.invoice || undefined,
408
- paymentMethod: intent.payment_method || 'unknown',
409
- description: intent.description,
410
- createdAt: new Date(intent.created * 1000),
411
- })),
412
- hasMore: response.has_more,
413
- nextCursor: response.has_more ? response.data[response.data.length - 1]?.id : undefined,
414
- };
415
- },
416
- async refundPayment(paymentId, amount) {
417
- const data = {
418
- payment_intent: paymentId,
419
- };
420
- if (amount !== undefined) {
421
- data.amount = Math.round(amount * 100);
422
- }
423
- const refund = await stripeRequestWithParams('/refunds', {
424
- method: 'POST',
425
- data,
426
- });
427
- return {
428
- id: refund.id,
429
- paymentId: refund.payment_intent,
430
- amount: refund.amount / 100,
431
- status: refund.status,
432
- createdAt: new Date(refund.created * 1000),
433
- };
434
- },
435
- async createCustomer(customer) {
436
- const data = {
437
- name: customer.name,
438
- };
439
- if (customer.email) {
440
- data.email = customer.email;
441
- }
442
- if (customer.phone) {
443
- data.phone = customer.phone;
444
- }
445
- if (customer.address) {
446
- data.address = {
447
- line1: customer.address.line1,
448
- line2: customer.address.line2,
449
- city: customer.address.city,
450
- state: customer.address.state,
451
- postal_code: customer.address.postalCode,
452
- country: customer.address.country,
453
- };
454
- }
455
- const stripeCustomer = await stripeRequestWithParams('/customers', {
456
- method: 'POST',
457
- data,
458
- });
459
- return {
460
- id: stripeCustomer.id,
461
- name: stripeCustomer.name,
462
- email: stripeCustomer.email,
463
- phone: stripeCustomer.phone,
464
- balance: stripeCustomer.balance ? stripeCustomer.balance / 100 : undefined,
465
- createdAt: new Date(stripeCustomer.created * 1000),
466
- };
467
- },
468
- async getCustomer(customerId) {
469
- try {
470
- const customer = await stripeRequest(`/customers/${customerId}`);
471
- return {
472
- id: customer.id,
473
- name: customer.name,
474
- email: customer.email,
475
- phone: customer.phone,
476
- balance: customer.balance ? customer.balance / 100 : undefined,
477
- createdAt: new Date(customer.created * 1000),
478
- };
479
- }
480
- catch (error) {
481
- return null;
482
- }
483
- },
484
- async listCustomers(options = {}) {
485
- const params = {};
486
- if (options.limit) {
487
- params.limit = String(options.limit);
488
- }
489
- if (options.cursor) {
490
- params.starting_after = options.cursor;
491
- }
492
- const response = await stripeRequest('/customers', { params });
493
- return {
494
- items: response.data.map((customer) => ({
495
- id: customer.id,
496
- name: customer.name,
497
- email: customer.email,
498
- phone: customer.phone,
499
- balance: customer.balance ? customer.balance / 100 : undefined,
500
- createdAt: new Date(customer.created * 1000),
501
- })),
502
- hasMore: response.has_more,
503
- nextCursor: response.has_more ? response.data[response.data.length - 1]?.id : undefined,
504
- };
505
- },
506
- };
507
- }
508
- /**
509
- * Map Stripe invoice status to standard status
510
- */
511
- function mapStripeInvoiceStatus(status) {
512
- switch (status) {
513
- case 'draft':
514
- return 'draft';
515
- case 'open':
516
- return 'open';
517
- case 'paid':
518
- return 'paid';
519
- case 'void':
520
- return 'void';
521
- case 'uncollectible':
522
- return 'uncollectible';
523
- default:
524
- return 'draft';
525
- }
526
- }
527
- /**
528
- * Map Stripe payment status to standard status
529
- */
530
- function mapStripePaymentStatus(status) {
531
- switch (status) {
532
- case 'requires_payment_method':
533
- case 'requires_confirmation':
534
- case 'requires_action':
535
- case 'processing':
536
- return 'pending';
537
- case 'succeeded':
538
- return 'succeeded';
539
- case 'canceled':
540
- case 'requires_capture':
541
- return 'failed';
542
- default:
543
- return 'pending';
544
- }
545
- }
546
- /**
547
- * Stripe provider definition
548
- */
549
- export const stripeProvider = defineProvider(stripeInfo, async (config) => createStripeProvider(config));
@@ -1,17 +0,0 @@
1
- /**
2
- * Forms Providers
3
- *
4
- * @packageDocumentation
5
- */
6
- export { typeformInfo, typeformProvider, createTypeformProvider } from './typeform.js';
7
- import { typeformProvider } from './typeform.js';
8
- /**
9
- * Register all forms providers
10
- */
11
- export function registerFormsProviders() {
12
- typeformProvider.register();
13
- }
14
- /**
15
- * All forms providers
16
- */
17
- export const formsProviders = [typeformProvider];