@unchainedshop/api 4.8.4 → 5.0.0-alpha.1
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/acl.d.ts +2 -2
- package/lib/acl.js +36 -8
- package/lib/api-index.d.ts +3 -1
- package/lib/chat/generateImageHandler.js +6 -5
- package/lib/context.d.ts +4 -1
- package/lib/context.js +9 -3
- package/lib/events.d.ts +2 -0
- package/lib/events.js +2 -0
- package/lib/express/createMCPMiddleware.js +1 -1
- package/lib/express/index.d.ts +6 -9
- package/lib/express/index.js +52 -125
- package/lib/fastify/index.d.ts +6 -9
- package/lib/fastify/index.js +51 -117
- package/lib/fastify/mcpHandler.js +1 -1
- package/lib/loaders/buildTextMap.js +6 -3
- package/lib/locale-context.d.ts +4 -2
- package/lib/locale-context.js +2 -6
- package/lib/mcp/tools/assortment/assortmentManagement.d.ts +2 -2
- package/lib/mcp/tools/assortment/assortmentManagement.js +2 -2
- package/lib/mcp/tools/assortment/handlers/getAssortment.js +1 -1
- package/lib/mcp/tools/assortment/schemas.d.ts +322 -141
- package/lib/mcp/tools/assortment/schemas.js +179 -96
- package/lib/mcp/tools/filter/filterManagement.d.ts +2 -2
- package/lib/mcp/tools/filter/filterManagement.js +2 -2
- package/lib/mcp/tools/filter/schemas.d.ts +184 -75
- package/lib/mcp/tools/filter/schemas.js +87 -51
- package/lib/mcp/tools/localization/getLocalizationsConfig.d.ts +1 -1
- package/lib/mcp/tools/localization/localizationManagement.d.ts +2 -2
- package/lib/mcp/tools/localization/localizationManagement.js +2 -2
- package/lib/mcp/tools/localization/schemas.d.ts +144 -47
- package/lib/mcp/tools/localization/schemas.js +51 -36
- package/lib/mcp/tools/order/handlers/getTopCustomers.d.ts +2 -0
- package/lib/mcp/tools/order/orderManagement.d.ts +2 -2
- package/lib/mcp/tools/order/orderManagement.js +2 -2
- package/lib/mcp/tools/order/schemas.d.ts +184 -75
- package/lib/mcp/tools/order/schemas.js +113 -51
- package/lib/mcp/tools/product/handlers/getProduct.js +1 -1
- package/lib/mcp/tools/product/productManagement.d.ts +2 -2
- package/lib/mcp/tools/product/productManagement.js +2 -2
- package/lib/mcp/tools/product/schemas.d.ts +642 -317
- package/lib/mcp/tools/product/schemas.js +287 -191
- package/lib/mcp/tools/provider/providerManagement.d.ts +2 -2
- package/lib/mcp/tools/provider/providerManagement.js +2 -2
- package/lib/mcp/tools/provider/schemas.d.ts +142 -47
- package/lib/mcp/tools/provider/schemas.js +67 -32
- package/lib/mcp/tools/quotation/handlers/getQuotation.d.ts +2 -0
- package/lib/mcp/tools/quotation/handlers/listQuotations.d.ts +2 -0
- package/lib/mcp/tools/quotation/handlers/makeQuotationProposal.d.ts +2 -0
- package/lib/mcp/tools/quotation/handlers/rejectQuotation.d.ts +2 -0
- package/lib/mcp/tools/quotation/handlers/verifyQuotation.d.ts +2 -0
- package/lib/mcp/tools/quotation/quotationManagement.d.ts +2 -2
- package/lib/mcp/tools/quotation/quotationManagement.js +2 -2
- package/lib/mcp/tools/quotation/schemas.d.ts +111 -40
- package/lib/mcp/tools/quotation/schemas.js +54 -29
- package/lib/mcp/tools/system/handlers/countEvents.d.ts +8 -1
- package/lib/mcp/tools/system/handlers/countWork.d.ts +10 -1
- package/lib/mcp/tools/system/handlers/countWork.js +1 -0
- package/lib/mcp/tools/system/handlers/index.d.ts +4 -4
- package/lib/mcp/tools/system/handlers/listEvents.d.ts +12 -1
- package/lib/mcp/tools/system/handlers/listWork.d.ts +14 -1
- package/lib/mcp/tools/system/handlers/listWork.js +1 -0
- package/lib/mcp/tools/system/schemas.d.ts +179 -84
- package/lib/mcp/tools/system/schemas.js +188 -67
- package/lib/mcp/tools/system/systemManagement.d.ts +1 -1
- package/lib/mcp/tools/system/systemManagement.js +1 -1
- package/lib/mcp/tools/users/handlers/addUserEmail.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/createUser.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/enrollUser.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/getCurrentUser.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/getUser.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/listUsers.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/setUserTags.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/setUserUsername.d.ts +2 -0
- package/lib/mcp/tools/users/handlers/updateUser.d.ts +2 -0
- package/lib/mcp/tools/users/schemas.d.ts +296 -163
- package/lib/mcp/tools/users/schemas.js +152 -71
- package/lib/mcp/tools/users/usersManagement.d.ts +2 -2
- package/lib/mcp/tools/users/usersManagement.js +2 -2
- package/lib/mcp/utils/getNormalizedQuotationDetails.d.ts +2 -0
- package/lib/mcp/utils/getNormalizedUserDetails.d.ts +2 -0
- package/lib/mcp/utils/normalizeMediaUrl.js +1 -1
- package/lib/mcp/utils/sanitizeLocalizationEntityData.d.ts +1 -1
- package/lib/mcp/utils/sharedSchemas.d.ts +28 -39
- package/lib/mcp/utils/sharedSchemas.js +28 -47
- package/lib/mcp/utils/validateIsoCode.d.ts +1 -1
- package/lib/resolvers/mutations/accounts/changePassword.js +1 -2
- package/lib/resolvers/mutations/index.d.ts +150 -155
- package/lib/resolvers/mutations/index.js +2 -12
- package/lib/resolvers/mutations/orders/updateCart.js +7 -1
- package/lib/resolvers/mutations/users/setRoles.d.ts +1 -1
- package/lib/resolvers/mutations/users/setRoles.js +8 -1
- package/lib/resolvers/queries/events/registeredEventTypes.d.ts +1 -1
- package/lib/resolvers/queries/events/registeredEventTypes.js +1 -1
- package/lib/resolvers/queries/index.d.ts +71 -71
- package/lib/resolvers/queries/index.js +1 -1
- package/lib/resolvers/type/index.d.ts +0 -1
- package/lib/resolvers/type/login-method-response-types.js +2 -1
- package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +0 -1
- package/lib/resolvers/type/order/order-delivery-pickup-types.js +0 -7
- package/lib/resolvers/type/shop-types.js +1 -1
- package/lib/resolvers/type/user-types.js +3 -3
- package/lib/roles/all.js +5 -3
- package/lib/roles/index.d.ts +4 -11
- package/lib/roles/index.js +16 -11
- package/lib/roles/loggedIn.js +2 -0
- package/lib/schema/mutation.js +6 -44
- package/lib/schema/query.js +5 -5
- package/lib/schema/types/index.js +2 -2
- package/lib/schema/types/order/delivery.js +0 -2
- package/package.json +13 -23
|
@@ -1,120 +1,215 @@
|
|
|
1
|
-
import { z } from 'zod
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
export declare const WorkStatusKeys: [string, ...string[]];
|
|
3
|
-
export declare const ActiveWorkTypesSchema: z.
|
|
3
|
+
export declare const ActiveWorkTypesSchema: z.ZodObject<{}, z.core.$strip>;
|
|
4
4
|
export declare const actionValidators: {
|
|
5
|
-
readonly SHOP_INFO: z.
|
|
6
|
-
readonly WORKER_ADD: z.
|
|
7
|
-
type: z.
|
|
8
|
-
priority: z.
|
|
9
|
-
input: z.
|
|
10
|
-
originalWorkId: z.
|
|
11
|
-
scheduled: z.
|
|
12
|
-
retries: z.
|
|
13
|
-
worker: z.
|
|
5
|
+
readonly SHOP_INFO: z.ZodObject<{}, z.core.$strip>;
|
|
6
|
+
readonly WORKER_ADD: z.ZodObject<{
|
|
7
|
+
type: z.ZodString;
|
|
8
|
+
priority: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
input: z.ZodOptional<z.ZodAny>;
|
|
10
|
+
originalWorkId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
scheduled: z.ZodOptional<z.ZodString>;
|
|
12
|
+
retries: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
worker: z.ZodOptional<z.ZodString>;
|
|
14
14
|
}, z.core.$strip>;
|
|
15
|
-
readonly WORKER_ACTIVE_WORK_TYPES: z.
|
|
16
|
-
readonly WORKER_ALLOCATE: z.
|
|
17
|
-
types: z.
|
|
18
|
-
worker: z.
|
|
15
|
+
readonly WORKER_ACTIVE_WORK_TYPES: z.ZodObject<{}, z.core.$strip>;
|
|
16
|
+
readonly WORKER_ALLOCATE: z.ZodObject<{
|
|
17
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
|
+
worker: z.ZodOptional<z.ZodString>;
|
|
19
19
|
}, z.core.$strip>;
|
|
20
|
-
readonly WORKER_REMOVE: z.
|
|
21
|
-
workId: z.
|
|
20
|
+
readonly WORKER_REMOVE: z.ZodObject<{
|
|
21
|
+
workId: z.ZodString;
|
|
22
22
|
}, z.core.$strip>;
|
|
23
|
-
readonly WORKER_GET: z.
|
|
24
|
-
workId: z.
|
|
23
|
+
readonly WORKER_GET: z.ZodObject<{
|
|
24
|
+
workId: z.ZodString;
|
|
25
25
|
}, z.core.$strip>;
|
|
26
|
-
readonly WORKER_LIST: z.
|
|
27
|
-
created: z.
|
|
28
|
-
from: z.
|
|
29
|
-
to: z.
|
|
26
|
+
readonly WORKER_LIST: z.ZodObject<{
|
|
27
|
+
created: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
from: z.ZodOptional<z.ZodString>;
|
|
29
|
+
to: z.ZodOptional<z.ZodString>;
|
|
30
30
|
}, z.core.$strip>>;
|
|
31
|
-
status: z.
|
|
31
|
+
status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
32
32
|
[x: string]: string;
|
|
33
33
|
}>>>;
|
|
34
|
-
types: z.
|
|
35
|
-
queryString: z.
|
|
36
|
-
includeInactive: z.
|
|
37
|
-
sort: z.
|
|
38
|
-
key: z.
|
|
39
|
-
value: z.
|
|
34
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
35
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
36
|
+
includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
37
|
+
sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
38
|
+
key: z.ZodString;
|
|
39
|
+
value: z.ZodEnum<{
|
|
40
40
|
[x: string]: string;
|
|
41
41
|
}>;
|
|
42
42
|
}, z.core.$strip>>>;
|
|
43
|
-
limit: z.
|
|
44
|
-
offset: z.
|
|
43
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
45
45
|
}, z.core.$strip>;
|
|
46
|
-
readonly WORKER_COUNT: z.
|
|
47
|
-
created: z.
|
|
48
|
-
from: z.
|
|
49
|
-
to: z.
|
|
46
|
+
readonly WORKER_COUNT: z.ZodObject<{
|
|
47
|
+
created: z.ZodOptional<z.ZodObject<{
|
|
48
|
+
from: z.ZodOptional<z.ZodString>;
|
|
49
|
+
to: z.ZodOptional<z.ZodString>;
|
|
50
50
|
}, z.core.$strip>>;
|
|
51
|
-
status: z.
|
|
51
|
+
status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
52
52
|
[x: string]: string;
|
|
53
53
|
}>>>;
|
|
54
|
-
types: z.
|
|
55
|
-
queryString: z.
|
|
56
|
-
includeInactive: z.
|
|
54
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
55
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
56
|
+
includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
57
57
|
}, z.core.$strip>;
|
|
58
|
-
readonly WORKER_FINISH_WORK: z.
|
|
59
|
-
workId: z.
|
|
60
|
-
result: z.
|
|
61
|
-
error: z.
|
|
62
|
-
success: z.
|
|
63
|
-
worker: z.
|
|
64
|
-
started: z.
|
|
65
|
-
finished: z.
|
|
58
|
+
readonly WORKER_FINISH_WORK: z.ZodObject<{
|
|
59
|
+
workId: z.ZodString;
|
|
60
|
+
result: z.ZodOptional<z.ZodAny>;
|
|
61
|
+
error: z.ZodOptional<z.ZodAny>;
|
|
62
|
+
success: z.ZodBoolean;
|
|
63
|
+
worker: z.ZodOptional<z.ZodString>;
|
|
64
|
+
started: z.ZodOptional<z.ZodString>;
|
|
65
|
+
finished: z.ZodOptional<z.ZodString>;
|
|
66
66
|
}, z.core.$strip>;
|
|
67
|
-
readonly WORKER_PROCESS_NEXT: z.
|
|
68
|
-
worker: z.
|
|
67
|
+
readonly WORKER_PROCESS_NEXT: z.ZodObject<{
|
|
68
|
+
worker: z.ZodOptional<z.ZodString>;
|
|
69
69
|
}, z.core.$strip>;
|
|
70
|
-
readonly WORKER_STATISTICS: z.
|
|
71
|
-
types: z.
|
|
72
|
-
dateRange: z.
|
|
73
|
-
from: z.
|
|
74
|
-
to: z.
|
|
70
|
+
readonly WORKER_STATISTICS: z.ZodObject<{
|
|
71
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
72
|
+
dateRange: z.ZodOptional<z.ZodObject<{
|
|
73
|
+
from: z.ZodOptional<z.ZodString>;
|
|
74
|
+
to: z.ZodOptional<z.ZodString>;
|
|
75
75
|
}, z.core.$strip>>;
|
|
76
76
|
}, z.core.$strip>;
|
|
77
|
-
readonly EVENT_GET: z.
|
|
78
|
-
eventId: z.
|
|
77
|
+
readonly EVENT_GET: z.ZodObject<{
|
|
78
|
+
eventId: z.ZodString;
|
|
79
79
|
}, z.core.$strip>;
|
|
80
|
-
readonly EVENT_LIST: z.
|
|
81
|
-
types: z.
|
|
82
|
-
created: z.
|
|
83
|
-
from: z.
|
|
84
|
-
to: z.
|
|
80
|
+
readonly EVENT_LIST: z.ZodObject<{
|
|
81
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
82
|
+
created: z.ZodOptional<z.ZodObject<{
|
|
83
|
+
from: z.ZodOptional<z.ZodString>;
|
|
84
|
+
to: z.ZodOptional<z.ZodString>;
|
|
85
85
|
}, z.core.$strip>>;
|
|
86
|
-
queryString: z.
|
|
87
|
-
includeInactive: z.
|
|
88
|
-
sort: z.
|
|
89
|
-
key: z.
|
|
90
|
-
value: z.
|
|
86
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
87
|
+
includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
88
|
+
sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
89
|
+
key: z.ZodString;
|
|
90
|
+
value: z.ZodEnum<{
|
|
91
91
|
[x: string]: string;
|
|
92
92
|
}>;
|
|
93
93
|
}, z.core.$strip>>>;
|
|
94
|
-
limit: z.
|
|
95
|
-
offset: z.
|
|
94
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
96
96
|
}, z.core.$strip>;
|
|
97
|
-
readonly EVENT_COUNT: z.
|
|
98
|
-
types: z.
|
|
99
|
-
created: z.
|
|
100
|
-
from: z.
|
|
101
|
-
to: z.
|
|
97
|
+
readonly EVENT_COUNT: z.ZodObject<{
|
|
98
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
99
|
+
created: z.ZodOptional<z.ZodObject<{
|
|
100
|
+
from: z.ZodOptional<z.ZodString>;
|
|
101
|
+
to: z.ZodOptional<z.ZodString>;
|
|
102
102
|
}, z.core.$strip>>;
|
|
103
|
-
queryString: z.
|
|
104
|
-
includeInactive: z.
|
|
103
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
104
|
+
includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
105
105
|
}, z.core.$strip>;
|
|
106
|
-
readonly EVENT_STATISTICS: z.
|
|
107
|
-
types: z.
|
|
108
|
-
dateRange: z.
|
|
109
|
-
from: z.
|
|
110
|
-
to: z.
|
|
106
|
+
readonly EVENT_STATISTICS: z.ZodObject<{
|
|
107
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
108
|
+
dateRange: z.ZodOptional<z.ZodObject<{
|
|
109
|
+
from: z.ZodOptional<z.ZodString>;
|
|
110
|
+
to: z.ZodOptional<z.ZodString>;
|
|
111
111
|
}, z.core.$strip>>;
|
|
112
112
|
}, z.core.$strip>;
|
|
113
113
|
};
|
|
114
114
|
export declare const SystemManagementSchema: {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
dateRange: z.ZodOptional<z.ZodObject<{
|
|
116
|
+
from: z.ZodOptional<z.ZodString>;
|
|
117
|
+
to: z.ZodOptional<z.ZodString>;
|
|
118
|
+
}, z.core.$strip>>;
|
|
119
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
120
|
+
includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
121
|
+
sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
122
|
+
key: z.ZodString;
|
|
123
|
+
value: z.ZodEnum<{
|
|
124
|
+
[x: string]: string;
|
|
125
|
+
}>;
|
|
126
|
+
}, z.core.$strip>>>;
|
|
127
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
128
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
129
|
+
action: z.ZodEnum<{
|
|
130
|
+
SHOP_INFO: "SHOP_INFO";
|
|
131
|
+
WORKER_ADD: "WORKER_ADD";
|
|
132
|
+
WORKER_REMOVE: "WORKER_REMOVE";
|
|
133
|
+
WORKER_COUNT: "WORKER_COUNT";
|
|
134
|
+
WORKER_GET: "WORKER_GET";
|
|
135
|
+
WORKER_LIST: "WORKER_LIST";
|
|
136
|
+
WORKER_STATISTICS: "WORKER_STATISTICS";
|
|
137
|
+
WORKER_PROCESS_NEXT: "WORKER_PROCESS_NEXT";
|
|
138
|
+
WORKER_ALLOCATE: "WORKER_ALLOCATE";
|
|
139
|
+
WORKER_FINISH_WORK: "WORKER_FINISH_WORK";
|
|
140
|
+
WORKER_ACTIVE_WORK_TYPES: "WORKER_ACTIVE_WORK_TYPES";
|
|
141
|
+
EVENT_GET: "EVENT_GET";
|
|
142
|
+
EVENT_LIST: "EVENT_LIST";
|
|
143
|
+
EVENT_COUNT: "EVENT_COUNT";
|
|
144
|
+
EVENT_STATISTICS: "EVENT_STATISTICS";
|
|
145
|
+
}>;
|
|
146
|
+
type: z.ZodOptional<z.ZodString>;
|
|
147
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
148
|
+
originalWorkId: z.ZodOptional<z.ZodString>;
|
|
149
|
+
scheduled: z.ZodOptional<z.ZodString>;
|
|
150
|
+
retries: z.ZodOptional<z.ZodNumber>;
|
|
151
|
+
worker: z.ZodOptional<z.ZodString>;
|
|
152
|
+
workId: z.ZodOptional<z.ZodString>;
|
|
153
|
+
success: z.ZodOptional<z.ZodBoolean>;
|
|
154
|
+
started: z.ZodOptional<z.ZodString>;
|
|
155
|
+
finished: z.ZodOptional<z.ZodString>;
|
|
156
|
+
status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
157
|
+
[x: string]: string;
|
|
158
|
+
}>>>;
|
|
159
|
+
eventId: z.ZodOptional<z.ZodString>;
|
|
160
|
+
created: z.ZodOptional<z.ZodString>;
|
|
161
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
162
|
+
};
|
|
163
|
+
export declare const SystemManagementZodSchema: z.ZodObject<{
|
|
164
|
+
dateRange: z.ZodOptional<z.ZodObject<{
|
|
165
|
+
from: z.ZodOptional<z.ZodString>;
|
|
166
|
+
to: z.ZodOptional<z.ZodString>;
|
|
167
|
+
}, z.core.$strip>>;
|
|
168
|
+
queryString: z.ZodOptional<z.ZodString>;
|
|
169
|
+
includeInactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
170
|
+
sort: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
171
|
+
key: z.ZodString;
|
|
172
|
+
value: z.ZodEnum<{
|
|
173
|
+
[x: string]: string;
|
|
174
|
+
}>;
|
|
175
|
+
}, z.core.$strip>>>;
|
|
176
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
177
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
178
|
+
action: z.ZodEnum<{
|
|
179
|
+
SHOP_INFO: "SHOP_INFO";
|
|
180
|
+
WORKER_ADD: "WORKER_ADD";
|
|
181
|
+
WORKER_REMOVE: "WORKER_REMOVE";
|
|
182
|
+
WORKER_COUNT: "WORKER_COUNT";
|
|
183
|
+
WORKER_GET: "WORKER_GET";
|
|
184
|
+
WORKER_LIST: "WORKER_LIST";
|
|
185
|
+
WORKER_STATISTICS: "WORKER_STATISTICS";
|
|
186
|
+
WORKER_PROCESS_NEXT: "WORKER_PROCESS_NEXT";
|
|
187
|
+
WORKER_ALLOCATE: "WORKER_ALLOCATE";
|
|
188
|
+
WORKER_FINISH_WORK: "WORKER_FINISH_WORK";
|
|
189
|
+
WORKER_ACTIVE_WORK_TYPES: "WORKER_ACTIVE_WORK_TYPES";
|
|
190
|
+
EVENT_GET: "EVENT_GET";
|
|
191
|
+
EVENT_LIST: "EVENT_LIST";
|
|
192
|
+
EVENT_COUNT: "EVENT_COUNT";
|
|
193
|
+
EVENT_STATISTICS: "EVENT_STATISTICS";
|
|
194
|
+
}>;
|
|
195
|
+
type: z.ZodOptional<z.ZodString>;
|
|
196
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
197
|
+
originalWorkId: z.ZodOptional<z.ZodString>;
|
|
198
|
+
scheduled: z.ZodOptional<z.ZodString>;
|
|
199
|
+
retries: z.ZodOptional<z.ZodNumber>;
|
|
200
|
+
worker: z.ZodOptional<z.ZodString>;
|
|
201
|
+
workId: z.ZodOptional<z.ZodString>;
|
|
202
|
+
success: z.ZodOptional<z.ZodBoolean>;
|
|
203
|
+
started: z.ZodOptional<z.ZodString>;
|
|
204
|
+
finished: z.ZodOptional<z.ZodString>;
|
|
205
|
+
status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
206
|
+
[x: string]: string;
|
|
207
|
+
}>>>;
|
|
208
|
+
eventId: z.ZodOptional<z.ZodString>;
|
|
209
|
+
created: z.ZodOptional<z.ZodString>;
|
|
210
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
211
|
+
}, z.core.$strip>;
|
|
212
|
+
export type SystemManagementParams = z.infer<typeof SystemManagementZodSchema>;
|
|
118
213
|
export type ActionName = keyof typeof actionValidators;
|
|
119
214
|
export type Params<T extends ActionName> = z.infer<(typeof actionValidators)[T]>;
|
|
120
215
|
export type Handler<T extends ActionName> = (modules: any, params: Params<T>) => Promise<unknown>;
|
|
@@ -1,140 +1,261 @@
|
|
|
1
|
-
import { z } from 'zod
|
|
2
|
-
import { PaginationSchema, SortingSchema, SearchSchema, DateRangeSchema,
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PaginationSchema, SortingSchema, SearchSchema, DateRangeSchema, } from "../../utils/sharedSchemas.js";
|
|
3
3
|
import { WorkStatus } from '@unchainedshop/core-worker';
|
|
4
4
|
export const WorkStatusKeys = Object.keys(WorkStatus);
|
|
5
5
|
export const ActiveWorkTypesSchema = z.object({});
|
|
6
6
|
export const actionValidators = {
|
|
7
7
|
SHOP_INFO: z
|
|
8
8
|
.object({})
|
|
9
|
-
.
|
|
9
|
+
.describe('Get shop configuration including default locale settings. No parameters expected - returns system-wide defaults.'),
|
|
10
10
|
WORKER_ADD: z.object({
|
|
11
11
|
type: z
|
|
12
12
|
.string()
|
|
13
|
-
.
|
|
13
|
+
.min(1)
|
|
14
|
+
.describe('Work type key that determines which worker/handler will process the job. Must match a registered worker type in the system.'),
|
|
14
15
|
priority: z
|
|
15
|
-
.
|
|
16
|
-
.
|
|
16
|
+
.number()
|
|
17
|
+
.int()
|
|
18
|
+
.default(0)
|
|
19
|
+
.describe('Job priority for queue ordering. Higher values are processed first. Default is 0. Negative values allowed for lower priority.'),
|
|
17
20
|
input: z
|
|
18
|
-
.
|
|
19
|
-
.
|
|
21
|
+
.any()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Arbitrary JSON payload passed to the worker. The structure depends on the work type and should be validated by the worker implementation.'),
|
|
20
24
|
originalWorkId: z
|
|
21
|
-
.
|
|
22
|
-
.
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('Reference to the original work item ID. Useful for tracking retries, parent-child relationships, or audit trails.'),
|
|
23
28
|
scheduled: z
|
|
24
|
-
.
|
|
25
|
-
.
|
|
29
|
+
.string()
|
|
30
|
+
.datetime()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('ISO 8601 timestamp when the job should be executed. If omitted, the job is immediately available for processing.'),
|
|
26
33
|
retries: z
|
|
27
|
-
.
|
|
28
|
-
.
|
|
34
|
+
.number()
|
|
35
|
+
.int()
|
|
36
|
+
.min(0)
|
|
37
|
+
.max(1000)
|
|
38
|
+
.default(20)
|
|
39
|
+
.describe('Maximum number of retry attempts allowed for this job. Default: 20.'),
|
|
29
40
|
worker: z
|
|
30
|
-
.
|
|
31
|
-
.
|
|
41
|
+
.string()
|
|
42
|
+
.optional()
|
|
43
|
+
.describe('Specific worker identifier to assign this job to. If provided, only that worker can process this job.'),
|
|
32
44
|
}),
|
|
33
|
-
WORKER_ACTIVE_WORK_TYPES: ActiveWorkTypesSchema.
|
|
45
|
+
WORKER_ACTIVE_WORK_TYPES: ActiveWorkTypesSchema.describe('Current active work types in the system. This includes all registered worker types that can process jobs. The list is dynamically generated based on the workers currently available. No parameters expected.'),
|
|
34
46
|
WORKER_ALLOCATE: z.object({
|
|
35
47
|
types: z
|
|
36
|
-
.
|
|
37
|
-
.
|
|
48
|
+
.array(z.string())
|
|
49
|
+
.nonempty()
|
|
50
|
+
.optional()
|
|
51
|
+
.describe('Must match a registered worker type in the system, When provided, the worker will take precedence in the queue and be allocated'),
|
|
38
52
|
worker: z
|
|
39
|
-
.
|
|
40
|
-
.
|
|
53
|
+
.string()
|
|
54
|
+
.optional()
|
|
55
|
+
.describe('Worker identifier that will process the allocated task. Used for tracking and locking the work item to this worker.'),
|
|
41
56
|
}),
|
|
42
57
|
WORKER_REMOVE: z.object({
|
|
43
58
|
workId: z
|
|
44
59
|
.string()
|
|
45
|
-
.
|
|
60
|
+
.describe('Unique identifier of the work item to remove from the queue. only NEW worker that is not deleted, allocated or finished'),
|
|
46
61
|
}),
|
|
47
62
|
WORKER_GET: z.object({
|
|
48
|
-
workId: z
|
|
49
|
-
.string()
|
|
50
|
-
.check(z.minLength(1), z.describe('Unique identifier of the work item to retrieve')),
|
|
63
|
+
workId: z.string().min(1).describe('Unique identifier of the work item to retrieve'),
|
|
51
64
|
}),
|
|
52
65
|
WORKER_LIST: z.object({
|
|
53
66
|
...PaginationSchema,
|
|
54
67
|
...SortingSchema,
|
|
55
68
|
...SearchSchema,
|
|
56
69
|
created: z
|
|
57
|
-
.
|
|
58
|
-
.
|
|
70
|
+
.object(DateRangeSchema)
|
|
71
|
+
.optional()
|
|
72
|
+
.describe('Date range filter for when work items were created'),
|
|
59
73
|
status: z
|
|
60
|
-
.
|
|
61
|
-
.
|
|
62
|
-
|
|
74
|
+
.array(z.enum(WorkStatusKeys))
|
|
75
|
+
.optional()
|
|
76
|
+
.describe('Filter by work item status (NEW, ALLOCATED, SUCCESS, FAILED, DELETED)'),
|
|
77
|
+
types: z.array(z.string()).optional().describe('Filter by specific work types'),
|
|
63
78
|
}),
|
|
64
79
|
WORKER_COUNT: z.object({
|
|
65
80
|
...SearchSchema,
|
|
66
81
|
created: z
|
|
67
|
-
.
|
|
68
|
-
.
|
|
82
|
+
.object(DateRangeSchema)
|
|
83
|
+
.optional()
|
|
84
|
+
.describe('Date range filter for when work items were created'),
|
|
69
85
|
status: z
|
|
70
|
-
.
|
|
71
|
-
.
|
|
72
|
-
|
|
86
|
+
.array(z.enum(WorkStatusKeys))
|
|
87
|
+
.optional()
|
|
88
|
+
.describe('Filter by work item status (NEW, ALLOCATED, SUCCESS, FAILED, DELETED)'),
|
|
89
|
+
types: z.array(z.string()).optional().describe('Filter by specific work types'),
|
|
73
90
|
}),
|
|
74
91
|
WORKER_FINISH_WORK: z.object({
|
|
75
|
-
workId: z.string().
|
|
92
|
+
workId: z.string().describe('Unique identifier of the work item to mark as completed.'),
|
|
76
93
|
result: z
|
|
77
|
-
.
|
|
78
|
-
.
|
|
94
|
+
.any()
|
|
95
|
+
.optional()
|
|
96
|
+
.describe('JSON result data produced by the work execution. Can be any valid JSON value.'),
|
|
79
97
|
error: z
|
|
80
|
-
.
|
|
81
|
-
.
|
|
98
|
+
.any()
|
|
99
|
+
.optional()
|
|
100
|
+
.describe('Error information if the work failed. Can be an error message, stack trace, or error object.'),
|
|
82
101
|
success: z
|
|
83
102
|
.boolean()
|
|
84
|
-
.
|
|
103
|
+
.describe('Whether the work completed successfully. Required to mark work as finished.'),
|
|
85
104
|
worker: z
|
|
86
|
-
.
|
|
87
|
-
.
|
|
105
|
+
.string()
|
|
106
|
+
.optional()
|
|
107
|
+
.describe('Identifier of the worker that completed the task. Used for logging and tracking purposes.'),
|
|
88
108
|
started: z
|
|
89
|
-
.
|
|
90
|
-
.
|
|
109
|
+
.string()
|
|
110
|
+
.datetime()
|
|
111
|
+
.optional()
|
|
112
|
+
.describe('ISO 8601 timestamp when the worker began executing this work item.'),
|
|
91
113
|
finished: z
|
|
92
|
-
.
|
|
93
|
-
.
|
|
114
|
+
.string()
|
|
115
|
+
.datetime()
|
|
116
|
+
.optional()
|
|
117
|
+
.describe('ISO 8601 timestamp when the work execution completed (success or failure).'),
|
|
94
118
|
}),
|
|
95
119
|
WORKER_PROCESS_NEXT: z.object({
|
|
96
120
|
worker: z
|
|
97
|
-
.
|
|
98
|
-
.
|
|
121
|
+
.string()
|
|
122
|
+
.optional()
|
|
123
|
+
.describe('Worker identifier for task allocation. If provided, assigns the next available task to this specific worker.'),
|
|
99
124
|
}),
|
|
100
125
|
WORKER_STATISTICS: z.object({
|
|
101
|
-
types: z.
|
|
102
|
-
dateRange: z
|
|
103
|
-
.optional(z.object(DateRangeSchema))
|
|
104
|
-
.check(z.describe('Date range to filter work statistics')),
|
|
126
|
+
types: z.array(z.string()).optional().describe('Filter statistics by specific work types'),
|
|
127
|
+
dateRange: z.object(DateRangeSchema).optional().describe('Date range to filter work statistics'),
|
|
105
128
|
}),
|
|
106
129
|
EVENT_GET: z.object({
|
|
107
130
|
eventId: z
|
|
108
131
|
.string()
|
|
109
|
-
.
|
|
132
|
+
.min(1)
|
|
133
|
+
.describe('Unique identifier of the event to retrieve from the event history'),
|
|
110
134
|
}),
|
|
111
135
|
EVENT_LIST: z.object({
|
|
112
136
|
...PaginationSchema,
|
|
113
137
|
...SortingSchema,
|
|
114
138
|
...SearchSchema,
|
|
115
139
|
types: z
|
|
116
|
-
.
|
|
117
|
-
.
|
|
140
|
+
.array(z.string())
|
|
141
|
+
.optional()
|
|
142
|
+
.describe('Filter events by specific event types (e.g., USER_CREATED, ORDER_PLACED)'),
|
|
118
143
|
created: z
|
|
119
|
-
.
|
|
120
|
-
.
|
|
144
|
+
.object(DateRangeSchema)
|
|
145
|
+
.optional()
|
|
146
|
+
.describe('Date range filter for when events are emitted/created'),
|
|
121
147
|
}),
|
|
122
148
|
EVENT_COUNT: z.object({
|
|
123
149
|
...SearchSchema,
|
|
124
150
|
types: z
|
|
125
|
-
.
|
|
126
|
-
.
|
|
151
|
+
.array(z.string())
|
|
152
|
+
.optional()
|
|
153
|
+
.describe('Filter events by specific event types (e.g., USER_CREATED, ORDER_PLACED)'),
|
|
127
154
|
created: z
|
|
128
|
-
.
|
|
129
|
-
.
|
|
155
|
+
.object(DateRangeSchema)
|
|
156
|
+
.optional()
|
|
157
|
+
.describe('Date range filter for when events are emitted/created'),
|
|
130
158
|
}),
|
|
131
159
|
EVENT_STATISTICS: z.object({
|
|
132
160
|
types: z
|
|
133
|
-
.
|
|
134
|
-
.
|
|
161
|
+
.array(z.string())
|
|
162
|
+
.optional()
|
|
163
|
+
.describe('Filter statistics by specific event types. If not provided, includes all event types'),
|
|
135
164
|
dateRange: z
|
|
136
|
-
.
|
|
137
|
-
.
|
|
165
|
+
.object(DateRangeSchema)
|
|
166
|
+
.optional()
|
|
167
|
+
.describe('Date range to filter event statistics. Includes start and/or end dates'),
|
|
138
168
|
}),
|
|
139
169
|
};
|
|
140
|
-
export const SystemManagementSchema =
|
|
170
|
+
export const SystemManagementSchema = {
|
|
171
|
+
action: z
|
|
172
|
+
.enum([
|
|
173
|
+
'SHOP_INFO',
|
|
174
|
+
'WORKER_ADD',
|
|
175
|
+
'WORKER_REMOVE',
|
|
176
|
+
'WORKER_COUNT',
|
|
177
|
+
'WORKER_GET',
|
|
178
|
+
'WORKER_LIST',
|
|
179
|
+
'WORKER_STATISTICS',
|
|
180
|
+
'WORKER_PROCESS_NEXT',
|
|
181
|
+
'WORKER_ALLOCATE',
|
|
182
|
+
'WORKER_FINISH_WORK',
|
|
183
|
+
'WORKER_ACTIVE_WORK_TYPES',
|
|
184
|
+
'EVENT_GET',
|
|
185
|
+
'EVENT_LIST',
|
|
186
|
+
'EVENT_COUNT',
|
|
187
|
+
'EVENT_STATISTICS',
|
|
188
|
+
])
|
|
189
|
+
.describe('Action to perform on the system. System actions: SHOP_INFO (get shop configuration). Worker actions: WORKER_ADD (add work), WORKER_ALLOCATE (assign work), WORKER_REMOVE (delete work), WORKER_GET (retrieve work), WORKER_LIST (search work), WORKER_COUNT (count work), WORKER_FINISH_WORK (complete work), WORKER_PROCESS_NEXT (get next work), WORKER_STATISTICS (work stats), WORKER_ACTIVE_WORK_TYPES (get active work types). Event actions: EVENT_GET (retrieve event), EVENT_LIST (search events), EVENT_COUNT (count events), EVENT_STATISTICS (event stats).'),
|
|
190
|
+
type: z
|
|
191
|
+
.string()
|
|
192
|
+
.min(1)
|
|
193
|
+
.optional()
|
|
194
|
+
.describe('Work type key for WORKER_ADD action. Determines which worker/handler will process the job.'),
|
|
195
|
+
priority: z
|
|
196
|
+
.number()
|
|
197
|
+
.int()
|
|
198
|
+
.optional()
|
|
199
|
+
.describe('Job priority for WORKER_ADD action. Higher values processed first. Default: 0.'),
|
|
200
|
+
originalWorkId: z
|
|
201
|
+
.string()
|
|
202
|
+
.optional()
|
|
203
|
+
.describe('Reference to original work item ID for WORKER_ADD action. For tracking retries/relationships.'),
|
|
204
|
+
scheduled: z
|
|
205
|
+
.string()
|
|
206
|
+
.datetime()
|
|
207
|
+
.optional()
|
|
208
|
+
.describe('ISO 8601 timestamp for WORKER_ADD action. When job should be executed.'),
|
|
209
|
+
retries: z
|
|
210
|
+
.number()
|
|
211
|
+
.int()
|
|
212
|
+
.optional()
|
|
213
|
+
.describe('Maximum retry attempts for WORKER_ADD action. Default: 20.'),
|
|
214
|
+
worker: z
|
|
215
|
+
.string()
|
|
216
|
+
.optional()
|
|
217
|
+
.describe('Worker identifier. Used in WORKER_ADD, WORKER_ALLOCATE, WORKER_FINISH_WORK, WORKER_PROCESS_NEXT actions.'),
|
|
218
|
+
workId: z
|
|
219
|
+
.string()
|
|
220
|
+
.optional()
|
|
221
|
+
.describe('Unique work identifier. Required for WORKER_GET, WORKER_REMOVE, WORKER_FINISH_WORK actions.'),
|
|
222
|
+
success: z
|
|
223
|
+
.boolean()
|
|
224
|
+
.optional()
|
|
225
|
+
.describe('Success status for WORKER_FINISH_WORK action. Required to mark work as finished.'),
|
|
226
|
+
started: z
|
|
227
|
+
.string()
|
|
228
|
+
.datetime()
|
|
229
|
+
.optional()
|
|
230
|
+
.describe('ISO 8601 start timestamp for WORKER_FINISH_WORK action. When worker began execution.'),
|
|
231
|
+
finished: z
|
|
232
|
+
.string()
|
|
233
|
+
.datetime()
|
|
234
|
+
.optional()
|
|
235
|
+
.describe('ISO 8601 finish timestamp for WORKER_FINISH_WORK action. When work completed.'),
|
|
236
|
+
status: z
|
|
237
|
+
.array(z.enum(WorkStatusKeys))
|
|
238
|
+
.optional()
|
|
239
|
+
.describe('Status filter for WORKER_LIST/WORKER_COUNT actions. Work item statuses to include.'),
|
|
240
|
+
eventId: z
|
|
241
|
+
.string()
|
|
242
|
+
.optional()
|
|
243
|
+
.describe('Unique event identifier. Required for EVENT_GET action to retrieve a specific event.'),
|
|
244
|
+
created: z
|
|
245
|
+
.string()
|
|
246
|
+
.datetime()
|
|
247
|
+
.optional()
|
|
248
|
+
.describe('ISO 8601 timestamp filter for EVENT_LIST/EVENT_COUNT actions. Shows events created on or after this date/time.'),
|
|
249
|
+
types: z
|
|
250
|
+
.array(z.string())
|
|
251
|
+
.optional()
|
|
252
|
+
.describe('Filter by specific types. For worker actions: use in WORKER_LIST, WORKER_ALLOCATE work types. For event actions: event types (e.g., USER_CREATED, ORDER_PLACED).'),
|
|
253
|
+
...PaginationSchema,
|
|
254
|
+
...SortingSchema,
|
|
255
|
+
...SearchSchema,
|
|
256
|
+
dateRange: z
|
|
257
|
+
.object(DateRangeSchema)
|
|
258
|
+
.optional()
|
|
259
|
+
.describe('Date range filter for WORKER_STATISTICS/EVENT_STATISTICS actions. Filter statistics by date range.'),
|
|
260
|
+
};
|
|
261
|
+
export const SystemManagementZodSchema = z.object(SystemManagementSchema);
|
|
@@ -6,5 +6,5 @@ export declare function systemManagement(context: Context, params: SystemManagem
|
|
|
6
6
|
text: string;
|
|
7
7
|
}[];
|
|
8
8
|
}>;
|
|
9
|
-
export { SystemManagementSchema } from './schemas.ts';
|
|
9
|
+
export { SystemManagementSchema, SystemManagementZodSchema } from './schemas.ts';
|
|
10
10
|
export type { SystemManagementParams } from './schemas.ts';
|