@happyvertical/smrt-fields 0.40.61 → 0.40.62

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 (68) hide show
  1. package/README.md +125 -112
  2. package/dist/chunks/FieldPolicyCollection--RxukfCX.js +1218 -0
  3. package/dist/chunks/FieldPolicyCollection--RxukfCX.js.map +1 -0
  4. package/dist/collections/FieldPolicySuggestionCollection.d.ts +160 -0
  5. package/dist/collections/FieldPolicySuggestionCollection.d.ts.map +1 -0
  6. package/dist/collections/FieldUsageCounterCollection.d.ts +143 -0
  7. package/dist/collections/FieldUsageCounterCollection.d.ts.map +1 -0
  8. package/dist/deterministic-id.d.ts +18 -0
  9. package/dist/deterministic-id.d.ts.map +1 -0
  10. package/dist/field-definitions.d.ts +8 -0
  11. package/dist/field-definitions.d.ts.map +1 -1
  12. package/dist/index.d.ts +8 -2
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1565 -1077
  15. package/dist/index.js.map +1 -1
  16. package/dist/manifest.json +1442 -188
  17. package/dist/models/FieldPolicySuggestion.d.ts +132 -0
  18. package/dist/models/FieldPolicySuggestion.d.ts.map +1 -0
  19. package/dist/models/FieldUsageCounter.d.ts +178 -0
  20. package/dist/models/FieldUsageCounter.d.ts.map +1 -0
  21. package/dist/models/FieldUsageReportReceipt.d.ts +25 -0
  22. package/dist/models/FieldUsageReportReceipt.d.ts.map +1 -0
  23. package/dist/smrt-knowledge.json +402 -5
  24. package/dist/svelte/__tests__/FieldPolicyControlPanel.test.js +54 -0
  25. package/dist/svelte/__tests__/ObjectForm.test.js +131 -0
  26. package/dist/svelte/__tests__/UsageLearning.test.js +140 -0
  27. package/dist/svelte/__tests__/fixtures/ObjectFormActionsFixture.svelte +21 -4
  28. package/dist/svelte/__tests__/fixtures/ObjectFormActionsFixture.svelte.d.ts +5 -1
  29. package/dist/svelte/__tests__/fixtures/ObjectFormActionsFixture.svelte.d.ts.map +1 -1
  30. package/dist/svelte/__tests__/fixtures/SuggestionGearFixture.svelte +23 -0
  31. package/dist/svelte/__tests__/fixtures/SuggestionGearFixture.svelte.d.ts +10 -0
  32. package/dist/svelte/__tests__/fixtures/SuggestionGearFixture.svelte.d.ts.map +1 -0
  33. package/dist/svelte/components/FieldPolicyControlPanel.svelte +28 -1
  34. package/dist/svelte/components/FieldPolicyControlPanel.svelte.d.ts +3 -0
  35. package/dist/svelte/components/FieldPolicyControlPanel.svelte.d.ts.map +1 -1
  36. package/dist/svelte/components/FieldPolicyGearButton.svelte +8 -1
  37. package/dist/svelte/components/FieldPolicyGearButton.svelte.d.ts.map +1 -1
  38. package/dist/svelte/components/FieldPolicyGearProvider.svelte +34 -0
  39. package/dist/svelte/components/FieldPolicyGearProvider.svelte.d.ts +3 -0
  40. package/dist/svelte/components/FieldPolicyGearProvider.svelte.d.ts.map +1 -1
  41. package/dist/svelte/components/FieldPolicySuggestionQueue.svelte +135 -0
  42. package/dist/svelte/components/FieldPolicySuggestionQueue.svelte.d.ts +11 -0
  43. package/dist/svelte/components/FieldPolicySuggestionQueue.svelte.d.ts.map +1 -0
  44. package/dist/svelte/components/ObjectForm.svelte +91 -2
  45. package/dist/svelte/components/ObjectForm.svelte.d.ts +11 -1
  46. package/dist/svelte/components/ObjectForm.svelte.d.ts.map +1 -1
  47. package/dist/svelte/gear-context.svelte.d.ts +2 -0
  48. package/dist/svelte/gear-context.svelte.d.ts.map +1 -1
  49. package/dist/svelte/index.d.ts +6 -1
  50. package/dist/svelte/index.d.ts.map +1 -1
  51. package/dist/svelte/index.js +4 -1
  52. package/dist/svelte/suggestions.d.ts +38 -0
  53. package/dist/svelte/suggestions.d.ts.map +1 -0
  54. package/dist/svelte/suggestions.js +68 -0
  55. package/dist/svelte/usage-capture.d.ts +63 -0
  56. package/dist/svelte/usage-capture.d.ts.map +1 -0
  57. package/dist/svelte/usage-capture.js +61 -0
  58. package/dist/types.d.ts +40 -0
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/types.js +7 -1
  61. package/dist/types.js.map +1 -1
  62. package/dist/usage-learning.d.ts +201 -0
  63. package/dist/usage-learning.d.ts.map +1 -0
  64. package/dist/usage-schedules.d.ts +110 -0
  65. package/dist/usage-schedules.d.ts.map +1 -0
  66. package/dist/users-module.d.ts +30 -0
  67. package/dist/users-module.d.ts.map +1 -0
  68. package/package.json +8 -8
@@ -2,8 +2,108 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-fields",
5
- "packageVersion": "0.40.61",
5
+ "packageVersion": "0.40.62",
6
6
  "objects": {
7
+ "@happyvertical/smrt-fields:FieldUsageLearningAgent": {
8
+ "name": "fieldusagelearningagent",
9
+ "className": "FieldUsageLearningAgent",
10
+ "qualifiedName": "@happyvertical/smrt-fields:FieldUsageLearningAgent",
11
+ "collection": "fieldusagelearningagents",
12
+ "filePath": "/home/runner/_work/smrt/smrt/packages/fields/src/usage-learning.ts",
13
+ "packageName": "@happyvertical/smrt-fields",
14
+ "fields": {},
15
+ "methods": {
16
+ "runUsageMaintenance": {
17
+ "name": "runUsageMaintenance",
18
+ "async": true,
19
+ "parameters": [
20
+ {
21
+ "name": "args",
22
+ "type": "Record<string>",
23
+ "optional": true
24
+ }
25
+ ],
26
+ "returnType": "Promise<FieldUsageMaintenanceSummary>",
27
+ "isStatic": false,
28
+ "isPublic": true
29
+ },
30
+ "runSuggestionGeneration": {
31
+ "name": "runSuggestionGeneration",
32
+ "async": true,
33
+ "parameters": [
34
+ {
35
+ "name": "args",
36
+ "type": "Record<string>",
37
+ "optional": true
38
+ }
39
+ ],
40
+ "returnType": "Promise<FieldUsageSuggestionRunSummary>",
41
+ "isStatic": false,
42
+ "isPublic": true
43
+ }
44
+ },
45
+ "decoratorConfig": {
46
+ "tableName": "_smrt_field_usage_learning_agents",
47
+ "api": {
48
+ "include": []
49
+ },
50
+ "cli": false,
51
+ "mcp": {
52
+ "include": []
53
+ }
54
+ },
55
+ "extends": "SmrtObject",
56
+ "exportName": "FieldUsageLearningAgent",
57
+ "collectionExportName": "FieldUsageLearningAgentCollection",
58
+ "schema": {
59
+ "tableName": "_smrt_field_usage_learning_agents",
60
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_usage_learning_agents\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
61
+ "columns": {
62
+ "id": {
63
+ "type": "UUID",
64
+ "primaryKey": true,
65
+ "referenceKind": "id",
66
+ "notNull": true
67
+ },
68
+ "slug": {
69
+ "type": "TEXT",
70
+ "notNull": true
71
+ },
72
+ "context": {
73
+ "type": "TEXT",
74
+ "notNull": true,
75
+ "default": ""
76
+ },
77
+ "created_at": {
78
+ "type": "TIMESTAMP",
79
+ "notNull": true,
80
+ "default": "current_timestamp"
81
+ },
82
+ "updated_at": {
83
+ "type": "TIMESTAMP",
84
+ "notNull": true,
85
+ "default": "current_timestamp"
86
+ }
87
+ },
88
+ "indexes": [
89
+ {
90
+ "name": "_smrt_field_usage_learning_agents_id_idx",
91
+ "columns": [
92
+ "id"
93
+ ]
94
+ },
95
+ {
96
+ "name": "_smrt_field_usage_learning_agents_slug_context_idx",
97
+ "columns": [
98
+ "slug",
99
+ "context"
100
+ ],
101
+ "unique": true
102
+ }
103
+ ],
104
+ "version": "183ee1d8"
105
+ }
106
+ },
7
107
  "@happyvertical/smrt-fields:FieldPolicyCollection": {
8
108
  "name": "fieldpolicycollection",
9
109
  "className": "FieldPolicyCollection",
@@ -202,184 +302,539 @@
202
302
  "version": "13aa748c"
203
303
  }
204
304
  },
