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

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 (219) 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 +268 -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 +48 -45
  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/metadata.d.ts +2 -0
  70. package/dist/src/commands/metadata.js +194 -0
  71. package/dist/src/commands/metadata.js.map +1 -0
  72. package/dist/src/commands/prompts.d.ts +2 -0
  73. package/dist/src/commands/prompts.js +50 -52
  74. package/dist/src/commands/prompts.js.map +1 -1
  75. package/dist/src/commands/rule-sets.d.ts +3 -0
  76. package/dist/src/commands/rule-sets.js +388 -0
  77. package/dist/src/commands/rule-sets.js.map +1 -0
  78. package/dist/src/commands/scripts.d.ts +2 -0
  79. package/dist/src/commands/scripts.js +667 -0
  80. package/dist/src/commands/scripts.js.map +1 -0
  81. package/dist/src/commands/secrets.d.ts +2 -0
  82. package/dist/src/commands/secrets.js +108 -0
  83. package/dist/src/commands/secrets.js.map +1 -0
  84. package/dist/src/commands/skill.d.ts +2 -0
  85. package/dist/src/commands/skill.js +29 -0
  86. package/dist/src/commands/skill.js.map +1 -0
  87. package/dist/src/commands/sync.d.ts +175 -0
  88. package/dist/src/commands/sync.js +4412 -233
  89. package/dist/src/commands/sync.js.map +1 -1
  90. package/dist/src/commands/tokens.d.ts +2 -0
  91. package/dist/src/commands/tokens.js +122 -19
  92. package/dist/src/commands/tokens.js.map +1 -1
  93. package/dist/src/commands/users.d.ts +2 -0
  94. package/dist/src/commands/users.js +440 -22
  95. package/dist/src/commands/users.js.map +1 -1
  96. package/dist/src/commands/waitlist.d.ts +2 -0
  97. package/dist/src/commands/waitlist.js +10 -10
  98. package/dist/src/commands/waitlist.js.map +1 -1
  99. package/dist/src/commands/webhooks.d.ts +2 -0
  100. package/dist/src/commands/webhooks.js +391 -0
  101. package/dist/src/commands/webhooks.js.map +1 -0
  102. package/dist/src/commands/workflows.d.ts +49 -0
  103. package/dist/src/commands/workflows.js +1009 -123
  104. package/dist/src/commands/workflows.js.map +1 -1
  105. package/dist/src/lib/api-client.d.ts +1283 -0
  106. package/dist/src/lib/api-client.js +1129 -83
  107. package/dist/src/lib/api-client.js.map +1 -1
  108. package/dist/src/lib/auth-flow.d.ts +8 -0
  109. package/dist/src/lib/block-layout.d.ts +160 -0
  110. package/dist/src/lib/block-layout.js +451 -0
  111. package/dist/src/lib/block-layout.js.map +1 -0
  112. package/dist/src/lib/cli-manifest.d.ts +60 -0
  113. package/dist/src/lib/cli-manifest.js +70 -0
  114. package/dist/src/lib/cli-manifest.js.map +1 -0
  115. package/dist/src/lib/config.d.ts +53 -0
  116. package/dist/src/lib/config.js +92 -53
  117. package/dist/src/lib/config.js.map +1 -1
  118. package/dist/src/lib/confirm-prompt.d.ts +83 -0
  119. package/dist/src/lib/confirm-prompt.js +110 -0
  120. package/dist/src/lib/confirm-prompt.js.map +1 -0
  121. package/dist/src/lib/constants.d.ts +2 -0
  122. package/dist/src/lib/constants.js +3 -0
  123. package/dist/src/lib/constants.js.map +1 -0
  124. package/dist/src/lib/crash-handlers.d.ts +20 -0
  125. package/dist/src/lib/crash-handlers.js +49 -0
  126. package/dist/src/lib/crash-handlers.js.map +1 -0
  127. package/dist/src/lib/credentials-store.d.ts +79 -0
  128. package/dist/src/lib/credentials-store.js +307 -0
  129. package/dist/src/lib/credentials-store.js.map +1 -0
  130. package/dist/src/lib/csv.d.ts +48 -0
  131. package/dist/src/lib/csv.js +177 -0
  132. package/dist/src/lib/csv.js.map +1 -0
  133. package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
  134. package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
  135. package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
  136. package/dist/src/lib/db-codegen/dbGenerator.d.ts +111 -0
  137. package/dist/src/lib/db-codegen/dbGenerator.js +371 -0
  138. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
  139. package/dist/src/lib/db-codegen/dbNaming.d.ts +45 -0
  140. package/dist/src/lib/db-codegen/dbNaming.js +104 -0
  141. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
  142. package/dist/src/lib/db-codegen/dbTemplates.d.ts +97 -0
  143. package/dist/src/lib/db-codegen/dbTemplates.js +159 -0
  144. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
  145. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +78 -0
  146. package/dist/src/lib/db-codegen/dbTsTypes.js +112 -0
  147. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
  148. package/dist/src/lib/env-resolver.d.ts +62 -0
  149. package/dist/src/lib/env-resolver.js +121 -0
  150. package/dist/src/lib/env-resolver.js.map +1 -0
  151. package/dist/src/lib/fetch.d.ts +5 -0
  152. package/dist/src/lib/generated-allowlist.d.ts +28 -0
  153. package/dist/src/lib/generated-allowlist.js +220 -0
  154. package/dist/src/lib/generated-allowlist.js.map +1 -0
  155. package/dist/src/lib/init-config.d.ts +59 -0
  156. package/dist/src/lib/init-config.js +113 -0
  157. package/dist/src/lib/init-config.js.map +1 -0
  158. package/dist/src/lib/migration-nag.d.ts +49 -0
  159. package/dist/src/lib/migration-nag.js +163 -0
  160. package/dist/src/lib/migration-nag.js.map +1 -0
  161. package/dist/src/lib/output.d.ts +86 -0
  162. package/dist/src/lib/output.js +150 -8
  163. package/dist/src/lib/output.js.map +1 -1
  164. package/dist/src/lib/paginate.d.ts +33 -0
  165. package/dist/src/lib/paginate.js +42 -0
  166. package/dist/src/lib/paginate.js.map +1 -0
  167. package/dist/src/lib/project-config.d.ts +97 -0
  168. package/dist/src/lib/project-config.js +209 -0
  169. package/dist/src/lib/project-config.js.map +1 -0
  170. package/dist/src/lib/query-operators.d.ts +43 -0
  171. package/dist/src/lib/query-operators.js +80 -0
  172. package/dist/src/lib/query-operators.js.map +1 -0
  173. package/dist/src/lib/refresh-admin-credentials.d.ts +65 -0
  174. package/dist/src/lib/refresh-admin-credentials.js +103 -0
  175. package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
  176. package/dist/src/lib/resolve-platform.d.ts +45 -0
  177. package/dist/src/lib/resolve-platform.js +43 -0
  178. package/dist/src/lib/resolve-platform.js.map +1 -0
  179. package/dist/src/lib/skill-installer.d.ts +23 -0
  180. package/dist/src/lib/skill-installer.js +135 -0
  181. package/dist/src/lib/skill-installer.js.map +1 -0
  182. package/dist/src/lib/snapshots.d.ts +99 -0
  183. package/dist/src/lib/snapshots.js +357 -0
  184. package/dist/src/lib/snapshots.js.map +1 -0
  185. package/dist/src/lib/sync-paths.d.ts +72 -0
  186. package/dist/src/lib/sync-paths.js +130 -0
  187. package/dist/src/lib/sync-paths.js.map +1 -0
  188. package/dist/src/lib/template.d.ts +97 -0
  189. package/dist/src/lib/template.js +336 -62
  190. package/dist/src/lib/template.js.map +1 -1
  191. package/dist/src/lib/token-inject.d.ts +56 -0
  192. package/dist/src/lib/token-inject.js +204 -0
  193. package/dist/src/lib/token-inject.js.map +1 -0
  194. package/dist/src/lib/toml-database-config.d.ts +152 -0
  195. package/dist/src/lib/toml-database-config.js +600 -0
  196. package/dist/src/lib/toml-database-config.js.map +1 -0
  197. package/dist/src/lib/toml-metadata-config.d.ts +139 -0
  198. package/dist/src/lib/toml-metadata-config.js +427 -0
  199. package/dist/src/lib/toml-metadata-config.js.map +1 -0
  200. package/dist/src/lib/toml-params-validator.d.ts +129 -0
  201. package/dist/src/lib/toml-params-validator.js +298 -0
  202. package/dist/src/lib/toml-params-validator.js.map +1 -0
  203. package/dist/src/lib/version-check.d.ts +10 -0
  204. package/dist/src/lib/version-check.js +172 -0
  205. package/dist/src/lib/version-check.js.map +1 -0
  206. package/dist/src/lib/workflow-apply.d.ts +66 -0
  207. package/dist/src/lib/workflow-apply.js +117 -0
  208. package/dist/src/lib/workflow-apply.js.map +1 -0
  209. package/dist/src/lib/workflow-fragments.d.ts +41 -0
  210. package/dist/src/lib/workflow-fragments.js +121 -0
  211. package/dist/src/lib/workflow-fragments.js.map +1 -0
  212. package/dist/src/lib/workflow-toml-validator.d.ts +95 -0
  213. package/dist/src/lib/workflow-toml-validator.js +323 -0
  214. package/dist/src/lib/workflow-toml-validator.js.map +1 -0
  215. package/dist/src/types/index.d.ts +520 -0
  216. package/dist/src/validators.d.ts +64 -0
  217. package/dist/src/validators.js +63 -0
  218. package/dist/src/validators.js.map +1 -0
  219. package/package.json +18 -4
