@prenta/plugin-commerce 0.2.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 (92) hide show
  1. package/CHANGELOG.md +262 -0
  2. package/LICENSE +21 -0
  3. package/README.md +28 -0
  4. package/dist/__tests__/checkout.test.d.ts +2 -0
  5. package/dist/__tests__/checkout.test.d.ts.map +1 -0
  6. package/dist/__tests__/checkout.test.js +83 -0
  7. package/dist/__tests__/checkout.test.js.map +1 -0
  8. package/dist/__tests__/client.test.d.ts +2 -0
  9. package/dist/__tests__/client.test.d.ts.map +1 -0
  10. package/dist/__tests__/client.test.js +74 -0
  11. package/dist/__tests__/client.test.js.map +1 -0
  12. package/dist/__tests__/customer.test.d.ts +2 -0
  13. package/dist/__tests__/customer.test.d.ts.map +1 -0
  14. package/dist/__tests__/customer.test.js +21 -0
  15. package/dist/__tests__/customer.test.js.map +1 -0
  16. package/dist/__tests__/hooks.test.d.ts +2 -0
  17. package/dist/__tests__/hooks.test.d.ts.map +1 -0
  18. package/dist/__tests__/hooks.test.js +119 -0
  19. package/dist/__tests__/hooks.test.js.map +1 -0
  20. package/dist/__tests__/index.test.d.ts +2 -0
  21. package/dist/__tests__/index.test.d.ts.map +1 -0
  22. package/dist/__tests__/index.test.js +37 -0
  23. package/dist/__tests__/index.test.js.map +1 -0
  24. package/dist/__tests__/products.test.d.ts +2 -0
  25. package/dist/__tests__/products.test.d.ts.map +1 -0
  26. package/dist/__tests__/products.test.js +39 -0
  27. package/dist/__tests__/products.test.js.map +1 -0
  28. package/dist/__tests__/webhooks.test.d.ts +2 -0
  29. package/dist/__tests__/webhooks.test.d.ts.map +1 -0
  30. package/dist/__tests__/webhooks.test.js +71 -0
  31. package/dist/__tests__/webhooks.test.js.map +1 -0
  32. package/dist/admin/CommerceDashboard.d.ts +35 -0
  33. package/dist/admin/CommerceDashboard.d.ts.map +1 -0
  34. package/dist/admin/CommerceDashboard.js +36 -0
  35. package/dist/admin/CommerceDashboard.js.map +1 -0
  36. package/dist/admin/DiscountManager.d.ts +24 -0
  37. package/dist/admin/DiscountManager.d.ts.map +1 -0
  38. package/dist/admin/DiscountManager.js +77 -0
  39. package/dist/admin/DiscountManager.js.map +1 -0
  40. package/dist/admin/OrderDetail.d.ts +62 -0
  41. package/dist/admin/OrderDetail.d.ts.map +1 -0
  42. package/dist/admin/OrderDetail.js +62 -0
  43. package/dist/admin/OrderDetail.js.map +1 -0
  44. package/dist/admin/OrderList.d.ts +29 -0
  45. package/dist/admin/OrderList.d.ts.map +1 -0
  46. package/dist/admin/OrderList.js +30 -0
  47. package/dist/admin/OrderList.js.map +1 -0
  48. package/dist/admin/ProductEdit.d.ts +43 -0
  49. package/dist/admin/ProductEdit.d.ts.map +1 -0
  50. package/dist/admin/ProductEdit.js +68 -0
  51. package/dist/admin/ProductEdit.js.map +1 -0
  52. package/dist/admin/ProductList.d.ts +21 -0
  53. package/dist/admin/ProductList.d.ts.map +1 -0
  54. package/dist/admin/ProductList.js +39 -0
  55. package/dist/admin/ProductList.js.map +1 -0
  56. package/dist/client.d.ts +107 -0
  57. package/dist/client.d.ts.map +1 -0
  58. package/dist/client.js +71 -0
  59. package/dist/client.js.map +1 -0
  60. package/dist/collections.d.ts +4 -0
  61. package/dist/collections.d.ts.map +1 -0
  62. package/dist/collections.js +335 -0
  63. package/dist/collections.js.map +1 -0
  64. package/dist/fields.d.ts +4 -0
  65. package/dist/fields.d.ts.map +1 -0
  66. package/dist/fields.js +3 -0
  67. package/dist/fields.js.map +1 -0
  68. package/dist/hooks.d.ts +3 -0
  69. package/dist/hooks.d.ts.map +1 -0
  70. package/dist/hooks.js +33 -0
  71. package/dist/hooks.js.map +1 -0
  72. package/dist/index.d.ts +23 -0
  73. package/dist/index.d.ts.map +1 -0
  74. package/dist/index.js +23 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/stripe/checkout.d.ts +39 -0
  77. package/dist/stripe/checkout.d.ts.map +1 -0
  78. package/dist/stripe/checkout.js +60 -0
  79. package/dist/stripe/checkout.js.map +1 -0
  80. package/dist/stripe/customer.d.ts +11 -0
  81. package/dist/stripe/customer.d.ts.map +1 -0
  82. package/dist/stripe/customer.js +22 -0
  83. package/dist/stripe/customer.js.map +1 -0
  84. package/dist/stripe/products.d.ts +25 -0
  85. package/dist/stripe/products.d.ts.map +1 -0
  86. package/dist/stripe/products.js +29 -0
  87. package/dist/stripe/products.js.map +1 -0
  88. package/dist/stripe/webhooks.d.ts +28 -0
  89. package/dist/stripe/webhooks.d.ts.map +1 -0
  90. package/dist/stripe/webhooks.js +103 -0
  91. package/dist/stripe/webhooks.js.map +1 -0
  92. package/package.json +43 -0
