@easy-cms/plugin-ecommerce 0.0.0-stage → 0.47.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.
- package/LICENSE +21 -0
- package/README.md +48 -2
- package/dist/admin.js +62 -0
- package/dist/chunk-5ILURANO.js +1937 -0
- package/dist/chunk-KON3VWC6.js +302 -0
- package/dist/client.d.ts +250 -0
- package/dist/client.js +18 -0
- package/dist/index.d.ts +530 -0
- package/dist/index.js +44 -0
- package/dist/payments-tPD3bTTW.d.ts +213 -0
- package/dist/react.d.ts +95 -0
- package/dist/react.js +170 -0
- package/dist/stripe.d.ts +58 -0
- package/dist/stripe.js +90 -0
- package/dist/vue.d.ts +119 -0
- package/dist/vue.js +179 -0
- package/package.json +84 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { Label, Field, FieldTypeDefinition, ID, AuthUser, RequestContext, EasyCMS, MembersSignup, MembersConfig, CollectionConfig, TypedPlugin } from '@easy-cms/core';
|
|
2
|
+
import { O as ORDER_STATUSES, C as CartView, a as Currency, A as Address, b as Adjustment, c as OrderStatus, P as PaymentAdapter } from './payments-tPD3bTTW.js';
|
|
3
|
+
export { d as CURRENCIES, e as CartLine, f as CheckoutResult, g as ConfirmResult, I as InitiateResult, M as ManualAdapterOptions, h as PaymentTransaction, S as ShopSettings, T as TRANSACTION_STATUSES, i as TransactionStatus, j as definePaymentAdapter, k as formatPrice, m as manualAdapter, p as priceField } from './payments-tPD3bTTW.js';
|
|
4
|
+
|
|
5
|
+
declare module '@easy-cms/core' {
|
|
6
|
+
interface CustomFieldTypes {
|
|
7
|
+
/** An amount in a currency's smallest unit (satang, cents), shown as `฿1,234.50`. */
|
|
8
|
+
price: {
|
|
9
|
+
value: number;
|
|
10
|
+
options: {
|
|
11
|
+
/** ISO 4217, e.g. `THB`. */
|
|
12
|
+
readonly currency?: string;
|
|
13
|
+
/** Digits after the point. Default 2. */
|
|
14
|
+
readonly decimals?: number;
|
|
15
|
+
readonly symbol?: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
declare const SHOP_COLLECTIONS: readonly ["products", "variant-types", "variant-options", "variants", "carts", "addresses", "orders", "transactions", "shop-counters"];
|
|
21
|
+
type ShopCollection = (typeof SHOP_COLLECTIONS)[number];
|
|
22
|
+
/**
|
|
23
|
+
* `type: 'price'`: a whole number of a currency's smallest unit (`123450` for ฿1,234.50), typed
|
|
24
|
+
* and shown in the admin as money.
|
|
25
|
+
*/
|
|
26
|
+
declare const price: FieldTypeDefinition;
|
|
27
|
+
/** The fields of an address, Thai style; `addresses.fields` replaces them. */
|
|
28
|
+
declare function addressFields(countries: readonly string[]): Field[];
|
|
29
|
+
declare const STATUS_LABELS: Record<(typeof ORDER_STATUSES)[number], Label>;
|
|
30
|
+
|
|
31
|
+
type Data = Record<string, unknown>;
|
|
32
|
+
/** A guest's cart: its id and the secret the browser keeps. */
|
|
33
|
+
interface CartRef {
|
|
34
|
+
readonly id: ID;
|
|
35
|
+
readonly secret: string;
|
|
36
|
+
}
|
|
37
|
+
/** What `totals` receives. */
|
|
38
|
+
interface TotalsArgs {
|
|
39
|
+
readonly cart: CartView;
|
|
40
|
+
readonly currency: Currency;
|
|
41
|
+
/** At checkout; `undefined` while shopping. */
|
|
42
|
+
readonly shippingAddress?: Address;
|
|
43
|
+
readonly customer: AuthUser | null;
|
|
44
|
+
readonly context: RequestContext;
|
|
45
|
+
readonly cms: EasyCMS;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Shipping, tax and discounts: what to add to (or, negative, take off) a cart's subtotal. Runs
|
|
49
|
+
* for the cart and again at checkout, with the address.
|
|
50
|
+
*/
|
|
51
|
+
type TotalsFn = (args: TotalsArgs) => readonly Adjustment[] | Promise<readonly Adjustment[]>;
|
|
52
|
+
/** An order as emails and events see it. */
|
|
53
|
+
type OrderDoc = Data & {
|
|
54
|
+
id: ID;
|
|
55
|
+
orderNumber: string;
|
|
56
|
+
status: OrderStatus;
|
|
57
|
+
email: string;
|
|
58
|
+
currency: string;
|
|
59
|
+
total: number;
|
|
60
|
+
};
|
|
61
|
+
type OrderEvent = 'created' | 'paid' | 'fulfilled' | 'cancelled' | 'refunded';
|
|
62
|
+
|
|
63
|
+
/** What an order email function receives. */
|
|
64
|
+
interface OrderEmailArgs {
|
|
65
|
+
readonly order: OrderDoc;
|
|
66
|
+
/** `en` or `th`: the language of the checkout. */
|
|
67
|
+
readonly locale: string;
|
|
68
|
+
readonly currency: Currency;
|
|
69
|
+
/** For a manual payment (bank transfer): what to tell the customer. */
|
|
70
|
+
readonly instructions: string | null;
|
|
71
|
+
readonly cms: EasyCMS;
|
|
72
|
+
}
|
|
73
|
+
interface OrderEmail {
|
|
74
|
+
readonly subject: string;
|
|
75
|
+
readonly text: string;
|
|
76
|
+
readonly html?: string;
|
|
77
|
+
}
|
|
78
|
+
type OrderEmailFn = (args: OrderEmailArgs) => OrderEmail | Promise<OrderEmail>;
|
|
79
|
+
|
|
80
|
+
interface EcommerceOptions<Cur extends string = string> {
|
|
81
|
+
/** How customers pay: `stripeAdapter()` from `@easy-cms/plugin-ecommerce/stripe`, `manualAdapter()`. */
|
|
82
|
+
readonly payments: {
|
|
83
|
+
readonly methods: readonly PaymentAdapter[];
|
|
84
|
+
};
|
|
85
|
+
readonly currencies?: {
|
|
86
|
+
/**
|
|
87
|
+
* Currencies prices are given in: codes of the built-in ones (`THB`, `USD`, `EUR`, `GBP`,
|
|
88
|
+
* `JPY`) or your own. Each adds a price field, so adding one needs a migration. Default
|
|
89
|
+
* `['THB']`.
|
|
90
|
+
*/
|
|
91
|
+
readonly supported?: readonly (Cur | (Currency & {
|
|
92
|
+
readonly code: Cur;
|
|
93
|
+
}))[];
|
|
94
|
+
/** Default: the first. */
|
|
95
|
+
readonly default?: Cur;
|
|
96
|
+
};
|
|
97
|
+
readonly products?: {
|
|
98
|
+
/** Colors, sizes and the like, each with its own price and stock. Default `true`. */
|
|
99
|
+
readonly variants?: boolean;
|
|
100
|
+
/** More fields for products. */
|
|
101
|
+
readonly fields?: readonly Field[];
|
|
102
|
+
};
|
|
103
|
+
/** Count stock, take it when an order is made and put it back when one is cancelled. Default `true`. */
|
|
104
|
+
readonly inventory?: boolean;
|
|
105
|
+
readonly carts?: {
|
|
106
|
+
/** People who aren't signed in can shop and pay. Default `true`. */
|
|
107
|
+
readonly allowGuests?: boolean;
|
|
108
|
+
/** Guests' carts left this many days are deleted. Default 30. */
|
|
109
|
+
readonly guestCartDays?: number;
|
|
110
|
+
};
|
|
111
|
+
readonly addresses?: {
|
|
112
|
+
/** Countries the shop sends to (ISO 3166-1 alpha-2). Default `['TH']`. */
|
|
113
|
+
readonly supportedCountries?: readonly string[];
|
|
114
|
+
/** Replaces the address fields (name, phone, line1, …, country). */
|
|
115
|
+
readonly fields?: readonly Field[];
|
|
116
|
+
};
|
|
117
|
+
/** Customers' accounts: users with a role of the site (`auth.members`). */
|
|
118
|
+
readonly customers?: {
|
|
119
|
+
/** Default `customer`. */
|
|
120
|
+
readonly role?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Visitors create an account themselves (`POST <api>/users/signup`), confirming their email.
|
|
123
|
+
* `false` to make accounts some other way. Default `true`.
|
|
124
|
+
*/
|
|
125
|
+
readonly signup?: boolean | Omit<MembersSignup, 'role'>;
|
|
126
|
+
/** The site's pages for email links (`auth.members.pages`). */
|
|
127
|
+
readonly pages?: MembersConfig['pages'];
|
|
128
|
+
};
|
|
129
|
+
/** Shipping, tax and discounts, worked out from the cart (and at checkout, the address). */
|
|
130
|
+
readonly totals?: TotalsFn;
|
|
131
|
+
readonly orders?: {
|
|
132
|
+
/** An order's number from its count (1, 2, …). Default: `1001`, `1002`, … */
|
|
133
|
+
readonly number?: (n: number) => string;
|
|
134
|
+
};
|
|
135
|
+
readonly emails?: {
|
|
136
|
+
/** To the customer when an order is made. `false` for none. */
|
|
137
|
+
readonly orderConfirmation?: OrderEmailFn | false;
|
|
138
|
+
/** To the customer when a manual payment is marked received. `false` for none. */
|
|
139
|
+
readonly paymentReceived?: OrderEmailFn | false;
|
|
140
|
+
/** Who hears about new orders, e.g. `shop@example.com`. */
|
|
141
|
+
readonly notify?: string | readonly string[];
|
|
142
|
+
readonly newOrder?: OrderEmailFn;
|
|
143
|
+
};
|
|
144
|
+
/** Change a collection the shop makes, e.g. add fields or access. */
|
|
145
|
+
readonly overrides?: {
|
|
146
|
+
readonly [S in ShopCollection]?: (collection: CollectionConfig) => CollectionConfig;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* The label of the shop's group in the admin menu (`shop`, with `catalog`, `sales` and
|
|
150
|
+
* `customers`). Default `Shop` / `ร้านค้า`. Declare `{ id: 'shop', … }` in `admin.nav` for more.
|
|
151
|
+
*/
|
|
152
|
+
readonly group?: Label;
|
|
153
|
+
}
|
|
154
|
+
type Price<C extends string> = {
|
|
155
|
+
readonly name: `priceIn${C}`;
|
|
156
|
+
readonly type: 'number';
|
|
157
|
+
};
|
|
158
|
+
/** What `ecommercePlugin(options)` adds, for the types the Local API infers from the config. */
|
|
159
|
+
type EcommercePluginTypes<Cur extends string> = {
|
|
160
|
+
/** Accounts made by signing up confirm their email (`auth.members.signup`). */
|
|
161
|
+
readonly fields: {
|
|
162
|
+
readonly users: readonly [{
|
|
163
|
+
readonly name: 'emailVerified';
|
|
164
|
+
readonly type: 'boolean';
|
|
165
|
+
}];
|
|
166
|
+
};
|
|
167
|
+
readonly collections: readonly [
|
|
168
|
+
{
|
|
169
|
+
readonly slug: 'products';
|
|
170
|
+
readonly drafts: true;
|
|
171
|
+
readonly fields: readonly [
|
|
172
|
+
{
|
|
173
|
+
readonly name: 'title';
|
|
174
|
+
readonly type: 'text';
|
|
175
|
+
readonly required: true;
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
readonly name: 'slug';
|
|
179
|
+
readonly type: 'slug';
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
readonly name: 'description';
|
|
183
|
+
readonly type: 'richText';
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
readonly name: 'images';
|
|
187
|
+
readonly type: 'upload';
|
|
188
|
+
readonly hasMany: true;
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
readonly name: 'sku';
|
|
192
|
+
readonly type: 'text';
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
readonly name: 'inventory';
|
|
196
|
+
readonly type: 'number';
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
readonly name: 'variantTypes';
|
|
200
|
+
readonly type: 'relationship';
|
|
201
|
+
readonly to: 'variant-types';
|
|
202
|
+
readonly hasMany: true;
|
|
203
|
+
},
|
|
204
|
+
...Price<Cur>[]
|
|
205
|
+
];
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
readonly slug: 'variant-types';
|
|
209
|
+
readonly fields: readonly [
|
|
210
|
+
{
|
|
211
|
+
readonly name: 'name';
|
|
212
|
+
readonly type: 'text';
|
|
213
|
+
readonly required: true;
|
|
214
|
+
}
|
|
215
|
+
];
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
readonly slug: 'variant-options';
|
|
219
|
+
readonly fields: readonly [
|
|
220
|
+
{
|
|
221
|
+
readonly name: 'type';
|
|
222
|
+
readonly type: 'relationship';
|
|
223
|
+
readonly to: 'variant-types';
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
readonly name: 'label';
|
|
227
|
+
readonly type: 'text';
|
|
228
|
+
readonly required: true;
|
|
229
|
+
}
|
|
230
|
+
];
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
readonly slug: 'variants';
|
|
234
|
+
readonly fields: readonly [
|
|
235
|
+
{
|
|
236
|
+
readonly name: 'product';
|
|
237
|
+
readonly type: 'relationship';
|
|
238
|
+
readonly to: 'products';
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
readonly name: 'options';
|
|
242
|
+
readonly type: 'relationship';
|
|
243
|
+
readonly to: 'variant-options';
|
|
244
|
+
readonly hasMany: true;
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
readonly name: 'title';
|
|
248
|
+
readonly type: 'text';
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
readonly name: 'sku';
|
|
252
|
+
readonly type: 'text';
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
readonly name: 'inventory';
|
|
256
|
+
readonly type: 'number';
|
|
257
|
+
},
|
|
258
|
+
...Price<Cur>[]
|
|
259
|
+
];
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
readonly slug: 'carts';
|
|
263
|
+
readonly fields: readonly [
|
|
264
|
+
{
|
|
265
|
+
readonly name: 'customer';
|
|
266
|
+
readonly type: 'relationship';
|
|
267
|
+
readonly to: 'users';
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
readonly name: 'currency';
|
|
271
|
+
readonly type: 'text';
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
readonly name: 'items';
|
|
275
|
+
readonly type: 'array';
|
|
276
|
+
readonly fields: readonly [
|
|
277
|
+
{
|
|
278
|
+
readonly name: 'product';
|
|
279
|
+
readonly type: 'relationship';
|
|
280
|
+
readonly to: 'products';
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
readonly name: 'variant';
|
|
284
|
+
readonly type: 'relationship';
|
|
285
|
+
readonly to: 'variants';
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
readonly name: 'quantity';
|
|
289
|
+
readonly type: 'number';
|
|
290
|
+
}
|
|
291
|
+
];
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
readonly name: 'purchasedAt';
|
|
295
|
+
readonly type: 'date';
|
|
296
|
+
}
|
|
297
|
+
];
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
readonly slug: 'addresses';
|
|
301
|
+
readonly fields: readonly [
|
|
302
|
+
{
|
|
303
|
+
readonly name: 'customer';
|
|
304
|
+
readonly type: 'relationship';
|
|
305
|
+
readonly to: 'users';
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
readonly name: 'name';
|
|
309
|
+
readonly type: 'text';
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
readonly name: 'phone';
|
|
313
|
+
readonly type: 'text';
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
readonly name: 'line1';
|
|
317
|
+
readonly type: 'text';
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
readonly name: 'line2';
|
|
321
|
+
readonly type: 'text';
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
readonly name: 'subdistrict';
|
|
325
|
+
readonly type: 'text';
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
readonly name: 'district';
|
|
329
|
+
readonly type: 'text';
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
readonly name: 'province';
|
|
333
|
+
readonly type: 'text';
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
readonly name: 'postalCode';
|
|
337
|
+
readonly type: 'text';
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
readonly name: 'country';
|
|
341
|
+
readonly type: 'text';
|
|
342
|
+
}
|
|
343
|
+
];
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
readonly slug: 'orders';
|
|
347
|
+
readonly fields: readonly [
|
|
348
|
+
{
|
|
349
|
+
readonly name: 'orderNumber';
|
|
350
|
+
readonly type: 'text';
|
|
351
|
+
readonly required: true;
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
readonly name: 'status';
|
|
355
|
+
readonly type: 'select';
|
|
356
|
+
readonly options: readonly ['pending', 'paid', 'fulfilled', 'cancelled', 'refunded'];
|
|
357
|
+
readonly required: true;
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
readonly name: 'customer';
|
|
361
|
+
readonly type: 'relationship';
|
|
362
|
+
readonly to: 'users';
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
readonly name: 'email';
|
|
366
|
+
readonly type: 'email';
|
|
367
|
+
readonly required: true;
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
readonly name: 'currency';
|
|
371
|
+
readonly type: 'text';
|
|
372
|
+
readonly required: true;
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
readonly name: 'items';
|
|
376
|
+
readonly type: 'array';
|
|
377
|
+
readonly fields: readonly [
|
|
378
|
+
{
|
|
379
|
+
readonly name: 'product';
|
|
380
|
+
readonly type: 'relationship';
|
|
381
|
+
readonly to: 'products';
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
readonly name: 'variant';
|
|
385
|
+
readonly type: 'relationship';
|
|
386
|
+
readonly to: 'variants';
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
readonly name: 'title';
|
|
390
|
+
readonly type: 'text';
|
|
391
|
+
readonly required: true;
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
readonly name: 'sku';
|
|
395
|
+
readonly type: 'text';
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
readonly name: 'unitPrice';
|
|
399
|
+
readonly type: 'number';
|
|
400
|
+
readonly required: true;
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
readonly name: 'quantity';
|
|
404
|
+
readonly type: 'number';
|
|
405
|
+
readonly required: true;
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
readonly name: 'total';
|
|
409
|
+
readonly type: 'number';
|
|
410
|
+
readonly required: true;
|
|
411
|
+
}
|
|
412
|
+
];
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
readonly name: 'subtotal';
|
|
416
|
+
readonly type: 'number';
|
|
417
|
+
readonly required: true;
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
readonly name: 'adjustments';
|
|
421
|
+
readonly type: 'array';
|
|
422
|
+
readonly fields: readonly [
|
|
423
|
+
{
|
|
424
|
+
readonly name: 'label';
|
|
425
|
+
readonly type: 'text';
|
|
426
|
+
readonly required: true;
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
readonly name: 'amount';
|
|
430
|
+
readonly type: 'number';
|
|
431
|
+
readonly required: true;
|
|
432
|
+
}
|
|
433
|
+
];
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
readonly name: 'total';
|
|
437
|
+
readonly type: 'number';
|
|
438
|
+
readonly required: true;
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
readonly name: 'shippingAddress';
|
|
442
|
+
readonly type: 'json';
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
readonly name: 'payment';
|
|
446
|
+
readonly type: 'text';
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
readonly name: 'stockShort';
|
|
450
|
+
readonly type: 'boolean';
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
readonly name: 'paidAt';
|
|
454
|
+
readonly type: 'date';
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
readonly name: 'locale';
|
|
458
|
+
readonly type: 'text';
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
readonly name: 'note';
|
|
462
|
+
readonly type: 'textarea';
|
|
463
|
+
}
|
|
464
|
+
];
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
readonly slug: 'transactions';
|
|
468
|
+
readonly fields: readonly [
|
|
469
|
+
{
|
|
470
|
+
readonly name: 'status';
|
|
471
|
+
readonly type: 'text';
|
|
472
|
+
readonly required: true;
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
readonly name: 'method';
|
|
476
|
+
readonly type: 'text';
|
|
477
|
+
readonly required: true;
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
readonly name: 'amount';
|
|
481
|
+
readonly type: 'number';
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
readonly name: 'currency';
|
|
485
|
+
readonly type: 'text';
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
readonly name: 'email';
|
|
489
|
+
readonly type: 'email';
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
readonly name: 'order';
|
|
493
|
+
readonly type: 'relationship';
|
|
494
|
+
readonly to: 'orders';
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
readonly name: 'data';
|
|
498
|
+
readonly type: 'json';
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
readonly name: 'reference';
|
|
502
|
+
readonly type: 'text';
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
readonly name: 'error';
|
|
506
|
+
readonly type: 'text';
|
|
507
|
+
}
|
|
508
|
+
];
|
|
509
|
+
}
|
|
510
|
+
];
|
|
511
|
+
};
|
|
512
|
+
/** Events the shop sends to webhooks that list them (`events: ['order.paid']`). */
|
|
513
|
+
declare const ORDER_EVENTS: readonly ["order.created", "order.paid", "order.fulfilled", "order.cancelled", "order.refunded"];
|
|
514
|
+
/**
|
|
515
|
+
* For payment adapters' endpoints (e.g. a provider's webhook): the payment with this reference
|
|
516
|
+
* (the `reference` the adapter gave at `initiate`) went through. Makes its order, once.
|
|
517
|
+
*/
|
|
518
|
+
declare function paymentSucceeded(reference: string): Promise<{
|
|
519
|
+
order: ID;
|
|
520
|
+
} | null>;
|
|
521
|
+
/** For payment adapters' endpoints: the payment with this reference failed. */
|
|
522
|
+
declare function paymentFailed(reference: string, error: string): Promise<void>;
|
|
523
|
+
/**
|
|
524
|
+
* A shop: products with variants and prices in several currencies, carts (guests too), checkout
|
|
525
|
+
* with Stripe or a bank transfer, orders made exactly once, stock, customer accounts, emails and
|
|
526
|
+
* events. Pages use the `/client`, `/react` or `/vue` kit.
|
|
527
|
+
*/
|
|
528
|
+
declare function ecommercePlugin<const Cur extends string = 'THB'>(options: EcommerceOptions<Cur>): TypedPlugin<EcommercePluginTypes<Cur>>;
|
|
529
|
+
|
|
530
|
+
export { Address, Adjustment, type CartRef, CartView, Currency, type EcommerceOptions, type EcommercePluginTypes, ORDER_EVENTS, ORDER_STATUSES, type OrderDoc, type OrderEmail, type OrderEmailArgs, type OrderEmailFn, type OrderEvent, OrderStatus, PaymentAdapter, SHOP_COLLECTIONS, STATUS_LABELS, type ShopCollection, type TotalsArgs, type TotalsFn, addressFields, ecommercePlugin, paymentFailed, paymentSucceeded, price };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CURRENCIES,
|
|
3
|
+
ORDER_EVENTS,
|
|
4
|
+
ORDER_STATUSES,
|
|
5
|
+
SHOP_COLLECTIONS,
|
|
6
|
+
STATUS_LABELS,
|
|
7
|
+
TRANSACTION_STATUSES,
|
|
8
|
+
addressFields,
|
|
9
|
+
ecommercePlugin,
|
|
10
|
+
formatPrice,
|
|
11
|
+
paymentFailed,
|
|
12
|
+
paymentSucceeded,
|
|
13
|
+
price,
|
|
14
|
+
priceField
|
|
15
|
+
} from "./chunk-5ILURANO.js";
|
|
16
|
+
|
|
17
|
+
// src/payments.ts
|
|
18
|
+
var definePaymentAdapter = (adapter) => adapter;
|
|
19
|
+
function manualAdapter(options = {}) {
|
|
20
|
+
return {
|
|
21
|
+
name: options.name ?? "bank-transfer",
|
|
22
|
+
label: options.label ?? { en: "Bank transfer", th: "\u0E42\u0E2D\u0E19\u0E40\u0E07\u0E34\u0E19" },
|
|
23
|
+
manual: true,
|
|
24
|
+
...options.instructions ? { instructions: options.instructions } : {},
|
|
25
|
+
initiate: () => ({})
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
CURRENCIES,
|
|
30
|
+
ORDER_EVENTS,
|
|
31
|
+
ORDER_STATUSES,
|
|
32
|
+
SHOP_COLLECTIONS,
|
|
33
|
+
STATUS_LABELS,
|
|
34
|
+
TRANSACTION_STATUSES,
|
|
35
|
+
addressFields,
|
|
36
|
+
definePaymentAdapter,
|
|
37
|
+
ecommercePlugin,
|
|
38
|
+
formatPrice,
|
|
39
|
+
manualAdapter,
|
|
40
|
+
paymentFailed,
|
|
41
|
+
paymentSucceeded,
|
|
42
|
+
price,
|
|
43
|
+
priceField
|
|
44
|
+
};
|