@hartl-services/medusa-contracts 1.5.0 → 1.7.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/README.md +14 -0
- package/dist/email/schemas.d.ts +7 -0
- package/dist/email/schemas.js +1 -0
- package/dist/esm/email/schemas.mjs +1 -0
- package/dist/esm/order-assistant/paths.mjs +33 -0
- package/dist/esm/order-assistant/schemas.mjs +385 -0
- package/dist/esm/order-assistant/types.mjs +1 -0
- package/dist/order-assistant/paths.d.ts +33 -0
- package/dist/order-assistant/paths.js +36 -0
- package/dist/order-assistant/schemas.d.ts +391 -0
- package/dist/order-assistant/schemas.js +389 -0
- package/dist/order-assistant/types.d.ts +31 -0
- package/dist/order-assistant/types.js +2 -0
- package/dist/plugin-features/schemas.d.ts +36 -36
- package/package.json +16 -1
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeleteOrderAssistantConnectionResponseSchema = exports.AdminOrderAssistantConnectionsResponseSchema = exports.AdminOrderAssistantConnectionSchema = exports.DecideOrderAssistantAuthorizationResponseSchema = exports.DecideOrderAssistantAuthorizationSchema = exports.AdminOrderAssistantAuthorizationResponseSchema = exports.AdminOrderAssistantAuthorizationSchema = exports.OAuthAuthorizationServerMetadataSchema = exports.OAuthProtectedResourceMetadataSchema = exports.OAuthErrorResponseSchema = exports.OAuthErrorCodeSchema = exports.OAuthTokenResponseSchema = exports.OAuthTokenRequestSchema = exports.OAuthAuthorizeQuerySchema = exports.OAuthClientRegistrationResponseSchema = exports.OAuthClientRegistrationRequestSchema = exports.OAuthRedirectUriSchema = exports.isOAuthLoopbackRedirectUri = exports.ORDER_ASSISTANT_OAUTH = exports.ORDER_ASSISTANT_FEATURES = exports.CreateDraftOrderOutputSchema = exports.OrderAssistantDraftItemSchema = exports.CreateDraftOrderInputSchema = exports.OrderAssistantNewCustomerSchema = exports.ListShippingOptionsOutputSchema = exports.OrderAssistantShippingOptionSchema = exports.ListShippingOptionsInputSchema = exports.SearchProductsOutputSchema = exports.OrderAssistantVariantSchema = exports.SearchProductsInputSchema = exports.SearchCustomersOutputSchema = exports.OrderAssistantCustomerSchema = exports.OrderAssistantCustomerAddressSchema = exports.SearchCustomersInputSchema = exports.OrderAssistantAddressSchema = exports.ORDER_ASSISTANT_LIMITS = exports.ORDER_ASSISTANT_METADATA = exports.OrderAssistantSourceSchema = exports.ORDER_ASSISTANT_TOOLS = exports.ORDER_ASSISTANT_PLUGIN_KEY = void 0;
|
|
4
|
+
const zod_1 = require("@medusajs/framework/zod");
|
|
5
|
+
const primitives_1 = require("../shared/primitives");
|
|
6
|
+
/** Plugin key and container key of the order assistant in the base. */
|
|
7
|
+
exports.ORDER_ASSISTANT_PLUGIN_KEY = "order_assistant";
|
|
8
|
+
/** Tool names as the MCP client sees them. */
|
|
9
|
+
exports.ORDER_ASSISTANT_TOOLS = {
|
|
10
|
+
searchCustomers: "kunden_suchen",
|
|
11
|
+
searchProducts: "produkte_suchen",
|
|
12
|
+
listShippingOptions: "versandarten_auflisten",
|
|
13
|
+
createDraftOrder: "bestellentwurf_anlegen",
|
|
14
|
+
};
|
|
15
|
+
/** How the order reached the shop; stored in the order metadata. */
|
|
16
|
+
exports.OrderAssistantSourceSchema = zod_1.z.enum(["fax", "telefon"]);
|
|
17
|
+
/** Order metadata keys the assistant writes. */
|
|
18
|
+
exports.ORDER_ASSISTANT_METADATA = {
|
|
19
|
+
source: "order_source",
|
|
20
|
+
note: "order_note",
|
|
21
|
+
};
|
|
22
|
+
exports.ORDER_ASSISTANT_LIMITS = {
|
|
23
|
+
customers: 10,
|
|
24
|
+
variants: 20,
|
|
25
|
+
items: 50,
|
|
26
|
+
noteLength: 2000,
|
|
27
|
+
};
|
|
28
|
+
const CountryCodeSchema = zod_1.z
|
|
29
|
+
.string()
|
|
30
|
+
.trim()
|
|
31
|
+
.toLowerCase()
|
|
32
|
+
.regex(/^[a-z]{2}$/)
|
|
33
|
+
.describe("Land als ISO-3166-1-alpha-2-Code, z. B. at oder de.");
|
|
34
|
+
const OptionalTextSchema = zod_1.z.string().trim().min(1).max(255).optional();
|
|
35
|
+
exports.OrderAssistantAddressSchema = zod_1.z
|
|
36
|
+
.object({
|
|
37
|
+
first_name: primitives_1.NonEmptyStringSchema.max(255),
|
|
38
|
+
last_name: primitives_1.NonEmptyStringSchema.max(255),
|
|
39
|
+
company: OptionalTextSchema.describe("Firma oder Praxis, falls angegeben."),
|
|
40
|
+
address_1: primitives_1.NonEmptyStringSchema.max(255).describe("Straße und Hausnummer."),
|
|
41
|
+
address_2: OptionalTextSchema.describe("Adresszusatz."),
|
|
42
|
+
postal_code: primitives_1.NonEmptyStringSchema.max(20),
|
|
43
|
+
city: primitives_1.NonEmptyStringSchema.max(255),
|
|
44
|
+
country_code: CountryCodeSchema,
|
|
45
|
+
phone: OptionalTextSchema,
|
|
46
|
+
})
|
|
47
|
+
.strict();
|
|
48
|
+
exports.SearchCustomersInputSchema = zod_1.z
|
|
49
|
+
.object({
|
|
50
|
+
query: OptionalTextSchema.describe("Name, Firma, Telefonnummer oder E-Mail-Adresse (auch Teile davon)."),
|
|
51
|
+
postal_code: OptionalTextSchema.describe("PLZ einer Adresse der Person."),
|
|
52
|
+
city: OptionalTextSchema.describe("Ort einer Adresse der Person."),
|
|
53
|
+
})
|
|
54
|
+
.strict()
|
|
55
|
+
.refine((value) => Boolean(value.query ?? value.postal_code ?? value.city), { message: "Mindestens ein Suchfeld ist nötig." });
|
|
56
|
+
exports.OrderAssistantCustomerAddressSchema = zod_1.z.object({
|
|
57
|
+
first_name: zod_1.z.string().nullable(),
|
|
58
|
+
last_name: zod_1.z.string().nullable(),
|
|
59
|
+
company: zod_1.z.string().nullable(),
|
|
60
|
+
address_1: zod_1.z.string().nullable(),
|
|
61
|
+
address_2: zod_1.z.string().nullable(),
|
|
62
|
+
postal_code: zod_1.z.string().nullable(),
|
|
63
|
+
city: zod_1.z.string().nullable(),
|
|
64
|
+
country_code: zod_1.z.string().nullable(),
|
|
65
|
+
phone: zod_1.z.string().nullable(),
|
|
66
|
+
});
|
|
67
|
+
exports.OrderAssistantCustomerSchema = zod_1.z.object({
|
|
68
|
+
id: zod_1.z.string(),
|
|
69
|
+
first_name: zod_1.z.string().nullable(),
|
|
70
|
+
last_name: zod_1.z.string().nullable(),
|
|
71
|
+
company_name: zod_1.z.string().nullable(),
|
|
72
|
+
email: zod_1.z.string().nullable(),
|
|
73
|
+
phone: zod_1.z.string().nullable(),
|
|
74
|
+
/** Registered shop account (true) or a customer record without login. */
|
|
75
|
+
has_account: zod_1.z.boolean(),
|
|
76
|
+
addresses: zod_1.z.array(exports.OrderAssistantCustomerAddressSchema),
|
|
77
|
+
});
|
|
78
|
+
exports.SearchCustomersOutputSchema = zod_1.z.object({
|
|
79
|
+
customers: zod_1.z.array(exports.OrderAssistantCustomerSchema),
|
|
80
|
+
});
|
|
81
|
+
exports.SearchProductsInputSchema = zod_1.z
|
|
82
|
+
.object({
|
|
83
|
+
query: primitives_1.NonEmptyStringSchema.max(255).describe("Produktname oder Artikelnummer (auch Teile davon)."),
|
|
84
|
+
country_code: CountryCodeSchema.describe("Lieferland als ISO-Code; bestimmt Preis und Währung."),
|
|
85
|
+
})
|
|
86
|
+
.strict();
|
|
87
|
+
exports.OrderAssistantVariantSchema = zod_1.z.object({
|
|
88
|
+
variant_id: zod_1.z.string(),
|
|
89
|
+
product_title: zod_1.z.string(),
|
|
90
|
+
variant_title: zod_1.z.string().nullable(),
|
|
91
|
+
sku: zod_1.z.string().nullable(),
|
|
92
|
+
/** Price per unit in major currency units (33.5 = 33,50); null without a price. */
|
|
93
|
+
unit_price: zod_1.z.number().nullable(),
|
|
94
|
+
currency_code: zod_1.z.string(),
|
|
95
|
+
/** Available quantity; null when the variant's stock is not managed. */
|
|
96
|
+
available_quantity: zod_1.z.number().nullable(),
|
|
97
|
+
/** False when the variant cannot be ordered (no price or no stock). */
|
|
98
|
+
orderable: zod_1.z.boolean(),
|
|
99
|
+
});
|
|
100
|
+
exports.SearchProductsOutputSchema = zod_1.z.object({
|
|
101
|
+
variants: zod_1.z.array(exports.OrderAssistantVariantSchema),
|
|
102
|
+
});
|
|
103
|
+
exports.ListShippingOptionsInputSchema = zod_1.z
|
|
104
|
+
.object({
|
|
105
|
+
country_code: CountryCodeSchema.describe("Lieferland als ISO-Code."),
|
|
106
|
+
})
|
|
107
|
+
.strict();
|
|
108
|
+
exports.OrderAssistantShippingOptionSchema = zod_1.z.object({
|
|
109
|
+
id: zod_1.z.string(),
|
|
110
|
+
name: zod_1.z.string(),
|
|
111
|
+
/** Flat price in major currency units; null when none is set for the currency. */
|
|
112
|
+
amount: zod_1.z.number().nullable(),
|
|
113
|
+
currency_code: zod_1.z.string(),
|
|
114
|
+
});
|
|
115
|
+
exports.ListShippingOptionsOutputSchema = zod_1.z.object({
|
|
116
|
+
shipping_options: zod_1.z.array(exports.OrderAssistantShippingOptionSchema),
|
|
117
|
+
});
|
|
118
|
+
exports.OrderAssistantNewCustomerSchema = zod_1.z
|
|
119
|
+
.object({
|
|
120
|
+
first_name: primitives_1.NonEmptyStringSchema.max(255),
|
|
121
|
+
last_name: primitives_1.NonEmptyStringSchema.max(255),
|
|
122
|
+
company_name: OptionalTextSchema,
|
|
123
|
+
email: zod_1.z
|
|
124
|
+
.string()
|
|
125
|
+
.trim()
|
|
126
|
+
.toLowerCase()
|
|
127
|
+
.email()
|
|
128
|
+
.max(255)
|
|
129
|
+
.optional()
|
|
130
|
+
.describe("Nur angeben, wenn eine E-Mail-Adresse bekannt ist."),
|
|
131
|
+
phone: OptionalTextSchema,
|
|
132
|
+
})
|
|
133
|
+
.strict();
|
|
134
|
+
exports.CreateDraftOrderInputSchema = zod_1.z
|
|
135
|
+
.object({
|
|
136
|
+
customer_id: zod_1.z
|
|
137
|
+
.string()
|
|
138
|
+
.trim()
|
|
139
|
+
.min(1)
|
|
140
|
+
.optional()
|
|
141
|
+
.describe("ID einer bestehenden Kund:in aus kunden_suchen."),
|
|
142
|
+
new_customer: exports.OrderAssistantNewCustomerSchema.optional().describe("Neue Kund:in ohne Konto; nur wenn kunden_suchen niemanden findet."),
|
|
143
|
+
shipping_address: exports.OrderAssistantAddressSchema,
|
|
144
|
+
billing_address: exports.OrderAssistantAddressSchema.optional().describe("Rechnungsadresse; ohne Angabe gilt die Lieferadresse."),
|
|
145
|
+
items: zod_1.z
|
|
146
|
+
.array(zod_1.z
|
|
147
|
+
.object({
|
|
148
|
+
variant_id: primitives_1.NonEmptyStringSchema.describe("ID der Variante aus produkte_suchen."),
|
|
149
|
+
quantity: zod_1.z.number().int().positive().max(9999),
|
|
150
|
+
})
|
|
151
|
+
.strict())
|
|
152
|
+
.min(1)
|
|
153
|
+
.max(exports.ORDER_ASSISTANT_LIMITS.items),
|
|
154
|
+
shipping_option_id: primitives_1.NonEmptyStringSchema.describe("ID der Versandart aus versandarten_auflisten."),
|
|
155
|
+
source: exports.OrderAssistantSourceSchema.describe("Wie die Bestellung eingegangen ist."),
|
|
156
|
+
note: zod_1.z
|
|
157
|
+
.string()
|
|
158
|
+
.trim()
|
|
159
|
+
.min(1)
|
|
160
|
+
.max(exports.ORDER_ASSISTANT_LIMITS.noteLength)
|
|
161
|
+
.optional()
|
|
162
|
+
.describe("Interne Notiz, z. B. Unklarheiten auf dem Fax."),
|
|
163
|
+
})
|
|
164
|
+
.strict()
|
|
165
|
+
.refine((value) => Boolean(value.customer_id) !== Boolean(value.new_customer), { message: "Genau eines von customer_id und new_customer ist nötig." });
|
|
166
|
+
exports.OrderAssistantDraftItemSchema = zod_1.z.object({
|
|
167
|
+
title: zod_1.z.string(),
|
|
168
|
+
sku: zod_1.z.string().nullable(),
|
|
169
|
+
quantity: zod_1.z.number(),
|
|
170
|
+
unit_price: zod_1.z.number(),
|
|
171
|
+
total: zod_1.z.number(),
|
|
172
|
+
});
|
|
173
|
+
exports.CreateDraftOrderOutputSchema = zod_1.z.object({
|
|
174
|
+
draft_order_id: zod_1.z.string(),
|
|
175
|
+
display_id: zod_1.z.number().nullable(),
|
|
176
|
+
customer_id: zod_1.z.string(),
|
|
177
|
+
/** True when the assistant created the customer record for this draft. */
|
|
178
|
+
customer_created: zod_1.z.boolean(),
|
|
179
|
+
currency_code: zod_1.z.string(),
|
|
180
|
+
items: zod_1.z.array(exports.OrderAssistantDraftItemSchema),
|
|
181
|
+
shipping_total: zod_1.z.number(),
|
|
182
|
+
tax_total: zod_1.z.number(),
|
|
183
|
+
total: zod_1.z.number(),
|
|
184
|
+
/** Path of the draft in the Admin, relative to the backend URL. */
|
|
185
|
+
admin_path: zod_1.z.string(),
|
|
186
|
+
});
|
|
187
|
+
// --- Anmeldung per OAuth (MCP authorization, OAuth 2.1) --------------------
|
|
188
|
+
/** Feature keys of the order assistant's plugin toggles. */
|
|
189
|
+
exports.ORDER_ASSISTANT_FEATURES = {
|
|
190
|
+
oauth: "oauth",
|
|
191
|
+
};
|
|
192
|
+
exports.ORDER_ASSISTANT_OAUTH = {
|
|
193
|
+
/** The one scope: use the assistant's tools as the signed-in Admin user. */
|
|
194
|
+
scope: "order_assistant",
|
|
195
|
+
accessTokenTtlSeconds: 3600,
|
|
196
|
+
/** A connection ends when its refresh token stays unused this long. */
|
|
197
|
+
connectionIdleDays: 30,
|
|
198
|
+
/** How long the consent page may stay open. */
|
|
199
|
+
authorizationRequestTtlSeconds: 600,
|
|
200
|
+
/** How long the client has to redeem the code after the consent. */
|
|
201
|
+
authorizationCodeTtlSeconds: 120,
|
|
202
|
+
maxRedirectUris: 10,
|
|
203
|
+
maxUriLength: 2000,
|
|
204
|
+
maxClientNameLength: 120,
|
|
205
|
+
maxStateLength: 2000,
|
|
206
|
+
};
|
|
207
|
+
const OAUTH_LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "[::1]"];
|
|
208
|
+
/** `http://localhost`, `http://127.0.0.1` or `http://[::1]`, any port. */
|
|
209
|
+
const isOAuthLoopbackRedirectUri = (value) => {
|
|
210
|
+
try {
|
|
211
|
+
const url = new URL(value);
|
|
212
|
+
return (url.protocol === "http:" && OAUTH_LOOPBACK_HOSTS.includes(url.hostname));
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
exports.isOAuthLoopbackRedirectUri = isOAuthLoopbackRedirectUri;
|
|
219
|
+
/**
|
|
220
|
+
* A redirect URI a client may register: https, or http on a loopback address
|
|
221
|
+
* (native clients such as Claude Code), without credentials or fragment.
|
|
222
|
+
*/
|
|
223
|
+
exports.OAuthRedirectUriSchema = zod_1.z
|
|
224
|
+
.string()
|
|
225
|
+
.max(exports.ORDER_ASSISTANT_OAUTH.maxUriLength)
|
|
226
|
+
.refine((value) => {
|
|
227
|
+
let url;
|
|
228
|
+
try {
|
|
229
|
+
url = new URL(value);
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
if (url.hash || url.username || url.password) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
return url.protocol === "https:" || (0, exports.isOAuthLoopbackRedirectUri)(value);
|
|
238
|
+
}, {
|
|
239
|
+
message: "A redirect URI must use https, or http on a loopback address, and carry no fragment.",
|
|
240
|
+
});
|
|
241
|
+
/**
|
|
242
|
+
* Dynamic client registration request (RFC 7591). Unknown metadata is
|
|
243
|
+
* ignored; the requested authentication method, grant and response types are
|
|
244
|
+
* accepted as sent and answered with what the server actually supports.
|
|
245
|
+
*/
|
|
246
|
+
exports.OAuthClientRegistrationRequestSchema = zod_1.z.object({
|
|
247
|
+
redirect_uris: zod_1.z
|
|
248
|
+
.array(exports.OAuthRedirectUriSchema)
|
|
249
|
+
.min(1)
|
|
250
|
+
.max(exports.ORDER_ASSISTANT_OAUTH.maxRedirectUris),
|
|
251
|
+
client_name: zod_1.z
|
|
252
|
+
.string()
|
|
253
|
+
.trim()
|
|
254
|
+
.min(1)
|
|
255
|
+
.max(exports.ORDER_ASSISTANT_OAUTH.maxClientNameLength)
|
|
256
|
+
.optional(),
|
|
257
|
+
});
|
|
258
|
+
exports.OAuthClientRegistrationResponseSchema = zod_1.z.object({
|
|
259
|
+
client_id: zod_1.z.string(),
|
|
260
|
+
/** Seconds since the epoch. */
|
|
261
|
+
client_id_issued_at: zod_1.z.number(),
|
|
262
|
+
client_name: zod_1.z.string().optional(),
|
|
263
|
+
redirect_uris: zod_1.z.array(zod_1.z.string()),
|
|
264
|
+
/** Public clients only: PKCE instead of a client secret. */
|
|
265
|
+
token_endpoint_auth_method: zod_1.z.literal("none"),
|
|
266
|
+
grant_types: zod_1.z.array(zod_1.z.string()),
|
|
267
|
+
response_types: zod_1.z.array(zod_1.z.string()),
|
|
268
|
+
scope: zod_1.z.string(),
|
|
269
|
+
});
|
|
270
|
+
/** Query of the authorization endpoint, before the client is looked up. */
|
|
271
|
+
exports.OAuthAuthorizeQuerySchema = zod_1.z.object({
|
|
272
|
+
client_id: zod_1.z.string().min(1).max(200),
|
|
273
|
+
redirect_uri: zod_1.z.string().min(1).max(exports.ORDER_ASSISTANT_OAUTH.maxUriLength),
|
|
274
|
+
response_type: zod_1.z.string().max(100).optional(),
|
|
275
|
+
code_challenge: zod_1.z.string().max(200).optional(),
|
|
276
|
+
code_challenge_method: zod_1.z.string().max(20).optional(),
|
|
277
|
+
state: zod_1.z.string().max(exports.ORDER_ASSISTANT_OAUTH.maxStateLength).optional(),
|
|
278
|
+
scope: zod_1.z.string().max(1000).optional(),
|
|
279
|
+
resource: zod_1.z.string().max(exports.ORDER_ASSISTANT_OAUTH.maxUriLength).optional(),
|
|
280
|
+
});
|
|
281
|
+
/** Body of the token endpoint (`application/x-www-form-urlencoded`). */
|
|
282
|
+
exports.OAuthTokenRequestSchema = zod_1.z.discriminatedUnion("grant_type", [
|
|
283
|
+
zod_1.z.object({
|
|
284
|
+
grant_type: zod_1.z.literal("authorization_code"),
|
|
285
|
+
code: zod_1.z.string().min(1).max(200),
|
|
286
|
+
/** RFC 7636: 43 to 128 unreserved characters. */
|
|
287
|
+
code_verifier: zod_1.z.string().regex(/^[A-Za-z0-9\-._~]{43,128}$/),
|
|
288
|
+
client_id: zod_1.z.string().min(1).max(200),
|
|
289
|
+
redirect_uri: zod_1.z.string().max(exports.ORDER_ASSISTANT_OAUTH.maxUriLength).optional(),
|
|
290
|
+
resource: zod_1.z.string().max(exports.ORDER_ASSISTANT_OAUTH.maxUriLength).optional(),
|
|
291
|
+
}),
|
|
292
|
+
zod_1.z.object({
|
|
293
|
+
grant_type: zod_1.z.literal("refresh_token"),
|
|
294
|
+
refresh_token: zod_1.z.string().min(1).max(200),
|
|
295
|
+
client_id: zod_1.z.string().min(1).max(200),
|
|
296
|
+
resource: zod_1.z.string().max(exports.ORDER_ASSISTANT_OAUTH.maxUriLength).optional(),
|
|
297
|
+
}),
|
|
298
|
+
]);
|
|
299
|
+
exports.OAuthTokenResponseSchema = zod_1.z.object({
|
|
300
|
+
access_token: zod_1.z.string(),
|
|
301
|
+
token_type: zod_1.z.literal("Bearer"),
|
|
302
|
+
/** Seconds until the access token expires. */
|
|
303
|
+
expires_in: zod_1.z.number(),
|
|
304
|
+
/** Replaces the refresh token that was sent; the old one stops working. */
|
|
305
|
+
refresh_token: zod_1.z.string(),
|
|
306
|
+
scope: zod_1.z.string(),
|
|
307
|
+
});
|
|
308
|
+
exports.OAuthErrorCodeSchema = zod_1.z.enum([
|
|
309
|
+
"invalid_request",
|
|
310
|
+
"invalid_client",
|
|
311
|
+
"invalid_grant",
|
|
312
|
+
"invalid_target",
|
|
313
|
+
"invalid_client_metadata",
|
|
314
|
+
"invalid_redirect_uri",
|
|
315
|
+
"unsupported_grant_type",
|
|
316
|
+
"unsupported_response_type",
|
|
317
|
+
"access_denied",
|
|
318
|
+
"temporarily_unavailable",
|
|
319
|
+
]);
|
|
320
|
+
/** Error body of the registration and token endpoints (RFC 6749, RFC 7591). */
|
|
321
|
+
exports.OAuthErrorResponseSchema = zod_1.z.object({
|
|
322
|
+
error: exports.OAuthErrorCodeSchema,
|
|
323
|
+
error_description: zod_1.z.string(),
|
|
324
|
+
});
|
|
325
|
+
/** RFC 9728: where the MCP endpoint's authorization server is. */
|
|
326
|
+
exports.OAuthProtectedResourceMetadataSchema = zod_1.z.object({
|
|
327
|
+
resource: zod_1.z.string(),
|
|
328
|
+
authorization_servers: zod_1.z.array(zod_1.z.string()),
|
|
329
|
+
bearer_methods_supported: zod_1.z.array(zod_1.z.string()),
|
|
330
|
+
scopes_supported: zod_1.z.array(zod_1.z.string()),
|
|
331
|
+
resource_name: zod_1.z.string(),
|
|
332
|
+
});
|
|
333
|
+
/** RFC 8414: the authorization server's endpoints and capabilities. */
|
|
334
|
+
exports.OAuthAuthorizationServerMetadataSchema = zod_1.z.object({
|
|
335
|
+
issuer: zod_1.z.string(),
|
|
336
|
+
authorization_endpoint: zod_1.z.string(),
|
|
337
|
+
token_endpoint: zod_1.z.string(),
|
|
338
|
+
registration_endpoint: zod_1.z.string(),
|
|
339
|
+
response_types_supported: zod_1.z.array(zod_1.z.string()),
|
|
340
|
+
grant_types_supported: zod_1.z.array(zod_1.z.string()),
|
|
341
|
+
code_challenge_methods_supported: zod_1.z.array(zod_1.z.string()),
|
|
342
|
+
token_endpoint_auth_methods_supported: zod_1.z.array(zod_1.z.string()),
|
|
343
|
+
scopes_supported: zod_1.z.array(zod_1.z.string()),
|
|
344
|
+
/** RFC 9207: every authorization response carries `iss`. */
|
|
345
|
+
authorization_response_iss_parameter_supported: zod_1.z.boolean(),
|
|
346
|
+
});
|
|
347
|
+
/** What the consent page shows about a pending sign-in request. */
|
|
348
|
+
exports.AdminOrderAssistantAuthorizationSchema = zod_1.z.object({
|
|
349
|
+
id: zod_1.z.string(),
|
|
350
|
+
/** Name the chatbot registered with; `null` when it gave none. */
|
|
351
|
+
client_name: zod_1.z.string().nullable(),
|
|
352
|
+
/** Host the browser is sent back to after the decision. */
|
|
353
|
+
redirect_host: zod_1.z.string(),
|
|
354
|
+
/** True when the chatbot runs on this computer (loopback redirect). */
|
|
355
|
+
redirect_is_loopback: zod_1.z.boolean(),
|
|
356
|
+
/** True when the host belongs to a chatbot service the shop knows. */
|
|
357
|
+
redirect_is_known: zod_1.z.boolean(),
|
|
358
|
+
expires_at: primitives_1.WireDateSchema,
|
|
359
|
+
});
|
|
360
|
+
exports.AdminOrderAssistantAuthorizationResponseSchema = zod_1.z.object({
|
|
361
|
+
authorization: exports.AdminOrderAssistantAuthorizationSchema,
|
|
362
|
+
});
|
|
363
|
+
exports.DecideOrderAssistantAuthorizationSchema = zod_1.z
|
|
364
|
+
.object({ approve: zod_1.z.boolean() })
|
|
365
|
+
.strict();
|
|
366
|
+
exports.DecideOrderAssistantAuthorizationResponseSchema = zod_1.z.object({
|
|
367
|
+
/** Where the browser must go next: the chatbot's redirect URI. */
|
|
368
|
+
redirect_to: zod_1.z.string(),
|
|
369
|
+
});
|
|
370
|
+
/** One chatbot an Admin user connected through OAuth. */
|
|
371
|
+
exports.AdminOrderAssistantConnectionSchema = zod_1.z.object({
|
|
372
|
+
id: zod_1.z.string(),
|
|
373
|
+
client_name: zod_1.z.string().nullable(),
|
|
374
|
+
redirect_host: zod_1.z.string(),
|
|
375
|
+
user_id: zod_1.z.string(),
|
|
376
|
+
/** `null` when the Admin user no longer exists. */
|
|
377
|
+
user_email: zod_1.z.string().nullable(),
|
|
378
|
+
created_at: primitives_1.WireDateSchema,
|
|
379
|
+
last_used_at: primitives_1.WireDateSchema.nullable(),
|
|
380
|
+
/** When the connection ends unless the chatbot uses it before. */
|
|
381
|
+
expires_at: primitives_1.WireDateSchema,
|
|
382
|
+
});
|
|
383
|
+
exports.AdminOrderAssistantConnectionsResponseSchema = zod_1.z.object({
|
|
384
|
+
connections: zod_1.z.array(exports.AdminOrderAssistantConnectionSchema),
|
|
385
|
+
});
|
|
386
|
+
exports.DeleteOrderAssistantConnectionResponseSchema = zod_1.z.object({
|
|
387
|
+
id: zod_1.z.string(),
|
|
388
|
+
deleted: zod_1.z.literal(true),
|
|
389
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { z } from "@medusajs/framework/zod";
|
|
2
|
+
import type { AdminOrderAssistantAuthorizationResponseSchema, AdminOrderAssistantAuthorizationSchema, AdminOrderAssistantConnectionSchema, AdminOrderAssistantConnectionsResponseSchema, CreateDraftOrderInputSchema, CreateDraftOrderOutputSchema, DecideOrderAssistantAuthorizationResponseSchema, DecideOrderAssistantAuthorizationSchema, DeleteOrderAssistantConnectionResponseSchema, ListShippingOptionsInputSchema, ListShippingOptionsOutputSchema, OAuthAuthorizationServerMetadataSchema, OAuthAuthorizeQuerySchema, OAuthClientRegistrationRequestSchema, OAuthClientRegistrationResponseSchema, OAuthErrorCodeSchema, OAuthErrorResponseSchema, OAuthProtectedResourceMetadataSchema, OAuthTokenRequestSchema, OAuthTokenResponseSchema, OrderAssistantAddressSchema, OrderAssistantCustomerSchema, OrderAssistantShippingOptionSchema, OrderAssistantSourceSchema, OrderAssistantVariantSchema, SearchCustomersInputSchema, SearchCustomersOutputSchema, SearchProductsInputSchema, SearchProductsOutputSchema } from "./schemas";
|
|
3
|
+
export type OrderAssistantSource = z.infer<typeof OrderAssistantSourceSchema>;
|
|
4
|
+
export type OrderAssistantAddress = z.infer<typeof OrderAssistantAddressSchema>;
|
|
5
|
+
export type OrderAssistantCustomer = z.infer<typeof OrderAssistantCustomerSchema>;
|
|
6
|
+
export type OrderAssistantVariant = z.infer<typeof OrderAssistantVariantSchema>;
|
|
7
|
+
export type OrderAssistantShippingOption = z.infer<typeof OrderAssistantShippingOptionSchema>;
|
|
8
|
+
export type SearchCustomersInput = z.infer<typeof SearchCustomersInputSchema>;
|
|
9
|
+
export type SearchCustomersOutput = z.infer<typeof SearchCustomersOutputSchema>;
|
|
10
|
+
export type SearchProductsInput = z.infer<typeof SearchProductsInputSchema>;
|
|
11
|
+
export type SearchProductsOutput = z.infer<typeof SearchProductsOutputSchema>;
|
|
12
|
+
export type ListShippingOptionsInput = z.infer<typeof ListShippingOptionsInputSchema>;
|
|
13
|
+
export type ListShippingOptionsOutput = z.infer<typeof ListShippingOptionsOutputSchema>;
|
|
14
|
+
export type CreateDraftOrderInput = z.infer<typeof CreateDraftOrderInputSchema>;
|
|
15
|
+
export type CreateDraftOrderOutput = z.infer<typeof CreateDraftOrderOutputSchema>;
|
|
16
|
+
export type OAuthClientRegistrationRequest = z.infer<typeof OAuthClientRegistrationRequestSchema>;
|
|
17
|
+
export type OAuthClientRegistrationResponse = z.infer<typeof OAuthClientRegistrationResponseSchema>;
|
|
18
|
+
export type OAuthAuthorizeQuery = z.infer<typeof OAuthAuthorizeQuerySchema>;
|
|
19
|
+
export type OAuthTokenRequest = z.infer<typeof OAuthTokenRequestSchema>;
|
|
20
|
+
export type OAuthTokenResponse = z.infer<typeof OAuthTokenResponseSchema>;
|
|
21
|
+
export type OAuthErrorCode = z.infer<typeof OAuthErrorCodeSchema>;
|
|
22
|
+
export type OAuthErrorResponse = z.infer<typeof OAuthErrorResponseSchema>;
|
|
23
|
+
export type OAuthProtectedResourceMetadata = z.infer<typeof OAuthProtectedResourceMetadataSchema>;
|
|
24
|
+
export type OAuthAuthorizationServerMetadata = z.infer<typeof OAuthAuthorizationServerMetadataSchema>;
|
|
25
|
+
export type AdminOrderAssistantAuthorization = z.infer<typeof AdminOrderAssistantAuthorizationSchema>;
|
|
26
|
+
export type AdminOrderAssistantAuthorizationResponse = z.infer<typeof AdminOrderAssistantAuthorizationResponseSchema>;
|
|
27
|
+
export type DecideOrderAssistantAuthorizationRequest = z.infer<typeof DecideOrderAssistantAuthorizationSchema>;
|
|
28
|
+
export type DecideOrderAssistantAuthorizationResponse = z.infer<typeof DecideOrderAssistantAuthorizationResponseSchema>;
|
|
29
|
+
export type AdminOrderAssistantConnection = z.infer<typeof AdminOrderAssistantConnectionSchema>;
|
|
30
|
+
export type AdminOrderAssistantConnectionsResponse = z.infer<typeof AdminOrderAssistantConnectionsResponseSchema>;
|
|
31
|
+
export type DeleteOrderAssistantConnectionResponse = z.infer<typeof DeleteOrderAssistantConnectionResponseSchema>;
|