@unchainedshop/api 4.8.12 → 5.0.0-alpha.2

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.
Files changed (111) hide show
  1. package/lib/acl.d.ts +2 -2
  2. package/lib/acl.js +36 -8
  3. package/lib/api-index.d.ts +3 -1
  4. package/lib/chat/generateImageHandler.js +6 -5
  5. package/lib/context.d.ts +3 -1
  6. package/lib/context.js +9 -4
  7. package/lib/events.d.ts +2 -0
  8. package/lib/events.js +2 -0
  9. package/lib/express/createMCPMiddleware.js +1 -1
  10. package/lib/express/index.d.ts +6 -9
  11. package/lib/express/index.js +53 -126
  12. package/lib/fastify/index.d.ts +6 -9
  13. package/lib/fastify/index.js +52 -118
  14. package/lib/fastify/mcpHandler.js +1 -1
  15. package/lib/loaders/buildTextMap.js +6 -3
  16. package/lib/loaders/index.d.ts +0 -25
  17. package/lib/loaders/index.js +0 -10
  18. package/lib/locale-context.d.ts +4 -2
  19. package/lib/locale-context.js +2 -6
  20. package/lib/mcp/tools/assortment/assortmentManagement.d.ts +2 -2
  21. package/lib/mcp/tools/assortment/assortmentManagement.js +2 -2
  22. package/lib/mcp/tools/assortment/schemas.d.ts +322 -141
  23. package/lib/mcp/tools/assortment/schemas.js +179 -96
  24. package/lib/mcp/tools/filter/filterManagement.d.ts +2 -2
  25. package/lib/mcp/tools/filter/filterManagement.js +2 -2
  26. package/lib/mcp/tools/filter/schemas.d.ts +184 -75
  27. package/lib/mcp/tools/filter/schemas.js +87 -51
  28. package/lib/mcp/tools/localization/getLocalizationsConfig.d.ts +1 -1
  29. package/lib/mcp/tools/localization/localizationManagement.d.ts +2 -2
  30. package/lib/mcp/tools/localization/localizationManagement.js +2 -2
  31. package/lib/mcp/tools/localization/schemas.d.ts +144 -47
  32. package/lib/mcp/tools/localization/schemas.js +51 -36
  33. package/lib/mcp/tools/order/handlers/getTopCustomers.d.ts +2 -0
  34. package/lib/mcp/tools/order/orderManagement.d.ts +2 -2
  35. package/lib/mcp/tools/order/orderManagement.js +2 -2
  36. package/lib/mcp/tools/order/schemas.d.ts +184 -75
  37. package/lib/mcp/tools/order/schemas.js +113 -51
  38. package/lib/mcp/tools/product/productManagement.d.ts +2 -2
  39. package/lib/mcp/tools/product/productManagement.js +2 -2
  40. package/lib/mcp/tools/product/schemas.d.ts +642 -317
  41. package/lib/mcp/tools/product/schemas.js +287 -191
  42. package/lib/mcp/tools/provider/providerManagement.d.ts +2 -2
  43. package/lib/mcp/tools/provider/providerManagement.js +2 -2
  44. package/lib/mcp/tools/provider/schemas.d.ts +142 -47
  45. package/lib/mcp/tools/provider/schemas.js +67 -32
  46. package/lib/mcp/tools/quotation/handlers/getQuotation.d.ts +2 -0
  47. package/lib/mcp/tools/quotation/handlers/listQuotations.d.ts +2 -0
  48. package/lib/mcp/tools/quotation/handlers/makeQuotationProposal.d.ts +2 -0
  49. package/lib/mcp/tools/quotation/handlers/rejectQuotation.d.ts +2 -0
  50. package/lib/mcp/tools/quotation/handlers/verifyQuotation.d.ts +2 -0
  51. package/lib/mcp/tools/quotation/quotationManagement.d.ts +2 -2
  52. package/lib/mcp/tools/quotation/quotationManagement.js +2 -2
  53. package/lib/mcp/tools/quotation/schemas.d.ts +111 -40
  54. package/lib/mcp/tools/quotation/schemas.js +54 -29
  55. package/lib/mcp/tools/system/handlers/countEvents.d.ts +8 -1
  56. package/lib/mcp/tools/system/handlers/countWork.d.ts +10 -1
  57. package/lib/mcp/tools/system/handlers/countWork.js +1 -0
  58. package/lib/mcp/tools/system/handlers/index.d.ts +4 -4
  59. package/lib/mcp/tools/system/handlers/listEvents.d.ts +12 -1
  60. package/lib/mcp/tools/system/handlers/listWork.d.ts +14 -1
  61. package/lib/mcp/tools/system/handlers/listWork.js +1 -0
  62. package/lib/mcp/tools/system/schemas.d.ts +179 -84
  63. package/lib/mcp/tools/system/schemas.js +188 -67
  64. package/lib/mcp/tools/system/systemManagement.d.ts +1 -1
  65. package/lib/mcp/tools/system/systemManagement.js +1 -1
  66. package/lib/mcp/tools/users/handlers/addUserEmail.d.ts +2 -0
  67. package/lib/mcp/tools/users/handlers/createUser.d.ts +2 -0
  68. package/lib/mcp/tools/users/handlers/enrollUser.d.ts +2 -0
  69. package/lib/mcp/tools/users/handlers/getCurrentUser.d.ts +2 -0
  70. package/lib/mcp/tools/users/handlers/getUser.d.ts +2 -0
  71. package/lib/mcp/tools/users/handlers/listUsers.d.ts +2 -0
  72. package/lib/mcp/tools/users/handlers/setUserTags.d.ts +2 -0
  73. package/lib/mcp/tools/users/handlers/setUserUsername.d.ts +2 -0
  74. package/lib/mcp/tools/users/handlers/updateUser.d.ts +2 -0
  75. package/lib/mcp/tools/users/schemas.d.ts +296 -163
  76. package/lib/mcp/tools/users/schemas.js +152 -71
  77. package/lib/mcp/tools/users/usersManagement.d.ts +2 -2
  78. package/lib/mcp/tools/users/usersManagement.js +2 -2
  79. package/lib/mcp/utils/getNormalizedQuotationDetails.d.ts +2 -0
  80. package/lib/mcp/utils/getNormalizedUserDetails.d.ts +2 -0
  81. package/lib/mcp/utils/normalizeMediaUrl.js +1 -1
  82. package/lib/mcp/utils/sanitizeLocalizationEntityData.d.ts +1 -1
  83. package/lib/mcp/utils/sharedSchemas.d.ts +28 -39
  84. package/lib/mcp/utils/sharedSchemas.js +28 -47
  85. package/lib/mcp/utils/validateIsoCode.d.ts +1 -1
  86. package/lib/middleware/createAuthMiddleware.js +1 -3
  87. package/lib/resolvers/mutations/accounts/changePassword.js +1 -2
  88. package/lib/resolvers/mutations/index.d.ts +150 -155
  89. package/lib/resolvers/mutations/index.js +2 -12
  90. package/lib/resolvers/mutations/orders/updateCart.js +7 -1
  91. package/lib/resolvers/mutations/users/setRoles.d.ts +1 -1
  92. package/lib/resolvers/mutations/users/setRoles.js +6 -4
  93. package/lib/resolvers/queries/events/registeredEventTypes.d.ts +1 -1
  94. package/lib/resolvers/queries/events/registeredEventTypes.js +1 -1
  95. package/lib/resolvers/queries/index.d.ts +71 -71
  96. package/lib/resolvers/queries/index.js +1 -1
  97. package/lib/resolvers/type/index.d.ts +5 -6
  98. package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +0 -1
  99. package/lib/resolvers/type/order/order-delivery-pickup-types.js +0 -7
  100. package/lib/resolvers/type/order/order-types.d.ts +5 -5
  101. package/lib/resolvers/type/order/order-types.js +27 -12
  102. package/lib/resolvers/type/shop-types.js +1 -1
  103. package/lib/resolvers/type/user-types.js +3 -3
  104. package/lib/roles/index.d.ts +4 -11
  105. package/lib/roles/index.js +16 -11
  106. package/lib/roles/loggedIn.js +2 -1
  107. package/lib/schema/mutation.js +6 -44
  108. package/lib/schema/query.js +5 -5
  109. package/lib/schema/types/index.js +2 -2
  110. package/lib/schema/types/order/delivery.js +0 -2
  111. package/package.json +14 -24
