@elqnt/entity 2.0.7 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.d.mts +45 -0
- package/dist/api/index.d.ts +45 -0
- package/dist/api/index.js +34 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/index.mjs +34 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/chunk-4GC36G4D.js.map +1 -1
- package/dist/chunk-GQJJP4YL.js +204 -0
- package/dist/chunk-GQJJP4YL.js.map +1 -0
- package/dist/chunk-JEDTIUWW.mjs +204 -0
- package/dist/chunk-JEDTIUWW.mjs.map +1 -0
- package/dist/chunk-SXBB42DJ.js +80 -0
- package/dist/chunk-SXBB42DJ.js.map +1 -0
- package/dist/chunk-UHASYUCH.mjs +80 -0
- package/dist/chunk-UHASYUCH.mjs.map +1 -0
- package/dist/hooks/index.d.mts +46 -0
- package/dist/hooks/index.d.ts +46 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +10 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +35 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -1
- package/dist/index.mjs.map +1 -1
- package/dist/models/index.js.map +1 -1
- package/package.json +30 -16
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ApiClientOptions, ApiResponse } from '@elqnt/api-client';
|
|
2
|
+
import { ResponseMetadata } from '@elqnt/types';
|
|
3
|
+
import { EntityRecord, EntityDefinition, EntityDefinitionResponse, EntityRecordResponse, ListEntityDefinitionsResponse, ListEntityRecordsResponse } from '../models/index.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Entity API functions
|
|
7
|
+
*
|
|
8
|
+
* Browser-side API client for entity operations.
|
|
9
|
+
* Uses @elqnt/api-client for HTTP requests with automatic token management.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function listEntityDefinitionsApi(options: ApiClientOptions): Promise<ApiResponse<ListEntityDefinitionsResponse>>;
|
|
13
|
+
declare function getEntityDefinitionApi(entityName: string, options: ApiClientOptions): Promise<ApiResponse<EntityDefinitionResponse>>;
|
|
14
|
+
declare function createEntityDefinitionApi(definition: Partial<EntityDefinition>, options: ApiClientOptions): Promise<ApiResponse<EntityDefinitionResponse>>;
|
|
15
|
+
declare function updateEntityDefinitionApi(entityName: string, definition: Partial<EntityDefinition>, options: ApiClientOptions): Promise<ApiResponse<EntityDefinitionResponse>>;
|
|
16
|
+
declare function deleteEntityDefinitionApi(entityName: string, options: ApiClientOptions): Promise<ApiResponse<{
|
|
17
|
+
success: boolean;
|
|
18
|
+
metadata: ResponseMetadata;
|
|
19
|
+
}>>;
|
|
20
|
+
declare function queryEntityRecordsApi(entityName: string, query: Record<string, unknown>, options: ApiClientOptions): Promise<ApiResponse<ListEntityRecordsResponse>>;
|
|
21
|
+
declare function getEntityRecordApi(entityName: string, recordId: string, options: ApiClientOptions): Promise<ApiResponse<EntityRecordResponse>>;
|
|
22
|
+
declare function createEntityRecordApi(entityName: string, record: Partial<EntityRecord>, options: ApiClientOptions): Promise<ApiResponse<EntityRecordResponse>>;
|
|
23
|
+
declare function updateEntityRecordApi(entityName: string, recordId: string, record: Partial<EntityRecord>, options: ApiClientOptions): Promise<ApiResponse<EntityRecordResponse>>;
|
|
24
|
+
declare function deleteEntityRecordApi(entityName: string, recordId: string, options: ApiClientOptions): Promise<ApiResponse<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
metadata: ResponseMetadata;
|
|
27
|
+
}>>;
|
|
28
|
+
declare function bulkCreateEntityRecordsApi(entityName: string, records: Partial<EntityRecord>[], options: ApiClientOptions): Promise<ApiResponse<{
|
|
29
|
+
records: EntityRecord[];
|
|
30
|
+
metadata: ResponseMetadata;
|
|
31
|
+
}>>;
|
|
32
|
+
declare function bulkUpdateEntityRecordsApi(entityName: string, records: Partial<EntityRecord>[], options: ApiClientOptions): Promise<ApiResponse<{
|
|
33
|
+
records: EntityRecord[];
|
|
34
|
+
metadata: ResponseMetadata;
|
|
35
|
+
}>>;
|
|
36
|
+
declare function bulkDeleteEntityRecordsApi(entityName: string, recordIds: string[], options: ApiClientOptions): Promise<ApiResponse<{
|
|
37
|
+
success: boolean;
|
|
38
|
+
metadata: ResponseMetadata;
|
|
39
|
+
}>>;
|
|
40
|
+
declare function countEntityRecordsApi(entityName: string, filters: Record<string, unknown>, options: ApiClientOptions): Promise<ApiResponse<{
|
|
41
|
+
count: number;
|
|
42
|
+
metadata: ResponseMetadata;
|
|
43
|
+
}>>;
|
|
44
|
+
|
|
45
|
+
export { bulkCreateEntityRecordsApi, bulkDeleteEntityRecordsApi, bulkUpdateEntityRecordsApi, countEntityRecordsApi, createEntityDefinitionApi, createEntityRecordApi, deleteEntityDefinitionApi, deleteEntityRecordApi, getEntityDefinitionApi, getEntityRecordApi, listEntityDefinitionsApi, queryEntityRecordsApi, updateEntityDefinitionApi, updateEntityRecordApi };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ApiClientOptions, ApiResponse } from '@elqnt/api-client';
|
|
2
|
+
import { ResponseMetadata } from '@elqnt/types';
|
|
3
|
+
import { EntityRecord, EntityDefinition, EntityDefinitionResponse, EntityRecordResponse, ListEntityDefinitionsResponse, ListEntityRecordsResponse } from '../models/index.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Entity API functions
|
|
7
|
+
*
|
|
8
|
+
* Browser-side API client for entity operations.
|
|
9
|
+
* Uses @elqnt/api-client for HTTP requests with automatic token management.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function listEntityDefinitionsApi(options: ApiClientOptions): Promise<ApiResponse<ListEntityDefinitionsResponse>>;
|
|
13
|
+
declare function getEntityDefinitionApi(entityName: string, options: ApiClientOptions): Promise<ApiResponse<EntityDefinitionResponse>>;
|
|
14
|
+
declare function createEntityDefinitionApi(definition: Partial<EntityDefinition>, options: ApiClientOptions): Promise<ApiResponse<EntityDefinitionResponse>>;
|
|
15
|
+
declare function updateEntityDefinitionApi(entityName: string, definition: Partial<EntityDefinition>, options: ApiClientOptions): Promise<ApiResponse<EntityDefinitionResponse>>;
|
|
16
|
+
declare function deleteEntityDefinitionApi(entityName: string, options: ApiClientOptions): Promise<ApiResponse<{
|
|
17
|
+
success: boolean;
|
|
18
|
+
metadata: ResponseMetadata;
|
|
19
|
+
}>>;
|
|
20
|
+
declare function queryEntityRecordsApi(entityName: string, query: Record<string, unknown>, options: ApiClientOptions): Promise<ApiResponse<ListEntityRecordsResponse>>;
|
|
21
|
+
declare function getEntityRecordApi(entityName: string, recordId: string, options: ApiClientOptions): Promise<ApiResponse<EntityRecordResponse>>;
|
|
22
|
+
declare function createEntityRecordApi(entityName: string, record: Partial<EntityRecord>, options: ApiClientOptions): Promise<ApiResponse<EntityRecordResponse>>;
|
|
23
|
+
declare function updateEntityRecordApi(entityName: string, recordId: string, record: Partial<EntityRecord>, options: ApiClientOptions): Promise<ApiResponse<EntityRecordResponse>>;
|
|
24
|
+
declare function deleteEntityRecordApi(entityName: string, recordId: string, options: ApiClientOptions): Promise<ApiResponse<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
metadata: ResponseMetadata;
|
|
27
|
+
}>>;
|
|
28
|
+
declare function bulkCreateEntityRecordsApi(entityName: string, records: Partial<EntityRecord>[], options: ApiClientOptions): Promise<ApiResponse<{
|
|
29
|
+
records: EntityRecord[];
|
|
30
|
+
metadata: ResponseMetadata;
|
|
31
|
+
}>>;
|
|
32
|
+
declare function bulkUpdateEntityRecordsApi(entityName: string, records: Partial<EntityRecord>[], options: ApiClientOptions): Promise<ApiResponse<{
|
|
33
|
+
records: EntityRecord[];
|
|
34
|
+
metadata: ResponseMetadata;
|
|
35
|
+
}>>;
|
|
36
|
+
declare function bulkDeleteEntityRecordsApi(entityName: string, recordIds: string[], options: ApiClientOptions): Promise<ApiResponse<{
|
|
37
|
+
success: boolean;
|
|
38
|
+
metadata: ResponseMetadata;
|
|
39
|
+
}>>;
|
|
40
|
+
declare function countEntityRecordsApi(entityName: string, filters: Record<string, unknown>, options: ApiClientOptions): Promise<ApiResponse<{
|
|
41
|
+
count: number;
|
|
42
|
+
metadata: ResponseMetadata;
|
|
43
|
+
}>>;
|
|
44
|
+
|
|
45
|
+
export { bulkCreateEntityRecordsApi, bulkDeleteEntityRecordsApi, bulkUpdateEntityRecordsApi, countEntityRecordsApi, createEntityDefinitionApi, createEntityRecordApi, deleteEntityDefinitionApi, deleteEntityRecordApi, getEntityDefinitionApi, getEntityRecordApi, listEntityDefinitionsApi, queryEntityRecordsApi, updateEntityDefinitionApi, updateEntityRecordApi };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var _chunkSXBB42DJjs = require('../chunk-SXBB42DJ.js');
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.bulkCreateEntityRecordsApi = _chunkSXBB42DJjs.bulkCreateEntityRecordsApi; exports.bulkDeleteEntityRecordsApi = _chunkSXBB42DJjs.bulkDeleteEntityRecordsApi; exports.bulkUpdateEntityRecordsApi = _chunkSXBB42DJjs.bulkUpdateEntityRecordsApi; exports.countEntityRecordsApi = _chunkSXBB42DJjs.countEntityRecordsApi; exports.createEntityDefinitionApi = _chunkSXBB42DJjs.createEntityDefinitionApi; exports.createEntityRecordApi = _chunkSXBB42DJjs.createEntityRecordApi; exports.deleteEntityDefinitionApi = _chunkSXBB42DJjs.deleteEntityDefinitionApi; exports.deleteEntityRecordApi = _chunkSXBB42DJjs.deleteEntityRecordApi; exports.getEntityDefinitionApi = _chunkSXBB42DJjs.getEntityDefinitionApi; exports.getEntityRecordApi = _chunkSXBB42DJjs.getEntityRecordApi; exports.listEntityDefinitionsApi = _chunkSXBB42DJjs.listEntityDefinitionsApi; exports.queryEntityRecordsApi = _chunkSXBB42DJjs.queryEntityRecordsApi; exports.updateEntityDefinitionApi = _chunkSXBB42DJjs.updateEntityDefinitionApi; exports.updateEntityRecordApi = _chunkSXBB42DJjs.updateEntityRecordApi;
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/eloquent/eloquent/packages/@elqnt/entity/dist/api/index.js"],"names":[],"mappings":"AAAA,qFAAY;AACZ;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,uDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,uiCAAC","file":"/home/runner/work/eloquent/eloquent/packages/@elqnt/entity/dist/api/index.js"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
bulkCreateEntityRecordsApi,
|
|
4
|
+
bulkDeleteEntityRecordsApi,
|
|
5
|
+
bulkUpdateEntityRecordsApi,
|
|
6
|
+
countEntityRecordsApi,
|
|
7
|
+
createEntityDefinitionApi,
|
|
8
|
+
createEntityRecordApi,
|
|
9
|
+
deleteEntityDefinitionApi,
|
|
10
|
+
deleteEntityRecordApi,
|
|
11
|
+
getEntityDefinitionApi,
|
|
12
|
+
getEntityRecordApi,
|
|
13
|
+
listEntityDefinitionsApi,
|
|
14
|
+
queryEntityRecordsApi,
|
|
15
|
+
updateEntityDefinitionApi,
|
|
16
|
+
updateEntityRecordApi
|
|
17
|
+
} from "../chunk-UHASYUCH.mjs";
|
|
18
|
+
export {
|
|
19
|
+
bulkCreateEntityRecordsApi,
|
|
20
|
+
bulkDeleteEntityRecordsApi,
|
|
21
|
+
bulkUpdateEntityRecordsApi,
|
|
22
|
+
countEntityRecordsApi,
|
|
23
|
+
createEntityDefinitionApi,
|
|
24
|
+
createEntityRecordApi,
|
|
25
|
+
deleteEntityDefinitionApi,
|
|
26
|
+
deleteEntityRecordApi,
|
|
27
|
+
getEntityDefinitionApi,
|
|
28
|
+
getEntityRecordApi,
|
|
29
|
+
listEntityDefinitionsApi,
|
|
30
|
+
queryEntityRecordsApi,
|
|
31
|
+
updateEntityDefinitionApi,
|
|
32
|
+
updateEntityRecordApi
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/eloquent-packages/eloquent-packages/packages/entity/dist/chunk-4GC36G4D.js","../models/entity.ts"],"names":[],"mappings":"AAAA,qFAAY;AACZ;AACA;ACQO,IAAM,WAAA,EAAmC,IAAA;AAIzC,IAAM,WAAA,EAAmC,IAAA;AAIzC,IAAM,WAAA,EAAmC,IAAA;AAIzC,IAAM,YAAA,EAAoC,KAAA;AAI1C,IAAM,WAAA,EAAmC,IAAA;AAIzC,IAAM,YAAA,EAAoC,KAAA;AAI1C,IAAM,WAAA,EAAmC,IAAA;AAIzC,IAAM,YAAA,EAAoC,KAAA;AAI1C,IAAM,iBAAA,EAAyC,UAAA;AAI/C,IAAM,mBAAA,EAA2C,YAAA;AAIjD,IAAM,iBAAA,EAAyC,UAAA;AAI/C,IAAM,eAAA,EAAuC,QAAA;AAI7C,IAAM,cAAA,EAAsC,OAAA;AAI5C,I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;AACF,0hHAAC","file":"/home/runner/work/eloquent-packages/eloquent-packages/packages/entity/dist/chunk-4GC36G4D.js","sourcesContent":[null,"// Code generated by tygo. DO NOT EDIT.\nimport { JSONSchema } from \"@elqnt/types\";\n\n//////////\n// source: constants.go\n\nexport type EntityFilterOperator = string;\n/**\n * todo: move to types package\n */\nexport const OperatorEq: EntityFilterOperator = \"eq\";\n/**\n * todo: move to types package\n */\nexport const OperatorNe: EntityFilterOperator = \"ne\";\n/**\n * todo: move to types package\n */\nexport const OperatorGt: EntityFilterOperator = \"gt\";\n/**\n * todo: move to types package\n */\nexport const OperatorGte: EntityFilterOperator = \"gte\";\n/**\n * todo: move to types package\n */\nexport const OperatorLt: EntityFilterOperator = \"lt\";\n/**\n * todo: move to types package\n */\nexport const OperatorLte: EntityFilterOperator = \"lte\";\n/**\n * todo: move to types package\n */\nexport const OperatorIn: EntityFilterOperator = \"in\";\n/**\n * todo: move to types package\n */\nexport const OperatorNin: EntityFilterOperator = \"nin\";\n/**\n * todo: move to types package\n */\nexport const OperatorContains: EntityFilterOperator = \"contains\";\n/**\n * todo: move to types package\n */\nexport const OperatorStartsWith: EntityFilterOperator = \"startsWith\";\n/**\n * todo: move to types package\n */\nexport const OperatorEndsWith: EntityFilterOperator = \"endsWith\";\n/**\n * todo: move to types package\n */\nexport const OperatorExists: EntityFilterOperator = \"exists\";\n/**\n * todo: move to types package\n */\nexport const OperatorEmpty: EntityFilterOperator = \"empty\";\n/**\n * todo: move to types package\n */\nexport const OperatorBetween: EntityFilterOperator = \"between\";\n\nexport const EntityFilterOperators = {\n eq: { value: 'eq', label: 'Equal to' },\n ne: { value: 'ne', label: 'Not equal to' },\n gt: { value: 'gt', label: 'Greater than' },\n gte: { value: 'gte', label: 'Greater than or equal to' },\n lt: { value: 'lt', label: 'Less than' },\n lte: { value: 'lte', label: 'Less than or equal to' },\n in: { value: 'in', label: 'In' },\n nin: { value: 'nin', label: 'Not in' },\n contains: { value: 'contains', label: 'Contains' },\n startsWith: { value: 'startsWith', label: 'Starts with' },\n endsWith: { value: 'endsWith', label: 'Ends with' },\n exists: { value: 'exists', label: 'Exists' },\n empty: { value: 'empty', label: 'Empty' },\n between: { value: 'between', label: 'Between' }\n} as const;\n\nexport type EntityFilterOperatorTS = keyof typeof EntityFilterOperators;\nexport type EntityFilterOperatorOptionTS = typeof EntityFilterOperators[EntityFilterOperatorTS];\n\nexport type EntityFieldType = string;\nexport const EntityFieldTypeString: EntityFieldType = \"string\";\nexport const EntityFieldTypeStringMultiline: EntityFieldType = \"stringMultiline\";\nexport const EntityFieldTypeText: EntityFieldType = \"text\";\nexport const EntityFieldTypeInt: EntityFieldType = \"int\";\nexport const EntityFieldTypeFloat: EntityFieldType = \"float\";\nexport const EntityFieldTypeBool: EntityFieldType = \"bool\";\nexport const EntityFieldTypeDate: EntityFieldType = \"date\";\nexport const EntityFieldTypeDateTime: EntityFieldType = \"datetime\";\nexport const EntityFieldTypeEmail: EntityFieldType = \"email\";\nexport const EntityFieldTypePhone: EntityFieldType = \"phone\";\nexport const EntityFieldTypeURL: EntityFieldType = \"url\";\nexport const EntityFieldTypeDropdown: EntityFieldType = \"dropdown\";\nexport const EntityFieldTypeMultiSelect: EntityFieldType = \"multiselect\";\nexport const EntityFieldTypeLookup: EntityFieldType = \"lookup\";\nexport const EntityFieldTypeMultiLookup: EntityFieldType = \"multilookup\";\nexport const EntityFieldTypeCurrency: EntityFieldType = \"currency\";\nexport const EntityFieldTypeFile: EntityFieldType = \"file\";\nexport const EntityFieldTypeImage: EntityFieldType = \"image\";\nexport const EntityFieldTypeJSON: EntityFieldType = \"json\";\n\nexport const EntityFieldTypes = {\n string: { value: 'string', label: 'Short Text' },\n stringMultiline: { value: 'stringMultiline', label: 'Long Text' },\n text: { value: 'text', label: 'Rich Text Editor' },\n int: { value: 'int', label: 'Integer' },\n float: { value: 'float', label: 'Decimal' },\n bool: { value: 'bool', label: 'Boolean' },\n date: { value: 'date', label: 'Date' },\n datetime: { value: 'datetime', label: 'Date & Time' },\n email: { value: 'email', label: 'Email' },\n phone: { value: 'phone', label: 'Phone' },\n url: { value: 'url', label: 'URL' },\n dropdown: { value: 'dropdown', label: 'Dropdown' },\n multiselect: { value: 'multiselect', label: 'Multi Select' },\n lookup: { value: 'lookup', label: 'Lookup' },\n multilookup: { value: 'multilookup', label: 'Multi Lookup' },\n currency: { value: 'currency', label: 'Currency' },\n file: { value: 'file', label: 'File' },\n image: { value: 'image', label: 'Image' },\n json: { value: 'json', label: 'JSON' }\n} as const;\n\nexport type EntityFieldTypeTS = keyof typeof EntityFieldTypes;\nexport type EntityFieldTypeOptionTS = typeof EntityFieldTypes[EntityFieldTypeTS];\n\n\n//////////\n// source: entities-models.go\n\nexport interface EntityDefinition {\n id: string /* uuid */;\n name: string;\n displayName: string;\n module: string;\n description: string;\n schema: JSONSchema;\n defaultViewId: string /* uuid */;\n metadata?: { [key: string]: any};\n createdAt: string /* RFC3339 */;\n updatedAt: string /* RFC3339 */;\n isActive: boolean;\n version: number /* int */;\n}\nexport interface EntityRecord {\n id: string /* uuid */;\n entityId: string /* uuid */;\n name: string;\n fields: { [key: string]: any}; // ** must match the entity definition schema\n tags?: string[];\n metadata?: { [key: string]: any};\n createdAt: string /* RFC3339 */;\n updatedAt: string /* RFC3339 */;\n isActive: boolean;\n version: number /* int */;\n}\n/**\n * View defines how to display entity records in a list\n */\nexport interface View {\n id: string /* uuid */;\n entityId: string /* uuid */;\n name: string;\n displayName: string;\n description?: string;\n isDefault: boolean;\n columns: ViewColumn[];\n filters: Filter[];\n sort: Sort[];\n}\nexport interface Filter {\n field: string;\n operator: EntityFilterOperator;\n value: any;\n}\nexport interface Sort {\n field: string;\n direction: number /* int */; // 1 for asc, -1 for desc\n}\nexport interface FieldValidation {\n required: boolean;\n min?: number /* float64 */;\n max?: number /* float64 */;\n minLength?: number /* int */;\n maxLength?: number /* int */;\n pattern?: string;\n customRules?: ValidationRule[];\n}\nexport interface ValidationRule {\n name: string;\n conditions: ValidationRuleCondition[];\n}\nexport interface ValidationRuleCondition {\n field: string;\n operator: string;\n value: any;\n}\nexport interface RecordReference {\n entityName: string;\n recordId: string /* uuid */;\n fieldName: string;\n referencedAt: string /* RFC3339 */;\n}\nexport interface InsertOneResult {\n insertedId: string;\n success: boolean;\n error: string;\n}\n/**\n * Query related models\n */\nexport interface EntityQuery {\n filters: { [key: string]: any};\n page: number /* int64 */;\n pageSize: number /* int64 */;\n sortBy: string;\n sortOrder: number /* int */;\n includeLookups?: LookupInclude[];\n include?: string[]; // Fields to include\n exclude?: string[]; // Fields to exclude\n}\nexport interface LookupInclude {\n entityName: string;\n fieldName: string;\n fields?: string[];\n}\nexport interface QueryRequest {\n orgId: string;\n entityName: string;\n viewId?: string /* uuid */;\n query: EntityQuery;\n}\n/**\n * Request/Response models\n */\nexport interface CreateEntityDefinitionRequest {\n orgId: string;\n definition: EntityDefinition;\n}\nexport interface CreateOrgSchemaRequest {\n orgId: string /* uuid */;\n}\nexport interface CreateOrgSchemaResponse {\n metadata: ResponseMetadata;\n}\nexport interface DropOrgSchemaRequest {\n orgId: string /* uuid */;\n}\nexport interface DropOrgSchemaResponse {\n metadata: ResponseMetadata;\n}\nexport interface CreateRecordRequest {\n orgId: string;\n entityName: string;\n record: EntityRecord;\n}\nexport interface UpdateRecordRequest {\n orgId: string;\n entityName: string;\n recordId: string /* uuid */;\n record: EntityRecord;\n}\nexport interface DeleteRecordRequest {\n orgId: string;\n entityName: string;\n recordId: string;\n}\n/**\n * View models\n */\nexport interface EntityView {\n id: string /* uuid */;\n name: string;\n displayName: string;\n entityName: string;\n columns: ViewColumn[];\n filters: ViewFilter[];\n lookups: LookupInclude[];\n sortBy?: string;\n sortOrder?: number /* int */;\n isDefault: boolean;\n createdAt: string /* RFC3339 */;\n updatedAt: string /* RFC3339 */;\n isActive: boolean;\n version: number /* int */;\n}\nexport interface ViewColumn {\n fieldName: string;\n displayName: string;\n width: number /* int */;\n sortable: boolean;\n visible: boolean;\n order: number /* int */;\n}\nexport interface ViewFilter {\n fieldName: string;\n operator: string;\n value: any;\n}\n/**\n * Bulk operation models\n */\nexport interface BulkCreateRequest {\n orgId: string;\n entityName: string;\n records: EntityRecord[];\n}\nexport interface BulkUpdateRequest {\n orgId: string;\n entityName: string;\n records: EntityRecord[];\n}\nexport interface BulkDeleteRequest {\n orgId: string;\n entityName: string;\n recordIds: string /* uuid */[];\n}\nexport interface UpdateEntityDefinitionRequest {\n orgId: string;\n entityName: string; // Identify which entity to update\n definition: EntityDefinition;\n}\nexport interface GetEntityDefinitionRequest {\n orgId: string;\n entityName: string;\n}\nexport interface DeleteEntityDefinitionRequest {\n orgId: string;\n entityName: string;\n deleteRecords?: boolean; // If true, delete all entity records before deleting definition\n hardDelete?: boolean; // If true, permanently delete from database instead of soft delete\n}\nexport interface ListEntityDefinitionsRequest {\n orgId: string;\n module?: string; // Optional: filter by module (sales, marketing, etc)\n status?: string; // Optional: active, inactive, etc\n}\n/**\n * View related requests\n */\nexport interface CreateViewRequest {\n orgId: string;\n entityName: string;\n view: EntityView;\n}\nexport interface UpdateViewRequest {\n orgId: string;\n view: EntityView;\n}\nexport interface DeleteViewRequest {\n orgId: string;\n viewId: string /* uuid */;\n}\nexport interface GetViewRequest {\n orgId: string;\n viewId: string /* uuid */;\n}\nexport interface ListViewsRequest {\n orgId: string;\n entityName: string;\n}\n/**\n * Response models\n */\nexport interface EntityDefinitionResponse {\n definition: EntityDefinition;\n metadata: ResponseMetadata;\n}\nexport interface ListEntityDefinitionsResponse {\n definitions: EntityDefinition[];\n metadata: ResponseMetadata;\n}\nexport interface EntityViewResponse {\n view: EntityView;\n metadata: ResponseMetadata;\n}\nexport interface ListViewsResponse {\n views: EntityView[];\n metadata: ResponseMetadata;\n}\nexport interface EntityRecordResponse {\n record: EntityRecord;\n metadata: ResponseMetadata;\n}\nexport interface ListEntityRecordsResponse {\n records?: ListResult<EntityRecord>;\n metadata: ResponseMetadata;\n}\n/**\n * Common response metadata\n */\nexport interface ResponseMetadata {\n success: boolean;\n timestamp: string /* RFC3339 */;\n message?: string;\n error?: string;\n}\nexport interface ListOptions {\n Page: number /* int64 */;\n PageSize: number /* int64 */;\n SortBy: string;\n SortOrder: number /* int */;\n Filters: { [key: string]: any};\n Include: string[];\n Exclude: string[];\n}\nexport interface ListResult<T extends any> {\n items: T[];\n totalCount: number /* int64 */;\n currentPage: number /* int64 */;\n pageSize: number /* int64 */;\n totalPages: number /* int64 */;\n}\nexport interface GetEntityRecordRequest {\n orgId: string;\n entityName: string;\n recordId: string;\n}\nexport interface GetEntityRecordResponse {\n record?: EntityRecord;\n metadata: ResponseMetadata;\n}\nexport interface CountEntityRecordsRequest {\n orgId: string;\n entityName: string;\n filters?: { [key: string]: any};\n}\nexport interface CountEntityRecordsResponse {\n count: number /* int64 */;\n metadata: ResponseMetadata;\n}\n\n//////////\n// source: events.go\n\nexport interface EntityRecordChangeEvent {\n orgId: string;\n entityName: string;\n recordId: string;\n record?: EntityRecord;\n changes?: RecordChange;\n action: RecordChangeAction; // created, updated, deleted\n timestamp: string /* RFC3339 */;\n}\nexport interface RecordChange {\n /**\n * OldValues map[string]TypedValue `json:\"oldValues,omitempty\"`\n * NewValues map[string]TypedValue `json:\"newValues,omitempty\"`\n */\n changedAt: string /* RFC3339 */;\n changedBy: string /* ObjectID */;\n fields: string[]; // List of changed field names for quick reference\n}\nexport interface EntityDefinitionChangeEvent {\n orgId: string;\n definition?: EntityDefinition;\n action: string; // created, updated, deleted\n timestamp: string /* RFC3339 */;\n}\nexport interface EntityViewChangeEvent {\n orgId: string;\n entityName: string;\n view?: EntityView;\n action: string; // created, updated, deleted\n timestamp: string /* RFC3339 */;\n}\nexport type RecordChangeAction = string;\nexport const RecordChangeActionCreated: RecordChangeAction = \"created\";\nexport const RecordChangeActionUpdated: RecordChangeAction = \"updated\";\nexport const RecordChangeActionDeleted: RecordChangeAction = \"deleted\";\n\n//////////\n// source: subjects.go\n\nexport const EntityOrgSchemaCreate = \"entity.org.schema.create\";\nexport const EntityOrgSchemaDrop = \"entity.org.schema.drop\";\nexport const EntityDefinitionCreate = \"entity.definition.create\";\nexport const EntityDefinitionCreated = \"entity.definition.created\";\nexport const EntityDefinitionUpdate = \"entity.definition.update\";\nexport const EntityDefinitionGet = \"entity.definition.get\";\nexport const EntityDefinitionGetServer = \"entity.definition.get.server\";\nexport const EntityDefinitionList = \"entity.definition.list\";\nexport const EntityDefinitionUpdated = \"entity.definition.updated\";\nexport const EntityDefinitionDelete = \"entity.definition.delete\";\nexport const EntityDefinitionDeleted = \"entity.definition.deleted\";\nexport const EntityRecordCreate = \"entity.record.create\";\nexport const EntityRecordCreated = \"entity.record.created\";\nexport const EntityRecordGet = \"entity.record.get\";\nexport const EntityRecordQuery = \"entity.record.query\";\nexport const EntityRecordCount = \"entity.record.count\";\nexport const EntityRecordUpdate = \"entity.record.update\";\nexport const EntityRecordUpdated = \"entity.record.updated\";\nexport const EntityRecordDelete = \"entity.record.delete\";\nexport const EntityRecordDeleted = \"entity.record.deleted\";\nexport const EntityRecordsBulkCreate = \"entity.records.bulk.create\";\nexport const EntityRecordsBulkCreated = \"entity.records.bulk.created\";\nexport const EntityRecordsBulkUpdate = \"entity.records.bulk.update\";\nexport const EntityRecordsBulkUpdated = \"entity.records.bulk.updated\";\nexport const EntityRecordsBulkDelete = \"entity.records.bulk.delete\";\nexport const EntityRecordsBulkDeleted = \"entity.records.bulk.deleted\";\nexport const EntityViewCreate = \"entity.view.create\";\nexport const EntityViewCreated = \"entity.view.created\";\nexport const EntityViewUpdate = \"entity.view.update\";\nexport const EntityViewUpdated = \"entity.view.updated\";\nexport const EntityViewDelete = \"entity.view.delete\";\nexport const EntityViewDeleted = \"entity.view.deleted\";\nexport const EntityViewList = \"entity.view.list\";\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/eloquent/eloquent/packages/@elqnt/entity/dist/chunk-4GC36G4D.js","../models/entity.ts"],"names":[],"mappings":"AAAA,qFAAY;AACZ;AACA;ACQO,IAAM,WAAA,EAAmC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BAAA,EAAoB,qBAAA;AAC1B,IAAM,eAAA,EAAiB,kBAAA;ADjZ9B;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,0hHAAC","file":"/home/runner/work/eloquent/eloquent/packages/@elqnt/entity/dist/chunk-4GC36G4D.js","sourcesContent":[null,"// Code generated by tygo. DO NOT EDIT.\nimport { JSONSchema } from \"@elqnt/types\";\n\n//////////\n// source: constants.go\n\nexport type EntityFilterOperator = string;\n/**\n * todo: move to types package\n */\nexport const OperatorEq: EntityFilterOperator = \"eq\";\n/**\n * todo: move to types package\n */\nexport const OperatorNe: EntityFilterOperator = \"ne\";\n/**\n * todo: move to types package\n */\nexport const OperatorGt: EntityFilterOperator = \"gt\";\n/**\n * todo: move to types package\n */\nexport const OperatorGte: EntityFilterOperator = \"gte\";\n/**\n * todo: move to types package\n */\nexport const OperatorLt: EntityFilterOperator = \"lt\";\n/**\n * todo: move to types package\n */\nexport const OperatorLte: EntityFilterOperator = \"lte\";\n/**\n * todo: move to types package\n */\nexport const OperatorIn: EntityFilterOperator = \"in\";\n/**\n * todo: move to types package\n */\nexport const OperatorNin: EntityFilterOperator = \"nin\";\n/**\n * todo: move to types package\n */\nexport const OperatorContains: EntityFilterOperator = \"contains\";\n/**\n * todo: move to types package\n */\nexport const OperatorStartsWith: EntityFilterOperator = \"startsWith\";\n/**\n * todo: move to types package\n */\nexport const OperatorEndsWith: EntityFilterOperator = \"endsWith\";\n/**\n * todo: move to types package\n */\nexport const OperatorExists: EntityFilterOperator = \"exists\";\n/**\n * todo: move to types package\n */\nexport const OperatorEmpty: EntityFilterOperator = \"empty\";\n/**\n * todo: move to types package\n */\nexport const OperatorBetween: EntityFilterOperator = \"between\";\n\nexport const EntityFilterOperators = {\n eq: { value: 'eq', label: 'Equal to' },\n ne: { value: 'ne', label: 'Not equal to' },\n gt: { value: 'gt', label: 'Greater than' },\n gte: { value: 'gte', label: 'Greater than or equal to' },\n lt: { value: 'lt', label: 'Less than' },\n lte: { value: 'lte', label: 'Less than or equal to' },\n in: { value: 'in', label: 'In' },\n nin: { value: 'nin', label: 'Not in' },\n contains: { value: 'contains', label: 'Contains' },\n startsWith: { value: 'startsWith', label: 'Starts with' },\n endsWith: { value: 'endsWith', label: 'Ends with' },\n exists: { value: 'exists', label: 'Exists' },\n empty: { value: 'empty', label: 'Empty' },\n between: { value: 'between', label: 'Between' }\n} as const;\n\nexport type EntityFilterOperatorTS = keyof typeof EntityFilterOperators;\nexport type EntityFilterOperatorOptionTS = typeof EntityFilterOperators[EntityFilterOperatorTS];\n\nexport type EntityFieldType = string;\nexport const EntityFieldTypeString: EntityFieldType = \"string\";\nexport const EntityFieldTypeStringMultiline: EntityFieldType = \"stringMultiline\";\nexport const EntityFieldTypeText: EntityFieldType = \"text\";\nexport const EntityFieldTypeInt: EntityFieldType = \"int\";\nexport const EntityFieldTypeFloat: EntityFieldType = \"float\";\nexport const EntityFieldTypeBool: EntityFieldType = \"bool\";\nexport const EntityFieldTypeDate: EntityFieldType = \"date\";\nexport const EntityFieldTypeDateTime: EntityFieldType = \"datetime\";\nexport const EntityFieldTypeEmail: EntityFieldType = \"email\";\nexport const EntityFieldTypePhone: EntityFieldType = \"phone\";\nexport const EntityFieldTypeURL: EntityFieldType = \"url\";\nexport const EntityFieldTypeDropdown: EntityFieldType = \"dropdown\";\nexport const EntityFieldTypeMultiSelect: EntityFieldType = \"multiselect\";\nexport const EntityFieldTypeLookup: EntityFieldType = \"lookup\";\nexport const EntityFieldTypeMultiLookup: EntityFieldType = \"multilookup\";\nexport const EntityFieldTypeCurrency: EntityFieldType = \"currency\";\nexport const EntityFieldTypeFile: EntityFieldType = \"file\";\nexport const EntityFieldTypeImage: EntityFieldType = \"image\";\nexport const EntityFieldTypeJSON: EntityFieldType = \"json\";\n\nexport const EntityFieldTypes = {\n string: { value: 'string', label: 'Short Text' },\n stringMultiline: { value: 'stringMultiline', label: 'Long Text' },\n text: { value: 'text', label: 'Rich Text Editor' },\n int: { value: 'int', label: 'Integer' },\n float: { value: 'float', label: 'Decimal' },\n bool: { value: 'bool', label: 'Boolean' },\n date: { value: 'date', label: 'Date' },\n datetime: { value: 'datetime', label: 'Date & Time' },\n email: { value: 'email', label: 'Email' },\n phone: { value: 'phone', label: 'Phone' },\n url: { value: 'url', label: 'URL' },\n dropdown: { value: 'dropdown', label: 'Dropdown' },\n multiselect: { value: 'multiselect', label: 'Multi Select' },\n lookup: { value: 'lookup', label: 'Lookup' },\n multilookup: { value: 'multilookup', label: 'Multi Lookup' },\n currency: { value: 'currency', label: 'Currency' },\n file: { value: 'file', label: 'File' },\n image: { value: 'image', label: 'Image' },\n json: { value: 'json', label: 'JSON' }\n} as const;\n\nexport type EntityFieldTypeTS = keyof typeof EntityFieldTypes;\nexport type EntityFieldTypeOptionTS = typeof EntityFieldTypes[EntityFieldTypeTS];\n\n\n//////////\n// source: entities-models.go\n\nexport interface EntityDefinition {\n id: string /* uuid */;\n name: string;\n displayName: string;\n module: string;\n description: string;\n schema: JSONSchema;\n defaultViewId: string /* uuid */;\n metadata?: { [key: string]: any};\n createdAt: string /* RFC3339 */;\n updatedAt: string /* RFC3339 */;\n isActive: boolean;\n version: number /* int */;\n}\nexport interface EntityRecord {\n id: string /* uuid */;\n entityId: string /* uuid */;\n name: string;\n fields: { [key: string]: any}; // ** must match the entity definition schema\n tags?: string[];\n metadata?: { [key: string]: any};\n createdAt: string /* RFC3339 */;\n updatedAt: string /* RFC3339 */;\n isActive: boolean;\n version: number /* int */;\n}\n/**\n * View defines how to display entity records in a list\n */\nexport interface View {\n id: string /* uuid */;\n entityId: string /* uuid */;\n name: string;\n displayName: string;\n description?: string;\n isDefault: boolean;\n columns: ViewColumn[];\n filters: Filter[];\n sort: Sort[];\n}\nexport interface Filter {\n field: string;\n operator: EntityFilterOperator;\n value: any;\n}\nexport interface Sort {\n field: string;\n direction: number /* int */; // 1 for asc, -1 for desc\n}\nexport interface FieldValidation {\n required: boolean;\n min?: number /* float64 */;\n max?: number /* float64 */;\n minLength?: number /* int */;\n maxLength?: number /* int */;\n pattern?: string;\n customRules?: ValidationRule[];\n}\nexport interface ValidationRule {\n name: string;\n conditions: ValidationRuleCondition[];\n}\nexport interface ValidationRuleCondition {\n field: string;\n operator: string;\n value: any;\n}\nexport interface RecordReference {\n entityName: string;\n recordId: string /* uuid */;\n fieldName: string;\n referencedAt: string /* RFC3339 */;\n}\nexport interface InsertOneResult {\n insertedId: string;\n success: boolean;\n error: string;\n}\n/**\n * Query related models\n */\nexport interface EntityQuery {\n filters: { [key: string]: any};\n page: number /* int64 */;\n pageSize: number /* int64 */;\n sortBy: string;\n sortOrder: number /* int */;\n includeLookups?: LookupInclude[];\n include?: string[]; // Fields to include\n exclude?: string[]; // Fields to exclude\n}\nexport interface LookupInclude {\n entityName: string;\n fieldName: string;\n fields?: string[];\n}\nexport interface QueryRequest {\n orgId: string;\n entityName: string;\n viewId?: string /* uuid */;\n query: EntityQuery;\n}\n/**\n * Request/Response models\n */\nexport interface CreateEntityDefinitionRequest {\n orgId: string;\n definition: EntityDefinition;\n}\nexport interface CreateOrgSchemaRequest {\n orgId: string /* uuid */;\n}\nexport interface CreateOrgSchemaResponse {\n metadata: ResponseMetadata;\n}\nexport interface DropOrgSchemaRequest {\n orgId: string /* uuid */;\n}\nexport interface DropOrgSchemaResponse {\n metadata: ResponseMetadata;\n}\nexport interface CreateRecordRequest {\n orgId: string;\n entityName: string;\n record: EntityRecord;\n}\nexport interface UpdateRecordRequest {\n orgId: string;\n entityName: string;\n recordId: string /* uuid */;\n record: EntityRecord;\n}\nexport interface DeleteRecordRequest {\n orgId: string;\n entityName: string;\n recordId: string;\n}\n/**\n * View models\n */\nexport interface EntityView {\n id: string /* uuid */;\n name: string;\n displayName: string;\n entityName: string;\n columns: ViewColumn[];\n filters: ViewFilter[];\n lookups: LookupInclude[];\n sortBy?: string;\n sortOrder?: number /* int */;\n isDefault: boolean;\n createdAt: string /* RFC3339 */;\n updatedAt: string /* RFC3339 */;\n isActive: boolean;\n version: number /* int */;\n}\nexport interface ViewColumn {\n fieldName: string;\n displayName: string;\n width: number /* int */;\n sortable: boolean;\n visible: boolean;\n order: number /* int */;\n}\nexport interface ViewFilter {\n fieldName: string;\n operator: string;\n value: any;\n}\n/**\n * Bulk operation models\n */\nexport interface BulkCreateRequest {\n orgId: string;\n entityName: string;\n records: EntityRecord[];\n}\nexport interface BulkUpdateRequest {\n orgId: string;\n entityName: string;\n records: EntityRecord[];\n}\nexport interface BulkDeleteRequest {\n orgId: string;\n entityName: string;\n recordIds: string /* uuid */[];\n}\nexport interface UpdateEntityDefinitionRequest {\n orgId: string;\n entityName: string; // Identify which entity to update\n definition: EntityDefinition;\n}\nexport interface GetEntityDefinitionRequest {\n orgId: string;\n entityName: string;\n}\nexport interface DeleteEntityDefinitionRequest {\n orgId: string;\n entityName: string;\n deleteRecords?: boolean; // If true, delete all entity records before deleting definition\n hardDelete?: boolean; // If true, permanently delete from database instead of soft delete\n}\nexport interface ListEntityDefinitionsRequest {\n orgId: string;\n module?: string; // Optional: filter by module (sales, marketing, etc)\n status?: string; // Optional: active, inactive, etc\n}\n/**\n * View related requests\n */\nexport interface CreateViewRequest {\n orgId: string;\n entityName: string;\n view: EntityView;\n}\nexport interface UpdateViewRequest {\n orgId: string;\n view: EntityView;\n}\nexport interface DeleteViewRequest {\n orgId: string;\n viewId: string /* uuid */;\n}\nexport interface GetViewRequest {\n orgId: string;\n viewId: string /* uuid */;\n}\nexport interface ListViewsRequest {\n orgId: string;\n entityName: string;\n}\n/**\n * Response models\n */\nexport interface EntityDefinitionResponse {\n definition: EntityDefinition;\n metadata: ResponseMetadata;\n}\nexport interface ListEntityDefinitionsResponse {\n definitions: EntityDefinition[];\n metadata: ResponseMetadata;\n}\nexport interface EntityViewResponse {\n view: EntityView;\n metadata: ResponseMetadata;\n}\nexport interface ListViewsResponse {\n views: EntityView[];\n metadata: ResponseMetadata;\n}\nexport interface EntityRecordResponse {\n record: EntityRecord;\n metadata: ResponseMetadata;\n}\nexport interface ListEntityRecordsResponse {\n records?: ListResult<EntityRecord>;\n metadata: ResponseMetadata;\n}\n/**\n * Common response metadata\n */\nexport interface ResponseMetadata {\n success: boolean;\n timestamp: string /* RFC3339 */;\n message?: string;\n error?: string;\n}\nexport interface ListOptions {\n Page: number /* int64 */;\n PageSize: number /* int64 */;\n SortBy: string;\n SortOrder: number /* int */;\n Filters: { [key: string]: any};\n Include: string[];\n Exclude: string[];\n}\nexport interface ListResult<T extends any> {\n items: T[];\n totalCount: number /* int64 */;\n currentPage: number /* int64 */;\n pageSize: number /* int64 */;\n totalPages: number /* int64 */;\n}\nexport interface GetEntityRecordRequest {\n orgId: string;\n entityName: string;\n recordId: string;\n}\nexport interface GetEntityRecordResponse {\n record?: EntityRecord;\n metadata: ResponseMetadata;\n}\nexport interface CountEntityRecordsRequest {\n orgId: string;\n entityName: string;\n filters?: { [key: string]: any};\n}\nexport interface CountEntityRecordsResponse {\n count: number /* int64 */;\n metadata: ResponseMetadata;\n}\n\n//////////\n// source: events.go\n\nexport interface EntityRecordChangeEvent {\n orgId: string;\n entityName: string;\n recordId: string;\n record?: EntityRecord;\n changes?: RecordChange;\n action: RecordChangeAction; // created, updated, deleted\n timestamp: string /* RFC3339 */;\n}\nexport interface RecordChange {\n /**\n * OldValues map[string]TypedValue `json:\"oldValues,omitempty\"`\n * NewValues map[string]TypedValue `json:\"newValues,omitempty\"`\n */\n changedAt: string /* RFC3339 */;\n changedBy: string /* ObjectID */;\n fields: string[]; // List of changed field names for quick reference\n}\nexport interface EntityDefinitionChangeEvent {\n orgId: string;\n definition?: EntityDefinition;\n action: string; // created, updated, deleted\n timestamp: string /* RFC3339 */;\n}\nexport interface EntityViewChangeEvent {\n orgId: string;\n entityName: string;\n view?: EntityView;\n action: string; // created, updated, deleted\n timestamp: string /* RFC3339 */;\n}\nexport type RecordChangeAction = string;\nexport const RecordChangeActionCreated: RecordChangeAction = \"created\";\nexport const RecordChangeActionUpdated: RecordChangeAction = \"updated\";\nexport const RecordChangeActionDeleted: RecordChangeAction = \"deleted\";\n\n//////////\n// source: subjects.go\n\nexport const EntityOrgSchemaCreate = \"entity.org.schema.create\";\nexport const EntityOrgSchemaDrop = \"entity.org.schema.drop\";\nexport const EntityDefinitionCreate = \"entity.definition.create\";\nexport const EntityDefinitionCreated = \"entity.definition.created\";\nexport const EntityDefinitionUpdate = \"entity.definition.update\";\nexport const EntityDefinitionGet = \"entity.definition.get\";\nexport const EntityDefinitionGetServer = \"entity.definition.get.server\";\nexport const EntityDefinitionList = \"entity.definition.list\";\nexport const EntityDefinitionUpdated = \"entity.definition.updated\";\nexport const EntityDefinitionDelete = \"entity.definition.delete\";\nexport const EntityDefinitionDeleted = \"entity.definition.deleted\";\nexport const EntityRecordCreate = \"entity.record.create\";\nexport const EntityRecordCreated = \"entity.record.created\";\nexport const EntityRecordGet = \"entity.record.get\";\nexport const EntityRecordQuery = \"entity.record.query\";\nexport const EntityRecordCount = \"entity.record.count\";\nexport const EntityRecordUpdate = \"entity.record.update\";\nexport const EntityRecordUpdated = \"entity.record.updated\";\nexport const EntityRecordDelete = \"entity.record.delete\";\nexport const EntityRecordDeleted = \"entity.record.deleted\";\nexport const EntityRecordsBulkCreate = \"entity.records.bulk.create\";\nexport const EntityRecordsBulkCreated = \"entity.records.bulk.created\";\nexport const EntityRecordsBulkUpdate = \"entity.records.bulk.update\";\nexport const EntityRecordsBulkUpdated = \"entity.records.bulk.updated\";\nexport const EntityRecordsBulkDelete = \"entity.records.bulk.delete\";\nexport const EntityRecordsBulkDeleted = \"entity.records.bulk.deleted\";\nexport const EntityViewCreate = \"entity.view.create\";\nexport const EntityViewCreated = \"entity.view.created\";\nexport const EntityViewUpdate = \"entity.view.update\";\nexport const EntityViewUpdated = \"entity.view.updated\";\nexport const EntityViewDelete = \"entity.view.delete\";\nexport const EntityViewDeleted = \"entity.view.deleted\";\nexport const EntityViewList = \"entity.view.list\";\n"]}
|
|
@@ -0,0 +1,204 @@
|
|
|
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; }"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkSXBB42DJjs = require('./chunk-SXBB42DJ.js');
|
|
11
|
+
|
|
12
|
+
// hooks/use-entities.ts
|
|
13
|
+
var _react = require('react');
|
|
14
|
+
function useEntities(options) {
|
|
15
|
+
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
16
|
+
const [error, setError] = _react.useState.call(void 0, null);
|
|
17
|
+
const listDefinitions = _react.useCallback.call(void 0, async () => {
|
|
18
|
+
setLoading(true);
|
|
19
|
+
setError(null);
|
|
20
|
+
try {
|
|
21
|
+
const response = await _chunkSXBB42DJjs.listEntityDefinitionsApi.call(void 0, options);
|
|
22
|
+
if (response.error) {
|
|
23
|
+
setError(response.error);
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
return _optionalChain([response, 'access', _ => _.data, 'optionalAccess', _2 => _2.definitions]) || [];
|
|
27
|
+
} catch (err) {
|
|
28
|
+
const message = err instanceof Error ? err.message : "Failed to load definitions";
|
|
29
|
+
setError(message);
|
|
30
|
+
return [];
|
|
31
|
+
} finally {
|
|
32
|
+
setLoading(false);
|
|
33
|
+
}
|
|
34
|
+
}, [options]);
|
|
35
|
+
const getDefinition = _react.useCallback.call(void 0,
|
|
36
|
+
async (entityName) => {
|
|
37
|
+
setLoading(true);
|
|
38
|
+
setError(null);
|
|
39
|
+
try {
|
|
40
|
+
const response = await _chunkSXBB42DJjs.getEntityDefinitionApi.call(void 0, entityName, options);
|
|
41
|
+
if (response.error) {
|
|
42
|
+
setError(response.error);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return _optionalChain([response, 'access', _3 => _3.data, 'optionalAccess', _4 => _4.definition]) || null;
|
|
46
|
+
} catch (err) {
|
|
47
|
+
const message = err instanceof Error ? err.message : "Failed to get definition";
|
|
48
|
+
setError(message);
|
|
49
|
+
return null;
|
|
50
|
+
} finally {
|
|
51
|
+
setLoading(false);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
[options]
|
|
55
|
+
);
|
|
56
|
+
const queryRecords = _react.useCallback.call(void 0,
|
|
57
|
+
async (entityName, query = {}) => {
|
|
58
|
+
setLoading(true);
|
|
59
|
+
setError(null);
|
|
60
|
+
try {
|
|
61
|
+
const queryParams = {
|
|
62
|
+
page: query.page || 1,
|
|
63
|
+
pageSize: query.pageSize || 20
|
|
64
|
+
};
|
|
65
|
+
if (query.filters) {
|
|
66
|
+
queryParams.filters = JSON.stringify(query.filters);
|
|
67
|
+
}
|
|
68
|
+
if (query.sortBy) {
|
|
69
|
+
queryParams.sortBy = query.sortBy;
|
|
70
|
+
}
|
|
71
|
+
if (query.sortOrder) {
|
|
72
|
+
queryParams.sortOrder = query.sortOrder;
|
|
73
|
+
}
|
|
74
|
+
const response = await _chunkSXBB42DJjs.queryEntityRecordsApi.call(void 0, entityName, queryParams, options);
|
|
75
|
+
if (response.error) {
|
|
76
|
+
setError(response.error);
|
|
77
|
+
return { records: [], total: 0, page: 1, pageSize: 20 };
|
|
78
|
+
}
|
|
79
|
+
const data = response.data;
|
|
80
|
+
if (_optionalChain([data, 'optionalAccess', _5 => _5.records, 'optionalAccess', _6 => _6.items])) {
|
|
81
|
+
return {
|
|
82
|
+
records: data.records.items,
|
|
83
|
+
total: data.records.totalCount,
|
|
84
|
+
page: data.records.currentPage,
|
|
85
|
+
pageSize: data.records.pageSize
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
records: _optionalChain([data, 'optionalAccess', _7 => _7.records]) || [],
|
|
90
|
+
total: _optionalChain([data, 'optionalAccess', _8 => _8.total]) || 0,
|
|
91
|
+
page: _optionalChain([data, 'optionalAccess', _9 => _9.page]) || 1,
|
|
92
|
+
pageSize: _optionalChain([data, 'optionalAccess', _10 => _10.pageSize]) || 20
|
|
93
|
+
};
|
|
94
|
+
} catch (err) {
|
|
95
|
+
const message = err instanceof Error ? err.message : "Failed to query records";
|
|
96
|
+
setError(message);
|
|
97
|
+
return { records: [], total: 0, page: 1, pageSize: 20 };
|
|
98
|
+
} finally {
|
|
99
|
+
setLoading(false);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
[options]
|
|
103
|
+
);
|
|
104
|
+
const getRecord = _react.useCallback.call(void 0,
|
|
105
|
+
async (entityName, recordId) => {
|
|
106
|
+
setLoading(true);
|
|
107
|
+
setError(null);
|
|
108
|
+
try {
|
|
109
|
+
const response = await _chunkSXBB42DJjs.getEntityRecordApi.call(void 0, entityName, recordId, options);
|
|
110
|
+
if (response.error) {
|
|
111
|
+
setError(response.error);
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
return _optionalChain([response, 'access', _11 => _11.data, 'optionalAccess', _12 => _12.record]) || null;
|
|
115
|
+
} catch (err) {
|
|
116
|
+
const message = err instanceof Error ? err.message : "Failed to get record";
|
|
117
|
+
setError(message);
|
|
118
|
+
return null;
|
|
119
|
+
} finally {
|
|
120
|
+
setLoading(false);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
[options]
|
|
124
|
+
);
|
|
125
|
+
const createRecord = _react.useCallback.call(void 0,
|
|
126
|
+
async (entityName, record) => {
|
|
127
|
+
setLoading(true);
|
|
128
|
+
setError(null);
|
|
129
|
+
try {
|
|
130
|
+
const response = await _chunkSXBB42DJjs.createEntityRecordApi.call(void 0, entityName, record, options);
|
|
131
|
+
if (response.error) {
|
|
132
|
+
setError(response.error);
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
return _optionalChain([response, 'access', _13 => _13.data, 'optionalAccess', _14 => _14.record]) || null;
|
|
136
|
+
} catch (err) {
|
|
137
|
+
const message = err instanceof Error ? err.message : "Failed to create record";
|
|
138
|
+
setError(message);
|
|
139
|
+
return null;
|
|
140
|
+
} finally {
|
|
141
|
+
setLoading(false);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
[options]
|
|
145
|
+
);
|
|
146
|
+
const updateRecord = _react.useCallback.call(void 0,
|
|
147
|
+
async (entityName, recordId, record) => {
|
|
148
|
+
setLoading(true);
|
|
149
|
+
setError(null);
|
|
150
|
+
try {
|
|
151
|
+
const response = await _chunkSXBB42DJjs.updateEntityRecordApi.call(void 0, entityName, recordId, record, options);
|
|
152
|
+
if (response.error) {
|
|
153
|
+
setError(response.error);
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
return _optionalChain([response, 'access', _15 => _15.data, 'optionalAccess', _16 => _16.record]) || null;
|
|
157
|
+
} catch (err) {
|
|
158
|
+
const message = err instanceof Error ? err.message : "Failed to update record";
|
|
159
|
+
setError(message);
|
|
160
|
+
return null;
|
|
161
|
+
} finally {
|
|
162
|
+
setLoading(false);
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
[options]
|
|
166
|
+
);
|
|
167
|
+
const deleteRecord = _react.useCallback.call(void 0,
|
|
168
|
+
async (entityName, recordId) => {
|
|
169
|
+
setLoading(true);
|
|
170
|
+
setError(null);
|
|
171
|
+
try {
|
|
172
|
+
const response = await _chunkSXBB42DJjs.deleteEntityRecordApi.call(void 0, entityName, recordId, options);
|
|
173
|
+
if (response.error) {
|
|
174
|
+
setError(response.error);
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
return true;
|
|
178
|
+
} catch (err) {
|
|
179
|
+
const message = err instanceof Error ? err.message : "Failed to delete record";
|
|
180
|
+
setError(message);
|
|
181
|
+
return false;
|
|
182
|
+
} finally {
|
|
183
|
+
setLoading(false);
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
[options]
|
|
187
|
+
);
|
|
188
|
+
return {
|
|
189
|
+
loading,
|
|
190
|
+
error,
|
|
191
|
+
listDefinitions,
|
|
192
|
+
getDefinition,
|
|
193
|
+
queryRecords,
|
|
194
|
+
getRecord,
|
|
195
|
+
createRecord,
|
|
196
|
+
updateRecord,
|
|
197
|
+
deleteRecord
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
exports.useEntities = useEntities;
|
|
204
|
+
//# sourceMappingURL=chunk-GQJJP4YL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/eloquent/eloquent/packages/@elqnt/entity/dist/chunk-GQJJP4YL.js","../hooks/use-entities.ts"],"names":[],"mappings":"AAAA,ylBAAY;AACZ;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACA;ACHA,8BAAsC;AAqD/B,SAAS,WAAA,CAAY,OAAA,EAA6B;AACvD,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,EAAA,EAAI,6BAAA,KAAc,CAAA;AAC5C,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,EAAA,EAAI,6BAAA,IAA4B,CAAA;AAEtD,EAAA,MAAM,gBAAA,EAAkB,gCAAA,MAAY,CAAA,EAAA,GAAyC;AAC3E,IAA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CAAS,QAAA,CAAS,KAAK,CAAA;AACvB,UAAA,OAAO,KAAA;AAAA,QACT;AACA,QAAA,OAAO,IAAA;AAAA,MACT,EAAA,MAAA,CAAS,GAAA,EAAK;AACZ,QAAA,MAAM,QAAA,EAAU,IAAA,WAAe,MAAA,EAAQ,GAAA,CAAI,QAAA,EAAU,yBAAA;AACrD,QAAA,QAAA,CAAS,OAAO,CAAA;AAChB,QAAA,OAAO,KAAA;AAAA,MACT,EAAA,QAAE;AACA,QAAA,UAAA,CAAW,KAAK,CAAA;AAAA,MAClB;AAAA,IACF,CAAA;AAAA,IACA,CAAC,OAAO;AAAA,EACV,CAAA;AAEA,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,KAAA;AAAA,IACA,eAAA;AAAA,IACA,aAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAA;AAAA,IACA,YAAA;AAAA,IACA,YAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF;ADhEA;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/eloquent/eloquent/packages/@elqnt/entity/dist/chunk-GQJJP4YL.js","sourcesContent":[null,"\"use client\";\n\n/**\n * Entity hooks for React applications\n *\n * Provides React hooks for entity CRUD operations with loading/error states.\n */\n\nimport { useState, useCallback } from \"react\";\nimport type { ApiClientOptions } from \"@elqnt/api-client\";\nimport type { EntityDefinition, EntityRecord } from \"../models\";\nimport {\n listEntityDefinitionsApi,\n getEntityDefinitionApi,\n queryEntityRecordsApi,\n getEntityRecordApi,\n createEntityRecordApi,\n updateEntityRecordApi,\n deleteEntityRecordApi,\n} from \"../api\";\n\n// =============================================================================\n// TYPES\n// =============================================================================\n\nexport type UseEntitiesOptions = ApiClientOptions;\n\nexport interface QueryOptions {\n page?: number;\n pageSize?: number;\n filters?: Record<string, unknown>;\n sortBy?: string;\n sortOrder?: \"asc\" | \"desc\";\n}\n\nexport interface QueryResult {\n records: EntityRecord[];\n total: number;\n page: number;\n pageSize: number;\n}\n\n// =============================================================================\n// USE ENTITIES HOOK\n// =============================================================================\n\n/**\n * Hook for entity CRUD operations\n *\n * @example\n * ```tsx\n * const { loading, error, queryRecords, createRecord } = useEntities({\n * baseUrl: apiGatewayUrl,\n * orgId: selectedOrgId,\n * userId: user?.id,\n * userEmail: user?.email,\n * });\n *\n * const records = await queryRecords(\"contacts\", { page: 1, pageSize: 20 });\n * ```\n */\nexport function useEntities(options: UseEntitiesOptions) {\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const listDefinitions = useCallback(async (): Promise<EntityDefinition[]> => {\n setLoading(true);\n setError(null);\n try {\n const response = await listEntityDefinitionsApi(options);\n if (response.error) {\n setError(response.error);\n return [];\n }\n return response.data?.definitions || [];\n } catch (err) {\n const message = err instanceof Error ? err.message : \"Failed to load definitions\";\n setError(message);\n return [];\n } finally {\n setLoading(false);\n }\n }, [options]);\n\n const getDefinition = useCallback(\n async (entityName: string): Promise<EntityDefinition | null> => {\n setLoading(true);\n setError(null);\n try {\n const response = await getEntityDefinitionApi(entityName, options);\n if (response.error) {\n setError(response.error);\n return null;\n }\n return response.data?.definition || null;\n } catch (err) {\n const message = err instanceof Error ? err.message : \"Failed to get definition\";\n setError(message);\n return null;\n } finally {\n setLoading(false);\n }\n },\n [options]\n );\n\n const queryRecords = useCallback(\n async (entityName: string, query: QueryOptions = {}): Promise<QueryResult> => {\n setLoading(true);\n setError(null);\n try {\n const queryParams: Record<string, unknown> = {\n page: query.page || 1,\n pageSize: query.pageSize || 20,\n };\n if (query.filters) {\n queryParams.filters = JSON.stringify(query.filters);\n }\n if (query.sortBy) {\n queryParams.sortBy = query.sortBy;\n }\n if (query.sortOrder) {\n queryParams.sortOrder = query.sortOrder;\n }\n\n const response = await queryEntityRecordsApi(entityName, queryParams, options);\n if (response.error) {\n setError(response.error);\n return { records: [], total: 0, page: 1, pageSize: 20 };\n }\n\n // Handle both direct records array and nested ListResult structure\n const data = response.data;\n if (data?.records?.items) {\n // ListEntityRecordsResponse with ListResult\n return {\n records: data.records.items,\n total: data.records.totalCount,\n page: data.records.currentPage,\n pageSize: data.records.pageSize,\n };\n }\n // Fallback for simpler response structure\n return {\n records: (data as any)?.records || [],\n total: (data as any)?.total || 0,\n page: (data as any)?.page || 1,\n pageSize: (data as any)?.pageSize || 20,\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : \"Failed to query records\";\n setError(message);\n return { records: [], total: 0, page: 1, pageSize: 20 };\n } finally {\n setLoading(false);\n }\n },\n [options]\n );\n\n const getRecord = useCallback(\n async (entityName: string, recordId: string): Promise<EntityRecord | null> => {\n setLoading(true);\n setError(null);\n try {\n const response = await getEntityRecordApi(entityName, recordId, options);\n if (response.error) {\n setError(response.error);\n return null;\n }\n return response.data?.record || null;\n } catch (err) {\n const message = err instanceof Error ? err.message : \"Failed to get record\";\n setError(message);\n return null;\n } finally {\n setLoading(false);\n }\n },\n [options]\n );\n\n const createRecord = useCallback(\n async (entityName: string, record: Partial<EntityRecord>): Promise<EntityRecord | null> => {\n setLoading(true);\n setError(null);\n try {\n const response = await createEntityRecordApi(entityName, record, options);\n if (response.error) {\n setError(response.error);\n return null;\n }\n return response.data?.record || null;\n } catch (err) {\n const message = err instanceof Error ? err.message : \"Failed to create record\";\n setError(message);\n return null;\n } finally {\n setLoading(false);\n }\n },\n [options]\n );\n\n const updateRecord = useCallback(\n async (\n entityName: string,\n recordId: string,\n record: Partial<EntityRecord>\n ): Promise<EntityRecord | null> => {\n setLoading(true);\n setError(null);\n try {\n const response = await updateEntityRecordApi(entityName, recordId, record, options);\n if (response.error) {\n setError(response.error);\n return null;\n }\n return response.data?.record || null;\n } catch (err) {\n const message = err instanceof Error ? err.message : \"Failed to update record\";\n setError(message);\n return null;\n } finally {\n setLoading(false);\n }\n },\n [options]\n );\n\n const deleteRecord = useCallback(\n async (entityName: string, recordId: string): Promise<boolean> => {\n setLoading(true);\n setError(null);\n try {\n const response = await deleteEntityRecordApi(entityName, recordId, options);\n if (response.error) {\n setError(response.error);\n return false;\n }\n return true;\n } catch (err) {\n const message = err instanceof Error ? err.message : \"Failed to delete record\";\n setError(message);\n return false;\n } finally {\n setLoading(false);\n }\n },\n [options]\n );\n\n return {\n loading,\n error,\n listDefinitions,\n getDefinition,\n queryRecords,\n getRecord,\n createRecord,\n updateRecord,\n deleteRecord,\n };\n}\n"]}
|