@haakco/custd-sdk 0.0.0-stage → 3.71.1

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 (196) hide show
  1. package/README.md +958 -2
  2. package/dist/admin-accounting-evidence.d.ts +48 -0
  3. package/dist/admin-accounting-evidence.js +24 -0
  4. package/dist/admin-app-releases.d.ts +116 -0
  5. package/dist/admin-app-releases.js +8 -0
  6. package/dist/admin-apps.d.ts +120 -0
  7. package/dist/admin-apps.js +47 -0
  8. package/dist/admin-auth-project-domain.d.ts +125 -0
  9. package/dist/admin-auth-project-domain.js +37 -0
  10. package/dist/admin-auth-projects.d.ts +989 -0
  11. package/dist/admin-auth-projects.js +527 -0
  12. package/dist/admin-campaign-email.d.ts +120 -0
  13. package/dist/admin-campaign-email.js +64 -0
  14. package/dist/admin-client-setup.d.ts +122 -0
  15. package/dist/admin-client-setup.js +408 -0
  16. package/dist/admin-data-labels.d.ts +124 -0
  17. package/dist/admin-data-labels.js +51 -0
  18. package/dist/admin-data-scopes.d.ts +93 -0
  19. package/dist/admin-data-scopes.js +154 -0
  20. package/dist/admin-email-relay.d.ts +66 -0
  21. package/dist/admin-email-relay.js +25 -0
  22. package/dist/admin-environment-policy.d.ts +32 -0
  23. package/dist/admin-environment-policy.js +26 -0
  24. package/dist/admin-error-issues.d.ts +91 -0
  25. package/dist/admin-error-issues.js +52 -0
  26. package/dist/admin-event-types.d.ts +57 -0
  27. package/dist/admin-event-types.js +28 -0
  28. package/dist/admin-impersonation.d.ts +48 -0
  29. package/dist/admin-impersonation.js +27 -0
  30. package/dist/admin-ingest-claims.d.ts +35 -0
  31. package/dist/admin-ingest-claims.js +26 -0
  32. package/dist/admin-managed-audit.d.ts +13 -0
  33. package/dist/admin-managed-audit.js +13 -0
  34. package/dist/admin-measurement-projects.d.ts +166 -0
  35. package/dist/admin-measurement-projects.js +120 -0
  36. package/dist/admin-notification-destinations.d.ts +31 -0
  37. package/dist/admin-notification-destinations.js +19 -0
  38. package/dist/admin-notification-webhooks.d.ts +64 -0
  39. package/dist/admin-notification-webhooks.js +42 -0
  40. package/dist/admin-oauth-client-admissions.d.ts +65 -0
  41. package/dist/admin-oauth-client-admissions.js +46 -0
  42. package/dist/admin-offboarding.d.ts +123 -0
  43. package/dist/admin-offboarding.js +129 -0
  44. package/dist/admin-predictions.d.ts +266 -0
  45. package/dist/admin-predictions.js +93 -0
  46. package/dist/admin-privacy-erasures.d.ts +74 -0
  47. package/dist/admin-privacy-erasures.js +73 -0
  48. package/dist/admin-retention.d.ts +99 -0
  49. package/dist/admin-retention.js +60 -0
  50. package/dist/admin-rls.d.ts +94 -0
  51. package/dist/admin-rls.js +33 -0
  52. package/dist/admin-sdk-usage.d.ts +41 -0
  53. package/dist/admin-sdk-usage.js +23 -0
  54. package/dist/admin-site-ai.d.ts +72 -0
  55. package/dist/admin-site-ai.js +1 -0
  56. package/dist/admin-site-analytics.d.ts +52 -0
  57. package/dist/admin-site-analytics.js +14 -0
  58. package/dist/admin-site-audit-pages.d.ts +76 -0
  59. package/dist/admin-site-audit-pages.js +27 -0
  60. package/dist/admin-site-campaign-links.d.ts +40 -0
  61. package/dist/admin-site-campaign-links.js +9 -0
  62. package/dist/admin-site-domains.d.ts +733 -0
  63. package/dist/admin-site-domains.js +768 -0
  64. package/dist/admin-site-export.d.ts +76 -0
  65. package/dist/admin-site-export.js +15 -0
  66. package/dist/admin-site-insights-tasks.d.ts +44 -0
  67. package/dist/admin-site-insights-tasks.js +28 -0
  68. package/dist/admin-site-insights.d.ts +527 -0
  69. package/dist/admin-site-insights.js +61 -0
  70. package/dist/admin-site-links.d.ts +87 -0
  71. package/dist/admin-site-links.js +16 -0
  72. package/dist/admin-site-monitors.d.ts +110 -0
  73. package/dist/admin-site-monitors.js +25 -0
  74. package/dist/admin-site-next-actions.d.ts +93 -0
  75. package/dist/admin-site-next-actions.js +36 -0
  76. package/dist/admin-site-page-queries.d.ts +63 -0
  77. package/dist/admin-site-page-queries.js +20 -0
  78. package/dist/admin-site-rankings.d.ts +98 -0
  79. package/dist/admin-site-rankings.js +46 -0
  80. package/dist/admin-site-regional-trends.d.ts +30 -0
  81. package/dist/admin-site-regional-trends.js +1 -0
  82. package/dist/admin-site-saved-reports.d.ts +45 -0
  83. package/dist/admin-site-saved-reports.js +13 -0
  84. package/dist/admin-site-search-pool.d.ts +77 -0
  85. package/dist/admin-site-search-pool.js +41 -0
  86. package/dist/admin-site-search-value.d.ts +97 -0
  87. package/dist/admin-site-search-value.js +29 -0
  88. package/dist/admin-site-status-page.d.ts +57 -0
  89. package/dist/admin-site-status-page.js +10 -0
  90. package/dist/admin-site-traffic.d.ts +145 -0
  91. package/dist/admin-site-traffic.js +32 -0
  92. package/dist/admin-site-web-data.d.ts +258 -0
  93. package/dist/admin-site-web-data.js +60 -0
  94. package/dist/admin-subject-exports.d.ts +79 -0
  95. package/dist/admin-subject-exports.js +44 -0
  96. package/dist/admin-support-access.d.ts +32 -0
  97. package/dist/admin-support-access.js +21 -0
  98. package/dist/admin-system.d.ts +283 -0
  99. package/dist/admin-system.js +65 -0
  100. package/dist/admin-tenant-storage.d.ts +35 -0
  101. package/dist/admin-tenant-storage.js +24 -0
  102. package/dist/admin-timeplans.d.ts +512 -0
  103. package/dist/admin-timeplans.js +200 -0
  104. package/dist/admin-uncertainty-models.d.ts +42 -0
  105. package/dist/admin-uncertainty-models.js +53 -0
  106. package/dist/admin-usage.d.ts +124 -0
  107. package/dist/admin-usage.js +169 -0
  108. package/dist/admin-users.d.ts +124 -0
  109. package/dist/admin-users.js +82 -0
  110. package/dist/admin-workflow-timings.d.ts +367 -0
  111. package/dist/admin-workflow-timings.js +117 -0
  112. package/dist/analytics-events.d.ts +167 -0
  113. package/dist/analytics-events.js +197 -0
  114. package/dist/analytics-reads.d.ts +81 -0
  115. package/dist/analytics-reads.js +5 -0
  116. package/dist/app-account.d.ts +84 -0
  117. package/dist/app-account.js +177 -0
  118. package/dist/app-alerts.d.ts +120 -0
  119. package/dist/app-alerts.js +44 -0
  120. package/dist/app-items.d.ts +786 -0
  121. package/dist/app-items.js +524 -0
  122. package/dist/app-live.d.ts +84 -0
  123. package/dist/app-live.js +228 -0
  124. package/dist/app-meetings.d.ts +95 -0
  125. package/dist/app-meetings.js +26 -0
  126. package/dist/app-models.d.ts +271 -0
  127. package/dist/app-models.js +83 -0
  128. package/dist/app-push.d.ts +64 -0
  129. package/dist/app-push.js +178 -0
  130. package/dist/backend-lifecycle.d.ts +85 -0
  131. package/dist/backend-lifecycle.js +212 -0
  132. package/dist/browser-manifest.json +7 -0
  133. package/dist/browser-script-BWnwDjAC.js +711 -0
  134. package/dist/browser-script.d.ts +1 -0
  135. package/dist/browser-script.js +5 -0
  136. package/dist/browser-sign-in.d.ts +153 -0
  137. package/dist/browser-sign-in.js +410 -0
  138. package/dist/browser-tracker.d.ts +142 -0
  139. package/dist/browser-tracker.js +775 -0
  140. package/dist/browser-web-vitals.d.ts +22 -0
  141. package/dist/browser-web-vitals.js +116 -0
  142. package/dist/browser.d.ts +10 -0
  143. package/dist/browser.js +10 -0
  144. package/dist/download-stream.d.ts +16 -0
  145. package/dist/download-stream.js +55 -0
  146. package/dist/error-capture.d.ts +62 -0
  147. package/dist/error-capture.js +168 -0
  148. package/dist/hosted-app.d.ts +115 -0
  149. package/dist/hosted-app.js +275 -0
  150. package/dist/index.d.ts +2324 -0
  151. package/dist/index.js +2226 -0
  152. package/dist/ingest-operations.d.ts +483 -0
  153. package/dist/ingest-operations.js +154 -0
  154. package/dist/measurement.d.ts +164 -0
  155. package/dist/measurement.js +104 -0
  156. package/dist/mobile-adapter.d.ts +25 -0
  157. package/dist/mobile-adapter.js +57 -0
  158. package/dist/mobile-context.d.ts +32 -0
  159. package/dist/mobile-context.js +156 -0
  160. package/dist/mobile-queue.d.ts +22 -0
  161. package/dist/mobile-queue.js +73 -0
  162. package/dist/oauth.d.ts +1 -0
  163. package/dist/oauth.js +8 -0
  164. package/dist/parsers.d.ts +149 -0
  165. package/dist/parsers.js +115 -0
  166. package/dist/public-reads.d.ts +79 -0
  167. package/dist/public-reads.js +57 -0
  168. package/dist/reporting-catalogue.d.ts +264 -0
  169. package/dist/reporting-catalogue.js +5 -0
  170. package/dist/reporting-state.d.ts +46 -0
  171. package/dist/reporting-state.js +76 -0
  172. package/dist/response-lists.d.ts +16 -0
  173. package/dist/response-lists.generated.d.ts +7 -0
  174. package/dist/response-lists.generated.js +1927 -0
  175. package/dist/response-lists.js +70 -0
  176. package/dist/response-validation.d.ts +30 -0
  177. package/dist/response-validation.js +94 -0
  178. package/dist/runtime-readiness.d.ts +30 -0
  179. package/dist/runtime-readiness.js +150 -0
  180. package/dist/schema-registry.d.ts +45 -0
  181. package/dist/schema-registry.js +9 -0
  182. package/dist/secure-url.d.ts +4 -0
  183. package/dist/secure-url.js +23 -0
  184. package/dist/site-ai-owner.d.ts +34 -0
  185. package/dist/site-ai-owner.js +99 -0
  186. package/dist/site-monitor-reports.d.ts +15 -0
  187. package/dist/site-monitor-reports.js +87 -0
  188. package/dist/testing/fake-custd.d.ts +150 -0
  189. package/dist/testing/fake-custd.js +842 -0
  190. package/dist/testing/fake-results.d.ts +30 -0
  191. package/dist/testing/fake-results.js +293 -0
  192. package/dist/testing.d.ts +2 -0
  193. package/dist/testing.js +3 -0
  194. package/dist/version.d.ts +10 -0
  195. package/dist/version.js +10 -0
  196. package/package.json +57 -4