@@ -0,0 +1,1283 @@
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
+ readResourceMetadata(appId: string, resourceType: string, resourceId: string, category: string): Promise<any>;
483
+ writeResourceMetadata(appId: string, resourceType: string, resourceId: string, category: string, data: Record<string, any>): Promise<any>;
484
+ batchReadResourceMetadata(appId: string, requests: Array<{
485
+ resourceType: string;
486
+ resourceId: string;
487
+ categories: string[];
488
+ }>): Promise<{
489
+ results: any[];
490
+ }>;
491
+ listPrompts(appId: string, params?: {
492
+ status?: string;
493
+ limit?: number;
494
+ cursor?: string;
495
+ }): Promise<{
496
+ items: any[];
497
+ nextCursor?: string | null;
498
+ }>;
499
+ getPrompt(appId: string, promptId: string): Promise<any>;
500
+ createPrompt(appId: string, payload: any): Promise<any>;
501
+ updatePrompt(appId: string, promptId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
502
+ deletePrompt(appId: string, promptId: string, hard?: boolean): Promise<void>;
503
+ executePrompt(appId: string, promptId: string, payload: {
504
+ variables: Record<string, any>;
505
+ modelOverride?: string;
506
+ configId?: string;
507
+ }): Promise<any>;
508
+ previewPrompt(appId: string, promptId: string, payload: {
509
+ variables: Record<string, any>;
510
+ configId?: string;
511
+ }): Promise<any>;
512
+ listPromptConfigs(appId: string, promptId: string): Promise<{
513
+ items: any[];
514
+ }>;
515
+ getPromptConfig(appId: string, promptId: string, configId: string): Promise<any>;
516
+ createPromptConfig(appId: string, promptId: string, payload: any): Promise<any>;
517
+ updatePromptConfig(appId: string, promptId: string, configId: string, payload: any): Promise<any>;
518
+ activatePromptConfig(appId: string, promptId: string, configId: string): Promise<any>;
519
+ duplicatePromptConfig(appId: string, promptId: string, configId: string, payload?: {
520
+ configName?: string;
521
+ description?: string;
522
+ }): Promise<any>;
523
+ listScripts(appId: string): Promise<{
524
+ items: any[];
525
+ }>;
526
+ getScript(appId: string, scriptId: string): Promise<any>;
527
+ /**
528
+ * List a script's versioned configs (the `ScriptConfig` rows). Each config
529
+ * is a distinct block version: `configId` is the stable version selector,
530
+ * `contentHash` is its content identity, and `status` reports whether it is
531
+ * `active`/`draft`/`archived`. The script header's `activeConfigId` names
532
+ * the live version. Used by `scripts configs list` and by the script test
533
+ * commands to run against a specific pinned version.
534
+ */
535
+ listScriptConfigs(appId: string, scriptId: string): Promise<{
536
+ items: any[];
537
+ }>;
538
+ createScript(appId: string, payload: {
539
+ name: string;
540
+ body: string;
541
+ description?: string;
542
+ }): Promise<any>;
543
+ /**
544
+ * Push a new body for an existing script by creating a new `ScriptConfig`
545
+ * and activating it (the prompt-model "edit → activate" flow). Referencing
546
+ * workflows pick up the new body on their next run with no fan-out. The
547
+ * config name is unique per script, so we mint a timestamped name.
548
+ */
549
+ pushScriptBody(appId: string, scriptId: string, body: string): Promise<any>;
550
+ deleteScript(appId: string, scriptId: string): Promise<void>;
551
+ getPromptSchema(appId: string, promptId: string): Promise<{
552
+ promptId: string;
553
+ promptKey: string;
554
+ displayName: string;
555
+ inputSchema: any;
556
+ inputVariables: string[];
557
+ outputSchema: any;
558
+ activeConfigId: string | null;
559
+ activeConfigName: string | null;
560
+ }>;
561
+ listTestCases(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string): Promise<{
562
+ items: any[];
563
+ }>;
564
+ getTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<any>;
565
+ createTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload: {
566
+ name: string;
567
+ inputVariables: Record<string, any>;
568
+ expectedOutputPattern?: string;
569
+ expectedOutputContains?: string[];
570
+ expectedJsonSubset?: Record<string, any>;
571
+ configId?: string;
572
+ evaluatorPromptId?: string;
573
+ evaluatorConfigId?: string;
574
+ }): Promise<any>;
575
+ updateTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, payload: {
576
+ name?: string;
577
+ inputVariables?: Record<string, any>;
578
+ expectedOutputPattern?: string | null;
579
+ expectedOutputContains?: string[] | null;
580
+ expectedJsonSubset?: Record<string, any> | null;
581
+ configId?: string | null;
582
+ evaluatorPromptId?: string | null;
583
+ evaluatorConfigId?: string | null;
584
+ }): Promise<any>;
585
+ deleteTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<void>;
586
+ listTestCaseAttachments(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<{
587
+ attachments: Array<{
588
+ filename: string;
589
+ contentType: string;
590
+ size: number;
591
+ r2Key: string;
592
+ }>;
593
+ }>;
594
+ uploadTestCaseAttachment(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, filename: string, data: Buffer, contentType: string): Promise<{
595
+ success: boolean;
596
+ attachment: {
597
+ filename: string;
598
+ contentType: string;
599
+ size: number;
600
+ r2Key: string;
601
+ };
602
+ }>;
603
+ downloadTestCaseAttachment(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, filename: string): Promise<{
604
+ data: Buffer;
605
+ contentType: string;
606
+ }>;
607
+ deleteTestCaseAttachment(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, filename: string): Promise<{
608
+ success: boolean;
609
+ deleted: boolean;
610
+ }>;
611
+ executeBlockTest(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload: {
612
+ variables?: Record<string, any>;
613
+ testCaseId?: string;
614
+ configId?: string;
615
+ comparisonGroup?: string;
616
+ }): Promise<any>;
617
+ runAllTestCases(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload?: {
618
+ overrideConfigId?: string;
619
+ comparisonGroup?: string;
620
+ testCaseIds?: string[];
621
+ }): Promise<any>;
622
+ listTestRuns(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, params?: {
623
+ limit?: number;
624
+ comparisonGroup?: string;
625
+ }): Promise<{
626
+ items: any[];
627
+ }>;
628
+ listWorkflows(appId: string, params?: {
629
+ status?: string;
630
+ limit?: number;
631
+ cursor?: string;
632
+ }): Promise<{
633
+ items: any[];
634
+ nextCursor?: string | null;
635
+ }>;
636
+ getWorkflow(appId: string, workflowId: string): Promise<any>;
637
+ createWorkflow(appId: string, payload: any): Promise<any>;
638
+ updateWorkflow(appId: string, workflowId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
639
+ deleteWorkflow(appId: string, workflowId: string): Promise<void>;
640
+ updateWorkflowDraft(appId: string, workflowId: string, payload: any): Promise<any>;
641
+ publishWorkflow(appId: string, workflowId: string): Promise<any>;
642
+ previewWorkflow(appId: string, workflowId: string, payload: {
643
+ rootInput?: object;
644
+ meta?: object;
645
+ configId?: string;
646
+ useDraft?: boolean;
647
+ preferActive?: boolean;
648
+ }): Promise<{
649
+ instanceId: string;
650
+ usingDraft?: boolean;
651
+ source?: "config" | "active" | "draft" | null;
652
+ configName?: string | null;
653
+ configId?: string | null;
654
+ warning?: string;
655
+ }>;
656
+ getPreviewStatus(appId: string, workflowId: string, instanceId: string): Promise<any>;
657
+ listWorkflowRuns(appId: string, workflowId: string, params?: {
658
+ status?: string;
659
+ limit?: number;
660
+ cursor?: string;
661
+ forward?: boolean;
662
+ }): Promise<{
663
+ items: any[];
664
+ cursor?: string | null;
665
+ }>;
666
+ getWorkflowRunStatus(appId: string, workflowId: string, runId: string): Promise<any>;
667
+ getWorkflowStepRuns(appId: string, workflowId: string, runId: string): Promise<{
668
+ items: any[];
669
+ }>;
670
+ getWorkflowAnalytics(appId: string, params?: {
671
+ windowDays?: number;
672
+ }): Promise<any>;
673
+ getTopWorkflows(appId: string, params?: {
674
+ windowDays?: number;
675
+ limit?: number;
676
+ }): Promise<any>;
677
+ listWorkflowConfigs(appId: string, workflowId: string): Promise<{
678
+ items: any[];
679
+ }>;
680
+ getWorkflowConfig(appId: string, workflowId: string, configId: string): Promise<any>;
681
+ createWorkflowConfig(appId: string, workflowId: string, payload: {
682
+ configName: string;
683
+ description?: string;
684
+ steps: any[];
685
+ }): Promise<any>;
686
+ updateWorkflowConfig(appId: string, workflowId: string, configId: string, payload: {
687
+ configName?: string;
688
+ description?: string;
689
+ steps?: any[];
690
+ status?: string;
691
+ }): Promise<any>;
692
+ archiveWorkflowConfig(appId: string, workflowId: string, configId: string): Promise<any>;
693
+ activateWorkflowConfig(appId: string, workflowId: string, configId: string): Promise<any>;
694
+ duplicateWorkflowConfig(appId: string, workflowId: string, configId: string, payload?: {
695
+ configName?: string;
696
+ }): Promise<any>;
697
+ getAnalyticsTopUsers(appId: string, params?: {
698
+ windowDays?: number;
699
+ limit?: number;
700
+ }): Promise<AnalyticsTopUsersResponse>;
701
+ getAnalyticsIntegrationMetrics(appId: string, params?: {
702
+ windowDays?: number;
703
+ }): Promise<AnalyticsIntegrationMetricsResponse>;
704
+ getAnalyticsOverviewDau(appId: string): Promise<AnalyticsMetricResponse>;
705
+ getAnalyticsOverviewWau(appId: string): Promise<AnalyticsMetricResponse>;
706
+ getAnalyticsOverviewMau(appId: string): Promise<AnalyticsMetricResponse>;
707
+ getAnalyticsOverviewGrowth(appId: string, params?: {
708
+ windowDays?: number;
709
+ }): Promise<AnalyticsGrowthResponse>;
710
+ getAnalyticsDailyActive(appId: string, params?: {
711
+ windowDays?: number;
712
+ }): Promise<AnalyticsDailyActiveResponse>;
713
+ getAnalyticsRollingActive(appId: string, params?: {
714
+ windowDays?: number;
715
+ }): Promise<AnalyticsDailyActiveResponse>;
716
+ getAnalyticsCohortRetention(appId: string): Promise<AnalyticsCohortResponse>;
717
+ getAnalyticsUserSearch(appId: string, params: {
718
+ q: string;
719
+ limit?: number;
720
+ }): Promise<AnalyticsUserSearchResponse>;
721
+ getAnalyticsUserDetail(appId: string, userUlid: string): Promise<AnalyticsUserDetailResponse>;
722
+ getAnalyticsUserSnapshot(appId: string, userUlid: string): Promise<AnalyticsUserSnapshotResponse>;
723
+ getAnalyticsEvents(appId: string, params?: {
724
+ windowDays?: number;
725
+ page?: number;
726
+ [key: string]: any;
727
+ }): Promise<AnalyticsEventsResponse>;
728
+ getAnalyticsEventsGrouped(appId: string, params?: {
729
+ groupBy?: string;
730
+ windowDays?: number;
731
+ [key: string]: any;
732
+ }): Promise<AnalyticsEventsGroupedResponse>;
733
+ getAnalyticsTopWorkflows(appId: string, params?: {
734
+ windowDays?: number;
735
+ limit?: number;
736
+ }): Promise<TopWorkflowsResponse>;
737
+ getAnalyticsTopPrompts(appId: string, params?: {
738
+ windowDays?: number;
739
+ limit?: number;
740
+ }): Promise<TopPromptsResponse>;
741
+ listAllAdmins(params?: {
742
+ limit?: number;
743
+ cursor?: string;
744
+ }): Promise<any>;
745
+ searchAdminByEmail(email: string): Promise<any>;
746
+ getAdminApps(email: string): Promise<any>;
747
+ updateAdminSettings(adminId: string, data: {
748
+ appCreationLimit?: number;
749
+ disabled?: boolean;
750
+ role?: "admin" | "super-admin";
751
+ }): Promise<any>;
752
+ reindexAdmin(adminId: string): Promise<void>;
753
+ listAllAdminInvitations(): Promise<any[]>;
754
+ createGlobalAdminInvitation(data: {
755
+ email: string;
756
+ appCreationLimit?: number;
757
+ expiresInDays?: number;
758
+ }): Promise<any>;
759
+ deleteGlobalAdminInvitation(invitationId: string): Promise<void>;
760
+ listPromptCatalog(params?: {
761
+ status?: string;
762
+ limit?: number;
763
+ cursor?: string;
764
+ }): Promise<any>;
765
+ getPromptCatalogItem(catalogId: string): Promise<any>;
766
+ createPromptCatalogItem(payload: any): Promise<any>;
767
+ updatePromptCatalogItem(catalogId: string, payload: any): Promise<any>;
768
+ deletePromptCatalogItem(catalogId: string): Promise<void>;
769
+ listIntegrationCatalog(params?: {
770
+ status?: string;
771
+ limit?: number;
772
+ cursor?: string;
773
+ }): Promise<any>;
774
+ getIntegrationCatalogItem(catalogId: string): Promise<any>;
775
+ createIntegrationCatalogItem(payload: any): Promise<any>;
776
+ updateIntegrationCatalogItem(catalogId: string, payload: any): Promise<any>;
777
+ deleteIntegrationCatalogItem(catalogId: string): Promise<void>;
778
+ listLlmModels(provider?: string): Promise<{
779
+ models: Array<{
780
+ id: string;
781
+ name: string;
782
+ context_length?: number;
783
+ pricing?: any;
784
+ }>;
785
+ defaultModel?: string;
786
+ cachedAt?: string;
787
+ }>;
788
+ generatePrompt(payload: {
789
+ description: string;
790
+ generateOutputSchema?: boolean;
791
+ }): Promise<any>;
792
+ generateEvaluator(payload: {
793
+ appId: string;
794
+ promptId: string;
795
+ }): Promise<any>;
796
+ generateWorkflowEvaluator(payload: {
797
+ appId: string;
798
+ workflowId: string;
799
+ }): Promise<any>;
800
+ startBatchTests(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload?: {
801
+ comparisonGroup?: string;
802
+ overrideConfigId?: string;
803
+ testCaseIds?: string[];
804
+ }): Promise<{
805
+ batchId: string;
806
+ totalTests: number;
807
+ instanceIds: string[];
808
+ errors?: any[];
809
+ }>;
810
+ getBatchTestStatus(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, batchId: string): Promise<{
811
+ status: string;
812
+ batchId: string;
813
+ completed: number;
814
+ passed: number;
815
+ failed: number;
816
+ results: Array<{
817
+ testCaseId: string;
818
+ runId: string;
819
+ status: string;
820
+ verificationPassed: boolean;
821
+ durationMs?: number;
822
+ verificationDetails?: any;
823
+ startedAt?: string;
824
+ endedAt?: string;
825
+ }>;
826
+ }>;
827
+ cancelBatchTests(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, batchId: string, instanceIds: string[]): Promise<{
828
+ batchId: string;
829
+ terminated: string[];
830
+ errors?: any[];
831
+ }>;
832
+ getComparisonGroup(appId: string, group: string): Promise<{
833
+ comparisonGroup: string;
834
+ runs: any[];
835
+ }>;
836
+ listEmailTemplates(appId: string): Promise<{
837
+ templates: EmailTemplateSummary[];
838
+ }>;
839
+ getEmailTemplate(appId: string, emailType: string): Promise<EmailTemplateDetail>;
840
+ upsertEmailTemplate(appId: string, emailType: string, payload: {
841
+ subject: string;
842
+ htmlBody: string;
843
+ textBody: string;
844
+ }): Promise<EmailTemplateUpsertResult>;
845
+ deleteEmailTemplate(appId: string, emailType: string): Promise<{
846
+ success: boolean;
847
+ }>;
848
+ testEmailTemplate(appId: string, emailType: string, payload?: {
849
+ subject: string;
850
+ htmlBody: string;
851
+ textBody: string;
852
+ }): Promise<{
853
+ success: boolean;
854
+ sentTo: string;
855
+ error?: string;
856
+ }>;
857
+ createToken(appId: string, data: {
858
+ name: string;
859
+ ttl?: string;
860
+ userId?: string;
861
+ }): Promise<{
862
+ token: string;
863
+ tokenId: string;
864
+ name: string;
865
+ expiresAt: string | null;
866
+ createdAt: string;
867
+ warning: string;
868
+ }>;
869
+ listTokens(appId: string, params?: {
870
+ userId?: string;
871
+ }): Promise<Array<{
872
+ tokenId: string;
873
+ name: string;
874
+ userId: string;
875
+ expiresAt: string | null;
876
+ lastUsedAt: string | null;
877
+ createdAt: string;
878
+ createdBy: string;
879
+ }>>;
880
+ getToken(appId: string, tokenId: string): Promise<{
881
+ tokenId: string;
882
+ name: string;
883
+ userId: string;
884
+ expiresAt: string | null;
885
+ lastUsedAt: string | null;
886
+ createdAt: string;
887
+ createdBy: string;
888
+ revokedAt: string | null;
889
+ }>;
890
+ revokeToken(appId: string, tokenId: string): Promise<{
891
+ success: boolean;
892
+ message: string;
893
+ }>;
894
+ listDatabases(appId: string): Promise<any[]>;
895
+ createDatabase(appId: string, data: {
896
+ title: string;
897
+ databaseType?: string;
898
+ metadata?: Record<string, any> | string;
899
+ }): Promise<any>;
900
+ getDatabase(appId: string, databaseId: string): Promise<any>;
901
+ updateDatabase(appId: string, databaseId: string, data: Record<string, any>): Promise<any>;
902
+ deleteDatabase(appId: string, databaseId: string): Promise<void>;
903
+ /**
904
+ * Read a database's CEL context dict.
905
+ *
906
+ * The HTTP path stays `/metadata` because the wire field name is still
907
+ * `metadata`; only the client/CLI-facing helper names were reframed.
908
+ */
909
+ getDatabaseCelContext(appId: string, databaseId: string): Promise<any>;
910
+ /** Update a database's CEL context dict (merge with existing). */
911
+ updateDatabaseCelContext(appId: string, databaseId: string, celContext: Record<string, any>): Promise<any>;
912
+ /** @deprecated Use {@link getDatabaseCelContext} instead. */
913
+ getDatabaseMetadata(appId: string, databaseId: string): Promise<any>;
914
+ /** @deprecated Use {@link updateDatabaseCelContext} instead. */
915
+ updateDatabaseMetadata(appId: string, databaseId: string, metadata: Record<string, any>): Promise<any>;
916
+ listDatabasePermissions(appId: string, databaseId: string): Promise<any[]>;
917
+ addDatabaseManager(appId: string, databaseId: string, userId: string): Promise<any>;
918
+ removeDatabaseManager(appId: string, databaseId: string, userId: string): Promise<any>;
919
+ /** @deprecated Use {@link addDatabaseManager} instead. */
920
+ grantDatabasePermission(appId: string, databaseId: string, data: {
921
+ userId: string;
922
+ permission: "manager";
923
+ }): Promise<any>;
924
+ /** @deprecated Use {@link removeDatabaseManager} instead. */
925
+ revokeDatabasePermission(appId: string, databaseId: string, userId: string): Promise<any>;
926
+ listDatabaseModels(appId: string, databaseId: string): Promise<any>;
927
+ describeDatabaseModel(appId: string, databaseId: string, modelName: string): Promise<any>;
928
+ queryDatabaseRecords(appId: string, databaseId: string, modelName: string, queryOptions?: {
929
+ filter?: Record<string, any>;
930
+ limit?: number;
931
+ cursor?: string;
932
+ }): Promise<any>;
933
+ listDatabaseOperations(appId: string, databaseId: string): Promise<any[]>;
934
+ executeDatabaseOperation(appId: string, databaseId: string, operationName: string, data?: {
935
+ params?: Record<string, any>;
936
+ limit?: number;
937
+ cursor?: string;
938
+ direction?: number;
939
+ }, token?: string, options?: {
940
+ timing?: boolean;
941
+ }): Promise<any>;
942
+ /**
943
+ * Execute a registered batch (bulk) database operation. Posts a chunk of
944
+ * items to the canonical `operations/:name/batch` endpoint (the same one the
945
+ * client library's `executeBatch` uses — NOT the deprecated `import-bulk`
946
+ * alias). Used by `databases import-csv`.
947
+ *
948
+ * @returns `{ imported, failed }` — DO-level write outcome counts. Per-item
949
+ * validation/access failures abort the whole chunk with a 4xx (thrown).
950
+ */
951
+ executeBatch(appId: string, databaseId: string, operationName: string, batch: Array<{
952
+ params: Record<string, any>;
953
+ }>): Promise<{
954
+ imported: number;
955
+ failed: number;
956
+ }>;
957
+ /**
958
+ * Make a request using a specific JWT token instead of the CLI's credentials.
959
+ * Used for executing operations as a different user.
960
+ */
961
+ requestWithToken<T = any>(path: string, token: string, options?: RequestInit): Promise<T>;
962
+ listDatabaseIndexes(appId: string, databaseId: string, modelName?: string): Promise<any>;
963
+ registerDatabaseIndex(appId: string, databaseId: string, data: {
964
+ modelName: string;
965
+ fieldName: string;
966
+ fieldType: string;
967
+ unique?: boolean;
968
+ }): Promise<any>;
969
+ dropDatabaseIndex(appId: string, databaseId: string, data: {
970
+ modelName: string;
971
+ fieldName: string;
972
+ }): Promise<any>;
973
+ /**
974
+ * Issue #974: back-provision an existing database instance's schema-declared
975
+ * unique indexes by reading its type schema and registering any declared-but-
976
+ * missing unique index. Idempotent.
977
+ */
978
+ reindexDatabaseFromSchema(appId: string, databaseId: string): Promise<{
979
+ ok: boolean;
980
+ registered: number;
981
+ skipped?: boolean;
982
+ reason?: string;
983
+ databaseType?: string;
984
+ }>;
985
+ listDatabaseTypeConfigs(appId: string): Promise<any[]>;
986
+ getDatabaseTypeConfig(appId: string, databaseType: string): Promise<any>;
987
+ createDatabaseTypeConfig(appId: string, data: {
988
+ databaseType: string;
989
+ ruleSetId?: string | null;
990
+ triggers?: Record<string, any> | null;
991
+ metadataAccess?: string | null;
992
+ defaultAccess?: string | null;
993
+ autoPopulatedFields?: Record<string, any> | null;
994
+ timestamps?: Record<string, any> | null;
995
+ schema?: string | null;
996
+ metadataManifest?: any;
997
+ }): Promise<any>;
998
+ updateDatabaseTypeConfig(appId: string, databaseType: string, data: {
999
+ ruleSetId?: string | null;
1000
+ triggers?: Record<string, any> | null;
1001
+ metadataAccess?: string | null;
1002
+ defaultAccess?: string | null;
1003
+ autoPopulatedFields?: Record<string, any> | null;
1004
+ timestamps?: Record<string, any> | null;
1005
+ schema?: string | null;
1006
+ pendingOpDeletes?: string[];
1007
+ finalOpNames?: string[];
1008
+ metadataManifest?: any;
1009
+ }, expectedModifiedAt?: string, options?: {
1010
+ dryRun?: boolean;
1011
+ acceptWarnings?: boolean;
1012
+ }): Promise<any>;
1013
+ deleteDatabaseTypeConfig(appId: string, databaseType: string, options?: {
1014
+ force?: boolean;
1015
+ }): Promise<any>;
1016
+ /**
1017
+ * Issue #666 Phase 3: ask the server to scaffold a TOML schema from
1018
+ * existing ops + DO field introspection. Read-only — does NOT persist.
1019
+ */
1020
+ scaffoldDatabaseTypeSchema(appId: string, databaseType: string): Promise<{
1021
+ schema: string;
1022
+ }>;
1023
+ listDatabaseTypeOperations(appId: string, databaseType: string): Promise<any[]>;
1024
+ getDatabaseTypeOperation(appId: string, databaseType: string, name: string): Promise<any>;
1025
+ createDatabaseTypeOperation(appId: string, databaseType: string, data: {
1026
+ name: string;
1027
+ type: string;
1028
+ modelName: string;
1029
+ access?: string | null;
1030
+ definition: Record<string, any>;
1031
+ params?: Record<string, any> | null;
1032
+ }, options?: {
1033
+ dryRun?: boolean;
1034
+ schemaOverride?: string | null;
1035
+ defaultAccess?: string | null;
1036
+ }): Promise<any>;
1037
+ updateDatabaseTypeOperation(appId: string, databaseType: string, name: string, data: Record<string, any>, expectedModifiedAt?: string, options?: {
1038
+ dryRun?: boolean;
1039
+ schemaOverride?: string | null;
1040
+ }): Promise<any>;
1041
+ deleteDatabaseTypeOperation(appId: string, databaseType: string, name: string): Promise<any>;
1042
+ listDatabaseTypeSubscriptions(appId: string, databaseType: string): Promise<any[]>;
1043
+ getDatabaseTypeSubscription(appId: string, databaseType: string, subscriptionKey: string): Promise<any>;
1044
+ createDatabaseTypeSubscription(appId: string, databaseType: string, data: {
1045
+ subscriptionKey: string;
1046
+ displayName: string;
1047
+ modelName: string;
1048
+ filter: string;
1049
+ access: string;
1050
+ description?: string | null;
1051
+ select?: string[] | null;
1052
+ emit?: string[] | null;
1053
+ params?: Record<string, any> | null;
1054
+ status?: string;
1055
+ }): Promise<any>;
1056
+ updateDatabaseTypeSubscription(appId: string, databaseType: string, subscriptionKey: string, data: Record<string, any>): Promise<any>;
1057
+ deleteDatabaseTypeSubscription(appId: string, databaseType: string, subscriptionKey: string): Promise<any>;
1058
+ listGroups(appId: string, params?: {
1059
+ type?: string;
1060
+ limit?: number;
1061
+ cursor?: string;
1062
+ }): Promise<{
1063
+ items: any[];
1064
+ cursor?: string;
1065
+ }>;
1066
+ createGroup(appId: string, data: {
1067
+ groupType: string;
1068
+ groupId?: string;
1069
+ name: string;
1070
+ description?: string;
1071
+ }): Promise<any>;
1072
+ getGroup(appId: string, groupType: string, groupId: string): Promise<any>;
1073
+ updateGroup(appId: string, groupType: string, groupId: string, data: {
1074
+ name?: string;
1075
+ description?: string;
1076
+ }): Promise<any>;
1077
+ deleteGroup(appId: string, groupType: string, groupId: string): Promise<any>;
1078
+ listGroupMembers(appId: string, groupType: string, groupId: string): Promise<{
1079
+ items: any[];
1080
+ cursor?: string;
1081
+ }>;
1082
+ addGroupMember(appId: string, groupType: string, groupId: string, data: {
1083
+ userId: string;
1084
+ }): Promise<any>;
1085
+ removeGroupMember(appId: string, groupType: string, groupId: string, userId: string): Promise<any>;
1086
+ listGroupDocuments(appId: string, groupType: string, groupId: string): Promise<any[]>;
1087
+ listUserMemberships(appId: string, userId: string): Promise<any[]>;
1088
+ listDocumentGroupPermissions(appId: string, documentId: string): Promise<any[]>;
1089
+ grantDocumentGroupPermission(appId: string, documentId: string, data: {
1090
+ groupType: string;
1091
+ groupId: string;
1092
+ permission: string;
1093
+ }): Promise<any>;
1094
+ revokeDocumentGroupPermission(appId: string, documentId: string, groupType: string, groupId: string): Promise<any>;
1095
+ listCollections(appId: string, params?: {
1096
+ limit?: number;
1097
+ cursor?: string;
1098
+ }): Promise<{
1099
+ items: any[];
1100
+ nextCursor?: string | null;
1101
+ }>;
1102
+ listAllCollections(appId: string, params?: {
1103
+ limit?: number;
1104
+ cursor?: string;
1105
+ }): Promise<{
1106
+ items: any[];
1107
+ nextCursor?: string | null;
1108
+ }>;
1109
+ createCollection(appId: string, data: {
1110
+ name: string;
1111
+ description?: string;
1112
+ }): Promise<any>;
1113
+ getCollection(appId: string, collectionId: string): Promise<any>;
1114
+ updateCollection(appId: string, collectionId: string, data: {
1115
+ name?: string;
1116
+ description?: string;
1117
+ }): Promise<any>;
1118
+ deleteCollection(appId: string, collectionId: string): Promise<any>;
1119
+ listCollectionDocuments(appId: string, collectionId: string, params?: {
1120
+ limit?: number;
1121
+ cursor?: string;
1122
+ }): Promise<{
1123
+ items: any[];
1124
+ nextCursor?: string | null;
1125
+ }>;
1126
+ addCollectionDocument(appId: string, collectionId: string, data: {
1127
+ documentId: string;
1128
+ }): Promise<any>;
1129
+ removeCollectionDocument(appId: string, collectionId: string, documentId: string): Promise<any>;
1130
+ listCollectionsForDocument(appId: string, documentId: string, params?: {
1131
+ limit?: number;
1132
+ cursor?: string;
1133
+ }): Promise<{
1134
+ items: any[];
1135
+ nextCursor?: string | null;
1136
+ }>;
1137
+ getCollectionAccess(appId: string, collectionId: string): Promise<any>;
1138
+ grantCollectionGroupPermission(appId: string, collectionId: string, data: {
1139
+ groupType: string;
1140
+ groupId: string;
1141
+ permission: string;
1142
+ }): Promise<any>;
1143
+ revokeCollectionGroupPermission(appId: string, collectionId: string, groupType: string, groupId: string): Promise<any>;
1144
+ addCollectionMember(appId: string, collectionId: string, data: {
1145
+ userId: string;
1146
+ permission: string;
1147
+ }): Promise<any>;
1148
+ removeCollectionMember(appId: string, collectionId: string, userId: string): Promise<any>;
1149
+ listCollectionTypeConfigs(appId: string): Promise<any[]>;
1150
+ getCollectionTypeConfig(appId: string, collectionType: string): Promise<any>;
1151
+ createCollectionTypeConfig(appId: string, data: {
1152
+ collectionType: string;
1153
+ ruleSetId?: string;
1154
+ metadataManifest?: any;
1155
+ }): Promise<any>;
1156
+ updateCollectionTypeConfig(appId: string, collectionType: string, data: {
1157
+ ruleSetId?: string | null;
1158
+ metadataManifest?: any;
1159
+ }, expectedModifiedAt?: string): Promise<any>;
1160
+ deleteCollectionTypeConfig(appId: string, collectionType: string): Promise<any>;
1161
+ /**
1162
+ * List all metadata category configs for an app. The route returns
1163
+ * `{ configs: [...] }`; unwrap to a bare array to match the other
1164
+ * `list*Configs` helpers.
1165
+ */
1166
+ listMetadataCategoryConfigs(appId: string): Promise<any[]>;
1167
+ getMetadataCategoryConfig(appId: string, resourceType: string, category: string): Promise<any>;
1168
+ /**
1169
+ * Create or replace a metadata category config (idempotent upsert via the
1170
+ * path-addressed PUT route). `resourceType` / `category` identify the config;
1171
+ * the body carries `schema` / `readRule` / `writeRule` / `description`.
1172
+ */
1173
+ upsertMetadataCategoryConfig(appId: string, resourceType: string, category: string, data: {
1174
+ schema: unknown;
1175
+ readRule?: string | null;
1176
+ writeRule?: string | null;
1177
+ description?: string | null;
1178
+ }): Promise<any>;
1179
+ listRuleSets(appId: string, params?: {
1180
+ resourceType?: string;
1181
+ }): Promise<any[]>;
1182
+ createRuleSet(appId: string, data: {
1183
+ name: string;
1184
+ resourceType: string;
1185
+ rules: Record<string, any>;
1186
+ description?: string;
1187
+ }): Promise<any>;
1188
+ getRuleSet(appId: string, ruleSetId: string): Promise<any>;
1189
+ updateRuleSet(appId: string, ruleSetId: string, data: {
1190
+ name?: string;
1191
+ description?: string;
1192
+ rules?: Record<string, any>;
1193
+ }, expectedModifiedAt?: string): Promise<any>;
1194
+ deleteRuleSet(appId: string, ruleSetId: string): Promise<any>;
1195
+ getRuleSetSchema(appId: string): Promise<any>;
1196
+ getRuleSetResourceTypes(appId: string): Promise<{
1197
+ resourceTypes: string[];
1198
+ }>;
1199
+ testRuleSet(appId: string, ruleSetId: string, data: any): Promise<any>;
1200
+ debugRuleSet(appId: string, data: any): Promise<any>;
1201
+ listGroupTypeConfigs(appId: string): Promise<any[]>;
1202
+ getGroupTypeConfig(appId: string, groupType: string): Promise<any>;
1203
+ createGroupTypeConfig(appId: string, data: {
1204
+ groupType: string;
1205
+ ruleSetId?: string;
1206
+ autoAddCreator?: boolean;
1207
+ metadataManifest?: any;
1208
+ }): Promise<any>;
1209
+ updateGroupTypeConfig(appId: string, groupType: string, data: {
1210
+ ruleSetId?: string | null;
1211
+ autoAddCreator?: boolean;
1212
+ metadataManifest?: any;
1213
+ }, expectedModifiedAt?: string): Promise<any>;
1214
+ deleteGroupTypeConfig(appId: string, groupType: string): Promise<any>;
1215
+ exportDocumentState(appId: string, documentId: string): Promise<{
1216
+ state: string;
1217
+ byteLength: number;
1218
+ documentId: string;
1219
+ }>;
1220
+ importDocumentState(appId: string, documentId: string, stateBase64: string): Promise<any>;
1221
+ getDocument(appId: string, documentId: string): Promise<any>;
1222
+ createDocument(appId: string, data: {
1223
+ title: string;
1224
+ documentId?: string;
1225
+ tags?: string[];
1226
+ createdBy?: string;
1227
+ }): Promise<any>;
1228
+ listDocumentPermissions(appId: string, documentId: string): Promise<any[]>;
1229
+ grantDocumentPermission(appId: string, documentId: string, permissions: Array<{
1230
+ userId: string;
1231
+ permission: string;
1232
+ }>): Promise<any>;
1233
+ listDocumentInvitations(appId: string, documentId: string): Promise<any[]>;
1234
+ listDocumentBlobs(appId: string, documentId: string): Promise<any[]>;
1235
+ downloadBlob(appId: string, documentId: string, blobId: string): Promise<Buffer>;
1236
+ uploadBlob(appId: string, documentId: string, blobId: string, data: Buffer, meta: {
1237
+ filename: string;
1238
+ contentType: string;
1239
+ sha256: string;
1240
+ }): Promise<any>;
1241
+ listDocumentAliases(appId: string, documentId: string): Promise<any[]>;
1242
+ setDocumentAlias(appId: string, aliasScope: string, aliasKey: string, documentId: string, ownerUserId?: string, mustNotExist?: boolean): Promise<any>;
1243
+ findUserByEmail(appId: string, email: string): Promise<any | null>;
1244
+ listAdminDocuments(appId: string, userId: string): Promise<any[]>;
1245
+ saveDatabaseRecord(appId: string, databaseId: string, modelName: string, id: string, data: any): Promise<any>;
1246
+ batchDatabaseRecords(appId: string, databaseId: string, operations: any[]): Promise<any>;
1247
+ deleteDatabaseRecord(appId: string, databaseId: string, modelName: string, id: string): Promise<any>;
1248
+ batchDeleteDatabaseRecords(appId: string, databaseId: string, operations: {
1249
+ op: "delete";
1250
+ modelName: string;
1251
+ id: string;
1252
+ }[]): Promise<any>;
1253
+ listDatabaseUniqueConstraints(appId: string, databaseId: string): Promise<any[]>;
1254
+ registerDatabaseUniqueConstraint(appId: string, databaseId: string, constraint: {
1255
+ modelName: string;
1256
+ constraintName: string;
1257
+ fields: string[];
1258
+ }): Promise<any>;
1259
+ listBlobBuckets(appId: string): Promise<{
1260
+ items: any[];
1261
+ }>;
1262
+ createBlobBucket(appId: string, payload: any): Promise<any>;
1263
+ getBlobBucket(appId: string, bucketIdOrKey: string): Promise<any>;
1264
+ updateBlobBucket(appId: string, bucketIdOrKey: string, payload: any): Promise<any>;
1265
+ deleteBlobBucket(appId: string, bucketIdOrKey: string): Promise<any>;
1266
+ listBucketBlobs(appId: string, bucketIdOrKey: string, params?: {
1267
+ cursor?: string;
1268
+ limit?: number;
1269
+ }): Promise<{
1270
+ items: any[];
1271
+ cursor?: string;
1272
+ }>;
1273
+ uploadBucketBlob(appId: string, bucketIdOrKey: string, data: Buffer, meta: {
1274
+ filename: string;
1275
+ contentType: string;
1276
+ tags?: string[];
1277
+ }): Promise<any>;
1278
+ downloadBucketBlob(appId: string, bucketIdOrKey: string, blobId: string): Promise<Buffer>;
1279
+ deleteBucketBlob(appId: string, bucketIdOrKey: string, blobId: string): Promise<any>;
1280
+ getBucketBlobSignedUrl(appId: string, bucketIdOrKey: string, blobId: string, expiresInSeconds?: number): Promise<any>;
1281
+ }
1282
+ export declare const apiClient: ApiClient;
1283
+ export {};