@medyll/idae-machine 0.107.0 โ 0.108.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/README.md +21 -7
- package/dist/db/dbFields.d.ts +5 -5
- package/dist/db/dbFields.js +10 -6
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/machine.d.ts +76 -0
- package/dist/machine.js +129 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -159,23 +159,37 @@ fields: {
|
|
|
159
159
|
}
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
## ๐ Development Status
|
|
163
162
|
|
|
164
|
-
|
|
163
|
+
## ๐ก๏ธ Robustness & Test Coverage
|
|
165
164
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
- **
|
|
169
|
-
- **
|
|
165
|
+
All core logic in `src/lib/db/dbFields.ts` is now fully schema-driven and covered by comprehensive unit tests (see `src/lib/db/*.spec.ts`).
|
|
166
|
+
|
|
167
|
+
- **Field parsing**: Handles all types (primitive, array, object, fk) and modifiers (required, readonly, private) with robust string DSL parsing.
|
|
168
|
+
- **Foreign key support**: Correctly parses and exposes fk and reverse-fk relations, with type-safe metadata.
|
|
169
|
+
- **Test-driven**: All exported classes are covered by robust Vitest suites, including edge cases and complex schemas.
|
|
170
|
+
- **Svelte 5 compliance**: All UI code and event handling strictly follow Svelte 5 idioms (see `AGENTS.md`).
|
|
170
171
|
|
|
171
172
|
### Current Focus Areas
|
|
172
173
|
- โ
Schema declaration & type safety
|
|
173
174
|
- โ
Database integration with idae-idbql
|
|
174
175
|
- โ
Component exports & library structure
|
|
176
|
+
- โ
Comprehensive test coverage (dbFields, CRUD, UI)
|
|
177
|
+
- โ
Svelte 5 event and binding policy
|
|
175
178
|
- ๐ Form validation (in progress)
|
|
176
179
|
- ๐ Field rendering pipeline (needs refinement)
|
|
177
180
|
- โณ End-to-end CRUD workflows
|
|
178
|
-
|
|
181
|
+
|
|
182
|
+
## ๐งช Testing Policy
|
|
183
|
+
|
|
184
|
+
All logic in `dbFields.ts` and related modules is covered by unit tests:
|
|
185
|
+
|
|
186
|
+
- **Test schema**: All tests use a realistic, complex schema (see `testDbSchema.ts`).
|
|
187
|
+
- **Coverage**: Every method of every exported class is tested, including edge cases (array/object/fk/required/readonly).
|
|
188
|
+
- **Continuous validation**: All tests must pass before merge. See `CHANGELOG.md` for test and coverage history.
|
|
189
|
+
|
|
190
|
+
## ๐ฆ Svelte 5 Coding Policy
|
|
191
|
+
|
|
192
|
+
All UI code must strictly follow Svelte 5 syntax and conventions. See `AGENTS.md` for details and migration rules.
|
|
179
193
|
|
|
180
194
|
## ๐ Dependencies
|
|
181
195
|
|
package/dist/db/dbFields.d.ts
CHANGED
|
@@ -213,11 +213,6 @@ export declare class IDbCollectionValues<T extends Record<string, any>> {
|
|
|
213
213
|
* @param collection The collection name.
|
|
214
214
|
*/
|
|
215
215
|
constructor(collection: TplCollectionName);
|
|
216
|
-
/**
|
|
217
|
-
* Get the presentation string for a data object, using the collection's presentation template.
|
|
218
|
-
* @param data The data object.
|
|
219
|
-
* @returns The formatted presentation string.
|
|
220
|
-
*/
|
|
221
216
|
presentation(data: Record<string, any>): string;
|
|
222
217
|
/**
|
|
223
218
|
* Get the value of the index field for a data object.
|
|
@@ -256,6 +251,11 @@ export declare class IDbCollectionValues<T extends Record<string, any>> {
|
|
|
256
251
|
}
|
|
257
252
|
export declare class IDbCollectionFieldValues<T extends Record<string, any>> {
|
|
258
253
|
#private;
|
|
254
|
+
/**
|
|
255
|
+
* Returns the IDbForge metadata for a given field name.
|
|
256
|
+
* @param fieldName The field name to introspect.
|
|
257
|
+
*/
|
|
258
|
+
getForge(fieldName: keyof T): IDbForge | undefined;
|
|
259
259
|
constructor(collection: TplCollectionName, data: T);
|
|
260
260
|
format(fieldName: keyof T): string | string[];
|
|
261
261
|
getInputDataSet(fieldName: keyof T): Record<"data-collection" | "data-fieldName" | "data-fieldType" | "data-fieldArgs" | "data-collectionId", string>;
|
package/dist/db/dbFields.js
CHANGED
|
@@ -296,7 +296,8 @@ export class IDbCollections {
|
|
|
296
296
|
is = is ?? fieldType;
|
|
297
297
|
break;
|
|
298
298
|
case 'fk':
|
|
299
|
-
fieldType
|
|
299
|
+
// Pour les fk, fieldType doit rester la string d'origine (ex: 'fk-agentPrompt.id')
|
|
300
|
+
fieldType = 'fk-' + extractAfter('fk-', fieldRule);
|
|
300
301
|
is = extractedArgs?.piece;
|
|
301
302
|
break;
|
|
302
303
|
case 'primitive':
|
|
@@ -404,11 +405,6 @@ export class IDbCollectionValues {
|
|
|
404
405
|
this.collection = collection;
|
|
405
406
|
this.dbCollections = new IDbCollections();
|
|
406
407
|
}
|
|
407
|
-
/**
|
|
408
|
-
* Get the presentation string for a data object, using the collection's presentation template.
|
|
409
|
-
* @param data The data object.
|
|
410
|
-
* @returns The formatted presentation string.
|
|
411
|
-
*/
|
|
412
408
|
presentation(data) {
|
|
413
409
|
try {
|
|
414
410
|
this.#checkError(!this.#checkAccess(), 'Access denied', 'ACCESS_DENIED');
|
|
@@ -563,6 +559,13 @@ export class IDbCollectionFieldValues {
|
|
|
563
559
|
#collection;
|
|
564
560
|
#collectionValues;
|
|
565
561
|
#data;
|
|
562
|
+
/**
|
|
563
|
+
* Returns the IDbForge metadata for a given field name.
|
|
564
|
+
* @param fieldName The field name to introspect.
|
|
565
|
+
*/
|
|
566
|
+
getForge(fieldName) {
|
|
567
|
+
return this.#collectionValues.dbCollections.parseCollectionFieldName(this.#collection, String(fieldName));
|
|
568
|
+
}
|
|
566
569
|
constructor(collection, data) {
|
|
567
570
|
this.#collection = collection;
|
|
568
571
|
this.#collectionValues = new IDbCollectionValues(collection);
|
|
@@ -814,3 +817,4 @@ export class IDbFormValidate {
|
|
|
814
817
|
}
|
|
815
818
|
}
|
|
816
819
|
}
|
|
820
|
+
// (fin de fichier)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './machine.js';
|
|
1
2
|
export * from './types/appschemeTypes.js';
|
|
2
3
|
export { default as Skeleton } from './fragments/Skeleton.svelte';
|
|
3
4
|
export { default as Selector } from './fragments/Selector.svelte';
|
|
@@ -11,7 +12,6 @@ export { default as FieldInPlace } from './form/FieldInPlace.svelte';
|
|
|
11
12
|
export { default as DataProvider } from './form/DataProvider.svelte';
|
|
12
13
|
export { default as DataList } from './form/DataList.svelte';
|
|
13
14
|
export { default as CrudZone } from './form/CrudZone.svelte';
|
|
14
|
-
export * from './form/CrudZone.spec.js';
|
|
15
15
|
export { default as CreateUpdate } from './form/CreateUpdate.svelte';
|
|
16
16
|
export { default as CollectionReverseFks } from './form/CollectionReverseFks.svelte';
|
|
17
17
|
export { default as CollectionListMenu } from './form/CollectionListMenu.svelte';
|
|
@@ -30,5 +30,4 @@ export * from './db/dbCollectionValues.spec.js';
|
|
|
30
30
|
export * from './db/dbCollectionFieldValues.spec.js';
|
|
31
31
|
export * from './db/dbCollectionFieldForge.spec.js';
|
|
32
32
|
export * from './db/dataModel.js';
|
|
33
|
-
export * from './db/FieldValue.spec.js';
|
|
34
33
|
export * from './db/CrudService.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// auto exports of entry components
|
|
2
|
+
export * from './machine.js';
|
|
2
3
|
export * from './types/appschemeTypes.js';
|
|
3
4
|
export { default as Skeleton } from './fragments/Skeleton.svelte';
|
|
4
5
|
export { default as Selector } from './fragments/Selector.svelte';
|
|
@@ -12,7 +13,6 @@ export { default as FieldInPlace } from './form/FieldInPlace.svelte';
|
|
|
12
13
|
export { default as DataProvider } from './form/DataProvider.svelte';
|
|
13
14
|
export { default as DataList } from './form/DataList.svelte';
|
|
14
15
|
export { default as CrudZone } from './form/CrudZone.svelte';
|
|
15
|
-
export * from './form/CrudZone.spec.js';
|
|
16
16
|
export { default as CreateUpdate } from './form/CreateUpdate.svelte';
|
|
17
17
|
export { default as CollectionReverseFks } from './form/CollectionReverseFks.svelte';
|
|
18
18
|
export { default as CollectionListMenu } from './form/CollectionListMenu.svelte';
|
|
@@ -31,5 +31,4 @@ export * from './db/dbCollectionValues.spec.js';
|
|
|
31
31
|
export * from './db/dbCollectionFieldValues.spec.js';
|
|
32
32
|
export * from './db/dbCollectionFieldForge.spec.js';
|
|
33
33
|
export * from './db/dataModel.js';
|
|
34
|
-
export * from './db/FieldValue.spec.js';
|
|
35
34
|
export * from './db/CrudService.js';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IDbCollections } from './db/dbFields.js';
|
|
2
|
+
import { createIdbqDb } from '@medyll/idae-idbql';
|
|
3
|
+
/**
|
|
4
|
+
* Machine: main entry point for managing the IDBQL connection and centralized data access.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Machine {
|
|
7
|
+
/**
|
|
8
|
+
|
|
9
|
+
* IDBQL (readonly collections instance)
|
|
10
|
+
*/
|
|
11
|
+
idbql: ReturnType<ReturnType<typeof createIdbqDb>["create"]>["idbql"] | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* IDBQL (stateful collections instance)
|
|
14
|
+
*/
|
|
15
|
+
idbqlState: ReturnType<ReturnType<typeof createIdbqDb>["create"]>["idbqlState"] | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Direct access to IndexedDB (core)
|
|
18
|
+
*/
|
|
19
|
+
idbDatabase: ReturnType<ReturnType<typeof createIdbqDb>["create"]>["idbDatabase"] | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* IDBQL data model
|
|
22
|
+
*/
|
|
23
|
+
idbqModel: ReturnType<ReturnType<typeof createIdbqDb>["create"]>["idbqModel"] | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Centralized access to schema and collection logic
|
|
26
|
+
*/
|
|
27
|
+
collections: IDbCollections | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Database name
|
|
30
|
+
*/
|
|
31
|
+
dbName: string;
|
|
32
|
+
/**
|
|
33
|
+
* Schema version
|
|
34
|
+
*/
|
|
35
|
+
version: number;
|
|
36
|
+
/**
|
|
37
|
+
* Data model
|
|
38
|
+
*/
|
|
39
|
+
model: any;
|
|
40
|
+
/**
|
|
41
|
+
* Main constructor
|
|
42
|
+
* @param dbName Database name (default: 'idae-machine')
|
|
43
|
+
* @param version Schema version (default: 1)
|
|
44
|
+
* @param model Data model (default: schemeModel)
|
|
45
|
+
*/
|
|
46
|
+
constructor(dbName?: string, version?: number, model?: import("@medyll/idae-idbql").IdbqModel<Record<string, Record<string, any>>>);
|
|
47
|
+
/**
|
|
48
|
+
* Start the machine: initialize collections and IDBQL connection.
|
|
49
|
+
* @param options Optional overrides: { dbName, version, model }
|
|
50
|
+
*/
|
|
51
|
+
start(options?: {
|
|
52
|
+
dbName?: string;
|
|
53
|
+
version?: number;
|
|
54
|
+
model?: any;
|
|
55
|
+
}): void;
|
|
56
|
+
/**
|
|
57
|
+
* Get the IDbCollections (schema logic) instance
|
|
58
|
+
*/
|
|
59
|
+
getCollections(): IDbCollections | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Get the IDBQL (readonly) instance
|
|
62
|
+
*/
|
|
63
|
+
getIdbql(): import("@medyll/idae-idbql").ReadonlyCollections<import("@medyll/idae-idbql").IdbqModel<Record<string, Record<string, any>>>> | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Get the IDBQL (stateful) instance
|
|
66
|
+
*/
|
|
67
|
+
getIdbqlState(): import("@medyll/idae-idbql").StateCollections<import("@medyll/idae-idbql").IdbqModel<Record<string, Record<string, any>>>> | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Get the IndexedDB (core) instance
|
|
70
|
+
*/
|
|
71
|
+
getIdbDatabase(): import("@medyll/idae-idbql").IdbqlIndexedCore<import("@medyll/idae-idbql").IdbqModel<Record<string, Record<string, any>>>> | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Get the IDBQL data model instance
|
|
74
|
+
*/
|
|
75
|
+
getIdbqModel(): import("@medyll/idae-idbql").IdbqModel<Record<string, Record<string, any>>> | undefined;
|
|
76
|
+
}
|
package/dist/machine.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example usage:
|
|
3
|
+
*
|
|
4
|
+
* import { Machine } from './machine.js';
|
|
5
|
+
*
|
|
6
|
+
* // Create a new Machine instance with default parameters
|
|
7
|
+
* const machine = new Machine();
|
|
8
|
+
*
|
|
9
|
+
* // Start the machine (initialize collections and IDBQL connection)
|
|
10
|
+
* machine.start();
|
|
11
|
+
*
|
|
12
|
+
* // Access collections (schema logic)
|
|
13
|
+
* const collections = machine.getCollections();
|
|
14
|
+
*
|
|
15
|
+
* // Access IDBQL (readonly)
|
|
16
|
+
* const idbql = machine.getIdbql();
|
|
17
|
+
*
|
|
18
|
+
* // Access IDBQL (stateful)
|
|
19
|
+
* const idbqlState = machine.getIdbqlState();
|
|
20
|
+
*
|
|
21
|
+
* // Access IndexedDB core
|
|
22
|
+
* const db = machine.getIdbDatabase();
|
|
23
|
+
*
|
|
24
|
+
* // Access the IDBQL data model
|
|
25
|
+
* const model = machine.getIdbqModel();
|
|
26
|
+
*/
|
|
27
|
+
import { schemeModel } from './db/dbSchema.js';
|
|
28
|
+
import { IDbCollections } from './db/dbFields.js';
|
|
29
|
+
import { createIdbqDb } from '@medyll/idae-idbql';
|
|
30
|
+
/**
|
|
31
|
+
* Machine: main entry point for managing the IDBQL connection and centralized data access.
|
|
32
|
+
*/
|
|
33
|
+
export class Machine {
|
|
34
|
+
/**
|
|
35
|
+
|
|
36
|
+
* IDBQL (readonly collections instance)
|
|
37
|
+
*/
|
|
38
|
+
idbql;
|
|
39
|
+
/**
|
|
40
|
+
* IDBQL (stateful collections instance)
|
|
41
|
+
*/
|
|
42
|
+
idbqlState;
|
|
43
|
+
/**
|
|
44
|
+
* Direct access to IndexedDB (core)
|
|
45
|
+
*/
|
|
46
|
+
idbDatabase;
|
|
47
|
+
/**
|
|
48
|
+
* IDBQL data model
|
|
49
|
+
*/
|
|
50
|
+
idbqModel;
|
|
51
|
+
/**
|
|
52
|
+
* Centralized access to schema and collection logic
|
|
53
|
+
*/
|
|
54
|
+
collections;
|
|
55
|
+
/**
|
|
56
|
+
* Database name
|
|
57
|
+
*/
|
|
58
|
+
dbName;
|
|
59
|
+
/**
|
|
60
|
+
* Schema version
|
|
61
|
+
*/
|
|
62
|
+
version;
|
|
63
|
+
/**
|
|
64
|
+
* Data model
|
|
65
|
+
*/
|
|
66
|
+
model;
|
|
67
|
+
/**
|
|
68
|
+
* Main constructor
|
|
69
|
+
* @param dbName Database name (default: 'idae-machine')
|
|
70
|
+
* @param version Schema version (default: 1)
|
|
71
|
+
* @param model Data model (default: schemeModel)
|
|
72
|
+
*/
|
|
73
|
+
constructor(dbName = 'idae-machine', version = 1, model = schemeModel) {
|
|
74
|
+
this.dbName = dbName;
|
|
75
|
+
this.version = version;
|
|
76
|
+
this.model = model;
|
|
77
|
+
this.collections = undefined;
|
|
78
|
+
this.idbql = undefined;
|
|
79
|
+
this.idbqlState = undefined;
|
|
80
|
+
this.idbDatabase = undefined;
|
|
81
|
+
this.idbqModel = undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Start the machine: initialize collections and IDBQL connection.
|
|
85
|
+
* @param options Optional overrides: { dbName, version, model }
|
|
86
|
+
*/
|
|
87
|
+
start(options) {
|
|
88
|
+
const dbName = options?.dbName ?? this.dbName;
|
|
89
|
+
const version = options?.version ?? this.version;
|
|
90
|
+
const model = options?.model ?? this.model;
|
|
91
|
+
this.collections = new IDbCollections(model);
|
|
92
|
+
const idbqStore = createIdbqDb(model, version);
|
|
93
|
+
const { idbql, idbqlState, idbDatabase, idbqModel } = idbqStore.create(dbName);
|
|
94
|
+
this.idbql = idbql;
|
|
95
|
+
this.idbqlState = idbqlState;
|
|
96
|
+
this.idbDatabase = idbDatabase;
|
|
97
|
+
this.idbqModel = idbqModel;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the IDbCollections (schema logic) instance
|
|
101
|
+
*/
|
|
102
|
+
getCollections() {
|
|
103
|
+
return this.collections;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get the IDBQL (readonly) instance
|
|
107
|
+
*/
|
|
108
|
+
getIdbql() {
|
|
109
|
+
return this.idbql;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get the IDBQL (stateful) instance
|
|
113
|
+
*/
|
|
114
|
+
getIdbqlState() {
|
|
115
|
+
return this.idbqlState;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get the IndexedDB (core) instance
|
|
119
|
+
*/
|
|
120
|
+
getIdbDatabase() {
|
|
121
|
+
return this.idbDatabase;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get the IDBQL data model instance
|
|
125
|
+
*/
|
|
126
|
+
getIdbqModel() {
|
|
127
|
+
return this.idbqModel;
|
|
128
|
+
}
|
|
129
|
+
}
|