@happyvertical/smrt-fields 0.40.61 → 0.40.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/AGENTS.md +18 -0
  2. package/README.md +125 -112
  3. package/dist/chunks/FieldPolicyCollection--RxukfCX.js +1218 -0
  4. package/dist/chunks/FieldPolicyCollection--RxukfCX.js.map +1 -0
  5. package/dist/collections/FieldPolicySuggestionCollection.d.ts +160 -0
  6. package/dist/collections/FieldPolicySuggestionCollection.d.ts.map +1 -0
  7. package/dist/collections/FieldUsageCounterCollection.d.ts +143 -0
  8. package/dist/collections/FieldUsageCounterCollection.d.ts.map +1 -0
  9. package/dist/deterministic-id.d.ts +18 -0
  10. package/dist/deterministic-id.d.ts.map +1 -0
  11. package/dist/field-definitions.d.ts +8 -0
  12. package/dist/field-definitions.d.ts.map +1 -1
  13. package/dist/index.d.ts +8 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1565 -1077
  16. package/dist/index.js.map +1 -1
  17. package/dist/manifest.json +1442 -188
  18. package/dist/models/FieldPolicySuggestion.d.ts +132 -0
  19. package/dist/models/FieldPolicySuggestion.d.ts.map +1 -0
  20. package/dist/models/FieldUsageCounter.d.ts +178 -0
  21. package/dist/models/FieldUsageCounter.d.ts.map +1 -0
  22. package/dist/models/FieldUsageReportReceipt.d.ts +25 -0
  23. package/dist/models/FieldUsageReportReceipt.d.ts.map +1 -0
  24. package/dist/smrt-knowledge.json +404 -7
  25. package/dist/svelte/__tests__/FieldPolicyControlPanel.test.js +54 -0
  26. package/dist/svelte/__tests__/FormHelp.test.js +8 -0
  27. package/dist/svelte/__tests__/ObjectForm.test.js +131 -0
  28. package/dist/svelte/__tests__/UsageLearning.test.js +140 -0
  29. package/dist/svelte/__tests__/fixtures/ObjectFormActionsFixture.svelte +21 -4
  30. package/dist/svelte/__tests__/fixtures/ObjectFormActionsFixture.svelte.d.ts +5 -1
  31. package/dist/svelte/__tests__/fixtures/ObjectFormActionsFixture.svelte.d.ts.map +1 -1
  32. package/dist/svelte/__tests__/fixtures/SuggestionGearFixture.svelte +23 -0
  33. package/dist/svelte/__tests__/fixtures/SuggestionGearFixture.svelte.d.ts +10 -0
  34. package/dist/svelte/__tests__/fixtures/SuggestionGearFixture.svelte.d.ts.map +1 -0
  35. package/dist/svelte/__tests__/playground.test.js +66 -0
  36. package/dist/svelte/components/FieldPolicyControlPanel.svelte +28 -1
  37. package/dist/svelte/components/FieldPolicyControlPanel.svelte.d.ts +3 -0
  38. package/dist/svelte/components/FieldPolicyControlPanel.svelte.d.ts.map +1 -1
  39. package/dist/svelte/components/FieldPolicyGearButton.svelte +8 -1
  40. package/dist/svelte/components/FieldPolicyGearButton.svelte.d.ts.map +1 -1
  41. package/dist/svelte/components/FieldPolicyGearProvider.svelte +34 -0
  42. package/dist/svelte/components/FieldPolicyGearProvider.svelte.d.ts +3 -0
  43. package/dist/svelte/components/FieldPolicyGearProvider.svelte.d.ts.map +1 -1
  44. package/dist/svelte/components/FieldPolicySuggestionQueue.svelte +135 -0
  45. package/dist/svelte/components/FieldPolicySuggestionQueue.svelte.d.ts +11 -0
  46. package/dist/svelte/components/FieldPolicySuggestionQueue.svelte.d.ts.map +1 -0
  47. package/dist/svelte/components/FormHelp.svelte +16 -1
  48. package/dist/svelte/components/FormHelp.svelte.d.ts.map +1 -1
  49. package/dist/svelte/components/ObjectForm.svelte +91 -2
  50. package/dist/svelte/components/ObjectForm.svelte.d.ts +11 -1
  51. package/dist/svelte/components/ObjectForm.svelte.d.ts.map +1 -1
  52. package/dist/svelte/context.svelte.d.ts +15 -0
  53. package/dist/svelte/context.svelte.d.ts.map +1 -1
  54. package/dist/svelte/context.svelte.js +15 -0
  55. package/dist/svelte/gear-context.svelte.d.ts +2 -0
  56. package/dist/svelte/gear-context.svelte.d.ts.map +1 -1
  57. package/dist/svelte/index.d.ts +6 -1
  58. package/dist/svelte/index.d.ts.map +1 -1
  59. package/dist/svelte/index.js +4 -1
  60. package/dist/svelte/playground/FieldPolicyFormPreview.svelte +18 -12
  61. package/dist/svelte/playground/FieldPolicyFormPreview.svelte.d.ts.map +1 -1
  62. package/dist/svelte/suggestions.d.ts +38 -0
  63. package/dist/svelte/suggestions.d.ts.map +1 -0
  64. package/dist/svelte/suggestions.js +68 -0
  65. package/dist/svelte/usage-capture.d.ts +63 -0
  66. package/dist/svelte/usage-capture.d.ts.map +1 -0
  67. package/dist/svelte/usage-capture.js +61 -0
  68. package/dist/types.d.ts +40 -0
  69. package/dist/types.d.ts.map +1 -1
  70. package/dist/types.js +7 -1
  71. package/dist/types.js.map +1 -1
  72. package/dist/usage-learning.d.ts +201 -0
  73. package/dist/usage-learning.d.ts.map +1 -0
  74. package/dist/usage-schedules.d.ts +110 -0
  75. package/dist/usage-schedules.d.ts.map +1 -0
  76. package/dist/users-module.d.ts +30 -0
  77. package/dist/users-module.d.ts.map +1 -0
  78. package/package.json +9 -9
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Structural browser contracts for field-policy suggestion review.
3
+ *
4
+ * These types intentionally omit tenant, user, authorization, and field
5
+ * sensitivity data. Hosts bind methods to authenticated generated clients;
6
+ * the server derives identity and validates every action.
7
+ */
8
+ /**
9
+ * Validate generated custom-action output at the browser boundary. A malformed
10
+ * response is an error, never an empty queue that could conceal work.
11
+ */
12
+ export function parsePendingFieldPolicySuggestions(value) {
13
+ if (!value || typeof value !== 'object') {
14
+ throw new Error('Unable to load pending field suggestions.');
15
+ }
16
+ const candidate = value;
17
+ const total = candidate.total;
18
+ if (!Array.isArray(candidate.suggestions) ||
19
+ typeof total !== 'number' ||
20
+ !Number.isSafeInteger(total) ||
21
+ total < 0) {
22
+ throw new Error('Unable to load pending field suggestions.');
23
+ }
24
+ const suggestions = candidate.suggestions.map(parseSuggestion);
25
+ if (total < suggestions.length) {
26
+ throw new Error('Unable to load pending field suggestions.');
27
+ }
28
+ return { suggestions, total };
29
+ }
30
+ function parseSuggestion(value) {
31
+ if (!value || typeof value !== 'object') {
32
+ throw new Error('Unable to load pending field suggestions.');
33
+ }
34
+ const candidate = value;
35
+ if (typeof candidate.id !== 'string' ||
36
+ typeof candidate.objectRef !== 'string' ||
37
+ typeof candidate.fieldName !== 'string' ||
38
+ (candidate.kind !== 'promote' && candidate.kind !== 'default') ||
39
+ (candidate.proposedValue !== null &&
40
+ typeof candidate.proposedValue !== 'string') ||
41
+ !isRecord(candidate.evidence) ||
42
+ (candidate.status !== undefined && candidate.status !== 'pending')) {
43
+ throw new Error('Unable to load pending field suggestions.');
44
+ }
45
+ return {
46
+ id: candidate.id,
47
+ objectRef: candidate.objectRef,
48
+ fieldName: candidate.fieldName,
49
+ kind: candidate.kind,
50
+ proposedValue: candidate.proposedValue,
51
+ evidence: candidate.evidence,
52
+ };
53
+ }
54
+ function isRecord(value) {
55
+ return !!value && typeof value === 'object' && !Array.isArray(value);
56
+ }
57
+ /** Human-readable evidence without assuming a server-side evidence schema. */
58
+ export function fieldPolicySuggestionEvidence(suggestion) {
59
+ const summary = suggestion.evidence.summary;
60
+ if (typeof summary === 'string' && summary.trim())
61
+ return summary;
62
+ const distinctUsers = suggestion.evidence.distinctUsers;
63
+ const setCount = suggestion.evidence.setCount;
64
+ if (typeof distinctUsers === 'number' && typeof setCount === 'number') {
65
+ return `${distinctUsers} users set this field ${setCount} times.`;
66
+ }
67
+ return 'Based on recent organization field usage.';
68
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Browser-safe usage capture primitives for the field-policy learning loop.
3
+ *
4
+ * Hosts own the authenticated transport. This module deliberately carries no
5
+ * tenant, user, permission, or field-sensitivity information: the server
6
+ * derives all of that from its ambient context and live object registry.
7
+ */
8
+ /** One submitted field value sent to the host's usage transport. */
9
+ export interface FieldUsageEntry {
10
+ objectRef: string;
11
+ fieldName: string;
12
+ value?: unknown;
13
+ /** Optional value-less hint; normal ObjectForm capture sends the value. */
14
+ matchedDefault?: boolean;
15
+ }
16
+ /** Resolved default metadata used only for a value-less count signal. */
17
+ export interface FieldUsageDefault {
18
+ hasDefault: boolean;
19
+ defaultValue: unknown;
20
+ }
21
+ /**
22
+ * Structural host transport for the counters collection's batched action.
23
+ * A reporter must never be allowed to affect a successful form submission.
24
+ */
25
+ export interface FieldUsageReporter {
26
+ reportUsage(input: {
27
+ entries: readonly FieldUsageEntry[];
28
+ }): unknown;
29
+ }
30
+ export interface CollectFieldUsageEntriesOptions {
31
+ objectRef: string;
32
+ values: Readonly<Record<string, unknown>>;
33
+ /**
34
+ * Rendered field names and their persisted browser wire type. The type is
35
+ * used only to minimize value transit — it is never a sensitivity or
36
+ * authorization decision.
37
+ */
38
+ fields?: Readonly<Record<string, FieldUsageWireType>>;
39
+ /**
40
+ * Resolved defaults for rendered fields. For count-only values, a matching
41
+ * default is sent as a positive hint so the server does not treat it as a
42
+ * deviation. Absent or non-matching defaults deliberately send no hint.
43
+ */
44
+ defaults?: Readonly<Record<string, FieldUsageDefault>>;
45
+ }
46
+ export type FieldUsageWireType = 'text' | 'integer' | 'decimal' | 'boolean' | 'datetime' | 'json' | 'foreignKey' | 'crossPackageRef';
47
+ /** Values may transit only for bounded, identifier-like wire types. */
48
+ export declare function canCaptureFieldUsageValue(type: FieldUsageWireType | undefined): boolean;
49
+ /**
50
+ * Collect every non-blank submitted field, including values matching a
51
+ * resolved default. Values transit only for bounded boolean/reference fields;
52
+ * free text, numbers, dates, and JSON emit count-only signals. Capturing only
53
+ * deviations would make the default's dominance denominator disappear. The
54
+ * server still derives eligibility, sensitivity, and every aggregate.
55
+ */
56
+ export declare function collectFieldUsageEntries(options: CollectFieldUsageEntriesOptions): FieldUsageEntry[];
57
+ /** Zero and false are submissions; only absent/null/empty-string values are not. */
58
+ export declare function isBlankFieldValue(value: unknown): boolean;
59
+ /** JSON-safe equality for the count-only default-match hint. */
60
+ export declare function fieldUsageValuesEqual(left: unknown, right: unknown): boolean;
61
+ /** Fire-and-forget by design: metrics transport failures never reject submit. */
62
+ export declare function reportFieldUsage(reporter: FieldUsageReporter | undefined, entries: readonly FieldUsageEntry[]): void;
63
+ //# sourceMappingURL=usage-capture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage-capture.d.ts","sourceRoot":"","sources":["../../src/svelte/usage-capture.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,yEAAyE;AACzE,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,SAAS,eAAe,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC;CACtE;AAED,MAAM,WAAW,+BAA+B;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1C;;;;OAIG;IACH,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;IACtD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;CACxD;AAED,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,SAAS,GACT,SAAS,GACT,SAAS,GACT,UAAU,GACV,MAAM,GACN,YAAY,GACZ,iBAAiB,CAAC;AAEtB,uEAAuE;AACvE,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,kBAAkB,GAAG,SAAS,GACnC,OAAO,CAIT;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,+BAA+B,GACvC,eAAe,EAAE,CAyBnB;AAED,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED,gEAAgE;AAChE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAO5E;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,kBAAkB,GAAG,SAAS,EACxC,OAAO,EAAE,SAAS,eAAe,EAAE,GAClC,IAAI,CASN"}
@@ -0,0 +1,61 @@
1
+ /** Values may transit only for bounded, identifier-like wire types. */
2
+ export function canCaptureFieldUsageValue(type) {
3
+ return (type === 'boolean' || type === 'foreignKey' || type === 'crossPackageRef');
4
+ }
5
+ /**
6
+ * Collect every non-blank submitted field, including values matching a
7
+ * resolved default. Values transit only for bounded boolean/reference fields;
8
+ * free text, numbers, dates, and JSON emit count-only signals. Capturing only
9
+ * deviations would make the default's dominance denominator disappear. The
10
+ * server still derives eligibility, sensitivity, and every aggregate.
11
+ */
12
+ export function collectFieldUsageEntries(options) {
13
+ const fields = options.fields ??
14
+ Object.fromEntries(Object.keys(options.values).map((fieldName) => [fieldName, undefined]));
15
+ const entries = [];
16
+ for (const [fieldName, type] of Object.entries(fields)) {
17
+ const value = options.values[fieldName];
18
+ if (isBlankFieldValue(value))
19
+ continue;
20
+ if (canCaptureFieldUsageValue(type)) {
21
+ entries.push({ objectRef: options.objectRef, fieldName, value });
22
+ continue;
23
+ }
24
+ const fieldDefault = options.defaults?.[fieldName];
25
+ entries.push({
26
+ objectRef: options.objectRef,
27
+ fieldName,
28
+ ...(fieldDefault?.hasDefault &&
29
+ fieldUsageValuesEqual(value, fieldDefault.defaultValue)
30
+ ? { matchedDefault: true }
31
+ : {}),
32
+ });
33
+ }
34
+ return entries;
35
+ }
36
+ /** Zero and false are submissions; only absent/null/empty-string values are not. */
37
+ export function isBlankFieldValue(value) {
38
+ return value === undefined || value === null || value === '';
39
+ }
40
+ /** JSON-safe equality for the count-only default-match hint. */
41
+ export function fieldUsageValuesEqual(left, right) {
42
+ if (left === right)
43
+ return true;
44
+ try {
45
+ return JSON.stringify(left) === JSON.stringify(right);
46
+ }
47
+ catch {
48
+ return false;
49
+ }
50
+ }
51
+ /** Fire-and-forget by design: metrics transport failures never reject submit. */
52
+ export function reportFieldUsage(reporter, entries) {
53
+ if (!reporter || entries.length === 0)
54
+ return;
55
+ try {
56
+ void Promise.resolve(reporter.reportUsage({ entries })).catch(() => undefined);
57
+ }
58
+ catch {
59
+ // A synchronous host adapter failure is non-fatal by the same contract.
60
+ }
61
+ }
package/dist/types.d.ts CHANGED
@@ -272,5 +272,45 @@ export interface FieldPolicyEditorStateDenied {
272
272
  status: 403;
273
273
  }
274
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
+ }
275
315
  export type { SmrtClassOptions };
