@haakco/custd-sdk 2.4.0 → 3.71.2

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 (183) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +586 -40
  3. package/dist/admin-accounting-evidence.d.ts +48 -0
  4. package/dist/admin-accounting-evidence.js +24 -0
  5. package/dist/admin-app-releases.d.ts +116 -0
  6. package/dist/admin-app-releases.js +8 -0
  7. package/dist/admin-apps.d.ts +120 -0
  8. package/dist/admin-apps.js +47 -0
  9. package/dist/admin-auth-project-domain.d.ts +125 -0
  10. package/dist/admin-auth-project-domain.js +37 -0
  11. package/dist/admin-auth-projects.d.ts +989 -0
  12. package/dist/admin-auth-projects.js +527 -0
  13. package/dist/admin-campaign-email.d.ts +120 -0
  14. package/dist/admin-campaign-email.js +64 -0
  15. package/dist/admin-client-setup.d.ts +22 -0
  16. package/dist/admin-client-setup.js +11 -1
  17. package/dist/admin-data-scopes.d.ts +93 -0
  18. package/dist/admin-data-scopes.js +154 -0
  19. package/dist/admin-email-relay.d.ts +66 -0
  20. package/dist/admin-email-relay.js +25 -0
  21. package/dist/admin-environment-policy.d.ts +32 -0
  22. package/dist/admin-environment-policy.js +26 -0
  23. package/dist/admin-error-issues.d.ts +91 -0
  24. package/dist/admin-error-issues.js +52 -0
  25. package/dist/admin-event-types.d.ts +57 -0
  26. package/dist/admin-event-types.js +28 -0
  27. package/dist/admin-impersonation.d.ts +48 -0
  28. package/dist/admin-impersonation.js +27 -0
  29. package/dist/admin-ingest-claims.d.ts +35 -0
  30. package/dist/admin-ingest-claims.js +26 -0
  31. package/dist/admin-managed-audit.d.ts +13 -0
  32. package/dist/admin-managed-audit.js +13 -0
  33. package/dist/admin-measurement-projects.d.ts +166 -0
  34. package/dist/admin-measurement-projects.js +120 -0
  35. package/dist/admin-notification-destinations.d.ts +31 -0
  36. package/dist/admin-notification-destinations.js +19 -0
  37. package/dist/admin-notification-webhooks.d.ts +64 -0
  38. package/dist/admin-notification-webhooks.js +42 -0
  39. package/dist/admin-oauth-client-admissions.d.ts +65 -0
  40. package/dist/admin-oauth-client-admissions.js +46 -0
  41. package/dist/admin-offboarding.d.ts +20 -6
  42. package/dist/admin-offboarding.js +27 -6
  43. package/dist/admin-predictions.d.ts +127 -8
  44. package/dist/admin-predictions.js +22 -12
  45. package/dist/admin-privacy-erasures.d.ts +24 -12
  46. package/dist/admin-privacy-erasures.js +3 -2
  47. package/dist/admin-retention.d.ts +72 -24
  48. package/dist/admin-retention.js +38 -13
  49. package/dist/admin-rls.d.ts +94 -0
  50. package/dist/admin-rls.js +33 -0
  51. package/dist/admin-sdk-usage.d.ts +41 -0
  52. package/dist/admin-sdk-usage.js +23 -0
  53. package/dist/admin-site-ai.d.ts +72 -0
  54. package/dist/admin-site-ai.js +1 -0
  55. package/dist/admin-site-analytics.d.ts +52 -0
  56. package/dist/admin-site-analytics.js +14 -0
  57. package/dist/admin-site-audit-pages.d.ts +76 -0
  58. package/dist/admin-site-audit-pages.js +27 -0
  59. package/dist/admin-site-campaign-links.d.ts +40 -0
  60. package/dist/admin-site-campaign-links.js +9 -0
  61. package/dist/admin-site-domains.d.ts +733 -0
  62. package/dist/admin-site-domains.js +768 -0
  63. package/dist/admin-site-export.d.ts +76 -0
  64. package/dist/admin-site-export.js +15 -0
  65. package/dist/admin-site-insights-tasks.d.ts +44 -0
  66. package/dist/admin-site-insights-tasks.js +28 -0
  67. package/dist/admin-site-insights.d.ts +527 -0
  68. package/dist/admin-site-insights.js +61 -0
  69. package/dist/admin-site-links.d.ts +87 -0
  70. package/dist/admin-site-links.js +16 -0
  71. package/dist/admin-site-monitors.d.ts +110 -0
  72. package/dist/admin-site-monitors.js +25 -0
  73. package/dist/admin-site-next-actions.d.ts +93 -0
  74. package/dist/admin-site-next-actions.js +36 -0
  75. package/dist/admin-site-page-queries.d.ts +63 -0
  76. package/dist/admin-site-page-queries.js +20 -0
  77. package/dist/admin-site-rankings.d.ts +98 -0
  78. package/dist/admin-site-rankings.js +46 -0
  79. package/dist/admin-site-regional-trends.d.ts +30 -0
  80. package/dist/admin-site-regional-trends.js +1 -0
  81. package/dist/admin-site-saved-reports.d.ts +45 -0
  82. package/dist/admin-site-saved-reports.js +13 -0
  83. package/dist/admin-site-search-pool.d.ts +77 -0
  84. package/dist/admin-site-search-pool.js +41 -0
  85. package/dist/admin-site-search-value.d.ts +97 -0
  86. package/dist/admin-site-search-value.js +29 -0
  87. package/dist/admin-site-status-page.d.ts +57 -0
  88. package/dist/admin-site-status-page.js +10 -0
  89. package/dist/admin-site-traffic.d.ts +145 -0
  90. package/dist/admin-site-traffic.js +32 -0
  91. package/dist/admin-site-web-data.d.ts +258 -0
  92. package/dist/admin-site-web-data.js +60 -0
  93. package/dist/admin-subject-exports.d.ts +58 -27
  94. package/dist/admin-subject-exports.js +32 -16
  95. package/dist/admin-support-access.d.ts +32 -0
  96. package/dist/admin-support-access.js +21 -0
  97. package/dist/admin-system.d.ts +283 -0
  98. package/dist/admin-system.js +65 -0
  99. package/dist/admin-tenant-storage.d.ts +22 -14
  100. package/dist/admin-tenant-storage.js +13 -14
  101. package/dist/admin-timeplans.d.ts +276 -2
  102. package/dist/admin-timeplans.js +54 -0
  103. package/dist/admin-uncertainty-models.d.ts +42 -0
  104. package/dist/admin-uncertainty-models.js +53 -0
  105. package/dist/admin-usage.d.ts +124 -0
  106. package/dist/admin-usage.js +169 -0
  107. package/dist/admin-users.d.ts +124 -0
  108. package/dist/admin-users.js +82 -0
  109. package/dist/admin-workflow-timings.d.ts +367 -0
  110. package/dist/admin-workflow-timings.js +117 -0
  111. package/dist/analytics-events.d.ts +82 -0
  112. package/dist/analytics-events.js +157 -0
  113. package/dist/analytics-reads.d.ts +81 -0
  114. package/dist/analytics-reads.js +5 -0
  115. package/dist/app-account.d.ts +84 -0
  116. package/dist/app-account.js +177 -0
  117. package/dist/app-alerts.d.ts +120 -0
  118. package/dist/app-alerts.js +44 -0
  119. package/dist/app-items.d.ts +786 -0
  120. package/dist/app-items.js +524 -0
  121. package/dist/app-live.d.ts +84 -0
  122. package/dist/app-live.js +228 -0
  123. package/dist/app-meetings.d.ts +95 -0
  124. package/dist/app-meetings.js +26 -0
  125. package/dist/app-models.d.ts +271 -0
  126. package/dist/app-models.js +83 -0
  127. package/dist/app-push.d.ts +64 -0
  128. package/dist/app-push.js +178 -0
  129. package/dist/backend-lifecycle.d.ts +2 -2
  130. package/dist/browser-manifest.json +5 -5
  131. package/dist/browser-script-BWnwDjAC.js +711 -0
  132. package/dist/browser-sign-in.d.ts +153 -0
  133. package/dist/browser-sign-in.js +410 -0
  134. package/dist/browser-tracker.d.ts +95 -0
  135. package/dist/browser-tracker.js +362 -40
  136. package/dist/browser-web-vitals.d.ts +22 -0
  137. package/dist/browser-web-vitals.js +116 -0
  138. package/dist/browser.d.ts +9 -0
  139. package/dist/browser.js +9 -0
  140. package/dist/download-stream.d.ts +16 -0
  141. package/dist/download-stream.js +55 -0
  142. package/dist/error-capture.d.ts +62 -0
  143. package/dist/error-capture.js +168 -0
  144. package/dist/hosted-app.d.ts +115 -0
  145. package/dist/hosted-app.js +275 -0
  146. package/dist/index.d.ts +1168 -154
  147. package/dist/index.js +682 -162
  148. package/dist/ingest-operations.d.ts +483 -0
  149. package/dist/ingest-operations.js +154 -0
  150. package/dist/measurement.d.ts +164 -0
  151. package/dist/measurement.js +104 -0
  152. package/dist/parsers.d.ts +149 -0
  153. package/dist/parsers.js +115 -0
  154. package/dist/public-reads.d.ts +79 -0
  155. package/dist/public-reads.js +57 -0
  156. package/dist/reporting-catalogue.d.ts +264 -0
  157. package/dist/reporting-catalogue.js +5 -0
  158. package/dist/response-lists.d.ts +16 -0
  159. package/dist/response-lists.generated.d.ts +7 -0
  160. package/dist/response-lists.generated.js +1927 -0
  161. package/dist/response-lists.js +70 -0
  162. package/dist/response-validation.d.ts +30 -0
  163. package/dist/response-validation.js +94 -0
  164. package/dist/schema-registry.d.ts +45 -0
  165. package/dist/schema-registry.js +9 -0
  166. package/dist/secure-url.d.ts +4 -0
  167. package/dist/secure-url.js +23 -0
  168. package/dist/site-ai-owner.d.ts +34 -0
  169. package/dist/site-ai-owner.js +99 -0
  170. package/dist/site-monitor-reports.d.ts +15 -0
  171. package/dist/site-monitor-reports.js +87 -0
  172. package/dist/testing/fake-custd.d.ts +150 -0
  173. package/dist/testing/fake-custd.js +842 -0
  174. package/dist/testing/fake-results.d.ts +30 -0
  175. package/dist/testing/fake-results.js +293 -0
  176. package/dist/testing.d.ts +2 -0
  177. package/dist/testing.js +3 -0
  178. package/dist/version.d.ts +2 -2
  179. package/dist/version.js +1 -1
  180. package/package.json +25 -14
  181. package/dist/browser-script-BvgjdZSO.js +0 -429
  182. package/dist/fixtures.d.ts +0 -10
  183. package/dist/fixtures.js +0 -57
