@tapi-dev/sdk 0.1.33 → 0.1.36
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.
- package/README.md +160 -120
- package/dist/catalog.js +3 -2
- package/dist/cli.d.ts +30 -0
- package/dist/cli.js +1255 -232
- package/dist/client.d.ts +1 -0
- package/dist/client.js +11 -1
- package/dist/cloud-runs.js +5 -4
- package/dist/runs.js +7 -6
- package/dist/service-contract.d.ts +6 -0
- package/dist/service-contract.js +84 -0
- package/dist/services.d.ts +6 -5
- package/dist/services.js +119 -20
- package/dist/sessions.js +3 -2
- package/dist/triggers.d.ts +8 -8
- package/dist/triggers.js +61 -1
- package/dist/types.d.ts +55 -52
- package/dist/workspace.d.ts +2 -2
- package/dist/workspace.js +10 -6
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -3,20 +3,20 @@ export type RunStatus = "queued" | "running" | "waiting_for_input" | "completed"
|
|
|
3
3
|
export interface TapiClientOptions {
|
|
4
4
|
baseUrl: string;
|
|
5
5
|
apiKey: string;
|
|
6
|
+
tappId: string;
|
|
6
7
|
projectId?: string;
|
|
7
8
|
dev?: boolean;
|
|
8
9
|
fetch?: typeof fetch;
|
|
9
10
|
localControlUrl?: string;
|
|
10
11
|
webSocket?: LocalWebSocketConstructor;
|
|
11
12
|
}
|
|
12
|
-
export interface
|
|
13
|
+
export interface ServiceRunRequest {
|
|
14
|
+
queueId: string;
|
|
13
15
|
inputs?: Record<string, unknown | LateInput<unknown>>;
|
|
14
16
|
runtime?: RuntimeRunOptions;
|
|
15
17
|
priority?: number;
|
|
16
|
-
runnerId?: string;
|
|
17
18
|
idempotencyKey?: string;
|
|
18
19
|
site?: string;
|
|
19
|
-
sitemapId?: string;
|
|
20
20
|
}
|
|
21
21
|
export interface CloudRunOptions {
|
|
22
22
|
windows?: boolean;
|
|
@@ -33,23 +33,23 @@ export interface CloudRunPaymentOptions {
|
|
|
33
33
|
successUrl?: string;
|
|
34
34
|
cancelUrl?: string;
|
|
35
35
|
}
|
|
36
|
-
export interface
|
|
36
|
+
export interface ServiceCloudQuoteRequest {
|
|
37
37
|
inputs?: Array<Record<string, unknown>>;
|
|
38
38
|
cloud?: CloudRunOptions;
|
|
39
39
|
user?: CloudRunUser;
|
|
40
|
+
runtime?: RuntimeRunOptions;
|
|
40
41
|
site?: string;
|
|
41
42
|
}
|
|
42
|
-
export interface
|
|
43
|
+
export interface ServiceCloudBatchRequest {
|
|
43
44
|
inputs: Array<Record<string, unknown>>;
|
|
45
|
+
queueId: string;
|
|
44
46
|
cloud?: CloudRunOptions;
|
|
45
47
|
user?: CloudRunUser;
|
|
48
|
+
runtime?: RuntimeRunOptions;
|
|
46
49
|
payment?: CloudRunPaymentOptions;
|
|
47
50
|
site?: string;
|
|
48
51
|
idempotencyKey?: string;
|
|
49
52
|
}
|
|
50
|
-
export type ServiceRunRequest = WebsiteApiRunRequest;
|
|
51
|
-
export type ServiceCloudQuoteRequest = WebsiteApiCloudQuoteRequest;
|
|
52
|
-
export type ServiceCloudBatchRequest = WebsiteApiCloudBatchRequest;
|
|
53
53
|
export interface CloudRunQuote {
|
|
54
54
|
inputCount: number;
|
|
55
55
|
windows: boolean;
|
|
@@ -71,8 +71,9 @@ export interface CloudRunQuote {
|
|
|
71
71
|
export interface CloudBatchRun {
|
|
72
72
|
id: string;
|
|
73
73
|
status: RunStatus | "payment_required" | "provisioning";
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
serviceName: string;
|
|
75
|
+
serviceKey: string;
|
|
76
|
+
serviceRun?: string;
|
|
76
77
|
site?: string;
|
|
77
78
|
inputCount?: number;
|
|
78
79
|
completedCount?: number;
|
|
@@ -138,7 +139,7 @@ export interface CloudCreditCheckout {
|
|
|
138
139
|
paymentProvider: "stripe" | string;
|
|
139
140
|
paymentProviderEnabled: boolean;
|
|
140
141
|
}
|
|
141
|
-
export interface
|
|
142
|
+
export interface ServiceInputContract {
|
|
142
143
|
key: string;
|
|
143
144
|
label?: string;
|
|
144
145
|
type?: string;
|
|
@@ -149,60 +150,58 @@ export interface WebsiteApiInputContract {
|
|
|
149
150
|
default?: unknown;
|
|
150
151
|
[key: string]: unknown;
|
|
151
152
|
}
|
|
152
|
-
export interface
|
|
153
|
+
export interface ServiceOutputContract {
|
|
153
154
|
key: string;
|
|
154
155
|
type?: string;
|
|
155
156
|
[key: string]: unknown;
|
|
156
157
|
}
|
|
157
|
-
export interface
|
|
158
|
+
export interface ServiceOperation {
|
|
158
159
|
name: string;
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
serviceName: string;
|
|
161
|
+
serviceKey: string;
|
|
162
|
+
serviceRun?: string;
|
|
161
163
|
site?: string;
|
|
162
|
-
sitemapId?: string;
|
|
163
164
|
version?: string;
|
|
164
165
|
status?: string;
|
|
165
|
-
publishedAt?: string | null;
|
|
166
166
|
deviceMode?: "desktop" | "mobile" | string;
|
|
167
167
|
runtime?: RuntimeRunOptions | Record<string, unknown>;
|
|
168
|
-
inputs:
|
|
169
|
-
outputs?:
|
|
168
|
+
inputs: ServiceInputContract[];
|
|
169
|
+
outputs?: ServiceOutputContract[];
|
|
170
170
|
inputSchema?: Record<string, unknown>;
|
|
171
171
|
outputSchema?: Record<string, unknown>;
|
|
172
172
|
[key: string]: unknown;
|
|
173
173
|
}
|
|
174
|
-
export interface
|
|
174
|
+
export interface ServiceTriggerSchedule {
|
|
175
175
|
intervalSeconds?: number;
|
|
176
176
|
cron?: string;
|
|
177
177
|
[key: string]: unknown;
|
|
178
178
|
}
|
|
179
|
-
export interface
|
|
179
|
+
export interface ServiceTriggerCreateRequest {
|
|
180
180
|
name: string;
|
|
181
|
-
|
|
181
|
+
serviceRun: string;
|
|
182
182
|
enabled?: boolean;
|
|
183
|
-
schedule?:
|
|
183
|
+
schedule?: ServiceTriggerSchedule;
|
|
184
184
|
inputs?: Record<string, unknown>;
|
|
185
185
|
runtime?: RuntimeRunOptions;
|
|
186
|
-
|
|
186
|
+
queueId: string;
|
|
187
187
|
priority?: number;
|
|
188
188
|
site?: string;
|
|
189
|
-
sitemapId?: string;
|
|
190
189
|
}
|
|
191
|
-
export interface
|
|
190
|
+
export interface ServiceTriggerUpdateRequest {
|
|
192
191
|
enabled: boolean;
|
|
193
192
|
}
|
|
194
|
-
export interface
|
|
193
|
+
export interface ServiceTrigger {
|
|
195
194
|
id: string;
|
|
196
195
|
name: string;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
serviceRun: string;
|
|
197
|
+
serviceName: string;
|
|
198
|
+
serviceKey: string;
|
|
200
199
|
site?: string;
|
|
201
200
|
enabled: boolean;
|
|
202
|
-
schedule?:
|
|
201
|
+
schedule?: ServiceTriggerSchedule | Record<string, unknown>;
|
|
203
202
|
inputs?: Record<string, unknown>;
|
|
204
203
|
runtime?: RuntimeRunOptions | Record<string, unknown>;
|
|
205
|
-
|
|
204
|
+
queueId?: string;
|
|
206
205
|
priority?: number;
|
|
207
206
|
lastRun?: TapiRun | Record<string, unknown> | null;
|
|
208
207
|
lastError?: string;
|
|
@@ -212,39 +211,43 @@ export interface WebsiteApiTrigger {
|
|
|
212
211
|
updatedAt?: string;
|
|
213
212
|
[key: string]: unknown;
|
|
214
213
|
}
|
|
215
|
-
export interface
|
|
216
|
-
triggers:
|
|
214
|
+
export interface ServiceTriggerList {
|
|
215
|
+
triggers: ServiceTrigger[];
|
|
217
216
|
}
|
|
218
|
-
export interface
|
|
217
|
+
export interface ServiceTriggerRunResult {
|
|
219
218
|
success: boolean;
|
|
220
|
-
trigger:
|
|
219
|
+
trigger: ServiceTrigger;
|
|
221
220
|
run: TapiRun | Record<string, unknown>;
|
|
222
221
|
}
|
|
223
222
|
export interface TapiRun {
|
|
224
223
|
id: string;
|
|
225
224
|
status: RunStatus;
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
serviceName: string;
|
|
226
|
+
serviceKey: string;
|
|
227
|
+
serviceRun?: string;
|
|
228
|
+
tappId?: string;
|
|
229
|
+
queueId?: string;
|
|
230
|
+
runnerId?: string;
|
|
231
|
+
slotIndex?: number;
|
|
232
|
+
deviceId?: string;
|
|
228
233
|
result?: Record<string, unknown> | null;
|
|
229
234
|
error?: Record<string, unknown> | null;
|
|
230
235
|
runtime?: RuntimeRunOptions | Record<string, unknown> | null;
|
|
231
|
-
waitingInput?:
|
|
232
|
-
pendingInputs?:
|
|
236
|
+
waitingInput?: ServiceWaitingInput | null;
|
|
237
|
+
pendingInputs?: ServiceWaitingInput[];
|
|
233
238
|
createdAt?: string;
|
|
234
239
|
updatedAt?: string;
|
|
235
240
|
[key: string]: unknown;
|
|
236
241
|
}
|
|
237
|
-
export type ServiceInputContract = WebsiteApiInputContract;
|
|
238
|
-
export type ServiceOutputContract = WebsiteApiOutputContract;
|
|
239
|
-
export type ServiceOperation = WebsiteApiOperation;
|
|
240
242
|
export type TapiDevSessionStatus = "queued" | "running" | "waiting_for_input" | "awaiting_takeover" | "needs_developer_attention" | "completed" | "failed" | "cancelled" | string;
|
|
241
243
|
export interface TapiDevSession {
|
|
242
244
|
id: string;
|
|
243
245
|
projectId: string;
|
|
244
246
|
sitemap: string;
|
|
245
247
|
site?: string;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
+
serviceName: string;
|
|
249
|
+
serviceKey: string;
|
|
250
|
+
serviceRun?: string;
|
|
248
251
|
status: TapiDevSessionStatus;
|
|
249
252
|
stateId?: number | null;
|
|
250
253
|
stateLabel?: string;
|
|
@@ -267,7 +270,7 @@ export interface TapiDevSessionsList {
|
|
|
267
270
|
projectId: string;
|
|
268
271
|
groups: TapiDevSessionGroup[];
|
|
269
272
|
}
|
|
270
|
-
export interface
|
|
273
|
+
export interface ServiceWaitingInput {
|
|
271
274
|
key: string;
|
|
272
275
|
label?: string;
|
|
273
276
|
stateId?: number;
|
|
@@ -316,6 +319,7 @@ export interface RuntimeProfile {
|
|
|
316
319
|
[key: string]: unknown;
|
|
317
320
|
}
|
|
318
321
|
export interface RuntimeRunOptions {
|
|
322
|
+
owner?: "service_run";
|
|
319
323
|
profileRef?: string;
|
|
320
324
|
destroyOnRelease?: boolean;
|
|
321
325
|
[key: string]: unknown;
|
|
@@ -376,24 +380,23 @@ export interface SdkCatalogRequest {
|
|
|
376
380
|
status: string;
|
|
377
381
|
operation?: string;
|
|
378
382
|
sdkName?: string;
|
|
379
|
-
sitemapId?: string;
|
|
380
383
|
deviceMode?: "desktop" | "mobile" | string;
|
|
381
384
|
runtime?: RuntimeRunOptions | Record<string, unknown>;
|
|
382
|
-
inputs?:
|
|
385
|
+
inputs?: ServiceInputContract[];
|
|
383
386
|
inputSchema?: Record<string, unknown>;
|
|
384
387
|
outputSchema?: Record<string, unknown>;
|
|
385
388
|
responseSchema?: Record<string, unknown>;
|
|
386
389
|
[key: string]: unknown;
|
|
387
390
|
}
|
|
388
|
-
export interface
|
|
391
|
+
export interface SdkCatalogService {
|
|
389
392
|
name: string;
|
|
390
|
-
|
|
393
|
+
serviceName: string;
|
|
394
|
+
version?: string;
|
|
391
395
|
site?: string;
|
|
392
|
-
sitemapId?: string;
|
|
393
396
|
requests: SdkCatalogRequest[];
|
|
394
397
|
[key: string]: unknown;
|
|
395
398
|
}
|
|
396
399
|
export interface SdkCatalog {
|
|
397
|
-
|
|
400
|
+
services: SdkCatalogService[];
|
|
398
401
|
[key: string]: unknown;
|
|
399
402
|
}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const TAPI_WORKSPACE_DIR = ".tapi";
|
|
2
2
|
export declare const TAPI_WORKSPACE_CONFIG = "project.json";
|
|
3
|
-
export interface
|
|
3
|
+
export interface TapiServicesConfig {
|
|
4
4
|
catalog?: string;
|
|
5
5
|
typescript?: string;
|
|
6
6
|
[key: string]: unknown;
|
|
@@ -10,7 +10,7 @@ export interface TapiWorkspaceConfig {
|
|
|
10
10
|
projectId: string;
|
|
11
11
|
projectSlug?: string;
|
|
12
12
|
apiBaseUrl?: string;
|
|
13
|
-
|
|
13
|
+
services?: TapiServicesConfig;
|
|
14
14
|
[key: string]: unknown;
|
|
15
15
|
}
|
|
16
16
|
export interface TapiWorkspace {
|
package/dist/workspace.js
CHANGED
|
@@ -3,6 +3,7 @@ import { mkdir, writeFile } from "node:fs/promises";
|
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
export const TAPI_WORKSPACE_DIR = ".tapi";
|
|
5
5
|
export const TAPI_WORKSPACE_CONFIG = "project.json";
|
|
6
|
+
const RETIRED_SERVICE_HELPER_CONFIG_KEY = "gener" + "ated";
|
|
6
7
|
export function findWorkspaceConfigPath(startDir = process.cwd()) {
|
|
7
8
|
let current = resolve(startDir);
|
|
8
9
|
while (true) {
|
|
@@ -51,14 +52,18 @@ export function readWorkspaceConfig(configPath) {
|
|
|
51
52
|
const projectId = normalizeProjectValue(parsed.projectId, "projectId");
|
|
52
53
|
const projectSlug = optionalProjectValue(parsed.projectSlug, "projectSlug");
|
|
53
54
|
const apiBaseUrl = typeof parsed.apiBaseUrl === "string" && parsed.apiBaseUrl.trim() ? parsed.apiBaseUrl.trim() : undefined;
|
|
54
|
-
const
|
|
55
|
+
const services = isRecord(parsed.services) ? { ...parsed.services } : undefined;
|
|
56
|
+
if (Object.prototype.hasOwnProperty.call(parsed, RETIRED_SERVICE_HELPER_CONFIG_KEY)) {
|
|
57
|
+
throw new Error(`Tapi workspace config at ${configPath} uses retired service helper config. Remove '${RETIRED_SERVICE_HELPER_CONFIG_KEY}' and use 'services' instead.`);
|
|
58
|
+
}
|
|
59
|
+
const config = { ...parsed };
|
|
55
60
|
return {
|
|
56
|
-
...
|
|
61
|
+
...config,
|
|
57
62
|
version: 1,
|
|
58
63
|
projectId,
|
|
59
64
|
...(projectSlug ? { projectSlug } : {}),
|
|
60
65
|
...(apiBaseUrl ? { apiBaseUrl } : {}),
|
|
61
|
-
...(
|
|
66
|
+
...(services ? { services } : {}),
|
|
62
67
|
};
|
|
63
68
|
}
|
|
64
69
|
export async function writeWorkspaceConfig(options) {
|
|
@@ -74,9 +79,8 @@ export async function writeWorkspaceConfig(options) {
|
|
|
74
79
|
projectId,
|
|
75
80
|
projectSlug,
|
|
76
81
|
...(options.apiBaseUrl ? { apiBaseUrl: options.apiBaseUrl } : {}),
|
|
77
|
-
|
|
78
|
-
catalog: ".tapi/
|
|
79
|
-
typescript: "src/tapi.generated.ts",
|
|
82
|
+
services: {
|
|
83
|
+
catalog: ".tapi/services/catalog.json",
|
|
80
84
|
},
|
|
81
85
|
};
|
|
82
86
|
await mkdir(dirname(configPath), { recursive: true });
|