@happyvertical/smrt-preferences 0.0.0-stage → 0.55.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +133 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +134 -2
- package/agents/preference-kinds.md +79 -0
- package/dist/__smrt-register__.d.ts +2 -0
- package/dist/__smrt-register__.d.ts.map +1 -0
- package/dist/collections/UiPreferenceRecordCollection.d.ts +18 -0
- package/dist/collections/UiPreferenceRecordCollection.d.ts.map +1 -0
- package/dist/context.d.ts +36 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +990 -0
- package/dist/index.js.map +1 -0
- package/dist/kinds/builtin.d.ts +2 -0
- package/dist/kinds/builtin.d.ts.map +1 -0
- package/dist/kinds/overview.d.ts +32 -0
- package/dist/kinds/overview.d.ts.map +1 -0
- package/dist/kinds/shell-layout.d.ts +59 -0
- package/dist/kinds/shell-layout.d.ts.map +1 -0
- package/dist/kinds.d.ts +77 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/manifest.json +533 -0
- package/dist/models/UiPreferenceRecord.d.ts +100 -0
- package/dist/models/UiPreferenceRecord.d.ts.map +1 -0
- package/dist/overview.d.ts +127 -0
- package/dist/overview.d.ts.map +1 -0
- package/dist/permissions.d.ts +22 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/read-guard.d.ts +9 -0
- package/dist/read-guard.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +341 -0
- package/dist/store.d.ts +86 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/write-capability.d.ts +39 -0
- package/dist/write-capability.d.ts.map +1 -0
- package/package.json +63 -3
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"timestamp": 0,
|
|
4
|
+
"packageName": "@happyvertical/smrt-preferences",
|
|
5
|
+
"packageVersion": "0.55.10",
|
|
6
|
+
"objects": {
|
|
7
|
+
"@happyvertical/smrt-preferences:UiPreferenceRecordCollection": {
|
|
8
|
+
"name": "uipreferencerecordcollection",
|
|
9
|
+
"className": "UiPreferenceRecordCollection",
|
|
10
|
+
"qualifiedName": "@happyvertical/smrt-preferences:UiPreferenceRecordCollection",
|
|
11
|
+
"collection": "uipreferencerecords",
|
|
12
|
+
"description": "Reads of UiPreferenceRecord. Not decorated: the model has no generated surface, so a decorated collection would only add a second manifest schema for the same table.",
|
|
13
|
+
"filePath": "/home/runner/work/smrt/smrt/packages/preferences/src/collections/UiPreferenceRecordCollection.ts",
|
|
14
|
+
"packageName": "@happyvertical/smrt-preferences",
|
|
15
|
+
"fields": {},
|
|
16
|
+
"methods": {
|
|
17
|
+
"findTier": {
|
|
18
|
+
"name": "findTier",
|
|
19
|
+
"async": true,
|
|
20
|
+
"parameters": [
|
|
21
|
+
{
|
|
22
|
+
"name": "tenantId",
|
|
23
|
+
"type": "string",
|
|
24
|
+
"optional": false
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "kind",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"optional": false
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "surfaceId",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"optional": false
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "scope",
|
|
38
|
+
"type": "PreferenceScope",
|
|
39
|
+
"optional": false
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "userId",
|
|
43
|
+
"type": "string",
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"returnType": "Promise<UiPreferenceRecord | null>",
|
|
48
|
+
"isStatic": false,
|
|
49
|
+
"isPublic": true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"decoratorConfig": {
|
|
53
|
+
"tableName": "_smrt_ui_preferences",
|
|
54
|
+
"cli": false
|
|
55
|
+
},
|
|
56
|
+
"extends": "SmrtCollection",
|
|
57
|
+
"extendsTypeArg": "UiPreferenceRecord",
|
|
58
|
+
"exportName": "UiPreferenceRecordCollection",
|
|
59
|
+
"collectionExportName": "UiPreferenceRecordCollectionCollection",
|
|
60
|
+
"schema": {
|
|
61
|
+
"tableName": "_smrt_ui_preferences",
|
|
62
|
+
"ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_ui_preferences\" (\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 \"kind\" TEXT NOT NULL DEFAULT '',\n \"surface_id\" TEXT NOT NULL DEFAULT '',\n \"scope_type\" TEXT NOT NULL DEFAULT 'tenant',\n \"user_id\" UUID,\n \"scope_key\" TEXT NOT NULL,\n \"payload_json\" TEXT NOT NULL,\n \"format_version\" INTEGER,\n \"updated_by\" UUID\n);",
|
|
63
|
+
"columns": {
|
|
64
|
+
"id": {
|
|
65
|
+
"type": "UUID",
|
|
66
|
+
"primaryKey": true,
|
|
67
|
+
"referenceKind": "id",
|
|
68
|
+
"notNull": true
|
|
69
|
+
},
|
|
70
|
+
"slug": {
|
|
71
|
+
"type": "TEXT",
|
|
72
|
+
"notNull": true
|
|
73
|
+
},
|
|
74
|
+
"context": {
|
|
75
|
+
"type": "TEXT",
|
|
76
|
+
"notNull": true,
|
|
77
|
+
"default": ""
|
|
78
|
+
},
|
|
79
|
+
"created_at": {
|
|
80
|
+
"type": "TIMESTAMP",
|
|
81
|
+
"notNull": true,
|
|
82
|
+
"default": "current_timestamp"
|
|
83
|
+
},
|
|
84
|
+
"updated_at": {
|
|
85
|
+
"type": "TIMESTAMP",
|
|
86
|
+
"notNull": true,
|
|
87
|
+
"default": "current_timestamp"
|
|
88
|
+
},
|
|
89
|
+
"tenant_id": {
|
|
90
|
+
"type": "UUID",
|
|
91
|
+
"referenceKind": "tenantId",
|
|
92
|
+
"notNull": true,
|
|
93
|
+
"unique": false
|
|
94
|
+
},
|
|
95
|
+
"kind": {
|
|
96
|
+
"type": "TEXT",
|
|
97
|
+
"notNull": true,
|
|
98
|
+
"unique": false,
|
|
99
|
+
"default": ""
|
|
100
|
+
},
|
|
101
|
+
"surface_id": {
|
|
102
|
+
"type": "TEXT",
|
|
103
|
+
"notNull": true,
|
|
104
|
+
"unique": false,
|
|
105
|
+
"default": ""
|
|
106
|
+
},
|
|
107
|
+
"scope_type": {
|
|
108
|
+
"type": "TEXT",
|
|
109
|
+
"notNull": true,
|
|
110
|
+
"unique": false,
|
|
111
|
+
"default": "tenant"
|
|
112
|
+
},
|
|
113
|
+
"user_id": {
|
|
114
|
+
"type": "UUID",
|
|
115
|
+
"referenceKind": "crossPackageRef",
|
|
116
|
+
"notNull": false,
|
|
117
|
+
"unique": false
|
|
118
|
+
},
|
|
119
|
+
"scope_key": {
|
|
120
|
+
"type": "TEXT",
|
|
121
|
+
"notNull": true,
|
|
122
|
+
"unique": false
|
|
123
|
+
},
|
|
124
|
+
"payload_json": {
|
|
125
|
+
"type": "TEXT",
|
|
126
|
+
"notNull": true,
|
|
127
|
+
"unique": false
|
|
128
|
+
},
|
|
129
|
+
"format_version": {
|
|
130
|
+
"type": "INTEGER",
|
|
131
|
+
"notNull": false,
|
|
132
|
+
"unique": false
|
|
133
|
+
},
|
|
134
|
+
"updated_by": {
|
|
135
|
+
"type": "UUID",
|
|
136
|
+
"referenceKind": "crossPackageRef",
|
|
137
|
+
"notNull": false,
|
|
138
|
+
"unique": false
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"indexes": [
|
|
142
|
+
{
|
|
143
|
+
"name": "_smrt_ui_preferences_tenant_id_kind_idx",
|
|
144
|
+
"columns": [
|
|
145
|
+
"tenant_id",
|
|
146
|
+
"kind",
|
|
147
|
+
"surface_id",
|
|
148
|
+
"scope_type",
|
|
149
|
+
"scope_key"
|
|
150
|
+
],
|
|
151
|
+
"unique": true
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"name": "_smrt_ui_preferences_slug_context_idx",
|
|
155
|
+
"columns": [
|
|
156
|
+
"slug",
|
|
157
|
+
"context"
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "_smrt_ui_preferences_tenant_id_created_at_idx",
|
|
162
|
+
"columns": [
|
|
163
|
+
"tenant_id",
|
|
164
|
+
"created_at"
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"name": "_smrt_ui_preferences_user_id_idx",
|
|
169
|
+
"columns": [
|
|
170
|
+
"user_id"
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "_smrt_ui_preferences_updated_by_idx",
|
|
175
|
+
"columns": [
|
|
176
|
+
"updated_by"
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"version": "3f9df5fd"
|
|
181
|
+
},
|
|
182
|
+
"importPath": "@happyvertical/smrt-preferences"
|
|
183
|
+
},
|
|
184
|
+
"@happyvertical/smrt-preferences:UiPreferenceRecord": {
|
|
185
|
+
"name": "uipreferencerecord",
|
|
186
|
+
"className": "UiPreferenceRecord",
|
|
187
|
+
"qualifiedName": "@happyvertical/smrt-preferences:UiPreferenceRecord",
|
|
188
|
+
"collection": "uipreferencerecords",
|
|
189
|
+
"description": "One stored user-interface preference (#3727): the canonical payload of a registered preference kind (overview, shell-layout, ...) for one surface at one tier of one tenant.",
|
|
190
|
+
"filePath": "/home/runner/work/smrt/smrt/packages/preferences/src/models/UiPreferenceRecord.ts",
|
|
191
|
+
"packageName": "@happyvertical/smrt-preferences",
|
|
192
|
+
"fields": {
|
|
193
|
+
"tenantId": {
|
|
194
|
+
"type": "text",
|
|
195
|
+
"required": true,
|
|
196
|
+
"_meta": {
|
|
197
|
+
"sqlType": "UUID",
|
|
198
|
+
"__tenancy": {
|
|
199
|
+
"isTenantIdField": true,
|
|
200
|
+
"autoFilter": true,
|
|
201
|
+
"required": true,
|
|
202
|
+
"autoPopulate": true,
|
|
203
|
+
"nullable": false,
|
|
204
|
+
"mode": "required",
|
|
205
|
+
"field": "tenantId",
|
|
206
|
+
"allowSuperAdminBypass": false
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"kind": {
|
|
211
|
+
"type": "text",
|
|
212
|
+
"required": true,
|
|
213
|
+
"default": "",
|
|
214
|
+
"_meta": {
|
|
215
|
+
"required": true
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
"surfaceId": {
|
|
219
|
+
"type": "text",
|
|
220
|
+
"required": true,
|
|
221
|
+
"default": "",
|
|
222
|
+
"_meta": {
|
|
223
|
+
"required": true
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
"scopeType": {
|
|
227
|
+
"type": "text",
|
|
228
|
+
"required": true,
|
|
229
|
+
"default": "tenant",
|
|
230
|
+
"_meta": {
|
|
231
|
+
"required": true
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
"userId": {
|
|
235
|
+
"type": "crossPackageRef",
|
|
236
|
+
"required": false,
|
|
237
|
+
"related": "@happyvertical/smrt-users:User",
|
|
238
|
+
"_meta": {
|
|
239
|
+
"nullable": true
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
"scopeKey": {
|
|
243
|
+
"type": "text",
|
|
244
|
+
"required": true,
|
|
245
|
+
"_meta": {
|
|
246
|
+
"required": true
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
"payloadJson": {
|
|
250
|
+
"type": "text",
|
|
251
|
+
"required": true,
|
|
252
|
+
"_meta": {
|
|
253
|
+
"required": true
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
"formatVersion": {
|
|
257
|
+
"type": "integer",
|
|
258
|
+
"required": false,
|
|
259
|
+
"_meta": {}
|
|
260
|
+
},
|
|
261
|
+
"updatedBy": {
|
|
262
|
+
"type": "crossPackageRef",
|
|
263
|
+
"required": false,
|
|
264
|
+
"related": "@happyvertical/smrt-users:User",
|
|
265
|
+
"_meta": {
|
|
266
|
+
"nullable": true
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"methods": {
|
|
271
|
+
"loadFromId": {
|
|
272
|
+
"name": "loadFromId",
|
|
273
|
+
"async": true,
|
|
274
|
+
"parameters": [],
|
|
275
|
+
"returnType": "Promise<void>",
|
|
276
|
+
"isStatic": false,
|
|
277
|
+
"isPublic": true
|
|
278
|
+
},
|
|
279
|
+
"loadFromSlug": {
|
|
280
|
+
"name": "loadFromSlug",
|
|
281
|
+
"async": true,
|
|
282
|
+
"parameters": [],
|
|
283
|
+
"returnType": "Promise<void>",
|
|
284
|
+
"isStatic": false,
|
|
285
|
+
"isPublic": true
|
|
286
|
+
},
|
|
287
|
+
"getPayload": {
|
|
288
|
+
"name": "getPayload",
|
|
289
|
+
"async": false,
|
|
290
|
+
"parameters": [],
|
|
291
|
+
"returnType": "unknown",
|
|
292
|
+
"isStatic": false,
|
|
293
|
+
"isPublic": true
|
|
294
|
+
},
|
|
295
|
+
"setPayload": {
|
|
296
|
+
"name": "setPayload",
|
|
297
|
+
"async": false,
|
|
298
|
+
"parameters": [
|
|
299
|
+
{
|
|
300
|
+
"name": "value",
|
|
301
|
+
"type": "unknown",
|
|
302
|
+
"optional": false
|
|
303
|
+
}
|
|
304
|
+
],
|
|
305
|
+
"returnType": "void",
|
|
306
|
+
"isStatic": false,
|
|
307
|
+
"isPublic": true
|
|
308
|
+
},
|
|
309
|
+
"save": {
|
|
310
|
+
"name": "save",
|
|
311
|
+
"async": true,
|
|
312
|
+
"parameters": [
|
|
313
|
+
{
|
|
314
|
+
"name": "options",
|
|
315
|
+
"type": "SaveOptions",
|
|
316
|
+
"optional": true
|
|
317
|
+
}
|
|
318
|
+
],
|
|
319
|
+
"returnType": "Promise<this>",
|
|
320
|
+
"isStatic": false,
|
|
321
|
+
"isPublic": true
|
|
322
|
+
},
|
|
323
|
+
"delete": {
|
|
324
|
+
"name": "delete",
|
|
325
|
+
"async": true,
|
|
326
|
+
"parameters": [
|
|
327
|
+
{
|
|
328
|
+
"name": "options",
|
|
329
|
+
"type": "DeleteOptions",
|
|
330
|
+
"optional": true
|
|
331
|
+
}
|
|
332
|
+
],
|
|
333
|
+
"returnType": "Promise<void>",
|
|
334
|
+
"isStatic": false,
|
|
335
|
+
"isPublic": true
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
"decoratorConfig": {
|
|
339
|
+
"tableName": "_smrt_ui_preferences",
|
|
340
|
+
"conflictColumns": [
|
|
341
|
+
"tenant_id",
|
|
342
|
+
"kind",
|
|
343
|
+
"surface_id",
|
|
344
|
+
"scope_type",
|
|
345
|
+
"scope_key"
|
|
346
|
+
],
|
|
347
|
+
"api": {
|
|
348
|
+
"include": []
|
|
349
|
+
},
|
|
350
|
+
"cli": false,
|
|
351
|
+
"mcp": {
|
|
352
|
+
"include": []
|
|
353
|
+
},
|
|
354
|
+
"tenantScoped": {
|
|
355
|
+
"mode": "required"
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
"extends": "SmrtObject",
|
|
359
|
+
"exportName": "UiPreferenceRecord",
|
|
360
|
+
"collectionExportName": "UiPreferenceRecordCollection",
|
|
361
|
+
"validationRules": [
|
|
362
|
+
{
|
|
363
|
+
"field": "kind",
|
|
364
|
+
"rule": "required",
|
|
365
|
+
"fieldType": "text"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"field": "surfaceId",
|
|
369
|
+
"rule": "required",
|
|
370
|
+
"fieldType": "text"
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"field": "scopeType",
|
|
374
|
+
"rule": "required",
|
|
375
|
+
"fieldType": "text"
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"field": "scopeKey",
|
|
379
|
+
"rule": "required",
|
|
380
|
+
"fieldType": "text"
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
"field": "payloadJson",
|
|
384
|
+
"rule": "required",
|
|
385
|
+
"fieldType": "text"
|
|
386
|
+
}
|
|
387
|
+
],
|
|
388
|
+
"schema": {
|
|
389
|
+
"tableName": "_smrt_ui_preferences",
|
|
390
|
+
"ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_ui_preferences\" (\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 \"kind\" TEXT NOT NULL DEFAULT '',\n \"surface_id\" TEXT NOT NULL DEFAULT '',\n \"scope_type\" TEXT NOT NULL DEFAULT 'tenant',\n \"user_id\" UUID,\n \"scope_key\" TEXT NOT NULL,\n \"payload_json\" TEXT NOT NULL,\n \"format_version\" INTEGER,\n \"updated_by\" UUID\n);",
|
|
391
|
+
"columns": {
|
|
392
|
+
"id": {
|
|
393
|
+
"type": "UUID",
|
|
394
|
+
"primaryKey": true,
|
|
395
|
+
"referenceKind": "id",
|
|
396
|
+
"notNull": true
|
|
397
|
+
},
|
|
398
|
+
"slug": {
|
|
399
|
+
"type": "TEXT",
|
|
400
|
+
"notNull": true
|
|
401
|
+
},
|
|
402
|
+
"context": {
|
|
403
|
+
"type": "TEXT",
|
|
404
|
+
"notNull": true,
|
|
405
|
+
"default": ""
|
|
406
|
+
},
|
|
407
|
+
"created_at": {
|
|
408
|
+
"type": "TIMESTAMP",
|
|
409
|
+
"notNull": true,
|
|
410
|
+
"default": "current_timestamp"
|
|
411
|
+
},
|
|
412
|
+
"updated_at": {
|
|
413
|
+
"type": "TIMESTAMP",
|
|
414
|
+
"notNull": true,
|
|
415
|
+
"default": "current_timestamp"
|
|
416
|
+
},
|
|
417
|
+
"tenant_id": {
|
|
418
|
+
"type": "UUID",
|
|
419
|
+
"referenceKind": "tenantId",
|
|
420
|
+
"notNull": true,
|
|
421
|
+
"unique": false
|
|
422
|
+
},
|
|
423
|
+
"kind": {
|
|
424
|
+
"type": "TEXT",
|
|
425
|
+
"notNull": true,
|
|
426
|
+
"unique": false,
|
|
427
|
+
"default": ""
|
|
428
|
+
},
|
|
429
|
+
"surface_id": {
|
|
430
|
+
"type": "TEXT",
|
|
431
|
+
"notNull": true,
|
|
432
|
+
"unique": false,
|
|
433
|
+
"default": ""
|
|
434
|
+
},
|
|
435
|
+
"scope_type": {
|
|
436
|
+
"type": "TEXT",
|
|
437
|
+
"notNull": true,
|
|
438
|
+
"unique": false,
|
|
439
|
+
"default": "tenant"
|
|
440
|
+
},
|
|
441
|
+
"user_id": {
|
|
442
|
+
"type": "UUID",
|
|
443
|
+
"referenceKind": "crossPackageRef",
|
|
444
|
+
"notNull": false,
|
|
445
|
+
"unique": false
|
|
446
|
+
},
|
|
447
|
+
"scope_key": {
|
|
448
|
+
"type": "TEXT",
|
|
449
|
+
"notNull": true,
|
|
450
|
+
"unique": false
|
|
451
|
+
},
|
|
452
|
+
"payload_json": {
|
|
453
|
+
"type": "TEXT",
|
|
454
|
+
"notNull": true,
|
|
455
|
+
"unique": false
|
|
456
|
+
},
|
|
457
|
+
"format_version": {
|
|
458
|
+
"type": "INTEGER",
|
|
459
|
+
"notNull": false,
|
|
460
|
+
"unique": false
|
|
461
|
+
},
|
|
462
|
+
"updated_by": {
|
|
463
|
+
"type": "UUID",
|
|
464
|
+
"referenceKind": "crossPackageRef",
|
|
465
|
+
"notNull": false,
|
|
466
|
+
"unique": false
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
"indexes": [
|
|
470
|
+
{
|
|
471
|
+
"name": "_smrt_ui_preferences_tenant_id_kind_idx",
|
|
472
|
+
"columns": [
|
|
473
|
+
"tenant_id",
|
|
474
|
+
"kind",
|
|
475
|
+
"surface_id",
|
|
476
|
+
"scope_type",
|
|
477
|
+
"scope_key"
|
|
478
|
+
],
|
|
479
|
+
"unique": true
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"name": "_smrt_ui_preferences_slug_context_idx",
|
|
483
|
+
"columns": [
|
|
484
|
+
"slug",
|
|
485
|
+
"context"
|
|
486
|
+
]
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"name": "_smrt_ui_preferences_tenant_id_created_at_idx",
|
|
490
|
+
"columns": [
|
|
491
|
+
"tenant_id",
|
|
492
|
+
"created_at"
|
|
493
|
+
]
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
"name": "_smrt_ui_preferences_user_id_idx",
|
|
497
|
+
"columns": [
|
|
498
|
+
"user_id"
|
|
499
|
+
]
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
"name": "_smrt_ui_preferences_updated_by_idx",
|
|
503
|
+
"columns": [
|
|
504
|
+
"updated_by"
|
|
505
|
+
]
|
|
506
|
+
}
|
|
507
|
+
],
|
|
508
|
+
"version": "3f9df5fd"
|
|
509
|
+
},
|
|
510
|
+
"importPath": "@happyvertical/smrt-preferences"
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
"moduleType": "smrt",
|
|
514
|
+
"smrtDependencies": [
|
|
515
|
+
"@happyvertical/smrt-core",
|
|
516
|
+
"@happyvertical/smrt-tenancy",
|
|
517
|
+
"@happyvertical/smrt-users"
|
|
518
|
+
],
|
|
519
|
+
"browser": {
|
|
520
|
+
"status": "server-only",
|
|
521
|
+
"issues": [
|
|
522
|
+
"#3617",
|
|
523
|
+
"#3624",
|
|
524
|
+
"#3626"
|
|
525
|
+
],
|
|
526
|
+
"via": [
|
|
527
|
+
"@happyvertical/smrt-profiles",
|
|
528
|
+
"@happyvertical/smrt-tenancy",
|
|
529
|
+
"@happyvertical/smrt-users"
|
|
530
|
+
]
|
|
531
|
+
},
|
|
532
|
+
"stampsConstructors": true
|
|
533
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
+
import { type PreferenceScope } from '../kinds.js';
|
|
3
|
+
type ConstructorOptions = ConstructorParameters<typeof SmrtObject>[0];
|
|
4
|
+
type SaveOptions = NonNullable<Parameters<SmrtObject['save']>[0]>;
|
|
5
|
+
type DeleteOptions = NonNullable<Parameters<SmrtObject['delete']>[0]>;
|
|
6
|
+
/** `scopeKey` of a tenant-default row (user rows use the user id). */
|
|
7
|
+
export declare const TENANT_SCOPE_KEY = "__tenant__";
|
|
8
|
+
/**
|
|
9
|
+
* One stored user-interface preference (#3727): the canonical payload of a
|
|
10
|
+
* registered preference kind (`overview`, `shell-layout`, ...) for one surface
|
|
11
|
+
* at one tier of one tenant.
|
|
12
|
+
*
|
|
13
|
+
* - `scopeType: 'tenant'` is the tenant default (`userId` null), written with
|
|
14
|
+
* the kind's tenant permission.
|
|
15
|
+
* - `scopeType: 'user'` is one person's preference on top of the tenant
|
|
16
|
+
* default, inside that tenant. Only that user may write it, with the kind's
|
|
17
|
+
* user permission.
|
|
18
|
+
*
|
|
19
|
+
* Every row carries its tenant, so the table is `@TenantScoped` (required):
|
|
20
|
+
* the tenancy interceptor filters reads and refuses foreign rows, and the
|
|
21
|
+
* save/delete guards below re-check identity, tier ownership and the kind's
|
|
22
|
+
* permission. The kind's validator (run by the store) owns the payload's
|
|
23
|
+
* content; this model owns identity, scope shape and authorization, and
|
|
24
|
+
* refuses any kind that is not registered.
|
|
25
|
+
*
|
|
26
|
+
* No generated surface: a payload is only meaningful after its kind's
|
|
27
|
+
* validation, which a generated route would skip.
|
|
28
|
+
*/
|
|
29
|
+
export declare class UiPreferenceRecord extends SmrtObject {
|
|
30
|
+
/** Owning tenant (native UUID on PostgreSQL/DuckDB). */
|
|
31
|
+
tenantId: string;
|
|
32
|
+
/** The registered preference kind (`overview`, `shell-layout`, ...). */
|
|
33
|
+
kind: string;
|
|
34
|
+
/** The surface within the kind (an overview id, a shell key). */
|
|
35
|
+
surfaceId: string;
|
|
36
|
+
/** `tenant` (the tenant default) or `user` (one person's preference). */
|
|
37
|
+
scopeType: PreferenceScope;
|
|
38
|
+
/** The owning user of a user-scope row; NULL on the tenant default. */
|
|
39
|
+
userId: string | null;
|
|
40
|
+
/**
|
|
41
|
+
* `userId ?? '__tenant__'`, set on save. Keeps the `conflictColumns`
|
|
42
|
+
* unique index total while `userId` is nullable (NULLs are distinct in a
|
|
43
|
+
* unique index). Kept in lockstep with
|
|
44
|
+
* `scopeType` / `userId` on every write, so the owner read predicate
|
|
45
|
+
* (`read-guard.ts`) can filter on it in one condition.
|
|
46
|
+
*/
|
|
47
|
+
scopeKey: string;
|
|
48
|
+
/** The kind's canonical payload as JSON text. */
|
|
49
|
+
payloadJson: string;
|
|
50
|
+
/** The kind's format version the payload was written at. */
|
|
51
|
+
formatVersion: number;
|
|
52
|
+
/** Who last wrote the row; stamped from the ambient principal. */
|
|
53
|
+
updatedBy: string | null;
|
|
54
|
+
constructor(options?: ConstructorOptions);
|
|
55
|
+
/**
|
|
56
|
+
* Single-row hydration (`new UiPreferenceRecord({ id }).initialize()`)
|
|
57
|
+
* reads the table directly, outside the collection interceptors, so the
|
|
58
|
+
* owner check runs here: another user's row is wiped and refused.
|
|
59
|
+
*/
|
|
60
|
+
loadFromId(): Promise<void>;
|
|
61
|
+
loadFromSlug(): Promise<void>;
|
|
62
|
+
private assertReadable;
|
|
63
|
+
/** The stored payload, parsed. `undefined` when the text is not JSON. */
|
|
64
|
+
getPayload(): unknown;
|
|
65
|
+
/** Store a payload; the caller passes the kind's canonical value. */
|
|
66
|
+
setPayload(value: unknown): void;
|
|
67
|
+
/** The optimistic-concurrency token a client echoes back on save. */
|
|
68
|
+
get revision(): string | null;
|
|
69
|
+
save(options?: SaveOptions): Promise<this>;
|
|
70
|
+
/**
|
|
71
|
+
* Runs for ordinary saves and bulk creates alike, so a collection-level
|
|
72
|
+
* bulk insert is refused too (`save()` checks first so callers see it).
|
|
73
|
+
*/
|
|
74
|
+
protected validateBeforeSave(): Promise<void>;
|
|
75
|
+
delete(options?: DeleteOptions): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Only the store, after the kind's validator accepted exactly this
|
|
78
|
+
* payload, may write a row (see `write-capability.ts`).
|
|
79
|
+
*/
|
|
80
|
+
private assertStoreWrite;
|
|
81
|
+
private syncScopeKey;
|
|
82
|
+
private validateShape;
|
|
83
|
+
/**
|
|
84
|
+
* Fail-closed tier guard. The tenant must be the principal's (the
|
|
85
|
+
* interceptor checks this too; a super-admin bypass does not filter reads,
|
|
86
|
+
* so it is re-checked here), a user row must belong to the principal (a
|
|
87
|
+
* principal with no user id may not touch the user tier), the kind must be
|
|
88
|
+
* registered, and its permission for the tier must be held.
|
|
89
|
+
*/
|
|
90
|
+
private authorize;
|
|
91
|
+
/**
|
|
92
|
+
* A persisted row keeps its identity: the stored tenant, kind, surface and
|
|
93
|
+
* tier must be the ones in memory, so {@link authorize} always judges the
|
|
94
|
+
* row as stored. Matched by predicate rather than by reading the columns
|
|
95
|
+
* back, because DuckDB returns raw UUID columns as lossy HUGEINTs.
|
|
96
|
+
*/
|
|
97
|
+
private assertPersistedIdentityUnchanged;
|
|
98
|
+
}
|
|
99
|
+
export {};
|
|
100
|
+
//# sourceMappingURL=UiPreferenceRecord.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UiPreferenceRecord.d.ts","sourceRoot":"","sources":["../../src/models/UiPreferenceRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,aAAa,CAAC;AAsBrB,KAAK,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AACtE,KAAK,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,KAAK,aAAa,GAAG,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtE,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAca,kBAAmB,SAAQ,UAAU;IAChD,wDAAwD;IAExD,QAAQ,EAAE,MAAM,CAAM;IAEtB,wEAAwE;IAExE,IAAI,EAAE,MAAM,CAAM;IAElB,iEAAiE;IAEjE,SAAS,EAAE,MAAM,CAAM;IAEvB,yEAAyE;IAEzE,SAAS,EAAE,eAAe,CAAY;IAEtC,uEAAuE;IAEvE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE7B;;;;;;OAMG;IAEH,QAAQ,EAAE,MAAM,CAAM;IAEtB,iDAAiD;IAEjD,WAAW,EAAE,MAAM,CAAM;IAEzB,4DAA4D;IAE5D,aAAa,EAAE,MAAM,CAAK;IAE1B,kEAAkE;IAElE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;gBAEpB,OAAO,GAAE,kBAAuB;IAK5C;;;;OAIG;IACY,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5C,OAAO,CAAC,cAAc;IAQtB,yEAAyE;IACzE,UAAU,IAAI,OAAO;IAQrB,qEAAqE;IACrE,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAIhC,qEAAqE;IACrE,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAK5B;IAEc,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB7D;;;OAGG;cACsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAK7C,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAcjE;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,aAAa;IAwBrB;;;;;;OAMG;YACW,SAAS;IA4BvB;;;;;OAKG;YACW,gCAAgC;CAkB/C"}
|