@elqnt/entity 1.0.0 → 1.0.5

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.
@@ -0,0 +1,602 @@
1
+ import { JSONSchema } from '@elqnt/types';
2
+
3
+ type EntityFilterOperator = string;
4
+ /**
5
+ * todo: move to types package
6
+ */
7
+ declare const OperatorEq: EntityFilterOperator;
8
+ /**
9
+ * todo: move to types package
10
+ */
11
+ declare const OperatorNe: EntityFilterOperator;
12
+ /**
13
+ * todo: move to types package
14
+ */
15
+ declare const OperatorGt: EntityFilterOperator;
16
+ /**
17
+ * todo: move to types package
18
+ */
19
+ declare const OperatorGte: EntityFilterOperator;
20
+ /**
21
+ * todo: move to types package
22
+ */
23
+ declare const OperatorLt: EntityFilterOperator;
24
+ /**
25
+ * todo: move to types package
26
+ */
27
+ declare const OperatorLte: EntityFilterOperator;
28
+ /**
29
+ * todo: move to types package
30
+ */
31
+ declare const OperatorIn: EntityFilterOperator;
32
+ /**
33
+ * todo: move to types package
34
+ */
35
+ declare const OperatorNin: EntityFilterOperator;
36
+ /**
37
+ * todo: move to types package
38
+ */
39
+ declare const OperatorContains: EntityFilterOperator;
40
+ /**
41
+ * todo: move to types package
42
+ */
43
+ declare const OperatorStartsWith: EntityFilterOperator;
44
+ /**
45
+ * todo: move to types package
46
+ */
47
+ declare const OperatorEndsWith: EntityFilterOperator;
48
+ /**
49
+ * todo: move to types package
50
+ */
51
+ declare const OperatorExists: EntityFilterOperator;
52
+ /**
53
+ * todo: move to types package
54
+ */
55
+ declare const OperatorEmpty: EntityFilterOperator;
56
+ /**
57
+ * todo: move to types package
58
+ */
59
+ declare const OperatorBetween: EntityFilterOperator;
60
+ declare const EntityFilterOperators: {
61
+ readonly eq: {
62
+ readonly value: "eq";
63
+ readonly label: "Equal to";
64
+ };
65
+ readonly ne: {
66
+ readonly value: "ne";
67
+ readonly label: "Not equal to";
68
+ };
69
+ readonly gt: {
70
+ readonly value: "gt";
71
+ readonly label: "Greater than";
72
+ };
73
+ readonly gte: {
74
+ readonly value: "gte";
75
+ readonly label: "Greater than or equal to";
76
+ };
77
+ readonly lt: {
78
+ readonly value: "lt";
79
+ readonly label: "Less than";
80
+ };
81
+ readonly lte: {
82
+ readonly value: "lte";
83
+ readonly label: "Less than or equal to";
84
+ };
85
+ readonly in: {
86
+ readonly value: "in";
87
+ readonly label: "In";
88
+ };
89
+ readonly nin: {
90
+ readonly value: "nin";
91
+ readonly label: "Not in";
92
+ };
93
+ readonly contains: {
94
+ readonly value: "contains";
95
+ readonly label: "Contains";
96
+ };
97
+ readonly startsWith: {
98
+ readonly value: "startsWith";
99
+ readonly label: "Starts with";
100
+ };
101
+ readonly endsWith: {
102
+ readonly value: "endsWith";
103
+ readonly label: "Ends with";
104
+ };
105
+ readonly exists: {
106
+ readonly value: "exists";
107
+ readonly label: "Exists";
108
+ };
109
+ readonly empty: {
110
+ readonly value: "empty";
111
+ readonly label: "Empty";
112
+ };
113
+ readonly between: {
114
+ readonly value: "between";
115
+ readonly label: "Between";
116
+ };
117
+ };
118
+ type EntityFilterOperatorTS = keyof typeof EntityFilterOperators;
119
+ type EntityFilterOperatorOptionTS = typeof EntityFilterOperators[EntityFilterOperatorTS];
120
+ type EntityFieldType = string;
121
+ declare const EntityFieldTypeString: EntityFieldType;
122
+ declare const EntityFieldTypeStringMultiline: EntityFieldType;
123
+ declare const EntityFieldTypeText: EntityFieldType;
124
+ declare const EntityFieldTypeInt: EntityFieldType;
125
+ declare const EntityFieldTypeFloat: EntityFieldType;
126
+ declare const EntityFieldTypeBool: EntityFieldType;
127
+ declare const EntityFieldTypeDate: EntityFieldType;
128
+ declare const EntityFieldTypeDateTime: EntityFieldType;
129
+ declare const EntityFieldTypeEmail: EntityFieldType;
130
+ declare const EntityFieldTypePhone: EntityFieldType;
131
+ declare const EntityFieldTypeURL: EntityFieldType;
132
+ declare const EntityFieldTypeDropdown: EntityFieldType;
133
+ declare const EntityFieldTypeMultiSelect: EntityFieldType;
134
+ declare const EntityFieldTypeLookup: EntityFieldType;
135
+ declare const EntityFieldTypeMultiLookup: EntityFieldType;
136
+ declare const EntityFieldTypeCurrency: EntityFieldType;
137
+ declare const EntityFieldTypeFile: EntityFieldType;
138
+ declare const EntityFieldTypeImage: EntityFieldType;
139
+ declare const EntityFieldTypeJSON: EntityFieldType;
140
+ declare const EntityFieldTypes: {
141
+ readonly string: {
142
+ readonly value: "string";
143
+ readonly label: "Short Text";
144
+ };
145
+ readonly stringMultiline: {
146
+ readonly value: "stringMultiline";
147
+ readonly label: "Long Text";
148
+ };
149
+ readonly text: {
150
+ readonly value: "text";
151
+ readonly label: "Rich Text Editor";
152
+ };
153
+ readonly int: {
154
+ readonly value: "int";
155
+ readonly label: "Integer";
156
+ };
157
+ readonly float: {
158
+ readonly value: "float";
159
+ readonly label: "Decimal";
160
+ };
161
+ readonly bool: {
162
+ readonly value: "bool";
163
+ readonly label: "Boolean";
164
+ };
165
+ readonly date: {
166
+ readonly value: "date";
167
+ readonly label: "Date";
168
+ };
169
+ readonly datetime: {
170
+ readonly value: "datetime";
171
+ readonly label: "Date & Time";
172
+ };
173
+ readonly email: {
174
+ readonly value: "email";
175
+ readonly label: "Email";
176
+ };
177
+ readonly phone: {
178
+ readonly value: "phone";
179
+ readonly label: "Phone";
180
+ };
181
+ readonly url: {
182
+ readonly value: "url";
183
+ readonly label: "URL";
184
+ };
185
+ readonly dropdown: {
186
+ readonly value: "dropdown";
187
+ readonly label: "Dropdown";
188
+ };
189
+ readonly multiselect: {
190
+ readonly value: "multiselect";
191
+ readonly label: "Multi Select";
192
+ };
193
+ readonly lookup: {
194
+ readonly value: "lookup";
195
+ readonly label: "Lookup";
196
+ };
197
+ readonly multilookup: {
198
+ readonly value: "multilookup";
199
+ readonly label: "Multi Lookup";
200
+ };
201
+ readonly currency: {
202
+ readonly value: "currency";
203
+ readonly label: "Currency";
204
+ };
205
+ readonly file: {
206
+ readonly value: "file";
207
+ readonly label: "File";
208
+ };
209
+ readonly image: {
210
+ readonly value: "image";
211
+ readonly label: "Image";
212
+ };
213
+ readonly json: {
214
+ readonly value: "json";
215
+ readonly label: "JSON";
216
+ };
217
+ };
218
+ type EntityFieldTypeTS = keyof typeof EntityFieldTypes;
219
+ type EntityFieldTypeOptionTS = typeof EntityFieldTypes[EntityFieldTypeTS];
220
+ interface EntityDefinition {
221
+ id: string;
222
+ name: string;
223
+ displayName: string;
224
+ module: string;
225
+ description: string;
226
+ schema: JSONSchema;
227
+ defaultViewId: string;
228
+ metadata?: {
229
+ [key: string]: any;
230
+ };
231
+ createdAt: string;
232
+ updatedAt: string;
233
+ isActive: boolean;
234
+ version: number;
235
+ }
236
+ interface EntityRecord {
237
+ id: string;
238
+ entityId: string;
239
+ name: string;
240
+ fields: {
241
+ [key: string]: any;
242
+ };
243
+ tags?: string[];
244
+ metadata?: {
245
+ [key: string]: any;
246
+ };
247
+ createdAt: string;
248
+ updatedAt: string;
249
+ isActive: boolean;
250
+ version: number;
251
+ }
252
+ /**
253
+ * View defines how to display entity records in a list
254
+ */
255
+ interface View {
256
+ id: string;
257
+ entityId: string;
258
+ name: string;
259
+ displayName: string;
260
+ description?: string;
261
+ isDefault: boolean;
262
+ columns: ViewColumn[];
263
+ filters: Filter[];
264
+ sort: Sort[];
265
+ }
266
+ interface Filter {
267
+ field: string;
268
+ operator: EntityFilterOperator;
269
+ value: any;
270
+ }
271
+ interface Sort {
272
+ field: string;
273
+ direction: number;
274
+ }
275
+ interface FieldValidation {
276
+ required: boolean;
277
+ min?: number;
278
+ max?: number;
279
+ minLength?: number;
280
+ maxLength?: number;
281
+ pattern?: string;
282
+ customRules?: ValidationRule[];
283
+ }
284
+ interface ValidationRule {
285
+ name: string;
286
+ conditions: ValidationRuleCondition[];
287
+ }
288
+ interface ValidationRuleCondition {
289
+ field: string;
290
+ operator: string;
291
+ value: any;
292
+ }
293
+ interface RecordReference {
294
+ entityName: string;
295
+ recordId: string;
296
+ fieldName: string;
297
+ referencedAt: string;
298
+ }
299
+ interface InsertOneResult {
300
+ insertedId: string;
301
+ success: boolean;
302
+ error: string;
303
+ }
304
+ /**
305
+ * Query related models
306
+ */
307
+ interface EntityQuery {
308
+ filters: {
309
+ [key: string]: any;
310
+ };
311
+ page: number;
312
+ pageSize: number;
313
+ sortBy: string;
314
+ sortOrder: number;
315
+ includeLookups?: LookupInclude[];
316
+ include?: string[];
317
+ exclude?: string[];
318
+ }
319
+ interface LookupInclude {
320
+ entityName: string;
321
+ fieldName: string;
322
+ fields?: string[];
323
+ }
324
+ interface QueryRequest {
325
+ orgId: string;
326
+ entityName: string;
327
+ viewId?: string;
328
+ query: EntityQuery;
329
+ }
330
+ /**
331
+ * Request/Response models
332
+ */
333
+ interface CreateEntityDefinitionRequest {
334
+ orgId: string;
335
+ definition: EntityDefinition;
336
+ }
337
+ interface CreateOrgSchemaRequest {
338
+ orgId: string;
339
+ }
340
+ interface CreateOrgSchemaResponse {
341
+ metadata: ResponseMetadata;
342
+ }
343
+ interface DropOrgSchemaRequest {
344
+ orgId: string;
345
+ }
346
+ interface DropOrgSchemaResponse {
347
+ metadata: ResponseMetadata;
348
+ }
349
+ interface CreateRecordRequest {
350
+ orgId: string;
351
+ entityName: string;
352
+ record: EntityRecord;
353
+ }
354
+ interface UpdateRecordRequest {
355
+ orgId: string;
356
+ entityName: string;
357
+ recordId: string;
358
+ record: EntityRecord;
359
+ }
360
+ interface DeleteRecordRequest {
361
+ orgId: string;
362
+ entityName: string;
363
+ recordId: string;
364
+ }
365
+ /**
366
+ * View models
367
+ */
368
+ interface EntityView {
369
+ id: string;
370
+ name: string;
371
+ displayName: string;
372
+ entityName: string;
373
+ columns: ViewColumn[];
374
+ filters: ViewFilter[];
375
+ lookups: LookupInclude[];
376
+ sortBy?: string;
377
+ sortOrder?: number;
378
+ isDefault: boolean;
379
+ createdAt: string;
380
+ updatedAt: string;
381
+ isActive: boolean;
382
+ version: number;
383
+ }
384
+ interface ViewColumn {
385
+ fieldName: string;
386
+ displayName: string;
387
+ width: number;
388
+ sortable: boolean;
389
+ visible: boolean;
390
+ order: number;
391
+ }
392
+ interface ViewFilter {
393
+ fieldName: string;
394
+ operator: string;
395
+ value: any;
396
+ }
397
+ /**
398
+ * Bulk operation models
399
+ */
400
+ interface BulkCreateRequest {
401
+ orgId: string;
402
+ entityName: string;
403
+ records: EntityRecord[];
404
+ }
405
+ interface BulkUpdateRequest {
406
+ orgId: string;
407
+ entityName: string;
408
+ records: EntityRecord[];
409
+ }
410
+ interface BulkDeleteRequest {
411
+ orgId: string;
412
+ entityName: string;
413
+ recordIds: string[];
414
+ }
415
+ interface UpdateEntityDefinitionRequest {
416
+ orgId: string;
417
+ entityName: string;
418
+ definition: EntityDefinition;
419
+ }
420
+ interface GetEntityDefinitionRequest {
421
+ orgId: string;
422
+ entityName: string;
423
+ }
424
+ interface DeleteEntityDefinitionRequest {
425
+ orgId: string;
426
+ entityName: string;
427
+ deleteRecords?: boolean;
428
+ hardDelete?: boolean;
429
+ }
430
+ interface ListEntityDefinitionsRequest {
431
+ orgId: string;
432
+ module?: string;
433
+ status?: string;
434
+ }
435
+ /**
436
+ * View related requests
437
+ */
438
+ interface CreateViewRequest {
439
+ orgId: string;
440
+ entityName: string;
441
+ view: EntityView;
442
+ }
443
+ interface UpdateViewRequest {
444
+ orgId: string;
445
+ view: EntityView;
446
+ }
447
+ interface DeleteViewRequest {
448
+ orgId: string;
449
+ viewId: string;
450
+ }
451
+ interface GetViewRequest {
452
+ orgId: string;
453
+ viewId: string;
454
+ }
455
+ interface ListViewsRequest {
456
+ orgId: string;
457
+ entityName: string;
458
+ }
459
+ /**
460
+ * Response models
461
+ */
462
+ interface EntityDefinitionResponse {
463
+ definition: EntityDefinition;
464
+ metadata: ResponseMetadata;
465
+ }
466
+ interface ListEntityDefinitionsResponse {
467
+ definitions: EntityDefinition[];
468
+ metadata: ResponseMetadata;
469
+ }
470
+ interface EntityViewResponse {
471
+ view: EntityView;
472
+ metadata: ResponseMetadata;
473
+ }
474
+ interface ListViewsResponse {
475
+ views: EntityView[];
476
+ metadata: ResponseMetadata;
477
+ }
478
+ interface EntityRecordResponse {
479
+ record: EntityRecord;
480
+ metadata: ResponseMetadata;
481
+ }
482
+ interface ListEntityRecordsResponse {
483
+ records?: ListResult<EntityRecord>;
484
+ metadata: ResponseMetadata;
485
+ }
486
+ /**
487
+ * Common response metadata
488
+ */
489
+ interface ResponseMetadata {
490
+ success: boolean;
491
+ timestamp: string;
492
+ message?: string;
493
+ error?: string;
494
+ }
495
+ interface ListOptions {
496
+ Page: number;
497
+ PageSize: number;
498
+ SortBy: string;
499
+ SortOrder: number;
500
+ Filters: {
501
+ [key: string]: any;
502
+ };
503
+ Include: string[];
504
+ Exclude: string[];
505
+ }
506
+ interface ListResult<T extends any> {
507
+ items: T[];
508
+ totalCount: number;
509
+ currentPage: number;
510
+ pageSize: number;
511
+ totalPages: number;
512
+ }
513
+ interface GetEntityRecordRequest {
514
+ orgId: string;
515
+ entityName: string;
516
+ recordId: string;
517
+ }
518
+ interface GetEntityRecordResponse {
519
+ record?: EntityRecord;
520
+ metadata: ResponseMetadata;
521
+ }
522
+ interface CountEntityRecordsRequest {
523
+ orgId: string;
524
+ entityName: string;
525
+ filters?: {
526
+ [key: string]: any;
527
+ };
528
+ }
529
+ interface CountEntityRecordsResponse {
530
+ count: number;
531
+ metadata: ResponseMetadata;
532
+ }
533
+ interface EntityRecordChangeEvent {
534
+ orgId: string;
535
+ entityName: string;
536
+ recordId: string;
537
+ record?: EntityRecord;
538
+ changes?: RecordChange;
539
+ action: RecordChangeAction;
540
+ timestamp: string;
541
+ }
542
+ interface RecordChange {
543
+ /**
544
+ * OldValues map[string]TypedValue `json:"oldValues,omitempty"`
545
+ * NewValues map[string]TypedValue `json:"newValues,omitempty"`
546
+ */
547
+ changedAt: string;
548
+ changedBy: string;
549
+ fields: string[];
550
+ }
551
+ interface EntityDefinitionChangeEvent {
552
+ orgId: string;
553
+ definition?: EntityDefinition;
554
+ action: string;
555
+ timestamp: string;
556
+ }
557
+ interface EntityViewChangeEvent {
558
+ orgId: string;
559
+ entityName: string;
560
+ view?: EntityView;
561
+ action: string;
562
+ timestamp: string;
563
+ }
564
+ type RecordChangeAction = string;
565
+ declare const RecordChangeActionCreated: RecordChangeAction;
566
+ declare const RecordChangeActionUpdated: RecordChangeAction;
567
+ declare const RecordChangeActionDeleted: RecordChangeAction;
568
+ declare const EntityOrgSchemaCreate = "entity.org.schema.create";
569
+ declare const EntityOrgSchemaDrop = "entity.org.schema.drop";
570
+ declare const EntityDefinitionCreate = "entity.definition.create";
571
+ declare const EntityDefinitionCreated = "entity.definition.created";
572
+ declare const EntityDefinitionUpdate = "entity.definition.update";
573
+ declare const EntityDefinitionGet = "entity.definition.get";
574
+ declare const EntityDefinitionGetServer = "entity.definition.get.server";
575
+ declare const EntityDefinitionList = "entity.definition.list";
576
+ declare const EntityDefinitionUpdated = "entity.definition.updated";
577
+ declare const EntityDefinitionDelete = "entity.definition.delete";
578
+ declare const EntityDefinitionDeleted = "entity.definition.deleted";
579
+ declare const EntityRecordCreate = "entity.record.create";
580
+ declare const EntityRecordCreated = "entity.record.created";
581
+ declare const EntityRecordGet = "entity.record.get";
582
+ declare const EntityRecordQuery = "entity.record.query";
583
+ declare const EntityRecordCount = "entity.record.count";
584
+ declare const EntityRecordUpdate = "entity.record.update";
585
+ declare const EntityRecordUpdated = "entity.record.updated";
586
+ declare const EntityRecordDelete = "entity.record.delete";
587
+ declare const EntityRecordDeleted = "entity.record.deleted";
588
+ declare const EntityRecordsBulkCreate = "entity.records.bulk.create";
589
+ declare const EntityRecordsBulkCreated = "entity.records.bulk.created";
590
+ declare const EntityRecordsBulkUpdate = "entity.records.bulk.update";
591
+ declare const EntityRecordsBulkUpdated = "entity.records.bulk.updated";
592
+ declare const EntityRecordsBulkDelete = "entity.records.bulk.delete";
593
+ declare const EntityRecordsBulkDeleted = "entity.records.bulk.deleted";
594
+ declare const EntityViewCreate = "entity.view.create";
595
+ declare const EntityViewCreated = "entity.view.created";
596
+ declare const EntityViewUpdate = "entity.view.update";
597
+ declare const EntityViewUpdated = "entity.view.updated";
598
+ declare const EntityViewDelete = "entity.view.delete";
599
+ declare const EntityViewDeleted = "entity.view.deleted";
600
+ declare const EntityViewList = "entity.view.list";
601
+
602
+ export { type BulkCreateRequest, type BulkDeleteRequest, type BulkUpdateRequest, type CountEntityRecordsRequest, type CountEntityRecordsResponse, type CreateEntityDefinitionRequest, type CreateOrgSchemaRequest, type CreateOrgSchemaResponse, type CreateRecordRequest, type CreateViewRequest, type DeleteEntityDefinitionRequest, type DeleteRecordRequest, type DeleteViewRequest, type DropOrgSchemaRequest, type DropOrgSchemaResponse, type EntityDefinition, type EntityDefinitionChangeEvent, EntityDefinitionCreate, EntityDefinitionCreated, EntityDefinitionDelete, EntityDefinitionDeleted, EntityDefinitionGet, EntityDefinitionGetServer, EntityDefinitionList, type EntityDefinitionResponse, EntityDefinitionUpdate, EntityDefinitionUpdated, type EntityFieldType, EntityFieldTypeBool, EntityFieldTypeCurrency, EntityFieldTypeDate, EntityFieldTypeDateTime, EntityFieldTypeDropdown, EntityFieldTypeEmail, EntityFieldTypeFile, EntityFieldTypeFloat, EntityFieldTypeImage, EntityFieldTypeInt, EntityFieldTypeJSON, EntityFieldTypeLookup, EntityFieldTypeMultiLookup, EntityFieldTypeMultiSelect, type EntityFieldTypeOptionTS, EntityFieldTypePhone, EntityFieldTypeString, EntityFieldTypeStringMultiline, type EntityFieldTypeTS, EntityFieldTypeText, EntityFieldTypeURL, EntityFieldTypes, type EntityFilterOperator, type EntityFilterOperatorOptionTS, type EntityFilterOperatorTS, EntityFilterOperators, EntityOrgSchemaCreate, EntityOrgSchemaDrop, type EntityQuery, type EntityRecord, type EntityRecordChangeEvent, EntityRecordCount, EntityRecordCreate, EntityRecordCreated, EntityRecordDelete, EntityRecordDeleted, EntityRecordGet, EntityRecordQuery, type EntityRecordResponse, EntityRecordUpdate, EntityRecordUpdated, EntityRecordsBulkCreate, EntityRecordsBulkCreated, EntityRecordsBulkDelete, EntityRecordsBulkDeleted, EntityRecordsBulkUpdate, EntityRecordsBulkUpdated, type EntityView, type EntityViewChangeEvent, EntityViewCreate, EntityViewCreated, EntityViewDelete, EntityViewDeleted, EntityViewList, type EntityViewResponse, EntityViewUpdate, EntityViewUpdated, type FieldValidation, type Filter, type GetEntityDefinitionRequest, type GetEntityRecordRequest, type GetEntityRecordResponse, type GetViewRequest, type InsertOneResult, type ListEntityDefinitionsRequest, type ListEntityDefinitionsResponse, type ListEntityRecordsResponse, type ListOptions, type ListResult, type ListViewsRequest, type ListViewsResponse, type LookupInclude, OperatorBetween, OperatorContains, OperatorEmpty, OperatorEndsWith, OperatorEq, OperatorExists, OperatorGt, OperatorGte, OperatorIn, OperatorLt, OperatorLte, OperatorNe, OperatorNin, OperatorStartsWith, type QueryRequest, type RecordChange, type RecordChangeAction, RecordChangeActionCreated, RecordChangeActionDeleted, RecordChangeActionUpdated, type RecordReference, type ResponseMetadata, type Sort, type UpdateEntityDefinitionRequest, type UpdateRecordRequest, type UpdateViewRequest, type ValidationRule, type ValidationRuleCondition, type View, type ViewColumn, type ViewFilter };