@porulle/plugin-marketplace 0.64.0 → 0.65.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/README.md +11 -59
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -11
- package/dist/routes/b2b.d.ts +1 -3
- package/dist/routes/b2b.d.ts.map +1 -1
- package/dist/routes/b2b.js +2 -70
- package/dist/routes/sub-orders.js +3 -3
- package/dist/routes/vendor-portal.js +6 -6
- package/dist/schema.d.ts +0 -194
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +0 -14
- package/dist/schemas/b2b.d.ts +0 -986
- package/dist/schemas/b2b.d.ts.map +1 -1
- package/dist/schemas/b2b.js +1 -184
- package/dist/schemas/commission.d.ts +0 -495
- package/dist/schemas/commission.d.ts.map +1 -1
- package/dist/schemas/commission.js +1 -78
- package/dist/schemas/disputes-returns-reviews.d.ts +0 -1354
- package/dist/schemas/disputes-returns-reviews.d.ts.map +1 -1
- package/dist/schemas/disputes-returns-reviews.js +1 -208
- package/dist/schemas/sub-orders.d.ts +0 -290
- package/dist/schemas/sub-orders.d.ts.map +1 -1
- package/dist/schemas/sub-orders.js +1 -59
- package/dist/schemas/vendor-portal.d.ts +0 -1755
- package/dist/schemas/vendor-portal.d.ts.map +1 -1
- package/dist/schemas/vendor-portal.js +1 -247
- package/dist/schemas/vendors.d.ts +0 -1321
- package/dist/schemas/vendors.d.ts.map +1 -1
- package/dist/schemas/vendors.js +1 -205
- package/dist/services/sub-order.d.ts +1 -31
- package/dist/services/sub-order.d.ts.map +1 -1
- package/dist/services/sub-order.js +14 -22
- package/dist/types.d.ts +0 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -4
- package/package.json +13 -11
- package/src/index.ts +3 -11
- package/src/routes/b2b.ts +1 -76
- package/src/routes/sub-orders.ts +3 -3
- package/src/routes/vendor-portal.ts +6 -6
- package/src/schema.ts +0 -16
- package/src/schemas/b2b.ts +1 -208
- package/src/schemas/commission.ts +1 -86
- package/src/schemas/disputes-returns-reviews.ts +1 -225
- package/src/schemas/sub-orders.ts +1 -65
- package/src/schemas/vendor-portal.ts +1 -269
- package/src/schemas/vendors.ts +1 -222
- package/src/services/sub-order.ts +16 -18
- package/src/types.ts +0 -28
- package/dist/schemas/payouts.d.ts +0 -375
- package/dist/schemas/payouts.d.ts.map +0 -1
- package/dist/schemas/payouts.js +0 -78
- package/dist/services/contract-price.d.ts +0 -64
- package/dist/services/contract-price.d.ts.map +0 -1
- package/dist/services/contract-price.js +0 -57
- package/src/schemas/payouts.ts +0 -90
- package/src/services/contract-price.ts +0 -80
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { eq, and, desc } from "@porulle/core/drizzle";
|
|
2
|
+
import { CommerceInvalidTransitionError, CommerceNotFoundError } from "@porulle/core";
|
|
2
3
|
import { vendorSubOrders } from "../schema.js";
|
|
3
4
|
import type { Db, SubOrderStatus } from "../types.js";
|
|
4
5
|
import { SUB_ORDER_TRANSITIONS } from "../types.js";
|
|
@@ -19,12 +20,6 @@ export class SubOrderService {
|
|
|
19
20
|
return sub ?? null;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
async listByOrder(orderId: string) {
|
|
23
|
-
return this.db.select().from(vendorSubOrders)
|
|
24
|
-
.where(eq(vendorSubOrders.orderId, orderId))
|
|
25
|
-
.orderBy(desc(vendorSubOrders.createdAt));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
23
|
async listByVendor(vendorId: string, filters?: { status?: string }) {
|
|
29
24
|
const conditions = [eq(vendorSubOrders.vendorId, vendorId)];
|
|
30
25
|
if (filters?.status) conditions.push(eq(vendorSubOrders.status, filters.status));
|
|
@@ -49,13 +44,21 @@ export class SubOrderService {
|
|
|
49
44
|
private assertTransition(current: SubOrderStatus, next: SubOrderStatus) {
|
|
50
45
|
const allowed = SUB_ORDER_TRANSITIONS[current];
|
|
51
46
|
if (!allowed?.includes(next)) {
|
|
52
|
-
throw new
|
|
47
|
+
throw new CommerceInvalidTransitionError(
|
|
48
|
+
`Cannot transition sub-order from "${current}" to "${next}".`,
|
|
49
|
+
);
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
|
|
53
|
+
private requireSubOrder(id: string) {
|
|
54
|
+
return this.getById(id).then((sub) => {
|
|
55
|
+
if (!sub) throw new CommerceNotFoundError("Sub-order not found.");
|
|
56
|
+
return sub;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
56
60
|
async confirm(id: string) {
|
|
57
|
-
const sub = await this.
|
|
58
|
-
if (!sub) throw new Error("Sub-order not found.");
|
|
61
|
+
const sub = await this.requireSubOrder(id);
|
|
59
62
|
this.assertTransition(sub.status as SubOrderStatus, "confirmed");
|
|
60
63
|
|
|
61
64
|
const [updated] = await this.db.update(vendorSubOrders).set({
|
|
@@ -67,8 +70,7 @@ export class SubOrderService {
|
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
async process(id: string) {
|
|
70
|
-
const sub = await this.
|
|
71
|
-
if (!sub) throw new Error("Sub-order not found.");
|
|
73
|
+
const sub = await this.requireSubOrder(id);
|
|
72
74
|
this.assertTransition(sub.status as SubOrderStatus, "processing");
|
|
73
75
|
|
|
74
76
|
const [updated] = await this.db.update(vendorSubOrders).set({
|
|
@@ -79,8 +81,7 @@ export class SubOrderService {
|
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
async ship(id: string, data: { trackingNumber: string; carrier: string }) {
|
|
82
|
-
const sub = await this.
|
|
83
|
-
if (!sub) throw new Error("Sub-order not found.");
|
|
84
|
+
const sub = await this.requireSubOrder(id);
|
|
84
85
|
this.assertTransition(sub.status as SubOrderStatus, "shipped");
|
|
85
86
|
|
|
86
87
|
const [updated] = await this.db.update(vendorSubOrders).set({
|
|
@@ -94,8 +95,7 @@ export class SubOrderService {
|
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
async deliver(id: string) {
|
|
97
|
-
const sub = await this.
|
|
98
|
-
if (!sub) throw new Error("Sub-order not found.");
|
|
98
|
+
const sub = await this.requireSubOrder(id);
|
|
99
99
|
this.assertTransition(sub.status as SubOrderStatus, "delivered");
|
|
100
100
|
|
|
101
101
|
const [updated] = await this.db.update(vendorSubOrders).set({
|
|
@@ -107,8 +107,7 @@ export class SubOrderService {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
async cancel(id: string, reason?: string) {
|
|
110
|
-
const sub = await this.
|
|
111
|
-
if (!sub) throw new Error("Sub-order not found.");
|
|
110
|
+
const sub = await this.requireSubOrder(id);
|
|
112
111
|
this.assertTransition(sub.status as SubOrderStatus, "cancelled");
|
|
113
112
|
|
|
114
113
|
const [updated] = await this.db.update(vendorSubOrders).set({
|
|
@@ -118,7 +117,6 @@ export class SubOrderService {
|
|
|
118
117
|
updatedAt: new Date(),
|
|
119
118
|
}).where(eq(vendorSubOrders.id, id)).returning();
|
|
120
119
|
|
|
121
|
-
// Trigger side effects: release inventory + reverse ledger
|
|
122
120
|
if (this.onCancel && sub) {
|
|
123
121
|
await this.onCancel(sub);
|
|
124
122
|
}
|
package/src/types.ts
CHANGED
|
@@ -99,34 +99,12 @@ export type RFQResponseStatus = "submitted" | "shortlisted" | "accepted" | "reje
|
|
|
99
99
|
|
|
100
100
|
export interface MarketplacePluginOptions {
|
|
101
101
|
defaultCommissionRateBps?: number;
|
|
102
|
-
|
|
103
|
-
vendorApprovalMode?: VendorApprovalMode;
|
|
104
|
-
requiredDocuments?: DocumentType[];
|
|
105
|
-
|
|
106
|
-
defaultPayoutSchedule?: PayoutSchedule;
|
|
107
102
|
defaultPayoutMinimumCents?: number;
|
|
108
|
-
defaultHoldbackDays?: number;
|
|
109
|
-
|
|
110
103
|
vendorResponseDeadlineDays?: number;
|
|
111
|
-
autoEscalateOnMissedDeadline?: boolean;
|
|
112
|
-
|
|
113
|
-
returnWindowDays?: number;
|
|
114
|
-
autoApproveReturnsOnVendorTimeout?: boolean;
|
|
115
|
-
vendorReturnResponseDays?: number;
|
|
116
|
-
|
|
117
|
-
requireVerifiedPurchase?: boolean;
|
|
118
104
|
reviewModerationEnabled?: boolean;
|
|
119
105
|
|
|
120
106
|
b2b?: {
|
|
121
107
|
rfq?: boolean;
|
|
122
|
-
contractPricing?: boolean;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
performanceThresholds?: {
|
|
126
|
-
minRating?: number;
|
|
127
|
-
maxDefectRatePercent?: number;
|
|
128
|
-
maxLateShipmentRatePercent?: number;
|
|
129
|
-
maxCancellationRatePercent?: number;
|
|
130
108
|
};
|
|
131
109
|
}
|
|
132
110
|
|
|
@@ -156,9 +134,3 @@ export interface RouteContext {
|
|
|
156
134
|
json(data: unknown, status?: number): Response;
|
|
157
135
|
get(key: string): unknown;
|
|
158
136
|
}
|
|
159
|
-
|
|
160
|
-
// ─── Error helper ────────────────────────────────────────────────────────────
|
|
161
|
-
|
|
162
|
-
export function errorMessage(err: unknown): string {
|
|
163
|
-
return err instanceof Error ? err.message : "Internal server error";
|
|
164
|
-
}
|
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
import { z } from "@hono/zod-openapi";
|
|
2
|
-
export declare const RunPayoutCycleBodySchema: z.ZodObject<{
|
|
3
|
-
vendorIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
|
|
4
|
-
force: z.ZodOptional<z.ZodBoolean>;
|
|
5
|
-
}, z.core.$strip>;
|
|
6
|
-
export declare const runPayoutCycleRoute: {
|
|
7
|
-
method: "post";
|
|
8
|
-
path: "/api/marketplace/payouts/run";
|
|
9
|
-
tags: string[];
|
|
10
|
-
summary: string;
|
|
11
|
-
request: {
|
|
12
|
-
body: {
|
|
13
|
-
content: {
|
|
14
|
-
"application/json": {
|
|
15
|
-
schema: z.ZodObject<{
|
|
16
|
-
vendorIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
|
|
17
|
-
force: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
-
}, z.core.$strip>;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
required: true;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
responses: {
|
|
25
|
-
401: {
|
|
26
|
-
readonly content: {
|
|
27
|
-
readonly "application/json": {
|
|
28
|
-
readonly schema: z.ZodObject<{
|
|
29
|
-
error: z.ZodObject<{
|
|
30
|
-
code: z.ZodString;
|
|
31
|
-
message: z.ZodString;
|
|
32
|
-
}, z.core.$strip>;
|
|
33
|
-
}, z.core.$strip>;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
readonly description: "Authentication required.";
|
|
37
|
-
};
|
|
38
|
-
403: {
|
|
39
|
-
readonly content: {
|
|
40
|
-
readonly "application/json": {
|
|
41
|
-
readonly schema: z.ZodObject<{
|
|
42
|
-
error: z.ZodObject<{
|
|
43
|
-
code: z.ZodString;
|
|
44
|
-
message: z.ZodString;
|
|
45
|
-
}, z.core.$strip>;
|
|
46
|
-
}, z.core.$strip>;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
readonly description: "Insufficient permissions.";
|
|
50
|
-
};
|
|
51
|
-
404: {
|
|
52
|
-
readonly content: {
|
|
53
|
-
readonly "application/json": {
|
|
54
|
-
readonly schema: z.ZodObject<{
|
|
55
|
-
error: z.ZodObject<{
|
|
56
|
-
code: z.ZodString;
|
|
57
|
-
message: z.ZodString;
|
|
58
|
-
}, z.core.$strip>;
|
|
59
|
-
}, z.core.$strip>;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
readonly description: "Not found.";
|
|
63
|
-
};
|
|
64
|
-
422: {
|
|
65
|
-
readonly content: {
|
|
66
|
-
readonly "application/json": {
|
|
67
|
-
readonly schema: z.ZodObject<{
|
|
68
|
-
error: z.ZodObject<{
|
|
69
|
-
code: z.ZodString;
|
|
70
|
-
message: z.ZodString;
|
|
71
|
-
}, z.core.$strip>;
|
|
72
|
-
}, z.core.$strip>;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
readonly description: "Validation error.";
|
|
76
|
-
};
|
|
77
|
-
500: {
|
|
78
|
-
readonly content: {
|
|
79
|
-
readonly "application/json": {
|
|
80
|
-
readonly schema: z.ZodObject<{
|
|
81
|
-
error: z.ZodObject<{
|
|
82
|
-
code: z.ZodString;
|
|
83
|
-
message: z.ZodString;
|
|
84
|
-
}, z.core.$strip>;
|
|
85
|
-
}, z.core.$strip>;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
readonly description: "Server error.";
|
|
89
|
-
};
|
|
90
|
-
200: {
|
|
91
|
-
content: {
|
|
92
|
-
"application/json": {
|
|
93
|
-
schema: z.ZodObject<{
|
|
94
|
-
data: z.ZodAny;
|
|
95
|
-
}, z.core.$strip>;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
description: string;
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
} & {
|
|
102
|
-
getRoutingPath(): "/api/marketplace/payouts/run";
|
|
103
|
-
};
|
|
104
|
-
export declare const listPayoutsRoute: {
|
|
105
|
-
method: "get";
|
|
106
|
-
path: "/api/marketplace/payouts";
|
|
107
|
-
tags: string[];
|
|
108
|
-
summary: string;
|
|
109
|
-
request: {
|
|
110
|
-
query: z.ZodObject<{
|
|
111
|
-
vendorId: z.ZodOptional<z.ZodString>;
|
|
112
|
-
status: z.ZodOptional<z.ZodString>;
|
|
113
|
-
}, z.core.$strip>;
|
|
114
|
-
};
|
|
115
|
-
responses: {
|
|
116
|
-
401: {
|
|
117
|
-
readonly content: {
|
|
118
|
-
readonly "application/json": {
|
|
119
|
-
readonly schema: z.ZodObject<{
|
|
120
|
-
error: z.ZodObject<{
|
|
121
|
-
code: z.ZodString;
|
|
122
|
-
message: z.ZodString;
|
|
123
|
-
}, z.core.$strip>;
|
|
124
|
-
}, z.core.$strip>;
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
readonly description: "Authentication required.";
|
|
128
|
-
};
|
|
129
|
-
403: {
|
|
130
|
-
readonly content: {
|
|
131
|
-
readonly "application/json": {
|
|
132
|
-
readonly schema: z.ZodObject<{
|
|
133
|
-
error: z.ZodObject<{
|
|
134
|
-
code: z.ZodString;
|
|
135
|
-
message: z.ZodString;
|
|
136
|
-
}, z.core.$strip>;
|
|
137
|
-
}, z.core.$strip>;
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
readonly description: "Insufficient permissions.";
|
|
141
|
-
};
|
|
142
|
-
404: {
|
|
143
|
-
readonly content: {
|
|
144
|
-
readonly "application/json": {
|
|
145
|
-
readonly schema: z.ZodObject<{
|
|
146
|
-
error: z.ZodObject<{
|
|
147
|
-
code: z.ZodString;
|
|
148
|
-
message: z.ZodString;
|
|
149
|
-
}, z.core.$strip>;
|
|
150
|
-
}, z.core.$strip>;
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
readonly description: "Not found.";
|
|
154
|
-
};
|
|
155
|
-
422: {
|
|
156
|
-
readonly content: {
|
|
157
|
-
readonly "application/json": {
|
|
158
|
-
readonly schema: z.ZodObject<{
|
|
159
|
-
error: z.ZodObject<{
|
|
160
|
-
code: z.ZodString;
|
|
161
|
-
message: z.ZodString;
|
|
162
|
-
}, z.core.$strip>;
|
|
163
|
-
}, z.core.$strip>;
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
readonly description: "Validation error.";
|
|
167
|
-
};
|
|
168
|
-
500: {
|
|
169
|
-
readonly content: {
|
|
170
|
-
readonly "application/json": {
|
|
171
|
-
readonly schema: z.ZodObject<{
|
|
172
|
-
error: z.ZodObject<{
|
|
173
|
-
code: z.ZodString;
|
|
174
|
-
message: z.ZodString;
|
|
175
|
-
}, z.core.$strip>;
|
|
176
|
-
}, z.core.$strip>;
|
|
177
|
-
};
|
|
178
|
-
};
|
|
179
|
-
readonly description: "Server error.";
|
|
180
|
-
};
|
|
181
|
-
200: {
|
|
182
|
-
content: {
|
|
183
|
-
"application/json": {
|
|
184
|
-
schema: z.ZodObject<{
|
|
185
|
-
data: z.ZodAny;
|
|
186
|
-
}, z.core.$strip>;
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
description: string;
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
} & {
|
|
193
|
-
getRoutingPath(): "/api/marketplace/payouts";
|
|
194
|
-
};
|
|
195
|
-
export declare const retryPayoutRoute: {
|
|
196
|
-
method: "post";
|
|
197
|
-
path: "/api/marketplace/payouts/{id}/retry";
|
|
198
|
-
tags: string[];
|
|
199
|
-
summary: string;
|
|
200
|
-
request: {
|
|
201
|
-
params: z.ZodObject<{
|
|
202
|
-
id: z.ZodUUID;
|
|
203
|
-
}, z.core.$strip>;
|
|
204
|
-
};
|
|
205
|
-
responses: {
|
|
206
|
-
401: {
|
|
207
|
-
readonly content: {
|
|
208
|
-
readonly "application/json": {
|
|
209
|
-
readonly schema: z.ZodObject<{
|
|
210
|
-
error: z.ZodObject<{
|
|
211
|
-
code: z.ZodString;
|
|
212
|
-
message: z.ZodString;
|
|
213
|
-
}, z.core.$strip>;
|
|
214
|
-
}, z.core.$strip>;
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
readonly description: "Authentication required.";
|
|
218
|
-
};
|
|
219
|
-
403: {
|
|
220
|
-
readonly content: {
|
|
221
|
-
readonly "application/json": {
|
|
222
|
-
readonly schema: z.ZodObject<{
|
|
223
|
-
error: z.ZodObject<{
|
|
224
|
-
code: z.ZodString;
|
|
225
|
-
message: z.ZodString;
|
|
226
|
-
}, z.core.$strip>;
|
|
227
|
-
}, z.core.$strip>;
|
|
228
|
-
};
|
|
229
|
-
};
|
|
230
|
-
readonly description: "Insufficient permissions.";
|
|
231
|
-
};
|
|
232
|
-
404: {
|
|
233
|
-
readonly content: {
|
|
234
|
-
readonly "application/json": {
|
|
235
|
-
readonly schema: z.ZodObject<{
|
|
236
|
-
error: z.ZodObject<{
|
|
237
|
-
code: z.ZodString;
|
|
238
|
-
message: z.ZodString;
|
|
239
|
-
}, z.core.$strip>;
|
|
240
|
-
}, z.core.$strip>;
|
|
241
|
-
};
|
|
242
|
-
};
|
|
243
|
-
readonly description: "Not found.";
|
|
244
|
-
};
|
|
245
|
-
422: {
|
|
246
|
-
readonly content: {
|
|
247
|
-
readonly "application/json": {
|
|
248
|
-
readonly schema: z.ZodObject<{
|
|
249
|
-
error: z.ZodObject<{
|
|
250
|
-
code: z.ZodString;
|
|
251
|
-
message: z.ZodString;
|
|
252
|
-
}, z.core.$strip>;
|
|
253
|
-
}, z.core.$strip>;
|
|
254
|
-
};
|
|
255
|
-
};
|
|
256
|
-
readonly description: "Validation error.";
|
|
257
|
-
};
|
|
258
|
-
500: {
|
|
259
|
-
readonly content: {
|
|
260
|
-
readonly "application/json": {
|
|
261
|
-
readonly schema: z.ZodObject<{
|
|
262
|
-
error: z.ZodObject<{
|
|
263
|
-
code: z.ZodString;
|
|
264
|
-
message: z.ZodString;
|
|
265
|
-
}, z.core.$strip>;
|
|
266
|
-
}, z.core.$strip>;
|
|
267
|
-
};
|
|
268
|
-
};
|
|
269
|
-
readonly description: "Server error.";
|
|
270
|
-
};
|
|
271
|
-
200: {
|
|
272
|
-
content: {
|
|
273
|
-
"application/json": {
|
|
274
|
-
schema: z.ZodObject<{
|
|
275
|
-
data: z.ZodAny;
|
|
276
|
-
}, z.core.$strip>;
|
|
277
|
-
};
|
|
278
|
-
};
|
|
279
|
-
description: string;
|
|
280
|
-
};
|
|
281
|
-
};
|
|
282
|
-
} & {
|
|
283
|
-
getRoutingPath(): "/api/marketplace/payouts/:id/retry";
|
|
284
|
-
};
|
|
285
|
-
export declare const getPayoutRoute: {
|
|
286
|
-
method: "get";
|
|
287
|
-
path: "/api/marketplace/payouts/{id}";
|
|
288
|
-
tags: string[];
|
|
289
|
-
summary: string;
|
|
290
|
-
request: {
|
|
291
|
-
params: z.ZodObject<{
|
|
292
|
-
id: z.ZodUUID;
|
|
293
|
-
}, z.core.$strip>;
|
|
294
|
-
};
|
|
295
|
-
responses: {
|
|
296
|
-
401: {
|
|
297
|
-
readonly content: {
|
|
298
|
-
readonly "application/json": {
|
|
299
|
-
readonly schema: z.ZodObject<{
|
|
300
|
-
error: z.ZodObject<{
|
|
301
|
-
code: z.ZodString;
|
|
302
|
-
message: z.ZodString;
|
|
303
|
-
}, z.core.$strip>;
|
|
304
|
-
}, z.core.$strip>;
|
|
305
|
-
};
|
|
306
|
-
};
|
|
307
|
-
readonly description: "Authentication required.";
|
|
308
|
-
};
|
|
309
|
-
403: {
|
|
310
|
-
readonly content: {
|
|
311
|
-
readonly "application/json": {
|
|
312
|
-
readonly schema: z.ZodObject<{
|
|
313
|
-
error: z.ZodObject<{
|
|
314
|
-
code: z.ZodString;
|
|
315
|
-
message: z.ZodString;
|
|
316
|
-
}, z.core.$strip>;
|
|
317
|
-
}, z.core.$strip>;
|
|
318
|
-
};
|
|
319
|
-
};
|
|
320
|
-
readonly description: "Insufficient permissions.";
|
|
321
|
-
};
|
|
322
|
-
404: {
|
|
323
|
-
readonly content: {
|
|
324
|
-
readonly "application/json": {
|
|
325
|
-
readonly schema: z.ZodObject<{
|
|
326
|
-
error: z.ZodObject<{
|
|
327
|
-
code: z.ZodString;
|
|
328
|
-
message: z.ZodString;
|
|
329
|
-
}, z.core.$strip>;
|
|
330
|
-
}, z.core.$strip>;
|
|
331
|
-
};
|
|
332
|
-
};
|
|
333
|
-
readonly description: "Not found.";
|
|
334
|
-
};
|
|
335
|
-
422: {
|
|
336
|
-
readonly content: {
|
|
337
|
-
readonly "application/json": {
|
|
338
|
-
readonly schema: z.ZodObject<{
|
|
339
|
-
error: z.ZodObject<{
|
|
340
|
-
code: z.ZodString;
|
|
341
|
-
message: z.ZodString;
|
|
342
|
-
}, z.core.$strip>;
|
|
343
|
-
}, z.core.$strip>;
|
|
344
|
-
};
|
|
345
|
-
};
|
|
346
|
-
readonly description: "Validation error.";
|
|
347
|
-
};
|
|
348
|
-
500: {
|
|
349
|
-
readonly content: {
|
|
350
|
-
readonly "application/json": {
|
|
351
|
-
readonly schema: z.ZodObject<{
|
|
352
|
-
error: z.ZodObject<{
|
|
353
|
-
code: z.ZodString;
|
|
354
|
-
message: z.ZodString;
|
|
355
|
-
}, z.core.$strip>;
|
|
356
|
-
}, z.core.$strip>;
|
|
357
|
-
};
|
|
358
|
-
};
|
|
359
|
-
readonly description: "Server error.";
|
|
360
|
-
};
|
|
361
|
-
200: {
|
|
362
|
-
content: {
|
|
363
|
-
"application/json": {
|
|
364
|
-
schema: z.ZodObject<{
|
|
365
|
-
data: z.ZodAny;
|
|
366
|
-
}, z.core.$strip>;
|
|
367
|
-
};
|
|
368
|
-
};
|
|
369
|
-
description: string;
|
|
370
|
-
};
|
|
371
|
-
};
|
|
372
|
-
} & {
|
|
373
|
-
getRoutingPath(): "/api/marketplace/payouts/:id";
|
|
374
|
-
};
|
|
375
|
-
//# sourceMappingURL=payouts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payouts.d.ts","sourceRoot":"","sources":["../../src/schemas/payouts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAe,MAAM,mBAAmB,CAAC;AAqBnD,eAAO,MAAM,wBAAwB;;;iBAGF,CAAC;AAEpC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAY9B,CAAC;AAIH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAe3B,CAAC;AAIH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAY3B,CAAC;AAIH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYzB,CAAC"}
|
package/dist/schemas/payouts.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { z, createRoute } from "@hono/zod-openapi";
|
|
2
|
-
const ErrorSchema = z.object({
|
|
3
|
-
error: z.object({
|
|
4
|
-
code: z.string(),
|
|
5
|
-
message: z.string(),
|
|
6
|
-
}),
|
|
7
|
-
});
|
|
8
|
-
const errorResponses = {
|
|
9
|
-
401: { content: { "application/json": { schema: ErrorSchema } }, description: "Authentication required." },
|
|
10
|
-
403: { content: { "application/json": { schema: ErrorSchema } }, description: "Insufficient permissions." },
|
|
11
|
-
404: { content: { "application/json": { schema: ErrorSchema } }, description: "Not found." },
|
|
12
|
-
422: { content: { "application/json": { schema: ErrorSchema } }, description: "Validation error." },
|
|
13
|
-
500: { content: { "application/json": { schema: ErrorSchema } }, description: "Server error." },
|
|
14
|
-
};
|
|
15
|
-
const PayoutResponseSchema = z.object({ data: z.any() });
|
|
16
|
-
// ─── Run Payout Cycle ────────────────────────────────────────────────────────
|
|
17
|
-
export const RunPayoutCycleBodySchema = z.object({
|
|
18
|
-
vendorIds: z.array(z.uuid()).optional().openapi({ description: "Limit payout run to specific vendors" }),
|
|
19
|
-
force: z.boolean().optional().openapi({ description: "Force payout even if below minimum threshold" }),
|
|
20
|
-
}).openapi("RunPayoutCycleRequest");
|
|
21
|
-
export const runPayoutCycleRoute = createRoute({
|
|
22
|
-
method: "post",
|
|
23
|
-
path: "/api/marketplace/payouts/run",
|
|
24
|
-
tags: ["Marketplace - Payouts"],
|
|
25
|
-
summary: "Run a payout cycle",
|
|
26
|
-
request: {
|
|
27
|
-
body: { content: { "application/json": { schema: RunPayoutCycleBodySchema } }, required: true },
|
|
28
|
-
},
|
|
29
|
-
responses: {
|
|
30
|
-
200: { content: { "application/json": { schema: PayoutResponseSchema } }, description: "Payout cycle completed." },
|
|
31
|
-
...errorResponses,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
// ─── List Payouts ───────────────────────────────────────────────────────────
|
|
35
|
-
export const listPayoutsRoute = createRoute({
|
|
36
|
-
method: "get",
|
|
37
|
-
path: "/api/marketplace/payouts",
|
|
38
|
-
tags: ["Marketplace - Payouts"],
|
|
39
|
-
summary: "List payouts",
|
|
40
|
-
request: {
|
|
41
|
-
query: z.object({
|
|
42
|
-
vendorId: z.string().optional(),
|
|
43
|
-
status: z.string().optional(),
|
|
44
|
-
}),
|
|
45
|
-
},
|
|
46
|
-
responses: {
|
|
47
|
-
200: { content: { "application/json": { schema: PayoutResponseSchema } }, description: "Success" },
|
|
48
|
-
...errorResponses,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
// ─── Retry Payout ───────────────────────────────────────────────────────────
|
|
52
|
-
export const retryPayoutRoute = createRoute({
|
|
53
|
-
method: "post",
|
|
54
|
-
path: "/api/marketplace/payouts/{id}/retry",
|
|
55
|
-
tags: ["Marketplace - Payouts"],
|
|
56
|
-
summary: "Retry a failed payout",
|
|
57
|
-
request: {
|
|
58
|
-
params: z.object({ id: z.uuid() }),
|
|
59
|
-
},
|
|
60
|
-
responses: {
|
|
61
|
-
200: { content: { "application/json": { schema: PayoutResponseSchema } }, description: "Payout retried." },
|
|
62
|
-
...errorResponses,
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
// ─── Get Payout ─────────────────────────────────────────────────────────────
|
|
66
|
-
export const getPayoutRoute = createRoute({
|
|
67
|
-
method: "get",
|
|
68
|
-
path: "/api/marketplace/payouts/{id}",
|
|
69
|
-
tags: ["Marketplace - Payouts"],
|
|
70
|
-
summary: "Get payout by ID",
|
|
71
|
-
request: {
|
|
72
|
-
params: z.object({ id: z.uuid() }),
|
|
73
|
-
},
|
|
74
|
-
responses: {
|
|
75
|
-
200: { content: { "application/json": { schema: PayoutResponseSchema } }, description: "Success" },
|
|
76
|
-
...errorResponses,
|
|
77
|
-
},
|
|
78
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { Db } from "../types.js";
|
|
2
|
-
export declare class ContractPriceService {
|
|
3
|
-
private db;
|
|
4
|
-
constructor(db: Db);
|
|
5
|
-
create(data: {
|
|
6
|
-
vendorId: string;
|
|
7
|
-
buyerId: string;
|
|
8
|
-
entityId: string;
|
|
9
|
-
variantId?: string;
|
|
10
|
-
priceCents: number;
|
|
11
|
-
minQuantity?: number;
|
|
12
|
-
currency?: string;
|
|
13
|
-
validFrom?: Date | undefined;
|
|
14
|
-
validUntil?: Date | undefined;
|
|
15
|
-
}): Promise<{
|
|
16
|
-
id: string;
|
|
17
|
-
createdAt: Date;
|
|
18
|
-
vendorId: string;
|
|
19
|
-
entityId: string;
|
|
20
|
-
variantId: string | null;
|
|
21
|
-
currency: string;
|
|
22
|
-
minQuantity: number;
|
|
23
|
-
validFrom: Date | null;
|
|
24
|
-
validUntil: Date | null;
|
|
25
|
-
buyerId: string;
|
|
26
|
-
priceCents: number;
|
|
27
|
-
} | undefined>;
|
|
28
|
-
update(id: string, data: Record<string, unknown>): Promise<{
|
|
29
|
-
id: string;
|
|
30
|
-
vendorId: string;
|
|
31
|
-
buyerId: string;
|
|
32
|
-
entityId: string;
|
|
33
|
-
variantId: string | null;
|
|
34
|
-
priceCents: number;
|
|
35
|
-
minQuantity: number;
|
|
36
|
-
currency: string;
|
|
37
|
-
validFrom: Date | null;
|
|
38
|
-
validUntil: Date | null;
|
|
39
|
-
createdAt: Date;
|
|
40
|
-
} | null>;
|
|
41
|
-
delete(id: string): Promise<void>;
|
|
42
|
-
list(filters?: {
|
|
43
|
-
vendorId?: string;
|
|
44
|
-
buyerId?: string;
|
|
45
|
-
}): Promise<{
|
|
46
|
-
id: string;
|
|
47
|
-
vendorId: string;
|
|
48
|
-
buyerId: string;
|
|
49
|
-
entityId: string;
|
|
50
|
-
variantId: string | null;
|
|
51
|
-
priceCents: number;
|
|
52
|
-
minQuantity: number;
|
|
53
|
-
currency: string;
|
|
54
|
-
validFrom: Date | null;
|
|
55
|
-
validUntil: Date | null;
|
|
56
|
-
createdAt: Date;
|
|
57
|
-
}[]>;
|
|
58
|
-
/**
|
|
59
|
-
* Resolve the best contract price for a buyer+vendor+entity+quantity.
|
|
60
|
-
* Returns null if no matching contract exists.
|
|
61
|
-
*/
|
|
62
|
-
resolvePrice(vendorId: string, buyerId: string, entityId: string, variantId: string | null, quantity: number): Promise<number | null>;
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=contract-price.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract-price.d.ts","sourceRoot":"","sources":["../../src/services/contract-price.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,qBAAa,oBAAoB;IACnB,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,EAAE;IAEpB,MAAM,CAAC,IAAI,EAAE;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;QAC7B,UAAU,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;KAC/B;;;;;;;;;;;;;IAKK,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;;IAMhD,MAAM,CAAC,EAAE,EAAE,MAAM;IAIjB,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;IAW5D;;;OAGG;IACG,YAAY,CAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CA0B1B"}
|