@happyvertical/smrt-fields 0.40.60 → 0.40.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +58 -12
- package/README.md +143 -42
- package/dist/__smrt-register__.d.ts +2 -0
- package/dist/__smrt-register__.d.ts.map +1 -0
- package/dist/cache.d.ts +18 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/chunks/FieldPolicyCollection--RxukfCX.js +1218 -0
- package/dist/chunks/FieldPolicyCollection--RxukfCX.js.map +1 -0
- package/dist/collections/FieldPolicyCollection.d.ts +95 -0
- package/dist/collections/FieldPolicyCollection.d.ts.map +1 -0
- package/dist/collections/FieldPolicySuggestionCollection.d.ts +160 -0
- package/dist/collections/FieldPolicySuggestionCollection.d.ts.map +1 -0
- package/dist/collections/FieldUsageCounterCollection.d.ts +143 -0
- package/dist/collections/FieldUsageCounterCollection.d.ts.map +1 -0
- package/dist/deterministic-id.d.ts +18 -0
- package/dist/deterministic-id.d.ts.map +1 -0
- package/dist/field-definitions.d.ts +85 -0
- package/dist/field-definitions.d.ts.map +1 -0
- package/dist/field-policy-resolver.d.ts +46 -0
- package/dist/field-policy-resolver.d.ts.map +1 -0
- package/dist/index.d.ts +15 -532
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1813 -628
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +1487 -191
- package/dist/models/FieldPolicy.d.ts +163 -0
- package/dist/models/FieldPolicy.d.ts.map +1 -0
- package/dist/models/FieldPolicySuggestion.d.ts +132 -0
- package/dist/models/FieldPolicySuggestion.d.ts.map +1 -0
- package/dist/models/FieldUsageCounter.d.ts +178 -0
- package/dist/models/FieldUsageCounter.d.ts.map +1 -0
- package/dist/models/FieldUsageReportReceipt.d.ts +25 -0
- package/dist/models/FieldUsageReportReceipt.d.ts.map +1 -0
- package/dist/permissions.d.ts +9 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/playground.d.ts +2 -0
- package/dist/playground.d.ts.map +1 -0
- package/dist/playground.js +39 -0
- package/dist/playground.js.map +1 -0
- package/dist/settings-catalog.d.ts +73 -0
- package/dist/settings-catalog.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +449 -9
- package/dist/svelte/__tests__/FieldPolicyControlPanel.test.js +277 -0
- package/dist/svelte/__tests__/FieldPolicyGear.test.js +503 -0
- package/dist/svelte/__tests__/FormHelp.test.js +138 -0
- package/dist/svelte/__tests__/ModeUX.test.js +109 -0
- package/dist/svelte/__tests__/ObjectForm.test.js +687 -0
- package/dist/svelte/__tests__/ObjectFormGeneratedApi.integration.test.js +436 -0
- package/dist/svelte/__tests__/PolicyField.test.js +373 -0
- package/dist/svelte/__tests__/UsageLearning.test.js +140 -0
- package/dist/svelte/__tests__/fixtures/AdvancedFieldsFixture.svelte +30 -0
- package/dist/svelte/__tests__/fixtures/AdvancedFieldsFixture.svelte.d.ts +9 -0
- package/dist/svelte/__tests__/fixtures/AdvancedFieldsFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/DomPrefillFixture.svelte +33 -0
- package/dist/svelte/__tests__/fixtures/DomPrefillFixture.svelte.d.ts +10 -0
- package/dist/svelte/__tests__/fixtures/DomPrefillFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/FormHelpFixture.svelte +19 -0
- package/dist/svelte/__tests__/fixtures/FormHelpFixture.svelte.d.ts +10 -0
- package/dist/svelte/__tests__/fixtures/FormHelpFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/GeneratedApiGearFixture.svelte +18 -0
- package/dist/svelte/__tests__/fixtures/GeneratedApiGearFixture.svelte.d.ts +11 -0
- package/dist/svelte/__tests__/fixtures/GeneratedApiGearFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/GracefulDegradeFixture.svelte +11 -0
- package/dist/svelte/__tests__/fixtures/GracefulDegradeFixture.svelte.d.ts +19 -0
- package/dist/svelte/__tests__/fixtures/GracefulDegradeFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/ModeSwitchFixture.svelte +18 -0
- package/dist/svelte/__tests__/fixtures/ModeSwitchFixture.svelte.d.ts +8 -0
- package/dist/svelte/__tests__/fixtures/ModeSwitchFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/NoIdFixture.svelte +24 -0
- package/dist/svelte/__tests__/fixtures/NoIdFixture.svelte.d.ts +13 -0
- package/dist/svelte/__tests__/fixtures/NoIdFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormActionsFixture.svelte +37 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormActionsFixture.svelte.d.ts +15 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormActionsFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormFixture.svelte +17 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormFixture.svelte.d.ts +10 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormRegistryFixture.svelte +25 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormRegistryFixture.svelte.d.ts +10 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormRegistryFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormSnippetFixture.svelte +34 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormSnippetFixture.svelte.d.ts +10 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormSnippetFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormSourceFixture.svelte +29 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormSourceFixture.svelte.d.ts +11 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormSourceFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormSourceSnippetFixture.svelte +33 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormSourceSnippetFixture.svelte.d.ts +9 -0
- package/dist/svelte/__tests__/fixtures/ObjectFormSourceSnippetFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/PolicyDataTableFixture.svelte +40 -0
- package/dist/svelte/__tests__/fixtures/PolicyDataTableFixture.svelte.d.ts +8 -0
- package/dist/svelte/__tests__/fixtures/PolicyDataTableFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/PrefillFixture.svelte +26 -0
- package/dist/svelte/__tests__/fixtures/PrefillFixture.svelte.d.ts +13 -0
- package/dist/svelte/__tests__/fixtures/PrefillFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/ProviderFieldFixture.svelte +39 -0
- package/dist/svelte/__tests__/fixtures/ProviderFieldFixture.svelte.d.ts +17 -0
- package/dist/svelte/__tests__/fixtures/ProviderFieldFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/RegistryInput.svelte +15 -0
- package/dist/svelte/__tests__/fixtures/RegistryInput.svelte.d.ts +5 -0
- package/dist/svelte/__tests__/fixtures/RegistryInput.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/RevealPrefillFixture.svelte +29 -0
- package/dist/svelte/__tests__/fixtures/RevealPrefillFixture.svelte.d.ts +14 -0
- package/dist/svelte/__tests__/fixtures/RevealPrefillFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/SettingsCatalogStub.svelte +24 -0
- package/dist/svelte/__tests__/fixtures/SettingsCatalogStub.svelte.d.ts +14 -0
- package/dist/svelte/__tests__/fixtures/SettingsCatalogStub.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/SnippetFixture.svelte +28 -0
- package/dist/svelte/__tests__/fixtures/SnippetFixture.svelte.d.ts +13 -0
- package/dist/svelte/__tests__/fixtures/SnippetFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/SuggestionGearFixture.svelte +23 -0
- package/dist/svelte/__tests__/fixtures/SuggestionGearFixture.svelte.d.ts +10 -0
- package/dist/svelte/__tests__/fixtures/SuggestionGearFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/ToggleModeButton.svelte +14 -0
- package/dist/svelte/__tests__/fixtures/ToggleModeButton.svelte.d.ts +19 -0
- package/dist/svelte/__tests__/fixtures/ToggleModeButton.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/fixtures/TooltipFixture.svelte +25 -0
- package/dist/svelte/__tests__/fixtures/TooltipFixture.svelte.d.ts +14 -0
- package/dist/svelte/__tests__/fixtures/TooltipFixture.svelte.d.ts.map +1 -0
- package/dist/svelte/__tests__/settings-catalog.test.js +161 -0
- package/dist/svelte/components/AdvancedFields.svelte +49 -0
- package/dist/svelte/components/AdvancedFields.svelte.d.ts +17 -0
- package/dist/svelte/components/AdvancedFields.svelte.d.ts.map +1 -0
- package/dist/svelte/components/FieldInput.svelte +159 -0
- package/dist/svelte/components/FieldInput.svelte.d.ts +5 -0
- package/dist/svelte/components/FieldInput.svelte.d.ts.map +1 -0
- package/dist/svelte/components/FieldPolicyControlPanel.svelte +288 -0
- package/dist/svelte/components/FieldPolicyControlPanel.svelte.d.ts +29 -0
- package/dist/svelte/components/FieldPolicyControlPanel.svelte.d.ts.map +1 -0
- package/dist/svelte/components/FieldPolicyEditor.svelte +417 -0
- package/dist/svelte/components/FieldPolicyEditor.svelte.d.ts +18 -0
- package/dist/svelte/components/FieldPolicyEditor.svelte.d.ts.map +1 -0
- package/dist/svelte/components/FieldPolicyGearButton.svelte +24 -0
- package/dist/svelte/components/FieldPolicyGearButton.svelte.d.ts +8 -0
- package/dist/svelte/components/FieldPolicyGearButton.svelte.d.ts.map +1 -0
- package/dist/svelte/components/FieldPolicyGearProvider.svelte +169 -0
- package/dist/svelte/components/FieldPolicyGearProvider.svelte.d.ts +20 -0
- package/dist/svelte/components/FieldPolicyGearProvider.svelte.d.ts.map +1 -0
- package/dist/svelte/components/FieldPolicyProvider.svelte +89 -0
- package/dist/svelte/components/FieldPolicyProvider.svelte.d.ts +35 -0
- package/dist/svelte/components/FieldPolicyProvider.svelte.d.ts.map +1 -0
- package/dist/svelte/components/FieldPolicySuggestionQueue.svelte +135 -0
- package/dist/svelte/components/FieldPolicySuggestionQueue.svelte.d.ts +11 -0
- package/dist/svelte/components/FieldPolicySuggestionQueue.svelte.d.ts.map +1 -0
- package/dist/svelte/components/FormHelp.svelte +157 -0
- package/dist/svelte/components/FormHelp.svelte.d.ts +15 -0
- package/dist/svelte/components/FormHelp.svelte.d.ts.map +1 -0
- package/dist/svelte/components/ModeSwitch.svelte +47 -0
- package/dist/svelte/components/ModeSwitch.svelte.d.ts +10 -0
- package/dist/svelte/components/ModeSwitch.svelte.d.ts.map +1 -0
- package/dist/svelte/components/ObjectForm.svelte +440 -0
- package/dist/svelte/components/ObjectForm.svelte.d.ts +50 -0
- package/dist/svelte/components/ObjectForm.svelte.d.ts.map +1 -0
- package/dist/svelte/components/ObjectFormSourceProvider.svelte +18 -0
- package/dist/svelte/components/ObjectFormSourceProvider.svelte.d.ts +11 -0
- package/dist/svelte/components/ObjectFormSourceProvider.svelte.d.ts.map +1 -0
- package/dist/svelte/components/PolicyField.svelte +338 -0
- package/dist/svelte/components/PolicyField.svelte.d.ts +80 -0
- package/dist/svelte/components/PolicyField.svelte.d.ts.map +1 -0
- package/dist/svelte/context.svelte.d.ts +54 -0
- package/dist/svelte/context.svelte.d.ts.map +1 -0
- package/dist/svelte/context.svelte.js +55 -0
- package/dist/svelte/data-table.d.ts +17 -0
- package/dist/svelte/data-table.d.ts.map +1 -0
- package/dist/svelte/data-table.js +19 -0
- package/dist/svelte/field-policy-editor.d.ts +81 -0
- package/dist/svelte/field-policy-editor.d.ts.map +1 -0
- package/dist/svelte/field-policy-editor.js +120 -0
- package/dist/svelte/gear-context.svelte.d.ts +16 -0
- package/dist/svelte/gear-context.svelte.d.ts.map +1 -0
- package/dist/svelte/gear-context.svelte.js +15 -0
- package/dist/svelte/index.d.ts +63 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +41 -0
- package/dist/svelte/input-registry.d.ts +21 -0
- package/dist/svelte/input-registry.d.ts.map +1 -0
- package/dist/svelte/input-registry.js +26 -0
- package/dist/svelte/object-form-source-context.svelte.d.ts +4 -0
- package/dist/svelte/object-form-source-context.svelte.d.ts.map +1 -0
- package/dist/svelte/object-form-source-context.svelte.js +8 -0
- package/dist/svelte/object-form-source.svelte.d.ts +18 -0
- package/dist/svelte/object-form-source.svelte.d.ts.map +1 -0
- package/dist/svelte/object-form-source.svelte.js +99 -0
- package/dist/svelte/object-form.d.ts +6 -0
- package/dist/svelte/object-form.d.ts.map +1 -0
- package/dist/svelte/object-form.js +38 -0
- package/dist/svelte/playground/FieldPolicyFormPreview.svelte +212 -0
- package/dist/svelte/playground/FieldPolicyFormPreview.svelte.d.ts +4 -0
- package/dist/svelte/playground/FieldPolicyFormPreview.svelte.d.ts.map +1 -0
- package/dist/svelte/playground/ObjectFormPreview.svelte +129 -0
- package/dist/svelte/playground/ObjectFormPreview.svelte.d.ts +4 -0
- package/dist/svelte/playground/ObjectFormPreview.svelte.d.ts.map +1 -0
- package/dist/svelte/playground.d.ts +20 -0
- package/dist/svelte/playground.d.ts.map +1 -0
- package/dist/svelte/playground.js +38 -0
- package/dist/svelte/settings-catalog.d.ts +54 -0
- package/dist/svelte/settings-catalog.d.ts.map +1 -0
- package/dist/svelte/settings-catalog.js +116 -0
- package/dist/svelte/suggestions.d.ts +38 -0
- package/dist/svelte/suggestions.d.ts.map +1 -0
- package/dist/svelte/suggestions.js +68 -0
- package/dist/svelte/types.d.ts +101 -0
- package/dist/svelte/types.d.ts.map +1 -0
- package/dist/svelte/types.js +4 -0
- package/dist/svelte/usage-capture.d.ts +63 -0
- package/dist/svelte/usage-capture.d.ts.map +1 -0
- package/dist/svelte/usage-capture.js +61 -0
- package/dist/types.d.ts +316 -203
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -1
- package/dist/types.js.map +1 -1
- package/dist/usage-learning.d.ts +201 -0
- package/dist/usage-learning.d.ts.map +1 -0
- package/dist/usage-schedules.d.ts +110 -0
- package/dist/usage-schedules.d.ts.map +1 -0
- package/dist/users-module.d.ts +30 -0
- package/dist/users-module.d.ts.map +1 -0
- package/package.json +33 -8
package/dist/types.d.ts
CHANGED
|
@@ -1,203 +1,316 @@
|
|
|
1
|
-
import { SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export declare const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
*/
|
|
114
|
-
export
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
export {
|
|
1
|
+
import { SmrtClassOptions, SmrtObjectOptions } from '@happyvertical/smrt-core';
|
|
2
|
+
/**
|
|
3
|
+
* Scope tier a {@link FieldPolicy} row belongs to.
|
|
4
|
+
*
|
|
5
|
+
* Resolution precedence is code seed → `app` → `tenant` (hierarchy walk,
|
|
6
|
+
* root → leaf) → `user`. Unlike smrt-features (which ships only
|
|
7
|
+
* `global`/`tenant`), the user tier is implemented end to end here — both
|
|
8
|
+
* defaults and visibility resolve through it.
|
|
9
|
+
*/
|
|
10
|
+
export type FieldPolicyScopeType = 'app' | 'tenant' | 'user';
|
|
11
|
+
/**
|
|
12
|
+
* Visibility tier for a field in generated/consuming form UIs.
|
|
13
|
+
*
|
|
14
|
+
* - `basic`: shown before the advanced disclosure
|
|
15
|
+
* - `advanced`: shown behind the advanced disclosure
|
|
16
|
+
* - `hidden`: not rendered (requires the field to be optional or have a
|
|
17
|
+
* resolved default — the required-field invariant)
|
|
18
|
+
*/
|
|
19
|
+
export type FieldPolicyVisibility = 'basic' | 'advanced' | 'hidden';
|
|
20
|
+
/**
|
|
21
|
+
* `scopeKey` value for app-scope rows. `scopeKey` exists ONLY so the
|
|
22
|
+
* `conflictColumns` unique index stays total while `tenantId`/`userId` are
|
|
23
|
+
* nullable (nullable columns would allow duplicate NULL rows) — the same
|
|
24
|
+
* trick as `PromptOverride.context`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const APP_FIELD_POLICY_SCOPE_KEY = "__app__";
|
|
27
|
+
export declare const FIELD_POLICY_SCOPE_TYPES: readonly FieldPolicyScopeType[];
|
|
28
|
+
export declare const FIELD_POLICY_VISIBILITIES: readonly FieldPolicyVisibility[];
|
|
29
|
+
export interface FieldPolicyOptions extends SmrtObjectOptions {
|
|
30
|
+
objectRef?: string;
|
|
31
|
+
fieldName?: string;
|
|
32
|
+
scopeType?: FieldPolicyScopeType;
|
|
33
|
+
tenantId?: string | null;
|
|
34
|
+
userId?: string | null;
|
|
35
|
+
/**
|
|
36
|
+
* ENCODED channel: an already-JSON-encoded default, exactly as the column
|
|
37
|
+
* stores it (`'"Net 30"'`, `'42'`, `'null'`), or `null` to inherit.
|
|
38
|
+
*
|
|
39
|
+
* This is the wire contract: the generated write routes hand the request
|
|
40
|
+
* body straight to the constructor, and the #2049/#2050 gear posts
|
|
41
|
+
* `JSON.stringify(draft.defaultValue)`. It must therefore keep meaning
|
|
42
|
+
* "already encoded" — auto-serializing here would double-encode every gear
|
|
43
|
+
* write.
|
|
44
|
+
*
|
|
45
|
+
* Use {@link FieldPolicyOptions.defaultValueRaw} for a plain value. The two
|
|
46
|
+
* are mutually exclusive: `'"TBD"'` and `'TBD'` are indistinguishable once
|
|
47
|
+
* a single option carries both meanings, so the channel must be explicit
|
|
48
|
+
* rather than sniffed.
|
|
49
|
+
*/
|
|
50
|
+
defaultValue?: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* PLAIN channel: any value, always serialized — strings included. The
|
|
53
|
+
* constructor-option twin of {@link FieldPolicy.setDefaultValue}, so
|
|
54
|
+
* `{ defaultValueRaw: 'Net 30' }` stores `'"Net 30"'` rather than the
|
|
55
|
+
* unparseable literal `Net 30`.
|
|
56
|
+
*/
|
|
57
|
+
defaultValueRaw?: unknown;
|
|
58
|
+
visibility?: FieldPolicyVisibility | null;
|
|
59
|
+
help?: string | null;
|
|
60
|
+
label?: string | null;
|
|
61
|
+
displayOrder?: number | null;
|
|
62
|
+
locked?: boolean | null;
|
|
63
|
+
updatedBy?: string | null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The sparse contribution of one layer (code seed or one stored row).
|
|
67
|
+
*
|
|
68
|
+
* `default` is boxed so an explicit JSON `null` default (meaning "default to
|
|
69
|
+
* null") stays distinguishable from "this layer contributes no default".
|
|
70
|
+
*/
|
|
71
|
+
export interface FieldPolicyDelta {
|
|
72
|
+
default?: {
|
|
73
|
+
value: unknown;
|
|
74
|
+
};
|
|
75
|
+
visibility?: FieldPolicyVisibility;
|
|
76
|
+
help?: string;
|
|
77
|
+
label?: string;
|
|
78
|
+
order?: number;
|
|
79
|
+
locked?: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** One layer's contribution to a field's resolved policy (explain variant). */
|
|
82
|
+
export interface FieldPolicyLayerContribution {
|
|
83
|
+
layer: 'code' | 'app' | 'tenant' | 'user';
|
|
84
|
+
/** Chain node id for `tenant` layers (root → leaf order). */
|
|
85
|
+
tenantId?: string;
|
|
86
|
+
/** User id for the `user` layer. */
|
|
87
|
+
userId?: string;
|
|
88
|
+
delta: FieldPolicyDelta;
|
|
89
|
+
}
|
|
90
|
+
/** Fully merged policy for a single field. */
|
|
91
|
+
export interface ResolvedFieldPolicy {
|
|
92
|
+
fieldName: string;
|
|
93
|
+
/** True when any layer resolved a default (including an explicit null). */
|
|
94
|
+
hasDefault: boolean;
|
|
95
|
+
/** Parsed default value; `undefined` when {@link hasDefault} is false. */
|
|
96
|
+
defaultValue: unknown;
|
|
97
|
+
visibility: FieldPolicyVisibility;
|
|
98
|
+
help: string | null;
|
|
99
|
+
label: string | null;
|
|
100
|
+
order: number | null;
|
|
101
|
+
/** Grouping key — code-seed only (`ui.group`), not overridable by rows. */
|
|
102
|
+
group: string | null;
|
|
103
|
+
locked: boolean;
|
|
104
|
+
/** Mirror of the manifest required flag (nullable fields are optional). */
|
|
105
|
+
required: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* True when the resolver forced `basic` visibility because the field is
|
|
108
|
+
* required and no usable default resolved (the resolver-side safety net for
|
|
109
|
+
* the required-field invariant).
|
|
110
|
+
*/
|
|
111
|
+
visibilityForced?: boolean;
|
|
112
|
+
}
|
|
113
|
+
/** Merged policy for every field of one object. */
|
|
114
|
+
export interface ResolvedObjectFieldPolicy {
|
|
115
|
+
objectRef: string;
|
|
116
|
+
fields: Record<string, ResolvedFieldPolicy>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Explain variant: merged result plus the ordered per-layer contributions for
|
|
120
|
+
* each field, so admin/gear UIs (#2049/#2050) never re-derive precedence.
|
|
121
|
+
* Layers are listed in application order (code, app, tenant chain root → leaf,
|
|
122
|
+
* user) and contain ONLY contributions that survive into the merged result:
|
|
123
|
+
* tenant ancestors discarded by a permission-inheritance break and user rows
|
|
124
|
+
* suppressed by an effective org lock are omitted, so sequentially replaying
|
|
125
|
+
* the listed deltas reproduces the merged policy.
|
|
126
|
+
*/
|
|
127
|
+
export interface ExplainedObjectFieldPolicy extends ResolvedObjectFieldPolicy {
|
|
128
|
+
layers: Record<string, FieldPolicyLayerContribution[]>;
|
|
129
|
+
}
|
|
130
|
+
/** Minimal tenant node consumed by the hierarchy walk (mirrors smrt-features). */
|
|
131
|
+
export interface FieldPolicyTenantNode {
|
|
132
|
+
id: string;
|
|
133
|
+
inheritPermissions: boolean;
|
|
134
|
+
cascadePermissions: boolean;
|
|
135
|
+
}
|
|
136
|
+
/** Provider returning the root → leaf tenant chain (mirrors smrt-features). */
|
|
137
|
+
export interface FieldPolicyTenantHierarchyProvider {
|
|
138
|
+
getChain(tenantId: string): Promise<FieldPolicyTenantNode[]>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Loader-function DI seam (NOT a container registration): the resolver calls
|
|
142
|
+
* it lazily and treats `null` as "no hierarchy available" (flat-tenant
|
|
143
|
+
* fallback). The default loader dynamic-imports `@happyvertical/smrt-users`
|
|
144
|
+
* and returns `null` when it is not installed.
|
|
145
|
+
*/
|
|
146
|
+
export type FieldPolicyTenantHierarchyLoader = (options: SmrtClassOptions) => Promise<FieldPolicyTenantHierarchyProvider | null>;
|
|
147
|
+
export interface ResolveFieldPolicyOptions {
|
|
148
|
+
tenantId?: string | null;
|
|
149
|
+
userId?: string | null;
|
|
150
|
+
/**
|
|
151
|
+
* Database holding `_smrt_field_policies`. Without it, only the code seed
|
|
152
|
+
* resolves (stored layers are skipped) — the smrt-prompts precedent.
|
|
153
|
+
*/
|
|
154
|
+
db?: SmrtClassOptions['db'];
|
|
155
|
+
tenantHierarchyLoader?: FieldPolicyTenantHierarchyLoader;
|
|
156
|
+
/**
|
|
157
|
+
* Internal write-validation seam: omit persisted rows while evaluating a
|
|
158
|
+
* proposed replacement. Excluded resolutions bypass the shared cache so a
|
|
159
|
+
* projected result can never poison ordinary reads.
|
|
160
|
+
*/
|
|
161
|
+
excludePolicyIds?: ReadonlySet<string>;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Minimal structural shape of the tenant surface loaded from
|
|
165
|
+
* `@happyvertical/smrt-users` by the default hierarchy loader. Only the
|
|
166
|
+
* permission-cascade fields consumed by the chain walk are modeled.
|
|
167
|
+
*/
|
|
168
|
+
export interface FieldPolicyUsersTenantRecord {
|
|
169
|
+
id: string;
|
|
170
|
+
inheritPermissions?: boolean;
|
|
171
|
+
cascadePermissions?: boolean;
|
|
172
|
+
}
|
|
173
|
+
export interface FieldPolicyUsersModule {
|
|
174
|
+
TenantCollection: {
|
|
175
|
+
create(options: SmrtClassOptions): Promise<{
|
|
176
|
+
get(criteria: {
|
|
177
|
+
id: string;
|
|
178
|
+
}): Promise<FieldPolicyUsersTenantRecord | null>;
|
|
179
|
+
getAncestorsFromRoot(tenantId: string): Promise<FieldPolicyUsersTenantRecord[]>;
|
|
180
|
+
}>;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/** Result shape of the batch resolve action (`FieldPolicyCollection.resolveBatch`). */
|
|
184
|
+
export interface FieldPolicyBatchResult {
|
|
185
|
+
policies: Record<string, ResolvedObjectFieldPolicy>;
|
|
186
|
+
}
|
|
187
|
+
/** A policy row safe to expose through the context-scoped gear action. */
|
|
188
|
+
export interface FieldPolicyEditorRow {
|
|
189
|
+
defaultValue: string | null;
|
|
190
|
+
displayOrder: number | null;
|
|
191
|
+
fieldName: string;
|
|
192
|
+
help: string | null;
|
|
193
|
+
id: string;
|
|
194
|
+
label: string | null;
|
|
195
|
+
locked: boolean | null;
|
|
196
|
+
scopeType: FieldPolicyScopeType;
|
|
197
|
+
tenantId: string | null;
|
|
198
|
+
updatedBy: string | null;
|
|
199
|
+
userId: string | null;
|
|
200
|
+
visibility: FieldPolicyVisibility | null;
|
|
201
|
+
}
|
|
202
|
+
/** Context-derived authorization state for the field-policy gear. */
|
|
203
|
+
export interface FieldPolicyEditorCapabilities {
|
|
204
|
+
manage: boolean;
|
|
205
|
+
personalize: boolean;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Gear bootstrap response. `policy` is always filtered by the public-field
|
|
209
|
+
* rail; raw rows and explanation layers appear only for scopes the caller is
|
|
210
|
+
* authorized to mutate. Row ids are present for reset/delete operations.
|
|
211
|
+
*/
|
|
212
|
+
export interface FieldPolicyEditorState {
|
|
213
|
+
capabilities: FieldPolicyEditorCapabilities;
|
|
214
|
+
/**
|
|
215
|
+
* For the caller's personal layer only, whether removing that layer's
|
|
216
|
+
* default still leaves a usable default at code/app/tenant precedence.
|
|
217
|
+
* This intentionally exposes no lower-layer rows or default values.
|
|
218
|
+
*/
|
|
219
|
+
personalLowerDefaultUsable: Record<string, boolean>;
|
|
220
|
+
policy: ExplainedObjectFieldPolicy;
|
|
221
|
+
rows: {
|
|
222
|
+
app: FieldPolicyEditorRow[];
|
|
223
|
+
tenant: FieldPolicyEditorRow[];
|
|
224
|
+
user: FieldPolicyEditorRow[];
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/** A stored organization row with the immutable audit metadata needed by #2050. */
|
|
228
|
+
export interface FieldPolicyAuditRow extends FieldPolicyEditorRow {
|
|
229
|
+
objectRef: string;
|
|
230
|
+
createdAt: string | null;
|
|
231
|
+
updatedAt: string | null;
|
|
232
|
+
}
|
|
233
|
+
/** Why a persisted policy row is no longer usable by the live registry. */
|
|
234
|
+
export type FieldPolicyDriftReason = 'unknown-object' | 'unknown-field' | 'excluded-field';
|
|
235
|
+
/** Drift is deliberately identity-only: stale values are never serialized. */
|
|
236
|
+
export interface FieldPolicyDriftRow {
|
|
237
|
+
id: string;
|
|
238
|
+
objectRef: string;
|
|
239
|
+
fieldName: string;
|
|
240
|
+
scopeType: FieldPolicyScopeType;
|
|
241
|
+
tenantId: string | null;
|
|
242
|
+
userId: string | null;
|
|
243
|
+
updatedBy: string | null;
|
|
244
|
+
createdAt: string | null;
|
|
245
|
+
updatedAt: string | null;
|
|
246
|
+
reason: FieldPolicyDriftReason;
|
|
247
|
+
prunable: boolean;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Tenant-admin catalog read surface. Foreign user rows are represented only
|
|
251
|
+
* by counts; their values and identifiers never leave the collection.
|
|
252
|
+
*/
|
|
253
|
+
export interface FieldPolicyAuditSnapshot {
|
|
254
|
+
orgRows: FieldPolicyAuditRow[];
|
|
255
|
+
appRows: FieldPolicyAuditRow[];
|
|
256
|
+
inheritedOrgKeys: Record<string, string[]>;
|
|
257
|
+
userOverrideCounts: Record<string, Record<string, number>>;
|
|
258
|
+
driftRows: FieldPolicyDriftRow[];
|
|
259
|
+
policies: Record<string, ExplainedObjectFieldPolicy>;
|
|
260
|
+
caller: {
|
|
261
|
+
tenantId: string | null;
|
|
262
|
+
userId: string | null;
|
|
263
|
+
canManageOrg: boolean;
|
|
264
|
+
canPersonalize: boolean;
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
/** Explicit 403 result used by generated custom-action transports. */
|
|
268
|
+
export interface FieldPolicyEditorStateDenied {
|
|
269
|
+
code: 'permission_denied';
|
|
270
|
+
message: string;
|
|
271
|
+
ok: false;
|
|
272
|
+
status: 403;
|
|
273
|
+
}
|
|
274
|
+
export type FieldPolicyEditorStateResult = FieldPolicyEditorState | FieldPolicyEditorStateDenied;
|
|
275
|
+
export type FieldPolicySuggestionKind = 'promote' | 'default';
|
|
276
|
+
export declare const FIELD_POLICY_SUGGESTION_KINDS: readonly FieldPolicySuggestionKind[];
|
|
277
|
+
export type FieldPolicySuggestionStatus = 'pending' | 'accepted' | 'dismissed';
|
|
278
|
+
export declare const FIELD_POLICY_SUGGESTION_STATUSES: readonly FieldPolicySuggestionStatus[];
|
|
279
|
+
/** One bounded client-side form submission sample. */
|
|
280
|
+
export interface FieldUsageReportEntry {
|
|
281
|
+
objectRef: string;
|
|
282
|
+
fieldName: string;
|
|
283
|
+
value?: unknown;
|
|
284
|
+
/** Used only for value-less samples; server comparison wins when present. */
|
|
285
|
+
matchedDefault?: boolean;
|
|
286
|
+
}
|
|
287
|
+
export interface FieldUsageReportResult {
|
|
288
|
+
accepted: number;
|
|
289
|
+
dropped: number;
|
|
290
|
+
}
|
|
291
|
+
export interface FieldPolicySuggestionData {
|
|
292
|
+
id: string;
|
|
293
|
+
objectRef: string;
|
|
294
|
+
fieldName: string;
|
|
295
|
+
tenantId: string;
|
|
296
|
+
kind: FieldPolicySuggestionKind;
|
|
297
|
+
proposedValue: string | null;
|
|
298
|
+
evidence: Record<string, unknown>;
|
|
299
|
+
status: FieldPolicySuggestionStatus;
|
|
300
|
+
cooldownUntil: string | null;
|
|
301
|
+
decidedBy: string | null;
|
|
302
|
+
decidedAt: string | null;
|
|
303
|
+
}
|
|
304
|
+
export interface PendingFieldPolicySuggestionsResult {
|
|
305
|
+
suggestions: FieldPolicySuggestionData[];
|
|
306
|
+
total: number;
|
|
307
|
+
}
|
|
308
|
+
export interface AcceptFieldPolicySuggestionResult {
|
|
309
|
+
suggestion: FieldPolicySuggestionData;
|
|
310
|
+
policyRowId: string;
|
|
311
|
+
}
|
|
312
|
+
export interface DismissFieldPolicySuggestionResult {
|
|
313
|
+
suggestion: FieldPolicySuggestionData;
|
|
314
|
+
}
|
|
315
|
+
export type { SmrtClassOptions };
|
|
316
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,YAAY,CAAC;AAEpD,eAAO,MAAM,wBAAwB,EAAE,SAAS,oBAAoB,EAInE,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,SAAS,qBAAqB,EAIrE,CAAC;AAEF,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;;;;;;;;;;;;;OAcG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC1C,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,CA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B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,mCAAmC;IAClD,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iCAAiC;IAChD,UAAU,EAAE,yBAAyB,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kCAAkC;IACjD,UAAU,EAAE,yBAAyB,CAAC;CACvC;AAED,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -10,7 +10,13 @@ var FIELD_POLICY_VISIBILITIES = [
|
|
|
10
10
|
"advanced",
|
|
11
11
|
"hidden"
|
|
12
12
|
];
|
|
13
|
+
var FIELD_POLICY_SUGGESTION_KINDS = ["promote", "default"];
|
|
14
|
+
var FIELD_POLICY_SUGGESTION_STATUSES = [
|
|
15
|
+
"pending",
|
|
16
|
+
"accepted",
|
|
17
|
+
"dismissed"
|
|
18
|
+
];
|
|
13
19
|
//#endregion
|
|
14
|
-
export { APP_FIELD_POLICY_SCOPE_KEY, FIELD_POLICY_SCOPE_TYPES, FIELD_POLICY_VISIBILITIES };
|
|
20
|
+
export { APP_FIELD_POLICY_SCOPE_KEY, FIELD_POLICY_SCOPE_TYPES, FIELD_POLICY_SUGGESTION_KINDS, FIELD_POLICY_SUGGESTION_STATUSES, FIELD_POLICY_VISIBILITIES };
|
|
15
21
|
|
|
16
22
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n SmrtClassOptions,\n SmrtObjectOptions,\n} from '@happyvertical/smrt-core';\n\n/**\n * Scope tier a {@link FieldPolicy} row belongs to.\n *\n * Resolution precedence is code seed → `app` → `tenant` (hierarchy walk,\n * root → leaf) → `user`. Unlike smrt-features (which ships only\n * `global`/`tenant`), the user tier is implemented end to end here — both\n * defaults and visibility resolve through it.\n */\nexport type FieldPolicyScopeType = 'app' | 'tenant' | 'user';\n\n/**\n * Visibility tier for a field in generated/consuming form UIs.\n *\n * - `basic`: shown before the advanced disclosure\n * - `advanced`: shown behind the advanced disclosure\n * - `hidden`: not rendered (requires the field to be optional or have a\n * resolved default — the required-field invariant)\n */\nexport type FieldPolicyVisibility = 'basic' | 'advanced' | 'hidden';\n\n/**\n * `scopeKey` value for app-scope rows. `scopeKey` exists ONLY so the\n * `conflictColumns` unique index stays total while `tenantId`/`userId` are\n * nullable (nullable columns would allow duplicate NULL rows) — the same\n * trick as `PromptOverride.context`.\n */\nexport const APP_FIELD_POLICY_SCOPE_KEY = '__app__';\n\nexport const FIELD_POLICY_SCOPE_TYPES: readonly FieldPolicyScopeType[] = [\n 'app',\n 'tenant',\n 'user',\n];\n\nexport const FIELD_POLICY_VISIBILITIES: readonly FieldPolicyVisibility[] = [\n 'basic',\n 'advanced',\n 'hidden',\n];\n\nexport interface FieldPolicyOptions extends SmrtObjectOptions {\n objectRef?: string;\n fieldName?: string;\n scopeType?: FieldPolicyScopeType;\n tenantId?: string | null;\n userId?: string | null;\n /**\n * ENCODED channel: an already-JSON-encoded default, exactly as the column\n * stores it (`'\"Net 30\"'`, `'42'`, `'null'`), or `null` to inherit.\n *\n * This is the wire contract: the generated write routes hand the request\n * body straight to the constructor, and the #2049/#2050 gear posts\n * `JSON.stringify(draft.defaultValue)`. It must therefore keep meaning\n * \"already encoded\" — auto-serializing here would double-encode every gear\n * write.\n *\n * Use {@link FieldPolicyOptions.defaultValueRaw} for a plain value. The two\n * are mutually exclusive: `'\"TBD\"'` and `'TBD'` are indistinguishable once\n * a single option carries both meanings, so the channel must be explicit\n * rather than sniffed.\n */\n defaultValue?: string | null;\n /**\n * PLAIN channel: any value, always serialized — strings included. The\n * constructor-option twin of {@link FieldPolicy.setDefaultValue}, so\n * `{ defaultValueRaw: 'Net 30' }` stores `'\"Net 30\"'` rather than the\n * unparseable literal `Net 30`.\n */\n defaultValueRaw?: unknown;\n visibility?: FieldPolicyVisibility | null;\n help?: string | null;\n label?: string | null;\n displayOrder?: number | null;\n locked?: boolean | null;\n updatedBy?: string | null;\n}\n\n/**\n * The sparse contribution of one layer (code seed or one stored row).\n *\n * `default` is boxed so an explicit JSON `null` default (meaning \"default to\n * null\") stays distinguishable from \"this layer contributes no default\".\n */\nexport interface FieldPolicyDelta {\n default?: { value: unknown };\n visibility?: FieldPolicyVisibility;\n help?: string;\n label?: string;\n order?: number;\n locked?: boolean;\n}\n\n/** One layer's contribution to a field's resolved policy (explain variant). */\nexport interface FieldPolicyLayerContribution {\n layer: 'code' | 'app' | 'tenant' | 'user';\n /** Chain node id for `tenant` layers (root → leaf order). */\n tenantId?: string;\n /** User id for the `user` layer. */\n userId?: string;\n delta: FieldPolicyDelta;\n}\n\n/** Fully merged policy for a single field. */\nexport interface ResolvedFieldPolicy {\n fieldName: string;\n /** True when any layer resolved a default (including an explicit null). */\n hasDefault: boolean;\n /** Parsed default value; `undefined` when {@link hasDefault} is false. */\n defaultValue: unknown;\n visibility: FieldPolicyVisibility;\n help: string | null;\n label: string | null;\n order: number | null;\n /** Grouping key — code-seed only (`ui.group`), not overridable by rows. */\n group: string | null;\n locked: boolean;\n /** Mirror of the manifest required flag (nullable fields are optional). */\n required: boolean;\n /**\n * True when the resolver forced `basic` visibility because the field is\n * required and no usable default resolved (the resolver-side safety net for\n * the required-field invariant).\n */\n visibilityForced?: boolean;\n}\n\n/** Merged policy for every field of one object. */\nexport interface ResolvedObjectFieldPolicy {\n objectRef: string;\n fields: Record<string, ResolvedFieldPolicy>;\n}\n\n/**\n * Explain variant: merged result plus the ordered per-layer contributions for\n * each field, so admin/gear UIs (#2049/#2050) never re-derive precedence.\n * Layers are listed in application order (code, app, tenant chain root → leaf,\n * user) and contain ONLY contributions that survive into the merged result:\n * tenant ancestors discarded by a permission-inheritance break and user rows\n * suppressed by an effective org lock are omitted, so sequentially replaying\n * the listed deltas reproduces the merged policy.\n */\nexport interface ExplainedObjectFieldPolicy extends ResolvedObjectFieldPolicy {\n layers: Record<string, FieldPolicyLayerContribution[]>;\n}\n\n/** Minimal tenant node consumed by the hierarchy walk (mirrors smrt-features). */\nexport interface FieldPolicyTenantNode {\n id: string;\n inheritPermissions: boolean;\n cascadePermissions: boolean;\n}\n\n/** Provider returning the root → leaf tenant chain (mirrors smrt-features). */\nexport interface FieldPolicyTenantHierarchyProvider {\n getChain(tenantId: string): Promise<FieldPolicyTenantNode[]>;\n}\n\n/**\n * Loader-function DI seam (NOT a container registration): the resolver calls\n * it lazily and treats `null` as \"no hierarchy available\" (flat-tenant\n * fallback). The default loader dynamic-imports `@happyvertical/smrt-users`\n * and returns `null` when it is not installed.\n */\nexport type FieldPolicyTenantHierarchyLoader = (\n options: SmrtClassOptions,\n) => Promise<FieldPolicyTenantHierarchyProvider | null>;\n\nexport interface ResolveFieldPolicyOptions {\n tenantId?: string | null;\n userId?: string | null;\n /**\n * Database holding `_smrt_field_policies`. Without it, only the code seed\n * resolves (stored layers are skipped) — the smrt-prompts precedent.\n */\n db?: SmrtClassOptions['db'];\n tenantHierarchyLoader?: FieldPolicyTenantHierarchyLoader;\n}\n\n/**\n * Minimal structural shape of the tenant surface loaded from\n * `@happyvertical/smrt-users` by the default hierarchy loader. Only the\n * permission-cascade fields consumed by the chain walk are modeled.\n */\nexport interface FieldPolicyUsersTenantRecord {\n id: string;\n inheritPermissions?: boolean;\n cascadePermissions?: boolean;\n}\n\nexport interface FieldPolicyUsersModule {\n TenantCollection: {\n create(options: SmrtClassOptions): Promise<{\n get(criteria: {\n id: string;\n }): Promise<FieldPolicyUsersTenantRecord | null>;\n getAncestorsFromRoot(\n tenantId: string,\n ): Promise<FieldPolicyUsersTenantRecord[]>;\n }>;\n };\n}\n\n/** Result shape of the batch resolve action (`FieldPolicyCollection.resolveBatch`). */\nexport interface FieldPolicyBatchResult {\n policies: Record<string, ResolvedObjectFieldPolicy>;\n}\n\nexport type { SmrtClassOptions };\n"],"mappings":";AA+BO,IAAM,6BAA6B;AAEnC,IAAM,2BAA4D;CACvE;CACA;CACA;AACF;AAEO,IAAM,4BAA8D;CACzE;CACA;CACA;AACF"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n SmrtClassOptions,\n SmrtObjectOptions,\n} from '@happyvertical/smrt-core';\n\n/**\n * Scope tier a {@link FieldPolicy} row belongs to.\n *\n * Resolution precedence is code seed → `app` → `tenant` (hierarchy walk,\n * root → leaf) → `user`. Unlike smrt-features (which ships only\n * `global`/`tenant`), the user tier is implemented end to end here — both\n * defaults and visibility resolve through it.\n */\nexport type FieldPolicyScopeType = 'app' | 'tenant' | 'user';\n\n/**\n * Visibility tier for a field in generated/consuming form UIs.\n *\n * - `basic`: shown before the advanced disclosure\n * - `advanced`: shown behind the advanced disclosure\n * - `hidden`: not rendered (requires the field to be optional or have a\n * resolved default — the required-field invariant)\n */\nexport type FieldPolicyVisibility = 'basic' | 'advanced' | 'hidden';\n\n/**\n * `scopeKey` value for app-scope rows. `scopeKey` exists ONLY so the\n * `conflictColumns` unique index stays total while `tenantId`/`userId` are\n * nullable (nullable columns would allow duplicate NULL rows) — the same\n * trick as `PromptOverride.context`.\n */\nexport const APP_FIELD_POLICY_SCOPE_KEY = '__app__';\n\nexport const FIELD_POLICY_SCOPE_TYPES: readonly FieldPolicyScopeType[] = [\n 'app',\n 'tenant',\n 'user',\n];\n\nexport const FIELD_POLICY_VISIBILITIES: readonly FieldPolicyVisibility[] = [\n 'basic',\n 'advanced',\n 'hidden',\n];\n\nexport interface FieldPolicyOptions extends SmrtObjectOptions {\n objectRef?: string;\n fieldName?: string;\n scopeType?: FieldPolicyScopeType;\n tenantId?: string | null;\n userId?: string | null;\n /**\n * ENCODED channel: an already-JSON-encoded default, exactly as the column\n * stores it (`'\"Net 30\"'`, `'42'`, `'null'`), or `null` to inherit.\n *\n * This is the wire contract: the generated write routes hand the request\n * body straight to the constructor, and the #2049/#2050 gear posts\n * `JSON.stringify(draft.defaultValue)`. It must therefore keep meaning\n * \"already encoded\" — auto-serializing here would double-encode every gear\n * write.\n *\n * Use {@link FieldPolicyOptions.defaultValueRaw} for a plain value. The two\n * are mutually exclusive: `'\"TBD\"'` and `'TBD'` are indistinguishable once\n * a single option carries both meanings, so the channel must be explicit\n * rather than sniffed.\n */\n defaultValue?: string | null;\n /**\n * PLAIN channel: any value, always serialized — strings included. The\n * constructor-option twin of {@link FieldPolicy.setDefaultValue}, so\n * `{ defaultValueRaw: 'Net 30' }` stores `'\"Net 30\"'` rather than the\n * unparseable literal `Net 30`.\n */\n defaultValueRaw?: unknown;\n visibility?: FieldPolicyVisibility | null;\n help?: string | null;\n label?: string | null;\n displayOrder?: number | null;\n locked?: boolean | null;\n updatedBy?: string | null;\n}\n\n/**\n * The sparse contribution of one layer (code seed or one stored row).\n *\n * `default` is boxed so an explicit JSON `null` default (meaning \"default to\n * null\") stays distinguishable from \"this layer contributes no default\".\n */\nexport interface FieldPolicyDelta {\n default?: { value: unknown };\n visibility?: FieldPolicyVisibility;\n help?: string;\n label?: string;\n order?: number;\n locked?: boolean;\n}\n\n/** One layer's contribution to a field's resolved policy (explain variant). */\nexport interface FieldPolicyLayerContribution {\n layer: 'code' | 'app' | 'tenant' | 'user';\n /** Chain node id for `tenant` layers (root → leaf order). */\n tenantId?: string;\n /** User id for the `user` layer. */\n userId?: string;\n delta: FieldPolicyDelta;\n}\n\n/** Fully merged policy for a single field. */\nexport interface ResolvedFieldPolicy {\n fieldName: string;\n /** True when any layer resolved a default (including an explicit null). */\n hasDefault: boolean;\n /** Parsed default value; `undefined` when {@link hasDefault} is false. */\n defaultValue: unknown;\n visibility: FieldPolicyVisibility;\n help: string | null;\n label: string | null;\n order: number | null;\n /** Grouping key — code-seed only (`ui.group`), not overridable by rows. */\n group: string | null;\n locked: boolean;\n /** Mirror of the manifest required flag (nullable fields are optional). */\n required: boolean;\n /**\n * True when the resolver forced `basic` visibility because the field is\n * required and no usable default resolved (the resolver-side safety net for\n * the required-field invariant).\n */\n visibilityForced?: boolean;\n}\n\n/** Merged policy for every field of one object. */\nexport interface ResolvedObjectFieldPolicy {\n objectRef: string;\n fields: Record<string, ResolvedFieldPolicy>;\n}\n\n/**\n * Explain variant: merged result plus the ordered per-layer contributions for\n * each field, so admin/gear UIs (#2049/#2050) never re-derive precedence.\n * Layers are listed in application order (code, app, tenant chain root → leaf,\n * user) and contain ONLY contributions that survive into the merged result:\n * tenant ancestors discarded by a permission-inheritance break and user rows\n * suppressed by an effective org lock are omitted, so sequentially replaying\n * the listed deltas reproduces the merged policy.\n */\nexport interface ExplainedObjectFieldPolicy extends ResolvedObjectFieldPolicy {\n layers: Record<string, FieldPolicyLayerContribution[]>;\n}\n\n/** Minimal tenant node consumed by the hierarchy walk (mirrors smrt-features). */\nexport interface FieldPolicyTenantNode {\n id: string;\n inheritPermissions: boolean;\n cascadePermissions: boolean;\n}\n\n/** Provider returning the root → leaf tenant chain (mirrors smrt-features). */\nexport interface FieldPolicyTenantHierarchyProvider {\n getChain(tenantId: string): Promise<FieldPolicyTenantNode[]>;\n}\n\n/**\n * Loader-function DI seam (NOT a container registration): the resolver calls\n * it lazily and treats `null` as \"no hierarchy available\" (flat-tenant\n * fallback). The default loader dynamic-imports `@happyvertical/smrt-users`\n * and returns `null` when it is not installed.\n */\nexport type FieldPolicyTenantHierarchyLoader = (\n options: SmrtClassOptions,\n) => Promise<FieldPolicyTenantHierarchyProvider | null>;\n\nexport interface ResolveFieldPolicyOptions {\n tenantId?: string | null;\n userId?: string | null;\n /**\n * Database holding `_smrt_field_policies`. Without it, only the code seed\n * resolves (stored layers are skipped) — the smrt-prompts precedent.\n */\n db?: SmrtClassOptions['db'];\n tenantHierarchyLoader?: FieldPolicyTenantHierarchyLoader;\n /**\n * Internal write-validation seam: omit persisted rows while evaluating a\n * proposed replacement. Excluded resolutions bypass the shared cache so a\n * projected result can never poison ordinary reads.\n */\n excludePolicyIds?: ReadonlySet<string>;\n}\n\n/**\n * Minimal structural shape of the tenant surface loaded from\n * `@happyvertical/smrt-users` by the default hierarchy loader. Only the\n * permission-cascade fields consumed by the chain walk are modeled.\n */\nexport interface FieldPolicyUsersTenantRecord {\n id: string;\n inheritPermissions?: boolean;\n cascadePermissions?: boolean;\n}\n\nexport interface FieldPolicyUsersModule {\n TenantCollection: {\n create(options: SmrtClassOptions): Promise<{\n get(criteria: {\n id: string;\n }): Promise<FieldPolicyUsersTenantRecord | null>;\n getAncestorsFromRoot(\n tenantId: string,\n ): Promise<FieldPolicyUsersTenantRecord[]>;\n }>;\n };\n}\n\n/** Result shape of the batch resolve action (`FieldPolicyCollection.resolveBatch`). */\nexport interface FieldPolicyBatchResult {\n policies: Record<string, ResolvedObjectFieldPolicy>;\n}\n\n/** A policy row safe to expose through the context-scoped gear action. */\nexport interface FieldPolicyEditorRow {\n defaultValue: string | null;\n displayOrder: number | null;\n fieldName: string;\n help: string | null;\n id: string;\n label: string | null;\n locked: boolean | null;\n scopeType: FieldPolicyScopeType;\n tenantId: string | null;\n updatedBy: string | null;\n userId: string | null;\n visibility: FieldPolicyVisibility | null;\n}\n\n/** Context-derived authorization state for the field-policy gear. */\nexport interface FieldPolicyEditorCapabilities {\n manage: boolean;\n personalize: boolean;\n}\n\n/**\n * Gear bootstrap response. `policy` is always filtered by the public-field\n * rail; raw rows and explanation layers appear only for scopes the caller is\n * authorized to mutate. Row ids are present for reset/delete operations.\n */\nexport interface FieldPolicyEditorState {\n capabilities: FieldPolicyEditorCapabilities;\n /**\n * For the caller's personal layer only, whether removing that layer's\n * default still leaves a usable default at code/app/tenant precedence.\n * This intentionally exposes no lower-layer rows or default values.\n */\n personalLowerDefaultUsable: Record<string, boolean>;\n policy: ExplainedObjectFieldPolicy;\n rows: {\n app: FieldPolicyEditorRow[];\n tenant: FieldPolicyEditorRow[];\n user: FieldPolicyEditorRow[];\n };\n}\n\n/** A stored organization row with the immutable audit metadata needed by #2050. */\nexport interface FieldPolicyAuditRow extends FieldPolicyEditorRow {\n objectRef: string;\n createdAt: string | null;\n updatedAt: string | null;\n}\n\n/** Why a persisted policy row is no longer usable by the live registry. */\nexport type FieldPolicyDriftReason =\n | 'unknown-object'\n | 'unknown-field'\n | 'excluded-field';\n\n/** Drift is deliberately identity-only: stale values are never serialized. */\nexport interface FieldPolicyDriftRow {\n id: string;\n objectRef: string;\n fieldName: string;\n scopeType: FieldPolicyScopeType;\n tenantId: string | null;\n userId: string | null;\n updatedBy: string | null;\n createdAt: string | null;\n updatedAt: string | null;\n reason: FieldPolicyDriftReason;\n prunable: boolean;\n}\n\n/**\n * Tenant-admin catalog read surface. Foreign user rows are represented only\n * by counts; their values and identifiers never leave the collection.\n */\nexport interface FieldPolicyAuditSnapshot {\n orgRows: FieldPolicyAuditRow[];\n appRows: FieldPolicyAuditRow[];\n inheritedOrgKeys: Record<string, string[]>;\n userOverrideCounts: Record<string, Record<string, number>>;\n driftRows: FieldPolicyDriftRow[];\n policies: Record<string, ExplainedObjectFieldPolicy>;\n caller: {\n tenantId: string | null;\n userId: string | null;\n canManageOrg: boolean;\n canPersonalize: boolean;\n };\n}\n\n/** Explicit 403 result used by generated custom-action transports. */\nexport interface FieldPolicyEditorStateDenied {\n code: 'permission_denied';\n message: string;\n ok: false;\n status: 403;\n}\n\nexport type FieldPolicyEditorStateResult =\n | FieldPolicyEditorState\n | FieldPolicyEditorStateDenied;\n\n// ---------------------------------------------------------------------------\n// Usage capture + promotion suggestions (#2051)\n// ---------------------------------------------------------------------------\n\nexport type FieldPolicySuggestionKind = 'promote' | 'default';\nexport const FIELD_POLICY_SUGGESTION_KINDS: readonly FieldPolicySuggestionKind[] =\n ['promote', 'default'];\n\nexport type FieldPolicySuggestionStatus = 'pending' | 'accepted' | 'dismissed';\nexport const FIELD_POLICY_SUGGESTION_STATUSES: readonly FieldPolicySuggestionStatus[] =\n ['pending', 'accepted', 'dismissed'];\n\n/** One bounded client-side form submission sample. */\nexport interface FieldUsageReportEntry {\n objectRef: string;\n fieldName: string;\n value?: unknown;\n /** Used only for value-less samples; server comparison wins when present. */\n matchedDefault?: boolean;\n}\n\nexport interface FieldUsageReportResult {\n accepted: number;\n dropped: number;\n}\n\nexport interface FieldPolicySuggestionData {\n id: string;\n objectRef: string;\n fieldName: string;\n tenantId: string;\n kind: FieldPolicySuggestionKind;\n proposedValue: string | null;\n evidence: Record<string, unknown>;\n status: FieldPolicySuggestionStatus;\n cooldownUntil: string | null;\n decidedBy: string | null;\n decidedAt: string | null;\n}\n\nexport interface PendingFieldPolicySuggestionsResult {\n suggestions: FieldPolicySuggestionData[];\n total: number;\n}\n\nexport interface AcceptFieldPolicySuggestionResult {\n suggestion: FieldPolicySuggestionData;\n policyRowId: string;\n}\n\nexport interface DismissFieldPolicySuggestionResult {\n suggestion: FieldPolicySuggestionData;\n}\n\nexport type { SmrtClassOptions };\n"],"mappings":";AA+BO,IAAM,6BAA6B;AAEnC,IAAM,2BAA4D;CACvE;CACA;CACA;AACF;AAEO,IAAM,4BAA8D;CACzE;CACA;CACA;AACF;AA0RO,IAAM,gCACX,CAAC,WAAW,SAAS;AAGhB,IAAM,mCACX;CAAC;CAAW;CAAY;AAAW"}
|