@moksa/plugin-commerce-retention 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ // Auto-generated by emdash-plugin build. Do not edit.
2
+ import type { PluginDescriptor } from "emdash";
3
+
4
+ declare const descriptor: PluginDescriptor;
5
+ export default descriptor;
package/dist/index.mjs ADDED
@@ -0,0 +1,609 @@
1
+ // Auto-generated by emdash-plugin build. Do not edit.
2
+ // Source: emdash-plugin.jsonc + package.json
3
+ //
4
+ // Default-exports a sandboxed plugin descriptor. Pass it directly into
5
+ // emdash's `plugins:` or `sandboxed:` array — no factory call needed.
6
+
7
+ /** @type {import("emdash").PluginDescriptor} */
8
+ const descriptor = Object.freeze({
9
+ "id": "moksa-commerce-retention",
10
+ "version": "0.1.1",
11
+ "format": "standard",
12
+ "entrypoint": "@moksa/plugin-commerce-retention/sandbox",
13
+ "capabilities": [
14
+ "content:read",
15
+ "content:revisions:read",
16
+ "content:write",
17
+ "content:publish",
18
+ "taxonomies:read",
19
+ "taxonomies:write",
20
+ "email:send"
21
+ ],
22
+ "allowedHosts": [],
23
+ "storage": {
24
+ "carts": {
25
+ "indexes": [
26
+ "status",
27
+ "token",
28
+ "cartToken",
29
+ "owner",
30
+ "orderNumber",
31
+ "createdAt",
32
+ "lastActivityAt",
33
+ [
34
+ "status",
35
+ "lastActivityAt"
36
+ ]
37
+ ]
38
+ },
39
+ "owners": {
40
+ "indexes": [
41
+ "updatedAt"
42
+ ]
43
+ },
44
+ "optouts": {
45
+ "indexes": [
46
+ "createdAt"
47
+ ]
48
+ },
49
+ "sales": {
50
+ "indexes": [
51
+ "units"
52
+ ]
53
+ },
54
+ "registry": {
55
+ "indexes": [
56
+ "createdAt"
57
+ ]
58
+ },
59
+ "events": {
60
+ "indexes": [
61
+ "createdAt"
62
+ ]
63
+ },
64
+ "marks": {
65
+ "indexes": [
66
+ "createdAt"
67
+ ]
68
+ },
69
+ "reports": {
70
+ "indexes": [
71
+ "status",
72
+ "nextAt",
73
+ [
74
+ "status",
75
+ "nextAt"
76
+ ]
77
+ ]
78
+ }
79
+ },
80
+ "hooks": [
81
+ "plugin:activate",
82
+ "cron",
83
+ "content:afterSave",
84
+ "content:afterPublish",
85
+ "content:afterUnpublish",
86
+ "content:afterDelete"
87
+ ],
88
+ "routes": [
89
+ {
90
+ "name": "migrate/import",
91
+ "methods": [
92
+ "POST"
93
+ ],
94
+ "permission": "plugins:manage"
95
+ },
96
+ {
97
+ "name": "migrate/kv",
98
+ "methods": [
99
+ "POST"
100
+ ],
101
+ "permission": "plugins:manage"
102
+ },
103
+ {
104
+ "name": "migrate/stats",
105
+ "methods": [
106
+ "GET",
107
+ "POST"
108
+ ],
109
+ "permission": "plugins:manage"
110
+ },
111
+ {
112
+ "name": "bus/events",
113
+ "methods": [
114
+ "POST"
115
+ ],
116
+ "request": {
117
+ "body": "text",
118
+ "maxBytes": 262144,
119
+ "headers": [
120
+ "x-moksa-bus-ts",
121
+ "x-moksa-bus-id",
122
+ "x-moksa-bus-sig"
123
+ ]
124
+ },
125
+ "public": true
126
+ },
127
+ {
128
+ "name": "bus/reports/due",
129
+ "methods": [
130
+ "POST"
131
+ ],
132
+ "request": {
133
+ "body": "text",
134
+ "maxBytes": 262144,
135
+ "headers": [
136
+ "x-moksa-bus-ts",
137
+ "x-moksa-bus-id",
138
+ "x-moksa-bus-sig"
139
+ ]
140
+ },
141
+ "public": true
142
+ },
143
+ {
144
+ "name": "bus/reports/ack",
145
+ "methods": [
146
+ "POST"
147
+ ],
148
+ "request": {
149
+ "body": "text",
150
+ "maxBytes": 262144,
151
+ "headers": [
152
+ "x-moksa-bus-ts",
153
+ "x-moksa-bus-id",
154
+ "x-moksa-bus-sig"
155
+ ]
156
+ },
157
+ "public": true
158
+ },
159
+ {
160
+ "name": "bus/retention/capture",
161
+ "methods": [
162
+ "POST"
163
+ ],
164
+ "request": {
165
+ "body": "text",
166
+ "maxBytes": 262144,
167
+ "headers": [
168
+ "x-moksa-bus-ts",
169
+ "x-moksa-bus-id",
170
+ "x-moksa-bus-sig"
171
+ ]
172
+ },
173
+ "public": true
174
+ },
175
+ {
176
+ "name": "bus/retention/status",
177
+ "methods": [
178
+ "POST"
179
+ ],
180
+ "request": {
181
+ "body": "text",
182
+ "maxBytes": 262144,
183
+ "headers": [
184
+ "x-moksa-bus-ts",
185
+ "x-moksa-bus-id",
186
+ "x-moksa-bus-sig"
187
+ ]
188
+ },
189
+ "public": true
190
+ },
191
+ {
192
+ "name": "bus/retention/recover",
193
+ "methods": [
194
+ "POST"
195
+ ],
196
+ "request": {
197
+ "body": "text",
198
+ "maxBytes": 262144,
199
+ "headers": [
200
+ "x-moksa-bus-ts",
201
+ "x-moksa-bus-id",
202
+ "x-moksa-bus-sig"
203
+ ]
204
+ },
205
+ "public": true
206
+ },
207
+ {
208
+ "name": "bus/retention/stop",
209
+ "methods": [
210
+ "POST"
211
+ ],
212
+ "request": {
213
+ "body": "text",
214
+ "maxBytes": 262144,
215
+ "headers": [
216
+ "x-moksa-bus-ts",
217
+ "x-moksa-bus-id",
218
+ "x-moksa-bus-sig"
219
+ ]
220
+ },
221
+ "public": true
222
+ },
223
+ {
224
+ "name": "bus/retention/picks",
225
+ "methods": [
226
+ "POST"
227
+ ],
228
+ "request": {
229
+ "body": "text",
230
+ "maxBytes": 262144,
231
+ "headers": [
232
+ "x-moksa-bus-ts",
233
+ "x-moksa-bus-id",
234
+ "x-moksa-bus-sig"
235
+ ]
236
+ },
237
+ "public": true
238
+ },
239
+ {
240
+ "name": "bus/retention/recommend",
241
+ "methods": [
242
+ "POST"
243
+ ],
244
+ "request": {
245
+ "body": "text",
246
+ "maxBytes": 262144,
247
+ "headers": [
248
+ "x-moksa-bus-ts",
249
+ "x-moksa-bus-id",
250
+ "x-moksa-bus-sig"
251
+ ]
252
+ },
253
+ "public": true
254
+ },
255
+ {
256
+ "name": "carts/list",
257
+ "methods": [
258
+ "GET",
259
+ "POST"
260
+ ],
261
+ "permission": "plugins:manage"
262
+ },
263
+ {
264
+ "name": "carts/report",
265
+ "methods": [
266
+ "GET",
267
+ "POST"
268
+ ],
269
+ "permission": "plugins:manage"
270
+ },
271
+ {
272
+ "name": "carts/send",
273
+ "methods": [
274
+ "GET",
275
+ "POST"
276
+ ],
277
+ "permission": "plugins:manage"
278
+ },
279
+ {
280
+ "name": "carts/delete",
281
+ "methods": [
282
+ "GET",
283
+ "POST"
284
+ ],
285
+ "permission": "plugins:manage"
286
+ },
287
+ {
288
+ "name": "products/export",
289
+ "methods": [
290
+ "GET",
291
+ "POST"
292
+ ],
293
+ "permission": "plugins:manage"
294
+ },
295
+ {
296
+ "name": "products/import",
297
+ "methods": [
298
+ "GET",
299
+ "POST"
300
+ ],
301
+ "permission": "plugins:manage"
302
+ },
303
+ {
304
+ "name": "admin",
305
+ "permission": "plugins:manage"
306
+ }
307
+ ],
308
+ "mcp": {
309
+ "tools": [
310
+ {
311
+ "name": "list_abandoned_carts",
312
+ "description": "Abandoned carts (未結帳購物車): shopper, items, subtotal, status (open, recovered, converted, expired, emptied, unsubscribed, withdrawn), reminders sent, coupon and recovered order.",
313
+ "route": "carts/list",
314
+ "permission": "plugins:manage",
315
+ "destructive": false,
316
+ "inputSchema": {
317
+ "$schema": "http://json-schema.org/draft-07/schema#",
318
+ "type": "object",
319
+ "properties": {
320
+ "status": {
321
+ "enum": [
322
+ "all",
323
+ "open",
324
+ "recovered",
325
+ "converted",
326
+ "expired",
327
+ "emptied",
328
+ "unsubscribed",
329
+ "withdrawn"
330
+ ],
331
+ "default": "all"
332
+ },
333
+ "search": {
334
+ "anyOf": [
335
+ {
336
+ "type": "string",
337
+ "maxLength": 100
338
+ },
339
+ {
340
+ "type": "null"
341
+ }
342
+ ]
343
+ },
344
+ "page": {
345
+ "type": "integer",
346
+ "minimum": 1,
347
+ "maximum": 10000,
348
+ "default": 1
349
+ },
350
+ "perPage": {
351
+ "type": "integer",
352
+ "minimum": 1,
353
+ "maximum": 100,
354
+ "default": 30
355
+ }
356
+ },
357
+ "additionalProperties": true
358
+ }
359
+ },
360
+ {
361
+ "name": "abandoned_cart_report",
362
+ "description": "Abandoned-cart recovery report for the last N days: carts tracked, reminded, clicked, recovered, recovery rate (%), recovered revenue (paid orders) and open cart value.",
363
+ "route": "carts/report",
364
+ "permission": "plugins:manage",
365
+ "destructive": false,
366
+ "inputSchema": {
367
+ "$schema": "http://json-schema.org/draft-07/schema#",
368
+ "type": "object",
369
+ "properties": {
370
+ "days": {
371
+ "type": "integer",
372
+ "minimum": 1,
373
+ "maximum": 365,
374
+ "default": 30
375
+ }
376
+ },
377
+ "additionalProperties": true
378
+ }
379
+ },
380
+ {
381
+ "name": "send_abandoned_cart_reminders",
382
+ "description": "Send abandoned-cart reminders now: with id, the next reminder for that one cart; without id, every reminder that is due (same as the scheduled job). Sends email to shoppers; each reminder goes out once.",
383
+ "route": "carts/send",
384
+ "permission": "plugins:manage",
385
+ "destructive": true,
386
+ "inputSchema": {
387
+ "$schema": "http://json-schema.org/draft-07/schema#",
388
+ "type": "object",
389
+ "properties": {
390
+ "id": {
391
+ "anyOf": [
392
+ {
393
+ "type": "string",
394
+ "maxLength": 40
395
+ },
396
+ {
397
+ "type": "null"
398
+ }
399
+ ]
400
+ }
401
+ },
402
+ "additionalProperties": true
403
+ }
404
+ },
405
+ {
406
+ "name": "delete_abandoned_cart",
407
+ "description": "Delete one abandoned-cart record (stops its reminders).",
408
+ "route": "carts/delete",
409
+ "permission": "plugins:manage",
410
+ "destructive": true,
411
+ "inputSchema": {
412
+ "$schema": "http://json-schema.org/draft-07/schema#",
413
+ "type": "object",
414
+ "properties": {
415
+ "id": {
416
+ "type": "string",
417
+ "minLength": 1,
418
+ "maxLength": 40
419
+ }
420
+ },
421
+ "additionalProperties": true,
422
+ "required": [
423
+ "id"
424
+ ]
425
+ }
426
+ },
427
+ {
428
+ "name": "export_products_csv",
429
+ "description": "Export products as CSV (WooCommerce-style rows: simple, variable, variation) with prices, sale prices, categories, attributes and up/cross-sells, one page at a time: pass the returned cursor until it is null and join the csv parts (the header comes with the first page). The stock column is blank: stock is core's (list_inventory).",
430
+ "route": "products/export",
431
+ "permission": "plugins:manage",
432
+ "destructive": false,
433
+ "inputSchema": {
434
+ "$schema": "http://json-schema.org/draft-07/schema#",
435
+ "type": "object",
436
+ "properties": {
437
+ "includeDrafts": {
438
+ "type": "boolean",
439
+ "default": true
440
+ },
441
+ "cursor": {
442
+ "anyOf": [
443
+ {
444
+ "type": "string",
445
+ "maxLength": 200
446
+ },
447
+ {
448
+ "type": "null"
449
+ }
450
+ ]
451
+ },
452
+ "limit": {
453
+ "type": "integer",
454
+ "minimum": 1,
455
+ "maximum": 100,
456
+ "default": 50
457
+ }
458
+ },
459
+ "additionalProperties": true
460
+ }
461
+ },
462
+ {
463
+ "name": "import_products_csv",
464
+ "description": "Import products from CSV in the export_products_csv format. dryRun (default true) only returns the plan: per product create/update/unchanged/error with the changed fields and per-row errors. With dryRun false, valid products are written in batches (new ones as draft unless publish is true or the status column says published): call again with offset = next until next is null. A stock cell sets the SKU's stock in core; rows with errors are skipped. Uploading the same file again changes nothing.",
465
+ "route": "products/import",
466
+ "permission": "plugins:manage",
467
+ "destructive": true,
468
+ "inputSchema": {
469
+ "$schema": "http://json-schema.org/draft-07/schema#",
470
+ "type": "object",
471
+ "properties": {
472
+ "csv": {
473
+ "type": "string",
474
+ "minLength": 1,
475
+ "maxLength": 5000000
476
+ },
477
+ "dryRun": {
478
+ "type": "boolean",
479
+ "default": true
480
+ },
481
+ "publish": {
482
+ "type": "boolean",
483
+ "default": false
484
+ },
485
+ "offset": {
486
+ "type": "integer",
487
+ "minimum": 0,
488
+ "maximum": 100000,
489
+ "default": 0
490
+ }
491
+ },
492
+ "additionalProperties": true,
493
+ "required": [
494
+ "csv"
495
+ ]
496
+ }
497
+ }
498
+ ]
499
+ },
500
+ "adminPages": [
501
+ {
502
+ "path": "/carts",
503
+ "label": "未結帳購物車",
504
+ "icon": "cart"
505
+ },
506
+ {
507
+ "path": "/products-csv",
508
+ "label": "商品匯入匯出",
509
+ "icon": "upload"
510
+ }
511
+ ],
512
+ "settingsSchema": {
513
+ "storeName": {
514
+ "label": "商店名稱(提醒信標題)",
515
+ "type": "string",
516
+ "default": ""
517
+ },
518
+ "abandonedEnabled": {
519
+ "label": "啟用購物車未結帳提醒",
520
+ "type": "boolean",
521
+ "default": false
522
+ },
523
+ "abandonedSchedule": {
524
+ "label": "提醒時間(閒置幾小時後寄出,逗號分隔,最多 3 次)",
525
+ "description": "例如「1,24,72」:閒置 1 小時寄第一封、24 小時第二封、72 小時第三封。",
526
+ "type": "string",
527
+ "default": "1,24,72"
528
+ },
529
+ "abandonedRequireConsent": {
530
+ "label": "會員需同意接收行銷訊息(訂閱會員電子報)才寄送",
531
+ "type": "boolean",
532
+ "default": true
533
+ },
534
+ "abandonedLineEnabled": {
535
+ "label": "已綁定 LINE 的會員同時以 LINE 提醒",
536
+ "type": "boolean",
537
+ "default": true
538
+ },
539
+ "abandonedMinSubtotal": {
540
+ "label": "購物車小計至少多少元才提醒(0 為不限)",
541
+ "type": "number",
542
+ "default": 0,
543
+ "min": 0
544
+ },
545
+ "abandonedExpireDays": {
546
+ "label": "超過幾天未回來就停止追蹤",
547
+ "type": "number",
548
+ "default": 30,
549
+ "min": 1
550
+ },
551
+ "abandonedCouponOn": {
552
+ "label": "在第幾封提醒附上專屬優惠碼",
553
+ "type": "select",
554
+ "options": [
555
+ {
556
+ "value": "0",
557
+ "label": "不附優惠碼"
558
+ },
559
+ {
560
+ "value": "1",
561
+ "label": "第 1 封"
562
+ },
563
+ {
564
+ "value": "2",
565
+ "label": "第 2 封"
566
+ },
567
+ {
568
+ "value": "3",
569
+ "label": "第 3 封"
570
+ }
571
+ ],
572
+ "default": "0"
573
+ },
574
+ "abandonedCouponType": {
575
+ "label": "優惠碼類型",
576
+ "type": "select",
577
+ "options": [
578
+ {
579
+ "value": "percent",
580
+ "label": "百分比折扣"
581
+ },
582
+ {
583
+ "value": "fixed_cart",
584
+ "label": "整單折抵金額"
585
+ }
586
+ ],
587
+ "default": "percent"
588
+ },
589
+ "abandonedCouponAmount": {
590
+ "label": "折扣(百分比填 10 為 9 折;金額填元)",
591
+ "type": "number",
592
+ "default": 10,
593
+ "min": 1
594
+ },
595
+ "abandonedCouponDays": {
596
+ "label": "優惠碼有效天數",
597
+ "type": "number",
598
+ "default": 3,
599
+ "min": 1
600
+ },
601
+ "busKey": {
602
+ "label": "匯流排金鑰",
603
+ "description": "由 scripts/provision-bus.mjs 寫入。",
604
+ "type": "secret"
605
+ }
606
+ }
607
+ });
608
+
609
+ export default descriptor;