@molda-org/orders-fulfillment 0.1.0-next.2 → 0.1.0-next.21
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/dist/index.d.ts +208 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/package.json +16 -5
- package/index.d.ts +0 -20
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import type { MoldaModuleDefinition, MoldaModuleShape } from '@molda-org/module-contracts';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { type ModuleRepository } from '@molda-org/module-runtime';
|
|
4
|
+
export type OrdersFulfillmentAction = 'placeOrder' | 'updateOrderStatus' | 'assignFulfillment' | 'confirmHandoff';
|
|
5
|
+
export type OrdersFulfillmentView = 'orders' | 'ordersByStatus' | 'fulfillmentQueue';
|
|
6
|
+
export type OrdersFulfillmentHook = 'useOrders' | 'useOrder' | 'useFulfillmentQueue';
|
|
7
|
+
export interface OrdersFulfillmentModuleShape extends MoldaModuleShape<'orders-fulfillment', OrdersFulfillmentAction, OrdersFulfillmentView, OrdersFulfillmentHook> {
|
|
8
|
+
readonly stage: 'initial';
|
|
9
|
+
readonly category: 'commerce';
|
|
10
|
+
readonly purpose: 'Order capture, immutable line snapshots, lifecycle, fulfillment assignment, and handoff evidence.';
|
|
11
|
+
}
|
|
12
|
+
export type OrdersFulfillmentModule = MoldaModuleDefinition<OrdersFulfillmentModuleShape>;
|
|
13
|
+
export declare const OrdersFulfillmentActionIds: readonly ["placeOrder", "updateOrderStatus", "assignFulfillment", "confirmHandoff"];
|
|
14
|
+
export declare const OrdersFulfillmentViewIds: readonly ["orders", "ordersByStatus", "fulfillmentQueue"];
|
|
15
|
+
export declare const OrdersFulfillmentHookIds: readonly ["useOrders", "useOrder", "useFulfillmentQueue"];
|
|
16
|
+
export declare const OrdersFulfillmentSpecification: {
|
|
17
|
+
readonly id: "orders-fulfillment";
|
|
18
|
+
readonly version: "1.0.0";
|
|
19
|
+
readonly collections: {
|
|
20
|
+
readonly orders: z.ZodObject<{
|
|
21
|
+
customerId: z.ZodString;
|
|
22
|
+
status: z.ZodEnum<{
|
|
23
|
+
draft: "draft";
|
|
24
|
+
placed: "placed";
|
|
25
|
+
preparing: "preparing";
|
|
26
|
+
ready: "ready";
|
|
27
|
+
"handed-off": "handed-off";
|
|
28
|
+
cancelled: "cancelled";
|
|
29
|
+
}>;
|
|
30
|
+
currency: z.ZodString;
|
|
31
|
+
totalMinor: z.ZodNumber;
|
|
32
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
33
|
+
itemId: z.ZodString;
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
quantity: z.ZodNumber;
|
|
36
|
+
unitAmountMinor: z.ZodNumber;
|
|
37
|
+
}, z.core.$strict>>;
|
|
38
|
+
transitionReason: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
readonly 'fulfillment-assignments': z.ZodObject<{
|
|
41
|
+
orderId: z.ZodString;
|
|
42
|
+
assigneeId: z.ZodString;
|
|
43
|
+
status: z.ZodEnum<{
|
|
44
|
+
assigned: "assigned";
|
|
45
|
+
accepted: "accepted";
|
|
46
|
+
completed: "completed";
|
|
47
|
+
}>;
|
|
48
|
+
}, z.core.$strict>;
|
|
49
|
+
};
|
|
50
|
+
readonly actions: {
|
|
51
|
+
readonly placeOrder: {
|
|
52
|
+
readonly kind: "create";
|
|
53
|
+
readonly collection: "orders";
|
|
54
|
+
readonly permission: "place.order";
|
|
55
|
+
readonly event: "place.order";
|
|
56
|
+
readonly confirmation: "required";
|
|
57
|
+
readonly validate: ({ value }: {
|
|
58
|
+
readonly value: import("@molda-org/module-runtime").ModuleEntityValue;
|
|
59
|
+
readonly current: import("@molda-org/module-runtime").ModuleRecord | null;
|
|
60
|
+
readonly transaction: import("@molda-org/module-runtime").ModuleTransaction;
|
|
61
|
+
}) => void;
|
|
62
|
+
};
|
|
63
|
+
readonly updateOrderStatus: {
|
|
64
|
+
readonly kind: "update";
|
|
65
|
+
readonly collection: "orders";
|
|
66
|
+
readonly permission: "update.order.status";
|
|
67
|
+
readonly event: "update.order.status";
|
|
68
|
+
readonly validate: ({ value, current }: {
|
|
69
|
+
readonly value: import("@molda-org/module-runtime").ModuleEntityValue;
|
|
70
|
+
readonly current: import("@molda-org/module-runtime").ModuleRecord | null;
|
|
71
|
+
readonly transaction: import("@molda-org/module-runtime").ModuleTransaction;
|
|
72
|
+
}) => void;
|
|
73
|
+
};
|
|
74
|
+
readonly assignFulfillment: {
|
|
75
|
+
readonly kind: "upsert";
|
|
76
|
+
readonly collection: "fulfillment-assignments";
|
|
77
|
+
readonly permission: "assign.fulfillment";
|
|
78
|
+
readonly event: "assign.fulfillment";
|
|
79
|
+
readonly validate: ({ value, transaction }: {
|
|
80
|
+
readonly value: import("@molda-org/module-runtime").ModuleEntityValue;
|
|
81
|
+
readonly current: import("@molda-org/module-runtime").ModuleRecord | null;
|
|
82
|
+
readonly transaction: import("@molda-org/module-runtime").ModuleTransaction;
|
|
83
|
+
}) => Promise<void>;
|
|
84
|
+
};
|
|
85
|
+
readonly confirmHandoff: {
|
|
86
|
+
readonly kind: "transition";
|
|
87
|
+
readonly collection: "orders";
|
|
88
|
+
readonly permission: "confirm.handoff";
|
|
89
|
+
readonly event: "confirm.handoff";
|
|
90
|
+
readonly status: "handed-off";
|
|
91
|
+
readonly allowedFrom: readonly ["ready"];
|
|
92
|
+
readonly confirmation: "required";
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
readonly views: {
|
|
96
|
+
readonly orders: {
|
|
97
|
+
readonly kind: "list";
|
|
98
|
+
readonly collection: "orders";
|
|
99
|
+
readonly permission: "orders.read";
|
|
100
|
+
};
|
|
101
|
+
readonly ordersByStatus: {
|
|
102
|
+
readonly kind: "list";
|
|
103
|
+
readonly collection: "orders";
|
|
104
|
+
readonly permission: "orders.by.status.read";
|
|
105
|
+
};
|
|
106
|
+
readonly fulfillmentQueue: {
|
|
107
|
+
readonly kind: "list";
|
|
108
|
+
readonly collection: "fulfillment-assignments";
|
|
109
|
+
readonly permission: "fulfillment.queue.read";
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
readonly migrations: readonly [{
|
|
113
|
+
readonly version: 1;
|
|
114
|
+
readonly description: "Create orders-fulfillment collections and indexes";
|
|
115
|
+
}];
|
|
116
|
+
readonly fixtures: readonly [{
|
|
117
|
+
readonly id: "orders-fulfillment-baseline";
|
|
118
|
+
readonly description: "Deterministic orders-fulfillment production-case fixture";
|
|
119
|
+
readonly records: readonly [{
|
|
120
|
+
readonly collection: "orders";
|
|
121
|
+
readonly id: "order-fixture";
|
|
122
|
+
readonly value: {
|
|
123
|
+
readonly customerId: "customer-fixture";
|
|
124
|
+
readonly status: "placed";
|
|
125
|
+
readonly currency: "EUR";
|
|
126
|
+
readonly totalMinor: 2500;
|
|
127
|
+
readonly lines: readonly [{
|
|
128
|
+
readonly itemId: "service-fixture";
|
|
129
|
+
readonly name: "Fixture Service";
|
|
130
|
+
readonly quantity: 1;
|
|
131
|
+
readonly unitAmountMinor: 2500;
|
|
132
|
+
}];
|
|
133
|
+
};
|
|
134
|
+
}];
|
|
135
|
+
}];
|
|
136
|
+
};
|
|
137
|
+
export declare const OrdersFulfillmentBlueprint: import("@molda-org/module-runtime").ModuleBlueprint<{
|
|
138
|
+
[k: string]: import("@molda-org/module-runtime").ModuleActionDefinition<{
|
|
139
|
+
id: string;
|
|
140
|
+
data: Record<string, unknown>;
|
|
141
|
+
}, import("@molda-org/module-runtime").ModuleRecord<Readonly<Record<string, unknown>>>> | import("@molda-org/module-runtime").ModuleActionDefinition<{
|
|
142
|
+
data: Record<string, unknown>;
|
|
143
|
+
}, import("@molda-org/module-runtime").ModuleRecord<Readonly<Record<string, unknown>>>> | import("@molda-org/module-runtime").ModuleActionDefinition<{
|
|
144
|
+
id: string;
|
|
145
|
+
expectedRevision: number;
|
|
146
|
+
patch: Record<string, unknown>;
|
|
147
|
+
reason?: string | undefined;
|
|
148
|
+
}, import("@molda-org/module-runtime").ModuleRecord<Readonly<Record<string, unknown>>>> | import("@molda-org/module-runtime").ModuleActionDefinition<{
|
|
149
|
+
id: string;
|
|
150
|
+
expectedRevision: number;
|
|
151
|
+
patch: Record<string, unknown>;
|
|
152
|
+
}, import("@molda-org/module-runtime").ModuleRecord<Readonly<Record<string, unknown>>>>;
|
|
153
|
+
}, {
|
|
154
|
+
[k: string]: import("@molda-org/module-runtime").ModuleViewDefinition<{
|
|
155
|
+
id: string;
|
|
156
|
+
}, import("@molda-org/module-runtime").ModuleRecord<Readonly<Record<string, unknown>>>> | import("@molda-org/module-runtime").ModuleViewDefinition<{
|
|
157
|
+
limit: number;
|
|
158
|
+
equals?: Record<string, unknown> | undefined;
|
|
159
|
+
}, readonly import("@molda-org/module-runtime").ModuleRecord<Record<string, unknown>>[]>;
|
|
160
|
+
}>;
|
|
161
|
+
export declare function createOrdersFulfillmentService(repository: ModuleRepository): {
|
|
162
|
+
blueprint: import("@molda-org/module-runtime").ModuleBlueprint<{
|
|
163
|
+
[k: string]: import("@molda-org/module-runtime").ModuleActionDefinition<{
|
|
164
|
+
id: string;
|
|
165
|
+
data: Record<string, unknown>;
|
|
166
|
+
}, import("@molda-org/module-runtime").ModuleRecord<Readonly<Record<string, unknown>>>> | import("@molda-org/module-runtime").ModuleActionDefinition<{
|
|
167
|
+
data: Record<string, unknown>;
|
|
168
|
+
}, import("@molda-org/module-runtime").ModuleRecord<Readonly<Record<string, unknown>>>> | import("@molda-org/module-runtime").ModuleActionDefinition<{
|
|
169
|
+
id: string;
|
|
170
|
+
expectedRevision: number;
|
|
171
|
+
patch: Record<string, unknown>;
|
|
172
|
+
reason?: string | undefined;
|
|
173
|
+
}, import("@molda-org/module-runtime").ModuleRecord<Readonly<Record<string, unknown>>>> | import("@molda-org/module-runtime").ModuleActionDefinition<{
|
|
174
|
+
id: string;
|
|
175
|
+
expectedRevision: number;
|
|
176
|
+
patch: Record<string, unknown>;
|
|
177
|
+
}, import("@molda-org/module-runtime").ModuleRecord<Readonly<Record<string, unknown>>>>;
|
|
178
|
+
}, {
|
|
179
|
+
[k: string]: import("@molda-org/module-runtime").ModuleViewDefinition<{
|
|
180
|
+
id: string;
|
|
181
|
+
}, import("@molda-org/module-runtime").ModuleRecord<Readonly<Record<string, unknown>>>> | import("@molda-org/module-runtime").ModuleViewDefinition<{
|
|
182
|
+
limit: number;
|
|
183
|
+
equals?: Record<string, unknown> | undefined;
|
|
184
|
+
}, readonly import("@molda-org/module-runtime").ModuleRecord<Record<string, unknown>>[]>;
|
|
185
|
+
}>;
|
|
186
|
+
executeAction<TKey extends string>(actionId: TKey, unsafeInput: {
|
|
187
|
+
id: string;
|
|
188
|
+
data: Record<string, unknown>;
|
|
189
|
+
} | {
|
|
190
|
+
data: Record<string, unknown>;
|
|
191
|
+
} | {
|
|
192
|
+
id: string;
|
|
193
|
+
expectedRevision: number;
|
|
194
|
+
patch: Record<string, unknown>;
|
|
195
|
+
reason?: string | undefined;
|
|
196
|
+
} | {
|
|
197
|
+
id: string;
|
|
198
|
+
expectedRevision: number;
|
|
199
|
+
patch: Record<string, unknown>;
|
|
200
|
+
}, invocation: import("@molda-org/module-runtime").ModuleActionInvocation): Promise<import("@molda-org/module-runtime").ModuleActionExecution<never>>;
|
|
201
|
+
executeView<TKey extends string>(viewId: TKey, unsafeInput: {
|
|
202
|
+
id: string;
|
|
203
|
+
} | {
|
|
204
|
+
limit: number;
|
|
205
|
+
equals?: Record<string, unknown> | undefined;
|
|
206
|
+
}, context: import("@molda-org/module-runtime").ModuleExecutionContext): Promise<never>;
|
|
207
|
+
};
|
|
208
|
+
export declare function createOrdersFulfillmentRuntimeModule(repository: ModuleRepository): import("@molda-org/module-runtime").ResourceModuleContribution;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createResourceModuleContribution, createResourceModuleService, defineResourceModule, ModuleConflictError, } from '@molda-org/module-runtime';
|
|
3
|
+
export const OrdersFulfillmentActionIds = ["placeOrder", "updateOrderStatus", "assignFulfillment", "confirmHandoff"];
|
|
4
|
+
export const OrdersFulfillmentViewIds = ["orders", "ordersByStatus", "fulfillmentQueue"];
|
|
5
|
+
export const OrdersFulfillmentHookIds = ["useOrders", "useOrder", "useFulfillmentQueue"];
|
|
6
|
+
export const OrdersFulfillmentSpecification = {
|
|
7
|
+
id: 'orders-fulfillment',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
collections: {
|
|
10
|
+
'orders': z.object({ customerId: z.string().min(1).max(200), status: z.enum(['draft', 'placed', 'preparing', 'ready', 'handed-off', 'cancelled']), currency: z.string().regex(/^[A-Z]{3}$/), totalMinor: z.number().int().nonnegative(), lines: z.array(z.object({ itemId: z.string().min(1), name: z.string().min(1), quantity: z.number().int().positive(), unitAmountMinor: z.number().int().nonnegative() }).strict()).min(1).max(200), transitionReason: z.string().max(1_000).optional() }).strict(),
|
|
11
|
+
'fulfillment-assignments': z.object({ orderId: z.string().min(1).max(200), assigneeId: z.string().min(1).max(200), status: z.enum(['assigned', 'accepted', 'completed']) }).strict(),
|
|
12
|
+
},
|
|
13
|
+
actions: {
|
|
14
|
+
placeOrder: {
|
|
15
|
+
kind: 'create', collection: 'orders', permission: 'place.order', event: 'place.order', confirmation: 'required',
|
|
16
|
+
validate: ({ value }) => {
|
|
17
|
+
const lines = value.lines;
|
|
18
|
+
const calculated = lines.reduce((total, line) => total + line.quantity * line.unitAmountMinor, 0);
|
|
19
|
+
if (calculated !== value.totalMinor)
|
|
20
|
+
throw new ModuleConflictError('Order total does not match immutable line snapshots');
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
updateOrderStatus: {
|
|
24
|
+
kind: 'update', collection: 'orders', permission: 'update.order.status', event: 'update.order.status',
|
|
25
|
+
validate: ({ value, current }) => {
|
|
26
|
+
if (!current)
|
|
27
|
+
throw new ModuleConflictError('Order does not exist');
|
|
28
|
+
for (const field of ['customerId', 'currency', 'totalMinor']) {
|
|
29
|
+
if (value[field] !== current.value[field])
|
|
30
|
+
throw new ModuleConflictError(`Order ${field} is immutable after placement`);
|
|
31
|
+
}
|
|
32
|
+
if (JSON.stringify(value.lines) !== JSON.stringify(current.value.lines)) {
|
|
33
|
+
throw new ModuleConflictError('Order line snapshots are immutable after placement');
|
|
34
|
+
}
|
|
35
|
+
const transitions = {
|
|
36
|
+
draft: ['placed', 'cancelled'], placed: ['preparing', 'cancelled'], preparing: ['ready', 'cancelled'],
|
|
37
|
+
ready: [], 'handed-off': [], cancelled: [],
|
|
38
|
+
};
|
|
39
|
+
const from = String(current.value.status);
|
|
40
|
+
const to = String(value.status);
|
|
41
|
+
if (from !== to && !transitions[from]?.includes(to)) {
|
|
42
|
+
throw new ModuleConflictError(`Cannot update order status from ${from} to ${to}`);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
assignFulfillment: {
|
|
47
|
+
kind: 'upsert', collection: 'fulfillment-assignments', permission: 'assign.fulfillment', event: 'assign.fulfillment',
|
|
48
|
+
validate: async ({ value, transaction }) => {
|
|
49
|
+
const order = await transaction.require('orders', String(value.orderId));
|
|
50
|
+
if (order.value.status === 'cancelled' || order.value.status === 'handed-off') {
|
|
51
|
+
throw new ModuleConflictError('Fulfillment cannot be assigned to a closed order');
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
confirmHandoff: { kind: 'transition', collection: 'orders', permission: 'confirm.handoff', event: 'confirm.handoff', status: 'handed-off', allowedFrom: ["ready"], confirmation: 'required' },
|
|
56
|
+
},
|
|
57
|
+
views: {
|
|
58
|
+
orders: { kind: 'list', collection: 'orders', permission: 'orders.read' },
|
|
59
|
+
ordersByStatus: { kind: 'list', collection: 'orders', permission: 'orders.by.status.read' },
|
|
60
|
+
fulfillmentQueue: { kind: 'list', collection: 'fulfillment-assignments', permission: 'fulfillment.queue.read' },
|
|
61
|
+
},
|
|
62
|
+
migrations: [{ version: 1, description: 'Create orders-fulfillment collections and indexes' }],
|
|
63
|
+
fixtures: [{ id: 'orders-fulfillment-baseline', description: 'Deterministic orders-fulfillment production-case fixture', records: [
|
|
64
|
+
{ collection: 'orders', id: 'order-fixture', value: { customerId: 'customer-fixture', status: 'placed', currency: 'EUR', totalMinor: 2500, lines: [{ itemId: 'service-fixture', name: 'Fixture Service', quantity: 1, unitAmountMinor: 2500 }] } },
|
|
65
|
+
] }],
|
|
66
|
+
};
|
|
67
|
+
export const OrdersFulfillmentBlueprint = defineResourceModule(OrdersFulfillmentSpecification);
|
|
68
|
+
export function createOrdersFulfillmentService(repository) {
|
|
69
|
+
return createResourceModuleService(OrdersFulfillmentSpecification, repository);
|
|
70
|
+
}
|
|
71
|
+
export function createOrdersFulfillmentRuntimeModule(repository) {
|
|
72
|
+
return createResourceModuleContribution(OrdersFulfillmentSpecification, repository);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,gCAAgC,EAChC,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,GAGpB,MAAM,2BAA2B,CAAC;AAcnC,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,YAAY,EAAC,mBAAmB,EAAC,mBAAmB,EAAC,gBAAgB,CAAU,CAAC;AAC3H,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAC,gBAAgB,EAAC,kBAAkB,CAAU,CAAC;AAChG,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,WAAW,EAAC,UAAU,EAAC,qBAAqB,CAAU,CAAC;AAEhG,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,EAAE,EAAE,oBAAoB;IACxB,OAAO,EAAE,OAAO;IACh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GAAG,oBAAoB,CAAC,8BAA8B,CAAC,CAAC;AAE/F,MAAM,UAAU,8BAA8B,CAAC,UAA4B;IACzE,OAAO,2BAA2B,CAAC,8BAA8B,EAAE,UAAU,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,oCAAoC,CAAC,UAA4B;IAC/E,OAAO,gCAAgC,CAAC,8BAA8B,EAAE,UAAU,CAAC,CAAC;AACtF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molda-org/orders-fulfillment",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.21",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"types": "./index.d.ts",
|
|
6
5
|
"exports": {
|
|
7
6
|
".": {
|
|
8
|
-
"types": "./index.d.ts"
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./dist/index.js"
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"
|
|
12
|
+
"dist"
|
|
13
13
|
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc -p tsconfig.json",
|
|
16
|
+
"prepack": "npm run build",
|
|
17
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
18
|
+
},
|
|
14
19
|
"dependencies": {
|
|
15
|
-
"@molda-org/module-contracts": "0.1.0-next.
|
|
20
|
+
"@molda-org/module-contracts": "0.1.0-next.21",
|
|
21
|
+
"@molda-org/module-runtime": "0.1.0-next.21",
|
|
22
|
+
"zod": "4.6.5"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "22.19.19",
|
|
26
|
+
"typescript": "5.9.3"
|
|
16
27
|
},
|
|
17
28
|
"publishConfig": {
|
|
18
29
|
"access": "public",
|
package/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { MoldaModuleDefinition, MoldaModuleShape } from '@molda-org/module-contracts';
|
|
2
|
-
|
|
3
|
-
export type OrdersFulfillmentAction = 'placeOrder' | 'updateOrderStatus' | 'assignFulfillment' | 'confirmHandoff';
|
|
4
|
-
export type OrdersFulfillmentView = 'orders' | 'ordersByStatus' | 'fulfillmentQueue';
|
|
5
|
-
export type OrdersFulfillmentHook = 'useCart' | 'useCheckout' | 'useCustomerOrders';
|
|
6
|
-
|
|
7
|
-
export interface OrdersFulfillmentModuleShape
|
|
8
|
-
extends MoldaModuleShape<
|
|
9
|
-
'orders-fulfillment',
|
|
10
|
-
OrdersFulfillmentAction,
|
|
11
|
-
OrdersFulfillmentView,
|
|
12
|
-
OrdersFulfillmentHook
|
|
13
|
-
> {
|
|
14
|
-
readonly stage: 'initial';
|
|
15
|
-
readonly category: 'commerce';
|
|
16
|
-
readonly purpose: 'Cart, checkout, order lifecycle, pickup, delivery, tracking, and handoff.';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type OrdersFulfillmentModule = MoldaModuleDefinition<OrdersFulfillmentModuleShape>;
|
|
20
|
-
|