276
316
  //# sourceMappingURL=types.d.ts.map
@@ -1 +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,E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;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,yBAAyB,CAAC;IAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,MAAM,EAAE,2BAA2B,CAAC;IACpC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,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 * 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\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"}
@@ -0,0 +1,201 @@
1
+ import { SmrtObject, SmrtObjectOptions } from '@happyvertical/smrt-core';
2
+ import { DatabaseInterface } from '@happyvertical/sql';
3
+ import { FieldPolicySuggestionKind } from './types.js';
4
+ export interface FieldUsageMaintenanceConfig {
5
+ /** Drop counter buckets older than this (by `period`). Default 90 days. */
6
+ counterMaxAgeMs: number;
7
+ /** Keep at most this many counter rows (oldest pruned first). Default 100k. */
8
+ counterMaxRows: number;
9
+ /** Drop ACCEPTED suggestions decided longer ago than this. Default 180 days. */
10
+ suggestionAcceptedMaxAgeMs: number;
11
+ }
12
+ export declare const FIELD_USAGE_MAINTENANCE_DEFAULTS: FieldUsageMaintenanceConfig;
13
+ export interface FieldUsageSuggestionConfig {
14
+ /** Usage window the thresholds evaluate over. Default 30 days. */
15
+ windowDays: number;
16
+ /** Distinct users required for a `promote` suggestion. Default 5. */
17
+ minDistinctUsers: number;
18
+ /** Submissions required before a `default` suggestion. Default 10. */
19
+ minSetCount: number;
20
+ /**
21
+ * Share of windowed submissions a single value must reach for a `default`
22
+ * suggestion (denominator is TOTAL setCount, so histogram overflow can only
23
+ * make this more conservative). Default 0.8.
24
+ */
25
+ defaultDominanceRatio: number;
26
+ }
27
+ export declare const FIELD_USAGE_SUGGESTION_DEFAULTS: FieldUsageSuggestionConfig;
28
+ export interface FieldUsageMaintenanceSummary {
29
+ countersPruned: number;
30
+ receiptsPruned: number;
31
+ suggestionsPruned: number;
32
+ }
33
+ export interface FieldUsageSuggestionRunSummary {
34
+ /**
35
+ * Suggestions this run wrote. Under overlapping runs both may report a
36
+ * create for the same candidate while the model's active-slot unique index
37
+ * converges them onto ONE row (see `FieldPolicySuggestion.activeKey`) — the
38
+ * tally is per-run work, not a row count.
39
+ */
40
+ created: number;
41
+ /** Candidates suppressed by a pending or cooling-down suggestion. */
42
+ suppressed: number;
43
+ /** Distinct (tenant, objectRef, fieldName) groups evaluated. */
44
+ groupsConsidered: number;
45
+ /**
46
+ * Groups whose evaluation threw and was skipped. A failing group never
47
+ * aborts the run — a global pass must keep serving every other tenant.
48
+ */
49
+ groupsFailed: number;
50
+ /**
51
+ * Bounded sample of failure messages (`MAX_REPORTED_GROUP_FAILURES`) so an
52
+ * operator can see WHY without the summary growing with the queue.
53
+ */
54
+ failures: string[];
55
+ }
56
+ /** Cap on {@link FieldUsageSuggestionRunSummary.failures} entries. */
57
+ export declare const MAX_REPORTED_GROUP_FAILURES = 5;
58
+ export interface FieldUsageCounterRetention {
59
+ maxAgeMs?: number;
60
+ maxRows?: number;
61
+ /** Restrict pruning to one tenant (ambient-context runs). */
62
+ tenantId?: string | null;
63
+ }
64
+ /**
65
+ * Prune counter rows to bound growth. Applies whichever bounds are provided
66
+ * (at least one required): `maxAgeMs` drops buckets whose `period` day is
67
+ * older than the cutoff; `maxRows` keeps only the newest N rows by
68
+ * `(period, id)`, deleting oldest-first. Mirrors core's `pruneChangeFeed`.
69
+ */
70
+ export declare function pruneFieldUsageCounters(db: DatabaseInterface, retention: FieldUsageCounterRetention): Promise<{
71
+ pruned: number;
72
+ }>;
73
+ /**
74
+ * Drop durable anti-inflation receipts at the same age cutoff as counters.
75
+ *
76
+ * Deliberately do NOT delete a receipt merely because its counter row is
77
+ * absent: report ingestion claims its receipt before merging the counter, so
78
+ * an orphan sweep could otherwise reopen the once-per-user/day quota during
79
+ * that in-flight interval. A max-row counter trim likewise leaves its recent
80
+ * receipts until the age cutoff — retaining a de-duplication guard is safer
81
+ * than allowing a second contribution for that day.
82
+ */
83
+ export declare function pruneFieldUsageReportReceipts(db: DatabaseInterface, options: {
84
+ maxAgeMs: number;
85
+ tenantId?: string | null;
86
+ }): Promise<{
87
+ pruned: number;
88
+ }>;
89
+ export interface FieldPolicySuggestionRetention {
90
+ /** Drop ACCEPTED suggestions decided longer ago than this. */
91
+ acceptedMaxAgeMs: number;
92
+ /** Restrict pruning to one tenant (ambient-context runs). */
93
+ tenantId?: string | null;
94
+ /** Clock override for deterministic tests. */
95
+ now?: Date;
96
+ }
97
+ /**
98
+ * Prune settled suggestion rows ONLY (#2051 pin): a dismissed suggestion once
99
+ * its cool-down has fully elapsed (its suppression job is done), and an
100
+ * accepted suggestion once it is old. Pending suggestions are NEVER pruned.
101
+ */
102
+ export declare function pruneFieldPolicySuggestions(db: DatabaseInterface, retention: FieldPolicySuggestionRetention): Promise<{
103
+ pruned: number;
104
+ }>;
105
+ export interface RunFieldUsageMaintenanceOptions extends Partial<FieldUsageMaintenanceConfig> {
106
+ db: DatabaseInterface;
107
+ }
108
+ /**
109
+ * The "aggregation" schedule's work. Ingestion pre-aggregates into period
110
+ * buckets, so the roll-up job's real job is retention: prune counter buckets
111
+ * and durable receipts at the shared age cutoff, then settle old suggestion
112
+ * rows. Max-row trimming leaves recent receipts intact to preserve daily
113
+ * de-duplication while an ingestion merge is in flight.
114
+ */
115
+ export declare function runFieldUsageMaintenance(options: RunFieldUsageMaintenanceOptions): Promise<FieldUsageMaintenanceSummary>;
116
+ export interface RunFieldPolicySuggestionGenerationOptions extends Partial<FieldUsageSuggestionConfig> {
117
+ db: DatabaseInterface;
118
+ /** Clock override for deterministic tests. */
119
+ now?: Date;
120
+ }
121
+ /**
122
+ * The threshold job: evaluate windowed counters per
123
+ * `(tenantId, objectRef, fieldName)` and create PENDING suggestions with
124
+ * human-readable evidence.
125
+ *
126
+ * - `promote`: at least `minDistinctUsers` distinct users set the field to a
127
+ * non-default value in the window AND the org-resolved visibility is not
128
+ * already `basic`.
129
+ * - `default`: at least `minSetCount` TOTAL submissions, a single recorded
130
+ * value covers `defaultDominanceRatio` of those TOTAL submissions (not of
131
+ * the deviations — see `FieldUsageCounter.submissionCount`), and it differs
132
+ * from the org-resolved default. Only histogram-eligible fields
133
+ * (low-cardinality, non-sensitive, non-gated) can ever qualify, and a group
134
+ * containing a legacy bucket with no recorded total is skipped rather than
135
+ * ratioed against the wrong denominator.
136
+ *
137
+ * Dedup: a candidate is suppressed while the same
138
+ * `(tenantId, objectRef, fieldName, kind)` has a PENDING suggestion or a
139
+ * DISMISSED one still inside its cool-down. Accepted history never blocks —
140
+ * once accepted, the resolved policy itself stops regeneration (visibility is
141
+ * basic / the default matches). The pre-check is an optimization only: the
142
+ * single-active guarantee is STRUCTURAL (`FieldPolicySuggestion.activeKey` in
143
+ * `conflictColumns`), so overlapping runs upsert onto one row instead of
144
+ * duplicating.
145
+ *
146
+ * Sensitive, read-permission-gated, and transient fields are skipped
147
+ * entirely: their usage rows are count-only observability data and never
148
+ * produce suggestions.
149
+ */
150
+ export declare function runFieldPolicySuggestionGeneration(options: RunFieldPolicySuggestionGenerationOptions): Promise<FieldUsageSuggestionRunSummary>;
151
+ /**
152
+ * The registered schedule target for the #2051 learning loop (see the module
153
+ * doc for why it is NOT an smrt-agents `Agent` subclass). Rows of its system
154
+ * table are never written — the class exists so `AgentSchedule.agentType`
155
+ * resolves through the `ObjectRegistry` and smrt-jobs can construct it and
156
+ * invoke the two allowlisted methods.
157
+ */
158
+ export declare class FieldUsageLearningAgent extends SmrtObject {
159
+ /**
160
+ * The smrt-jobs opt-in background allowlist (S5 contract): ONLY these two
161
+ * methods are reachable from a persisted job/schedule row.
162
+ */
163
+ static backgroundEligibleMethods: ReadonlyArray<string>;
164
+ constructor(options?: SmrtObjectOptions);
165
+ /** Schedule entry point for {@link runFieldUsageMaintenance}. */
166
+ runUsageMaintenance(args?: Record<string, unknown>): Promise<FieldUsageMaintenanceSummary>;
167
+ /** Schedule entry point for {@link runFieldPolicySuggestionGeneration}. */
168
+ runSuggestionGeneration(args?: Record<string, unknown>): Promise<FieldUsageSuggestionRunSummary>;
169
+ }
170
+ export interface FieldUsageEvidenceInput {
171
+ kind: FieldPolicySuggestionKind;
172
+ objectRef: string;
173
+ fieldName: string;
174
+ windowStart: string;
175
+ windowEnd: string;
176
+ distinctUsers: number;
177
+ /** True when the distinct-user set overflowed (count is a lower bound). */
178
+ distinctUsersAtLeast: boolean;
179
+ /** Submissions that DIFFERED from the resolved default. */
180
+ setCount: number;
181
+ /**
182
+ * TOTAL submissions observed in the window (the dominance denominator).
183
+ * `undefined` only for legacy buckets that never recorded a total, in which
184
+ * case the summary states the deviation count alone.
185
+ */
186
+ submissionCount?: number;
187
+ /** The threshold the candidate cleared (documented in the evidence). */
188
+ threshold: number;
189
+ topValue?: unknown;
190
+ topValueShare?: number;
191
+ }
192
+ /**
193
+ * Human-readable evidence for a suggestion: a `summary` sentence a reviewer
194
+ * can read as-is, plus the structured numbers behind it.
195
+ *
196
+ * The sentence always states BOTH numbers when known — deviations and total
197
+ * submissions — so a reviewer can see the base rate a dominance percentage was
198
+ * computed against instead of trusting a bare ratio.
199
+ */
200
+ export declare function buildFieldUsageEvidence(input: FieldUsageEvidenceInput): Record<string, unknown>;
201
+ //# sourceMappingURL=usage-learning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage-learning.d.ts","sourceRoot":"","sources":["../src/usage-learning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAuB5D,OAAO,KAAK,EACV,yBAAyB,EAE1B,MAAM,YAAY,CAAC;AASpB,MAAM,WAAW,2BAA2B;IAC1C,2EAA2E;IAC3E,eAAe,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,cAAc,EAAE,MAAM,CAAC;IACvB,gFAAgF;IAChF,0BAA0B,EAAE,MAAM,CAAC;CACpC;AAED,eAAO,MAAM,gCAAgC,EAAE,2BAI9C,CAAC;AAEF,MAAM,WA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