@@ -0,0 +1,367 @@
1
+ /**
2
+ * Workflow timings: facts another system observed about its own work. Custd is not the
3
+ * controller: the caller keeps its own lifecycle and reports what it observed after its own
4
+ * commit. Every append is idempotent through the caller's deterministic key, and a 200 answer
5
+ * is not a durable append: read each result's `accepted`.
6
+ */
7
+ import type { RequestOptions } from "./index.js";
8
+ /** Expectation states. Only `ready` may be presented as a forecast; a cold start must look different. */
9
+ export declare const WORKFLOW_TIMING_STATES: {
10
+ readonly ready: "ready";
11
+ readonly coldStart: "cold_start";
12
+ readonly sparse: "sparse";
13
+ readonly stale: "stale";
14
+ readonly partial: "partial";
15
+ readonly unavailable: "unavailable";
16
+ readonly error: "error";
17
+ };
18
+ export type WorkflowTimingState = (typeof WORKFLOW_TIMING_STATES)[keyof typeof WORKFLOW_TIMING_STATES];
19
+ /** The observed fact kinds. */
20
+ export declare const WORKFLOW_TIMING_FACT_KINDS: {
21
+ readonly runStarted: "run_started";
22
+ readonly runFinished: "run_finished";
23
+ readonly stepStarted: "step_started";
24
+ readonly stepFinished: "step_finished";
25
+ };
26
+ export type WorkflowTimingFactKind = (typeof WORKFLOW_TIMING_FACT_KINDS)[keyof typeof WORKFLOW_TIMING_FACT_KINDS];
27
+ /** One declared step of a workflow shape. */
28
+ export type WorkflowTimingStepDeclaration = {
29
+ stepKey: string;
30
+ name: string;
31
+ nominalMs: number;
32
+ };
33
+ /** The declarative workflow shape. Repeating it is a no-op; a changed shape adds a forward-only revision. */
34
+ export type WorkflowTimingDeclaration = {
35
+ workflowKey: string;
36
+ name: string;
37
+ description?: string;
38
+ allowOverlap?: boolean;
39
+ dimensions?: string[];
40
+ steps: WorkflowTimingStepDeclaration[];
41
+ retired?: boolean;
42
+ predictionVersionUuid?: string;
43
+ };
44
+ export type WorkflowTimingRunFact = {
45
+ state: string;
46
+ };
47
+ export type WorkflowTimingStepFact = {
48
+ stepKey: string;
49
+ attempt: number;
50
+ state: string;
51
+ errorClass?: string;
52
+ };
53
+ /** The observed fact body. */
54
+ export type WorkflowTimingFact = {
55
+ kind: WorkflowTimingFactKind;
56
+ occurredAt: string;
57
+ dimensions?: Record<string, string>;
58
+ run?: WorkflowTimingRunFact;
59
+ step?: WorkflowTimingStepFact;
60
+ };
61
+ /** Which collector supplied a fact. Both the actor kind and reference are required. */
62
+ export type WorkflowTimingProvenance = {
63
+ actorKind: string;
64
+ actorRef: string;
65
+ collector?: string;
66
+ };
67
+ /** One observed fact with its idempotency identity. */
68
+ export type WorkflowTimingObservation = {
69
+ workflowKey: string;
70
+ externalRunId: string;
71
+ idempotencyKey: string;
72
+ supersedesFactUuid?: string;
73
+ provenance?: WorkflowTimingProvenance;
74
+ fact: WorkflowTimingFact;
75
+ };
76
+ /** The per-item outcome of an append. */
77
+ export type WorkflowTimingObservationResult = {
78
+ index: number;
79
+ accepted: boolean;
80
+ duplicate: boolean;
81
+ workflowKey: string;
82
+ externalRunId: string;
83
+ idempotencyKey: string;
84
+ runUuid?: string;
85
+ factUuid?: string;
86
+ errorCode?: string;
87
+ errorMessage?: string;
88
+ };
89
+ /** The outcome of one append. A rejected item is not a durable append. */
90
+ export type WorkflowTimingBatchResult = {
91
+ results: WorkflowTimingObservationResult[];
92
+ accepted: number;
93
+ rejected: number;
94
+ duplicates: number;
95
+ };
96
+ export type WorkflowTimingDimensionDefinition = {
97
+ dimensionKey: string;
98
+ maxValueBytes: number;
99
+ };
100
+ export type WorkflowTimingStepDefinition = {
101
+ stepKey: string;
102
+ name: string;
103
+ sequence: number;
104
+ nominalMs: number;
105
+ };
106
+ /** An immutable compiled workflow shape. */
107
+ export type WorkflowTimingRevision = {
108
+ uuid: string;
109
+ number: number;
110
+ hash: string;
111
+ allowOverlap: boolean;
112
+ predictionVersionUuid?: string;
113
+ dimensions: WorkflowTimingDimensionDefinition[];
114
+ steps: WorkflowTimingStepDefinition[];
115
+ };
116
+ /** One tenant-scoped workflow shape. */
117
+ export type WorkflowTimingDefinition = {
118
+ uuid: string;
119
+ workflowKey: string;
120
+ name: string;
121
+ description: string;
122
+ status: string;
123
+ currentRevision: WorkflowTimingRevision;
124
+ revisionCount: number;
125
+ };
126
+ export type WorkflowTimingDefinitionList = {
127
+ items: WorkflowTimingDefinition[];
128
+ };
129
+ /** What one reconcile changed. */
130
+ export type WorkflowTimingReconcileResult = {
131
+ definition: WorkflowTimingDefinition;
132
+ created: boolean;
133
+ revisionChanged: boolean;
134
+ };
135
+ /** One evidence-backed duration expectation. The point and range are absent when not produced. */
136
+ export type WorkflowTimingExpectation = {
137
+ seriesKey: string;
138
+ stepKey?: string;
139
+ attempt?: number;
140
+ state: WorkflowTimingState;
141
+ baselineMs: number;
142
+ expectedMs?: number;
143
+ conservativeLowMs?: number;
144
+ conservativeHighMs?: number;
145
+ sampleCount: number;
146
+ method: string;
147
+ methodVersion: string;
148
+ predictionVersionUuid?: string;
149
+ inputHash: string;
150
+ generatedAt: string;
151
+ evidenceWindowStart: string;
152
+ warnings: string[];
153
+ };
154
+ /** One observed run's completion expectation. */
155
+ export type WorkflowTimingPrediction = {
156
+ runUuid: string;
157
+ workflowKey: string;
158
+ externalRunId: string;
159
+ state: WorkflowTimingState;
160
+ allowOverlap: boolean;
161
+ generatedAt: string;
162
+ run: WorkflowTimingExpectation;
163
+ steps: WorkflowTimingExpectation[];
164
+ };
165
+ /** The projection state of one run. Pending facts mean its durations are not yet trustworthy. */
166
+ export type WorkflowTimingProjectionStatus = {
167
+ state: string;
168
+ projectedLedgerId: number;
169
+ latestLedgerId: number;
170
+ pendingFacts: number;
171
+ foldError?: string;
172
+ healthy: boolean;
173
+ nextAction: string;
174
+ };
175
+ export type WorkflowTimingAttempt = {
176
+ stepKey: string;
177
+ attempt: number;
178
+ state: string;
179
+ startedAt?: string;
180
+ finishedAt?: string;
181
+ errorClass?: string;
182
+ occurredAt: string;
183
+ receiptAt: string;
184
+ };
185
+ /** One observed run with its projection status and attempts. */
186
+ export type WorkflowTimingRun = {
187
+ runUuid: string;
188
+ workflowKey: string;
189
+ workflowUuid: string;
190
+ revisionUuid: string;
191
+ revisionNumber: number;
192
+ revisionHash: string;
193
+ externalRunId: string;
194
+ state: string;
195
+ startedAt?: string;
196
+ finishedAt?: string;
197
+ sourceOccurredAt?: string;
198
+ receiptAt: string;
199
+ dimensions: Record<string, string>;
200
+ attempts: WorkflowTimingAttempt[];
201
+ projectionStatus: WorkflowTimingProjectionStatus;
202
+ };
203
+ export type WorkflowTimingRunSummary = {
204
+ runUuid: string;
205
+ externalRunId: string;
206
+ workflowKey: string;
207
+ state: string;
208
+ startedAt?: string;
209
+ finishedAt?: string;
210
+ pendingFacts: number;
211
+ openAttempts: number;
212
+ receiptAt: string;
213
+ };
214
+ export type WorkflowTimingRunList = {
215
+ items: WorkflowTimingRunSummary[];
216
+ };
217
+ /** The closed outcome tally of a workflow. */
218
+ export type WorkflowTimingOutcomeCounts = {
219
+ completedRuns: number;
220
+ failedRuns: number;
221
+ cancelledRuns: number;
222
+ runningRuns: number;
223
+ completedSteps: number;
224
+ failedAttempts: number;
225
+ skippedAttempts: number;
226
+ cancelledSteps: number;
227
+ openAttempts: number;
228
+ retries: number;
229
+ };
230
+ export type WorkflowTimingDurationHistoryEntry = {
231
+ runUuid: string;
232
+ stepKey: string;
233
+ valueMs: number;
234
+ baselineMs: number;
235
+ revisionUuid: string;
236
+ revisionNumber: number;
237
+ outcome: string;
238
+ corrected: boolean;
239
+ observedAt: string;
240
+ };
241
+ export type WorkflowTimingContribution = {
242
+ stepKey: string;
243
+ attempts: number;
244
+ totalMs: number;
245
+ baselineMs: number;
246
+ contributionPermille: number;
247
+ };
248
+ /** The latest completed run's split. Active time is the union of step intervals, never their sum. */
249
+ export type WorkflowTimingRunTiming = {
250
+ runUuid: string;
251
+ wallClockMs: number;
252
+ activeMs: number;
253
+ waitMs: number;
254
+ nominalMs: number;
255
+ };
256
+ export type WorkflowTimingDurationHistory = {
257
+ workflowKey: string;
258
+ workflowUuid: string;
259
+ entries: WorkflowTimingDurationHistoryEntry[];
260
+ outcomes: WorkflowTimingOutcomeCounts;
261
+ contributions: WorkflowTimingContribution[];
262
+ latestCompletedRun?: WorkflowTimingRunTiming;
263
+ };
264
+ /** The measurement owner's evaluation artifact, as it stores it. */
265
+ export type WorkflowTimingEvaluationArtifact = {
266
+ schema_version: string;
267
+ source: string;
268
+ prediction_version_uuid: string;
269
+ content_sha256: string;
270
+ evaluation: Record<string, unknown>;
271
+ };
272
+ /** The rolling-origin evaluation. Unavailable, with a next action, until a prediction version is selected. */
273
+ export type WorkflowTimingEvaluation = {
274
+ workflowKey: string;
275
+ workflowUuid: string;
276
+ seriesKey: string;
277
+ state: string;
278
+ nextAction: string;
279
+ baselineMs: number;
280
+ outcomes: WorkflowTimingOutcomeCounts;
281
+ predictionVersionUuid?: string;
282
+ artifact?: WorkflowTimingEvaluationArtifact;
283
+ };
284
+ export type WorkflowTimingRunProjection = {
285
+ runUuid: string;
286
+ state: string;
287
+ corrected: boolean;
288
+ startedAt?: string;
289
+ finishedAt?: string;
290
+ occurredAt?: string;
291
+ receiptAt: string;
292
+ dimensions: Record<string, string>;
293
+ attempts: WorkflowTimingAttempt[];
294
+ appliedLedgerId: number;
295
+ openAttempts: number;
296
+ };
297
+ export type WorkflowTimingRunDuration = {
298
+ valueMs: number;
299
+ baselineMs: number;
300
+ startedAt: string;
301
+ finishedAt: string;
302
+ };
303
+ export type WorkflowTimingStepDuration = {
304
+ stepKey: string;
305
+ attempt: number;
306
+ valueMs: number;
307
+ baselineMs: number;
308
+ startedAt: string;
309
+ finishedAt: string;
310
+ receiptAt: string;
311
+ };
312
+ export type WorkflowTimingExcludedStep = {
313
+ stepKey: string;
314
+ attempt: number;
315
+ outcome: string;
316
+ };
317
+ export type WorkflowTimingDurationProjection = {
318
+ runEligible: boolean;
319
+ run: WorkflowTimingRunDuration;
320
+ steps: WorkflowTimingStepDuration[];
321
+ excluded: WorkflowTimingExcludedStep[];
322
+ activeMs: number;
323
+ waitMs: number;
324
+ openAttempts: number;
325
+ };
326
+ /** What one deterministic projection rebuild produced. */
327
+ export type WorkflowTimingRebuildResult = {
328
+ runUuid: string;
329
+ workflowKey: string;
330
+ externalRunId: string;
331
+ facts: number;
332
+ status: WorkflowTimingProjectionStatus;
333
+ observationsWritten: number;
334
+ projection: WorkflowTimingRunProjection;
335
+ durations: WorkflowTimingDurationProjection;
336
+ };
337
+ /** Optional narrowing for a run list. */
338
+ export type WorkflowTimingRunListQuery = {
339
+ workflowKey?: string;
340
+ limit?: number;
341
+ };
342
+ type AdminRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
343
+ export declare class WorkflowTimingAdminClient {
344
+ private readonly request;
345
+ constructor(request: AdminRequester);
346
+ /** Declaratively applies one workflow shape, keyed by its workflowKey. */
347
+ reconcileDefinition(companySlug: string, declaration: WorkflowTimingDeclaration, options?: RequestOptions): Promise<WorkflowTimingReconcileResult>;
348
+ listDefinitions(companySlug: string, limit?: number, options?: RequestOptions): Promise<WorkflowTimingDefinitionList>;
349
+ getDefinition(companySlug: string, workflowKey: string, options?: RequestOptions): Promise<WorkflowTimingDefinition>;
350
+ /** Records one observed fact. Read the result's `accepted`, not the transport status. */
351
+ appendObservation(companySlug: string, observation: WorkflowTimingObservation, options?: RequestOptions): Promise<WorkflowTimingBatchResult>;
352
+ /** Records a bounded batch (10,000 facts, 1 MiB). Replay a failed request with the same idempotency keys. */
353
+ appendObservations(companySlug: string, observations: WorkflowTimingObservation[], options?: RequestOptions): Promise<WorkflowTimingBatchResult>;
354
+ /** Appends a fact that supersedes an accepted one; the observation must name `supersedesFactUuid`. */
355
+ correctObservation(companySlug: string, observation: WorkflowTimingObservation, options?: RequestOptions): Promise<WorkflowTimingBatchResult>;
356
+ /** Lists observed runs, newest first. The server filters by workflow before it limits. */
357
+ listRuns(companySlug: string, query?: WorkflowTimingRunListQuery, options?: RequestOptions): Promise<WorkflowTimingRunList>;
358
+ getRun(companySlug: string, runUuid: string, options?: RequestOptions): Promise<WorkflowTimingRun>;
359
+ /** Reads the evidence-backed completion expectation for one run. */
360
+ getPrediction(companySlug: string, runUuid: string, options?: RequestOptions): Promise<WorkflowTimingPrediction>;
361
+ getDurationHistory(companySlug: string, workflowKey: string, limit?: number, options?: RequestOptions): Promise<WorkflowTimingDurationHistory>;
362
+ getEvaluation(companySlug: string, workflowKey: string, seriesKey?: string, options?: RequestOptions): Promise<WorkflowTimingEvaluation>;
363
+ /** Rebuilds one run's projection from its ledger: the repair path when its status reports pending facts. */
364
+ rebuildRun(companySlug: string, runUuid: string, options?: RequestOptions): Promise<WorkflowTimingRebuildResult>;
365
+ private append;
366
+ }
367
+ export {};
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Workflow timings: facts another system observed about its own work. Custd is not the
3
+ * controller: the caller keeps its own lifecycle and reports what it observed after its own
4
+ * commit. Every append is idempotent through the caller's deterministic key, and a 200 answer
5
+ * is not a durable append: read each result's `accepted`.
6
+ */
7
+ /** Expectation states. Only `ready` may be presented as a forecast; a cold start must look different. */
8
+ export const WORKFLOW_TIMING_STATES = {
9
+ ready: "ready",
10
+ coldStart: "cold_start",
11
+ sparse: "sparse",
12
+ stale: "stale",
13
+ partial: "partial",
14
+ unavailable: "unavailable",
15
+ error: "error",
16
+ };
17
+ /** The observed fact kinds. */
18
+ export const WORKFLOW_TIMING_FACT_KINDS = {
19
+ runStarted: "run_started",
20
+ runFinished: "run_finished",
21
+ stepStarted: "step_started",
22
+ stepFinished: "step_finished",
23
+ };
24
+ export class WorkflowTimingAdminClient {
25
+ constructor(request) {
26
+ this.request = request;
27
+ }
28
+ /** Declaratively applies one workflow shape, keyed by its workflowKey. */
29
+ reconcileDefinition(companySlug, declaration, options) {
30
+ const path = timingPath(`/definitions/${encodeURIComponent(declaration.workflowKey)}`, companySlug);
31
+ return this.request("PUT", path, declaration, options).then((result) => ({
32
+ ...result,
33
+ definition: definition(result.definition),
34
+ }));
35
+ }
36
+ async listDefinitions(companySlug, limit, options) {
37
+ const path = timingPath("/definitions", companySlug, { limit });
38
+ const list = await this.request("GET", path, undefined, options);
39
+ return { items: (list.items ?? []).map(definition) };
40
+ }
41
+ async getDefinition(companySlug, workflowKey, options) {
42
+ const path = timingPath(`/definitions/${encodeURIComponent(workflowKey)}`, companySlug);
43
+ return definition(await this.request("GET", path, undefined, options));
44
+ }
45
+ /** Records one observed fact. Read the result's `accepted`, not the transport status. */
46
+ appendObservation(companySlug, observation, options) {
47
+ return this.append("/observations", companySlug, { observation }, options);
48
+ }
49
+ /** Records a bounded batch (10,000 facts, 1 MiB). Replay a failed request with the same idempotency keys. */
50
+ appendObservations(companySlug, observations, options) {
51
+ return this.append("/observations:batch", companySlug, { observations }, options);
52
+ }
53
+ /** Appends a fact that supersedes an accepted one; the observation must name `supersedesFactUuid`. */
54
+ correctObservation(companySlug, observation, options) {
55
+ return this.append("/corrections", companySlug, { observation }, options);
56
+ }
57
+ /** Lists observed runs, newest first. The server filters by workflow before it limits. */
58
+ async listRuns(companySlug, query = {}, options) {
59
+ const path = timingPath("/runs", companySlug, { workflowKey: query.workflowKey, limit: query.limit });
60
+ const list = await this.request("GET", path, undefined, options);
61
+ return { items: list.items ?? [] };
62
+ }
63
+ async getRun(companySlug, runUuid, options) {
64
+ const path = timingPath(`/runs/${encodeURIComponent(runUuid)}`, companySlug);
65
+ const run = await this.request("GET", path, undefined, options);
66
+ return { ...run, attempts: run.attempts ?? [] };
67
+ }
68
+ /** Reads the evidence-backed completion expectation for one run. */
69
+ async getPrediction(companySlug, runUuid, options) {
70
+ const path = timingPath(`/runs/${encodeURIComponent(runUuid)}/prediction`, companySlug);
71
+ const prediction = await this.request("GET", path, undefined, options);
72
+ return { ...prediction, run: expectation(prediction.run), steps: (prediction.steps ?? []).map(expectation) };
73
+ }
74
+ async getDurationHistory(companySlug, workflowKey, limit, options) {
75
+ const path = timingPath(`/definitions/${encodeURIComponent(workflowKey)}/duration-history`, companySlug, { limit });
76
+ const history = await this.request("GET", path, undefined, options);
77
+ return { ...history, entries: history.entries ?? [], contributions: history.contributions ?? [] };
78
+ }
79
+ getEvaluation(companySlug, workflowKey, seriesKey, options) {
80
+ const path = timingPath(`/definitions/${encodeURIComponent(workflowKey)}/evaluation`, companySlug, { seriesKey });
81
+ return this.request("GET", path, undefined, options);
82
+ }
83
+ /** Rebuilds one run's projection from its ledger: the repair path when its status reports pending facts. */
84
+ async rebuildRun(companySlug, runUuid, options) {
85
+ const path = timingPath(`/runs/${encodeURIComponent(runUuid)}/rebuild`, companySlug);
86
+ return rebuildResult(await this.request("POST", path, undefined, options));
87
+ }
88
+ async append(route, companySlug, body, options) {
89
+ const result = await this.request("POST", timingPath(route, companySlug), body, options);
90
+ return { ...result, results: result.results ?? [] };
91
+ }
92
+ }
93
+ function timingPath(route, companySlug, query = {}) {
94
+ const params = new URLSearchParams({ companySlug });
95
+ for (const [key, value] of Object.entries(query)) {
96
+ if (value !== undefined && value !== "")
97
+ params.set(key, String(value));
98
+ }
99
+ return `/workflow-timings${route}?${params.toString()}`;
100
+ }
101
+ function definition(value) {
102
+ const revision = value.currentRevision;
103
+ return {
104
+ ...value,
105
+ currentRevision: { ...revision, dimensions: revision.dimensions ?? [], steps: revision.steps ?? [] },
106
+ };
107
+ }
108
+ function expectation(value) {
109
+ return { ...value, warnings: value.warnings ?? [] };
110
+ }
111
+ function rebuildResult(value) {
112
+ return {
113
+ ...value,
114
+ projection: { ...value.projection, attempts: value.projection.attempts ?? [] },
115
+ durations: { ...value.durations, steps: value.durations.steps ?? [], excluded: value.durations.excluded ?? [] },
116
+ };
117
+ }
@@ -1,6 +1,14 @@
1
+ import type { AnalyticsActiveNow, AnalyticsDashboardSummary, AnalyticsEventCount, AnalyticsEventCountQuery } from "./analytics-reads.js";
1
2
  import type { RequestOptions } from "./index.js";
