skedyul 1.5.0 → 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.
package/dist/cli/index.js CHANGED
@@ -364,6 +364,96 @@ var init_link = __esm({
364
364
  }
365
365
  });
366
366
 
367
+ // src/config/transpileConfigMetadata.ts
368
+ var transpileConfigMetadata_exports = {};
369
+ __export(transpileConfigMetadata_exports, {
370
+ transpileConfigMetadata: () => transpileConfigMetadata
371
+ });
372
+ function prepareConfigSource(content) {
373
+ return content.replace(/import\s*\(\s*(['"])([^'"]+)\1\s*\)/g, "Promise.resolve(null)");
374
+ }
375
+ function isJsonImport(importPath) {
376
+ return importPath.endsWith(".json");
377
+ }
378
+ async function transpileConfigMetadata(configPath) {
379
+ const esbuild = await import("esbuild");
380
+ const absolutePath = path12.resolve(configPath);
381
+ const configDir = path12.dirname(absolutePath);
382
+ const configBasename = path12.basename(absolutePath);
383
+ const result = await esbuild.build({
384
+ absWorkingDir: configDir,
385
+ entryPoints: [absolutePath],
386
+ bundle: true,
387
+ format: "cjs",
388
+ platform: "node",
389
+ target: "node22",
390
+ write: false,
391
+ logLevel: "silent",
392
+ plugins: [
393
+ {
394
+ name: "prepare-config-entry",
395
+ setup(build) {
396
+ build.onLoad({ filter: new RegExp(`/${configBasename.replace(".", "\\.")}$`) }, () => ({
397
+ contents: prepareConfigSource(fs12.readFileSync(absolutePath, "utf-8")),
398
+ loader: "ts"
399
+ }));
400
+ }
401
+ },
402
+ {
403
+ name: "skedyul-shim",
404
+ setup(build) {
405
+ build.onResolve({ filter: /^skedyul$/ }, () => ({
406
+ path: "skedyul-shim",
407
+ namespace: SKEDYUL_SHIM_NAMESPACE
408
+ }));
409
+ build.onLoad({ filter: /.*/, namespace: SKEDYUL_SHIM_NAMESPACE }, () => ({
410
+ contents: [
411
+ "function defineConfig(config) { return config; }",
412
+ "module.exports = { defineConfig };"
413
+ ].join("\n"),
414
+ loader: "js"
415
+ }));
416
+ }
417
+ },
418
+ {
419
+ name: "metadata-stub-imports",
420
+ setup(build) {
421
+ build.onResolve({ filter: /^\.{1,2}\// }, (args2) => {
422
+ if (isJsonImport(args2.path)) {
423
+ return void 0;
424
+ }
425
+ return {
426
+ path: args2.path,
427
+ namespace: METADATA_STUB_NAMESPACE
428
+ };
429
+ });
430
+ build.onLoad({ filter: /.*/, namespace: METADATA_STUB_NAMESPACE }, () => ({
431
+ contents: "module.exports = {};\n",
432
+ loader: "js"
433
+ }));
434
+ }
435
+ }
436
+ ]
437
+ });
438
+ if (result.errors.length > 0) {
439
+ throw new Error(result.errors.map((error) => error.text).join("\n"));
440
+ }
441
+ if (result.outputFiles.length === 0) {
442
+ throw new Error("Config transpile produced no output");
443
+ }
444
+ return result.outputFiles[0].text;
445
+ }
446
+ var fs12, path12, SKEDYUL_SHIM_NAMESPACE, METADATA_STUB_NAMESPACE;
447
+ var init_transpileConfigMetadata = __esm({
448
+ "src/config/transpileConfigMetadata.ts"() {
449
+ "use strict";
450
+ fs12 = __toESM(require("fs"));
451
+ path12 = __toESM(require("path"));
452
+ SKEDYUL_SHIM_NAMESPACE = "skedyul-shim";
453
+ METADATA_STUB_NAMESPACE = "metadata-stub";
454
+ }
455
+ });
456
+
367
457
  // src/cli/commands/invoke.ts
368
458
  var z2 = __toESM(require("zod"));
369
459
  var fs5 = __toESM(require("fs"));
@@ -5871,165 +5961,10 @@ var fs14 = __toESM(require("fs"));
5871
5961
  var path14 = __toESM(require("path"));
5872
5962
  init_utils();
5873
5963
 
5874
- // src/config/loader.ts
5875
- var fs11 = __toESM(require("fs"));
5876
- var path11 = __toESM(require("path"));
5877
- var os2 = __toESM(require("os"));
5878
-
5879
- // src/config/transpileConfigMetadata.ts
5880
- var esbuild = __toESM(require("esbuild"));
5964
+ // src/config/schema-loader.ts
5881
5965
  var fs10 = __toESM(require("fs"));
5882
5966
  var path10 = __toESM(require("path"));
5883
- var SKEDYUL_SHIM_NAMESPACE = "skedyul-shim";
5884
- var METADATA_STUB_NAMESPACE = "metadata-stub";
5885
- function prepareConfigSource(content) {
5886
- return content.replace(/import\s*\(\s*(['"])([^'"]+)\1\s*\)/g, "Promise.resolve(null)");
5887
- }
5888
- function isJsonImport(importPath) {
5889
- return importPath.endsWith(".json");
5890
- }
5891
- async function transpileConfigMetadata(configPath) {
5892
- const absolutePath = path10.resolve(configPath);
5893
- const configDir = path10.dirname(absolutePath);
5894
- const configBasename = path10.basename(absolutePath);
5895
- const result = await esbuild.build({
5896
- absWorkingDir: configDir,
5897
- entryPoints: [absolutePath],
5898
- bundle: true,
5899
- format: "cjs",
5900
- platform: "node",
5901
- target: "node22",
5902
- write: false,
5903
- logLevel: "silent",
5904
- plugins: [
5905
- {
5906
- name: "prepare-config-entry",
5907
- setup(build2) {
5908
- build2.onLoad({ filter: new RegExp(`/${configBasename.replace(".", "\\.")}$`) }, () => ({
5909
- contents: prepareConfigSource(fs10.readFileSync(absolutePath, "utf-8")),
5910
- loader: "ts"
5911
- }));
5912
- }
5913
- },
5914
- {
5915
- name: "skedyul-shim",
5916
- setup(build2) {
5917
- build2.onResolve({ filter: /^skedyul$/ }, () => ({
5918
- path: "skedyul-shim",
5919
- namespace: SKEDYUL_SHIM_NAMESPACE
5920
- }));
5921
- build2.onLoad({ filter: /.*/, namespace: SKEDYUL_SHIM_NAMESPACE }, () => ({
5922
- contents: [
5923
- "function defineConfig(config) { return config; }",
5924
- "module.exports = { defineConfig };"
5925
- ].join("\n"),
5926
- loader: "js"
5927
- }));
5928
- }
5929
- },
5930
- {
5931
- name: "metadata-stub-imports",
5932
- setup(build2) {
5933
- build2.onResolve({ filter: /^\.{1,2}\// }, (args2) => {
5934
- if (isJsonImport(args2.path)) {
5935
- return void 0;
5936
- }
5937
- return {
5938
- path: args2.path,
5939
- namespace: METADATA_STUB_NAMESPACE
5940
- };
5941
- });
5942
- build2.onLoad({ filter: /.*/, namespace: METADATA_STUB_NAMESPACE }, () => ({
5943
- contents: "module.exports = {};\n",
5944
- loader: "js"
5945
- }));
5946
- }
5947
- }
5948
- ]
5949
- });
5950
- if (result.errors.length > 0) {
5951
- throw new Error(result.errors.map((error) => error.text).join("\n"));
5952
- }
5953
- if (result.outputFiles.length === 0) {
5954
- throw new Error("Config transpile produced no output");
5955
- }
5956
- return result.outputFiles[0].text;
5957
- }
5958
-
5959
- // src/config/loader.ts
5960
- var CONFIG_FILE_NAMES = [
5961
- "skedyul.config.ts",
5962
- "skedyul.config.js",
5963
- "skedyul.config.mjs",
5964
- "skedyul.config.cjs"
5965
- ];
5966
- async function loadConfig(configPath) {
5967
- const absolutePath = path11.resolve(configPath);
5968
- if (!fs11.existsSync(absolutePath)) {
5969
- throw new Error(`Config file not found: ${absolutePath}`);
5970
- }
5971
- const isTypeScript = absolutePath.endsWith(".ts");
5972
- try {
5973
- if (isTypeScript) {
5974
- try {
5975
- const transpiled = await transpileConfigMetadata(absolutePath);
5976
- const tempFile = path11.join(os2.tmpdir(), `skedyul-config-${Date.now()}.cjs`);
5977
- fs11.writeFileSync(tempFile, transpiled);
5978
- try {
5979
- const module3 = require(tempFile);
5980
- const config2 = module3.default || module3;
5981
- if (!config2 || typeof config2 !== "object") {
5982
- throw new Error("Config file must export a configuration object");
5983
- }
5984
- if (!config2.name || typeof config2.name !== "string") {
5985
- throw new Error('Config must have a "name" property');
5986
- }
5987
- return config2;
5988
- } finally {
5989
- try {
5990
- fs11.unlinkSync(tempFile);
5991
- } catch {
5992
- }
5993
- }
5994
- } catch (transpileError) {
5995
- throw new Error(
5996
- `Cannot load TypeScript config metadata from ${absolutePath}: ${transpileError instanceof Error ? transpileError.message : String(transpileError)}`
5997
- );
5998
- }
5999
- }
6000
- const module2 = await import(
6001
- /* webpackIgnore: true */
6002
- absolutePath
6003
- );
6004
- const config = module2.default || module2;
6005
- if (!config || typeof config !== "object") {
6006
- throw new Error("Config file must export a configuration object");
6007
- }
6008
- if (!config.name || typeof config.name !== "string") {
6009
- throw new Error('Config must have a "name" property');
6010
- }
6011
- return config;
6012
- } catch (error) {
6013
- throw new Error(
6014
- `Failed to load config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`
6015
- );
6016
- }
6017
- }
6018
- function validateConfig(config) {
6019
- const errors = [];
6020
- if (!config.name) {
6021
- errors.push("Missing required field: name");
6022
- }
6023
- if (config.computeLayer && !["serverless", "dedicated"].includes(config.computeLayer)) {
6024
- errors.push(`Invalid computeLayer: ${config.computeLayer}. Must be 'serverless' or 'dedicated'`);
6025
- }
6026
- return { valid: errors.length === 0, errors };
6027
- }
6028
-
6029
- // src/config/schema-loader.ts
6030
- var fs12 = __toESM(require("fs"));
6031
- var path12 = __toESM(require("path"));
6032
- var os3 = __toESM(require("os"));
5967
+ var os2 = __toESM(require("os"));
6033
5968
 
6034
5969
  // src/schemas/crm-schema.ts
6035
5970
  var import_v42 = require("zod/v4");
@@ -6181,39 +6116,39 @@ function validateCRMSchema(data) {
6181
6116
 
6182
6117
  // src/config/schema-loader.ts
6183
6118
  async function transpileSchemaTypeScript(filePath) {
6184
- const content = fs12.readFileSync(filePath, "utf-8");
6119
+ const content = fs10.readFileSync(filePath, "utf-8");
6185
6120
  let transpiled = content.replace(/import\s+type\s+\{[^}]+\}\s+from\s+['"][^'"]+['"]\s*;?\n?/g, "").replace(/import\s+\{\s*defineSchema\s*\}\s+from\s+['"]skedyul['"]\s*;?\n?/g, "").replace(/:\s*CRMSchema/g, "").replace(/export\s+default\s+/, "module.exports = ").replace(/defineSchema\s*\(\s*\{/, "{").replace(/\}\s*\)\s*;?\s*$/, "}");
6186
6121
  return transpiled;
6187
6122
  }
6188
6123
  async function loadSchema(schemaPath, options = {}) {
6189
6124
  const { validate = true } = options;
6190
- const absolutePath = path12.resolve(schemaPath);
6191
- if (!fs12.existsSync(absolutePath)) {
6125
+ const absolutePath = path10.resolve(schemaPath);
6126
+ if (!fs10.existsSync(absolutePath)) {
6192
6127
  throw new Error(`Schema file not found: ${absolutePath}`);
6193
6128
  }
6194
6129
  const isTypeScript = absolutePath.endsWith(".ts");
6195
6130
  const isJson = absolutePath.endsWith(".json");
6196
6131
  if (!isTypeScript && !isJson) {
6197
6132
  throw new Error(
6198
- `Unsupported schema file format: ${path12.extname(absolutePath)}. Use .schema.ts or .schema.json`
6133
+ `Unsupported schema file format: ${path10.extname(absolutePath)}. Use .schema.ts or .schema.json`
6199
6134
  );
6200
6135
  }
6201
6136
  let rawSchema;
6202
6137
  try {
6203
6138
  if (isJson) {
6204
- const content = fs12.readFileSync(absolutePath, "utf-8");
6139
+ const content = fs10.readFileSync(absolutePath, "utf-8");
6205
6140
  rawSchema = JSON.parse(content);
6206
6141
  } else {
6207
6142
  const transpiled = await transpileSchemaTypeScript(absolutePath);
6208
- const tempDir = os3.tmpdir();
6209
- const tempFile = path12.join(tempDir, `skedyul-schema-${Date.now()}.cjs`);
6210
- fs12.writeFileSync(tempFile, transpiled);
6143
+ const tempDir = os2.tmpdir();
6144
+ const tempFile = path10.join(tempDir, `skedyul-schema-${Date.now()}.cjs`);
6145
+ fs10.writeFileSync(tempFile, transpiled);
6211
6146
  try {
6212
6147
  const module2 = require(tempFile);
6213
6148
  rawSchema = module2.default || module2;
6214
6149
  } finally {
6215
6150
  try {
6216
- fs12.unlinkSync(tempFile);
6151
+ fs10.unlinkSync(tempFile);
6217
6152
  } catch {
6218
6153
  }
6219
6154
  }
@@ -6258,10 +6193,10 @@ export default defineSchema(${jsonContent})
6258
6193
  `;
6259
6194
  }
6260
6195
  async function saveSchema(schema, outputPath, options = {}) {
6261
- const absolutePath = path12.resolve(outputPath);
6196
+ const absolutePath = path10.resolve(outputPath);
6262
6197
  const isTypeScript = absolutePath.endsWith(".ts");
6263
6198
  const content = isTypeScript ? serializeSchemaToTypeScript(schema) : serializeSchemaToJson(schema, options);
6264
- fs12.writeFileSync(absolutePath, content, "utf-8");
6199
+ fs10.writeFileSync(absolutePath, content, "utf-8");
6265
6200
  }
6266
6201
  var FIELD_TYPE_MAP = {
6267
6202
  string: "STRING",
@@ -6408,8 +6343,8 @@ function transformToBackendSchema(schema) {
6408
6343
  }
6409
6344
 
6410
6345
  // src/config/resolver.ts
6411
- var fs13 = __toESM(require("fs"));
6412
- var path13 = __toESM(require("path"));
6346
+ var fs11 = __toESM(require("fs"));
6347
+ var path11 = __toESM(require("path"));
6413
6348
  async function loadConfigModule(absolutePath) {
6414
6349
  if (absolutePath.endsWith(".ts")) {
6415
6350
  const altPaths = [
@@ -6418,7 +6353,7 @@ async function loadConfigModule(absolutePath) {
6418
6353
  absolutePath.replace(".ts", ".js")
6419
6354
  ];
6420
6355
  for (const altPath of altPaths) {
6421
- if (fs13.existsSync(altPath)) {
6356
+ if (fs11.existsSync(altPath)) {
6422
6357
  return await import(altPath);
6423
6358
  }
6424
6359
  }
@@ -6435,7 +6370,7 @@ async function loadConfigModule(absolutePath) {
6435
6370
  return await import(absolutePath);
6436
6371
  }
6437
6372
  async function loadAndResolveConfig(configPath) {
6438
- const absolutePath = path13.resolve(configPath);
6373
+ const absolutePath = path11.resolve(configPath);
6439
6374
  const module2 = await loadConfigModule(absolutePath);
6440
6375
  const config = module2.default;
6441
6376
  if (!config || typeof config !== "object") {
@@ -6515,6 +6450,80 @@ function getAllEnvKeys(config) {
6515
6450
  };
6516
6451
  }
6517
6452
 
6453
+ // src/config/loader.ts
6454
+ var fs13 = __toESM(require("fs"));
6455
+ var path13 = __toESM(require("path"));
6456
+ var os3 = __toESM(require("os"));
6457
+ var CONFIG_FILE_NAMES = [
6458
+ "skedyul.config.ts",
6459
+ "skedyul.config.js",
6460
+ "skedyul.config.mjs",
6461
+ "skedyul.config.cjs"
6462
+ ];
6463
+ async function loadConfig(configPath) {
6464
+ const absolutePath = path13.resolve(configPath);
6465
+ if (!fs13.existsSync(absolutePath)) {
6466
+ throw new Error(`Config file not found: ${absolutePath}`);
6467
+ }
6468
+ const isTypeScript = absolutePath.endsWith(".ts");
6469
+ try {
6470
+ if (isTypeScript) {
6471
+ try {
6472
+ const { transpileConfigMetadata: transpileConfigMetadata2 } = await Promise.resolve().then(() => (init_transpileConfigMetadata(), transpileConfigMetadata_exports));
6473
+ const transpiled = await transpileConfigMetadata2(absolutePath);
6474
+ const tempFile = path13.join(os3.tmpdir(), `skedyul-config-${Date.now()}.cjs`);
6475
+ fs13.writeFileSync(tempFile, transpiled);
6476
+ try {
6477
+ const module3 = require(tempFile);
6478
+ const config2 = module3.default || module3;
6479
+ if (!config2 || typeof config2 !== "object") {
6480
+ throw new Error("Config file must export a configuration object");
6481
+ }
6482
+ if (!config2.name || typeof config2.name !== "string") {
6483
+ throw new Error('Config must have a "name" property');
6484
+ }
6485
+ return config2;
6486
+ } finally {
6487
+ try {
6488
+ fs13.unlinkSync(tempFile);
6489
+ } catch {
6490
+ }
6491
+ }
6492
+ } catch (transpileError) {
6493
+ throw new Error(
6494
+ `Cannot load TypeScript config metadata from ${absolutePath}: ${transpileError instanceof Error ? transpileError.message : String(transpileError)}`
6495
+ );
6496
+ }
6497
+ }
6498
+ const module2 = await import(
6499
+ /* webpackIgnore: true */
6500
+ absolutePath
6501
+ );
6502
+ const config = module2.default || module2;
6503
+ if (!config || typeof config !== "object") {
6504
+ throw new Error("Config file must export a configuration object");
6505
+ }
6506
+ if (!config.name || typeof config.name !== "string") {
6507
+ throw new Error('Config must have a "name" property');
6508
+ }
6509
+ return config;
6510
+ } catch (error) {
6511
+ throw new Error(
6512
+ `Failed to load config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`
6513
+ );
6514
+ }
6515
+ }
6516
+ function validateConfig(config) {
6517
+ const errors = [];
6518
+ if (!config.name) {
6519
+ errors.push("Missing required field: name");
6520
+ }
6521
+ if (config.computeLayer && !["serverless", "dedicated"].includes(config.computeLayer)) {
6522
+ errors.push(`Invalid computeLayer: ${config.computeLayer}. Must be 'serverless' or 'dedicated'`);
6523
+ }
6524
+ return { valid: errors.length === 0, errors };
6525
+ }
6526
+
6518
6527
  // src/cli/commands/validate.ts
6519
6528
  function printHelp5() {
6520
6529
  console.log(`
@@ -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
+ });