@medyll/idae-machine 0.107.0 โ†’ 0.109.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 CHANGED
@@ -159,23 +159,37 @@ fields: {
159
159
  }
160
160
  ```
161
161
 
162
- ## ๐Ÿ“ Development Status
163
162
 
164
- โš ๏ธ **Early Development Phase**
163
+ ## ๐Ÿ›ก๏ธ Robustness & Test Coverage
165
164
 
166
- This package contains foundational code that is:
167
- - **Partially validated**: Core schema & field system works; form validation in progress
168
- - **Under active refinement**: API may change as patterns solidify
169
- - **Proof of concept**: Not recommended for production until v1.0 release
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
- - โณ Comprehensive test coverage
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
 
@@ -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>;
@@ -296,7 +296,8 @@ export class IDbCollections {
296
296
  is = is ?? fieldType;
297
297
  break;
298
298
  case 'fk':
299
- fieldType = this.getFkFieldType(extractAfter('fk-', fieldRule));
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,4 +1,6 @@
1
1
  export * from './types/appschemeTypes.js';
2
+ export * from './main/machine.js';
3
+ export * from './main/machine.spec.js';
2
4
  export { default as Skeleton } from './fragments/Skeleton.svelte';
3
5
  export { default as Selector } from './fragments/Selector.svelte';
4
6
  export { default as List } from './fragments/List.svelte';
@@ -11,7 +13,6 @@ export { default as FieldInPlace } from './form/FieldInPlace.svelte';
11
13
  export { default as DataProvider } from './form/DataProvider.svelte';
12
14
  export { default as DataList } from './form/DataList.svelte';
13
15
  export { default as CrudZone } from './form/CrudZone.svelte';
14
- export * from './form/CrudZone.spec.js';
15
16
  export { default as CreateUpdate } from './form/CreateUpdate.svelte';
16
17
  export { default as CollectionReverseFks } from './form/CollectionReverseFks.svelte';
17
18
  export { default as CollectionListMenu } from './form/CollectionListMenu.svelte';
@@ -30,5 +31,4 @@ export * from './db/dbCollectionValues.spec.js';
30
31
  export * from './db/dbCollectionFieldValues.spec.js';
31
32
  export * from './db/dbCollectionFieldForge.spec.js';
32
33
  export * from './db/dataModel.js';
33
- export * from './db/FieldValue.spec.js';
34
34
  export * from './db/CrudService.js';
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // auto exports of entry components
2
2
  export * from './types/appschemeTypes.js';
3
+ export * from './main/machine.js';
4
+ export * from './main/machine.spec.js';
3
5
  export { default as Skeleton } from './fragments/Skeleton.svelte';
4
6
  export { default as Selector } from './fragments/Selector.svelte';
5
7
  export { default as List } from './fragments/List.svelte';
@@ -12,7 +14,6 @@ export { default as FieldInPlace } from './form/FieldInPlace.svelte';
12
14
  export { default as DataProvider } from './form/DataProvider.svelte';
13
15
  export { default as DataList } from './form/DataList.svelte';
14
16
  export { default as CrudZone } from './form/CrudZone.svelte';
15
- export * from './form/CrudZone.spec.js';
16
17
  export { default as CreateUpdate } from './form/CreateUpdate.svelte';
17
18
  export { default as CollectionReverseFks } from './form/CollectionReverseFks.svelte';
18
19
  export { default as CollectionListMenu } from './form/CollectionListMenu.svelte';
@@ -31,5 +32,4 @@ export * from './db/dbCollectionValues.spec.js';
31
32
  export * from './db/dbCollectionFieldValues.spec.js';
32
33
  export * from './db/dbCollectionFieldForge.spec.js';
33
34
  export * from './db/dataModel.js';
34
- export * from './db/FieldValue.spec.js';
35
35
  export * from './db/CrudService.js';
@@ -0,0 +1,78 @@
1
+ import { IDbCollections } from '../db/dbFields.js';
2
+ import { createIdbqDb, type IdbqModel } 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: IdbqModel;
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?: IdbqModel);
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?: IdbqModel;
55
+ }): void;
56
+ private createCollections;
57
+ private createStore;
58
+ /**
59
+ * Get the IDbCollections (schema logic) instance
60
+ */
61
+ get collections(): IDbCollections | undefined;
62
+ /**
63
+ * IDBQL (readonly) instance
64
+ */
65
+ get idbql(): import("@medyll/idae-idbql").ReadonlyCollections<IdbqModel<Record<string, Record<string, any>>>> | undefined;
66
+ /**
67
+ * IDBQL (stateful) instance
68
+ */
69
+ get idbqlState(): import("@medyll/idae-idbql").StateCollections<IdbqModel<Record<string, Record<string, any>>>> | undefined;
70
+ /**
71
+ * IndexedDB (core) instance
72
+ */
73
+ get indexedb(): import("@medyll/idae-idbql").IdbqlIndexedCore<IdbqModel<Record<string, Record<string, any>>>> | undefined;
74
+ /**
75
+ * IDBQL data model instance
76
+ */
77
+ get idbqModel(): IdbqModel<Record<string, Record<string, any>>> | undefined;
78
+ }
@@ -0,0 +1,136 @@
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( 'example-db', 1, { collections: {} });
8
+ *
9
+ * // Start the machine (initialize collections and IDBQL connection)
10
+ * machine.start();
11
+ *
12
+ * // Access collections (schema logic)
13
+ * const collections = machine.collections;
14
+ *
15
+ * // Access IDBQL (readonly)
16
+ * const idbql = machine.idbql;
17
+ *
18
+ * // Access IDBQL (stateful)
19
+ * const idbqlState = machine.idbqlState;
20
+ *
21
+ * // Access IndexedDB core
22
+ * const db = machine.indexedb;
23
+ *
24
+ * // Access the IDBQL data model
25
+ * const model = machine.idbqModel;
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
+ }
78
+ /**
79
+ * Start the machine: initialize collections and IDBQL connection.
80
+ * @param options Optional overrides: { dbName, version, model }
81
+ */
82
+ start(options) {
83
+ this._dbName = options?.dbName ?? this._dbName;
84
+ this._version = options?.version ?? this._version;
85
+ this._model = options?.model ?? this._model;
86
+ this.createCollections();
87
+ this.createStore();
88
+ }
89
+ createCollections() {
90
+ if (!this._model) {
91
+ throw new Error('Data model is not defined');
92
+ }
93
+ this._collections = new IDbCollections(this._model);
94
+ }
95
+ createStore() {
96
+ if (!this._model || !this._dbName || !this._version) {
97
+ throw new Error('Model, dbName, or version is not defined');
98
+ }
99
+ const idbqStore = createIdbqDb(this._model, this._version);
100
+ const { idbql, idbqlState, idbDatabase, idbqModel } = idbqStore.create(this._dbName);
101
+ this._idbql = idbql;
102
+ this._idbqlState = idbqlState;
103
+ this._idbDatabase = idbDatabase;
104
+ this._idbqModel = idbqModel;
105
+ }
106
+ /**
107
+ * Get the IDbCollections (schema logic) instance
108
+ */
109
+ get collections() {
110
+ return this._collections;
111
+ }
112
+ /**
113
+ * IDBQL (readonly) instance
114
+ */
115
+ get idbql() {
116
+ return this._idbql;
117
+ }
118
+ /**
119
+ * IDBQL (stateful) instance
120
+ */
121
+ get idbqlState() {
122
+ return this._idbqlState;
123
+ }
124
+ /**
125
+ * IndexedDB (core) instance
126
+ */
127
+ get indexedb() {
128
+ return this._idbDatabase;
129
+ }
130
+ /**
131
+ * IDBQL data model instance
132
+ */
133
+ get idbqModel() {
134
+ return this._idbqModel;
135
+ }
136
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medyll/idae-machine",
3
- "version": "0.107.0",
3
+ "version": "0.109.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",