@unchainedshop/api 3.1.12 → 3.1.13
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/lib/errors.d.ts +1 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -0
- package/lib/errors.js.map +1 -1
- package/lib/express/chatRouter.d.ts +3 -0
- package/lib/express/chatRouter.d.ts.map +1 -0
- package/lib/express/chatRouter.js +86 -0
- package/lib/express/chatRouter.js.map +1 -0
- package/lib/express/createApolloMiddleware.d.ts +4 -0
- package/lib/express/createApolloMiddleware.d.ts.map +1 -0
- package/lib/express/createApolloMiddleware.js +36 -0
- package/lib/express/createApolloMiddleware.js.map +1 -0
- package/lib/express/createSingleSignOnMiddleware.d.ts +5 -0
- package/lib/express/createSingleSignOnMiddleware.d.ts.map +1 -0
- package/lib/express/createSingleSignOnMiddleware.js +71 -0
- package/lib/express/createSingleSignOnMiddleware.js.map +1 -0
- package/lib/hashPassword.d.ts +2 -0
- package/lib/hashPassword.d.ts.map +1 -0
- package/lib/hashPassword.js +5 -0
- package/lib/hashPassword.js.map +1 -0
- package/lib/loaders/assortmentMediaTextLoader.js +1 -1
- package/lib/loaders/assortmentMediaTextLoader.js.map +1 -1
- package/lib/loaders/assortmentTextLoader.js +1 -1
- package/lib/loaders/assortmentTextLoader.js.map +1 -1
- package/lib/loaders/filterTextLoader.js +1 -1
- package/lib/loaders/filterTextLoader.js.map +1 -1
- package/lib/loaders/index.d.ts.map +1 -1
- package/lib/loaders/index.js.map +1 -1
- package/lib/loaders/productMediaTextLoader.d.ts.map +1 -1
- package/lib/loaders/productMediaTextLoader.js +1 -1
- package/lib/loaders/productMediaTextLoader.js.map +1 -1
- package/lib/loaders/productTextLoader.d.ts.map +1 -1
- package/lib/loaders/productTextLoader.js +1 -1
- package/lib/loaders/productTextLoader.js.map +1 -1
- package/lib/mcp/index.d.ts.map +1 -1
- package/lib/mcp/index.js +1 -1
- package/lib/mcp/index.js.map +1 -1
- package/lib/mcp/tools/addProductAssignmentHandler.d.ts +52 -0
- package/lib/mcp/tools/addProductAssignmentHandler.d.ts.map +1 -0
- package/lib/mcp/tools/addProductAssignmentHandler.js +97 -0
- package/lib/mcp/tools/addProductAssignmentHandler.js.map +1 -0
- package/lib/mcp/tools/countriesHandler.d.ts +60 -0
- package/lib/mcp/tools/countriesHandler.d.ts.map +1 -0
- package/lib/mcp/tools/countriesHandler.js +48 -0
- package/lib/mcp/tools/countriesHandler.js.map +1 -0
- package/lib/mcp/tools/countryHandler.d.ts +20 -0
- package/lib/mcp/tools/countryHandler.d.ts.map +1 -0
- package/lib/mcp/tools/countryHandler.js +34 -0
- package/lib/mcp/tools/countryHandler.js.map +1 -0
- package/lib/mcp/tools/createProduct.d.ts +138 -0
- package/lib/mcp/tools/createProduct.d.ts.map +1 -0
- package/lib/mcp/tools/createProduct.js +60 -0
- package/lib/mcp/tools/createProduct.js.map +1 -0
- package/lib/mcp/tools/createProductVariationHandler.d.ts +84 -0
- package/lib/mcp/tools/createProductVariationHandler.d.ts.map +1 -0
- package/lib/mcp/tools/createProductVariationHandler.js +67 -0
- package/lib/mcp/tools/createProductVariationHandler.js.map +1 -0
- package/lib/mcp/tools/currenciesHandler.d.ts +60 -0
- package/lib/mcp/tools/currenciesHandler.d.ts.map +1 -0
- package/lib/mcp/tools/currenciesHandler.js +50 -0
- package/lib/mcp/tools/currenciesHandler.js.map +1 -0
- package/lib/mcp/tools/currencyHandler.d.ts +20 -0
- package/lib/mcp/tools/currencyHandler.d.ts.map +1 -0
- package/lib/mcp/tools/currencyHandler.js +34 -0
- package/lib/mcp/tools/currencyHandler.js.map +1 -0
- package/lib/mcp/tools/getProduct.d.ts +0 -3
- package/lib/mcp/tools/getProduct.d.ts.map +1 -1
- package/lib/mcp/tools/getProduct.js +0 -324
- package/lib/mcp/tools/getProduct.js.map +1 -1
- package/lib/mcp/tools/languageHandler.d.ts +20 -0
- package/lib/mcp/tools/languageHandler.d.ts.map +1 -0
- package/lib/mcp/tools/languageHandler.js +31 -0
- package/lib/mcp/tools/languageHandler.js.map +1 -0
- package/lib/mcp/tools/languagesHandler.d.ts +60 -0
- package/lib/mcp/tools/languagesHandler.d.ts.map +1 -0
- package/lib/mcp/tools/languagesHandler.js +42 -0
- package/lib/mcp/tools/languagesHandler.js.map +1 -0
- package/lib/mcp/tools/listProducts.d.ts.map +1 -1
- package/lib/mcp/tools/listProducts.js +0 -13
- package/lib/mcp/tools/listProducts.js.map +1 -1
- package/lib/mcp/tools/normalizeMediaUrl.d.ts +3 -0
- package/lib/mcp/tools/normalizeMediaUrl.d.ts.map +1 -0
- package/lib/mcp/tools/normalizeMediaUrl.js +21 -0
- package/lib/mcp/tools/normalizeMediaUrl.js.map +1 -0
- package/lib/mcp/tools/productsCountHandler.d.ts +32 -0
- package/lib/mcp/tools/productsCountHandler.d.ts.map +1 -0
- package/lib/mcp/tools/productsCountHandler.js +33 -0
- package/lib/mcp/tools/productsCountHandler.js.map +1 -0
- package/lib/mcp/tools/publishProduct.d.ts +20 -0
- package/lib/mcp/tools/publishProduct.d.ts.map +1 -0
- package/lib/mcp/tools/publishProduct.js +40 -0
- package/lib/mcp/tools/publishProduct.js.map +1 -0
- package/lib/mcp/tools/removeProduct.d.ts +20 -0
- package/lib/mcp/tools/removeProduct.d.ts.map +1 -0
- package/lib/mcp/tools/removeProduct.js +34 -0
- package/lib/mcp/tools/removeProduct.js.map +1 -0
- package/lib/mcp/tools/removeProductVariationHandler.d.ts +20 -0
- package/lib/mcp/tools/removeProductVariationHandler.d.ts.map +1 -0
- package/lib/mcp/tools/removeProductVariationHandler.js +43 -0
- package/lib/mcp/tools/removeProductVariationHandler.js.map +1 -0
- package/lib/mcp/tools/unPublishProduct.d.ts +20 -0
- package/lib/mcp/tools/unPublishProduct.d.ts.map +1 -0
- package/lib/mcp/tools/unPublishProduct.js +40 -0
- package/lib/mcp/tools/unPublishProduct.js.map +1 -0
- package/lib/mcp/tools/updateProduct.d.ts +56 -0
- package/lib/mcp/tools/updateProduct.d.ts.map +1 -0
- package/lib/mcp/tools/updateProduct.js +44 -0
- package/lib/mcp/tools/updateProduct.js.map +1 -0
- package/lib/mcp/tools/updateProductCommerceHandler.d.ts +166 -0
- package/lib/mcp/tools/updateProductCommerceHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductCommerceHandler.js +64 -0
- package/lib/mcp/tools/updateProductCommerceHandler.js.map +1 -0
- package/lib/mcp/tools/updateProductPlanHandler.d.ts +72 -0
- package/lib/mcp/tools/updateProductPlanHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductPlanHandler.js +51 -0
- package/lib/mcp/tools/updateProductPlanHandler.js.map +1 -0
- package/lib/mcp/tools/updateProductSupplyHandler.d.ts +64 -0
- package/lib/mcp/tools/updateProductSupplyHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductSupplyHandler.js +52 -0
- package/lib/mcp/tools/updateProductSupplyHandler.js.map +1 -0
- package/lib/mcp/tools/updateProductTextsHandler.d.ts +114 -0
- package/lib/mcp/tools/updateProductTextsHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductTextsHandler.js +50 -0
- package/lib/mcp/tools/updateProductTextsHandler.js.map +1 -0
- package/lib/mcp/tools/updateProductTokenizationHandler.d.ts +72 -0
- package/lib/mcp/tools/updateProductTokenizationHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductTokenizationHandler.js +49 -0
- package/lib/mcp/tools/updateProductTokenizationHandler.js.map +1 -0
- package/lib/mcp/tools/updateProductWarehousingHandler.d.ts +48 -0
- package/lib/mcp/tools/updateProductWarehousingHandler.d.ts.map +1 -0
- package/lib/mcp/tools/updateProductWarehousingHandler.js +45 -0
- package/lib/mcp/tools/updateProductWarehousingHandler.js.map +1 -0
- package/lib/mcp/utils/getNormalizedProductDetails.d.ts +26 -0
- package/lib/mcp/utils/getNormalizedProductDetails.d.ts.map +1 -0
- package/lib/mcp/utils/getNormalizedProductDetails.js +36 -0
- package/lib/mcp/utils/getNormalizedProductDetails.js.map +1 -0
- package/lib/mcp/utils/normalizeMediaUrl.d.ts +3 -0
- package/lib/mcp/utils/normalizeMediaUrl.d.ts.map +1 -0
- package/lib/mcp/utils/normalizeMediaUrl.js +21 -0
- package/lib/mcp/utils/normalizeMediaUrl.js.map +1 -0
- package/lib/resolvers/mutations/accounts/buildSecretTOTPAuthURL.d.ts +3 -0
- package/lib/resolvers/mutations/accounts/buildSecretTOTPAuthURL.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/buildSecretTOTPAuthURL.js +6 -0
- package/lib/resolvers/mutations/accounts/buildSecretTOTPAuthURL.js.map +1 -0
- package/lib/resolvers/mutations/accounts/disableTOTP.d.ts +6 -0
- package/lib/resolvers/mutations/accounts/disableTOTP.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/disableTOTP.js +27 -0
- package/lib/resolvers/mutations/accounts/disableTOTP.js.map +1 -0
- package/lib/resolvers/mutations/accounts/enableTOTP.d.ts +6 -0
- package/lib/resolvers/mutations/accounts/enableTOTP.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/enableTOTP.js +20 -0
- package/lib/resolvers/mutations/accounts/enableTOTP.js.map +1 -0
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.d.ts +7 -0
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.js +30 -0
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.js.map +1 -0
- package/lib/resolvers/mutations/accounts/loginWithOAuth.d.ts +8 -0
- package/lib/resolvers/mutations/accounts/loginWithOAuth.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/loginWithOAuth.js +25 -0
- package/lib/resolvers/mutations/accounts/loginWithOAuth.js.map +1 -0
- package/lib/resolvers/mutations/accounts/logoutAllSessions.d.ts +5 -0
- package/lib/resolvers/mutations/accounts/logoutAllSessions.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/logoutAllSessions.js +20 -0
- package/lib/resolvers/mutations/accounts/logoutAllSessions.js.map +1 -0
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.d.ts +6 -0
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.d.ts.map +1 -0
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.js +13 -0
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.js.map +1 -0
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.d.ts +6 -0
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.d.ts.map +1 -0
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.js +18 -0
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.js.map +1 -0
- package/lib/resolvers/mutations/products/addProductAssignment.d.ts.map +1 -1
- package/lib/resolvers/mutations/products/addProductAssignment.js +3 -1
- package/lib/resolvers/mutations/products/addProductAssignment.js.map +1 -1
- package/lib/resolvers/mutations/products/addProductMedia.d.ts +6 -0
- package/lib/resolvers/mutations/products/addProductMedia.d.ts.map +1 -0
- package/lib/resolvers/mutations/products/addProductMedia.js +18 -0
- package/lib/resolvers/mutations/products/addProductMedia.js.map +1 -0
- package/lib/resolvers/mutations/users/updateUserAvatar.d.ts +6 -0
- package/lib/resolvers/mutations/users/updateUserAvatar.d.ts.map +1 -0
- package/lib/resolvers/mutations/users/updateUserAvatar.js +22 -0
- package/lib/resolvers/mutations/users/updateUserAvatar.js.map +1 -0
- package/lib/resolvers/mutations/utils/getOrderCart.d.ts +7 -0
- package/lib/resolvers/mutations/utils/getOrderCart.d.ts.map +1 -0
- package/lib/resolvers/mutations/utils/getOrderCart.js +13 -0
- package/lib/resolvers/mutations/utils/getOrderCart.js.map +1 -0
- package/lib/resolvers/type/dispatch-types.d.ts +15 -0
- package/lib/resolvers/type/dispatch-types.d.ts.map +1 -0
- package/lib/resolvers/type/dispatch-types.js +16 -0
- package/lib/resolvers/type/dispatch-types.js.map +1 -0
- package/lib/resolvers/type/oauth-account.d.ts +6 -0
- package/lib/resolvers/type/oauth-account.d.ts.map +1 -0
- package/lib/resolvers/type/oauth-account.js +7 -0
- package/lib/resolvers/type/oauth-account.js.map +1 -0
- package/lib/resolvers/type/oauth-provider.d.ts +6 -0
- package/lib/resolvers/type/oauth-provider.d.ts.map +1 -0
- package/lib/resolvers/type/oauth-provider.js +6 -0
- package/lib/resolvers/type/oauth-provider.js.map +1 -0
- package/lib/resolvers/type/stock-types.d.ts +14 -0
- package/lib/resolvers/type/stock-types.d.ts.map +1 -0
- package/lib/resolvers/type/stock-types.js +15 -0
- package/lib/resolvers/type/stock-types.js.map +1 -0
- package/lib/user-context.d.ts +7 -0
- package/lib/user-context.d.ts.map +1 -0
- package/lib/user-context.js +76 -0
- package/lib/user-context.js.map +1 -0
- package/package.json +13 -13
- package/src/errors.ts +5 -0
- package/src/loaders/buildLocaleMap.test.ts +14 -25
- package/src/loaders/buildLocaleMap.ts +1 -1
- package/src/loaders/buildTextMap.test.ts +9 -10
- package/src/loaders/index.ts +0 -1
- package/src/resolvers/mutations/products/addProductAssignment.ts +8 -1
- package/lib/express/mcpHandler.d.ts.map +0 -1
- package/lib/express/mcpHandler.js +0 -68
- package/lib/express/mcpHandler.js.map +0 -1
- package/lib/fastify/createMCPMiddleware.d.ts +0 -2
- package/lib/fastify/createMCPMiddleware.d.ts.map +0 -1
- package/lib/fastify/createMCPMiddleware.js +0 -2
- package/lib/fastify/createMCPMiddleware.js.map +0 -1
- package/lib/fastify/index copy.d.ts.map +0 -1
- package/lib/fastify/index copy.js +0 -157
- package/lib/fastify/index copy.js.map +0 -1
- package/lib/fastify/mcpHandler.d.ts +0 -8
- package/lib/fastify/mcpHandler.d.ts.map +0 -1
- package/lib/fastify/mcpHandler.js +0 -46
- package/lib/fastify/mcpHandler.js.map +0 -1
- package/lib/mcp/server.d.ts +0 -4
- package/lib/mcp/server.d.ts.map +0 -1
- package/lib/mcp/server.js +0 -60
- package/lib/mcp/server.js.map +0 -1
- package/lib/mcp/types.d.ts +0 -27
- package/lib/mcp/types.d.ts.map +0 -1
- package/lib/mcp/types.js +0 -5
- package/lib/mcp/types.js.map +0 -1
- package/lib/mcp/utils/html.d.ts +0 -16
- package/lib/mcp/utils/html.d.ts.map +0 -1
- package/lib/mcp/utils/html.js +0 -102
- package/lib/mcp/utils/html.js.map +0 -1
- package/lib/middleware/accountLockout.d.ts.map +0 -1
- package/lib/middleware/accountLockout.js +0 -84
- package/lib/middleware/accountLockout.js.map +0 -1
- package/lib/middleware/rateLimiter.d.ts.map +0 -1
- package/lib/middleware/rateLimiter.js +0 -91
- package/lib/middleware/rateLimiter.js.map +0 -1
- package/lib/plugins/inputValidation.d.ts.map +0 -1
- package/lib/plugins/inputValidation.js +0 -95
- package/lib/plugins/inputValidation.js.map +0 -1
- package/lib/utils/inputValidation.d.ts.map +0 -1
- package/lib/utils/inputValidation.js +0 -51
- package/lib/utils/inputValidation.js.map +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
3
|
+
export const UpdateProductTextsSchema = {
|
|
4
|
+
productId: z.string().min(1).describe('ID of the product to update texts for'),
|
|
5
|
+
texts: z
|
|
6
|
+
.array(z.object({
|
|
7
|
+
locale: z
|
|
8
|
+
.string()
|
|
9
|
+
.min(2)
|
|
10
|
+
.describe('Locale code like "en", "de" always use locales registered in the system languages, if explicitly provided check if it exists'),
|
|
11
|
+
slug: z.string().optional().describe('URL slug'),
|
|
12
|
+
title: z.string().optional().describe('Product title'),
|
|
13
|
+
subtitle: z.string().optional().describe('Product subtitle'),
|
|
14
|
+
description: z.string().optional().describe('Markdown description'),
|
|
15
|
+
vendor: z.string().optional().describe('Vendor name'),
|
|
16
|
+
brand: z.string().optional().describe('Brand name'),
|
|
17
|
+
labels: z.array(z.string()).optional().describe('Labels or tags'),
|
|
18
|
+
}))
|
|
19
|
+
.nonempty()
|
|
20
|
+
.describe('Localized product text entries'),
|
|
21
|
+
};
|
|
22
|
+
export const UpdateProductTextsZodSchema = z.object(UpdateProductTextsSchema);
|
|
23
|
+
export async function updateProductTextsHandler(context, params) {
|
|
24
|
+
const { productId, texts } = params;
|
|
25
|
+
const { modules } = context;
|
|
26
|
+
try {
|
|
27
|
+
await modules.products.texts.updateTexts(productId, texts);
|
|
28
|
+
return {
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
type: 'text',
|
|
32
|
+
text: JSON.stringify({
|
|
33
|
+
product: await getNormalizedProductDetails(productId, context),
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return {
|
|
41
|
+
content: [
|
|
42
|
+
{
|
|
43
|
+
type: 'text',
|
|
44
|
+
text: `Error updating product texts: ${error.message}`,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=updateProductTextsHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateProductTextsHandler.js","sourceRoot":"","sources":["../../../src/mcp/tools/updateProductTextsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEtF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,uCAAuC,CAAC;IAC9E,KAAK,EAAE,CAAC;SACL,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;QACP,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CACP,8HAA8H,CAC/H;QACH,IAAI,EAAE,CAAC,CAAC,MAAM,EAA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CAAC,SAAS,EAAE,OAAO,CAAC;qBAC/D,CAAC;iBACH;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,iCAAkC,KAAe,CAAC,OAAO,EAAE;iBAClE;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
export declare const UpdateProductTokenizationSchema: {
|
|
4
|
+
productId: z.ZodString;
|
|
5
|
+
tokenization: z.ZodObject<{
|
|
6
|
+
contractAddress: z.ZodString;
|
|
7
|
+
contractStandard: z.ZodString;
|
|
8
|
+
tokenId: z.ZodString;
|
|
9
|
+
supply: z.ZodNumber;
|
|
10
|
+
ercMetadataProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
supply?: number;
|
|
13
|
+
contractAddress?: string;
|
|
14
|
+
tokenId?: string;
|
|
15
|
+
contractStandard?: string;
|
|
16
|
+
ercMetadataProperties?: Record<string, any>;
|
|
17
|
+
}, {
|
|
18
|
+
supply?: number;
|
|
19
|
+
contractAddress?: string;
|
|
20
|
+
tokenId?: string;
|
|
21
|
+
contractStandard?: string;
|
|
22
|
+
ercMetadataProperties?: Record<string, any>;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
export declare const UpdateProductTokenizationZodSchema: z.ZodObject<{
|
|
26
|
+
productId: z.ZodString;
|
|
27
|
+
tokenization: z.ZodObject<{
|
|
28
|
+
contractAddress: z.ZodString;
|
|
29
|
+
contractStandard: z.ZodString;
|
|
30
|
+
tokenId: z.ZodString;
|
|
31
|
+
supply: z.ZodNumber;
|
|
32
|
+
ercMetadataProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
supply?: number;
|
|
35
|
+
contractAddress?: string;
|
|
36
|
+
tokenId?: string;
|
|
37
|
+
contractStandard?: string;
|
|
38
|
+
ercMetadataProperties?: Record<string, any>;
|
|
39
|
+
}, {
|
|
40
|
+
supply?: number;
|
|
41
|
+
contractAddress?: string;
|
|
42
|
+
tokenId?: string;
|
|
43
|
+
contractStandard?: string;
|
|
44
|
+
ercMetadataProperties?: Record<string, any>;
|
|
45
|
+
}>;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
productId?: string;
|
|
48
|
+
tokenization?: {
|
|
49
|
+
supply?: number;
|
|
50
|
+
contractAddress?: string;
|
|
51
|
+
tokenId?: string;
|
|
52
|
+
contractStandard?: string;
|
|
53
|
+
ercMetadataProperties?: Record<string, any>;
|
|
54
|
+
};
|
|
55
|
+
}, {
|
|
56
|
+
productId?: string;
|
|
57
|
+
tokenization?: {
|
|
58
|
+
supply?: number;
|
|
59
|
+
contractAddress?: string;
|
|
60
|
+
tokenId?: string;
|
|
61
|
+
contractStandard?: string;
|
|
62
|
+
ercMetadataProperties?: Record<string, any>;
|
|
63
|
+
};
|
|
64
|
+
}>;
|
|
65
|
+
export type UpdateProductTokenizationParams = z.infer<typeof UpdateProductTokenizationZodSchema>;
|
|
66
|
+
export declare function updateProductTokenizationHandler(context: Context, params: UpdateProductTokenizationParams): Promise<{
|
|
67
|
+
content: {
|
|
68
|
+
type: "text";
|
|
69
|
+
text: string;
|
|
70
|
+
}[];
|
|
71
|
+
}>;
|
|
72
|
+
//# sourceMappingURL=updateProductTokenizationHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateProductTokenizationHandler.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/updateProductTokenizationHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAK3C,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;CAS3C,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA4C,CAAC;AAC5F,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAEjG,wBAAsB,gCAAgC,CACpD,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,+BAA+B;;;;;GAmCxC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductTypes } from '@unchainedshop/core-products';
|
|
3
|
+
import { ProductNotFoundError, ProductWrongStatusError } from '../../errors.js';
|
|
4
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
5
|
+
export const UpdateProductTokenizationSchema = {
|
|
6
|
+
productId: z.string().min(1).describe('ID of the product of type TOKENIZED_PRODUCT to tokenize only'),
|
|
7
|
+
tokenization: z.object({
|
|
8
|
+
contractAddress: z.string().min(1),
|
|
9
|
+
contractStandard: z.string(),
|
|
10
|
+
tokenId: z.string().min(1),
|
|
11
|
+
supply: z.number().int().positive(),
|
|
12
|
+
ercMetadataProperties: z.record(z.any()).optional(),
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
export const UpdateProductTokenizationZodSchema = z.object(UpdateProductTokenizationSchema);
|
|
16
|
+
export async function updateProductTokenizationHandler(context, params) {
|
|
17
|
+
const { productId, tokenization } = params;
|
|
18
|
+
const { modules } = context;
|
|
19
|
+
try {
|
|
20
|
+
const product = await modules.products.findProduct({ productId });
|
|
21
|
+
if (!product)
|
|
22
|
+
throw new ProductNotFoundError({ productId });
|
|
23
|
+
if (product?.type !== ProductTypes.TokenizedProduct)
|
|
24
|
+
throw new ProductWrongStatusError({
|
|
25
|
+
received: product?.type,
|
|
26
|
+
required: ProductTypes.TokenizedProduct,
|
|
27
|
+
});
|
|
28
|
+
await modules.products.update(productId, { tokenization });
|
|
29
|
+
return {
|
|
30
|
+
content: [
|
|
31
|
+
{
|
|
32
|
+
type: 'text',
|
|
33
|
+
text: JSON.stringify({ product: await getNormalizedProductDetails(productId, context) }),
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return {
|
|
40
|
+
content: [
|
|
41
|
+
{
|
|
42
|
+
type: 'text',
|
|
43
|
+
text: `Error updating product tokenization: ${error.message}`,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=updateProductTokenizationHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateProductTokenizationHandler.js","sourceRoot":"","sources":["../../../src/mcp/tools/updateProductTokenizationHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEtF,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,8DAA8D,CAAC;IACrG,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC;QACrB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAClC,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;QAC5B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1B,MAAM,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,IAAI,EAAE,wCAAyC,KAAe,CAAC,OAAO,EAAE;iBACzE;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Context } from '../../context.js';
|
|
3
|
+
export declare const UpdateProductWarehousingSchema: {
|
|
4
|
+
productId: z.ZodString;
|
|
5
|
+
warehousing: z.ZodObject<{
|
|
6
|
+
sku: z.ZodOptional<z.ZodString>;
|
|
7
|
+
baseUnit: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
sku?: string;
|
|
10
|
+
baseUnit?: string;
|
|
11
|
+
}, {
|
|
12
|
+
sku?: string;
|
|
13
|
+
baseUnit?: string;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
export declare const UpdateProductWarehousingZodSchema: z.ZodObject<{
|
|
17
|
+
productId: z.ZodString;
|
|
18
|
+
warehousing: z.ZodObject<{
|
|
19
|
+
sku: z.ZodOptional<z.ZodString>;
|
|
20
|
+
baseUnit: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
sku?: string;
|
|
23
|
+
baseUnit?: string;
|
|
24
|
+
}, {
|
|
25
|
+
sku?: string;
|
|
26
|
+
baseUnit?: string;
|
|
27
|
+
}>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
productId?: string;
|
|
30
|
+
warehousing?: {
|
|
31
|
+
sku?: string;
|
|
32
|
+
baseUnit?: string;
|
|
33
|
+
};
|
|
34
|
+
}, {
|
|
35
|
+
productId?: string;
|
|
36
|
+
warehousing?: {
|
|
37
|
+
sku?: string;
|
|
38
|
+
baseUnit?: string;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
export type UpdateProductWarehousingParams = z.infer<typeof UpdateProductWarehousingZodSchema>;
|
|
42
|
+
export declare function updateProductWarehousingHandler(context: Context, params: UpdateProductWarehousingParams): Promise<{
|
|
43
|
+
content: {
|
|
44
|
+
type: "text";
|
|
45
|
+
text: string;
|
|
46
|
+
}[];
|
|
47
|
+
}>;
|
|
48
|
+
//# sourceMappingURL=updateProductWarehousingHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateProductWarehousingHandler.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/updateProductWarehousingHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAK3C,eAAO,MAAM,8BAA8B;;;;;;;;;;;;CAM1C,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;EAA2C,CAAC;AAE1F,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAE/F,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,8BAA8B;;;;;GAiCvC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductWrongTypeError } from '../../errors.js';
|
|
3
|
+
import { ProductTypes } from '@unchainedshop/core-products';
|
|
4
|
+
import { getNormalizedProductDetails } from '../utils/getNormalizedProductDetails.js';
|
|
5
|
+
export const UpdateProductWarehousingSchema = {
|
|
6
|
+
productId: z.string().min(1).describe('ID of the SIMPLE_PRODUCT product type to update to be updated'),
|
|
7
|
+
warehousing: z.object({
|
|
8
|
+
sku: z.string().min(1).optional().describe('Stock keeping unit'),
|
|
9
|
+
baseUnit: z.string().min(1).optional().describe('Base unit of the product (e.g., "piece", "kg")'),
|
|
10
|
+
}),
|
|
11
|
+
};
|
|
12
|
+
export const UpdateProductWarehousingZodSchema = z.object(UpdateProductWarehousingSchema);
|
|
13
|
+
export async function updateProductWarehousingHandler(context, params) {
|
|
14
|
+
const { productId, warehousing } = params;
|
|
15
|
+
const { modules } = context;
|
|
16
|
+
try {
|
|
17
|
+
const product = await modules.products.findProduct({ productId });
|
|
18
|
+
if (product?.type !== ProductTypes.SimpleProduct)
|
|
19
|
+
throw new ProductWrongTypeError({
|
|
20
|
+
productId,
|
|
21
|
+
received: product.type,
|
|
22
|
+
required: ProductTypes.SimpleProduct,
|
|
23
|
+
});
|
|
24
|
+
await modules.products.update(productId, { warehousing });
|
|
25
|
+
return {
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: 'text',
|
|
29
|
+
text: JSON.stringify({ product: await getNormalizedProductDetails(productId, context) }),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return {
|
|
36
|
+
content: [
|
|
37
|
+
{
|
|
38
|
+
type: 'text',
|
|
39
|
+
text: `Error updating product warehousing: ${error.message}`,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=updateProductWarehousingHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateProductWarehousingHandler.js","sourceRoot":"","sources":["../../../src/mcp/tools/updateProductWarehousingHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEtF,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,+DAA+D,CAAC;IACtG,WAAW,EAAE,CAAC,CAAC,M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AAI,EAAE,MAAe;oBACrB,IAAI,EAAE,uCAAwC,KAAe,CAAC,OAAO,EAAE;iBACxE;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Context } from '../../context.js';
|
|
2
|
+
export declare function getNormalizedProductDetails(productId: string, context: Context): Promise<{
|
|
3
|
+
texts: import("@unchainedshop/core-products").ProductText;
|
|
4
|
+
media: any[];
|
|
5
|
+
variations: any[];
|
|
6
|
+
pricing: any;
|
|
7
|
+
_id?: string;
|
|
8
|
+
bundleItems: import("@unchainedshop/core-products").ProductBundleItem[];
|
|
9
|
+
commerce?: import("@unchainedshop/core-products").ProductCommerce;
|
|
10
|
+
meta?: any;
|
|
11
|
+
plan: import("@unchainedshop/core-products").ProductPlan;
|
|
12
|
+
proxy: import("@unchainedshop/core-products").ProductProxy;
|
|
13
|
+
published?: Date;
|
|
14
|
+
sequence: number;
|
|
15
|
+
slugs: string[];
|
|
16
|
+
status?: string;
|
|
17
|
+
supply: import("@unchainedshop/core-products").ProductSupply;
|
|
18
|
+
tags?: string[];
|
|
19
|
+
type: string;
|
|
20
|
+
warehousing?: import("@unchainedshop/core-products").ProductWarehousing;
|
|
21
|
+
tokenization?: import("@unchainedshop/core-products").ProductTokenization;
|
|
22
|
+
created?: Date;
|
|
23
|
+
updated?: Date;
|
|
24
|
+
deleted?: Date;
|
|
25
|
+
}>;
|
|
26
|
+
//# sourceMappingURL=getNormalizedProductDetails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNormalizedProductDetails.d.ts","sourceRoot":"","sources":["../../../src/mcp/utils/getNormalizedProductDetails.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,wBAAsB,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;GAoCpF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ProductTypes } from '@unchainedshop/core-products';
|
|
2
|
+
import normalizeMediaUrl from './normalizeMediaUrl.js';
|
|
3
|
+
export async function getNormalizedProductDetails(productId, context) {
|
|
4
|
+
const { modules, locale, loaders } = context;
|
|
5
|
+
const product = await modules.products.findProduct({ productId });
|
|
6
|
+
const texts = await loaders.productTextLoader.load({
|
|
7
|
+
productId,
|
|
8
|
+
locale,
|
|
9
|
+
});
|
|
10
|
+
let variations = [];
|
|
11
|
+
if (product.type === ProductTypes.ConfigurableProduct)
|
|
12
|
+
variations = await context.modules.products.variations.findProductVariations({
|
|
13
|
+
productId: product._id,
|
|
14
|
+
});
|
|
15
|
+
// Get pricing information
|
|
16
|
+
let pricing = null;
|
|
17
|
+
try {
|
|
18
|
+
pricing = await context.modules.products.prices.price(product, {
|
|
19
|
+
countryCode: context.countryCode,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// Pricing might not be available for all products
|
|
24
|
+
console.warn('Pricing not available for product:', product._id);
|
|
25
|
+
}
|
|
26
|
+
const productMedias = await modules.products.media.findProductMedias({ productId });
|
|
27
|
+
const media = await normalizeMediaUrl(productMedias, context);
|
|
28
|
+
return {
|
|
29
|
+
...product,
|
|
30
|
+
texts,
|
|
31
|
+
media,
|
|
32
|
+
variations,
|
|
33
|
+
pricing,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=getNormalizedProductDetails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNormalizedProductDetails.js","sourceRoot":"","sources":["../../../src/mcp/utils/getNormalizedProductDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAEvD,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,SAAiB,EAAE,OAAgB;IACnF,MAAM,EAA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izeMediaUrl.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,iBAAiB,GAAU,aAAW,EAAE,YAAO,mBAqBpD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getFileAdapter } from '@unchainedshop/core-files';
|
|
2
|
+
const normalizeMediaUrl = async (medias = [], context) => {
|
|
3
|
+
if (medias?.length) {
|
|
4
|
+
const normalizedMedias = await Promise.all(medias.map(async (media) => {
|
|
5
|
+
const file = await context.loaders.fileLoader.load({
|
|
6
|
+
fileId: media.mediaId,
|
|
7
|
+
});
|
|
8
|
+
const fileUploadAdapter = getFileAdapter();
|
|
9
|
+
const url = await fileUploadAdapter.createDownloadURL(file);
|
|
10
|
+
file.url = context.modules.files.normalizeUrl(url, {});
|
|
11
|
+
return {
|
|
12
|
+
...media,
|
|
13
|
+
file,
|
|
14
|
+
};
|
|
15
|
+
}));
|
|
16
|
+
return normalizedMedias.filter(Boolean);
|
|
17
|
+
}
|
|
18
|
+
return medias;
|
|
19
|
+
};
|
|
20
|
+
export default normalizeMediaUrl;
|
|
21
|
+
//# sourceMappingURL=normalizeMediaUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeMediaUrl.js","sourceRoot":"","sources":["../../../src/mcp/utils/normalizeMediaUrl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,MAAM,iBAAiB,GAAG,KAAK,EAAE,MAAM,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE;IACvD,IAAI,MAAM,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC,GAAG,CACxC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YACzB,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;gBACjD,MAAM,EAAE,KAAK,CAAC,OAAO;aACtB,CAAC,CAAC;YACH,MAAM,iBAAiB,GAAG,cAAc,EAAE,CAAC;YAC3C,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YAC5D,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAEvD,OAAO;gBACL,GAAG,KAAK;gBACR,IAAI;aACL,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;QAEF,OAAO,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSecretTOTPAuthURL.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/buildSecretTOTPAuthURL.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAE5D,wBAA8B,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,mBAI7F"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { log } from '@unchainedshop/logger';
|
|
2
|
+
export default async function buildTOTPSecret(root, _, { modules, userId }) {
|
|
3
|
+
log('mutation buildTOTPSecret', { userId });
|
|
4
|
+
return modules.accounts.buildTOTPSecret();
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=buildSecretTOTPAuthURL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSecretTOTPAuthURL.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/buildSecretTOTPAuthURL.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAG5C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,eAAe,CAAC,IAAU,EAAE,CAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAW;IAC5F,GAAG,CAAC,0BAA0B,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAE5C,OAAO,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Context, Root } from '@unchainedshop/types/api.js';
|
|
2
|
+
export default function disableTOTP(root: Root, params: {
|
|
3
|
+
code: string;
|
|
4
|
+
userId: string;
|
|
5
|
+
}, { modules, userId }: Context): Promise<import("@unchainedshop/types/user.js").User>;
|
|
6
|
+
//# sourceMappingURL=disableTOTP.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disableTOTP.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/disableTOTP.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAO5D,wBAA8B,WAAW,CACvC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACxC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,wDAwB7B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { log } from '@unchainedshop/logger';
|
|
2
|
+
import { TwoFactorCodeDidNotMatchError, TwoFactorNotSetError, UserNotFoundError, } from '../../../errors.js';
|
|
3
|
+
export default async function disableTOTP(root, params, { modules, userId }) {
|
|
4
|
+
const normalizedUserId = params.userId || userId;
|
|
5
|
+
log(`mutation disableTOTP ${params.code} ${normalizedUserId}`, {
|
|
6
|
+
userId,
|
|
7
|
+
});
|
|
8
|
+
const user = await modules.users.findUserById(normalizedUserId);
|
|
9
|
+
if (!user)
|
|
10
|
+
throw new UserNotFoundError({ userId: normalizedUserId });
|
|
11
|
+
try {
|
|
12
|
+
await modules.accounts.disableTOTP(normalizedUserId, params.code);
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
if (e?.message?.includes("2FA code didn't match"))
|
|
16
|
+
throw new TwoFactorCodeDidNotMatchError({
|
|
17
|
+
submittedCode: params.code,
|
|
18
|
+
userId: params?.userId || userId,
|
|
19
|
+
});
|
|
20
|
+
else if (e?.message?.includes('2FA not set'))
|
|
21
|
+
throw new TwoFactorNotSetError({ userId: params?.userId || userId });
|
|
22
|
+
else
|
|
23
|
+
throw e;
|
|
24
|
+
}
|
|
25
|
+
return user;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=disableTOTP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disableTOTP.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/disableTOTP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,WAAW,CACvC,IAAU,EACV,MAAwC,EACxC,EAAE,OAAO,EAAE,MAAM,EAAW;IAE5B,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC;IAEjD,GAAG,CAAC,wBAAwB,MAAM,CAAC,IAAI,IAAI,gBAAgB,EAAE,EAAE;QAC7D,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAChE,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,iBAAiB,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACrE,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACpE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,uBAAuB,CAAC;YAC/C,MAAM,IAAI,6BAA6B,CAAC;gBACtC,aAAa,EAAE,MAAM,CAAC,IAAI;gBAC1B,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,MAAM;aACjC,CAAC,CAAC;aACA,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC;YAC1C,MAAM,IAAI,oBAAoB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,MAAM,EAAE,CAAC,CAAC;;YAClE,MAAM,CAAC,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Context, Root } from '@unchainedshop/types/api.js';
|
|
2
|
+
export default function enableTOTP(root: Root, params: {
|
|
3
|
+
code: string;
|
|
4
|
+
secretBase32: string;
|
|
5
|
+
}, { modules, userId }: Context): Promise<import("@unchainedshop/types/user.js").User>;
|
|
6
|
+
//# sourceMappingURL=enableTOTP.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enableTOTP.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/enableTOTP.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAG5D,wBAA8B,UAAU,CACtC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAC9C,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,wDAe7B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { log } from '@unchainedshop/logger';
|
|
2
|
+
import { TwoFactorAlreadySetError, TwoFactorCodeDidNotMatchError } from '../../../errors.js';
|
|
3
|
+
export default async function enableTOTP(root, params, { modules, userId }) {
|
|
4
|
+
log(`mutation enableTOTP ${params.code}`, {
|
|
5
|
+
userId,
|
|
6
|
+
});
|
|
7
|
+
try {
|
|
8
|
+
await modules.accounts.enableTOTP(userId, params.secretBase32, params.code);
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
if (e?.message?.includes("2FA code didn't match"))
|
|
12
|
+
throw new TwoFactorCodeDidNotMatchError({ submittedCode: params.code, userId });
|
|
13
|
+
else if (e?.message?.includes('2FA already set'))
|
|
14
|
+
throw new TwoFactorAlreadySetError({ userId });
|
|
15
|
+
else
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
18
|
+
return modules.users.findUserById(userId);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=enableTOTP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enableTOTP.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/enableTOTP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAE7F,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,UAAU,CACtC,IAAU,EACV,MAA8C,EAC9C,EAAE,OAAO,EAAE,MAAM,EAAW;IAE5B,GAAG,CAAC,uBAAuB,MAAM,CAAC,IAAI,EAAE,EAAE;QACxC,MAAM;KACP,CAAC,CAAC;IACH,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC9E,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,uBAAuB,CAAC;YAC/C,MAAM,IAAI,6BAA6B,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;aAC7E,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC;YAAE,MAAM,IAAI,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;;YAC5F,MAAM,CAAC,CAAC;IACf,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Context, Root } from '@unchainedshop/types/api.js';
|
|
2
|
+
export default function linkOAuthAccount(root: Root, { provider, redirectUrl, authorizationCode, }: {
|
|
3
|
+
provider: string;
|
|
4
|
+
redirectUrl: string;
|
|
5
|
+
authorizationCode: string;
|
|
6
|
+
}, context: Context): Promise<boolean>;
|
|
7
|
+
//# sourceMappingURL=linkOAuthAccount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkOAuthAccount.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/linkOAuthAccount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAG5D,wBAA8B,gBAAgB,CAC5C,IAAI,EAAE,IAAI,EACV,EACE,QAAQ,EACR,WAAW,EACX,iBAAiB,GAClB,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,EACvE,OAAO,EAAE,OAAO,oBAuCjB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { log } from '@unchainedshop/logger';
|
|
2
|
+
import { AuthOperationFailedError } from '../../../errors.js';
|
|
3
|
+
export default async function linkOAuthAccount(root, { provider, redirectUrl, authorizationCode, }, context) {
|
|
4
|
+
const { userId, user } = context;
|
|
5
|
+
log(`mutation linkOAuthAccount ${user.username}`, {
|
|
6
|
+
userId,
|
|
7
|
+
});
|
|
8
|
+
try {
|
|
9
|
+
const { modules } = context;
|
|
10
|
+
const authorizationToken = await modules.accounts.oAuth2.getAuthorizationToken(provider, authorizationCode, redirectUrl);
|
|
11
|
+
if (!authorizationToken)
|
|
12
|
+
throw new Error('Unable to authorize user');
|
|
13
|
+
const { id, ...data } = await modules.accounts.oAuth2.getAccountData(provider, authorizationToken);
|
|
14
|
+
await modules.users.updateUser({ _id: userId }, {
|
|
15
|
+
$push: {
|
|
16
|
+
[`services.oauth.${provider}`]: {
|
|
17
|
+
id,
|
|
18
|
+
authorizationToken,
|
|
19
|
+
authorizationCode,
|
|
20
|
+
data,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
}, { upsert: true });
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
throw new AuthOperationFailedError({});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=linkOAuthAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkOAuthAccount.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/linkOAuthAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAC5C,IAAU,EACV,EACE,QAAQ,EACR,WAAW,EACX,iBAAiB,GACoD,EACvE,OAAgB;IAEhB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAEjC,GAAG,CAAC,6BAA6B,IAAI,CAAC,QAAQ,EAAE,EAAE;QAChD,MAAM;KACP,CAAC,CAAC;IACH,IAAI,CAAC;QACH,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAE5B,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAC5E,QAAQ,EACR,iBAAiB,EACjB,WAAW,CACZ,CAAC;QAEF,IAAI,CAAC,kBAAkB;YAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAErE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;QAEnG,MAAM,OAAO,CAAC,KAAK,CAAC,UAAU,CAC5B,EAAE,GAAG,EAAE,MAAM,EAAE,EACf;YACE,KAAK,EAAE;gBACL,CAAC,kBAAkB,QAAQ,EAAE,CAAC,EAAE;oBAC9B,EAAE;oBACF,kBAAkB;oBAClB,iBAAiB;oBACjB,IAAI;iBACL;aACF;SACF,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,wBAAwB,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Context } from '@unchainedshop/types/api.js';
|
|
2
|
+
declare const loginWithOAuth: (_: any, { provider, authorizationCode, redirectUrl, }: {
|
|
3
|
+
provider: string;
|
|
4
|
+
authorizationCode: string;
|
|
5
|
+
redirectUrl: string;
|
|
6
|
+
}, context: Context) => Promise<any | null>;
|
|
7
|
+
export default loginWithOAuth;
|
|
8
|
+
//# sourceMappingURL=loginWithOAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loginWithOAuth.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/loginWithOAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAStD,QAAA,MAAM,cAAc,0DAMf;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,WAC9D,OAAO,KACf,OAAO,CAAC,GAAG,GAAG,IAAI,CAkBpB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { log } from '@unchainedshop/logger';
|
|
2
|
+
import { AuthOperationFailedError, EmailAlreadyExistsError, UsernameAlreadyExistsError, UsernameOrEmailRequiredError, } from '../../../errors.js';
|
|
3
|
+
const loginWithOAuth = async (_, { provider, authorizationCode, redirectUrl, }, context) => {
|
|
4
|
+
log(`mutation loginWithOAuth ${provider} ${authorizationCode}`);
|
|
5
|
+
try {
|
|
6
|
+
return context.modules.accounts.loginWithService({
|
|
7
|
+
service: 'oauth2',
|
|
8
|
+
authorizationCode,
|
|
9
|
+
provider,
|
|
10
|
+
redirectUrl,
|
|
11
|
+
}, context);
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
if (e.code === 'EmailAlreadyExists')
|
|
15
|
+
throw new EmailAlreadyExistsError({});
|
|
16
|
+
else if (e.code === 'UsernameAlreadyExists')
|
|
17
|
+
throw new UsernameAlreadyExistsError({});
|
|
18
|
+
else if (e.code === 'UsernameOrEmailRequired')
|
|
19
|
+
throw new UsernameOrEmailRequiredError({});
|
|
20
|
+
else
|
|
21
|
+
throw new AuthOperationFailedError({});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export default loginWithOAuth;
|
|
25
|
+
//# sourceMappingURL=loginWithOAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loginWithOAuth.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/loginWithOAuth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAA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,0 +1,20 @@
|
|
|
1
|
+
import { log, LogLevel } from '@unchainedshop/logger';
|
|
2
|
+
export default async function logoutAllSessions(root, _, context) {
|
|
3
|
+
const { modules, userId, setLoginToken } = context;
|
|
4
|
+
log('mutation logoutAllSessions', { userId });
|
|
5
|
+
const loggedOut = await modules.accounts.logout({
|
|
6
|
+
loginToken: context.loginToken,
|
|
7
|
+
userId: context.userId,
|
|
8
|
+
}, context);
|
|
9
|
+
if (loggedOut.error) {
|
|
10
|
+
log('Error while logging out', {
|
|
11
|
+
logLevel: LogLevel.Error,
|
|
12
|
+
...loggedOut.error,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
setLoginToken(context.res, null);
|
|
17
|
+
}
|
|
18
|
+
return { success: loggedOut.success };
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=logoutAllSessions.js.map
|