2
3
  /** Sources the server may answer a query from. */
3
4
  export type AnalyticsQuerySource = "auto" | "postgres" | "duckdb" | "rollup" | "materialized";
5
+ /**
6
+ * Sources the range query accepts. The range API accepts only omitted, empty,
7
+ * `auto`, or `duckdb`; the single-day query's retired `postgres`, `rollup`, and
8
+ * `materialized` sources are not part of the range contract. An empty string is
9
+ * accepted as the default and normalized to an omitted `source`.
10
+ */
11
+ export type AnalyticsRangeQuerySource = "" | "auto" | "duckdb";
4
12
  /**
5
13
  * One exact tenant-vocabulary key/value filter.
6
14
  *
@@ -20,6 +28,15 @@ export type AnalyticsEventQueryRequest = {
20
28
  limit?: number;
21
29
  source?: AnalyticsQuerySource;
22
30
  labelFilters?: AnalyticsLabelFilter[];
31
+ /**
32
+ * Optional promoted log-dimension filters. Each is an exact equality match
33
+ * against the matching typed column (max 256 bytes server-side); an empty
34
+ * value is omitted so an unset filter never narrows the query.
35
+ */
36
+ severity?: string;
37
+ service?: string;
38
+ subClient?: string;
39
+ resource?: string;
23
40
  };