@@ -1,139 +1,220 @@
1
- import { z } from 'zod/v4-mini';
2
- import { PaginationSchema, SortingSchema, SearchSchema, createManagementSchemaFromValidators, } from "../../utils/sharedSchemas.js";
1
+ import { z } from 'zod';
2
+ import { PaginationSchema, SortingSchema, SearchSchema, DateRangeSchema, } from "../../utils/sharedSchemas.js";
3
3
  export const UserProfileSchema = z.object({
4
- displayName: z.optional(z.string()).check(z.describe("User's display name shown in the interface")),
5
- birthday: z.optional(z.string()).check(z.describe("User's birthday in ISO date format (YYYY-MM-DD)")),
6
- phoneMobile: z.optional(z.string()).check(z.describe("User's mobile phone number")),
4
+ displayName: z.string().optional().describe("User's display name shown in the interface"),
5
+ birthday: z.string().optional().describe("User's birthday in ISO date format (YYYY-MM-DD)"),
6
+ phoneMobile: z.string().optional().describe("User's mobile phone number"),
7
7
  address: z
8
- .optional(z.object({
9
- firstName: z.optional(z.string()).check(z.describe('First name for billing/shipping address')),
10
- lastName: z.optional(z.string()).check(z.describe('Last name for billing/shipping address')),
11
- addressLine: z.optional(z.string()).check(z.describe('Primary address line (street address)')),
12
- addressLine2: z
13
- .optional(z.string())
14
- .check(z.describe('Secondary address line (apartment, suite, etc.)')),
15
- postalCode: z.optional(z.string()).check(z.describe('Postal/ZIP code')),
16
- city: z.optional(z.string()).check(z.describe('City name')),
17
- regionCode: z.optional(z.string()).check(z.describe('Region/state code (e.g. "CA", "TX")')),
18
- countryCode: z
19
- .optional(z.string())
20
- .check(z.describe('ISO country code (e.g. "US", "DE", "CH")')),
21
- }))
22
- .check(z.describe("User's address information for billing and shipping")),
8
+ .object({
9
+ firstName: z.string().optional().describe('First name for billing/shipping address'),
10
+ lastName: z.string().optional().describe('Last name for billing/shipping address'),
11
+ addressLine: z.string().optional().describe('Primary address line (street address)'),
12
+ addressLine2: z.string().optional().describe('Secondary address line (apartment, suite, etc.)'),
13
+ postalCode: z.string().optional().describe('Postal/ZIP code'),
14
+ city: z.string().optional().describe('City name'),
15
+ regionCode: z.string().optional().describe('Region/state code (e.g. "CA", "TX")'),
16
+ countryCode: z.string().optional().describe('ISO country code (e.g. "US", "DE", "CH")'),
17
+ })
18
+ .optional()
19
+ .describe("User's address information for billing and shipping"),
23
20
  });
