typed-bridge 2.1.5 → 3.0.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.
- package/dist/bridge/index.d.ts +9 -4
- package/dist/bridge/index.js +32 -4
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +2 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +11 -1
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.js +119 -0
- package/dist/scripts/buildTypeBridge.js +34 -1
- package/dist/scripts/typedBridgeCleaner.js +247 -28
- package/dist/tools/index.d.ts +126 -0
- package/dist/tools/index.js +218 -0
- package/package.json +18 -3
- package/readme.md +203 -234
- package/.vscode/settings.json +0 -3
- package/dist/demo/bridge/index.d.ts +0 -255
- package/dist/demo/bridge/index.js +0 -56
- package/dist/demo/bridge/order/index.d.ts +0 -42
- package/dist/demo/bridge/order/index.js +0 -165
- package/dist/demo/bridge/order/types.d.ts +0 -187
- package/dist/demo/bridge/order/types.js +0 -150
- package/dist/demo/bridge/product/index.d.ts +0 -16
- package/dist/demo/bridge/product/index.js +0 -67
- package/dist/demo/bridge/product/types.d.ts +0 -24
- package/dist/demo/bridge/product/types.js +0 -27
- package/dist/demo/bridge/user/index.d.ts +0 -28
- package/dist/demo/bridge/user/index.js +0 -86
- package/dist/demo/bridge/user/types.d.ts +0 -23
- package/dist/demo/bridge/user/types.js +0 -26
- package/dist/demo/index.d.ts +0 -1
- package/dist/demo/index.js +0 -23
- package/dist/demo/middleware.d.ts +0 -1
- package/dist/demo/middleware.js +0 -58
- package/test/bridge.ts +0 -283
- package/test/index.ts +0 -251
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import * as user from './user';
|
|
2
|
-
import * as product from './product';
|
|
3
|
-
import * as order from './order';
|
|
4
|
-
declare const _default: {
|
|
5
|
-
'user.fetch': (args: import("zod").infer<import("zod").ZodObject<{
|
|
6
|
-
id: import("zod").ZodNumber;
|
|
7
|
-
}, import("zod/v4/core").$strip>>, context: {
|
|
8
|
-
requestedAt: number;
|
|
9
|
-
userId: number;
|
|
10
|
-
}) => Promise<import("zod").infer<import("zod").ZodObject<{
|
|
11
|
-
id: import("zod").ZodNumber;
|
|
12
|
-
name: import("zod").ZodString;
|
|
13
|
-
email: import("zod").ZodString;
|
|
14
|
-
}, import("zod/v4/core").$strip>>>;
|
|
15
|
-
'user.create': (args: import("zod").infer<import("zod").ZodObject<{
|
|
16
|
-
name: import("zod").ZodString;
|
|
17
|
-
email: import("zod").ZodString;
|
|
18
|
-
}, import("zod/v4/core").$strip>>, context: {
|
|
19
|
-
requestedAt: number;
|
|
20
|
-
userId: number;
|
|
21
|
-
}) => Promise<import("zod").infer<import("zod").ZodObject<{
|
|
22
|
-
id: import("zod").ZodNumber;
|
|
23
|
-
name: import("zod").ZodString;
|
|
24
|
-
email: import("zod").ZodString;
|
|
25
|
-
createdAt: import("zod").ZodDate;
|
|
26
|
-
}, import("zod/v4/core").$strip>>>;
|
|
27
|
-
'user.update': (args: {
|
|
28
|
-
id: number;
|
|
29
|
-
name?: string;
|
|
30
|
-
email?: string;
|
|
31
|
-
}, context: {
|
|
32
|
-
requestedAt: number;
|
|
33
|
-
userId: number;
|
|
34
|
-
}) => Promise<user.User>;
|
|
35
|
-
'user.remove': (args: {
|
|
36
|
-
id: number;
|
|
37
|
-
}, context: {
|
|
38
|
-
requestedAt: number;
|
|
39
|
-
userId: number;
|
|
40
|
-
} & {
|
|
41
|
-
isAdmin: boolean;
|
|
42
|
-
}) => Promise<{
|
|
43
|
-
success: boolean;
|
|
44
|
-
}>;
|
|
45
|
-
'user.fetchAll': () => Promise<user.User[]>;
|
|
46
|
-
'product.fetch': (args: import("zod").infer<import("zod").ZodObject<{
|
|
47
|
-
id: import("zod").ZodNumber;
|
|
48
|
-
}, import("zod/v4/core").$strip>>, context: {
|
|
49
|
-
requestedAt: number;
|
|
50
|
-
userId: number;
|
|
51
|
-
}) => Promise<import("zod").infer<import("zod").ZodObject<{
|
|
52
|
-
id: import("zod").ZodNumber;
|
|
53
|
-
name: import("zod").ZodString;
|
|
54
|
-
price: import("zod").ZodNumber;
|
|
55
|
-
createdAt: import("zod").ZodDate;
|
|
56
|
-
}, import("zod/v4/core").$strip>>>;
|
|
57
|
-
'product.create': (args: import("zod").infer<import("zod").ZodObject<{
|
|
58
|
-
name: import("zod").ZodString;
|
|
59
|
-
price: import("zod").ZodNumber;
|
|
60
|
-
}, import("zod/v4/core").$strip>>, context: {
|
|
61
|
-
requestedAt: number;
|
|
62
|
-
userId: number;
|
|
63
|
-
}) => Promise<import("zod").infer<import("zod").ZodObject<{
|
|
64
|
-
id: import("zod").ZodNumber;
|
|
65
|
-
name: import("zod").ZodString;
|
|
66
|
-
price: import("zod").ZodNumber;
|
|
67
|
-
createdAt: import("zod").ZodDate;
|
|
68
|
-
}, import("zod/v4/core").$strip>>>;
|
|
69
|
-
'product.list': () => Promise<product.Product[]>;
|
|
70
|
-
'order.create': (args: import("zod").infer<import("zod").ZodObject<{
|
|
71
|
-
customerId: import("zod").ZodNumber;
|
|
72
|
-
items: import("zod").ZodArray<import("zod").ZodObject<{
|
|
73
|
-
productId: import("zod").ZodNumber;
|
|
74
|
-
quantity: import("zod").ZodNumber;
|
|
75
|
-
price: import("zod").ZodNumber;
|
|
76
|
-
notes: import("zod").ZodOptional<import("zod").ZodString>;
|
|
77
|
-
discount: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
78
|
-
}, import("zod/v4/core").$strip>>;
|
|
79
|
-
shippingAddress: import("zod").ZodObject<{
|
|
80
|
-
street: import("zod").ZodString;
|
|
81
|
-
city: import("zod").ZodString;
|
|
82
|
-
state: import("zod").ZodString;
|
|
83
|
-
zip: import("zod").ZodString;
|
|
84
|
-
country: import("zod").ZodDefault<import("zod").ZodString>;
|
|
85
|
-
}, import("zod/v4/core").$strip>;
|
|
86
|
-
billingAddress: import("zod").ZodNullable<import("zod").ZodObject<{
|
|
87
|
-
street: import("zod").ZodString;
|
|
88
|
-
city: import("zod").ZodString;
|
|
89
|
-
state: import("zod").ZodString;
|
|
90
|
-
zip: import("zod").ZodString;
|
|
91
|
-
country: import("zod").ZodDefault<import("zod").ZodString>;
|
|
92
|
-
}, import("zod/v4/core").$strip>>;
|
|
93
|
-
couponCode: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
94
|
-
scheduledDate: import("zod").ZodOptional<import("zod").ZodDate>;
|
|
95
|
-
isGift: import("zod").ZodBoolean;
|
|
96
|
-
giftMessage: import("zod").ZodNullable<import("zod").ZodString>;
|
|
97
|
-
}, import("zod/v4/core").$strip>>, context: {
|
|
98
|
-
requestedAt: number;
|
|
99
|
-
userId: number;
|
|
100
|
-
}) => Promise<import("zod").infer<import("zod").ZodObject<{
|
|
101
|
-
id: import("zod").ZodNumber;
|
|
102
|
-
status: import("zod").ZodString;
|
|
103
|
-
total: import("zod").ZodNumber;
|
|
104
|
-
items: import("zod").ZodArray<import("zod").ZodObject<{
|
|
105
|
-
productId: import("zod").ZodNumber;
|
|
106
|
-
quantity: import("zod").ZodNumber;
|
|
107
|
-
price: import("zod").ZodNumber;
|
|
108
|
-
notes: import("zod").ZodOptional<import("zod").ZodString>;
|
|
109
|
-
discount: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
110
|
-
}, import("zod/v4/core").$strip>>;
|
|
111
|
-
createdAt: import("zod").ZodDate;
|
|
112
|
-
}, import("zod/v4/core").$strip>>>;
|
|
113
|
-
'order.fetch': (args: import("zod").infer<import("zod").ZodObject<{
|
|
114
|
-
id: import("zod").ZodNumber;
|
|
115
|
-
}, import("zod/v4/core").$strip>>, context: {
|
|
116
|
-
requestedAt: number;
|
|
117
|
-
userId: number;
|
|
118
|
-
}) => Promise<import("zod").infer<import("zod").ZodObject<{
|
|
119
|
-
id: import("zod").ZodNumber;
|
|
120
|
-
customerId: import("zod").ZodNumber;
|
|
121
|
-
status: import("zod").ZodString;
|
|
122
|
-
total: import("zod").ZodNumber;
|
|
123
|
-
items: import("zod").ZodArray<import("zod").ZodObject<{
|
|
124
|
-
productId: import("zod").ZodNumber;
|
|
125
|
-
quantity: import("zod").ZodNumber;
|
|
126
|
-
price: import("zod").ZodNumber;
|
|
127
|
-
notes: import("zod").ZodOptional<import("zod").ZodString>;
|
|
128
|
-
discount: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
129
|
-
}, import("zod/v4/core").$strip>>;
|
|
130
|
-
shippingAddress: import("zod").ZodObject<{
|
|
131
|
-
street: import("zod").ZodString;
|
|
132
|
-
city: import("zod").ZodString;
|
|
133
|
-
state: import("zod").ZodString;
|
|
134
|
-
zip: import("zod").ZodString;
|
|
135
|
-
country: import("zod").ZodDefault<import("zod").ZodString>;
|
|
136
|
-
}, import("zod/v4/core").$strip>;
|
|
137
|
-
billingAddress: import("zod").ZodNullable<import("zod").ZodObject<{
|
|
138
|
-
street: import("zod").ZodString;
|
|
139
|
-
city: import("zod").ZodString;
|
|
140
|
-
state: import("zod").ZodString;
|
|
141
|
-
zip: import("zod").ZodString;
|
|
142
|
-
country: import("zod").ZodDefault<import("zod").ZodString>;
|
|
143
|
-
}, import("zod/v4/core").$strip>>;
|
|
144
|
-
isGift: import("zod").ZodBoolean;
|
|
145
|
-
giftMessage: import("zod").ZodNullable<import("zod").ZodString>;
|
|
146
|
-
createdAt: import("zod").ZodDate;
|
|
147
|
-
updatedAt: import("zod").ZodNullable<import("zod").ZodDate>;
|
|
148
|
-
}, import("zod/v4/core").$strip>>>;
|
|
149
|
-
'order.update': (args: import("zod").infer<import("zod").ZodObject<{
|
|
150
|
-
id: import("zod").ZodNumber;
|
|
151
|
-
status: import("zod").ZodOptional<import("zod").ZodString>;
|
|
152
|
-
shippingAddress: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
153
|
-
street: import("zod").ZodString;
|
|
154
|
-
city: import("zod").ZodString;
|
|
155
|
-
state: import("zod").ZodString;
|
|
156
|
-
zip: import("zod").ZodString;
|
|
157
|
-
country: import("zod").ZodDefault<import("zod").ZodString>;
|
|
158
|
-
}, import("zod/v4/core").$strip>>;
|
|
159
|
-
giftMessage: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
160
|
-
}, import("zod/v4/core").$strip>>, context: {
|
|
161
|
-
requestedAt: number;
|
|
162
|
-
userId: number;
|
|
163
|
-
}) => Promise<import("zod").infer<import("zod").ZodObject<{
|
|
164
|
-
id: import("zod").ZodNumber;
|
|
165
|
-
status: import("zod").ZodString;
|
|
166
|
-
updatedAt: import("zod").ZodDate;
|
|
167
|
-
}, import("zod/v4/core").$strip>>>;
|
|
168
|
-
'order.list': () => Promise<order.Order[]>;
|
|
169
|
-
'order.resolve': (args: import("zod").infer<import("zod").ZodObject<{
|
|
170
|
-
id: import("zod").ZodNumber;
|
|
171
|
-
}, import("zod/v4/core").$strip>>, context: {
|
|
172
|
-
requestedAt: number;
|
|
173
|
-
userId: number;
|
|
174
|
-
}) => Promise<import("zod").infer<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
175
|
-
status: import("zod").ZodLiteral<"found">;
|
|
176
|
-
order: import("zod").ZodObject<{
|
|
177
|
-
id: import("zod").ZodNumber;
|
|
178
|
-
customerName: import("zod").ZodString;
|
|
179
|
-
orderStatus: import("zod").ZodEnum<{
|
|
180
|
-
pending: "pending";
|
|
181
|
-
confirmed: "confirmed";
|
|
182
|
-
shipped: "shipped";
|
|
183
|
-
delivered: "delivered";
|
|
184
|
-
cancelled: "cancelled";
|
|
185
|
-
}>;
|
|
186
|
-
total: import("zod").ZodNumber;
|
|
187
|
-
}, import("zod/v4/core").$strip>;
|
|
188
|
-
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
189
|
-
status: import("zod").ZodLiteral<"not_found">;
|
|
190
|
-
}, import("zod/v4/core").$strip>], "status">>>;
|
|
191
|
-
'order.statusFilter': (args: import("zod").infer<import("zod").ZodObject<{
|
|
192
|
-
status: import("zod").ZodEnum<{
|
|
193
|
-
pending: "pending";
|
|
194
|
-
confirmed: "confirmed";
|
|
195
|
-
shipped: "shipped";
|
|
196
|
-
delivered: "delivered";
|
|
197
|
-
cancelled: "cancelled";
|
|
198
|
-
}>;
|
|
199
|
-
}, import("zod/v4/core").$strip>>, context: {
|
|
200
|
-
requestedAt: number;
|
|
201
|
-
userId: number;
|
|
202
|
-
}) => Promise<import("zod").infer<import("zod").ZodObject<{
|
|
203
|
-
orders: import("zod").ZodArray<import("zod").ZodObject<{
|
|
204
|
-
id: import("zod").ZodNumber;
|
|
205
|
-
status: import("zod").ZodEnum<{
|
|
206
|
-
pending: "pending";
|
|
207
|
-
confirmed: "confirmed";
|
|
208
|
-
shipped: "shipped";
|
|
209
|
-
delivered: "delivered";
|
|
210
|
-
cancelled: "cancelled";
|
|
211
|
-
}>;
|
|
212
|
-
total: import("zod").ZodNumber;
|
|
213
|
-
}, import("zod/v4/core").$strip>>;
|
|
214
|
-
}, import("zod/v4/core").$strip>>>;
|
|
215
|
-
'order.tag': (args: import("zod").infer<import("zod").ZodObject<{
|
|
216
|
-
orderId: import("zod").ZodNumber;
|
|
217
|
-
tag: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber]>;
|
|
218
|
-
}, import("zod/v4/core").$strip>>, context: {
|
|
219
|
-
requestedAt: number;
|
|
220
|
-
userId: number;
|
|
221
|
-
}) => Promise<import("zod").infer<import("zod").ZodObject<{
|
|
222
|
-
orderId: import("zod").ZodNumber;
|
|
223
|
-
tag: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber]>;
|
|
224
|
-
appliedAt: import("zod").ZodDate;
|
|
225
|
-
}, import("zod/v4/core").$strip>>>;
|
|
226
|
-
'order.primitives': (args: import("zod").infer<import("zod").ZodObject<{
|
|
227
|
-
key: import("zod").ZodString;
|
|
228
|
-
}, import("zod/v4/core").$strip>>) => Promise<import("zod").infer<import("zod").ZodObject<{
|
|
229
|
-
str: import("zod").ZodString;
|
|
230
|
-
num: import("zod").ZodNumber;
|
|
231
|
-
bool: import("zod").ZodBoolean;
|
|
232
|
-
date: import("zod").ZodDate;
|
|
233
|
-
nul: import("zod").ZodNull;
|
|
234
|
-
undef: import("zod").ZodUndefined;
|
|
235
|
-
unk: import("zod").ZodUnknown;
|
|
236
|
-
whatever: import("zod").ZodAny;
|
|
237
|
-
optStr: import("zod").ZodOptional<import("zod").ZodString>;
|
|
238
|
-
nullStr: import("zod").ZodNullable<import("zod").ZodString>;
|
|
239
|
-
defStr: import("zod").ZodDefault<import("zod").ZodString>;
|
|
240
|
-
optNullStr: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
241
|
-
nullOptStr: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodString>>;
|
|
242
|
-
tags: import("zod").ZodArray<import("zod").ZodString>;
|
|
243
|
-
scores: import("zod").ZodNullable<import("zod").ZodArray<import("zod").ZodNumber>>;
|
|
244
|
-
optDates: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodDate>>;
|
|
245
|
-
nested: import("zod").ZodObject<{
|
|
246
|
-
a: import("zod").ZodNumber;
|
|
247
|
-
b: import("zod").ZodOptional<import("zod").ZodString>;
|
|
248
|
-
c: import("zod").ZodObject<{
|
|
249
|
-
d: import("zod").ZodBoolean;
|
|
250
|
-
e: import("zod").ZodNullable<import("zod").ZodArray<import("zod").ZodString>>;
|
|
251
|
-
}, import("zod/v4/core").$strip>;
|
|
252
|
-
}, import("zod/v4/core").$strip>;
|
|
253
|
-
}, import("zod/v4/core").$strip>>>;
|
|
254
|
-
};
|
|
255
|
-
export default _default;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const user = __importStar(require("./user"));
|
|
37
|
-
const product = __importStar(require("./product"));
|
|
38
|
-
const order = __importStar(require("./order"));
|
|
39
|
-
exports.default = {
|
|
40
|
-
'user.fetch': user.fetch,
|
|
41
|
-
'user.create': user.create,
|
|
42
|
-
'user.update': user.update,
|
|
43
|
-
'user.remove': user.remove,
|
|
44
|
-
'user.fetchAll': user.fetchAll,
|
|
45
|
-
'product.fetch': product.fetch,
|
|
46
|
-
'product.create': product.create,
|
|
47
|
-
'product.list': product.list,
|
|
48
|
-
'order.create': order.create,
|
|
49
|
-
'order.fetch': order.fetch,
|
|
50
|
-
'order.update': order.update,
|
|
51
|
-
'order.list': order.list,
|
|
52
|
-
'order.resolve': order.resolve,
|
|
53
|
-
'order.statusFilter': order.statusFilter,
|
|
54
|
-
'order.tag': order.tag,
|
|
55
|
-
'order.primitives': order.primitives
|
|
56
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { z } from '../../..';
|
|
2
|
-
import * as types from './types';
|
|
3
|
-
export interface OrderItem {
|
|
4
|
-
productId: number;
|
|
5
|
-
quantity: number;
|
|
6
|
-
price: number;
|
|
7
|
-
notes?: string;
|
|
8
|
-
discount: number | null;
|
|
9
|
-
}
|
|
10
|
-
export interface Address {
|
|
11
|
-
street: string;
|
|
12
|
-
city: string;
|
|
13
|
-
state: string;
|
|
14
|
-
zip: string;
|
|
15
|
-
country: string;
|
|
16
|
-
}
|
|
17
|
-
export interface Order {
|
|
18
|
-
id: number;
|
|
19
|
-
customerId: number;
|
|
20
|
-
status: string;
|
|
21
|
-
total: number;
|
|
22
|
-
items: OrderItem[];
|
|
23
|
-
shippingAddress: Address;
|
|
24
|
-
billingAddress: Address | null;
|
|
25
|
-
isGift: boolean;
|
|
26
|
-
giftMessage: string | null;
|
|
27
|
-
createdAt: Date;
|
|
28
|
-
updatedAt: Date | null;
|
|
29
|
-
}
|
|
30
|
-
type Context = {
|
|
31
|
-
requestedAt: number;
|
|
32
|
-
userId: number;
|
|
33
|
-
};
|
|
34
|
-
export declare const create: (args: z.infer<typeof types.create.args>, context: Context) => Promise<z.infer<typeof types.create.res>>;
|
|
35
|
-
export declare const fetch: (args: z.infer<typeof types.fetch.args>, context: Context) => Promise<z.infer<typeof types.fetch.res>>;
|
|
36
|
-
export declare const update: (args: z.infer<typeof types.update.args>, context: Context) => Promise<z.infer<typeof types.update.res>>;
|
|
37
|
-
export declare const list: () => Promise<Order[]>;
|
|
38
|
-
export declare const resolve: (args: z.infer<typeof types.resolve.args>, context: Context) => Promise<z.infer<typeof types.resolve.res>>;
|
|
39
|
-
export declare const statusFilter: (args: z.infer<typeof types.statusFilter.args>, context: Context) => Promise<z.infer<typeof types.statusFilter.res>>;
|
|
40
|
-
export declare const tag: (args: z.infer<typeof types.tag.args>, context: Context) => Promise<z.infer<typeof types.tag.res>>;
|
|
41
|
-
export declare const primitives: (args: z.infer<typeof types.primitives.args>) => Promise<z.infer<typeof types.primitives.res>>;
|
|
42
|
-
export {};
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.primitives = exports.tag = exports.statusFilter = exports.resolve = exports.list = exports.update = exports.fetch = exports.create = void 0;
|
|
37
|
-
const types = __importStar(require("./types"));
|
|
38
|
-
let nextId = 1;
|
|
39
|
-
const orders = [];
|
|
40
|
-
const create = async (args, context) => {
|
|
41
|
-
args = types.create.args.parse(args);
|
|
42
|
-
const items = args.items.map(item => ({
|
|
43
|
-
...item,
|
|
44
|
-
price: item.price,
|
|
45
|
-
discount: item.discount
|
|
46
|
-
}));
|
|
47
|
-
const order = {
|
|
48
|
-
id: nextId++,
|
|
49
|
-
customerId: args.customerId,
|
|
50
|
-
status: 'pending',
|
|
51
|
-
total: items.reduce((sum, i) => sum + i.price * i.quantity, 0),
|
|
52
|
-
items,
|
|
53
|
-
shippingAddress: { ...args.shippingAddress, country: args.shippingAddress.country ?? 'US' },
|
|
54
|
-
billingAddress: args.billingAddress
|
|
55
|
-
? { ...args.billingAddress, country: args.billingAddress.country ?? 'US' }
|
|
56
|
-
: null,
|
|
57
|
-
isGift: args.isGift,
|
|
58
|
-
giftMessage: args.giftMessage,
|
|
59
|
-
createdAt: new Date(),
|
|
60
|
-
updatedAt: null
|
|
61
|
-
};
|
|
62
|
-
orders.push(order);
|
|
63
|
-
return {
|
|
64
|
-
id: order.id,
|
|
65
|
-
status: order.status,
|
|
66
|
-
total: order.total,
|
|
67
|
-
items: order.items,
|
|
68
|
-
createdAt: order.createdAt
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
exports.create = create;
|
|
72
|
-
const fetch = async (args, context) => {
|
|
73
|
-
args = types.fetch.args.parse(args);
|
|
74
|
-
const order = orders.find(o => o.id === args.id);
|
|
75
|
-
if (!order)
|
|
76
|
-
throw new Error(`Order with ID ${args.id} not found`);
|
|
77
|
-
return order;
|
|
78
|
-
};
|
|
79
|
-
exports.fetch = fetch;
|
|
80
|
-
const update = async (args, context) => {
|
|
81
|
-
args = types.update.args.parse(args);
|
|
82
|
-
const order = orders.find(o => o.id === args.id);
|
|
83
|
-
if (!order)
|
|
84
|
-
throw new Error(`Order with ID ${args.id} not found`);
|
|
85
|
-
if (args.status)
|
|
86
|
-
order.status = args.status;
|
|
87
|
-
if (args.shippingAddress)
|
|
88
|
-
order.shippingAddress = { ...args.shippingAddress, country: args.shippingAddress.country ?? 'US' };
|
|
89
|
-
if (args.giftMessage !== undefined)
|
|
90
|
-
order.giftMessage = args.giftMessage ?? null;
|
|
91
|
-
order.updatedAt = new Date();
|
|
92
|
-
return { id: order.id, status: order.status, updatedAt: order.updatedAt };
|
|
93
|
-
};
|
|
94
|
-
exports.update = update;
|
|
95
|
-
const list = async () => {
|
|
96
|
-
return orders;
|
|
97
|
-
};
|
|
98
|
-
exports.list = list;
|
|
99
|
-
const resolve = async (args, context) => {
|
|
100
|
-
args = types.resolve.args.parse(args);
|
|
101
|
-
const order = orders.find(o => o.id === args.id);
|
|
102
|
-
if (!order)
|
|
103
|
-
return { status: 'not_found' };
|
|
104
|
-
return {
|
|
105
|
-
status: 'found',
|
|
106
|
-
order: {
|
|
107
|
-
id: order.id,
|
|
108
|
-
customerName: `Customer #${order.customerId}`,
|
|
109
|
-
orderStatus: order.status,
|
|
110
|
-
total: order.total
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
exports.resolve = resolve;
|
|
115
|
-
const statusFilter = async (args, context) => {
|
|
116
|
-
args = types.statusFilter.args.parse(args);
|
|
117
|
-
return {
|
|
118
|
-
orders: orders
|
|
119
|
-
.filter(o => o.status === args.status)
|
|
120
|
-
.map(o => ({ id: o.id, status: o.status, total: o.total }))
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
exports.statusFilter = statusFilter;
|
|
124
|
-
const orderTags = new Map();
|
|
125
|
-
const tag = async (args, context) => {
|
|
126
|
-
args = types.tag.args.parse(args);
|
|
127
|
-
const order = orders.find(o => o.id === args.orderId);
|
|
128
|
-
if (!order)
|
|
129
|
-
throw new Error(`Order with ID ${args.orderId} not found`);
|
|
130
|
-
const tags = orderTags.get(args.orderId) || [];
|
|
131
|
-
tags.push(args.tag);
|
|
132
|
-
orderTags.set(args.orderId, tags);
|
|
133
|
-
return { orderId: args.orderId, tag: args.tag, appliedAt: new Date() };
|
|
134
|
-
};
|
|
135
|
-
exports.tag = tag;
|
|
136
|
-
const primitives = async (args) => {
|
|
137
|
-
args = types.primitives.args.parse(args);
|
|
138
|
-
return {
|
|
139
|
-
str: 'hello',
|
|
140
|
-
num: 42,
|
|
141
|
-
bool: true,
|
|
142
|
-
date: new Date(),
|
|
143
|
-
nul: null,
|
|
144
|
-
undef: undefined,
|
|
145
|
-
unk: { anything: true },
|
|
146
|
-
whatever: 'literally anything',
|
|
147
|
-
optStr: 'present',
|
|
148
|
-
nullStr: null,
|
|
149
|
-
defStr: 'default value',
|
|
150
|
-
optNullStr: null,
|
|
151
|
-
nullOptStr: undefined,
|
|
152
|
-
tags: ['a', 'b', 'c'],
|
|
153
|
-
scores: [1, 2, 3],
|
|
154
|
-
optDates: [new Date()],
|
|
155
|
-
nested: {
|
|
156
|
-
a: 1,
|
|
157
|
-
b: 'nested',
|
|
158
|
-
c: {
|
|
159
|
-
d: true,
|
|
160
|
-
e: ['deep']
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
exports.primitives = primitives;
|