@medyll/idae-machine 0.119.0 → 0.121.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/db/dbSchema.d.ts +1 -1
- package/dist/db/testDbSchema.d.ts +1 -1
- package/dist/form/CollectionFks.svelte +1 -1
- package/dist/form/CollectionReverseFks.svelte +1 -1
- package/dist/form/CreateUpdate.svelte +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +8 -8
- package/dist/main/machine.d.ts +13 -10
- package/dist/main/machine.js +16 -8
- package/dist/{db/dbFields.d.ts → main/machineDb.d.ts} +46 -24
- package/dist/{db/dbFields.js → main/machineDb.js} +71 -57
- package/package.json +4 -2
package/dist/db/dbSchema.d.ts
CHANGED
|
@@ -453,4 +453,4 @@ export declare const schemeModelDb: {
|
|
|
453
453
|
};
|
|
454
454
|
export declare const schemeModel: IdbqModel;
|
|
455
455
|
export type DataModelFinal = DbDataModelTs<typeof schemeModelDb>;
|
|
456
|
-
export declare const idbql:
|
|
456
|
+
export declare const idbql: import("@medyll/idae-idbql").ReadonlyCollections<IdbqModel<Record<string, Record<string, any>>>>, idbqlState: import("@medyll/idae-idbql").StateCollections<IdbqModel<Record<string, Record<string, any>>>>, idbDatabase: import("@medyll/idae-idbql").IdbqlIndexedCore<IdbqModel<Record<string, Record<string, any>>>>, idbqModel: IdbqModel<Record<string, Record<string, any>>>;
|
|
@@ -53,4 +53,4 @@ export declare const schemeModelTestDb: {
|
|
|
53
53
|
};
|
|
54
54
|
export declare const schemeModelTest: IdbqModel;
|
|
55
55
|
export type DataModelTestFinal = DbDataModelTs<typeof schemeModelTestDb>;
|
|
56
|
-
export declare const idbql:
|
|
56
|
+
export declare const idbql: import("@medyll/idae-idbql").ReadonlyCollections<IdbqModel<Record<string, Record<string, any>>>>, idbqlState: import("@medyll/idae-idbql").StateCollections<IdbqModel<Record<string, Record<string, any>>>>, idbDatabase: import("@medyll/idae-idbql").IdbqlIndexedCore<IdbqModel<Record<string, Record<string, any>>>>, idbqModel: IdbqModel<Record<string, Record<string, any>>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { IDbBase } from '../
|
|
2
|
+
import { IDbBase } from '../main/machineDb.js';
|
|
3
3
|
import { schemeModel, idbqlState } from '../db/dbSchema.js';
|
|
4
4
|
import type { TplCollectionName, Where } from '@medyll/idae-idbql';
|
|
5
5
|
import { Looper } from '@medyll/idae-slotui-svelte';
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
-->
|
|
16
16
|
<script lang="ts">
|
|
17
|
-
import { IDbBase } from '../
|
|
17
|
+
import { IDbBase } from '../main/machineDb.js';
|
|
18
18
|
import { schemeModel, idbqlState } from '../db/dbSchema';
|
|
19
19
|
import type { Tpl, TplCollectionName, Where } from '@medyll/idae-idbql';
|
|
20
20
|
import { Looper } from '@medyll/idae-slotui-svelte';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
-->
|
|
5
5
|
|
|
6
6
|
<script lang="ts" generics="COL = Record<string,any>">
|
|
7
|
-
import { IDbFormValidate } from '../
|
|
7
|
+
import { IDbFormValidate } from '../main/machineDb.js';
|
|
8
8
|
import type { CreateUpdateProps } from './types';
|
|
9
9
|
import CollectionReverseFks from './CollectionReverseFks.svelte';
|
|
10
10
|
import FieldInput from './FieldValue.svelte';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export * from './types/appschemeTypes.js';
|
|
2
|
+
export * from './main/machineDb.js';
|
|
3
|
+
export * from './main/machineDb.spec.js';
|
|
2
4
|
export * from './main/machine.js';
|
|
3
5
|
export * from './main/machine.spec.js';
|
|
6
|
+
export { default as Skeleton } from './fragments/Skeleton.svelte';
|
|
7
|
+
export { default as Selector } from './fragments/Selector.svelte';
|
|
8
|
+
export { default as List } from './fragments/List.svelte';
|
|
9
|
+
export { default as InfoLine } from './fragments/InfoLine.svelte';
|
|
10
|
+
export { default as Frame } from './fragments/Frame.svelte';
|
|
11
|
+
export { default as Confirm } from './fragments/Confirm.svelte';
|
|
4
12
|
export * from './form/types.js';
|
|
5
13
|
export { default as FieldValue } from './form/FieldValue.svelte';
|
|
6
14
|
export { default as FieldInPlace } from './form/FieldInPlace.svelte';
|
|
@@ -14,19 +22,11 @@ export { default as CollectionList } from './form/CollectionList.svelte';
|
|
|
14
22
|
export { default as CollectionFks } from './form/CollectionFks.svelte';
|
|
15
23
|
export { default as CollectionFieldGuess } from './form/CollectionFieldGuess.svelte';
|
|
16
24
|
export { default as CollectionButton } from './form/CollectionButton.svelte';
|
|
17
|
-
export { default as Skeleton } from './fragments/Skeleton.svelte';
|
|
18
|
-
export { default as Selector } from './fragments/Selector.svelte';
|
|
19
|
-
export { default as List } from './fragments/List.svelte';
|
|
20
|
-
export { default as InfoLine } from './fragments/InfoLine.svelte';
|
|
21
|
-
export { default as Frame } from './fragments/Frame.svelte';
|
|
22
|
-
export { default as Confirm } from './fragments/Confirm.svelte';
|
|
23
25
|
export * from './db/types.js';
|
|
24
26
|
export * from './db/testDbSchema.js';
|
|
25
27
|
export * from './db/dbSchema.js';
|
|
26
28
|
export * from './db/dbSchema.spec.js';
|
|
27
29
|
export * from './db/dbFormValidate.spec.js';
|
|
28
|
-
export * from './db/dbFields.js';
|
|
29
|
-
export * from './db/dbFields.spec.js';
|
|
30
30
|
export * from './db/dbCollectionValues.spec.js';
|
|
31
31
|
export * from './db/dbCollectionFieldValues.spec.js';
|
|
32
32
|
export * from './db/dbCollectionFieldForge.spec.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
// auto exports of entry components
|
|
2
2
|
export * from './types/appschemeTypes.js';
|
|
3
|
+
export * from './main/machineDb.js';
|
|
4
|
+
export * from './main/machineDb.spec.js';
|
|
3
5
|
export * from './main/machine.js';
|
|
4
6
|
export * from './main/machine.spec.js';
|
|
7
|
+
export { default as Skeleton } from './fragments/Skeleton.svelte';
|
|
8
|
+
export { default as Selector } from './fragments/Selector.svelte';
|
|
9
|
+
export { default as List } from './fragments/List.svelte';
|
|
10
|
+
export { default as InfoLine } from './fragments/InfoLine.svelte';
|
|
11
|
+
export { default as Frame } from './fragments/Frame.svelte';
|
|
12
|
+
export { default as Confirm } from './fragments/Confirm.svelte';
|
|
5
13
|
export * from './form/types.js';
|
|
6
14
|
export { default as FieldValue } from './form/FieldValue.svelte';
|
|
7
15
|
export { default as FieldInPlace } from './form/FieldInPlace.svelte';
|
|
@@ -15,19 +23,11 @@ export { default as CollectionList } from './form/CollectionList.svelte';
|
|
|
15
23
|
export { default as CollectionFks } from './form/CollectionFks.svelte';
|
|
16
24
|
export { default as CollectionFieldGuess } from './form/CollectionFieldGuess.svelte';
|
|
17
25
|
export { default as CollectionButton } from './form/CollectionButton.svelte';
|
|
18
|
-
export { default as Skeleton } from './fragments/Skeleton.svelte';
|
|
19
|
-
export { default as Selector } from './fragments/Selector.svelte';
|
|
20
|
-
export { default as List } from './fragments/List.svelte';
|
|
21
|
-
export { default as InfoLine } from './fragments/InfoLine.svelte';
|
|
22
|
-
export { default as Frame } from './fragments/Frame.svelte';
|
|
23
|
-
export { default as Confirm } from './fragments/Confirm.svelte';
|
|
24
26
|
export * from './db/types.js';
|
|
25
27
|
export * from './db/testDbSchema.js';
|
|
26
28
|
export * from './db/dbSchema.js';
|
|
27
29
|
export * from './db/dbSchema.spec.js';
|
|
28
30
|
export * from './db/dbFormValidate.spec.js';
|
|
29
|
-
export * from './db/dbFields.js';
|
|
30
|
-
export * from './db/dbFields.spec.js';
|
|
31
31
|
export * from './db/dbCollectionValues.spec.js';
|
|
32
32
|
export * from './db/dbCollectionFieldValues.spec.js';
|
|
33
33
|
export * from './db/dbCollectionFieldForge.spec.js';
|
package/dist/main/machine.d.ts
CHANGED
|
@@ -24,14 +24,13 @@
|
|
|
24
24
|
* // Access the IDBQL data model
|
|
25
25
|
* const model = machine.idbqModel;
|
|
26
26
|
*/
|
|
27
|
-
import { IDbBase } from '
|
|
27
|
+
import { IDbBase } from './machineDb.js';
|
|
28
28
|
import { createIdbqDb, type IdbqModel } from '@medyll/idae-idbql';
|
|
29
29
|
/**
|
|
30
30
|
* Machine: main entry point for managing the IDBQL connection and centralized data access.
|
|
31
31
|
*/
|
|
32
32
|
export declare class Machine {
|
|
33
33
|
/**
|
|
34
|
-
|
|
35
34
|
* IDBQL (readonly collections instance)
|
|
36
35
|
*/
|
|
37
36
|
_idbql: ReturnType<ReturnType<typeof createIdbqDb>["create"]>["idbql"] | undefined;
|
|
@@ -50,7 +49,7 @@ export declare class Machine {
|
|
|
50
49
|
/**
|
|
51
50
|
* Centralized access to schema and collection logic
|
|
52
51
|
*/
|
|
53
|
-
|
|
52
|
+
_idbbase: IDbBase;
|
|
54
53
|
/**
|
|
55
54
|
* Database name
|
|
56
55
|
*/
|
|
@@ -66,7 +65,7 @@ export declare class Machine {
|
|
|
66
65
|
/**
|
|
67
66
|
* Main constructor
|
|
68
67
|
*/
|
|
69
|
-
constructor();
|
|
68
|
+
constructor(dbName?: string, version?: number, model?: IdbqModel);
|
|
70
69
|
init(options?: {
|
|
71
70
|
dbName?: string;
|
|
72
71
|
version?: number;
|
|
@@ -79,25 +78,29 @@ export declare class Machine {
|
|
|
79
78
|
private createCollections;
|
|
80
79
|
private createStore;
|
|
81
80
|
/**
|
|
82
|
-
* Get the
|
|
81
|
+
* Get the IDbBase (schema logic) instance
|
|
83
82
|
*/
|
|
84
83
|
get collections(): IDbBase;
|
|
85
84
|
/**
|
|
86
85
|
* IDBQL (readonly) instance
|
|
87
86
|
*/
|
|
88
|
-
get idbql(): any;
|
|
87
|
+
get idbql(): import("@medyll/idae-idbql").ReadonlyCollections<IdbqModel<Record<string, Record<string, any>>>> | undefined;
|
|
89
88
|
/**
|
|
90
|
-
* IDBQL (stateful) instance
|
|
89
|
+
* IDBQL (stateful) instance , old name was idbqlState => store
|
|
91
90
|
*/
|
|
92
|
-
get store(): any
|
|
91
|
+
get store(): import("@medyll/idae-idbql").StateCollections<IdbqModel<Record<string, Record<string, any>>>>;
|
|
92
|
+
/**
|
|
93
|
+
* Direct getter for idbqlState (for test compatibility)
|
|
94
|
+
*/
|
|
95
|
+
get idbqlState(): import("@medyll/idae-idbql").StateCollections<IdbqModel<Record<string, Record<string, any>>>>;
|
|
93
96
|
/**
|
|
94
97
|
* IndexedDB (core) instance
|
|
95
98
|
* @deprecated
|
|
96
99
|
*/
|
|
97
|
-
get indexedb(): any;
|
|
100
|
+
get indexedb(): import("@medyll/idae-idbql").IdbqlIndexedCore<IdbqModel<Record<string, Record<string, any>>>> | undefined;
|
|
98
101
|
/**
|
|
99
102
|
* IDBQL data model instance
|
|
100
103
|
*/
|
|
101
|
-
get idbqModel(): any;
|
|
104
|
+
get idbqModel(): IdbqModel<Record<string, Record<string, any>>> | undefined;
|
|
102
105
|
}
|
|
103
106
|
export declare const machine: Machine;
|
package/dist/main/machine.js
CHANGED
|
@@ -24,14 +24,13 @@
|
|
|
24
24
|
* // Access the IDBQL data model
|
|
25
25
|
* const model = machine.idbqModel;
|
|
26
26
|
*/
|
|
27
|
-
import { IDbBase } from '
|
|
27
|
+
import { IDbBase } from './machineDb.js';
|
|
28
28
|
import { createIdbqDb } from '@medyll/idae-idbql';
|
|
29
29
|
/**
|
|
30
30
|
* Machine: main entry point for managing the IDBQL connection and centralized data access.
|
|
31
31
|
*/
|
|
32
32
|
export class Machine {
|
|
33
33
|
/**
|
|
34
|
-
|
|
35
34
|
* IDBQL (readonly collections instance)
|
|
36
35
|
*/
|
|
37
36
|
_idbql;
|
|
@@ -50,7 +49,7 @@ export class Machine {
|
|
|
50
49
|
/**
|
|
51
50
|
* Centralized access to schema and collection logic
|
|
52
51
|
*/
|
|
53
|
-
|
|
52
|
+
_idbbase;
|
|
54
53
|
/**
|
|
55
54
|
* Database name
|
|
56
55
|
*/
|
|
@@ -66,7 +65,10 @@ export class Machine {
|
|
|
66
65
|
/**
|
|
67
66
|
* Main constructor
|
|
68
67
|
*/
|
|
69
|
-
constructor() {
|
|
68
|
+
constructor(dbName, version, model) {
|
|
69
|
+
this._dbName = dbName ?? '';
|
|
70
|
+
this._version = version ?? 1;
|
|
71
|
+
this._model = model ?? undefined;
|
|
70
72
|
}
|
|
71
73
|
init(options) {
|
|
72
74
|
this._dbName = options?.dbName ?? this._dbName;
|
|
@@ -84,7 +86,7 @@ export class Machine {
|
|
|
84
86
|
if (!this._model) {
|
|
85
87
|
throw new Error('Data model is not defined');
|
|
86
88
|
}
|
|
87
|
-
this.
|
|
89
|
+
this._idbbase = new IDbBase(this._model);
|
|
88
90
|
}
|
|
89
91
|
createStore() {
|
|
90
92
|
if (!this._model || !this._dbName || !this._version) {
|
|
@@ -98,10 +100,10 @@ export class Machine {
|
|
|
98
100
|
this._idbqModel = idbqModel;
|
|
99
101
|
}
|
|
100
102
|
/**
|
|
101
|
-
* Get the
|
|
103
|
+
* Get the IDbBase (schema logic) instance
|
|
102
104
|
*/
|
|
103
105
|
get collections() {
|
|
104
|
-
return this.
|
|
106
|
+
return this._idbbase;
|
|
105
107
|
}
|
|
106
108
|
/**
|
|
107
109
|
* IDBQL (readonly) instance
|
|
@@ -110,11 +112,17 @@ export class Machine {
|
|
|
110
112
|
return this._idbql;
|
|
111
113
|
}
|
|
112
114
|
/**
|
|
113
|
-
* IDBQL (stateful) instance
|
|
115
|
+
* IDBQL (stateful) instance , old name was idbqlState => store
|
|
114
116
|
*/
|
|
115
117
|
get store() {
|
|
116
118
|
return this._idbqlState;
|
|
117
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Direct getter for idbqlState (for test compatibility)
|
|
122
|
+
*/
|
|
123
|
+
get idbqlState() {
|
|
124
|
+
return this._idbqlState;
|
|
125
|
+
}
|
|
118
126
|
/**
|
|
119
127
|
* IndexedDB (core) instance
|
|
120
128
|
* @deprecated
|
|
@@ -38,22 +38,6 @@ export type IDbForge = {
|
|
|
38
38
|
fieldArgs?: IDbForgeArgs | undefined;
|
|
39
39
|
is: any;
|
|
40
40
|
};
|
|
41
|
-
export declare class IDbCollection {
|
|
42
|
-
collection: TplCollectionName;
|
|
43
|
-
_dbCollections: IDbBase;
|
|
44
|
-
constructor(collection: TplCollectionName, dbCollections: IDbBase);
|
|
45
|
-
getCollectionModelTemplate(): Tpl;
|
|
46
|
-
getCollectionModelTemplateFks(): Tpl;
|
|
47
|
-
getIndexName(): any;
|
|
48
|
-
collectionValues(): IDbCollectionValues<any>;
|
|
49
|
-
collectionFieldValues<T extends Record<string, any>>(data: T): IDbCollectionFieldValues<T>;
|
|
50
|
-
fieldForge<T extends Record<string, any>>(fieldName: keyof T, data: T): IDbCollectionFieldForge<T>;
|
|
51
|
-
getFormValidate(): IDbFormValidate;
|
|
52
|
-
fks(): {
|
|
53
|
-
[collection: string]: Tpl;
|
|
54
|
-
};
|
|
55
|
-
reverseFks(): Record<string, any>;
|
|
56
|
-
}
|
|
57
41
|
/**
|
|
58
42
|
* Central class for parsing, introspecting, and extracting metadata from the database schema.
|
|
59
43
|
* Provides methods to access collections, templates, fields, foreign keys, and type information.
|
|
@@ -61,6 +45,20 @@ export declare class IDbCollection {
|
|
|
61
45
|
*/
|
|
62
46
|
export declare class IDbBase {
|
|
63
47
|
#private;
|
|
48
|
+
/**
|
|
49
|
+
* Public: Get the foreign keys (fks) object for a collection.
|
|
50
|
+
*/
|
|
51
|
+
getCollectionTemplateFks(collection: TplCollectionName): {
|
|
52
|
+
[x: string]: {
|
|
53
|
+
code: string;
|
|
54
|
+
multiple: boolean;
|
|
55
|
+
rules: import("@medyll/idae-idbql").CombinedArgs;
|
|
56
|
+
} | undefined;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Public: Get the value of the index field for a given data object.
|
|
60
|
+
*/
|
|
61
|
+
indexValue(collection: TplCollectionName, data: object): unknown;
|
|
64
62
|
/**
|
|
65
63
|
* The database model (schema) used for introspection.
|
|
66
64
|
*/
|
|
@@ -110,11 +108,13 @@ export declare class IDbBase {
|
|
|
110
108
|
getCollectionModel(collection: TplCollectionName): CollectionModel;
|
|
111
109
|
getCollectionModelTemplate(collection: TplCollectionName): Tpl;
|
|
112
110
|
getCollectionModelTemplateFks(collection: TplCollectionName): Tpl["fks"];
|
|
113
|
-
getIndexName(collection: TplCollectionName):
|
|
111
|
+
getIndexName(collection: TplCollectionName): string;
|
|
114
112
|
getCollectionTemplateFields(collection: TplCollectionName): TplFields;
|
|
115
113
|
getTemplatePresentation(collection: TplCollectionName): string;
|
|
116
114
|
getFkFieldType(string: `${string}.${string}`): IDbFieldRules | undefined;
|
|
117
|
-
getFkTemplateFields(string: `${string}.${string}`):
|
|
115
|
+
getFkTemplateFields(string: `${string}.${string}`): {
|
|
116
|
+
[x: string]: import("@medyll/idae-idbql").TplFieldRules;
|
|
117
|
+
};
|
|
118
118
|
private testIs;
|
|
119
119
|
is(what: 'array' | 'object' | 'fk' | 'primitive', fieldRule: IDbFieldRules): Partial<IDbForge>;
|
|
120
120
|
extract(type: 'array' | 'object' | 'fk' | 'primitive', fieldRule: IDbFieldRules): Partial<IDbForge>;
|
|
@@ -125,6 +125,28 @@ export declare class IDbBase {
|
|
|
125
125
|
iterateArrayField(collection: TplCollectionName, fieldName: keyof TplFields, data: any[]): IDbForge[];
|
|
126
126
|
iterateObjectField(collection: TplCollectionName, fieldName: keyof TplFields, data: Record<string, any>): IDbForge[];
|
|
127
127
|
}
|
|
128
|
+
export declare class IDbCollection {
|
|
129
|
+
collection: TplCollectionName;
|
|
130
|
+
_dbCollections: IDbBase;
|
|
131
|
+
constructor(collection: TplCollectionName, dbCollections: IDbBase);
|
|
132
|
+
getCollectionModelTemplate(): Tpl;
|
|
133
|
+
getCollectionModelTemplateFks(): {
|
|
134
|
+
[x: string]: {
|
|
135
|
+
code: string;
|
|
136
|
+
multiple: boolean;
|
|
137
|
+
rules: import("@medyll/idae-idbql").CombinedArgs;
|
|
138
|
+
} | undefined;
|
|
139
|
+
};
|
|
140
|
+
getIndexName(): string;
|
|
141
|
+
collectionValues(): IDbCollectionValues<any>;
|
|
142
|
+
collectionFieldValues<T extends Record<string, any>>(data: T): IDbCollectionFieldValues<T>;
|
|
143
|
+
fieldForge<T extends Record<string, any>>(fieldName: keyof T, data: T): IDbCollectionFieldForge<T>;
|
|
144
|
+
getFormValidate(): IDbFormValidate;
|
|
145
|
+
fks(): {
|
|
146
|
+
[collection: string]: Tpl;
|
|
147
|
+
};
|
|
148
|
+
reverseFks(): Record<string, any>;
|
|
149
|
+
}
|
|
128
150
|
/**
|
|
129
151
|
* IDbCollectionValues
|
|
130
152
|
*
|
|
@@ -132,7 +154,7 @@ export declare class IDbBase {
|
|
|
132
154
|
* It is designed for dynamic UI rendering, presentation logic, and metadata extraction for form generation in schema-driven applications.
|
|
133
155
|
*
|
|
134
156
|
* Main responsibilities:
|
|
135
|
-
* - Holds a reference to the collection name and the schema (
|
|
157
|
+
* - Holds a reference to the collection name and the schema (IDbBase).
|
|
136
158
|
* - Provides methods to format field values according to their type (number, text, array, object, etc.).
|
|
137
159
|
* - Supplies presentation logic for displaying records (e.g., presentation string, index value).
|
|
138
160
|
* - Offers input attribute generation for forms (inputDataSet).
|
|
@@ -146,15 +168,15 @@ export declare class IDbBase {
|
|
|
146
168
|
* const formatted = values.format('name', agentData); // formatted field value
|
|
147
169
|
* const attrs = values.getInputDataSet('name', agentData); // input attributes for forms
|
|
148
170
|
*
|
|
149
|
-
* This class is typically used via
|
|
171
|
+
* This class is typically used via IDbBase.getCollectionValues for shared instance management.
|
|
150
172
|
* @template T - The type of the data object for the collection.
|
|
151
173
|
*/
|
|
152
174
|
export declare class IDbCollectionValues<T extends Record<string, any>> {
|
|
153
175
|
#private;
|
|
154
176
|
/**
|
|
155
|
-
* The
|
|
177
|
+
* The IDbBase instance used for schema introspection.
|
|
156
178
|
*/
|
|
157
|
-
|
|
179
|
+
idbBase: IDbBase;
|
|
158
180
|
/**
|
|
159
181
|
* The collection name this instance operates on.
|
|
160
182
|
*/
|
|
@@ -163,7 +185,7 @@ export declare class IDbCollectionValues<T extends Record<string, any>> {
|
|
|
163
185
|
* Create a new IDbCollectionValues instance for a given collection.
|
|
164
186
|
* @param collectionName The collection name.
|
|
165
187
|
*/
|
|
166
|
-
constructor(collectionName: TplCollectionName,
|
|
188
|
+
constructor(collectionName: TplCollectionName, idbBase?: IDbBase);
|
|
167
189
|
presentation(data: Record<string, any>): string;
|
|
168
190
|
/**
|
|
169
191
|
* Get the value of the index field for a data object.
|
|
@@ -233,7 +255,7 @@ export declare class IDbCollectionFieldValues<T extends Record<string, any>> {
|
|
|
233
255
|
* const inputType = forge.htmlInputType; // e.g. 'text', 'area', 'email', etc.
|
|
234
256
|
* const meta = forge.forge; // IDbForge metadata for the field
|
|
235
257
|
*
|
|
236
|
-
* This class is typically used via
|
|
258
|
+
* This class is typically used via IDbBase.getCollectionFieldForge for shared instance management.
|
|
237
259
|
*/
|
|
238
260
|
export declare class IDbCollectionFieldForge<T extends Record<string, any>> {
|
|
239
261
|
#private;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
path: D:\boulot\python\wollama\src\lib\db\dbFields.ts
|
|
3
3
|
*/
|
|
4
|
-
import { schemeModel } from '
|
|
4
|
+
import { schemeModel } from '../db/dbSchema.js';
|
|
5
5
|
export var enumPrimitive;
|
|
6
6
|
(function (enumPrimitive) {
|
|
7
7
|
enumPrimitive["id"] = "id";
|
|
@@ -46,48 +46,26 @@ class IDbError extends Error {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
/* Single collection relies on IDbCollections */
|
|
50
|
-
export class IDbCollection {
|
|
51
|
-
collection;
|
|
52
|
-
_dbCollections;
|
|
53
|
-
constructor(collection, dbCollections) {
|
|
54
|
-
this.collection = collection;
|
|
55
|
-
this._dbCollections = dbCollections;
|
|
56
|
-
}
|
|
57
|
-
getCollectionModelTemplate() {
|
|
58
|
-
return this._dbCollections.getCollectionModelTemplate(this.collection);
|
|
59
|
-
}
|
|
60
|
-
getCollectionModelTemplateFks() {
|
|
61
|
-
return this._dbCollections.getCollectionModelTemplateFks(this.collection);
|
|
62
|
-
}
|
|
63
|
-
getIndexName() {
|
|
64
|
-
return this._dbCollections.getIndexName(this.collection);
|
|
65
|
-
}
|
|
66
|
-
collectionValues() {
|
|
67
|
-
return this._dbCollections.collectionValues(this.collection);
|
|
68
|
-
}
|
|
69
|
-
collectionFieldValues(data) {
|
|
70
|
-
return this._dbCollections.collectionFieldValues(this.collection, data);
|
|
71
|
-
}
|
|
72
|
-
fieldForge(fieldName, data) {
|
|
73
|
-
return this._dbCollections.collectionFieldForge(this.collection, fieldName, data);
|
|
74
|
-
}
|
|
75
|
-
getFormValidate() {
|
|
76
|
-
return this._dbCollections.formValidate(this.collection);
|
|
77
|
-
}
|
|
78
|
-
fks() {
|
|
79
|
-
return this._dbCollections.fks(this.collection);
|
|
80
|
-
}
|
|
81
|
-
reverseFks() {
|
|
82
|
-
return this._dbCollections.reverseFks(this.collection);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
49
|
/**
|
|
86
50
|
* Central class for parsing, introspecting, and extracting metadata from the database schema.
|
|
87
51
|
* Provides methods to access collections, templates, fields, foreign keys, and type information.
|
|
88
52
|
* Used for dynamic UI generation, validation, and schema-driven logic.
|
|
89
53
|
*/
|
|
90
54
|
export class IDbBase {
|
|
55
|
+
/**
|
|
56
|
+
* Public: Get the foreign keys (fks) object for a collection.
|
|
57
|
+
*/
|
|
58
|
+
getCollectionTemplateFks(collection) {
|
|
59
|
+
return this.getCollectionModelTemplateFks(collection);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Public: Get the value of the index field for a given data object.
|
|
63
|
+
*/
|
|
64
|
+
indexValue(collection, data) {
|
|
65
|
+
const indexName = this.getIndexName(collection);
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
return data && typeof data === 'object' && indexName && data[indexName];
|
|
68
|
+
}
|
|
91
69
|
/**
|
|
92
70
|
* The database model (schema) used for introspection.
|
|
93
71
|
*/
|
|
@@ -309,6 +287,42 @@ export class IDbBase {
|
|
|
309
287
|
return Object.keys(data).map((key) => ({ ...fieldInfo, fieldName: `${String(fieldName)}.${key}` }));
|
|
310
288
|
}
|
|
311
289
|
}
|
|
290
|
+
/* Single collection relies on IDbBase */
|
|
291
|
+
export class IDbCollection {
|
|
292
|
+
collection;
|
|
293
|
+
_dbCollections;
|
|
294
|
+
constructor(collection, dbCollections) {
|
|
295
|
+
this.collection = collection;
|
|
296
|
+
this._dbCollections = dbCollections;
|
|
297
|
+
}
|
|
298
|
+
getCollectionModelTemplate() {
|
|
299
|
+
return this._dbCollections.getCollectionModelTemplate(this.collection);
|
|
300
|
+
}
|
|
301
|
+
getCollectionModelTemplateFks() {
|
|
302
|
+
return this._dbCollections.getCollectionModelTemplateFks(this.collection);
|
|
303
|
+
}
|
|
304
|
+
getIndexName() {
|
|
305
|
+
return this._dbCollections.getIndexName(this.collection);
|
|
306
|
+
}
|
|
307
|
+
collectionValues() {
|
|
308
|
+
return this._dbCollections.collectionValues(this.collection);
|
|
309
|
+
}
|
|
310
|
+
collectionFieldValues(data) {
|
|
311
|
+
return this._dbCollections.collectionFieldValues(this.collection, data);
|
|
312
|
+
}
|
|
313
|
+
fieldForge(fieldName, data) {
|
|
314
|
+
return this._dbCollections.collectionFieldForge(this.collection, fieldName, data);
|
|
315
|
+
}
|
|
316
|
+
getFormValidate() {
|
|
317
|
+
return this._dbCollections.formValidate(this.collection);
|
|
318
|
+
}
|
|
319
|
+
fks() {
|
|
320
|
+
return this._dbCollections.fks(this.collection);
|
|
321
|
+
}
|
|
322
|
+
reverseFks() {
|
|
323
|
+
return this._dbCollections.reverseFks(this.collection);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
312
326
|
/**
|
|
313
327
|
* IDbCollectionValues
|
|
314
328
|
*
|
|
@@ -316,7 +330,7 @@ export class IDbBase {
|
|
|
316
330
|
* It is designed for dynamic UI rendering, presentation logic, and metadata extraction for form generation in schema-driven applications.
|
|
317
331
|
*
|
|
318
332
|
* Main responsibilities:
|
|
319
|
-
* - Holds a reference to the collection name and the schema (
|
|
333
|
+
* - Holds a reference to the collection name and the schema (IDbBase).
|
|
320
334
|
* - Provides methods to format field values according to their type (number, text, array, object, etc.).
|
|
321
335
|
* - Supplies presentation logic for displaying records (e.g., presentation string, index value).
|
|
322
336
|
* - Offers input attribute generation for forms (inputDataSet).
|
|
@@ -330,14 +344,14 @@ export class IDbBase {
|
|
|
330
344
|
* const formatted = values.format('name', agentData); // formatted field value
|
|
331
345
|
* const attrs = values.getInputDataSet('name', agentData); // input attributes for forms
|
|
332
346
|
*
|
|
333
|
-
* This class is typically used via
|
|
347
|
+
* This class is typically used via IDbBase.getCollectionValues for shared instance management.
|
|
334
348
|
* @template T - The type of the data object for the collection.
|
|
335
349
|
*/
|
|
336
350
|
export class IDbCollectionValues {
|
|
337
351
|
/**
|
|
338
|
-
* The
|
|
352
|
+
* The IDbBase instance used for schema introspection.
|
|
339
353
|
*/
|
|
340
|
-
|
|
354
|
+
idbBase;
|
|
341
355
|
/**
|
|
342
356
|
* The collection name this instance operates on.
|
|
343
357
|
*/
|
|
@@ -346,14 +360,14 @@ export class IDbCollectionValues {
|
|
|
346
360
|
* Create a new IDbCollectionValues instance for a given collection.
|
|
347
361
|
* @param collectionName The collection name.
|
|
348
362
|
*/
|
|
349
|
-
constructor(collectionName,
|
|
363
|
+
constructor(collectionName, idbBase) {
|
|
350
364
|
this.collectionName = collectionName;
|
|
351
|
-
this.
|
|
365
|
+
this.idbBase = idbBase ?? new IDbBase();
|
|
352
366
|
}
|
|
353
367
|
presentation(data) {
|
|
354
368
|
try {
|
|
355
369
|
this.#checkError(!this.#checkAccess(), 'Access denied', 'ACCESS_DENIED');
|
|
356
|
-
const presentation = this.
|
|
370
|
+
const presentation = this.idbBase.getTemplatePresentation(this.collectionName);
|
|
357
371
|
this.#checkError(!presentation, 'Presentation template not found', 'TEMPLATE_NOT_FOUND');
|
|
358
372
|
const fields = presentation.split(' ');
|
|
359
373
|
return fields
|
|
@@ -376,7 +390,7 @@ export class IDbCollectionValues {
|
|
|
376
390
|
indexValue(data) {
|
|
377
391
|
try {
|
|
378
392
|
this.#checkError(!this.#checkAccess(), 'Access denied', 'ACCESS_DENIED');
|
|
379
|
-
const indexName = this.
|
|
393
|
+
const indexName = this.idbBase.getIndexName(this.collectionName);
|
|
380
394
|
this.#checkError(!indexName, 'Index not found for collection', 'INDEX_NOT_FOUND');
|
|
381
395
|
this.#checkError(!(indexName in data), `Index field ${indexName} not found in data`, 'FIELD_NOT_FOUND');
|
|
382
396
|
return data[indexName];
|
|
@@ -396,7 +410,7 @@ export class IDbCollectionValues {
|
|
|
396
410
|
try {
|
|
397
411
|
this.#checkError(!this.#checkAccess(), 'Access denied', 'ACCESS_DENIED');
|
|
398
412
|
this.#checkError(!(fieldName in data), `Field ${String(fieldName)} not found in data`, 'FIELD_NOT_FOUND');
|
|
399
|
-
const fieldInfo = this.
|
|
413
|
+
const fieldInfo = this.idbBase.parseCollectionFieldName(this.collectionName, fieldName);
|
|
400
414
|
this.#checkError(!fieldInfo, `Field ${String(fieldName)} not found in collection`, 'FIELD_NOT_FOUND');
|
|
401
415
|
switch (fieldInfo?.fieldType) {
|
|
402
416
|
case 'number':
|
|
@@ -424,10 +438,10 @@ export class IDbCollectionValues {
|
|
|
424
438
|
* @returns An object with data-* attributes for the field.
|
|
425
439
|
*/
|
|
426
440
|
getInputDataSet(fieldName, data) {
|
|
427
|
-
const fieldInfo = this.
|
|
441
|
+
const fieldInfo = this.idbBase.parseCollectionFieldName(this.collectionName, fieldName);
|
|
428
442
|
const fieldType = fieldInfo?.fieldType ?? '';
|
|
429
443
|
const fieldArgs = fieldInfo?.fieldArgs?.join(' ') ?? '';
|
|
430
|
-
const indexName = this.
|
|
444
|
+
const indexName = this.idbBase.getIndexName(this.collectionName);
|
|
431
445
|
return {
|
|
432
446
|
'data-collection': this.collectionName,
|
|
433
447
|
'data-collectionId': indexName && data?.[indexName] !== undefined ? String(data?.[indexName]) : '',
|
|
@@ -443,7 +457,7 @@ export class IDbCollectionValues {
|
|
|
443
457
|
* @returns An array of IDbForge objects.
|
|
444
458
|
*/
|
|
445
459
|
iterateArrayField(fieldName, data) {
|
|
446
|
-
return this.
|
|
460
|
+
return this.idbBase.iterateArrayField(this.collectionName, fieldName, data);
|
|
447
461
|
}
|
|
448
462
|
/**
|
|
449
463
|
* Iterate over an object field and return an array of IDbForge objects for each property.
|
|
@@ -452,7 +466,7 @@ export class IDbCollectionValues {
|
|
|
452
466
|
* @returns An array of IDbForge objects.
|
|
453
467
|
*/
|
|
454
468
|
iterateObjectField(fieldName, data) {
|
|
455
|
-
return this.
|
|
469
|
+
return this.idbBase.iterateObjectField(this.collectionName, fieldName, data);
|
|
456
470
|
}
|
|
457
471
|
/**
|
|
458
472
|
* Internal: Format a number field for display.
|
|
@@ -477,8 +491,9 @@ export class IDbCollectionValues {
|
|
|
477
491
|
'text-long': 40,
|
|
478
492
|
'text-giant': 50
|
|
479
493
|
};
|
|
480
|
-
const
|
|
481
|
-
|
|
494
|
+
const str = typeof value === 'string' ? value : String(value ?? '');
|
|
495
|
+
const maxLength = lengths[type] || str.length;
|
|
496
|
+
return str.substring(0, maxLength);
|
|
482
497
|
}
|
|
483
498
|
/**
|
|
484
499
|
* Internal: Check if access is allowed (override for custom logic).
|
|
@@ -509,7 +524,7 @@ export class IDbCollectionFieldValues {
|
|
|
509
524
|
* @param fieldName The field name to introspect.
|
|
510
525
|
*/
|
|
511
526
|
getForge(fieldName) {
|
|
512
|
-
return this.#collectionValues.
|
|
527
|
+
return this.#collectionValues.idbBase.parseCollectionFieldName(this.#collection, String(fieldName));
|
|
513
528
|
}
|
|
514
529
|
constructor(collection, data, collectionValues) {
|
|
515
530
|
this.#collection = collection;
|
|
@@ -517,7 +532,7 @@ export class IDbCollectionFieldValues {
|
|
|
517
532
|
this.#data = data;
|
|
518
533
|
}
|
|
519
534
|
format(fieldName) {
|
|
520
|
-
const fieldInfo = this.#collectionValues.
|
|
535
|
+
const fieldInfo = this.#collectionValues.idbBase.parseCollectionFieldName(this.#collection, fieldName);
|
|
521
536
|
if (fieldInfo?.is === 'array') {
|
|
522
537
|
return this.iterateArray(String(fieldName), this.#data);
|
|
523
538
|
}
|
|
@@ -560,14 +575,13 @@ export class IDbCollectionFieldValues {
|
|
|
560
575
|
* const inputType = forge.htmlInputType; // e.g. 'text', 'area', 'email', etc.
|
|
561
576
|
* const meta = forge.forge; // IDbForge metadata for the field
|
|
562
577
|
*
|
|
563
|
-
* This class is typically used via
|
|
578
|
+
* This class is typically used via IDbBase.getCollectionFieldForge for shared instance management.
|
|
564
579
|
*/
|
|
565
580
|
export class IDbCollectionFieldForge {
|
|
566
581
|
#collection;
|
|
567
582
|
#collectionValues;
|
|
568
583
|
#fieldName;
|
|
569
584
|
#data;
|
|
570
|
-
#forge;
|
|
571
585
|
constructor(collection, fieldName, data, collectionValues) {
|
|
572
586
|
this.#collection = collection;
|
|
573
587
|
this.#collectionValues = collectionValues ?? new IDbCollectionValues(collection);
|
|
@@ -582,7 +596,7 @@ export class IDbCollectionFieldForge {
|
|
|
582
596
|
}
|
|
583
597
|
// renamed from parseCollectionFieldName
|
|
584
598
|
get forge() {
|
|
585
|
-
return this.#collectionValues.
|
|
599
|
+
return this.#collectionValues.idbBase.parseCollectionFieldName(this.#collection, String(this.#fieldName));
|
|
586
600
|
}
|
|
587
601
|
get fieldArgs() {
|
|
588
602
|
return this.forge?.fieldArgs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medyll/idae-machine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.121.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"!dist/**/*.test.*",
|
|
@@ -48,7 +48,9 @@
|
|
|
48
48
|
},
|
|
49
49
|
"scope": "@medyll",
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@huggingface/prettier-plugin-vertical-align": "^0.2.3"
|
|
51
|
+
"@huggingface/prettier-plugin-vertical-align": "^0.2.3",
|
|
52
|
+
"@medyll/idae-slotui-svelte": "0.174.0",
|
|
53
|
+
"@medyll/idae-idbql": "0.171.0"
|
|
52
54
|
},
|
|
53
55
|
"scripts": {
|
|
54
56
|
"dev": "vite dev",
|