205
- "@happyvertical/smrt-fields:FieldPolicy": {
206
- "name": "fieldpolicy",
207
- "className": "FieldPolicy",
208
- "qualifiedName": "@happyvertical/smrt-fields:FieldPolicy",
209
- "collection": "fieldpolicies",
210
- "filePath": "/home/runner/_work/smrt/smrt/packages/fields/src/models/FieldPolicy.ts",
305
+ "@happyvertical/smrt-fields:FieldPolicySuggestionCollection": {
306
+ "name": "fieldpolicysuggestioncollection",
307
+ "className": "FieldPolicySuggestionCollection",
308
+ "qualifiedName": "@happyvertical/smrt-fields:FieldPolicySuggestionCollection",
309
+ "collection": "fieldpolicysuggestions",
310
+ "filePath": "/home/runner/_work/smrt/smrt/packages/fields/src/collections/FieldPolicySuggestionCollection.ts",
211
311
  "packageName": "@happyvertical/smrt-fields",
212
- "fields": {
213
- "objectRef": {
214
- "type": "text",
215
- "required": true,
216
- "default": "",
217
- "_meta": {
218
- "required": true
219
- }
220
- },
221
- "fieldName": {
222
- "type": "text",
223
- "required": true,
224
- "default": "",
225
- "_meta": {
226
- "required": true
227
- }
228
- },
229
- "scopeType": {
230
- "type": "text",
231
- "required": true,
232
- "default": "app",
233
- "_meta": {
234
- "required": true
235
- }
236
- },
237
- "tenantId": {
238
- "type": "text",
239
- "required": false,
240
- "_meta": {
241
- "sqlType": "UUID",
242
- "nullable": true,
243
- "__tenancy": {
244
- "isTenantIdField": true,
245
- "autoFilter": true,
246
- "required": false,
247
- "autoPopulate": true,
248
- "nullable": true
249
- }
250
- }
251
- },
252
- "userId": {
253
- "type": "crossPackageRef",
254
- "required": false,
255
- "related": "@happyvertical/smrt-users:User",
256
- "_meta": {
257
- "nullable": true
258
- }
259
- },
260
- "scopeKey": {
261
- "type": "text",
262
- "required": true,
263
- "_meta": {
264
- "required": true
265
- }
266
- },
267
- "defaultValue": {
268
- "type": "text",
269
- "required": false,
270
- "_meta": {
271
- "nullable": true
272
- }
273
- },
274
- "visibility": {
275
- "type": "text",
276
- "required": false,
277
- "_meta": {
278
- "nullable": true
279
- }
280
- },
281
- "help": {
282
- "type": "text",
283
- "required": false,
284
- "_meta": {
285
- "nullable": true
286
- }
287
- },
288
- "label": {
289
- "type": "text",
290
- "required": false,
291
- "_meta": {
292
- "nullable": true
293
- }
294
- },
295
- "displayOrder": {
296
- "type": "integer",
297
- "required": false,
298
- "_meta": {
299
- "nullable": true
300
- }
301
- },
302
- "locked": {
303
- "type": "boolean",
304
- "required": false,
305
- "_meta": {
306
- "nullable": true
307
- }
308
- },
309
- "updatedBy": {
310
- "type": "crossPackageRef",
311
- "required": false,
312
- "related": "@happyvertical/smrt-users:User",
313
- "_meta": {
314
- "nullable": true
315
- }
316
- }
317
- },
312
+ "fields": {},
318
313
  "methods": {
319
- "getDefaultValue": {
320
- "name": "getDefaultValue",
321
- "async": false,
322
- "parameters": [],
323
- "returnType": "any",
324
- "isStatic": false,
325
- "isPublic": true
326
- },
327
- "setDefaultValue": {
328
- "name": "setDefaultValue",
329
- "async": false,
314
+ "pendingSuggestions": {
315
+ "name": "pendingSuggestions",
316
+ "async": true,
330
317
  "parameters": [
331
318
  {
332
- "name": "value",
333
- "type": "any",
334
- "optional": false
319
+ "name": "options",
320
+ "type": "object",
321
+ "optional": true
335
322
  }
336
323
  ],
337
- "returnType": "void",
324
+ "returnType": "Promise<PendingFieldPolicySuggestionsResult>",
338
325
  "isStatic": false,
339
326
  "isPublic": true
340
327
  },
341
- "save": {
342
- "name": "save",
328
+ "acceptSuggestion": {
329
+ "name": "acceptSuggestion",
343
330
  "async": true,
344
- "parameters": [],
345
- "returnType": "Promise",
331
+ "parameters": [
332
+ {
333
+ "name": "options",
334
+ "type": "object",
335
+ "optional": true
336
+ }
337
+ ],
338
+ "returnType": "Promise<AcceptFieldPolicySuggestionResult>",
346
339
  "isStatic": false,
347
340
  "isPublic": true
348
341
  },
349
- "delete": {
350
- "name": "delete",
342
+ "dismissSuggestion": {
343
+ "name": "dismissSuggestion",
351
344
  "async": true,
352
- "parameters": [],
353
- "returnType": "Promise<void>",
345
+ "parameters": [
346
+ {
347
+ "name": "options",
348
+ "type": "object",
349
+ "optional": true
350
+ }
351
+ ],
352
+ "returnType": "Promise<DismissFieldPolicySuggestionResult>",
354
353
  "isStatic": false,
355
354
  "isPublic": true
356
355
  }
357
356
  },
358
357
  "decoratorConfig": {
359
- "tableName": "_smrt_field_policies",
360
358
  "conflictColumns": [
361
359
  "object_ref",
362
360
  "field_name",
363
- "scope_type",
364
- "scope_key"
361
+ "tenant_id",
362
+ "kind",
363
+ "active_key"
365
364
  ],
366
365
  "api": {
367
366
  "include": [
368
- "create",
369
- "update",
370
- "delete"
367
+ "pendingSuggestions",
368
+ "acceptSuggestion",
369
+ "dismissSuggestion"
371
370
  ],
372
- "principalContext": true
371
+ "principalContext": true,
372
+ "routes": {
373
+ "pendingSuggestions": {
374
+ "scope": "collection",
375
+ "method": "POST",
376
+ "path": "pending"
377
+ },
378
+ "acceptSuggestion": {
379
+ "scope": "collection",
380
+ "method": "POST",
381
+ "path": "accept"
382
+ },
383
+ "dismissSuggestion": {
384
+ "scope": "collection",
385
+ "method": "POST",
386
+ "path": "dismiss"
387
+ }
388
+ }
373
389
  },
374
- "cli": {
375
- "include": [
376
- "create",
377
- "update",
378
- "delete"
379
- ],
380
- "exclude": [
381
- "getDefaultValue",
382
- "setDefaultValue"
390
+ "cli": false,
391
+ "mcp": false,
392
+ "tableName": "_smrt_field_policy_suggestions"
393
+ },
394
+ "extends": "SmrtCollection",
395
+ "extendsTypeArg": "FieldPolicySuggestion",
396
+ "exportName": "FieldPolicySuggestionCollection",
397
+ "collectionExportName": "FieldPolicySuggestionCollectionCollection",
398
+ "schema": {
399
+ "tableName": "_smrt_field_policy_suggestions",
400
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_policy_suggestions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
401
+ "columns": {
402
+ "id": {
403
+ "type": "UUID",
404
+ "primaryKey": true,
405
+ "referenceKind": "id",
406
+ "notNull": true
407
+ },
408
+ "slug": {
409
+ "type": "TEXT",
410
+ "notNull": true
411
+ },
412
+ "context": {
413
+ "type": "TEXT",
414
+ "notNull": true,
415
+ "default": ""
416
+ },
417
+ "created_at": {
418
+ "type": "TIMESTAMP",
419
+ "notNull": true,
420
+ "default": "current_timestamp"
421
+ },
422
+ "updated_at": {
423
+ "type": "TIMESTAMP",
424
+ "notNull": true,
425
+ "default": "current_timestamp"
426
+ }
427
+ },
428
+ "indexes": [
429
+ {
430
+ "name": "_smrt_field_policy_suggestions_id_idx",
431
+ "columns": [
432
+ "id"
433
+ ]
434
+ },
435
+ {
436
+ "name": "_smrt_field_policy_suggestions_object_ref_field_name_idx",
437
+ "columns": [
438
+ "object_ref",
439
+ "field_name",
440
+ "tenant_id",
441
+ "kind",
442
+ "active_key"
443
+ ],
444
+ "unique": true
445
+ }
446
+ ],
447
+ "version": "853df86d"
448
+ }
449
+ },
450
+ "@happyvertical/smrt-fields:FieldUsageCounterCollection": {
451
+ "name": "fieldusagecountercollection",
452
+ "className": "FieldUsageCounterCollection",
453
+ "qualifiedName": "@happyvertical/smrt-fields:FieldUsageCounterCollection",
454
+ "collection": "fieldusagecounters",
455
+ "filePath": "/home/runner/_work/smrt/smrt/packages/fields/src/collections/FieldUsageCounterCollection.ts",
456
+ "packageName": "@happyvertical/smrt-fields",
457
+ "fields": {},
458
+ "methods": {
459
+ "reportUsage": {
460
+ "name": "reportUsage",
461
+ "async": true,
462
+ "parameters": [
463
+ {
464
+ "name": "options",
465
+ "type": "object",
466
+ "optional": true
467
+ }
468
+ ],
469
+ "returnType": "Promise<FieldUsageReportResult>",
470
+ "isStatic": false,
471
+ "isPublic": true
472
+ },
473
+ "listWindow": {
474
+ "name": "listWindow",
475
+ "async": true,
476
+ "parameters": [
477
+ {
478
+ "name": "options",
479
+ "type": "object",
480
+ "optional": false
481
+ }
482
+ ],
483
+ "returnType": "Promise<FieldUsageCounter[]>",
484
+ "isStatic": false,
485
+ "isPublic": true
486
+ }
487
+ },
488
+ "decoratorConfig": {
489
+ "conflictColumns": [
490
+ "object_ref",
491
+ "field_name",
492
+ "tenant_id",
493
+ "period"
494
+ ],
495
+ "api": {
496
+ "include": [
497
+ "reportUsage"
498
+ ],
499
+ "principalContext": true,
500
+ "routes": {
501
+ "reportUsage": {
502
+ "scope": "collection",
503
+ "method": "POST",
504
+ "path": "report"
505
+ }
506
+ }
507
+ },
508
+ "cli": false,
509
+ "mcp": false,
510
+ "tableName": "_smrt_field_usage_counters"
511
+ },
512
+ "extends": "SmrtCollection",
513
+ "extendsTypeArg": "FieldUsageCounter",
514
+ "exportName": "FieldUsageCounterCollection",
515
+ "collectionExportName": "FieldUsageCounterCollectionCollection",
516
+ "schema": {
517
+ "tableName": "_smrt_field_usage_counters",
518
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_usage_counters\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
519
+ "columns": {
520
+ "id": {
521
+ "type": "UUID",
522
+ "primaryKey": true,
523
+ "referenceKind": "id",
524
+ "notNull": true
525
+ },
526
+ "slug": {
527
+ "type": "TEXT",
528
+ "notNull": true
529
+ },
530
+ "context": {
531
+ "type": "TEXT",
532
+ "notNull": true,
533
+ "default": ""
534
+ },
535
+ "created_at": {
536
+ "type": "TIMESTAMP",
537
+ "notNull": true,
538
+ "default": "current_timestamp"
539
+ },
540
+ "updated_at": {
541
+ "type": "TIMESTAMP",
542
+ "notNull": true,
543
+ "default": "current_timestamp"
544
+ }
545
+ },
546
+ "indexes": [
547
+ {
548
+ "name": "_smrt_field_usage_counters_id_idx",
549
+ "columns": [
550
+ "id"
551
+ ]
552
+ },
553
+ {
554
+ "name": "_smrt_field_usage_counters_object_ref_field_name_idx",
555
+ "columns": [
556
+ "object_ref",
557
+ "field_name",
558
+ "tenant_id",
559
+ "period"
560
+ ],
561
+ "unique": true
562
+ }
563
+ ],
564
+ "version": "8bd9beae"
565
+ }
566
+ },
567
+ "@happyvertical/smrt-fields:FieldUsageReportReceiptCollection": {
568
+ "name": "fieldusagereportreceiptcollection",
569
+ "className": "FieldUsageReportReceiptCollection",
570
+ "qualifiedName": "@happyvertical/smrt-fields:FieldUsageReportReceiptCollection",
571
+ "collection": "fieldusagereportreceipts",
572
+ "filePath": "/home/runner/_work/smrt/smrt/packages/fields/src/collections/FieldUsageCounterCollection.ts",
573
+ "packageName": "@happyvertical/smrt-fields",
574
+ "fields": {},
575
+ "methods": {
576
+ "claim": {
577
+ "name": "claim",
578
+ "async": true,
579
+ "parameters": [
580
+ {
581
+ "name": "options",
582
+ "type": "object",
583
+ "optional": false
584
+ }
585
+ ],
586
+ "returnType": "Promise<boolean>",
587
+ "isStatic": false,
588
+ "isPublic": true
589
+ }
590
+ },
591
+ "decoratorConfig": {
592
+ "conflictColumns": [
593
+ "tenant_id",
594
+ "user_id",
595
+ "object_ref",
596
+ "field_name",
597
+ "period"
598
+ ],
599
+ "api": false,
600
+ "cli": false,
601
+ "mcp": false,
602
+ "tableName": "_smrt_field_usage_report_receipts"
603
+ },
604
+ "extends": "SmrtCollection",
605
+ "extendsTypeArg": "FieldUsageReportReceipt",
606
+ "exportName": "FieldUsageReportReceiptCollection",
607
+ "collectionExportName": "FieldUsageReportReceiptCollectionCollection",
608
+ "schema": {
609
+ "tableName": "_smrt_field_usage_report_receipts",
610
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_usage_report_receipts\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
611
+ "columns": {
612
+ "id": {
613
+ "type": "UUID",
614
+ "primaryKey": true,
615
+ "referenceKind": "id",
616
+ "notNull": true
617
+ },
618
+ "slug": {
619
+ "type": "TEXT",
620
+ "notNull": true
621
+ },
622
+ "context": {
623
+ "type": "TEXT",
624
+ "notNull": true,
625
+ "default": ""
626
+ },
627
+ "created_at": {
628
+ "type": "TIMESTAMP",
629
+ "notNull": true,
630
+ "default": "current_timestamp"
631
+ },
632
+ "updated_at": {
633
+ "type": "TIMESTAMP",
634
+ "notNull": true,
635
+ "default": "current_timestamp"
636
+ }
637
+ },
638
+ "indexes": [
639
+ {
640
+ "name": "_smrt_field_usage_report_receipts_id_idx",
641
+ "columns": [
642
+ "id"
643
+ ]
644
+ },
645
+ {
646
+ "name": "_smrt_field_usage_report_receipts_tenant_id_user_id_idx",
647
+ "columns": [
648
+ "tenant_id",
649
+ "user_id",
650
+ "object_ref",
651
+ "field_name",
652
+ "period"
653
+ ],
654
+ "unique": true
655
+ }
656
+ ],
657
+ "version": "2e77b775"
658
+ }
659
+ },
660
+ "@happyvertical/smrt-fields:FieldPolicy": {
661
+ "name": "fieldpolicy",
662
+ "className": "FieldPolicy",
663
+ "qualifiedName": "@happyvertical/smrt-fields:FieldPolicy",
664
+ "collection": "fieldpolicies",
665
+ "filePath": "/home/runner/_work/smrt/smrt/packages/fields/src/models/FieldPolicy.ts",
666
+ "packageName": "@happyvertical/smrt-fields",
667
+ "fields": {
668
+ "objectRef": {
669
+ "type": "text",
670
+ "required": true,
671
+ "default": "",
672
+ "_meta": {
673
+ "required": true
674
+ }
675
+ },
676
+ "fieldName": {
677
+ "type": "text",
678
+ "required": true,
679
+ "default": "",
680
+ "_meta": {
681
+ "required": true
682
+ }
683
+ },
684
+ "scopeType": {
685
+ "type": "text",
686
+ "required": true,
687
+ "default": "app",
688
+ "_meta": {
689
+ "required": true
690
+ }
691
+ },
692
+ "tenantId": {
693
+ "type": "text",
694
+ "required": false,
695
+ "_meta": {
696
+ "sqlType": "UUID",
697
+ "nullable": true,
698
+ "__tenancy": {
699
+ "isTenantIdField": true,
700
+ "autoFilter": true,
701
+ "required": false,
702
+ "autoPopulate": true,
703
+ "nullable": true
704
+ }
705
+ }
706
+ },
707
+ "userId": {
708
+ "type": "crossPackageRef",
709
+ "required": false,
710
+ "related": "@happyvertical/smrt-users:User",
711
+ "_meta": {
712
+ "nullable": true
713
+ }
714
+ },
715
+ "scopeKey": {
716
+ "type": "text",
717
+ "required": true,
718
+ "_meta": {
719
+ "required": true
720
+ }
721
+ },
722
+ "defaultValue": {
723
+ "type": "text",
724
+ "required": false,
725
+ "_meta": {
726
+ "nullable": true
727
+ }
728
+ },
729
+ "visibility": {
730
+ "type": "text",
731
+ "required": false,
732
+ "_meta": {
733
+ "nullable": true
734
+ }
735
+ },
736
+ "help": {
737
+ "type": "text",
738
+ "required": false,
739
+ "_meta": {
740
+ "nullable": true
741
+ }
742
+ },
743
+ "label": {
744
+ "type": "text",
745
+ "required": false,
746
+ "_meta": {
747
+ "nullable": true
748
+ }
749
+ },
750
+ "displayOrder": {
751
+ "type": "integer",
752
+ "required": false,
753
+ "_meta": {
754
+ "nullable": true
755
+ }
756
+ },
757
+ "locked": {
758
+ "type": "boolean",
759
+ "required": false,
760
+ "_meta": {
761
+ "nullable": true
762
+ }
763
+ },
764
+ "updatedBy": {
765
+ "type": "crossPackageRef",
766
+ "required": false,
767
+ "related": "@happyvertical/smrt-users:User",
768
+ "_meta": {
769
+ "nullable": true
770
+ }
771
+ }
772
+ },
773
+ "methods": {
774
+ "getDefaultValue": {
775
+ "name": "getDefaultValue",
776
+ "async": false,
777
+ "parameters": [],
778
+ "returnType": "any",
779
+ "isStatic": false,
780
+ "isPublic": true
781
+ },
782
+ "setDefaultValue": {
783
+ "name": "setDefaultValue",
784
+ "async": false,
785
+ "parameters": [
786
+ {
787
+ "name": "value",
788
+ "type": "any",
789
+ "optional": false
790
+ }
791
+ ],
792
+ "returnType": "void",
793
+ "isStatic": false,
794
+ "isPublic": true
795
+ },
796
+ "save": {
797
+ "name": "save",
798
+ "async": true,
799
+ "parameters": [],
800
+ "returnType": "Promise",
801
+ "isStatic": false,
802
+ "isPublic": true
803
+ },
804
+ "delete": {
805
+ "name": "delete",
806
+ "async": true,
807
+ "parameters": [],
808
+ "returnType": "Promise<void>",
809
+ "isStatic": false,
810
+ "isPublic": true
811
+ }
812
+ },
813
+ "decoratorConfig": {
814
+ "tableName": "_smrt_field_policies",
815
+ "conflictColumns": [
816
+ "object_ref",
817
+ "field_name",
818
+ "scope_type",
819
+ "scope_key"
820
+ ],
821
+ "api": {
822
+ "include": [
823
+ "create",
824
+ "update",
825
+ "delete"
826
+ ],
827
+ "principalContext": true
828
+ },
829
+ "cli": {
830
+ "include": [
831
+ "create",
832
+ "update",
833
+ "delete"
834
+ ],
835
+ "exclude": [
836
+ "getDefaultValue",
837
+ "setDefaultValue"
383
838
  ]
384
839
  },
385
840
  "mcp": {
@@ -387,8 +842,642 @@
387
842
  }
388
843
  },
389
844
  "extends": "SmrtObject",
390
- "exportName": "FieldPolicy",
391
- "collectionExportName": "FieldPolicyCollection",
845
+ "exportName": "FieldPolicy",
846
+ "collectionExportName": "FieldPolicyCollection",
847
+ "validationRules": [
848
+ {
849
+ "field": "objectRef",
850
+ "rule": "required",
851
+ "fieldType": "text"
852
+ },
853
+ {
854
+ "field": "fieldName",
855
+ "rule": "required",
856
+ "fieldType": "text"
857
+ },
858
+ {
859
+ "field": "scopeType",
860
+ "rule": "required",
861
+ "fieldType": "text"
862
+ },
863
+ {
864
+ "field": "scopeKey",
865
+ "rule": "required",
866
+ "fieldType": "text"
867
+ }
868
+ ],
869
+ "schema": {
870
+ "tableName": "_smrt_field_policies",
871
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_policies\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"object_ref\" TEXT NOT NULL DEFAULT '',\n \"field_name\" TEXT NOT NULL DEFAULT '',\n \"scope_type\" TEXT NOT NULL DEFAULT 'app',\n \"tenant_id\" UUID,\n \"user_id\" UUID,\n \"scope_key\" TEXT NOT NULL,\n \"default_value\" TEXT,\n \"visibility\" TEXT,\n \"help\" TEXT,\n \"label\" TEXT,\n \"display_order\" INTEGER,\n \"locked\" BOOLEAN,\n \"updated_by\" UUID\n);",
872
+ "columns": {
873
+ "id": {
874
+ "type": "UUID",
875
+ "primaryKey": true,
876
+ "referenceKind": "id",
877
+ "notNull": true
878
+ },
879
+ "slug": {
880
+ "type": "TEXT",
881
+ "notNull": true
882
+ },
883
+ "context": {
884
+ "type": "TEXT",
885
+ "notNull": true,
886
+ "default": ""
887
+ },
888
+ "created_at": {
889
+ "type": "TIMESTAMP",
890
+ "notNull": true,
891
+ "default": "current_timestamp"
892
+ },
893
+ "updated_at": {
894
+ "type": "TIMESTAMP",
895
+ "notNull": true,
896
+ "default": "current_timestamp"
897
+ },
898
+ "object_ref": {
899
+ "type": "TEXT",
900
+ "notNull": true,
901
+ "unique": false,
902
+ "default": ""
903
+ },
904
+ "field_name": {
905
+ "type": "TEXT",
906
+ "notNull": true,
907
+ "unique": false,
908
+ "default": ""
909
+ },
910
+ "scope_type": {
911
+ "type": "TEXT",
912
+ "notNull": true,
913
+ "unique": false,
914
+ "default": "app"
915
+ },
916
+ "tenant_id": {
917
+ "type": "UUID",
918
+ "referenceKind": "tenantId",
919
+ "notNull": false,
920
+ "unique": false
921
+ },
922
+ "user_id": {
923
+ "type": "UUID",
924
+ "referenceKind": "crossPackageRef",
925
+ "notNull": false,
926
+ "unique": false
927
+ },
928
+ "scope_key": {
929
+ "type": "TEXT",
930
+ "notNull": true,
931
+ "unique": false
932
+ },
933
+ "default_value": {
934
+ "type": "TEXT",
935
+ "notNull": false,
936
+ "unique": false
937
+ },
938
+ "visibility": {
939
+ "type": "TEXT",
940
+ "notNull": false,
941
+ "unique": false
942
+ },
943
+ "help": {
944
+ "type": "TEXT",
945
+ "notNull": false,
946
+ "unique": false
947
+ },
948
+ "label": {
949
+ "type": "TEXT",
950
+ "notNull": false,
951
+ "unique": false
952
+ },
953
+ "display_order": {
954
+ "type": "INTEGER",
955
+ "notNull": false,
956
+ "unique": false
957
+ },
958
+ "locked": {
959
+ "type": "BOOLEAN",
960
+ "notNull": false,
961
+ "unique": false
962
+ },
963
+ "updated_by": {
964
+ "type": "UUID",
965
+ "referenceKind": "crossPackageRef",
966
+ "notNull": false,
967
+ "unique": false
968
+ }
969
+ },
970
+ "indexes": [
971
+ {
972
+ "name": "_smrt_field_policies_id_idx",
973
+ "columns": [
974
+ "id"
975
+ ]
976
+ },
977
+ {
978
+ "name": "_smrt_field_policies_object_ref_field_name_idx",
979
+ "columns": [
980
+ "object_ref",
981
+ "field_name",
982
+ "scope_type",
983
+ "scope_key"
984
+ ],
985
+ "unique": true
986
+ }
987
+ ],
988
+ "version": "34b355cc"
989
+ }
990
+ },
991
+ "@happyvertical/smrt-fields:FieldPolicySuggestion": {
992
+ "name": "fieldpolicysuggestion",
993
+ "className": "FieldPolicySuggestion",
994
+ "qualifiedName": "@happyvertical/smrt-fields:FieldPolicySuggestion",
995
+ "collection": "fieldpolicysuggestions",
996
+ "filePath": "/home/runner/_work/smrt/smrt/packages/fields/src/models/FieldPolicySuggestion.ts",
997
+ "packageName": "@happyvertical/smrt-fields",
998
+ "fields": {
999
+ "objectRef": {
1000
+ "type": "text",
1001
+ "required": true,
1002
+ "default": "",
1003
+ "_meta": {
1004
+ "required": true
1005
+ }
1006
+ },
1007
+ "fieldName": {
1008
+ "type": "text",
1009
+ "required": true,
1010
+ "default": "",
1011
+ "_meta": {
1012
+ "required": true
1013
+ }
1014
+ },
1015
+ "tenantId": {
1016
+ "type": "text",
1017
+ "required": true,
1018
+ "_meta": {
1019
+ "sqlType": "UUID",
1020
+ "__tenancy": {
1021
+ "isTenantIdField": true,
1022
+ "autoFilter": true,
1023
+ "required": true,
1024
+ "autoPopulate": true,
1025
+ "nullable": false
1026
+ }
1027
+ }
1028
+ },
1029
+ "kind": {
1030
+ "type": "text",
1031
+ "required": true,
1032
+ "default": "promote",
1033
+ "_meta": {
1034
+ "required": true
1035
+ }
1036
+ },
1037
+ "proposedValue": {
1038
+ "type": "text",
1039
+ "required": false,
1040
+ "_meta": {
1041
+ "nullable": true
1042
+ }
1043
+ },
1044
+ "evidence": {
1045
+ "type": "text",
1046
+ "required": false,
1047
+ "_meta": {}
1048
+ },
1049
+ "status": {
1050
+ "type": "text",
1051
+ "required": true,
1052
+ "default": "pending",
1053
+ "_meta": {
1054
+ "required": true
1055
+ }
1056
+ },
1057
+ "activeKey": {
1058
+ "type": "text",
1059
+ "required": true,
1060
+ "_meta": {
1061
+ "required": true
1062
+ }
1063
+ },
1064
+ "cooldownUntil": {
1065
+ "type": "datetime",
1066
+ "required": false,
1067
+ "_meta": {
1068
+ "nullable": true
1069
+ }
1070
+ },
1071
+ "decidedBy": {
1072
+ "type": "crossPackageRef",
1073
+ "required": false,
1074
+ "related": "@happyvertical/smrt-users:User",
1075
+ "_meta": {
1076
+ "nullable": true
1077
+ }
1078
+ },
1079
+ "decidedAt": {
1080
+ "type": "datetime",
1081
+ "required": false,
1082
+ "_meta": {
1083
+ "nullable": true
1084
+ }
1085
+ }
1086
+ },
1087
+ "methods": {
1088
+ "getEvidence": {
1089
+ "name": "getEvidence",
1090
+ "async": false,
1091
+ "parameters": [],
1092
+ "returnType": "Record<string>",
1093
+ "isStatic": false,
1094
+ "isPublic": true
1095
+ },
1096
+ "setEvidence": {
1097
+ "name": "setEvidence",
1098
+ "async": false,
1099
+ "parameters": [
1100
+ {
1101
+ "name": "evidence",
1102
+ "type": "Record<string>",
1103
+ "optional": false
1104
+ }
1105
+ ],
1106
+ "returnType": "void",
1107
+ "isStatic": false,
1108
+ "isPublic": true
1109
+ },
1110
+ "getProposedValue": {
1111
+ "name": "getProposedValue",
1112
+ "async": false,
1113
+ "parameters": [],
1114
+ "returnType": "any",
1115
+ "isStatic": false,
1116
+ "isPublic": true
1117
+ },
1118
+ "toSuggestionData": {
1119
+ "name": "toSuggestionData",
1120
+ "async": false,
1121
+ "parameters": [],
1122
+ "returnType": "FieldPolicySuggestionData",
1123
+ "isStatic": false,
1124
+ "isPublic": true
1125
+ },
1126
+ "save": {
1127
+ "name": "save",
1128
+ "async": true,
1129
+ "parameters": [],
1130
+ "returnType": "Promise",
1131
+ "isStatic": false,
1132
+ "isPublic": true
1133
+ },
1134
+ "delete": {
1135
+ "name": "delete",
1136
+ "async": true,
1137
+ "parameters": [],
1138
+ "returnType": "Promise<void>",
1139
+ "isStatic": false,
1140
+ "isPublic": true
1141
+ }
1142
+ },
1143
+ "decoratorConfig": {
1144
+ "tableName": "_smrt_field_policy_suggestions",
1145
+ "conflictColumns": [
1146
+ "object_ref",
1147
+ "field_name",
1148
+ "tenant_id",
1149
+ "kind",
1150
+ "active_key"
1151
+ ],
1152
+ "api": {
1153
+ "include": []
1154
+ },
1155
+ "cli": false,
1156
+ "mcp": {
1157
+ "include": []
1158
+ }
1159
+ },
1160
+ "extends": "SmrtObject",
1161
+ "exportName": "FieldPolicySuggestion",
1162
+ "collectionExportName": "FieldPolicySuggestionCollection",
1163
+ "validationRules": [
1164
+ {
1165
+ "field": "objectRef",
1166
+ "rule": "required",
1167
+ "fieldType": "text"
1168
+ },
1169
+ {
1170
+ "field": "fieldName",
1171
+ "rule": "required",
1172
+ "fieldType": "text"
1173
+ },
1174
+ {
1175
+ "field": "tenantId",
1176
+ "rule": "required",
1177
+ "fieldType": "text"
1178
+ },
1179
+ {
1180
+ "field": "kind",
1181
+ "rule": "required",
1182
+ "fieldType": "text"
1183
+ },
1184
+ {
1185
+ "field": "status",
1186
+ "rule": "required",
1187
+ "fieldType": "text"
1188
+ },
1189
+ {
1190
+ "field": "activeKey",
1191
+ "rule": "required",
1192
+ "fieldType": "text"
1193
+ }
1194
+ ],
1195
+ "schema": {
1196
+ "tableName": "_smrt_field_policy_suggestions",
1197
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_policy_suggestions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"object_ref\" TEXT NOT NULL DEFAULT '',\n \"field_name\" TEXT NOT NULL DEFAULT '',\n \"tenant_id\" UUID NOT NULL,\n \"kind\" TEXT NOT NULL DEFAULT 'promote',\n \"proposed_value\" TEXT,\n \"evidence\" TEXT,\n \"status\" TEXT NOT NULL DEFAULT 'pending',\n \"active_key\" TEXT NOT NULL,\n \"cooldown_until\" TIMESTAMP,\n \"decided_by\" UUID,\n \"decided_at\" TIMESTAMP\n);",
1198
+ "columns": {
1199
+ "id": {
1200
+ "type": "UUID",
1201
+ "primaryKey": true,
1202
+ "referenceKind": "id",
1203
+ "notNull": true
1204
+ },
1205
+ "slug": {
1206
+ "type": "TEXT",
1207
+ "notNull": true
1208
+ },
1209
+ "context": {
1210
+ "type": "TEXT",
1211
+ "notNull": true,
1212
+ "default": ""
1213
+ },
1214
+ "created_at": {
1215
+ "type": "TIMESTAMP",
1216
+ "notNull": true,
1217
+ "default": "current_timestamp"
1218
+ },
1219
+ "updated_at": {
1220
+ "type": "TIMESTAMP",
1221
+ "notNull": true,
1222
+ "default": "current_timestamp"
1223
+ },
1224
+ "object_ref": {
1225
+ "type": "TEXT",
1226
+ "notNull": true,
1227
+ "unique": false,
1228
+ "default": ""
1229
+ },
1230
+ "field_name": {
1231
+ "type": "TEXT",
1232
+ "notNull": true,
1233
+ "unique": false,
1234
+ "default": ""
1235
+ },
1236
+ "tenant_id": {
1237
+ "type": "UUID",
1238
+ "referenceKind": "tenantId",
1239
+ "notNull": true,
1240
+ "unique": false
1241
+ },
1242
+ "kind": {
1243
+ "type": "TEXT",
1244
+ "notNull": true,
1245
+ "unique": false,
1246
+ "default": "promote"
1247
+ },
1248
+ "proposed_value": {
1249
+ "type": "TEXT",
1250
+ "notNull": false,
1251
+ "unique": false
1252
+ },
1253
+ "evidence": {
1254
+ "type": "TEXT",
1255
+ "notNull": false,
1256
+ "unique": false
1257
+ },
1258
+ "status": {
1259
+ "type": "TEXT",
1260
+ "notNull": true,
1261
+ "unique": false,
1262
+ "default": "pending"
1263
+ },
1264
+ "active_key": {
1265
+ "type": "TEXT",
1266
+ "notNull": true,
1267
+ "unique": false
1268
+ },
1269
+ "cooldown_until": {
1270
+ "type": "TIMESTAMP",
1271
+ "notNull": false,
1272
+ "unique": false
1273
+ },
1274
+ "decided_by": {
1275
+ "type": "UUID",
1276
+ "referenceKind": "crossPackageRef",
1277
+ "notNull": false,
1278
+ "unique": false
1279
+ },
1280
+ "decided_at": {
1281
+ "type": "TIMESTAMP",
1282
+ "notNull": false,
1283
+ "unique": false
1284
+ }
1285
+ },
1286
+ "indexes": [
1287
+ {
1288
+ "name": "_smrt_field_policy_suggestions_id_idx",
1289
+ "columns": [
1290
+ "id"
1291
+ ]
1292
+ },
1293
+ {
1294
+ "name": "_smrt_field_policy_suggestions_object_ref_field_name_idx",
1295
+ "columns": [
1296
+ "object_ref",
1297
+ "field_name",
1298
+ "tenant_id",
1299
+ "kind",
1300
+ "active_key"
1301
+ ],
1302
+ "unique": true
1303
+ }
1304
+ ],
1305
+ "version": "1bc8c6e5"
1306
+ }
1307
+ },
1308
+ "@happyvertical/smrt-fields:FieldUsageCounter": {
1309
+ "name": "fieldusagecounter",
1310
+ "className": "FieldUsageCounter",
1311
+ "qualifiedName": "@happyvertical/smrt-fields:FieldUsageCounter",
1312
+ "collection": "fieldusagecounters",
1313
+ "filePath": "/home/runner/_work/smrt/smrt/packages/fields/src/models/FieldUsageCounter.ts",
1314
+ "packageName": "@happyvertical/smrt-fields",
1315
+ "fields": {
1316
+ "objectRef": {
1317
+ "type": "text",
1318
+ "required": true,
1319
+ "default": "",
1320
+ "_meta": {
1321
+ "required": true
1322
+ }
1323
+ },
1324
+ "fieldName": {
1325
+ "type": "text",
1326
+ "required": true,
1327
+ "default": "",
1328
+ "_meta": {
1329
+ "required": true
1330
+ }
1331
+ },
1332
+ "tenantId": {
1333
+ "type": "text",
1334
+ "required": true,
1335
+ "_meta": {
1336
+ "sqlType": "UUID",
1337
+ "__tenancy": {
1338
+ "isTenantIdField": true,
1339
+ "autoFilter": true,
1340
+ "required": true,
1341
+ "autoPopulate": true,
1342
+ "nullable": false
1343
+ }
1344
+ }
1345
+ },
1346
+ "period": {
1347
+ "type": "text",
1348
+ "required": true,
1349
+ "default": "",
1350
+ "_meta": {
1351
+ "required": true
1352
+ }
1353
+ },
1354
+ "submissionCount": {
1355
+ "type": "integer",
1356
+ "required": false,
1357
+ "_meta": {}
1358
+ },
1359
+ "setCount": {
1360
+ "type": "integer",
1361
+ "required": false,
1362
+ "_meta": {}
1363
+ },
1364
+ "distinctUserCount": {
1365
+ "type": "integer",
1366
+ "required": false,
1367
+ "_meta": {}
1368
+ },
1369
+ "distinctUserIds": {
1370
+ "type": "text",
1371
+ "required": false,
1372
+ "_meta": {}
1373
+ },
1374
+ "distinctUsersOverflowed": {
1375
+ "type": "boolean",
1376
+ "required": false,
1377
+ "_meta": {}
1378
+ },
1379
+ "valueHistogram": {
1380
+ "type": "text",
1381
+ "required": false,
1382
+ "_meta": {
1383
+ "nullable": true
1384
+ }
1385
+ },
1386
+ "valueHistogramOverflowed": {
1387
+ "type": "boolean",
1388
+ "required": false,
1389
+ "_meta": {}
1390
+ }
1391
+ },
1392
+ "methods": {
1393
+ "getDistinctUserIds": {
1394
+ "name": "getDistinctUserIds",
1395
+ "async": false,
1396
+ "parameters": [],
1397
+ "returnType": "string[]",
1398
+ "isStatic": false,
1399
+ "isPublic": true
1400
+ },
1401
+ "addDistinctUser": {
1402
+ "name": "addDistinctUser",
1403
+ "async": false,
1404
+ "parameters": [
1405
+ {
1406
+ "name": "userId",
1407
+ "type": "string",
1408
+ "optional": false
1409
+ }
1410
+ ],
1411
+ "returnType": "void",
1412
+ "isStatic": false,
1413
+ "isPublic": true
1414
+ },
1415
+ "getValueHistogram": {
1416
+ "name": "getValueHistogram",
1417
+ "async": false,
1418
+ "parameters": [],
1419
+ "returnType": "Record<string, number>",
1420
+ "isStatic": false,
1421
+ "isPublic": true
1422
+ },
1423
+ "recordHistogramSample": {
1424
+ "name": "recordHistogramSample",
1425
+ "async": false,
1426
+ "parameters": [
1427
+ {
1428
+ "name": "key",
1429
+ "type": "string",
1430
+ "optional": false
1431
+ }
1432
+ ],
1433
+ "returnType": "void",
1434
+ "isStatic": false,
1435
+ "isPublic": true
1436
+ },
1437
+ "isLegacyBucket": {
1438
+ "name": "isLegacyBucket",
1439
+ "async": false,
1440
+ "parameters": [],
1441
+ "returnType": "boolean",
1442
+ "isStatic": false,
1443
+ "isPublic": true
1444
+ },
1445
+ "save": {
1446
+ "name": "save",
1447
+ "async": true,
1448
+ "parameters": [],
1449
+ "returnType": "Promise",
1450
+ "isStatic": false,
1451
+ "isPublic": true
1452
+ },
1453
+ "delete": {
1454
+ "name": "delete",
1455
+ "async": true,
1456
+ "parameters": [],
1457
+ "returnType": "Promise<void>",
1458
+ "isStatic": false,
1459
+ "isPublic": true
1460
+ }
1461
+ },
1462
+ "decoratorConfig": {
1463
+ "tableName": "_smrt_field_usage_counters",
1464
+ "conflictColumns": [
1465
+ "object_ref",
1466
+ "field_name",
1467
+ "tenant_id",
1468
+ "period"
1469
+ ],
1470
+ "api": {
1471
+ "include": []
1472
+ },
1473
+ "cli": false,
1474
+ "mcp": {
1475
+ "include": []
1476
+ }
1477
+ },
1478
+ "extends": "SmrtObject",
1479
+ "exportName": "FieldUsageCounter",
1480
+ "collectionExportName": "FieldUsageCounterCollection",
392
1481
  "validationRules": [
393
1482
  {
394
1483
  "field": "objectRef",
@@ -401,19 +1490,19 @@
401
1490
  "fieldType": "text"
402
1491
  },
403
1492
  {
404
- "field": "scopeType",
1493
+ "field": "tenantId",
405
1494
  "rule": "required",
406
1495
  "fieldType": "text"
407
1496
  },
408
1497
  {
409
- "field": "scopeKey",
1498
+ "field": "period",
410
1499
  "rule": "required",
411
1500
  "fieldType": "text"
412
1501
  }
413
1502
  ],
414
1503
  "schema": {
415
- "tableName": "_smrt_field_policies",
416
- "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_policies\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"object_ref\" TEXT NOT NULL DEFAULT '',\n \"field_name\" TEXT NOT NULL DEFAULT '',\n \"scope_type\" TEXT NOT NULL DEFAULT 'app',\n \"tenant_id\" UUID,\n \"user_id\" UUID,\n \"scope_key\" TEXT NOT NULL,\n \"default_value\" TEXT,\n \"visibility\" TEXT,\n \"help\" TEXT,\n \"label\" TEXT,\n \"display_order\" INTEGER,\n \"locked\" BOOLEAN,\n \"updated_by\" UUID\n);",
1504
+ "tableName": "_smrt_field_usage_counters",
1505
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_usage_counters\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"object_ref\" TEXT NOT NULL DEFAULT '',\n \"field_name\" TEXT NOT NULL DEFAULT '',\n \"tenant_id\" UUID NOT NULL,\n \"period\" TEXT NOT NULL DEFAULT '',\n \"submission_count\" INTEGER,\n \"set_count\" INTEGER,\n \"distinct_user_count\" INTEGER,\n \"distinct_user_ids\" TEXT,\n \"distinct_users_overflowed\" BOOLEAN,\n \"value_histogram\" TEXT,\n \"value_histogram_overflowed\" BOOLEAN\n);",
417
1506
  "columns": {
418
1507
  "id": {
419
1508
  "type": "UUID",
@@ -452,85 +1541,250 @@
452
1541
  "unique": false,
453
1542
  "default": ""
454
1543
  },
455
- "scope_type": {
456
- "type": "TEXT",
457
- "notNull": true,
458
- "unique": false,
459
- "default": "app"
460
- },
461
1544
  "tenant_id": {
462
1545
  "type": "UUID",
463
1546
  "referenceKind": "tenantId",
464
- "notNull": false,
465
- "unique": false
466
- },
467
- "user_id": {
468
- "type": "UUID",
469
- "referenceKind": "crossPackageRef",
470
- "notNull": false,
1547
+ "notNull": true,
471
1548
  "unique": false
472
1549
  },
473
- "scope_key": {
1550
+ "period": {
474
1551
  "type": "TEXT",
475
1552
  "notNull": true,
1553
+ "unique": false,
1554
+ "default": ""
1555
+ },
1556
+ "submission_count": {
1557
+ "type": "INTEGER",
1558
+ "notNull": false,
476
1559
  "unique": false
477
1560
  },
478
- "default_value": {
479
- "type": "TEXT",
1561
+ "set_count": {
1562
+ "type": "INTEGER",
480
1563
  "notNull": false,
481
1564
  "unique": false
482
1565
  },
483
- "visibility": {
484
- "type": "TEXT",
1566
+ "distinct_user_count": {
1567
+ "type": "INTEGER",
485
1568
  "notNull": false,
486
1569
  "unique": false
487
1570
  },
488
- "help": {
1571
+ "distinct_user_ids": {
489
1572
  "type": "TEXT",
490
1573
  "notNull": false,
491
1574
  "unique": false
492
1575
  },
493
- "label": {
494
- "type": "TEXT",
1576
+ "distinct_users_overflowed": {
1577
+ "type": "BOOLEAN",
495
1578
  "notNull": false,
496
1579
  "unique": false
497
1580
  },
498
- "display_order": {
499
- "type": "INTEGER",
1581
+ "value_histogram": {
1582
+ "type": "TEXT",
500
1583
  "notNull": false,
501
1584
  "unique": false
502
1585
  },
503
- "locked": {
1586
+ "value_histogram_overflowed": {
504
1587
  "type": "BOOLEAN",
505
1588
  "notNull": false,
506
1589
  "unique": false
1590
+ }
1591
+ },
1592
+ "indexes": [
1593
+ {
1594
+ "name": "_smrt_field_usage_counters_id_idx",
1595
+ "columns": [
1596
+ "id"
1597
+ ]
507
1598
  },
508
- "updated_by": {
1599
+ {
1600
+ "name": "_smrt_field_usage_counters_object_ref_field_name_idx",
1601
+ "columns": [
1602
+ "object_ref",
1603
+ "field_name",
1604
+ "tenant_id",
1605
+ "period"
1606
+ ],
1607
+ "unique": true
1608
+ }
1609
+ ],
1610
+ "version": "46fcebc6"
1611
+ }
1612
+ },
1613
+ "@happyvertical/smrt-fields:FieldUsageReportReceipt": {
1614
+ "name": "fieldusagereportreceipt",
1615
+ "className": "FieldUsageReportReceipt",
1616
+ "qualifiedName": "@happyvertical/smrt-fields:FieldUsageReportReceipt",
1617
+ "collection": "fieldusagereportreceipts",
1618
+ "filePath": "/home/runner/_work/smrt/smrt/packages/fields/src/models/FieldUsageReportReceipt.ts",
1619
+ "packageName": "@happyvertical/smrt-fields",
1620
+ "fields": {
1621
+ "tenantId": {
1622
+ "type": "text",
1623
+ "required": true,
1624
+ "_meta": {
1625
+ "sqlType": "UUID",
1626
+ "__tenancy": {
1627
+ "isTenantIdField": true,
1628
+ "autoFilter": true,
1629
+ "required": true,
1630
+ "autoPopulate": true,
1631
+ "nullable": false
1632
+ }
1633
+ }
1634
+ },
1635
+ "userId": {
1636
+ "type": "crossPackageRef",
1637
+ "required": false,
1638
+ "related": "@happyvertical/smrt-users:User"
1639
+ },
1640
+ "objectRef": {
1641
+ "type": "text",
1642
+ "required": true,
1643
+ "default": "",
1644
+ "_meta": {
1645
+ "required": true
1646
+ }
1647
+ },
1648
+ "fieldName": {
1649
+ "type": "text",
1650
+ "required": true,
1651
+ "default": "",
1652
+ "_meta": {
1653
+ "required": true
1654
+ }
1655
+ },
1656
+ "period": {
1657
+ "type": "text",
1658
+ "required": true,
1659
+ "default": "",
1660
+ "_meta": {
1661
+ "required": true
1662
+ }
1663
+ }
1664
+ },
1665
+ "methods": {},
1666
+ "decoratorConfig": {
1667
+ "tableName": "_smrt_field_usage_report_receipts",
1668
+ "conflictColumns": [
1669
+ "tenant_id",
1670
+ "user_id",
1671
+ "object_ref",
1672
+ "field_name",
1673
+ "period"
1674
+ ],
1675
+ "api": {
1676
+ "include": []
1677
+ },
1678
+ "cli": false,
1679
+ "mcp": {
1680
+ "include": []
1681
+ }
1682
+ },
1683
+ "extends": "SmrtObject",
1684
+ "exportName": "FieldUsageReportReceipt",
1685
+ "collectionExportName": "FieldUsageReportReceiptCollection",
1686
+ "validationRules": [
1687
+ {
1688
+ "field": "tenantId",
1689
+ "rule": "required",
1690
+ "fieldType": "text"
1691
+ },
1692
+ {
1693
+ "field": "objectRef",
1694
+ "rule": "required",
1695
+ "fieldType": "text"
1696
+ },
1697
+ {
1698
+ "field": "fieldName",
1699
+ "rule": "required",
1700
+ "fieldType": "text"
1701
+ },
1702
+ {
1703
+ "field": "period",
1704
+ "rule": "required",
1705
+ "fieldType": "text"
1706
+ }
1707
+ ],
1708
+ "schema": {
1709
+ "tableName": "_smrt_field_usage_report_receipts",
1710
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_usage_report_receipts\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"user_id\" UUID,\n \"object_ref\" TEXT NOT NULL DEFAULT '',\n \"field_name\" TEXT NOT NULL DEFAULT '',\n \"period\" TEXT NOT NULL DEFAULT ''\n);",
1711
+ "columns": {
1712
+ "id": {
1713
+ "type": "UUID",
1714
+ "primaryKey": true,
1715
+ "referenceKind": "id",
1716
+ "notNull": true
1717
+ },
1718
+ "slug": {
1719
+ "type": "TEXT",
1720
+ "notNull": true
1721
+ },
1722
+ "context": {
1723
+ "type": "TEXT",
1724
+ "notNull": true,
1725
+ "default": ""
1726
+ },
1727
+ "created_at": {
1728
+ "type": "TIMESTAMP",
1729
+ "notNull": true,
1730
+ "default": "current_timestamp"
1731
+ },
1732
+ "updated_at": {
1733
+ "type": "TIMESTAMP",
1734
+ "notNull": true,
1735
+ "default": "current_timestamp"
1736
+ },
1737
+ "tenant_id": {
1738
+ "type": "UUID",
1739
+ "referenceKind": "tenantId",
1740
+ "notNull": true,
1741
+ "unique": false
1742
+ },
1743
+ "user_id": {
509
1744
  "type": "UUID",
510
1745
  "referenceKind": "crossPackageRef",
511
1746
  "notNull": false,
512
1747
  "unique": false
1748
+ },
1749
+ "object_ref": {
1750
+ "type": "TEXT",
1751
+ "notNull": true,
1752
+ "unique": false,
1753
+ "default": ""
1754
+ },
1755
+ "field_name": {
1756
+ "type": "TEXT",
1757
+ "notNull": true,
1758
+ "unique": false,
1759
+ "default": ""
1760
+ },
1761
+ "period": {
1762
+ "type": "TEXT",
1763
+ "notNull": true,
1764
+ "unique": false,
1765
+ "default": ""
513
1766
  }
514
1767
  },
515
1768
  "indexes": [
516
1769
  {
517
- "name": "_smrt_field_policies_id_idx",
1770
+ "name": "_smrt_field_usage_report_receipts_id_idx",
518
1771
  "columns": [
519
1772
  "id"
520
1773
  ]
521
1774
  },
522
1775
  {
523
- "name": "_smrt_field_policies_object_ref_field_name_idx",
1776
+ "name": "_smrt_field_usage_report_receipts_tenant_id_user_id_idx",
524
1777
  "columns": [
1778
+ "tenant_id",
1779
+ "user_id",
525
1780
  "object_ref",
526
1781
  "field_name",
527
- "scope_type",
528
- "scope_key"
1782
+ "period"
529
1783
  ],
530
1784
  "unique": true
531
1785
  }
532
1786
  ],
533
- "version": "34b355cc"
1787
+ "version": "c3119047"
534
1788
  }
535
1789
  }
536
1790
  },