@tapi-dev/sdk 0.1.34 → 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 +1208 -189
- 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 +54 -5
- package/dist/types.d.ts +55 -54
- package/dist/workspace.d.ts +0 -6
- package/dist/workspace.js +6 -4
- 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,62 +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
|
-
serviceRun
|
|
182
|
-
service?: string;
|
|
183
|
-
apiRequest?: string;
|
|
181
|
+
serviceRun: string;
|
|
184
182
|
enabled?: boolean;
|
|
185
|
-
schedule?:
|
|
183
|
+
schedule?: ServiceTriggerSchedule;
|
|
186
184
|
inputs?: Record<string, unknown>;
|
|
187
185
|
runtime?: RuntimeRunOptions;
|
|
188
|
-
|
|
186
|
+
queueId: string;
|
|
189
187
|
priority?: number;
|
|
190
188
|
site?: string;
|
|
191
|
-
sitemapId?: string;
|
|
192
189
|
}
|
|
193
|
-
export interface
|
|
190
|
+
export interface ServiceTriggerUpdateRequest {
|
|
194
191
|
enabled: boolean;
|
|
195
192
|
}
|
|
196
|
-
export interface
|
|
193
|
+
export interface ServiceTrigger {
|
|
197
194
|
id: string;
|
|
198
195
|
name: string;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
196
|
+
serviceRun: string;
|
|
197
|
+
serviceName: string;
|
|
198
|
+
serviceKey: string;
|
|
202
199
|
site?: string;
|
|
203
200
|
enabled: boolean;
|
|
204
|
-
schedule?:
|
|
201
|
+
schedule?: ServiceTriggerSchedule | Record<string, unknown>;
|
|
205
202
|
inputs?: Record<string, unknown>;
|
|
206
203
|
runtime?: RuntimeRunOptions | Record<string, unknown>;
|
|
207
|
-
|
|
204
|
+
queueId?: string;
|
|
208
205
|
priority?: number;
|
|
209
206
|
lastRun?: TapiRun | Record<string, unknown> | null;
|
|
210
207
|
lastError?: string;
|
|
@@ -214,39 +211,43 @@ export interface WebsiteApiTrigger {
|
|
|
214
211
|
updatedAt?: string;
|
|
215
212
|
[key: string]: unknown;
|
|
216
213
|
}
|
|
217
|
-
export interface
|
|
218
|
-
triggers:
|
|
214
|
+
export interface ServiceTriggerList {
|
|
215
|
+
triggers: ServiceTrigger[];
|
|
219
216
|
}
|
|
220
|
-
export interface
|
|
217
|
+
export interface ServiceTriggerRunResult {
|
|
221
218
|
success: boolean;
|
|
222
|
-
trigger:
|
|
219
|
+
trigger: ServiceTrigger;
|
|
223
220
|
run: TapiRun | Record<string, unknown>;
|
|
224
221
|
}
|
|
225
222
|
export interface TapiRun {
|
|
226
223
|
id: string;
|
|
227
224
|
status: RunStatus;
|
|
228
|
-
|
|
229
|
-
|
|
225
|
+
serviceName: string;
|
|
226
|
+
serviceKey: string;
|
|
227
|
+
serviceRun?: string;
|
|
228
|
+
tappId?: string;
|
|
229
|
+
queueId?: string;
|
|
230
|
+
runnerId?: string;
|
|
231
|
+
slotIndex?: number;
|
|
232
|
+
deviceId?: string;
|
|
230
233
|
result?: Record<string, unknown> | null;
|
|
231
234
|
error?: Record<string, unknown> | null;
|
|
232
235
|
runtime?: RuntimeRunOptions | Record<string, unknown> | null;
|
|
233
|
-
waitingInput?:
|
|
234
|
-
pendingInputs?:
|
|
236
|
+
waitingInput?: ServiceWaitingInput | null;
|
|
237
|
+
pendingInputs?: ServiceWaitingInput[];
|
|
235
238
|
createdAt?: string;
|
|
236
239
|
updatedAt?: string;
|
|
237
240
|
[key: string]: unknown;
|
|
238
241
|
}
|
|
239
|
-
export type ServiceInputContract = WebsiteApiInputContract;
|
|
240
|
-
export type ServiceOutputContract = WebsiteApiOutputContract;
|
|
241
|
-
export type ServiceOperation = WebsiteApiOperation;
|
|
242
242
|
export type TapiDevSessionStatus = "queued" | "running" | "waiting_for_input" | "awaiting_takeover" | "needs_developer_attention" | "completed" | "failed" | "cancelled" | string;
|
|
243
243
|
export interface TapiDevSession {
|
|
244
244
|
id: string;
|
|
245
245
|
projectId: string;
|
|
246
246
|
sitemap: string;
|
|
247
247
|
site?: string;
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
serviceName: string;
|
|
249
|
+
serviceKey: string;
|
|
250
|
+
serviceRun?: string;
|
|
250
251
|
status: TapiDevSessionStatus;
|
|
251
252
|
stateId?: number | null;
|
|
252
253
|
stateLabel?: string;
|
|
@@ -269,7 +270,7 @@ export interface TapiDevSessionsList {
|
|
|
269
270
|
projectId: string;
|
|
270
271
|
groups: TapiDevSessionGroup[];
|
|
271
272
|
}
|
|
272
|
-
export interface
|
|
273
|
+
export interface ServiceWaitingInput {
|
|
273
274
|
key: string;
|
|
274
275
|
label?: string;
|
|
275
276
|
stateId?: number;
|
|
@@ -318,6 +319,7 @@ export interface RuntimeProfile {
|
|
|
318
319
|
[key: string]: unknown;
|
|
319
320
|
}
|
|
320
321
|
export interface RuntimeRunOptions {
|
|
322
|
+
owner?: "service_run";
|
|
321
323
|
profileRef?: string;
|
|
322
324
|
destroyOnRelease?: boolean;
|
|
323
325
|
[key: string]: unknown;
|
|
@@ -378,24 +380,23 @@ export interface SdkCatalogRequest {
|
|
|
378
380
|
status: string;
|
|
379
381
|
operation?: string;
|
|
380
382
|
sdkName?: string;
|
|
381
|
-
sitemapId?: string;
|
|
382
383
|
deviceMode?: "desktop" | "mobile" | string;
|
|
383
384
|
runtime?: RuntimeRunOptions | Record<string, unknown>;
|
|
384
|
-
inputs?:
|
|
385
|
+
inputs?: ServiceInputContract[];
|
|
385
386
|
inputSchema?: Record<string, unknown>;
|
|
386
387
|
outputSchema?: Record<string, unknown>;
|
|
387
388
|
responseSchema?: Record<string, unknown>;
|
|
388
389
|
[key: string]: unknown;
|
|
389
390
|
}
|
|
390
|
-
export interface
|
|
391
|
+
export interface SdkCatalogService {
|
|
391
392
|
name: string;
|
|
392
|
-
|
|
393
|
+
serviceName: string;
|
|
394
|
+
version?: string;
|
|
393
395
|
site?: string;
|
|
394
|
-
sitemapId?: string;
|
|
395
396
|
requests: SdkCatalogRequest[];
|
|
396
397
|
[key: string]: unknown;
|
|
397
398
|
}
|
|
398
399
|
export interface SdkCatalog {
|
|
399
|
-
|
|
400
|
+
services: SdkCatalogService[];
|
|
400
401
|
[key: string]: unknown;
|
|
401
402
|
}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
export declare const TAPI_WORKSPACE_DIR = ".tapi";
|
|
2
2
|
export declare const TAPI_WORKSPACE_CONFIG = "project.json";
|
|
3
|
-
export interface TapiGeneratedConfig {
|
|
4
|
-
catalog?: string;
|
|
5
|
-
typescript?: string;
|
|
6
|
-
[key: string]: unknown;
|
|
7
|
-
}
|
|
8
3
|
export interface TapiServicesConfig {
|
|
9
4
|
catalog?: string;
|
|
10
5
|
typescript?: string;
|
|
@@ -16,7 +11,6 @@ export interface TapiWorkspaceConfig {
|
|
|
16
11
|
projectSlug?: string;
|
|
17
12
|
apiBaseUrl?: string;
|
|
18
13
|
services?: TapiServicesConfig;
|
|
19
|
-
generated?: TapiGeneratedConfig;
|
|
20
14
|
[key: string]: unknown;
|
|
21
15
|
}
|
|
22
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) {
|
|
@@ -52,15 +53,17 @@ export function readWorkspaceConfig(configPath) {
|
|
|
52
53
|
const projectSlug = optionalProjectValue(parsed.projectSlug, "projectSlug");
|
|
53
54
|
const apiBaseUrl = typeof parsed.apiBaseUrl === "string" && parsed.apiBaseUrl.trim() ? parsed.apiBaseUrl.trim() : undefined;
|
|
54
55
|
const services = isRecord(parsed.services) ? { ...parsed.services } : undefined;
|
|
55
|
-
|
|
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 };
|
|
56
60
|
return {
|
|
57
|
-
...
|
|
61
|
+
...config,
|
|
58
62
|
version: 1,
|
|
59
63
|
projectId,
|
|
60
64
|
...(projectSlug ? { projectSlug } : {}),
|
|
61
65
|
...(apiBaseUrl ? { apiBaseUrl } : {}),
|
|
62
66
|
...(services ? { services } : {}),
|
|
63
|
-
...(generated ? { generated } : {}),
|
|
64
67
|
};
|
|
65
68
|
}
|
|
66
69
|
export async function writeWorkspaceConfig(options) {
|
|
@@ -78,7 +81,6 @@ export async function writeWorkspaceConfig(options) {
|
|
|
78
81
|
...(options.apiBaseUrl ? { apiBaseUrl: options.apiBaseUrl } : {}),
|
|
79
82
|
services: {
|
|
80
83
|
catalog: ".tapi/services/catalog.json",
|
|
81
|
-
typescript: "src/tapi.services.ts",
|
|
82
84
|
},
|
|
83
85
|
};
|
|
84
86
|
await mkdir(dirname(configPath), { recursive: true });
|