skedyul 1.4.11 → 1.5.2

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.
@@ -12,7 +12,6 @@ export * from './types';
12
12
  export type { InstallConfig, ProvisionConfig, BuildConfig, CorsOptions, SkedyulConfig, SerializableSkedyulConfig, QueueScope, QueueConfig, SerializableQueueConfig, QueueRegistry, } from './app-config';
13
13
  export { defineConfig } from './app-config';
14
14
  export { defineModel, defineChannel, definePage, defineWorkflow, defineAgent, defineEnv, defineNavigation, } from './define';
15
- export { CONFIG_FILE_NAMES, loadConfig, validateConfig } from './loader';
16
15
  export { SCHEMA_FILE_EXTENSIONS, loadSchema, saveSchema, serializeSchemaToJson, serializeSchemaToTypeScript, transformToBackendSchema, transformFromBackendSchema, type LoadSchemaOptions, type LoadSchemaResult, type SerializeSchemaOptions, type BackendModelDefinition, type BackendFieldDefinition, type BackendRelationshipDefinition, type BackendDesiredSchema, } from './schema-loader';
17
16
  export { loadAndResolveConfig, serializeResolvedConfig, type ResolvedConfig } from './resolver';
18
17
  export { getAllEnvKeys, getRequiredInstallEnvKeys } from './utils';
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // src/config/transpileConfigMetadata.ts
34
+ var transpileConfigMetadata_exports = {};
35
+ __export(transpileConfigMetadata_exports, {
36
+ transpileConfigMetadata: () => transpileConfigMetadata
37
+ });
38
+ function prepareConfigSource(content) {
39
+ return content.replace(/import\s*\(\s*(['"])([^'"]+)\1\s*\)/g, "Promise.resolve(null)");
40
+ }
41
+ function isJsonImport(importPath) {
42
+ return importPath.endsWith(".json");
43
+ }
44
+ async function transpileConfigMetadata(configPath) {
45
+ const esbuild = await import("esbuild");
46
+ const absolutePath = path.resolve(configPath);
47
+ const configDir = path.dirname(absolutePath);
48
+ const configBasename = path.basename(absolutePath);
49
+ const result = await esbuild.build({
50
+ absWorkingDir: configDir,
51
+ entryPoints: [absolutePath],
52
+ bundle: true,
53
+ format: "cjs",
54
+ platform: "node",
55
+ target: "node22",
56
+ write: false,
57
+ logLevel: "silent",
58
+ plugins: [
59
+ {
60
+ name: "prepare-config-entry",
61
+ setup(build) {
62
+ build.onLoad({ filter: new RegExp(`/${configBasename.replace(".", "\\.")}$`) }, () => ({
63
+ contents: prepareConfigSource(fs.readFileSync(absolutePath, "utf-8")),
64
+ loader: "ts"
65
+ }));
66
+ }
67
+ },
68
+ {
69
+ name: "skedyul-shim",
70
+ setup(build) {
71
+ build.onResolve({ filter: /^skedyul$/ }, () => ({
72
+ path: "skedyul-shim",
73
+ namespace: SKEDYUL_SHIM_NAMESPACE
74
+ }));
75
+ build.onLoad({ filter: /.*/, namespace: SKEDYUL_SHIM_NAMESPACE }, () => ({
76
+ contents: [
77
+ "function defineConfig(config) { return config; }",
78
+ "module.exports = { defineConfig };"
79
+ ].join("\n"),
80
+ loader: "js"
81
+ }));
82
+ }
83
+ },
84
+ {
85
+ name: "metadata-stub-imports",
86
+ setup(build) {
87
+ build.onResolve({ filter: /^\.{1,2}\// }, (args) => {
88
+ if (isJsonImport(args.path)) {
89
+ return void 0;
90
+ }
91
+ return {
92
+ path: args.path,
93
+ namespace: METADATA_STUB_NAMESPACE
94
+ };
95
+ });
96
+ build.onLoad({ filter: /.*/, namespace: METADATA_STUB_NAMESPACE }, () => ({
97
+ contents: "module.exports = {};\n",
98
+ loader: "js"
99
+ }));
100
+ }
101
+ }
102
+ ]
103
+ });
104
+ if (result.errors.length > 0) {
105
+ throw new Error(result.errors.map((error) => error.text).join("\n"));
106
+ }
107
+ if (result.outputFiles.length === 0) {
108
+ throw new Error("Config transpile produced no output");
109
+ }
110
+ return result.outputFiles[0].text;
111
+ }
112
+ var fs, path, SKEDYUL_SHIM_NAMESPACE, METADATA_STUB_NAMESPACE;
113
+ var init_transpileConfigMetadata = __esm({
114
+ "src/config/transpileConfigMetadata.ts"() {
115
+ "use strict";
116
+ fs = __toESM(require("fs"));
117
+ path = __toESM(require("path"));
118
+ SKEDYUL_SHIM_NAMESPACE = "skedyul-shim";
119
+ METADATA_STUB_NAMESPACE = "metadata-stub";
120
+ }
121
+ });
122
+
123
+ // src/config/loader.ts
124
+ var loader_exports = {};
125
+ __export(loader_exports, {
126
+ CONFIG_FILE_NAMES: () => CONFIG_FILE_NAMES,
127
+ loadConfig: () => loadConfig,
128
+ validateConfig: () => validateConfig
129
+ });
130
+ module.exports = __toCommonJS(loader_exports);
131
+ var fs2 = __toESM(require("fs"));
132
+ var path2 = __toESM(require("path"));
133
+ var os = __toESM(require("os"));
134
+ var CONFIG_FILE_NAMES = [
135
+ "skedyul.config.ts",
136
+ "skedyul.config.js",
137
+ "skedyul.config.mjs",
138
+ "skedyul.config.cjs"
139
+ ];
140
+ async function loadConfig(configPath) {
141
+ const absolutePath = path2.resolve(configPath);
142
+ if (!fs2.existsSync(absolutePath)) {
143
+ throw new Error(`Config file not found: ${absolutePath}`);
144
+ }
145
+ const isTypeScript = absolutePath.endsWith(".ts");
146
+ try {
147
+ if (isTypeScript) {
148
+ try {
149
+ const { transpileConfigMetadata: transpileConfigMetadata2 } = await Promise.resolve().then(() => (init_transpileConfigMetadata(), transpileConfigMetadata_exports));
150
+ const transpiled = await transpileConfigMetadata2(absolutePath);
151
+ const tempFile = path2.join(os.tmpdir(), `skedyul-config-${Date.now()}.cjs`);
152
+ fs2.writeFileSync(tempFile, transpiled);
153
+ try {
154
+ const module3 = require(tempFile);
155
+ const config2 = module3.default || module3;
156
+ if (!config2 || typeof config2 !== "object") {
157
+ throw new Error("Config file must export a configuration object");
158
+ }
159
+ if (!config2.name || typeof config2.name !== "string") {
160
+ throw new Error('Config must have a "name" property');
161
+ }
162
+ return config2;
163
+ } finally {
164
+ try {
165
+ fs2.unlinkSync(tempFile);
166
+ } catch {
167
+ }
168
+ }
169
+ } catch (transpileError) {
170
+ throw new Error(
171
+ `Cannot load TypeScript config metadata from ${absolutePath}: ${transpileError instanceof Error ? transpileError.message : String(transpileError)}`
172
+ );
173
+ }
174
+ }
175
+ const module2 = await import(
176
+ /* webpackIgnore: true */
177
+ absolutePath
178
+ );
179
+ const config = module2.default || module2;
180
+ if (!config || typeof config !== "object") {
181
+ throw new Error("Config file must export a configuration object");
182
+ }
183
+ if (!config.name || typeof config.name !== "string") {
184
+ throw new Error('Config must have a "name" property');
185
+ }
186
+ return config;
187
+ } catch (error) {
188
+ throw new Error(
189
+ `Failed to load config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`
190
+ );
191
+ }
192
+ }
193
+ function validateConfig(config) {
194
+ const errors = [];
195
+ if (!config.name) {
196
+ errors.push("Missing required field: name");
197
+ }
198
+ if (config.computeLayer && !["serverless", "dedicated"].includes(config.computeLayer)) {
199
+ errors.push(`Invalid computeLayer: ${config.computeLayer}. Must be 'serverless' or 'dedicated'`);
200
+ }
201
+ return { valid: errors.length === 0, errors };
202
+ }
203
+ // Annotate the CommonJS export names for ESM import in node:
204
+ 0 && (module.exports = {
205
+ CONFIG_FILE_NAMES,
206
+ loadConfig,
207
+ validateConfig
208
+ });
@@ -0,0 +1,184 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
4
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
5
+ }) : x)(function(x) {
6
+ if (typeof require !== "undefined") return require.apply(this, arguments);
7
+ throw Error('Dynamic require of "' + x + '" is not supported');
8
+ });
9
+ var __esm = (fn, res) => function __init() {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ };
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
16
+
17
+ // src/config/transpileConfigMetadata.ts
18
+ var transpileConfigMetadata_exports = {};
19
+ __export(transpileConfigMetadata_exports, {
20
+ transpileConfigMetadata: () => transpileConfigMetadata
21
+ });
22
+ import * as fs from "fs";
23
+ import * as path from "path";
24
+ function prepareConfigSource(content) {
25
+ return content.replace(/import\s*\(\s*(['"])([^'"]+)\1\s*\)/g, "Promise.resolve(null)");
26
+ }
27
+ function isJsonImport(importPath) {
28
+ return importPath.endsWith(".json");
29
+ }
30
+ async function transpileConfigMetadata(configPath) {
31
+ const esbuild = await import("esbuild");
32
+ const absolutePath = path.resolve(configPath);
33
+ const configDir = path.dirname(absolutePath);
34
+ const configBasename = path.basename(absolutePath);
35
+ const result = await esbuild.build({
36
+ absWorkingDir: configDir,
37
+ entryPoints: [absolutePath],
38
+ bundle: true,
39
+ format: "cjs",
40
+ platform: "node",
41
+ target: "node22",
42
+ write: false,
43
+ logLevel: "silent",
44
+ plugins: [
45
+ {
46
+ name: "prepare-config-entry",
47
+ setup(build) {
48
+ build.onLoad({ filter: new RegExp(`/${configBasename.replace(".", "\\.")}$`) }, () => ({
49
+ contents: prepareConfigSource(fs.readFileSync(absolutePath, "utf-8")),
50
+ loader: "ts"
51
+ }));
52
+ }
53
+ },
54
+ {
55
+ name: "skedyul-shim",
56
+ setup(build) {
57
+ build.onResolve({ filter: /^skedyul$/ }, () => ({
58
+ path: "skedyul-shim",
59
+ namespace: SKEDYUL_SHIM_NAMESPACE
60
+ }));
61
+ build.onLoad({ filter: /.*/, namespace: SKEDYUL_SHIM_NAMESPACE }, () => ({
62
+ contents: [
63
+ "function defineConfig(config) { return config; }",
64
+ "module.exports = { defineConfig };"
65
+ ].join("\n"),
66
+ loader: "js"
67
+ }));
68
+ }
69
+ },
70
+ {
71
+ name: "metadata-stub-imports",
72
+ setup(build) {
73
+ build.onResolve({ filter: /^\.{1,2}\// }, (args) => {
74
+ if (isJsonImport(args.path)) {
75
+ return void 0;
76
+ }
77
+ return {
78
+ path: args.path,
79
+ namespace: METADATA_STUB_NAMESPACE
80
+ };
81
+ });
82
+ build.onLoad({ filter: /.*/, namespace: METADATA_STUB_NAMESPACE }, () => ({
83
+ contents: "module.exports = {};\n",
84
+ loader: "js"
85
+ }));
86
+ }
87
+ }
88
+ ]
89
+ });
90
+ if (result.errors.length > 0) {
91
+ throw new Error(result.errors.map((error) => error.text).join("\n"));
92
+ }
93
+ if (result.outputFiles.length === 0) {
94
+ throw new Error("Config transpile produced no output");
95
+ }
96
+ return result.outputFiles[0].text;
97
+ }
98
+ var SKEDYUL_SHIM_NAMESPACE, METADATA_STUB_NAMESPACE;
99
+ var init_transpileConfigMetadata = __esm({
100
+ "src/config/transpileConfigMetadata.ts"() {
101
+ "use strict";
102
+ SKEDYUL_SHIM_NAMESPACE = "skedyul-shim";
103
+ METADATA_STUB_NAMESPACE = "metadata-stub";
104
+ }
105
+ });
106
+
107
+ // src/config/loader.ts
108
+ import * as fs2 from "fs";
109
+ import * as path2 from "path";
110
+ import * as os from "os";
111
+ var CONFIG_FILE_NAMES = [
112
+ "skedyul.config.ts",
113
+ "skedyul.config.js",
114
+ "skedyul.config.mjs",
115
+ "skedyul.config.cjs"
116
+ ];
117
+ async function loadConfig(configPath) {
118
+ const absolutePath = path2.resolve(configPath);
119
+ if (!fs2.existsSync(absolutePath)) {
120
+ throw new Error(`Config file not found: ${absolutePath}`);
121
+ }
122
+ const isTypeScript = absolutePath.endsWith(".ts");
123
+ try {
124
+ if (isTypeScript) {
125
+ try {
126
+ const { transpileConfigMetadata: transpileConfigMetadata2 } = await Promise.resolve().then(() => (init_transpileConfigMetadata(), transpileConfigMetadata_exports));
127
+ const transpiled = await transpileConfigMetadata2(absolutePath);
128
+ const tempFile = path2.join(os.tmpdir(), `skedyul-config-${Date.now()}.cjs`);
129
+ fs2.writeFileSync(tempFile, transpiled);
130
+ try {
131
+ const module2 = __require(tempFile);
132
+ const config2 = module2.default || module2;
133
+ if (!config2 || typeof config2 !== "object") {
134
+ throw new Error("Config file must export a configuration object");
135
+ }
136
+ if (!config2.name || typeof config2.name !== "string") {
137
+ throw new Error('Config must have a "name" property');
138
+ }
139
+ return config2;
140
+ } finally {
141
+ try {
142
+ fs2.unlinkSync(tempFile);
143
+ } catch {
144
+ }
145
+ }
146
+ } catch (transpileError) {
147
+ throw new Error(
148
+ `Cannot load TypeScript config metadata from ${absolutePath}: ${transpileError instanceof Error ? transpileError.message : String(transpileError)}`
149
+ );
150
+ }
151
+ }
152
+ const module = await import(
153
+ /* webpackIgnore: true */
154
+ absolutePath
155
+ );
156
+ const config = module.default || module;
157
+ if (!config || typeof config !== "object") {
158
+ throw new Error("Config file must export a configuration object");
159
+ }
160
+ if (!config.name || typeof config.name !== "string") {
161
+ throw new Error('Config must have a "name" property');
162
+ }
163
+ return config;
164
+ } catch (error) {
165
+ throw new Error(
166
+ `Failed to load config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`
167
+ );
168
+ }
169
+ }
170
+ function validateConfig(config) {
171
+ const errors = [];
172
+ if (!config.name) {
173
+ errors.push("Missing required field: name");
174
+ }
175
+ if (config.computeLayer && !["serverless", "dedicated"].includes(config.computeLayer)) {
176
+ errors.push(`Invalid computeLayer: ${config.computeLayer}. Must be 'serverless' or 'dedicated'`);
177
+ }
178
+ return { valid: errors.length === 0, errors };
179
+ }
180
+ export {
181
+ CONFIG_FILE_NAMES,
182
+ loadConfig,
183
+ validateConfig
184
+ };
@@ -0,0 +1 @@
1
+ export declare function transpileConfigMetadata(configPath: string): Promise<string>;