@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @tailor-platform/sdk
2
2
 
3
+ ## 1.55.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1173](https://github.com/tailor-platform/sdk/pull/1173) [`4d8010d`](https://github.com/tailor-platform/sdk/commit/4d8010ddf93edd1e9e7344b7e868b7e6efc3fddf) Thanks [@Mistat](https://github.com/Mistat)! - Add `createHttpAdapter()` for declaring HTTP adapters that translate HTTP requests into GraphQL queries and reshape the responses. Adapter files are discovered via the new `httpAdapter.files` glob in `defineConfig()`.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#1320](https://github.com/tailor-platform/sdk/pull/1320) [`977c200`](https://github.com/tailor-platform/sdk/commit/977c2007eb6ac28507d6eac1c391448ab91caa2a) Thanks [@remiposo](https://github.com/remiposo)! - `createKyselyMock`: assert what a write wrote as a `{ column: value }` map instead of positional SQL parameters. On a recorded query:
12
+
13
+ - `insertValues()` / `insertRows()` — the values a single- / multi-row insert wrote
14
+ - `updateValues()` — the values an update's SET clause wrote
15
+ - `node` — the raw Kysely operation node, for anything the helpers don't cover
16
+
17
+ Also adds `withTx(fn)` to run `fn` inside a real `Transaction`.
18
+
19
+ - [#1314](https://github.com/tailor-platform/sdk/pull/1314) [`e423765`](https://github.com/tailor-platform/sdk/commit/e4237652c4ac65074e2bcd1da56adc1841bc71cd) Thanks [@toiroakr](https://github.com/toiroakr)! - Fix generated migrate.ts templates for enum value removal: removed enum values were compared by object identity (so unchanged values were also treated as removed) and rendered as `[object Object]` in the generated migration script.
20
+
21
+ ## 1.54.3
22
+
23
+ ### Patch Changes
24
+
25
+ - [#1293](https://github.com/tailor-platform/sdk/pull/1293) [`1f9991d`](https://github.com/tailor-platform/sdk/commit/1f9991dc089763b9a3dbf95e26742c7100f9dd24) Thanks [@toiroakr](https://github.com/toiroakr)! - Fix `db.fields.timestamps()` to respect user-specified `createdAt` / `updatedAt` values instead of always overwriting them with the current time. When a value is provided (e.g. seeding historical records), it is now used; when omitted, the current time is still applied as before.
26
+
3
27
  ## 1.54.2
4
28
 
5
29
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import { Bt as InferredAttributeMap, zt as InferredAttributeList } from "./tailor-db-field-D0qg8s4U.mjs";
1
+ import { A as InferredAttributeList, j as InferredAttributeMap } from "./tailordb-BlBGmQK-.mjs";
2
2
 
3
3
  //#region src/types/actor.d.ts
4
4
  /** User type enum values from the Tailor Platform server. */
@@ -21,4 +21,4 @@ type TailorActor = {
21
21
  };
22
22
  //#endregion
23
23
  export { TailorActor as t };
24
- //# sourceMappingURL=actor-Cjae_LGD.d.mts.map
24
+ //# sourceMappingURL=actor-J2gJ0eK5.d.mts.map
@@ -0,0 +1,4 @@
1
+
2
+ import { n as generatePluginFilesIfNeeded, r as loadApplication, t as defineApplication } from "./application-DzUlASfA.mjs";
3
+
4
+ export { defineApplication };
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { n as isSdkBranded } from "./brand-DlnJ375c.mjs";
3
- import { u as initOAuth2Client } from "./client-CGO7gniI.mjs";
3
+ import { u as initOAuth2Client } from "./client-DLPEPJ_s.mjs";
4
4
  import { a as parseBoolean, n as logger, r as styles } from "./logger-DpJyJvNz.mjs";
5
5
  import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "./enum-constants-C7DaWeQo.mjs";
6
6
  import { t as multiline } from "./multiline-Cf9ODpr1.mjs";
@@ -9,7 +9,7 @@ import { n as kyselyTypePlugin, t as KyselyGeneratorID } from "./kysely-type-D1e
9
9
  import { n as seedPlugin, r as isPluginGeneratedType, t as SeedGeneratorID } from "./seed-DfLyRh63.mjs";
10
10
  import { t as readPackageJson } from "./package-json-DcQApfPQ.mjs";
11
11
  import { n as tightenSecretFilePermissions, r as writeSecretFile } from "./secret-file-CWzF8rry.mjs";
12
- import { createRequire } from "node:module";
12
+ import { builtinModules, createRequire } from "node:module";
13
13
  import { z } from "zod";
14
14
  import * as fs$1 from "node:fs";
15
15
  import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
@@ -61,6 +61,7 @@ const AppConfigSchema = z.object({
61
61
  auth: z.unknown().optional(),
62
62
  executor: z.unknown().optional(),
63
63
  workflow: z.unknown().optional(),
64
+ httpAdapter: z.unknown().optional(),
64
65
  staticWebsites: z.unknown().optional(),
65
66
  secrets: z.unknown().optional()
66
67
  });
@@ -4159,6 +4160,315 @@ function createExecutorService(params) {
4159
4160
  };
4160
4161
  }
4161
4162
 
4163
+ //#endregion
4164
+ //#region src/cli/services/http-adapter/node-builtins.ts
4165
+ const NODE_BUILTINS = new Set(builtinModules.filter((m) => !m.startsWith("_")));
4166
+ function isNodeBuiltinImport(source) {
4167
+ if (source.startsWith("node:")) return true;
4168
+ const root = source.includes("/") ? source.slice(0, source.indexOf("/")) : source;
4169
+ return NODE_BUILTINS.has(root);
4170
+ }
4171
+
4172
+ //#endregion
4173
+ //#region src/parser/service/http-adapter/methods.ts
4174
+ /**
4175
+ * Maps the lowercase `input` handler keys to the HTTP methods they serve.
4176
+ * The key set is tied to `inputHandlersSchema` in `./schema` via the
4177
+ * zinfer-generated config type, so the two cannot drift apart.
4178
+ */
4179
+ const HTTP_METHODS = {
4180
+ get: "GET",
4181
+ post: "POST",
4182
+ put: "PUT",
4183
+ patch: "PATCH",
4184
+ delete: "DELETE"
4185
+ };
4186
+ const HTTP_METHOD_KEYS = Object.keys(HTTP_METHODS);
4187
+
4188
+ //#endregion
4189
+ //#region src/parser/service/http-adapter/schema.ts
4190
+ const NAME_PATTERN = /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/;
4191
+ const inputHandlersSchema = z.strictObject({
4192
+ get: functionSchema.optional().describe("Handler for GET requests"),
4193
+ post: functionSchema.optional().describe("Handler for POST requests"),
4194
+ put: functionSchema.optional().describe("Handler for PUT requests"),
4195
+ patch: functionSchema.optional().describe("Handler for PATCH requests"),
4196
+ delete: functionSchema.optional().describe("Handler for DELETE requests")
4197
+ }).refine((val) => Object.values(val).some((v) => v !== void 0), "input must declare at least one HTTP method handler").describe("Per-method functions that transform HTTP requests to GraphQL requests");
4198
+ const HttpAdapterConfigSchema = z.strictObject({
4199
+ name: z.string().regex(NAME_PATTERN, "name must be 3-63 chars, lowercase alphanumeric with hyphens, not starting or ending with a hyphen").describe("Unique adapter name within the domain"),
4200
+ pathPattern: z.string().min(1).describe("Path pattern with segment wildcards (trailing or single-segment)"),
4201
+ enabled: z.boolean().default(true).describe("Whether the adapter is active"),
4202
+ priority: z.number().int().min(0).default(0).describe("Matching priority; the lowest value wins when multiple adapters match"),
4203
+ input: inputHandlersSchema,
4204
+ output: functionSchema.optional().describe("Function that transforms GraphQL response to HTTP response")
4205
+ }).brand("HttpAdapterConfig");
4206
+
4207
+ //#endregion
4208
+ //#region src/cli/services/http-adapter/bundler.ts
4209
+ const ADAPTER_BUNDLE_WARN_BYTES = 64 * 1024;
4210
+ const ADAPTER_BUNDLE_ERROR_BYTES = 256 * 1024;
4211
+ /**
4212
+ * Bundle each adapter's `input` (and `output`, if present) into a standalone
4213
+ * IIFE defining a global `transform(input)` entry point. `input` gets a
4214
+ * generated dispatcher that routes by `req.method`; `output` is used as is.
4215
+ * @param adapters - Detected adapters to bundle
4216
+ * @param cache - Optional bundle cache for skipping unchanged builds
4217
+ * @returns Bundled scripts keyed by adapter name
4218
+ */
4219
+ async function bundleHttpAdapters(adapters, cache) {
4220
+ if (adapters.length === 0) return {
4221
+ bundledInputs: /* @__PURE__ */ new Map(),
4222
+ bundledOutputs: /* @__PURE__ */ new Map()
4223
+ };
4224
+ logger.newline();
4225
+ logger.log(`Bundling ${styles.highlight(adapters.length.toString())} files for ${styles.info("\"http-adapter\"")}`);
4226
+ const outputDir = path.resolve(getDistDir(), "http-adapters");
4227
+ fs$1.mkdirSync(outputDir, { recursive: true });
4228
+ let tsconfig;
4229
+ try {
4230
+ tsconfig = await resolveTSConfig();
4231
+ } catch {
4232
+ tsconfig = void 0;
4233
+ }
4234
+ const results = await withBundleConcurrency(adapters.flatMap((adapter) => {
4235
+ return (adapter.hasOutput ? ["input", "output"] : ["input"]).map((kind) => ({
4236
+ adapter,
4237
+ kind
4238
+ }));
4239
+ }), ({ adapter, kind }) => bundleAdapterScript(adapter, kind, outputDir, tsconfig, cache));
4240
+ const bundledInputs = /* @__PURE__ */ new Map();
4241
+ const bundledOutputs = /* @__PURE__ */ new Map();
4242
+ for (const [name, kind, code] of results) if (kind === "input") bundledInputs.set(name, code);
4243
+ else bundledOutputs.set(name, code);
4244
+ logger.log(`${styles.success("Bundled")} ${styles.info("\"http-adapter\"")}`);
4245
+ return {
4246
+ bundledInputs,
4247
+ bundledOutputs
4248
+ };
4249
+ }
4250
+ async function bundleAdapterScript(adapter, kind, outputDir, tsconfig, cache) {
4251
+ const contextHash = computeBundlerContextHash({
4252
+ sourceFile: adapter.sourceFile,
4253
+ serializedTriggerContext: kind === "input" ? adapter.methods.join(",") : "",
4254
+ tsconfig,
4255
+ inlineSourcemap: false,
4256
+ prefix: kind
4257
+ });
4258
+ const code = await withCache({
4259
+ cache,
4260
+ kind: kind === "input" ? "http-adapter-input" : "http-adapter-output",
4261
+ name: adapter.name,
4262
+ sourceFile: adapter.sourceFile,
4263
+ contextHash,
4264
+ async build(cachePlugins) {
4265
+ const entryPath = path.join(outputDir, `${adapter.name}.${kind}.entry.js`);
4266
+ const absoluteSourcePath = path.resolve(adapter.sourceFile);
4267
+ const entryContent = kind === "input" ? buildInputEntry(absoluteSourcePath, adapter.methods) : buildOutputEntry(absoluteSourcePath);
4268
+ fs$1.writeFileSync(entryPath, entryContent);
4269
+ const plugins = [
4270
+ {
4271
+ name: "http-adapter-reject-node-imports",
4272
+ resolveId(source) {
4273
+ if (isNodeBuiltinImport(source)) throw new Error(`HTTP adapter "${adapter.name}" imports Node module "${source}", which is unavailable in the gateway runtime`);
4274
+ return null;
4275
+ }
4276
+ },
4277
+ {
4278
+ name: "http-adapter-stub-sdk",
4279
+ resolveId(source) {
4280
+ if (source === "@tailor-platform/sdk" || source.startsWith("@tailor-platform/sdk/")) return {
4281
+ id: "\0http-adapter-sdk-stub",
4282
+ moduleSideEffects: false
4283
+ };
4284
+ return null;
4285
+ },
4286
+ load(id) {
4287
+ if (id === "\0http-adapter-sdk-stub") return "export const createHttpAdapter = (cfg) => cfg;\nexport default { createHttpAdapter };\n";
4288
+ return null;
4289
+ }
4290
+ },
4291
+ ...cachePlugins
4292
+ ];
4293
+ let bundled;
4294
+ try {
4295
+ bundled = (await rolldown.build({
4296
+ input: entryPath,
4297
+ write: false,
4298
+ output: {
4299
+ format: "iife",
4300
+ sourcemap: false,
4301
+ minify: true,
4302
+ codeSplitting: false
4303
+ },
4304
+ tsconfig,
4305
+ plugins,
4306
+ transform: { target: "es2017" },
4307
+ treeshake: {
4308
+ moduleSideEffects: false,
4309
+ annotations: true,
4310
+ unknownGlobalSideEffects: false
4311
+ },
4312
+ logLevel: "silent"
4313
+ })).output[0].code;
4314
+ } finally {
4315
+ try {
4316
+ fs$1.rmSync(entryPath, { force: true });
4317
+ } catch {}
4318
+ }
4319
+ const byteLength = Buffer.byteLength(bundled, "utf8");
4320
+ if (byteLength > ADAPTER_BUNDLE_ERROR_BYTES) throw new Error(`HTTP adapter "${adapter.name}" ${kind} script is ${byteLength} bytes, exceeding the ${ADAPTER_BUNDLE_ERROR_BYTES} byte limit`);
4321
+ if (byteLength > ADAPTER_BUNDLE_WARN_BYTES) logger.warn(`HTTP adapter "${adapter.name}" ${kind} script is ${byteLength} bytes, larger than the recommended ${ADAPTER_BUNDLE_WARN_BYTES} byte limit`);
4322
+ rejectAsyncInBundle(bundled, adapter.name, kind);
4323
+ return bundled;
4324
+ }
4325
+ });
4326
+ return [
4327
+ adapter.name,
4328
+ kind,
4329
+ code
4330
+ ];
4331
+ }
4332
+ function buildInputEntry(absoluteSourcePath, methods) {
4333
+ const cases = methods.map((method) => ` case "${HTTP_METHODS[method]}": return __adapter.input.${method}(req);`).join("\n");
4334
+ const supported = methods.map((m) => HTTP_METHODS[m]).join(", ");
4335
+ return `import __adapter from ${JSON.stringify(absoluteSourcePath)};
4336
+ globalThis.transform = function(req) {
4337
+ switch (req.method) {
4338
+ ${cases}
4339
+ default: throw new Error("HTTP adapter received unsupported method: " + req.method + " (supported: ${supported})");
4340
+ }
4341
+ };
4342
+ `;
4343
+ }
4344
+ function buildOutputEntry(absoluteSourcePath) {
4345
+ return `import __adapter from ${JSON.stringify(absoluteSourcePath)};
4346
+ globalThis.transform = __adapter.output;
4347
+ `;
4348
+ }
4349
+ function rejectAsyncInBundle(code, adapterName, kind) {
4350
+ const { program } = parseSync(`${adapterName}.${kind}.bundle.js`, code);
4351
+ let asyncFound = false;
4352
+ const stack = [program];
4353
+ while (stack.length > 0) {
4354
+ const node = stack.pop();
4355
+ if (!node || typeof node !== "object") continue;
4356
+ const n = node;
4357
+ const type = typeof n.type === "string" ? n.type : "";
4358
+ if (type === "AwaitExpression") {
4359
+ asyncFound = true;
4360
+ break;
4361
+ }
4362
+ if ((type === "FunctionDeclaration" || type === "FunctionExpression" || type === "ArrowFunctionExpression") && n.async === true) {
4363
+ asyncFound = true;
4364
+ break;
4365
+ }
4366
+ if ((type === "ForOfStatement" || type === "ForStatement") && n.await === true) {
4367
+ asyncFound = true;
4368
+ break;
4369
+ }
4370
+ for (const key of Object.keys(n)) {
4371
+ const child = n[key];
4372
+ if (Array.isArray(child)) for (const c of child) stack.push(c);
4373
+ else if (child && typeof child === "object") stack.push(child);
4374
+ }
4375
+ }
4376
+ if (asyncFound) throw new Error(`HTTP adapter "${adapterName}" ${kind} bundle contains async/await, which is unavailable in the gateway runtime. Check imported helper modules — even if your handler is synchronous, an async helper will fail at runtime.`);
4377
+ }
4378
+
4379
+ //#endregion
4380
+ //#region src/cli/services/http-adapter/service.ts
4381
+ function createHttpAdapterService(params) {
4382
+ const { config } = params;
4383
+ let adapters = [];
4384
+ let fileCount = 0;
4385
+ let loaded = false;
4386
+ return {
4387
+ config,
4388
+ get adapters() {
4389
+ return adapters;
4390
+ },
4391
+ get fileCount() {
4392
+ return fileCount;
4393
+ },
4394
+ loadAdapters: async () => {
4395
+ if (loaded) return;
4396
+ const result = await loadAdapterFiles(config);
4397
+ adapters = result.adapters;
4398
+ fileCount = result.fileCount;
4399
+ loaded = true;
4400
+ },
4401
+ printLoadedAdapters: () => {
4402
+ if (adapters.length === 0) return;
4403
+ logger.newline();
4404
+ logger.log(`Found ${styles.highlight(adapters.length.toString())} HTTP adapters`);
4405
+ for (const { adapter, sourceFile } of adapters) {
4406
+ const relativePath = path.relative(process.cwd(), sourceFile);
4407
+ logger.log(`HTTP adapter: ${styles.successBright(`"${adapter.name}"`)} loaded from ${styles.path(relativePath)}`);
4408
+ }
4409
+ }
4410
+ };
4411
+ }
4412
+ async function loadAdapterFiles(config) {
4413
+ if (!config.files || config.files.length === 0) return {
4414
+ adapters: [],
4415
+ fileCount: 0
4416
+ };
4417
+ const files = loadFilesWithIgnores(config);
4418
+ const loadResults = await Promise.all(files.map(loadAdapterFromFile));
4419
+ const adapters = [];
4420
+ const seenNames = /* @__PURE__ */ new Map();
4421
+ for (const result of loadResults) {
4422
+ if (!result) continue;
4423
+ const existing = seenNames.get(result.adapter.name);
4424
+ if (existing) throw new Error(`Duplicate HTTP adapter name "${result.adapter.name}" found:\n - ${existing}\n - ${result.sourceFile}\nEach HTTP adapter must have a unique name.`);
4425
+ seenNames.set(result.adapter.name, result.sourceFile);
4426
+ adapters.push(result);
4427
+ }
4428
+ return {
4429
+ adapters,
4430
+ fileCount: files.length
4431
+ };
4432
+ }
4433
+ async function loadAdapterFromFile(filePath) {
4434
+ try {
4435
+ const module = await import(pathToFileURL(filePath).href);
4436
+ if (!isSdkBranded(module.default, "http-adapter")) {
4437
+ const named = Object.entries(module).find(([exportName, value]) => exportName !== "default" && isSdkBranded(value, "http-adapter"));
4438
+ if (named) throw new Error(`HTTP adapter must be the default export, but it is exported as \`${named[0]}\`. Re-export it: \`export default createHttpAdapter({...})\`.`);
4439
+ return null;
4440
+ }
4441
+ const parsed = HttpAdapterConfigSchema.safeParse(module.default);
4442
+ if (!parsed.success) throw parsed.error;
4443
+ const adapter = parsed.data;
4444
+ const methods = collectMethodKeys(adapter);
4445
+ rejectAsyncHandlers(adapter, methods, filePath);
4446
+ return {
4447
+ adapter,
4448
+ sourceFile: filePath,
4449
+ methods,
4450
+ hasOutput: adapter.output !== void 0
4451
+ };
4452
+ } catch (error) {
4453
+ const relativePath = path.relative(process.cwd(), filePath);
4454
+ logger.error(`${styles.error("Failed to load HTTP adapter from")} ${styles.errorBright(relativePath)}`);
4455
+ logger.error(String(error));
4456
+ throw error;
4457
+ }
4458
+ }
4459
+ function collectMethodKeys(adapter) {
4460
+ const input = adapter.input;
4461
+ return HTTP_METHOD_KEYS.filter((key) => typeof input[key] === "function");
4462
+ }
4463
+ function rejectAsyncHandlers(adapter, methods, sourceFile) {
4464
+ const input = adapter.input;
4465
+ for (const method of methods) if (isAsyncFunction(input[method])) throw new Error(`HTTP adapter "${adapter.name}" in ${sourceFile} has an async \`input.${method}\` function. Handlers must be synchronous; async/await is not supported.`);
4466
+ if (adapter.output !== void 0 && isAsyncFunction(adapter.output)) throw new Error(`HTTP adapter "${adapter.name}" in ${sourceFile} has an async \`output\` function. Handlers must be synchronous; async/await is not supported.`);
4467
+ }
4468
+ function isAsyncFunction(fn) {
4469
+ return typeof fn === "function" && fn.constructor?.name === "AsyncFunction";
4470
+ }
4471
+
4162
4472
  //#endregion
4163
4473
  //#region src/parser/service/resolver/schema.ts
4164
4474
  const QueryTypeSchema = z.union([z.literal("query"), z.literal("mutation")]).describe("GraphQL operation type");
@@ -5181,6 +5491,10 @@ function defineWorkflow(config) {
5181
5491
  if (!config) return;
5182
5492
  return createWorkflowService({ config });
5183
5493
  }
5494
+ function defineHttpAdapterService(config) {
5495
+ if (!config) return;
5496
+ return createHttpAdapterService({ config });
5497
+ }
5184
5498
  function defineStaticWebsites(websites) {
5185
5499
  const staticWebsiteServices = [];
5186
5500
  const websiteNames = /* @__PURE__ */ new Set();
@@ -5249,6 +5563,7 @@ function buildApplication(params) {
5249
5563
  authService: params.authResult.authService,
5250
5564
  executorService: params.executorService,
5251
5565
  workflowService: params.workflowService,
5566
+ httpAdapterService: params.httpAdapterService,
5252
5567
  staticWebsiteServices: params.staticWebsiteServices,
5253
5568
  secrets: params.secrets,
5254
5569
  ignoreNullishValues: params.ignoreNullishValues,
@@ -5271,11 +5586,13 @@ function defineApplication(params) {
5271
5586
  const services = defineServices(config, pluginManager);
5272
5587
  const executorService = defineExecutor(config.executor, false);
5273
5588
  const workflowService = defineWorkflow(config.workflow);
5589
+ const httpAdapterService = defineHttpAdapterService(config.httpAdapter);
5274
5590
  return buildApplication({
5275
5591
  config,
5276
5592
  ...services,
5277
5593
  executorService,
5278
5594
  workflowService,
5595
+ httpAdapterService,
5279
5596
  env: config.env ?? {}
5280
5597
  });
5281
5598
  }
@@ -5323,6 +5640,8 @@ async function loadApplication(params) {
5323
5640
  const executorService = defineExecutor(config.executor, pluginExecutorFiles.length > 0);
5324
5641
  const workflowService = defineWorkflow(config.workflow);
5325
5642
  if (workflowService) await workflowService.loadWorkflows();
5643
+ const httpAdapterService = defineHttpAdapterService(config.httpAdapter);
5644
+ if (httpAdapterService) await httpAdapterService.loadAdapters();
5326
5645
  const triggerContext = await buildTriggerContext(config.workflow, authResult.authService?.config.name);
5327
5646
  const inlineSourcemap = resolveInlineSourcemap(config.inlineSourcemap);
5328
5647
  const bundledScripts = {
@@ -5348,6 +5667,13 @@ async function loadApplication(params) {
5348
5667
  workflowBuildResult = await bundleWorkflowJobs(workflowService.jobs, mainJobNames, config.env ?? {}, triggerContext, bundleCache, inlineSourcemap);
5349
5668
  bundledScripts.workflowJobs = workflowBuildResult.bundledCode;
5350
5669
  }
5670
+ let httpAdapterBuildResult;
5671
+ if (httpAdapterService && httpAdapterService.adapters.length > 0) httpAdapterBuildResult = await bundleHttpAdapters(httpAdapterService.adapters.map((a) => ({
5672
+ name: a.adapter.name,
5673
+ sourceFile: a.sourceFile,
5674
+ methods: a.methods,
5675
+ hasOutput: a.hasOutput
5676
+ })), bundleCache);
5351
5677
  if (authResult.authService?.config.hooks?.beforeLogin) {
5352
5678
  const authName = authResult.authService.config.name;
5353
5679
  bundledScripts.authHooks = await bundleAuthHooks({
@@ -5366,6 +5692,7 @@ async function loadApplication(params) {
5366
5692
  if (pluginExecutorFiles.length > 0) await executorService.loadPluginExecutorFiles([...pluginExecutorFiles]);
5367
5693
  }
5368
5694
  if (workflowService) workflowService.printLoadedWorkflows();
5695
+ if (httpAdapterService) httpAdapterService.printLoadedAdapters();
5369
5696
  logger.newline();
5370
5697
  return {
5371
5698
  application: buildApplication({
@@ -5376,16 +5703,18 @@ async function loadApplication(params) {
5376
5703
  authResult,
5377
5704
  executorService,
5378
5705
  workflowService,
5706
+ httpAdapterService,
5379
5707
  staticWebsiteServices,
5380
5708
  secrets,
5381
5709
  ignoreNullishValues,
5382
5710
  env: config.env ?? {}
5383
5711
  }),
5384
5712
  workflowBuildResult,
5713
+ httpAdapterBuildResult,
5385
5714
  bundledScripts
5386
5715
  };
5387
5716
  }
5388
5717
 
5389
5718
  //#endregion
5390
- export { loadConfigPath as C, saveUserTokens as D, resolveTokens as E, writePlatformConfig as O, loadAccessToken as S, readPlatformConfig as T, getDistDir as _, WorkflowJobSchema as a, deleteUserTokens as b, ExecutorSchema as c, buildResolverOperationHookExpr as d, OAuth2ClientSchema as f, createBundleCache as g, loadFilesWithIgnores as h, resolveInlineSourcemap as i, INVOKER_EXPR as l, stringifyFunction as m, generatePluginFilesIfNeeded as n, ResolverSchema as o, TailorDBTypeSchema as p, loadApplication as r, createExecutorService as s, defineApplication as t, buildExecutorArgsExpr as u, hashFile as v, loadWorkspaceId as w, fetchLatestToken as x, loadConfig as y };
5391
- //# sourceMappingURL=application-BfGje3iZ.mjs.map
5719
+ export { loadAccessToken as C, resolveTokens as D, readPlatformConfig as E, saveUserTokens as O, fetchLatestToken as S, loadWorkspaceId as T, createBundleCache as _, WorkflowJobSchema as a, loadConfig as b, createExecutorService as c, buildExecutorArgsExpr as d, buildResolverOperationHookExpr as f, loadFilesWithIgnores as g, stringifyFunction as h, resolveInlineSourcemap as i, writePlatformConfig as k, ExecutorSchema as l, TailorDBTypeSchema as m, generatePluginFilesIfNeeded as n, ResolverSchema as o, OAuth2ClientSchema as p, loadApplication as r, HTTP_METHODS as s, defineApplication as t, INVOKER_EXPR as u, getDistDir as v, loadConfigPath as w, deleteUserTokens as x, hashFile as y };
5720
+ //# sourceMappingURL=application-DzUlASfA.mjs.map