@tailor-platform/sdk 1.78.0 → 1.80.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.
- package/CHANGELOG.md +40 -0
- package/dist/{application-CUxVA7Fs.mjs → application-C1d52JP9.mjs} +290 -224
- package/dist/application-C1d52JP9.mjs.map +1 -0
- package/dist/application-Nlh9BHQf.mjs +3 -0
- package/dist/cli/commands/tailordb/migrate/bundler.d.mts +3 -2
- package/dist/cli/index.mjs +27 -53
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.mjs +3 -6
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/tsconfig-paths-hook.d.mts +1 -0
- package/dist/cli/tsconfig-paths-hook.mjs +153 -0
- package/dist/completion/zsh-worker.zsh +1 -1
- package/dist/configure/config/types.d.mts +5 -1
- package/dist/configure/index.mjs +7 -6
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/auth/types.d.mts +18 -23
- package/dist/configure/services/tailordb/schema.d.mts +1 -7
- package/dist/configure/services/workflow/execution-policy.d.mts +2 -2
- package/dist/configure/types/type.d.mts +1 -9
- package/dist/{globals-CvizbGLY.mjs → globals-B-n_3uYu.mjs} +11 -5
- package/dist/globals-B-n_3uYu.mjs.map +1 -0
- package/dist/{runtime-BD2vYJFT.mjs → register-typescript-runtime-Bd4bcLbW.mjs} +399 -124
- package/dist/register-typescript-runtime-Bd4bcLbW.mjs.map +1 -0
- package/dist/{registry-CYBRvfaU.mjs → registry-CXi7rJq7.mjs} +3 -2
- package/dist/registry-CXi7rJq7.mjs.map +1 -0
- package/dist/runtime/field-parse.d.mts +11 -0
- package/dist/runtime/globals.d.mts +4 -1
- package/dist/runtime/index.mjs +1 -1
- package/dist/runtime/workflow.d.mts +79 -15
- package/dist/runtime/workflow.mjs +2 -2
- package/dist/{schema-U6DxoZ8D.mjs → schema-CYrle8JZ.mjs} +42 -24
- package/dist/schema-CYrle8JZ.mjs.map +1 -0
- package/dist/{service-D12iQGcS.mjs → service-CDPatibu.mjs} +31 -17
- package/dist/service-CDPatibu.mjs.map +1 -0
- package/dist/service-Cg7Qibit.mjs +3 -0
- package/dist/vitest/environment.mjs +1 -1
- package/dist/vitest/index.mjs +36 -10
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mocks/workflow.d.mts +29 -15
- package/dist/vitest/setup.mjs +1 -1
- package/dist/workflow-CkIDJpdg.mjs +69 -0
- package/dist/workflow-CkIDJpdg.mjs.map +1 -0
- package/docs/cli/application.md +6 -0
- package/docs/cli-reference.md +21 -21
- package/docs/configuration.md +2 -0
- package/docs/runtime.md +2 -2
- package/docs/services/auth.md +2 -2
- package/docs/services/tailordb.md +2 -0
- package/docs/services/workflow.md +2 -2
- package/docs/testing.md +2 -2
- package/package.json +7 -6
- package/dist/application-CUxVA7Fs.mjs.map +0 -1
- package/dist/application-Dp_-ioiP.mjs +0 -3
- package/dist/configure/types/field-runtime.d.mts +0 -17
- package/dist/globals-CvizbGLY.mjs.map +0 -1
- package/dist/registry-CYBRvfaU.mjs.map +0 -1
- package/dist/runtime-BD2vYJFT.mjs.map +0 -1
- package/dist/schema-U6DxoZ8D.mjs.map +0 -1
- package/dist/service-CghpdV-9.mjs +0 -3
- package/dist/service-D12iQGcS.mjs.map +0 -1
- package/dist/workflow-DSwnYPPP.mjs +0 -45
- package/dist/workflow-DSwnYPPP.mjs.map +0 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { n as isSdkBranded } from "./brand-Eo4pLXPJ.mjs";
|
|
2
2
|
import { t as assertDefined } from "./assert-DBxo8jPo.mjs";
|
|
3
3
|
import { a as parseBoolean, n as logger, r as styles } from "./logger-BwS4ppwO.mjs";
|
|
4
|
-
import { a as TailorFieldSchema, i as AuthInvokerSchema, n as ExecutorSchema, o as loadFilesWithIgnores, r as AuthConfigSchema, s as functionSchema, t as createExecutorService } from "./service-
|
|
4
|
+
import { a as TailorFieldSchema, i as AuthInvokerSchema, n as ExecutorSchema, o as loadFilesWithIgnores, r as AuthConfigSchema, s as functionSchema, t as createExecutorService } from "./service-CDPatibu.mjs";
|
|
5
5
|
import { t as multiline } from "./multiline-sfHpTZZK.mjs";
|
|
6
6
|
import { t as isPluginGeneratedType } from "./type-source-DH_LH20p.mjs";
|
|
7
7
|
import { t as userAgent } from "./user-agent-DX2Jnw0-.mjs";
|
|
8
8
|
import { builtinModules, createRequire } from "node:module";
|
|
9
9
|
import { z } from "zod";
|
|
10
10
|
import { create } from "@bufbuild/protobuf";
|
|
11
|
-
import * as fs
|
|
12
|
-
import {
|
|
11
|
+
import * as fs from "node:fs";
|
|
12
|
+
import { readFileSync } from "node:fs";
|
|
13
13
|
import { MethodOptions_IdempotencyLevel } from "@bufbuild/protobuf/wkt";
|
|
14
14
|
import * as path from "pathe";
|
|
15
|
-
import {
|
|
15
|
+
import { resolve } from "pathe";
|
|
16
16
|
import { pathToFileURL } from "node:url";
|
|
17
17
|
import * as os from "node:os";
|
|
18
18
|
import { OAuth2Client } from "@badgateway/oauth2-client";
|
|
@@ -22,7 +22,6 @@ import pLimit from "p-limit";
|
|
|
22
22
|
import { resolveTSConfig } from "pkg-types";
|
|
23
23
|
import * as crypto from "node:crypto";
|
|
24
24
|
import * as rolldown from "rolldown";
|
|
25
|
-
import * as fs from "node:fs/promises";
|
|
26
25
|
import { parseSync } from "oxc-parser";
|
|
27
26
|
import * as inflection from "inflection";
|
|
28
27
|
import * as globals from "globals";
|
|
@@ -307,8 +306,10 @@ function connectCodeName(error) {
|
|
|
307
306
|
*
|
|
308
307
|
* Membership is deliberately an allowlist, not `startsWith("Create")`: swallowing
|
|
309
308
|
* synthesizes an empty response (see `synthesizeEmptyUnaryResponse`), which is only
|
|
310
|
-
* safe when every caller
|
|
311
|
-
* resource creations that fire under heavy parallelism and discard their response
|
|
309
|
+
* safe when every caller tolerates an empty response body. These are the deploy/apply
|
|
310
|
+
* resource creations that fire under heavy parallelism and discard their response —
|
|
311
|
+
* except `CreateSecretManagerSecret`, whose caller reads `secret.updateTime` but
|
|
312
|
+
* degrades safely when it is absent (the next deploy re-updates the secret).
|
|
312
313
|
*
|
|
313
314
|
* Intentionally excluded because their callers read the response body — swallowing
|
|
314
315
|
* would hand back an empty message and corrupt downstream state:
|
|
@@ -682,7 +683,7 @@ function hashContent(content) {
|
|
|
682
683
|
* @returns Hex-encoded SHA-256 hash of the file content
|
|
683
684
|
*/
|
|
684
685
|
function hashFile(filePath) {
|
|
685
|
-
const content = fs
|
|
686
|
+
const content = fs.readFileSync(filePath);
|
|
686
687
|
return crypto.createHash("sha256").update(content).digest("hex");
|
|
687
688
|
}
|
|
688
689
|
/**
|
|
@@ -811,7 +812,10 @@ function createBundleCache(store) {
|
|
|
811
812
|
return;
|
|
812
813
|
}
|
|
813
814
|
if (currentHash !== entry.inputHash) return;
|
|
814
|
-
|
|
815
|
+
const content = store.restoreBundleContent(cacheKey);
|
|
816
|
+
const output = entry.outputFiles.find((file) => file.outputPath === cacheKey);
|
|
817
|
+
if (content === void 0 || !output || hashContent(content) !== output.contentHash) return;
|
|
818
|
+
return content;
|
|
815
819
|
}
|
|
816
820
|
function save(params) {
|
|
817
821
|
const { kind, namespace, name, sourceFile, content, dependencyPaths, contextHash } = params;
|
|
@@ -858,7 +862,7 @@ function resolveRelativePluginImportPath(pluginImportPath, baseDirs) {
|
|
|
858
862
|
if (!pluginImportPath.startsWith(".")) return null;
|
|
859
863
|
for (const baseDir of baseDirs) {
|
|
860
864
|
const absolutePath = path.resolve(baseDir, pluginImportPath);
|
|
861
|
-
if (fs
|
|
865
|
+
if (fs.existsSync(absolutePath)) return absolutePath;
|
|
862
866
|
}
|
|
863
867
|
return null;
|
|
864
868
|
}
|
|
@@ -942,13 +946,13 @@ function generatePluginExecutorFiles(executors, outputDir, typeGenerationResult,
|
|
|
942
946
|
function generateSingleExecutorFile(info, outputDir, typeGenerationResult, sourceTypeInfoMap, baseDirs = []) {
|
|
943
947
|
const pluginDir = sanitizePluginId$1(info.pluginId);
|
|
944
948
|
const executorOutputDir = path.join(outputDir, pluginDir, "executors");
|
|
945
|
-
fs
|
|
949
|
+
fs.mkdirSync(executorOutputDir, { recursive: true });
|
|
946
950
|
const fileName = sanitizeExecutorFileName(info.executor.name);
|
|
947
951
|
const filePath = path.join(executorOutputDir, `${fileName}.ts`);
|
|
948
952
|
let content;
|
|
949
953
|
if (isPluginExecutorWithFile(info.executor)) content = generateExecutorFileContentNew(info, info.executor, outputDir, typeGenerationResult, sourceTypeInfoMap, baseDirs);
|
|
950
954
|
else content = generateExecutorFileContentLegacy(info.executor);
|
|
951
|
-
fs
|
|
955
|
+
fs.writeFileSync(filePath, content);
|
|
952
956
|
return filePath;
|
|
953
957
|
}
|
|
954
958
|
/**
|
|
@@ -1180,7 +1184,7 @@ function extractDynamicImportSpecifier(resolve) {
|
|
|
1180
1184
|
function resolvePluginBaseDir(pluginImportPath, baseDirs) {
|
|
1181
1185
|
if (pluginImportPath.startsWith(".")) {
|
|
1182
1186
|
const resolvedPath = resolveRelativePluginImportPath(pluginImportPath, baseDirs) ?? path.resolve(baseDirs[0] ?? process.cwd(), pluginImportPath);
|
|
1183
|
-
if (fs
|
|
1187
|
+
if (fs.existsSync(resolvedPath)) return fs.statSync(resolvedPath).isDirectory() ? resolvedPath : path.dirname(resolvedPath);
|
|
1184
1188
|
return path.extname(resolvedPath) ? path.dirname(resolvedPath) : resolvedPath;
|
|
1185
1189
|
}
|
|
1186
1190
|
for (const baseDir of baseDirs) try {
|
|
@@ -1267,11 +1271,11 @@ function generatePluginTypeFiles(types, outputDir) {
|
|
|
1267
1271
|
seenTypeNames.set(info.type.name, info);
|
|
1268
1272
|
const pluginDir = sanitizePluginId(info.pluginId);
|
|
1269
1273
|
const typeOutputDir = path.join(outputDir, pluginDir, "types");
|
|
1270
|
-
fs
|
|
1274
|
+
fs.mkdirSync(typeOutputDir, { recursive: true });
|
|
1271
1275
|
const fileName = `${toKebabCase(info.type.name)}.ts`;
|
|
1272
1276
|
const filePath = path.join(typeOutputDir, fileName);
|
|
1273
1277
|
const content = generateTypeFileContent(info);
|
|
1274
|
-
fs
|
|
1278
|
+
fs.writeFileSync(filePath, content);
|
|
1275
1279
|
generatedFiles.push(filePath);
|
|
1276
1280
|
const relativePath = path.relative(outputDir, filePath);
|
|
1277
1281
|
typeFilePaths.set(info.type.name, relativePath);
|
|
@@ -1392,20 +1396,6 @@ function toCamelCase(str) {
|
|
|
1392
1396
|
return result.charAt(0).toLowerCase() + result.slice(1);
|
|
1393
1397
|
}
|
|
1394
1398
|
|
|
1395
|
-
//#endregion
|
|
1396
|
-
//#region src/cli/services/stale-cleanup.ts
|
|
1397
|
-
/**
|
|
1398
|
-
* Remove stale `.entry.js` files from the output directory.
|
|
1399
|
-
*
|
|
1400
|
-
* Must be called before parallel bundling; concurrent builds
|
|
1401
|
-
* sharing the same output directory would otherwise conflict.
|
|
1402
|
-
* @param outputDir - Directory to clean
|
|
1403
|
-
*/
|
|
1404
|
-
async function removeStaleEntryFiles(outputDir) {
|
|
1405
|
-
const files = await fs.readdir(outputDir);
|
|
1406
|
-
await Promise.all(files.filter((file) => file.endsWith(".entry.js")).map((file) => fs.rm(path.join(outputDir, file), { force: true })));
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
1399
|
//#endregion
|
|
1410
1400
|
//#region src/cli/services/workflow/ast-utils.ts
|
|
1411
1401
|
/**
|
|
@@ -1805,16 +1795,17 @@ function createModuleBindings(program, source) {
|
|
|
1805
1795
|
* Build trigger context from configured workflow source files.
|
|
1806
1796
|
* @param workflowConfig - Workflow file loading configuration
|
|
1807
1797
|
* @param authNamespace - Auth service namespace used by workflow trigger options
|
|
1798
|
+
* @param baseDir - Directory the workflow config's file patterns are resolved against (defaults to process.cwd())
|
|
1808
1799
|
* @returns Module-local workflow and job binding metadata
|
|
1809
1800
|
*/
|
|
1810
|
-
async function buildTriggerContext(workflowConfig, authNamespace) {
|
|
1801
|
+
async function buildTriggerContext(workflowConfig, authNamespace, baseDir = process.cwd()) {
|
|
1811
1802
|
const modules = /* @__PURE__ */ new Map();
|
|
1812
1803
|
if (!workflowConfig) return {
|
|
1813
1804
|
modules,
|
|
1814
1805
|
authNamespace
|
|
1815
1806
|
};
|
|
1816
|
-
for (const file of loadFilesWithIgnores(workflowConfig)) try {
|
|
1817
|
-
const source = await fs
|
|
1807
|
+
for (const file of loadFilesWithIgnores(workflowConfig, baseDir)) try {
|
|
1808
|
+
const source = await fs.promises.readFile(file, "utf-8");
|
|
1818
1809
|
const { program } = parseSync("input.ts", source);
|
|
1819
1810
|
modules.set(normalizeFilePath(file), createModuleBindings(program, source));
|
|
1820
1811
|
} catch (error) {
|
|
@@ -2133,34 +2124,77 @@ const platformBundleDefinePlugin = {
|
|
|
2133
2124
|
}
|
|
2134
2125
|
};
|
|
2135
2126
|
|
|
2127
|
+
//#endregion
|
|
2128
|
+
//#region src/cli/shared/resolve-tsconfig.ts
|
|
2129
|
+
const warnedBaseDirs = /* @__PURE__ */ new Set();
|
|
2130
|
+
/**
|
|
2131
|
+
* Resolve the nearest tsconfig.json for baseDir, falling back to the tsconfig
|
|
2132
|
+
* resolved from the invocation cwd when baseDir's own ancestry has none.
|
|
2133
|
+
* @param baseDir - Directory to resolve the tsconfig against
|
|
2134
|
+
* @returns Absolute path to the resolved tsconfig.json, or undefined if none was found
|
|
2135
|
+
*/
|
|
2136
|
+
async function resolveTSConfigWithFallback(baseDir) {
|
|
2137
|
+
const tsconfig = await tryResolve(baseDir);
|
|
2138
|
+
if (tsconfig || baseDir === process.cwd()) return tsconfig;
|
|
2139
|
+
const fallback = await tryResolve(process.cwd());
|
|
2140
|
+
if (fallback && !warnedBaseDirs.has(baseDir)) {
|
|
2141
|
+
warnedBaseDirs.add(baseDir);
|
|
2142
|
+
logger.warn(`No tsconfig found from "${baseDir}"; falling back to the tsconfig resolved from process.cwd(). Move (or extend) a tsconfig into this directory before v2, when this fallback will be removed.`);
|
|
2143
|
+
}
|
|
2144
|
+
return fallback;
|
|
2145
|
+
}
|
|
2146
|
+
async function tryResolve(dir) {
|
|
2147
|
+
try {
|
|
2148
|
+
return await resolveTSConfig(dir);
|
|
2149
|
+
} catch {
|
|
2150
|
+
return;
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
//#endregion
|
|
2155
|
+
//#region src/cli/shared/virtual-entry.ts
|
|
2156
|
+
/**
|
|
2157
|
+
* Create an in-memory rolldown entry module with a deterministic ID.
|
|
2158
|
+
* @param name - Logical entry name
|
|
2159
|
+
* @param code - Entry module source
|
|
2160
|
+
* @param sourceType - Parser type for the generated module
|
|
2161
|
+
* @returns Rolldown input and plugin for loading the entry
|
|
2162
|
+
*/
|
|
2163
|
+
function createVirtualEntry(name, code, sourceType = "js") {
|
|
2164
|
+
const input = `tailor-sdk-entry:${name}.${sourceType}`;
|
|
2165
|
+
const resolvedId = `\0${input}`;
|
|
2166
|
+
return {
|
|
2167
|
+
input,
|
|
2168
|
+
plugin: {
|
|
2169
|
+
name: "tailor-sdk-virtual-entry",
|
|
2170
|
+
resolveId(source, importer) {
|
|
2171
|
+
return source === input && importer === void 0 ? resolvedId : null;
|
|
2172
|
+
},
|
|
2173
|
+
load(id) {
|
|
2174
|
+
return id === resolvedId ? code : null;
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
};
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2136
2180
|
//#endregion
|
|
2137
2181
|
//#region src/cli/services/auth/bundler.ts
|
|
2138
2182
|
/**
|
|
2139
2183
|
* Bundle a single auth hook handler.
|
|
2140
2184
|
*
|
|
2141
2185
|
* Follows the same pattern as the executor bundler:
|
|
2142
|
-
* 1. Generate an entry
|
|
2186
|
+
* 1. Generate an in-memory entry module that re-exports the handler as `main`
|
|
2143
2187
|
* 2. Bundle with rolldown + tree-shaking
|
|
2144
2188
|
* @param options - Bundle options
|
|
2145
2189
|
* @returns Map of function name to bundled code
|
|
2146
2190
|
*/
|
|
2147
2191
|
async function bundleAuthHooks(options) {
|
|
2148
|
-
const { configPath, authName, handlerAccessPath, env = {}, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG" } = options;
|
|
2192
|
+
const { configPath, authName, handlerAccessPath, env = {}, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG", baseDir } = options;
|
|
2149
2193
|
logger.newline();
|
|
2150
2194
|
logger.log(`Bundling auth hook for ${styles.info(`"${authName}"`)}`);
|
|
2151
|
-
const outputDir = path.resolve(getDistDir(), "auth-hooks");
|
|
2152
|
-
fs$1.mkdirSync(outputDir, { recursive: true });
|
|
2153
|
-
await removeStaleEntryFiles(outputDir);
|
|
2154
|
-
let tsconfig;
|
|
2155
|
-
try {
|
|
2156
|
-
tsconfig = await resolveTSConfig();
|
|
2157
|
-
} catch {
|
|
2158
|
-
tsconfig = void 0;
|
|
2159
|
-
}
|
|
2160
|
-
const functionName = `auth-hook--${authName}--before-login`;
|
|
2161
2195
|
const absoluteConfigPath = path.resolve(configPath);
|
|
2162
|
-
const
|
|
2163
|
-
const
|
|
2196
|
+
const tsconfig = await resolveTSConfigWithFallback(baseDir);
|
|
2197
|
+
const functionName = `auth-hook--${authName}--before-login`;
|
|
2164
2198
|
const code = await withCache({
|
|
2165
2199
|
cache,
|
|
2166
2200
|
kind: "auth-hook",
|
|
@@ -2168,14 +2202,13 @@ async function bundleAuthHooks(options) {
|
|
|
2168
2202
|
sourceFile: absoluteConfigPath,
|
|
2169
2203
|
contextHash: computeBundlerContextHash({
|
|
2170
2204
|
sourceFile: absoluteConfigPath,
|
|
2171
|
-
serializedTriggerContext,
|
|
2205
|
+
serializedTriggerContext: serializeTriggerContext(triggerContext),
|
|
2172
2206
|
tsconfig,
|
|
2173
2207
|
inlineSourcemap,
|
|
2174
2208
|
bundleLogLevel,
|
|
2175
|
-
prefix:
|
|
2209
|
+
prefix: JSON.stringify(Object.fromEntries(Object.entries(env).toSorted(([a], [b]) => a.localeCompare(b))))
|
|
2176
2210
|
}),
|
|
2177
2211
|
async build(cachePlugins) {
|
|
2178
|
-
const entryPath = path.join(outputDir, `${functionName}.entry.js`);
|
|
2179
2212
|
const entryContent = multiline`
|
|
2180
2213
|
import _config from "${absoluteConfigPath}";
|
|
2181
2214
|
const __auth_hook_function = _config.${handlerAccessPath};
|
|
@@ -2184,12 +2217,13 @@ async function bundleAuthHooks(options) {
|
|
|
2184
2217
|
return await __auth_hook_function({ ...args, env });
|
|
2185
2218
|
}
|
|
2186
2219
|
`;
|
|
2187
|
-
|
|
2220
|
+
const entry = createVirtualEntry(`auth-hook:${functionName}`, entryContent);
|
|
2188
2221
|
const triggerPlugin = createTriggerTransformPlugin(triggerContext);
|
|
2189
|
-
const plugins =
|
|
2222
|
+
const plugins = [entry.plugin];
|
|
2223
|
+
if (triggerPlugin) plugins.push(triggerPlugin);
|
|
2190
2224
|
plugins.push(platformBundleDefinePlugin, ...cachePlugins);
|
|
2191
2225
|
return (await rolldown.build({
|
|
2192
|
-
input:
|
|
2226
|
+
input: entry.input,
|
|
2193
2227
|
write: false,
|
|
2194
2228
|
output: {
|
|
2195
2229
|
format: "esm",
|
|
@@ -2491,6 +2525,36 @@ function findOmittedPermitRules(rawPermissions) {
|
|
|
2491
2525
|
});
|
|
2492
2526
|
return locations;
|
|
2493
2527
|
}
|
|
2528
|
+
/**
|
|
2529
|
+
* Check whether GraphQL exposure is fully disabled for a type, given its
|
|
2530
|
+
* effective gqlOperations (the type's own setting, falling back to the
|
|
2531
|
+
* TailorDB namespace default). `undefined` means the default of all
|
|
2532
|
+
* operations enabled, so it is never considered fully disabled.
|
|
2533
|
+
* @param gqlOperations - Effective, normalized gqlOperations configuration
|
|
2534
|
+
* @returns Whether create, update, delete, and read are all explicitly disabled
|
|
2535
|
+
*/
|
|
2536
|
+
function isGqlOperationsFullyDisabled(gqlOperations) {
|
|
2537
|
+
if (!gqlOperations) return false;
|
|
2538
|
+
return gqlOperations.create === false && gqlOperations.update === false && gqlOperations.delete === false && gqlOperations.read === false;
|
|
2539
|
+
}
|
|
2540
|
+
/**
|
|
2541
|
+
* Find missing permission configuration for a TailorDB type.
|
|
2542
|
+
*
|
|
2543
|
+
* Record-level permission is always required: TailorDB denies all record
|
|
2544
|
+
* operations for a type without it, regardless of whether the type is
|
|
2545
|
+
* exposed via GraphQL. GraphQL permission is required whenever GraphQL
|
|
2546
|
+
* exposure is enabled for the type (the default, unless every operation is
|
|
2547
|
+
* explicitly disabled via `gqlOperations`).
|
|
2548
|
+
* @param rawPermissions - Raw permissions definition for the type
|
|
2549
|
+
* @param effectiveGqlOperations - The type's own gqlOperations, falling back to the namespace default
|
|
2550
|
+
* @returns Which permission configuration, if any, is missing
|
|
2551
|
+
*/
|
|
2552
|
+
function findMissingPermissionConfig(rawPermissions, effectiveGqlOperations) {
|
|
2553
|
+
return {
|
|
2554
|
+
missingPermission: !rawPermissions.record,
|
|
2555
|
+
missingGqlPermission: !rawPermissions.gql && !isGqlOperationsFullyDisabled(effectiveGqlOperations)
|
|
2556
|
+
};
|
|
2557
|
+
}
|
|
2494
2558
|
|
|
2495
2559
|
//#endregion
|
|
2496
2560
|
//#region src/parser/service/tailordb/relation.ts
|
|
@@ -3311,7 +3375,7 @@ function buildMinimalEntryFromResolved(imports, declarations, fnSource, sourceFi
|
|
|
3311
3375
|
].join("\n");
|
|
3312
3376
|
}
|
|
3313
3377
|
async function bundleScriptTarget(args) {
|
|
3314
|
-
const { fn, kind, sourceFilePath, sourceBindings,
|
|
3378
|
+
const { fn, kind, sourceFilePath, sourceBindings, typeName, targetIndex, tsconfig } = args;
|
|
3315
3379
|
const context = `${kind} in ${sourceFilePath}`;
|
|
3316
3380
|
const fnSource = stringifyFunction(fn);
|
|
3317
3381
|
const inlineExpr = assertParsableExpression(`(${fnSource})({ value: _value, data: _data, user: ${tailorUserMap} })`, context);
|
|
@@ -3321,11 +3385,10 @@ async function bundleScriptTarget(args) {
|
|
|
3321
3385
|
if (unresolved.length > 0) throw new Error(`${context} captures unresolvable variables (${unresolved.join(", ")}). Hooks and validators must not reference variables that cannot be resolved from the source file.
|
|
3322
3386
|
${kind}: ${fnSource}`);
|
|
3323
3387
|
const entryContent = buildMinimalEntryFromResolved(imports, declarations, fnSource, sourceFilePath);
|
|
3324
|
-
const
|
|
3325
|
-
writeFileSync(entryPath, entryContent);
|
|
3388
|
+
const entry = createVirtualEntry(`tailordb-script:${typeName}:${targetIndex}`, entryContent, "ts");
|
|
3326
3389
|
const bundledCode = (await rolldown.build({
|
|
3327
|
-
plugins: [platformBundleDefinePlugin],
|
|
3328
|
-
input:
|
|
3390
|
+
plugins: [entry.plugin, platformBundleDefinePlugin],
|
|
3391
|
+
input: entry.input,
|
|
3329
3392
|
write: false,
|
|
3330
3393
|
output: {
|
|
3331
3394
|
format: "cjs",
|
|
@@ -3355,27 +3418,18 @@ async function precompileTailorDBTypeScripts(type, sourceFilePath, tsconfig) {
|
|
|
3355
3418
|
const targets = collectScriptTargets(type);
|
|
3356
3419
|
if (targets.length === 0) return;
|
|
3357
3420
|
const sourceBindings = collectSourceBindings(sourceFilePath);
|
|
3358
|
-
const
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
const firstError = results.find((r) => r.status === "rejected");
|
|
3371
|
-
if (firstError) throw firstError.reason;
|
|
3372
|
-
for (const [index, result] of results.entries()) if (result.status === "fulfilled") setPrecompiledScriptExpr(assertDefined(targets[index], `bundle target at index ${index} missing`).fn, result.value);
|
|
3373
|
-
} finally {
|
|
3374
|
-
rmSync(tempDir, {
|
|
3375
|
-
recursive: true,
|
|
3376
|
-
force: true
|
|
3377
|
-
});
|
|
3378
|
-
}
|
|
3421
|
+
const results = await Promise.allSettled(targets.map((target, index) => bundleScriptTarget({
|
|
3422
|
+
fn: target.fn,
|
|
3423
|
+
kind: target.kind,
|
|
3424
|
+
sourceFilePath,
|
|
3425
|
+
sourceBindings,
|
|
3426
|
+
typeName: type.name,
|
|
3427
|
+
targetIndex: index,
|
|
3428
|
+
tsconfig
|
|
3429
|
+
})));
|
|
3430
|
+
const firstError = results.find((r) => r.status === "rejected");
|
|
3431
|
+
if (firstError) throw firstError.reason;
|
|
3432
|
+
for (const [index, result] of results.entries()) if (result.status === "fulfilled") setPrecompiledScriptExpr(assertDefined(targets[index], `bundle target at index ${index} missing`).fn, result.value);
|
|
3379
3433
|
}
|
|
3380
3434
|
|
|
3381
3435
|
//#endregion
|
|
@@ -3505,7 +3559,7 @@ function formatTailorDBTypeNameSource(source) {
|
|
|
3505
3559
|
* @returns A new TailorDBService instance
|
|
3506
3560
|
*/
|
|
3507
3561
|
function createTailorDBService(params) {
|
|
3508
|
-
const { namespace, config, pluginManager } = params;
|
|
3562
|
+
const { namespace, config, pluginManager, baseDir } = params;
|
|
3509
3563
|
const createRawTypesByName = () => Object.create(null);
|
|
3510
3564
|
const rawTypes = Object.create(null);
|
|
3511
3565
|
let types = {};
|
|
@@ -3533,6 +3587,19 @@ function createTailorDBService(params) {
|
|
|
3533
3587
|
if (locations.length > 0) logger.warn(`TailorDB type "${typeName}" has permission rule(s) ${locations.join(", ")} in object form without an explicit "permit"; they default to "deny". Set permit: true (allow) or permit: false (deny) to silence this warning.`);
|
|
3534
3588
|
}
|
|
3535
3589
|
};
|
|
3590
|
+
const validateRequiredPermissions = () => {
|
|
3591
|
+
const errors = [];
|
|
3592
|
+
for (const fileTypes of Object.values(rawTypes)) for (const [typeName, type] of Object.entries(fileTypes)) {
|
|
3593
|
+
const effectiveGqlOperations = type.metadata.settings?.gqlOperations ?? config.gqlOperations;
|
|
3594
|
+
const { missingPermission, missingGqlPermission } = findMissingPermissionConfig(type.metadata.permissions, effectiveGqlOperations);
|
|
3595
|
+
if (!missingPermission && !missingGqlPermission) continue;
|
|
3596
|
+
const source = formatTailorDBTypeSourceInfo(typeSourceInfo[typeName]);
|
|
3597
|
+
const location = source ? ` (${source})` : "";
|
|
3598
|
+
if (missingPermission) errors.push(`TailorDB type "${typeName}"${location} has no .permission() configured. TailorDB denies all record operations for types without permission; call .permission(...) to grant access explicitly.`);
|
|
3599
|
+
if (missingGqlPermission) errors.push(`TailorDB type "${typeName}"${location} has no .gqlPermission() configured, but GraphQL operations are enabled for it. Call .gqlPermission(...) to grant GraphQL access explicitly, or disable GraphQL exposure with .features({ gqlOperations: { create: false, update: false, delete: false, read: false } }).`);
|
|
3600
|
+
}
|
|
3601
|
+
if (errors.length > 0) throw new Error(`TailorDB permission configuration errors in service "${namespace}":\n${errors.map((e) => ` - ${e}`).join("\n")}`);
|
|
3602
|
+
};
|
|
3536
3603
|
/**
|
|
3537
3604
|
* Process plugins for a type and add generated types to rawTypes
|
|
3538
3605
|
* @param rawType - The raw TailorDB type being processed
|
|
@@ -3612,19 +3679,15 @@ function createTailorDBService(params) {
|
|
|
3612
3679
|
loadTypes: async () => {
|
|
3613
3680
|
if (!loadPromise) loadPromise = (async () => {
|
|
3614
3681
|
if (config.files.length === 0) return;
|
|
3615
|
-
const typeFiles = [...new Set(loadFilesWithIgnores(config))];
|
|
3616
|
-
|
|
3617
|
-
try {
|
|
3618
|
-
tsconfig = await resolveTSConfig();
|
|
3619
|
-
} catch {
|
|
3620
|
-
tsconfig = void 0;
|
|
3621
|
-
}
|
|
3682
|
+
const typeFiles = [...new Set(loadFilesWithIgnores(config, baseDir))];
|
|
3683
|
+
const tsconfig = await resolveTSConfigWithFallback(baseDir);
|
|
3622
3684
|
logger.newline();
|
|
3623
3685
|
logger.log(`Found ${styles.highlight(typeFiles.length.toString())} type files for TailorDB service ${styles.highlight(`"${namespace}"`)}`);
|
|
3624
3686
|
if (pluginManager) for (const typeFile of typeFiles) await loadTypeFile(typeFile, tsconfig);
|
|
3625
3687
|
else await Promise.all(typeFiles.map((typeFile) => loadTypeFile(typeFile, tsconfig)));
|
|
3626
3688
|
doParseTypes();
|
|
3627
3689
|
warnOmittedPermit();
|
|
3690
|
+
validateRequiredPermissions();
|
|
3628
3691
|
return types;
|
|
3629
3692
|
})();
|
|
3630
3693
|
return loadPromise;
|
|
@@ -3666,7 +3729,10 @@ function createTailorDBService(params) {
|
|
|
3666
3729
|
hasGeneratedTypes = true;
|
|
3667
3730
|
logger.log(` Generated: ${styles.success(generatedType.name)} by namespace plugin ${styles.info(pluginId)}`);
|
|
3668
3731
|
}
|
|
3669
|
-
if (hasGeneratedTypes || hadPreviousGeneratedTypes)
|
|
3732
|
+
if (hasGeneratedTypes || hadPreviousGeneratedTypes) {
|
|
3733
|
+
doParseTypes();
|
|
3734
|
+
validateRequiredPermissions();
|
|
3735
|
+
}
|
|
3670
3736
|
}
|
|
3671
3737
|
};
|
|
3672
3738
|
}
|
|
@@ -3753,9 +3819,31 @@ function resolveBundleConcurrency() {
|
|
|
3753
3819
|
* @param worker - Async worker function
|
|
3754
3820
|
* @returns Worker results in input order
|
|
3755
3821
|
*/
|
|
3756
|
-
function withBundleConcurrency(items, worker) {
|
|
3757
|
-
const
|
|
3758
|
-
|
|
3822
|
+
async function withBundleConcurrency(items, worker) {
|
|
3823
|
+
const resultCount = items.length;
|
|
3824
|
+
const workItems = items.flatMap((item, index) => [{
|
|
3825
|
+
index,
|
|
3826
|
+
item
|
|
3827
|
+
}]);
|
|
3828
|
+
const results = [];
|
|
3829
|
+
results.length = resultCount;
|
|
3830
|
+
let nextWorkIndex = 0;
|
|
3831
|
+
let rejection;
|
|
3832
|
+
const runWorker = async () => {
|
|
3833
|
+
while (!rejection) {
|
|
3834
|
+
const workItem = workItems[nextWorkIndex++];
|
|
3835
|
+
if (workItem === void 0) return;
|
|
3836
|
+
try {
|
|
3837
|
+
results[workItem.index] = await worker(workItem.item);
|
|
3838
|
+
} catch (reason) {
|
|
3839
|
+
rejection ??= { reason };
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
};
|
|
3843
|
+
const workerCount = Math.min(resolveBundleConcurrency(), workItems.length);
|
|
3844
|
+
await Promise.all(Array.from({ length: workerCount }, runWorker));
|
|
3845
|
+
if (rejection) throw rejection.reason;
|
|
3846
|
+
return results;
|
|
3759
3847
|
}
|
|
3760
3848
|
|
|
3761
3849
|
//#endregion
|
|
@@ -3766,7 +3854,7 @@ function withBundleConcurrency(items, worker) {
|
|
|
3766
3854
|
* Two delivery paths:
|
|
3767
3855
|
* - Apply config: shipped with apply and evaluated by the platform before
|
|
3768
3856
|
* invoking user code.
|
|
3769
|
-
* - Bundle inline: interpolated into the generated
|
|
3857
|
+
* - Bundle inline: interpolated into the generated entry module and
|
|
3770
3858
|
* evaluated inside the bundled script at function entry.
|
|
3771
3859
|
*
|
|
3772
3860
|
* The user field mapping (server → SDK) shared across services is defined in
|
|
@@ -3851,15 +3939,15 @@ async function loadExecutor(executorFilePath) {
|
|
|
3851
3939
|
* Bundle executors from the specified configuration
|
|
3852
3940
|
*
|
|
3853
3941
|
* This function:
|
|
3854
|
-
* 1. Creates entry
|
|
3942
|
+
* 1. Creates an in-memory entry module that extracts operation.body
|
|
3855
3943
|
* 2. Bundles in a single step with tree-shaking
|
|
3856
3944
|
* @param options - Bundle executor options
|
|
3857
3945
|
* @returns Map of executor name to bundled code
|
|
3858
3946
|
*/
|
|
3859
3947
|
async function bundleExecutors(options) {
|
|
3860
3948
|
const bundledCode = /* @__PURE__ */ new Map();
|
|
3861
|
-
const { config, triggerContext, additionalFiles = [], cache, inlineSourcemap, bundleLogLevel = "DEBUG" } = options;
|
|
3862
|
-
const files = [...loadFilesWithIgnores(config), ...additionalFiles];
|
|
3949
|
+
const { config, triggerContext, additionalFiles = [], cache, inlineSourcemap, bundleLogLevel = "DEBUG", baseDir } = options;
|
|
3950
|
+
const files = [...loadFilesWithIgnores(config, baseDir), ...additionalFiles];
|
|
3863
3951
|
if (files.length === 0) {
|
|
3864
3952
|
logger.warn(`No executor files found for patterns: ${config.files.join(", ")}`);
|
|
3865
3953
|
return bundledCode;
|
|
@@ -3886,21 +3974,13 @@ async function bundleExecutors(options) {
|
|
|
3886
3974
|
logger.debug(" No function executors to bundle");
|
|
3887
3975
|
return bundledCode;
|
|
3888
3976
|
}
|
|
3889
|
-
const
|
|
3890
|
-
|
|
3891
|
-
await removeStaleEntryFiles(outputDir);
|
|
3892
|
-
let tsconfig;
|
|
3893
|
-
try {
|
|
3894
|
-
tsconfig = await resolveTSConfig();
|
|
3895
|
-
} catch {
|
|
3896
|
-
tsconfig = void 0;
|
|
3897
|
-
}
|
|
3898
|
-
const results = await withBundleConcurrency(executors, (executor) => bundleSingleExecutor(executor, outputDir, tsconfig, triggerContext, cache, inlineSourcemap, bundleLogLevel));
|
|
3977
|
+
const tsconfig = await resolveTSConfigWithFallback(baseDir);
|
|
3978
|
+
const results = await withBundleConcurrency(executors, (executor) => bundleSingleExecutor(executor, tsconfig, triggerContext, cache, inlineSourcemap, bundleLogLevel));
|
|
3899
3979
|
for (const [name, code] of results) bundledCode.set(name, code);
|
|
3900
3980
|
logger.log(`${styles.success("Bundled")} ${styles.info("\"executor\"")}`);
|
|
3901
3981
|
return bundledCode;
|
|
3902
3982
|
}
|
|
3903
|
-
async function bundleSingleExecutor(executor,
|
|
3983
|
+
async function bundleSingleExecutor(executor, tsconfig, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
|
|
3904
3984
|
const serializedTriggerContext = serializeTriggerContext(triggerContext);
|
|
3905
3985
|
const contextHash = computeBundlerContextHash({
|
|
3906
3986
|
sourceFile: executor.sourceFile,
|
|
@@ -3916,7 +3996,6 @@ async function bundleSingleExecutor(executor, outputDir, tsconfig, triggerContex
|
|
|
3916
3996
|
sourceFile: executor.sourceFile,
|
|
3917
3997
|
contextHash,
|
|
3918
3998
|
async build(cachePlugins) {
|
|
3919
|
-
const entryPath = path.join(outputDir, `${executor.name}.entry.js`);
|
|
3920
3999
|
const entryContent = multiline`
|
|
3921
4000
|
import _internalExecutor from "${path.resolve(executor.sourceFile)}";
|
|
3922
4001
|
|
|
@@ -3927,12 +4006,13 @@ async function bundleSingleExecutor(executor, outputDir, tsconfig, triggerContex
|
|
|
3927
4006
|
|
|
3928
4007
|
export { __executor_function as main };
|
|
3929
4008
|
`;
|
|
3930
|
-
|
|
4009
|
+
const entry = createVirtualEntry(`executor:${executor.name}`, entryContent);
|
|
3931
4010
|
const triggerPlugin = createTriggerTransformPlugin(triggerContext);
|
|
3932
|
-
const plugins =
|
|
4011
|
+
const plugins = [entry.plugin];
|
|
4012
|
+
if (triggerPlugin) plugins.push(triggerPlugin);
|
|
3933
4013
|
plugins.push(platformBundleDefinePlugin, ...cachePlugins);
|
|
3934
4014
|
return (await rolldown.build({
|
|
3935
|
-
input:
|
|
4015
|
+
input: entry.input,
|
|
3936
4016
|
write: false,
|
|
3937
4017
|
output: {
|
|
3938
4018
|
format: "esm",
|
|
@@ -4004,31 +4084,25 @@ const GRAPHQL_WEB_MODULE = createRequire(import.meta.url).resolve("@0no-co/graph
|
|
|
4004
4084
|
* IIFE defining a global `transform(input)` entry point. `input` gets a
|
|
4005
4085
|
* generated dispatcher that routes by `req.method`; `output` is used as is.
|
|
4006
4086
|
* @param adapters - Detected adapters to bundle
|
|
4087
|
+
* @param baseDir - Directory the owning config's tsconfig is resolved against
|
|
4007
4088
|
* @param cache - Optional bundle cache for skipping unchanged builds
|
|
4008
4089
|
* @param bundleLogLevel - Controls which console calls are kept in bundled code
|
|
4009
4090
|
* @returns Bundled scripts keyed by adapter name
|
|
4010
4091
|
*/
|
|
4011
|
-
async function bundleHttpAdapters(adapters, cache, bundleLogLevel = "DEBUG") {
|
|
4092
|
+
async function bundleHttpAdapters(adapters, baseDir, cache, bundleLogLevel = "DEBUG") {
|
|
4012
4093
|
if (adapters.length === 0) return {
|
|
4013
4094
|
bundledInputs: /* @__PURE__ */ new Map(),
|
|
4014
4095
|
bundledOutputs: /* @__PURE__ */ new Map()
|
|
4015
4096
|
};
|
|
4016
4097
|
logger.newline();
|
|
4017
4098
|
logger.log(`Bundling ${styles.highlight(adapters.length.toString())} files for ${styles.info("\"http-adapter\"")}`);
|
|
4018
|
-
const
|
|
4019
|
-
fs$1.mkdirSync(outputDir, { recursive: true });
|
|
4020
|
-
let tsconfig;
|
|
4021
|
-
try {
|
|
4022
|
-
tsconfig = await resolveTSConfig();
|
|
4023
|
-
} catch {
|
|
4024
|
-
tsconfig = void 0;
|
|
4025
|
-
}
|
|
4099
|
+
const tsconfig = await resolveTSConfigWithFallback(baseDir);
|
|
4026
4100
|
const results = await withBundleConcurrency(adapters.flatMap((adapter) => {
|
|
4027
4101
|
return (adapter.hasOutput ? ["input", "output"] : ["input"]).map((kind) => ({
|
|
4028
4102
|
adapter,
|
|
4029
4103
|
kind
|
|
4030
4104
|
}));
|
|
4031
|
-
}), ({ adapter, kind }) => bundleAdapterScript(adapter, kind,
|
|
4105
|
+
}), ({ adapter, kind }) => bundleAdapterScript(adapter, kind, tsconfig, cache, bundleLogLevel));
|
|
4032
4106
|
const bundledInputs = /* @__PURE__ */ new Map();
|
|
4033
4107
|
const bundledOutputs = /* @__PURE__ */ new Map();
|
|
4034
4108
|
for (const [name, kind, code] of results) if (kind === "input") bundledInputs.set(name, code);
|
|
@@ -4039,7 +4113,7 @@ async function bundleHttpAdapters(adapters, cache, bundleLogLevel = "DEBUG") {
|
|
|
4039
4113
|
bundledOutputs
|
|
4040
4114
|
};
|
|
4041
4115
|
}
|
|
4042
|
-
async function bundleAdapterScript(adapter, kind,
|
|
4116
|
+
async function bundleAdapterScript(adapter, kind, tsconfig, cache, bundleLogLevel = "DEBUG") {
|
|
4043
4117
|
const contextHash = computeBundlerContextHash({
|
|
4044
4118
|
sourceFile: adapter.sourceFile,
|
|
4045
4119
|
serializedTriggerContext: kind === "input" ? adapter.methods.join(",") : "",
|
|
@@ -4055,9 +4129,11 @@ async function bundleAdapterScript(adapter, kind, outputDir, tsconfig, cache, bu
|
|
|
4055
4129
|
sourceFile: adapter.sourceFile,
|
|
4056
4130
|
contextHash,
|
|
4057
4131
|
async build(cachePlugins) {
|
|
4058
|
-
const entryPath = path.join(outputDir, `${adapter.name}.${kind}.entry.js`);
|
|
4059
4132
|
const absoluteSourcePath = path.resolve(adapter.sourceFile);
|
|
4133
|
+
const entryContent = kind === "input" ? buildInputEntry(absoluteSourcePath, adapter.methods, GRAPHQL_WEB_MODULE) : buildOutputEntry(absoluteSourcePath);
|
|
4134
|
+
const entry = createVirtualEntry(`http-adapter:${adapter.name}:${kind}`, entryContent);
|
|
4060
4135
|
const plugins = [
|
|
4136
|
+
entry.plugin,
|
|
4061
4137
|
{
|
|
4062
4138
|
name: "http-adapter-reject-node-imports",
|
|
4063
4139
|
resolveId(source) {
|
|
@@ -4081,30 +4157,21 @@ async function bundleAdapterScript(adapter, kind, outputDir, tsconfig, cache, bu
|
|
|
4081
4157
|
},
|
|
4082
4158
|
...cachePlugins
|
|
4083
4159
|
];
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
transform: { target: "es2017" },
|
|
4100
|
-
treeshake: composeFunctionTreeshakeOptions([createLogLevelTreeshakeOptions(bundleLogLevel)]),
|
|
4101
|
-
logLevel: "silent"
|
|
4102
|
-
})).output[0].code;
|
|
4103
|
-
} finally {
|
|
4104
|
-
try {
|
|
4105
|
-
fs$1.rmSync(entryPath, { force: true });
|
|
4106
|
-
} catch {}
|
|
4107
|
-
}
|
|
4160
|
+
const bundled = (await rolldown.build({
|
|
4161
|
+
input: entry.input,
|
|
4162
|
+
write: false,
|
|
4163
|
+
output: {
|
|
4164
|
+
format: "iife",
|
|
4165
|
+
sourcemap: false,
|
|
4166
|
+
minify: true,
|
|
4167
|
+
codeSplitting: false
|
|
4168
|
+
},
|
|
4169
|
+
tsconfig,
|
|
4170
|
+
plugins,
|
|
4171
|
+
transform: { target: "es2017" },
|
|
4172
|
+
treeshake: composeFunctionTreeshakeOptions([createLogLevelTreeshakeOptions(bundleLogLevel)]),
|
|
4173
|
+
logLevel: "silent"
|
|
4174
|
+
})).output[0].code;
|
|
4108
4175
|
const byteLength = Buffer.byteLength(bundled, "utf8");
|
|
4109
4176
|
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`);
|
|
4110
4177
|
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`);
|
|
@@ -4178,7 +4245,7 @@ function rejectAsyncInBundle(code, adapterName, kind) {
|
|
|
4178
4245
|
//#endregion
|
|
4179
4246
|
//#region src/cli/services/http-adapter/service.ts
|
|
4180
4247
|
function createHttpAdapterService(params) {
|
|
4181
|
-
const { config } = params;
|
|
4248
|
+
const { config, baseDir } = params;
|
|
4182
4249
|
let adapters = [];
|
|
4183
4250
|
let fileCount = 0;
|
|
4184
4251
|
let loaded = false;
|
|
@@ -4192,7 +4259,7 @@ function createHttpAdapterService(params) {
|
|
|
4192
4259
|
},
|
|
4193
4260
|
loadAdapters: async () => {
|
|
4194
4261
|
if (loaded) return;
|
|
4195
|
-
const result = await loadAdapterFiles(config);
|
|
4262
|
+
const result = await loadAdapterFiles(config, baseDir);
|
|
4196
4263
|
adapters = result.adapters;
|
|
4197
4264
|
fileCount = result.fileCount;
|
|
4198
4265
|
loaded = true;
|
|
@@ -4208,12 +4275,12 @@ function createHttpAdapterService(params) {
|
|
|
4208
4275
|
}
|
|
4209
4276
|
};
|
|
4210
4277
|
}
|
|
4211
|
-
async function loadAdapterFiles(config) {
|
|
4278
|
+
async function loadAdapterFiles(config, baseDir) {
|
|
4212
4279
|
if (config.files.length === 0) return {
|
|
4213
4280
|
adapters: [],
|
|
4214
4281
|
fileCount: 0
|
|
4215
4282
|
};
|
|
4216
|
-
const files = loadFilesWithIgnores(config);
|
|
4283
|
+
const files = loadFilesWithIgnores(config, baseDir);
|
|
4217
4284
|
const loadResults = await Promise.all(files.map(loadAdapterFromFile));
|
|
4218
4285
|
const adapters = [];
|
|
4219
4286
|
const seenNames = /* @__PURE__ */ new Map();
|
|
@@ -4303,19 +4370,20 @@ async function loadResolver(resolverFilePath) {
|
|
|
4303
4370
|
*
|
|
4304
4371
|
* This function:
|
|
4305
4372
|
* 1. Uses a transform plugin to add validation wrapper during bundling
|
|
4306
|
-
* 2. Creates entry
|
|
4373
|
+
* 2. Creates an in-memory entry module
|
|
4307
4374
|
* 3. Bundles in a single step with tree-shaking
|
|
4308
4375
|
* @param namespace - Resolver namespace name
|
|
4309
4376
|
* @param config - Resolver file loading configuration
|
|
4377
|
+
* @param baseDir - Directory the config's file patterns are resolved against
|
|
4310
4378
|
* @param triggerContext - Trigger context for workflow/job transformations
|
|
4311
4379
|
* @param cache - Optional bundle cache for skipping unchanged builds
|
|
4312
4380
|
* @param inlineSourcemap - Whether to enable inline sourcemaps
|
|
4313
4381
|
* @param bundleLogLevel - Controls which console calls are kept in bundled code
|
|
4314
4382
|
* @returns Map of resolver name to bundled code
|
|
4315
4383
|
*/
|
|
4316
|
-
async function bundleResolvers(namespace, config, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
|
|
4384
|
+
async function bundleResolvers(namespace, config, baseDir, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
|
|
4317
4385
|
const bundledCode = /* @__PURE__ */ new Map();
|
|
4318
|
-
const files = loadFilesWithIgnores(config);
|
|
4386
|
+
const files = loadFilesWithIgnores(config, baseDir);
|
|
4319
4387
|
if (files.length === 0) {
|
|
4320
4388
|
logger.warn(`No resolver files found for patterns: ${config.files.join(", ")}`);
|
|
4321
4389
|
return bundledCode;
|
|
@@ -4334,21 +4402,13 @@ async function bundleResolvers(namespace, config, triggerContext, cache, inlineS
|
|
|
4334
4402
|
sourceFile: file
|
|
4335
4403
|
});
|
|
4336
4404
|
}
|
|
4337
|
-
const
|
|
4338
|
-
|
|
4339
|
-
await removeStaleEntryFiles(outputDir);
|
|
4340
|
-
let tsconfig;
|
|
4341
|
-
try {
|
|
4342
|
-
tsconfig = await resolveTSConfig();
|
|
4343
|
-
} catch {
|
|
4344
|
-
tsconfig = void 0;
|
|
4345
|
-
}
|
|
4346
|
-
const results = await withBundleConcurrency(resolvers, (resolver) => bundleSingleResolver(namespace, resolver, outputDir, tsconfig, triggerContext, cache, inlineSourcemap, bundleLogLevel));
|
|
4405
|
+
const tsconfig = await resolveTSConfigWithFallback(baseDir);
|
|
4406
|
+
const results = await withBundleConcurrency(resolvers, (resolver) => bundleSingleResolver(namespace, resolver, tsconfig, triggerContext, cache, inlineSourcemap, bundleLogLevel));
|
|
4347
4407
|
for (const [name, code] of results) bundledCode.set(name, code);
|
|
4348
4408
|
logger.log(`${styles.success("Bundled")} ${styles.info(`"${namespace}"`)}`);
|
|
4349
4409
|
return bundledCode;
|
|
4350
4410
|
}
|
|
4351
|
-
async function bundleSingleResolver(namespace, resolver,
|
|
4411
|
+
async function bundleSingleResolver(namespace, resolver, tsconfig, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
|
|
4352
4412
|
const serializedTriggerContext = serializeTriggerContext(triggerContext);
|
|
4353
4413
|
const contextHash = computeBundlerContextHash({
|
|
4354
4414
|
sourceFile: resolver.sourceFile,
|
|
@@ -4365,7 +4425,6 @@ async function bundleSingleResolver(namespace, resolver, outputDir, tsconfig, tr
|
|
|
4365
4425
|
sourceFile: resolver.sourceFile,
|
|
4366
4426
|
contextHash,
|
|
4367
4427
|
async build(cachePlugins) {
|
|
4368
|
-
const entryPath = path.join(outputDir, `${resolver.name}.entry.js`);
|
|
4369
4428
|
const entryContent = multiline`
|
|
4370
4429
|
import _internalResolver from "${path.resolve(resolver.sourceFile)}";
|
|
4371
4430
|
import { t } from "@tailor-platform/sdk";
|
|
@@ -4392,12 +4451,13 @@ async function bundleSingleResolver(namespace, resolver, outputDir, tsconfig, tr
|
|
|
4392
4451
|
|
|
4393
4452
|
export { $tailor_resolver_body as main };
|
|
4394
4453
|
`;
|
|
4395
|
-
|
|
4454
|
+
const entry = createVirtualEntry(`resolver:${resolver.name}`, entryContent);
|
|
4396
4455
|
const triggerPlugin = createTriggerTransformPlugin(triggerContext);
|
|
4397
|
-
const plugins =
|
|
4456
|
+
const plugins = [entry.plugin];
|
|
4457
|
+
if (triggerPlugin) plugins.push(triggerPlugin);
|
|
4398
4458
|
plugins.push(platformBundleDefinePlugin, ...cachePlugins);
|
|
4399
4459
|
return (await rolldown.build({
|
|
4400
|
-
input:
|
|
4460
|
+
input: entry.input,
|
|
4401
4461
|
write: false,
|
|
4402
4462
|
output: {
|
|
4403
4463
|
format: "esm",
|
|
@@ -4421,9 +4481,10 @@ async function bundleSingleResolver(namespace, resolver, outputDir, tsconfig, tr
|
|
|
4421
4481
|
* Creates a new ResolverService instance.
|
|
4422
4482
|
* @param namespace - The namespace for this resolver service
|
|
4423
4483
|
* @param config - The resolver service configuration
|
|
4484
|
+
* @param baseDir - Directory the config's file patterns are resolved against
|
|
4424
4485
|
* @returns A new ResolverService instance
|
|
4425
4486
|
*/
|
|
4426
|
-
function createResolverService(namespace, config) {
|
|
4487
|
+
function createResolverService(namespace, config, baseDir) {
|
|
4427
4488
|
const resolvers = {};
|
|
4428
4489
|
const loadResolverForFile = async (resolverFile) => {
|
|
4429
4490
|
try {
|
|
@@ -4452,7 +4513,7 @@ function createResolverService(namespace, config) {
|
|
|
4452
4513
|
loadResolvers: async () => {
|
|
4453
4514
|
if (Object.keys(resolvers).length > 0) return;
|
|
4454
4515
|
if (config.files.length === 0) return;
|
|
4455
|
-
const resolverFiles = loadFilesWithIgnores(config);
|
|
4516
|
+
const resolverFiles = loadFilesWithIgnores(config, baseDir);
|
|
4456
4517
|
logger.log(`Found ${styles.highlight(resolverFiles.length.toString())} resolver files for service ${styles.highlight(`"${namespace}"`)}`);
|
|
4457
4518
|
await Promise.all(resolverFiles.map((resolverFile) => loadResolverForFile(resolverFile)));
|
|
4458
4519
|
assertUniqueResolverNames(resolvers, namespace);
|
|
@@ -4585,7 +4646,7 @@ function transformWorkflowSource(source, targetJobName, targetJobExportName, oth
|
|
|
4585
4646
|
function safeRealpath(p) {
|
|
4586
4647
|
const resolved = path.resolve(p);
|
|
4587
4648
|
try {
|
|
4588
|
-
return fs
|
|
4649
|
+
return fs.realpathSync(resolved);
|
|
4589
4650
|
} catch (e) {
|
|
4590
4651
|
logger.debug(`realpathSync failed for ${resolved}: ${e instanceof Error ? e.message : e}`);
|
|
4591
4652
|
return resolved;
|
|
@@ -4597,19 +4658,20 @@ function safeRealpath(p) {
|
|
|
4597
4658
|
* This function:
|
|
4598
4659
|
* 1. Detects which jobs are actually used (mainJobs + their dependencies)
|
|
4599
4660
|
* 2. Uses a transform plugin to transform trigger calls during bundling
|
|
4600
|
-
* 3. Creates entry
|
|
4661
|
+
* 3. Creates an in-memory entry module and bundles with tree-shaking
|
|
4601
4662
|
*
|
|
4602
4663
|
* Returns metadata about which jobs each workflow uses.
|
|
4603
4664
|
* @param allJobs - All available job infos
|
|
4604
4665
|
* @param mainJobNames - Names of main jobs
|
|
4605
4666
|
* @param env - Environment variables to inject
|
|
4606
4667
|
* @param triggerContext - Trigger context for transformations
|
|
4668
|
+
* @param baseDir - Directory the owning config's tsconfig is resolved against
|
|
4607
4669
|
* @param cache - Optional bundle cache for skipping unchanged builds
|
|
4608
4670
|
* @param inlineSourcemap - Whether to enable inline sourcemaps
|
|
4609
4671
|
* @param bundleLogLevel - Controls which console calls are kept in bundled code
|
|
4610
4672
|
* @returns Workflow job bundling result
|
|
4611
4673
|
*/
|
|
4612
|
-
async function bundleWorkflowJobs(allJobs, mainJobNames, env = {}, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
|
|
4674
|
+
async function bundleWorkflowJobs(allJobs, mainJobNames, env = {}, triggerContext, baseDir, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
|
|
4613
4675
|
if (allJobs.length === 0) {
|
|
4614
4676
|
logger.warn("No workflow jobs to bundle");
|
|
4615
4677
|
return {
|
|
@@ -4621,19 +4683,8 @@ async function bundleWorkflowJobs(allJobs, mainJobNames, env = {}, triggerContex
|
|
|
4621
4683
|
const { usedJobs, mainJobDeps } = await filterUsedJobs(allJobs, mainJobNames, triggerContext);
|
|
4622
4684
|
logger.newline();
|
|
4623
4685
|
logger.log(`Bundling ${styles.highlight(usedJobs.length.toString())} files for ${styles.info("\"workflow-job\"")}`);
|
|
4624
|
-
const
|
|
4625
|
-
|
|
4626
|
-
const currentJobNames = new Set(usedJobs.map((j) => j.name));
|
|
4627
|
-
const existingFiles = fs$1.readdirSync(outputDir);
|
|
4628
|
-
for (const file of existingFiles) if (file.endsWith(".js") && !currentJobNames.has(path.basename(file, ".js"))) fs$1.rmSync(path.join(outputDir, file), { force: true });
|
|
4629
|
-
else if (file.endsWith(".js.map") && !currentJobNames.has(path.basename(file, ".js.map"))) fs$1.rmSync(path.join(outputDir, file), { force: true });
|
|
4630
|
-
let tsconfig;
|
|
4631
|
-
try {
|
|
4632
|
-
tsconfig = await resolveTSConfig();
|
|
4633
|
-
} catch {
|
|
4634
|
-
tsconfig = void 0;
|
|
4635
|
-
}
|
|
4636
|
-
const results = await withBundleConcurrency(usedJobs, (job) => bundleSingleJob(job, usedJobs, outputDir, tsconfig, env, triggerContext, cache, inlineSourcemap, bundleLogLevel));
|
|
4686
|
+
const tsconfig = await resolveTSConfigWithFallback(baseDir);
|
|
4687
|
+
const results = await withBundleConcurrency(usedJobs, (job) => bundleSingleJob(job, usedJobs, tsconfig, env, triggerContext, cache, inlineSourcemap, bundleLogLevel));
|
|
4637
4688
|
const bundledCode = /* @__PURE__ */ new Map();
|
|
4638
4689
|
for (const [name, code] of results) bundledCode.set(name, code);
|
|
4639
4690
|
logger.log(`${styles.success("Bundled")} ${styles.info("\"workflow-job\"")}`);
|
|
@@ -4669,7 +4720,7 @@ async function filterUsedJobs(allJobs, mainJobNames, triggerContext) {
|
|
|
4669
4720
|
const dependencies = /* @__PURE__ */ new Map();
|
|
4670
4721
|
const fileResults = await Promise.all(Array.from(jobsBySourceFile.entries()).map(async ([sourceFile, jobs]) => {
|
|
4671
4722
|
try {
|
|
4672
|
-
const source = await fs
|
|
4723
|
+
const source = await fs.promises.readFile(sourceFile, "utf-8");
|
|
4673
4724
|
const { program } = parseSync("input.ts", source);
|
|
4674
4725
|
const detectedJobs = findAllJobs(program, source);
|
|
4675
4726
|
const triggerCalls = detectResolvedTriggerCalls(program, source, triggerContext, sourceFile);
|
|
@@ -4709,7 +4760,7 @@ async function filterUsedJobs(allJobs, mainJobNames, triggerContext) {
|
|
|
4709
4760
|
mainJobDeps
|
|
4710
4761
|
};
|
|
4711
4762
|
}
|
|
4712
|
-
async function bundleSingleJob(job, allJobs,
|
|
4763
|
+
async function bundleSingleJob(job, allJobs, tsconfig, env, triggerContext, cache, inlineSourcemap, bundleLogLevel = "DEBUG") {
|
|
4713
4764
|
const serializedTriggerContext = serializeTriggerContext(triggerContext);
|
|
4714
4765
|
const sortedEnvPrefix = JSON.stringify(Object.fromEntries(Object.entries(env).toSorted(([a], [b]) => a.localeCompare(b))));
|
|
4715
4766
|
const contextHash = computeBundlerContextHash({
|
|
@@ -4727,7 +4778,6 @@ async function bundleSingleJob(job, allJobs, outputDir, tsconfig, env, triggerCo
|
|
|
4727
4778
|
sourceFile: job.sourceFile,
|
|
4728
4779
|
contextHash,
|
|
4729
4780
|
async build(cachePlugins) {
|
|
4730
|
-
const entryPath = path.join(outputDir, `${job.name}.entry.js`);
|
|
4731
4781
|
const absoluteSourcePath = path.resolve(job.sourceFile);
|
|
4732
4782
|
const entryContent = multiline`
|
|
4733
4783
|
import { ${job.exportName} } from "${absoluteSourcePath}";
|
|
@@ -4738,10 +4788,11 @@ async function bundleSingleJob(job, allJobs, outputDir, tsconfig, env, triggerCo
|
|
|
4738
4788
|
return await ${job.exportName}.body(input, { env, invoker });
|
|
4739
4789
|
}
|
|
4740
4790
|
`;
|
|
4741
|
-
|
|
4791
|
+
const entry = createVirtualEntry(`workflow-job:${job.name}`, entryContent);
|
|
4742
4792
|
const resolvedSourceFile = safeRealpath(job.sourceFile);
|
|
4743
4793
|
const otherJobExportNames = allJobs.filter((candidate) => candidate.name !== job.name && safeRealpath(candidate.sourceFile) === resolvedSourceFile).map((j) => j.exportName);
|
|
4744
4794
|
const plugins = [
|
|
4795
|
+
entry.plugin,
|
|
4745
4796
|
{
|
|
4746
4797
|
name: "workflow-transform",
|
|
4747
4798
|
transform: {
|
|
@@ -4760,7 +4811,7 @@ async function bundleSingleJob(job, allJobs, outputDir, tsconfig, env, triggerCo
|
|
|
4760
4811
|
...cachePlugins
|
|
4761
4812
|
];
|
|
4762
4813
|
return (await rolldown.build({
|
|
4763
|
-
input:
|
|
4814
|
+
input: entry.input,
|
|
4764
4815
|
write: false,
|
|
4765
4816
|
output: {
|
|
4766
4817
|
format: "esm",
|
|
@@ -4819,7 +4870,7 @@ const RetryPolicySchema = z.object({
|
|
|
4819
4870
|
});
|
|
4820
4871
|
const ConcurrencyPolicySchema = z.object({ maxConcurrentExecutions: z.number().int().min(1).max(1e3).describe("Maximum number of concurrent executions (1-1000)") });
|
|
4821
4872
|
const ExecutionPolicyNameSchema = z.string().regex(/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/, "Invalid execution policy name: must match [a-z0-9-] (3-63 chars; must start and end with [a-z0-9])").describe("Workspace-unique execution policy name embedded in the resource TRN");
|
|
4822
|
-
const ExecutionPolicyKeySchema = z.string().regex(/^[a-z0-9][a-z0-9_:.-]{0,62}[a-z0-9*]$/, "Invalid execution policy key: must match [a-z0-9_:.-] (2-64 chars; must start with [a-z0-9] and end with [a-z0-9] or a trailing '*')").describe("Execution policy key passed to triggerJobFunction's executionPolicyKey option");
|
|
4873
|
+
const ExecutionPolicyKeySchema = z.string().regex(/^[a-z0-9][a-z0-9_:.-]{0,62}[a-z0-9*]$/, "Invalid execution policy key: must match [a-z0-9_:.-] (2-64 chars; must start with [a-z0-9] and end with [a-z0-9] or a trailing '*')").describe("Execution policy key passed to startJobFunction's (or its frozen alias triggerJobFunction's) executionPolicyKey option");
|
|
4823
4874
|
const WorkflowJobFunctionExecutionPolicySchema = z.object({
|
|
4824
4875
|
name: ExecutionPolicyNameSchema,
|
|
4825
4876
|
key: ExecutionPolicyKeySchema,
|
|
@@ -4840,7 +4891,7 @@ const WorkflowSchema = z.object({
|
|
|
4840
4891
|
* @returns A new WorkflowService instance
|
|
4841
4892
|
*/
|
|
4842
4893
|
function createWorkflowService(params) {
|
|
4843
|
-
const { config } = params;
|
|
4894
|
+
const { config, baseDir } = params;
|
|
4844
4895
|
let workflows = {};
|
|
4845
4896
|
let workflowSources = [];
|
|
4846
4897
|
let jobs = [];
|
|
@@ -4862,7 +4913,7 @@ function createWorkflowService(params) {
|
|
|
4862
4913
|
},
|
|
4863
4914
|
loadWorkflows: async () => {
|
|
4864
4915
|
if (loaded) return;
|
|
4865
|
-
const result = await loadAndCollectJobs(config);
|
|
4916
|
+
const result = await loadAndCollectJobs(config, baseDir);
|
|
4866
4917
|
workflows = result.workflows;
|
|
4867
4918
|
workflowSources = result.workflowSources;
|
|
4868
4919
|
jobs = result.jobs;
|
|
@@ -4884,9 +4935,10 @@ function createWorkflowService(params) {
|
|
|
4884
4935
|
* Load workflow files and collect all jobs in a single pass.
|
|
4885
4936
|
* Dependencies are detected at bundle time via AST analysis.
|
|
4886
4937
|
* @param config - Workflow service configuration
|
|
4938
|
+
* @param baseDir - Directory the config's file patterns are resolved against
|
|
4887
4939
|
* @returns Loaded workflows and collected jobs
|
|
4888
4940
|
*/
|
|
4889
|
-
async function loadAndCollectJobs(config) {
|
|
4941
|
+
async function loadAndCollectJobs(config, baseDir) {
|
|
4890
4942
|
const workflows = {};
|
|
4891
4943
|
const workflowSources = [];
|
|
4892
4944
|
const collectedJobs = [];
|
|
@@ -4896,7 +4948,7 @@ async function loadAndCollectJobs(config) {
|
|
|
4896
4948
|
jobs: collectedJobs,
|
|
4897
4949
|
fileCount: 0
|
|
4898
4950
|
};
|
|
4899
|
-
const workflowFiles = loadFilesWithIgnores(config);
|
|
4951
|
+
const workflowFiles = loadFilesWithIgnores(config, baseDir);
|
|
4900
4952
|
const fileCount = workflowFiles.length;
|
|
4901
4953
|
const allJobsMap = /* @__PURE__ */ new Map();
|
|
4902
4954
|
const loadResults = await Promise.all(workflowFiles.map(async (workflowFile) => {
|
|
@@ -5198,7 +5250,7 @@ const StaticWebsiteSchema = z.object({
|
|
|
5198
5250
|
|
|
5199
5251
|
//#endregion
|
|
5200
5252
|
//#region src/cli/services/application.ts
|
|
5201
|
-
function defineTailorDB(config, pluginManager) {
|
|
5253
|
+
function defineTailorDB(config, baseDir, pluginManager) {
|
|
5202
5254
|
const tailorDBServices = [];
|
|
5203
5255
|
const externalTailorDBNamespaces = [];
|
|
5204
5256
|
const subgraphs = [];
|
|
@@ -5213,7 +5265,8 @@ function defineTailorDB(config, pluginManager) {
|
|
|
5213
5265
|
const tailorDB = createTailorDBService({
|
|
5214
5266
|
namespace,
|
|
5215
5267
|
config: TailorDBServiceConfigSchema.parse(serviceConfig),
|
|
5216
|
-
pluginManager
|
|
5268
|
+
pluginManager,
|
|
5269
|
+
baseDir
|
|
5217
5270
|
});
|
|
5218
5271
|
tailorDBServices.push(tailorDB);
|
|
5219
5272
|
}
|
|
@@ -5228,7 +5281,7 @@ function defineTailorDB(config, pluginManager) {
|
|
|
5228
5281
|
subgraphs
|
|
5229
5282
|
};
|
|
5230
5283
|
}
|
|
5231
|
-
function defineResolver(config) {
|
|
5284
|
+
function defineResolver(config, baseDir) {
|
|
5232
5285
|
const resolverServices = [];
|
|
5233
5286
|
const subgraphs = [];
|
|
5234
5287
|
if (!config) return {
|
|
@@ -5237,7 +5290,7 @@ function defineResolver(config) {
|
|
|
5237
5290
|
};
|
|
5238
5291
|
for (const [namespace, serviceConfig] of Object.entries(config)) {
|
|
5239
5292
|
if (!("external" in serviceConfig)) {
|
|
5240
|
-
const resolverService = createResolverService(namespace, serviceConfig);
|
|
5293
|
+
const resolverService = createResolverService(namespace, serviceConfig, baseDir);
|
|
5241
5294
|
resolverServices.push(resolverService);
|
|
5242
5295
|
}
|
|
5243
5296
|
subgraphs.push({
|
|
@@ -5293,17 +5346,26 @@ function defineAuth(config, tailorDBServices, externalTailorDBNamespaces) {
|
|
|
5293
5346
|
subgraphs
|
|
5294
5347
|
};
|
|
5295
5348
|
}
|
|
5296
|
-
function defineExecutor(config, hasPluginExecutors) {
|
|
5349
|
+
function defineExecutor(config, baseDir, hasPluginExecutors) {
|
|
5297
5350
|
if (!config && !hasPluginExecutors) return;
|
|
5298
|
-
return createExecutorService({
|
|
5351
|
+
return createExecutorService({
|
|
5352
|
+
config: config ?? { files: [] },
|
|
5353
|
+
baseDir
|
|
5354
|
+
});
|
|
5299
5355
|
}
|
|
5300
|
-
function defineWorkflow(config) {
|
|
5356
|
+
function defineWorkflow(config, baseDir) {
|
|
5301
5357
|
if (!config) return;
|
|
5302
|
-
return createWorkflowService({
|
|
5358
|
+
return createWorkflowService({
|
|
5359
|
+
config,
|
|
5360
|
+
baseDir
|
|
5361
|
+
});
|
|
5303
5362
|
}
|
|
5304
|
-
function defineHttpAdapterService(config) {
|
|
5363
|
+
function defineHttpAdapterService(config, baseDir) {
|
|
5305
5364
|
if (!config) return;
|
|
5306
|
-
return createHttpAdapterService({
|
|
5365
|
+
return createHttpAdapterService({
|
|
5366
|
+
config,
|
|
5367
|
+
baseDir
|
|
5368
|
+
});
|
|
5307
5369
|
}
|
|
5308
5370
|
function defineStaticWebsites(websites) {
|
|
5309
5371
|
const staticWebsiteServices = [];
|
|
@@ -5349,9 +5411,9 @@ function parseSecretManager(config) {
|
|
|
5349
5411
|
ignoreNullishValues
|
|
5350
5412
|
};
|
|
5351
5413
|
}
|
|
5352
|
-
function defineServices(config, pluginManager) {
|
|
5353
|
-
const tailordbResult = defineTailorDB(config.db, pluginManager);
|
|
5354
|
-
const resolverResult = defineResolver(config.resolver);
|
|
5414
|
+
function defineServices(config, baseDir, pluginManager) {
|
|
5415
|
+
const tailordbResult = defineTailorDB(config.db, baseDir, pluginManager);
|
|
5416
|
+
const resolverResult = defineResolver(config.resolver, baseDir);
|
|
5355
5417
|
const idpResult = defineIdp(config.idp);
|
|
5356
5418
|
const authResult = defineAuth(config.auth, tailordbResult.tailorDBServices, tailordbResult.externalTailorDBNamespaces);
|
|
5357
5419
|
const staticWebsiteServices = defineStaticWebsites(config.staticWebsites);
|
|
@@ -5407,10 +5469,11 @@ function buildApplication(params) {
|
|
|
5407
5469
|
*/
|
|
5408
5470
|
function defineApplication(params) {
|
|
5409
5471
|
const { config, pluginManager } = params;
|
|
5410
|
-
const
|
|
5411
|
-
const
|
|
5412
|
-
const
|
|
5413
|
-
const
|
|
5472
|
+
const baseDir = path.dirname(config.path);
|
|
5473
|
+
const services = defineServices(config, baseDir, pluginManager);
|
|
5474
|
+
const executorService = defineExecutor(config.executor, baseDir, false);
|
|
5475
|
+
const workflowService = defineWorkflow(config.workflow, baseDir);
|
|
5476
|
+
const httpAdapterService = defineHttpAdapterService(config.httpAdapter, baseDir);
|
|
5414
5477
|
return buildApplication({
|
|
5415
5478
|
config,
|
|
5416
5479
|
...services,
|
|
@@ -5455,19 +5518,20 @@ function generatePluginFilesIfNeeded(pluginManager, tailorDBServices, configPath
|
|
|
5455
5518
|
*/
|
|
5456
5519
|
async function loadApplication(params) {
|
|
5457
5520
|
const { config, pluginManager, bundleCache } = params;
|
|
5458
|
-
const
|
|
5521
|
+
const baseDir = path.dirname(config.path);
|
|
5522
|
+
const { tailordbResult, resolverResult, idpResult, authResult, staticWebsiteServices, aiGatewayServices, secrets, ignoreNullishValues } = defineServices(config, baseDir, pluginManager);
|
|
5459
5523
|
for (const tailordb of tailordbResult.tailorDBServices) {
|
|
5460
5524
|
await tailordb.loadTypes();
|
|
5461
5525
|
await tailordb.processNamespacePlugins();
|
|
5462
5526
|
}
|
|
5463
5527
|
assertUniqueLocalTailorDBTypeNames({ tailorDBServices: tailordbResult.tailorDBServices });
|
|
5464
5528
|
const pluginExecutorFiles = generatePluginFilesIfNeeded(pluginManager, tailordbResult.tailorDBServices, config.path);
|
|
5465
|
-
const executorService = defineExecutor(config.executor, pluginExecutorFiles.length > 0);
|
|
5466
|
-
const workflowService = defineWorkflow(config.workflow);
|
|
5529
|
+
const executorService = defineExecutor(config.executor, baseDir, pluginExecutorFiles.length > 0);
|
|
5530
|
+
const workflowService = defineWorkflow(config.workflow, baseDir);
|
|
5467
5531
|
if (workflowService) await workflowService.loadWorkflows();
|
|
5468
|
-
const httpAdapterService = defineHttpAdapterService(config.httpAdapter);
|
|
5532
|
+
const httpAdapterService = defineHttpAdapterService(config.httpAdapter, baseDir);
|
|
5469
5533
|
if (httpAdapterService) await httpAdapterService.loadAdapters();
|
|
5470
|
-
const triggerContext = await buildTriggerContext(config.workflow, authResult.authService?.config.name);
|
|
5534
|
+
const triggerContext = await buildTriggerContext(config.workflow, authResult.authService?.config.name, baseDir);
|
|
5471
5535
|
const inlineSourcemap = resolveInlineSourcemap(config.inlineSourcemap);
|
|
5472
5536
|
const bundleLogLevel = resolveBundleLogLevel(config.logLevel);
|
|
5473
5537
|
const bundledScripts = {
|
|
@@ -5477,7 +5541,7 @@ async function loadApplication(params) {
|
|
|
5477
5541
|
authHooks: /* @__PURE__ */ new Map()
|
|
5478
5542
|
};
|
|
5479
5543
|
for (const pipeline of resolverResult.resolverServices) {
|
|
5480
|
-
const resolverBundles = await bundleResolvers(pipeline.namespace, pipeline.config, triggerContext, bundleCache, inlineSourcemap, bundleLogLevel);
|
|
5544
|
+
const resolverBundles = await bundleResolvers(pipeline.namespace, pipeline.config, baseDir, triggerContext, bundleCache, inlineSourcemap, bundleLogLevel);
|
|
5481
5545
|
for (const [name, code] of resolverBundles) bundledScripts.resolvers.set(resolverBundleKey(pipeline.namespace, name), code);
|
|
5482
5546
|
}
|
|
5483
5547
|
if (executorService) bundledScripts.executors = await bundleExecutors({
|
|
@@ -5486,12 +5550,13 @@ async function loadApplication(params) {
|
|
|
5486
5550
|
additionalFiles: [...pluginExecutorFiles],
|
|
5487
5551
|
cache: bundleCache,
|
|
5488
5552
|
inlineSourcemap,
|
|
5489
|
-
bundleLogLevel
|
|
5553
|
+
bundleLogLevel,
|
|
5554
|
+
baseDir
|
|
5490
5555
|
});
|
|
5491
5556
|
let workflowBuildResult;
|
|
5492
5557
|
if (workflowService && workflowService.jobs.length > 0) {
|
|
5493
5558
|
const mainJobNames = workflowService.workflowSources.map((ws) => ws.workflow.mainJob.name);
|
|
5494
|
-
workflowBuildResult = await bundleWorkflowJobs(workflowService.jobs, mainJobNames, config.env ?? {}, triggerContext, bundleCache, inlineSourcemap, bundleLogLevel);
|
|
5559
|
+
workflowBuildResult = await bundleWorkflowJobs(workflowService.jobs, mainJobNames, config.env ?? {}, triggerContext, baseDir, bundleCache, inlineSourcemap, bundleLogLevel);
|
|
5495
5560
|
bundledScripts.workflowJobs = workflowBuildResult.bundledCode;
|
|
5496
5561
|
}
|
|
5497
5562
|
let httpAdapterBuildResult;
|
|
@@ -5500,7 +5565,7 @@ async function loadApplication(params) {
|
|
|
5500
5565
|
sourceFile: a.sourceFile,
|
|
5501
5566
|
methods: a.methods,
|
|
5502
5567
|
hasOutput: a.hasOutput
|
|
5503
|
-
})), bundleCache, bundleLogLevel);
|
|
5568
|
+
})), baseDir, bundleCache, bundleLogLevel);
|
|
5504
5569
|
if (authResult.authService?.config.hooks?.beforeLogin) {
|
|
5505
5570
|
const authName = authResult.authService.config.name;
|
|
5506
5571
|
bundledScripts.authHooks = await bundleAuthHooks({
|
|
@@ -5511,7 +5576,8 @@ async function loadApplication(params) {
|
|
|
5511
5576
|
triggerContext,
|
|
5512
5577
|
cache: bundleCache,
|
|
5513
5578
|
inlineSourcemap,
|
|
5514
|
-
bundleLogLevel
|
|
5579
|
+
bundleLogLevel,
|
|
5580
|
+
baseDir
|
|
5515
5581
|
});
|
|
5516
5582
|
}
|
|
5517
5583
|
for (const pipeline of resolverResult.resolverServices) await pipeline.loadResolvers();
|
|
@@ -5545,5 +5611,5 @@ async function loadApplication(params) {
|
|
|
5545
5611
|
}
|
|
5546
5612
|
|
|
5547
5613
|
//#endregion
|
|
5548
|
-
export {
|
|
5549
|
-
//# sourceMappingURL=application-
|
|
5614
|
+
export { fetchAll as A, initOAuth2Client as B, hasGenerationHooks as C, hashFile as D, hashContent as E, fetchUserInfo as F, resolveStaticWebsiteUrls as G, isDefaultPlatform as H, getConsoleBaseUrl as I, LOG_LEVELS as J, byName as K, getOAuth2ClientId as L, fetchMachineUserToken as M, fetchPaged as N, closeConnectionPool as O, fetchPlatformMachineUserToken as P, getOrNull as R, getPluginGenerationDependencies as S, getDistDir as T, normalizeBaseUrl as U, initOperatorClient as V, rememberPlatformConfigForToken as W, resolveTSConfigWithFallback as _, resolveInlineSourcemap as a, createLogLevelTreeshakeOptions as b, ResolverSchema as c, buildExecutorArgsExpr as d, buildResolverOperationHookExpr as f, stringifyFunction as g, TailorDBTypeSchema as h, resolverBundleKey as i, fetchAllTolerant as j, defaultPlatformBaseUrl as k, HTTP_METHODS as l, assertUniqueTailorDBTypeNamesWithExternal as m, generatePluginFilesIfNeeded as n, WorkflowJobFunctionExecutionPolicySchema as o, assertUniqueLocalTailorDBTypeNames as p, createApplyLimiter as q, loadApplication as r, WorkflowJobSchema as s, defineApplication as t, INVOKER_EXPR as u, platformBundleDefinePlugin as v, createBundleCache as w, resolveBundleLogLevel as x, composeFunctionTreeshakeOptions as y, getPlatformBaseUrl as z };
|
|
5615
|
+
//# sourceMappingURL=application-C1d52JP9.mjs.map
|