@lax-wp/editor 0.4.14 → 0.4.15-beta.0

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 (161) hide show
  1. package/README.md +25 -0
  2. package/dist/api/audit.d.ts +79 -0
  3. package/dist/api/derivedRulebook.d.ts +470 -0
  4. package/dist/api/documentVersions.d.ts +519 -0
  5. package/dist/api/effectiveRules.d.ts +372 -0
  6. package/dist/api/methodology.d.ts +62 -0
  7. package/dist/api/playbook.d.ts +604 -0
  8. package/dist/api/promotions.d.ts +1432 -0
  9. package/dist/api/r1.d.ts +1097 -0
  10. package/dist/api/r1.fixtures.d.ts +111 -0
  11. package/dist/api/redlineJobs.d.ts +377 -0
  12. package/dist/api/redlineStream.d.ts +2979 -0
  13. package/dist/api/redlines.d.ts +504 -0
  14. package/dist/api/regsync.d.ts +2355 -0
  15. package/dist/api/ruleAuthoring.d.ts +305 -0
  16. package/dist/api/ruleBuilder.d.ts +1009 -0
  17. package/dist/api/ruleOverrides.d.ts +31 -0
  18. package/dist/api/ruleStats.d.ts +84 -0
  19. package/dist/api/rulesCatalog.d.ts +234 -0
  20. package/dist/api/versions.d.ts +76 -0
  21. package/dist/api/workspace.d.ts +41 -0
  22. package/dist/components/EditorSidebar.d.ts +4 -1
  23. package/dist/components/audit/AuditView.d.ts +8 -0
  24. package/dist/components/capturededits/AddAsRuleModal.d.ts +8 -0
  25. package/dist/components/capturededits/CapturedEditCard.d.ts +15 -0
  26. package/dist/components/capturededits/CapturedEditsTray.d.ts +4 -0
  27. package/dist/components/capturededits/capturedEditIntent.d.ts +23 -0
  28. package/dist/components/common/EscDropdown.d.ts +2 -0
  29. package/dist/components/compliance/MethodologyPanel.d.ts +14 -0
  30. package/dist/components/compliance/RegSyncPanel.d.ts +18 -0
  31. package/dist/components/compliance/index.d.ts +8 -0
  32. package/dist/components/compliance/primitives.d.ts +41 -0
  33. package/dist/components/documents/DocumentVersionHistory.d.ts +12 -0
  34. package/dist/components/documents/documentDiff.d.ts +68 -0
  35. package/dist/components/documents/index.d.ts +4 -0
  36. package/dist/components/flowdown/FlowdownPanel.d.ts +28 -0
  37. package/dist/components/flowdown/FlowdownRowCard.d.ts +27 -0
  38. package/dist/components/flowdown/flowdownModel.d.ts +150 -0
  39. package/dist/components/history/PlaybookVersionHistory.d.ts +10 -0
  40. package/dist/components/history/versionDiff.d.ts +14 -0
  41. package/dist/components/playbook/AllPlaybooksView.d.ts +41 -0
  42. package/dist/components/playbook/DerivedRulebookView.d.ts +9 -0
  43. package/dist/components/playbook/DraftedRulePreview.d.ts +17 -0
  44. package/dist/components/playbook/EffectiveRulesView.d.ts +11 -0
  45. package/dist/components/playbook/NewRuleDrawer.d.ts +11 -0
  46. package/dist/components/playbook/PlaybookCard.d.ts +13 -0
  47. package/dist/components/playbook/PlaybookPage.d.ts +29 -0
  48. package/dist/components/playbook/PlaybookPanel.d.ts +73 -0
  49. package/dist/components/playbook/PromotionSuggestions.d.ts +1 -0
  50. package/dist/components/playbook/ReprioritizeDialog.d.ts +16 -0
  51. package/dist/components/playbook/RuleDetail.d.ts +27 -0
  52. package/dist/components/playbook/RuleEditorFields.d.ts +42 -0
  53. package/dist/components/playbook/RuleEditorModal.d.ts +27 -0
  54. package/dist/components/playbook/RulePerformancePanel.d.ts +4 -0
  55. package/dist/components/playbook/RuleRow.d.ts +26 -0
  56. package/dist/components/playbook/ThisDocumentView.d.ts +45 -0
  57. package/dist/components/playbook/ViewTabs.d.ts +8 -0
  58. package/dist/components/playbook/index.d.ts +14 -0
  59. package/dist/components/playbook/predicateSummary.d.ts +10 -0
  60. package/dist/components/playbook/primitives.d.ts +82 -0
  61. package/dist/components/playbook/useFocusTrap.d.ts +6 -0
  62. package/dist/components/playbook/usePlaybookData.d.ts +161 -0
  63. package/dist/components/playbook/usePlaybookLabel.d.ts +18 -0
  64. package/dist/components/r1/ApprovalPanel.d.ts +10 -0
  65. package/dist/components/r1/CandidateRuleCard.d.ts +8 -0
  66. package/dist/components/r1/ExecSummaryPanel.d.ts +23 -0
  67. package/dist/components/r1/PrimeUploadPanel.d.ts +8 -0
  68. package/dist/components/r1/ReviewStartControls.d.ts +24 -0
  69. package/dist/components/r1/ReviewSummaryTab.d.ts +38 -0
  70. package/dist/components/r1/index.d.ts +13 -0
  71. package/dist/components/r1/primitives.d.ts +59 -0
  72. package/dist/components/redline/AiReviewPanel.d.ts +194 -0
  73. package/dist/components/redline/RedlineHoverCard.d.ts +13 -0
  74. package/dist/components/redline/RedlineItem.d.ts +12 -0
  75. package/dist/components/redline/ReviewCard.d.ts +49 -0
  76. package/dist/components/redline/index.d.ts +6 -0
  77. package/dist/components/redline/reviewItems.d.ts +49 -0
  78. package/dist/components/redline/reviewPrefs.d.ts +18 -0
  79. package/dist/components/redline/useRunScopedCards.d.ts +16 -0
  80. package/dist/components/rulebuilder/AuthorForms.d.ts +28 -0
  81. package/dist/components/rulebuilder/CandidateQueue.d.ts +21 -0
  82. package/dist/components/rulebuilder/DraftPane.d.ts +12 -0
  83. package/dist/components/rulebuilder/RuleBuilderPanel.d.ts +6 -0
  84. package/dist/components/rulebuilder/RuleCard.d.ts +16 -0
  85. package/dist/components/rulebuilder/TestBench.d.ts +10 -0
  86. package/dist/components/rulebuilder/VocabularyPanel.d.ts +26 -0
  87. package/dist/components/rulebuilder/index.d.ts +13 -0
  88. package/dist/components/rulebuilder/primitives.d.ts +54 -0
  89. package/dist/components/rulebuilder/useRuleBuilder.d.ts +291 -0
  90. package/dist/components/sidebar/ExpandableSidebar.d.ts +2 -0
  91. package/dist/components/sidebar/WorkspaceRetentionPanel.d.ts +18 -0
  92. package/dist/components/sidebar/content/TrackChangesContent.d.ts +8 -0
  93. package/dist/components/sidebar/content/anonymization-page/PIIAnonymization.d.ts +1 -1
  94. package/dist/components/sidebar/content/anonymization-page/PiiIdleView.d.ts +12 -0
  95. package/dist/components/sidebar/content/anonymization-page/PiiRecoveryView.d.ts +16 -0
  96. package/dist/components/sidebar/content/anonymization-page/PiiSummaryView.d.ts +34 -0
  97. package/dist/components/sidebar/content/anonymization-page/PiiUnavailableView.d.ts +1 -0
  98. package/dist/components/sidebar/content/anonymization-page/RestoreConfirmDialog.d.ts +9 -0
  99. package/dist/components/sidebar/content/anonymization-page/anonymizationUtils.d.ts +38 -17
  100. package/dist/components/sidebar/content/anonymization-page/piiVault.d.ts +18 -0
  101. package/dist/components/sidebar/content/index.d.ts +0 -1
  102. package/dist/components/toolbar/AutocompletionToggle.d.ts +1 -0
  103. package/dist/components/trackChanges/TrackChangesCards.d.ts +1 -0
  104. package/dist/components/trackChanges/index.d.ts +2 -0
  105. package/dist/components/trackChanges/utils.d.ts +5 -0
  106. package/dist/config/EditorConfig.d.ts +197 -73
  107. package/dist/constants/Extensions.d.ts +12 -0
  108. package/dist/constants/playbook.d.ts +108 -0
  109. package/dist/contexts/CapturedEditsContext.d.ts +56 -0
  110. package/dist/contexts/EditorShellContext.d.ts +4 -1
  111. package/dist/editor.css +1 -1
  112. package/dist/extensions/AnonymizedText.d.ts +31 -2
  113. package/dist/extensions/VariableText.d.ts +20 -0
  114. package/dist/extensions/index.d.ts +1 -1
  115. package/dist/extensions/plugins/CapturedEditsPlugin.d.ts +90 -0
  116. package/dist/extensions/plugins/MarkHighlightPlugin.d.ts +0 -1
  117. package/dist/extensions/plugins/RedlinePlugin.d.ts +9 -0
  118. package/dist/extensions/plugins/ViewModeDocumentPreview.d.ts +1 -4
  119. package/dist/extensions/redline/changeTypes.d.ts +70 -0
  120. package/dist/extensions/redline/constants.d.ts +25 -0
  121. package/dist/extensions/redline/engine/blockNodes.d.ts +31 -0
  122. package/dist/extensions/redline/engine/clipboard.d.ts +16 -0
  123. package/dist/extensions/redline/engine/deletion.d.ts +34 -0
  124. package/dist/extensions/redline/engine/formatSplit.d.ts +16 -0
  125. package/dist/extensions/redline/engine/insertion.d.ts +26 -0
  126. package/dist/extensions/redline/engine/predicates.d.ts +73 -0
  127. package/dist/extensions/redline/engine/textReplace.d.ts +19 -0
  128. package/dist/extensions/redline/id.d.ts +7 -0
  129. package/dist/extensions/redline/index.d.ts +36 -0
  130. package/dist/extensions/redline/plugin.d.ts +34 -0
  131. package/dist/extensions/redline/query/scan.d.ts +52 -0
  132. package/dist/extensions/redline/review/applyChange.d.ts +25 -0
  133. package/dist/extensions/redline/review/index.d.ts +1 -0
  134. package/dist/extensions/redline/review/nodeResolvers.d.ts +29 -0
  135. package/dist/extensions/redline/review/pairedNodes.d.ts +38 -0
  136. package/dist/extensions/redline/review/structuralRevert.d.ts +20 -0
  137. package/dist/extensions/redline/review/textResolver.d.ts +9 -0
  138. package/dist/extensions/redline/schema/marks.d.ts +65 -0
  139. package/dist/extensions/redline/schema/shared.d.ts +34 -0
  140. package/dist/extensions/redline/session.d.ts +71 -0
  141. package/dist/extensions/redline/types.d.ts +24 -0
  142. package/dist/extensions/trackedChanges/TrackedChanges.d.ts +64 -0
  143. package/dist/extensions/trackedChanges/constants.d.ts +34 -0
  144. package/dist/extensions/trackedChanges/engine.d.ts +32 -0
  145. package/dist/extensions/trackedChanges/index.d.ts +13 -0
  146. package/dist/extensions/trackedChanges/marks.d.ts +20 -0
  147. package/dist/extensions/trackedChanges/normalize.d.ts +2 -0
  148. package/dist/extensions/trackedChanges/plugin.d.ts +32 -0
  149. package/dist/extensions/trackedChanges/query.d.ts +3 -0
  150. package/dist/extensions/trackedChanges/review.d.ts +34 -0
  151. package/dist/extensions/trackedChanges/types.d.ts +72 -0
  152. package/dist/extensions/trackedChanges/utils.d.ts +20 -0
  153. package/dist/hooks/useMediaQuery.d.ts +2 -0
  154. package/dist/hooks/useRedlineHover.d.ts +17 -0
  155. package/dist/hooks/useRedlineReview.d.ts +83 -0
  156. package/dist/index.d.ts +46 -0
  157. package/dist/index.es.js +40482 -24183
  158. package/dist/index.umd.js +224 -125
  159. package/dist/utils/cdts.d.ts +37 -0
  160. package/dist/utils/groundingAdapter.d.ts +36 -0
  161. package/package.json +39 -33
