@gzl10/nexus-sdk 0.12.7 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-6WVPKBUS.js +364 -0
- package/dist/chunk-JIEVWBDA.js +256 -0
- package/dist/chunk-WZM5DHUI.js +377 -0
- package/dist/collection/index.d.ts +506 -0
- package/dist/collection/index.js +1501 -0
- package/dist/entity-kPgsCMdR.d.ts +1504 -0
- package/dist/field-CngHXora.d.ts +375 -0
- package/dist/fields/index.d.ts +1305 -0
- package/dist/fields/index.js +58 -0
- package/dist/index.d.ts +387 -2302
- package/dist/index.js +25 -69
- package/dist/masters/index.d.ts +120 -0
- package/dist/masters/index.js +689 -0
- package/package.json +23 -2
|
@@ -0,0 +1,1501 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useColorField,
|
|
3
|
+
useDatetimeField,
|
|
4
|
+
useJsonField,
|
|
5
|
+
usePasswordField,
|
|
6
|
+
useSwitchField,
|
|
7
|
+
useTextareaField
|
|
8
|
+
} from "../chunk-WZM5DHUI.js";
|
|
9
|
+
import {
|
|
10
|
+
refMaster
|
|
11
|
+
} from "../chunk-JIEVWBDA.js";
|
|
12
|
+
import {
|
|
13
|
+
idField,
|
|
14
|
+
isActiveField,
|
|
15
|
+
orderField,
|
|
16
|
+
useIconField,
|
|
17
|
+
useIdField,
|
|
18
|
+
useLocalizedField,
|
|
19
|
+
useNumberField,
|
|
20
|
+
useSelectField,
|
|
21
|
+
useTextField,
|
|
22
|
+
useTextUniqueField,
|
|
23
|
+
useUrlField,
|
|
24
|
+
userIdField
|
|
25
|
+
} from "../chunk-6WVPKBUS.js";
|
|
26
|
+
|
|
27
|
+
// src/collection/helpers.ts
|
|
28
|
+
var polymorphicCaslPermissions = {
|
|
29
|
+
"*": { actions: ["read"] },
|
|
30
|
+
USER: {
|
|
31
|
+
actions: ["create", "update", "delete"],
|
|
32
|
+
conditions: { user_id: "${user.id}" }
|
|
33
|
+
},
|
|
34
|
+
ADMIN: { actions: ["manage"] }
|
|
35
|
+
};
|
|
36
|
+
var systemCaslPermissions = {
|
|
37
|
+
USER: {
|
|
38
|
+
actions: ["read"],
|
|
39
|
+
conditions: { user_id: "${user.id}" }
|
|
40
|
+
},
|
|
41
|
+
ADMIN: { actions: ["manage"] }
|
|
42
|
+
};
|
|
43
|
+
var workflowCaslPermissions = {
|
|
44
|
+
USER: {
|
|
45
|
+
actions: ["read", "update"],
|
|
46
|
+
conditions: { assignee_id: "${user.id}" }
|
|
47
|
+
},
|
|
48
|
+
ADMIN: { actions: ["manage"] }
|
|
49
|
+
};
|
|
50
|
+
var polymorphicFields = {
|
|
51
|
+
entity_type: useTextField({
|
|
52
|
+
label: { en: "Entity Type", es: "Tipo de entidad" },
|
|
53
|
+
required: true,
|
|
54
|
+
size: 50,
|
|
55
|
+
index: true,
|
|
56
|
+
placeholder: "posts",
|
|
57
|
+
meta: { showInForm: false, showInDisplay: false }
|
|
58
|
+
}),
|
|
59
|
+
entity_id: useTextField({
|
|
60
|
+
label: { en: "Entity ID", es: "ID de entidad" },
|
|
61
|
+
required: true,
|
|
62
|
+
size: 26,
|
|
63
|
+
index: true,
|
|
64
|
+
meta: { showInForm: false, showInDisplay: false }
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
function applyEntityConfig(base, defaultTable, defaultSubject, config) {
|
|
68
|
+
if (!config) return base;
|
|
69
|
+
const result = { ...base };
|
|
70
|
+
if (config.table) {
|
|
71
|
+
result.table = config.table;
|
|
72
|
+
} else if (config.tablePrefix) {
|
|
73
|
+
result.table = `${config.tablePrefix}${defaultTable}`;
|
|
74
|
+
}
|
|
75
|
+
if (config.label) {
|
|
76
|
+
result.label = config.label;
|
|
77
|
+
}
|
|
78
|
+
if (config.labelPlural) {
|
|
79
|
+
result.labelPlural = config.labelPlural;
|
|
80
|
+
}
|
|
81
|
+
if (config.routePrefix) {
|
|
82
|
+
result.routePrefix = config.routePrefix;
|
|
83
|
+
} else if (config.table || config.tablePrefix) {
|
|
84
|
+
const tableName = result.table || `${config.tablePrefix}${defaultTable}`;
|
|
85
|
+
result.routePrefix = `/${tableName.replace(/_/g, "-")}`;
|
|
86
|
+
}
|
|
87
|
+
if (result.casl) {
|
|
88
|
+
const subject = config.caslSubject || generateCaslSubject(result.table || defaultTable);
|
|
89
|
+
result.casl = {
|
|
90
|
+
...result.casl,
|
|
91
|
+
subject
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
function generateCaslSubject(tableName) {
|
|
97
|
+
return tableName.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("").replace(/s$/, "");
|
|
98
|
+
}
|
|
99
|
+
function createEntityFactory(baseEntity, defaultTable, defaultSubject) {
|
|
100
|
+
return (config) => applyEntityConfig(baseEntity, defaultTable, defaultSubject, config);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/collection/polymorphic/comments.entity.ts
|
|
104
|
+
var DEFAULT_TABLE = "comments";
|
|
105
|
+
var DEFAULT_SUBJECT = "NxComment";
|
|
106
|
+
var baseCommentsEntity = {
|
|
107
|
+
type: "collection",
|
|
108
|
+
table: `nx_${DEFAULT_TABLE}`,
|
|
109
|
+
routePrefix: "/comments",
|
|
110
|
+
label: { en: "Comment", es: "Comentario" },
|
|
111
|
+
labelPlural: { en: "Comments", es: "Comentarios" },
|
|
112
|
+
labelField: "content",
|
|
113
|
+
timestamps: true,
|
|
114
|
+
audit: true,
|
|
115
|
+
fields: {
|
|
116
|
+
id: useIdField(),
|
|
117
|
+
...polymorphicFields,
|
|
118
|
+
user_id: userIdField,
|
|
119
|
+
parent_id: useSelectField({
|
|
120
|
+
label: { en: "Parent Comment", es: "Comentario padre" },
|
|
121
|
+
table: "nx_comments",
|
|
122
|
+
endpoint: "/comments",
|
|
123
|
+
onDelete: "CASCADE",
|
|
124
|
+
nullable: true,
|
|
125
|
+
index: true,
|
|
126
|
+
meta: { showInForm: false, showInDisplay: false }
|
|
127
|
+
}),
|
|
128
|
+
content: useTextareaField({
|
|
129
|
+
label: { en: "Content", es: "Contenido" },
|
|
130
|
+
required: true
|
|
131
|
+
}),
|
|
132
|
+
is_edited: useSwitchField({
|
|
133
|
+
label: { en: "Edited", es: "Editado" },
|
|
134
|
+
meta: { showInForm: false }
|
|
135
|
+
})
|
|
136
|
+
},
|
|
137
|
+
indexes: [
|
|
138
|
+
{ columns: ["entity_type", "entity_id"] },
|
|
139
|
+
{ columns: ["user_id"] },
|
|
140
|
+
{ columns: ["parent_id"] }
|
|
141
|
+
],
|
|
142
|
+
casl: {
|
|
143
|
+
subject: DEFAULT_SUBJECT,
|
|
144
|
+
permissions: polymorphicCaslPermissions
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
var commentsEntity = baseCommentsEntity;
|
|
148
|
+
var createCommentsEntity = createEntityFactory(
|
|
149
|
+
baseCommentsEntity,
|
|
150
|
+
DEFAULT_TABLE,
|
|
151
|
+
DEFAULT_SUBJECT
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
// src/collection/polymorphic/attachments.entity.ts
|
|
155
|
+
var DEFAULT_TABLE2 = "attachments";
|
|
156
|
+
var DEFAULT_SUBJECT2 = "NxAttachment";
|
|
157
|
+
var baseAttachmentsEntity = {
|
|
158
|
+
type: "collection",
|
|
159
|
+
table: `nx_${DEFAULT_TABLE2}`,
|
|
160
|
+
routePrefix: "/attachments",
|
|
161
|
+
label: { en: "Attachment", es: "Adjunto" },
|
|
162
|
+
labelPlural: { en: "Attachments", es: "Adjuntos" },
|
|
163
|
+
labelField: "filename",
|
|
164
|
+
timestamps: true,
|
|
165
|
+
audit: true,
|
|
166
|
+
fields: {
|
|
167
|
+
id: useIdField(),
|
|
168
|
+
...polymorphicFields,
|
|
169
|
+
user_id: userIdField,
|
|
170
|
+
filename: useTextField({
|
|
171
|
+
label: { en: "Filename", es: "Nombre de archivo" },
|
|
172
|
+
required: true,
|
|
173
|
+
meta: { sortable: true }
|
|
174
|
+
}),
|
|
175
|
+
original_name: useTextField({
|
|
176
|
+
label: { en: "Original Name", es: "Nombre original" }
|
|
177
|
+
}),
|
|
178
|
+
mime_type: useTextField({
|
|
179
|
+
label: { en: "MIME Type", es: "Tipo MIME" },
|
|
180
|
+
required: true,
|
|
181
|
+
size: 100
|
|
182
|
+
}),
|
|
183
|
+
size: useNumberField({
|
|
184
|
+
label: { en: "Size (bytes)", es: "Tama\xF1o (bytes)" },
|
|
185
|
+
required: true
|
|
186
|
+
}),
|
|
187
|
+
path: useTextField({
|
|
188
|
+
label: { en: "Storage Path", es: "Ruta de almacenamiento" },
|
|
189
|
+
required: true,
|
|
190
|
+
size: 500,
|
|
191
|
+
meta: { showInDisplay: false }
|
|
192
|
+
}),
|
|
193
|
+
url: useUrlField({
|
|
194
|
+
label: { en: "URL", es: "URL" }
|
|
195
|
+
}),
|
|
196
|
+
thumbnail_url: useUrlField({
|
|
197
|
+
label: { en: "Thumbnail URL", es: "URL de miniatura" }
|
|
198
|
+
}),
|
|
199
|
+
description: useTextareaField({
|
|
200
|
+
label: { en: "Description", es: "Descripci\xF3n" }
|
|
201
|
+
}),
|
|
202
|
+
order: orderField
|
|
203
|
+
},
|
|
204
|
+
indexes: [
|
|
205
|
+
{ columns: ["entity_type", "entity_id"] },
|
|
206
|
+
{ columns: ["user_id"] },
|
|
207
|
+
{ columns: ["mime_type"] }
|
|
208
|
+
],
|
|
209
|
+
casl: {
|
|
210
|
+
subject: DEFAULT_SUBJECT2,
|
|
211
|
+
permissions: polymorphicCaslPermissions
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
var attachmentsEntity = baseAttachmentsEntity;
|
|
215
|
+
var createAttachmentsEntity = createEntityFactory(
|
|
216
|
+
baseAttachmentsEntity,
|
|
217
|
+
DEFAULT_TABLE2,
|
|
218
|
+
DEFAULT_SUBJECT2
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
// src/collection/polymorphic/tags.entity.ts
|
|
222
|
+
var DEFAULT_TABLE3 = "tags";
|
|
223
|
+
var DEFAULT_SUBJECT3 = "NxTag";
|
|
224
|
+
var tagsCaslPermissions = {
|
|
225
|
+
"*": { actions: ["read"] },
|
|
226
|
+
USER: { actions: ["create"] },
|
|
227
|
+
ADMIN: { actions: ["manage"] }
|
|
228
|
+
};
|
|
229
|
+
var baseTagsEntity = {
|
|
230
|
+
type: "dag",
|
|
231
|
+
table: `nx_${DEFAULT_TABLE3}`,
|
|
232
|
+
parentsTable: `nx_${DEFAULT_TABLE3}_parents`,
|
|
233
|
+
routePrefix: "/tags",
|
|
234
|
+
label: { en: "Tag", es: "Etiqueta" },
|
|
235
|
+
labelPlural: { en: "Tags", es: "Etiquetas" },
|
|
236
|
+
labelField: "name",
|
|
237
|
+
timestamps: true,
|
|
238
|
+
allowDragDrop: true,
|
|
239
|
+
fields: {
|
|
240
|
+
id: useIdField(),
|
|
241
|
+
name: useTextField({
|
|
242
|
+
label: { en: "Name", es: "Nombre" },
|
|
243
|
+
required: true,
|
|
244
|
+
size: 100,
|
|
245
|
+
meta: { sortable: true }
|
|
246
|
+
}),
|
|
247
|
+
slug: useTextUniqueField({
|
|
248
|
+
label: { en: "Slug", es: "Slug" },
|
|
249
|
+
size: 100,
|
|
250
|
+
validation: { pattern: "^[a-z0-9-]+$" }
|
|
251
|
+
}),
|
|
252
|
+
description: useTextareaField({
|
|
253
|
+
label: { en: "Description", es: "Descripci\xF3n" }
|
|
254
|
+
}),
|
|
255
|
+
color: useColorField({
|
|
256
|
+
label: { en: "Color", es: "Color" },
|
|
257
|
+
defaultValue: "#3B82F6"
|
|
258
|
+
}),
|
|
259
|
+
icon: useIconField({ label: { en: "Icon", es: "Icono" }, placeholder: "mdi:tag" }),
|
|
260
|
+
is_active: isActiveField,
|
|
261
|
+
order: orderField
|
|
262
|
+
},
|
|
263
|
+
indexes: [
|
|
264
|
+
{ columns: ["name"] }
|
|
265
|
+
],
|
|
266
|
+
// DAG requires at least one root node
|
|
267
|
+
seed: [
|
|
268
|
+
{ name: "Root", slug: "root", is_active: true, order: 0 }
|
|
269
|
+
],
|
|
270
|
+
casl: {
|
|
271
|
+
subject: DEFAULT_SUBJECT3,
|
|
272
|
+
permissions: tagsCaslPermissions
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
var tagEntitiesEntity = {
|
|
276
|
+
type: "collection",
|
|
277
|
+
table: "nx_tag_entities",
|
|
278
|
+
routePrefix: "/tag-entities",
|
|
279
|
+
label: { en: "Tag Association", es: "Asociaci\xF3n de etiqueta" },
|
|
280
|
+
labelPlural: { en: "Tag Associations", es: "Asociaciones de etiquetas" },
|
|
281
|
+
labelField: "tag_id",
|
|
282
|
+
timestamps: true,
|
|
283
|
+
fields: {
|
|
284
|
+
id: idField,
|
|
285
|
+
tag_id: useSelectField({
|
|
286
|
+
label: { en: "Tag", es: "Etiqueta" },
|
|
287
|
+
table: "nx_tags",
|
|
288
|
+
endpoint: "/tags",
|
|
289
|
+
onDelete: "CASCADE",
|
|
290
|
+
required: true,
|
|
291
|
+
index: true
|
|
292
|
+
}),
|
|
293
|
+
entity_type: useTextField({
|
|
294
|
+
label: { en: "Entity Type", es: "Tipo de entidad" },
|
|
295
|
+
required: true,
|
|
296
|
+
size: 50,
|
|
297
|
+
index: true
|
|
298
|
+
}),
|
|
299
|
+
entity_id: useTextField({
|
|
300
|
+
label: { en: "Entity ID", es: "ID de entidad" },
|
|
301
|
+
required: true,
|
|
302
|
+
size: 26,
|
|
303
|
+
index: true
|
|
304
|
+
})
|
|
305
|
+
},
|
|
306
|
+
indexes: [
|
|
307
|
+
{ columns: ["tag_id", "entity_type", "entity_id"], unique: true },
|
|
308
|
+
{ columns: ["entity_type", "entity_id"] }
|
|
309
|
+
],
|
|
310
|
+
casl: {
|
|
311
|
+
subject: "NxTagEntity",
|
|
312
|
+
permissions: tagsCaslPermissions
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
var tagsEntity = baseTagsEntity;
|
|
316
|
+
var createTagsEntity = createEntityFactory(
|
|
317
|
+
baseTagsEntity,
|
|
318
|
+
DEFAULT_TABLE3,
|
|
319
|
+
DEFAULT_SUBJECT3
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
// src/collection/polymorphic/notes.entity.ts
|
|
323
|
+
var DEFAULT_TABLE4 = "notes";
|
|
324
|
+
var DEFAULT_SUBJECT4 = "NxNote";
|
|
325
|
+
var baseNotesEntity = {
|
|
326
|
+
type: "collection",
|
|
327
|
+
table: `nx_${DEFAULT_TABLE4}`,
|
|
328
|
+
routePrefix: "/notes",
|
|
329
|
+
label: { en: "Note", es: "Nota" },
|
|
330
|
+
labelPlural: { en: "Notes", es: "Notas" },
|
|
331
|
+
labelField: "content",
|
|
332
|
+
timestamps: true,
|
|
333
|
+
audit: true,
|
|
334
|
+
fields: {
|
|
335
|
+
id: useIdField(),
|
|
336
|
+
...polymorphicFields,
|
|
337
|
+
user_id: userIdField,
|
|
338
|
+
content: {
|
|
339
|
+
label: { en: "Content", es: "Contenido" },
|
|
340
|
+
input: "markdown",
|
|
341
|
+
required: true,
|
|
342
|
+
db: { type: "text", nullable: false },
|
|
343
|
+
meta: { searchable: true }
|
|
344
|
+
},
|
|
345
|
+
is_pinned: useSwitchField({
|
|
346
|
+
label: { en: "Pinned", es: "Fijada" },
|
|
347
|
+
meta: { sortable: true }
|
|
348
|
+
}),
|
|
349
|
+
visibility: useSelectField({
|
|
350
|
+
label: { en: "Visibility", es: "Visibilidad" },
|
|
351
|
+
options: [
|
|
352
|
+
{ value: "private", label: { en: "Private (only me)", es: "Privada (solo yo)" } },
|
|
353
|
+
{ value: "team", label: { en: "Team", es: "Equipo" } },
|
|
354
|
+
{ value: "public", label: { en: "Public", es: "P\xFAblica" } }
|
|
355
|
+
],
|
|
356
|
+
defaultValue: "private",
|
|
357
|
+
required: true,
|
|
358
|
+
size: 20
|
|
359
|
+
})
|
|
360
|
+
},
|
|
361
|
+
indexes: [
|
|
362
|
+
{ columns: ["entity_type", "entity_id"] },
|
|
363
|
+
{ columns: ["user_id"] },
|
|
364
|
+
{ columns: ["is_pinned"] }
|
|
365
|
+
],
|
|
366
|
+
casl: {
|
|
367
|
+
subject: DEFAULT_SUBJECT4,
|
|
368
|
+
permissions: polymorphicCaslPermissions
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
var notesEntity = baseNotesEntity;
|
|
372
|
+
var createNotesEntity = createEntityFactory(
|
|
373
|
+
baseNotesEntity,
|
|
374
|
+
DEFAULT_TABLE4,
|
|
375
|
+
DEFAULT_SUBJECT4
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
// src/collection/polymorphic/favorites.entity.ts
|
|
379
|
+
var DEFAULT_TABLE5 = "favorites";
|
|
380
|
+
var DEFAULT_SUBJECT5 = "NxFavorite";
|
|
381
|
+
var favoritesCaslPermissions = {
|
|
382
|
+
USER: {
|
|
383
|
+
actions: ["read", "create", "delete"],
|
|
384
|
+
conditions: { user_id: "${user.id}" }
|
|
385
|
+
},
|
|
386
|
+
ADMIN: { actions: ["manage"] }
|
|
387
|
+
};
|
|
388
|
+
var baseFavoritesEntity = {
|
|
389
|
+
type: "collection",
|
|
390
|
+
table: `nx_${DEFAULT_TABLE5}`,
|
|
391
|
+
routePrefix: "/favorites",
|
|
392
|
+
label: { en: "Favorite", es: "Favorito" },
|
|
393
|
+
labelPlural: { en: "Favorites", es: "Favoritos" },
|
|
394
|
+
labelField: "entity_type",
|
|
395
|
+
timestamps: true,
|
|
396
|
+
fields: {
|
|
397
|
+
id: useIdField(),
|
|
398
|
+
user_id: userIdField,
|
|
399
|
+
...polymorphicFields,
|
|
400
|
+
label: useTextField({
|
|
401
|
+
label: { en: "Label", es: "Etiqueta" },
|
|
402
|
+
size: 100,
|
|
403
|
+
hint: { en: "Custom label for this favorite", es: "Etiqueta personalizada" }
|
|
404
|
+
}),
|
|
405
|
+
folder: useTextField({
|
|
406
|
+
label: { en: "Folder", es: "Carpeta" },
|
|
407
|
+
size: 50,
|
|
408
|
+
index: true,
|
|
409
|
+
hint: { en: "Organize favorites into folders", es: "Organizar favoritos en carpetas" }
|
|
410
|
+
}),
|
|
411
|
+
order: orderField
|
|
412
|
+
},
|
|
413
|
+
indexes: [
|
|
414
|
+
{ columns: ["user_id", "entity_type", "entity_id"], unique: true },
|
|
415
|
+
{ columns: ["user_id", "folder"] }
|
|
416
|
+
],
|
|
417
|
+
casl: {
|
|
418
|
+
subject: DEFAULT_SUBJECT5,
|
|
419
|
+
permissions: favoritesCaslPermissions
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
var favoritesEntity = baseFavoritesEntity;
|
|
423
|
+
var createFavoritesEntity = createEntityFactory(
|
|
424
|
+
baseFavoritesEntity,
|
|
425
|
+
DEFAULT_TABLE5,
|
|
426
|
+
DEFAULT_SUBJECT5
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
// src/collection/polymorphic/ratings.entity.ts
|
|
430
|
+
var DEFAULT_TABLE6 = "ratings";
|
|
431
|
+
var DEFAULT_SUBJECT6 = "NxRating";
|
|
432
|
+
var ratingsCaslPermissions = {
|
|
433
|
+
"*": { actions: ["read"] },
|
|
434
|
+
USER: {
|
|
435
|
+
actions: ["create", "update", "delete"],
|
|
436
|
+
conditions: { user_id: "${user.id}" }
|
|
437
|
+
},
|
|
438
|
+
ADMIN: { actions: ["manage"] }
|
|
439
|
+
};
|
|
440
|
+
var baseRatingsEntity = {
|
|
441
|
+
type: "collection",
|
|
442
|
+
table: `nx_${DEFAULT_TABLE6}`,
|
|
443
|
+
routePrefix: "/ratings",
|
|
444
|
+
label: { en: "Rating", es: "Calificaci\xF3n" },
|
|
445
|
+
labelPlural: { en: "Ratings", es: "Calificaciones" },
|
|
446
|
+
labelField: "score",
|
|
447
|
+
timestamps: true,
|
|
448
|
+
audit: true,
|
|
449
|
+
fields: {
|
|
450
|
+
id: useIdField(),
|
|
451
|
+
...polymorphicFields,
|
|
452
|
+
user_id: userIdField,
|
|
453
|
+
score: useNumberField({
|
|
454
|
+
label: { en: "Score", es: "Puntuaci\xF3n" },
|
|
455
|
+
required: true,
|
|
456
|
+
validation: { min: 1, max: 5 }
|
|
457
|
+
}),
|
|
458
|
+
title: useTextField({
|
|
459
|
+
label: { en: "Title", es: "T\xEDtulo" },
|
|
460
|
+
size: 200
|
|
461
|
+
}),
|
|
462
|
+
review: useTextareaField({
|
|
463
|
+
label: { en: "Review", es: "Rese\xF1a" }
|
|
464
|
+
}),
|
|
465
|
+
is_verified: useSwitchField({
|
|
466
|
+
label: { en: "Verified Purchase", es: "Compra verificada" },
|
|
467
|
+
meta: { showInForm: false }
|
|
468
|
+
}),
|
|
469
|
+
helpful_count: useNumberField({
|
|
470
|
+
label: { en: "Helpful Votes", es: "Votos \xFAtiles" },
|
|
471
|
+
defaultValue: 0,
|
|
472
|
+
meta: { showInForm: false }
|
|
473
|
+
})
|
|
474
|
+
},
|
|
475
|
+
indexes: [
|
|
476
|
+
{ columns: ["entity_type", "entity_id"] },
|
|
477
|
+
{ columns: ["user_id", "entity_type", "entity_id"], unique: true },
|
|
478
|
+
{ columns: ["score"] }
|
|
479
|
+
],
|
|
480
|
+
casl: {
|
|
481
|
+
subject: DEFAULT_SUBJECT6,
|
|
482
|
+
permissions: ratingsCaslPermissions
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
var ratingsEntity = baseRatingsEntity;
|
|
486
|
+
var createRatingsEntity = createEntityFactory(
|
|
487
|
+
baseRatingsEntity,
|
|
488
|
+
DEFAULT_TABLE6,
|
|
489
|
+
DEFAULT_SUBJECT6
|
|
490
|
+
);
|
|
491
|
+
|
|
492
|
+
// src/collection/polymorphic/reactions.entity.ts
|
|
493
|
+
var DEFAULT_TABLE7 = "reactions";
|
|
494
|
+
var DEFAULT_SUBJECT7 = "NxReaction";
|
|
495
|
+
var reactionsCaslPermissions = {
|
|
496
|
+
"*": { actions: ["read"] },
|
|
497
|
+
USER: {
|
|
498
|
+
actions: ["create", "delete"],
|
|
499
|
+
conditions: { user_id: "${user.id}" }
|
|
500
|
+
},
|
|
501
|
+
ADMIN: { actions: ["manage"] }
|
|
502
|
+
};
|
|
503
|
+
var REACTION_TYPES = {
|
|
504
|
+
LIKE: "like",
|
|
505
|
+
LOVE: "love",
|
|
506
|
+
HAHA: "haha",
|
|
507
|
+
WOW: "wow",
|
|
508
|
+
SAD: "sad",
|
|
509
|
+
ANGRY: "angry",
|
|
510
|
+
THUMBS_UP: "thumbs_up",
|
|
511
|
+
THUMBS_DOWN: "thumbs_down",
|
|
512
|
+
CELEBRATE: "celebrate",
|
|
513
|
+
SUPPORT: "support"
|
|
514
|
+
};
|
|
515
|
+
var baseReactionsEntity = {
|
|
516
|
+
type: "collection",
|
|
517
|
+
table: `nx_${DEFAULT_TABLE7}`,
|
|
518
|
+
routePrefix: "/reactions",
|
|
519
|
+
label: { en: "Reaction", es: "Reacci\xF3n" },
|
|
520
|
+
labelPlural: { en: "Reactions", es: "Reacciones" },
|
|
521
|
+
labelField: "type",
|
|
522
|
+
timestamps: true,
|
|
523
|
+
fields: {
|
|
524
|
+
id: useIdField(),
|
|
525
|
+
...polymorphicFields,
|
|
526
|
+
user_id: userIdField,
|
|
527
|
+
type: useSelectField({
|
|
528
|
+
label: { en: "Type", es: "Tipo" },
|
|
529
|
+
options: [
|
|
530
|
+
{ value: "like", label: { en: "Like", es: "Me gusta" } },
|
|
531
|
+
{ value: "love", label: { en: "Love", es: "Me encanta" } },
|
|
532
|
+
{ value: "haha", label: { en: "Haha", es: "Jaja" } },
|
|
533
|
+
{ value: "wow", label: { en: "Wow", es: "Asombro" } },
|
|
534
|
+
{ value: "sad", label: { en: "Sad", es: "Triste" } },
|
|
535
|
+
{ value: "angry", label: { en: "Angry", es: "Enfadado" } },
|
|
536
|
+
{ value: "thumbs_up", label: { en: "Thumbs Up", es: "Pulgar arriba" } },
|
|
537
|
+
{ value: "thumbs_down", label: { en: "Thumbs Down", es: "Pulgar abajo" } },
|
|
538
|
+
{ value: "celebrate", label: { en: "Celebrate", es: "Celebrar" } },
|
|
539
|
+
{ value: "support", label: { en: "Support", es: "Apoyo" } }
|
|
540
|
+
],
|
|
541
|
+
required: true,
|
|
542
|
+
size: 20
|
|
543
|
+
})
|
|
544
|
+
},
|
|
545
|
+
indexes: [
|
|
546
|
+
{ columns: ["entity_type", "entity_id"] },
|
|
547
|
+
{ columns: ["user_id", "entity_type", "entity_id", "type"], unique: true },
|
|
548
|
+
{ columns: ["type"] }
|
|
549
|
+
],
|
|
550
|
+
casl: {
|
|
551
|
+
subject: DEFAULT_SUBJECT7,
|
|
552
|
+
permissions: reactionsCaslPermissions
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
var reactionsEntity = baseReactionsEntity;
|
|
556
|
+
var createReactionsEntity = createEntityFactory(
|
|
557
|
+
baseReactionsEntity,
|
|
558
|
+
DEFAULT_TABLE7,
|
|
559
|
+
DEFAULT_SUBJECT7
|
|
560
|
+
);
|
|
561
|
+
|
|
562
|
+
// src/collection/polymorphic/mentions.entity.ts
|
|
563
|
+
var DEFAULT_TABLE8 = "mentions";
|
|
564
|
+
var DEFAULT_SUBJECT8 = "NxMention";
|
|
565
|
+
var mentionsCaslPermissions = {
|
|
566
|
+
USER: {
|
|
567
|
+
actions: ["read"],
|
|
568
|
+
conditions: { mentioned_user_id: "${user.id}" }
|
|
569
|
+
},
|
|
570
|
+
ADMIN: { actions: ["manage"] }
|
|
571
|
+
};
|
|
572
|
+
var baseMentionsEntity = {
|
|
573
|
+
type: "collection",
|
|
574
|
+
table: `nx_${DEFAULT_TABLE8}`,
|
|
575
|
+
routePrefix: "/mentions",
|
|
576
|
+
label: { en: "Mention", es: "Menci\xF3n" },
|
|
577
|
+
labelPlural: { en: "Mentions", es: "Menciones" },
|
|
578
|
+
labelField: "mentioned_user_id",
|
|
579
|
+
timestamps: true,
|
|
580
|
+
fields: {
|
|
581
|
+
id: useIdField(),
|
|
582
|
+
...polymorphicFields,
|
|
583
|
+
mentioned_user_id: useSelectField({
|
|
584
|
+
label: { en: "Mentioned User", es: "Usuario mencionado" },
|
|
585
|
+
table: "users",
|
|
586
|
+
endpoint: "/users",
|
|
587
|
+
onDelete: "CASCADE",
|
|
588
|
+
required: true,
|
|
589
|
+
index: true
|
|
590
|
+
}),
|
|
591
|
+
mentioner_user_id: useSelectField({
|
|
592
|
+
label: { en: "Mentioner", es: "Quien menciona" },
|
|
593
|
+
table: "users",
|
|
594
|
+
endpoint: "/users",
|
|
595
|
+
onDelete: "CASCADE",
|
|
596
|
+
required: true,
|
|
597
|
+
index: true
|
|
598
|
+
}),
|
|
599
|
+
context: useTextareaField({
|
|
600
|
+
label: { en: "Context", es: "Contexto" },
|
|
601
|
+
hint: { en: "Text snippet around the mention", es: "Fragmento de texto alrededor de la menci\xF3n" },
|
|
602
|
+
nullable: true
|
|
603
|
+
}),
|
|
604
|
+
is_read: useSwitchField({
|
|
605
|
+
label: { en: "Read", es: "Le\xEDda" },
|
|
606
|
+
meta: { sortable: true }
|
|
607
|
+
})
|
|
608
|
+
},
|
|
609
|
+
indexes: [
|
|
610
|
+
{ columns: ["entity_type", "entity_id"] },
|
|
611
|
+
{ columns: ["mentioned_user_id", "is_read"] },
|
|
612
|
+
{ columns: ["mentioner_user_id"] }
|
|
613
|
+
],
|
|
614
|
+
casl: {
|
|
615
|
+
subject: DEFAULT_SUBJECT8,
|
|
616
|
+
permissions: mentionsCaslPermissions
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
var mentionsEntity = baseMentionsEntity;
|
|
620
|
+
var createMentionsEntity = createEntityFactory(
|
|
621
|
+
baseMentionsEntity,
|
|
622
|
+
DEFAULT_TABLE8,
|
|
623
|
+
DEFAULT_SUBJECT8
|
|
624
|
+
);
|
|
625
|
+
|
|
626
|
+
// src/collection/polymorphic/options.entity.ts
|
|
627
|
+
var DEFAULT_TABLE9 = "options";
|
|
628
|
+
var DEFAULT_SUBJECT9 = "NxOption";
|
|
629
|
+
var optionsCaslPermissions = {
|
|
630
|
+
"*": { actions: ["read"] },
|
|
631
|
+
ADMIN: { actions: ["manage"] }
|
|
632
|
+
};
|
|
633
|
+
var OPTION_GROUPS = {
|
|
634
|
+
STATUS: "status",
|
|
635
|
+
PRIORITY: "priority",
|
|
636
|
+
CATEGORY: "category",
|
|
637
|
+
TYPE: "type",
|
|
638
|
+
LEVEL: "level",
|
|
639
|
+
SIZE: "size",
|
|
640
|
+
COLOR: "color"
|
|
641
|
+
};
|
|
642
|
+
var DEFAULT_OPTIONS_SEED = [
|
|
643
|
+
// Status options
|
|
644
|
+
{ id: "opt-status-draft", option_group: "status", value: "draft", label: JSON.stringify({ en: "Draft", es: "Borrador" }), color: "#9CA3AF", icon: "mdi:file-edit-outline", order: 1, is_default: false, is_active: true },
|
|
645
|
+
{ id: "opt-status-pending", option_group: "status", value: "pending", label: JSON.stringify({ en: "Pending", es: "Pendiente" }), color: "#F59E0B", icon: "mdi:clock-outline", order: 2, is_default: false, is_active: true },
|
|
646
|
+
{ id: "opt-status-active", option_group: "status", value: "active", label: JSON.stringify({ en: "Active", es: "Activo" }), color: "#10B981", icon: "mdi:check-circle-outline", order: 3, is_default: true, is_active: true },
|
|
647
|
+
{ id: "opt-status-archived", option_group: "status", value: "archived", label: JSON.stringify({ en: "Archived", es: "Archivado" }), color: "#6B7280", icon: "mdi:archive-outline", order: 4, is_default: false, is_active: true },
|
|
648
|
+
// Priority options
|
|
649
|
+
{ id: "opt-priority-low", option_group: "priority", value: "low", label: JSON.stringify({ en: "Low", es: "Baja" }), color: "#10B981", icon: "mdi:arrow-down", order: 1, is_default: false, is_active: true },
|
|
650
|
+
{ id: "opt-priority-medium", option_group: "priority", value: "medium", label: JSON.stringify({ en: "Medium", es: "Media" }), color: "#F59E0B", icon: "mdi:minus", order: 2, is_default: true, is_active: true },
|
|
651
|
+
{ id: "opt-priority-high", option_group: "priority", value: "high", label: JSON.stringify({ en: "High", es: "Alta" }), color: "#EF4444", icon: "mdi:arrow-up", order: 3, is_default: false, is_active: true },
|
|
652
|
+
{ id: "opt-priority-critical", option_group: "priority", value: "critical", label: JSON.stringify({ en: "Critical", es: "Cr\xEDtica" }), color: "#DC2626", icon: "mdi:alert", order: 4, is_default: false, is_active: true }
|
|
653
|
+
];
|
|
654
|
+
var baseOptionsEntity = {
|
|
655
|
+
type: "collection",
|
|
656
|
+
table: `nx_${DEFAULT_TABLE9}`,
|
|
657
|
+
routePrefix: "/options",
|
|
658
|
+
label: { en: "Option", es: "Opci\xF3n" },
|
|
659
|
+
labelPlural: { en: "Options", es: "Opciones" },
|
|
660
|
+
labelField: "label",
|
|
661
|
+
timestamps: true,
|
|
662
|
+
fields: {
|
|
663
|
+
id: useIdField(),
|
|
664
|
+
option_group: useTextField({
|
|
665
|
+
label: { en: "Group", es: "Grupo" },
|
|
666
|
+
required: true,
|
|
667
|
+
size: 50,
|
|
668
|
+
index: true,
|
|
669
|
+
placeholder: "status",
|
|
670
|
+
hint: { en: "Groups options together (e.g., status, priority)", es: "Agrupa opciones (ej: status, priority)" },
|
|
671
|
+
meta: { sortable: true }
|
|
672
|
+
}),
|
|
673
|
+
value: useTextField({
|
|
674
|
+
label: { en: "Value", es: "Valor" },
|
|
675
|
+
required: true,
|
|
676
|
+
size: 100,
|
|
677
|
+
placeholder: "active",
|
|
678
|
+
hint: { en: "Internal value stored in DB", es: "Valor interno guardado en DB" },
|
|
679
|
+
validation: { pattern: "^[a-z0-9_-]+$" }
|
|
680
|
+
}),
|
|
681
|
+
label: useLocalizedField({
|
|
682
|
+
label: { en: "Label", es: "Etiqueta" },
|
|
683
|
+
hint: { en: "Display text (supports i18n JSON)", es: "Texto a mostrar (soporta JSON i18n)" },
|
|
684
|
+
meta: { searchable: true, sortable: false }
|
|
685
|
+
}),
|
|
686
|
+
description: useTextareaField({
|
|
687
|
+
label: { en: "Description", es: "Descripci\xF3n" },
|
|
688
|
+
nullable: true,
|
|
689
|
+
meta: { searchable: true }
|
|
690
|
+
}),
|
|
691
|
+
color: useColorField({
|
|
692
|
+
label: { en: "Color", es: "Color" },
|
|
693
|
+
defaultValue: "#3B82F6",
|
|
694
|
+
hint: { en: "Badge/tag color", es: "Color de badge/tag" }
|
|
695
|
+
}),
|
|
696
|
+
icon: useIconField({ label: { en: "Icon", es: "Icono" }, placeholder: "mdi:check" }),
|
|
697
|
+
is_default: useSwitchField({
|
|
698
|
+
label: { en: "Default", es: "Por defecto" },
|
|
699
|
+
hint: { en: "Use as default value for new records", es: "Usar como valor por defecto" }
|
|
700
|
+
}),
|
|
701
|
+
is_active: isActiveField,
|
|
702
|
+
order: orderField,
|
|
703
|
+
metadata: useJsonField({
|
|
704
|
+
label: { en: "Metadata", es: "Metadatos" },
|
|
705
|
+
hint: { en: "Extra data (e.g., workflows, transitions)", es: "Datos extra (ej: workflows, transiciones)" }
|
|
706
|
+
})
|
|
707
|
+
},
|
|
708
|
+
indexes: [
|
|
709
|
+
{ columns: ["option_group", "value"], unique: true },
|
|
710
|
+
{ columns: ["option_group", "is_active", "order"] },
|
|
711
|
+
{ columns: ["is_default"] }
|
|
712
|
+
],
|
|
713
|
+
casl: {
|
|
714
|
+
subject: DEFAULT_SUBJECT9,
|
|
715
|
+
permissions: optionsCaslPermissions
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
var optionsEntity = baseOptionsEntity;
|
|
719
|
+
var createOptionsEntity = createEntityFactory(
|
|
720
|
+
baseOptionsEntity,
|
|
721
|
+
DEFAULT_TABLE9,
|
|
722
|
+
DEFAULT_SUBJECT9
|
|
723
|
+
);
|
|
724
|
+
function dynamicOptions(group, module = "collection", entity = "nx-options") {
|
|
725
|
+
return {
|
|
726
|
+
endpoint: `/api/v1/${module}/${entity}`,
|
|
727
|
+
filter: { option_group: group, is_active: true },
|
|
728
|
+
valueField: "value",
|
|
729
|
+
labelField: "label",
|
|
730
|
+
sortField: "order"
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// src/collection/system/activity-log.entity.ts
|
|
735
|
+
var DEFAULT_TABLE10 = "activity_log";
|
|
736
|
+
var DEFAULT_SUBJECT10 = "NxActivityLog";
|
|
737
|
+
var activityLogCaslPermissions = {
|
|
738
|
+
ADMIN: { actions: ["read", "delete"] }
|
|
739
|
+
};
|
|
740
|
+
var ACTIVITY_TYPES = {
|
|
741
|
+
// Auth
|
|
742
|
+
LOGIN: "auth.login",
|
|
743
|
+
LOGOUT: "auth.logout",
|
|
744
|
+
PASSWORD_CHANGE: "auth.password_change",
|
|
745
|
+
// CRUD
|
|
746
|
+
CREATE: "data.create",
|
|
747
|
+
UPDATE: "data.update",
|
|
748
|
+
DELETE: "data.delete",
|
|
749
|
+
// System
|
|
750
|
+
EXPORT: "system.export",
|
|
751
|
+
IMPORT: "system.import",
|
|
752
|
+
CONFIG_CHANGE: "system.config_change",
|
|
753
|
+
// Custom
|
|
754
|
+
CUSTOM: "custom"
|
|
755
|
+
};
|
|
756
|
+
var baseActivityLogEntity = {
|
|
757
|
+
type: "event",
|
|
758
|
+
table: `nx_${DEFAULT_TABLE10}`,
|
|
759
|
+
routePrefix: "/activity-log",
|
|
760
|
+
label: { en: "Activity", es: "Actividad" },
|
|
761
|
+
labelPlural: { en: "Activities", es: "Actividades" },
|
|
762
|
+
labelField: "action",
|
|
763
|
+
timestamps: true,
|
|
764
|
+
retention: {
|
|
765
|
+
days: 90,
|
|
766
|
+
maxRows: 1e5
|
|
767
|
+
},
|
|
768
|
+
fields: {
|
|
769
|
+
id: useIdField(),
|
|
770
|
+
user_id: useSelectField({
|
|
771
|
+
label: { en: "User", es: "Usuario" },
|
|
772
|
+
table: "users",
|
|
773
|
+
endpoint: "/users",
|
|
774
|
+
onDelete: "SET NULL",
|
|
775
|
+
nullable: true,
|
|
776
|
+
index: true,
|
|
777
|
+
meta: { sortable: true }
|
|
778
|
+
}),
|
|
779
|
+
action: useTextField({
|
|
780
|
+
label: { en: "Action", es: "Acci\xF3n" },
|
|
781
|
+
required: true,
|
|
782
|
+
size: 100,
|
|
783
|
+
index: true,
|
|
784
|
+
placeholder: "data.create",
|
|
785
|
+
meta: { sortable: true }
|
|
786
|
+
}),
|
|
787
|
+
entity_type: useTextField({
|
|
788
|
+
label: { en: "Entity Type", es: "Tipo de entidad" },
|
|
789
|
+
size: 50,
|
|
790
|
+
index: true
|
|
791
|
+
}),
|
|
792
|
+
entity_id: useTextField({
|
|
793
|
+
label: { en: "Entity ID", es: "ID de entidad" },
|
|
794
|
+
size: 26,
|
|
795
|
+
index: true
|
|
796
|
+
}),
|
|
797
|
+
description: useTextField({
|
|
798
|
+
label: { en: "Description", es: "Descripci\xF3n" },
|
|
799
|
+
size: 500
|
|
800
|
+
}),
|
|
801
|
+
old_values: useJsonField({
|
|
802
|
+
label: { en: "Old Values", es: "Valores anteriores" }
|
|
803
|
+
}),
|
|
804
|
+
new_values: useJsonField({
|
|
805
|
+
label: { en: "New Values", es: "Valores nuevos" }
|
|
806
|
+
}),
|
|
807
|
+
ip_address: useTextField({
|
|
808
|
+
label: { en: "IP Address", es: "Direcci\xF3n IP" },
|
|
809
|
+
size: 45
|
|
810
|
+
}),
|
|
811
|
+
user_agent: useTextField({
|
|
812
|
+
label: { en: "User Agent", es: "Agente de usuario" },
|
|
813
|
+
size: 500,
|
|
814
|
+
meta: { showInDisplay: false }
|
|
815
|
+
}),
|
|
816
|
+
metadata: useJsonField({
|
|
817
|
+
label: { en: "Metadata", es: "Metadatos" }
|
|
818
|
+
})
|
|
819
|
+
},
|
|
820
|
+
casl: {
|
|
821
|
+
subject: DEFAULT_SUBJECT10,
|
|
822
|
+
permissions: activityLogCaslPermissions
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
var activityLogEntity = baseActivityLogEntity;
|
|
826
|
+
var createActivityLogEntity = createEntityFactory(
|
|
827
|
+
baseActivityLogEntity,
|
|
828
|
+
DEFAULT_TABLE10,
|
|
829
|
+
DEFAULT_SUBJECT10
|
|
830
|
+
);
|
|
831
|
+
|
|
832
|
+
// src/collection/system/notifications.entity.ts
|
|
833
|
+
var DEFAULT_TABLE11 = "notifications";
|
|
834
|
+
var DEFAULT_SUBJECT11 = "NxNotification";
|
|
835
|
+
var notificationsCaslPermissions = {
|
|
836
|
+
USER: {
|
|
837
|
+
actions: ["read", "update", "delete"],
|
|
838
|
+
conditions: { user_id: "${user.id}" }
|
|
839
|
+
},
|
|
840
|
+
ADMIN: { actions: ["manage"] }
|
|
841
|
+
};
|
|
842
|
+
var NOTIFICATION_TYPES = {
|
|
843
|
+
INFO: "info",
|
|
844
|
+
SUCCESS: "success",
|
|
845
|
+
WARNING: "warning",
|
|
846
|
+
ERROR: "error",
|
|
847
|
+
MENTION: "mention",
|
|
848
|
+
ASSIGNMENT: "assignment",
|
|
849
|
+
REMINDER: "reminder",
|
|
850
|
+
SYSTEM: "system"
|
|
851
|
+
};
|
|
852
|
+
var baseNotificationsEntity = {
|
|
853
|
+
type: "collection",
|
|
854
|
+
table: `nx_${DEFAULT_TABLE11}`,
|
|
855
|
+
routePrefix: "/notifications",
|
|
856
|
+
label: { en: "Notification", es: "Notificaci\xF3n" },
|
|
857
|
+
labelPlural: { en: "Notifications", es: "Notificaciones" },
|
|
858
|
+
labelField: "title",
|
|
859
|
+
timestamps: true,
|
|
860
|
+
fields: {
|
|
861
|
+
id: useIdField(),
|
|
862
|
+
user_id: useSelectField({
|
|
863
|
+
label: { en: "User", es: "Usuario" },
|
|
864
|
+
table: "users",
|
|
865
|
+
endpoint: "/users",
|
|
866
|
+
onDelete: "CASCADE",
|
|
867
|
+
required: true,
|
|
868
|
+
index: true
|
|
869
|
+
}),
|
|
870
|
+
type: useSelectField({
|
|
871
|
+
label: { en: "Type", es: "Tipo" },
|
|
872
|
+
options: [
|
|
873
|
+
{ value: "info", label: { en: "Info", es: "Informaci\xF3n" } },
|
|
874
|
+
{ value: "success", label: { en: "Success", es: "\xC9xito" } },
|
|
875
|
+
{ value: "warning", label: { en: "Warning", es: "Advertencia" } },
|
|
876
|
+
{ value: "error", label: { en: "Error", es: "Error" } },
|
|
877
|
+
{ value: "mention", label: { en: "Mention", es: "Menci\xF3n" } },
|
|
878
|
+
{ value: "assignment", label: { en: "Assignment", es: "Asignaci\xF3n" } },
|
|
879
|
+
{ value: "reminder", label: { en: "Reminder", es: "Recordatorio" } },
|
|
880
|
+
{ value: "system", label: { en: "System", es: "Sistema" } }
|
|
881
|
+
],
|
|
882
|
+
defaultValue: "info",
|
|
883
|
+
required: true,
|
|
884
|
+
size: 20,
|
|
885
|
+
index: true
|
|
886
|
+
}),
|
|
887
|
+
title: useTextField({
|
|
888
|
+
label: { en: "Title", es: "T\xEDtulo" },
|
|
889
|
+
required: true,
|
|
890
|
+
size: 200
|
|
891
|
+
}),
|
|
892
|
+
message: useTextareaField({
|
|
893
|
+
label: { en: "Message", es: "Mensaje" }
|
|
894
|
+
}),
|
|
895
|
+
icon: useIconField({ label: { en: "Icon", es: "Icono" } }),
|
|
896
|
+
link: useTextField({
|
|
897
|
+
label: { en: "Link", es: "Enlace" },
|
|
898
|
+
size: 500,
|
|
899
|
+
hint: { en: "URL or route to navigate on click", es: "URL o ruta al hacer clic" }
|
|
900
|
+
}),
|
|
901
|
+
entity_type: useTextField({
|
|
902
|
+
label: { en: "Related Entity Type", es: "Tipo de entidad relacionada" },
|
|
903
|
+
size: 50,
|
|
904
|
+
index: true
|
|
905
|
+
}),
|
|
906
|
+
entity_id: useTextField({
|
|
907
|
+
label: { en: "Related Entity ID", es: "ID de entidad relacionada" },
|
|
908
|
+
size: 26
|
|
909
|
+
}),
|
|
910
|
+
is_read: useSwitchField({
|
|
911
|
+
label: { en: "Read", es: "Le\xEDda" },
|
|
912
|
+
defaultValue: false,
|
|
913
|
+
meta: { sortable: true }
|
|
914
|
+
}),
|
|
915
|
+
read_at: useDatetimeField({
|
|
916
|
+
label: { en: "Read At", es: "Le\xEDda el" },
|
|
917
|
+
meta: { showInForm: false }
|
|
918
|
+
}),
|
|
919
|
+
metadata: useJsonField({
|
|
920
|
+
label: { en: "Metadata", es: "Metadatos" }
|
|
921
|
+
})
|
|
922
|
+
},
|
|
923
|
+
indexes: [
|
|
924
|
+
{ columns: ["user_id", "is_read", "created_at"] },
|
|
925
|
+
{ columns: ["type"] }
|
|
926
|
+
],
|
|
927
|
+
casl: {
|
|
928
|
+
subject: DEFAULT_SUBJECT11,
|
|
929
|
+
permissions: notificationsCaslPermissions
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
var notificationsEntity = baseNotificationsEntity;
|
|
933
|
+
var createNotificationsEntity = createEntityFactory(
|
|
934
|
+
baseNotificationsEntity,
|
|
935
|
+
DEFAULT_TABLE11,
|
|
936
|
+
DEFAULT_SUBJECT11
|
|
937
|
+
);
|
|
938
|
+
|
|
939
|
+
// src/collection/system/preferences.entity.ts
|
|
940
|
+
var DEFAULT_TABLE12 = "preferences";
|
|
941
|
+
var DEFAULT_SUBJECT12 = "NxPreference";
|
|
942
|
+
var preferencesCaslPermissions = {
|
|
943
|
+
USER: {
|
|
944
|
+
actions: ["read", "create", "update", "delete"],
|
|
945
|
+
conditions: { user_id: "${user.id}" }
|
|
946
|
+
},
|
|
947
|
+
ADMIN: { actions: ["manage"] }
|
|
948
|
+
};
|
|
949
|
+
var PREFERENCE_KEYS = {
|
|
950
|
+
THEME: "theme",
|
|
951
|
+
LANGUAGE: "language",
|
|
952
|
+
TIMEZONE: "timezone",
|
|
953
|
+
SIDEBAR_COLLAPSED: "sidebar_collapsed",
|
|
954
|
+
NOTIFICATIONS_ENABLED: "notifications_enabled",
|
|
955
|
+
EMAIL_DIGEST: "email_digest"
|
|
956
|
+
};
|
|
957
|
+
var basePreferencesEntity = {
|
|
958
|
+
type: "collection",
|
|
959
|
+
table: `nx_${DEFAULT_TABLE12}`,
|
|
960
|
+
routePrefix: "/preferences",
|
|
961
|
+
label: { en: "Preference", es: "Preferencia" },
|
|
962
|
+
labelPlural: { en: "Preferences", es: "Preferencias" },
|
|
963
|
+
labelField: "key",
|
|
964
|
+
timestamps: true,
|
|
965
|
+
fields: {
|
|
966
|
+
id: useIdField(),
|
|
967
|
+
user_id: useSelectField({
|
|
968
|
+
label: { en: "User", es: "Usuario" },
|
|
969
|
+
table: "users",
|
|
970
|
+
endpoint: "/users",
|
|
971
|
+
onDelete: "CASCADE",
|
|
972
|
+
required: true,
|
|
973
|
+
index: true
|
|
974
|
+
}),
|
|
975
|
+
scope: useTextField({
|
|
976
|
+
label: { en: "Scope", es: "\xC1mbito" },
|
|
977
|
+
size: 50,
|
|
978
|
+
defaultValue: "global",
|
|
979
|
+
nullable: false,
|
|
980
|
+
index: true,
|
|
981
|
+
hint: { en: "Module or feature scope (e.g., dashboard, editor)", es: "\xC1mbito de m\xF3dulo o funci\xF3n" }
|
|
982
|
+
}),
|
|
983
|
+
key: useTextField({
|
|
984
|
+
label: { en: "Key", es: "Clave" },
|
|
985
|
+
required: true,
|
|
986
|
+
size: 100,
|
|
987
|
+
placeholder: "theme"
|
|
988
|
+
}),
|
|
989
|
+
value: useJsonField({
|
|
990
|
+
label: { en: "Value", es: "Valor" },
|
|
991
|
+
required: true
|
|
992
|
+
})
|
|
993
|
+
},
|
|
994
|
+
indexes: [
|
|
995
|
+
{ columns: ["user_id", "scope", "key"], unique: true }
|
|
996
|
+
],
|
|
997
|
+
casl: {
|
|
998
|
+
subject: DEFAULT_SUBJECT12,
|
|
999
|
+
permissions: preferencesCaslPermissions
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
var preferencesEntity = basePreferencesEntity;
|
|
1003
|
+
var createPreferencesEntity = createEntityFactory(
|
|
1004
|
+
basePreferencesEntity,
|
|
1005
|
+
DEFAULT_TABLE12,
|
|
1006
|
+
DEFAULT_SUBJECT12
|
|
1007
|
+
);
|
|
1008
|
+
|
|
1009
|
+
// src/collection/system/schedules.entity.ts
|
|
1010
|
+
var DEFAULT_TABLE13 = "schedules";
|
|
1011
|
+
var DEFAULT_SUBJECT13 = "NxSchedule";
|
|
1012
|
+
var schedulesCaslPermissions = {
|
|
1013
|
+
ADMIN: { actions: ["manage"] }
|
|
1014
|
+
};
|
|
1015
|
+
var SCHEDULE_FREQUENCIES = {
|
|
1016
|
+
EVERY_MINUTE: "* * * * *",
|
|
1017
|
+
EVERY_5_MINUTES: "*/5 * * * *",
|
|
1018
|
+
EVERY_15_MINUTES: "*/15 * * * *",
|
|
1019
|
+
EVERY_HOUR: "0 * * * *",
|
|
1020
|
+
EVERY_DAY_MIDNIGHT: "0 0 * * *",
|
|
1021
|
+
EVERY_DAY_6AM: "0 6 * * *",
|
|
1022
|
+
EVERY_MONDAY: "0 0 * * 1",
|
|
1023
|
+
EVERY_MONTH_1ST: "0 0 1 * *"
|
|
1024
|
+
};
|
|
1025
|
+
var baseSchedulesEntity = {
|
|
1026
|
+
type: "collection",
|
|
1027
|
+
table: `nx_${DEFAULT_TABLE13}`,
|
|
1028
|
+
routePrefix: "/schedules",
|
|
1029
|
+
label: { en: "Schedule", es: "Programaci\xF3n" },
|
|
1030
|
+
labelPlural: { en: "Schedules", es: "Programaciones" },
|
|
1031
|
+
labelField: "name",
|
|
1032
|
+
timestamps: true,
|
|
1033
|
+
audit: true,
|
|
1034
|
+
fields: {
|
|
1035
|
+
id: useIdField(),
|
|
1036
|
+
name: useTextField({
|
|
1037
|
+
label: { en: "Name", es: "Nombre" },
|
|
1038
|
+
required: true,
|
|
1039
|
+
size: 100,
|
|
1040
|
+
placeholder: "Daily Cleanup",
|
|
1041
|
+
meta: { sortable: true }
|
|
1042
|
+
}),
|
|
1043
|
+
description: useTextareaField({
|
|
1044
|
+
label: { en: "Description", es: "Descripci\xF3n" }
|
|
1045
|
+
}),
|
|
1046
|
+
cron_expression: {
|
|
1047
|
+
label: { en: "Cron Expression", es: "Expresi\xF3n Cron" },
|
|
1048
|
+
input: "cron",
|
|
1049
|
+
required: true,
|
|
1050
|
+
placeholder: "0 0 * * *",
|
|
1051
|
+
db: { type: "string", size: 50, nullable: false },
|
|
1052
|
+
validation: { pattern: "^[\\d*,/-]+ [\\d*,/-]+ [\\d*,/-]+ [\\d*,/-]+ [\\d*,/-]+$" }
|
|
1053
|
+
},
|
|
1054
|
+
timezone: refMaster("timezone", { default: "UTC", label: { en: "Timezone", es: "Zona horaria" } }),
|
|
1055
|
+
action_type: useSelectField({
|
|
1056
|
+
label: { en: "Action Type", es: "Tipo de acci\xF3n" },
|
|
1057
|
+
options: [
|
|
1058
|
+
{ value: "webhook", label: { en: "Webhook", es: "Webhook" } },
|
|
1059
|
+
{ value: "command", label: { en: "Command", es: "Comando" } },
|
|
1060
|
+
{ value: "action", label: { en: "Action", es: "Acci\xF3n" } }
|
|
1061
|
+
],
|
|
1062
|
+
required: true,
|
|
1063
|
+
size: 20
|
|
1064
|
+
}),
|
|
1065
|
+
action_config: useJsonField({
|
|
1066
|
+
label: { en: "Action Config", es: "Configuraci\xF3n de acci\xF3n" },
|
|
1067
|
+
required: true,
|
|
1068
|
+
hint: { en: "Webhook URL, command name, or action parameters", es: "URL webhook, nombre de comando, o par\xE1metros" }
|
|
1069
|
+
}),
|
|
1070
|
+
is_active: isActiveField,
|
|
1071
|
+
last_run_at: useDatetimeField({
|
|
1072
|
+
label: { en: "Last Run", es: "\xDAltima ejecuci\xF3n" },
|
|
1073
|
+
meta: { showInForm: false, sortable: true }
|
|
1074
|
+
}),
|
|
1075
|
+
last_run_status: useSelectField({
|
|
1076
|
+
label: { en: "Last Status", es: "\xDAltimo estado" },
|
|
1077
|
+
options: [
|
|
1078
|
+
{ value: "success", label: { en: "Success", es: "\xC9xito" } },
|
|
1079
|
+
{ value: "error", label: { en: "Error", es: "Error" } },
|
|
1080
|
+
{ value: "running", label: { en: "Running", es: "Ejecutando" } }
|
|
1081
|
+
],
|
|
1082
|
+
size: 20,
|
|
1083
|
+
meta: { showInForm: false }
|
|
1084
|
+
}),
|
|
1085
|
+
last_run_error: useTextareaField({
|
|
1086
|
+
label: { en: "Last Error", es: "\xDAltimo error" },
|
|
1087
|
+
meta: { showInForm: false, showInDisplay: false }
|
|
1088
|
+
}),
|
|
1089
|
+
next_run_at: useDatetimeField({
|
|
1090
|
+
label: { en: "Next Run", es: "Pr\xF3xima ejecuci\xF3n" },
|
|
1091
|
+
meta: { showInForm: false, sortable: true }
|
|
1092
|
+
}),
|
|
1093
|
+
run_count: useNumberField({
|
|
1094
|
+
label: { en: "Run Count", es: "Ejecuciones" },
|
|
1095
|
+
defaultValue: 0,
|
|
1096
|
+
meta: { showInForm: false }
|
|
1097
|
+
})
|
|
1098
|
+
},
|
|
1099
|
+
indexes: [
|
|
1100
|
+
{ columns: ["is_active", "next_run_at"] },
|
|
1101
|
+
{ columns: ["action_type"] }
|
|
1102
|
+
],
|
|
1103
|
+
casl: {
|
|
1104
|
+
subject: DEFAULT_SUBJECT13,
|
|
1105
|
+
permissions: schedulesCaslPermissions
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
var schedulesEntity = baseSchedulesEntity;
|
|
1109
|
+
var createSchedulesEntity = createEntityFactory(
|
|
1110
|
+
baseSchedulesEntity,
|
|
1111
|
+
DEFAULT_TABLE13,
|
|
1112
|
+
DEFAULT_SUBJECT13
|
|
1113
|
+
);
|
|
1114
|
+
|
|
1115
|
+
// src/collection/system/webhooks.entity.ts
|
|
1116
|
+
var DEFAULT_TABLE14 = "webhooks";
|
|
1117
|
+
var DEFAULT_SUBJECT14 = "NxWebhook";
|
|
1118
|
+
var webhooksCaslPermissions = {
|
|
1119
|
+
ADMIN: { actions: ["manage"] }
|
|
1120
|
+
};
|
|
1121
|
+
var WEBHOOK_EVENTS = {
|
|
1122
|
+
// Generic CRUD
|
|
1123
|
+
CREATED: "created",
|
|
1124
|
+
UPDATED: "updated",
|
|
1125
|
+
DELETED: "deleted",
|
|
1126
|
+
// Specific
|
|
1127
|
+
PUBLISHED: "published",
|
|
1128
|
+
ARCHIVED: "archived",
|
|
1129
|
+
STATUS_CHANGED: "status_changed"
|
|
1130
|
+
};
|
|
1131
|
+
var baseWebhooksEntity = {
|
|
1132
|
+
type: "collection",
|
|
1133
|
+
table: `nx_${DEFAULT_TABLE14}`,
|
|
1134
|
+
routePrefix: "/webhooks",
|
|
1135
|
+
label: { en: "Webhook", es: "Webhook" },
|
|
1136
|
+
labelPlural: { en: "Webhooks", es: "Webhooks" },
|
|
1137
|
+
labelField: "name",
|
|
1138
|
+
timestamps: true,
|
|
1139
|
+
audit: true,
|
|
1140
|
+
fields: {
|
|
1141
|
+
id: useIdField(),
|
|
1142
|
+
name: useTextField({
|
|
1143
|
+
label: { en: "Name", es: "Nombre" },
|
|
1144
|
+
required: true,
|
|
1145
|
+
size: 100,
|
|
1146
|
+
placeholder: "Order Sync",
|
|
1147
|
+
meta: { sortable: true }
|
|
1148
|
+
}),
|
|
1149
|
+
description: useTextareaField({
|
|
1150
|
+
label: { en: "Description", es: "Descripci\xF3n" }
|
|
1151
|
+
}),
|
|
1152
|
+
url: useUrlField({
|
|
1153
|
+
label: { en: "Endpoint URL", es: "URL del endpoint" },
|
|
1154
|
+
required: true,
|
|
1155
|
+
placeholder: "https://api.example.com/webhooks"
|
|
1156
|
+
}),
|
|
1157
|
+
secret: usePasswordField({
|
|
1158
|
+
label: { en: "Secret", es: "Secreto" },
|
|
1159
|
+
hint: { en: "Used to sign webhook payloads (HMAC)", es: "Para firmar payloads (HMAC)" },
|
|
1160
|
+
nullable: true,
|
|
1161
|
+
meta: { showInDisplay: false }
|
|
1162
|
+
}),
|
|
1163
|
+
entity_type: useTextField({
|
|
1164
|
+
label: { en: "Entity Type", es: "Tipo de entidad" },
|
|
1165
|
+
required: true,
|
|
1166
|
+
size: 50,
|
|
1167
|
+
index: true,
|
|
1168
|
+
placeholder: "orders",
|
|
1169
|
+
hint: { en: "Entity to watch for events", es: "Entidad a observar" }
|
|
1170
|
+
}),
|
|
1171
|
+
events: {
|
|
1172
|
+
label: { en: "Events", es: "Eventos" },
|
|
1173
|
+
input: "multiselect",
|
|
1174
|
+
required: true,
|
|
1175
|
+
db: { type: "json", nullable: false },
|
|
1176
|
+
options: {
|
|
1177
|
+
static: [
|
|
1178
|
+
{ value: "created", label: { en: "Created", es: "Creado" } },
|
|
1179
|
+
{ value: "updated", label: { en: "Updated", es: "Actualizado" } },
|
|
1180
|
+
{ value: "deleted", label: { en: "Deleted", es: "Eliminado" } },
|
|
1181
|
+
{ value: "published", label: { en: "Published", es: "Publicado" } },
|
|
1182
|
+
{ value: "archived", label: { en: "Archived", es: "Archivado" } },
|
|
1183
|
+
{ value: "status_changed", label: { en: "Status Changed", es: "Estado cambiado" } }
|
|
1184
|
+
]
|
|
1185
|
+
}
|
|
1186
|
+
},
|
|
1187
|
+
headers: useJsonField({
|
|
1188
|
+
label: { en: "Custom Headers", es: "Headers personalizados" },
|
|
1189
|
+
hint: { en: "Additional HTTP headers to send", es: "Headers HTTP adicionales" }
|
|
1190
|
+
}),
|
|
1191
|
+
is_active: isActiveField,
|
|
1192
|
+
retry_count: useNumberField({
|
|
1193
|
+
label: { en: "Retry Count", es: "Reintentos" },
|
|
1194
|
+
defaultValue: 3,
|
|
1195
|
+
hint: { en: "Number of retries on failure", es: "Reintentos en caso de fallo" },
|
|
1196
|
+
validation: { min: 0, max: 10 }
|
|
1197
|
+
}),
|
|
1198
|
+
timeout_ms: useNumberField({
|
|
1199
|
+
label: { en: "Timeout (ms)", es: "Timeout (ms)" },
|
|
1200
|
+
defaultValue: 3e4,
|
|
1201
|
+
validation: { min: 1e3, max: 12e4 }
|
|
1202
|
+
}),
|
|
1203
|
+
last_triggered_at: useDatetimeField({
|
|
1204
|
+
label: { en: "Last Triggered", es: "\xDAltima activaci\xF3n" },
|
|
1205
|
+
meta: { showInForm: false, sortable: true }
|
|
1206
|
+
}),
|
|
1207
|
+
last_status: useSelectField({
|
|
1208
|
+
label: { en: "Last Status", es: "\xDAltimo estado" },
|
|
1209
|
+
options: [
|
|
1210
|
+
{ value: "success", label: { en: "Success", es: "\xC9xito" } },
|
|
1211
|
+
{ value: "error", label: { en: "Error", es: "Error" } },
|
|
1212
|
+
{ value: "pending", label: { en: "Pending", es: "Pendiente" } }
|
|
1213
|
+
],
|
|
1214
|
+
size: 20,
|
|
1215
|
+
meta: { showInForm: false }
|
|
1216
|
+
}),
|
|
1217
|
+
failure_count: useNumberField({
|
|
1218
|
+
label: { en: "Consecutive Failures", es: "Fallos consecutivos" },
|
|
1219
|
+
defaultValue: 0,
|
|
1220
|
+
meta: { showInForm: false }
|
|
1221
|
+
})
|
|
1222
|
+
},
|
|
1223
|
+
indexes: [
|
|
1224
|
+
{ columns: ["entity_type", "is_active"] },
|
|
1225
|
+
{ columns: ["is_active", "failure_count"] }
|
|
1226
|
+
],
|
|
1227
|
+
casl: {
|
|
1228
|
+
subject: DEFAULT_SUBJECT14,
|
|
1229
|
+
permissions: webhooksCaslPermissions
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
var webhooksEntity = baseWebhooksEntity;
|
|
1233
|
+
var createWebhooksEntity = createEntityFactory(
|
|
1234
|
+
baseWebhooksEntity,
|
|
1235
|
+
DEFAULT_TABLE14,
|
|
1236
|
+
DEFAULT_SUBJECT14
|
|
1237
|
+
);
|
|
1238
|
+
|
|
1239
|
+
// src/collection/workflow/approvals.entity.ts
|
|
1240
|
+
var DEFAULT_TABLE15 = "approvals";
|
|
1241
|
+
var DEFAULT_SUBJECT15 = "NxApproval";
|
|
1242
|
+
var approvalsCaslPermissions = {
|
|
1243
|
+
USER: { actions: ["read", "create"] },
|
|
1244
|
+
ADMIN: { actions: ["manage"] }
|
|
1245
|
+
};
|
|
1246
|
+
var APPROVAL_STATUS = {
|
|
1247
|
+
PENDING: "pending",
|
|
1248
|
+
APPROVED: "approved",
|
|
1249
|
+
REJECTED: "rejected",
|
|
1250
|
+
CANCELLED: "cancelled",
|
|
1251
|
+
EXPIRED: "expired"
|
|
1252
|
+
};
|
|
1253
|
+
var baseApprovalsEntity = {
|
|
1254
|
+
type: "collection",
|
|
1255
|
+
table: `nx_${DEFAULT_TABLE15}`,
|
|
1256
|
+
routePrefix: "/approvals",
|
|
1257
|
+
label: { en: "Approval", es: "Aprobaci\xF3n" },
|
|
1258
|
+
labelPlural: { en: "Approvals", es: "Aprobaciones" },
|
|
1259
|
+
labelField: "title",
|
|
1260
|
+
timestamps: true,
|
|
1261
|
+
audit: true,
|
|
1262
|
+
fields: {
|
|
1263
|
+
id: useIdField(),
|
|
1264
|
+
...polymorphicFields,
|
|
1265
|
+
title: useTextField({
|
|
1266
|
+
label: { en: "Title", es: "T\xEDtulo" },
|
|
1267
|
+
required: true,
|
|
1268
|
+
size: 200,
|
|
1269
|
+
meta: { sortable: true }
|
|
1270
|
+
}),
|
|
1271
|
+
description: useTextareaField({
|
|
1272
|
+
label: { en: "Description", es: "Descripci\xF3n" }
|
|
1273
|
+
}),
|
|
1274
|
+
requester_id: useSelectField({
|
|
1275
|
+
label: { en: "Requester", es: "Solicitante" },
|
|
1276
|
+
table: "users",
|
|
1277
|
+
endpoint: "/users",
|
|
1278
|
+
onDelete: "CASCADE",
|
|
1279
|
+
required: true,
|
|
1280
|
+
index: true,
|
|
1281
|
+
meta: { sortable: true }
|
|
1282
|
+
}),
|
|
1283
|
+
approver_id: useSelectField({
|
|
1284
|
+
label: { en: "Approver", es: "Aprobador" },
|
|
1285
|
+
table: "users",
|
|
1286
|
+
endpoint: "/users",
|
|
1287
|
+
onDelete: "CASCADE",
|
|
1288
|
+
required: true,
|
|
1289
|
+
index: true,
|
|
1290
|
+
meta: { sortable: true }
|
|
1291
|
+
}),
|
|
1292
|
+
status: useSelectField({
|
|
1293
|
+
label: { en: "Status", es: "Estado" },
|
|
1294
|
+
options: [
|
|
1295
|
+
{ value: "pending", label: { en: "Pending", es: "Pendiente" } },
|
|
1296
|
+
{ value: "approved", label: { en: "Approved", es: "Aprobado" } },
|
|
1297
|
+
{ value: "rejected", label: { en: "Rejected", es: "Rechazado" } },
|
|
1298
|
+
{ value: "cancelled", label: { en: "Cancelled", es: "Cancelado" } },
|
|
1299
|
+
{ value: "expired", label: { en: "Expired", es: "Expirado" } }
|
|
1300
|
+
],
|
|
1301
|
+
defaultValue: "pending",
|
|
1302
|
+
required: true,
|
|
1303
|
+
size: 20,
|
|
1304
|
+
index: true,
|
|
1305
|
+
meta: { sortable: true }
|
|
1306
|
+
}),
|
|
1307
|
+
decision_notes: useTextareaField({
|
|
1308
|
+
label: { en: "Decision Notes", es: "Notas de decisi\xF3n" },
|
|
1309
|
+
hint: { en: "Reason for approval/rejection", es: "Raz\xF3n de aprobaci\xF3n/rechazo" }
|
|
1310
|
+
}),
|
|
1311
|
+
decided_at: useDatetimeField({
|
|
1312
|
+
label: { en: "Decided At", es: "Decidido el" },
|
|
1313
|
+
meta: { showInForm: false, sortable: true }
|
|
1314
|
+
}),
|
|
1315
|
+
expires_at: useDatetimeField({
|
|
1316
|
+
label: { en: "Expires At", es: "Expira el" },
|
|
1317
|
+
hint: { en: "Auto-expire if not decided by this date", es: "Auto-expirar si no se decide antes" },
|
|
1318
|
+
meta: { sortable: true }
|
|
1319
|
+
}),
|
|
1320
|
+
priority: useSelectField({
|
|
1321
|
+
label: { en: "Priority", es: "Prioridad" },
|
|
1322
|
+
options: [
|
|
1323
|
+
{ value: "low", label: { en: "Low", es: "Baja" } },
|
|
1324
|
+
{ value: "medium", label: { en: "Medium", es: "Media" } },
|
|
1325
|
+
{ value: "high", label: { en: "High", es: "Alta" } },
|
|
1326
|
+
{ value: "urgent", label: { en: "Urgent", es: "Urgente" } }
|
|
1327
|
+
],
|
|
1328
|
+
defaultValue: "medium",
|
|
1329
|
+
required: true,
|
|
1330
|
+
size: 20
|
|
1331
|
+
}),
|
|
1332
|
+
metadata: useJsonField({
|
|
1333
|
+
label: { en: "Metadata", es: "Metadatos" },
|
|
1334
|
+
hint: { en: "Additional approval context", es: "Contexto adicional" }
|
|
1335
|
+
})
|
|
1336
|
+
},
|
|
1337
|
+
indexes: [
|
|
1338
|
+
{ columns: ["entity_type", "entity_id"] },
|
|
1339
|
+
{ columns: ["requester_id", "status"] },
|
|
1340
|
+
{ columns: ["approver_id", "status"] },
|
|
1341
|
+
{ columns: ["status", "expires_at"] }
|
|
1342
|
+
],
|
|
1343
|
+
casl: {
|
|
1344
|
+
subject: DEFAULT_SUBJECT15,
|
|
1345
|
+
permissions: approvalsCaslPermissions
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
var approvalsEntity = baseApprovalsEntity;
|
|
1349
|
+
var createApprovalsEntity = createEntityFactory(
|
|
1350
|
+
baseApprovalsEntity,
|
|
1351
|
+
DEFAULT_TABLE15,
|
|
1352
|
+
DEFAULT_SUBJECT15
|
|
1353
|
+
);
|
|
1354
|
+
|
|
1355
|
+
// src/collection/workflow/assignments.entity.ts
|
|
1356
|
+
var DEFAULT_TABLE16 = "assignments";
|
|
1357
|
+
var DEFAULT_SUBJECT16 = "NxAssignment";
|
|
1358
|
+
var assignmentsCaslPermissions = {
|
|
1359
|
+
USER: { actions: ["read"] },
|
|
1360
|
+
ADMIN: { actions: ["manage"] }
|
|
1361
|
+
};
|
|
1362
|
+
var ASSIGNMENT_ROLES = {
|
|
1363
|
+
OWNER: "owner",
|
|
1364
|
+
ASSIGNEE: "assignee",
|
|
1365
|
+
REVIEWER: "reviewer",
|
|
1366
|
+
COLLABORATOR: "collaborator",
|
|
1367
|
+
WATCHER: "watcher"
|
|
1368
|
+
};
|
|
1369
|
+
var baseAssignmentsEntity = {
|
|
1370
|
+
type: "collection",
|
|
1371
|
+
table: `nx_${DEFAULT_TABLE16}`,
|
|
1372
|
+
routePrefix: "/assignments",
|
|
1373
|
+
label: { en: "Assignment", es: "Asignaci\xF3n" },
|
|
1374
|
+
labelPlural: { en: "Assignments", es: "Asignaciones" },
|
|
1375
|
+
labelField: "role",
|
|
1376
|
+
timestamps: true,
|
|
1377
|
+
audit: true,
|
|
1378
|
+
fields: {
|
|
1379
|
+
id: useIdField(),
|
|
1380
|
+
...polymorphicFields,
|
|
1381
|
+
assignee_id: {
|
|
1382
|
+
label: { en: "Assignee", es: "Asignado a" },
|
|
1383
|
+
input: "select",
|
|
1384
|
+
required: true,
|
|
1385
|
+
db: { type: "string", size: 26, nullable: false, index: true },
|
|
1386
|
+
relation: {
|
|
1387
|
+
table: "users",
|
|
1388
|
+
column: "id",
|
|
1389
|
+
onDelete: "CASCADE"
|
|
1390
|
+
},
|
|
1391
|
+
meta: { sortable: true }
|
|
1392
|
+
},
|
|
1393
|
+
assigned_by_id: {
|
|
1394
|
+
label: { en: "Assigned By", es: "Asignado por" },
|
|
1395
|
+
input: "select",
|
|
1396
|
+
db: { type: "string", size: 26, nullable: true, index: true },
|
|
1397
|
+
relation: {
|
|
1398
|
+
table: "users",
|
|
1399
|
+
column: "id",
|
|
1400
|
+
onDelete: "SET NULL"
|
|
1401
|
+
}
|
|
1402
|
+
},
|
|
1403
|
+
role: useSelectField({
|
|
1404
|
+
label: { en: "Role", es: "Rol" },
|
|
1405
|
+
options: [
|
|
1406
|
+
{ value: "owner", label: { en: "Owner", es: "Propietario" } },
|
|
1407
|
+
{ value: "assignee", label: { en: "Assignee", es: "Asignado" } },
|
|
1408
|
+
{ value: "reviewer", label: { en: "Reviewer", es: "Revisor" } },
|
|
1409
|
+
{ value: "collaborator", label: { en: "Collaborator", es: "Colaborador" } },
|
|
1410
|
+
{ value: "watcher", label: { en: "Watcher", es: "Observador" } }
|
|
1411
|
+
],
|
|
1412
|
+
defaultValue: "assignee",
|
|
1413
|
+
required: true,
|
|
1414
|
+
size: 20
|
|
1415
|
+
}),
|
|
1416
|
+
notes: useTextareaField({
|
|
1417
|
+
label: { en: "Notes", es: "Notas" },
|
|
1418
|
+
hint: { en: "Assignment notes or instructions", es: "Notas o instrucciones" }
|
|
1419
|
+
}),
|
|
1420
|
+
due_date: useDatetimeField({
|
|
1421
|
+
label: { en: "Due Date", es: "Fecha l\xEDmite" },
|
|
1422
|
+
meta: { sortable: true }
|
|
1423
|
+
}),
|
|
1424
|
+
is_active: isActiveField,
|
|
1425
|
+
completed_at: useDatetimeField({
|
|
1426
|
+
label: { en: "Completed At", es: "Completado el" },
|
|
1427
|
+
meta: { showInForm: false, sortable: true }
|
|
1428
|
+
}),
|
|
1429
|
+
metadata: useJsonField({
|
|
1430
|
+
label: { en: "Metadata", es: "Metadatos" }
|
|
1431
|
+
})
|
|
1432
|
+
},
|
|
1433
|
+
indexes: [
|
|
1434
|
+
{ columns: ["entity_type", "entity_id"] },
|
|
1435
|
+
{ columns: ["assignee_id", "is_active"] },
|
|
1436
|
+
{ columns: ["assigned_by_id"] },
|
|
1437
|
+
{ columns: ["entity_type", "entity_id", "assignee_id", "role"], unique: true }
|
|
1438
|
+
],
|
|
1439
|
+
casl: {
|
|
1440
|
+
subject: DEFAULT_SUBJECT16,
|
|
1441
|
+
permissions: assignmentsCaslPermissions
|
|
1442
|
+
}
|
|
1443
|
+
};
|
|
1444
|
+
var assignmentsEntity = baseAssignmentsEntity;
|
|
1445
|
+
var createAssignmentsEntity = createEntityFactory(
|
|
1446
|
+
baseAssignmentsEntity,
|
|
1447
|
+
DEFAULT_TABLE16,
|
|
1448
|
+
DEFAULT_SUBJECT16
|
|
1449
|
+
);
|
|
1450
|
+
export {
|
|
1451
|
+
ACTIVITY_TYPES,
|
|
1452
|
+
APPROVAL_STATUS,
|
|
1453
|
+
ASSIGNMENT_ROLES,
|
|
1454
|
+
DEFAULT_OPTIONS_SEED,
|
|
1455
|
+
NOTIFICATION_TYPES,
|
|
1456
|
+
OPTION_GROUPS,
|
|
1457
|
+
PREFERENCE_KEYS,
|
|
1458
|
+
REACTION_TYPES,
|
|
1459
|
+
SCHEDULE_FREQUENCIES,
|
|
1460
|
+
WEBHOOK_EVENTS,
|
|
1461
|
+
activityLogEntity,
|
|
1462
|
+
applyEntityConfig,
|
|
1463
|
+
approvalsEntity,
|
|
1464
|
+
assignmentsEntity,
|
|
1465
|
+
attachmentsEntity,
|
|
1466
|
+
commentsEntity,
|
|
1467
|
+
createActivityLogEntity,
|
|
1468
|
+
createApprovalsEntity,
|
|
1469
|
+
createAssignmentsEntity,
|
|
1470
|
+
createAttachmentsEntity,
|
|
1471
|
+
createCommentsEntity,
|
|
1472
|
+
createEntityFactory,
|
|
1473
|
+
createFavoritesEntity,
|
|
1474
|
+
createMentionsEntity,
|
|
1475
|
+
createNotesEntity,
|
|
1476
|
+
createNotificationsEntity,
|
|
1477
|
+
createOptionsEntity,
|
|
1478
|
+
createPreferencesEntity,
|
|
1479
|
+
createRatingsEntity,
|
|
1480
|
+
createReactionsEntity,
|
|
1481
|
+
createSchedulesEntity,
|
|
1482
|
+
createTagsEntity,
|
|
1483
|
+
createWebhooksEntity,
|
|
1484
|
+
dynamicOptions,
|
|
1485
|
+
favoritesEntity,
|
|
1486
|
+
mentionsEntity,
|
|
1487
|
+
notesEntity,
|
|
1488
|
+
notificationsEntity,
|
|
1489
|
+
optionsEntity,
|
|
1490
|
+
polymorphicCaslPermissions,
|
|
1491
|
+
polymorphicFields,
|
|
1492
|
+
preferencesEntity,
|
|
1493
|
+
ratingsEntity,
|
|
1494
|
+
reactionsEntity,
|
|
1495
|
+
schedulesEntity,
|
|
1496
|
+
systemCaslPermissions,
|
|
1497
|
+
tagEntitiesEntity,
|
|
1498
|
+
tagsEntity,
|
|
1499
|
+
webhooksEntity,
|
|
1500
|
+
workflowCaslPermissions
|
|
1501
|
+
};
|