@erxes/core-contract 0.1.0-v2.2 → 0.1.0-v2.4
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/dist/automations.d.ts +5 -7
- package/dist/automations.js +6 -4
- package/dist/client.d.ts +302 -10
- package/dist/contract/routes.json.js +16 -0
- package/dist/emails.d.ts +105 -0
- package/dist/emails.js +25 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +1 -0
- package/dist/index.d.ts +291 -9
- package/dist/index.js +4 -2
- package/dist/plugins.d.ts +82 -1
- package/dist/plugins.js +14 -3
- package/dist/roles.d.ts +136 -0
- package/dist/roles.js +22 -1
- package/package.json +2 -1
package/dist/plugins.d.ts
CHANGED
|
@@ -5,12 +5,13 @@ export declare const PluginName: z.ZodString;
|
|
|
5
5
|
* What a plugin may do in core, granted per organisation when it is
|
|
6
6
|
* installed. A plugin only ever gets the scopes it asked for in its manifest.
|
|
7
7
|
*/
|
|
8
|
-
export declare const PLUGIN_SCOPES: readonly ['activities:write', 'customers:read', 'customers:write', 'audit:write', 'events:read', 'events:write', 'files:read', 'files:write', 'live:write', 'notifications:write', 'payments:read', 'payments:write', 'products:read', 'products:write'];
|
|
8
|
+
export declare const PLUGIN_SCOPES: readonly ['activities:write', 'customers:read', 'customers:write', 'audit:write', 'emails:write', 'events:read', 'events:write', 'files:read', 'files:write', 'live:write', 'notifications:write', 'payments:read', 'payments:write', 'products:read', 'products:write', 'users:read'];
|
|
9
9
|
export declare const PluginScope: z.ZodEnum<{
|
|
10
10
|
"activities:write": "activities:write";
|
|
11
11
|
"audit:write": "audit:write";
|
|
12
12
|
"customers:read": "customers:read";
|
|
13
13
|
"customers:write": "customers:write";
|
|
14
|
+
"emails:write": "emails:write";
|
|
14
15
|
"events:read": "events:read";
|
|
15
16
|
"events:write": "events:write";
|
|
16
17
|
"files:read": "files:read";
|
|
@@ -21,6 +22,7 @@ export declare const PluginScope: z.ZodEnum<{
|
|
|
21
22
|
"payments:write": "payments:write";
|
|
22
23
|
"products:read": "products:read";
|
|
23
24
|
"products:write": "products:write";
|
|
25
|
+
"users:read": "users:read";
|
|
24
26
|
}>;
|
|
25
27
|
export type PluginScope = z.infer<typeof PluginScope>;
|
|
26
28
|
/** Live update topic: `leave-requests`, `leave:abc123`. */
|
|
@@ -48,6 +50,7 @@ export declare const PluginManifest: z.ZodObject<{
|
|
|
48
50
|
"audit:write": "audit:write";
|
|
49
51
|
"customers:read": "customers:read";
|
|
50
52
|
"customers:write": "customers:write";
|
|
53
|
+
"emails:write": "emails:write";
|
|
51
54
|
"events:read": "events:read";
|
|
52
55
|
"events:write": "events:write";
|
|
53
56
|
"files:read": "files:read";
|
|
@@ -58,6 +61,7 @@ export declare const PluginManifest: z.ZodObject<{
|
|
|
58
61
|
"payments:write": "payments:write";
|
|
59
62
|
"products:read": "products:read";
|
|
60
63
|
"products:write": "products:write";
|
|
64
|
+
"users:read": "users:read";
|
|
61
65
|
}>>>;
|
|
62
66
|
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
63
67
|
action: z.ZodString;
|
|
@@ -65,6 +69,12 @@ export declare const PluginManifest: z.ZodObject<{
|
|
|
65
69
|
description: z.ZodOptional<z.ZodString>;
|
|
66
70
|
group: z.ZodOptional<z.ZodString>;
|
|
67
71
|
}, z.core.$strip>>>;
|
|
72
|
+
permissionSets: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
73
|
+
key: z.ZodString;
|
|
74
|
+
label: z.ZodString;
|
|
75
|
+
description: z.ZodOptional<z.ZodString>;
|
|
76
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
77
|
+
}, z.core.$strip>>>;
|
|
68
78
|
notificationKinds: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
69
79
|
kind: z.ZodString;
|
|
70
80
|
label: z.ZodString;
|
|
@@ -274,6 +284,9 @@ export declare const pluginsContract: {
|
|
|
274
284
|
CROSS_SITE: {
|
|
275
285
|
status: number;
|
|
276
286
|
};
|
|
287
|
+
DUPLICATE_PERMISSION_SET: {
|
|
288
|
+
status: number;
|
|
289
|
+
};
|
|
277
290
|
INVALID_CLIENT: {
|
|
278
291
|
status: number;
|
|
279
292
|
};
|
|
@@ -289,6 +302,12 @@ export declare const pluginsContract: {
|
|
|
289
302
|
PLUGIN_NOT_FOUND: {
|
|
290
303
|
status: number;
|
|
291
304
|
};
|
|
305
|
+
UNKNOWN_PERMISSION: {
|
|
306
|
+
status: number;
|
|
307
|
+
data: z.ZodObject<{
|
|
308
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
309
|
+
}, z.core.$strip>;
|
|
310
|
+
};
|
|
292
311
|
}>, Record<never, never>>;
|
|
293
312
|
registerManifest: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
294
313
|
title: z.ZodString;
|
|
@@ -313,6 +332,7 @@ export declare const pluginsContract: {
|
|
|
313
332
|
"audit:write": "audit:write";
|
|
314
333
|
"customers:read": "customers:read";
|
|
315
334
|
"customers:write": "customers:write";
|
|
335
|
+
"emails:write": "emails:write";
|
|
316
336
|
"events:read": "events:read";
|
|
317
337
|
"events:write": "events:write";
|
|
318
338
|
"files:read": "files:read";
|
|
@@ -323,6 +343,7 @@ export declare const pluginsContract: {
|
|
|
323
343
|
"payments:write": "payments:write";
|
|
324
344
|
"products:read": "products:read";
|
|
325
345
|
"products:write": "products:write";
|
|
346
|
+
"users:read": "users:read";
|
|
326
347
|
}>>>;
|
|
327
348
|
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
328
349
|
action: z.ZodString;
|
|
@@ -330,6 +351,12 @@ export declare const pluginsContract: {
|
|
|
330
351
|
description: z.ZodOptional<z.ZodString>;
|
|
331
352
|
group: z.ZodOptional<z.ZodString>;
|
|
332
353
|
}, z.core.$strip>>>;
|
|
354
|
+
permissionSets: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
355
|
+
key: z.ZodString;
|
|
356
|
+
label: z.ZodString;
|
|
357
|
+
description: z.ZodOptional<z.ZodString>;
|
|
358
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
359
|
+
}, z.core.$strip>>>;
|
|
333
360
|
notificationKinds: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
334
361
|
kind: z.ZodString;
|
|
335
362
|
label: z.ZodString;
|
|
@@ -475,6 +502,9 @@ export declare const pluginsContract: {
|
|
|
475
502
|
CROSS_SITE: {
|
|
476
503
|
status: number;
|
|
477
504
|
};
|
|
505
|
+
DUPLICATE_PERMISSION_SET: {
|
|
506
|
+
status: number;
|
|
507
|
+
};
|
|
478
508
|
INVALID_CLIENT: {
|
|
479
509
|
status: number;
|
|
480
510
|
};
|
|
@@ -490,6 +520,12 @@ export declare const pluginsContract: {
|
|
|
490
520
|
PLUGIN_NOT_FOUND: {
|
|
491
521
|
status: number;
|
|
492
522
|
};
|
|
523
|
+
UNKNOWN_PERMISSION: {
|
|
524
|
+
status: number;
|
|
525
|
+
data: z.ZodObject<{
|
|
526
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
527
|
+
}, z.core.$strip>;
|
|
528
|
+
};
|
|
493
529
|
}>, Record<never, never>>;
|
|
494
530
|
list: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodObject<{
|
|
495
531
|
data: z.ZodArray<z.ZodObject<{
|
|
@@ -606,6 +642,9 @@ export declare const pluginsContract: {
|
|
|
606
642
|
CROSS_SITE: {
|
|
607
643
|
status: number;
|
|
608
644
|
};
|
|
645
|
+
DUPLICATE_PERMISSION_SET: {
|
|
646
|
+
status: number;
|
|
647
|
+
};
|
|
609
648
|
INVALID_CLIENT: {
|
|
610
649
|
status: number;
|
|
611
650
|
};
|
|
@@ -621,6 +660,12 @@ export declare const pluginsContract: {
|
|
|
621
660
|
PLUGIN_NOT_FOUND: {
|
|
622
661
|
status: number;
|
|
623
662
|
};
|
|
663
|
+
UNKNOWN_PERMISSION: {
|
|
664
|
+
status: number;
|
|
665
|
+
data: z.ZodObject<{
|
|
666
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
667
|
+
}, z.core.$strip>;
|
|
668
|
+
};
|
|
624
669
|
}>, Record<never, never>>;
|
|
625
670
|
install: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
626
671
|
name: z.ZodString;
|
|
@@ -737,6 +782,9 @@ export declare const pluginsContract: {
|
|
|
737
782
|
CROSS_SITE: {
|
|
738
783
|
status: number;
|
|
739
784
|
};
|
|
785
|
+
DUPLICATE_PERMISSION_SET: {
|
|
786
|
+
status: number;
|
|
787
|
+
};
|
|
740
788
|
INVALID_CLIENT: {
|
|
741
789
|
status: number;
|
|
742
790
|
};
|
|
@@ -752,6 +800,12 @@ export declare const pluginsContract: {
|
|
|
752
800
|
PLUGIN_NOT_FOUND: {
|
|
753
801
|
status: number;
|
|
754
802
|
};
|
|
803
|
+
UNKNOWN_PERMISSION: {
|
|
804
|
+
status: number;
|
|
805
|
+
data: z.ZodObject<{
|
|
806
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
807
|
+
}, z.core.$strip>;
|
|
808
|
+
};
|
|
755
809
|
}>, Record<never, never>>;
|
|
756
810
|
uninstall: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
757
811
|
name: z.ZodString;
|
|
@@ -868,6 +922,9 @@ export declare const pluginsContract: {
|
|
|
868
922
|
CROSS_SITE: {
|
|
869
923
|
status: number;
|
|
870
924
|
};
|
|
925
|
+
DUPLICATE_PERMISSION_SET: {
|
|
926
|
+
status: number;
|
|
927
|
+
};
|
|
871
928
|
INVALID_CLIENT: {
|
|
872
929
|
status: number;
|
|
873
930
|
};
|
|
@@ -883,6 +940,12 @@ export declare const pluginsContract: {
|
|
|
883
940
|
PLUGIN_NOT_FOUND: {
|
|
884
941
|
status: number;
|
|
885
942
|
};
|
|
943
|
+
UNKNOWN_PERMISSION: {
|
|
944
|
+
status: number;
|
|
945
|
+
data: z.ZodObject<{
|
|
946
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
947
|
+
}, z.core.$strip>;
|
|
948
|
+
};
|
|
886
949
|
}>, Record<never, never>>;
|
|
887
950
|
session: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
888
951
|
name: z.ZodString;
|
|
@@ -971,6 +1034,9 @@ export declare const pluginsContract: {
|
|
|
971
1034
|
CROSS_SITE: {
|
|
972
1035
|
status: number;
|
|
973
1036
|
};
|
|
1037
|
+
DUPLICATE_PERMISSION_SET: {
|
|
1038
|
+
status: number;
|
|
1039
|
+
};
|
|
974
1040
|
INVALID_CLIENT: {
|
|
975
1041
|
status: number;
|
|
976
1042
|
};
|
|
@@ -986,6 +1052,12 @@ export declare const pluginsContract: {
|
|
|
986
1052
|
PLUGIN_NOT_FOUND: {
|
|
987
1053
|
status: number;
|
|
988
1054
|
};
|
|
1055
|
+
UNKNOWN_PERMISSION: {
|
|
1056
|
+
status: number;
|
|
1057
|
+
data: z.ZodObject<{
|
|
1058
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
1059
|
+
}, z.core.$strip>;
|
|
1060
|
+
};
|
|
989
1061
|
}>, Record<never, never>>;
|
|
990
1062
|
signal: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
991
1063
|
topics: z.ZodArray<z.ZodString>;
|
|
@@ -1073,6 +1145,9 @@ export declare const pluginsContract: {
|
|
|
1073
1145
|
CROSS_SITE: {
|
|
1074
1146
|
status: number;
|
|
1075
1147
|
};
|
|
1148
|
+
DUPLICATE_PERMISSION_SET: {
|
|
1149
|
+
status: number;
|
|
1150
|
+
};
|
|
1076
1151
|
INVALID_CLIENT: {
|
|
1077
1152
|
status: number;
|
|
1078
1153
|
};
|
|
@@ -1088,5 +1163,11 @@ export declare const pluginsContract: {
|
|
|
1088
1163
|
PLUGIN_NOT_FOUND: {
|
|
1089
1164
|
status: number;
|
|
1090
1165
|
};
|
|
1166
|
+
UNKNOWN_PERMISSION: {
|
|
1167
|
+
status: number;
|
|
1168
|
+
data: z.ZodObject<{
|
|
1169
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
1170
|
+
}, z.core.$strip>;
|
|
1171
|
+
};
|
|
1091
1172
|
}>, Record<never, never>>;
|
|
1092
1173
|
};
|
package/dist/plugins.js
CHANGED
|
@@ -7,6 +7,7 @@ import { Id, isoDate, listOf } from "./common.js";
|
|
|
7
7
|
import { ActionField } from "./automationRuns.js";
|
|
8
8
|
import { Country } from "./money.js";
|
|
9
9
|
import { EventType } from "./platform.js";
|
|
10
|
+
import { ManifestPermissionSet } from "./roles.js";
|
|
10
11
|
import { oc } from "@orpc/contract";
|
|
11
12
|
import { z } from "zod";
|
|
12
13
|
import { createSelectSchema } from "drizzle-zod";
|
|
@@ -22,6 +23,7 @@ const PLUGIN_SCOPES = [
|
|
|
22
23
|
"customers:read",
|
|
23
24
|
"customers:write",
|
|
24
25
|
"audit:write",
|
|
26
|
+
"emails:write",
|
|
25
27
|
"events:read",
|
|
26
28
|
"events:write",
|
|
27
29
|
"files:read",
|
|
@@ -31,7 +33,8 @@ const PLUGIN_SCOPES = [
|
|
|
31
33
|
"payments:read",
|
|
32
34
|
"payments:write",
|
|
33
35
|
"products:read",
|
|
34
|
-
"products:write"
|
|
36
|
+
"products:write",
|
|
37
|
+
"users:read"
|
|
35
38
|
];
|
|
36
39
|
const PluginScope = z.enum(PLUGIN_SCOPES);
|
|
37
40
|
/** Live update topic: `leave-requests`, `leave:abc123`. */
|
|
@@ -81,6 +84,12 @@ const PluginManifest = z.object({
|
|
|
81
84
|
description: z.string().trim().max(300).optional(),
|
|
82
85
|
group: z.string().trim().max(60).optional()
|
|
83
86
|
})).max(500).optional(),
|
|
87
|
+
/**
|
|
88
|
+
* Ready-made bundles of its own permissions (`agent`: reply, assign, view),
|
|
89
|
+
* which an owner adds to any role in one click. Members keep one role, so a
|
|
90
|
+
* plugin offers sets instead of roles of its own.
|
|
91
|
+
*/
|
|
92
|
+
permissionSets: z.array(ManifestPermissionSet).max(20).optional(),
|
|
84
93
|
notificationKinds: z.array(z.object({
|
|
85
94
|
kind: EventType,
|
|
86
95
|
label: z.string().trim().min(1).max(100),
|
|
@@ -178,16 +187,18 @@ const TokenResponse = z.object({
|
|
|
178
187
|
* plugin UIs (a member's short-lived session for one plugin's API), and live
|
|
179
188
|
* signals to plugin UIs.
|
|
180
189
|
*/
|
|
181
|
-
const { CROSS_SITE, INVALID_CLIENT, LIMIT_EXCEEDED, NAMESPACE_REQUIRED, NOT_INSTALLED, PLUGIN_NOT_FOUND } = ERRORS;
|
|
190
|
+
const { CROSS_SITE, DUPLICATE_PERMISSION_SET, INVALID_CLIENT, LIMIT_EXCEEDED, NAMESPACE_REQUIRED, NOT_INSTALLED, PLUGIN_NOT_FOUND, UNKNOWN_PERMISSION } = ERRORS;
|
|
182
191
|
/** What these procedures answer with besides the common errors. */
|
|
183
192
|
const base = oc.errors({
|
|
184
193
|
...COMMON_ERRORS,
|
|
185
194
|
CROSS_SITE,
|
|
195
|
+
DUPLICATE_PERMISSION_SET,
|
|
186
196
|
INVALID_CLIENT,
|
|
187
197
|
LIMIT_EXCEEDED,
|
|
188
198
|
NAMESPACE_REQUIRED,
|
|
189
199
|
NOT_INSTALLED,
|
|
190
|
-
PLUGIN_NOT_FOUND
|
|
200
|
+
PLUGIN_NOT_FOUND,
|
|
201
|
+
UNKNOWN_PERMISSION
|
|
191
202
|
});
|
|
192
203
|
const pluginsContract = {
|
|
193
204
|
token: base.route({
|
package/dist/roles.d.ts
CHANGED
|
@@ -152,6 +152,22 @@ export declare const PermissionInfo: z.ZodObject<{
|
|
|
152
152
|
ownerOnly: z.ZodBoolean;
|
|
153
153
|
}, z.core.$strip>;
|
|
154
154
|
export type PermissionInfo = z.infer<typeof PermissionInfo>;
|
|
155
|
+
/** A plugin's ready-made bundle of its permissions (`frontline` `agent`), added to a role at once. */
|
|
156
|
+
/** A bundle of a plugin's own permissions, as its manifest declares it. */
|
|
157
|
+
export declare const ManifestPermissionSet: z.ZodObject<{
|
|
158
|
+
key: z.ZodString;
|
|
159
|
+
label: z.ZodString;
|
|
160
|
+
description: z.ZodOptional<z.ZodString>;
|
|
161
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
162
|
+
}, z.core.$strip>;
|
|
163
|
+
export declare const PermissionSet: z.ZodObject<{
|
|
164
|
+
source: z.ZodString;
|
|
165
|
+
key: z.ZodString;
|
|
166
|
+
label: z.ZodString;
|
|
167
|
+
description: z.ZodNullable<z.ZodString>;
|
|
168
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
169
|
+
}, z.core.$strip>;
|
|
170
|
+
export type PermissionSet = z.infer<typeof PermissionSet>;
|
|
155
171
|
export declare const rolesContract: {
|
|
156
172
|
list: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodObject<{
|
|
157
173
|
data: z.ZodArray<z.ZodObject<{
|
|
@@ -399,6 +415,126 @@ export declare const rolesContract: {
|
|
|
399
415
|
}, z.core.$strip>;
|
|
400
416
|
};
|
|
401
417
|
}>, Record<never, never>>;
|
|
418
|
+
permissionSets: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, z.ZodObject<{
|
|
419
|
+
data: z.ZodArray<z.ZodObject<{
|
|
420
|
+
source: z.ZodString;
|
|
421
|
+
key: z.ZodString;
|
|
422
|
+
label: z.ZodString;
|
|
423
|
+
description: z.ZodNullable<z.ZodString>;
|
|
424
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
425
|
+
}, z.core.$strip>>;
|
|
426
|
+
}, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
|
|
427
|
+
UNAUTHORIZED: {
|
|
428
|
+
status: number;
|
|
429
|
+
};
|
|
430
|
+
NOT_ALLOWED: {
|
|
431
|
+
status: number;
|
|
432
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
433
|
+
permission: z.ZodString;
|
|
434
|
+
}, z.core.$strip>>;
|
|
435
|
+
};
|
|
436
|
+
PLUGIN_ONLY: {
|
|
437
|
+
status: number;
|
|
438
|
+
};
|
|
439
|
+
MEMBERS_ONLY: {
|
|
440
|
+
status: number;
|
|
441
|
+
};
|
|
442
|
+
ORG_REQUIRED: {
|
|
443
|
+
status: number;
|
|
444
|
+
};
|
|
445
|
+
SCOPE_REQUIRED: {
|
|
446
|
+
status: number;
|
|
447
|
+
};
|
|
448
|
+
SERVICE_TOKEN_REQUIRED: {
|
|
449
|
+
status: number;
|
|
450
|
+
};
|
|
451
|
+
ORGANIZATION_DISABLED: {
|
|
452
|
+
status: number;
|
|
453
|
+
data: z.ZodObject<{
|
|
454
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
455
|
+
}, z.core.$strip>;
|
|
456
|
+
};
|
|
457
|
+
NOT_IN_PLAN: {
|
|
458
|
+
status: number;
|
|
459
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
460
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
461
|
+
}, z.core.$strip>>;
|
|
462
|
+
};
|
|
463
|
+
READ_ONLY: {
|
|
464
|
+
status: number;
|
|
465
|
+
};
|
|
466
|
+
TOO_MANY_REQUESTS: {
|
|
467
|
+
status: number;
|
|
468
|
+
};
|
|
469
|
+
INVALID_INPUT: {
|
|
470
|
+
status: number;
|
|
471
|
+
data: z.ZodObject<{
|
|
472
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
473
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
474
|
+
message: z.ZodString;
|
|
475
|
+
}, z.core.$strip>>;
|
|
476
|
+
}, z.core.$strip>;
|
|
477
|
+
};
|
|
478
|
+
NOT_FOUND: {
|
|
479
|
+
status: number;
|
|
480
|
+
};
|
|
481
|
+
TAKEN: {
|
|
482
|
+
status: number;
|
|
483
|
+
data: z.ZodObject<{
|
|
484
|
+
field: z.ZodString;
|
|
485
|
+
id: z.ZodOptional<z.ZodString>;
|
|
486
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
487
|
+
}, z.core.$strip>;
|
|
488
|
+
};
|
|
489
|
+
INVALID_CURSOR: {
|
|
490
|
+
status: number;
|
|
491
|
+
};
|
|
492
|
+
INVALID_REFERENCE: {
|
|
493
|
+
status: number;
|
|
494
|
+
data: z.ZodObject<{
|
|
495
|
+
field: z.ZodString;
|
|
496
|
+
}, z.core.$strip>;
|
|
497
|
+
};
|
|
498
|
+
INVALID_FILTER: {
|
|
499
|
+
status: number;
|
|
500
|
+
};
|
|
501
|
+
FILTER_TOO_SLOW: {
|
|
502
|
+
status: number;
|
|
503
|
+
};
|
|
504
|
+
BEYOND_OWN_PERMISSIONS: {
|
|
505
|
+
status: number;
|
|
506
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
507
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
508
|
+
}, z.core.$strip>>;
|
|
509
|
+
};
|
|
510
|
+
BUILTIN_ROLE: {
|
|
511
|
+
status: number;
|
|
512
|
+
};
|
|
513
|
+
FIXED_ROLE: {
|
|
514
|
+
status: number;
|
|
515
|
+
};
|
|
516
|
+
LIMIT_EXCEEDED: {
|
|
517
|
+
status: number;
|
|
518
|
+
};
|
|
519
|
+
OWNER_ONLY_PERMISSION: {
|
|
520
|
+
status: number;
|
|
521
|
+
data: z.ZodObject<{
|
|
522
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
523
|
+
}, z.core.$strip>;
|
|
524
|
+
};
|
|
525
|
+
ROLE_IN_USE: {
|
|
526
|
+
status: number;
|
|
527
|
+
};
|
|
528
|
+
ROLE_NOT_FOUND: {
|
|
529
|
+
status: number;
|
|
530
|
+
};
|
|
531
|
+
UNKNOWN_PERMISSION: {
|
|
532
|
+
status: number;
|
|
533
|
+
data: z.ZodObject<{
|
|
534
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
535
|
+
}, z.core.$strip>;
|
|
536
|
+
};
|
|
537
|
+
}>, Record<never, never>>;
|
|
402
538
|
create: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
403
539
|
name: z.ZodNonOptional<z.ZodOptional<z.ZodString>>;
|
|
404
540
|
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
package/dist/roles.js
CHANGED
|
@@ -187,6 +187,22 @@ const PermissionInfo = z.object({
|
|
|
187
187
|
source: z.string(),
|
|
188
188
|
ownerOnly: z.boolean()
|
|
189
189
|
});
|
|
190
|
+
/** A plugin's ready-made bundle of its permissions (`frontline` `agent`), added to a role at once. */
|
|
191
|
+
/** A bundle of a plugin's own permissions, as its manifest declares it. */
|
|
192
|
+
const ManifestPermissionSet = z.object({
|
|
193
|
+
key: z.string().regex(/^[a-z][a-z0-9_]{0,39}$/),
|
|
194
|
+
label: z.string().trim().min(1).max(100),
|
|
195
|
+
description: z.string().trim().max(300).optional(),
|
|
196
|
+
permissions: z.array(PermissionAction).min(1).max(500)
|
|
197
|
+
});
|
|
198
|
+
const PermissionSet = z.object({
|
|
199
|
+
/** The plugin that offers it. */
|
|
200
|
+
source: z.string(),
|
|
201
|
+
key: z.string(),
|
|
202
|
+
label: z.string(),
|
|
203
|
+
description: z.string().nullable(),
|
|
204
|
+
permissions: z.array(z.string())
|
|
205
|
+
});
|
|
190
206
|
const RoleFields = createUpdateSchema(roles, {
|
|
191
207
|
name: (name) => name.trim().min(1).max(60),
|
|
192
208
|
description: (value) => value.trim().max(300),
|
|
@@ -220,6 +236,11 @@ const rolesContract = {
|
|
|
220
236
|
path: "/permissions",
|
|
221
237
|
summary: "Every action a role can include: core's and installed plugins'"
|
|
222
238
|
}).output(listOf(PermissionInfo)),
|
|
239
|
+
permissionSets: base.route({
|
|
240
|
+
method: "GET",
|
|
241
|
+
path: "/permission-sets",
|
|
242
|
+
summary: "Installed plugins' ready-made bundles of their permissions, to add to a role"
|
|
243
|
+
}).output(listOf(PermissionSet)),
|
|
223
244
|
create: base.route({
|
|
224
245
|
method: "POST",
|
|
225
246
|
path: "/roles",
|
|
@@ -240,4 +261,4 @@ const rolesContract = {
|
|
|
240
261
|
summary: "Delete a custom role nobody has (roles.manage); 409 ROLE_IN_USE"
|
|
241
262
|
}).input(z.object({ key: RoleKey })).output(z.object({ ok: z.literal(true) }))
|
|
242
263
|
};
|
|
243
|
-
export { CORE_PERMISSIONS, OWNER_ONLY_PERMISSIONS, PermissionAction, PermissionInfo, Role, rolesContract };
|
|
264
|
+
export { CORE_PERMISSIONS, ManifestPermissionSet, OWNER_ONLY_PERMISSIONS, PermissionAction, PermissionInfo, PermissionSet, Role, rolesContract };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erxes/core-contract",
|
|
3
|
-
"version": "0.1.0-v2.
|
|
3
|
+
"version": "0.1.0-v2.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "erxes core API contract (/core/v1) and event schemas, shared by core and plugins",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"./companies": "./dist/companies.js",
|
|
27
27
|
"./customerAuth": "./dist/customerAuth.js",
|
|
28
28
|
"./customers": "./dist/customers.js",
|
|
29
|
+
"./emails": "./dist/emails.js",
|
|
29
30
|
"./errors": "./dist/errors.js",
|
|
30
31
|
"./events": "./dist/events.js",
|
|
31
32
|
"./fields": "./dist/fields.js",
|