@@ -0,0 +1,335 @@
1
+ const products = {
2
+ slug: 'products',
3
+ labels: { singular: 'Product', plural: 'Products' },
4
+ fields: {
5
+ name: { type: 'text', label: 'Name', required: true },
6
+ slug: { type: 'slug', label: 'Slug', from: 'name' },
7
+ description: { type: 'richText', label: 'Description' },
8
+ status: {
9
+ type: 'select',
10
+ label: 'Status',
11
+ options: [
12
+ { label: 'Draft', value: 'draft' },
13
+ { label: 'Active', value: 'active' },
14
+ { label: 'Archived', value: 'archived' },
15
+ ],
16
+ },
17
+ price: { type: 'number', label: 'Price', min: 0, step: 0.01 },
18
+ compareAtPrice: { type: 'number', label: 'Compare at Price', min: 0, step: 0.01 },
19
+ sku: { type: 'text', label: 'SKU', unique: true },
20
+ barcode: { type: 'text', label: 'Barcode' },
21
+ trackInventory: { type: 'boolean', label: 'Track Inventory' },
22
+ inventoryCount: { type: 'number', label: 'Inventory Count', min: 0 },
23
+ weight: { type: 'number', label: 'Weight' },
24
+ weightUnit: {
25
+ type: 'select',
26
+ label: 'Weight Unit',
27
+ options: [
28
+ { label: 'kg', value: 'kg' },
29
+ { label: 'lb', value: 'lb' },
30
+ { label: 'oz', value: 'oz' },
31
+ { label: 'g', value: 'g' },
32
+ ],
33
+ },
34
+ taxable: { type: 'boolean', label: 'Taxable', defaultValue: true },
35
+ category: {
36
+ type: 'relationship',
37
+ label: 'Category',
38
+ relationTo: 'product-categories',
39
+ },
40
+ tags: { type: 'json', label: 'Tags' },
41
+ },
42
+ timestamps: true,
43
+ admin: {
44
+ useAsTitle: 'name',
45
+ group: 'Commerce',
46
+ defaultColumns: ['name', 'price', 'status', 'inventoryCount'],
47
+ },
48
+ };
49
+ const productVariants = {
50
+ slug: 'product-variants',
51
+ labels: { singular: 'Product Variant', plural: 'Product Variants' },
52
+ fields: {
53
+ product: {
54
+ type: 'relationship',
55
+ label: 'Product',
56
+ relationTo: 'products',
57
+ },
58
+ name: { type: 'text', label: 'Name', required: true },
59
+ sku: { type: 'text', label: 'SKU', unique: true },
60
+ price: { type: 'number', label: 'Price', min: 0, step: 0.01 },
61
+ inventoryCount: { type: 'number', label: 'Inventory Count', min: 0 },
62
+ options: { type: 'json', label: 'Variant Options' },
63
+ image: { type: 'media', label: 'Image' },
64
+ },
65
+ timestamps: true,
66
+ admin: { group: 'Commerce' },
67
+ };
68
+ const productCategories = {
69
+ slug: 'product-categories',
70
+ labels: { singular: 'Product Category', plural: 'Product Categories' },
71
+ fields: {
72
+ name: { type: 'text', label: 'Name', required: true },
73
+ slug: { type: 'slug', label: 'Slug', from: 'name' },
74
+ description: { type: 'text', label: 'Description' },
75
+ parent: {
76
+ type: 'relationship',
77
+ label: 'Parent Category',
78
+ relationTo: 'product-categories',
79
+ },
80
+ image: { type: 'media', label: 'Image' },
81
+ sortOrder: { type: 'number', label: 'Sort Order' },
82
+ },
83
+ timestamps: true,
84
+ admin: { useAsTitle: 'name', group: 'Commerce' },
85
+ };
86
+ const productImages = {
87
+ slug: 'product-images',
88
+ labels: { singular: 'Product Image', plural: 'Product Images' },
89
+ fields: {
90
+ product: {
91
+ type: 'relationship',
92
+ label: 'Product',
93
+ relationTo: 'products',
94
+ },
95
+ image: { type: 'media', label: 'Image', required: true },
96
+ alt: { type: 'text', label: 'Alt Text' },
97
+ sortOrder: { type: 'number', label: 'Sort Order', defaultValue: 0 },
98
+ },
99
+ timestamps: true,
100
+ admin: { group: 'Commerce' },
101
+ };
102
+ const carts = {
103
+ slug: 'carts',
104
+ labels: { singular: 'Cart', plural: 'Carts' },
105
+ fields: {
106
+ sessionId: { type: 'text', label: 'Session ID', unique: true },
107
+ customerId: {
108
+ type: 'relationship',
109
+ label: 'Customer',
110
+ relationTo: 'users',
111
+ },
112
+ status: {
113
+ type: 'select',
114
+ label: 'Status',
115
+ options: [
116
+ { label: 'Active', value: 'active' },
117
+ { label: 'Merged', value: 'merged' },
118
+ { label: 'Abandoned', value: 'abandoned' },
119
+ { label: 'Converted', value: 'converted' },
120
+ ],
121
+ },
122
+ expiresAt: { type: 'date', label: 'Expires At', includeTime: true },
123
+ },
124
+ timestamps: true,
125
+ admin: { group: 'Commerce', hidden: true },
126
+ };
127
+ const cartItems = {
128
+ slug: 'cart-items',
129
+ labels: { singular: 'Cart Item', plural: 'Cart Items' },
130
+ fields: {
131
+ cart: { type: 'relationship', label: 'Cart', relationTo: 'carts' },
132
+ product: {
133
+ type: 'relationship',
134
+ label: 'Product',
135
+ relationTo: 'products',
136
+ },
137
+ variant: {
138
+ type: 'relationship',
139
+ label: 'Variant',
140
+ relationTo: 'product-variants',
141
+ },
142
+ quantity: { type: 'number', label: 'Quantity', min: 1 },
143
+ unitPrice: { type: 'number', label: 'Unit Price' },
144
+ },
145
+ timestamps: true,
146
+ admin: { group: 'Commerce', hidden: true },
147
+ };
148
+ const orders = {
149
+ slug: 'orders',
150
+ labels: { singular: 'Order', plural: 'Orders' },
151
+ fields: {
152
+ orderNumber: {
153
+ type: 'text',
154
+ label: 'Order Number',
155
+ unique: true,
156
+ required: true,
157
+ },
158
+ customer: {
159
+ type: 'relationship',
160
+ label: 'Customer',
161
+ relationTo: 'users',
162
+ },
163
+ status: {
164
+ type: 'select',
165
+ label: 'Status',
166
+ options: [
167
+ { label: 'Pending', value: 'pending' },
168
+ { label: 'Confirmed', value: 'confirmed' },
169
+ { label: 'Processing', value: 'processing' },
170
+ { label: 'Shipped', value: 'shipped' },
171
+ { label: 'Delivered', value: 'delivered' },
172
+ { label: 'Cancelled', value: 'cancelled' },
173
+ { label: 'Refunded', value: 'refunded' },
174
+ ],
175
+ },
176
+ email: { type: 'email', label: 'Email' },
177
+ shippingAddress: { type: 'json', label: 'Shipping Address' },
178
+ billingAddress: { type: 'json', label: 'Billing Address' },
179
+ subtotal: { type: 'number', label: 'Subtotal' },
180
+ taxAmount: { type: 'number', label: 'Tax Amount' },
181
+ shippingAmount: { type: 'number', label: 'Shipping Amount' },
182
+ discountAmount: { type: 'number', label: 'Discount Amount' },
183
+ total: { type: 'number', label: 'Total' },
184
+ currency: { type: 'text', label: 'Currency', defaultValue: 'USD' },
185
+ notes: { type: 'text', label: 'Notes' },
186
+ placedAt: { type: 'date', label: 'Placed At', includeTime: true },
187
+ },
188
+ timestamps: true,
189
+ admin: {
190
+ useAsTitle: 'orderNumber',
191
+ group: 'Commerce',
192
+ defaultColumns: ['orderNumber', 'customer', 'status', 'total', 'placedAt'],
193
+ },
194
+ };
195
+ const orderItems = {
196
+ slug: 'order-items',
197
+ labels: { singular: 'Order Item', plural: 'Order Items' },
198
+ fields: {
199
+ order: { type: 'relationship', label: 'Order', relationTo: 'orders' },
200
+ product: {
201
+ type: 'relationship',
202
+ label: 'Product',
203
+ relationTo: 'products',
204
+ },
205
+ variant: {
206
+ type: 'relationship',
207
+ label: 'Variant',
208
+ relationTo: 'product-variants',
209
+ },
210
+ name: { type: 'text', label: 'Product Name' },
211
+ sku: { type: 'text', label: 'SKU' },
212
+ quantity: { type: 'number', label: 'Quantity' },
213
+ unitPrice: { type: 'number', label: 'Unit Price' },
214
+ totalPrice: { type: 'number', label: 'Total Price' },
215
+ },
216
+ timestamps: true,
217
+ admin: { group: 'Commerce' },
218
+ };
219
+ const payments = {
220
+ slug: 'payments',
221
+ labels: { singular: 'Payment', plural: 'Payments' },
222
+ fields: {
223
+ order: { type: 'relationship', label: 'Order', relationTo: 'orders' },
224
+ stripePaymentIntentId: {
225
+ type: 'text',
226
+ label: 'Stripe Payment Intent ID',
227
+ unique: true,
228
+ },
229
+ amount: { type: 'number', label: 'Amount' },
230
+ currency: { type: 'text', label: 'Currency' },
231
+ status: {
232
+ type: 'select',
233
+ label: 'Status',
234
+ options: [
235
+ { label: 'Pending', value: 'pending' },
236
+ { label: 'Succeeded', value: 'succeeded' },
237
+ { label: 'Failed', value: 'failed' },
238
+ { label: 'Refunded', value: 'refunded' },
239
+ ],
240
+ },
241
+ method: { type: 'text', label: 'Payment Method' },
242
+ paidAt: { type: 'date', label: 'Paid At', includeTime: true },
243
+ },
244
+ timestamps: true,
245
+ admin: { group: 'Commerce' },
246
+ };
247
+ const discounts = {
248
+ slug: 'discounts',
249
+ labels: { singular: 'Discount', plural: 'Discounts' },
250
+ fields: {
251
+ code: { type: 'text', label: 'Code', required: true, unique: true },
252
+ type: {
253
+ type: 'select',
254
+ label: 'Discount Type',
255
+ options: [
256
+ { label: 'Percentage', value: 'percentage' },
257
+ { label: 'Fixed Amount', value: 'fixed_amount' },
258
+ { label: 'Free Shipping', value: 'free_shipping' },
259
+ ],
260
+ },
261
+ value: { type: 'number', label: 'Value', required: true },
262
+ minPurchase: { type: 'number', label: 'Minimum Purchase' },
263
+ maxUses: { type: 'number', label: 'Maximum Uses' },
264
+ usedCount: { type: 'number', label: 'Used Count', defaultValue: 0 },
265
+ startsAt: { type: 'date', label: 'Starts At', includeTime: true },
266
+ expiresAt: { type: 'date', label: 'Expires At', includeTime: true },
267
+ isActive: { type: 'boolean', label: 'Active', defaultValue: true },
268
+ applicableTo: {
269
+ type: 'select',
270
+ label: 'Applicable To',
271
+ options: [
272
+ { label: 'All Products', value: 'all' },
273
+ { label: 'Specific Products', value: 'specific_products' },
274
+ { label: 'Specific Categories', value: 'specific_categories' },
275
+ ],
276
+ },
277
+ productIds: { type: 'json', label: 'Product IDs' },
278
+ categoryIds: { type: 'json', label: 'Category IDs' },
279
+ },
280
+ timestamps: true,
281
+ admin: { useAsTitle: 'code', group: 'Commerce' },
282
+ };
283
+ const shippingZones = {
284
+ slug: 'shipping-zones',
285
+ labels: { singular: 'Shipping Zone', plural: 'Shipping Zones' },
286
+ fields: {
287
+ name: { type: 'text', label: 'Name', required: true },
288
+ countries: { type: 'json', label: 'Country Codes' },
289
+ rates: { type: 'json', label: 'Shipping Rates' },
290
+ freeShippingThreshold: {
291
+ type: 'number',
292
+ label: 'Free Shipping Threshold',
293
+ },
294
+ },
295
+ timestamps: true,
296
+ admin: { useAsTitle: 'name', group: 'Commerce' },
297
+ };
298
+ const taxRates = {
299
+ slug: 'tax-rates',
300
+ labels: { singular: 'Tax Rate', plural: 'Tax Rates' },
301
+ fields: {
302
+ name: { type: 'text', label: 'Name', required: true },
303
+ rate: {
304
+ type: 'number',
305
+ label: 'Rate (%)',
306
+ required: true,
307
+ min: 0,
308
+ max: 100,
309
+ step: 0.001,
310
+ },
311
+ country: { type: 'text', label: 'Country' },
312
+ state: { type: 'text', label: 'State' },
313
+ postalCode: { type: 'text', label: 'Postal Code' },
314
+ isDefault: { type: 'boolean', label: 'Default Rate', defaultValue: false },
315
+ priority: { type: 'number', label: 'Priority', defaultValue: 0 },
316
+ },
317
+ timestamps: true,
318
+ admin: { useAsTitle: 'name', group: 'Commerce' },
319
+ };
320
+ /** All collection definitions provided by the commerce plugin. */
321
+ export const commerceCollections = {
322
+ products,
323
+ 'product-variants': productVariants,
324
+ 'product-categories': productCategories,
325
+ 'product-images': productImages,
326
+ carts,
327
+ 'cart-items': cartItems,
328
+ orders,
329
+ 'order-items': orderItems,
330
+ payments,
331
+ discounts,
332
+ 'shipping-zones': shippingZones,
333
+ 'tax-rates': taxRates,
334
+ };
335
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.js","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAyB;IACrC,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,EAAE,QAAQ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AE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;QACrD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,IAAI;YACd,GAAG,EAAE,CAAC;YACN,GAAG,EAAE,GAAG;YACR,IAAI,EAAE,KAAK;SACZ;QACD,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE;QAC3C,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;QACvC,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE;QAClD,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,EAAE;QAC1E,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,EAAE;KACjE;IACD,UAAU,EAAE,IAAI;IAChB,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE;CACjD,CAAA;AAED,kEAAkE;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAyC;IACvE,QAAQ;IACR,kBAAkB,EAAE,eAAe;IACnC,oBAAoB,EAAE,iBAAiB;IACvC,gBAAgB,EAAE,aAAa;IAC/B,KAAK;IACL,YAAY,EAAE,SAAS;IACvB,MAAM;IACN,aAAa,EAAE,UAAU;IACzB,QAAQ;IACR,SAAS;IACT,gBAAgB,EAAE,aAAa;IAC/B,WAAW,EAAE,QAAQ;CACtB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { FieldDefinition } from '@prenta/core';
2
+ /** Commerce injects its own collections rather than adding fields to existing ones. */
3
+ export declare const commerceFields: Record<string, FieldDefinition>;
4
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD,uFAAuF;AACvF,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAM,CAAA"}
package/dist/fields.js ADDED
@@ -0,0 +1,3 @@
1
+ /** Commerce injects its own collections rather than adding fields to existing ones. */
2
+ export const commerceFields = {};
3
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAEA,uFAAuF;AACvF,MAAM,CAAC,MAAM,cAAc,GAAoC,EAAE,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { PluginHook } from '@prenta/core';
2
+ export declare const commerceHooks: PluginHook[];
3
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAgD,MAAM,cAAc,CAAA;AAE5F,eAAO,MAAM,aAAa,EAAE,UAAU,EAmCrC,CAAA"}
package/dist/hooks.js ADDED
@@ -0,0 +1,33 @@
1
+ export const commerceHooks = [
2
+ {
3
+ event: 'afterCreate:orders',
4
+ handler: async (payload) => {
5
+ // Document-lifecycle event: payload is the document; field values live in payload.data.
6
+ const { id: orderId, data } = payload;
7
+ const total = data?.['total'];
8
+ const currency = data?.['currency'] ?? 'USD';
9
+ if (!orderId || total === undefined)
10
+ return;
11
+ // TODO: Integrate with Stripe payment intent creation
12
+ console.info(`[commerce] Syncing order ${orderId} to Stripe — ${currency} ${total}`);
13
+ },
14
+ },
15
+ {
16
+ event: 'afterUpdate:products',
17
+ handler: async (payload) => {
18
+ // Document-lifecycle event: payload is the document; field values live in payload.data.
19
+ const { data } = payload;
20
+ const name = data?.['name'];
21
+ const trackInventory = data?.['trackInventory'];
22
+ const inventoryCount = data?.['inventoryCount'];
23
+ if (!trackInventory || inventoryCount === undefined)
24
+ return;
25
+ const LOW_STOCK_THRESHOLD = 5;
26
+ if (inventoryCount <= LOW_STOCK_THRESHOLD) {
27
+ // TODO: Dispatch notification via configured channel
28
+ console.warn(`[commerce] Low stock alert: "${name}" has ${inventoryCount} unit(s) remaining`);
29
+ }
30
+ },
31
+ },
32
+ ];
33
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAiB;IACzC;QACE,KAAK,EAAE,oBAAoB;QAC3B,OAAO,EAAE,KAAK,EAAE,OAA0B,EAAiB,EAAE;YAC3D,wFAAwF;YACxF,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,OAAoC,CAAA;YAClE,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC,OAAO,CAAuB,CAAA;YACnD,MAAM,QAAQ,GAAI,IAAI,EAAE,CAAC,UAAU,CAAY,IAAI,KAAK,CAAA;YAExD,IAAI,CAAC,OAAO,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAM;YAE3C,sDAAsD;YACtD,OAAO,CAAC,IAAI,CAAC,4BAA4B,OAAO,gBAAgB,QAAQ,IAAI,KAAK,EAAE,CAAC,CAAA;QACtF,CAAC;KACF;IACD;QACE,KAAK,EAAE,sBAAsB;QAC7B,OAAO,EAAE,KAAK,EAAE,OAA0B,EAAiB,EAAE;YAC3D,wFAAwF;YACxF,MAAM,EAAE,IAAI,EAAE,GAAG,OAAoC,CAAA;YACrD,MAAM,IAAI,GAAG,IAAI,EAAE,CAAC,MAAM,CAAuB,CAAA;YACjD,MAAM,cAAc,GAAG,IAAI,EAAE,CAAC,gBAAgB,CAAwB,CAAA;YACtE,MAAM,cAAc,GAAG,IAAI,EAAE,CAAC,gBAAgB,CAAuB,CAAA;YAErE,IAAI,CAAC,cAAc,IAAI,cAAc,KAAK,SAAS;gBAAE,OAAM;YAE3D,MAAM,mBAAmB,GAAG,CAAC,CAAA;YAC7B,IAAI,cAAc,IAAI,mBAAmB,EAAE,CAAC;gBAC1C,qDAAqD;gBACrD,OAAO,CAAC,IAAI,CACV,gCAAgC,IAAI,SAAS,cAAc,oBAAoB,CAChF,CAAA;YACH,CAAC;QACH,CAAC;KACF;CACF,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { type PluginDefinition } from '@prenta/core/config';
2
+ export interface CommercePluginConfig {
3
+ stripe?: {
4
+ secretKey: string;
5
+ webhookSecret: string;
6
+ currency?: string;
7
+ };
8
+ tax?: {
9
+ autoCalculate?: boolean;
10
+ };
11
+ shipping?: {
12
+ enabled?: boolean;
13
+ };
14
+ }
15
+ /** Creates the Prenta Commerce plugin with optional Stripe, tax, and shipping configuration. */
16
+ export declare function commercePlugin(config?: CommercePluginConfig): PluginDefinition;
17
+ export type { CommercePluginConfig as CommerceConfig };
18
+ export { commerceFields } from './fields.js';
19
+ export { commerceCollections } from './collections.js';
20
+ export { commerceHooks } from './hooks.js';
21
+ export { createCommerceClient } from './client.js';
22
+ export type { CommerceClient } from './client.js';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAKzE,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE;QACP,SAAS,EAAE,MAAM,CAAA;QACjB,aAAa,EAAE,MAAM,CAAA;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,GAAG,CAAC,EAAE;QACJ,aAAa,CAAC,EAAE,OAAO,CAAA;KACxB,CAAA;IACD,QAAQ,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;CACF;AAED,gGAAgG;AAChG,wBAAgB,cAAc,CAAC,MAAM,GAAE,oBAAyB,GAAG,gBAAgB,CAYlF;AAED,YAAY,EAAE,oBAAoB,IAAI,cAAc,EAAE,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ import { definePlugin } from '@prenta/core/config';
2
+ import { commerceFields } from './fields.js';
3
+ import { commerceCollections } from './collections.js';
4
+ import { commerceHooks } from './hooks.js';
5
+ /** Creates the Prenta Commerce plugin with optional Stripe, tax, and shipping configuration. */
6
+ export function commercePlugin(config = {}) {
7
+ return definePlugin({
8
+ name: 'commerce',
9
+ fields: commerceFields,
10
+ collections: commerceCollections,
11
+ // No adminNavItems: the commerce collections already surface in the sidebar
12
+ // under their "Commerce" group at their real /<slug> routes (/products,
13
+ // /orders, /discounts, …). The old /commerce/* items pointed at routes the
14
+ // admin router has no view for, so they were dead 404s that also duplicated
15
+ // the working collection nav. Guarded by cms-admin's plugin-nav-resolves test.
16
+ hooks: commerceHooks,
17
+ });
18
+ }
19
+ export { commerceFields } from './fields.js';
20
+ export { commerceCollections } from './collections.js';
21
+ export { commerceHooks } from './hooks.js';
22
+ export { createCommerceClient } from './client.js';
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAyB,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAgB1C,gGAAgG;AAChG,MAAM,UAAU,cAAc,CAAC,SAA+B,EAAE;IAC9D,OAAO,YAAY,CAAC;QAClB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,cAAc;QACtB,WAAW,EAAE,mBAAmB;QAChC,4EAA4E;QAC5E,wEAAwE;QACxE,2EAA2E;QAC3E,4EAA4E;QAC5E,+EAA+E;QAC/E,KAAK,EAAE,aAAa;KACrB,CAAC,CAAA;AACJ,CAAC;AAGD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1,39 @@
1
+ export interface CheckoutLineItem {
2
+ productId: string;
3
+ variantId?: string;
4
+ name: string;
5
+ quantity: number;
6
+ unitPrice: number;
7
+ image?: string;
8
+ }
9
+ export interface ShippingOption {
10
+ id: string;
11
+ label: string;
12
+ amount: number;
13
+ }
14
+ export interface CheckoutSessionOptions {
15
+ lineItems: CheckoutLineItem[];
16
+ successUrl: string;
17
+ cancelUrl: string;
18
+ customerEmail?: string;
19
+ shippingOptions?: ShippingOption[];
20
+ discountCode?: string;
21
+ }
22
+ export interface CheckoutSession {
23
+ id: string;
24
+ url: string;
25
+ expiresAt: Date;
26
+ }
27
+ /**
28
+ * Build the Stripe Checkout Session params from cart line items and options.
29
+ *
30
+ * Pure and money-critical: it converts dollar amounts to integer cents
31
+ * (`Math.round(x * 100)`) for every line item and shipping rate. Extracted from
32
+ * `createCheckoutSession` so this mapping is unit-testable independently of the
33
+ * (still-stubbed) Stripe API call — a cents-rounding or field-shape bug here is
34
+ * a real overcharge/undercharge once the SDK is wired.
35
+ */
36
+ export declare function buildCheckoutSessionParams(options: CheckoutSessionOptions): Record<string, unknown>;
37
+ /** Creates a Stripe Checkout session from cart line items and configuration. */
38
+ export declare function createCheckoutSession(options: CheckoutSessionOptions): Promise<CheckoutSession>;
39
+ //# sourceMappingURL=checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/stripe/checkout.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,gBAAgB,EAAE,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAA;IAClC,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,IAAI,CAAA;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,sBAAsB,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAwCzB;AAED,gFAAgF;AAChF,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,eAAe,CAAC,CAa1B"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Build the Stripe Checkout Session params from cart line items and options.
3
+ *
4
+ * Pure and money-critical: it converts dollar amounts to integer cents
5
+ * (`Math.round(x * 100)`) for every line item and shipping rate. Extracted from
6
+ * `createCheckoutSession` so this mapping is unit-testable independently of the
7
+ * (still-stubbed) Stripe API call — a cents-rounding or field-shape bug here is
8
+ * a real overcharge/undercharge once the SDK is wired.
9
+ */
10
+ export function buildCheckoutSessionParams(options) {
11
+ const stripeLineItems = options.lineItems.map((item) => ({
12
+ price_data: {
13
+ currency: 'usd',
14
+ product_data: {
15
+ name: item.name,
16
+ images: item.image ? [item.image] : [],
17
+ metadata: {
18
+ productId: item.productId,
19
+ ...(item.variantId ? { variantId: item.variantId } : {}),
20
+ },
21
+ },
22
+ unit_amount: Math.round(item.unitPrice * 100),
23
+ },
24
+ quantity: item.quantity,
25
+ }));
26
+ const sessionParams = {
27
+ mode: 'payment',
28
+ line_items: stripeLineItems,
29
+ success_url: options.successUrl,
30
+ cancel_url: options.cancelUrl,
31
+ ...(options.customerEmail ? { customer_email: options.customerEmail } : {}),
32
+ };
33
+ if (options.shippingOptions?.length) {
34
+ sessionParams['shipping_options'] = options.shippingOptions.map((opt) => ({
35
+ shipping_rate_data: {
36
+ display_name: opt.label,
37
+ type: 'fixed_amount',
38
+ fixed_amount: { amount: Math.round(opt.amount * 100), currency: 'usd' },
39
+ },
40
+ }));
41
+ }
42
+ if (options.discountCode) {
43
+ sessionParams['discounts'] = [{ coupon: options.discountCode }];
44
+ }
45
+ return sessionParams;
46
+ }
47
+ /** Creates a Stripe Checkout session from cart line items and configuration. */
48
+ export async function createCheckoutSession(options) {
49
+ const sessionParams = buildCheckoutSessionParams(options);
50
+ // TODO: Call Stripe SDK — stripe.checkout.sessions.create(sessionParams)
51
+ void sessionParams;
52
+ const expiresAt = new Date();
53
+ expiresAt.setMinutes(expiresAt.getMinutes() + 30);
54
+ return {
55
+ id: `cs_stub_${Date.now()}`,
56
+ url: `https://checkout.stripe.com/pay/cs_stub_${Date.now()}`,
57
+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AAC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACxE,kBAAkB,EAAE;gBAClB,YAAY,EAAE,GAAG,CAAC,KAAK;gBACvB,IAAI,EAAE,cAAc;gBACpB,YAAY,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE;aACxE;SACF,CAAC,CAAC,CAAA;IACL,CAAC;IAED,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACzB,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;IACjE,CAAC;IAED,OAAO,aAAa,CAAA;AACtB,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAA+B;IAE/B,MAAM,aAAa,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAA;IAEzD,yEAAyE;IACzE,KAAK,aAAa,CAAA;IAClB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAA;IAC5B,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAA;IAEjD,OAAO;QACL,EAAE,EAAE,WAAW,IAAI,CAAC,GAAG,EAAE,EAAE;QAC3B,GAAG,EAAE,2CAA2C,IAAI,CAAC,GAAG,EAAE,EAAE;QAC5D,SAAS;KACV,CAAA;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ export interface StripeCustomer {
2
+ id: string;
3
+ email: string;
4
+ name?: string;
5
+ metadata: Record<string, string>;
6
+ }
7
+ /** Links an Prenta user to a Stripe customer, creating one if necessary. */
8
+ export declare function syncCustomer(userId: string, email: string): Promise<StripeCustomer>;
9
+ /** Retrieves an existing Stripe customer by email or creates a new one. */
10
+ export declare function getOrCreateCustomer(email: string): Promise<StripeCustomer>;
11
+ //# sourceMappingURL=customer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer.d.ts","sourceRoot":"","sources":["../../src/stripe/customer.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC;AAED,4EAA4E;AAC5E,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAUzF;AAED,2EAA2E;AAC3E,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAShF"}
@@ -0,0 +1,22 @@
1
+ /** Links an Prenta user to a Stripe customer, creating one if necessary. */
2
+ export async function syncCustomer(userId, email) {
3
+ // TODO: Search Stripe for existing customer by metadata.prentaUserId,
4
+ // then create or update accordingly
5
+ const existing = await getOrCreateCustomer(email);
6
+ // TODO: stripe.customers.update(existing.id, { metadata: { prentaUserId: userId } })
7
+ return {
8
+ ...existing,
9
+ metadata: { ...existing.metadata, prentaUserId: userId },
10
+ };
11
+ }
12
+ /** Retrieves an existing Stripe customer by email or creates a new one. */
13
+ export async function getOrCreateCustomer(email) {
14
+ // TODO: stripe.customers.list({ email, limit: 1 })
15
+ // If found, return mapped customer; otherwise stripe.customers.create({ email })
16
+ return {
17
+ id: `cus_stub_${Date.now()}`,
18
+ email,
19
+ metadata: {},
20
+ };
21
+ }
22
+ //# sourceMappingURL=customer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer.js","sourceRoot":"","sources":["../../src/stripe/customer.ts"],"names":[],"mappings":"AAOA,4EAA4E;AAC5E,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAc,EAAE,KAAa;IAC9D,sEAAsE;IACtE,0CAA0C;IAC1C,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAEjD,qFAAqF;IACrF,OAAO;QACL,GAAG,QAAQ;QACX,QAAQ,EAAE,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE;KACzD,CAAA;AACH,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAAa;IACrD,mDAAmD;IACnD,uFAAuF;IAEvF,OAAO;QACL,EAAE,EAAE,YAAY,IAAI,CAAC,GAAG,EAAE,EAAE;QAC5B,KAAK;QACL,QAAQ,EAAE,EAAE;KACb,CAAA;AACH,CAAC"}