package/README.md CHANGED
@@ -627,6 +627,31 @@ import 'lax-wp-editor/styles';
627
627
 
628
628
  You can also customize the styles by overriding CSS variables or using your own CSS.
629
629
 
630
+ ### Fonts (consumer-provided) — IMPORTANT
631
+
632
+ The editor wires two font tokens (defined in `src/styles/tokens.css`) to the UI:
633
+
634
+ - `--font-ui` (**Inter**) → editor chrome/toolbar (the `.lax-wp-editor-host` wrapper)
635
+ - `--font-document` (**Nunito**) → the document content root (`.ProseMirror`)
636
+
637
+ **This package does NOT ship `@font-face` rules or font binaries.** Inter and
638
+ Nunito are both OFL-licensed (self-hosting is permitted), but to keep the bundle
639
+ lean the faces are not bundled. If your app does not already load Inter and
640
+ Nunito, the editor silently falls back to the token fallback stack (system
641
+ sans-serif) and Nunito/Inter render nowhere.
642
+
643
+ To get the intended typography, provide the faces in your host app, e.g. via
644
+ `@fontsource/inter` + `@fontsource/nunito`, a self-hosted `@font-face`, or your
645
+ existing font pipeline:
646
+
647
+ ```tsx
648
+ import '@fontsource/inter'; // or your own @font-face for "Inter"
649
+ import '@fontsource/nunito'; // or your own @font-face for "Nunito"
650
+ ```
651
+
652
+ The token wiring already points at these family names, so once the faces are
653
+ available they render automatically — no further config needed.
654
+
630
655
  ## TypeScript Support
