@tapi-dev/sdk 0.1.36 → 0.1.39
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 +60 -48
- package/dist/cli.d.ts +3 -1
- package/dist/cli.js +459 -255
- package/dist/client.d.ts +1 -1
- package/dist/client.js +10 -3
- package/dist/types.d.ts +1 -1
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -13,20 +13,32 @@ This package is ESM-first and works in runtimes with `fetch`, including modern N
|
|
|
13
13
|
The CLI command is `tapi`. If your package manager only installed the SDK
|
|
14
14
|
locally and `tapi` is not on `PATH`, use `npx tapi` as a fallback.
|
|
15
15
|
|
|
16
|
-
## Developer Flow
|
|
17
|
-
|
|
18
|
-
Tapi Studio is launched from the developer
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
tapi
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
## Developer Flow
|
|
17
|
+
|
|
18
|
+
Tapi Studio is launched from the signed-in developer account. Running
|
|
19
|
+
`tapi studio` lists the Tapps available to that account, asks which one to open,
|
|
20
|
+
then starts Studio in that Tapp context. The current directory can still provide
|
|
21
|
+
a default via `.tapi/project.json`, but it is no longer required for Studio to
|
|
22
|
+
know which Tapp to show.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @tapi-dev/sdk
|
|
26
|
+
tapi login
|
|
27
|
+
tapi tapp create brokerage
|
|
28
|
+
tapi studio
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Useful Studio launch forms:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
tapi studio # ask which Tapp to open
|
|
35
|
+
tapi studio --tapp brokerage # open one Tapp directly
|
|
36
|
+
tapi studio --select # force the picker
|
|
37
|
+
tapi studio --last # reuse the last selected Tapp
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`tapi studio` checks the required local `tapi-service`, installs it when needed,
|
|
41
|
+
downloads the portable Studio server release when the channel manifest uses
|
|
30
42
|
`installerKind: portable-server`, starts Studio locally, and opens the browser.
|
|
31
43
|
If the channel still publishes a legacy NSIS desktop Studio manifest and no
|
|
32
44
|
Studio executable is installed yet, `tapi studio` runs the installer first, then
|
|
@@ -52,10 +64,12 @@ The current artifact and current release are kept.
|
|
|
52
64
|
|
|
53
65
|
Useful commands:
|
|
54
66
|
|
|
55
|
-
```bash
|
|
56
|
-
tapi
|
|
57
|
-
tapi
|
|
67
|
+
```bash
|
|
68
|
+
tapi login
|
|
69
|
+
tapi init --project brokerage
|
|
70
|
+
tapi link --project brokerage
|
|
58
71
|
tapi studio
|
|
72
|
+
tapi studio --tapp brokerage
|
|
59
73
|
tapi service install --channel pilot
|
|
60
74
|
tapi service status
|
|
61
75
|
tapi services describe schwab.place_order
|
|
@@ -80,8 +94,8 @@ ServiceMaps and service-run contracts are saved in the bound Tapi server
|
|
|
80
94
|
project. Runtime SDK calls read the service catalog from that project.
|
|
81
95
|
|
|
82
96
|
```bash
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
tapi tapp create brokerage --name "Brokerage"
|
|
98
|
+
tapi tapp service add brokerage schwab.place_order \
|
|
85
99
|
--service-map sm_123 \
|
|
86
100
|
--entry place_order
|
|
87
101
|
```
|
|
@@ -102,23 +116,23 @@ page that can create or accept a queue id, attach that queue to the Tapp, and
|
|
|
102
116
|
assign one or more slots on the runner:
|
|
103
117
|
|
|
104
118
|
```bash
|
|
105
|
-
|
|
119
|
+
tapi runner setup \
|
|
106
120
|
--runner-id john-laptop \
|
|
107
121
|
--project brokerage
|
|
108
122
|
```
|
|
109
123
|
|
|
110
124
|
## Quick Start
|
|
111
125
|
|
|
112
|
-
Create one TAPI client in server-side app code. Use a
|
|
113
|
-
|
|
114
|
-
`.tapi/project.json`.
|
|
126
|
+
Create one TAPI client in server-side app code. Use a Firebase ID token for the
|
|
127
|
+
developer identity that owns and pays for the Tapp, the Tapp id that owns the
|
|
128
|
+
service call, and optionally the same project id from `.tapi/project.json`.
|
|
115
129
|
|
|
116
130
|
```ts
|
|
117
131
|
import { TapiClient } from "@tapi-dev/sdk";
|
|
118
132
|
|
|
119
133
|
export const tapi = new TapiClient({
|
|
120
134
|
baseUrl: process.env.TAPI_BASE_URL!,
|
|
121
|
-
|
|
135
|
+
authToken: process.env.TAPI_FIREBASE_ID_TOKEN!,
|
|
122
136
|
tappId: process.env.TAPI_TAPP_ID!,
|
|
123
137
|
projectId: process.env.TAPI_PROJECT_ID!,
|
|
124
138
|
});
|
|
@@ -130,7 +144,7 @@ holding a browser open:
|
|
|
130
144
|
```ts
|
|
131
145
|
const tapi = new TapiClient({
|
|
132
146
|
baseUrl: process.env.TAPI_BASE_URL!,
|
|
133
|
-
|
|
147
|
+
authToken: process.env.TAPI_FIREBASE_ID_TOKEN!,
|
|
134
148
|
tappId: process.env.TAPI_TAPP_ID!,
|
|
135
149
|
projectId: process.env.TAPI_PROJECT_ID!,
|
|
136
150
|
dev: false,
|
|
@@ -144,7 +158,7 @@ production failure:
|
|
|
144
158
|
```ts
|
|
145
159
|
const tapi = new TapiClient({
|
|
146
160
|
baseUrl: process.env.TAPI_BASE_URL!,
|
|
147
|
-
|
|
161
|
+
authToken: process.env.TAPI_FIREBASE_ID_TOKEN!,
|
|
148
162
|
tappId: process.env.TAPI_TAPP_ID!,
|
|
149
163
|
projectId: process.env.TAPI_PROJECT_ID!,
|
|
150
164
|
dev: true,
|
|
@@ -269,8 +283,8 @@ export default {
|
|
|
269
283
|
};
|
|
270
284
|
```
|
|
271
285
|
|
|
272
|
-
```bash
|
|
273
|
-
|
|
286
|
+
```bash
|
|
287
|
+
tapi triggers sync
|
|
274
288
|
```
|
|
275
289
|
|
|
276
290
|
`triggers sync` upserts by trigger name for the current `.tapi/project.json`
|
|
@@ -295,14 +309,13 @@ await tapi.triggers.disable("act_123");
|
|
|
295
309
|
You can inspect the same input/output contract from the CLI:
|
|
296
310
|
|
|
297
311
|
```bash
|
|
298
|
-
tapi services describe schwab.place_order \
|
|
299
|
-
--api-base-url "$TAPI_BASE_URL" \
|
|
300
|
-
--
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
own backend route, server action, or job worker when using secret API keys.
|
|
312
|
+
tapi services describe schwab.place_order \
|
|
313
|
+
--api-base-url "$TAPI_BASE_URL" \
|
|
314
|
+
--project "$TAPI_PROJECT_ID"
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Do not expose developer Firebase ID tokens in public browser bundles. Put the
|
|
318
|
+
SDK behind your own backend route, server action, or job worker.
|
|
306
319
|
|
|
307
320
|
## Runtime Profiles and Proxies
|
|
308
321
|
|
|
@@ -370,7 +383,7 @@ If your JavaScript runtime does not provide `WebSocket`, pass one:
|
|
|
370
383
|
```ts
|
|
371
384
|
const tapi = new TapiClient({
|
|
372
385
|
baseUrl: process.env.TAPI_BASE_URL!,
|
|
373
|
-
|
|
386
|
+
authToken: process.env.TAPI_FIREBASE_ID_TOKEN!,
|
|
374
387
|
tappId: process.env.TAPI_TAPP_ID!,
|
|
375
388
|
webSocket: MyWebSocketImplementation,
|
|
376
389
|
});
|
|
@@ -378,17 +391,16 @@ const tapi = new TapiClient({
|
|
|
378
391
|
|
|
379
392
|
## Configuration
|
|
380
393
|
|
|
381
|
-
```env
|
|
394
|
+
```env
|
|
382
395
|
TAPI_BASE_URL=https://your-tapi-api-host
|
|
383
|
-
|
|
396
|
+
TAPI_FIREBASE_ID_TOKEN=firebase_id_token_for_the_tapp_owner
|
|
384
397
|
TAPI_TAPP_ID=brokerage
|
|
385
398
|
TAPI_PROJECT_ID=brokerage
|
|
386
399
|
```
|
|
387
400
|
|
|
388
401
|
`tappId` is required. Service calls are made for that Tapp, and the developer
|
|
389
|
-
who owns the Tapp pays for the service delivery. `projectId` is
|
|
390
|
-
|
|
391
|
-
`X-Tapi-Project` header and the server rejects mismatches.
|
|
402
|
+
who owns the Tapp pays for the service delivery. If provided, `projectId` is
|
|
403
|
+
sent as the `X-Tapi-Project` header and the server rejects mismatches.
|
|
392
404
|
|
|
393
405
|
## Common Project Setup
|
|
394
406
|
|
|
@@ -406,7 +418,7 @@ import { TapiClient } from "@tapi-dev/sdk";
|
|
|
406
418
|
|
|
407
419
|
export const tapi = new TapiClient({
|
|
408
420
|
baseUrl: process.env.TAPI_BASE_URL!,
|
|
409
|
-
|
|
421
|
+
authToken: process.env.TAPI_FIREBASE_ID_TOKEN!,
|
|
410
422
|
tappId: process.env.TAPI_TAPP_ID!,
|
|
411
423
|
projectId: process.env.TAPI_PROJECT_ID!,
|
|
412
424
|
});
|
|
@@ -446,10 +458,10 @@ Cloud runs are requested from the SDK, but VM provisioning, service
|
|
|
446
458
|
installation, worker leases, browser internals, and AWS cleanup stay on the
|
|
447
459
|
Tapi server. The SDK is only the front door.
|
|
448
460
|
|
|
449
|
-
Keep this code server-side. Do not put
|
|
450
|
-
do not wire AWS or Stripe from the developer's app. The app
|
|
451
|
-
identity to Tapi, and Tapi handles prepaid Stripe checkout,
|
|
452
|
-
AWS worker provisioning, and cleanup.
|
|
461
|
+
Keep this code server-side. Do not put developer Firebase ID tokens in a
|
|
462
|
+
browser bundle and do not wire AWS or Stripe from the developer's app. The app
|
|
463
|
+
sends its own user identity to Tapi, and Tapi handles prepaid Stripe checkout,
|
|
464
|
+
credit accounting, AWS worker provisioning, and cleanup.
|
|
453
465
|
|
|
454
466
|
The minimum developer flow is:
|
|
455
467
|
|
|
@@ -523,7 +535,7 @@ low, `runCloudBatch` converts the server's HTTP `402` into a normal
|
|
|
523
535
|
`availableBalanceCents`, and `requiredBalanceCents`. That keeps the button
|
|
524
536
|
handler simple.
|
|
525
537
|
|
|
526
|
-
Credits are scoped under the
|
|
538
|
+
Credits are scoped under the authenticated Firebase owner, Tapp id, and
|
|
527
539
|
`user.externalUserId`. Use the same `externalUserId` for quote, balance,
|
|
528
540
|
checkout, and run calls. If you omit `externalUserId` but provide `email`, Tapi
|
|
529
541
|
uses the normalized email as the external user id.
|
package/dist/cli.d.ts
CHANGED
|
@@ -66,12 +66,14 @@ export interface StudioCliOptions {
|
|
|
66
66
|
workspaceRoot?: string;
|
|
67
67
|
projectId?: string;
|
|
68
68
|
projectSlug?: string;
|
|
69
|
+
projectIdSource?: "option" | "env" | "workspace" | "selection";
|
|
69
70
|
workspaceMode: boolean;
|
|
70
71
|
launchUrlQuery?: string;
|
|
72
|
+
tappSelectionMode: "auto" | "select" | "last" | "none";
|
|
71
73
|
}
|
|
72
74
|
export interface RunnerSetupCliOptions {
|
|
73
75
|
apiBaseUrl: string;
|
|
74
|
-
|
|
76
|
+
authToken?: string;
|
|
75
77
|
projectId: string;
|
|
76
78
|
runnerId: string;
|
|
77
79
|
port: number;
|