@@ -0,0 +1,228 @@
1
+ // Self-refreshing reads of app items by conditional polling. One poller serves every watcher
2
+ // of the same resource and link; it asks with If-None-Match, so an unchanged item costs one
3
+ // 304. Polling pauses while the page is hidden, resumes at once when it is shown again, and
4
+ // backs off while requests fail. When the client has a realtime channel, a pushed change
5
+ // replaces the timer: the poller polls when told, and falls back to its timer whenever push
6
+ // is not carrying it.
7
+ export const APP_LIVE_STATUSES = {
8
+ /** No answer yet. */
9
+ loading: "loading",
10
+ /** The last poll confirmed the data. */
11
+ fresh: "fresh",
12
+ /** The last poll confirmed there is nothing yet, such as no forecast run. */
13
+ empty: "empty",
14
+ /** The data is from an earlier poll; the last one failed and is being retried. */
15
+ stale: "stale",
16
+ /** The last poll got no answer; retried with backoff and as soon as the browser is online. */
17
+ offline: "offline",
18
+ /** Refused (link revoked or expired, key refused), or failing before any data arrived. */
19
+ error: "error",
20
+ };
21
+ export const APP_LIVE_DEFAULT_INTERVAL_MS = 5000;
22
+ /** The safety poll interval while pushed changes carry a read. */
23
+ export const APP_LIVE_PUSHED_INTERVAL_MS = 60000;
24
+ const DEFAULT_MAX_BACKOFF_MS = 60000;
25
+ const LOADING = Object.freeze({ status: APP_LIVE_STATUSES.loading });
26
+ class AppLivePoller {
27
+ constructor(token, load, intervalMs, maxBackoffMs, push) {
28
+ this.token = token;
29
+ this.load = load;
30
+ this.intervalMs = intervalMs;
31
+ this.maxBackoffMs = maxBackoffMs;
32
+ this.push = push;
33
+ this.state = LOADING;
34
+ this.listeners = new Set();
35
+ this.failures = 0;
36
+ this.inFlight = false;
37
+ this.again = false;
38
+ this.halted = false;
39
+ /** True while the realtime channel carries this read, so no timer is needed. */
40
+ this.pushed = false;
41
+ this.onVisibility = () => {
42
+ if (pageHidden())
43
+ this.clearTimer();
44
+ else if (!this.halted)
45
+ this.pollNow();
46
+ };
47
+ this.onOnline = () => {
48
+ if (!this.halted)
49
+ this.pollNow();
50
+ };
51
+ }
52
+ get idle() {
53
+ return this.listeners.size === 0;
54
+ }
55
+ add(listener) {
56
+ this.listeners.add(listener);
57
+ if (this.listeners.size > 1)
58
+ return;
59
+ globalThis.document?.addEventListener("visibilitychange", this.onVisibility);
60
+ globalThis.addEventListener?.("online", this.onOnline);
61
+ if (!pageHidden())
62
+ void this.poll();
63
+ this.stopPush = this.push?.channel.watch(this.push.target, {
64
+ changed: () => this.pollNow(),
65
+ pushed: (on) => this.setPushed(on),
66
+ });
67
+ }
68
+ remove(listener) {
69
+ this.listeners.delete(listener);
70
+ if (this.listeners.size > 0)
71
+ return;
72
+ this.clearTimer();
73
+ globalThis.document?.removeEventListener("visibilitychange", this.onVisibility);
74
+ globalThis.removeEventListener?.("online", this.onOnline);
75
+ this.stopPush?.();
76
+ this.stopPush = undefined;
77
+ this.pushed = false;
78
+ }
79
+ /** Push took over (no timer) or dropped (poll now, then on the timer again). */
80
+ setPushed(on) {
81
+ const dropped = this.pushed && !on;
82
+ this.pushed = on;
83
+ if (on)
84
+ this.clearTimer();
85
+ else if (dropped)
86
+ this.pollNow();
87
+ }
88
+ /** Polls now, and resumes polling stopped by a refusal. */
89
+ pollNow() {
90
+ this.halted = false;
91
+ if (this.idle || pageHidden())
92
+ return;
93
+ this.clearTimer();
94
+ void this.poll();
95
+ }
96
+ async poll() {
97
+ if (this.inFlight) {
98
+ this.again = true;
99
+ return;
100
+ }
101
+ this.inFlight = true;
102
+ try {
103
+ this.succeed(await this.load(this.etag));
104
+ }
105
+ catch (error) {
106
+ this.fail(error);
107
+ }
108
+ finally {
109
+ this.inFlight = false;
110
+ }
111
+ if (this.idle)
112
+ return;
113
+ if (this.again) {
114
+ this.again = false;
115
+ void this.poll();
116
+ return;
117
+ }
118
+ this.schedule();
119
+ }
120
+ succeed(read) {
121
+ this.failures = 0;
122
+ const at = new Date();
123
+ if (read.status === APP_LIVE_STATUSES.empty) {
124
+ // Only a 200 carries an ETag worth repeating: an empty answer must be asked for again.
125
+ this.etag = undefined;
126
+ this.data = undefined;
127
+ this.publish({ status: APP_LIVE_STATUSES.empty, lastUpdatedAt: at });
128
+ return;
129
+ }
130
+ if (read.status === "modified") {
131
+ this.etag = read.etag ?? undefined;
132
+ this.data = { value: read.data, at };
133
+ }
134
+ else if (this.data) {
135
+ this.data = { value: this.data.value, at };
136
+ }
137
+ if (this.data)
138
+ this.publish({ status: APP_LIVE_STATUSES.fresh, data: this.data.value, lastUpdatedAt: at });
139
+ }
140
+ fail(error) {
141
+ this.failures += 1;
142
+ const kept = this.data ? { data: this.data.value, lastUpdatedAt: this.data.at } : {};
143
+ if (error.terminal) {
144
+ this.halted = true;
145
+ this.publish({ status: APP_LIVE_STATUSES.error, error, retrying: false, ...kept });
146
+ }
147
+ else if (error.status === null) {
148
+ this.publish({ status: APP_LIVE_STATUSES.offline, error, ...kept });
149
+ }
150
+ else if (this.data) {
151
+ this.publish({ status: APP_LIVE_STATUSES.stale, error, data: this.data.value, lastUpdatedAt: this.data.at });
152
+ }
153
+ else {
154
+ this.publish({ status: APP_LIVE_STATUSES.error, error, retrying: true });
155
+ }
156
+ }
157
+ schedule() {
158
+ this.clearTimer();
159
+ if (this.halted || pageHidden())
160
+ return;
161
+ // Pushed changes replace the fast timer; a slow safety poll still notices a socket that went
162
+ // quiet without closing, and a failing poll still retries with backoff.
163
+ const interval = this.pushed ? Math.max(APP_LIVE_PUSHED_INTERVAL_MS, this.intervalMs) : this.intervalMs;
164
+ const delay = Math.min(interval * 2 ** this.failures, Math.max(this.maxBackoffMs, interval));
165
+ this.timer = setTimeout(() => {
166
+ this.timer = undefined;
167
+ void this.poll();
168
+ }, delay);
169
+ }
170
+ clearTimer() {
171
+ if (this.timer !== undefined)
172
+ clearTimeout(this.timer);
173
+ this.timer = undefined;
174
+ }
175
+ publish(state) {
176
+ this.state = state;
177
+ for (const listener of [...this.listeners])
178
+ listener();
179
+ }
180
+ }
181
+ /** The pollers of one client, keyed by resource, collection item and link. */
182
+ export class AppLiveRegistry {
183
+ /** `push`, when given, carries pushed changes for every read watched with a push target. */
184
+ constructor(push) {
185
+ this.push = push;
186
+ this.pollers = new Map();
187
+ }
188
+ watch(key, token, options, load, pushTarget) {
189
+ const interval = options.intervalMs ?? APP_LIVE_DEFAULT_INTERVAL_MS;
190
+ const maxBackoff = options.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
191
+ const current = () => this.pollers.get(key);
192
+ return {
193
+ getState: () => current()?.state ?? LOADING,
194
+ subscribe: (listener) => {
195
+ let poller = current();
196
+ if (!poller) {
197
+ const push = this.push && pushTarget ? { channel: this.push, target: pushTarget } : undefined;
198
+ poller = new AppLivePoller(token, load, interval, maxBackoff, push);
199
+ this.pollers.set(key, poller);
200
+ }
201
+ const subscribed = poller;
202
+ subscribed.add(listener);
203
+ return () => {
204
+ subscribed.remove(listener);
205
+ if (subscribed.idle && this.pollers.get(key) === subscribed)
206
+ this.pollers.delete(key);
207
+ };
208
+ },
209
+ refresh: () => current()?.pollNow(),
210
+ };
211
+ }
212
+ /** Polls every watched read now, and resubscribes pushed reads whose user token changed. */
213
+ refreshAll() {
214
+ this.push?.refreshCredentials();
215
+ for (const poller of this.pollers.values())
216
+ poller.pollNow();
217
+ }
218
+ /** Polls every watched read of this link now, after a change made through it. */
219
+ refreshToken(token) {
220
+ for (const poller of this.pollers.values()) {
221
+ if (poller.token === token)
222
+ poller.pollNow();
223
+ }
224
+ }
225
+ }
226
+ function pageHidden() {
227
+ return globalThis.document?.hidden === true;
228
+ }
@@ -0,0 +1,95 @@
1
+ export declare const APP_MEETING_STATUSES: {
2
+ /** Created, not started. */
3
+ readonly ready: "ready";
4
+ readonly running: "running";
5
+ readonly completed: "completed";
6
+ readonly cancelled: "cancelled";
7
+ };
8
+ export type AppMeetingStatus = (typeof APP_MEETING_STATUSES)[keyof typeof APP_MEETING_STATUSES];
9
+ export declare const APP_MEETING_BLOCK_STATUSES: {
10
+ readonly pending: "pending";
11
+ readonly active: "active";
12
+ readonly completed: "completed";
13
+ readonly skipped: "skipped";
14
+ /** The meeting ended before the block was reached. */
15
+ readonly notRun: "not_run";
16
+ };
17
+ export type AppMeetingBlockStatus = (typeof APP_MEETING_BLOCK_STATUSES)[keyof typeof APP_MEETING_BLOCK_STATUSES];
18
+ /** Problem codes the meeting routes answer with. */
19
+ export declare const APP_MEETING_ERROR_CODES: {
20
+ /**
21
+ * 409: the meeting cannot take this step now, such as advancing a block that is neither on nor
22
+ * the one that last finished. Read the meeting again and act on its `currentBlockUuid`.
23
+ */
24
+ readonly stepRefused: "app_item_meeting_step_refused";
25
+ };
26
+ export type AppMeetingBlockCreate = {
27
+ /** At most 200 bytes. */
28
+ title: string;
29
+ /** Milliseconds, at least 1000. */
30
+ predictedMs: number;
31
+ };
32
+ /** A meeting item's agenda: 1 to 128 blocks lasting at most 28 days in all. */
33
+ export type AppMeetingCreate = {
34
+ name: string;
35
+ blocks: AppMeetingBlockCreate[];
36
+ };
37
+ /** Names the block an advance finishes: a repeat is a no-op, any other block a stale 409. */
38
+ export type AppMeetingAdvanceRequest = {
39
+ blockUuid: string;
40
+ };
41
+ export type AppMeetingBlock = {
42
+ blockUuid: string;
43
+ position: number;
44
+ title: string;
45
+ status: AppMeetingBlockStatus;
46
+ /** The time the agenda predicted. */
47
+ predictedMs: number;
48
+ /** The time it has now: an overrun earlier block shrinks the blocks after it. */
49
+ allocatedMs: number;
50
+ /** The time it took, once it is done. */
51
+ actualMs: number;
52
+ startedAt?: string;
53
+ endedAt?: string;
54
+ };
55
+ /** The agenda's predicted time against the time its finished blocks took. */
56
+ export type AppMeetingSummary = {
57
+ predictedMs: number;
58
+ finishedPredictedMs: number;
59
+ finishedActualMs: number;
60
+ finishedBlocks: number;
61
+ /** How far the meeting ran past its planned end. */
62
+ overrunMs: number;
63
+ };
64
+ /** A meeting as it runs. `startedAt` and `endsAt` are set once it starts. */
65
+ export type AppMeeting = {
66
+ name: string;
67
+ status: AppMeetingStatus;
68
+ startedAt?: string;
69
+ /** When the agenda is planned to finish. */
70
+ endsAt?: string;
71
+ /** The block that is on now, if any. */
72
+ currentBlockUuid?: string;
73
+ blocks: AppMeetingBlock[] | null;
74
+ summary: AppMeetingSummary;
75
+ };
76
+ export type AppMeetingAction = {
77
+ description: string;
78
+ partUuid?: string;
79
+ };
80
+ export type AppMeetingMinutes = {
81
+ planUuid?: string;
82
+ minutes: string;
83
+ decisions: string;
84
+ sharedSummary?: string;
85
+ actions: AppMeetingAction[];
86
+ };
87
+ export type AppMeetingMinutesUpdate = AppMeetingMinutes & {
88
+ expectedRevision: number;
89
+ planLinkToken?: string;
90
+ };
91
+ export type AppPlanMeetingSummary = {
92
+ meetingUuid: string;
93
+ name: string;
94
+ summary: string;
95
+ };
@@ -0,0 +1,26 @@
1
+ // Meeting items (Admin API /api/v1/app/item/meeting): an agenda of blocks, each with a predicted
2
+ // time. The owner starts it, advances block by block and ends it; an overrun block takes its extra
3
+ // time from the blocks after it. Every step returns the item read with the meeting as it runs.
4
+ export const APP_MEETING_STATUSES = {
5
+ /** Created, not started. */
6
+ ready: "ready",
7
+ running: "running",
8
+ completed: "completed",
9
+ cancelled: "cancelled",
10
+ };
11
+ export const APP_MEETING_BLOCK_STATUSES = {
12
+ pending: "pending",
13
+ active: "active",
14
+ completed: "completed",
15
+ skipped: "skipped",
16
+ /** The meeting ended before the block was reached. */
17
+ notRun: "not_run",
18
+ };
19
+ /** Problem codes the meeting routes answer with. */
20
+ export const APP_MEETING_ERROR_CODES = {
21
+ /**
22
+ * 409: the meeting cannot take this step now, such as advancing a block that is neither on nor
23
+ * the one that last finished. Read the meeting again and act on its `currentBlockUuid`.
24
+ */
25
+ stepRefused: "app_item_meeting_step_refused",
26
+ };
@@ -0,0 +1,271 @@
1
+ export declare const APP_MODEL_QUANTITY_KINDS: {
2
+ readonly input: "input";
3
+ readonly formula: "formula";
4
+ };
5
+ export type AppModelQuantityKind = (typeof APP_MODEL_QUANTITY_KINDS)[keyof typeof APP_MODEL_QUANTITY_KINDS];
6
+ export declare const APP_MODEL_INPUT_SHAPES: {
7
+ /** One known value. */
8
+ readonly point: "point";
9
+ /** A low and high read as a 90% interval. */
10
+ readonly range: "range";
11
+ /** k successes of n trials, read as a beta distribution. */
12
+ readonly proportion: "proportion";
13
+ /** Pasted data used as an empirical distribution. */
14
+ readonly samples: "samples";
15
+ /** A live input read from its source when the model runs. */
16
+ readonly bound: "bound";
17
+ };
18
+ export type AppModelInputShape = (typeof APP_MODEL_INPUT_SHAPES)[keyof typeof APP_MODEL_INPUT_SHAPES];
19
+ export declare const APP_MODEL_RANGE_DISTRIBUTIONS: {
20
+ readonly normal: "normal";
21
+ readonly lognormal: "lognormal";
22
+ readonly uniform: "uniform";
23
+ };
24
+ export type AppModelRangeDistribution = (typeof APP_MODEL_RANGE_DISTRIBUTIONS)[keyof typeof APP_MODEL_RANGE_DISTRIBUTIONS];
25
+ export declare const APP_MODEL_SOURCE_KINDS: {
26
+ /** The latest completed counter forecast of a measurement project. */
27
+ readonly counterForecast: "counter_forecast";
28
+ };
29
+ export type AppModelSourceKind = (typeof APP_MODEL_SOURCE_KINDS)[keyof typeof APP_MODEL_SOURCE_KINDS];
30
+ export declare const APP_MODEL_FORECAST_FIELDS: {
31
+ readonly completionDays: "completion_days";
32
+ readonly deadlineProbability: "deadline_probability";
33
+ readonly ratePerDay: "rate_per_day";
34
+ };
35
+ export type AppModelForecastField = (typeof APP_MODEL_FORECAST_FIELDS)[keyof typeof APP_MODEL_FORECAST_FIELDS];
36
+ /** Problem codes of the model routes, beside the app item codes. */
37
+ export declare const APP_MODEL_ERROR_CODES: {
38
+ readonly versionLimit: "app_item_model_version_limit";
39
+ readonly runMissing: "app_model_run_missing";
40
+ readonly runInvalid: "uncertainty_model_run_invalid";
41
+ /** The quantities reference each other in a loop; `fieldErrors` names each one in it. */
42
+ readonly formulaCycle: "formula_cycle";
43
+ /** Too many calculations from this caller; wait and try again. */
44
+ readonly calculateLimited: "app_model_calculate_limited";
45
+ };
46
+ export declare const APP_MODEL_RUN_TRIGGERS: {
47
+ readonly request: "request";
48
+ readonly sourceChanged: "source_changed";
49
+ };
50
+ export type AppModelRunTrigger = (typeof APP_MODEL_RUN_TRIGGERS)[keyof typeof APP_MODEL_RUN_TRIGGERS];
51
+ export declare const APP_MODEL_BOUND_STATES: {
52
+ readonly resolved: "resolved";
53
+ readonly sourceMissing: "source_missing";
54
+ readonly valueMissing: "value_missing";
55
+ };
56
+ export type AppModelBoundState = (typeof APP_MODEL_BOUND_STATES)[keyof typeof APP_MODEL_BOUND_STATES];
57
+ export type AppModelInputSource = {
58
+ kind: AppModelSourceKind;
59
+ /** Lowercase UUID of the bound measurement project. */
60
+ projectUuid: string;
61
+ field: AppModelForecastField;
62
+ };
63
+ /** An input's shorthand; only the fields of its shape are sent. */
64
+ export type AppModelInput = {
65
+ shape: typeof APP_MODEL_INPUT_SHAPES.point;
66
+ value: number;
67
+ } | {
68
+ shape: typeof APP_MODEL_INPUT_SHAPES.range;
69
+ low: number;
70
+ high: number;
71
+ distribution: AppModelRangeDistribution;
72
+ } | {
73
+ shape: typeof APP_MODEL_INPUT_SHAPES.proportion;
74
+ successes: number;
75
+ trials: number;
76
+ } | {
77
+ shape: typeof APP_MODEL_INPUT_SHAPES.samples;
78
+ samples: number[];
79
+ } | {
80
+ shape: typeof APP_MODEL_INPUT_SHAPES.bound;
81
+ source: AppModelInputSource;
82
+ };
83
+ type AppModelQuantityBase = {
84
+ /** A letter or underscore, then letters, digits or underscores; formulas refer to it. */
85
+ name: string;
86
+ /** Markdown. */
87
+ description?: string;
88
+ unit?: string;
89
+ };
90
+ /** One cell of a version. A formula is stored without a leading `=`. */
91
+ export type AppModelQuantity = (AppModelQuantityBase & {
92
+ kind: typeof APP_MODEL_QUANTITY_KINDS.input;
93
+ input: AppModelInput;
94
+ }) | (AppModelQuantityBase & {
95
+ kind: typeof APP_MODEL_QUANTITY_KINDS.formula;
96
+ formula: string;
97
+ });
98
+ export type AppModelVersion = {
99
+ versionUuid: string;
100
+ versionNumber: number;
101
+ note: string;
102
+ quantities: AppModelQuantity[];
103
+ createdAt: string;
104
+ };
105
+ /** The model an `uncertainty_model` item wraps, with its latest version when one was saved. */
106
+ export type AppUncertaintyModel = {
107
+ modelUuid: string;
108
+ name: string;
109
+ description: string;
110
+ /** 0 until a version is saved. */
111
+ latestVersion: number;
112
+ createdAt: string;
113
+ updatedAt: string;
114
+ version?: AppModelVersion;
115
+ queuedRunFailure?: AppModelQueuedRunFailure;
116
+ };
117
+ /** The model of a new item; its quantities, when given, are saved as version 1. */
118
+ export type AppModelCreate = {
119
+ name: string;
120
+ description?: string;
121
+ quantities?: AppModelQuantity[];
122
+ note?: string;
123
+ };
124
+ /** A new immutable version: the whole quantity list, 1 to 100 quantities. */
125
+ export type AppModelVersionCreateRequest = {
126
+ quantities: AppModelQuantity[];
127
+ /** Counter link tokens authorizing newly linked projects. Tokens are excluded from the saved graph. */
128
+ counterLinks?: string[];
129
+ note?: string;
130
+ };
131
+ /** Copies one version into a new item. 0 or absent copies the latest; no name gives "Copy of …". */
132
+ export type AppModelCopyRequest = {
133
+ name?: string;
134
+ versionNumber?: number;
135
+ };
136
+ /** Acting is worth valuePerUnit × (output − threshold); holding is worth zero. */
137
+ export type AppModelDecision = {
138
+ output: string;
139
+ threshold: number;
140
+ /** Above 0. */
141
+ valuePerUnit: number;
142
+ /** What a measurement must be worth before it is suggested. */
143
+ minimumWorthwhile?: number;
144
+ };
145
+ /** One run. 0 or absent runs the latest version with the default sample count (max 10000). */
146
+ export type AppModelRunRequest = {
147
+ versionNumber?: number;
148
+ seed: number;
149
+ sampleCount?: number;
150
+ /** The quantity inputs are ranked against; with a decision it defaults to the decision output. */
151
+ sensitivityOutput?: string;
152
+ decision?: AppModelDecision;
153
+ };
154
+ /** A calculator run: some inputs set to other values, only the named outputs back. Never stored. */
155
+ export type AppModelCalculateRequest = {
156
+ /** 0 or absent: the latest version. */
157
+ versionNumber?: number;
158
+ seed?: number;
159
+ sampleCount?: number;
160
+ inputs?: {
161
+ name: string;
162
+ input: AppModelInput;
163
+ }[];
164
+ outputs: string[];
165
+ };
166
+ export type AppModelCalculateResult = {
167
+ modelUuid: string;
168
+ versionNumber: number;
169
+ seed: number;
170
+ sampleCount: number;
171
+ quantities: AppModelQuantityResult[] | null;
172
+ };
173
+ /** Why the run a live input's source change queued has not landed; it stays until one succeeds. */
174
+ export type AppModelQueuedRunFailure = {
175
+ error: string;
176
+ failedAt: string;
177
+ attempts: number;
178
+ };
179
+ export type AppModelPercentiles = {
180
+ p5: number;
181
+ p25: number;
182
+ p50: number;
183
+ p75: number;
184
+ p95: number;
185
+ };
186
+ /** Sample counts in equal-width bins from min to max. */
187
+ export type AppModelHistogram = {
188
+ min: number;
189
+ max: number;
190
+ counts: number[] | null;
191
+ };
192
+ export type AppModelQuantitySummary = {
193
+ mean: number;
194
+ stdDev: number;
195
+ percentiles: AppModelPercentiles;
196
+ histogram: AppModelHistogram;
197
+ };
198
+ /** `code` is an uncertainty error code such as `model_input_source_missing` or `model_upstream_failed`. */
199
+ export type AppModelQuantityError = {
200
+ code: string;
201
+ detail: string;
202
+ };
203
+ /** One quantity's summary, or the reason it failed. */
204
+ export type AppModelQuantityResult = {
205
+ name: string;
206
+ summary?: AppModelQuantitySummary;
207
+ error?: AppModelQuantityError;
208
+ };
209
+ export type AppModelScatterPoint = {
210
+ input: number;
211
+ output: number;
212
+ };
213
+ /** Spearman rank correlation with the output; only the strongest ten inputs keep a scatter sample. */
214
+ export type AppModelInputSensitivity = {
215
+ name: string;
216
+ rankCorrelation: number;
217
+ share: number;
218
+ scatter?: AppModelScatterPoint[] | null;
219
+ };
220
+ export type AppModelSensitivity = {
221
+ output: string;
222
+ inputs: AppModelInputSensitivity[] | null;
223
+ };
224
+ export type AppModelInputInformation = {
225
+ name: string;
226
+ expectedValueOfPerfectInformation: number;
227
+ };
228
+ /** "What to measure next" for the run's decision. */
229
+ export type AppModelInformation = {
230
+ recommended: "act" | "hold";
231
+ actProbability: number;
232
+ expectedValueOfPerfectInformation: number;
233
+ /** Empty when no measurement is worth its minimum. */
234
+ suggestedNextMeasurement?: string;
235
+ inputs: AppModelInputInformation[] | null;
236
+ };
237
+ export type AppModelBoundInput = {
238
+ quantity: string;
239
+ source: AppModelInputSource;
240
+ state: AppModelBoundState;
241
+ value?: number;
242
+ forecastRunUuid?: string;
243
+ forecastGeneratedAt?: string;
244
+ detail?: string;
245
+ };
246
+ /** One stored run with its results, in model order. */
247
+ export type AppModelRun = {
248
+ runUuid: string;
249
+ modelUuid: string;
250
+ versionNumber: number;
251
+ trigger: AppModelRunTrigger;
252
+ sourceForecastRunUuid?: string;
253
+ seed: number;
254
+ sampleCount: number;
255
+ createdAt: string;
256
+ sensitivityOutput?: string;
257
+ decision?: AppModelDecision;
258
+ quantities: AppModelQuantityResult[] | null;
259
+ sensitivity?: AppModelSensitivity;
260
+ information?: AppModelInformation;
261
+ boundInputs: AppModelBoundInput[] | null;
262
+ /** On the latest-run read only: a queued run failed after this run was made. */
263
+ queuedRunFailure?: AppModelQueuedRunFailure;
264
+ };
265
+ /**
266
+ * One row per quantity of a run: mean, spread and percentiles, or the reason it failed. Units come
267
+ * from the model's quantities when given. Text cells are quoted and cells a spreadsheet would read
268
+ * as a formula are prefixed with `'`.
269
+ */
270
+ export declare function modelRunSummaryCsv(run: Pick<AppModelRun, "quantities">, quantities?: AppModelQuantity[]): string;
271
+ export {};