primitive-admin 1.1.0-alpha.4 → 1.1.0-alpha.40

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 (216) hide show
  1. package/README.md +325 -31
  2. package/assets/skill/skills/primitive-platform/SKILL.md +281 -0
  3. package/dist/bin/primitive.d.ts +2 -0
  4. package/dist/bin/primitive.js +266 -16
  5. package/dist/bin/primitive.js.map +1 -1
  6. package/dist/src/commands/admins.d.ts +2 -0
  7. package/dist/src/commands/admins.js +123 -18
  8. package/dist/src/commands/admins.js.map +1 -1
  9. package/dist/src/commands/analytics.d.ts +2 -0
  10. package/dist/src/commands/analytics.js +464 -55
  11. package/dist/src/commands/analytics.js.map +1 -1
  12. package/dist/src/commands/apps.d.ts +2 -0
  13. package/dist/src/commands/apps.js +55 -13
  14. package/dist/src/commands/apps.js.map +1 -1
  15. package/dist/src/commands/auth.d.ts +2 -0
  16. package/dist/src/commands/auth.js +177 -7
  17. package/dist/src/commands/auth.js.map +1 -1
  18. package/dist/src/commands/blob-buckets.d.ts +2 -0
  19. package/dist/src/commands/blob-buckets.js +422 -0
  20. package/dist/src/commands/blob-buckets.js.map +1 -0
  21. package/dist/src/commands/catalog.d.ts +2 -0
  22. package/dist/src/commands/catalog.js +34 -35
  23. package/dist/src/commands/catalog.js.map +1 -1
  24. package/dist/src/commands/collection-type-configs.d.ts +2 -0
  25. package/dist/src/commands/collection-type-configs.js +178 -0
  26. package/dist/src/commands/collection-type-configs.js.map +1 -0
  27. package/dist/src/commands/collections.d.ts +2 -0
  28. package/dist/src/commands/collections.js +515 -0
  29. package/dist/src/commands/collections.js.map +1 -0
  30. package/dist/src/commands/comparisons.d.ts +2 -0
  31. package/dist/src/commands/comparisons.js +6 -6
  32. package/dist/src/commands/comparisons.js.map +1 -1
  33. package/dist/src/commands/cron-triggers.d.ts +2 -0
  34. package/dist/src/commands/cron-triggers.js +357 -0
  35. package/dist/src/commands/cron-triggers.js.map +1 -0
  36. package/dist/src/commands/database-types.d.ts +2 -0
  37. package/dist/src/commands/database-types.js +471 -0
  38. package/dist/src/commands/database-types.js.map +1 -0
  39. package/dist/src/commands/databases.d.ts +2 -0
  40. package/dist/src/commands/databases.js +1462 -83
  41. package/dist/src/commands/databases.js.map +1 -1
  42. package/dist/src/commands/documents.d.ts +2 -0
  43. package/dist/src/commands/documents.js +518 -11
  44. package/dist/src/commands/documents.js.map +1 -1
  45. package/dist/src/commands/email-templates.d.ts +2 -0
  46. package/dist/src/commands/email-templates.js +281 -0
  47. package/dist/src/commands/email-templates.js.map +1 -0
  48. package/dist/src/commands/env.d.ts +12 -0
  49. package/dist/src/commands/env.js +260 -0
  50. package/dist/src/commands/env.js.map +1 -0
  51. package/dist/src/commands/group-type-configs.d.ts +2 -0
  52. package/dist/src/commands/group-type-configs.js +181 -0
  53. package/dist/src/commands/group-type-configs.js.map +1 -0
  54. package/dist/src/commands/groups.d.ts +2 -0
  55. package/dist/src/commands/groups.js +45 -43
  56. package/dist/src/commands/groups.js.map +1 -1
  57. package/dist/src/commands/guides.d.ts +159 -0
  58. package/dist/src/commands/guides.js +449 -35
  59. package/dist/src/commands/guides.js.map +1 -1
  60. package/dist/src/commands/init.d.ts +17 -0
  61. package/dist/src/commands/init.js +811 -201
  62. package/dist/src/commands/init.js.map +1 -1
  63. package/dist/src/commands/integrations.d.ts +2 -0
  64. package/dist/src/commands/integrations.js +533 -46
  65. package/dist/src/commands/integrations.js.map +1 -1
  66. package/dist/src/commands/llm.d.ts +2 -0
  67. package/dist/src/commands/llm.js +4 -2
  68. package/dist/src/commands/llm.js.map +1 -1
  69. package/dist/src/commands/prompts.d.ts +2 -0
  70. package/dist/src/commands/prompts.js +50 -52
  71. package/dist/src/commands/prompts.js.map +1 -1
  72. package/dist/src/commands/rule-sets.d.ts +3 -0
  73. package/dist/src/commands/rule-sets.js +388 -0
  74. package/dist/src/commands/rule-sets.js.map +1 -0
  75. package/dist/src/commands/scripts.d.ts +2 -0
  76. package/dist/src/commands/scripts.js +667 -0
  77. package/dist/src/commands/scripts.js.map +1 -0
  78. package/dist/src/commands/secrets.d.ts +2 -0
  79. package/dist/src/commands/secrets.js +108 -0
  80. package/dist/src/commands/secrets.js.map +1 -0
  81. package/dist/src/commands/skill.d.ts +2 -0
  82. package/dist/src/commands/skill.js +29 -0
  83. package/dist/src/commands/skill.js.map +1 -0
  84. package/dist/src/commands/sync.d.ts +174 -0
  85. package/dist/src/commands/sync.js +4392 -235
  86. package/dist/src/commands/sync.js.map +1 -1
  87. package/dist/src/commands/tokens.d.ts +2 -0
  88. package/dist/src/commands/tokens.js +122 -19
  89. package/dist/src/commands/tokens.js.map +1 -1
  90. package/dist/src/commands/users.d.ts +2 -0
  91. package/dist/src/commands/users.js +440 -22
  92. package/dist/src/commands/users.js.map +1 -1
  93. package/dist/src/commands/waitlist.d.ts +2 -0
  94. package/dist/src/commands/waitlist.js +10 -10
  95. package/dist/src/commands/waitlist.js.map +1 -1
  96. package/dist/src/commands/webhooks.d.ts +2 -0
  97. package/dist/src/commands/webhooks.js +391 -0
  98. package/dist/src/commands/webhooks.js.map +1 -0
  99. package/dist/src/commands/workflows.d.ts +49 -0
  100. package/dist/src/commands/workflows.js +1009 -123
  101. package/dist/src/commands/workflows.js.map +1 -1
  102. package/dist/src/lib/api-client.d.ts +1272 -0
  103. package/dist/src/lib/api-client.js +1115 -83
  104. package/dist/src/lib/api-client.js.map +1 -1
  105. package/dist/src/lib/auth-flow.d.ts +8 -0
  106. package/dist/src/lib/block-layout.d.ts +160 -0
  107. package/dist/src/lib/block-layout.js +451 -0
  108. package/dist/src/lib/block-layout.js.map +1 -0
  109. package/dist/src/lib/cli-manifest.d.ts +60 -0
  110. package/dist/src/lib/cli-manifest.js +70 -0
  111. package/dist/src/lib/cli-manifest.js.map +1 -0
  112. package/dist/src/lib/config.d.ts +53 -0
  113. package/dist/src/lib/config.js +92 -53
  114. package/dist/src/lib/config.js.map +1 -1
  115. package/dist/src/lib/confirm-prompt.d.ts +83 -0
  116. package/dist/src/lib/confirm-prompt.js +110 -0
  117. package/dist/src/lib/confirm-prompt.js.map +1 -0
  118. package/dist/src/lib/constants.d.ts +2 -0
  119. package/dist/src/lib/constants.js +3 -0
  120. package/dist/src/lib/constants.js.map +1 -0
  121. package/dist/src/lib/crash-handlers.d.ts +20 -0
  122. package/dist/src/lib/crash-handlers.js +49 -0
  123. package/dist/src/lib/crash-handlers.js.map +1 -0
  124. package/dist/src/lib/credentials-store.d.ts +79 -0
  125. package/dist/src/lib/credentials-store.js +307 -0
  126. package/dist/src/lib/credentials-store.js.map +1 -0
  127. package/dist/src/lib/csv.d.ts +48 -0
  128. package/dist/src/lib/csv.js +177 -0
  129. package/dist/src/lib/csv.js.map +1 -0
  130. package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
  131. package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
  132. package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
  133. package/dist/src/lib/db-codegen/dbGenerator.d.ts +111 -0
  134. package/dist/src/lib/db-codegen/dbGenerator.js +371 -0
  135. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
  136. package/dist/src/lib/db-codegen/dbNaming.d.ts +45 -0
  137. package/dist/src/lib/db-codegen/dbNaming.js +104 -0
  138. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
  139. package/dist/src/lib/db-codegen/dbTemplates.d.ts +97 -0
  140. package/dist/src/lib/db-codegen/dbTemplates.js +159 -0
  141. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
  142. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +78 -0
  143. package/dist/src/lib/db-codegen/dbTsTypes.js +112 -0
  144. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
  145. package/dist/src/lib/env-resolver.d.ts +62 -0
  146. package/dist/src/lib/env-resolver.js +121 -0
  147. package/dist/src/lib/env-resolver.js.map +1 -0
  148. package/dist/src/lib/fetch.d.ts +5 -0
  149. package/dist/src/lib/generated-allowlist.d.ts +28 -0
  150. package/dist/src/lib/generated-allowlist.js +213 -0
  151. package/dist/src/lib/generated-allowlist.js.map +1 -0
  152. package/dist/src/lib/init-config.d.ts +59 -0
  153. package/dist/src/lib/init-config.js +113 -0
  154. package/dist/src/lib/init-config.js.map +1 -0
  155. package/dist/src/lib/migration-nag.d.ts +49 -0
  156. package/dist/src/lib/migration-nag.js +163 -0
  157. package/dist/src/lib/migration-nag.js.map +1 -0
  158. package/dist/src/lib/output.d.ts +86 -0
  159. package/dist/src/lib/output.js +150 -8
  160. package/dist/src/lib/output.js.map +1 -1
  161. package/dist/src/lib/paginate.d.ts +33 -0
  162. package/dist/src/lib/paginate.js +42 -0
  163. package/dist/src/lib/paginate.js.map +1 -0
  164. package/dist/src/lib/project-config.d.ts +97 -0
  165. package/dist/src/lib/project-config.js +209 -0
  166. package/dist/src/lib/project-config.js.map +1 -0
  167. package/dist/src/lib/query-operators.d.ts +43 -0
  168. package/dist/src/lib/query-operators.js +80 -0
  169. package/dist/src/lib/query-operators.js.map +1 -0
  170. package/dist/src/lib/refresh-admin-credentials.d.ts +65 -0
  171. package/dist/src/lib/refresh-admin-credentials.js +103 -0
  172. package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
  173. package/dist/src/lib/resolve-platform.d.ts +45 -0
  174. package/dist/src/lib/resolve-platform.js +43 -0
  175. package/dist/src/lib/resolve-platform.js.map +1 -0
  176. package/dist/src/lib/skill-installer.d.ts +23 -0
  177. package/dist/src/lib/skill-installer.js +135 -0
  178. package/dist/src/lib/skill-installer.js.map +1 -0
  179. package/dist/src/lib/snapshots.d.ts +99 -0
  180. package/dist/src/lib/snapshots.js +357 -0
  181. package/dist/src/lib/snapshots.js.map +1 -0
  182. package/dist/src/lib/sync-paths.d.ts +72 -0
  183. package/dist/src/lib/sync-paths.js +130 -0
  184. package/dist/src/lib/sync-paths.js.map +1 -0
  185. package/dist/src/lib/template.d.ts +97 -0
  186. package/dist/src/lib/template.js +336 -62
  187. package/dist/src/lib/template.js.map +1 -1
  188. package/dist/src/lib/token-inject.d.ts +56 -0
  189. package/dist/src/lib/token-inject.js +204 -0
  190. package/dist/src/lib/token-inject.js.map +1 -0
  191. package/dist/src/lib/toml-database-config.d.ts +152 -0
  192. package/dist/src/lib/toml-database-config.js +600 -0
  193. package/dist/src/lib/toml-database-config.js.map +1 -0
  194. package/dist/src/lib/toml-metadata-config.d.ts +108 -0
  195. package/dist/src/lib/toml-metadata-config.js +371 -0
  196. package/dist/src/lib/toml-metadata-config.js.map +1 -0
  197. package/dist/src/lib/toml-params-validator.d.ts +129 -0
  198. package/dist/src/lib/toml-params-validator.js +298 -0
  199. package/dist/src/lib/toml-params-validator.js.map +1 -0
  200. package/dist/src/lib/version-check.d.ts +10 -0
  201. package/dist/src/lib/version-check.js +172 -0
  202. package/dist/src/lib/version-check.js.map +1 -0
  203. package/dist/src/lib/workflow-apply.d.ts +66 -0
  204. package/dist/src/lib/workflow-apply.js +117 -0
  205. package/dist/src/lib/workflow-apply.js.map +1 -0
  206. package/dist/src/lib/workflow-fragments.d.ts +41 -0
  207. package/dist/src/lib/workflow-fragments.js +121 -0
  208. package/dist/src/lib/workflow-fragments.js.map +1 -0
  209. package/dist/src/lib/workflow-toml-validator.d.ts +95 -0
  210. package/dist/src/lib/workflow-toml-validator.js +323 -0
  211. package/dist/src/lib/workflow-toml-validator.js.map +1 -0
  212. package/dist/src/types/index.d.ts +520 -0
  213. package/dist/src/validators.d.ts +64 -0
  214. package/dist/src/validators.js +63 -0
  215. package/dist/src/validators.js.map +1 -0
  216. package/package.json +18 -4
