@hartl-services/medusa-contracts 1.6.0 → 1.8.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 +6 -1
- package/dist/email/schemas.d.ts +27 -4
- package/dist/email/schemas.js +9 -0
- package/dist/esm/email/schemas.mjs +9 -0
- package/dist/esm/order-assistant/paths.mjs +26 -0
- package/dist/esm/order-assistant/schemas.mjs +203 -1
- package/dist/order-assistant/paths.d.ts +26 -0
- package/dist/order-assistant/paths.js +26 -0
- package/dist/order-assistant/schemas.d.ts +178 -0
- package/dist/order-assistant/schemas.js +204 -1
- package/dist/order-assistant/types.d.ts +17 -1
- package/dist/plugin-features/schemas.d.ts +36 -36
- package/package.json +1 -1
|
@@ -211,3 +211,181 @@ export declare const CreateDraftOrderOutputSchema: z.ZodObject<{
|
|
|
211
211
|
total: z.ZodNumber;
|
|
212
212
|
admin_path: z.ZodString;
|
|
213
213
|
}, z.core.$strip>;
|
|
214
|
+
/** Feature keys of the order assistant's plugin toggles. */
|
|
215
|
+
export declare const ORDER_ASSISTANT_FEATURES: {
|
|
216
|
+
readonly oauth: "oauth";
|
|
217
|
+
};
|
|
218
|
+
export declare const ORDER_ASSISTANT_OAUTH: {
|
|
219
|
+
/** The one scope: use the assistant's tools as the signed-in Admin user. */
|
|
220
|
+
readonly scope: "order_assistant";
|
|
221
|
+
readonly accessTokenTtlSeconds: 3600;
|
|
222
|
+
/** A connection ends when its refresh token stays unused this long. */
|
|
223
|
+
readonly connectionIdleDays: 30;
|
|
224
|
+
/** How long the consent page may stay open. */
|
|
225
|
+
readonly authorizationRequestTtlSeconds: 600;
|
|
226
|
+
/** How long the client has to redeem the code after the consent. */
|
|
227
|
+
readonly authorizationCodeTtlSeconds: 120;
|
|
228
|
+
readonly maxRedirectUris: 10;
|
|
229
|
+
readonly maxUriLength: 2000;
|
|
230
|
+
readonly maxClientNameLength: 120;
|
|
231
|
+
readonly maxStateLength: 2000;
|
|
232
|
+
};
|
|
233
|
+
/** `http://localhost`, `http://127.0.0.1` or `http://[::1]`, any port. */
|
|
234
|
+
export declare const isOAuthLoopbackRedirectUri: (value: string) => boolean;
|
|
235
|
+
/**
|
|
236
|
+
* A redirect URI a client may register: https, or http on a loopback address
|
|
237
|
+
* (native clients such as Claude Code), without credentials or fragment.
|
|
238
|
+
*/
|
|
239
|
+
export declare const OAuthRedirectUriSchema: z.ZodString;
|
|
240
|
+
/**
|
|
241
|
+
* Dynamic client registration request (RFC 7591). Unknown metadata is
|
|
242
|
+
* ignored; the requested authentication method, grant and response types are
|
|
243
|
+
* accepted as sent and answered with what the server actually supports.
|
|
244
|
+
*/
|
|
245
|
+
export declare const OAuthClientRegistrationRequestSchema: z.ZodObject<{
|
|
246
|
+
redirect_uris: z.ZodArray<z.ZodString>;
|
|
247
|
+
client_name: z.ZodOptional<z.ZodString>;
|
|
248
|
+
}, z.core.$strip>;
|
|
249
|
+
export declare const OAuthClientRegistrationResponseSchema: z.ZodObject<{
|
|
250
|
+
client_id: z.ZodString;
|
|
251
|
+
client_id_issued_at: z.ZodNumber;
|
|
252
|
+
client_name: z.ZodOptional<z.ZodString>;
|
|
253
|
+
redirect_uris: z.ZodArray<z.ZodString>;
|
|
254
|
+
token_endpoint_auth_method: z.ZodLiteral<"none">;
|
|
255
|
+
grant_types: z.ZodArray<z.ZodString>;
|
|
256
|
+
response_types: z.ZodArray<z.ZodString>;
|
|
257
|
+
scope: z.ZodString;
|
|
258
|
+
}, z.core.$strip>;
|
|
259
|
+
/** Query of the authorization endpoint, before the client is looked up. */
|
|
260
|
+
export declare const OAuthAuthorizeQuerySchema: z.ZodObject<{
|
|
261
|
+
client_id: z.ZodString;
|
|
262
|
+
redirect_uri: z.ZodString;
|
|
263
|
+
response_type: z.ZodOptional<z.ZodString>;
|
|
264
|
+
code_challenge: z.ZodOptional<z.ZodString>;
|
|
265
|
+
code_challenge_method: z.ZodOptional<z.ZodString>;
|
|
266
|
+
state: z.ZodOptional<z.ZodString>;
|
|
267
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
268
|
+
resource: z.ZodOptional<z.ZodString>;
|
|
269
|
+
}, z.core.$strip>;
|
|
270
|
+
/** Body of the token endpoint (`application/x-www-form-urlencoded`). */
|
|
271
|
+
export declare const OAuthTokenRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
272
|
+
grant_type: z.ZodLiteral<"authorization_code">;
|
|
273
|
+
code: z.ZodString;
|
|
274
|
+
code_verifier: z.ZodString;
|
|
275
|
+
client_id: z.ZodString;
|
|
276
|
+
redirect_uri: z.ZodOptional<z.ZodString>;
|
|
277
|
+
resource: z.ZodOptional<z.ZodString>;
|
|
278
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
279
|
+
grant_type: z.ZodLiteral<"refresh_token">;
|
|
280
|
+
refresh_token: z.ZodString;
|
|
281
|
+
client_id: z.ZodString;
|
|
282
|
+
resource: z.ZodOptional<z.ZodString>;
|
|
283
|
+
}, z.core.$strip>], "grant_type">;
|
|
284
|
+
export declare const OAuthTokenResponseSchema: z.ZodObject<{
|
|
285
|
+
access_token: z.ZodString;
|
|
286
|
+
token_type: z.ZodLiteral<"Bearer">;
|
|
287
|
+
expires_in: z.ZodNumber;
|
|
288
|
+
refresh_token: z.ZodString;
|
|
289
|
+
scope: z.ZodString;
|
|
290
|
+
}, z.core.$strip>;
|
|
291
|
+
export declare const OAuthErrorCodeSchema: z.ZodEnum<{
|
|
292
|
+
invalid_request: "invalid_request";
|
|
293
|
+
invalid_client: "invalid_client";
|
|
294
|
+
invalid_grant: "invalid_grant";
|
|
295
|
+
invalid_target: "invalid_target";
|
|
296
|
+
invalid_client_metadata: "invalid_client_metadata";
|
|
297
|
+
invalid_redirect_uri: "invalid_redirect_uri";
|
|
298
|
+
unsupported_grant_type: "unsupported_grant_type";
|
|
299
|
+
unsupported_response_type: "unsupported_response_type";
|
|
300
|
+
access_denied: "access_denied";
|
|
301
|
+
temporarily_unavailable: "temporarily_unavailable";
|
|
302
|
+
}>;
|
|
303
|
+
/** Error body of the registration and token endpoints (RFC 6749, RFC 7591). */
|
|
304
|
+
export declare const OAuthErrorResponseSchema: z.ZodObject<{
|
|
305
|
+
error: z.ZodEnum<{
|
|
306
|
+
invalid_request: "invalid_request";
|
|
307
|
+
invalid_client: "invalid_client";
|
|
308
|
+
invalid_grant: "invalid_grant";
|
|
309
|
+
invalid_target: "invalid_target";
|
|
310
|
+
invalid_client_metadata: "invalid_client_metadata";
|
|
311
|
+
invalid_redirect_uri: "invalid_redirect_uri";
|
|
312
|
+
unsupported_grant_type: "unsupported_grant_type";
|
|
313
|
+
unsupported_response_type: "unsupported_response_type";
|
|
314
|
+
access_denied: "access_denied";
|
|
315
|
+
temporarily_unavailable: "temporarily_unavailable";
|
|
316
|
+
}>;
|
|
317
|
+
error_description: z.ZodString;
|
|
318
|
+
}, z.core.$strip>;
|
|
319
|
+
/** RFC 9728: where the MCP endpoint's authorization server is. */
|
|
320
|
+
export declare const OAuthProtectedResourceMetadataSchema: z.ZodObject<{
|
|
321
|
+
resource: z.ZodString;
|
|
322
|
+
authorization_servers: z.ZodArray<z.ZodString>;
|
|
323
|
+
bearer_methods_supported: z.ZodArray<z.ZodString>;
|
|
324
|
+
scopes_supported: z.ZodArray<z.ZodString>;
|
|
325
|
+
resource_name: z.ZodString;
|
|
326
|
+
}, z.core.$strip>;
|
|
327
|
+
/** RFC 8414: the authorization server's endpoints and capabilities. */
|
|
328
|
+
export declare const OAuthAuthorizationServerMetadataSchema: z.ZodObject<{
|
|
329
|
+
issuer: z.ZodString;
|
|
330
|
+
authorization_endpoint: z.ZodString;
|
|
331
|
+
token_endpoint: z.ZodString;
|
|
332
|
+
registration_endpoint: z.ZodString;
|
|
333
|
+
response_types_supported: z.ZodArray<z.ZodString>;
|
|
334
|
+
grant_types_supported: z.ZodArray<z.ZodString>;
|
|
335
|
+
code_challenge_methods_supported: z.ZodArray<z.ZodString>;
|
|
336
|
+
token_endpoint_auth_methods_supported: z.ZodArray<z.ZodString>;
|
|
337
|
+
scopes_supported: z.ZodArray<z.ZodString>;
|
|
338
|
+
authorization_response_iss_parameter_supported: z.ZodBoolean;
|
|
339
|
+
}, z.core.$strip>;
|
|
340
|
+
/** What the consent page shows about a pending sign-in request. */
|
|
341
|
+
export declare const AdminOrderAssistantAuthorizationSchema: z.ZodObject<{
|
|
342
|
+
id: z.ZodString;
|
|
343
|
+
client_name: z.ZodNullable<z.ZodString>;
|
|
344
|
+
redirect_host: z.ZodString;
|
|
345
|
+
redirect_is_loopback: z.ZodBoolean;
|
|
346
|
+
redirect_is_known: z.ZodBoolean;
|
|
347
|
+
expires_at: z.ZodString;
|
|
348
|
+
}, z.core.$strip>;
|
|
349
|
+
export declare const AdminOrderAssistantAuthorizationResponseSchema: z.ZodObject<{
|
|
350
|
+
authorization: z.ZodObject<{
|
|
351
|
+
id: z.ZodString;
|
|
352
|
+
client_name: z.ZodNullable<z.ZodString>;
|
|
353
|
+
redirect_host: z.ZodString;
|
|
354
|
+
redirect_is_loopback: z.ZodBoolean;
|
|
355
|
+
redirect_is_known: z.ZodBoolean;
|
|
356
|
+
expires_at: z.ZodString;
|
|
357
|
+
}, z.core.$strip>;
|
|
358
|
+
}, z.core.$strip>;
|
|
359
|
+
export declare const DecideOrderAssistantAuthorizationSchema: z.ZodObject<{
|
|
360
|
+
approve: z.ZodBoolean;
|
|
361
|
+
}, z.core.$strict>;
|
|
362
|
+
export declare const DecideOrderAssistantAuthorizationResponseSchema: z.ZodObject<{
|
|
363
|
+
redirect_to: z.ZodString;
|
|
364
|
+
}, z.core.$strip>;
|
|
365
|
+
/** One chatbot an Admin user connected through OAuth. */
|
|
366
|
+
export declare const AdminOrderAssistantConnectionSchema: z.ZodObject<{
|
|
367
|
+
id: z.ZodString;
|
|
368
|
+
client_name: z.ZodNullable<z.ZodString>;
|
|
369
|
+
redirect_host: z.ZodString;
|
|
370
|
+
user_id: z.ZodString;
|
|
371
|
+
user_email: z.ZodNullable<z.ZodString>;
|
|
372
|
+
created_at: z.ZodString;
|
|
373
|
+
last_used_at: z.ZodNullable<z.ZodString>;
|
|
374
|
+
expires_at: z.ZodString;
|
|
375
|
+
}, z.core.$strip>;
|
|
376
|
+
export declare const AdminOrderAssistantConnectionsResponseSchema: z.ZodObject<{
|
|
377
|
+
connections: z.ZodArray<z.ZodObject<{
|
|
378
|
+
id: z.ZodString;
|
|
379
|
+
client_name: z.ZodNullable<z.ZodString>;
|
|
380
|
+
redirect_host: z.ZodString;
|
|
381
|
+
user_id: z.ZodString;
|
|
382
|
+
user_email: z.ZodNullable<z.ZodString>;
|
|
383
|
+
created_at: z.ZodString;
|
|
384
|
+
last_used_at: z.ZodNullable<z.ZodString>;
|
|
385
|
+
expires_at: z.ZodString;
|
|
386
|
+
}, z.core.$strip>>;
|
|
387
|
+
}, z.core.$strip>;
|
|
388
|
+
export declare const DeleteOrderAssistantConnectionResponseSchema: z.ZodObject<{
|
|
389
|
+
id: z.ZodString;
|
|
390
|
+
deleted: z.ZodLiteral<true>;
|
|
391
|
+
}, z.core.$strip>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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;
|
|
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
4
|
const zod_1 = require("@medusajs/framework/zod");
|
|
5
5
|
const primitives_1 = require("../shared/primitives");
|
|
6
6
|
/** Plugin key and container key of the order assistant in the base. */
|
|
@@ -184,3 +184,206 @@ exports.CreateDraftOrderOutputSchema = zod_1.z.object({
|
|
|
184
184
|
/** Path of the draft in the Admin, relative to the backend URL. */
|
|
185
185
|
admin_path: zod_1.z.string(),
|
|
186
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
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { z } from "@medusajs/framework/zod";
|
|
2
|
-
import type { CreateDraftOrderInputSchema, CreateDraftOrderOutputSchema, ListShippingOptionsInputSchema, ListShippingOptionsOutputSchema, OrderAssistantAddressSchema, OrderAssistantCustomerSchema, OrderAssistantShippingOptionSchema, OrderAssistantSourceSchema, OrderAssistantVariantSchema, SearchCustomersInputSchema, SearchCustomersOutputSchema, SearchProductsInputSchema, SearchProductsOutputSchema } from "./schemas";
|
|
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
3
|
export type OrderAssistantSource = z.infer<typeof OrderAssistantSourceSchema>;
|
|
4
4
|
export type OrderAssistantAddress = z.infer<typeof OrderAssistantAddressSchema>;
|
|
5
5
|
export type OrderAssistantCustomer = z.infer<typeof OrderAssistantCustomerSchema>;
|
|
@@ -13,3 +13,19 @@ export type ListShippingOptionsInput = z.infer<typeof ListShippingOptionsInputSc
|
|
|
13
13
|
export type ListShippingOptionsOutput = z.infer<typeof ListShippingOptionsOutputSchema>;
|
|
14
14
|
export type CreateDraftOrderInput = z.infer<typeof CreateDraftOrderInputSchema>;
|
|
15
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>;
|