24
21
  export const actionValidators = {
25
22
  LIST: z.object({
26
23
  ...PaginationSchema,
27
24
  ...SortingSchema,
28
25
  ...SearchSchema,
29
- includeGuests: z.optional(z.boolean()).check(z.describe('Include guest users in results')),
30
- emailVerified: z.optional(z.boolean()).check(z.describe('Filter by email verification status')),
26
+ includeGuests: z.boolean().optional().describe('Include guest users in results'),
27
+ emailVerified: z.boolean().optional().describe('Filter by email verification status'),
31
28
  lastLogin: z
32
- .optional(z.object({
33
- start: z.optional(z.string()),
34
- end: z.optional(z.string()),
35
- }))
36
- .check(z.describe('Filter by last login date range')),
29
+ .object({
30
+ start: z.string().optional(),
31
+ end: z.string().optional(),
32
+ })
33
+ .optional()
34
+ .describe('Filter by last login date range'),
37
35
  }),
38
36
  COUNT: z.object({
39
37
  ...SearchSchema,
40
- includeGuests: z.optional(z.boolean()).check(z.describe('Include guest users in count')),
41
- emailVerified: z.optional(z.boolean()).check(z.describe('Filter by email verification status')),
38
+ includeGuests: z.boolean().optional().describe('Include guest users in count'),
39
+ emailVerified: z.boolean().optional().describe('Filter by email verification status'),
42
40
  lastLogin: z
43
- .optional(z.object({
44
- start: z.optional(z.string()),
45
- end: z.optional(z.string()),
46
- }))
47
- .check(z.describe('Filter by last login date range')),
41
+ .object({
42
+ start: z.string().optional(),
43
+ end: z.string().optional(),
44
+ })
45
+ .optional()
46
+ .describe('Filter by last login date range'),
48
47
  }),
49
48
  GET: z.object({
50
- userId: z.string().check(z.describe('User ID to retrieve')),
49
+ userId: z.string().describe('User ID to retrieve'),
51
50
  }),
52
51
  CREATE: z.object({
53
- username: z.optional(z.string()).check(z.describe('Username for the new user')),
54
- email: z.optional(z.string()).check(z.describe('Email address for the new user')),
55
- password: z.optional(z.string()).check(z.describe('Password for the new user')),
56
- profile: z.optional(UserProfileSchema).check(z.describe('User profile information')),
52
+ username: z.string().optional().describe('Username for the new user'),
53
+ email: z.string().optional().describe('Email address for the new user'),
54
+ password: z.string().optional().describe('Password for the new user'),
55
+ profile: UserProfileSchema.optional().describe('User profile information'),
57
56
  }),
58
57
  UPDATE: z.object({
59
- userId: z.string().check(z.describe('User ID to update')),
60
- profile: z.optional(UserProfileSchema).check(z.describe('Profile updates')),
61
- meta: z.optional(z.any()).check(z.describe('Additional metadata')),
58
+ userId: z.string().describe('User ID to update'),
59
+ profile: UserProfileSchema.optional().describe('Profile updates'),
60
+ meta: z.any().optional().describe('Additional metadata'),
62
61
  }),
63
62
  REMOVE: z.object({
64
- userId: z.string().check(z.describe('User ID to remove')),
65
- removeUserReviews: z._default(z.boolean(), false).check(z.describe('Also remove user reviews')),
63
+ userId: z.string().describe('User ID to remove'),
64
+ removeUserReviews: z.boolean().optional().default(false).describe('Also remove user reviews'),
66
65
  }),
67
66
  ENROLL: z.object({
68
- email: z.string().check(z.describe('Email address for enrollment')),
69
- profile: UserProfileSchema.check(z.describe('Profile information for new user')),
67
+ email: z.string().describe('Email address for enrollment'),
68
+ profile: UserProfileSchema.describe('Profile information for new user'),
70
69
  password: z
71
- .optional(z.string())
72
- .check(z.describe('Optional password (if not provided, enrollment email sent)')),
70
+ .string()
71
+ .optional()
72
+ .describe('Optional password (if not provided, enrollment email sent)'),
73
73
  }),
74
74
  SET_TAGS: z.object({
75
- userId: z.string().check(z.describe('User ID to update')),
76
- tags: z.array(z.string()).check(z.describe('Array of tags to assign')),
75
+ userId: z.string().describe('User ID to update'),
76
+ tags: z.array(z.string()).describe('Array of tags to assign'),
77
77
  }),
78
78
  SET_USERNAME: z.object({
79
- userId: z.string().check(z.describe('User ID to update')),
80
- username: z.string().check(z.describe('New username to set')),
79
+ userId: z.string().describe('User ID to update'),
80
+ username: z.string().describe('New username to set'),
81
81
  }),
82
82
  ADD_EMAIL: z.object({
83
- userId: z.optional(z.string()).check(z.describe('User ID (optional, defaults to current user)')),
84
- email: z.string().check(z.describe('Email address to add')),
83
+ userId: z.string().optional().describe('User ID (optional, defaults to current user)'),
84
+ email: z.string().describe('Email address to add'),
85
85
  }),
86
86
  REMOVE_EMAIL: z.object({
87
- userId: z.optional(z.string()).check(z.describe('User ID (optional, defaults to current user)')),
88
- email: z.string().check(z.describe('Email address to remove')),
87
+ userId: z.string().optional().describe('User ID (optional, defaults to current user)'),
88
+ email: z.string().describe('Email address to remove'),
89
89
  }),
90
90
  SEND_ENROLLMENT_EMAIL: z.object({
91
- email: z.string().check(z.describe('Email address to send enrollment to')),
91
+ email: z.string().describe('Email address to send enrollment to'),
92
92
  }),
93
93
  SEND_VERIFICATION_EMAIL: z.object({
94
- email: z.optional(z.string()).check(z.describe('Email address to verify (optional)')),
94
+ email: z.string().optional().describe('Email address to verify (optional)'),
95
95
  }),
96
96
  REMOVE_PRODUCT_REVIEWS: z.object({
97
- userId: z.string().check(z.describe('User ID whose reviews to remove')),
97
+ userId: z.string().describe('User ID whose reviews to remove'),
98
98
  }),
99
99
  GET_ORDERS: z.object({
100
- userId: z.string().check(z.describe('User ID to get orders for')),
100
+ userId: z.string().describe('User ID to get orders for'),
101
101
  ...PaginationSchema,
102
102
  ...SortingSchema,
103
103
  ...SearchSchema,
104
- includeCarts: z._default(z.boolean(), false).check(z.describe('Include cart orders')),
105
- status: z.optional(z.array(z.string())).check(z.describe('Filter by order status')),
104
+ includeCarts: z.boolean().optional().default(false).describe('Include cart orders'),
105
+ status: z.array(z.string()).optional().describe('Filter by order status'),
106
106
  }),
107
107
  GET_ENROLLMENTS: z.object({
108
- userId: z.string().check(z.describe('User ID to get enrollments for')),
108
+ userId: z.string().describe('User ID to get enrollments for'),
109
109
  ...PaginationSchema,
110
110
  ...SortingSchema,
111
111
  ...SearchSchema,
112
- status: z.optional(z.array(z.string())).check(z.describe('Filter by enrollment status')),
112
+ status: z.array(z.string()).optional().describe('Filter by enrollment status'),
113
113
  }),
114
114
  GET_QUOTATIONS: z.object({
115
- userId: z.string().check(z.describe('User ID to get quotations for')),
115
+ userId: z.string().describe('User ID to get quotations for'),
116
116
  ...PaginationSchema,
117
117
  ...SortingSchema,
118
118
  ...SearchSchema,
119
119
  }),
120
120
  GET_BOOKMARKS: z.object({
121
- userId: z.string().check(z.describe('User ID to get bookmarks for')),
121
+ userId: z.string().describe('User ID to get bookmarks for'),
122
122
  }),
123
123
  GET_CURRENT_USER: z.object({}),
124
124
  GET_PAYMENT_CREDENTIALS: z.object({
125
- userId: z.string().check(z.describe('User ID to get payment credentials for')),
125
+ userId: z.string().describe('User ID to get payment credentials for'),
126
126
  }),
127
127
  GET_AVATAR: z.object({
128
- userId: z.string().check(z.describe('User ID to get avatar for')),
128
+ userId: z.string().describe('User ID to get avatar for'),
129
129
  }),
130
130
  GET_REVIEWS: z.object({
131
- userId: z.string().check(z.describe('User ID to get reviews for')),
131
+ userId: z.string().describe('User ID to get reviews for'),
132
132
  ...PaginationSchema,
133
133
  ...SortingSchema,
134
134
  }),
135
135
  GET_REVIEWS_COUNT: z.object({
136
- userId: z.string().check(z.describe('User ID to count reviews for')),
136
+ userId: z.string().describe('User ID to count reviews for'),
137
137
  }),
138
138
  };