@@ -0,0 +1,1272 @@
1
+ export declare class ApiError extends Error {
2
+ statusCode: number;
3
+ code?: string;
4
+ /**
5
+ * Structured `details` payload from `corsErrorResponse`.
6
+ *
7
+ * The server's error envelope can emit `details` as either:
8
+ * - an array of validation issues (e.g. `[{ path, message }, ...]`) —
9
+ * this is what most legacy endpoints produce, and what sync.ts walks
10
+ * via `Array.isArray(err.details)` / `for (const detail of ...)`.
11
+ * - a record of structured offender fields (e.g. `{ refs, operations,
12
+ * opCount, line, column, ... }`) — emitted by the issue #666 schema
13
+ * gate and consumed by the typed exception subclasses below.
14
+ *
15
+ * Callers must narrow before use: `Array.isArray(err.details)` for the
16
+ * legacy shape, otherwise treat as `Record<string, any>`.
17
+ */
18
+ details?: unknown[] | Record<string, any>;
19
+ constructor(message: string, statusCode: number, code?: string, details?: unknown[] | Record<string, any>);
20
+ }
21
+ export declare class ConflictError extends ApiError {
22
+ serverModifiedAt: string;
23
+ expectedModifiedAt: string;
24
+ constructor(message: string, serverModifiedAt: string, expectedModifiedAt: string, details?: Record<string, any>);
25
+ }
26
+ /**
27
+ * Parsed shape of a non-OK HTTP response body.
28
+ *
29
+ * The server's standard error envelope (corsErrorResponse, `src/utils.ts:348`)
30
+ * writes the message to `error`. A handful of bespoke endpoints (ConflictError,
31
+ * integrations proxy) use `message`. This helper reads both fields so all CLI
32
+ * call sites surface the real server message instead of `HTTP <status>`.
33
+ *
34
+ * `htmlNotFound` is set when the body looks like an HTML 404 page (typically
35
+ * served when an API path is wrong); callers can use it to throw a clearer
36
+ * "API endpoint not found" message regardless of the original status code.
37
+ *
38
+ * `details` can be either an array (legacy validation-issue list) or a
39
+ * structured record (issue #666 schema gate); the schema-feature errors
40
+ * below need the record shape, while the legacy `for (const detail of ...)`
41
+ * walkers in sync.ts assume the array shape.
42
+ */
43
+ export interface ParsedErrorResponse {
44
+ message: string;
45
+ code?: string;
46
+ details?: unknown[] | Record<string, any>;
47
+ /** True when the response body is an HTML error page (e.g. wrong API path). */
48
+ htmlNotFound?: boolean;
49
+ /** Raw parsed JSON envelope (or `undefined` for non-JSON bodies). */
50
+ raw?: any;
51
+ }
52
+ /**
53
+ * Extract a human-readable error message + structured fields from a non-OK
54
+ * HTTP response body. Single source of truth used by every error-handler call
55
+ * site in this file (see issue #684).
56
+ */
57
+ export declare function parseErrorResponse(response: {
58
+ status: number;
59
+ }, text: string, path?: string): ParsedErrorResponse;
60
+ /**
61
+ * Typed exception classes for the database-schema feature (issue #666).
62
+ * Each maps 1:1 to a server `code` value emitted from the op-edit or
63
+ * schema-edit gate. They all extend ApiError so existing catch-all paths
64
+ * continue to work; specialized catch blocks can branch on `instanceof`.
65
+ *
66
+ * Per round-2 addendum A1, `details` is always preserved so callers can
67
+ * extract structured offender lists (refs[], operations[], etc.).
68
+ */
69
+ export declare class SchemaRequiredError extends ApiError {
70
+ constructor(message: string, details?: Record<string, any>);
71
+ }
72
+ export declare class OperationRefError extends ApiError {
73
+ constructor(message: string, details?: Record<string, any>);
74
+ get refs(): Array<{
75
+ ref: string;
76
+ location: string;
77
+ }>;
78
+ }
79
+ export declare class SchemaBreaksOpsError extends ApiError {
80
+ constructor(message: string, details?: Record<string, any>);
81
+ get operations(): Array<{
82
+ operation: string;
83
+ refs: Array<{
84
+ ref: string;
85
+ location: string;
86
+ }>;
87
+ }>;
88
+ }
89
+ export declare class SchemaHasUncheckableOpsError extends ApiError {
90
+ constructor(message: string, details?: Record<string, any>);
91
+ get operations(): Array<{
92
+ operation: string;
93
+ locations: string[];
94
+ }>;
95
+ }
96
+ export declare class TomlParseError extends ApiError {
97
+ constructor(message: string, details?: Record<string, any>);
98
+ get line(): number | undefined;
99
+ get column(): number | undefined;
100
+ }
101
+ export declare class OpsExistError extends ApiError {
102
+ constructor(message: string, details?: Record<string, any>);
103
+ get opCount(): number;
104
+ }
105
+ interface EmailTemplateSummary {
106
+ emailType: string;
107
+ label: string;
108
+ description: string;
109
+ hasOverride: boolean;
110
+ modifiedAt: string | null;
111
+ }
112
+ interface EmailTemplateDetail {
113
+ emailType: string;
114
+ label: string;
115
+ description: string;
116
+ hasOverride: boolean;
117
+ override: {
118
+ templateId: string;
119
+ subject: string;
120
+ htmlBody: string;
121
+ textBody: string;
122
+ createdAt: string;
123
+ modifiedAt: string;
124
+ } | null;
125
+ default: {
126
+ subject: string;
127
+ htmlBody: string;
128
+ textBody: string;
129
+ };
130
+ variables: {
131
+ name: string;
132
+ required: boolean;
133
+ description: string;
134
+ }[];
135
+ }
136
+ interface EmailTemplateUpsertResult {
137
+ emailType: string;
138
+ templateId: string;
139
+ subject: string;
140
+ htmlBody: string;
141
+ textBody: string;
142
+ createdAt: string;
143
+ modifiedAt: string;
144
+ warnings: string[];
145
+ }
146
+ interface AnalyticsTiming {
147
+ total_ms: number;
148
+ wae_queries: number[];
149
+ }
150
+ interface AnalyticsMetricResponse {
151
+ value: number;
152
+ previous: number;
153
+ deltaPct: number;
154
+ _timing: AnalyticsTiming;
155
+ }
156
+ interface AnalyticsGrowthResponse {
157
+ window_days: number;
158
+ retained_users: number;
159
+ new_users: number;
160
+ reactivated_users: number;
161
+ churned_users: number;
162
+ current_active: number;
163
+ previous_active: number;
164
+ deltaPct: number;
165
+ _timing: AnalyticsTiming;
166
+ }
167
+ interface AnalyticsDailyActivePoint {
168
+ day_ts: number;
169
+ day_label: string;
170
+ active_users: number;
171
+ }
172
+ interface AnalyticsDailyActiveResponse {
173
+ window_days: number;
174
+ rows: AnalyticsDailyActivePoint[];
175
+ _timing: AnalyticsTiming;
176
+ }
177
+ interface AnalyticsCohortRow {
178
+ signup_week: number;
179
+ signup_week_label: string;
180
+ cohort_size: number;
181
+ retention: (number | null)[];
182
+ }
183
+ interface AnalyticsCohortResponse {
184
+ weeks: number[];
185
+ rows: AnalyticsCohortRow[];
186
+ averages: (number | null)[];
187
+ _timing: AnalyticsTiming;
188
+ }
189
+ interface AnalyticsUserSummary {
190
+ userUlid: string;
191
+ email: string | null;
192
+ name: string | null;
193
+ firstSeen: string;
194
+ lastSeen: string;
195
+ eventCount: number;
196
+ }
197
+ interface AnalyticsTopUsersResponse {
198
+ windowDays: number;
199
+ limit: number;
200
+ results: AnalyticsUserSummary[];
201
+ _timing: AnalyticsTiming;
202
+ }
203
+ interface AnalyticsUserSearchResponse {
204
+ query: string;
205
+ limit: number;
206
+ results: AnalyticsUserSummary[];
207
+ }
208
+ interface AnalyticsUserDetailResponse {
209
+ user: {
210
+ user_ulid: string;
211
+ email: string | null;
212
+ name: string | null;
213
+ };
214
+ stats: {
215
+ first_seen: string | null;
216
+ last_active: string | null;
217
+ total_events: number;
218
+ days_active: number;
219
+ };
220
+ events_by_action: Array<{
221
+ action: string;
222
+ event_count: number;
223
+ last_occurred: string;
224
+ }>;
225
+ events_by_feature: Array<{
226
+ feature: string;
227
+ event_count: number;
228
+ pct: number;
229
+ }>;
230
+ _timing: AnalyticsTiming;
231
+ }
232
+ interface AnalyticsUserSnapshotResponse {
233
+ snapshot: {
234
+ timestamp: string;
235
+ values: unknown;
236
+ } | null;
237
+ _timing: AnalyticsTiming;
238
+ }
239
+ interface AnalyticsEventRow {
240
+ timestamp: string;
241
+ user_ulid: string;
242
+ action: string;
243
+ feature: string;
244
+ route: string;
245
+ country: string;
246
+ }
247
+ interface AnalyticsEventsResponse {
248
+ page: number;
249
+ page_size: number;
250
+ total_rows: number;
251
+ rows: AnalyticsEventRow[];
252
+ _timing: AnalyticsTiming;
253
+ }
254
+ interface AnalyticsGroupedRow {
255
+ group_value: string;
256
+ raw_group_value: string;
257
+ events: number;
258
+ unique_users: number;
259
+ }
260
+ interface AnalyticsEventsGroupedResponse {
261
+ group_by: string;
262
+ rows: AnalyticsGroupedRow[];
263
+ _timing: AnalyticsTiming;
264
+ }
265
+ interface AnalyticsIntegrationMetric {
266
+ integrationKey: string;
267
+ invocations: number;
268
+ errorRate: number;
269
+ medianDurationMs: number;
270
+ p95DurationMs: number;
271
+ }
272
+ interface AnalyticsIntegrationMetricsResponse {
273
+ windowDays: number;
274
+ integrations: AnalyticsIntegrationMetric[];
275
+ _timing: AnalyticsTiming;
276
+ }
277
+ interface WorkflowAnalyticsSummary {
278
+ workflowKey: string;
279
+ runs: number;
280
+ successRate: number;
281
+ medianDurationMs: number;
282
+ p95: number;
283
+ totalTokens: number;
284
+ }
285
+ interface TopWorkflowsResponse {
286
+ windowDays: number;
287
+ limit: number;
288
+ workflows: WorkflowAnalyticsSummary[];
289
+ _timing: AnalyticsTiming;
290
+ }
291
+ interface PromptAnalyticsSummary {
292
+ promptKey: string;
293
+ executions: number;
294
+ medianDurationMs: number;
295
+ p95DurationMs: number;
296
+ totalTokens: number;
297
+ }
298
+ interface TopPromptsResponse {
299
+ windowDays: number;
300
+ limit: number;
301
+ prompts: PromptAnalyticsSummary[];
302
+ _timing: AnalyticsTiming;
303
+ }
304
+ export declare class ApiClient {
305
+ private credentials;
306
+ constructor();
307
+ private ensureAuthenticated;
308
+ private refreshToken;
309
+ request<T = any>(path: string, options?: RequestInit): Promise<T>;
310
+ get<T = any>(path: string, params?: Record<string, any>): Promise<T>;
311
+ post<T = any>(path: string, body?: any): Promise<T>;
312
+ put<T = any>(path: string, body?: any): Promise<T>;
313
+ patch<T = any>(path: string, body?: any): Promise<T>;
314
+ delete<T = any>(path: string): Promise<T>;
315
+ listApps(): Promise<{
316
+ apps: Array<{
317
+ id: string;
318
+ name: string;
319
+ role?: string;
320
+ }>;
321
+ }>;
322
+ createApp(data: {
323
+ name: string;
324
+ initialAdminEmail?: string;
325
+ }): Promise<any>;
326
+ getApp(appId: string): Promise<{
327
+ id: string;
328
+ name: string;
329
+ }>;
330
+ deleteApp(appId: string): Promise<void>;
331
+ getAppSettings(appId: string): Promise<any>;
332
+ updateAppSettings(appId: string, settings: any): Promise<any>;
333
+ addUserByEmail(appId: string, data: {
334
+ email: string;
335
+ role?: string;
336
+ }): Promise<any>;
337
+ mintTestJwt(appId: string, userId: string, role?: string): Promise<any>;
338
+ rebuildUserSearchText(appId: string): Promise<{
339
+ count: number;
340
+ }>;
341
+ listUsers(appId: string, params?: {
342
+ name?: string;
343
+ email?: string;
344
+ userId?: string;
345
+ limit?: number;
346
+ cursor?: string;
347
+ }): Promise<{
348
+ items: any[];
349
+ nextCursor?: string | null;
350
+ }>;
351
+ removeUser(appId: string, userId: string): Promise<void>;
352
+ updateUserRole(appId: string, userId: string, role: "admin" | "member"): Promise<any>;
353
+ transferOwnership(appId: string, newOwnerEmail: string): Promise<void>;
354
+ transferAdminOwnership(appId: string, adminId: string): Promise<any>;
355
+ listAppAdmins(appId: string): Promise<any[]>;
356
+ addAppAdmin(appId: string, data: {
357
+ adminEmail: string;
358
+ role?: string;
359
+ sendEmail?: boolean;
360
+ loginUrl?: string;
361
+ }): Promise<any>;
362
+ removeAppAdmin(appId: string, adminId: string): Promise<any>;
363
+ listAppAdminInvitations(appId: string): Promise<any[]>;
364
+ deleteAppAdminInvitation(appId: string, invitationId: string): Promise<any>;
365
+ transferDocumentOwnership(appId: string, documentId: string, newOwnerId: string): Promise<void>;
366
+ listInvitations(appId: string, params?: {
367
+ limit?: number;
368
+ cursor?: string;
369
+ }): Promise<{
370
+ items: any[];
371
+ cursor?: string;
372
+ }>;
373
+ createInvitation(appId: string, data: {
374
+ email: string;
375
+ role: "admin" | "member";
376
+ expiresInDays?: number;
377
+ sendEmail?: boolean;
378
+ note?: string;
379
+ }): Promise<any>;
380
+ deleteInvitation(appId: string, invitationId: string): Promise<void>;
381
+ listWaitlist(appId: string): Promise<any[]>;
382
+ inviteWaitlistEntry(appId: string, waitlistId: string, options?: {
383
+ sendEmail?: boolean;
384
+ signupUrl?: string;
385
+ }): Promise<any>;
386
+ bulkInviteWaitlist(appId: string, payload: {
387
+ waitlistIds?: string[];
388
+ count?: number;
389
+ sendEmail?: boolean;
390
+ signupUrl?: string;
391
+ }): Promise<any>;
392
+ removeWaitlistEntry(appId: string, waitlistId: string): Promise<void>;
393
+ listDeferredGrants(appId: string, params?: {
394
+ type?: string;
395
+ email?: string;
396
+ limit?: number;
397
+ }): Promise<{
398
+ grants: any[];
399
+ nextCursor?: string | null;
400
+ }>;
401
+ revokeDeferredGrant(appId: string, deferredId: string, type: string): Promise<any>;
402
+ listIntegrations(appId: string, params?: {
403
+ status?: string;
404
+ cursor?: string;
405
+ limit?: number;
406
+ }): Promise<{
407
+ items: any[];
408
+ nextCursor?: string | null;
409
+ }>;
410
+ getIntegration(appId: string, integrationId: string): Promise<any>;
411
+ createIntegration(appId: string, payload: any): Promise<any>;
412
+ updateIntegration(appId: string, integrationId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
413
+ deleteIntegration(appId: string, integrationId: string, hard?: boolean): Promise<void>;
414
+ testIntegration(appId: string, integrationId: string, payload: any): Promise<any>;
415
+ listIntegrationLogs(appId: string, integrationId: string, params?: {
416
+ limit?: number;
417
+ status?: string;
418
+ from?: string;
419
+ to?: string;
420
+ source?: "user" | "admin" | "test" | "workflow";
421
+ }): Promise<any[]>;
422
+ listWorkflowRunIntegrationLogs(appId: string, runId: string, params?: {
423
+ limit?: number;
424
+ }): Promise<any[]>;
425
+ listIntegrationSecrets(appId: string, integrationId: string, params?: {
426
+ limit?: number;
427
+ }): Promise<any[]>;
428
+ addIntegrationSecret(appId: string, integrationId: string, payload: {
429
+ secretData: any;
430
+ secretSummary?: string;
431
+ }): Promise<any>;
432
+ archiveIntegrationSecret(appId: string, integrationId: string, secretId: string): Promise<any>;
433
+ listAppSecrets(appId: string): Promise<any[]>;
434
+ createAppSecret(appId: string, payload: {
435
+ key: string;
436
+ value: string;
437
+ summary?: string;
438
+ }): Promise<any>;
439
+ updateAppSecret(appId: string, secretId: string, payload: {
440
+ value?: string;
441
+ summary?: string;
442
+ }): Promise<any>;
443
+ upsertAppSecret(appId: string, key: string, payload: {
444
+ value: string;
445
+ summary?: string;
446
+ }): Promise<any>;
447
+ deleteAppSecret(appId: string, secretId: string): Promise<any>;
448
+ listWebhooks(appId: string, params?: {
449
+ status?: string;
450
+ cursor?: string;
451
+ limit?: number;
452
+ }): Promise<{
453
+ items: any[];
454
+ nextCursor?: string | null;
455
+ }>;
456
+ getWebhook(appId: string, webhookId: string): Promise<any>;
457
+ createWebhook(appId: string, payload: any): Promise<any>;
458
+ updateWebhook(appId: string, webhookId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
459
+ deleteWebhook(appId: string, webhookId: string): Promise<void>;
460
+ rotateWebhookSecret(appId: string, webhookId: string, payload: {
461
+ signingSecret: string;
462
+ }): Promise<any>;
463
+ listWebhookEvents(appId: string, webhookId: string, params?: {
464
+ limit?: number;
465
+ }): Promise<any>;
466
+ testWebhook(appId: string, webhookId: string, payload?: any): Promise<any>;
467
+ listCronTriggers(appId: string): Promise<{
468
+ items: any[];
469
+ }>;
470
+ getCronTrigger(appId: string, triggerId: string): Promise<any>;
471
+ createCronTrigger(appId: string, payload: any): Promise<any>;
472
+ updateCronTrigger(appId: string, triggerId: string, payload: any): Promise<any>;
473
+ deleteCronTrigger(appId: string, triggerId: string): Promise<any>;
474
+ pauseCronTrigger(appId: string, triggerId: string): Promise<any>;
475
+ resumeCronTrigger(appId: string, triggerId: string): Promise<any>;
476
+ testCronTrigger(appId: string, triggerId: string): Promise<any>;
477
+ listIterations(appId: string): Promise<{
478
+ items: any[];
479
+ }>;
480
+ getIteration(appId: string, iterationName: string): Promise<any>;
481
+ resetIteration(appId: string, iterationName: string): Promise<any>;
482
+ listPrompts(appId: string, params?: {
483
+ status?: string;
484
+ limit?: number;
485
+ cursor?: string;
486
+ }): Promise<{
487
+ items: any[];
488
+ nextCursor?: string | null;
489
+ }>;
490
+ getPrompt(appId: string, promptId: string): Promise<any>;
491
+ createPrompt(appId: string, payload: any): Promise<any>;
492
+ updatePrompt(appId: string, promptId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
493
+ deletePrompt(appId: string, promptId: string, hard?: boolean): Promise<void>;
494
+ executePrompt(appId: string, promptId: string, payload: {
495
+ variables: Record<string, any>;
496
+ modelOverride?: string;
497
+ configId?: string;
498
+ }): Promise<any>;
499
+ previewPrompt(appId: string, promptId: string, payload: {
500
+ variables: Record<string, any>;
501
+ configId?: string;
502
+ }): Promise<any>;
503
+ listPromptConfigs(appId: string, promptId: string): Promise<{
504
+ items: any[];
505
+ }>;
506
+ getPromptConfig(appId: string, promptId: string, configId: string): Promise<any>;
507
+ createPromptConfig(appId: string, promptId: string, payload: any): Promise<any>;
508
+ updatePromptConfig(appId: string, promptId: string, configId: string, payload: any): Promise<any>;
509
+ activatePromptConfig(appId: string, promptId: string, configId: string): Promise<any>;
510
+ duplicatePromptConfig(appId: string, promptId: string, configId: string, payload?: {
511
+ configName?: string;
512
+ description?: string;
513
+ }): Promise<any>;
514
+ listScripts(appId: string): Promise<{
515
+ items: any[];
516
+ }>;
517
+ getScript(appId: string, scriptId: string): Promise<any>;
518
+ /**
519
+ * List a script's versioned configs (the `ScriptConfig` rows). Each config
520
+ * is a distinct block version: `configId` is the stable version selector,
521
+ * `contentHash` is its content identity, and `status` reports whether it is
522
+ * `active`/`draft`/`archived`. The script header's `activeConfigId` names
523
+ * the live version. Used by `scripts configs list` and by the script test
524
+ * commands to run against a specific pinned version.
525
+ */
526
+ listScriptConfigs(appId: string, scriptId: string): Promise<{
527
+ items: any[];
528
+ }>;
529
+ createScript(appId: string, payload: {
530
+ name: string;
531
+ body: string;
532
+ description?: string;
533
+ }): Promise<any>;
534
+ /**
535
+ * Push a new body for an existing script by creating a new `ScriptConfig`
536
+ * and activating it (the prompt-model "edit → activate" flow). Referencing
537
+ * workflows pick up the new body on their next run with no fan-out. The
538
+ * config name is unique per script, so we mint a timestamped name.
539
+ */
540
+ pushScriptBody(appId: string, scriptId: string, body: string): Promise<any>;
541
+ deleteScript(appId: string, scriptId: string): Promise<void>;
542
+ getPromptSchema(appId: string, promptId: string): Promise<{
543
+ promptId: string;
544
+ promptKey: string;
545
+ displayName: string;
546
+ inputSchema: any;
547
+ inputVariables: string[];
548
+ outputSchema: any;
549
+ activeConfigId: string | null;
550
+ activeConfigName: string | null;
551
+ }>;
552
+ listTestCases(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string): Promise<{
553
+ items: any[];
554
+ }>;
555
+ getTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<any>;
556
+ createTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload: {
557
+ name: string;
558
+ inputVariables: Record<string, any>;
559
+ expectedOutputPattern?: string;
560
+ expectedOutputContains?: string[];
561
+ expectedJsonSubset?: Record<string, any>;
562
+ configId?: string;
563
+ evaluatorPromptId?: string;
564
+ evaluatorConfigId?: string;
565
+ }): Promise<any>;
566
+ updateTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, payload: {
567
+ name?: string;
568
+ inputVariables?: Record<string, any>;
569
+ expectedOutputPattern?: string | null;
570
+ expectedOutputContains?: string[] | null;
571
+ expectedJsonSubset?: Record<string, any> | null;
572
+ configId?: string | null;
573
+ evaluatorPromptId?: string | null;
574
+ evaluatorConfigId?: string | null;
575
+ }): Promise<any>;
576
+ deleteTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<void>;
577
+ listTestCaseAttachments(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<{
578
+ attachments: Array<{
579
+ filename: string;
580
+ contentType: string;
581
+ size: number;
582
+ r2Key: string;
583
+ }>;
584
+ }>;
585
+ uploadTestCaseAttachment(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, filename: string, data: Buffer, contentType: string): Promise<{
586
+ success: boolean;
587
+ attachment: {
588
+ filename: string;
589
+ contentType: string;
590
+ size: number;
591
+ r2Key: string;
592
+ };
593
+ }>;
594
+ downloadTestCaseAttachment(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, filename: string): Promise<{
595
+ data: Buffer;
596
+ contentType: string;
597
+ }>;
598
+ deleteTestCaseAttachment(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, filename: string): Promise<{
599
+ success: boolean;
600
+ deleted: boolean;
601
+ }>;
602
+ executeBlockTest(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload: {
603
+ variables?: Record<string, any>;
604
+ testCaseId?: string;
605
+ configId?: string;
606
+ comparisonGroup?: string;
607
+ }): Promise<any>;
608
+ runAllTestCases(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload?: {
609
+ overrideConfigId?: string;
610
+ comparisonGroup?: string;
611
+ testCaseIds?: string[];
612
+ }): Promise<any>;
613
+ listTestRuns(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, params?: {
614
+ limit?: number;
615
+ comparisonGroup?: string;
616
+ }): Promise<{
617
+ items: any[];
618
+ }>;
619
+ listWorkflows(appId: string, params?: {
620
+ status?: string;
621
+ limit?: number;
622
+ cursor?: string;
623
+ }): Promise<{
624
+ items: any[];
625
+ nextCursor?: string | null;
626
+ }>;
627
+ getWorkflow(appId: string, workflowId: string): Promise<any>;
628
+ createWorkflow(appId: string, payload: any): Promise<any>;
629
+ updateWorkflow(appId: string, workflowId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
630
+ deleteWorkflow(appId: string, workflowId: string): Promise<void>;
631
+ updateWorkflowDraft(appId: string, workflowId: string, payload: any): Promise<any>;
632
+ publishWorkflow(appId: string, workflowId: string): Promise<any>;
633
+ previewWorkflow(appId: string, workflowId: string, payload: {
634
+ rootInput?: object;
635
+ meta?: object;
636
+ configId?: string;
637
+ useDraft?: boolean;
638
+ preferActive?: boolean;
639
+ }): Promise<{
640
+ instanceId: string;
641
+ usingDraft?: boolean;
642
+ source?: "config" | "active" | "draft" | null;
643
+ configName?: string | null;
644
+ configId?: string | null;
645
+ warning?: string;
646
+ }>;
647
+ getPreviewStatus(appId: string, workflowId: string, instanceId: string): Promise<any>;
648
+ listWorkflowRuns(appId: string, workflowId: string, params?: {
649
+ status?: string;
650
+ limit?: number;
651
+ cursor?: string;
652
+ forward?: boolean;
653
+ }): Promise<{
654
+ items: any[];
655
+ cursor?: string | null;
656
+ }>;
657
+ getWorkflowRunStatus(appId: string, workflowId: string, runId: string): Promise<any>;
658
+ getWorkflowStepRuns(appId: string, workflowId: string, runId: string): Promise<{
659
+ items: any[];
660
+ }>;
661
+ getWorkflowAnalytics(appId: string, params?: {
662
+ windowDays?: number;
663
+ }): Promise<any>;
664
+ getTopWorkflows(appId: string, params?: {
665
+ windowDays?: number;
666
+ limit?: number;
667
+ }): Promise<any>;
668
+ listWorkflowConfigs(appId: string, workflowId: string): Promise<{
669
+ items: any[];
670
+ }>;
671
+ getWorkflowConfig(appId: string, workflowId: string, configId: string): Promise<any>;
672
+ createWorkflowConfig(appId: string, workflowId: string, payload: {
673
+ configName: string;
674
+ description?: string;
675
+ steps: any[];
676
+ }): Promise<any>;
677
+ updateWorkflowConfig(appId: string, workflowId: string, configId: string, payload: {
678
+ configName?: string;
679
+ description?: string;
680
+ steps?: any[];
681
+ status?: string;
682
+ }): Promise<any>;
683
+ archiveWorkflowConfig(appId: string, workflowId: string, configId: string): Promise<any>;
684
+ activateWorkflowConfig(appId: string, workflowId: string, configId: string): Promise<any>;
685
+ duplicateWorkflowConfig(appId: string, workflowId: string, configId: string, payload?: {
686
+ configName?: string;
687
+ }): Promise<any>;
688
+ getAnalyticsTopUsers(appId: string, params?: {
689
+ windowDays?: number;
690
+ limit?: number;
691
+ }): Promise<AnalyticsTopUsersResponse>;
692
+ getAnalyticsIntegrationMetrics(appId: string, params?: {
693
+ windowDays?: number;
694
+ }): Promise<AnalyticsIntegrationMetricsResponse>;
695
+ getAnalyticsOverviewDau(appId: string): Promise<AnalyticsMetricResponse>;
696
+ getAnalyticsOverviewWau(appId: string): Promise<AnalyticsMetricResponse>;
697
+ getAnalyticsOverviewMau(appId: string): Promise<AnalyticsMetricResponse>;
698
+ getAnalyticsOverviewGrowth(appId: string, params?: {
699
+ windowDays?: number;
700
+ }): Promise<AnalyticsGrowthResponse>;
701
+ getAnalyticsDailyActive(appId: string, params?: {
702
+ windowDays?: number;
703
+ }): Promise<AnalyticsDailyActiveResponse>;
704
+ getAnalyticsRollingActive(appId: string, params?: {
705
+ windowDays?: number;
706
+ }): Promise<AnalyticsDailyActiveResponse>;
707
+ getAnalyticsCohortRetention(appId: string): Promise<AnalyticsCohortResponse>;
708
+ getAnalyticsUserSearch(appId: string, params: {
709
+ q: string;
710
+ limit?: number;
711
+ }): Promise<AnalyticsUserSearchResponse>;
712
+ getAnalyticsUserDetail(appId: string, userUlid: string): Promise<AnalyticsUserDetailResponse>;
713
+ getAnalyticsUserSnapshot(appId: string, userUlid: string): Promise<AnalyticsUserSnapshotResponse>;
714
+ getAnalyticsEvents(appId: string, params?: {
715
+ windowDays?: number;
716
+ page?: number;
717
+ [key: string]: any;
718
+ }): Promise<AnalyticsEventsResponse>;
719
+ getAnalyticsEventsGrouped(appId: string, params?: {
720
+ groupBy?: string;
721
+ windowDays?: number;
722
+ [key: string]: any;
723
+ }): Promise<AnalyticsEventsGroupedResponse>;
724
+ getAnalyticsTopWorkflows(appId: string, params?: {
725
+ windowDays?: number;
726
+ limit?: number;
727
+ }): Promise<TopWorkflowsResponse>;
728
+ getAnalyticsTopPrompts(appId: string, params?: {
729
+ windowDays?: number;
730
+ limit?: number;
731
+ }): Promise<TopPromptsResponse>;
732
+ listAllAdmins(params?: {
733
+ limit?: number;
734
+ cursor?: string;
735
+ }): Promise<any>;
736
+ searchAdminByEmail(email: string): Promise<any>;
737
+ getAdminApps(email: string): Promise<any>;
738
+ updateAdminSettings(adminId: string, data: {
739
+ appCreationLimit?: number;
740
+ disabled?: boolean;
741
+ role?: "admin" | "super-admin";
742
+ }): Promise<any>;
743
+ reindexAdmin(adminId: string): Promise<void>;
744
+ listAllAdminInvitations(): Promise<any[]>;
745
+ createGlobalAdminInvitation(data: {
746
+ email: string;
747
+ appCreationLimit?: number;
748
+ expiresInDays?: number;
749
+ }): Promise<any>;
750
+ deleteGlobalAdminInvitation(invitationId: string): Promise<void>;
751
+ listPromptCatalog(params?: {
752
+ status?: string;
753
+ limit?: number;
754
+ cursor?: string;
755
+ }): Promise<any>;
756
+ getPromptCatalogItem(catalogId: string): Promise<any>;
757
+ createPromptCatalogItem(payload: any): Promise<any>;
758
+ updatePromptCatalogItem(catalogId: string, payload: any): Promise<any>;
759
+ deletePromptCatalogItem(catalogId: string): Promise<void>;
760
+ listIntegrationCatalog(params?: {
761
+ status?: string;
762
+ limit?: number;
763
+ cursor?: string;
764
+ }): Promise<any>;
765
+ getIntegrationCatalogItem(catalogId: string): Promise<any>;
766
+ createIntegrationCatalogItem(payload: any): Promise<any>;
767
+ updateIntegrationCatalogItem(catalogId: string, payload: any): Promise<any>;
768
+ deleteIntegrationCatalogItem(catalogId: string): Promise<void>;
769
+ listLlmModels(provider?: string): Promise<{
770
+ models: Array<{
771
+ id: string;
772
+ name: string;
773
+ context_length?: number;
774
+ pricing?: any;
775
+ }>;
776
+ defaultModel?: string;
777
+ cachedAt?: string;
778
+ }>;
779
+ generatePrompt(payload: {
780
+ description: string;
781
+ generateOutputSchema?: boolean;
782
+ }): Promise<any>;
783
+ generateEvaluator(payload: {
784
+ appId: string;
785
+ promptId: string;
786
+ }): Promise<any>;
787
+ generateWorkflowEvaluator(payload: {
788
+ appId: string;
789
+ workflowId: string;
790
+ }): Promise<any>;
791
+ startBatchTests(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload?: {
792
+ comparisonGroup?: string;
793
+ overrideConfigId?: string;
794
+ testCaseIds?: string[];
795
+ }): Promise<{
796
+ batchId: string;
797
+ totalTests: number;
798
+ instanceIds: string[];
799
+ errors?: any[];
800
+ }>;
801
+ getBatchTestStatus(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, batchId: string): Promise<{
802
+ status: string;
803
+ batchId: string;
804
+ completed: number;
805
+ passed: number;
806
+ failed: number;
807
+ results: Array<{
808
+ testCaseId: string;
809
+ runId: string;
810
+ status: string;
811
+ verificationPassed: boolean;
812
+ durationMs?: number;
813
+ verificationDetails?: any;
814
+ startedAt?: string;
815
+ endedAt?: string;
816
+ }>;
817
+ }>;
818
+ cancelBatchTests(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, batchId: string, instanceIds: string[]): Promise<{
819
+ batchId: string;
820
+ terminated: string[];
821
+ errors?: any[];
822
+ }>;
823
+ getComparisonGroup(appId: string, group: string): Promise<{
824
+ comparisonGroup: string;
825
+ runs: any[];
826
+ }>;
827
+ listEmailTemplates(appId: string): Promise<{
828
+ templates: EmailTemplateSummary[];
829
+ }>;
830
+ getEmailTemplate(appId: string, emailType: string): Promise<EmailTemplateDetail>;
831
+ upsertEmailTemplate(appId: string, emailType: string, payload: {
832
+ subject: string;
833
+ htmlBody: string;
834
+ textBody: string;
835
+ }): Promise<EmailTemplateUpsertResult>;
836
+ deleteEmailTemplate(appId: string, emailType: string): Promise<{
837
+ success: boolean;
838
+ }>;
839
+ testEmailTemplate(appId: string, emailType: string, payload?: {
840
+ subject: string;
841
+ htmlBody: string;
842
+ textBody: string;
843
+ }): Promise<{
844
+ success: boolean;
845
+ sentTo: string;
846
+ error?: string;
847
+ }>;
848
+ createToken(appId: string, data: {
849
+ name: string;
850
+ ttl?: string;
851
+ userId?: string;
852
+ }): Promise<{
853
+ token: string;
854
+ tokenId: string;
855
+ name: string;
856
+ expiresAt: string | null;
857
+ createdAt: string;
858
+ warning: string;
859
+ }>;
860
+ listTokens(appId: string, params?: {
861
+ userId?: string;
862
+ }): Promise<Array<{
863
+ tokenId: string;
864
+ name: string;
865
+ userId: string;
866
+ expiresAt: string | null;
867
+ lastUsedAt: string | null;
868
+ createdAt: string;
869
+ createdBy: string;
870
+ }>>;
871
+ getToken(appId: string, tokenId: string): Promise<{
872
+ tokenId: string;
873
+ name: string;
874
+ userId: string;
875
+ expiresAt: string | null;
876
+ lastUsedAt: string | null;
877
+ createdAt: string;
878
+ createdBy: string;
879
+ revokedAt: string | null;
880
+ }>;
881
+ revokeToken(appId: string, tokenId: string): Promise<{
882
+ success: boolean;
883
+ message: string;
884
+ }>;
885
+ listDatabases(appId: string): Promise<any[]>;
886
+ createDatabase(appId: string, data: {
887
+ title: string;
888
+ databaseType?: string;
889
+ metadata?: Record<string, any> | string;
890
+ }): Promise<any>;
891
+ getDatabase(appId: string, databaseId: string): Promise<any>;
892
+ updateDatabase(appId: string, databaseId: string, data: Record<string, any>): Promise<any>;
893
+ deleteDatabase(appId: string, databaseId: string): Promise<void>;
894
+ /**
895
+ * Read a database's CEL context dict.
896
+ *
897
+ * The HTTP path stays `/metadata` because the wire field name is still
898
+ * `metadata`; only the client/CLI-facing helper names were reframed.
899
+ */
900
+ getDatabaseCelContext(appId: string, databaseId: string): Promise<any>;
901
+ /** Update a database's CEL context dict (merge with existing). */
902
+ updateDatabaseCelContext(appId: string, databaseId: string, celContext: Record<string, any>): Promise<any>;
903
+ /** @deprecated Use {@link getDatabaseCelContext} instead. */
904
+ getDatabaseMetadata(appId: string, databaseId: string): Promise<any>;
905
+ /** @deprecated Use {@link updateDatabaseCelContext} instead. */
906
+ updateDatabaseMetadata(appId: string, databaseId: string, metadata: Record<string, any>): Promise<any>;
907
+ listDatabasePermissions(appId: string, databaseId: string): Promise<any[]>;
908
+ addDatabaseManager(appId: string, databaseId: string, userId: string): Promise<any>;
909
+ removeDatabaseManager(appId: string, databaseId: string, userId: string): Promise<any>;
910
+ /** @deprecated Use {@link addDatabaseManager} instead. */
911
+ grantDatabasePermission(appId: string, databaseId: string, data: {
912
+ userId: string;
913
+ permission: "manager";
914
+ }): Promise<any>;
915
+ /** @deprecated Use {@link removeDatabaseManager} instead. */
916
+ revokeDatabasePermission(appId: string, databaseId: string, userId: string): Promise<any>;
917
+ listDatabaseModels(appId: string, databaseId: string): Promise<any>;
918
+ describeDatabaseModel(appId: string, databaseId: string, modelName: string): Promise<any>;
919
+ queryDatabaseRecords(appId: string, databaseId: string, modelName: string, queryOptions?: {
920
+ filter?: Record<string, any>;
921
+ limit?: number;
922
+ cursor?: string;
923
+ }): Promise<any>;
924
+ listDatabaseOperations(appId: string, databaseId: string): Promise<any[]>;
925
+ executeDatabaseOperation(appId: string, databaseId: string, operationName: string, data?: {
926
+ params?: Record<string, any>;
927
+ limit?: number;
928
+ cursor?: string;
929
+ direction?: number;
930
+ }, token?: string, options?: {
931
+ timing?: boolean;
932
+ }): Promise<any>;
933
+ /**
934
+ * Execute a registered batch (bulk) database operation. Posts a chunk of
935
+ * items to the canonical `operations/:name/batch` endpoint (the same one the
936
+ * client library's `executeBatch` uses — NOT the deprecated `import-bulk`
937
+ * alias). Used by `databases import-csv`.
938
+ *
939
+ * @returns `{ imported, failed }` — DO-level write outcome counts. Per-item
940
+ * validation/access failures abort the whole chunk with a 4xx (thrown).
941
+ */
942
+ executeBatch(appId: string, databaseId: string, operationName: string, batch: Array<{
943
+ params: Record<string, any>;
944
+ }>): Promise<{
945
+ imported: number;
946
+ failed: number;
947
+ }>;
948
+ /**
949
+ * Make a request using a specific JWT token instead of the CLI's credentials.
950
+ * Used for executing operations as a different user.
951
+ */
952
+ requestWithToken<T = any>(path: string, token: string, options?: RequestInit): Promise<T>;
953
+ listDatabaseIndexes(appId: string, databaseId: string, modelName?: string): Promise<any>;
954
+ registerDatabaseIndex(appId: string, databaseId: string, data: {
955
+ modelName: string;
956
+ fieldName: string;
957
+ fieldType: string;
958
+ unique?: boolean;
959
+ }): Promise<any>;
960
+ dropDatabaseIndex(appId: string, databaseId: string, data: {
961
+ modelName: string;
962
+ fieldName: string;
963
+ }): Promise<any>;
964
+ /**
965
+ * Issue #974: back-provision an existing database instance's schema-declared
966
+ * unique indexes by reading its type schema and registering any declared-but-
967
+ * missing unique index. Idempotent.
968
+ */
969
+ reindexDatabaseFromSchema(appId: string, databaseId: string): Promise<{
970
+ ok: boolean;
971
+ registered: number;
972
+ skipped?: boolean;
973
+ reason?: string;
974
+ databaseType?: string;
975
+ }>;
976
+ listDatabaseTypeConfigs(appId: string): Promise<any[]>;
977
+ getDatabaseTypeConfig(appId: string, databaseType: string): Promise<any>;
978
+ createDatabaseTypeConfig(appId: string, data: {
979
+ databaseType: string;
980
+ ruleSetId?: string | null;
981
+ triggers?: Record<string, any> | null;
982
+ metadataAccess?: string | null;
983
+ defaultAccess?: string | null;
984
+ autoPopulatedFields?: Record<string, any> | null;
985
+ timestamps?: Record<string, any> | null;
986
+ schema?: string | null;
987
+ metadataManifest?: any;
988
+ }): Promise<any>;
989
+ updateDatabaseTypeConfig(appId: string, databaseType: string, data: {
990
+ ruleSetId?: string | null;
991
+ triggers?: Record<string, any> | null;
992
+ metadataAccess?: string | null;
993
+ defaultAccess?: string | null;
994
+ autoPopulatedFields?: Record<string, any> | null;
995
+ timestamps?: Record<string, any> | null;
996
+ schema?: string | null;
997
+ pendingOpDeletes?: string[];
998
+ finalOpNames?: string[];
999
+ metadataManifest?: any;
1000
+ }, expectedModifiedAt?: string, options?: {
1001
+ dryRun?: boolean;
1002
+ acceptWarnings?: boolean;
1003
+ }): Promise<any>;
1004
+ deleteDatabaseTypeConfig(appId: string, databaseType: string, options?: {
1005
+ force?: boolean;
1006
+ }): Promise<any>;
1007
+ /**
1008
+ * Issue #666 Phase 3: ask the server to scaffold a TOML schema from
1009
+ * existing ops + DO field introspection. Read-only — does NOT persist.
1010
+ */
1011
+ scaffoldDatabaseTypeSchema(appId: string, databaseType: string): Promise<{
1012
+ schema: string;
1013
+ }>;
1014
+ listDatabaseTypeOperations(appId: string, databaseType: string): Promise<any[]>;
1015
+ getDatabaseTypeOperation(appId: string, databaseType: string, name: string): Promise<any>;
1016
+ createDatabaseTypeOperation(appId: string, databaseType: string, data: {
1017
+ name: string;
1018
+ type: string;
1019
+ modelName: string;
1020
+ access?: string | null;
1021
+ definition: Record<string, any>;
1022
+ params?: Record<string, any> | null;
1023
+ }, options?: {
1024
+ dryRun?: boolean;
1025
+ schemaOverride?: string | null;
1026
+ defaultAccess?: string | null;
1027
+ }): Promise<any>;
1028
+ updateDatabaseTypeOperation(appId: string, databaseType: string, name: string, data: Record<string, any>, expectedModifiedAt?: string, options?: {
1029
+ dryRun?: boolean;
1030
+ schemaOverride?: string | null;
1031
+ }): Promise<any>;
1032
+ deleteDatabaseTypeOperation(appId: string, databaseType: string, name: string): Promise<any>;
1033
+ listDatabaseTypeSubscriptions(appId: string, databaseType: string): Promise<any[]>;
1034
+ getDatabaseTypeSubscription(appId: string, databaseType: string, subscriptionKey: string): Promise<any>;
1035
+ createDatabaseTypeSubscription(appId: string, databaseType: string, data: {
1036
+ subscriptionKey: string;
1037
+ displayName: string;
1038
+ modelName: string;
1039
+ filter: string;
1040
+ access: string;
1041
+ description?: string | null;
1042
+ select?: string[] | null;
1043
+ emit?: string[] | null;
1044
+ params?: Record<string, any> | null;
1045
+ status?: string;
1046
+ }): Promise<any>;
1047
+ updateDatabaseTypeSubscription(appId: string, databaseType: string, subscriptionKey: string, data: Record<string, any>): Promise<any>;
1048
+ deleteDatabaseTypeSubscription(appId: string, databaseType: string, subscriptionKey: string): Promise<any>;
1049
+ listGroups(appId: string, params?: {
1050
+ type?: string;
1051
+ limit?: number;
1052
+ cursor?: string;
1053
+ }): Promise<{
1054
+ items: any[];
1055
+ cursor?: string;
1056
+ }>;
1057
+ createGroup(appId: string, data: {
1058
+ groupType: string;
1059
+ groupId: string;
1060
+ name: string;
1061
+ description?: string;
1062
+ }): Promise<any>;
1063
+ getGroup(appId: string, groupType: string, groupId: string): Promise<any>;
1064
+ updateGroup(appId: string, groupType: string, groupId: string, data: {
1065
+ name?: string;
1066
+ description?: string;
1067
+ }): Promise<any>;
1068
+ deleteGroup(appId: string, groupType: string, groupId: string): Promise<any>;
1069
+ listGroupMembers(appId: string, groupType: string, groupId: string): Promise<{
1070
+ items: any[];
1071
+ cursor?: string;
1072
+ }>;
1073
+ addGroupMember(appId: string, groupType: string, groupId: string, data: {
1074
+ userId: string;
1075
+ }): Promise<any>;
1076
+ removeGroupMember(appId: string, groupType: string, groupId: string, userId: string): Promise<any>;
1077
+ listGroupDocuments(appId: string, groupType: string, groupId: string): Promise<any[]>;
1078
+ listUserMemberships(appId: string, userId: string): Promise<any[]>;
1079
+ listDocumentGroupPermissions(appId: string, documentId: string): Promise<any[]>;
1080
+ grantDocumentGroupPermission(appId: string, documentId: string, data: {
1081
+ groupType: string;
1082
+ groupId: string;
1083
+ permission: string;
1084
+ }): Promise<any>;
1085
+ revokeDocumentGroupPermission(appId: string, documentId: string, groupType: string, groupId: string): Promise<any>;
1086
+ listCollections(appId: string, params?: {
1087
+ limit?: number;
1088
+ cursor?: string;
1089
+ }): Promise<{
1090
+ items: any[];
1091
+ nextCursor?: string | null;
1092
+ }>;
1093
+ listAllCollections(appId: string, params?: {
1094
+ limit?: number;
1095
+ cursor?: string;
1096
+ }): Promise<{
1097
+ items: any[];
1098
+ nextCursor?: string | null;
1099
+ }>;
1100
+ createCollection(appId: string, data: {
1101
+ name: string;
1102
+ description?: string;
1103
+ }): Promise<any>;
1104
+ getCollection(appId: string, collectionId: string): Promise<any>;
1105
+ updateCollection(appId: string, collectionId: string, data: {
1106
+ name?: string;
1107
+ description?: string;
1108
+ }): Promise<any>;
1109
+ deleteCollection(appId: string, collectionId: string): Promise<any>;
1110
+ listCollectionDocuments(appId: string, collectionId: string, params?: {
1111
+ limit?: number;
1112
+ cursor?: string;
1113
+ }): Promise<{
1114
+ items: any[];
1115
+ nextCursor?: string | null;
1116
+ }>;
1117
+ addCollectionDocument(appId: string, collectionId: string, data: {
1118
+ documentId: string;
1119
+ }): Promise<any>;
1120
+ removeCollectionDocument(appId: string, collectionId: string, documentId: string): Promise<any>;
1121
+ listCollectionsForDocument(appId: string, documentId: string, params?: {
1122
+ limit?: number;
1123
+ cursor?: string;
1124
+ }): Promise<{
1125
+ items: any[];
1126
+ nextCursor?: string | null;
1127
+ }>;
1128
+ getCollectionAccess(appId: string, collectionId: string): Promise<any>;
1129
+ grantCollectionGroupPermission(appId: string, collectionId: string, data: {
1130
+ groupType: string;
1131
+ groupId: string;
1132
+ permission: string;
1133
+ }): Promise<any>;
1134
+ revokeCollectionGroupPermission(appId: string, collectionId: string, groupType: string, groupId: string): Promise<any>;
1135
+ addCollectionMember(appId: string, collectionId: string, data: {
1136
+ userId: string;
1137
+ permission: string;
1138
+ }): Promise<any>;
1139
+ removeCollectionMember(appId: string, collectionId: string, userId: string): Promise<any>;
1140
+ listCollectionTypeConfigs(appId: string): Promise<any[]>;
1141
+ getCollectionTypeConfig(appId: string, collectionType: string): Promise<any>;
1142
+ createCollectionTypeConfig(appId: string, data: {
1143
+ collectionType: string;
1144
+ ruleSetId?: string;
1145
+ metadataManifest?: any;
1146
+ }): Promise<any>;
1147
+ updateCollectionTypeConfig(appId: string, collectionType: string, data: {
1148
+ ruleSetId?: string | null;
1149
+ metadataManifest?: any;
1150
+ }, expectedModifiedAt?: string): Promise<any>;
1151
+ deleteCollectionTypeConfig(appId: string, collectionType: string): Promise<any>;
1152
+ /**
1153
+ * List all metadata category configs for an app. The route returns
1154
+ * `{ configs: [...] }`; unwrap to a bare array to match the other
1155
+ * `list*Configs` helpers.
1156
+ */
1157
+ listMetadataCategoryConfigs(appId: string): Promise<any[]>;
1158
+ getMetadataCategoryConfig(appId: string, resourceType: string, category: string): Promise<any>;
1159
+ /**
1160
+ * Create or replace a metadata category config (idempotent upsert via the
1161
+ * path-addressed PUT route). `resourceType` / `category` identify the config;
1162
+ * the body carries `schema` / `readRule` / `writeRule` / `description`.
1163
+ */
1164
+ upsertMetadataCategoryConfig(appId: string, resourceType: string, category: string, data: {
1165
+ schema: unknown;
1166
+ readRule?: string | null;
1167
+ writeRule?: string | null;
1168
+ description?: string | null;
1169
+ }): Promise<any>;
1170
+ listRuleSets(appId: string, params?: {
1171
+ resourceType?: string;
1172
+ }): Promise<any[]>;
1173
+ createRuleSet(appId: string, data: {
1174
+ name: string;
1175
+ resourceType: string;
1176
+ rules: Record<string, any>;
1177
+ description?: string;
1178
+ }): Promise<any>;
1179
+ getRuleSet(appId: string, ruleSetId: string): Promise<any>;
1180
+ updateRuleSet(appId: string, ruleSetId: string, data: {
1181
+ name?: string;
1182
+ description?: string;
1183
+ rules?: Record<string, any>;
1184
+ }, expectedModifiedAt?: string): Promise<any>;
1185
+ deleteRuleSet(appId: string, ruleSetId: string): Promise<any>;
1186
+ getRuleSetSchema(appId: string): Promise<any>;
1187
+ getRuleSetResourceTypes(appId: string): Promise<{
1188
+ resourceTypes: string[];
1189
+ }>;
1190
+ testRuleSet(appId: string, ruleSetId: string, data: any): Promise<any>;
1191
+ debugRuleSet(appId: string, data: any): Promise<any>;
1192
+ listGroupTypeConfigs(appId: string): Promise<any[]>;
1193
+ getGroupTypeConfig(appId: string, groupType: string): Promise<any>;
1194
+ createGroupTypeConfig(appId: string, data: {
1195
+ groupType: string;
1196
+ ruleSetId?: string;
1197
+ autoAddCreator?: boolean;
1198
+ }): Promise<any>;
1199
+ updateGroupTypeConfig(appId: string, groupType: string, data: {
1200
+ ruleSetId?: string | null;
1201
+ autoAddCreator?: boolean;
1202
+ }, expectedModifiedAt?: string): Promise<any>;
1203
+ deleteGroupTypeConfig(appId: string, groupType: string): Promise<any>;
1204
+ exportDocumentState(appId: string, documentId: string): Promise<{
1205
+ state: string;
1206
+ byteLength: number;
1207
+ documentId: string;
1208
+ }>;
1209
+ importDocumentState(appId: string, documentId: string, stateBase64: string): Promise<any>;
1210
+ getDocument(appId: string, documentId: string): Promise<any>;
1211
+ createDocument(appId: string, data: {
1212
+ title: string;
1213
+ documentId?: string;
1214
+ tags?: string[];
1215
+ createdBy?: string;
1216
+ }): Promise<any>;
1217
+ listDocumentPermissions(appId: string, documentId: string): Promise<any[]>;
1218
+ grantDocumentPermission(appId: string, documentId: string, permissions: Array<{
1219
+ userId: string;
1220
+ permission: string;
1221
+ }>): Promise<any>;
1222
+ listDocumentInvitations(appId: string, documentId: string): Promise<any[]>;
1223
+ listDocumentBlobs(appId: string, documentId: string): Promise<any[]>;
1224
+ downloadBlob(appId: string, documentId: string, blobId: string): Promise<Buffer>;
1225
+ uploadBlob(appId: string, documentId: string, blobId: string, data: Buffer, meta: {
1226
+ filename: string;
1227
+ contentType: string;
1228
+ sha256: string;
1229
+ }): Promise<any>;
1230
+ listDocumentAliases(appId: string, documentId: string): Promise<any[]>;
1231
+ setDocumentAlias(appId: string, aliasScope: string, aliasKey: string, documentId: string, ownerUserId?: string, mustNotExist?: boolean): Promise<any>;
1232
+ findUserByEmail(appId: string, email: string): Promise<any | null>;
1233
+ listAdminDocuments(appId: string, userId: string): Promise<any[]>;
1234
+ saveDatabaseRecord(appId: string, databaseId: string, modelName: string, id: string, data: any): Promise<any>;
1235
+ batchDatabaseRecords(appId: string, databaseId: string, operations: any[]): Promise<any>;
1236
+ deleteDatabaseRecord(appId: string, databaseId: string, modelName: string, id: string): Promise<any>;
1237
+ batchDeleteDatabaseRecords(appId: string, databaseId: string, operations: {
1238
+ op: "delete";
1239
+ modelName: string;
1240
+ id: string;
1241
+ }[]): Promise<any>;
1242
+ listDatabaseUniqueConstraints(appId: string, databaseId: string): Promise<any[]>;
1243
+ registerDatabaseUniqueConstraint(appId: string, databaseId: string, constraint: {
1244
+ modelName: string;
1245
+ constraintName: string;
1246
+ fields: string[];
1247
+ }): Promise<any>;
1248
+ listBlobBuckets(appId: string): Promise<{
1249
+ items: any[];
1250
+ }>;
1251
+ createBlobBucket(appId: string, payload: any): Promise<any>;
1252
+ getBlobBucket(appId: string, bucketIdOrKey: string): Promise<any>;
1253
+ updateBlobBucket(appId: string, bucketIdOrKey: string, payload: any): Promise<any>;
1254
+ deleteBlobBucket(appId: string, bucketIdOrKey: string): Promise<any>;
1255
+ listBucketBlobs(appId: string, bucketIdOrKey: string, params?: {
1256
+ cursor?: string;
1257
+ limit?: number;
1258
+ }): Promise<{
1259
+ items: any[];
1260
+ cursor?: string;
1261
+ }>;
1262
+ uploadBucketBlob(appId: string, bucketIdOrKey: string, data: Buffer, meta: {
1263
+ filename: string;
1264
+ contentType: string;
1265
+ tags?: string[];
1266
+ }): Promise<any>;
1267
+ downloadBucketBlob(appId: string, bucketIdOrKey: string, blobId: string): Promise<Buffer>;
1268
+ deleteBucketBlob(appId: string, bucketIdOrKey: string, blobId: string): Promise<any>;
1269
+ getBucketBlobSignedUrl(appId: string, bucketIdOrKey: string, blobId: string, expiresInSeconds?: number): Promise<any>;
1270
+ }
1271
+ export declare const apiClient: ApiClient;
1272
+ export {};