@medyll/idae-machine 0.124.0 → 0.126.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.
Files changed (45) hide show
  1. package/dist/db/dataModel.d.ts +2 -1
  2. package/dist/db/dataModel.js +0 -38
  3. package/dist/db/dbSchema.d.ts +169 -169
  4. package/dist/db/fieldTypes.d.ts +13 -0
  5. package/dist/db/fieldTypes.js +67 -0
  6. package/dist/{db → demo}/testDbSchema.d.ts +1 -1
  7. package/dist/form/CreateUpdate.svelte +2 -1
  8. package/dist/index.d.ts +17 -8
  9. package/dist/index.js +17 -8
  10. package/dist/main/machine/IDbCollection.d.ts +71 -0
  11. package/dist/main/machine/IDbCollection.js +102 -0
  12. package/dist/main/machine/IDbCollectionFieldForge.d.ts +42 -0
  13. package/dist/main/machine/IDbCollectionFieldForge.js +74 -0
  14. package/dist/main/machine/IDbCollectionFieldValues.d.ts +57 -0
  15. package/dist/main/machine/IDbCollectionFieldValues.js +82 -0
  16. package/dist/main/machine/IDbCollectionValues.d.ts +78 -0
  17. package/dist/main/machine/IDbCollectionValues.js +203 -0
  18. package/dist/main/machine/IDbError.d.ts +6 -0
  19. package/dist/main/machine/IDbError.js +61 -0
  20. package/dist/main/machine/IDbFormValidate.d.ts +55 -0
  21. package/dist/main/machine/IDbFormValidate.js +183 -0
  22. package/dist/main/machine/IDbValidationError.d.ts +19 -0
  23. package/dist/main/machine/IDbValidationError.js +24 -0
  24. package/dist/main/machine/types.d.ts +1 -0
  25. package/dist/main/machine/types.js +1 -0
  26. package/dist/main/machineDb.d.ts +15 -222
  27. package/dist/main/machineDb.js +33 -687
  28. package/dist/main/machineForge.d.ts +57 -0
  29. package/dist/main/machineForge.js +105 -0
  30. package/dist/{form → ui}/CollectionButton.svelte +2 -2
  31. package/dist/{form → ui}/CollectionButton.svelte.d.ts +1 -1
  32. package/dist/{form → ui}/CollectionFks.svelte +3 -5
  33. package/dist/{form → ui}/CollectionList.svelte +1 -1
  34. package/dist/{form → ui}/CollectionListMenu.svelte +3 -2
  35. package/package.json +3 -3
  36. package/dist/form/DataList.svelte +0 -60
  37. package/dist/form/DataList.svelte.d.ts +0 -10
  38. /package/dist/{db → demo}/testDbSchema.js +0 -0
  39. /package/dist/{form → ui}/CollectionFieldGuess.svelte +0 -0
  40. /package/dist/{form → ui}/CollectionFieldGuess.svelte.d.ts +0 -0
  41. /package/dist/{form → ui}/CollectionFks.svelte.d.ts +0 -0
  42. /package/dist/{form → ui}/CollectionList.svelte.d.ts +0 -0
  43. /package/dist/{form → ui}/CollectionListMenu.svelte.d.ts +0 -0
  44. /package/dist/{form → ui}/CollectionReverseFks.svelte +0 -0
  45. /package/dist/{form → ui}/CollectionReverseFks.svelte.d.ts +0 -0
@@ -1,3 +1,4 @@
1
+ import type { FieldType } from './fieldTypes';
1
2
  export type DbDataModel<T = Record<string, CollectionDbModel>> = {
2
3
  readonly [K in keyof T]: CollectionDbModel<T[K]>;
3
4
  };