24
41
  /**
25
42
  * One tenant event.
@@ -66,6 +83,57 @@ export type AnalyticsEventQueryResponse = {
66
83
  sources: AnalyticsEventSourceSummary[];
67
84
  timing: AnalyticsEventTiming;
68
85
  };
86
+ /** The longest inclusive range the service accepts, in days. */
87
+ export declare const ANALYTICS_MAX_RANGE_DAYS = 120;
88
+ /** The only bucket granularity the service supports today. */
89
+ export declare const ANALYTICS_RANGE_GROUP_BY = "day";
90
+ export type AnalyticsEventRangeQueryRequest = {
91
+ /** Inclusive range start, formatted YYYY-MM-DD. The server requires this. */
92
+ from: string;
93
+ /** Inclusive range end, formatted YYYY-MM-DD. The server requires this. */
94
+ to: string;
95
+ /** Exact event-type slug to match. */
96
+ eventType?: string;
97
+ /** Maximum rows across the whole range. The server clamps this and reports the applied count. */
98
+ limit?: number;
99
+ /** Query source. Omitted, `auto`, or `duckdb` only. */
100
+ source?: AnalyticsRangeQuerySource;
101
+ /** Bucket granularity. Omit, or set to {@link ANALYTICS_RANGE_GROUP_BY}. */
102
+ groupBy?: typeof ANALYTICS_RANGE_GROUP_BY;
103
+ labelFilters?: AnalyticsLabelFilter[];
104
+ /**
105
+ * Optional promoted log-dimension filters, shared with the single-day query.
106
+ * Each filters exactly like the day query it summarizes; an empty value is
107
+ * omitted from the wire.
108
+ */
109
+ severity?: string;
110
+ service?: string;
111
+ subClient?: string;
112
+ resource?: string;
113
+ };
114
+ /**
115
+ * One day's coverage inside a range query.
116
+ *
117
+ * `complete` is the server's own assessment of whether that day's source answered the
118
+ * whole request, so it is surfaced unchanged; the client must not substitute its own
119
+ * confidence heuristic.
120
+ */
121
+ export type AnalyticsEventRangeBucket = {
122
+ date: string;
123
+ count: number;
124
+ source: AnalyticsQuerySource;
125
+ complete: boolean;
126
+ queryDurationMs: number;
127
+ parquetUriCount?: number;
128
+ message?: string;
129
+ };
130
+ export type AnalyticsEventRangeQueryResponse = {
131
+ rows: AnalyticsEventRow[];
132
+ count: number;
133
+ buckets: AnalyticsEventRangeBucket[];
134
+ sources: AnalyticsEventSourceSummary[];
135
+ timing: AnalyticsEventTiming;
136
+ };
69
137
  /** The server accepts at most this many label filters on one query. */
