@unchainedshop/api 4.4.0 → 4.5.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/lib/api-index.js +3 -0
- package/lib/context.js +2 -13
- package/lib/errors.d.ts +1 -0
- package/lib/errors.js +2 -1
- package/lib/events.js +0 -2
- package/lib/fastify/index.js +9 -3
- package/lib/loaders/assortmentMediaTextLoader.js +1 -1
- package/lib/loaders/assortmentMediasLoader.js +1 -1
- package/lib/loaders/assortmentTextLoader.js +1 -1
- package/lib/loaders/countryLoader.js +1 -1
- package/lib/loaders/currencyLoader.js +1 -1
- package/lib/loaders/deliveryProviderLoader.js +1 -1
- package/lib/loaders/fileLoader.js +1 -1
- package/lib/loaders/filterTextLoader.js +1 -1
- package/lib/loaders/languageLoader.js +1 -1
- package/lib/loaders/orderLoader.js +1 -1
- package/lib/loaders/paymentProviderLoader.js +1 -1
- package/lib/loaders/productBySKULoader.js +2 -4
- package/lib/loaders/productLoader.js +1 -3
- package/lib/loaders/productMediaTextLoader.js +1 -1
- package/lib/loaders/productMediasLoader.js +1 -1
- package/lib/loaders/productProxiesLoader.js +2 -10
- package/lib/loaders/productTextLoader.js +1 -1
- package/lib/loaders/productVariationByKeyLoader.js +1 -1
- package/lib/loaders/productVariationLoader.js +1 -1
- package/lib/loaders/productVariationTextLoader.js +1 -1
- package/lib/loaders/quotationLoader.js +1 -1
- package/lib/loaders/userLoader.js +1 -1
- package/lib/loaders/warehousingProviderLoader.js +1 -1
- package/lib/mcp/tools/order/handlers/getTopCustomers.d.ts +5 -5
- package/lib/mcp/tools/order/handlers/getTopCustomers.js +4 -54
- package/lib/mcp/tools/order/handlers/getTopProducts.d.ts +3 -3
- package/lib/mcp/tools/order/handlers/getTopProducts.js +3 -42
- package/lib/mcp/tools/provider/handlers/listProviders.js +4 -8
- package/lib/resolvers/mutations/accounts/addWeb3Address.d.ts +2 -2
- package/lib/resolvers/mutations/accounts/addWeb3Address.js +1 -14
- package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.d.ts +2 -2
- package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.js +2 -6
- package/lib/resolvers/mutations/accounts/createUser.js +3 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.d.ts +1 -4
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.d.ts +1 -4
- package/lib/resolvers/mutations/accounts/loginAsGuest.js +1 -3
- package/lib/resolvers/mutations/accounts/removeWeb3Address.d.ts +1 -1
- package/lib/resolvers/mutations/accounts/removeWeb3Address.js +3 -7
- package/lib/resolvers/mutations/accounts/removeWebAuthnCredentials.d.ts +1 -1
- package/lib/resolvers/mutations/accounts/removeWebAuthnCredentials.js +1 -5
- package/lib/resolvers/mutations/accounts/verifyWeb3Address.d.ts +2 -2
- package/lib/resolvers/mutations/accounts/verifyWeb3Address.js +8 -89
- package/lib/resolvers/mutations/filters/removeFilter.d.ts +2 -2
- package/lib/resolvers/mutations/filters/removeFilter.js +3 -5
- package/lib/resolvers/mutations/orders/addMultipleCartProducts.js +23 -31
- package/lib/resolvers/mutations/orders/removeCartDiscount.d.ts +2 -2
- package/lib/resolvers/mutations/orders/removeCartDiscount.js +9 -14
- package/lib/resolvers/mutations/orders/updateCart.js +2 -8
- package/lib/resolvers/mutations/users/removeUser.js +1 -1
- package/lib/resolvers/mutations/warehousing/exportToken.js +9 -17
- package/lib/resolvers/queries/payment/paymentProvidersCount.d.ts +3 -3
- package/lib/resolvers/queries/payment/paymentProvidersCount.js +1 -1
- package/lib/resolvers/queries/shopInfo.js +4 -36
- package/lib/resolvers/type/delivery-provider-interface.d.ts +1 -7
- package/lib/resolvers/type/delivery-provider-interface.js +10 -20
- package/lib/resolvers/type/delivery-provider-pickup-types.d.ts +1 -7
- package/lib/resolvers/type/delivery-provider-shipping-types.d.ts +1 -7
- package/lib/resolvers/type/delivery-provider-types.d.ts +1 -7
- package/lib/resolvers/type/index.d.ts +33 -54
- package/lib/resolvers/type/media-types.d.ts +1 -1
- package/lib/resolvers/type/media-types.js +7 -5
- package/lib/resolvers/type/order/order-item-types.d.ts +2 -9
- package/lib/resolvers/type/order/order-item-types.js +2 -37
- package/lib/resolvers/type/order/order-statistics-types.d.ts +10 -10
- package/lib/resolvers/type/order/order-statistics-types.js +10 -64
- package/lib/resolvers/type/payment/payment-provider-types.d.ts +1 -7
- package/lib/resolvers/type/payment/payment-provider-types.js +7 -17
- package/lib/resolvers/type/price-types.d.ts +0 -1
- package/lib/resolvers/type/product/product-bundle-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-configurable-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-configurable-types.js +9 -32
- package/lib/resolvers/type/product/product-plan-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-simple-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-tokenized-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-types.js +7 -17
- package/lib/resolvers/type/shop-types.js +2 -5
- package/lib/resolvers/type/token-types.d.ts +3 -3
- package/lib/resolvers/type/token-types.js +4 -25
- package/lib/resolvers/type/user-types.js +1 -4
- package/lib/resolvers/type/webauthn-credentials-types.d.ts +10 -1
- package/lib/roles/index.d.ts +2 -1
- package/lib/roles/index.js +7 -1
- package/lib/utils/getConfiguredTags.d.ts +1 -0
- package/lib/utils/getConfiguredTags.js +9 -0
- package/package.json +7 -17
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { checkAction } from "../../acl.js";
|
|
2
|
-
import {
|
|
2
|
+
import { actions, getPublicRoles } from "../../roles/index.js";
|
|
3
3
|
export const Shop = {
|
|
4
4
|
_id() {
|
|
5
5
|
return 'root';
|
|
@@ -12,9 +12,6 @@ export const Shop = {
|
|
|
12
12
|
},
|
|
13
13
|
userRoles: async (_root, _params, context) => {
|
|
14
14
|
await checkAction(context, actions.manageUsers);
|
|
15
|
-
return
|
|
16
|
-
.map((i) => i?.name)
|
|
17
|
-
.filter(Boolean)
|
|
18
|
-
.filter((name) => name.substring(0, 2) !== '__');
|
|
15
|
+
return getPublicRoles();
|
|
19
16
|
},
|
|
20
17
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Context } from '../../context.ts';
|
|
2
|
-
import {
|
|
2
|
+
import type { TokenSurrogate } from '@unchainedshop/core-warehousing';
|
|
3
3
|
export declare const Token: {
|
|
4
4
|
product: (token: TokenSurrogate, params: never, { loaders }: Context) => Promise<import("@unchainedshop/core-products").Product>;
|
|
5
5
|
user: (token: TokenSurrogate, params: never, { loaders }: Context) => Promise<import("@unchainedshop/core-users").User | null>;
|
|
6
|
-
status: (token: TokenSurrogate, params: never, {
|
|
6
|
+
status: (token: TokenSurrogate, params: never, { services }: Context) => Promise<import("@unchainedshop/core-warehousing").TokenStatus>;
|
|
7
7
|
ercMetadata: (token: TokenSurrogate, { forceLocale }: {
|
|
8
8
|
forceLocale: string;
|
|
9
9
|
}, context: Context) => Promise<any>;
|
|
10
|
-
isInvalidateable: (token: TokenSurrogate, _params: never,
|
|
10
|
+
isInvalidateable: (token: TokenSurrogate, _params: never, { services }: Context) => Promise<boolean>;
|
|
11
11
|
accessKey: (token: TokenSurrogate, params: never, requestContext: Context) => Promise<string | null>;
|
|
12
12
|
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { TokenStatus, WarehousingProviderType, } from '@unchainedshop/core-warehousing';
|
|
2
|
-
import { WorkStatus } from '@unchainedshop/core-worker';
|
|
3
1
|
import { checkAction } from "../../acl.js";
|
|
4
2
|
import { actions } from "../../roles/index.js";
|
|
5
|
-
import { WarehousingDirector } from '@unchainedshop/core';
|
|
6
3
|
export const Token = {
|
|
7
4
|
product: async (token, params, { loaders }) => {
|
|
8
5
|
return loaders.productLoader.load({ productId: token.productId });
|
|
@@ -12,17 +9,8 @@ export const Token = {
|
|
|
12
9
|
return null;
|
|
13
10
|
return loaders.userLoader.load({ userId: token.userId });
|
|
14
11
|
},
|
|
15
|
-
status: async (token, params, {
|
|
16
|
-
|
|
17
|
-
return TokenStatus.DECENTRALIZED;
|
|
18
|
-
}
|
|
19
|
-
const workItems = await modules.worker.findWorkQueue({
|
|
20
|
-
types: ['EXPORT_TOKEN'],
|
|
21
|
-
status: [WorkStatus.NEW, WorkStatus.ALLOCATED],
|
|
22
|
-
});
|
|
23
|
-
if (workItems.find((item) => item.input?.token?._id === token._id))
|
|
24
|
-
return TokenStatus.EXPORTING;
|
|
25
|
-
return TokenStatus.CENTRALIZED;
|
|
12
|
+
status: async (token, params, { services }) => {
|
|
13
|
+
return services.warehousing.resolveTokenStatus({ token });
|
|
26
14
|
},
|
|
27
15
|
ercMetadata: async (token, { forceLocale }, context) => {
|
|
28
16
|
const { loaders, services } = context;
|
|
@@ -33,17 +21,8 @@ export const Token = {
|
|
|
33
21
|
locale: forceLocale ? new Intl.Locale(forceLocale) : context.locale,
|
|
34
22
|
});
|
|
35
23
|
},
|
|
36
|
-
isInvalidateable: async (token, _params,
|
|
37
|
-
|
|
38
|
-
const product = await loaders.productLoader.load({ productId: token.productId });
|
|
39
|
-
const virtualProviders = (await context.modules.warehousing.allProviders()).filter(({ type }) => type === WarehousingProviderType.VIRTUAL);
|
|
40
|
-
const isInvalidateable = await WarehousingDirector.isInvalidateable(virtualProviders, {
|
|
41
|
-
token,
|
|
42
|
-
product,
|
|
43
|
-
quantity: token?.quantity || 1,
|
|
44
|
-
referenceDate: new Date(),
|
|
45
|
-
}, context);
|
|
46
|
-
return !!isInvalidateable;
|
|
24
|
+
isInvalidateable: async (token, _params, { services }) => {
|
|
25
|
+
return services.warehousing.isTokenInvalidateable({ token });
|
|
47
26
|
},
|
|
48
27
|
accessKey: async (token, params, requestContext) => {
|
|
49
28
|
const { modules } = requestContext;
|
|
@@ -2,9 +2,6 @@ import { Roles, permissions } from '@unchainedshop/roles';
|
|
|
2
2
|
import { checkAction, checkTypeResolver } from "../../acl.js";
|
|
3
3
|
import { actions } from "../../roles/index.js";
|
|
4
4
|
const { viewUserPrivateInfos, viewUserPublicInfos, viewUserOrders, viewUserEnrollments, viewUserQuotations, viewUserProductReviews, } = actions;
|
|
5
|
-
const getPrimaryEmail = (user) => {
|
|
6
|
-
return (user.emails || []).toSorted((left, right) => Number(right.verified) - Number(left.verified))?.[0];
|
|
7
|
-
};
|
|
8
5
|
export const User = {
|
|
9
6
|
_id: checkTypeResolver(viewUserPublicInfos, '_id'),
|
|
10
7
|
created: checkTypeResolver(viewUserPrivateInfos, 'created'),
|
|
@@ -27,7 +24,7 @@ export const User = {
|
|
|
27
24
|
},
|
|
28
25
|
primaryEmail: async (user, params, context) => {
|
|
29
26
|
await checkAction(context, viewUserPrivateInfos, [user, params]);
|
|
30
|
-
return
|
|
27
|
+
return context.modules.users.primaryEmail(user);
|
|
31
28
|
},
|
|
32
29
|
isInitialPassword: async (user, params, context) => {
|
|
33
30
|
await checkAction(context, viewUserPrivateInfos, [user, params]);
|
|
@@ -23,5 +23,14 @@ export declare const WebAuthnCredentials: {
|
|
|
23
23
|
aaguid: string;
|
|
24
24
|
counter: number;
|
|
25
25
|
mdsMetadata: any;
|
|
26
|
-
}, _: never, { modules }: Context): Promise<
|
|
26
|
+
}, _: never, { modules }: Context): Promise<{
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
description?: string;
|
|
29
|
+
icon?: string;
|
|
30
|
+
authenticatorGetInfo?: {
|
|
31
|
+
versions?: string[];
|
|
32
|
+
extensions?: string[];
|
|
33
|
+
options?: Record<string, boolean>;
|
|
34
|
+
};
|
|
35
|
+
} | null>;
|
|
27
36
|
};
|
package/lib/roles/index.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ declare const configureRoles: ({ additionalRoles, additionalActions, }: {
|
|
|
12
12
|
LOGGEDIN: import("@unchainedshop/roles").RoleInterface | undefined;
|
|
13
13
|
ALL: import("@unchainedshop/roles").RoleInterface | undefined;
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
declare const getPublicRoles: () => string[];
|
|
16
|
+
export { allRoles, actions, configureRoles, getPublicRoles };
|
package/lib/roles/index.js
CHANGED
|
@@ -137,4 +137,10 @@ const configureRoles = ({ additionalRoles, additionalActions, }) => {
|
|
|
137
137
|
admin(allRoles.ADMIN, actions);
|
|
138
138
|
return allRoles;
|
|
139
139
|
};
|
|
140
|
-
|
|
140
|
+
const getPublicRoles = () => {
|
|
141
|
+
return Object.values(allRoles)
|
|
142
|
+
.map((role) => role?.name)
|
|
143
|
+
.filter(Boolean)
|
|
144
|
+
.filter((name) => !name.startsWith('__'));
|
|
145
|
+
};
|
|
146
|
+
export { allRoles, actions, configureRoles, getPublicRoles };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getConfiguredTags(existingTagsFn: () => Promise<string[]>, envVar: string, configDefault: string[] | undefined): Promise<string[]>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export async function getConfiguredTags(existingTagsFn, envVar, configDefault) {
|
|
2
|
+
const existingTags = await existingTagsFn();
|
|
3
|
+
const envTags = (process.env[envVar] || '')
|
|
4
|
+
.split(',')
|
|
5
|
+
.map((t) => t.trim())
|
|
6
|
+
.filter(Boolean);
|
|
7
|
+
const normalizedDefaultTags = envTags?.length ? envTags : (configDefault || []).filter(Boolean);
|
|
8
|
+
return Array.from(new Set(normalizedDefaultTags.concat(existingTags)));
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/api",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"main": "lib/api-index.js",
|
|
5
5
|
"types": "lib/api-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
9
10
|
"import": "./lib/api-index.js",
|
|
@@ -64,8 +65,6 @@
|
|
|
64
65
|
"@fastify/session": ">= 11 < 12",
|
|
65
66
|
"@fastify/static": ">= 8 < 9",
|
|
66
67
|
"@modelcontextprotocol/sdk": ">= 1 < 2",
|
|
67
|
-
"@noble/curves": "^2.0.0",
|
|
68
|
-
"@noble/hashes": "^2.0.0",
|
|
69
68
|
"ai": ">= 5 < 6",
|
|
70
69
|
"express": ">= 5 < 6",
|
|
71
70
|
"express-session": ">= 1.18 < 2",
|
|
@@ -113,25 +112,18 @@
|
|
|
113
112
|
},
|
|
114
113
|
"passport": {
|
|
115
114
|
"optional": true
|
|
116
|
-
},
|
|
117
|
-
"@noble/curves": {
|
|
118
|
-
"optional": true
|
|
119
|
-
},
|
|
120
|
-
"@noble/hashes": {
|
|
121
|
-
"optional": true
|
|
122
115
|
}
|
|
123
116
|
},
|
|
124
117
|
"dependencies": {
|
|
125
|
-
"@unchainedshop/core": "^4.
|
|
126
|
-
"@unchainedshop/events": "^4.
|
|
127
|
-
"@unchainedshop/logger": "^4.
|
|
128
|
-
"@unchainedshop/roles": "^4.
|
|
129
|
-
"@unchainedshop/utils": "^4.
|
|
118
|
+
"@unchainedshop/core": "^4.5.0",
|
|
119
|
+
"@unchainedshop/events": "^4.5.0",
|
|
120
|
+
"@unchainedshop/logger": "^4.5.0",
|
|
121
|
+
"@unchainedshop/roles": "^4.5.0",
|
|
122
|
+
"@unchainedshop/utils": "^4.5.0",
|
|
130
123
|
"dataloader": "^2.2.3",
|
|
131
124
|
"expiry-map": "^2.0.0",
|
|
132
125
|
"graphql-scalars": "^1.24.2",
|
|
133
126
|
"mime": ">= 4 < 5",
|
|
134
|
-
"moniker": "0.1.2",
|
|
135
127
|
"p-memoize": "^8.0.0",
|
|
136
128
|
"zod": "^3.25.76 || ^4"
|
|
137
129
|
},
|
|
@@ -142,8 +134,6 @@
|
|
|
142
134
|
"@fastify/session": "^11.1.0",
|
|
143
135
|
"@fastify/static": "^8.2.0",
|
|
144
136
|
"@modelcontextprotocol/sdk": "^1.15.1",
|
|
145
|
-
"@noble/curves": "^2.0.0",
|
|
146
|
-
"@noble/hashes": "^2.0.0",
|
|
147
137
|
"@types/express": "^5.0.3",
|
|
148
138
|
"@types/express-session": "^1.18.2",
|
|
149
139
|
"@types/node": "^25.0.0",
|