@stndrds/schema 0.1.0-alpha.67 → 1.0.0-alpha.100
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/attributes-CH89Z_J-.d.mts +675 -0
- package/dist/attributes-dw-jLtYS.d.ts +675 -0
- package/dist/chunk-2LUHLHLE.mjs +8 -0
- package/dist/chunk-3RFFA4EV.mjs +14 -0
- package/dist/chunk-4DMDOSFN.js +10 -0
- package/dist/chunk-4IVCBFJA.mjs +12 -0
- package/dist/chunk-5CBTJS7J.js +22 -0
- package/dist/chunk-5SQEKHPW.js +78 -0
- package/dist/chunk-6IFD5732.js +10 -0
- package/dist/chunk-6MXQAQBB.mjs +18 -0
- package/dist/chunk-7FSIBNRH.mjs +25 -0
- package/dist/chunk-ALV6GETG.mjs +10 -0
- package/dist/chunk-ANP6HGMJ.js +64 -0
- package/dist/chunk-ATA4XHB4.js +20 -0
- package/dist/chunk-BEN6TE7Y.js +11 -0
- package/dist/chunk-BZTLI773.mjs +8 -0
- package/dist/chunk-C7KW4NAD.js +20 -0
- package/dist/chunk-CE25ADK5.js +212 -0
- package/dist/chunk-E6XO2STS.js +61 -0
- package/dist/chunk-EKG35CSO.mjs +1 -0
- package/dist/chunk-ERG77ADK.mjs +18 -0
- package/dist/chunk-FKETRWAF.js +10 -0
- package/dist/chunk-FKPYFM6G.mjs +14 -0
- package/dist/chunk-H3VBSMVW.js +105 -0
- package/dist/chunk-HJNLL34O.js +12 -0
- package/dist/chunk-IMEPIVTR.js +217 -0
- package/dist/chunk-JEDANRCG.mjs +74 -0
- package/dist/chunk-KC2FFNL4.js +16 -0
- package/dist/chunk-OO2LJ6GP.js +32 -0
- package/dist/chunk-P4NGPF5L.mjs +99 -0
- package/dist/chunk-PGHTIMRD.mjs +199 -0
- package/dist/chunk-PZT3CIHD.mjs +192 -0
- package/dist/chunk-QPDXDX7A.js +16 -0
- package/dist/chunk-R6JFUC32.js +2 -0
- package/dist/chunk-RDGBQM3N.mjs +20 -0
- package/dist/chunk-RDXQ4CYT.mjs +9 -0
- package/dist/chunk-STKN6A5M.js +14 -0
- package/dist/chunk-TV4G2KMD.mjs +8 -0
- package/dist/chunk-UPEQEX2D.js +10 -0
- package/dist/chunk-VC4E3OSZ.mjs +8 -0
- package/dist/{chunk-V2RPPE2Y.mjs → chunk-XAORXFAX.mjs} +20 -9
- package/dist/chunk-XPFWKISJ.mjs +60 -0
- package/dist/chunk-ZJNX6UXB.mjs +28 -0
- package/dist/chunk-ZWMMEQI7.js +28 -0
- package/dist/index-CftmKoRP.d.mts +2053 -0
- package/dist/index-Dh_XiNFt.d.ts +2053 -0
- package/dist/index.d.mts +4406 -490
- package/dist/index.d.ts +4406 -490
- package/dist/index.js +6598 -1729
- package/dist/index.mjs +5260 -938
- package/dist/types-D-0QbsA9.d.ts +39 -0
- package/dist/types-Ms3HtAmo.d.mts +39 -0
- package/dist/utils.d.mts +20 -1
- package/dist/utils.d.ts +20 -1
- package/dist/utils.js +38 -19
- package/dist/utils.mjs +1 -19
- package/dist/validation/all.d.mts +23 -0
- package/dist/validation/all.d.ts +23 -0
- package/dist/validation/all.js +265 -0
- package/dist/validation/all.mjs +20 -0
- package/dist/validation/complex/currency.d.mts +15 -0
- package/dist/validation/complex/currency.d.ts +15 -0
- package/dist/validation/complex/currency.js +12 -0
- package/dist/validation/complex/currency.mjs +3 -0
- package/dist/validation/complex/file.d.mts +13 -0
- package/dist/validation/complex/file.d.ts +13 -0
- package/dist/validation/complex/file.js +12 -0
- package/dist/validation/complex/file.mjs +3 -0
- package/dist/validation/complex/location.d.mts +22 -0
- package/dist/validation/complex/location.d.ts +22 -0
- package/dist/validation/complex/location.js +12 -0
- package/dist/validation/complex/location.mjs +3 -0
- package/dist/validation/complex/phone.d.mts +22 -0
- package/dist/validation/complex/phone.d.ts +22 -0
- package/dist/validation/complex/phone.js +12 -0
- package/dist/validation/complex/phone.mjs +3 -0
- package/dist/validation/complex/relation.d.mts +25 -0
- package/dist/validation/complex/relation.d.ts +25 -0
- package/dist/validation/complex/relation.js +20 -0
- package/dist/validation/complex/relation.mjs +3 -0
- package/dist/validation/complex/richtext.d.mts +13 -0
- package/dist/validation/complex/richtext.d.ts +13 -0
- package/dist/validation/complex/richtext.js +12 -0
- package/dist/validation/complex/richtext.mjs +3 -0
- package/dist/validation/complex/select.d.mts +20 -0
- package/dist/validation/complex/select.d.ts +20 -0
- package/dist/validation/complex/select.js +20 -0
- package/dist/validation/complex/select.mjs +3 -0
- package/dist/validation/complex/user.d.mts +13 -0
- package/dist/validation/complex/user.d.ts +13 -0
- package/dist/validation/complex/user.js +12 -0
- package/dist/validation/complex/user.mjs +3 -0
- package/dist/validation/computed/formula.d.mts +14 -0
- package/dist/validation/computed/formula.d.ts +14 -0
- package/dist/validation/computed/formula.js +12 -0
- package/dist/validation/computed/formula.mjs +3 -0
- package/dist/validation/computed/rollup.d.mts +14 -0
- package/dist/validation/computed/rollup.d.ts +14 -0
- package/dist/validation/computed/rollup.js +12 -0
- package/dist/validation/computed/rollup.mjs +3 -0
- package/dist/validation/config/index.d.mts +421 -0
- package/dist/validation/config/index.d.ts +421 -0
- package/dist/validation/config/index.js +103 -0
- package/dist/validation/config/index.mjs +2 -0
- package/dist/validation/core/index.d.mts +68 -0
- package/dist/validation/core/index.d.ts +68 -0
- package/dist/validation/core/index.js +23 -0
- package/dist/validation/core/index.mjs +2 -0
- package/dist/validation/object/index.d.mts +6 -0
- package/dist/validation/object/index.d.ts +6 -0
- package/dist/validation/object/index.js +71 -0
- package/dist/validation/object/index.mjs +18 -0
- package/dist/validation/primitives/checkbox.d.mts +12 -0
- package/dist/validation/primitives/checkbox.d.ts +12 -0
- package/dist/validation/primitives/checkbox.js +12 -0
- package/dist/validation/primitives/checkbox.mjs +3 -0
- package/dist/validation/primitives/date.d.mts +12 -0
- package/dist/validation/primitives/date.d.ts +12 -0
- package/dist/validation/primitives/date.js +12 -0
- package/dist/validation/primitives/date.mjs +3 -0
- package/dist/validation/primitives/number.d.mts +12 -0
- package/dist/validation/primitives/number.d.ts +12 -0
- package/dist/validation/primitives/number.js +12 -0
- package/dist/validation/primitives/number.mjs +3 -0
- package/dist/validation/primitives/rating.d.mts +12 -0
- package/dist/validation/primitives/rating.d.ts +12 -0
- package/dist/validation/primitives/rating.js +12 -0
- package/dist/validation/primitives/rating.mjs +3 -0
- package/dist/validation/primitives/text.d.mts +17 -0
- package/dist/validation/primitives/text.d.ts +17 -0
- package/dist/validation/primitives/text.js +16 -0
- package/dist/validation/primitives/text.mjs +3 -0
- package/dist/validation/validators.d.mts +21 -2
- package/dist/validation/validators.d.ts +21 -2
- package/dist/validation/validators.js +265 -121
- package/dist/validation/validators.mjs +20 -121
- package/package.json +109 -13
- package/dist/chunk-36UBIXJN.js +0 -82
- package/dist/chunk-3RG5ZIWI.js +0 -10
- package/dist/chunk-A6T4UUZ2.mjs +0 -18669
- package/dist/chunk-NEVERCM3.js +0 -41
- package/dist/chunk-SV4BCGQU.mjs +0 -617
- package/dist/chunk-TOTUS3YS.js +0 -18669
- package/dist/chunk-U4AB53AM.js +0 -617
- package/dist/chunk-V5QXU2OK.mjs +0 -82
- package/dist/chunk-Y6FXYEAI.mjs +0 -10
- package/dist/default-roles-42X3TJI5.mjs +0 -21
- package/dist/default-roles-C3FYDYMN.js +0 -21
- package/dist/runtime-BgtwoMx5.d.ts +0 -12759
- package/dist/runtime-DQlTgVZJ.d.mts +0 -12759
- package/dist/runtime.d.mts +0 -6
- package/dist/runtime.d.ts +0 -6
- package/dist/runtime.js +0 -323
- package/dist/runtime.mjs +0 -323
- package/dist/validators-BROsLGn4.d.mts +0 -1556
- package/dist/validators-CEzdvxEq.d.ts +0 -1556
package/dist/chunk-U4AB53AM.js
DELETED
|
@@ -1,617 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/validation/validators.ts
|
|
2
|
-
var _zod = require('zod');
|
|
3
|
-
var regexPatternCache = /* @__PURE__ */ new Map();
|
|
4
|
-
function getCachedRegex(pattern) {
|
|
5
|
-
let cached = regexPatternCache.get(pattern);
|
|
6
|
-
if (!cached) {
|
|
7
|
-
cached = new RegExp(pattern);
|
|
8
|
-
regexPatternCache.set(pattern, cached);
|
|
9
|
-
}
|
|
10
|
-
return cached;
|
|
11
|
-
}
|
|
12
|
-
function formatZodErrors(error) {
|
|
13
|
-
return error.issues.map((err) => ({
|
|
14
|
-
path: err.path.map(String),
|
|
15
|
-
message: err.message
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
|
-
var DEFAULT_VALIDATION_MESSAGES = {
|
|
19
|
-
required: (attr) => `${attr.label} is required`,
|
|
20
|
-
invalidType: (attr, expected) => `${attr.label} must be a ${expected}`,
|
|
21
|
-
minLength: (attr, min) => `${attr.label} must be at least ${min} characters`,
|
|
22
|
-
maxLength: (attr, max) => `${attr.label} must be at most ${max} characters`,
|
|
23
|
-
invalidPattern: (attr) => `${attr.label} format is invalid`,
|
|
24
|
-
minValue: (attr, min) => `${attr.label} must be at least ${min}`,
|
|
25
|
-
maxValue: (attr, max) => `${attr.label} must be at most ${max}`,
|
|
26
|
-
mustBeInteger: (attr) => `${attr.label} must be an integer`,
|
|
27
|
-
invalidDate: (attr) => `${attr.label} must be a valid date`,
|
|
28
|
-
invalidOption: (attr, options) => `${attr.label} must be one of: ${options.join(", ")}`,
|
|
29
|
-
invalidId: (attr) => `${attr.label} must be a valid ID`,
|
|
30
|
-
minItems: (attr, min) => `${attr.label} must have at least ${min} item${min > 1 ? "s" : ""}`,
|
|
31
|
-
maxItems: (attr, max) => `${attr.label} must have at most ${max} item${max > 1 ? "s" : ""}`,
|
|
32
|
-
invalidRichtext: (attr) => `${attr.label} must be valid rich text content`,
|
|
33
|
-
invalidPhone: (attr) => `${attr.label} must be a valid phone number`,
|
|
34
|
-
invalidCurrency: (attr) => `${attr.label} must be a valid currency value`,
|
|
35
|
-
invalidLocation: (attr) => `${attr.label} must be a valid location`
|
|
36
|
-
};
|
|
37
|
-
var baseConfigSchema = _zod.z.object({
|
|
38
|
-
disabled: _zod.z.boolean().optional(),
|
|
39
|
-
placeholder: _zod.z.string().optional(),
|
|
40
|
-
description: _zod.z.string().optional(),
|
|
41
|
-
defaultValue: _zod.z.unknown().optional(),
|
|
42
|
-
icon: _zod.z.string().optional(),
|
|
43
|
-
order: _zod.z.number().int().optional(),
|
|
44
|
-
hidden: _zod.z.boolean().optional(),
|
|
45
|
-
archived: _zod.z.boolean().optional(),
|
|
46
|
-
deprecated: _zod.z.boolean().optional(),
|
|
47
|
-
metadata: _zod.z.record(_zod.z.string(), _zod.z.unknown()).optional()
|
|
48
|
-
});
|
|
49
|
-
var optionSchema = _zod.z.object({
|
|
50
|
-
id: _zod.z.string().min(1),
|
|
51
|
-
label: _zod.z.string().min(1),
|
|
52
|
-
value: _zod.z.string().min(1),
|
|
53
|
-
color: _zod.z.string().optional(),
|
|
54
|
-
icon: _zod.z.string().optional(),
|
|
55
|
-
description: _zod.z.string().optional(),
|
|
56
|
-
group: _zod.z.enum(["idle", "in_progress", "finished"]).optional()
|
|
57
|
-
});
|
|
58
|
-
var optionsArraySchema = _zod.z.array(optionSchema).min(1).refine(
|
|
59
|
-
(options) => {
|
|
60
|
-
const values = options.map((o) => o.value);
|
|
61
|
-
return new Set(values).size === values.length;
|
|
62
|
-
},
|
|
63
|
-
{ message: "Duplicate option values are not allowed" }
|
|
64
|
-
);
|
|
65
|
-
var relationTargetSchema = _zod.z.object({
|
|
66
|
-
object: _zod.z.string().min(1),
|
|
67
|
-
displayTemplate: _zod.z.string().optional(),
|
|
68
|
-
filter: _zod.z.record(_zod.z.string(), _zod.z.unknown()).optional()
|
|
69
|
-
});
|
|
70
|
-
var textConfigSchema = baseConfigSchema.extend({
|
|
71
|
-
minLength: _zod.z.number().int().min(0).optional(),
|
|
72
|
-
maxLength: _zod.z.number().int().min(1).optional(),
|
|
73
|
-
pattern: _zod.z.string().optional()
|
|
74
|
-
});
|
|
75
|
-
var textareaConfigSchema = baseConfigSchema;
|
|
76
|
-
var richtextConfigSchema = baseConfigSchema.extend({
|
|
77
|
-
features: _zod.z.array(
|
|
78
|
-
_zod.z.enum(["headings", "bold", "italic", "lists", "links", "images", "codeBlocks", "tables"])
|
|
79
|
-
).optional()
|
|
80
|
-
});
|
|
81
|
-
var numberConfigSchema = baseConfigSchema.extend({
|
|
82
|
-
min: _zod.z.number().optional(),
|
|
83
|
-
max: _zod.z.number().optional(),
|
|
84
|
-
unit: _zod.z.enum(["integer", "decimal", "percentage"]).optional(),
|
|
85
|
-
decimals: _zod.z.number().int().min(0).optional()
|
|
86
|
-
});
|
|
87
|
-
var checkboxConfigSchema = baseConfigSchema;
|
|
88
|
-
var dateConfigSchema = baseConfigSchema.extend({
|
|
89
|
-
dateFormat: _zod.z.enum(["short", "long", "full", "relative"]).optional(),
|
|
90
|
-
minDate: _zod.z.string().optional(),
|
|
91
|
-
maxDate: _zod.z.string().optional()
|
|
92
|
-
});
|
|
93
|
-
var phoneConfigSchema = baseConfigSchema.extend({
|
|
94
|
-
defaultCountryCode: _zod.z.string().length(3).optional()
|
|
95
|
-
});
|
|
96
|
-
var currencyConfigSchema = baseConfigSchema.extend({
|
|
97
|
-
defaultCurrency: _zod.z.string().length(3).optional(),
|
|
98
|
-
allowedCurrencies: _zod.z.array(_zod.z.string().length(3)).optional()
|
|
99
|
-
});
|
|
100
|
-
var statusConfigSchema = baseConfigSchema.extend({
|
|
101
|
-
options: optionsArraySchema
|
|
102
|
-
});
|
|
103
|
-
var locationConfigSchema = baseConfigSchema.extend({
|
|
104
|
-
granularity: _zod.z.enum(["full", "address", "city", "state", "country", "coordinates"]),
|
|
105
|
-
enableAutocomplete: _zod.z.boolean().optional(),
|
|
106
|
-
enableMap: _zod.z.boolean().optional(),
|
|
107
|
-
defaultCountry: _zod.z.string().length(3).optional(),
|
|
108
|
-
allowedCountries: _zod.z.array(_zod.z.string().length(3)).optional(),
|
|
109
|
-
displayFormat: _zod.z.enum(["single_line", "multi_line", "compact"]).optional()
|
|
110
|
-
});
|
|
111
|
-
var selectConfigSchema = baseConfigSchema.extend({
|
|
112
|
-
options: optionsArraySchema
|
|
113
|
-
});
|
|
114
|
-
var multiselectConfigSchema = baseConfigSchema.extend({
|
|
115
|
-
options: optionsArraySchema
|
|
116
|
-
});
|
|
117
|
-
var fileConfigSchema = baseConfigSchema.extend({
|
|
118
|
-
maxFiles: _zod.z.number().int().min(1).optional(),
|
|
119
|
-
maxSize: _zod.z.number().int().min(1).optional(),
|
|
120
|
-
allowedTypes: _zod.z.array(_zod.z.string()).optional(),
|
|
121
|
-
multiple: _zod.z.boolean().optional()
|
|
122
|
-
});
|
|
123
|
-
var userConfigSchema = baseConfigSchema.extend({
|
|
124
|
-
allowedRoles: _zod.z.array(_zod.z.string()).optional(),
|
|
125
|
-
multiple: _zod.z.boolean().optional()
|
|
126
|
-
});
|
|
127
|
-
var relationConfigSchema = baseConfigSchema.extend({
|
|
128
|
-
targets: _zod.z.array(relationTargetSchema).min(1),
|
|
129
|
-
cardinality: _zod.z.enum(["one", "many"]),
|
|
130
|
-
minItems: _zod.z.number().int().min(0).optional(),
|
|
131
|
-
maxItems: _zod.z.number().int().min(1).optional()
|
|
132
|
-
});
|
|
133
|
-
var ratingConfigSchema = baseConfigSchema.extend({
|
|
134
|
-
max: _zod.z.number().int().min(1).optional(),
|
|
135
|
-
iconType: _zod.z.enum(["star", "heart", "thumbs", "number"]).optional()
|
|
136
|
-
});
|
|
137
|
-
var formulaConfigSchema = baseConfigSchema.extend({
|
|
138
|
-
expression: _zod.z.string().min(1),
|
|
139
|
-
returnType: _zod.z.enum(["text", "number", "boolean", "date"]),
|
|
140
|
-
decimals: _zod.z.number().int().min(0).max(10).optional(),
|
|
141
|
-
allowRelations: _zod.z.boolean().optional()
|
|
142
|
-
});
|
|
143
|
-
var rollupConfigSchema = baseConfigSchema.extend({
|
|
144
|
-
relationAttribute: _zod.z.string().min(1).optional(),
|
|
145
|
-
relationPath: _zod.z.string().optional(),
|
|
146
|
-
targetAttribute: _zod.z.string().min(1),
|
|
147
|
-
function: _zod.z.enum([
|
|
148
|
-
// Numeric aggregates
|
|
149
|
-
"sum",
|
|
150
|
-
"avg",
|
|
151
|
-
// Date aggregates
|
|
152
|
-
"earliest",
|
|
153
|
-
"latest",
|
|
154
|
-
// Count (universal)
|
|
155
|
-
"count",
|
|
156
|
-
"countValues",
|
|
157
|
-
"countUniqueValues",
|
|
158
|
-
"countEmpty",
|
|
159
|
-
// Percent (universal)
|
|
160
|
-
"percentEmpty",
|
|
161
|
-
"percentNotEmpty",
|
|
162
|
-
// Lookup (universal)
|
|
163
|
-
"original"
|
|
164
|
-
]),
|
|
165
|
-
decimals: _zod.z.number().int().min(0).max(10).optional(),
|
|
166
|
-
targetAttributeType: _zod.z.string().optional(),
|
|
167
|
-
targetAttributeOptions: _zod.z.array(
|
|
168
|
-
_zod.z.object({
|
|
169
|
-
id: _zod.z.string(),
|
|
170
|
-
label: _zod.z.string(),
|
|
171
|
-
value: _zod.z.string(),
|
|
172
|
-
color: _zod.z.string().optional(),
|
|
173
|
-
icon: _zod.z.string().optional(),
|
|
174
|
-
description: _zod.z.string().optional(),
|
|
175
|
-
group: _zod.z.enum(["idle", "in_progress", "finished"]).optional()
|
|
176
|
-
})
|
|
177
|
-
).optional()
|
|
178
|
-
});
|
|
179
|
-
var documentConfigSchema = baseConfigSchema.extend({
|
|
180
|
-
templateId: _zod.z.string().optional(),
|
|
181
|
-
allowedTemplates: _zod.z.array(_zod.z.string()).optional(),
|
|
182
|
-
multiple: _zod.z.boolean().optional(),
|
|
183
|
-
maxDocuments: _zod.z.number().int().min(1).optional(),
|
|
184
|
-
autoProcess: _zod.z.boolean().optional()
|
|
185
|
-
});
|
|
186
|
-
var attributeConfigSchemas = {
|
|
187
|
-
text: textConfigSchema,
|
|
188
|
-
textarea: textareaConfigSchema,
|
|
189
|
-
richtext: richtextConfigSchema,
|
|
190
|
-
number: numberConfigSchema,
|
|
191
|
-
checkbox: checkboxConfigSchema,
|
|
192
|
-
date: dateConfigSchema,
|
|
193
|
-
phone: phoneConfigSchema,
|
|
194
|
-
currency: currencyConfigSchema,
|
|
195
|
-
status: statusConfigSchema,
|
|
196
|
-
location: locationConfigSchema,
|
|
197
|
-
select: selectConfigSchema,
|
|
198
|
-
multiselect: multiselectConfigSchema,
|
|
199
|
-
file: fileConfigSchema,
|
|
200
|
-
user: userConfigSchema,
|
|
201
|
-
relation: relationConfigSchema,
|
|
202
|
-
rating: ratingConfigSchema,
|
|
203
|
-
formula: formulaConfigSchema,
|
|
204
|
-
rollup: rollupConfigSchema,
|
|
205
|
-
document: documentConfigSchema
|
|
206
|
-
};
|
|
207
|
-
function getAttributeConfigSchema(type) {
|
|
208
|
-
return attributeConfigSchemas[type];
|
|
209
|
-
}
|
|
210
|
-
function validateAttributeConfig(type, config) {
|
|
211
|
-
const schema = getAttributeConfigSchema(type);
|
|
212
|
-
const result = schema.safeParse(config);
|
|
213
|
-
if (result.success) {
|
|
214
|
-
return { success: true, data: result.data };
|
|
215
|
-
}
|
|
216
|
-
return {
|
|
217
|
-
success: false,
|
|
218
|
-
errors: formatZodErrors(result.error).map((err) => `${err.path.join(".")}: ${err.message}`)
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
function parseAttributeConfig(type, config) {
|
|
222
|
-
const schema = getAttributeConfigSchema(type);
|
|
223
|
-
return schema.strip().parse(config);
|
|
224
|
-
}
|
|
225
|
-
function safeParseAttributeConfig(type, config) {
|
|
226
|
-
const schema = getAttributeConfigSchema(type);
|
|
227
|
-
const result = schema.strip().safeParse(config);
|
|
228
|
-
return result.success ? result.data : void 0;
|
|
229
|
-
}
|
|
230
|
-
function createTextValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
231
|
-
let schema = _zod.z.string();
|
|
232
|
-
if (attr.minLength !== void 0) {
|
|
233
|
-
schema = schema.min(attr.minLength, messages.minLength(attr, attr.minLength));
|
|
234
|
-
}
|
|
235
|
-
if (attr.maxLength !== void 0) {
|
|
236
|
-
schema = schema.max(attr.maxLength, messages.maxLength(attr, attr.maxLength));
|
|
237
|
-
}
|
|
238
|
-
if (attr.pattern) {
|
|
239
|
-
schema = schema.regex(getCachedRegex(attr.pattern), messages.invalidPattern(attr));
|
|
240
|
-
}
|
|
241
|
-
return schema;
|
|
242
|
-
}
|
|
243
|
-
function createNumberValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
244
|
-
let schema = _zod.z.number();
|
|
245
|
-
if (attr.min !== void 0) {
|
|
246
|
-
schema = schema.min(attr.min, messages.minValue(attr, attr.min));
|
|
247
|
-
}
|
|
248
|
-
if (attr.max !== void 0) {
|
|
249
|
-
schema = schema.max(attr.max, messages.maxValue(attr, attr.max));
|
|
250
|
-
}
|
|
251
|
-
if (attr.unit === "integer") {
|
|
252
|
-
schema = schema.int(messages.mustBeInteger(attr));
|
|
253
|
-
}
|
|
254
|
-
return schema;
|
|
255
|
-
}
|
|
256
|
-
function createCheckboxValidator(_attr, _messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
257
|
-
return _zod.z.boolean();
|
|
258
|
-
}
|
|
259
|
-
function createDateValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
260
|
-
return _zod.z.coerce.date({ message: messages.invalidDate(attr) });
|
|
261
|
-
}
|
|
262
|
-
function createPhoneValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
263
|
-
return _zod.z.object(
|
|
264
|
-
{
|
|
265
|
-
countryCode: _zod.z.string().length(3),
|
|
266
|
-
phoneNumber: _zod.z.string().min(1)
|
|
267
|
-
},
|
|
268
|
-
{ message: messages.invalidPhone(attr) }
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
function createCurrencyValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
272
|
-
return _zod.z.object(
|
|
273
|
-
{
|
|
274
|
-
code: _zod.z.string().length(3),
|
|
275
|
-
value: _zod.z.number().min(0)
|
|
276
|
-
},
|
|
277
|
-
{ message: messages.invalidCurrency(attr) }
|
|
278
|
-
);
|
|
279
|
-
}
|
|
280
|
-
function createStatusValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
281
|
-
const validValues = attr.options.map((opt) => opt.value);
|
|
282
|
-
return _zod.z.enum(validValues, {
|
|
283
|
-
message: messages.invalidOption(attr, validValues)
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
function createSelectValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
287
|
-
const validValues = attr.options.map((opt) => opt.value);
|
|
288
|
-
return _zod.z.enum(validValues, {
|
|
289
|
-
message: messages.invalidOption(attr, validValues)
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
function createMultiselectValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
293
|
-
const validValues = attr.options.map((opt) => opt.value);
|
|
294
|
-
return _zod.z.array(
|
|
295
|
-
_zod.z.enum(validValues, {
|
|
296
|
-
message: messages.invalidOption(attr, validValues)
|
|
297
|
-
})
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
function createLocationValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
301
|
-
return _zod.z.object(
|
|
302
|
-
{
|
|
303
|
-
address: _zod.z.string().optional(),
|
|
304
|
-
address2: _zod.z.string().optional(),
|
|
305
|
-
city: _zod.z.string().optional(),
|
|
306
|
-
state: _zod.z.string().optional(),
|
|
307
|
-
postalCode: _zod.z.string().optional(),
|
|
308
|
-
country: _zod.z.string().length(3).optional(),
|
|
309
|
-
latitude: _zod.z.number().optional(),
|
|
310
|
-
longitude: _zod.z.number().optional()
|
|
311
|
-
},
|
|
312
|
-
{ message: messages.invalidLocation(attr) }
|
|
313
|
-
);
|
|
314
|
-
}
|
|
315
|
-
function createFileValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
316
|
-
const uuidSchema = _zod.z.uuid({
|
|
317
|
-
message: messages.invalidId(attr)
|
|
318
|
-
});
|
|
319
|
-
if (attr.multiple) {
|
|
320
|
-
let arraySchema = _zod.z.array(uuidSchema);
|
|
321
|
-
if (attr.maxFiles) {
|
|
322
|
-
arraySchema = arraySchema.max(attr.maxFiles, messages.maxItems(attr, attr.maxFiles));
|
|
323
|
-
}
|
|
324
|
-
return arraySchema;
|
|
325
|
-
}
|
|
326
|
-
return uuidSchema;
|
|
327
|
-
}
|
|
328
|
-
function createUserValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
329
|
-
const uuidSchema = _zod.z.uuid({
|
|
330
|
-
message: messages.invalidId(attr)
|
|
331
|
-
});
|
|
332
|
-
if (attr.multiple) {
|
|
333
|
-
return _zod.z.array(uuidSchema);
|
|
334
|
-
}
|
|
335
|
-
return uuidSchema;
|
|
336
|
-
}
|
|
337
|
-
function createSingleRelationValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
338
|
-
const uuidSchema = _zod.z.uuid({
|
|
339
|
-
message: messages.invalidId(attr)
|
|
340
|
-
});
|
|
341
|
-
return _zod.z.union([uuidSchema, _zod.z.null()]);
|
|
342
|
-
}
|
|
343
|
-
function createMultiRelationValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
344
|
-
const uuidSchema = _zod.z.uuid({
|
|
345
|
-
message: messages.invalidId(attr)
|
|
346
|
-
});
|
|
347
|
-
let arraySchema = _zod.z.array(uuidSchema);
|
|
348
|
-
if (attr.minItems !== void 0) {
|
|
349
|
-
arraySchema = arraySchema.min(attr.minItems, messages.minItems(attr, attr.minItems));
|
|
350
|
-
}
|
|
351
|
-
if (attr.maxItems !== void 0) {
|
|
352
|
-
arraySchema = arraySchema.max(attr.maxItems, messages.maxItems(attr, attr.maxItems));
|
|
353
|
-
}
|
|
354
|
-
return arraySchema;
|
|
355
|
-
}
|
|
356
|
-
function createRelationValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
357
|
-
if (attr.cardinality === "many") {
|
|
358
|
-
return createMultiRelationValidator(attr, messages);
|
|
359
|
-
}
|
|
360
|
-
return createSingleRelationValidator(attr, messages);
|
|
361
|
-
}
|
|
362
|
-
function createRatingValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
363
|
-
let schema = _zod.z.number().min(0);
|
|
364
|
-
if (attr.max !== void 0) {
|
|
365
|
-
schema = schema.max(attr.max, messages.maxValue(attr, attr.max));
|
|
366
|
-
}
|
|
367
|
-
return schema;
|
|
368
|
-
}
|
|
369
|
-
function createFormulaValidator(_attr, _messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
370
|
-
return _zod.z.unknown();
|
|
371
|
-
}
|
|
372
|
-
function createRollupValidator(_attr, _messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
373
|
-
return _zod.z.unknown();
|
|
374
|
-
}
|
|
375
|
-
function createTextAreaValidator(_attr, _messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
376
|
-
return _zod.z.string();
|
|
377
|
-
}
|
|
378
|
-
function createRichtextValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
379
|
-
return _zod.z.string({
|
|
380
|
-
message: messages.invalidRichtext(attr)
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
function createAttributeValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
384
|
-
switch (attr.type) {
|
|
385
|
-
case "text":
|
|
386
|
-
return createTextValidator(attr, messages);
|
|
387
|
-
case "textarea":
|
|
388
|
-
return createTextAreaValidator(attr, messages);
|
|
389
|
-
case "richtext":
|
|
390
|
-
return createRichtextValidator(attr, messages);
|
|
391
|
-
case "number":
|
|
392
|
-
return createNumberValidator(attr, messages);
|
|
393
|
-
case "checkbox":
|
|
394
|
-
return createCheckboxValidator(attr, messages);
|
|
395
|
-
case "date":
|
|
396
|
-
return createDateValidator(attr, messages);
|
|
397
|
-
case "phone":
|
|
398
|
-
return createPhoneValidator(attr, messages);
|
|
399
|
-
case "currency":
|
|
400
|
-
return createCurrencyValidator(attr, messages);
|
|
401
|
-
case "status":
|
|
402
|
-
return createStatusValidator(attr, messages);
|
|
403
|
-
case "location":
|
|
404
|
-
return createLocationValidator(attr, messages);
|
|
405
|
-
case "select":
|
|
406
|
-
return createSelectValidator(attr, messages);
|
|
407
|
-
case "multiselect":
|
|
408
|
-
return createMultiselectValidator(attr, messages);
|
|
409
|
-
case "file":
|
|
410
|
-
return createFileValidator(attr, messages);
|
|
411
|
-
case "user":
|
|
412
|
-
return createUserValidator(attr, messages);
|
|
413
|
-
case "relation":
|
|
414
|
-
return createRelationValidator(attr, messages);
|
|
415
|
-
case "rating":
|
|
416
|
-
return createRatingValidator(attr, messages);
|
|
417
|
-
case "formula":
|
|
418
|
-
return createFormulaValidator(attr, messages);
|
|
419
|
-
case "rollup":
|
|
420
|
-
return createRollupValidator(attr, messages);
|
|
421
|
-
default:
|
|
422
|
-
return _zod.z.unknown();
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
function isEmptyValue(value) {
|
|
426
|
-
if (value === null || value === void 0) return true;
|
|
427
|
-
if (typeof value === "string" && value.trim() === "") return true;
|
|
428
|
-
if (value instanceof Date) return false;
|
|
429
|
-
if (typeof value === "object" && !Array.isArray(value)) {
|
|
430
|
-
return Object.values(value).every(
|
|
431
|
-
(v) => v === null || v === void 0 || typeof v === "string" && v.trim() === ""
|
|
432
|
-
);
|
|
433
|
-
}
|
|
434
|
-
return false;
|
|
435
|
-
}
|
|
436
|
-
function withEmptyToNull(validator) {
|
|
437
|
-
return _zod.z.preprocess((val) => isEmptyValue(val) ? null : val, validator.nullish());
|
|
438
|
-
}
|
|
439
|
-
function createFormAttributeValidator(attr, messages = DEFAULT_VALIDATION_MESSAGES) {
|
|
440
|
-
const validator = createAttributeValidator(attr, messages);
|
|
441
|
-
if (!attr.required) {
|
|
442
|
-
return withEmptyToNull(validator);
|
|
443
|
-
}
|
|
444
|
-
return validator;
|
|
445
|
-
}
|
|
446
|
-
function createObjectValidator(objectDef) {
|
|
447
|
-
const shape = {};
|
|
448
|
-
for (const attr of objectDef.attributes) {
|
|
449
|
-
const validator = createAttributeValidator(attr);
|
|
450
|
-
shape[attr.name] = attr.required ? validator : withEmptyToNull(validator);
|
|
451
|
-
}
|
|
452
|
-
return _zod.z.object(shape).passthrough();
|
|
453
|
-
}
|
|
454
|
-
function validateAttribute(attr, value) {
|
|
455
|
-
const validator = createAttributeValidator(attr);
|
|
456
|
-
if (!attr.required && (value === void 0 || value === null)) {
|
|
457
|
-
return { success: true, data: { [attr.name]: value } };
|
|
458
|
-
}
|
|
459
|
-
const result = validator.safeParse(value);
|
|
460
|
-
if (result.success) {
|
|
461
|
-
return {
|
|
462
|
-
success: true,
|
|
463
|
-
data: { [attr.name]: result.data }
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
return {
|
|
467
|
-
success: false,
|
|
468
|
-
errors: formatZodErrors(result.error).map((err) => ({
|
|
469
|
-
path: [attr.name, ...err.path],
|
|
470
|
-
message: err.message
|
|
471
|
-
}))
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
function validateObject(objectDef, data) {
|
|
475
|
-
const validator = createObjectValidator(objectDef);
|
|
476
|
-
const result = validator.safeParse(data);
|
|
477
|
-
if (result.success) {
|
|
478
|
-
return {
|
|
479
|
-
success: true,
|
|
480
|
-
data: result.data
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
return {
|
|
484
|
-
success: false,
|
|
485
|
-
errors: formatZodErrors(result.error)
|
|
486
|
-
};
|
|
487
|
-
}
|
|
488
|
-
function validateObjectOrThrow(objectDef, data) {
|
|
489
|
-
const result = validateObject(objectDef, data);
|
|
490
|
-
if (!result.success) {
|
|
491
|
-
const errorMessages = _optionalChain([result, 'access', _ => _.errors, 'optionalAccess', _2 => _2.map, 'call', _3 => _3((err) => `${err.path.join(".")}: ${err.message}`), 'access', _4 => _4.join, 'call', _5 => _5("\n")]) || "Unknown validation error";
|
|
492
|
-
throw new Error(`Validation failed for ${objectDef.label}:
|
|
493
|
-
${errorMessages}`);
|
|
494
|
-
}
|
|
495
|
-
return result.data;
|
|
496
|
-
}
|
|
497
|
-
function createDraftValidator(objectDef) {
|
|
498
|
-
const shape = {};
|
|
499
|
-
for (const attr of objectDef.attributes) {
|
|
500
|
-
const validator = createAttributeValidator(attr);
|
|
501
|
-
shape[attr.name] = withEmptyToNull(validator);
|
|
502
|
-
}
|
|
503
|
-
return _zod.z.object(shape).passthrough();
|
|
504
|
-
}
|
|
505
|
-
function validateDraft(objectDef, data) {
|
|
506
|
-
const validator = createDraftValidator(objectDef);
|
|
507
|
-
const result = validator.safeParse(data);
|
|
508
|
-
if (result.success) {
|
|
509
|
-
return {
|
|
510
|
-
success: true,
|
|
511
|
-
data: result.data
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
return {
|
|
515
|
-
success: false,
|
|
516
|
-
errors: formatZodErrors(result.error)
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
function validateDraftOrThrow(objectDef, data) {
|
|
520
|
-
const result = validateDraft(objectDef, data);
|
|
521
|
-
if (!result.success) {
|
|
522
|
-
const errorMessages = _optionalChain([result, 'access', _6 => _6.errors, 'optionalAccess', _7 => _7.map, 'call', _8 => _8((err) => `${err.path.join(".")}: ${err.message}`), 'access', _9 => _9.join, 'call', _10 => _10("\n")]) || "Unknown validation error";
|
|
523
|
-
throw new Error(`Draft validation failed for ${objectDef.label}:
|
|
524
|
-
${errorMessages}`);
|
|
525
|
-
}
|
|
526
|
-
return result.data;
|
|
527
|
-
}
|
|
528
|
-
function isValuePresent(value) {
|
|
529
|
-
if (value === void 0 || value === null) {
|
|
530
|
-
return false;
|
|
531
|
-
}
|
|
532
|
-
if (typeof value === "string" && value.trim() === "") {
|
|
533
|
-
return false;
|
|
534
|
-
}
|
|
535
|
-
return true;
|
|
536
|
-
}
|
|
537
|
-
function getMissingRequiredAttributes(objectDef, data) {
|
|
538
|
-
const missing = [];
|
|
539
|
-
for (const attr of objectDef.attributes) {
|
|
540
|
-
if (attr.required && !isValuePresent(data[attr.name])) {
|
|
541
|
-
missing.push(attr);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
return missing;
|
|
545
|
-
}
|
|
546
|
-
function isRecordComplete(objectDef, data) {
|
|
547
|
-
const missing = getMissingRequiredAttributes(objectDef, data);
|
|
548
|
-
if (missing.length > 0) {
|
|
549
|
-
return false;
|
|
550
|
-
}
|
|
551
|
-
const validation = validateObject(objectDef, data);
|
|
552
|
-
return validation.success;
|
|
553
|
-
}
|
|
554
|
-
function computeRecordStatus(objectDef, data) {
|
|
555
|
-
return isRecordComplete(objectDef, data) ? "complete" : "draft";
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
exports.formatZodErrors = formatZodErrors; exports.DEFAULT_VALIDATION_MESSAGES = DEFAULT_VALIDATION_MESSAGES; exports.textConfigSchema = textConfigSchema; exports.textareaConfigSchema = textareaConfigSchema; exports.richtextConfigSchema = richtextConfigSchema; exports.numberConfigSchema = numberConfigSchema; exports.checkboxConfigSchema = checkboxConfigSchema; exports.dateConfigSchema = dateConfigSchema; exports.phoneConfigSchema = phoneConfigSchema; exports.currencyConfigSchema = currencyConfigSchema; exports.statusConfigSchema = statusConfigSchema; exports.locationConfigSchema = locationConfigSchema; exports.selectConfigSchema = selectConfigSchema; exports.multiselectConfigSchema = multiselectConfigSchema; exports.fileConfigSchema = fileConfigSchema; exports.userConfigSchema = userConfigSchema; exports.relationConfigSchema = relationConfigSchema; exports.ratingConfigSchema = ratingConfigSchema; exports.formulaConfigSchema = formulaConfigSchema; exports.rollupConfigSchema = rollupConfigSchema; exports.documentConfigSchema = documentConfigSchema; exports.attributeConfigSchemas = attributeConfigSchemas; exports.getAttributeConfigSchema = getAttributeConfigSchema; exports.validateAttributeConfig = validateAttributeConfig; exports.parseAttributeConfig = parseAttributeConfig; exports.safeParseAttributeConfig = safeParseAttributeConfig; exports.createTextValidator = createTextValidator; exports.createNumberValidator = createNumberValidator; exports.createCheckboxValidator = createCheckboxValidator; exports.createDateValidator = createDateValidator; exports.createPhoneValidator = createPhoneValidator; exports.createCurrencyValidator = createCurrencyValidator; exports.createStatusValidator = createStatusValidator; exports.createSelectValidator = createSelectValidator; exports.createMultiselectValidator = createMultiselectValidator; exports.createLocationValidator = createLocationValidator; exports.createFileValidator = createFileValidator; exports.createUserValidator = createUserValidator; exports.createSingleRelationValidator = createSingleRelationValidator; exports.createMultiRelationValidator = createMultiRelationValidator; exports.createRelationValidator = createRelationValidator; exports.createRatingValidator = createRatingValidator; exports.createFormulaValidator = createFormulaValidator; exports.createRollupValidator = createRollupValidator; exports.createTextAreaValidator = createTextAreaValidator; exports.createRichtextValidator = createRichtextValidator; exports.createAttributeValidator = createAttributeValidator; exports.createFormAttributeValidator = createFormAttributeValidator; exports.createObjectValidator = createObjectValidator; exports.validateAttribute = validateAttribute; exports.validateObject = validateObject; exports.validateObjectOrThrow = validateObjectOrThrow; exports.createDraftValidator = createDraftValidator; exports.validateDraft = validateDraft; exports.validateDraftOrThrow = validateDraftOrThrow; exports.getMissingRequiredAttributes = getMissingRequiredAttributes; exports.isRecordComplete = isRecordComplete; exports.computeRecordStatus = computeRecordStatus;
|
package/dist/chunk-V5QXU2OK.mjs
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// src/constants/default-roles.ts
|
|
2
|
-
var SYSTEM_RESOURCES = {
|
|
3
|
-
/** User profiles and invitations management */
|
|
4
|
-
USERS: "users",
|
|
5
|
-
/** Object definitions and attributes management */
|
|
6
|
-
SCHEMA: "schema",
|
|
7
|
-
/** Roles and permissions management */
|
|
8
|
-
ROLES: "roles",
|
|
9
|
-
/** Tenant settings and configuration */
|
|
10
|
-
SETTINGS: "settings",
|
|
11
|
-
/** Audit logs and activity trail */
|
|
12
|
-
AUDIT: "audit",
|
|
13
|
-
/** File uploads and storage management */
|
|
14
|
-
FILES: "files"
|
|
15
|
-
};
|
|
16
|
-
var ALL_SYSTEM_RESOURCES = [
|
|
17
|
-
SYSTEM_RESOURCES.USERS,
|
|
18
|
-
SYSTEM_RESOURCES.SCHEMA,
|
|
19
|
-
SYSTEM_RESOURCES.ROLES,
|
|
20
|
-
SYSTEM_RESOURCES.SETTINGS,
|
|
21
|
-
SYSTEM_RESOURCES.AUDIT,
|
|
22
|
-
SYSTEM_RESOURCES.FILES
|
|
23
|
-
];
|
|
24
|
-
var SYSTEM_RESOURCE_LABELS = {
|
|
25
|
-
users: "Users",
|
|
26
|
-
schema: "Schema",
|
|
27
|
-
roles: "Roles & Permissions",
|
|
28
|
-
settings: "Settings",
|
|
29
|
-
audit: "Audit Logs",
|
|
30
|
-
files: "Files"
|
|
31
|
-
};
|
|
32
|
-
var DEFAULT_ROLES = {
|
|
33
|
-
/** Full platform access - can manage everything */
|
|
34
|
-
ADMIN: "admin",
|
|
35
|
-
/** Standard user - can work with business data but not platform settings */
|
|
36
|
-
MEMBER: "member",
|
|
37
|
-
/** Read-only access - can view but not modify */
|
|
38
|
-
GUEST: "guest"
|
|
39
|
-
};
|
|
40
|
-
var DEFAULT_ROLE_LABELS = {
|
|
41
|
-
admin: "Administrator",
|
|
42
|
-
member: "Member",
|
|
43
|
-
guest: "Guest"
|
|
44
|
-
};
|
|
45
|
-
var DEFAULT_ROLE_DESCRIPTIONS = {
|
|
46
|
-
admin: "Full access to all platform features and data",
|
|
47
|
-
member: "Can view, create and edit business data",
|
|
48
|
-
guest: "Read-only access to business data"
|
|
49
|
-
};
|
|
50
|
-
var ALL_ACTIONS = ["read", "create", "update", "delete"];
|
|
51
|
-
var MEMBER_ACTIONS = ["read", "create", "update"];
|
|
52
|
-
var READ_ONLY = ["read"];
|
|
53
|
-
var DEFAULT_ROLE_PERMISSIONS = {
|
|
54
|
-
admin: {
|
|
55
|
-
system: [{ target: "*", actions: ALL_ACTIONS }],
|
|
56
|
-
object: [{ target: "*", actions: ALL_ACTIONS }]
|
|
57
|
-
},
|
|
58
|
-
member: {
|
|
59
|
-
system: [],
|
|
60
|
-
// No access to system resources
|
|
61
|
-
object: [{ target: "*", actions: MEMBER_ACTIONS }]
|
|
62
|
-
},
|
|
63
|
-
guest: {
|
|
64
|
-
system: [],
|
|
65
|
-
// No access to system resources
|
|
66
|
-
object: [{ target: "*", actions: READ_ONLY }]
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
function isDefaultRole(roleName) {
|
|
70
|
-
return Object.values(DEFAULT_ROLES).includes(roleName);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export {
|
|
74
|
-
SYSTEM_RESOURCES,
|
|
75
|
-
ALL_SYSTEM_RESOURCES,
|
|
76
|
-
SYSTEM_RESOURCE_LABELS,
|
|
77
|
-
DEFAULT_ROLES,
|
|
78
|
-
DEFAULT_ROLE_LABELS,
|
|
79
|
-
DEFAULT_ROLE_DESCRIPTIONS,
|
|
80
|
-
DEFAULT_ROLE_PERMISSIONS,
|
|
81
|
-
isDefaultRole
|
|
82
|
-
};
|