@umec/core 0.1.0-alpha.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 (45) hide show
  1. package/LICENSE +21 -0
  2. package/dist/access.d.ts +18 -0
  3. package/dist/access.js +7 -0
  4. package/dist/access.js.map +1 -0
  5. package/dist/checkout.d.ts +28 -0
  6. package/dist/checkout.js +8 -0
  7. package/dist/checkout.js.map +1 -0
  8. package/dist/chunk-2NYFCO5V.js +192 -0
  9. package/dist/chunk-2NYFCO5V.js.map +1 -0
  10. package/dist/chunk-2SNGXEIL.js +37 -0
  11. package/dist/chunk-2SNGXEIL.js.map +1 -0
  12. package/dist/chunk-7TJANK6S.js +10 -0
  13. package/dist/chunk-7TJANK6S.js.map +1 -0
  14. package/dist/chunk-7ZJOZAEO.js +82 -0
  15. package/dist/chunk-7ZJOZAEO.js.map +1 -0
  16. package/dist/chunk-QRFFBMFN.js +109 -0
  17. package/dist/chunk-QRFFBMFN.js.map +1 -0
  18. package/dist/chunk-REUSLO5I.js +199 -0
  19. package/dist/chunk-REUSLO5I.js.map +1 -0
  20. package/dist/chunk-WZFM6R5J.js +47 -0
  21. package/dist/chunk-WZFM6R5J.js.map +1 -0
  22. package/dist/chunk-X2SNVVFW.js +73 -0
  23. package/dist/chunk-X2SNVVFW.js.map +1 -0
  24. package/dist/config.d.ts +67 -0
  25. package/dist/config.js +11 -0
  26. package/dist/config.js.map +1 -0
  27. package/dist/env.d.ts +15 -0
  28. package/dist/env.js +7 -0
  29. package/dist/env.js.map +1 -0
  30. package/dist/index.d.ts +11 -0
  31. package/dist/index.js +41 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/middleware.d.ts +13 -0
  34. package/dist/middleware.js +7 -0
  35. package/dist/middleware.js.map +1 -0
  36. package/dist/notify.d.ts +23 -0
  37. package/dist/notify.js +7 -0
  38. package/dist/notify.js.map +1 -0
  39. package/dist/subscribe.d.ts +9 -0
  40. package/dist/subscribe.js +8 -0
  41. package/dist/subscribe.js.map +1 -0
  42. package/dist/webhook.d.ts +65 -0
  43. package/dist/webhook.js +10 -0
  44. package/dist/webhook.js.map +1 -0
  45. package/package.json +80 -0
