@tailor-platform/sdk 1.50.1 → 1.51.1
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/CHANGELOG.md +60 -0
- package/README.md +1 -0
- package/agent-skills/tailor-sdk/SKILL.md +2 -0
- package/dist/{actor-BeIEiPYM.d.mts → actor-Nag62ZDM.d.mts} +2 -3
- package/dist/application-Bcx-FbDE.mjs +4 -0
- package/dist/{application-CZMzt9jL.mjs → application-Z-fNwyZB.mjs} +50 -14
- package/dist/application-Z-fNwyZB.mjs.map +1 -0
- package/dist/authconnection-BDFTabLQ.d.mts +39 -0
- package/dist/authconnection-BUko4V6H.mjs +16 -0
- package/dist/authconnection-BUko4V6H.mjs.map +1 -0
- package/dist/{brand-D-d15jx3.mjs → brand-Ll48SMXe.mjs} +1 -1
- package/dist/{brand-D-d15jx3.mjs.map → brand-Ll48SMXe.mjs.map} +1 -1
- package/dist/chunk-DLeslSnM.mjs +21 -0
- package/dist/cli/index.d.mts +0 -1
- package/dist/cli/index.mjs +16 -16
- package/dist/cli/lib.d.mts +6 -7
- package/dist/cli/lib.mjs +8 -8
- package/dist/cli/skills.d.mts +0 -1
- package/dist/cli/skills.mjs +1 -1
- package/dist/{client-_kHh0Pip.mjs → client-BwV17byk.mjs} +4 -4
- package/dist/{client-_kHh0Pip.mjs.map → client-BwV17byk.mjs.map} +1 -1
- package/dist/{client-CPW1N1Rs.mjs → client-D_a50aIg.mjs} +1 -1
- package/dist/configure/index.d.mts +5 -5
- package/dist/configure/index.mjs +4 -4
- package/dist/configure/index.mjs.map +1 -1
- package/dist/context-BP5BUdcq.mjs +25 -0
- package/dist/context-BP5BUdcq.mjs.map +1 -0
- package/dist/context-BXDgEQK9.d.mts +68 -0
- package/dist/{crashreport-DHJuSmUc.mjs → crashreport-C4EbRoku.mjs} +1 -1
- package/dist/{crashreport-CvmdFs4i.mjs → crashreport-DauPOrKn.mjs} +5 -5
- package/dist/{crashreport-CvmdFs4i.mjs.map → crashreport-DauPOrKn.mjs.map} +1 -1
- package/dist/{enum-constants-C3KSpsYj.mjs → enum-constants-DI85-fPE.mjs} +1 -1
- package/dist/{enum-constants-C3KSpsYj.mjs.map → enum-constants-DI85-fPE.mjs.map} +1 -1
- package/dist/{errors-pMPXghkO.mjs → errors-C4cJ0M2K.mjs} +1 -1
- package/dist/{errors-pMPXghkO.mjs.map → errors-C4cJ0M2K.mjs.map} +1 -1
- package/dist/{field-DLSIuMTu.mjs → field-BY2vbJ8f.mjs} +1 -1
- package/dist/{field-DLSIuMTu.mjs.map → field-BY2vbJ8f.mjs.map} +1 -1
- package/dist/file-BE5Sy7lP.mjs +54 -0
- package/dist/file-BE5Sy7lP.mjs.map +1 -0
- package/dist/file-Dc4_QrlQ.d.mts +206 -0
- package/dist/{file-utils-DjNi_3U_.mjs → file-utils-BM8t5jCy.mjs} +20 -10
- package/dist/file-utils-BM8t5jCy.mjs.map +1 -0
- package/dist/iconv-BFNfdlIS.d.mts +122 -0
- package/dist/iconv-D0yL88Il.mjs +64 -0
- package/dist/iconv-D0yL88Il.mjs.map +1 -0
- package/dist/idp-B1b4O7ia.d.mts +161 -0
- package/dist/idp-CM7N7iID.mjs +76 -0
- package/dist/idp-CM7N7iID.mjs.map +1 -0
- package/dist/{index-C--7W0UO.d.mts → index-BD99GoHO.d.mts} +4 -5
- package/dist/{index-nV4ZC_Ve.d.mts → index-BXwAT_oE.d.mts} +2 -3
- package/dist/{index-BQ4oi0AI.d.mts → index-CYAZkd4b.d.mts} +2 -3
- package/dist/{index-BjXN1SdY.d.mts → index-CfSjuxzK.d.mts} +2 -3
- package/dist/index-Dy3ZH5Wm.d.mts +46 -0
- package/dist/{index-VJW98BSy.d.mts → index-aiIbrFGw.d.mts} +2 -3
- package/dist/{interceptor-DTNS0EtF.mjs → interceptor-Cr3kZWMc.mjs} +1 -1
- package/dist/{interceptor-DTNS0EtF.mjs.map → interceptor-Cr3kZWMc.mjs.map} +1 -1
- package/dist/{job-M3Avv_SV.mjs → job-4GOnasfT.mjs} +2 -2
- package/dist/{job-M3Avv_SV.mjs.map → job-4GOnasfT.mjs.map} +1 -1
- package/dist/kysely/index.d.mts +0 -1
- package/dist/{kysely-type-B8aRz_oC.mjs → kysely-type-BUoVDC5r.mjs} +2 -2
- package/dist/{kysely-type-B8aRz_oC.mjs.map → kysely-type-BUoVDC5r.mjs.map} +1 -1
- package/dist/{logger-DTNAMYGy.mjs → logger-B1g4I9wT.mjs} +1 -1
- package/dist/{logger-DTNAMYGy.mjs.map → logger-B1g4I9wT.mjs.map} +1 -1
- package/dist/{mock-BfL09ULZ.mjs → mock-B2t5gDMl.mjs} +11 -5
- package/dist/mock-B2t5gDMl.mjs.map +1 -0
- package/dist/{multiline-e3IpANmS.mjs → multiline-G1yF18OH.mjs} +1 -1
- package/dist/{multiline-e3IpANmS.mjs.map → multiline-G1yF18OH.mjs.map} +1 -1
- package/dist/package-json-CAGKAJff.mjs +4 -0
- package/dist/{package-json-6Px8bDpG.mjs → package-json-ZL0MkZOO.mjs} +1 -1
- package/dist/{package-json-6Px8bDpG.mjs.map → package-json-ZL0MkZOO.mjs.map} +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -2
- package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -2
- package/dist/plugin/builtin/file-utils/index.mjs +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -2
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -2
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/index.d.mts +2 -3
- package/dist/{repl-editor-jZ493eQI.mjs → repl-editor-yAjwS5_M.mjs} +1 -1
- package/dist/{repl-editor-jZ493eQI.mjs.map → repl-editor-yAjwS5_M.mjs.map} +1 -1
- package/dist/runtime/authconnection.d.mts +2 -0
- package/dist/runtime/authconnection.mjs +4 -0
- package/dist/runtime/context.d.mts +2 -0
- package/dist/runtime/context.mjs +4 -0
- package/dist/runtime/file.d.mts +2 -0
- package/dist/runtime/file.mjs +4 -0
- package/dist/runtime/globals.d.mts +103 -0
- package/dist/runtime/globals.mjs +2 -0
- package/dist/runtime/iconv.d.mts +2 -0
- package/dist/runtime/iconv.mjs +4 -0
- package/dist/runtime/idp.d.mts +2 -0
- package/dist/runtime/idp.mjs +4 -0
- package/dist/runtime/index.d.mts +9 -0
- package/dist/runtime/index.mjs +10 -0
- package/dist/runtime/secretmanager.d.mts +2 -0
- package/dist/runtime/secretmanager.mjs +4 -0
- package/dist/runtime/workflow.d.mts +2 -0
- package/dist/runtime/workflow.mjs +4 -0
- package/dist/{runtime-DgsMnMrO.mjs → runtime-CyX4zeod.mjs} +55 -32
- package/dist/runtime-CyX4zeod.mjs.map +1 -0
- package/dist/{schema-C5QjYEc-.mjs → schema-DBq6hr6h.mjs} +3 -3
- package/dist/{schema-C5QjYEc-.mjs.map → schema-DBq6hr6h.mjs.map} +1 -1
- package/dist/{secret-file-BHpxGyNf.mjs → secret-file-DnbmTWec.mjs} +1 -1
- package/dist/{secret-file-BHpxGyNf.mjs.map → secret-file-DnbmTWec.mjs.map} +1 -1
- package/dist/secretmanager-CQTTuCmn.mjs +25 -0
- package/dist/secretmanager-CQTTuCmn.mjs.map +1 -0
- package/dist/secretmanager-Cjq3s2aU.d.mts +55 -0
- package/dist/seed/index.d.mts +0 -1
- package/dist/{seed-DjfAn0BC.mjs → seed-kNk-xLoB.mjs} +7 -2
- package/dist/{seed-DjfAn0BC.mjs.map → seed-kNk-xLoB.mjs.map} +1 -1
- package/dist/{service-DCgJxdg1.mjs → service-DHgJ4YEF.mjs} +3 -3
- package/dist/{service-DCgJxdg1.mjs.map → service-DHgJ4YEF.mjs.map} +1 -1
- package/dist/{tailor-db-field-4bMLe25-.d.mts → tailor-db-field-BhWvOyky.d.mts} +1 -2
- package/dist/{telemetry-C1Y56L5E.mjs → telemetry-C8xKz3GM.mjs} +2 -2
- package/dist/{telemetry-C1Y56L5E.mjs.map → telemetry-C8xKz3GM.mjs.map} +1 -1
- package/dist/telemetry-DQl47E1s.mjs +4 -0
- package/dist/types-BnphjkIJ.mjs +5 -0
- package/dist/{types-sir9UPht.mjs → types-Duhhsx3R.mjs} +2 -2
- package/dist/{types-sir9UPht.mjs.map → types-Duhhsx3R.mjs.map} +1 -1
- package/dist/utils/test/index.d.mts +3 -4
- package/dist/utils/test/index.mjs +1 -1
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.d.mts +0 -1
- package/dist/vitest/environment.mjs +1 -1
- package/dist/vitest/index.d.mts +2 -3
- package/dist/vitest/index.mjs +3 -3
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/setup.d.mts +0 -1
- package/dist/vitest/setup.mjs +1 -1
- package/dist/workflow-DJRr-0nl.mjs +39 -0
- package/dist/workflow-DJRr-0nl.mjs.map +1 -0
- package/dist/workflow-DV_88JEf.d.mts +96 -0
- package/dist/{workflow.generated-OYAu_6zX.d.mts → workflow.generated-DV87DJfO.d.mts} +2 -3
- package/docs/cli/application.md +1 -1
- package/docs/cli/tailordb.md +9 -8
- package/docs/cli-reference.md +17 -16
- package/docs/configuration.md +1 -0
- package/docs/generator/builtin.md +2 -0
- package/docs/runtime.md +113 -0
- package/docs/testing.md +21 -0
- package/package.json +53 -9
- package/dist/application-CZMzt9jL.mjs.map +0 -1
- package/dist/application-v_E2W-Fz.mjs +0 -4
- package/dist/file-utils-DjNi_3U_.mjs.map +0 -1
- package/dist/mock-BfL09ULZ.mjs.map +0 -1
- package/dist/package-json-7sRXVndJ.mjs +0 -4
- package/dist/runtime-DgsMnMrO.mjs.map +0 -1
- package/dist/telemetry-C13VIFpT.mjs +0 -4
- package/dist/types-DoIG6Nij.mjs +0 -5
package/docs/cli/tailordb.md
CHANGED
|
@@ -77,14 +77,14 @@ tailor-sdk tailordb truncate [options] [types]
|
|
|
77
77
|
|
|
78
78
|
**Options**
|
|
79
79
|
|
|
80
|
-
| Option | Alias | Description
|
|
81
|
-
| ------------------------------- | ----- |
|
|
82
|
-
| `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID
|
|
83
|
-
| `--profile <PROFILE>` | `-p` | Workspace profile
|
|
84
|
-
| `--config <CONFIG>` | `-c` | Path to SDK config file
|
|
85
|
-
| `--yes` | `-y` | Skip confirmation prompts
|
|
86
|
-
| `--all` | `-a` | Truncate all tables in all namespaces
|
|
87
|
-
| `--namespace <NAMESPACE>` | `-n` | Truncate all tables in specified namespace
|
|
80
|
+
| Option | Alias | Description | Required | Default | Env |
|
|
81
|
+
| ------------------------------- | ----- | -------------------------------------------------------------------------- | -------- | -------------------- | --------------------------------- |
|
|
82
|
+
| `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID` |
|
|
83
|
+
| `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE` |
|
|
84
|
+
| `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` | `TAILOR_PLATFORM_SDK_CONFIG_PATH` |
|
|
85
|
+
| `--yes` | `-y` | Skip confirmation prompts | No | `false` | - |
|
|
86
|
+
| `--all` | `-a` | Truncate all tables in all owned namespaces (excludes external namespaces) | No | `false` | - |
|
|
87
|
+
| `--namespace <NAMESPACE>` | `-n` | Truncate all tables in specified namespace | No | - | - |
|
|
88
88
|
|
|
89
89
|
<!-- politty:command:tailordb truncate:options:end -->
|
|
90
90
|
|
|
@@ -122,6 +122,7 @@ tailor-sdk tailordb truncate User Post --yes
|
|
|
122
122
|
- `--namespace`: requires typing `truncate <namespace-name>`
|
|
123
123
|
- Specific types: requires typing `yes`
|
|
124
124
|
- Use `--yes` flag to skip confirmation prompts (useful for scripts and CI/CD)
|
|
125
|
+
- Namespaces declared with `{ external: true }` are skipped by `--all` and rejected with a dedicated error when targeted by `--namespace`. Run truncate from the app that owns the namespace.
|
|
125
126
|
|
|
126
127
|
<!-- politty:command:tailordb migration:heading:start -->
|
|
127
128
|
|
package/docs/cli-reference.md
CHANGED
|
@@ -53,22 +53,23 @@ tailor-sdk deploy --env-file .env --env-file .env.production
|
|
|
53
53
|
|
|
54
54
|
You can use environment variables to configure workspace and authentication:
|
|
55
55
|
|
|
56
|
-
| Variable | Description
|
|
57
|
-
| -------------------------------------------- |
|
|
58
|
-
| `TAILOR_PLATFORM_WORKSPACE_ID` | Workspace ID for deployment commands
|
|
59
|
-
| `TAILOR_PLATFORM_ORGANIZATION_ID` | Organization ID for organization commands
|
|
60
|
-
| `TAILOR_PLATFORM_FOLDER_ID` | Folder ID for folder commands
|
|
61
|
-
| `TAILOR_PLATFORM_TOKEN` | Authentication token (alternative to `login`)
|
|
62
|
-
| `TAILOR_TOKEN` | **Deprecated.** Use `TAILOR_PLATFORM_TOKEN` instead
|
|
63
|
-
| `TAILOR_PLATFORM_PROFILE` | Workspace profile name
|
|
64
|
-
| `TAILOR_PLATFORM_SDK_CONFIG_PATH` | Path to SDK config file
|
|
65
|
-
| `TAILOR_PLATFORM_SDK_DTS_PATH` | Output path for generated `tailor.d.ts` type definition file
|
|
66
|
-
| `TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID` | Client ID for `login --machine-user`
|
|
67
|
-
| `TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET` | Client secret for `login --machine-user`
|
|
68
|
-
| `TAILOR_PLATFORM_MACHINE_USER_NAME` | Default machine user name for `query`, `workflow start`, `function test-run`
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
56
|
+
| Variable | Description |
|
|
57
|
+
| -------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
58
|
+
| `TAILOR_PLATFORM_WORKSPACE_ID` | Workspace ID for deployment commands |
|
|
59
|
+
| `TAILOR_PLATFORM_ORGANIZATION_ID` | Organization ID for organization commands |
|
|
60
|
+
| `TAILOR_PLATFORM_FOLDER_ID` | Folder ID for folder commands |
|
|
61
|
+
| `TAILOR_PLATFORM_TOKEN` | Authentication token (alternative to `login`) |
|
|
62
|
+
| `TAILOR_TOKEN` | **Deprecated.** Use `TAILOR_PLATFORM_TOKEN` instead |
|
|
63
|
+
| `TAILOR_PLATFORM_PROFILE` | Workspace profile name |
|
|
64
|
+
| `TAILOR_PLATFORM_SDK_CONFIG_PATH` | Path to SDK config file |
|
|
65
|
+
| `TAILOR_PLATFORM_SDK_DTS_PATH` | Output path for generated `tailor.d.ts` type definition file |
|
|
66
|
+
| `TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID` | Client ID for `login --machine-user` |
|
|
67
|
+
| `TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET` | Client secret for `login --machine-user` |
|
|
68
|
+
| `TAILOR_PLATFORM_MACHINE_USER_NAME` | Default machine user name for `query`, `workflow start`, `function test-run` |
|
|
69
|
+
| `TAILOR_BUNDLE_CONCURRENCY` | Max concurrent bundle workers for `deploy` (resolvers/executors/workflows). Defaults to CPU count |
|
|
70
|
+
| `VISUAL` / `EDITOR` | Preferred editor for commands that open files (e.g., `vim`, `code`, `nano`) |
|
|
71
|
+
| `TAILOR_CRASH_REPORTS_LOCAL` | Local crash log writing: `on` (default) or `off` |
|
|
72
|
+
| `TAILOR_CRASH_REPORTS_REMOTE` | Automatic crash report submission: `off` (default) or `on` |
|
|
72
73
|
|
|
73
74
|
### Authentication Token Priority
|
|
74
75
|
|
package/docs/configuration.md
CHANGED
|
@@ -93,6 +93,7 @@ When using external resources:
|
|
|
93
93
|
- The resource itself is not deployed by this project
|
|
94
94
|
- The resource must be deployed and available before referencing it
|
|
95
95
|
- You can combine external resources with locally-defined resources
|
|
96
|
+
- Destructive operations like `tailordb truncate` (and `seedPlugin`'s `seed:reset`) automatically exclude external resources to prevent accidental data loss in shared resources
|
|
96
97
|
|
|
97
98
|
### Built-in IdP
|
|
98
99
|
|
|
@@ -253,3 +253,5 @@ node seed/exec.mjs -m admin --truncate --yes
|
|
|
253
253
|
The `--machine-user` option is required at runtime if `machineUserName` is not configured in the generator options.
|
|
254
254
|
|
|
255
255
|
The generated files are compatible with gql-ingest for bulk data import.
|
|
256
|
+
|
|
257
|
+
The `exec.mjs` is fully regenerated on every `sdk generate` and starts with an `@generated` header — do not hand-edit it. Its `--truncate` path reuses the `tailordb truncate` command, so namespaces declared with `{ external: true }` are skipped automatically and a shell app cannot wipe a sibling app's data via `seed:reset`.
|
package/docs/runtime.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Runtime API
|
|
2
|
+
|
|
3
|
+
`@tailor-platform/sdk/runtime` provides typed wrappers for the `tailor.*` and `tailordb.file` APIs that the Tailor Platform Function runtime injects into the global scope at execution time. The wrappers are thin and delegate to the platform-provided globals; they exist so that you can:
|
|
4
|
+
|
|
5
|
+
- Reach the runtime API without relying on a separate ambient `.d.ts` package
|
|
6
|
+
- Get IDE-friendly imports (`iconv.convert`, `idp.Client`, …) instead of unmemorable `tailor.iconv.convert(...)` calls
|
|
7
|
+
- Use the same module surface in resolvers, executors, and workflows
|
|
8
|
+
|
|
9
|
+
The wrappers and their associated types are self-contained — you do not need to activate any ambient globals to use them. If you also want `tailor.iconv.convert(...)` calls to type-check, opt into the globals via the [Activating the global types](#activating-the-global-types) section below.
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import {
|
|
15
|
+
iconv,
|
|
16
|
+
secretmanager,
|
|
17
|
+
authconnection,
|
|
18
|
+
idp,
|
|
19
|
+
workflow,
|
|
20
|
+
context,
|
|
21
|
+
file,
|
|
22
|
+
} from "@tailor-platform/sdk/runtime";
|
|
23
|
+
|
|
24
|
+
const utf8 = iconv.convert(sjisBuffer, "Shift_JIS", "UTF-8");
|
|
25
|
+
|
|
26
|
+
const apiKey = await secretmanager.getSecret("my-vault", "API_KEY");
|
|
27
|
+
|
|
28
|
+
const token = await authconnection.getConnectionToken("google");
|
|
29
|
+
|
|
30
|
+
const client = new idp.Client({ namespace: "my-namespace" });
|
|
31
|
+
const { users } = await client.users({ first: 10 });
|
|
32
|
+
|
|
33
|
+
const executionId = await workflow.triggerWorkflow("approval", { reportId });
|
|
34
|
+
|
|
35
|
+
const invoker = context.getInvoker();
|
|
36
|
+
|
|
37
|
+
const { metadata } = await file.upload("my-namespace", "Document", "attachment", recordId, bytes);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Subpath imports
|
|
41
|
+
|
|
42
|
+
Each namespace can also be imported individually so you only pull what you need:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import * as iconv from "@tailor-platform/sdk/runtime/iconv";
|
|
46
|
+
import type { ListUsersResponse, ClientConfig } from "@tailor-platform/sdk/runtime/idp";
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Activating the global types
|
|
50
|
+
|
|
51
|
+
Most users do not need to touch the globals entry — `@tailor-platform/sdk/runtime` (and its subpath modules) cover the same surface without depending on any ambient declaration.
|
|
52
|
+
|
|
53
|
+
For backwards compatibility with the previous `@tailor-platform/function-types`-based setup, the SDK still activates the ambient `tailor.*` / `tailordb.*` types automatically when you import from `@tailor-platform/sdk`. **This implicit activation will be removed in v2.0**; new code should prefer the typed wrappers from `@tailor-platform/sdk/runtime`.
|
|
54
|
+
|
|
55
|
+
If you want to opt into the globals explicitly (or you are migrating ahead of v2.0), add a single side-effect import anywhere in your project:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import "@tailor-platform/sdk/runtime/globals";
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Or register the entry in `tsconfig.json`:
|
|
62
|
+
|
|
63
|
+
```jsonc
|
|
64
|
+
{
|
|
65
|
+
"compilerOptions": {
|
|
66
|
+
"types": ["@tailor-platform/sdk/runtime/globals"],
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Namespaces
|
|
72
|
+
|
|
73
|
+
The runtime entry re-exports the following namespaces. Detailed signatures, parameters, and return types live in the JSDoc next to each export — hover the symbol in your IDE or browse the source.
|
|
74
|
+
|
|
75
|
+
- `iconv` — character encoding conversion (`convert`, `convertBuffer`, `decode`, `encode`, `encodings`, `Iconv`)
|
|
76
|
+
- `secretmanager` — secret-vault access (`getSecret`, `getSecrets`)
|
|
77
|
+
- `authconnection` — OAuth-style connection tokens (`getConnectionToken`)
|
|
78
|
+
- `idp` — IdP user management (`new Client({ namespace })`)
|
|
79
|
+
- `workflow` — workflow & job control (`triggerWorkflow`, `triggerJobFunction`, `wait`, `resolve`)
|
|
80
|
+
- `context` — execution context (`getInvoker`)
|
|
81
|
+
- `file` — `tailordb.file` BLOB API (`upload`, `download`, `downloadAsBase64`, `delete`, `getMetadata`, `openDownloadStream`)
|
|
82
|
+
|
|
83
|
+
## Testing
|
|
84
|
+
|
|
85
|
+
`@tailor-platform/sdk/vitest` ships mock controllers for every runtime namespace. Pair them with the `tailor-runtime` Vitest environment so your unit tests run against the same wrappers your production code does.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { iconv, secretmanager } from "@tailor-platform/sdk/runtime";
|
|
89
|
+
import { iconvMock, secretmanagerMock } from "@tailor-platform/sdk/vitest";
|
|
90
|
+
import { beforeEach, expect, test } from "vitest";
|
|
91
|
+
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
iconvMock.reset();
|
|
94
|
+
secretmanagerMock.reset();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("encodes via iconv", () => {
|
|
98
|
+
iconvMock.setResolver(() => new Uint8Array([0x82, 0xa0]));
|
|
99
|
+
|
|
100
|
+
const out = iconv.convert("あ", "UTF-8", "Shift_JIS");
|
|
101
|
+
|
|
102
|
+
expect(out).toEqual(new Uint8Array([0x82, 0xa0]));
|
|
103
|
+
expect(iconvMock.calls[0]?.method).toBe("convert");
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("reads from a vault", async () => {
|
|
107
|
+
secretmanagerMock.setSecrets({ "my-vault": { API_KEY: "sk-123" } });
|
|
108
|
+
|
|
109
|
+
await expect(secretmanager.getSecret("my-vault", "API_KEY")).resolves.toBe("sk-123");
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
See [Testing Guide](./testing.md#runtime-environment-emulation-beta) for the full list of mock controllers and the `tailor-runtime` environment setup.
|
package/docs/testing.md
CHANGED
|
@@ -228,6 +228,27 @@ test("mock file download", async () => {
|
|
|
228
228
|
});
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
+
For `openDownloadStream`, enqueue an iterable of `StreamValue` items — `metadata`, one or more `chunk` items, and a terminal `complete`. Raw `Uint8Array` / `ArrayBuffer` chunks are rejected so tests stay aligned with the platform's structured stream contract.
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
test("mock file download stream", async () => {
|
|
235
|
+
fileMock.enqueueResult([
|
|
236
|
+
{
|
|
237
|
+
type: "metadata",
|
|
238
|
+
metadata: { contentType: "image/png", fileSize: 3, sha256sum: "abc" },
|
|
239
|
+
},
|
|
240
|
+
{ type: "chunk", data: new Uint8Array([1, 2]), position: 0 },
|
|
241
|
+
{ type: "chunk", data: new Uint8Array([3]), position: 2 },
|
|
242
|
+
{ type: "complete" },
|
|
243
|
+
]);
|
|
244
|
+
|
|
245
|
+
const stream = await tailordb.file.openDownloadStream("ns", "Doc", "attachment", "r-1");
|
|
246
|
+
const items = [];
|
|
247
|
+
for await (const item of stream) items.push(item);
|
|
248
|
+
expect(items).toHaveLength(4);
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
231
252
|
### Iconv Mock
|
|
232
253
|
|
|
233
254
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.51.1",
|
|
4
4
|
"description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -87,6 +87,51 @@
|
|
|
87
87
|
"types": "./dist/vitest/environment.d.mts",
|
|
88
88
|
"import": "./dist/vitest/environment.mjs",
|
|
89
89
|
"default": "./dist/vitest/environment.mjs"
|
|
90
|
+
},
|
|
91
|
+
"./runtime": {
|
|
92
|
+
"types": "./dist/runtime/index.d.mts",
|
|
93
|
+
"import": "./dist/runtime/index.mjs",
|
|
94
|
+
"default": "./dist/runtime/index.mjs"
|
|
95
|
+
},
|
|
96
|
+
"./runtime/globals": {
|
|
97
|
+
"types": "./dist/runtime/globals.d.mts",
|
|
98
|
+
"import": "./dist/runtime/globals.mjs",
|
|
99
|
+
"default": "./dist/runtime/globals.mjs"
|
|
100
|
+
},
|
|
101
|
+
"./runtime/iconv": {
|
|
102
|
+
"types": "./dist/runtime/iconv.d.mts",
|
|
103
|
+
"import": "./dist/runtime/iconv.mjs",
|
|
104
|
+
"default": "./dist/runtime/iconv.mjs"
|
|
105
|
+
},
|
|
106
|
+
"./runtime/secretmanager": {
|
|
107
|
+
"types": "./dist/runtime/secretmanager.d.mts",
|
|
108
|
+
"import": "./dist/runtime/secretmanager.mjs",
|
|
109
|
+
"default": "./dist/runtime/secretmanager.mjs"
|
|
110
|
+
},
|
|
111
|
+
"./runtime/authconnection": {
|
|
112
|
+
"types": "./dist/runtime/authconnection.d.mts",
|
|
113
|
+
"import": "./dist/runtime/authconnection.mjs",
|
|
114
|
+
"default": "./dist/runtime/authconnection.mjs"
|
|
115
|
+
},
|
|
116
|
+
"./runtime/idp": {
|
|
117
|
+
"types": "./dist/runtime/idp.d.mts",
|
|
118
|
+
"import": "./dist/runtime/idp.mjs",
|
|
119
|
+
"default": "./dist/runtime/idp.mjs"
|
|
120
|
+
},
|
|
121
|
+
"./runtime/workflow": {
|
|
122
|
+
"types": "./dist/runtime/workflow.d.mts",
|
|
123
|
+
"import": "./dist/runtime/workflow.mjs",
|
|
124
|
+
"default": "./dist/runtime/workflow.mjs"
|
|
125
|
+
},
|
|
126
|
+
"./runtime/context": {
|
|
127
|
+
"types": "./dist/runtime/context.d.mts",
|
|
128
|
+
"import": "./dist/runtime/context.mjs",
|
|
129
|
+
"default": "./dist/runtime/context.mjs"
|
|
130
|
+
},
|
|
131
|
+
"./runtime/file": {
|
|
132
|
+
"types": "./dist/runtime/file.d.mts",
|
|
133
|
+
"import": "./dist/runtime/file.mjs",
|
|
134
|
+
"default": "./dist/runtime/file.mjs"
|
|
90
135
|
}
|
|
91
136
|
},
|
|
92
137
|
"dependencies": {
|
|
@@ -101,14 +146,13 @@
|
|
|
101
146
|
"@liam-hq/cli": "0.7.24",
|
|
102
147
|
"@napi-rs/keyring": "1.3.0",
|
|
103
148
|
"@opentelemetry/api": "1.9.1",
|
|
104
|
-
"@opentelemetry/exporter-trace-otlp-proto": "0.
|
|
149
|
+
"@opentelemetry/exporter-trace-otlp-proto": "0.218.0",
|
|
105
150
|
"@opentelemetry/resources": "2.7.1",
|
|
106
151
|
"@opentelemetry/sdk-trace-node": "2.7.1",
|
|
107
|
-
"@opentelemetry/semantic-conventions": "1.
|
|
152
|
+
"@opentelemetry/semantic-conventions": "1.41.1",
|
|
108
153
|
"@oxc-project/types": "0.127.0",
|
|
109
154
|
"@standard-schema/spec": "1.1.0",
|
|
110
155
|
"@tailor-platform/function-kysely-tailordb": "0.1.3",
|
|
111
|
-
"@tailor-platform/function-types": "0.8.5",
|
|
112
156
|
"@toiroakr/lines-db": "0.9.2",
|
|
113
157
|
"@toiroakr/read-multiline": "0.4.1",
|
|
114
158
|
"@urql/core": "6.0.1",
|
|
@@ -118,8 +162,8 @@
|
|
|
118
162
|
"date-fns": "4.1.0",
|
|
119
163
|
"es-toolkit": "1.46.1",
|
|
120
164
|
"find-up-simple": "1.0.1",
|
|
121
|
-
"globals": "17.
|
|
122
|
-
"graphql": "16.
|
|
165
|
+
"globals": "17.6.0",
|
|
166
|
+
"graphql": "16.14.0",
|
|
123
167
|
"inflection": "3.0.2",
|
|
124
168
|
"kysely": "0.28.17",
|
|
125
169
|
"madge": "8.0.0",
|
|
@@ -142,7 +186,7 @@
|
|
|
142
186
|
"type-fest": "5.6.0",
|
|
143
187
|
"undici": "6.25.0",
|
|
144
188
|
"xdg-basedir": "5.1.0",
|
|
145
|
-
"zod": "4.3
|
|
189
|
+
"zod": "4.4.3"
|
|
146
190
|
},
|
|
147
191
|
"devDependencies": {
|
|
148
192
|
"@opentelemetry/sdk-trace-base": "2.7.1",
|
|
@@ -150,11 +194,11 @@
|
|
|
150
194
|
"@types/mime-types": "3.0.1",
|
|
151
195
|
"@types/node": "24.12.4",
|
|
152
196
|
"@types/semver": "7.7.1",
|
|
153
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
197
|
+
"@typescript/native-preview": "7.0.0-dev.20260524.1",
|
|
154
198
|
"@vitest/coverage-v8": "4.1.6",
|
|
155
199
|
"oxfmt": "0.46.0",
|
|
156
200
|
"oxlint": "1.61.0",
|
|
157
|
-
"oxlint-tsgolint": "0.
|
|
201
|
+
"oxlint-tsgolint": "0.23.0",
|
|
158
202
|
"sonda": "0.11.1",
|
|
159
203
|
"tsdown": "0.22.0",
|
|
160
204
|
"typescript": "5.9.3",
|