139
- export const UsersManagementSchema = createManagementSchemaFromValidators(actionValidators);
139
+ export const UsersManagementSchema = {
140
+ action: z
141
+ .enum([
142
+ 'LIST',
143
+ 'COUNT',
144
+ 'GET',
145
+ 'CREATE',
146
+ 'UPDATE',
147
+ 'REMOVE',
148
+ 'ENROLL',
149
+ 'SET_TAGS',
150
+ 'SET_USERNAME',
151
+ 'ADD_EMAIL',
152
+ 'REMOVE_EMAIL',
153
+ 'SEND_ENROLLMENT_EMAIL',
154
+ 'SEND_VERIFICATION_EMAIL',
155
+ 'REMOVE_PRODUCT_REVIEWS',
156
+ 'GET_ORDERS',
157
+ 'GET_ENROLLMENTS',
158
+ 'GET_QUOTATIONS',
159
+ 'GET_BOOKMARKS',
160
+ 'GET_PAYMENT_CREDENTIALS',
161
+ 'GET_AVATAR',
162
+ 'GET_REVIEWS',
163
+ 'GET_REVIEWS_COUNT',
164
+ 'GET_CURRENT_USER',
165
+ ])
166
+ .describe('User management action to perform. LIST: list users with filters and pagination. COUNT: count users matching criteria. GET: retrieve single user by ID. CREATE: create new user account. UPDATE: update user profile/metadata. REMOVE: mark user as deleted. ENROLL: create user and send enrollment email. SET_TAGS: assign tags to user. SET_USERNAME: set user username. ADD_EMAIL/REMOVE_EMAIL: manage user email addresses. SEND_ENROLLMENT_EMAIL/SEND_VERIFICATION_EMAIL: trigger email workflows. REMOVE_PRODUCT_REVIEWS: delete all reviews by user. GET_ORDERS/GET_ENROLLMENTS/GET_QUOTATIONS/GET_BOOKMARKS/GET_PAYMENT_CREDENTIALS/GET_AVATAR/GET_REVIEWS/GET_REVIEWS_COUNT/GET_CURRENT_USER: retrieve user-related data with optional filtering and pagination.'),
167
+ userId: z
168
+ .string()
169
+ .optional()
170
+ .describe('Required for: GET, UPDATE, REMOVE, SET_TAGS, SET_USERNAME, GET_ORDERS, GET_ENROLLMENTS, GET_QUOTATIONS, GET_BOOKMARKS, GET_PAYMENT_CREDENTIALS, GET_AVATAR, GET_REVIEWS, GET_REVIEWS_COUNT, REMOVE_PRODUCT_REVIEWS. Optional for: ADD_EMAIL, REMOVE_EMAIL (defaults to current user if not provided)'),
171
+ username: z
172
+ .string()
173
+ .optional()
174
+ .describe('Used for: CREATE (optional username for new user), SET_USERNAME (new username to assign)'),
175
+ email: z
176
+ .string()
177
+ .optional()
178
+ .describe('Used for: CREATE (optional email for new user), ENROLL (required email for enrollment), ADD_EMAIL/REMOVE_EMAIL (email address to add/remove), SEND_ENROLLMENT_EMAIL/SEND_VERIFICATION_EMAIL (target email address)'),
179
+ password: z
180
+ .string()
181
+ .optional()
182
+ .describe('Used for: CREATE (optional password for new user), ENROLL (optional password - if not provided, enrollment email is sent)'),
183
+ profile: UserProfileSchema.optional().describe('Used for: CREATE (optional profile data for new user), UPDATE (profile updates to apply), ENROLL (required profile data for new user including displayName, birthday, phoneMobile, address)'),
184
+ tags: z
185
+ .array(z.string())
186
+ .optional()
187
+ .describe('Used for: SET_TAGS (array of tag names to assign to user for categorization/filtering)'),
188
+ removeUserReviews: z
189
+ .boolean()
190
+ .optional()
191
+ .describe('Used for: REMOVE (if true, also delete all product reviews authored by the user when removing the user account)'),
192
+ ...PaginationSchema,
193
+ ...SortingSchema,
194
+ ...SearchSchema,
195
+ ...DateRangeSchema,
196
+ includeGuests: z
197
+ .boolean()
198
+ .optional()
199
+ .describe('Used for: LIST, COUNT (if true, include guest/anonymous users in results, default: false)'),
200
+ emailVerified: z
201
+ .boolean()
202
+ .optional()
203
+ .describe('Used for: LIST, COUNT (filter users by email verification status - true: only verified emails, false: only unverified emails, undefined: all users)'),
204
+ lastLogin: z
205
+ .object({
206
+ start: z.string().optional().describe('ISO date string for earliest last login date'),
207
+ end: z.string().optional().describe('ISO date string for latest last login date'),
208
+ })
209
+ .optional()
210
+ .describe('Used for: LIST, COUNT (filter users by their last login date range)'),
211
+ includeCarts: z
212
+ .boolean()
213
+ .optional()
214
+ .describe('Used for: GET_ORDERS (if true, include cart/open orders in results along with completed orders, default: false)'),
215
+ status: z
216
+ .array(z.string())
217
+ .optional()
218
+ .describe('Used for: GET_ORDERS (filter by order status like ["PENDING", "CONFIRMED"]), GET_ENROLLMENTS (filter by enrollment status like ["ACTIVE", "PAUSED"])'),
219
+ };
220
+ export const UsersManagementZodSchema = z.object(UsersManagementSchema);
@@ -1,6 +1,6 @@
1
1
  import type { Context } from '../../../context.ts';