70
138
  export declare const ANALYTICS_MAX_LABEL_FILTERS = 4;
71
139
  type AnalyticsRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
@@ -81,5 +149,19 @@ export declare class AnalyticsEventClient {
81
149
  * them even when a caller passes extra properties.
82
150
  */
83
151
  query(request: AnalyticsEventQueryRequest, options?: RequestOptions): Promise<AnalyticsEventQueryResponse>;
152
+ /**
153
+ * Query this tenant's own events across an inclusive date range.
154
+ *
155
+ * Only the documented public fields are serialised. As with {@link query}, the internal
156
+ * `anonymousId` predicate and `countOnly` flag are absent from the service's public JSON
157
+ * contract and cannot be transmitted by a caller passing extra properties.
158
+ */
159
+ queryRange(request: AnalyticsEventRangeQueryRequest, options?: RequestOptions): Promise<AnalyticsEventRangeQueryResponse>;
160
+ /** Counts the sessions active on one site now. A 503 means realtime counts are unavailable: hide them. */
161
+ activeNow(siteUuid: string, options?: RequestOptions): Promise<AnalyticsActiveNow>;
162
+ /** Returns the tenant's stored-event overview. */
163
+ dashboardSummary(options?: RequestOptions): Promise<AnalyticsDashboardSummary>;
164
+ /** Counts the tenant's events on one UTC day, optionally of one event type. */
165
+ eventCount(query: AnalyticsEventCountQuery, options?: RequestOptions): Promise<AnalyticsEventCount>;
84
166
  }
85
167
  export {};