@tailor-platform/sdk 1.54.2 → 1.55.0

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 (48) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/{actor-Cjae_LGD.d.mts → actor-J2gJ0eK5.d.mts} +2 -2
  3. package/dist/application-DM8q9GDI.mjs +4 -0
  4. package/dist/{application-BfGje3iZ.mjs → application-DzUlASfA.mjs} +333 -4
  5. package/dist/application-DzUlASfA.mjs.map +1 -0
  6. package/dist/brand-DlnJ375c.mjs.map +1 -1
  7. package/dist/cli/index.mjs +5 -5
  8. package/dist/cli/index.mjs.map +1 -1
  9. package/dist/cli/lib.d.mts +1334 -176
  10. package/dist/cli/lib.mjs +3 -3
  11. package/dist/{client-CGO7gniI.mjs → client-DLPEPJ_s.mjs} +24 -19
  12. package/dist/client-DLPEPJ_s.mjs.map +1 -0
  13. package/dist/{client-yfFdZU9s.mjs → client-DrzwCD1W.mjs} +1 -1
  14. package/dist/configure/index.d.mts +5 -4
  15. package/dist/configure/index.mjs +48 -2
  16. package/dist/configure/index.mjs.map +1 -1
  17. package/dist/{crashreport-DGdAgX8Y.mjs → crashreport-Bm2mN5tg.mjs} +2 -2
  18. package/dist/{crashreport-DGdAgX8Y.mjs.map → crashreport-Bm2mN5tg.mjs.map} +1 -1
  19. package/dist/{crashreport-DnwIxpzF.mjs → crashreport-C5oHvHUC.mjs} +1 -1
  20. package/dist/{index-qQYMbkT-.d.mts → index-BE-fpxIo.d.mts} +2 -2
  21. package/dist/{index-BTLgs0DP.d.mts → index-BLsnrEtc.d.mts} +97 -5
  22. package/dist/{index-DrYHpTja.d.mts → index-D9xG-a6Y.d.mts} +2 -2
  23. package/dist/{index-CyyoHrPK.d.mts → index-S6-FtUpA.d.mts} +2 -2
  24. package/dist/{index-Cf1Lo_XT.d.mts → index-cHqh66cF.d.mts} +2 -2
  25. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  26. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  27. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  28. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  29. package/dist/plugin/index.d.mts +2 -2
  30. package/dist/plugin-BuE5ZOnW.d.mts +634 -0
  31. package/dist/{runtime-DLFzjgEo.mjs → runtime-BZsl7Mh9.mjs} +320 -155
  32. package/dist/runtime-BZsl7Mh9.mjs.map +1 -0
  33. package/dist/{schema-CQrYG_55.mjs → schema-DKsNhbav.mjs} +5 -3
  34. package/dist/{schema-CQrYG_55.mjs.map → schema-DKsNhbav.mjs.map} +1 -1
  35. package/dist/seed-DfLyRh63.mjs.map +1 -1
  36. package/dist/tailordb-BlBGmQK-.d.mts +863 -0
  37. package/dist/utils/test/index.d.mts +3 -3
  38. package/dist/vitest/index.d.mts +25 -1
  39. package/dist/vitest/index.mjs +57 -12
  40. package/dist/vitest/index.mjs.map +1 -1
  41. package/dist/{workflow.generated-dBixCwUo.d.mts → workflow.generated-CQg1_Ami.d.mts} +185 -8
  42. package/docs/services/http-adapter.md +100 -0
  43. package/package.json +1 -1
  44. package/dist/application-BfGje3iZ.mjs.map +0 -1
  45. package/dist/application-BsipSxp3.mjs +0 -4
  46. package/dist/client-CGO7gniI.mjs.map +0 -1
  47. package/dist/runtime-DLFzjgEo.mjs.map +0 -1
  48. package/dist/tailor-db-field-D0qg8s4U.d.mts +0 -1639