2
- import { UsersManagementSchema, type UsersManagementParams } from './schemas.ts';
3
- export { UsersManagementSchema };
2
+ import { UsersManagementSchema, UsersManagementZodSchema, type UsersManagementParams } from './schemas.ts';
3
+ export { UsersManagementSchema, UsersManagementZodSchema };
4
4
  export type { UsersManagementParams };
5
5
  export declare function usersManagement(context: Context, params: UsersManagementParams): Promise<{
6
6
  content: {
@@ -1,8 +1,8 @@
1
1
  import { log } from '@unchainedshop/logger';
2
- import { actionValidators, UsersManagementSchema, } from "./schemas.js";
2
+ import { actionValidators, UsersManagementSchema, UsersManagementZodSchema, } from "./schemas.js";
3
3
  import actionHandlers from "./handlers/index.js";
4
4
  import { createMcpResponse, createMcpErrorResponse } from "../../utils/sharedSchemas.js";
5
- export { UsersManagementSchema };
5
+ export { UsersManagementSchema, UsersManagementZodSchema };
6
6
  export async function usersManagement(context, params) {
7
7
  const { action, ...actionParams } = params;
8
8
  log('MCP handler usersManagement ', { userId: context.userId, params });
@@ -24,6 +24,8 @@ export declare function getNormalizedQuotationDetails(quotationId: string, conte
24
24
  pushSubscriptions: import("@unchainedshop/core-users").PushSubscriptionObject[];
25
25
  username?: string;
26
26
  meta?: any;
27
+ tokenVersion?: number;
28
+ oidcLogoutAt?: Date;
27
29
  created: Date;
28
30
  updated?: Date;
29
31
  };
@@ -35,6 +35,8 @@ export declare function getNormalizedUserDetails(userId: string, context: Contex
35
35
  pushSubscriptions: import("@unchainedshop/core-users").PushSubscriptionObject[];
36
36
  username?: string;
37
37
  meta?: any;
38
+ tokenVersion?: number;
39
+ oidcLogoutAt?: Date;
38
40
  created: Date;
39
41
  updated?: Date;
40
42
  } | null>;
@@ -1,4 +1,4 @@
1
- import { getFileAdapter } from '@unchainedshop/core-files';
1
+ import { getFileAdapter } from '@unchainedshop/core';
2
2
  const normalizeMediaUrl = async (medias = [], context) => {
3
3
  if (medias?.length) {
4
4
  const normalizedMedias = await Promise.all(medias
@@ -1,4 +1,4 @@
1
- import type { LocalizationType, LocalizationEntity, LocalizationUpdateEntity } from '../tools/localization/types.ts';
1
+ import type { LocalizationType, LocalizationEntity, LocalizationUpdateEntity } from '../tools/localization/schemas.ts';
2
2
  declare const sanitizeEntityData: (localizationType: LocalizationType, entity: LocalizationEntity | LocalizationUpdateEntity) => {
3
3
  isoCode: string;
4
4
  contractAddress?: string;
@@ -1,33 +1,33 @@
1
- import { z } from 'zod/v4-mini';
1
+ import { z } from 'zod';
2
2
  export declare const PaginationSchema: {
3
- limit: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
4
- offset: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
3
+ limit: z.ZodOptional<z.ZodNumber>;
4
+ offset: z.ZodOptional<z.ZodNumber>;
5
5
  };
6
6
  export declare const SortingSchema: {
7
- sort: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
8
- key: z.ZodMiniString<string>;
9
- value: z.ZodMiniEnum<{
7
+ sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
8
+ key: z.ZodString;
9
+ value: z.ZodEnum<{
10
10
  [x: string]: string;
11
11
  }>;
12
12
  }, z.core.$strip>>>;
13
13
  };
14
14
  export declare const SearchSchema: {
15
- queryString: z.ZodMiniOptional<z.ZodMiniString<string>>;
16
- includeInactive: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
15
+ queryString: z.ZodOptional<z.ZodString>;
16
+ includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
17
17
  };
18
- export declare const LocalizationTextSchema: z.ZodMiniObject<{
19
- locale: z.ZodMiniString<string>;
20
- title: z.ZodMiniString<string>;
21
- subtitle: z.ZodMiniOptional<z.ZodMiniString<string>>;
18
+ export declare const LocalizationTextSchema: z.ZodObject<{
19
+ locale: z.ZodString;
20
+ title: z.ZodString;
21
+ subtitle: z.ZodOptional<z.ZodString>;
22
22
  }, z.core.$strip>;
23
23
  export declare const DateRangeSchema: {
24
- from: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
25
- to: z.ZodMiniOptional<z.iso.ZodMiniISODateTime>;
24
+ from: z.ZodOptional<z.ZodString>;
25
+ to: z.ZodOptional<z.ZodString>;
26
26
  };
27
27
  export declare const OrderFilterSchema: {
28
- paymentProviderIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
29
- deliveryProviderIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
30
- status: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniEnum<{
28
+ paymentProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
29
+ deliveryProviderIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
30
+ status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
31
31
  DELIVERED: "DELIVERED";
32
32
  PENDING: "PENDING";
33
33
  CONFIRMED: "CONFIRMED";
@@ -36,36 +36,26 @@ export declare const OrderFilterSchema: {
36
36
  }>>>;
37
37
  };
38
38
  export declare const EntityIdSchema: {
39
- id: z.ZodMiniOptional<z.ZodMiniString<string>>;
39
+ id: z.ZodOptional<z.ZodString>;
40
40
  };
41
41
  export declare const MediaUrlSchema: {
42
- url: z.ZodMiniOptional<z.ZodMiniURL>;
42
+ url: z.ZodOptional<z.ZodString>;
43
43
  };
44
- export declare function createManagementSchema<T extends readonly string[]>(actions: T, additionalFields?: Record<string, z.core.$ZodType>): {
45
- queryString: z.ZodMiniOptional<z.ZodMiniString<string>>;
46
- includeInactive: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
47
- sort: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
48
- key: z.ZodMiniString<string>;
49
- value: z.ZodMiniEnum<{
44
+ export declare function createManagementSchema<T extends readonly string[]>(actions: T, additionalFields?: Record<string, z.ZodType>): {
45
+ queryString: z.ZodOptional<z.ZodString>;
46
+ includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
47
+ sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
48
+ key: z.ZodString;
49
+ value: z.ZodEnum<{
50
50
  [x: string]: string;
51
51
  }>;
52
52
  }, z.core.$strip>>>;
53
- limit: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
54
- offset: z.ZodMiniOptional<z.ZodMiniNumberFormat>;
55
- action: z.ZodMiniEnum<{
53
+ limit: z.ZodOptional<z.ZodNumber>;
54
+ offset: z.ZodOptional<z.ZodNumber>;
55
+ action: z.ZodEnum<{
56
56
  [x: string]: any;
57
57
  }>;
58
58
  };
59
- export interface ManagementParams {
60
- action: string;
61
- [key: string]: unknown;
62
- }
63
- type ManagementSchemaShape = {
64
- action: z.core.$ZodType<string>;
65
- } & Record<string, z.core.$ZodType>;
66
- export declare function createManagementSchemaFromValidators(validators: Record<string, {
67
- shape: Record<string, z.core.$ZodType>;
68
- }>): ManagementSchemaShape;
69
59
  export declare function createMcpResponse(response: any): {
70
60
  content: {
71
61
  type: "text";
@@ -78,4 +68,3 @@ export declare function createMcpErrorResponse(action: string, error: Error): {
78
68
  text: string;
79
69
  }[];
80
70
  };
81
- export {};
@@ -1,81 +1,62 @@
1
- import { z } from 'zod/v4-mini';
1
+ import { z } from 'zod';
2
2
  import { SortDirection } from '@unchainedshop/utils';
3
3
  const sortDirectionKeys = Object.keys(SortDirection);
4
4
  export const PaginationSchema = {
5
- limit: z
6
- .optional(z.int().check(z.gte(1), z.lte(100)))
7
- .check(z.describe('Maximum number of results to return')),
8
- offset: z
9
- .optional(z.int().check(z.gte(0)))
10
- .check(z.describe('Number of results to skip for pagination')),
5
+ limit: z.number().int().min(1).max(100).optional().describe('Maximum number of results to return'),
6
+ offset: z.number().int().min(0).optional().describe('Number of results to skip for pagination'),
11
7
  };
12
8
  export const SortingSchema = {
13
9
  sort: z
14
- .optional(z.array(z.object({
15
- key: z.string().check(z.describe('Field to sort by')),
16
- value: z.enum(sortDirectionKeys).check(z.describe('Sort direction (ASC/DESC)')),
17
- })))
18
- .check(z.describe('Array of sort options')),
10
+ .array(z.object({
11
+ key: z.string().describe('Field to sort by'),
12
+ value: z.enum(sortDirectionKeys).describe('Sort direction (ASC/DESC)'),
13
+ }))
14
+ .optional()
15
+ .describe('Array of sort options'),
19
16
  };
20
17
  export const SearchSchema = {
21
- queryString: z.optional(z.string()).check(z.describe('Search query string for text-based filtering')),
18
+ queryString: z.string().optional().describe('Search query string for text-based filtering'),
22
19
  includeInactive: z
23
- ._default(z.boolean(), true)
24
- .check(z.describe('Whether to include inactive/disabled items')),
20
+ .boolean()
21
+ .optional()
22
+ .default(true)
23
+ .describe('Whether to include inactive/disabled items'),
25
24
  };
26
25
  export const LocalizationTextSchema = z.object({
27
26
  locale: z
28
27
  .string()
29
- .check(z.minLength(2), z.describe('Locale code (e.g., "en-US", "de-CH"). Must match an available language from the shop languages resource. If the language does not exist, prompt the user to add it first. NEVER add it automatically unless explicitly specified by the user.')),
30
- title: z.string().check(z.minLength(1), z.describe('Localized title')),
31
- subtitle: z.optional(z.string()).check(z.describe('Optional localized subtitle')),
28
+ .min(2)
29
+ .describe('Locale code (e.g., "en-US", "de-CH"). Must match an available language from the shop languages resource. If the language does not exist, prompt the user to add it first. NEVER add it automatically unless explicitly specified by the user.'),
30
+ title: z.string().min(1).describe('Localized title'),
31
+ subtitle: z.string().optional().describe('Optional localized subtitle'),
32
32
  });
33
33
  export const DateRangeSchema = {
34
- from: z.optional(z.iso.datetime()).check(z.describe('Start date in ISO format')),
35
- to: z.optional(z.iso.datetime()).check(z.describe('End date in ISO format')),
34
+ from: z.string().datetime().optional().describe('Start date in ISO format'),
35
+ to: z.string().datetime().optional().describe('End date in ISO format'),
36
36
  };
37
37
  export const OrderFilterSchema = {
38
- paymentProviderIds: z
39
- .optional(z.array(z.string()))
40
- .check(z.describe('Filter by payment provider IDs')),
41
- deliveryProviderIds: z
42
- .optional(z.array(z.string()))
43
- .check(z.describe('Filter by delivery provider IDs')),
38
+ paymentProviderIds: z.array(z.string()).optional().describe('Filter by payment provider IDs'),
39
+ deliveryProviderIds: z.array(z.string()).optional().describe('Filter by delivery provider IDs'),
44
40
  status: z
45
- .optional(z.array(z.enum(['PENDING', 'CONFIRMED', 'SHIPPED', 'DELIVERED', 'CANCELLED'])))
46
- .check(z.describe('Filter by order statuses')),
41
+ .array(z.enum(['PENDING', 'CONFIRMED', 'SHIPPED', 'DELIVERED', 'CANCELLED']))
42
+ .optional()
43
+ .describe('Filter by order statuses'),
47
44
  };
48
45
  export const EntityIdSchema = {
49
- id: z.optional(z.string().check(z.minLength(1))).check(z.describe('Entity ID')),
46
+ id: z.string().min(1).optional().describe('Entity ID'),
50
47
  };
51
48
  export const MediaUrlSchema = {
52
- url: z.optional(z.url()).check(z.describe('Media URL')),
49
+ url: z.string().url().optional().describe('Media URL'),
53
50
  };
54
51
  export function createManagementSchema(actions, additionalFields = {}) {
55
52
  return {
56
- action: z.enum(actions).check(z.describe(`Management action: ${actions.join(', ')}`)),
53
+ action: z.enum(actions).describe(`Management action: ${actions.join(', ')}`),
57
54
  ...PaginationSchema,
58
55
  ...SortingSchema,
59
56
  ...SearchSchema,
60
57
  ...additionalFields,
61
58
  };
62
59
  }
63
- export function createManagementSchemaFromValidators(validators) {
64
- const merged = {};
65
- for (const validator of Object.values(validators)) {
66
- for (const [key, schema] of Object.entries(validator.shape)) {
67
- if (!merged[key]) {
68
- merged[key] = z.optional(schema);
69
- }
70
- }
71
- }
72
- return {
73
- action: z
74
- .enum(Object.keys(validators))
75
- .check(z.describe('Action to perform')),
76
- ...merged,
77
- };
78
- }
79
60
  export function createMcpResponse(response) {
80
61
  return {
81
62
  content: [
@@ -1,3 +1,3 @@
1
- import type { LocalizationType } from '../tools/localization/types.ts';
1
+ import type { LocalizationType } from '../tools/localization/schemas.ts';
2
2
  declare const validateIsoCode: (localizationType: LocalizationType, isoCode: string) => string;
3
3
  export default validateIsoCode;
@@ -65,9 +65,8 @@ export async function createAuthContext(params, authConfig) {
65
65
  const fingerprintCookie = getCookie(UNCHAINED_FINGERPRINT_COOKIE_NAME);
66
66
  const verifyToken = createAuthHandler(authConfig);
67
67
  const authResult = token ? await verifyToken(token) : {};
68
- let fingerprintValid = true;
69
68
  if (authResult.fingerprintHash && fingerprintCookie) {
70
- fingerprintValid = verifyFingerprint(fingerprintCookie, authResult.fingerprintHash);
69
+ const fingerprintValid = verifyFingerprint(fingerprintCookie, authResult.fingerprintHash);
71
70
  if (!fingerprintValid) {
72
71
  logger.warn('Token sidejacking detected: fingerprint mismatch', {
73
72
  userId: authResult.userId,
@@ -81,7 +80,6 @@ export async function createAuthContext(params, authConfig) {
81
80
  logger.warn('Token sidejacking detected: fingerprint cookie missing', {
82
81
  userId: authResult.userId,
83
82
  });
84
- fingerprintValid = false;
85
83
  authResult.userId = undefined;
86
84
  authResult.tokenVersion = undefined;
87
85
  authResult.impersonatorId = undefined;
@@ -13,8 +13,7 @@ export default async function changePassword(root, params, { modules, userId })
13
13
  catch (e) {
14
14
  if (e.cause === 'PASSWORD_INVALID')
15
15
  throw new PasswordInvalidError({ userId });
16
- else
17
- throw e;
16
+ throw e;
18
17
  }
19
18
  return { success: true };
20
19
  }