631
656
 
632
657
  The package includes full TypeScript definitions:
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Audit-trail API module (sprint-2 story 2).
3
+ *
4
+ * GET /v1/audit/export workspace audit trail, JSON
5
+ * GET /v1/audit/export?format=csv CSV download (not used here)
6
+ *
7
+ * Shape verified against internal/redlining/api/auditexport.go +
8
+ * audit.ExportJSON: the body is a TOP-LEVEL ARRAY of events with Go-default
9
+ * (PascalCase) field names — ID, Kind, EmittedAt, SourceModule, DocumentID,
10
+ * SuggestionID, RuleID, Actor, Details, … The workspace comes from the
11
+ * X-Workspace-Id header (tenancy context), never a query param.
12
+ *
13
+ * Mirrors `redlines.ts`'s conventions: module-level mutable config merged
14
+ * with Vite env defaults, zod + `.passthrough()` at the boundary.
15
+ */
16
+ import { z } from "zod";
17
+ export interface AuditApiConfig {
18
+ baseUrl?: string;
19
+ workspaceId?: string;
20
+ }
21
+ /** Configure once from the consumer (App.tsx / lax-web-portal). */
22
+ export declare const configureAuditApi: (next: AuditApiConfig) => void;
23
+ export declare class AuditApiError extends Error {
24
+ readonly status?: number;
25
+ constructor(message: string, status?: number);
26
+ }
27
+ declare const auditEventSchema: z.ZodObject<{
28
+ ID: z.ZodString;
29
+ WorkspaceID: z.ZodDefault<z.ZodOptional<z.ZodString>>;
30
+ /** e.g. "suggestion_produced", "suggestion_accepted" … */
31
+ Kind: z.ZodDefault<z.ZodOptional<z.ZodString>>;
32
+ EmittedAt: z.ZodDefault<z.ZodOptional<z.ZodString>>;
33
+ SourceModule: z.ZodDefault<z.ZodOptional<z.ZodString>>;
34
+ DocumentID: z.ZodDefault<z.ZodOptional<z.ZodString>>;
35
+ SuggestionID: z.ZodDefault<z.ZodOptional<z.ZodString>>;
36
+ RuleID: z.ZodDefault<z.ZodOptional<z.ZodString>>;
37
+ Actor: z.ZodDefault<z.ZodOptional<z.ZodString>>;
38
+ Details: z.ZodOptional<z.ZodUnknown>;
39
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
40
+ ID: z.ZodString;
41
+ WorkspaceID: z.ZodDefault<z.ZodOptional<z.ZodString>>;
42
+ /** e.g. "suggestion_produced", "suggestion_accepted" … */
43
+ Kind: z.ZodDefault<z.ZodOptional<z.ZodString>>;
44
+ EmittedAt: z.ZodDefault<z.ZodOptional<z.ZodString>>;
45
+ SourceModule: z.ZodDefault<z.ZodOptional<z.ZodString>>;
46
+ DocumentID: z.ZodDefault<z.ZodOptional<z.ZodString>>;
47
+ SuggestionID: z.ZodDefault<z.ZodOptional<z.ZodString>>;
48
+ RuleID: z.ZodDefault<z.ZodOptional<z.ZodString>>;
49
+ Actor: z.ZodDefault<z.ZodOptional<z.ZodString>>;
50
+ Details: z.ZodOptional<z.ZodUnknown>;
51
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
52
+ ID: z.ZodString;
53
+ WorkspaceID: z.ZodDefault<z.ZodOptional<z.ZodString>>;
54
+ /** e.g. "suggestion_produced", "suggestion_accepted" … */
55
+ Kind: z.ZodDefault<z.ZodOptional<z.ZodString>>;
56
+ EmittedAt: z.ZodDefault<z.ZodOptional<z.ZodString>>;
57
+ SourceModule: z.ZodDefault<z.ZodOptional<z.ZodString>>;
58
+ DocumentID: z.ZodDefault<z.ZodOptional<z.ZodString>>;
59
+ SuggestionID: z.ZodDefault<z.ZodOptional<z.ZodString>>;
60
+ RuleID: z.ZodDefault<z.ZodOptional<z.ZodString>>;
61
+ Actor: z.ZodDefault<z.ZodOptional<z.ZodString>>;
62
+ Details: z.ZodOptional<z.ZodUnknown>;
63
+ }, z.ZodTypeAny, "passthrough">>;
64
+ export type AuditEvent = z.infer<typeof auditEventSchema>;
65
+ export interface AuditExport {
66
+ events: AuditEvent[];
67
+ /**
68
+ * Pre-limit trail size from the `X-Total-Events` response header
69
+ * (BE f13904c) — lets the UI render "showing latest N of M" when the
70
+ * export is limited. Null when the backend doesn't send it.
71
+ */
72
+ totalEvents: number | null;
73
+ }
74
+ /**
75
+ * The calling workspace's audit trail (newest N events), newest first
76
+ * (sorted here — the export itself is append-ordered).
77
+ */
78
+ export declare const fetchAuditEvents: () => Promise<AuditExport>;
79
+ export {};
@@ -0,0 +1,470 @@
1
+ /**
2
+ * Derived-rulebook (R1) API module — `FE_INTEGRATION_API.md §2.A`.
3
+ *
4
+ * Lifecycle: upload prime → poll job → list candidate rules → approve /
5
+ * reject / edit / bulk-approve → rulebook status flips to `active` once every
6
+ * rule of the version is disposed.
7
+ *
8
+ * This is the ONLY endpoint family that gives the panel a real
9
+ * accept/reject-a-rule capability: `/v1/rules` has no enable/disable field,
10
+ * so "reject" there can only mean DELETE. Here rejection is a first-class,
11
+ * audited state — rejected rules are retained, never deleted (§2.A).
12
+ *
13
+ * Concurrency: every mutation carries the caller's last-seen integer `etag`
14
+ * and the store compare-and-swaps; a stale etag is a 409, never a clobber
15
+ * (§3). After an `edit`, use the etag from the edit RESPONSE for the
16
+ * follow-up approve.
17
+ */
18
+ import { z } from "zod";
19
+ import { type PlaybookApiConfig } from "./playbook";
20
+ /** Rule states: draft → in_review → approved | rejected (approved/rejected terminal). */
21
+ export declare const derivedRuleStateSchema: z.ZodEnum<["draft", "in_review", "approved", "rejected"]>;
22
+ export type DerivedRuleState = z.infer<typeof derivedRuleStateSchema>;
23
+ /**
24
+ * `body` is the full contracts.Rule. Passthrough: the doc lists the fields FE
25
+ * consumes but the struct carries more, and unknown fields must not throw.
26
+ */
27
+ export declare const derivedRuleBodySchema: z.ZodObject<{
28
+ id: z.ZodString;
29
+ playbook_id: z.ZodOptional<z.ZodString>;
30
+ workspace_id: z.ZodOptional<z.ZodString>;
31
+ default_severity: z.ZodOptional<z.ZodString>;
32
+ category: z.ZodOptional<z.ZodString>;
33
+ verbatim_excerpt: z.ZodOptional<z.ZodString>;
34
+ suggested_text: z.ZodOptional<z.ZodString>;
35
+ fallback_text: z.ZodOptional<z.ZodString>;
36
+ walkaway_text: z.ZodOptional<z.ZodString>;
37
+ rationale: z.ZodOptional<z.ZodString>;
38
+ mandatory: z.ZodOptional<z.ZodBoolean>;
39
+ authority: z.ZodOptional<z.ZodString>;
40
+ source: z.ZodOptional<z.ZodString>;
41
+ prime_section_ref: z.ZodOptional<z.ZodString>;
42
+ semantic_intent: z.ZodOptional<z.ZodString>;
43
+ read_only: z.ZodOptional<z.ZodBoolean>;
44
+ action: z.ZodOptional<z.ZodString>;
45
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
46
+ id: z.ZodString;
47
+ playbook_id: z.ZodOptional<z.ZodString>;
48
+ workspace_id: z.ZodOptional<z.ZodString>;
49
+ default_severity: z.ZodOptional<z.ZodString>;
50
+ category: z.ZodOptional<z.ZodString>;
51
+ verbatim_excerpt: z.ZodOptional<z.ZodString>;
52
+ suggested_text: z.ZodOptional<z.ZodString>;
53
+ fallback_text: z.ZodOptional<z.ZodString>;
54
+ walkaway_text: z.ZodOptional<z.ZodString>;
55
+ rationale: z.ZodOptional<z.ZodString>;
56
+ mandatory: z.ZodOptional<z.ZodBoolean>;
57
+ authority: z.ZodOptional<z.ZodString>;
58
+ source: z.ZodOptional<z.ZodString>;
59
+ prime_section_ref: z.ZodOptional<z.ZodString>;
60
+ semantic_intent: z.ZodOptional<z.ZodString>;
61
+ read_only: z.ZodOptional<z.ZodBoolean>;
62
+ action: z.ZodOptional<z.ZodString>;
63
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
64
+ id: z.ZodString;
65
+ playbook_id: z.ZodOptional<z.ZodString>;
66
+ workspace_id: z.ZodOptional<z.ZodString>;
67
+ default_severity: z.ZodOptional<z.ZodString>;
68
+ category: z.ZodOptional<z.ZodString>;
69
+ verbatim_excerpt: z.ZodOptional<z.ZodString>;
70
+ suggested_text: z.ZodOptional<z.ZodString>;
71
+ fallback_text: z.ZodOptional<z.ZodString>;
72
+ walkaway_text: z.ZodOptional<z.ZodString>;
73
+ rationale: z.ZodOptional<z.ZodString>;
74
+ mandatory: z.ZodOptional<z.ZodBoolean>;
75
+ authority: z.ZodOptional<z.ZodString>;
76
+ source: z.ZodOptional<z.ZodString>;
77
+ prime_section_ref: z.ZodOptional<z.ZodString>;
78
+ semantic_intent: z.ZodOptional<z.ZodString>;
79
+ read_only: z.ZodOptional<z.ZodBoolean>;
80
+ action: z.ZodOptional<z.ZodString>;
81
+ }, z.ZodTypeAny, "passthrough">>;
82
+ export declare const derivedRuleSchema: z.ZodObject<{
83
+ rule_id: z.ZodString;
84
+ clause_ref: z.ZodDefault<z.ZodOptional<z.ZodString>>;
85
+ rulebook_version: z.ZodOptional<z.ZodNumber>;
86
+ state: z.ZodEnum<["draft", "in_review", "approved", "rejected"]>;
87
+ /** Optimistic-concurrency token — echo on every mutation. */
88
+ etag: z.ZodNumber;
89
+ body: z.ZodObject<{
90
+ id: z.ZodString;
91
+ playbook_id: z.ZodOptional<z.ZodString>;
92
+ workspace_id: z.ZodOptional<z.ZodString>;
93
+ default_severity: z.ZodOptional<z.ZodString>;
94
+ category: z.ZodOptional<z.ZodString>;
95
+ verbatim_excerpt: z.ZodOptional<z.ZodString>;
96
+ suggested_text: z.ZodOptional<z.ZodString>;
97
+ fallback_text: z.ZodOptional<z.ZodString>;
98
+ walkaway_text: z.ZodOptional<z.ZodString>;
99
+ rationale: z.ZodOptional<z.ZodString>;
100
+ mandatory: z.ZodOptional<z.ZodBoolean>;
101
+ authority: z.ZodOptional<z.ZodString>;
102
+ source: z.ZodOptional<z.ZodString>;
103
+ prime_section_ref: z.ZodOptional<z.ZodString>;
104
+ semantic_intent: z.ZodOptional<z.ZodString>;
105
+ read_only: z.ZodOptional<z.ZodBoolean>;
106
+ action: z.ZodOptional<z.ZodString>;
107
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
108
+ id: z.ZodString;
109
+ playbook_id: z.ZodOptional<z.ZodString>;
110
+ workspace_id: z.ZodOptional<z.ZodString>;
111
+ default_severity: z.ZodOptional<z.ZodString>;
112
+ category: z.ZodOptional<z.ZodString>;
113
+ verbatim_excerpt: z.ZodOptional<z.ZodString>;
114
+ suggested_text: z.ZodOptional<z.ZodString>;
115
+ fallback_text: z.ZodOptional<z.ZodString>;
116
+ walkaway_text: z.ZodOptional<z.ZodString>;
117
+ rationale: z.ZodOptional<z.ZodString>;
118
+ mandatory: z.ZodOptional<z.ZodBoolean>;
119
+ authority: z.ZodOptional<z.ZodString>;
120
+ source: z.ZodOptional<z.ZodString>;
121
+ prime_section_ref: z.ZodOptional<z.ZodString>;
122
+ semantic_intent: z.ZodOptional<z.ZodString>;
123
+ read_only: z.ZodOptional<z.ZodBoolean>;
124
+ action: z.ZodOptional<z.ZodString>;
125
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
126
+ id: z.ZodString;
127
+ playbook_id: z.ZodOptional<z.ZodString>;
128
+ workspace_id: z.ZodOptional<z.ZodString>;
129
+ default_severity: z.ZodOptional<z.ZodString>;
130
+ category: z.ZodOptional<z.ZodString>;
131
+ verbatim_excerpt: z.ZodOptional<z.ZodString>;
132
+ suggested_text: z.ZodOptional<z.ZodString>;
133
+ fallback_text: z.ZodOptional<z.ZodString>;
134
+ walkaway_text: z.ZodOptional<z.ZodString>;
135
+ rationale: z.ZodOptional<z.ZodString>;
136
+ mandatory: z.ZodOptional<z.ZodBoolean>;
137
+ authority: z.ZodOptional<z.ZodString>;
138
+ source: z.ZodOptional<z.ZodString>;
139
+ prime_section_ref: z.ZodOptional<z.ZodString>;
140
+ semantic_intent: z.ZodOptional<z.ZodString>;
141
+ read_only: z.ZodOptional<z.ZodBoolean>;
142
+ action: z.ZodOptional<z.ZodString>;
143
+ }, z.ZodTypeAny, "passthrough">>;
144
+ disposed_by: z.ZodOptional<z.ZodString>;
145
+ disposed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
146
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
147
+ rule_id: z.ZodString;
148
+ clause_ref: z.ZodDefault<z.ZodOptional<z.ZodString>>;
149
+ rulebook_version: z.ZodOptional<z.ZodNumber>;
150
+ state: z.ZodEnum<["draft", "in_review", "approved", "rejected"]>;
151
+ /** Optimistic-concurrency token — echo on every mutation. */
152
+ etag: z.ZodNumber;
153
+ body: z.ZodObject<{
154
+ id: z.ZodString;
155
+ playbook_id: z.ZodOptional<z.ZodString>;
156
+ workspace_id: z.ZodOptional<z.ZodString>;
157
+ default_severity: z.ZodOptional<z.ZodString>;
158
+ category: z.ZodOptional<z.ZodString>;
159
+ verbatim_excerpt: z.ZodOptional<z.ZodString>;
160
+ suggested_text: z.ZodOptional<z.ZodString>;
161
+ fallback_text: z.ZodOptional<z.ZodString>;
162
+ walkaway_text: z.ZodOptional<z.ZodString>;
163
+ rationale: z.ZodOptional<z.ZodString>;
164
+ mandatory: z.ZodOptional<z.ZodBoolean>;
165
+ authority: z.ZodOptional<z.ZodString>;
166
+ source: z.ZodOptional<z.ZodString>;
167
+ prime_section_ref: z.ZodOptional<z.ZodString>;
168
+ semantic_intent: z.ZodOptional<z.ZodString>;
169
+ read_only: z.ZodOptional<z.ZodBoolean>;
170
+ action: z.ZodOptional<z.ZodString>;
171
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
172
+ id: z.ZodString;
173
+ playbook_id: z.ZodOptional<z.ZodString>;
174
+ workspace_id: z.ZodOptional<z.ZodString>;
175
+ default_severity: z.ZodOptional<z.ZodString>;
176
+ category: z.ZodOptional<z.ZodString>;
177
+ verbatim_excerpt: z.ZodOptional<z.ZodString>;
178
+ suggested_text: z.ZodOptional<z.ZodString>;
179
+ fallback_text: z.ZodOptional<z.ZodString>;
180
+ walkaway_text: z.ZodOptional<z.ZodString>;
181
+ rationale: z.ZodOptional<z.ZodString>;
182
+ mandatory: z.ZodOptional<z.ZodBoolean>;
183
+ authority: z.ZodOptional<z.ZodString>;
184
+ source: z.ZodOptional<z.ZodString>;
185
+ prime_section_ref: z.ZodOptional<z.ZodString>;
186
+ semantic_intent: z.ZodOptional<z.ZodString>;
187
+ read_only: z.ZodOptional<z.ZodBoolean>;
188
+ action: z.ZodOptional<z.ZodString>;
189
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
190
+ id: z.ZodString;
191
+ playbook_id: z.ZodOptional<z.ZodString>;
192
+ workspace_id: z.ZodOptional<z.ZodString>;
193
+ default_severity: z.ZodOptional<z.ZodString>;
194
+ category: z.ZodOptional<z.ZodString>;
195
+ verbatim_excerpt: z.ZodOptional<z.ZodString>;
196
+ suggested_text: z.ZodOptional<z.ZodString>;
197
+ fallback_text: z.ZodOptional<z.ZodString>;
198
+ walkaway_text: z.ZodOptional<z.ZodString>;
199
+ rationale: z.ZodOptional<z.ZodString>;
200
+ mandatory: z.ZodOptional<z.ZodBoolean>;
201
+ authority: z.ZodOptional<z.ZodString>;
202
+ source: z.ZodOptional<z.ZodString>;
203
+ prime_section_ref: z.ZodOptional<z.ZodString>;
204
+ semantic_intent: z.ZodOptional<z.ZodString>;
205
+ read_only: z.ZodOptional<z.ZodBoolean>;
206
+ action: z.ZodOptional<z.ZodString>;
207
+ }, z.ZodTypeAny, "passthrough">>;
208
+ disposed_by: z.ZodOptional<z.ZodString>;
209
+ disposed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
210
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
211
+ rule_id: z.ZodString;
212
+ clause_ref: z.ZodDefault<z.ZodOptional<z.ZodString>>;
213
+ rulebook_version: z.ZodOptional<z.ZodNumber>;
214
+ state: z.ZodEnum<["draft", "in_review", "approved", "rejected"]>;
215
+ /** Optimistic-concurrency token — echo on every mutation. */
216
+ etag: z.ZodNumber;
217
+ body: z.ZodObject<{
218
+ id: z.ZodString;
219
+ playbook_id: z.ZodOptional<z.ZodString>;
220
+ workspace_id: z.ZodOptional<z.ZodString>;
221
+ default_severity: z.ZodOptional<z.ZodString>;
222
+ category: z.ZodOptional<z.ZodString>;
223
+ verbatim_excerpt: z.ZodOptional<z.ZodString>;
224
+ suggested_text: z.ZodOptional<z.ZodString>;
225
+ fallback_text: z.ZodOptional<z.ZodString>;
226
+ walkaway_text: z.ZodOptional<z.ZodString>;
227
+ rationale: z.ZodOptional<z.ZodString>;
228
+ mandatory: z.ZodOptional<z.ZodBoolean>;
229
+ authority: z.ZodOptional<z.ZodString>;
230
+ source: z.ZodOptional<z.ZodString>;
231
+ prime_section_ref: z.ZodOptional<z.ZodString>;
232
+ semantic_intent: z.ZodOptional<z.ZodString>;
233
+ read_only: z.ZodOptional<z.ZodBoolean>;
234
+ action: z.ZodOptional<z.ZodString>;
235
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
236
+ id: z.ZodString;
237
+ playbook_id: z.ZodOptional<z.ZodString>;
238
+ workspace_id: z.ZodOptional<z.ZodString>;
239
+ default_severity: z.ZodOptional<z.ZodString>;
240
+ category: z.ZodOptional<z.ZodString>;
241
+ verbatim_excerpt: z.ZodOptional<z.ZodString>;
242
+ suggested_text: z.ZodOptional<z.ZodString>;
243
+ fallback_text: z.ZodOptional<z.ZodString>;
244
+ walkaway_text: z.ZodOptional<z.ZodString>;
245
+ rationale: z.ZodOptional<z.ZodString>;
246
+ mandatory: z.ZodOptional<z.ZodBoolean>;
247
+ authority: z.ZodOptional<z.ZodString>;
248
+ source: z.ZodOptional<z.ZodString>;
249
+ prime_section_ref: z.ZodOptional<z.ZodString>;
250
+ semantic_intent: z.ZodOptional<z.ZodString>;
251
+ read_only: z.ZodOptional<z.ZodBoolean>;
252
+ action: z.ZodOptional<z.ZodString>;
253
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
254
+ id: z.ZodString;
255
+ playbook_id: z.ZodOptional<z.ZodString>;
256
+ workspace_id: z.ZodOptional<z.ZodString>;
257
+ default_severity: z.ZodOptional<z.ZodString>;
258
+ category: z.ZodOptional<z.ZodString>;
259
+ verbatim_excerpt: z.ZodOptional<z.ZodString>;
260
+ suggested_text: z.ZodOptional<z.ZodString>;
261
+ fallback_text: z.ZodOptional<z.ZodString>;
262
+ walkaway_text: z.ZodOptional<z.ZodString>;
263
+ rationale: z.ZodOptional<z.ZodString>;
264
+ mandatory: z.ZodOptional<z.ZodBoolean>;
265
+ authority: z.ZodOptional<z.ZodString>;
266
+ source: z.ZodOptional<z.ZodString>;
267
+ prime_section_ref: z.ZodOptional<z.ZodString>;
268
+ semantic_intent: z.ZodOptional<z.ZodString>;
269
+ read_only: z.ZodOptional<z.ZodBoolean>;
270
+ action: z.ZodOptional<z.ZodString>;
271
+ }, z.ZodTypeAny, "passthrough">>;
272
+ disposed_by: z.ZodOptional<z.ZodString>;
273
+ disposed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
274
+ }, z.ZodTypeAny, "passthrough">>;
275
+ export declare const derivedRulebookSchema: z.ZodObject<{
276
+ prime_contract_id: z.ZodString;
277
+ latest_version: z.ZodOptional<z.ZodNumber>;
278
+ active_version: z.ZodOptional<z.ZodNumber>;
279
+ status: z.ZodOptional<z.ZodString>;
280
+ bundle_hash: z.ZodOptional<z.ZodString>;
281
+ counts: z.ZodOptional<z.ZodObject<{
282
+ draft: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
283
+ in_review: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
284
+ approved: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
285
+ rejected: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
286
+ }, "strip", z.ZodTypeAny, {
287
+ approved?: number | undefined;
288
+ rejected?: number | undefined;
289
+ draft?: number | undefined;
290
+ in_review?: number | undefined;
291
+ }, {
292
+ approved?: number | undefined;
293
+ rejected?: number | undefined;
294
+ draft?: number | undefined;
295
+ in_review?: number | undefined;
296
+ }>>;
297
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
298
+ prime_contract_id: z.ZodString;
299
+ latest_version: z.ZodOptional<z.ZodNumber>;
300
+ active_version: z.ZodOptional<z.ZodNumber>;
301
+ status: z.ZodOptional<z.ZodString>;
302
+ bundle_hash: z.ZodOptional<z.ZodString>;
303
+ counts: z.ZodOptional<z.ZodObject<{
304
+ draft: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
305
+ in_review: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
306
+ approved: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
307
+ rejected: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
308
+ }, "strip", z.ZodTypeAny, {
309
+ approved?: number | undefined;
310
+ rejected?: number | undefined;
311
+ draft?: number | undefined;
312
+ in_review?: number | undefined;
313
+ }, {
314
+ approved?: number | undefined;
315
+ rejected?: number | undefined;
316
+ draft?: number | undefined;
317
+ in_review?: number | undefined;
318
+ }>>;
319
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
320
+ prime_contract_id: z.ZodString;
321
+ latest_version: z.ZodOptional<z.ZodNumber>;
322
+ active_version: z.ZodOptional<z.ZodNumber>;
323
+ status: z.ZodOptional<z.ZodString>;
324
+ bundle_hash: z.ZodOptional<z.ZodString>;
325
+ counts: z.ZodOptional<z.ZodObject<{
326
+ draft: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
327
+ in_review: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
328
+ approved: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
329
+ rejected: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
330
+ }, "strip", z.ZodTypeAny, {
331
+ approved?: number | undefined;
332
+ rejected?: number | undefined;
333
+ draft?: number | undefined;
334
+ in_review?: number | undefined;
335
+ }, {
336
+ approved?: number | undefined;
337
+ rejected?: number | undefined;
338
+ draft?: number | undefined;
339
+ in_review?: number | undefined;
340
+ }>>;
341
+ }, z.ZodTypeAny, "passthrough">>;
342
+ /** `state`: queued → running → complete | failed. */
343
+ export declare const derivationJobSchema: z.ZodObject<{
344
+ job_id: z.ZodString;
345
+ prime_contract_id: z.ZodOptional<z.ZodString>;
346
+ state: z.ZodEnum<["queued", "running", "complete", "failed"]>;
347
+ attempts: z.ZodOptional<z.ZodNumber>;
348
+ retryable: z.ZodOptional<z.ZodBoolean>;
349
+ error: z.ZodOptional<z.ZodString>;
350
+ created_at: z.ZodOptional<z.ZodString>;
351
+ updated_at: z.ZodOptional<z.ZodString>;
352
+ /** Present ONLY when state === "complete". */
353
+ result: z.ZodOptional<z.ZodObject<{
354
+ rules: z.ZodOptional<z.ZodNumber>;
355
+ extracted_count: z.ZodOptional<z.ZodNumber>;
356
+ faithfulness_rejections: z.ZodOptional<z.ZodNumber>;
357
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
358
+ rules: z.ZodOptional<z.ZodNumber>;
359
+ extracted_count: z.ZodOptional<z.ZodNumber>;
360
+ faithfulness_rejections: z.ZodOptional<z.ZodNumber>;
361
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
362
+ rules: z.ZodOptional<z.ZodNumber>;
363
+ extracted_count: z.ZodOptional<z.ZodNumber>;
364
+ faithfulness_rejections: z.ZodOptional<z.ZodNumber>;
365
+ }, z.ZodTypeAny, "passthrough">>>;
366
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
367
+ job_id: z.ZodString;
368
+ prime_contract_id: z.ZodOptional<z.ZodString>;
369
+ state: z.ZodEnum<["queued", "running", "complete", "failed"]>;
370
+ attempts: z.ZodOptional<z.ZodNumber>;
371
+ retryable: z.ZodOptional<z.ZodBoolean>;
372
+ error: z.ZodOptional<z.ZodString>;
373
+ created_at: z.ZodOptional<z.ZodString>;
374
+ updated_at: z.ZodOptional<z.ZodString>;
375
+ /** Present ONLY when state === "complete". */
376
+ result: z.ZodOptional<z.ZodObject<{
377
+ rules: z.ZodOptional<z.ZodNumber>;
378
+ extracted_count: z.ZodOptional<z.ZodNumber>;
379
+ faithfulness_rejections: z.ZodOptional<z.ZodNumber>;
380
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
381
+ rules: z.ZodOptional<z.ZodNumber>;
382
+ extracted_count: z.ZodOptional<z.ZodNumber>;
383
+ faithfulness_rejections: z.ZodOptional<z.ZodNumber>;
384
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
385
+ rules: z.ZodOptional<z.ZodNumber>;
386
+ extracted_count: z.ZodOptional<z.ZodNumber>;
387
+ faithfulness_rejections: z.ZodOptional<z.ZodNumber>;
388
+ }, z.ZodTypeAny, "passthrough">>>;
389
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
390
+ job_id: z.ZodString;
391
+ prime_contract_id: z.ZodOptional<z.ZodString>;
392
+ state: z.ZodEnum<["queued", "running", "complete", "failed"]>;
393
+ attempts: z.ZodOptional<z.ZodNumber>;
394
+ retryable: z.ZodOptional<z.ZodBoolean>;
395
+ error: z.ZodOptional<z.ZodString>;
396
+ created_at: z.ZodOptional<z.ZodString>;
397
+ updated_at: z.ZodOptional<z.ZodString>;
398
+ /** Present ONLY when state === "complete". */
399
+ result: z.ZodOptional<z.ZodObject<{
400
+ rules: z.ZodOptional<z.ZodNumber>;
401
+ extracted_count: z.ZodOptional<z.ZodNumber>;
402
+ faithfulness_rejections: z.ZodOptional<z.ZodNumber>;
403
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
404
+ rules: z.ZodOptional<z.ZodNumber>;
405
+ extracted_count: z.ZodOptional<z.ZodNumber>;
406
+ faithfulness_rejections: z.ZodOptional<z.ZodNumber>;
407
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
408
+ rules: z.ZodOptional<z.ZodNumber>;
409
+ extracted_count: z.ZodOptional<z.ZodNumber>;
410
+ faithfulness_rejections: z.ZodOptional<z.ZodNumber>;
411
+ }, z.ZodTypeAny, "passthrough">>>;
412
+ }, z.ZodTypeAny, "passthrough">>;
413
+ export type DerivedRule = z.infer<typeof derivedRuleSchema>;
414
+ export type DerivedRulebook = z.infer<typeof derivedRulebookSchema>;
415
+ export type DerivationJob = z.infer<typeof derivationJobSchema>;
416
+ export interface DerivedRulesPage {
417
+ rulebook?: DerivedRulebook;
418
+ version?: number;
419
+ rules: DerivedRule[];
420
+ }
421
+ /**
422
+ * Lists candidate rules. ALL states are returned — rejected rules stay
423
+ * visible as audit records, so the UI filters rather than assuming absence.
424
+ * `version` defaults to latest.
425
+ */
426
+ export declare const listDerivedRules: (prime: string, options?: {
427
+ version?: number;
428
+ }) => Promise<DerivedRulesPage>;
429
+ /** Rulebook status + per-state counts (counts are status-endpoint only). */
430
+ export declare const getDerivedRulebookStatus: (prime: string) => Promise<DerivedRulebook>;
431
+ export declare const getDerivationJob: (prime: string, jobId: string) => Promise<DerivationJob>;
432
+ export interface DisposeOptions {
433
+ /** Last-seen etag. A stale value is a 409 — refresh and retry. */
434
+ etag: number;
435
+ /** 0/omitted = latest version. */
436
+ version?: number;
437
+ note?: string;
438
+ }
439
+ export declare const approveDerivedRule: (prime: string, ruleId: string, options: DisposeOptions) => Promise<DerivedRule>;
440
+ export declare const rejectDerivedRule: (prime: string, ruleId: string, options: DisposeOptions) => Promise<DerivedRule>;
441
+ /**
442
+ * Counsel tweaks a generated rule before disposing it. `body` REPLACES the
443
+ * stored rule wholesale — send the full edited contracts.Rule, not a patch.
444
+ * Disposed rules are immutable (409). The response carries a bumped etag;
445
+ * use THAT for a follow-up approve.
446
+ */
447
+ export declare const editDerivedRule: (prime: string, ruleId: string, options: DisposeOptions & {
448
+ body: Record<string, unknown>;
449
+ clauseRef?: string;
450
+ }) => Promise<DerivedRule>;
451
+ /**
452
+ * All-or-nothing in one transaction: ANY stale etag rolls the whole batch
453
+ * back with a single 409 and nothing is applied. Returns the rulebook DTO,
454
+ * not the rules — re-list to refresh etags/states.
455
+ */
456
+ export declare const bulkApproveDerivedRules: (prime: string, rules: readonly {
457
+ ruleId: string;
458
+ etag: number;
459
+ }[], options?: {
460
+ version?: number;
461
+ note?: string;
462
+ }) => Promise<DerivedRulebook>;
463
+ /**
464
+ * Uploads the prime contract DOCX. The multipart field MUST be named `file`
465
+ * — any other name is a 400. Content-Type is deliberately NOT set: the
466
+ * browser must add its own multipart boundary.
467
+ */
468
+ export declare const uploadPrimeContract: (prime: string, file: File | Blob) => Promise<DerivationJob>;
469
+ export declare const retryDerivationJob: (prime: string, jobId: string) => Promise<DerivationJob>;
470
+ export type { PlaybookApiConfig };