typed-bridge 2.1.4 → 3.0.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/dist/bridge/index.d.ts +9 -4
- package/dist/bridge/index.js +33 -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 +225 -32
- package/dist/tools/index.d.ts +126 -0
- package/dist/tools/index.js +218 -0
- package/package.json +19 -4
- 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/docs/auto-bridge-sync.md +0 -56
- package/test/bridge.ts +0 -283
- package/test/index.ts +0 -251
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { z } from '../../..';
|
|
2
|
-
export declare const create: {
|
|
3
|
-
args: z.ZodObject<{
|
|
4
|
-
customerId: z.ZodNumber;
|
|
5
|
-
items: z.ZodArray<z.ZodObject<{
|
|
6
|
-
productId: z.ZodNumber;
|
|
7
|
-
quantity: z.ZodNumber;
|
|
8
|
-
price: z.ZodNumber;
|
|
9
|
-
notes: z.ZodOptional<z.ZodString>;
|
|
10
|
-
discount: z.ZodNullable<z.ZodNumber>;
|
|
11
|
-
}, z.core.$strip>>;
|
|
12
|
-
shippingAddress: z.ZodObject<{
|
|
13
|
-
street: z.ZodString;
|
|
14
|
-
city: z.ZodString;
|
|
15
|
-
state: z.ZodString;
|
|
16
|
-
zip: z.ZodString;
|
|
17
|
-
country: z.ZodDefault<z.ZodString>;
|
|
18
|
-
}, z.core.$strip>;
|
|
19
|
-
billingAddress: z.ZodNullable<z.ZodObject<{
|
|
20
|
-
street: z.ZodString;
|
|
21
|
-
city: z.ZodString;
|
|
22
|
-
state: z.ZodString;
|
|
23
|
-
zip: z.ZodString;
|
|
24
|
-
country: z.ZodDefault<z.ZodString>;
|
|
25
|
-
}, z.core.$strip>>;
|
|
26
|
-
couponCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
-
scheduledDate: z.ZodOptional<z.ZodDate>;
|
|
28
|
-
isGift: z.ZodBoolean;
|
|
29
|
-
giftMessage: z.ZodNullable<z.ZodString>;
|
|
30
|
-
}, z.core.$strip>;
|
|
31
|
-
res: z.ZodObject<{
|
|
32
|
-
id: z.ZodNumber;
|
|
33
|
-
status: z.ZodString;
|
|
34
|
-
total: z.ZodNumber;
|
|
35
|
-
items: z.ZodArray<z.ZodObject<{
|
|
36
|
-
productId: z.ZodNumber;
|
|
37
|
-
quantity: z.ZodNumber;
|
|
38
|
-
price: z.ZodNumber;
|
|
39
|
-
notes: z.ZodOptional<z.ZodString>;
|
|
40
|
-
discount: z.ZodNullable<z.ZodNumber>;
|
|
41
|
-
}, z.core.$strip>>;
|
|
42
|
-
createdAt: z.ZodDate;
|
|
43
|
-
}, z.core.$strip>;
|
|
44
|
-
};
|
|
45
|
-
export declare const fetch: {
|
|
46
|
-
args: z.ZodObject<{
|
|
47
|
-
id: z.ZodNumber;
|
|
48
|
-
}, z.core.$strip>;
|
|
49
|
-
res: z.ZodObject<{
|
|
50
|
-
id: z.ZodNumber;
|
|
51
|
-
customerId: z.ZodNumber;
|
|
52
|
-
status: z.ZodString;
|
|
53
|
-
total: z.ZodNumber;
|
|
54
|
-
items: z.ZodArray<z.ZodObject<{
|
|
55
|
-
productId: z.ZodNumber;
|
|
56
|
-
quantity: z.ZodNumber;
|
|
57
|
-
price: z.ZodNumber;
|
|
58
|
-
notes: z.ZodOptional<z.ZodString>;
|
|
59
|
-
discount: z.ZodNullable<z.ZodNumber>;
|
|
60
|
-
}, z.core.$strip>>;
|
|
61
|
-
shippingAddress: z.ZodObject<{
|
|
62
|
-
street: z.ZodString;
|
|
63
|
-
city: z.ZodString;
|
|
64
|
-
state: z.ZodString;
|
|
65
|
-
zip: z.ZodString;
|
|
66
|
-
country: z.ZodDefault<z.ZodString>;
|
|
67
|
-
}, z.core.$strip>;
|
|
68
|
-
billingAddress: z.ZodNullable<z.ZodObject<{
|
|
69
|
-
street: z.ZodString;
|
|
70
|
-
city: z.ZodString;
|
|
71
|
-
state: z.ZodString;
|
|
72
|
-
zip: z.ZodString;
|
|
73
|
-
country: z.ZodDefault<z.ZodString>;
|
|
74
|
-
}, z.core.$strip>>;
|
|
75
|
-
isGift: z.ZodBoolean;
|
|
76
|
-
giftMessage: z.ZodNullable<z.ZodString>;
|
|
77
|
-
createdAt: z.ZodDate;
|
|
78
|
-
updatedAt: z.ZodNullable<z.ZodDate>;
|
|
79
|
-
}, z.core.$strip>;
|
|
80
|
-
};
|
|
81
|
-
export declare const update: {
|
|
82
|
-
args: z.ZodObject<{
|
|
83
|
-
id: z.ZodNumber;
|
|
84
|
-
status: z.ZodOptional<z.ZodString>;
|
|
85
|
-
shippingAddress: z.ZodOptional<z.ZodObject<{
|
|
86
|
-
street: z.ZodString;
|
|
87
|
-
city: z.ZodString;
|
|
88
|
-
state: z.ZodString;
|
|
89
|
-
zip: z.ZodString;
|
|
90
|
-
country: z.ZodDefault<z.ZodString>;
|
|
91
|
-
}, z.core.$strip>>;
|
|
92
|
-
giftMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
93
|
-
}, z.core.$strip>;
|
|
94
|
-
res: z.ZodObject<{
|
|
95
|
-
id: z.ZodNumber;
|
|
96
|
-
status: z.ZodString;
|
|
97
|
-
updatedAt: z.ZodDate;
|
|
98
|
-
}, z.core.$strip>;
|
|
99
|
-
};
|
|
100
|
-
export declare const resolve: {
|
|
101
|
-
args: z.ZodObject<{
|
|
102
|
-
id: z.ZodNumber;
|
|
103
|
-
}, z.core.$strip>;
|
|
104
|
-
res: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
105
|
-
status: z.ZodLiteral<"found">;
|
|
106
|
-
order: z.ZodObject<{
|
|
107
|
-
id: z.ZodNumber;
|
|
108
|
-
customerName: z.ZodString;
|
|
109
|
-
orderStatus: z.ZodEnum<{
|
|
110
|
-
pending: "pending";
|
|
111
|
-
confirmed: "confirmed";
|
|
112
|
-
shipped: "shipped";
|
|
113
|
-
delivered: "delivered";
|
|
114
|
-
cancelled: "cancelled";
|
|
115
|
-
}>;
|
|
116
|
-
total: z.ZodNumber;
|
|
117
|
-
}, z.core.$strip>;
|
|
118
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
119
|
-
status: z.ZodLiteral<"not_found">;
|
|
120
|
-
}, z.core.$strip>], "status">;
|
|
121
|
-
};
|
|
122
|
-
export declare const statusFilter: {
|
|
123
|
-
args: z.ZodObject<{
|
|
124
|
-
status: z.ZodEnum<{
|
|
125
|
-
pending: "pending";
|
|
126
|
-
confirmed: "confirmed";
|
|
127
|
-
shipped: "shipped";
|
|
128
|
-
delivered: "delivered";
|
|
129
|
-
cancelled: "cancelled";
|
|
130
|
-
}>;
|
|
131
|
-
}, z.core.$strip>;
|
|
132
|
-
res: z.ZodObject<{
|
|
133
|
-
orders: z.ZodArray<z.ZodObject<{
|
|
134
|
-
id: z.ZodNumber;
|
|
135
|
-
status: z.ZodEnum<{
|
|
136
|
-
pending: "pending";
|
|
137
|
-
confirmed: "confirmed";
|
|
138
|
-
shipped: "shipped";
|
|
139
|
-
delivered: "delivered";
|
|
140
|
-
cancelled: "cancelled";
|
|
141
|
-
}>;
|
|
142
|
-
total: z.ZodNumber;
|
|
143
|
-
}, z.core.$strip>>;
|
|
144
|
-
}, z.core.$strip>;
|
|
145
|
-
};
|
|
146
|
-
export declare const tag: {
|
|
147
|
-
args: z.ZodObject<{
|
|
148
|
-
orderId: z.ZodNumber;
|
|
149
|
-
tag: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
150
|
-
}, z.core.$strip>;
|
|
151
|
-
res: z.ZodObject<{
|
|
152
|
-
orderId: z.ZodNumber;
|
|
153
|
-
tag: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
154
|
-
appliedAt: z.ZodDate;
|
|
155
|
-
}, z.core.$strip>;
|
|
156
|
-
};
|
|
157
|
-
export declare const primitives: {
|
|
158
|
-
args: z.ZodObject<{
|
|
159
|
-
key: z.ZodString;
|
|
160
|
-
}, z.core.$strip>;
|
|
161
|
-
res: z.ZodObject<{
|
|
162
|
-
str: z.ZodString;
|
|
163
|
-
num: z.ZodNumber;
|
|
164
|
-
bool: z.ZodBoolean;
|
|
165
|
-
date: z.ZodDate;
|
|
166
|
-
nul: z.ZodNull;
|
|
167
|
-
undef: z.ZodUndefined;
|
|
168
|
-
unk: z.ZodUnknown;
|
|
169
|
-
whatever: z.ZodAny;
|
|
170
|
-
optStr: z.ZodOptional<z.ZodString>;
|
|
171
|
-
nullStr: z.ZodNullable<z.ZodString>;
|
|
172
|
-
defStr: z.ZodDefault<z.ZodString>;
|
|
173
|
-
optNullStr: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
174
|
-
nullOptStr: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
175
|
-
tags: z.ZodArray<z.ZodString>;
|
|
176
|
-
scores: z.ZodNullable<z.ZodArray<z.ZodNumber>>;
|
|
177
|
-
optDates: z.ZodOptional<z.ZodArray<z.ZodDate>>;
|
|
178
|
-
nested: z.ZodObject<{
|
|
179
|
-
a: z.ZodNumber;
|
|
180
|
-
b: z.ZodOptional<z.ZodString>;
|
|
181
|
-
c: z.ZodObject<{
|
|
182
|
-
d: z.ZodBoolean;
|
|
183
|
-
e: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
184
|
-
}, z.core.$strip>;
|
|
185
|
-
}, z.core.$strip>;
|
|
186
|
-
}, z.core.$strip>;
|
|
187
|
-
};
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.primitives = exports.tag = exports.statusFilter = exports.resolve = exports.update = exports.fetch = exports.create = void 0;
|
|
4
|
-
const __1 = require("../../..");
|
|
5
|
-
// --- Reusable schemas ---
|
|
6
|
-
const addressSchema = __1.z.object({
|
|
7
|
-
street: __1.z.string(),
|
|
8
|
-
city: __1.z.string(),
|
|
9
|
-
state: __1.z.string(),
|
|
10
|
-
zip: __1.z.string(),
|
|
11
|
-
country: __1.z.string().default('US') // ZodDefault<ZodString> → string
|
|
12
|
-
});
|
|
13
|
-
const orderItemSchema = __1.z.object({
|
|
14
|
-
productId: __1.z.number(),
|
|
15
|
-
quantity: __1.z.number().min(1),
|
|
16
|
-
price: __1.z.number(),
|
|
17
|
-
notes: __1.z.string().optional(), // ZodOptional<ZodString> → string?
|
|
18
|
-
discount: __1.z.number().nullable() // ZodNullable<ZodNumber> → number | null
|
|
19
|
-
});
|
|
20
|
-
// --- create ---
|
|
21
|
-
exports.create = {
|
|
22
|
-
args: __1.z.object({
|
|
23
|
-
customerId: __1.z.number().min(1),
|
|
24
|
-
items: __1.z.array(orderItemSchema), // ZodArray<ZodObject> → {...}[]
|
|
25
|
-
shippingAddress: addressSchema, // nested ZodObject
|
|
26
|
-
billingAddress: addressSchema.nullable(), // ZodNullable<ZodObject> → {...} | null
|
|
27
|
-
couponCode: __1.z.string().nullable().optional(), // ZodOptional<ZodNullable<ZodString>> → (string | null)?
|
|
28
|
-
scheduledDate: __1.z.date().optional(), // ZodOptional<ZodDate> → Date?
|
|
29
|
-
isGift: __1.z.boolean(), // ZodBoolean → boolean
|
|
30
|
-
giftMessage: __1.z.string().nullable() // ZodNullable<ZodString> → string | null
|
|
31
|
-
}),
|
|
32
|
-
res: __1.z.object({
|
|
33
|
-
id: __1.z.number(),
|
|
34
|
-
status: __1.z.string(),
|
|
35
|
-
total: __1.z.number(),
|
|
36
|
-
items: __1.z.array(orderItemSchema),
|
|
37
|
-
createdAt: __1.z.date() // ZodDate → Date
|
|
38
|
-
})
|
|
39
|
-
};
|
|
40
|
-
// --- fetch ---
|
|
41
|
-
exports.fetch = {
|
|
42
|
-
args: __1.z.object({
|
|
43
|
-
id: __1.z.number().min(1)
|
|
44
|
-
}),
|
|
45
|
-
res: __1.z.object({
|
|
46
|
-
id: __1.z.number(),
|
|
47
|
-
customerId: __1.z.number(),
|
|
48
|
-
status: __1.z.string(),
|
|
49
|
-
total: __1.z.number(),
|
|
50
|
-
items: __1.z.array(orderItemSchema),
|
|
51
|
-
shippingAddress: addressSchema,
|
|
52
|
-
billingAddress: addressSchema.nullable(),
|
|
53
|
-
isGift: __1.z.boolean(),
|
|
54
|
-
giftMessage: __1.z.string().nullable(),
|
|
55
|
-
createdAt: __1.z.date(),
|
|
56
|
-
updatedAt: __1.z.date().nullable() // ZodNullable<ZodDate> → Date | null
|
|
57
|
-
})
|
|
58
|
-
};
|
|
59
|
-
// --- update ---
|
|
60
|
-
exports.update = {
|
|
61
|
-
args: __1.z.object({
|
|
62
|
-
id: __1.z.number().min(1),
|
|
63
|
-
status: __1.z.string().optional(),
|
|
64
|
-
shippingAddress: addressSchema.optional(), // ZodOptional<ZodObject> → {...}?
|
|
65
|
-
giftMessage: __1.z.string().nullable().optional()
|
|
66
|
-
}),
|
|
67
|
-
res: __1.z.object({
|
|
68
|
-
id: __1.z.number(),
|
|
69
|
-
status: __1.z.string(),
|
|
70
|
-
updatedAt: __1.z.date()
|
|
71
|
-
})
|
|
72
|
-
};
|
|
73
|
-
// --- resolve: exercises ZodDiscriminatedUnion + ZodLiteral + ZodEnum ---
|
|
74
|
-
const orderStatusEnum = __1.z.enum(['pending', 'confirmed', 'shipped', 'delivered', 'cancelled']);
|
|
75
|
-
exports.resolve = {
|
|
76
|
-
args: __1.z.object({
|
|
77
|
-
id: __1.z.number().min(1)
|
|
78
|
-
}),
|
|
79
|
-
res: __1.z.discriminatedUnion('status', [
|
|
80
|
-
__1.z.object({
|
|
81
|
-
status: __1.z.literal('found'),
|
|
82
|
-
order: __1.z.object({
|
|
83
|
-
id: __1.z.number(),
|
|
84
|
-
customerName: __1.z.string(),
|
|
85
|
-
orderStatus: orderStatusEnum,
|
|
86
|
-
total: __1.z.number()
|
|
87
|
-
})
|
|
88
|
-
}),
|
|
89
|
-
__1.z.object({
|
|
90
|
-
status: __1.z.literal('not_found')
|
|
91
|
-
})
|
|
92
|
-
])
|
|
93
|
-
};
|
|
94
|
-
// --- statusFilter: exercises ZodEnum in args and response ---
|
|
95
|
-
exports.statusFilter = {
|
|
96
|
-
args: __1.z.object({
|
|
97
|
-
status: orderStatusEnum
|
|
98
|
-
}),
|
|
99
|
-
res: __1.z.object({
|
|
100
|
-
orders: __1.z.array(__1.z.object({
|
|
101
|
-
id: __1.z.number(),
|
|
102
|
-
status: orderStatusEnum,
|
|
103
|
-
total: __1.z.number()
|
|
104
|
-
}))
|
|
105
|
-
})
|
|
106
|
-
};
|
|
107
|
-
// --- tag: exercises ZodUnion ---
|
|
108
|
-
exports.tag = {
|
|
109
|
-
args: __1.z.object({
|
|
110
|
-
orderId: __1.z.number().min(1),
|
|
111
|
-
tag: __1.z.union([__1.z.string(), __1.z.number()])
|
|
112
|
-
}),
|
|
113
|
-
res: __1.z.object({
|
|
114
|
-
orderId: __1.z.number(),
|
|
115
|
-
tag: __1.z.union([__1.z.string(), __1.z.number()]),
|
|
116
|
-
appliedAt: __1.z.date()
|
|
117
|
-
})
|
|
118
|
-
};
|
|
119
|
-
// --- primitives: exercises all remaining keyword types ---
|
|
120
|
-
exports.primitives = {
|
|
121
|
-
args: __1.z.object({
|
|
122
|
-
key: __1.z.string()
|
|
123
|
-
}),
|
|
124
|
-
res: __1.z.object({
|
|
125
|
-
str: __1.z.string(), // ZodString → string
|
|
126
|
-
num: __1.z.number(), // ZodNumber → number
|
|
127
|
-
bool: __1.z.boolean(), // ZodBoolean → boolean
|
|
128
|
-
date: __1.z.date(), // ZodDate → Date
|
|
129
|
-
nul: __1.z.null(), // ZodNull → null
|
|
130
|
-
undef: __1.z.undefined(), // ZodUndefined → undefined
|
|
131
|
-
unk: __1.z.unknown(), // ZodUnknown → unknown
|
|
132
|
-
whatever: __1.z.any(), // ZodAny → any
|
|
133
|
-
optStr: __1.z.string().optional(), // ZodOptional<ZodString> → string?
|
|
134
|
-
nullStr: __1.z.string().nullable(), // ZodNullable<ZodString> → string | null
|
|
135
|
-
defStr: __1.z.string().default('hello'), // ZodDefault<ZodString> → string
|
|
136
|
-
optNullStr: __1.z.string().nullable().optional(), // ZodOptional<ZodNullable> → (string | null)?
|
|
137
|
-
nullOptStr: __1.z.string().optional().nullable(), // ZodNullable<ZodOptional> → (string | undefined) | null
|
|
138
|
-
tags: __1.z.array(__1.z.string()), // ZodArray<ZodString> → string[]
|
|
139
|
-
scores: __1.z.array(__1.z.number()).nullable(), // ZodNullable<ZodArray<ZodNumber>> → number[] | null
|
|
140
|
-
optDates: __1.z.array(__1.z.date()).optional(), // ZodOptional<ZodArray<ZodDate>> → Date[]?
|
|
141
|
-
nested: __1.z.object({
|
|
142
|
-
a: __1.z.number(),
|
|
143
|
-
b: __1.z.string().optional(),
|
|
144
|
-
c: __1.z.object({
|
|
145
|
-
d: __1.z.boolean(),
|
|
146
|
-
e: __1.z.array(__1.z.string()).nullable()
|
|
147
|
-
})
|
|
148
|
-
})
|
|
149
|
-
})
|
|
150
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from '../../..';
|
|
2
|
-
import * as types from './types';
|
|
3
|
-
export interface Product {
|
|
4
|
-
id: number;
|
|
5
|
-
name: string;
|
|
6
|
-
price: number;
|
|
7
|
-
createdAt: Date;
|
|
8
|
-
}
|
|
9
|
-
type Context = {
|
|
10
|
-
requestedAt: number;
|
|
11
|
-
userId: number;
|
|
12
|
-
};
|
|
13
|
-
export declare const fetch: (args: z.infer<typeof types.fetch.args>, context: Context) => Promise<z.infer<typeof types.fetch.res>>;
|
|
14
|
-
export declare const create: (args: z.infer<typeof types.create.args>, context: Context) => Promise<z.infer<typeof types.create.res>>;
|
|
15
|
-
export declare const list: () => Promise<Product[]>;
|
|
16
|
-
export {};
|
|
@@ -1,67 +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.list = exports.create = exports.fetch = void 0;
|
|
37
|
-
const types = __importStar(require("./types"));
|
|
38
|
-
let nextId = 4;
|
|
39
|
-
const products = [
|
|
40
|
-
{ id: 1, name: 'Laptop', price: 999, createdAt: new Date() },
|
|
41
|
-
{ id: 2, name: 'Keyboard', price: 79, createdAt: new Date() },
|
|
42
|
-
{ id: 3, name: 'Monitor', price: 349, createdAt: new Date() }
|
|
43
|
-
];
|
|
44
|
-
const fetch = async (args, context) => {
|
|
45
|
-
args = types.fetch.args.parse(args);
|
|
46
|
-
const product = products.find(p => p.id === args.id);
|
|
47
|
-
if (!product)
|
|
48
|
-
throw new Error(`Product with ID ${args.id} not found`);
|
|
49
|
-
return product;
|
|
50
|
-
};
|
|
51
|
-
exports.fetch = fetch;
|
|
52
|
-
const create = async (args, context) => {
|
|
53
|
-
args = types.create.args.parse(args);
|
|
54
|
-
const product = {
|
|
55
|
-
id: nextId++,
|
|
56
|
-
name: args.name,
|
|
57
|
-
price: args.price,
|
|
58
|
-
createdAt: new Date()
|
|
59
|
-
};
|
|
60
|
-
products.push(product);
|
|
61
|
-
return product;
|
|
62
|
-
};
|
|
63
|
-
exports.create = create;
|
|
64
|
-
const list = async () => {
|
|
65
|
-
return products;
|
|
66
|
-
};
|
|
67
|
-
exports.list = list;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { z } from '../../..';
|
|
2
|
-
export declare const fetch: {
|
|
3
|
-
args: z.ZodObject<{
|
|
4
|
-
id: z.ZodNumber;
|
|
5
|
-
}, z.core.$strip>;
|
|
6
|
-
res: z.ZodObject<{
|
|
7
|
-
id: z.ZodNumber;
|
|
8
|
-
name: z.ZodString;
|
|
9
|
-
price: z.ZodNumber;
|
|
10
|
-
createdAt: z.ZodDate;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
};
|
|
13
|
-
export declare const create: {
|
|
14
|
-
args: z.ZodObject<{
|
|
15
|
-
name: z.ZodString;
|
|
16
|
-
price: z.ZodNumber;
|
|
17
|
-
}, z.core.$strip>;
|
|
18
|
-
res: z.ZodObject<{
|
|
19
|
-
id: z.ZodNumber;
|
|
20
|
-
name: z.ZodString;
|
|
21
|
-
price: z.ZodNumber;
|
|
22
|
-
createdAt: z.ZodDate;
|
|
23
|
-
}, z.core.$strip>;
|
|
24
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.create = exports.fetch = void 0;
|
|
4
|
-
const __1 = require("../../..");
|
|
5
|
-
exports.fetch = {
|
|
6
|
-
args: __1.z.object({
|
|
7
|
-
id: __1.z.number().min(1)
|
|
8
|
-
}),
|
|
9
|
-
res: __1.z.object({
|
|
10
|
-
id: __1.z.number(),
|
|
11
|
-
name: __1.z.string(),
|
|
12
|
-
price: __1.z.number(),
|
|
13
|
-
createdAt: __1.z.date()
|
|
14
|
-
})
|
|
15
|
-
};
|
|
16
|
-
exports.create = {
|
|
17
|
-
args: __1.z.object({
|
|
18
|
-
name: __1.z.string().min(1),
|
|
19
|
-
price: __1.z.number().min(0)
|
|
20
|
-
}),
|
|
21
|
-
res: __1.z.object({
|
|
22
|
-
id: __1.z.number(),
|
|
23
|
-
name: __1.z.string(),
|
|
24
|
-
price: __1.z.number(),
|
|
25
|
-
createdAt: __1.z.date()
|
|
26
|
-
})
|
|
27
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { z } from '../../..';
|
|
2
|
-
import * as types from './types';
|
|
3
|
-
export interface User {
|
|
4
|
-
id: number;
|
|
5
|
-
name: string;
|
|
6
|
-
email: string;
|
|
7
|
-
createdAt: Date;
|
|
8
|
-
}
|
|
9
|
-
type Context = {
|
|
10
|
-
requestedAt: number;
|
|
11
|
-
userId: number;
|
|
12
|
-
};
|
|
13
|
-
export declare const fetch: (args: z.infer<typeof types.fetch.args>, context: Context) => Promise<z.infer<typeof types.fetch.res>>;
|
|
14
|
-
export declare const create: (args: z.infer<typeof types.create.args>, context: Context) => Promise<z.infer<typeof types.create.res>>;
|
|
15
|
-
export declare const update: (args: {
|
|
16
|
-
id: number;
|
|
17
|
-
name?: string;
|
|
18
|
-
email?: string;
|
|
19
|
-
}, context: Context) => Promise<User>;
|
|
20
|
-
export declare const remove: (args: {
|
|
21
|
-
id: number;
|
|
22
|
-
}, context: Context & {
|
|
23
|
-
isAdmin: boolean;
|
|
24
|
-
}) => Promise<{
|
|
25
|
-
success: boolean;
|
|
26
|
-
}>;
|
|
27
|
-
export declare const fetchAll: () => Promise<User[]>;
|
|
28
|
-
export {};
|
|
@@ -1,86 +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.fetchAll = exports.remove = exports.update = exports.create = exports.fetch = void 0;
|
|
37
|
-
const types = __importStar(require("./types"));
|
|
38
|
-
let nextId = 4;
|
|
39
|
-
const users = [
|
|
40
|
-
{ id: 1, name: 'Neil', email: 'neil@example.com', createdAt: new Date() },
|
|
41
|
-
{ id: 2, name: 'John', email: 'john@example.com', createdAt: new Date() },
|
|
42
|
-
{ id: 3, name: 'Jane', email: 'jane@example.com', createdAt: new Date() }
|
|
43
|
-
];
|
|
44
|
-
const fetch = async (args, context) => {
|
|
45
|
-
args = types.fetch.args.parse(args);
|
|
46
|
-
const user = users.find(u => u.id === args.id);
|
|
47
|
-
if (!user)
|
|
48
|
-
throw new Error(`User with ID ${args.id} not found`);
|
|
49
|
-
return user;
|
|
50
|
-
};
|
|
51
|
-
exports.fetch = fetch;
|
|
52
|
-
const create = async (args, context) => {
|
|
53
|
-
args = types.create.args.parse(args);
|
|
54
|
-
const user = {
|
|
55
|
-
id: nextId++,
|
|
56
|
-
name: args.name,
|
|
57
|
-
email: args.email,
|
|
58
|
-
createdAt: new Date()
|
|
59
|
-
};
|
|
60
|
-
users.push(user);
|
|
61
|
-
return user;
|
|
62
|
-
};
|
|
63
|
-
exports.create = create;
|
|
64
|
-
const update = async (args, context) => {
|
|
65
|
-
const user = users.find(u => u.id === args.id);
|
|
66
|
-
if (!user)
|
|
67
|
-
throw new Error(`User with ID ${args.id} not found`);
|
|
68
|
-
if (args.name)
|
|
69
|
-
user.name = args.name;
|
|
70
|
-
if (args.email)
|
|
71
|
-
user.email = args.email;
|
|
72
|
-
return user;
|
|
73
|
-
};
|
|
74
|
-
exports.update = update;
|
|
75
|
-
const remove = async (args, context) => {
|
|
76
|
-
const index = users.findIndex(u => u.id === args.id);
|
|
77
|
-
if (index === -1)
|
|
78
|
-
throw new Error(`User with ID ${args.id} not found`);
|
|
79
|
-
users.splice(index, 1);
|
|
80
|
-
return { success: true };
|
|
81
|
-
};
|
|
82
|
-
exports.remove = remove;
|
|
83
|
-
const fetchAll = async () => {
|
|
84
|
-
return users;
|
|
85
|
-
};
|
|
86
|
-
exports.fetchAll = fetchAll;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { z } from '../../..';
|
|
2
|
-
export declare const fetch: {
|
|
3
|
-
args: z.ZodObject<{
|
|
4
|
-
id: z.ZodNumber;
|
|
5
|
-
}, z.core.$strip>;
|
|
6
|
-
res: z.ZodObject<{
|
|
7
|
-
id: z.ZodNumber;
|
|
8
|
-
name: z.ZodString;
|
|
9
|
-
email: z.ZodString;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
};
|
|
12
|
-
export declare const create: {
|
|
13
|
-
args: z.ZodObject<{
|
|
14
|
-
name: z.ZodString;
|
|
15
|
-
email: z.ZodString;
|
|
16
|
-
}, z.core.$strip>;
|
|
17
|
-
res: z.ZodObject<{
|
|
18
|
-
id: z.ZodNumber;
|
|
19
|
-
name: z.ZodString;
|
|
20
|
-
email: z.ZodString;
|
|
21
|
-
createdAt: z.ZodDate;
|
|
22
|
-
}, z.core.$strip>;
|
|
23
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.create = exports.fetch = void 0;
|
|
4
|
-
const __1 = require("../../..");
|
|
5
|
-
exports.fetch = {
|
|
6
|
-
args: __1.z.object({
|
|
7
|
-
id: __1.z.number().min(1)
|
|
8
|
-
}),
|
|
9
|
-
res: __1.z.object({
|
|
10
|
-
id: __1.z.number(),
|
|
11
|
-
name: __1.z.string(),
|
|
12
|
-
email: __1.z.string()
|
|
13
|
-
})
|
|
14
|
-
};
|
|
15
|
-
exports.create = {
|
|
16
|
-
args: __1.z.object({
|
|
17
|
-
name: __1.z.string().min(1),
|
|
18
|
-
email: __1.z.string().email()
|
|
19
|
-
}),
|
|
20
|
-
res: __1.z.object({
|
|
21
|
-
id: __1.z.number(),
|
|
22
|
-
name: __1.z.string(),
|
|
23
|
-
email: __1.z.string(),
|
|
24
|
-
createdAt: __1.z.date()
|
|
25
|
-
})
|
|
26
|
-
};
|
package/dist/demo/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './middleware';
|
package/dist/demo/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const __1 = require("..");
|
|
7
|
-
const bridge_1 = __importDefault(require("./bridge"));
|
|
8
|
-
require("./middleware");
|
|
9
|
-
// Logging
|
|
10
|
-
__1.tbConfig.logs.request = true;
|
|
11
|
-
__1.tbConfig.logs.response = true;
|
|
12
|
-
__1.tbConfig.logs.error = true;
|
|
13
|
-
__1.tbConfig.logs.argsOnError = true;
|
|
14
|
-
__1.tbConfig.logs.contextOnError = true;
|
|
15
|
-
const { app } = (0, __1.createBridge)(bridge_1.default, 8080, '/bridge');
|
|
16
|
-
// Extend the server with custom routes
|
|
17
|
-
app.get('/status', (req, res) => {
|
|
18
|
-
res.json({ status: 'ok', uptime: process.uptime() });
|
|
19
|
-
});
|
|
20
|
-
// Graceful shutdown
|
|
21
|
-
(0, __1.onShutdown)(() => {
|
|
22
|
-
console.log('Cleanup complete');
|
|
23
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|