@@ -8,7 +9,7 @@ export interface CollectionDbModel<T = Record<string, any>> {
8
9
  template?: {
9
10
  index: string;
10
11
  presentation: any;
11
- fields?: {};
12
+ fields?: Record<string, FieldType | string>;
12
13
  fks?: {
13
14
  code: string;
14
15
  multiple: boolean;
@@ -1,40 +1,2 @@
1
- const monModel = {
2
- agent: {
3
- keyPath: '++id, promptId, created_at',
4
- ts: {},
5
- model: {},
6
- template: {
7
- index: 'id',
8
- presentation: 'name model',
9
- fields: {
10
- id: 'id (readonly)',
11
- name: 'text (private)',
12
- code: 'text',
13
- model: 'text',
14
- prompt: 'text-long',
15
- created_at: 'date (private)',
16
- ia_lock: 'boolean (private)',
17
- agentPromptId: 'fk-agentPrompt.id (required)'
18
- }
19
- }
20
- },
21
- agentPrompt: {
22
- keyPath: '++id, created_at',
23
- ts: {},
24
- model: {},
25
- template: {
26
- index: 'id',
27
- presentation: 'name',
28
- fields: {
29
- id: 'id (readonly)',
30
- created_at: 'date (private)',
31
- value: 'text-long (required)',
32
- name: 'text (required)',
33
- code: 'text (required)',
34
- ia_lock: 'boolean (private)'
35
- }
36
- }
37
- }
38
- };
39
1
  export {};
40
2
  //
@@ -13,20 +13,20 @@ export declare const schemeModelDb: {
13
13
  index: string;
14
14
  presentation: string;
15
15
  fields: {
16
- id: string;
17
- name: string;
18
- code: string;
19
- model: string;
20
- prompt: string;
21
- created_at: string;
22
- ia_lock: string;
23
- agentPromptId: string;
16
+ id: "id (readonly)";
17
+ name: "text (private)";
18
+ code: "text";
19
+ model: "text";
20
+ prompt: "text-long";
21
+ created_at: "date (private)";
22
+ ia_lock: "boolean (private)";
23
+ agentPromptId: "fk-agentPrompt.id (required)";
24
24
  };
25
25
  fks: {
26
26
  agentPrompt: {
27
27
  code: string;
28
- rules: string;
29
- multiple: boolean;
28
+ rules: "readonly private";
29
+ multiple: true;
30
30
  };
31
31
  };
32
32
  };
@@ -39,12 +39,12 @@ export declare const schemeModelDb: {
39
39
  index: string;
40
40
  presentation: string;
41
41
  fields: {
42
- id: string;
43
- created_at: string;
44
- value: string;
45
- name: string;
46
- code: string;
47
- ia_lock: string;
42
+ id: "id (readonly)";
43
+ created_at: "date (private)";
44
+ value: "text-long (required)";
45
+ name: "text (required)";
46
+ code: "text (required)";
47
+ ia_lock: "boolean (private)";
48
48
  };
49
49
  fks: {};
50
50
  };
@@ -57,9 +57,9 @@ export declare const schemeModelDb: {
57
57
  index: string;
58
58
  presentation: string;
59
59
  fields: {
60
- code: string;
61
- name: string;
62
- context: string;
60
+ code: "text";
61
+ name: "text";
62
+ context: "array-of-number";
63
63
  };
64
64
  fks: {};
65
65
  };
@@ -72,23 +72,23 @@ export declare const schemeModelDb: {
72
72
  index: string;
73
73
  presentation: string;
74
74
  fields: {
75
- id: string;
76
- chatId: string;
77
- chatPassKey: string;
78
- created_at: string;
79
- category: string;
80
- categoryId: string;
81
- dateLastMessage: string;
82
- name: string;
83
- description: string;
84
- ia_lock: string;
85
- spaceId: string;
75
+ id: "id";
76
+ chatId: "fk.chat.id ";
77
+ chatPassKey: "text";
78
+ created_at: "date";
79
+ category: "text";
80
+ categoryId: "id";
81
+ dateLastMessage: "date";
82
+ name: "text";
83
+ description: "text";
84
+ ia_lock: "boolean";
85
+ spaceId: "fk-space.id (required)";
86
86
  };
87
87
  fks: {
88
88
  space: {
89
89
  code: string;
90
- rules: string;
91
- multiple: boolean;
90
+ rules: "private required";
91
+ multiple: false;
92
92
  };
93
93
  };
94
94
  };
@@ -101,10 +101,10 @@ export declare const schemeModelDb: {
101
101
  index: string;
102
102
  presentation: string;
103
103
  fields: {
104
- id: string;
105
- code: string;
106
- name: string;
107
- ia_lock: string;
104
+ id: "id";
105
+ code: "text";
106
+ name: "text";
107
+ ia_lock: "boolean (private)";
108
108
  };
109
109
  fks: {};
110
110
  };
@@ -117,10 +117,10 @@ export declare const schemeModelDb: {
117
117
  index: string;
118
118
  presentation: string;
119
119
  fields: {
120
- id: string;
121
- code: string;
122
- name: string;
123
- ia_lock: string;
120
+ id: "id";
121
+ code: "text";
122
+ name: "text";
123
+ ia_lock: "boolean (private)";
124
124
  };
125
125
  fks: {};
126
126
  };
@@ -133,10 +133,10 @@ export declare const schemeModelDb: {
133
133
  index: string;
134
134
  presentation: string;
135
135
  fields: {
136
- id: string;
137
- code: string;
138
- name: string;
139
- ia_lock: string;
136
+ id: "id";
137
+ code: "text";
138
+ name: "text";
139
+ ia_lock: "boolean (private)";
140
140
  };
141
141
  fks: {};
142
142
  };
@@ -149,16 +149,16 @@ export declare const schemeModelDb: {
149
149
  index: string;
150
150
  presentation: string;
151
151
  fields: {
152
- id: string;
153
- chatId: string;
154
- messageId: string;
155
- created_at: string;
156
- content: string;
157
- status: string;
158
- context: string;
159
- resume: string;
160
- model: string;
161
- ia_lock: string;
152
+ id: "id";
153
+ chatId: "id";
154
+ messageId: "id";
155
+ created_at: "date";
156
+ content: "text-long";
157
+ status: "text";
158
+ context: "array-of-number";
159
+ resume: "text";
160
+ model: "text";
161
+ ia_lock: "boolean";
162
162
  };
163
163
  fks: {};
164
164
  };
@@ -171,12 +171,12 @@ export declare const schemeModelDb: {
171
171
  index: string;
172
172
  presentation: string;
173
173
  fields: {
174
- id: string;
175
- name: string;
176
- code: string;
177
- value: string;
178
- created_at: string;
179
- ia_lock: string;
174
+ id: "id";
175
+ name: "text";
176
+ code: "text";
177
+ value: "text";
178
+ created_at: "date";
179
+ ia_lock: "boolean";
180
180
  };
181
181
  fks: {};
182
182
  };
@@ -189,13 +189,13 @@ export declare const schemeModelDb: {
189
189
  index: string;
190
190
  presentation: string;
191
191
  fields: {
192
- id: string;
193
- userId: string;
194
- created_at: string;
195
- updated_at: string;
196
- code: string;
197
- value: string;
198
- ia_lock: string;
192
+ id: "id";
193
+ userId: "id";
194
+ created_at: "date (readonly)";
195
+ updated_at: "date (readonly)";
196
+ code: "text";
197
+ value: "text";
198
+ ia_lock: "boolean (private)";
199
199
  };
200
200
  fks: {};
201
201
  };
@@ -208,13 +208,13 @@ export declare const schemeModelDb: {
208
208
  index: string;
209
209
  presentation: string;
210
210
  fields: {
211
- id: string;
212
- name: string;
213
- color: string;
214
- created_at: string;
215
- email: string;
216
- password: string;
217
- ia_lock: string;
211
+ id: "id";
212
+ name: "text";
213
+ color: "text";
214
+ created_at: "date (readonly)";
215
+ email: "email";
216
+ password: "password";
217
+ ia_lock: "boolean (private)";
218
218
  };
219
219
  fks: {};
220
220
  };
@@ -227,20 +227,20 @@ export declare const schemeModelDb: {
227
227
  index: string;
228
228
  presentation: string;
229
229
  fields: {
230
- id: string;
231
- userId: string;
232
- title: string;
233
- description: string;
234
- created_at: string;
235
- updated_at: string;
236
- status: string;
237
- ia_lock: string;
230
+ id: "id (readonly)";
231
+ userId: "id";
232
+ title: "text-long (required)";
233
+ description: "text-area";
234
+ created_at: "date (readonly)";
235
+ updated_at: "date";
236
+ status: "text";
237
+ ia_lock: "boolean (private)";
238
238
  };
239
239
  fks: {
240
240
  user: {
241
241
  code: string;
242
- multiple: boolean;
243
- rules: string;
242
+ multiple: false;
243
+ rules: "readonly";
244
244
  };
245
245
  };
246
246
  };
@@ -253,20 +253,20 @@ export declare const schemeModelDb: {
253
253
  index: string;
254
254
  presentation: string;
255
255
  fields: {
256
- id: string;
257
- bookId: string;
258
- title: string;
259
- content: string;
260
- order: string;
261
- created_at: string;
262
- updated_at: string;
263
- ia_lock: string;
256
+ id: "id (readonly)";
257
+ bookId: "id";
258
+ title: "text-long (required)";
259
+ content: "text-area";
260
+ order: "number";
261
+ created_at: "date (readonly)";
262
+ updated_at: "date";
263
+ ia_lock: "boolean (private readonly)";
264
264
  };
265
265
  fks: {
266
266
  book: {
267
267
  code: string;
268
- multiple: boolean;
269
- rules: string;
268
+ multiple: false;
269
+ rules: "readonly";
270
270
  };
271
271
  };
272
272
  };
@@ -279,26 +279,26 @@ export declare const schemeModelDb: {
279
279
  index: string;
280
280
  presentation: string;
281
281
  fields: {
282
- id: string;
283
- userId: string;
284
- bookId: string;
285
- description: string;
286
- targetWordCount: string;
287
- deadline: string;
288
- created_at: string;
289
- updated_at: string;
290
- ia_lock: string;
282
+ id: "id (readonly)";
283
+ userId: "id";
284
+ bookId: "id";
285
+ description: "text (required)";
286
+ targetWordCount: "number";
287
+ deadline: "date";
288
+ created_at: "date (readonly)";
289
+ updated_at: "date";
290
+ ia_lock: "boolean (private)";
291
291
  };
292
292
  fks: {
293
293
  user: {
294
294
  code: string;
295
- multiple: boolean;
296
- rules: string;
295
+ multiple: false;
296
+ rules: "readonly";
297
297
  };
298
298
  book: {
299
299
  code: string;
300
- multiple: boolean;
301
- rules: string;
300
+ multiple: false;
301
+ rules: "readonly";
302
302
  };
303
303
  };
304
304
  };
@@ -311,42 +311,42 @@ export declare const schemeModelDb: {
311
311
  index: string;
312
312
  presentation: string;
313
313
  fields: {
314
- id: string;
315
- bookId: string;
316
- characterLinkIds: string;
317
- characterAttributesIds: string;
318
- firstName: string;
319
- lastName: string;
320
- nickname: string;
321
- age: string;
322
- gender: string;
323
- occupation: string;
324
- role: string;
325
- description: string;
326
- backstory: string;
327
- physicalDescription: string;
328
- personalityTraits: string;
329
- goals: string;
330
- conflicts: string;
331
- created_at: string;
332
- updated_at: string;
333
- ia_lock: string;
314
+ id: "id (readonly)";
315
+ bookId: "id";
316
+ characterLinkIds: "array-of-fk-characterLink.id (private)";
317
+ characterAttributesIds: "array-of-fk-characterAttributes.id (private)";
318
+ firstName: "text (required)";
319
+ lastName: "text";
320
+ nickname: "text";
321
+ age: "number";
322
+ gender: "text";
323
+ occupation: "text";
324
+ role: "text";
325
+ description: "text-area";
326
+ backstory: "text-area";
327
+ physicalDescription: "text-area";
328
+ personalityTraits: "array-of-text";
329
+ goals: "text-area";
330
+ conflicts: "text-area";
331
+ created_at: "date (readonly private)";
332
+ updated_at: "date (readonly private)";
333
+ ia_lock: "boolean (private)";
334
334
  };
335
335
  fks: {
336
336
  characterAttributes: {
337
337
  code: string;
338
- multiple: boolean;
339
- rules: string;
338
+ multiple: true;
339
+ rules: "";
340
340
  };
341
341
  book: {
342
342
  code: string;
343
- multiple: boolean;
344
- rules: string;
343
+ multiple: false;
344
+ rules: "readonly";
345
345
  };
346
346
  characterLink: {
347
347
  code: string;
348
- multiple: boolean;
349
- rules: string;
348
+ multiple: true;
349
+ rules: "";
350
350
  };
351
351
  };
352
352
  };
@@ -359,11 +359,11 @@ export declare const schemeModelDb: {
359
359
  index: string;
360
360
  presentation: string;
361
361
  fields: {
362
- id: string;
363
- attribute: string;
364
- name: string;
365
- created_at: string;
366
- updated_at: string;
362
+ id: "id (readonly)";
363
+ attribute: "text";
364
+ name: "text";
365
+ created_at: "date (readonly)";
366
+ updated_at: "date";
367
367
  };
368
368
  fks: {};
369
369
  };
@@ -376,17 +376,17 @@ export declare const schemeModelDb: {
376
376
  index: string;
377
377
  presentation: string;
378
378
  fields: {
379
- id: string;
380
- characterId: string;
381
- type: string;
382
- description: string;
383
- active: string;
379
+ id: "id";
380
+ characterId: "array-of-fk-character.id";
381
+ type: "text-short";
382
+ description: "text-medium";
383
+ active: "boolean";
384
384
  };
385
385
  fks: {
386
386
  character: {
387
387
  code: string;
388
- multiple: boolean;
389
- rules: string;
388
+ multiple: true;
389
+ rules: "";
390
390
  };
391
391
  };
392
392
  };
@@ -399,27 +399,27 @@ export declare const schemeModelDb: {
399
399
  index: string;
400
400
  presentation: string;
401
401
  fields: {
402
- id: string;
403
- characterId: string;
404
- chapterId: string;
405
- status: string;
406
- role: string;
407
- actions: string;
408
- development: string;
409
- notes: string;
410
- created_at: string;
411
- updated_at: string;
402
+ id: "id (readonly)";
403
+ characterId: "id";
404
+ chapterId: "id";
405
+ status: "text";
406
+ role: "text";
407
+ actions: "text-long";
408
+ development: "text-area";
409
+ notes: "text-long";
410
+ created_at: "date (readonly)";
411
+ updated_at: "date";
412
412
  };
413
413
  fks: {
414
414
  character: {
415
415
  code: string;
416
- multiple: boolean;
417
- rules: string;
416
+ multiple: false;
417
+ rules: "readonly";
418
418
  };
419
419
  chapter: {
420
420
  code: string;
421
- multiple: boolean;
422
- rules: string;
421
+ multiple: false;
422
+ rules: "readonly";
423
423
  };
424
424
  };
425
425
  };
@@ -432,20 +432,20 @@ export declare const schemeModelDb: {
432
432
  index: string;
433
433
  presentation: string;
434
434
  fields: {
435
- id: string;
436
- bookId: string;
437
- name: string;
438
- category: string;
439
- content: string;
440
- created_at: string;
441
- updated_at: string;
442
- ia_lock: string;
435
+ id: "id (readonly)";
436
+ bookId: "id";
437
+ name: "text (required)";
438
+ category: "text";
439
+ content: "text-area";
440
+ created_at: "date (readonly)";
441
+ updated_at: "date";
442
+ ia_lock: "boolean (private)";
443
443
  };
444
444
  fks: {
445
445
  book: {
446
446
  code: string;
447
- multiple: boolean;
448
- rules: string;
447
+ multiple: false;
448
+ rules: "readonly";
449
449
  };
450
450
  };
451
451
  };
@@ -0,0 +1,13 @@
1
+ export type FieldTypeId = 'id' | 'text' | 'text-short' | 'text-medium' | 'text-long' | 'text-area' | 'number' | 'boolean' | 'date' | 'email' | 'password' | 'object-any' | `fk-${string}.id` | `array-of-${string}` | `object-of-${string}` | `array-of-fk-${string}.id`;
2
+ export interface FieldTypeDef {
3
+ id: FieldTypeId;
4
+ formatter: (value: any) => any;
5
+ validator?: (value: any) => boolean;
6
+ }
7
+ export declare function registerFieldType(def: FieldTypeDef): void;
8
+ /**
9
+ * Ajoute plusieurs types de champs d'un coup
10
+ */
11
+ export declare function registerFieldTypes(defs: FieldTypeDef[]): void;
12
+ export declare function getFieldType(id: FieldTypeId): FieldTypeDef | undefined;
13
+ export declare function getAllFieldTypes(): FieldTypeDef[];
@@ -0,0 +1,67 @@
1
+ // src/lib/db/fieldTypes.ts
2
+ const fieldTypeRegistry = {};
3
+ export function registerFieldType(def) {
4
+ fieldTypeRegistry[def.id] = def;
5
+ }
6
+ /**
7
+ * Ajoute plusieurs types de champs d'un coup
8
+ */
9
+ export function registerFieldTypes(defs) {
10
+ defs.forEach(registerFieldType);
11
+ }
12
+ export function getFieldType(id) {
13
+ return fieldTypeRegistry[id];
14
+ }
15
+ export function getAllFieldTypes() {
16
+ return Object.values(fieldTypeRegistry);
17
+ }
18
+ // Enregistrement des types de base
19
+ registerFieldType({
20
+ id: 'id',
21
+ formatter: (v) => v
22
+ });
23
+ registerFieldType({
24
+ id: 'text',
25
+ formatter: (v) => (typeof v === 'string' ? v : String(v))
26
+ });
27
+ registerFieldType({
28
+ id: 'text-short',
29
+ formatter: (v) => (typeof v === 'string' ? v : String(v))
30
+ });
31
+ registerFieldType({
32
+ id: 'text-medium',
33
+ formatter: (v) => (typeof v === 'string' ? v : String(v))
34
+ });
35
+ registerFieldType({
36
+ id: 'text-long',
37
+ formatter: (v) => (typeof v === 'string' ? v : String(v))
38
+ });
39
+ registerFieldType({
40
+ id: 'text-area',
41
+ formatter: (v) => (typeof v === 'string' ? v : String(v))
42
+ });
43
+ registerFieldType({
44
+ id: 'number',
45
+ formatter: (v) => Number(v)
46
+ });
47
+ registerFieldType({
48
+ id: 'boolean',
49
+ formatter: (v) => Boolean(v)
50
+ });
51
+ registerFieldType({
52
+ id: 'date',
53
+ formatter: (v) => (v ? new Date(v) : null)
54
+ });
55
+ registerFieldType({
56
+ id: 'email',
57
+ formatter: (v) => (typeof v === 'string' ? v : String(v))
58
+ });
59
+ registerFieldType({
60
+ id: 'password',
61
+ formatter: (v) => (typeof v === 'string' ? v : String(v))
62
+ });
63
+ registerFieldType({
64
+ id: 'object-any',
65
+ formatter: (v) => v
66
+ });
67
+ // Pour les types dynamiques (fk-*, array-of-*) il faudra un traitement spécial à l'enregistrement
@@ -1,6 +1,6 @@
1
1
  import type { DBAgent, DbAgentPrompt } from '$types/db';
2
2
  import { type IdbqModel } from '@medyll/idae-idbql';
3
- import type { DbDataModelTs } from './dataModel.js';
3
+ import type { DbDataModelTs } from '../db/dataModel.js';
4
4
  export declare const schemeModelTestDb: {
5
5
  agent: {
6
6
  keyPath: string;
@@ -4,7 +4,8 @@
4
4
  -->
5
5
 
6
6
  <script lang="ts" generics="COL = Record<string,any>">
7
- import { IDbFormValidate } from '../main/machineDb.js';
7
+
8
+ import { IDbFormValidate } from '../main/IDbFormValidate';
8
9
  import type { CreateUpdateProps } from './types';
9
10
  import CollectionReverseFks from './CollectionReverseFks.svelte';
10
11
  import FieldInput from './FieldValue.svelte';