@happyvertical/smrt-fields 0.61.3 → 0.61.5

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.
@@ -2,169 +2,248 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-fields",
5
- "packageVersion": "0.61.3",
5
+ "packageVersion": "0.61.5",
6
6
  "objects": {
7
- "@happyvertical/smrt-fields:FieldPolicyCollection": {
8
- "name": "fieldpolicycollection",
9
- "className": "FieldPolicyCollection",
10
- "qualifiedName": "@happyvertical/smrt-fields:FieldPolicyCollection",
11
- "collection": "fieldpolicies",
12
- "filePath": "/home/runner/work/smrt/smrt/packages/fields/src/collections/FieldPolicyCollection.ts",
7
+ "@happyvertical/smrt-fields:FieldUsageCounter": {
8
+ "name": "fieldusagecounter",
9
+ "className": "FieldUsageCounter",
10
+ "qualifiedName": "@happyvertical/smrt-fields:FieldUsageCounter",
11
+ "collection": "fieldusagecounters",
12
+ "filePath": "src/models/FieldUsageCounter.ts",
13
13
  "packageName": "@happyvertical/smrt-fields",
14
- "fields": {},
14
+ "fields": {
15
+ "objectRef": {
16
+ "type": "text",
17
+ "_meta": {
18
+ "__statedOptions": [
19
+ "required",
20
+ "requiredFor",
21
+ "default"
22
+ ],
23
+ "required": true,
24
+ "requiredFor": "identity"
25
+ },
26
+ "required": true,
27
+ "default": ""
28
+ },
29
+ "fieldName": {
30
+ "type": "text",
31
+ "_meta": {
32
+ "__statedOptions": [
33
+ "required",
34
+ "requiredFor",
35
+ "default"
36
+ ],
37
+ "required": true,
38
+ "requiredFor": "identity"
39
+ },
40
+ "required": true,
41
+ "default": ""
42
+ },
43
+ "tenantId": {
44
+ "type": "text",
45
+ "_meta": {
46
+ "__tenancy": {
47
+ "isTenantIdField": true,
48
+ "autoFilter": true,
49
+ "required": true,
50
+ "autoPopulate": true,
51
+ "nullable": false
52
+ },
53
+ "__statedOptions": [
54
+ "sqlType",
55
+ "requiredFor",
56
+ "__tenancy"
57
+ ],
58
+ "sqlType": "UUID",
59
+ "requiredFor": "tenant-scope"
60
+ },
61
+ "required": true
62
+ },
63
+ "period": {
64
+ "type": "text",
65
+ "_meta": {
66
+ "__statedOptions": [
67
+ "required",
68
+ "requiredFor",
69
+ "default"
70
+ ],
71
+ "required": true,
72
+ "requiredFor": "identity"
73
+ },
74
+ "required": true,
75
+ "default": ""
76
+ },
77
+ "submissionCount": {
78
+ "type": "integer",
79
+ "_meta": {
80
+ "__statedOptions": []
81
+ },
82
+ "required": false
83
+ },
84
+ "setCount": {
85
+ "type": "integer",
86
+ "_meta": {
87
+ "__statedOptions": []
88
+ },
89
+ "required": false
90
+ },
91
+ "distinctUserCount": {
92
+ "type": "integer",
93
+ "_meta": {
94
+ "__statedOptions": []
95
+ },
96
+ "required": false
97
+ },
98
+ "distinctUserIds": {
99
+ "type": "text",
100
+ "_meta": {
101
+ "__statedOptions": []
102
+ },
103
+ "required": false
104
+ },
105
+ "distinctUsersOverflowed": {
106
+ "type": "boolean",
107
+ "_meta": {
108
+ "__statedOptions": []
109
+ },
110
+ "required": false
111
+ },
112
+ "valueHistogram": {
113
+ "type": "text",
114
+ "_meta": {
115
+ "__statedOptions": [
116
+ "nullable",
117
+ "required"
118
+ ],
119
+ "nullable": true,
120
+ "required": false
121
+ },
122
+ "required": false
123
+ },
124
+ "valueHistogramOverflowed": {
125
+ "type": "boolean",
126
+ "_meta": {
127
+ "__statedOptions": []
128
+ },
129
+ "required": false
130
+ }
131
+ },
15
132
  "methods": {
16
- "policyAudit": {
17
- "name": "policyAudit",
18
- "async": true,
19
- "parameters": [
20
- {
21
- "name": "options",
22
- "type": "object",
23
- "optional": true,
24
- "memberTypes": [
25
- "string[]",
26
- "boolean"
27
- ]
28
- }
29
- ],
30
- "returnType": "Promise<FieldPolicyAuditSnapshot>",
133
+ "getDistinctUserIds": {
134
+ "name": "getDistinctUserIds",
135
+ "async": false,
136
+ "parameters": [],
137
+ "returnType": "string[]",
31
138
  "isStatic": false,
32
139
  "isPublic": true
33
140
  },
34
- "getAppRows": {
35
- "name": "getAppRows",
36
- "async": true,
141
+ "addDistinctUser": {
142
+ "name": "addDistinctUser",
143
+ "async": false,
37
144
  "parameters": [
38
145
  {
39
- "name": "objectRef",
146
+ "name": "userId",
40
147
  "type": "string",
41
148
  "optional": false
42
149
  }
43
150
  ],
44
- "returnType": "Promise<Map<string, FieldPolicy>>",
151
+ "returnType": "void",
45
152
  "isStatic": false,
46
153
  "isPublic": true
47
154
  },
48
- "getTenantRows": {
49
- "name": "getTenantRows",
50
- "async": true,
51
- "parameters": [
52
- {
53
- "name": "objectRef",
54
- "type": "string",
55
- "optional": false
56
- },
57
- {
58
- "name": "tenantIds",
59
- "type": "string[]",
60
- "optional": false
61
- }
62
- ],
63
- "returnType": "Promise<Map<string, Map<string, FieldPolicy>>>",
155
+ "getValueHistogram": {
156
+ "name": "getValueHistogram",
157
+ "async": false,
158
+ "parameters": [],
159
+ "returnType": "Record<string, number>",
64
160
  "isStatic": false,
65
161
  "isPublic": true
66
162
  },
67
- "getUserRows": {
68
- "name": "getUserRows",
69
- "async": true,
163
+ "recordHistogramSample": {
164
+ "name": "recordHistogramSample",
165
+ "async": false,
70
166
  "parameters": [
71
167
  {
72
- "name": "objectRef",
73
- "type": "string",
74
- "optional": false
75
- },
76
- {
77
- "name": "userId",
168
+ "name": "key",
78
169
  "type": "string",
79
170
  "optional": false
80
171
  }
81
172
  ],
82
- "returnType": "Promise<Map<string, FieldPolicy>>",
173
+ "returnType": "void",
83
174
  "isStatic": false,
84
175
  "isPublic": true
85
176
  },
86
- "resolveBatch": {
87
- "name": "resolveBatch",
177
+ "isLegacyBucket": {
178
+ "name": "isLegacyBucket",
179
+ "async": false,
180
+ "parameters": [],
181
+ "returnType": "boolean",
182
+ "isStatic": false,
183
+ "isPublic": true
184
+ },
185
+ "save": {
186
+ "name": "save",
88
187
  "async": true,
89
188
  "parameters": [
90
189
  {
91
190
  "name": "options",
92
- "type": "object",
93
- "optional": true,
94
- "memberTypes": [
95
- "string[]"
96
- ]
191
+ "type": "SmrtSaveOptions",
192
+ "optional": true
97
193
  }
98
194
  ],
99
- "returnType": "Promise<FieldPolicyBatchResult>",
195
+ "returnType": "Promise<this>",
100
196
  "isStatic": false,
101
197
  "isPublic": true
102
198
  },
103
- "getEditorState": {
104
- "name": "getEditorState",
199
+ "delete": {
200
+ "name": "delete",
105
201
  "async": true,
106
- "parameters": [
107
- {
108
- "name": "options",
109
- "type": "object",
110
- "optional": true,
111
- "memberTypes": [
112
- "string"
113
- ]
114
- }
115
- ],
116
- "returnType": "Promise<FieldPolicyEditorStateResult>",
202
+ "parameters": [],
203
+ "returnType": "Promise<void>",
117
204
  "isStatic": false,
118
205
  "isPublic": true
119
206
  }
120
207
  },
121
208
  "decoratorConfig": {
209
+ "tableName": "_smrt_field_usage_counters",
122
210
  "conflictColumns": [
123
211
  "object_ref",
124
212
  "field_name",
125
- "scope_type",
126
- "scope_key"
213
+ "tenant_id",
214
+ "period"
127
215
  ],
128
216
  "api": {
129
- "include": [
130
- "create",
131
- "update",
132
- "delete",
133
- "resolveBatch",
134
- "getEditorState",
135
- "policyAudit"
136
- ],
137
- "principalContext": true,
138
- "routes": {
139
- "resolveBatch": {
140
- "scope": "collection",
141
- "method": "POST",
142
- "path": "resolve"
143
- },
144
- "getEditorState": {
145
- "scope": "collection",
146
- "method": "POST",
147
- "path": "editor-state"
148
- },
149
- "policyAudit": {
150
- "scope": "collection",
151
- "method": "POST",
152
- "path": "policy-audit"
153
- }
154
- }
217
+ "include": []
155
218
  },
156
219
  "cli": false,
157
- "mcp": false,
158
- "tableName": "_smrt_field_policies"
220
+ "mcp": {
221
+ "include": []
222
+ }
159
223
  },
160
- "extends": "SmrtCollection",
161
- "extendsTypeArg": "FieldPolicy",
162
- "exportName": "FieldPolicyCollection",
163
- "collectionExportName": "FieldPolicyCollectionCollection",
164
- "collectionOf": "@happyvertical/smrt-fields:FieldPolicy",
224
+ "extends": "SmrtObject",
225
+ "exportName": "FieldUsageCounter",
226
+ "collectionExportName": "FieldUsageCounterCollection",
227
+ "validationRules": [
228
+ {
229
+ "field": "objectRef",
230
+ "rule": "required",
231
+ "fieldType": "text"
232
+ },
233
+ {
234
+ "field": "fieldName",
235
+ "rule": "required",
236
+ "fieldType": "text"
237
+ },
238
+ {
239
+ "field": "period",
240
+ "rule": "required",
241
+ "fieldType": "text"
242
+ }
243
+ ],
165
244
  "schema": {
166
- "tableName": "_smrt_field_policies",
167
- "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_policies\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
245
+ "tableName": "_smrt_field_usage_counters",
246
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_usage_counters\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
168
247
  "columns": {
169
248
  "_sync_origin_device_id": {
170
249
  "type": "TEXT"
@@ -209,120 +288,95 @@
209
288
  "unique": false,
210
289
  "default": ""
211
290
  },
212
- "scope_type": {
213
- "type": "TEXT",
214
- "notNull": true,
215
- "unique": false,
216
- "default": "app"
217
- },
218
291
  "tenant_id": {
219
292
  "type": "UUID",
220
293
  "referenceKind": "tenantId",
221
- "notNull": false,
222
- "unique": false
223
- },
224
- "user_id": {
225
- "type": "UUID",
226
- "referenceKind": "crossPackageRef",
227
- "notNull": false,
294
+ "notNull": true,
228
295
  "unique": false
229
296
  },
230
- "scope_key": {
297
+ "period": {
231
298
  "type": "TEXT",
232
299
  "notNull": true,
233
- "unique": false
300
+ "unique": false,
301
+ "default": ""
234
302
  },
235
- "default_value": {
236
- "type": "TEXT",
303
+ "submission_count": {
304
+ "type": "INTEGER",
237
305
  "notNull": false,
238
306
  "unique": false
239
307
  },
240
- "visibility": {
241
- "type": "TEXT",
308
+ "set_count": {
309
+ "type": "INTEGER",
242
310
  "notNull": false,
243
311
  "unique": false
244
312
  },
245
- "help": {
246
- "type": "TEXT",
313
+ "distinct_user_count": {
314
+ "type": "INTEGER",
247
315
  "notNull": false,
248
316
  "unique": false
249
317
  },
250
- "label": {
318
+ "distinct_user_ids": {
251
319
  "type": "TEXT",
252
320
  "notNull": false,
253
321
  "unique": false
254
322
  },
255
- "display_order": {
256
- "type": "INTEGER",
323
+ "distinct_users_overflowed": {
324
+ "type": "BOOLEAN",
257
325
  "notNull": false,
258
326
  "unique": false
259
327
  },
260
- "locked": {
261
- "type": "BOOLEAN",
328
+ "value_histogram": {
329
+ "type": "TEXT",
262
330
  "notNull": false,
263
331
  "unique": false
264
332
  },
265
- "updated_by": {
266
- "type": "UUID",
267
- "referenceKind": "crossPackageRef",
333
+ "value_histogram_overflowed": {
334
+ "type": "BOOLEAN",
268
335
  "notNull": false,
269
336
  "unique": false
270
337
  }
271
338
  },
272
339
  "indexes": [
273
340
  {
274
- "name": "_smrt_field_policies_object_ref_field_name_idx",
341
+ "name": "_smrt_field_usage_counters_object_ref_field_name_idx",
275
342
  "columns": [
276
343
  "object_ref",
277
344
  "field_name",
278
- "scope_type",
279
- "scope_key"
345
+ "tenant_id",
346
+ "period"
280
347
  ],
281
348
  "unique": true
282
349
  },
283
350
  {
284
- "name": "_smrt_field_policies_slug_context_idx",
351
+ "name": "_smrt_field_usage_counters_slug_context_idx",
285
352
  "columns": [
286
353
  "slug",
287
354
  "context"
288
355
  ]
289
356
  },
290
357
  {
291
- "name": "_smrt_field_policies_tenant_id_created_at_idx",
358
+ "name": "_smrt_field_usage_counters_tenant_id_created_at_idx",
292
359
  "columns": [
293
360
  "tenant_id",
294
361
  "created_at"
295
362
  ]
296
- },
297
- {
298
- "name": "_smrt_field_policies_user_id_idx",
299
- "columns": [
300
- "user_id"
301
- ]
302
- },
303
- {
304
- "name": "_smrt_field_policies_updated_by_idx",
305
- "columns": [
306
- "updated_by"
307
- ]
308
363
  }
309
364
  ],
310
- "version": "83d6d14b"
365
+ "version": "c9f56519"
311
366
  },
312
367
  "importPath": "@happyvertical/smrt-fields"
313
368
  },
314
- "@happyvertical/smrt-fields:FieldPolicySuggestionCollection": {
315
- "name": "fieldpolicysuggestioncollection",
316
- "className": "FieldPolicySuggestionCollection",
317
- "qualifiedName": "@happyvertical/smrt-fields:FieldPolicySuggestionCollection",
318
- "collection": "fieldpolicysuggestions",
319
- "description": "Collection surface for FieldPolicySuggestion plus the three manage-gated actions the gear badge / control-panel queue consume (#2051; UI integration is #2050-follow-up territory — this is the minimal…",
320
- "filePath": "/home/runner/work/smrt/smrt/packages/fields/src/collections/FieldPolicySuggestionCollection.ts",
369
+ "@happyvertical/smrt-fields:FieldPolicyCollection": {
370
+ "name": "fieldpolicycollection",
371
+ "className": "FieldPolicyCollection",
372
+ "qualifiedName": "@happyvertical/smrt-fields:FieldPolicyCollection",
373
+ "collection": "fieldpolicies",
374
+ "filePath": "src/collections/FieldPolicyCollection.ts",
321
375
  "packageName": "@happyvertical/smrt-fields",
322
376
  "fields": {},
323
377
  "methods": {
324
- "pendingSuggestions": {
325
- "name": "pendingSuggestions",
378
+ "policyAudit": {
379
+ "name": "policyAudit",
326
380
  "async": true,
327
381
  "parameters": [
328
382
  {
@@ -330,16 +384,69 @@
330
384
  "type": "object",
331
385
  "optional": true,
332
386
  "memberTypes": [
333
- "string[]"
387
+ "string[]",
388
+ "boolean"
334
389
  ]
335
390
  }
336
391
  ],
337
- "returnType": "Promise<PendingFieldPolicySuggestionsResult>",
392
+ "returnType": "Promise<FieldPolicyAuditSnapshot>",
338
393
  "isStatic": false,
339
394
  "isPublic": true
340
395
  },
341
- "acceptSuggestion": {
342
- "name": "acceptSuggestion",
396
+ "getAppRows": {
397
+ "name": "getAppRows",
398
+ "async": true,
399
+ "parameters": [
400
+ {
401
+ "name": "objectRef",
402
+ "type": "string",
403
+ "optional": false
404
+ }
405
+ ],
406
+ "returnType": "Promise<Map<string, FieldPolicy>>",
407
+ "isStatic": false,
408
+ "isPublic": true
409
+ },
410
+ "getTenantRows": {
411
+ "name": "getTenantRows",
412
+ "async": true,
413
+ "parameters": [
414
+ {
415
+ "name": "objectRef",
416
+ "type": "string",
417
+ "optional": false
418
+ },
419
+ {
420
+ "name": "tenantIds",
421
+ "type": "string[]",
422
+ "optional": false
423
+ }
424
+ ],
425
+ "returnType": "Promise<Map<string, Map<string, FieldPolicy>>>",
426
+ "isStatic": false,
427
+ "isPublic": true
428
+ },
429
+ "getUserRows": {
430
+ "name": "getUserRows",
431
+ "async": true,
432
+ "parameters": [
433
+ {
434
+ "name": "objectRef",
435
+ "type": "string",
436
+ "optional": false
437
+ },
438
+ {
439
+ "name": "userId",
440
+ "type": "string",
441
+ "optional": false
442
+ }
443
+ ],
444
+ "returnType": "Promise<Map<string, FieldPolicy>>",
445
+ "isStatic": false,
446
+ "isPublic": true
447
+ },
448
+ "resolveBatch": {
449
+ "name": "resolveBatch",
343
450
  "async": true,
344
451
  "parameters": [
345
452
  {
@@ -347,16 +454,16 @@
347
454
  "type": "object",
348
455
  "optional": true,
349
456
  "memberTypes": [
350
- "string"
457
+ "string[]"
351
458
  ]
352
459
  }
353
460
  ],
354
- "returnType": "Promise<AcceptFieldPolicySuggestionResult>",
461
+ "returnType": "Promise<FieldPolicyBatchResult>",
355
462
  "isStatic": false,
356
463
  "isPublic": true
357
464
  },
358
- "dismissSuggestion": {
359
- "name": "dismissSuggestion",
465
+ "getEditorState": {
466
+ "name": "getEditorState",
360
467
  "async": true,
361
468
  "parameters": [
362
469
  {
@@ -364,12 +471,11 @@
364
471
  "type": "object",
365
472
  "optional": true,
366
473
  "memberTypes": [
367
- "string",
368
- "number"
474
+ "string"
369
475
  ]
370
476
  }
371
477
  ],
372
- "returnType": "Promise<DismissFieldPolicySuggestionResult>",
478
+ "returnType": "Promise<FieldPolicyEditorStateResult>",
373
479
  "isStatic": false,
374
480
  "isPublic": true
375
481
  }
@@ -378,47 +484,49 @@
378
484
  "conflictColumns": [
379
485
  "object_ref",
380
486
  "field_name",
381
- "tenant_id",
382
- "kind",
383
- "active_key"
487
+ "scope_type",
488
+ "scope_key"
384
489
  ],
385
490
  "api": {
386
491
  "include": [
387
- "pendingSuggestions",
388
- "acceptSuggestion",
389
- "dismissSuggestion"
492
+ "create",
493
+ "update",
494
+ "delete",
495
+ "resolveBatch",
496
+ "getEditorState",
497
+ "policyAudit"
390
498
  ],
391
499
  "principalContext": true,
392
500
  "routes": {
393
- "pendingSuggestions": {
501
+ "resolveBatch": {
394
502
  "scope": "collection",
395
503
  "method": "POST",
396
- "path": "pending"
504
+ "path": "resolve"
397
505
  },
398
- "acceptSuggestion": {
506
+ "getEditorState": {
399
507
  "scope": "collection",
400
508
  "method": "POST",
401
- "path": "accept"
509
+ "path": "editor-state"
402
510
  },
403
- "dismissSuggestion": {
511
+ "policyAudit": {
404
512
  "scope": "collection",
405
513
  "method": "POST",
406
- "path": "dismiss"
514
+ "path": "policy-audit"
407
515
  }
408
516
  }
409
517
  },
410
518
  "cli": false,
411
519
  "mcp": false,
412
- "tableName": "_smrt_field_policy_suggestions"
520
+ "tableName": "_smrt_field_policies"
413
521
  },
414
522
  "extends": "SmrtCollection",
415
- "extendsTypeArg": "FieldPolicySuggestion",
416
- "exportName": "FieldPolicySuggestionCollection",
417
- "collectionExportName": "FieldPolicySuggestionCollectionCollection",
418
- "collectionOf": "@happyvertical/smrt-fields:FieldPolicySuggestion",
523
+ "extendsTypeArg": "FieldPolicy",
524
+ "exportName": "FieldPolicyCollection",
525
+ "collectionExportName": "FieldPolicyCollectionCollection",
526
+ "collectionOf": "@happyvertical/smrt-fields:FieldPolicy",
419
527
  "schema": {
420
- "tableName": "_smrt_field_policy_suggestions",
421
- "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_policy_suggestions\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
528
+ "tableName": "_smrt_field_policies",
529
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_policies\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
422
530
  "columns": {
423
531
  "_sync_origin_device_id": {
424
532
  "type": "TEXT"
@@ -463,105 +571,120 @@
463
571
  "unique": false,
464
572
  "default": ""
465
573
  },
574
+ "scope_type": {
575
+ "type": "TEXT",
576
+ "notNull": true,
577
+ "unique": false,
578
+ "default": "app"
579
+ },
466
580
  "tenant_id": {
467
581
  "type": "UUID",
468
582
  "referenceKind": "tenantId",
469
- "notNull": true,
583
+ "notNull": false,
470
584
  "unique": false
471
585
  },
472
- "kind": {
586
+ "user_id": {
587
+ "type": "UUID",
588
+ "referenceKind": "crossPackageRef",
589
+ "notNull": false,
590
+ "unique": false
591
+ },
592
+ "scope_key": {
473
593
  "type": "TEXT",
474
594
  "notNull": true,
475
- "unique": false,
476
- "default": "promote"
595
+ "unique": false
477
596
  },
478
- "proposed_value": {
597
+ "default_value": {
479
598
  "type": "TEXT",
480
599
  "notNull": false,
481
600
  "unique": false
482
601
  },
483
- "evidence": {
602
+ "visibility": {
484
603
  "type": "TEXT",
485
604
  "notNull": false,
486
605
  "unique": false
487
606
  },
488
- "status": {
607
+ "help": {
489
608
  "type": "TEXT",
490
- "notNull": true,
491
- "unique": false,
492
- "default": "pending"
609
+ "notNull": false,
610
+ "unique": false
493
611
  },
494
- "active_key": {
612
+ "label": {
495
613
  "type": "TEXT",
496
- "notNull": true,
614
+ "notNull": false,
497
615
  "unique": false
498
616
  },
499
- "cooldown_until": {
500
- "type": "TIMESTAMP",
617
+ "display_order": {
618
+ "type": "INTEGER",
501
619
  "notNull": false,
502
620
  "unique": false
503
621
  },
504
- "decided_by": {
505
- "type": "UUID",
506
- "referenceKind": "crossPackageRef",
622
+ "locked": {
623
+ "type": "BOOLEAN",
507
624
  "notNull": false,
508
625
  "unique": false
509
626
  },
510
- "decided_at": {
511
- "type": "TIMESTAMP",
627
+ "updated_by": {
628
+ "type": "UUID",
629
+ "referenceKind": "crossPackageRef",
512
630
  "notNull": false,
513
631
  "unique": false
514
632
  }
515
633
  },
516
634
  "indexes": [
517
635
  {
518
- "name": "_smrt_field_policy_suggestions_object_ref_field_name_idx",
636
+ "name": "_smrt_field_policies_object_ref_field_name_idx",
519
637
  "columns": [
520
638
  "object_ref",
521
639
  "field_name",
522
- "tenant_id",
523
- "kind",
524
- "active_key"
640
+ "scope_type",
641
+ "scope_key"
525
642
  ],
526
643
  "unique": true
527
644
  },
528
645
  {
529
- "name": "_smrt_field_policy_suggestions_slug_context_idx",
646
+ "name": "_smrt_field_policies_slug_context_idx",
530
647
  "columns": [
531
648
  "slug",
532
649
  "context"
533
650
  ]
534
651
  },
535
652
  {
536
- "name": "_smrt_field_policy_suggestions_tenant_id_created_at_idx",
653
+ "name": "_smrt_field_policies_tenant_id_created_at_idx",
537
654
  "columns": [
538
655
  "tenant_id",
539
656
  "created_at"
540
657
  ]
541
658
  },
542
659
  {
543
- "name": "_smrt_field_policy_suggestions_decided_by_idx",
660
+ "name": "_smrt_field_policies_user_id_idx",
544
661
  "columns": [
545
- "decided_by"
662
+ "user_id"
663
+ ]
664
+ },
665
+ {
666
+ "name": "_smrt_field_policies_updated_by_idx",
667
+ "columns": [
668
+ "updated_by"
546
669
  ]
547
670
  }
548
671
  ],
549
- "version": "e3858540"
672
+ "version": "83d6d14b"
550
673
  },
551
674
  "importPath": "@happyvertical/smrt-fields"
552
675
  },
553
- "@happyvertical/smrt-fields:FieldUsageCounterCollection": {
554
- "name": "fieldusagecountercollection",
555
- "className": "FieldUsageCounterCollection",
556
- "qualifiedName": "@happyvertical/smrt-fields:FieldUsageCounterCollection",
557
- "collection": "fieldusagecounters",
558
- "description": "Collection surface for FieldUsageCounter plus the batched usage ingestion action (#2051).",
559
- "filePath": "/home/runner/work/smrt/smrt/packages/fields/src/collections/FieldUsageCounterCollection.ts",
676
+ "@happyvertical/smrt-fields:FieldPolicySuggestionCollection": {
677
+ "name": "fieldpolicysuggestioncollection",
678
+ "className": "FieldPolicySuggestionCollection",
679
+ "qualifiedName": "@happyvertical/smrt-fields:FieldPolicySuggestionCollection",
680
+ "collection": "fieldpolicysuggestions",
681
+ "description": "Collection surface for FieldPolicySuggestion plus the three manage-gated actions the gear badge / control-panel queue consume (#2051; UI integration is #2050-follow-up territory — this is the minimal…",
682
+ "filePath": "src/collections/FieldPolicySuggestionCollection.ts",
560
683
  "packageName": "@happyvertical/smrt-fields",
561
684
  "fields": {},
562
685
  "methods": {
563
- "reportUsage": {
564
- "name": "reportUsage",
686
+ "pendingSuggestions": {
687
+ "name": "pendingSuggestions",
565
688
  "async": true,
566
689
  "parameters": [
567
690
  {
@@ -569,29 +692,46 @@
569
692
  "type": "object",
570
693
  "optional": true,
571
694
  "memberTypes": [
572
- "FieldUsageReportEntry[]"
695
+ "string[]"
573
696
  ]
574
697
  }
575
698
  ],
576
- "returnType": "Promise<FieldUsageReportResult>",
699
+ "returnType": "Promise<PendingFieldPolicySuggestionsResult>",
577
700
  "isStatic": false,
578
701
  "isPublic": true
579
702
  },
580
- "listWindow": {
581
- "name": "listWindow",
703
+ "acceptSuggestion": {
704
+ "name": "acceptSuggestion",
582
705
  "async": true,
583
706
  "parameters": [
584
707
  {
585
708
  "name": "options",
586
709
  "type": "object",
587
- "optional": false,
710
+ "optional": true,
711
+ "memberTypes": [
712
+ "string"
713
+ ]
714
+ }
715
+ ],
716
+ "returnType": "Promise<AcceptFieldPolicySuggestionResult>",
717
+ "isStatic": false,
718
+ "isPublic": true
719
+ },
720
+ "dismissSuggestion": {
721
+ "name": "dismissSuggestion",
722
+ "async": true,
723
+ "parameters": [
724
+ {
725
+ "name": "options",
726
+ "type": "object",
727
+ "optional": true,
588
728
  "memberTypes": [
589
729
  "string",
590
- "string | null"
730
+ "number"
591
731
  ]
592
732
  }
593
733
  ],
594
- "returnType": "Promise<FieldUsageCounter[]>",
734
+ "returnType": "Promise<DismissFieldPolicySuggestionResult>",
595
735
  "isStatic": false,
596
736
  "isPublic": true
597
737
  }
@@ -601,33 +741,46 @@
601
741
  "object_ref",
602
742
  "field_name",
603
743
  "tenant_id",
604
- "period"
744
+ "kind",
745
+ "active_key"
605
746
  ],
606
747
  "api": {
607
748
  "include": [
608
- "reportUsage"
749
+ "pendingSuggestions",
750
+ "acceptSuggestion",
751
+ "dismissSuggestion"
609
752
  ],
610
753
  "principalContext": true,
611
754
  "routes": {
612
- "reportUsage": {
755
+ "pendingSuggestions": {
613
756
  "scope": "collection",
614
757
  "method": "POST",
615
- "path": "report"
758
+ "path": "pending"
759
+ },
760
+ "acceptSuggestion": {
761
+ "scope": "collection",
762
+ "method": "POST",
763
+ "path": "accept"
764
+ },
765
+ "dismissSuggestion": {
766
+ "scope": "collection",
767
+ "method": "POST",
768
+ "path": "dismiss"
616
769
  }
617
770
  }
618
771
  },
619
772
  "cli": false,
620
773
  "mcp": false,
621
- "tableName": "_smrt_field_usage_counters"
774
+ "tableName": "_smrt_field_policy_suggestions"
622
775
  },
623
776
  "extends": "SmrtCollection",
624
- "extendsTypeArg": "FieldUsageCounter",
625
- "exportName": "FieldUsageCounterCollection",
626
- "collectionExportName": "FieldUsageCounterCollectionCollection",
627
- "collectionOf": "@happyvertical/smrt-fields:FieldUsageCounter",
777
+ "extendsTypeArg": "FieldPolicySuggestion",
778
+ "exportName": "FieldPolicySuggestionCollection",
779
+ "collectionExportName": "FieldPolicySuggestionCollectionCollection",
780
+ "collectionOf": "@happyvertical/smrt-fields:FieldPolicySuggestion",
628
781
  "schema": {
629
- "tableName": "_smrt_field_usage_counters",
630
- "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_usage_counters\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
782
+ "tableName": "_smrt_field_policy_suggestions",
783
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_policy_suggestions\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
631
784
  "columns": {
632
785
  "_sync_origin_device_id": {
633
786
  "type": "TEXT"
@@ -678,469 +831,165 @@
678
831
  "notNull": true,
679
832
  "unique": false
680
833
  },
681
- "period": {
834
+ "kind": {
682
835
  "type": "TEXT",
683
836
  "notNull": true,
684
837
  "unique": false,
685
- "default": ""
838
+ "default": "promote"
686
839
  },
687
- "submission_count": {
688
- "type": "INTEGER",
840
+ "proposed_value": {
841
+ "type": "TEXT",
689
842
  "notNull": false,
690
843
  "unique": false
691
844
  },
692
- "set_count": {
693
- "type": "INTEGER",
845
+ "evidence": {
846
+ "type": "TEXT",
694
847
  "notNull": false,
695
848
  "unique": false
696
849
  },
697
- "distinct_user_count": {
698
- "type": "INTEGER",
699
- "notNull": false,
700
- "unique": false
850
+ "status": {
851
+ "type": "TEXT",
852
+ "notNull": true,
853
+ "unique": false,
854
+ "default": "pending"
701
855
  },
702
- "distinct_user_ids": {
856
+ "active_key": {
703
857
  "type": "TEXT",
704
- "notNull": false,
858
+ "notNull": true,
705
859
  "unique": false
706
860
  },
707
- "distinct_users_overflowed": {
708
- "type": "BOOLEAN",
861
+ "cooldown_until": {
862
+ "type": "TIMESTAMP",
709
863
  "notNull": false,
710
864
  "unique": false
711
865
  },
712
- "value_histogram": {
713
- "type": "TEXT",
866
+ "decided_by": {
867
+ "type": "UUID",
868
+ "referenceKind": "crossPackageRef",
714
869
  "notNull": false,
715
870
  "unique": false
716
871
  },
717
- "value_histogram_overflowed": {
718
- "type": "BOOLEAN",
872
+ "decided_at": {
873
+ "type": "TIMESTAMP",
719
874
  "notNull": false,
720
875
  "unique": false
721
876
  }
722
877
  },
723
878
  "indexes": [
724
879
  {
725
- "name": "_smrt_field_usage_counters_object_ref_field_name_idx",
880
+ "name": "_smrt_field_policy_suggestions_object_ref_field_name_idx",
726
881
  "columns": [
727
882
  "object_ref",
728
883
  "field_name",
729
884
  "tenant_id",
730
- "period"
885
+ "kind",
886
+ "active_key"
731
887
  ],
732
888
  "unique": true
733
889
  },
734
890
  {
735
- "name": "_smrt_field_usage_counters_slug_context_idx",
891
+ "name": "_smrt_field_policy_suggestions_slug_context_idx",
736
892
  "columns": [
737
893
  "slug",
738
894
  "context"
739
895
  ]
740
896
  },
741
897
  {
742
- "name": "_smrt_field_usage_counters_tenant_id_created_at_idx",
898
+ "name": "_smrt_field_policy_suggestions_tenant_id_created_at_idx",
743
899
  "columns": [
744
900
  "tenant_id",
745
901
  "created_at"
746
902
  ]
903
+ },
904
+ {
905
+ "name": "_smrt_field_policy_suggestions_decided_by_idx",
906
+ "columns": [
907
+ "decided_by"
908
+ ]
747
909
  }
748
910
  ],
749
- "version": "c9f56519"
911
+ "version": "e3858540"
750
912
  },
751
913
  "importPath": "@happyvertical/smrt-fields"
752
914
  },
753
- "@happyvertical/smrt-fields:FieldUsageReportReceiptCollection": {
754
- "name": "fieldusagereportreceiptcollection",
755
- "className": "FieldUsageReportReceiptCollection",
756
- "qualifiedName": "@happyvertical/smrt-fields:FieldUsageReportReceiptCollection",
757
- "collection": "fieldusagereportreceipts",
758
- "description": "Internal only — this table has no generated surface.",
759
- "filePath": "/home/runner/work/smrt/smrt/packages/fields/src/collections/FieldUsageCounterCollection.ts",
915
+ "@happyvertical/smrt-fields:FieldUsageCounterCollection": {
916
+ "name": "fieldusagecountercollection",
917
+ "className": "FieldUsageCounterCollection",
918
+ "qualifiedName": "@happyvertical/smrt-fields:FieldUsageCounterCollection",
919
+ "collection": "fieldusagecounters",
920
+ "description": "Collection surface for FieldUsageCounter plus the batched usage ingestion action (#2051).",
921
+ "filePath": "src/collections/FieldUsageCounterCollection.ts",
760
922
  "packageName": "@happyvertical/smrt-fields",
761
923
  "fields": {},
762
924
  "methods": {
763
- "claim": {
764
- "name": "claim",
925
+ "reportUsage": {
926
+ "name": "reportUsage",
765
927
  "async": true,
766
928
  "parameters": [
767
929
  {
768
930
  "name": "options",
769
931
  "type": "object",
770
- "optional": false,
932
+ "optional": true,
771
933
  "memberTypes": [
772
- "string"
934
+ "FieldUsageReportEntry[]"
773
935
  ]
774
936
  }
775
937
  ],
776
- "returnType": "Promise<boolean>",
777
- "isStatic": false,
778
- "isPublic": true
779
- }
780
- },
781
- "decoratorConfig": {
782
- "conflictColumns": [
783
- "tenant_id",
784
- "user_id",
785
- "object_ref",
786
- "field_name",
787
- "period"
788
- ],
789
- "api": false,
790
- "cli": false,
791
- "mcp": false,
792
- "tableName": "_smrt_field_usage_report_receipts"
793
- },
794
- "extends": "SmrtCollection",
795
- "extendsTypeArg": "FieldUsageReportReceipt",
796
- "exportName": "FieldUsageReportReceiptCollection",
797
- "collectionExportName": "FieldUsageReportReceiptCollectionCollection",
798
- "collectionOf": "@happyvertical/smrt-fields:FieldUsageReportReceipt",
799
- "schema": {
800
- "tableName": "_smrt_field_usage_report_receipts",
801
- "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_usage_report_receipts\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
802
- "columns": {
803
- "_sync_origin_device_id": {
804
- "type": "TEXT"
805
- },
806
- "_sync_revision": {
807
- "type": "INTEGER"
808
- },
809
- "id": {
810
- "type": "UUID",
811
- "primaryKey": true,
812
- "referenceKind": "id",
813
- "notNull": true
814
- },
815
- "slug": {
816
- "type": "TEXT",
817
- "notNull": true
818
- },
819
- "context": {
820
- "type": "TEXT",
821
- "notNull": true,
822
- "default": ""
823
- },
824
- "created_at": {
825
- "type": "TIMESTAMP",
826
- "notNull": true,
827
- "default": "current_timestamp"
828
- },
829
- "updated_at": {
830
- "type": "TIMESTAMP",
831
- "notNull": true,
832
- "default": "current_timestamp"
833
- },
834
- "tenant_id": {
835
- "type": "UUID",
836
- "referenceKind": "tenantId",
837
- "notNull": true,
838
- "unique": false
839
- },
840
- "user_id": {
841
- "type": "UUID",
842
- "referenceKind": "crossPackageRef",
843
- "notNull": false,
844
- "unique": false
845
- },
846
- "object_ref": {
847
- "type": "TEXT",
848
- "notNull": true,
849
- "unique": false,
850
- "default": ""
851
- },
852
- "field_name": {
853
- "type": "TEXT",
854
- "notNull": true,
855
- "unique": false,
856
- "default": ""
857
- },
858
- "period": {
859
- "type": "TEXT",
860
- "notNull": true,
861
- "unique": false,
862
- "default": ""
863
- }
864
- },
865
- "indexes": [
866
- {
867
- "name": "_smrt_field_usage_report_receipts_tenant_id_user_id_idx",
868
- "columns": [
869
- "tenant_id",
870
- "user_id",
871
- "object_ref",
872
- "field_name",
873
- "period"
874
- ],
875
- "unique": true,
876
- "nullsNotDistinct": true
877
- },
878
- {
879
- "name": "_smrt_field_usage_report_receipts_slug_context_idx",
880
- "columns": [
881
- "slug",
882
- "context"
883
- ]
884
- },
885
- {
886
- "name": "_smrt_field_usage_report_receipts_tenant_id_created_at_idx",
887
- "columns": [
888
- "tenant_id",
889
- "created_at"
890
- ]
891
- },
892
- {
893
- "name": "_smrt_field_usage_report_receipts_user_id_idx",
894
- "columns": [
895
- "user_id"
896
- ]
897
- }
898
- ],
899
- "version": "6a6af7cb"
900
- },
901
- "importPath": "@happyvertical/smrt-fields"
902
- },
903
- "@happyvertical/smrt-fields:FieldPolicy": {
904
- "name": "fieldpolicy",
905
- "className": "FieldPolicy",
906
- "qualifiedName": "@happyvertical/smrt-fields:FieldPolicy",
907
- "collection": "fieldpolicies",
908
- "filePath": "/home/runner/work/smrt/smrt/packages/fields/src/models/FieldPolicy.ts",
909
- "packageName": "@happyvertical/smrt-fields",
910
- "fields": {
911
- "objectRef": {
912
- "type": "text",
913
- "required": true,
914
- "default": "",
915
- "_meta": {
916
- "required": true
917
- }
918
- },
919
- "fieldName": {
920
- "type": "text",
921
- "required": true,
922
- "default": "",
923
- "_meta": {
924
- "required": true
925
- }
926
- },
927
- "scopeType": {
928
- "type": "text",
929
- "required": true,
930
- "default": "app",
931
- "_meta": {
932
- "required": true
933
- },
934
- "enum": [
935
- "app",
936
- "tenant",
937
- "user"
938
- ]
939
- },
940
- "tenantId": {
941
- "type": "text",
942
- "required": false,
943
- "_meta": {
944
- "sqlType": "UUID",
945
- "nullable": true,
946
- "__tenancy": {
947
- "isTenantIdField": true,
948
- "autoFilter": true,
949
- "required": false,
950
- "autoPopulate": true,
951
- "nullable": true
952
- }
953
- }
954
- },
955
- "userId": {
956
- "type": "crossPackageRef",
957
- "required": false,
958
- "related": "@happyvertical/smrt-users:User",
959
- "_meta": {
960
- "nullable": true
961
- }
962
- },
963
- "scopeKey": {
964
- "type": "text",
965
- "required": true,
966
- "_meta": {
967
- "required": true
968
- }
969
- },
970
- "defaultValue": {
971
- "type": "text",
972
- "required": false,
973
- "description": "The value a new record starts with for this field.",
974
- "_meta": {
975
- "nullable": true,
976
- "description": "The value a new record starts with for this field."
977
- }
978
- },
979
- "visibility": {
980
- "type": "text",
981
- "required": false,
982
- "description": "Whether the field is always shown, tucked under advanced, or hidden.",
983
- "_meta": {
984
- "nullable": true,
985
- "description": "Whether the field is always shown, tucked under advanced, or hidden."
986
- },
987
- "enum": [
988
- "basic",
989
- "advanced",
990
- "hidden"
991
- ]
992
- },
993
- "help": {
994
- "type": "text",
995
- "required": false,
996
- "description": "The hint shown beside the field on the form.",
997
- "_meta": {
998
- "nullable": true,
999
- "description": "The hint shown beside the field on the form."
1000
- }
1001
- },
1002
- "label": {
1003
- "type": "text",
1004
- "required": false,
1005
- "description": "The name people see for the field on forms.",
1006
- "_meta": {
1007
- "nullable": true,
1008
- "description": "The name people see for the field on forms."
1009
- }
1010
- },
1011
- "displayOrder": {
1012
- "type": "integer",
1013
- "required": false,
1014
- "description": "Where the field appears on the form; lower numbers come first.",
1015
- "_meta": {
1016
- "nullable": true,
1017
- "description": "Where the field appears on the form; lower numbers come first."
1018
- }
1019
- },
1020
- "locked": {
1021
- "type": "boolean",
1022
- "required": false,
1023
- "description": "Stops individual people from changing this field for themselves.",
1024
- "_meta": {
1025
- "nullable": true,
1026
- "description": "Stops individual people from changing this field for themselves."
1027
- }
1028
- },
1029
- "updatedBy": {
1030
- "type": "crossPackageRef",
1031
- "required": false,
1032
- "related": "@happyvertical/smrt-users:User",
1033
- "_meta": {
1034
- "nullable": true
1035
- }
1036
- }
1037
- },
1038
- "methods": {
1039
- "getDefaultValue": {
1040
- "name": "getDefaultValue",
1041
- "async": false,
1042
- "parameters": [],
1043
- "returnType": "unknown",
1044
- "isStatic": false,
1045
- "isPublic": true
1046
- },
1047
- "setDefaultValue": {
1048
- "name": "setDefaultValue",
1049
- "async": false,
1050
- "parameters": [
1051
- {
1052
- "name": "value",
1053
- "type": "unknown",
1054
- "optional": false
1055
- }
1056
- ],
1057
- "returnType": "void",
938
+ "returnType": "Promise<FieldUsageReportResult>",
1058
939
  "isStatic": false,
1059
940
  "isPublic": true
1060
941
  },
1061
- "save": {
1062
- "name": "save",
942
+ "listWindow": {
943
+ "name": "listWindow",
1063
944
  "async": true,
1064
945
  "parameters": [
1065
946
  {
1066
947
  "name": "options",
1067
- "type": "SmrtSaveOptions",
1068
- "optional": true
948
+ "type": "object",
949
+ "optional": false,
950
+ "memberTypes": [
951
+ "string",
952
+ "string | null"
953
+ ]
1069
954
  }
1070
955
  ],
1071
- "returnType": "Promise<this>",
1072
- "isStatic": false,
1073
- "isPublic": true
1074
- },
1075
- "delete": {
1076
- "name": "delete",
1077
- "async": true,
1078
- "parameters": [],
1079
- "returnType": "Promise<void>",
956
+ "returnType": "Promise<FieldUsageCounter[]>",
1080
957
  "isStatic": false,
1081
958
  "isPublic": true
1082
959
  }
1083
960
  },
1084
961
  "decoratorConfig": {
1085
- "tableName": "_smrt_field_policies",
1086
962
  "conflictColumns": [
1087
963
  "object_ref",
1088
964
  "field_name",
1089
- "scope_type",
1090
- "scope_key"
965
+ "tenant_id",
966
+ "period"
1091
967
  ],
1092
968
  "api": {
1093
969
  "include": [
1094
- "create",
1095
- "update",
1096
- "delete"
1097
- ],
1098
- "principalContext": true
1099
- },
1100
- "cli": {
1101
- "include": [
1102
- "create",
1103
- "update",
1104
- "delete"
970
+ "reportUsage"
1105
971
  ],
1106
- "exclude": [
1107
- "getDefaultValue",
1108
- "setDefaultValue"
1109
- ]
1110
- },
1111
- "mcp": {
1112
- "include": []
1113
- }
1114
- },
1115
- "extends": "SmrtObject",
1116
- "exportName": "FieldPolicy",
1117
- "collectionExportName": "FieldPolicyCollection",
1118
- "displayLabelField": "label",
1119
- "validationRules": [
1120
- {
1121
- "field": "objectRef",
1122
- "rule": "required",
1123
- "fieldType": "text"
1124
- },
1125
- {
1126
- "field": "fieldName",
1127
- "rule": "required",
1128
- "fieldType": "text"
1129
- },
1130
- {
1131
- "field": "scopeType",
1132
- "rule": "required",
1133
- "fieldType": "text"
972
+ "principalContext": true,
973
+ "routes": {
974
+ "reportUsage": {
975
+ "scope": "collection",
976
+ "method": "POST",
977
+ "path": "report"
978
+ }
979
+ }
1134
980
  },
1135
- {
1136
- "field": "scopeKey",
1137
- "rule": "required",
1138
- "fieldType": "text"
1139
- }
1140
- ],
981
+ "cli": false,
982
+ "mcp": false,
983
+ "tableName": "_smrt_field_usage_counters"
984
+ },
985
+ "extends": "SmrtCollection",
986
+ "extendsTypeArg": "FieldUsageCounter",
987
+ "exportName": "FieldUsageCounterCollection",
988
+ "collectionExportName": "FieldUsageCounterCollectionCollection",
989
+ "collectionOf": "@happyvertical/smrt-fields:FieldUsageCounter",
1141
990
  "schema": {
1142
- "tableName": "_smrt_field_policies",
1143
- "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_policies\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
991
+ "tableName": "_smrt_field_usage_counters",
992
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_usage_counters\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
1144
993
  "columns": {
1145
994
  "_sync_origin_device_id": {
1146
995
  "type": "TEXT"
@@ -1185,229 +1034,463 @@
1185
1034
  "unique": false,
1186
1035
  "default": ""
1187
1036
  },
1188
- "scope_type": {
1189
- "type": "TEXT",
1190
- "notNull": true,
1191
- "unique": false,
1192
- "default": "app"
1193
- },
1194
1037
  "tenant_id": {
1195
1038
  "type": "UUID",
1196
1039
  "referenceKind": "tenantId",
1197
- "notNull": false,
1198
- "unique": false
1199
- },
1200
- "user_id": {
1201
- "type": "UUID",
1202
- "referenceKind": "crossPackageRef",
1203
- "notNull": false,
1040
+ "notNull": true,
1204
1041
  "unique": false
1205
1042
  },
1206
- "scope_key": {
1043
+ "period": {
1207
1044
  "type": "TEXT",
1208
1045
  "notNull": true,
1209
- "unique": false
1046
+ "unique": false,
1047
+ "default": ""
1210
1048
  },
1211
- "default_value": {
1212
- "type": "TEXT",
1049
+ "submission_count": {
1050
+ "type": "INTEGER",
1213
1051
  "notNull": false,
1214
1052
  "unique": false
1215
1053
  },
1216
- "visibility": {
1217
- "type": "TEXT",
1054
+ "set_count": {
1055
+ "type": "INTEGER",
1218
1056
  "notNull": false,
1219
1057
  "unique": false
1220
1058
  },
1221
- "help": {
1222
- "type": "TEXT",
1059
+ "distinct_user_count": {
1060
+ "type": "INTEGER",
1223
1061
  "notNull": false,
1224
1062
  "unique": false
1225
1063
  },
1226
- "label": {
1064
+ "distinct_user_ids": {
1227
1065
  "type": "TEXT",
1228
1066
  "notNull": false,
1229
1067
  "unique": false
1230
1068
  },
1231
- "display_order": {
1232
- "type": "INTEGER",
1069
+ "distinct_users_overflowed": {
1070
+ "type": "BOOLEAN",
1233
1071
  "notNull": false,
1234
1072
  "unique": false
1235
1073
  },
1236
- "locked": {
1237
- "type": "BOOLEAN",
1074
+ "value_histogram": {
1075
+ "type": "TEXT",
1238
1076
  "notNull": false,
1239
1077
  "unique": false
1240
1078
  },
1241
- "updated_by": {
1242
- "type": "UUID",
1243
- "referenceKind": "crossPackageRef",
1079
+ "value_histogram_overflowed": {
1080
+ "type": "BOOLEAN",
1244
1081
  "notNull": false,
1245
1082
  "unique": false
1246
1083
  }
1247
1084
  },
1248
1085
  "indexes": [
1249
1086
  {
1250
- "name": "_smrt_field_policies_object_ref_field_name_idx",
1087
+ "name": "_smrt_field_usage_counters_object_ref_field_name_idx",
1251
1088
  "columns": [
1252
1089
  "object_ref",
1253
1090
  "field_name",
1254
- "scope_type",
1255
- "scope_key"
1091
+ "tenant_id",
1092
+ "period"
1256
1093
  ],
1257
1094
  "unique": true
1258
1095
  },
1259
1096
  {
1260
- "name": "_smrt_field_policies_slug_context_idx",
1097
+ "name": "_smrt_field_usage_counters_slug_context_idx",
1261
1098
  "columns": [
1262
1099
  "slug",
1263
1100
  "context"
1264
1101
  ]
1265
1102
  },
1266
1103
  {
1267
- "name": "_smrt_field_policies_tenant_id_created_at_idx",
1104
+ "name": "_smrt_field_usage_counters_tenant_id_created_at_idx",
1268
1105
  "columns": [
1269
1106
  "tenant_id",
1270
1107
  "created_at"
1271
1108
  ]
1109
+ }
1110
+ ],
1111
+ "version": "c9f56519"
1112
+ },
1113
+ "importPath": "@happyvertical/smrt-fields"
1114
+ },
1115
+ "@happyvertical/smrt-fields:FieldUsageReportReceiptCollection": {
1116
+ "name": "fieldusagereportreceiptcollection",
1117
+ "className": "FieldUsageReportReceiptCollection",
1118
+ "qualifiedName": "@happyvertical/smrt-fields:FieldUsageReportReceiptCollection",
1119
+ "collection": "fieldusagereportreceipts",
1120
+ "description": "Internal only — this table has no generated surface.",
1121
+ "filePath": "src/collections/FieldUsageCounterCollection.ts",
1122
+ "packageName": "@happyvertical/smrt-fields",
1123
+ "fields": {},
1124
+ "methods": {
1125
+ "claim": {
1126
+ "name": "claim",
1127
+ "async": true,
1128
+ "parameters": [
1129
+ {
1130
+ "name": "options",
1131
+ "type": "object",
1132
+ "optional": false,
1133
+ "memberTypes": [
1134
+ "string"
1135
+ ]
1136
+ }
1137
+ ],
1138
+ "returnType": "Promise<boolean>",
1139
+ "isStatic": false,
1140
+ "isPublic": true
1141
+ }
1142
+ },
1143
+ "decoratorConfig": {
1144
+ "conflictColumns": [
1145
+ "tenant_id",
1146
+ "user_id",
1147
+ "object_ref",
1148
+ "field_name",
1149
+ "period"
1150
+ ],
1151
+ "api": false,
1152
+ "cli": false,
1153
+ "mcp": false,
1154
+ "tableName": "_smrt_field_usage_report_receipts"
1155
+ },
1156
+ "extends": "SmrtCollection",
1157
+ "extendsTypeArg": "FieldUsageReportReceipt",
1158
+ "exportName": "FieldUsageReportReceiptCollection",
1159
+ "collectionExportName": "FieldUsageReportReceiptCollectionCollection",
1160
+ "collectionOf": "@happyvertical/smrt-fields:FieldUsageReportReceipt",
1161
+ "schema": {
1162
+ "tableName": "_smrt_field_usage_report_receipts",
1163
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_usage_report_receipts\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
1164
+ "columns": {
1165
+ "_sync_origin_device_id": {
1166
+ "type": "TEXT"
1167
+ },
1168
+ "_sync_revision": {
1169
+ "type": "INTEGER"
1170
+ },
1171
+ "id": {
1172
+ "type": "UUID",
1173
+ "primaryKey": true,
1174
+ "referenceKind": "id",
1175
+ "notNull": true
1176
+ },
1177
+ "slug": {
1178
+ "type": "TEXT",
1179
+ "notNull": true
1180
+ },
1181
+ "context": {
1182
+ "type": "TEXT",
1183
+ "notNull": true,
1184
+ "default": ""
1185
+ },
1186
+ "created_at": {
1187
+ "type": "TIMESTAMP",
1188
+ "notNull": true,
1189
+ "default": "current_timestamp"
1190
+ },
1191
+ "updated_at": {
1192
+ "type": "TIMESTAMP",
1193
+ "notNull": true,
1194
+ "default": "current_timestamp"
1195
+ },
1196
+ "tenant_id": {
1197
+ "type": "UUID",
1198
+ "referenceKind": "tenantId",
1199
+ "notNull": true,
1200
+ "unique": false
1201
+ },
1202
+ "user_id": {
1203
+ "type": "UUID",
1204
+ "referenceKind": "crossPackageRef",
1205
+ "notNull": false,
1206
+ "unique": false
1207
+ },
1208
+ "object_ref": {
1209
+ "type": "TEXT",
1210
+ "notNull": true,
1211
+ "unique": false,
1212
+ "default": ""
1213
+ },
1214
+ "field_name": {
1215
+ "type": "TEXT",
1216
+ "notNull": true,
1217
+ "unique": false,
1218
+ "default": ""
1219
+ },
1220
+ "period": {
1221
+ "type": "TEXT",
1222
+ "notNull": true,
1223
+ "unique": false,
1224
+ "default": ""
1225
+ }
1226
+ },
1227
+ "indexes": [
1228
+ {
1229
+ "name": "_smrt_field_usage_report_receipts_tenant_id_user_id_idx",
1230
+ "columns": [
1231
+ "tenant_id",
1232
+ "user_id",
1233
+ "object_ref",
1234
+ "field_name",
1235
+ "period"
1236
+ ],
1237
+ "unique": true,
1238
+ "nullsNotDistinct": true
1239
+ },
1240
+ {
1241
+ "name": "_smrt_field_usage_report_receipts_slug_context_idx",
1242
+ "columns": [
1243
+ "slug",
1244
+ "context"
1245
+ ]
1272
1246
  },
1273
1247
  {
1274
- "name": "_smrt_field_policies_user_id_idx",
1248
+ "name": "_smrt_field_usage_report_receipts_tenant_id_created_at_idx",
1275
1249
  "columns": [
1276
- "user_id"
1250
+ "tenant_id",
1251
+ "created_at"
1277
1252
  ]
1278
1253
  },
1279
1254
  {
1280
- "name": "_smrt_field_policies_updated_by_idx",
1255
+ "name": "_smrt_field_usage_report_receipts_user_id_idx",
1281
1256
  "columns": [
1282
- "updated_by"
1257
+ "user_id"
1283
1258
  ]
1284
1259
  }
1285
1260
  ],
1286
- "version": "83d6d14b"
1261
+ "version": "6a6af7cb"
1287
1262
  },
1288
1263
  "importPath": "@happyvertical/smrt-fields"
1289
1264
  },
1290
- "@happyvertical/smrt-fields:FieldPolicySuggestion": {
1291
- "name": "fieldpolicysuggestion",
1292
- "className": "FieldPolicySuggestion",
1293
- "qualifiedName": "@happyvertical/smrt-fields:FieldPolicySuggestion",
1294
- "collection": "fieldpolicysuggestions",
1295
- "filePath": "/home/runner/work/smrt/smrt/packages/fields/src/models/FieldPolicySuggestion.ts",
1265
+ "@happyvertical/smrt-fields:FieldPolicy": {
1266
+ "name": "fieldpolicy",
1267
+ "className": "FieldPolicy",
1268
+ "qualifiedName": "@happyvertical/smrt-fields:FieldPolicy",
1269
+ "collection": "fieldpolicies",
1270
+ "filePath": "src/models/FieldPolicy.ts",
1296
1271
  "packageName": "@happyvertical/smrt-fields",
1297
1272
  "fields": {
1298
1273
  "objectRef": {
1299
1274
  "type": "text",
1300
- "required": true,
1301
- "default": "",
1302
1275
  "_meta": {
1303
- "required": true
1304
- }
1276
+ "__statedOptions": [
1277
+ "required",
1278
+ "requiredFor",
1279
+ "default"
1280
+ ],
1281
+ "required": true,
1282
+ "requiredFor": "identity"
1283
+ },
1284
+ "required": true,
1285
+ "default": ""
1305
1286
  },
1306
1287
  "fieldName": {
1307
1288
  "type": "text",
1289
+ "_meta": {
1290
+ "__statedOptions": [
1291
+ "required",
1292
+ "requiredFor",
1293
+ "default"
1294
+ ],
1295
+ "required": true,
1296
+ "requiredFor": "identity"
1297
+ },
1308
1298
  "required": true,
1309
- "default": "",
1299
+ "default": ""
1300
+ },
1301
+ "scopeType": {
1302
+ "type": "text",
1310
1303
  "_meta": {
1304
+ "__statedOptions": [
1305
+ "required",
1306
+ "default",
1307
+ "enum"
1308
+ ],
1311
1309
  "required": true
1312
- }
1310
+ },
1311
+ "required": true,
1312
+ "default": "app",
1313
+ "enum": [
1314
+ "app",
1315
+ "tenant",
1316
+ "user"
1317
+ ]
1313
1318
  },
1314
1319
  "tenantId": {
1315
1320
  "type": "text",
1316
- "required": true,
1317
1321
  "_meta": {
1318
- "sqlType": "UUID",
1319
1322
  "__tenancy": {
1320
1323
  "isTenantIdField": true,
1321
1324
  "autoFilter": true,
1322
- "required": true,
1325
+ "required": false,
1323
1326
  "autoPopulate": true,
1324
- "nullable": false
1325
- }
1326
- }
1327
+ "nullable": true
1328
+ },
1329
+ "__statedOptions": [
1330
+ "sqlType",
1331
+ "nullable",
1332
+ "__tenancy",
1333
+ "required"
1334
+ ],
1335
+ "sqlType": "UUID",
1336
+ "nullable": true,
1337
+ "required": false
1338
+ },
1339
+ "required": false
1327
1340
  },
1328
- "kind": {
1329
- "type": "text",
1330
- "required": true,
1331
- "default": "promote",
1341
+ "userId": {
1342
+ "type": "crossPackageRef",
1332
1343
  "_meta": {
1333
- "required": true
1344
+ "__statedOptions": [
1345
+ "nullable",
1346
+ "related",
1347
+ "required"
1348
+ ],
1349
+ "nullable": true,
1350
+ "required": false
1334
1351
  },
1335
- "enum": [
1336
- "promote",
1337
- "default"
1338
- ]
1352
+ "required": false,
1353
+ "related": "@happyvertical/smrt-users:User"
1339
1354
  },
1340
- "proposedValue": {
1355
+ "scopeKey": {
1341
1356
  "type": "text",
1342
- "required": false,
1343
1357
  "_meta": {
1344
- "nullable": true
1345
- }
1358
+ "__statedOptions": [
1359
+ "required",
1360
+ "requiredFor"
1361
+ ],
1362
+ "required": true,
1363
+ "requiredFor": "identity"
1364
+ },
1365
+ "required": true
1346
1366
  },
1347
- "evidence": {
1367
+ "defaultValue": {
1348
1368
  "type": "text",
1369
+ "_meta": {
1370
+ "__statedOptions": [
1371
+ "nullable",
1372
+ "description",
1373
+ "required"
1374
+ ],
1375
+ "description": "The value a new record starts with for this field.",
1376
+ "nullable": true,
1377
+ "required": false
1378
+ },
1349
1379
  "required": false,
1350
- "_meta": {}
1380
+ "description": "The value a new record starts with for this field."
1351
1381
  },
1352
- "status": {
1382
+ "visibility": {
1353
1383
  "type": "text",
1354
- "required": true,
1355
- "default": "pending",
1356
1384
  "_meta": {
1357
- "required": true
1385
+ "__statedOptions": [
1386
+ "nullable",
1387
+ "description",
1388
+ "enum",
1389
+ "required"
1390
+ ],
1391
+ "description": "Whether the field is always shown, tucked under advanced, or hidden.",
1392
+ "nullable": true,
1393
+ "required": false
1358
1394
  },
1395
+ "required": false,
1396
+ "description": "Whether the field is always shown, tucked under advanced, or hidden.",
1359
1397
  "enum": [
1360
- "pending",
1361
- "accepted",
1362
- "dismissed"
1398
+ "basic",
1399
+ "advanced",
1400
+ "hidden"
1363
1401
  ]
1364
1402
  },
1365
- "activeKey": {
1403
+ "help": {
1366
1404
  "type": "text",
1367
- "required": true,
1368
1405
  "_meta": {
1369
- "required": true
1370
- }
1371
- },
1372
- "cooldownUntil": {
1373
- "type": "datetime",
1406
+ "__statedOptions": [
1407
+ "nullable",
1408
+ "description",
1409
+ "required"
1410
+ ],
1411
+ "description": "The hint shown beside the field on the form.",
1412
+ "nullable": true,
1413
+ "required": false
1414
+ },
1374
1415
  "required": false,
1375
- "_meta": {
1376
- "nullable": true
1377
- }
1416
+ "description": "The hint shown beside the field on the form."
1378
1417
  },
1379
- "decidedBy": {
1380
- "type": "crossPackageRef",
1418
+ "label": {
1419
+ "type": "text",
1420
+ "_meta": {
1421
+ "__statedOptions": [
1422
+ "nullable",
1423
+ "description",
1424
+ "required"
1425
+ ],
1426
+ "description": "The name people see for the field on forms.",
1427
+ "nullable": true,
1428
+ "required": false
1429
+ },
1381
1430
  "required": false,
1382
- "related": "@happyvertical/smrt-users:User",
1431
+ "description": "The name people see for the field on forms."
1432
+ },
1433
+ "displayOrder": {
1434
+ "type": "integer",
1383
1435
  "_meta": {
1384
- "nullable": true
1385
- }
1436
+ "__statedOptions": [
1437
+ "nullable",
1438
+ "description",
1439
+ "required"
1440
+ ],
1441
+ "description": "Where the field appears on the form; lower numbers come first.",
1442
+ "nullable": true,
1443
+ "required": false
1444
+ },
1445
+ "required": false,
1446
+ "description": "Where the field appears on the form; lower numbers come first."
1386
1447
  },
1387
- "decidedAt": {
1388
- "type": "datetime",
1448
+ "locked": {
1449
+ "type": "boolean",
1450
+ "_meta": {
1451
+ "__statedOptions": [
1452
+ "nullable",
1453
+ "description",
1454
+ "required"
1455
+ ],
1456
+ "description": "Stops individual people from changing this field for themselves.",
1457
+ "nullable": true,
1458
+ "required": false
1459
+ },
1389
1460
  "required": false,
1461
+ "description": "Stops individual people from changing this field for themselves."
1462
+ },
1463
+ "updatedBy": {
1464
+ "type": "crossPackageRef",
1390
1465
  "_meta": {
1391
- "nullable": true
1392
- }
1466
+ "__statedOptions": [
1467
+ "nullable",
1468
+ "related",
1469
+ "required"
1470
+ ],
1471
+ "nullable": true,
1472
+ "required": false
1473
+ },
1474
+ "required": false,
1475
+ "related": "@happyvertical/smrt-users:User"
1393
1476
  }
1394
1477
  },
1395
1478
  "methods": {
1396
- "getEvidence": {
1397
- "name": "getEvidence",
1479
+ "getDefaultValue": {
1480
+ "name": "getDefaultValue",
1398
1481
  "async": false,
1399
1482
  "parameters": [],
1400
- "returnType": "Record<string, unknown>",
1483
+ "returnType": "unknown",
1401
1484
  "isStatic": false,
1402
1485
  "isPublic": true
1403
1486
  },
1404
- "setEvidence": {
1405
- "name": "setEvidence",
1487
+ "setDefaultValue": {
1488
+ "name": "setDefaultValue",
1406
1489
  "async": false,
1407
1490
  "parameters": [
1408
1491
  {
1409
- "name": "evidence",
1410
- "type": "Record<string, unknown>",
1492
+ "name": "value",
1493
+ "type": "unknown",
1411
1494
  "optional": false
1412
1495
  }
1413
1496
  ],
@@ -1415,22 +1498,6 @@
1415
1498
  "isStatic": false,
1416
1499
  "isPublic": true
1417
1500
  },
1418
- "getProposedValue": {
1419
- "name": "getProposedValue",
1420
- "async": false,
1421
- "parameters": [],
1422
- "returnType": "unknown",
1423
- "isStatic": false,
1424
- "isPublic": true
1425
- },
1426
- "toSuggestionData": {
1427
- "name": "toSuggestionData",
1428
- "async": false,
1429
- "parameters": [],
1430
- "returnType": "FieldPolicySuggestionData",
1431
- "isStatic": false,
1432
- "isPublic": true
1433
- },
1434
1501
  "save": {
1435
1502
  "name": "save",
1436
1503
  "async": true,
@@ -1455,25 +1522,40 @@
1455
1522
  }
1456
1523
  },
1457
1524
  "decoratorConfig": {
1458
- "tableName": "_smrt_field_policy_suggestions",
1525
+ "tableName": "_smrt_field_policies",
1459
1526
  "conflictColumns": [
1460
1527
  "object_ref",
1461
1528
  "field_name",
1462
- "tenant_id",
1463
- "kind",
1464
- "active_key"
1529
+ "scope_type",
1530
+ "scope_key"
1465
1531
  ],
1466
1532
  "api": {
1467
- "include": []
1533
+ "include": [
1534
+ "create",
1535
+ "update",
1536
+ "delete"
1537
+ ],
1538
+ "principalContext": true
1539
+ },
1540
+ "cli": {
1541
+ "include": [
1542
+ "create",
1543
+ "update",
1544
+ "delete"
1545
+ ],
1546
+ "exclude": [
1547
+ "getDefaultValue",
1548
+ "setDefaultValue"
1549
+ ]
1468
1550
  },
1469
- "cli": false,
1470
1551
  "mcp": {
1471
1552
  "include": []
1472
1553
  }
1473
1554
  },
1474
1555
  "extends": "SmrtObject",
1475
- "exportName": "FieldPolicySuggestion",
1476
- "collectionExportName": "FieldPolicySuggestionCollection",
1556
+ "exportName": "FieldPolicy",
1557
+ "collectionExportName": "FieldPolicyCollection",
1558
+ "displayLabelField": "label",
1477
1559
  "validationRules": [
1478
1560
  {
1479
1561
  "field": "objectRef",
@@ -1486,24 +1568,19 @@
1486
1568
  "fieldType": "text"
1487
1569
  },
1488
1570
  {
1489
- "field": "kind",
1490
- "rule": "required",
1491
- "fieldType": "text"
1492
- },
1493
- {
1494
- "field": "status",
1571
+ "field": "scopeType",
1495
1572
  "rule": "required",
1496
1573
  "fieldType": "text"
1497
1574
  },
1498
1575
  {
1499
- "field": "activeKey",
1576
+ "field": "scopeKey",
1500
1577
  "rule": "required",
1501
1578
  "fieldType": "text"
1502
1579
  }
1503
1580
  ],
1504
1581
  "schema": {
1505
- "tableName": "_smrt_field_policy_suggestions",
1506
- "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_policy_suggestions\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
1582
+ "tableName": "_smrt_field_policies",
1583
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_policies\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
1507
1584
  "columns": {
1508
1585
  "_sync_origin_device_id": {
1509
1586
  "type": "TEXT"
@@ -1548,193 +1625,283 @@
1548
1625
  "unique": false,
1549
1626
  "default": ""
1550
1627
  },
1628
+ "scope_type": {
1629
+ "type": "TEXT",
1630
+ "notNull": true,
1631
+ "unique": false,
1632
+ "default": "app"
1633
+ },
1551
1634
  "tenant_id": {
1552
1635
  "type": "UUID",
1553
1636
  "referenceKind": "tenantId",
1554
- "notNull": true,
1637
+ "notNull": false,
1555
1638
  "unique": false
1556
1639
  },
1557
- "kind": {
1640
+ "user_id": {
1641
+ "type": "UUID",
1642
+ "referenceKind": "crossPackageRef",
1643
+ "notNull": false,
1644
+ "unique": false
1645
+ },
1646
+ "scope_key": {
1558
1647
  "type": "TEXT",
1559
1648
  "notNull": true,
1560
- "unique": false,
1561
- "default": "promote"
1649
+ "unique": false
1562
1650
  },
1563
- "proposed_value": {
1651
+ "default_value": {
1564
1652
  "type": "TEXT",
1565
1653
  "notNull": false,
1566
1654
  "unique": false
1567
1655
  },
1568
- "evidence": {
1656
+ "visibility": {
1569
1657
  "type": "TEXT",
1570
1658
  "notNull": false,
1571
1659
  "unique": false
1572
1660
  },
1573
- "status": {
1661
+ "help": {
1574
1662
  "type": "TEXT",
1575
- "notNull": true,
1576
- "unique": false,
1577
- "default": "pending"
1663
+ "notNull": false,
1664
+ "unique": false
1578
1665
  },
1579
- "active_key": {
1666
+ "label": {
1580
1667
  "type": "TEXT",
1581
- "notNull": true,
1668
+ "notNull": false,
1582
1669
  "unique": false
1583
1670
  },
1584
- "cooldown_until": {
1585
- "type": "TIMESTAMP",
1671
+ "display_order": {
1672
+ "type": "INTEGER",
1586
1673
  "notNull": false,
1587
1674
  "unique": false
1588
1675
  },
1589
- "decided_by": {
1590
- "type": "UUID",
1591
- "referenceKind": "crossPackageRef",
1676
+ "locked": {
1677
+ "type": "BOOLEAN",
1592
1678
  "notNull": false,
1593
1679
  "unique": false
1594
1680
  },
1595
- "decided_at": {
1596
- "type": "TIMESTAMP",
1681
+ "updated_by": {
1682
+ "type": "UUID",
1683
+ "referenceKind": "crossPackageRef",
1597
1684
  "notNull": false,
1598
1685
  "unique": false
1599
1686
  }
1600
1687
  },
1601
1688
  "indexes": [
1602
1689
  {
1603
- "name": "_smrt_field_policy_suggestions_object_ref_field_name_idx",
1690
+ "name": "_smrt_field_policies_object_ref_field_name_idx",
1604
1691
  "columns": [
1605
1692
  "object_ref",
1606
1693
  "field_name",
1607
- "tenant_id",
1608
- "kind",
1609
- "active_key"
1694
+ "scope_type",
1695
+ "scope_key"
1610
1696
  ],
1611
1697
  "unique": true
1612
1698
  },
1613
1699
  {
1614
- "name": "_smrt_field_policy_suggestions_slug_context_idx",
1700
+ "name": "_smrt_field_policies_slug_context_idx",
1615
1701
  "columns": [
1616
1702
  "slug",
1617
1703
  "context"
1618
1704
  ]
1619
1705
  },
1620
1706
  {
1621
- "name": "_smrt_field_policy_suggestions_tenant_id_created_at_idx",
1707
+ "name": "_smrt_field_policies_tenant_id_created_at_idx",
1622
1708
  "columns": [
1623
1709
  "tenant_id",
1624
1710
  "created_at"
1625
1711
  ]
1626
1712
  },
1627
1713
  {
1628
- "name": "_smrt_field_policy_suggestions_decided_by_idx",
1714
+ "name": "_smrt_field_policies_user_id_idx",
1629
1715
  "columns": [
1630
- "decided_by"
1716
+ "user_id"
1717
+ ]
1718
+ },
1719
+ {
1720
+ "name": "_smrt_field_policies_updated_by_idx",
1721
+ "columns": [
1722
+ "updated_by"
1631
1723
  ]
1632
1724
  }
1633
1725
  ],
1634
- "version": "e3858540"
1726
+ "version": "83d6d14b"
1635
1727
  },
1636
- "importPath": "@happyvertical/smrt-fields"
1637
- },
1638
- "@happyvertical/smrt-fields:FieldUsageCounter": {
1639
- "name": "fieldusagecounter",
1640
- "className": "FieldUsageCounter",
1641
- "qualifiedName": "@happyvertical/smrt-fields:FieldUsageCounter",
1642
- "collection": "fieldusagecounters",
1643
- "filePath": "/home/runner/work/smrt/smrt/packages/fields/src/models/FieldUsageCounter.ts",
1728
+ "importPath": "@happyvertical/smrt-fields"
1729
+ },
1730
+ "@happyvertical/smrt-fields:FieldPolicySuggestion": {
1731
+ "name": "fieldpolicysuggestion",
1732
+ "className": "FieldPolicySuggestion",
1733
+ "qualifiedName": "@happyvertical/smrt-fields:FieldPolicySuggestion",
1734
+ "collection": "fieldpolicysuggestions",
1735
+ "filePath": "src/models/FieldPolicySuggestion.ts",
1644
1736
  "packageName": "@happyvertical/smrt-fields",
1645
1737
  "fields": {
1646
1738
  "objectRef": {
1647
1739
  "type": "text",
1648
- "required": true,
1649
- "default": "",
1650
1740
  "_meta": {
1651
- "required": true
1652
- }
1741
+ "__statedOptions": [
1742
+ "required",
1743
+ "requiredFor",
1744
+ "default"
1745
+ ],
1746
+ "required": true,
1747
+ "requiredFor": "identity"
1748
+ },
1749
+ "required": true,
1750
+ "default": ""
1653
1751
  },
1654
1752
  "fieldName": {
1655
1753
  "type": "text",
1656
- "required": true,
1657
- "default": "",
1658
1754
  "_meta": {
1659
- "required": true
1660
- }
1755
+ "__statedOptions": [
1756
+ "required",
1757
+ "requiredFor",
1758
+ "default"
1759
+ ],
1760
+ "required": true,
1761
+ "requiredFor": "identity"
1762
+ },
1763
+ "required": true,
1764
+ "default": ""
1661
1765
  },
1662
1766
  "tenantId": {
1663
1767
  "type": "text",
1664
- "required": true,
1665
1768
  "_meta": {
1666
- "sqlType": "UUID",
1667
1769
  "__tenancy": {
1668
1770
  "isTenantIdField": true,
1669
1771
  "autoFilter": true,
1670
1772
  "required": true,
1671
1773
  "autoPopulate": true,
1672
1774
  "nullable": false
1673
- }
1674
- }
1775
+ },
1776
+ "__statedOptions": [
1777
+ "sqlType",
1778
+ "requiredFor",
1779
+ "__tenancy"
1780
+ ],
1781
+ "sqlType": "UUID",
1782
+ "requiredFor": "tenant-scope"
1783
+ },
1784
+ "required": true
1675
1785
  },
1676
- "period": {
1786
+ "kind": {
1677
1787
  "type": "text",
1678
- "required": true,
1679
- "default": "",
1680
1788
  "_meta": {
1789
+ "__statedOptions": [
1790
+ "required",
1791
+ "default",
1792
+ "enum"
1793
+ ],
1681
1794
  "required": true
1682
- }
1683
- },
1684
- "submissionCount": {
1685
- "type": "integer",
1686
- "required": false,
1687
- "_meta": {}
1688
- },
1689
- "setCount": {
1690
- "type": "integer",
1691
- "required": false,
1692
- "_meta": {}
1795
+ },
1796
+ "required": true,
1797
+ "default": "promote",
1798
+ "enum": [
1799
+ "promote",
1800
+ "default"
1801
+ ]
1693
1802
  },
1694
- "distinctUserCount": {
1695
- "type": "integer",
1696
- "required": false,
1697
- "_meta": {}
1803
+ "proposedValue": {
1804
+ "type": "text",
1805
+ "_meta": {
1806
+ "__statedOptions": [
1807
+ "nullable",
1808
+ "required"
1809
+ ],
1810
+ "nullable": true,
1811
+ "required": false
1812
+ },
1813
+ "required": false
1698
1814
  },
1699
- "distinctUserIds": {
1815
+ "evidence": {
1700
1816
  "type": "text",
1701
- "required": false,
1702
- "_meta": {}
1817
+ "_meta": {
1818
+ "__statedOptions": []
1819
+ },
1820
+ "required": false
1703
1821
  },
1704
- "distinctUsersOverflowed": {
1705
- "type": "boolean",
1706
- "required": false,
1707
- "_meta": {}
1822
+ "status": {
1823
+ "type": "text",
1824
+ "_meta": {
1825
+ "__statedOptions": [
1826
+ "required",
1827
+ "default",
1828
+ "enum"
1829
+ ],
1830
+ "required": true
1831
+ },
1832
+ "required": true,
1833
+ "default": "pending",
1834
+ "enum": [
1835
+ "pending",
1836
+ "accepted",
1837
+ "dismissed"
1838
+ ]
1708
1839
  },
1709
- "valueHistogram": {
1840
+ "activeKey": {
1710
1841
  "type": "text",
1711
- "required": false,
1712
1842
  "_meta": {
1713
- "nullable": true
1714
- }
1843
+ "__statedOptions": [
1844
+ "required"
1845
+ ],
1846
+ "required": true
1847
+ },
1848
+ "required": true
1715
1849
  },
1716
- "valueHistogramOverflowed": {
1717
- "type": "boolean",
1850
+ "cooldownUntil": {
1851
+ "type": "datetime",
1852
+ "_meta": {
1853
+ "__statedOptions": [
1854
+ "nullable",
1855
+ "required"
1856
+ ],
1857
+ "nullable": true,
1858
+ "required": false
1859
+ },
1860
+ "required": false
1861
+ },
1862
+ "decidedBy": {
1863
+ "type": "crossPackageRef",
1864
+ "_meta": {
1865
+ "__statedOptions": [
1866
+ "nullable",
1867
+ "related",
1868
+ "required"
1869
+ ],
1870
+ "nullable": true,
1871
+ "required": false
1872
+ },
1718
1873
  "required": false,
1719
- "_meta": {}
1874
+ "related": "@happyvertical/smrt-users:User"
1875
+ },
1876
+ "decidedAt": {
1877
+ "type": "datetime",
1878
+ "_meta": {
1879
+ "__statedOptions": [
1880
+ "nullable",
1881
+ "required"
1882
+ ],
1883
+ "nullable": true,
1884
+ "required": false
1885
+ },
1886
+ "required": false
1720
1887
  }
1721
1888
  },
1722
1889
  "methods": {
1723
- "getDistinctUserIds": {
1724
- "name": "getDistinctUserIds",
1890
+ "getEvidence": {
1891
+ "name": "getEvidence",
1725
1892
  "async": false,
1726
1893
  "parameters": [],
1727
- "returnType": "string[]",
1894
+ "returnType": "Record<string, unknown>",
1728
1895
  "isStatic": false,
1729
1896
  "isPublic": true
1730
1897
  },
1731
- "addDistinctUser": {
1732
- "name": "addDistinctUser",
1898
+ "setEvidence": {
1899
+ "name": "setEvidence",
1733
1900
  "async": false,
1734
1901
  "parameters": [
1735
1902
  {
1736
- "name": "userId",
1737
- "type": "string",
1903
+ "name": "evidence",
1904
+ "type": "Record<string, unknown>",
1738
1905
  "optional": false
1739
1906
  }
1740
1907
  ],
@@ -1742,33 +1909,19 @@
1742
1909
  "isStatic": false,
1743
1910
  "isPublic": true
1744
1911
  },
1745
- "getValueHistogram": {
1746
- "name": "getValueHistogram",
1912
+ "getProposedValue": {
1913
+ "name": "getProposedValue",
1747
1914
  "async": false,
1748
1915
  "parameters": [],
1749
- "returnType": "Record<string, number>",
1750
- "isStatic": false,
1751
- "isPublic": true
1752
- },
1753
- "recordHistogramSample": {
1754
- "name": "recordHistogramSample",
1755
- "async": false,
1756
- "parameters": [
1757
- {
1758
- "name": "key",
1759
- "type": "string",
1760
- "optional": false
1761
- }
1762
- ],
1763
- "returnType": "void",
1916
+ "returnType": "unknown",
1764
1917
  "isStatic": false,
1765
1918
  "isPublic": true
1766
1919
  },
1767
- "isLegacyBucket": {
1768
- "name": "isLegacyBucket",
1920
+ "toSuggestionData": {
1921
+ "name": "toSuggestionData",
1769
1922
  "async": false,
1770
1923
  "parameters": [],
1771
- "returnType": "boolean",
1924
+ "returnType": "FieldPolicySuggestionData",
1772
1925
  "isStatic": false,
1773
1926
  "isPublic": true
1774
1927
  },
@@ -1796,12 +1949,13 @@
1796
1949
  }
1797
1950
  },
1798
1951
  "decoratorConfig": {
1799
- "tableName": "_smrt_field_usage_counters",
1952
+ "tableName": "_smrt_field_policy_suggestions",
1800
1953
  "conflictColumns": [
1801
1954
  "object_ref",
1802
1955
  "field_name",
1803
1956
  "tenant_id",
1804
- "period"
1957
+ "kind",
1958
+ "active_key"
1805
1959
  ],
1806
1960
  "api": {
1807
1961
  "include": []
@@ -1812,8 +1966,8 @@
1812
1966
  }
1813
1967
  },
1814
1968
  "extends": "SmrtObject",
1815
- "exportName": "FieldUsageCounter",
1816
- "collectionExportName": "FieldUsageCounterCollection",
1969
+ "exportName": "FieldPolicySuggestion",
1970
+ "collectionExportName": "FieldPolicySuggestionCollection",
1817
1971
  "validationRules": [
1818
1972
  {
1819
1973
  "field": "objectRef",
@@ -1826,14 +1980,24 @@
1826
1980
  "fieldType": "text"
1827
1981
  },
1828
1982
  {
1829
- "field": "period",
1983
+ "field": "kind",
1984
+ "rule": "required",
1985
+ "fieldType": "text"
1986
+ },
1987
+ {
1988
+ "field": "status",
1989
+ "rule": "required",
1990
+ "fieldType": "text"
1991
+ },
1992
+ {
1993
+ "field": "activeKey",
1830
1994
  "rule": "required",
1831
1995
  "fieldType": "text"
1832
1996
  }
1833
1997
  ],
1834
1998
  "schema": {
1835
- "tableName": "_smrt_field_usage_counters",
1836
- "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_usage_counters\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
1999
+ "tableName": "_smrt_field_policy_suggestions",
2000
+ "ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_field_policy_suggestions\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\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);",
1837
2001
  "columns": {
1838
2002
  "_sync_origin_device_id": {
1839
2003
  "type": "TEXT"
@@ -1884,75 +2048,84 @@
1884
2048
  "notNull": true,
1885
2049
  "unique": false
1886
2050
  },
1887
- "period": {
2051
+ "kind": {
1888
2052
  "type": "TEXT",
1889
2053
  "notNull": true,
1890
2054
  "unique": false,
1891
- "default": ""
2055
+ "default": "promote"
1892
2056
  },
1893
- "submission_count": {
1894
- "type": "INTEGER",
2057
+ "proposed_value": {
2058
+ "type": "TEXT",
1895
2059
  "notNull": false,
1896
2060
  "unique": false
1897
2061
  },
1898
- "set_count": {
1899
- "type": "INTEGER",
2062
+ "evidence": {
2063
+ "type": "TEXT",
1900
2064
  "notNull": false,
1901
2065
  "unique": false
1902
2066
  },
1903
- "distinct_user_count": {
1904
- "type": "INTEGER",
1905
- "notNull": false,
1906
- "unique": false
2067
+ "status": {
2068
+ "type": "TEXT",
2069
+ "notNull": true,
2070
+ "unique": false,
2071
+ "default": "pending"
1907
2072
  },
1908
- "distinct_user_ids": {
2073
+ "active_key": {
1909
2074
  "type": "TEXT",
1910
- "notNull": false,
2075
+ "notNull": true,
1911
2076
  "unique": false
1912
2077
  },
1913
- "distinct_users_overflowed": {
1914
- "type": "BOOLEAN",
2078
+ "cooldown_until": {
2079
+ "type": "TIMESTAMP",
1915
2080
  "notNull": false,
1916
2081
  "unique": false
1917
2082
  },
1918
- "value_histogram": {
1919
- "type": "TEXT",
2083
+ "decided_by": {
2084
+ "type": "UUID",
2085
+ "referenceKind": "crossPackageRef",
1920
2086
  "notNull": false,
1921
2087
  "unique": false
1922
2088
  },
1923
- "value_histogram_overflowed": {
1924
- "type": "BOOLEAN",
2089
+ "decided_at": {
2090
+ "type": "TIMESTAMP",
1925
2091
  "notNull": false,
1926
2092
  "unique": false
1927
2093
  }
1928
2094
  },
1929
2095
  "indexes": [
1930
2096
  {
1931
- "name": "_smrt_field_usage_counters_object_ref_field_name_idx",
2097
+ "name": "_smrt_field_policy_suggestions_object_ref_field_name_idx",
1932
2098
  "columns": [
1933
2099
  "object_ref",
1934
2100
  "field_name",
1935
2101
  "tenant_id",
1936
- "period"
2102
+ "kind",
2103
+ "active_key"
1937
2104
  ],
1938
2105
  "unique": true
1939
2106
  },
1940
2107
  {
1941
- "name": "_smrt_field_usage_counters_slug_context_idx",
2108
+ "name": "_smrt_field_policy_suggestions_slug_context_idx",
1942
2109
  "columns": [
1943
2110
  "slug",
1944
2111
  "context"
1945
2112
  ]
1946
2113
  },
1947
2114
  {
1948
- "name": "_smrt_field_usage_counters_tenant_id_created_at_idx",
2115
+ "name": "_smrt_field_policy_suggestions_tenant_id_created_at_idx",
1949
2116
  "columns": [
1950
2117
  "tenant_id",
1951
2118
  "created_at"
1952
2119
  ]
2120
+ },
2121
+ {
2122
+ "name": "_smrt_field_policy_suggestions_decided_by_idx",
2123
+ "columns": [
2124
+ "decided_by"
2125
+ ]
1953
2126
  }
1954
2127
  ],
1955
- "version": "c9f56519"
2128
+ "version": "e3858540"
1956
2129
  },
1957
2130
  "importPath": "@happyvertical/smrt-fields"
1958
2131
  },
@@ -1962,51 +2135,80 @@
1962
2135
  "qualifiedName": "@happyvertical/smrt-fields:FieldUsageReportReceipt",
1963
2136
  "collection": "fieldusagereportreceipts",
1964
2137
  "description": "Durable daily receipt for one member's contribution to one field.",
1965
- "filePath": "/home/runner/work/smrt/smrt/packages/fields/src/models/FieldUsageReportReceipt.ts",
2138
+ "filePath": "src/models/FieldUsageReportReceipt.ts",
1966
2139
  "packageName": "@happyvertical/smrt-fields",
1967
2140
  "fields": {
1968
2141
  "tenantId": {
1969
2142
  "type": "text",
1970
- "required": true,
1971
2143
  "_meta": {
1972
- "sqlType": "UUID",
1973
2144
  "__tenancy": {
1974
2145
  "isTenantIdField": true,
1975
2146
  "autoFilter": true,
1976
2147
  "required": true,
1977
2148
  "autoPopulate": true,
1978
2149
  "nullable": false
1979
- }
1980
- }
2150
+ },
2151
+ "__statedOptions": [
2152
+ "sqlType",
2153
+ "requiredFor",
2154
+ "__tenancy"
2155
+ ],
2156
+ "sqlType": "UUID",
2157
+ "requiredFor": "tenant-scope"
2158
+ },
2159
+ "required": true
1981
2160
  },
1982
2161
  "userId": {
1983
2162
  "type": "crossPackageRef",
2163
+ "_meta": {
2164
+ "__statedOptions": [
2165
+ "related"
2166
+ ]
2167
+ },
1984
2168
  "required": false,
1985
2169
  "related": "@happyvertical/smrt-users:User"
1986
2170
  },
1987
2171
  "objectRef": {
1988
2172
  "type": "text",
1989
- "required": true,
1990
- "default": "",
1991
2173
  "_meta": {
1992
- "required": true
1993
- }
2174
+ "__statedOptions": [
2175
+ "required",
2176
+ "requiredFor",
2177
+ "default"
2178
+ ],
2179
+ "required": true,
2180
+ "requiredFor": "idempotency"
2181
+ },
2182
+ "required": true,
2183
+ "default": ""
1994
2184
  },
1995
2185
  "fieldName": {
1996
2186
  "type": "text",
1997
- "required": true,
1998
- "default": "",
1999
2187
  "_meta": {
2000
- "required": true
2001
- }
2188
+ "__statedOptions": [
2189
+ "required",
2190
+ "requiredFor",
2191
+ "default"
2192
+ ],
2193
+ "required": true,
2194
+ "requiredFor": "idempotency"
2195
+ },
2196
+ "required": true,
2197
+ "default": ""
2002
2198
  },
2003
2199
  "period": {
2004
2200
  "type": "text",
2005
- "required": true,
2006
- "default": "",
2007
2201
  "_meta": {
2008
- "required": true
2009
- }
2202
+ "__statedOptions": [
2203
+ "required",
2204
+ "requiredFor",
2205
+ "default"
2206
+ ],
2207
+ "required": true,
2208
+ "requiredFor": "idempotency"
2209
+ },
2210
+ "required": true,
2211
+ "default": ""
2010
2212
  }
2011
2213
  },
2012
2214
  "methods": {},
@@ -2157,7 +2359,7 @@
2157
2359
  "qualifiedName": "@happyvertical/smrt-fields:FieldUsageLearningAgent",
2158
2360
  "collection": "fieldusagelearningagents",
2159
2361
  "description": "The registered schedule target for the #2051 learning loop (see the module doc for why it is NOT an smrt-agents Agent subclass).",
2160
- "filePath": "/home/runner/work/smrt/smrt/packages/fields/src/usage-learning.ts",
2362
+ "filePath": "src/usage-learning.ts",
2161
2363
  "packageName": "@happyvertical/smrt-fields",
2162
2364
  "fields": {},
2163
2365
  "methods": {
@@ -2331,5 +2533,6 @@
2331
2533
  "@happyvertical/smrt-users"
2332
2534
  ]
2333
2535
  },
2536
+ "schemaFingerprint": "04fcdf8c765bdab829fab461d9cc8405aa91365d1cb2312616453b37cd3df7ea",
2334
2537
  "stampsConstructors": true
2335
2538
  }