@@ -0,0 +1,65 @@
1
+ import Stripe from 'stripe';
2
+
3
+ type ShippingDetails = NonNullable<NonNullable<Stripe.Checkout.Session["collected_information"]>["shipping_details"]>;
4
+ type WebhookItem = {
5
+ sku: string;
6
+ quantity: number;
7
+ };
8
+ type SupportedWebhookEvent = "checkout.session.completed" | "checkout.session.expired" | "charge.refunded";
9
+ type OrderEmailLineItem = {
10
+ description: string | null;
11
+ quantity: number | null;
12
+ amount: number | null;
13
+ };
14
+ type OrderEmailData = {
15
+ name: string;
16
+ email: string;
17
+ phone: string | null;
18
+ items: OrderEmailLineItem[];
19
+ totalAmount: number;
20
+ shippingCostAmount: number | null;
21
+ shipping: ShippingDetails | null | undefined;
22
+ customFields: Record<string, string>;
23
+ };
24
+ type RenderOrderEmail = (order: OrderEmailData) => {
25
+ subject: string;
26
+ html: string;
27
+ };
28
+ type WebhookOrder = {
29
+ id: string;
30
+ email: string;
31
+ name: string | null;
32
+ phone: string | null;
33
+ items: WebhookItem[];
34
+ amount: number;
35
+ shippingCost: number | null;
36
+ shippingAddress: ShippingDetails | null | undefined;
37
+ paymentIntent: string | null;
38
+ offerSlug: string | null;
39
+ customFields: Record<string, string> | null;
40
+ createdAt: number;
41
+ };
42
+ type WebhookRecordedOrder = {
43
+ items: WebhookItem[];
44
+ offerSlug: string | null;
45
+ };
46
+ type WebhookHandlerOptions = {
47
+ claimEvent?: (eventId: string) => Promise<boolean>;
48
+ recordRefund?: (paymentIntentId: string) => Promise<WebhookRecordedOrder | null>;
49
+ recordExpiry?: (sessionId: string) => Promise<WebhookRecordedOrder | null>;
50
+ recordOrder?: (order: WebhookOrder) => Promise<void>;
51
+ restoreStock?: (items: WebhookItem[]) => Promise<void>;
52
+ decrementStock?: (items: WebhookItem[]) => Promise<void>;
53
+ incrementOfferSold?: (offerSlug: string, items: WebhookItem[]) => Promise<void>;
54
+ decrementOfferSold?: (offerSlug: string, items: WebhookItem[]) => Promise<void>;
55
+ renderOrderEmail?: RenderOrderEmail;
56
+ orderEmailFrom?: string;
57
+ orderEmailBcc?: string | string[];
58
+ };
59
+ type WebhookHandler = ({ request }: {
60
+ request: Request;
61
+ }) => Promise<Response>;
62
+ declare const GET: WebhookHandler;
63
+ declare function createWebhookHandler({ claimEvent, recordRefund, recordExpiry, recordOrder, restoreStock, decrementStock, incrementOfferSold, decrementOfferSold, renderOrderEmail, orderEmailFrom, orderEmailBcc, }?: WebhookHandlerOptions): WebhookHandler;
64
+
65
+ export { GET, type OrderEmailData, type OrderEmailLineItem, type RenderOrderEmail, type SupportedWebhookEvent, type WebhookHandler, type WebhookHandlerOptions, type WebhookItem, type WebhookOrder, type WebhookRecordedOrder, createWebhookHandler };
@@ -0,0 +1,10 @@
1
+ import {
2
+ GET,
3
+ createWebhookHandler
4
+ } from "./chunk-REUSLO5I.js";
5
+ import "./chunk-7TJANK6S.js";
6
+ export {
7
+ GET,
8
+ createWebhookHandler
9
+ };
10
+ //# sourceMappingURL=webhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@umec/core",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "Headless EC logic for umec — config schema and shared handlers",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/syrup-murayama/umec.git",
10
+ "directory": "packages/core"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "engines": {
16
+ "node": ">=22.12.0"
17
+ },
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./config": {
24
+ "types": "./dist/config.d.ts",
25
+ "import": "./dist/config.js"
26
+ },
27
+ "./access": {
28
+ "types": "./dist/access.d.ts",
29
+ "import": "./dist/access.js"
30
+ },
31
+ "./checkout": {
32
+ "types": "./dist/checkout.d.ts",
33
+ "import": "./dist/checkout.js"
34
+ },
35
+ "./env": {
36
+ "types": "./dist/env.d.ts",
37
+ "import": "./dist/env.js"
38
+ },
39
+ "./middleware": {
40
+ "types": "./dist/middleware.d.ts",
41
+ "import": "./dist/middleware.js"
42
+ },
43
+ "./notify": {
44
+ "types": "./dist/notify.d.ts",
45
+ "import": "./dist/notify.js"
46
+ },
47
+ "./subscribe": {
48
+ "types": "./dist/subscribe.d.ts",
49
+ "import": "./dist/subscribe.js"
50
+ },
51
+ "./webhook": {
52
+ "types": "./dist/webhook.d.ts",
53
+ "import": "./dist/webhook.js"
54
+ }
55
+ },
56
+ "files": [
57
+ "dist"
58
+ ],
59
+ "scripts": {
60
+ "build": "tsup",
61
+ "test": "vitest run",
62
+ "test:watch": "vitest"
63
+ },
64
+ "dependencies": {
65
+ "jose": "6.2.3",
66
+ "resend": "^6.12.4",
67
+ "stripe": "22.2.0"
68
+ },
69
+ "peerDependencies": {
70
+ "zod": "^4.0.0"
71
+ },
72
+ "devDependencies": {
73
+ "@cloudflare/workers-types": "^4.20250705.0",
74
+ "@types/node": "^22.15.3",
75
+ "tsup": "^8.5.0",
76
+ "typescript": "^5.8.3",
77
+ "vitest": "^3.2.4",
78
+ "zod": "4.4.3"
79
+ }
80
+ }