@@ -0,0 +1,100 @@
1
+ # HTTP Adapter
2
+
3
+ HTTP adapters expose REST-style HTTP endpoints on your application by translating each request into a GraphQL query and (optionally) reshaping the GraphQL response back into an HTTP response.
4
+
5
+ ## Overview
6
+
7
+ Each HTTP adapter is a single file that declares:
8
+
9
+ - A `pathPattern` (which methods it handles is derived from the `input` keys)
10
+ - An `input` object keyed by lowercase HTTP method (`get`, `post`, `put`, `patch`, `delete`) — each value is a function that converts an incoming HTTP request into a GraphQL request (`query`, `variables`, `operationName`)
11
+ - An optional `output` function — **shared across all methods** — that converts the GraphQL response into an HTTP response (`statusCode`, `headers`, `body`)
12
+
13
+ Adapters are deployed together with your application. When a request arrives under the `/api/` prefix and matches an adapter, the handler for the request method runs server-side.
14
+
15
+ For the official Tailor Platform documentation — including the exact URL routing, request/response body limits, execution timeouts, and CORS handling — see https://docs.tailor.tech/.
16
+
17
+ ## Requirements
18
+
19
+ - Each adapter file must `export default` the result of `createHttpAdapter`; files matched by the glob without one (e.g. shared helpers) are ignored
20
+ - `name` must match `^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$` and be unique across all adapters
21
+ - `input` must declare at least one method handler
22
+ - All handlers **must be synchronous** — `async`/`await` is rejected at build time
23
+
24
+ ## Constraints
25
+
26
+ Handlers run server-side and **must be synchronous**: `async`/`await`, Promises, `fetch`, Node APIs (`fs`, `path`, `crypto`, …), and top-level `await` are not available. `async`/`await` and Node built-in imports are rejected at build time. Each adapter's built output (including imported helpers) is capped at 256 KB, with a warning above 64 KB.
27
+
28
+ Request/response body size, execution timeout, and other limits are enforced by the platform — see the platform documentation linked above.
29
+
30
+ ## Configuration
31
+
32
+ Add an `httpAdapter` entry to `defineConfig`:
33
+
34
+ ```typescript
35
+ // tailor.config.ts
36
+ import { defineConfig } from "@tailor-platform/sdk";
37
+
38
+ export default defineConfig({
39
+ name: "my-app",
40
+ httpAdapter: {
41
+ files: ["adapters/**/*.ts"],
42
+ },
43
+ });
44
+ ```
45
+
46
+ ## Defining an Adapter
47
+
48
+ ```typescript
49
+ // adapters/user.ts
50
+ import { createHttpAdapter } from "@tailor-platform/sdk";
51
+
52
+ export default createHttpAdapter({
53
+ name: "user",
54
+ pathPattern: "/users/*",
55
+ input: {
56
+ get: (req) => ({
57
+ query: `query GetUser($id: ID!) { user(id: $id) { id name email } }`,
58
+ variables: { id: req.path.split("/")[2] },
59
+ }),
60
+ post: (req) => ({
61
+ query: `mutation CreateUser($input: CreateUserInput!) { createUser(input: $input) { id } }`,
62
+ variables: { input: JSON.parse(req.body) },
63
+ }),
64
+ },
65
+ output: (resp) => ({
66
+ statusCode: 200,
67
+ headers: { "content-type": "application/json" },
68
+ body: JSON.stringify(resp.data ?? null),
69
+ }),
70
+ });
71
+ ```
72
+
73
+ A request to `GET /api/users/abc-123` invokes the `get` handler, runs the resulting GraphQL query against your application's GraphQL endpoint (with the caller's auth context preserved), then invokes `output(resp)` to produce the HTTP response. A `POST /api/users/...` would instead invoke the `post` handler with the same shared `output`.
74
+
75
+ If `output` is omitted, the raw GraphQL response is returned as JSON.
76
+
77
+ ### Optional fields
78
+
79
+ Beyond `name`, `pathPattern`, `input`, and `output`, two optional fields control deploy-time behavior:
80
+
81
+ - `enabled` (default `true`) — set to `false` to deploy the adapter in a disabled state without removing its file. A disabled adapter is uploaded but not served.
82
+ - `priority` (non-negative integer, default `0`) — when multiple adapters' `pathPattern`s match the same request path, the adapter with the **lowest** `priority` value wins.
83
+
84
+ ### Why is `output` shared instead of per-method?
85
+
86
+ `input` and `output` run **in isolation** and cannot share any state; `output` only receives the GraphQL response (not the original request or method). `output` is primarily intended for reshaping the response format (e.g. JSON to XML) — method-specific processing is expected to be handled on the `input`/resolver side. For per-method response shaping, discriminate inside `output` based on the response data shape.
87
+
88
+ ## Path Pattern
89
+
90
+ `pathPattern` is matched against the request path **after** the `/api/` prefix.
91
+
92
+ - Literal segments must match exactly
93
+ - A `*` in the middle of the pattern matches exactly one path segment (`/users/*/items`)
94
+ - A trailing `*` matches the remaining path (`/users/*`)
95
+
96
+ Exact matching semantics (trailing-slash handling, percent-encoding, etc.) are defined by the platform — refer to the platform documentation for details.
97
+
98
+ ## Types
99
+
100
+ The request/response shapes (`HttpAdapterRequest`, `HttpAdapterGraphQLRequest`, `HttpAdapterGraphQLResponse`, `HttpAdapterResponse`, …) are exported from `@tailor-platform/sdk`; refer to the type definitions in your editor rather than this document.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.54.2",
3
+ "version": "1.55.0",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {