react-semaphor 0.1.603 → 0.1.604

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 (167) hide show
  1. package/dist/activity/index.js +1 -73
  2. package/dist/analytics-protocol/index.js +1 -1491
  3. package/dist/appearance/index.js +1 -12
  4. package/dist/appearance-runtime/index.js +1 -5
  5. package/dist/assistant-context/index.js +1 -11
  6. package/dist/assistant-protocol/index.js +1 -152
  7. package/dist/brand-studio/index.js +4 -1594
  8. package/dist/briefings/index.js +1 -70
  9. package/dist/chunks/add-to-dashboard-DeHEBEqG.js +12 -0
  10. package/dist/chunks/analytics-base-schemas-BREc5WGv.js +1 -0
  11. package/dist/chunks/appearance-context-BqBZrijL.js +1 -0
  12. package/dist/chunks/appearance-runtime-provider-DmbCrOOG.js +1 -0
  13. package/dist/chunks/applied-constraints-CinevlKD.js +1 -0
  14. package/dist/chunks/assistant-chat-CjYrwVDa.js +56 -0
  15. package/dist/chunks/attribution-BEFSsbNn.js +1 -0
  16. package/dist/chunks/availability-3AIOf6Z-.js +1 -0
  17. package/dist/chunks/bookmark-impact-C89zBLq3.js +1 -0
  18. package/dist/chunks/bookmark-state-69YYnRql.js +1 -0
  19. package/dist/chunks/brand-DCaZyRt6.js +1 -0
  20. package/dist/chunks/card-filter-builder-CTp6RAz1.js +17 -0
  21. package/dist/chunks/column-bands-DwxbZ6UI.js +1 -0
  22. package/dist/chunks/comparison-window-caption-C312mn3s.js +1 -0
  23. package/dist/chunks/context-ALdccLHw.js +2 -0
  24. package/dist/chunks/conversation-JMK2kyTK.js +1 -0
  25. package/dist/chunks/dashboard-BX28ld6s.js +1 -0
  26. package/dist/chunks/dashboard-briefing-launcher-qo7GH4EO.js +37 -0
  27. package/dist/chunks/dashboard-controls-DhRjB7MA.js +42 -0
  28. package/dist/chunks/dashboard-json-9cHzhSjC.js +1 -0
  29. package/dist/chunks/dates-D-KP8G-z.js +1 -0
  30. package/dist/chunks/edit-DEAK0UZo.js +1 -0
  31. package/dist/chunks/edit-dashboard-visual-Duq_QkB_.js +93 -0
  32. package/dist/chunks/export-file-format-B-wQNHIn.js +4 -0
  33. package/dist/chunks/filter-line-CwQrqORc.js +1 -0
  34. package/dist/chunks/filter-reach-preview-gixPFlZj.js +1 -0
  35. package/dist/chunks/filter-value-text-B3tXakhd.js +1 -0
  36. package/dist/chunks/index-B-VF1ogs.js +1 -0
  37. package/dist/chunks/index-BE1DfxNs.js +1 -0
  38. package/dist/chunks/index-DViPGDFj.js +1 -0
  39. package/dist/chunks/layout-grid-BWtlgw0T.js +6 -0
  40. package/dist/chunks/matrix-analytical-definition-CtFqWyCK.js +1 -0
  41. package/dist/chunks/matrix-member-presentation-Q0MCJ-YK.js +1 -0
  42. package/dist/chunks/matrix-operation-contract-D1RC1bfi.js +1 -0
  43. package/dist/chunks/metric-comparison-DEZYXROZ.js +1 -0
  44. package/dist/chunks/normalize-dashboard-for-dirty-check-ILKfqgL3.js +1 -0
  45. package/dist/chunks/paintbrush-BjS3SbrH.js +6 -0
  46. package/dist/chunks/palette-BzC-CGOc.js +6 -0
  47. package/dist/chunks/pickers-DuBrUht0.js +1 -0
  48. package/dist/chunks/pivot-result-contract-expectations-DTQAgr4n.js +1 -0
  49. package/dist/chunks/pivot-result-identity-DTNCB--h.js +1 -0
  50. package/dist/chunks/raw-temporal-value-DeyEhL0S.js +1 -0
  51. package/dist/chunks/rendered-file-BbvwaU6z.js +1 -0
  52. package/dist/chunks/report-preferences-dialog-B_gUmCzG.js +1 -0
  53. package/dist/chunks/report-runtime-context-BWzIHCKK.js +1 -0
  54. package/dist/chunks/resolve-dashboard-input-context-B-TtRqxu.js +8 -0
  55. package/dist/chunks/resolver-AN9ChBfZ.js +1 -0
  56. package/dist/chunks/save-DdFUZcbi.js +6 -0
  57. package/dist/chunks/saved-dashboard-context-BAJ5tWiq.js +1 -0
  58. package/dist/chunks/schema-MC0cQSAb.js +4 -0
  59. package/dist/chunks/selection-filter-compiler-CCoCD25M.js +1 -0
  60. package/dist/chunks/semaphor-ready-indicator-DzjorP3t.js +999 -0
  61. package/dist/chunks/set-DuJfGkbY.js +1 -0
  62. package/dist/chunks/shelf-drop-preview-context-BlLJ5RsT.js +6 -0
  63. package/dist/chunks/stored-dashboard-Ctcpkllg.js +1 -0
  64. package/dist/chunks/style-sheet-parts-BRGt9O05.js +178 -0
  65. package/dist/chunks/table-export-sheet-rC5pKmXg.js +2 -0
  66. package/dist/chunks/token-types-Bj9iMy0w.js +1 -0
  67. package/dist/chunks/validators-CqV3Yka1.js +1 -0
  68. package/dist/chunks/variable-draft-DJrfUyhv.js +1 -0
  69. package/dist/chunks/visual-choice-DgEFfkE-.js +1 -0
  70. package/dist/dashboard/index.js +1 -7
  71. package/dist/dashboard-authoring/index.js +1 -4614
  72. package/dist/format-utils/index.js +1 -425
  73. package/dist/index.js +1 -554
  74. package/dist/layouts/index.js +1 -7
  75. package/dist/live-channel/index.js +1 -124
  76. package/dist/pdf-export-policy/index.js +1 -92
  77. package/dist/pdf-table-layout/index.js +1 -993
  78. package/dist/report-runtime-context/index.js +1 -9
  79. package/dist/shared/index.js +1 -6
  80. package/dist/style.css +1 -1
  81. package/dist/surfboard/index.js +1 -9
  82. package/dist/types/index.js +1 -88
  83. package/dist/types/lib/filter-values/build-card-filter-definition.d.ts +32 -0
  84. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +9 -0
  85. package/dist/types/lib/stores/explorer-actions.d.ts +7 -6
  86. package/dist/types/lib/types/semantic-types.d.ts +6 -10
  87. package/dist/types/lib/utils/field-state-calculator.d.ts +7 -19
  88. package/dist/types/shared/dashboard-authoring/calculations/definition.d.ts +13 -0
  89. package/dist/types/shared/dashboard-authoring/card-data-source/card-base.d.ts +125 -0
  90. package/dist/types/shared/dashboard-authoring/card-data-source/card-field-folders.d.ts +55 -0
  91. package/dist/types/shared/dashboard-authoring/card-data-source/card-joins.d.ts +114 -0
  92. package/dist/types/shared/dashboard-authoring/card-data-source/card-prune.d.ts +12 -0
  93. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-catalog.d.ts +60 -0
  94. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-folders.d.ts +132 -0
  95. package/dist/types/shared/dashboard-authoring/card-data-source/index.d.ts +7 -0
  96. package/dist/types/shared/dashboard-authoring/card-data-source/join-reach.d.ts +42 -0
  97. package/dist/types/shared/dashboard-authoring/card-field-places.d.ts +28 -0
  98. package/dist/types/shared/dashboard-authoring/field-folders/field-folders.d.ts +115 -0
  99. package/dist/types/shared/dashboard-authoring/field-folders/index.d.ts +1 -0
  100. package/dist/types/shared/dashboard-authoring/filter-reach-decision.d.ts +11 -0
  101. package/dist/types/shared/dashboard-authoring/index.d.ts +6 -1
  102. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +2 -0
  103. package/dist/types/shared/dashboard-authoring/see-records/result.d.ts +7 -22
  104. package/dist/usage-events/index.js +1 -285
  105. package/dist/value-format-preferences/index.js +1 -635
  106. package/package.json +4 -1
  107. package/dist/chunks/add-to-dashboard-CFF-wFU-.js +0 -291
  108. package/dist/chunks/analytics-base-schemas-DsUh5Q3C.js +0 -680
  109. package/dist/chunks/appearance-context-BwBp25ZG.js +0 -162
  110. package/dist/chunks/appearance-runtime-provider-BRHYELkC.js +0 -80
  111. package/dist/chunks/applied-constraints-DU-wndZ7.js +0 -47
  112. package/dist/chunks/assistant-chat-B6hNQI1t.js +0 -6115
  113. package/dist/chunks/attribution-BvoKvhcj.js +0 -32
  114. package/dist/chunks/availability-Bp5Gfu1I.js +0 -44
  115. package/dist/chunks/bookmark-impact-Ba2PLcGp.js +0 -76
  116. package/dist/chunks/bookmark-state-n7AaNzR_.js +0 -1667
  117. package/dist/chunks/brand-BoUV0iHF.js +0 -54
  118. package/dist/chunks/card-filter-builder-Y22HizVx.js +0 -4069
  119. package/dist/chunks/column-bands-RdM-kjDe.js +0 -47
  120. package/dist/chunks/comparison-window-caption-Ck2TIbnR.js +0 -741
  121. package/dist/chunks/context-UCQ7sere.js +0 -369
  122. package/dist/chunks/conversation-sQiWYUOb.js +0 -16
  123. package/dist/chunks/dashboard-BghI99oY.js +0 -14
  124. package/dist/chunks/dashboard-briefing-launcher-DtBAnGiH.js +0 -4875
  125. package/dist/chunks/dashboard-controls-CtFXlyjV.js +0 -2290
  126. package/dist/chunks/dashboard-json-DfGBUtCd.js +0 -66
  127. package/dist/chunks/dates-BnrXF4bb.js +0 -185
  128. package/dist/chunks/edit-9df1zOWe.js +0 -226
  129. package/dist/chunks/edit-dashboard-visual-oxt3x1wb.js +0 -18397
  130. package/dist/chunks/export-file-format-C-tJsxsf.js +0 -111
  131. package/dist/chunks/filter-line-Cy5YYqRL.js +0 -703
  132. package/dist/chunks/filter-reach-copy-CE_ZX147.js +0 -5111
  133. package/dist/chunks/filter-value-text-fWvSDwkl.js +0 -153
  134. package/dist/chunks/index-BVKzKl5d.js +0 -90
  135. package/dist/chunks/index-CV_Kzou0.js +0 -595
  136. package/dist/chunks/index-D5rxbtS4.js +0 -2795
  137. package/dist/chunks/layout-grid-9LndRoLa.js +0 -16
  138. package/dist/chunks/matrix-analytical-definition-CCp48UCw.js +0 -1233
  139. package/dist/chunks/matrix-member-presentation-zNehruXR.js +0 -391
  140. package/dist/chunks/matrix-operation-contract-DPBj69D8.js +0 -1413
  141. package/dist/chunks/metric-comparison-B0FR-Q8I.js +0 -600
  142. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +0 -119
  143. package/dist/chunks/paintbrush-58FQYY-y.js +0 -27
  144. package/dist/chunks/palette-Be62Tkoa.js +0 -23
  145. package/dist/chunks/pickers-DkqmtnTL.js +0 -2403
  146. package/dist/chunks/pivot-result-contract-expectations-BYqAmG9n.js +0 -5092
  147. package/dist/chunks/pivot-result-identity-CAP4--iq.js +0 -77
  148. package/dist/chunks/raw-temporal-value-Dg_MTFF7.js +0 -3778
  149. package/dist/chunks/rendered-file-D8xEuVVx.js +0 -108
  150. package/dist/chunks/report-preferences-dialog-uJp9GBTM.js +0 -1651
  151. package/dist/chunks/report-runtime-context-c77_KF9v.js +0 -388
  152. package/dist/chunks/resolve-dashboard-input-context-Rtl1ffmE.js +0 -25324
  153. package/dist/chunks/resolver-DG_tfEpt.js +0 -156
  154. package/dist/chunks/save-C5A0JnEV.js +0 -21
  155. package/dist/chunks/saved-dashboard-context-tcyTU8jm.js +0 -618
  156. package/dist/chunks/schema-C9NPiIru.js +0 -2568
  157. package/dist/chunks/selection-filter-compiler-DNijjI5y.js +0 -150
  158. package/dist/chunks/semaphor-ready-indicator-FBvunj6S.js +0 -145603
  159. package/dist/chunks/shelf-drop-preview-context-QKStrcK9.js +0 -2466
  160. package/dist/chunks/stored-dashboard-CHozcAY9.js +0 -4075
  161. package/dist/chunks/style-sheet-parts-CDCG-8Ej.js +0 -8681
  162. package/dist/chunks/table-export-sheet-ZFIvs6Sj.js +0 -949
  163. package/dist/chunks/token-types-XbM6QByy.js +0 -8
  164. package/dist/chunks/upload-H15d7uHK.js +0 -15
  165. package/dist/chunks/validators-Baf3VIf5.js +0 -3686
  166. package/dist/chunks/variable-draft-C2y8Jp6Z.js +0 -242
  167. package/dist/chunks/visual-choice-DDfHfHvY.js +0 -172
@@ -1,285 +1 @@
1
- import { z as e } from "zod";
2
- import { g as h, l as S } from "../chunks/context-UCQ7sere.js";
3
- import { Q as b, a as y, b as x } from "../chunks/attribution-BvoKvhcj.js";
4
- import { U as te, c as ne, u as ae } from "../chunks/attribution-BvoKvhcj.js";
5
- const r = e.string().min(1).max(128), t = e.string().max(500), m = e.array(e.string().max(500)).max(500), n = e.number().int().nonnegative(), p = e.string().refine((o) => new TextEncoder().encode(o).length <= 16 * 1024), f = e.object({
6
- token_type: e.enum(["dashboard", "project"]),
7
- token_purpose: e.enum(["embed", "console"]).optional(),
8
- ttl_s: e.number().int().nonnegative().optional(),
9
- embed_origin: e.string().max(2048).optional(),
10
- initial_dashboard_id: r.optional(),
11
- dashboard_title: t.optional(),
12
- project_name: t.optional(),
13
- user_verified: e.boolean(),
14
- user_email: t.optional(),
15
- user_display_name: t.optional(),
16
- tenant_name: t.optional(),
17
- role: e.string().max(128).optional(),
18
- user_provisioned: e.boolean().optional(),
19
- domain_access_mode: e.enum(["all", "none", "include", "exclude"]).optional(),
20
- domain_ids: e.array(r).max(500).optional(),
21
- rls_policy_names: m.optional(),
22
- cls_policy_names: m.optional(),
23
- has_sls: e.boolean().optional(),
24
- security_param_keys: m.optional(),
25
- timezone: e.string().max(128).optional(),
26
- mcp_scopes: e.array(e.string().max(128)).max(64).optional(),
27
- mcp_sql: e.boolean().optional(),
28
- mcp_live: e.boolean().optional()
29
- }).strict(), E = e.object({
30
- requested_version: e.number().int().optional(),
31
- served: e.enum(["current", "version"]).optional(),
32
- dashboard_title: t.optional(),
33
- project_name: t.optional(),
34
- sheet_count: n.optional(),
35
- card_count: n.optional()
36
- }).strict(), T = e.object({
37
- statement: e.enum(b),
38
- duration_ms: e.number().nonnegative(),
39
- outcome: e.enum(["succeeded", "failed", "cancelled"]),
40
- rows: n.optional()
41
- }).strict(), v = e.object({
42
- data_service_calls: n,
43
- query_run_id: r,
44
- parent_query_run_id: r.optional(),
45
- query_kind: e.enum(x).optional(),
46
- statements: e.array(T).max(64),
47
- trigger: e.enum(y).optional(),
48
- card_title: t.optional(),
49
- card_type: e.string().max(128).optional(),
50
- dashboard_title: t.optional(),
51
- sheet_title: t.optional(),
52
- project_name: t.optional(),
53
- connection_name: t.optional(),
54
- connection_type: e.string().max(128).optional(),
55
- dialect: e.string().max(128).optional(),
56
- dataset: t.optional(),
57
- rows: n.optional(),
58
- row_limit_exceeded: e.boolean().optional(),
59
- sql_text: p.optional(),
60
- sql_truncated: e.boolean().optional(),
61
- sql_hash: e.string().regex(/^[0-9a-f]{64}$/).optional(),
62
- input_ids_applied: e.array(r).max(500).optional(),
63
- page: e.number().int().positive().optional(),
64
- export_job_id: r.optional()
65
- }).strict(), A = ["assistant", "mcp"], q = e.object({
66
- tool: e.string().min(1).max(128),
67
- args_json: p.optional(),
68
- args_truncated: e.boolean().optional(),
69
- arg_keys: e.array(e.string().max(128)).max(200),
70
- user_agent: e.string().max(1024).optional(),
71
- oauth_client: t.optional(),
72
- credential: e.string().max(64).optional(),
73
- access_mode: e.string().max(64).optional(),
74
- scopes: e.array(e.string().max(128)).max(64).optional(),
75
- response_bytes: n.optional(),
76
- /** Who called: the built-in assistant or an MCP client (Phase A, AL-D46). */
77
- origin: e.enum(A)
78
- }).strict(), U = ["job", "matrix_direct", "rendered"], R = ["csv", "xlsx", "pdf", "png"], O = ["visual", "card", "dashboard"], k = ["create", "acquire", "deadline", "render"], I = e.object({
79
- export_id: r.optional(),
80
- mechanism: e.enum(U),
81
- format: e.enum(R),
82
- scope: e.enum(O).optional(),
83
- rows: n.optional(),
84
- bytes: n.optional(),
85
- chunks: n.optional(),
86
- stage: e.enum(k).optional()
87
- }).strict(), N = ["export", "briefing", "cache_refresh"], j = ["scheduled", "manual", "api"], D = e.object({
88
- run_id: r,
89
- rule_id: r,
90
- rule_name: t.optional(),
91
- kind: e.enum(N),
92
- trigger_source: e.enum(j).optional(),
93
- attempt: n.optional(),
94
- scheduled_for: e.string().datetime({ offset: !0 }).optional()
95
- }).strict(), G = ["completed", "refused", "stopped", "failed"], C = e.object({
96
- /** Absent only when the request was refused before it could be read (no turn id was sent). */
97
- turn_id: r.optional(),
98
- conversation_id: r.optional(),
99
- question_text: p.optional(),
100
- question_truncated: e.boolean().optional(),
101
- turn_outcome: e.enum(G),
102
- refusal: e.enum(S).optional(),
103
- context_surface: e.enum(h),
104
- model: e.string().min(1).max(128),
105
- instructions_version: e.string().min(1).max(128),
106
- input_tokens: n,
107
- cached_input_tokens: n,
108
- output_tokens: n,
109
- tools: e.array(e.string().min(1).max(128)).max(500),
110
- tool_call_count: n,
111
- tool_error_count: n,
112
- asked_user: e.boolean().optional(),
113
- finish_reason: e.string().max(64).optional()
114
- }).strict(), B = [
115
- "token_issued",
116
- "dashboard_opened",
117
- "query_executed",
118
- "tool_called",
119
- "export_completed",
120
- "automation_run_completed",
121
- "assistant_turn_completed"
122
- ], M = ["usage", "runtime", "agent", "delivery"], P = ["org_user", "tenant_user", "tenant", "api_key", "system", "anonymous"], w = ["console", "embed", "public_link", "mcp", "api", "scheduler", "pdf_renderer"], L = ["succeeded", "failed", "cancelled", "timed_out"], X = ["app", "scheduler"], Y = {
123
- token_issued: {
124
- category: "usage",
125
- version: 1,
126
- emittedBy: "semaphor-app/src/lib/usage-events/token-issued.ts",
127
- personalData: !0,
128
- detailsSchema: f
129
- },
130
- dashboard_opened: {
131
- category: "usage",
132
- version: 1,
133
- emittedBy: "semaphor-app/src/lib/usage-events/dashboard-opened.ts",
134
- personalData: !1,
135
- detailsSchema: E
136
- },
137
- query_executed: {
138
- category: "runtime",
139
- version: 1,
140
- emittedBy: "semaphor-app/src/app/api/v1/query/query-run.ts",
141
- // sql_text holds the filter and control values the app compiled in.
142
- personalData: !0,
143
- detailsSchema: v
144
- },
145
- tool_called: {
146
- category: "agent",
147
- version: 1,
148
- emittedBy: "semaphor-app/src/lib/mcp/tool-telemetry.ts",
149
- // args_json is what the agent sent.
150
- personalData: !0,
151
- detailsSchema: q
152
- },
153
- export_completed: {
154
- category: "delivery",
155
- version: 1,
156
- emittedBy: "semaphor-app/src/lib/usage-events/export-completed.ts",
157
- personalData: !1,
158
- detailsSchema: I
159
- },
160
- automation_run_completed: {
161
- category: "delivery",
162
- version: 1,
163
- emittedBy: "semaphor-app/src/lib/usage-events/automation-run-completed.ts",
164
- // rule_name is what its author typed; error.message is the run's own error text.
165
- personalData: !0,
166
- detailsSchema: D
167
- },
168
- assistant_turn_completed: {
169
- category: "agent",
170
- version: 1,
171
- emittedBy: "semaphor-app/src/lib/usage-events/assistant-turn-completed.ts",
172
- // question_text is what the person typed (AL-D45).
173
- personalData: !0,
174
- detailsSchema: C
175
- }
176
- }, $ = 16 * 1024, F = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/, V = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?Z$/, Q = e.string().min(1).max(128), i = Q.nullable(), H = e.object({
177
- event_id: e.string().regex(F),
178
- event_type: e.enum(B),
179
- event_version: e.number().int().positive(),
180
- category: e.enum(M),
181
- occurred_at: e.string().regex(V),
182
- producer: e.enum(X),
183
- release: e.string().min(1).max(64),
184
- org_id: i,
185
- project_id: i,
186
- tenant_id: i,
187
- actor_type: e.enum(P),
188
- org_user_id: i,
189
- tenant_user_id: i,
190
- surface: e.enum(w),
191
- session_id: i,
192
- operation_id: i,
193
- dashboard_id: i,
194
- sheet_id: i,
195
- card_id: i,
196
- connection_id: i,
197
- domain_id: i,
198
- outcome: e.enum(L).nullable(),
199
- duration_ms: e.number().nonnegative().nullable(),
200
- error: e.object({
201
- code: e.string().min(1).max(128),
202
- message: e.string().refine((o) => new TextEncoder().encode(o).length <= $)
203
- }).strict().nullable(),
204
- details: e.unknown()
205
- }).strict();
206
- function W(o) {
207
- const s = H.safeParse(o);
208
- if (!s.success) return { ok: !1, issues: g(s.error.issues) };
209
- const a = s.data, d = a.event_type, u = Y[d], l = [];
210
- a.event_version !== u.version && l.push("event_version: not the catalog version"), a.category !== u.category && l.push("category: not the catalog category");
211
- const _ = a.outcome === "failed" || a.outcome === "timed_out";
212
- _ && a.error === null && l.push("error: required when the outcome is failed or timed_out"), !_ && a.error !== null && l.push("error: set only when the outcome is failed or timed_out"), l.push(...z[d](a));
213
- const c = u.detailsSchema.safeParse(a.details);
214
- return c.success || l.push(...g(c.error.issues, "details")), l.length > 0 ? { ok: !1, issues: l } : { ok: !0, event: { ...a, details: c.success ? c.data : a.details } };
215
- }
216
- const z = {
217
- token_issued: (o) => {
218
- const s = [];
219
- return ["org_user", "tenant_user", "tenant", "anonymous"].includes(o.actor_type) || s.push("actor_type: not a token_issued actor"), ["embed", "console", "mcp"].includes(o.surface) || s.push("surface: not a token_issued surface"), o.outcome === null && s.push("outcome: required"), o.outcome === "succeeded" && (o.session_id === null && s.push("session_id: required on success"), o.project_id === null && s.push("project_id: required on success")), s;
220
- },
221
- dashboard_opened: (o) => [
222
- ...o.outcome === null ? ["outcome: required"] : [],
223
- ...o.duration_ms === null ? ["duration_ms: required"] : [],
224
- ...o.dashboard_id === null ? ["dashboard_id: required"] : []
225
- ],
226
- query_executed: (o) => [
227
- ...o.outcome === null ? ["outcome: required"] : [],
228
- ...o.duration_ms === null ? ["duration_ms: required"] : []
229
- ],
230
- tool_called: (o) => [
231
- ...o.outcome === null ? ["outcome: required"] : [],
232
- ...o.duration_ms === null ? ["duration_ms: required"] : [],
233
- ...o.operation_id === null ? ["operation_id: required"] : []
234
- ],
235
- export_completed: (o) => [
236
- ...o.outcome === null ? ["outcome: required"] : [],
237
- ...o.duration_ms === null ? ["duration_ms: required"] : []
238
- ],
239
- automation_run_completed: (o) => [
240
- ...o.outcome === null ? ["outcome: required"] : [],
241
- ...o.duration_ms === null ? ["duration_ms: required"] : []
242
- ],
243
- assistant_turn_completed: (o) => [
244
- ...o.outcome === null ? ["outcome: required"] : [],
245
- ...o.duration_ms === null ? ["duration_ms: required"] : [],
246
- ...o.operation_id === null ? ["operation_id: required"] : []
247
- ]
248
- };
249
- function g(o, s) {
250
- return o.map((a) => `${[s, ...a.path].filter((u) => u !== void 0).join(".") || "(root)"}: ${a.code}`);
251
- }
252
- export {
253
- G as ASSISTANT_TURN_ENDINGS,
254
- N as AUTOMATION_RUN_KINDS,
255
- j as AUTOMATION_TRIGGER_SOURCES,
256
- R as EXPORT_FORMATS,
257
- U as EXPORT_MECHANISMS,
258
- O as EXPORT_SCOPES,
259
- k as EXPORT_STAGES,
260
- x as QUERY_KINDS,
261
- b as QUERY_STATEMENTS,
262
- y as QUERY_TRIGGERS,
263
- A as TOOL_CALL_ORIGINS,
264
- P as USAGE_ACTOR_TYPES,
265
- te as USAGE_ATTRIBUTION_ID_MAX_LENGTH,
266
- ne as USAGE_ATTRIBUTION_TITLE_MAX_LENGTH,
267
- Y as USAGE_EVENT_CATALOG,
268
- M as USAGE_EVENT_CATEGORIES,
269
- $ as USAGE_EVENT_TEXT_MAX_BYTES,
270
- B as USAGE_EVENT_TYPES,
271
- L as USAGE_OUTCOMES,
272
- X as USAGE_PRODUCERS,
273
- w as USAGE_SURFACES,
274
- C as assistantTurnCompletedDetailsSchema,
275
- D as automationRunCompletedDetailsSchema,
276
- E as dashboardOpenedDetailsSchema,
277
- I as exportCompletedDetailsSchema,
278
- W as parseUsageEvent,
279
- v as queryExecutedDetailsSchema,
280
- T as queryStatementRecordSchema,
281
- f as tokenIssuedDetailsSchema,
282
- q as toolCalledDetailsSchema,
283
- ae as usageAttributionFieldsSchema,
284
- H as usageEventEnvelopeSchema
285
- };
1
+ import{z as e}from"zod";import{g as h,l as S}from"../chunks/context-ALdccLHw.js";import{Q as b,a as y,b as x}from"../chunks/attribution-BEFSsbNn.js";import{U as te,c as ne,u as ae}from"../chunks/attribution-BEFSsbNn.js";const r=e.string().min(1).max(128),t=e.string().max(500),m=e.array(e.string().max(500)).max(500),n=e.number().int().nonnegative(),p=e.string().refine(o=>new TextEncoder().encode(o).length<=16*1024),f=e.object({token_type:e.enum(["dashboard","project"]),token_purpose:e.enum(["embed","console"]).optional(),ttl_s:e.number().int().nonnegative().optional(),embed_origin:e.string().max(2048).optional(),initial_dashboard_id:r.optional(),dashboard_title:t.optional(),project_name:t.optional(),user_verified:e.boolean(),user_email:t.optional(),user_display_name:t.optional(),tenant_name:t.optional(),role:e.string().max(128).optional(),user_provisioned:e.boolean().optional(),domain_access_mode:e.enum(["all","none","include","exclude"]).optional(),domain_ids:e.array(r).max(500).optional(),rls_policy_names:m.optional(),cls_policy_names:m.optional(),has_sls:e.boolean().optional(),security_param_keys:m.optional(),timezone:e.string().max(128).optional(),mcp_scopes:e.array(e.string().max(128)).max(64).optional(),mcp_sql:e.boolean().optional(),mcp_live:e.boolean().optional()}).strict(),E=e.object({requested_version:e.number().int().optional(),served:e.enum(["current","version"]).optional(),dashboard_title:t.optional(),project_name:t.optional(),sheet_count:n.optional(),card_count:n.optional()}).strict(),T=e.object({statement:e.enum(b),duration_ms:e.number().nonnegative(),outcome:e.enum(["succeeded","failed","cancelled"]),rows:n.optional()}).strict(),v=e.object({data_service_calls:n,query_run_id:r,parent_query_run_id:r.optional(),query_kind:e.enum(x).optional(),statements:e.array(T).max(64),trigger:e.enum(y).optional(),card_title:t.optional(),card_type:e.string().max(128).optional(),dashboard_title:t.optional(),sheet_title:t.optional(),project_name:t.optional(),connection_name:t.optional(),connection_type:e.string().max(128).optional(),dialect:e.string().max(128).optional(),dataset:t.optional(),rows:n.optional(),row_limit_exceeded:e.boolean().optional(),sql_text:p.optional(),sql_truncated:e.boolean().optional(),sql_hash:e.string().regex(/^[0-9a-f]{64}$/).optional(),input_ids_applied:e.array(r).max(500).optional(),page:e.number().int().positive().optional(),export_job_id:r.optional()}).strict(),A=["assistant","mcp"],q=e.object({tool:e.string().min(1).max(128),args_json:p.optional(),args_truncated:e.boolean().optional(),arg_keys:e.array(e.string().max(128)).max(200),user_agent:e.string().max(1024).optional(),oauth_client:t.optional(),credential:e.string().max(64).optional(),access_mode:e.string().max(64).optional(),scopes:e.array(e.string().max(128)).max(64).optional(),response_bytes:n.optional(),origin:e.enum(A)}).strict(),U=["job","matrix_direct","rendered"],R=["csv","xlsx","pdf","png"],O=["visual","card","dashboard"],k=["create","acquire","deadline","render"],I=e.object({export_id:r.optional(),mechanism:e.enum(U),format:e.enum(R),scope:e.enum(O).optional(),rows:n.optional(),bytes:n.optional(),chunks:n.optional(),stage:e.enum(k).optional()}).strict(),N=["export","briefing","cache_refresh"],j=["scheduled","manual","api"],D=e.object({run_id:r,rule_id:r,rule_name:t.optional(),kind:e.enum(N),trigger_source:e.enum(j).optional(),attempt:n.optional(),scheduled_for:e.string().datetime({offset:!0}).optional()}).strict(),G=["completed","refused","stopped","failed"],C=e.object({turn_id:r.optional(),conversation_id:r.optional(),question_text:p.optional(),question_truncated:e.boolean().optional(),turn_outcome:e.enum(G),refusal:e.enum(S).optional(),context_surface:e.enum(h),model:e.string().min(1).max(128),instructions_version:e.string().min(1).max(128),input_tokens:n,cached_input_tokens:n,output_tokens:n,tools:e.array(e.string().min(1).max(128)).max(500),tool_call_count:n,tool_error_count:n,asked_user:e.boolean().optional(),finish_reason:e.string().max(64).optional()}).strict(),B=["token_issued","dashboard_opened","query_executed","tool_called","export_completed","automation_run_completed","assistant_turn_completed"],M=["usage","runtime","agent","delivery"],P=["org_user","tenant_user","tenant","api_key","system","anonymous"],w=["console","embed","public_link","mcp","api","scheduler","pdf_renderer"],L=["succeeded","failed","cancelled","timed_out"],X=["app","scheduler"],Y={token_issued:{category:"usage",version:1,emittedBy:"semaphor-app/src/lib/usage-events/token-issued.ts",personalData:!0,detailsSchema:f},dashboard_opened:{category:"usage",version:1,emittedBy:"semaphor-app/src/lib/usage-events/dashboard-opened.ts",personalData:!1,detailsSchema:E},query_executed:{category:"runtime",version:1,emittedBy:"semaphor-app/src/app/api/v1/query/query-run.ts",personalData:!0,detailsSchema:v},tool_called:{category:"agent",version:1,emittedBy:"semaphor-app/src/lib/mcp/tool-telemetry.ts",personalData:!0,detailsSchema:q},export_completed:{category:"delivery",version:1,emittedBy:"semaphor-app/src/lib/usage-events/export-completed.ts",personalData:!1,detailsSchema:I},automation_run_completed:{category:"delivery",version:1,emittedBy:"semaphor-app/src/lib/usage-events/automation-run-completed.ts",personalData:!0,detailsSchema:D},assistant_turn_completed:{category:"agent",version:1,emittedBy:"semaphor-app/src/lib/usage-events/assistant-turn-completed.ts",personalData:!0,detailsSchema:C}},$=16*1024,F=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,V=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?Z$/,Q=e.string().min(1).max(128),i=Q.nullable(),H=e.object({event_id:e.string().regex(F),event_type:e.enum(B),event_version:e.number().int().positive(),category:e.enum(M),occurred_at:e.string().regex(V),producer:e.enum(X),release:e.string().min(1).max(64),org_id:i,project_id:i,tenant_id:i,actor_type:e.enum(P),org_user_id:i,tenant_user_id:i,surface:e.enum(w),session_id:i,operation_id:i,dashboard_id:i,sheet_id:i,card_id:i,connection_id:i,domain_id:i,outcome:e.enum(L).nullable(),duration_ms:e.number().nonnegative().nullable(),error:e.object({code:e.string().min(1).max(128),message:e.string().refine(o=>new TextEncoder().encode(o).length<=$)}).strict().nullable(),details:e.unknown()}).strict();function W(o){const s=H.safeParse(o);if(!s.success)return{ok:!1,issues:g(s.error.issues)};const a=s.data,d=a.event_type,u=Y[d],l=[];a.event_version!==u.version&&l.push("event_version: not the catalog version"),a.category!==u.category&&l.push("category: not the catalog category");const _=a.outcome==="failed"||a.outcome==="timed_out";_&&a.error===null&&l.push("error: required when the outcome is failed or timed_out"),!_&&a.error!==null&&l.push("error: set only when the outcome is failed or timed_out"),l.push(...z[d](a));const c=u.detailsSchema.safeParse(a.details);return c.success||l.push(...g(c.error.issues,"details")),l.length>0?{ok:!1,issues:l}:{ok:!0,event:{...a,details:c.success?c.data:a.details}};}const z={token_issued:o=>{const s=[];return["org_user","tenant_user","tenant","anonymous"].includes(o.actor_type)||s.push("actor_type: not a token_issued actor"),["embed","console","mcp"].includes(o.surface)||s.push("surface: not a token_issued surface"),o.outcome===null&&s.push("outcome: required"),o.outcome==="succeeded"&&(o.session_id===null&&s.push("session_id: required on success"),o.project_id===null&&s.push("project_id: required on success")),s;},dashboard_opened:o=>[...(o.outcome===null?["outcome: required"]:[]),...(o.duration_ms===null?["duration_ms: required"]:[]),...(o.dashboard_id===null?["dashboard_id: required"]:[])],query_executed:o=>[...(o.outcome===null?["outcome: required"]:[]),...(o.duration_ms===null?["duration_ms: required"]:[])],tool_called:o=>[...(o.outcome===null?["outcome: required"]:[]),...(o.duration_ms===null?["duration_ms: required"]:[]),...(o.operation_id===null?["operation_id: required"]:[])],export_completed:o=>[...(o.outcome===null?["outcome: required"]:[]),...(o.duration_ms===null?["duration_ms: required"]:[])],automation_run_completed:o=>[...(o.outcome===null?["outcome: required"]:[]),...(o.duration_ms===null?["duration_ms: required"]:[])],assistant_turn_completed:o=>[...(o.outcome===null?["outcome: required"]:[]),...(o.duration_ms===null?["duration_ms: required"]:[]),...(o.operation_id===null?["operation_id: required"]:[])]};function g(o,s){return o.map(a=>`${[s,...a.path].filter(u=>u!==void 0).join(".")||"(root)"}: ${a.code}`);}export{G as ASSISTANT_TURN_ENDINGS,N as AUTOMATION_RUN_KINDS,j as AUTOMATION_TRIGGER_SOURCES,R as EXPORT_FORMATS,U as EXPORT_MECHANISMS,O as EXPORT_SCOPES,k as EXPORT_STAGES,x as QUERY_KINDS,b as QUERY_STATEMENTS,y as QUERY_TRIGGERS,A as TOOL_CALL_ORIGINS,P as USAGE_ACTOR_TYPES,te as USAGE_ATTRIBUTION_ID_MAX_LENGTH,ne as USAGE_ATTRIBUTION_TITLE_MAX_LENGTH,Y as USAGE_EVENT_CATALOG,M as USAGE_EVENT_CATEGORIES,$ as USAGE_EVENT_TEXT_MAX_BYTES,B as USAGE_EVENT_TYPES,L as USAGE_OUTCOMES,X as USAGE_PRODUCERS,w as USAGE_SURFACES,C as assistantTurnCompletedDetailsSchema,D as automationRunCompletedDetailsSchema,E as dashboardOpenedDetailsSchema,I as exportCompletedDetailsSchema,W as parseUsageEvent,v as queryExecutedDetailsSchema,T as queryStatementRecordSchema,f as tokenIssuedDetailsSchema,q as toolCalledDetailsSchema,ae as usageAttributionFieldsSchema,H as usageEventEnvelopeSchema};