@warlock.js/core 4.1.4 → 4.1.6
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/esm/config/config-getter.mjs +5 -5
- package/esm/config/config-getter.mjs.map +1 -1
- package/esm/config/config-loader.mjs +2 -2
- package/esm/config/config-loader.mjs.map +1 -1
- package/esm/connectors/cache-connector.mjs +2 -2
- package/esm/connectors/cache-connector.mjs.map +1 -1
- package/esm/connectors/database-connector.mjs +2 -2
- package/esm/connectors/database-connector.mjs.map +1 -1
- package/esm/connectors/herald-connector.mjs +2 -2
- package/esm/connectors/herald-connector.mjs.map +1 -1
- package/esm/connectors/http-connector.mjs +5 -5
- package/esm/connectors/http-connector.mjs.map +1 -1
- package/esm/connectors/logger-connector.mjs +2 -2
- package/esm/connectors/logger-connector.mjs.map +1 -1
- package/esm/connectors/mail-connector.mjs +2 -2
- package/esm/connectors/mail-connector.mjs.map +1 -1
- package/esm/connectors/socket-connector.mjs +3 -3
- package/esm/connectors/socket-connector.mjs.map +1 -1
- package/esm/dev-server/create-worker.mjs +1 -1
- package/esm/dev-server/create-worker.mjs.map +1 -1
- package/esm/dev-server/health-checker/workers/eslint-health.worker.d.mts +1 -0
- package/esm/dev-server/health-checker/workers/ts-health.worker.d.mts +1 -0
- package/esm/dev-server/loader/hook-thread.d.mts +48 -0
- package/esm/dev-server/loader/hook-thread.d.mts.map +1 -0
- package/esm/dev-server/loader/hook-thread.mjs +47 -0
- package/esm/dev-server/loader/hook-thread.mjs.map +1 -0
- package/esm/dev-server/loader/load-hook.d.mts +58 -0
- package/esm/dev-server/loader/load-hook.d.mts.map +1 -0
- package/esm/dev-server/loader/load-hook.mjs +86 -0
- package/esm/dev-server/loader/load-hook.mjs.map +1 -0
- package/esm/dev-server/loader/own-resolver.mjs +69 -0
- package/esm/dev-server/loader/own-resolver.mjs.map +1 -0
- package/esm/dev-server/loader/register-loader.mjs +3 -1
- package/esm/dev-server/loader/register-loader.mjs.map +1 -1
- package/esm/dev-server/loader/resolve-capture.mjs +43 -0
- package/esm/dev-server/loader/resolve-capture.mjs.map +1 -0
- package/esm/dev-server/loader/resolve-hook.d.mts +41 -0
- package/esm/dev-server/loader/resolve-hook.d.mts.map +1 -0
- package/esm/dev-server/loader/resolve-hook.mjs +87 -0
- package/esm/dev-server/loader/resolve-hook.mjs.map +1 -0
- package/esm/dev-server/loader/source-slug.mjs +22 -0
- package/esm/dev-server/loader/source-slug.mjs.map +1 -0
- package/esm/dev-server/loader/transpile-cache.mjs +163 -1
- package/esm/dev-server/loader/transpile-cache.mjs.map +1 -1
- package/esm/dev-server/loader/version-registry.mjs +45 -0
- package/esm/dev-server/loader/version-registry.mjs.map +1 -0
- package/esm/http/config.mjs +2 -2
- package/esm/http/config.mjs.map +1 -1
- package/esm/http/createHttpApplication.mjs +2 -2
- package/esm/http/createHttpApplication.mjs.map +1 -1
- package/esm/http/middleware/idempotency.middleware.mjs +5 -5
- package/esm/http/middleware/idempotency.middleware.mjs.map +1 -1
- package/esm/http/middleware/inject-request-context.mjs +2 -2
- package/esm/http/middleware/inject-request-context.mjs.map +1 -1
- package/esm/http/middleware/maintenance.middleware.mjs +4 -4
- package/esm/http/middleware/maintenance.middleware.mjs.map +1 -1
- package/esm/http/plugins.mjs +9 -9
- package/esm/http/plugins.mjs.map +1 -1
- package/esm/http/response.mjs +5 -5
- package/esm/http/response.mjs.map +1 -1
- package/esm/http/server.mjs +2 -2
- package/esm/http/server.mjs.map +1 -1
- package/esm/utils/paths.mjs +2 -2
- package/esm/utils/paths.mjs.map +1 -1
- package/esm/validation/validateAll.mjs +2 -2
- package/esm/validation/validateAll.mjs.map +1 -1
- package/package.json +27 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import baseConfig from "@mongez/config";
|
|
2
2
|
|
|
3
3
|
//#region ../../@warlock.js/core/src/config/config-getter.ts
|
|
4
4
|
/**
|
|
@@ -14,15 +14,15 @@ import config from "@mongez/config";
|
|
|
14
14
|
* const port = config.key<number>("database.port", 27017);
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
const config
|
|
17
|
+
const config = {
|
|
18
18
|
key(key, defaultValue) {
|
|
19
|
-
return
|
|
19
|
+
return baseConfig.get(key, defaultValue);
|
|
20
20
|
},
|
|
21
21
|
get(name, defaultValue) {
|
|
22
|
-
return
|
|
22
|
+
return baseConfig.get(name, defaultValue);
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
//#endregion
|
|
27
|
-
export { config
|
|
27
|
+
export { config };
|
|
28
28
|
//# sourceMappingURL=config-getter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-getter.mjs","names":[
|
|
1
|
+
{"version":3,"file":"config-getter.mjs","names":[],"sources":["../../../../../../@warlock.js/core/src/config/config-getter.ts"],"sourcesContent":["import baseConfig from \"@mongez/config\";\nimport type { ConfigKey, ConfigRegistry } from \"./types\";\n\n/**\n * Config accessor interface with typed overloads\n */\ninterface ConfigAccessor {\n /**\n * Get a config value by dot-notation key path.\n */\n key<T = any>(key: ConfigKey | (string & {}), defaultValue?: T): T;\n\n /**\n * Get an entire config group by name with type inference.\n * Returns the typed config object for known config names.\n */\n get<K extends keyof ConfigRegistry>(name: K, defaultValue?: ConfigRegistry[K]): ConfigRegistry[K];\n\n /**\n * Get an entire config group by name (dynamic string).\n */\n get<T = any>(name: string, defaultValue?: T): T;\n}\n\n/**\n * Config accessor with typed autocomplete and return type inference.\n *\n * @example\n * ```typescript\n * // Get entire config group - returns the actual config type\n * const db = config.get(\"database\"); // → DatabaseConfigurations\n *\n * // Get specific key with dot notation\n * const host = config.key(\"database.host\");\n * const port = config.key<number>(\"database.port\", 27017);\n * ```\n */\nexport const config: ConfigAccessor = {\n key(key: ConfigKey | (string & {}), defaultValue?: any): any {\n return baseConfig.get(key, defaultValue);\n },\n\n get(name: string, defaultValue?: any): any {\n return baseConfig.get(name, defaultValue);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAa,SAAyB;CACpC,IAAI,KAAgC,cAAyB;EAC3D,OAAO,WAAW,IAAI,KAAK,YAAY;CACzC;CAEA,IAAI,MAAc,cAAyB;EACzC,OAAO,WAAW,IAAI,MAAM,YAAY;CAC1C;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { configSpecialHandlers } from "./config-special-handlers.mjs";
|
|
2
|
-
import
|
|
2
|
+
import baseConfig from "@mongez/config";
|
|
3
3
|
import { colors } from "@mongez/copper";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
5
|
|
|
@@ -27,7 +27,7 @@ var ConfigLoader = class {
|
|
|
27
27
|
console.log(colors.red(`config error: `), `Config file ${colors.yellow(file.relativePath)} does not have a default export`);
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
baseConfig.set(configName, configValue);
|
|
31
31
|
await configSpecialHandlers.execute(configName, configValue);
|
|
32
32
|
} catch (error) {
|
|
33
33
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.mjs","names":[],"sources":["../../../../../../@warlock.js/core/src/config/config-loader.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { colors } from \"@mongez/copper\";\r\nimport { pathToFileURL } from \"node:url\";\r\nimport type { FileManager } from \"../dev-server/file-manager\";\r\nimport { configSpecialHandlers } from \"./config-special-handlers\";\r\n\r\n/**\r\n * Special Config Handler\r\n * A function that handles special configuration loading\r\n */\r\nexport type SpecialConfigHandler = (configValue: any) => void | Promise<void>;\r\n\r\n/**\r\n * Config Loader\r\n * Dynamically loads all configuration files and registers them with @mongez/config\r\n * Supports special handlers for configs that require additional processing\r\n */\r\nexport class ConfigLoader {\r\n public async loadAll(configFiles: FileManager[]): Promise<void> {\r\n for (const file of configFiles) {\r\n await this.loadConfig(file);\r\n }\r\n }\r\n\r\n /**\r\n * Load a single configuration file.\r\n *\r\n * The ESM loader hook stamps a version token onto the URL so that each HMR\r\n * cycle gets a fresh module — no manual cache-busting needed here.\r\n */\r\n public async loadConfig(file: FileManager): Promise<void> {\r\n const configName = this.getConfigName(file.relativePath);\r\n\r\n try {\r\n const fileUrl = pathToFileURL(file.absolutePath).href;\r\n const configModule = await import(fileUrl);\r\n const configValue = configModule.default;\r\n\r\n if (configValue === undefined) {\r\n console.log(\r\n colors.red(`config error: `),\r\n `Config file ${colors.yellow(file.relativePath)} does not have a default export`,\r\n );\r\n return;\r\n }\r\n\r\n config.set(configName, configValue);\r\n await configSpecialHandlers.execute(configName, configValue);\r\n } catch (error) {\r\n throw error;\r\n }\r\n }\r\n\r\n public async reloadConfig(file: FileManager): Promise<void> {\r\n await this.loadConfig(file);\r\n }\r\n\r\n private getConfigName(relativePath: string): string {\r\n const match = relativePath.match(/^src\\/config\\/(.+)\\.(ts|tsx)$/);\r\n\r\n if (!match) {\r\n throw new Error(`Invalid config file path: ${relativePath}`);\r\n }\r\n\r\n return match[1];\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;AAiBA,IAAa,eAAb,MAA0B;CACxB,MAAa,QAAQ,aAA2C;EAC9D,KAAK,MAAM,QAAQ,aACjB,MAAM,KAAK,WAAW,IAAI;CAE9B;;;;;;;CAQA,MAAa,WAAW,MAAkC;EACxD,MAAM,aAAa,KAAK,cAAc,KAAK,YAAY;EAEvD,IAAI;GAGF,MAAM,eAAc,MADO,OADX,cAAc,KAAK,YAAY,EAAE,OAEhB;GAEjC,IAAI,gBAAgB,QAAW;IAC7B,QAAQ,IACN,OAAO,IAAI,gBAAgB,GAC3B,eAAe,OAAO,OAAO,KAAK,YAAY,EAAE,gCAClD;IACA;GACF;GAEA,
|
|
1
|
+
{"version":3,"file":"config-loader.mjs","names":[],"sources":["../../../../../../@warlock.js/core/src/config/config-loader.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { colors } from \"@mongez/copper\";\r\nimport { pathToFileURL } from \"node:url\";\r\nimport type { FileManager } from \"../dev-server/file-manager\";\r\nimport { configSpecialHandlers } from \"./config-special-handlers\";\r\n\r\n/**\r\n * Special Config Handler\r\n * A function that handles special configuration loading\r\n */\r\nexport type SpecialConfigHandler = (configValue: any) => void | Promise<void>;\r\n\r\n/**\r\n * Config Loader\r\n * Dynamically loads all configuration files and registers them with @mongez/config\r\n * Supports special handlers for configs that require additional processing\r\n */\r\nexport class ConfigLoader {\r\n public async loadAll(configFiles: FileManager[]): Promise<void> {\r\n for (const file of configFiles) {\r\n await this.loadConfig(file);\r\n }\r\n }\r\n\r\n /**\r\n * Load a single configuration file.\r\n *\r\n * The ESM loader hook stamps a version token onto the URL so that each HMR\r\n * cycle gets a fresh module — no manual cache-busting needed here.\r\n */\r\n public async loadConfig(file: FileManager): Promise<void> {\r\n const configName = this.getConfigName(file.relativePath);\r\n\r\n try {\r\n const fileUrl = pathToFileURL(file.absolutePath).href;\r\n const configModule = await import(fileUrl);\r\n const configValue = configModule.default;\r\n\r\n if (configValue === undefined) {\r\n console.log(\r\n colors.red(`config error: `),\r\n `Config file ${colors.yellow(file.relativePath)} does not have a default export`,\r\n );\r\n return;\r\n }\r\n\r\n config.set(configName, configValue);\r\n await configSpecialHandlers.execute(configName, configValue);\r\n } catch (error) {\r\n throw error;\r\n }\r\n }\r\n\r\n public async reloadConfig(file: FileManager): Promise<void> {\r\n await this.loadConfig(file);\r\n }\r\n\r\n private getConfigName(relativePath: string): string {\r\n const match = relativePath.match(/^src\\/config\\/(.+)\\.(ts|tsx)$/);\r\n\r\n if (!match) {\r\n throw new Error(`Invalid config file path: ${relativePath}`);\r\n }\r\n\r\n return match[1];\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;AAiBA,IAAa,eAAb,MAA0B;CACxB,MAAa,QAAQ,aAA2C;EAC9D,KAAK,MAAM,QAAQ,aACjB,MAAM,KAAK,WAAW,IAAI;CAE9B;;;;;;;CAQA,MAAa,WAAW,MAAkC;EACxD,MAAM,aAAa,KAAK,cAAc,KAAK,YAAY;EAEvD,IAAI;GAGF,MAAM,eAAc,MADO,OADX,cAAc,KAAK,YAAY,EAAE,OAEhB;GAEjC,IAAI,gBAAgB,QAAW;IAC7B,QAAQ,IACN,OAAO,IAAI,gBAAgB,GAC3B,eAAe,OAAO,OAAO,KAAK,YAAY,EAAE,gCAClD;IACA;GACF;GAEA,WAAO,IAAI,YAAY,WAAW;GAClC,MAAM,sBAAsB,QAAQ,YAAY,WAAW;EAC7D,SAAS,OAAO;GACd,MAAM;EACR;CACF;CAEA,MAAa,aAAa,MAAkC;EAC1D,MAAM,KAAK,WAAW,IAAI;CAC5B;CAEA,AAAQ,cAAc,cAA8B;EAClD,MAAM,QAAQ,aAAa,MAAM,+BAA+B;EAEhE,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,6BAA6B,cAAc;EAG7D,OAAO,MAAM;CACf;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConnectorLifecyclePhase, ConnectorPriority } from "./types.mjs";
|
|
2
2
|
import { BaseConnector } from "./base-connector.mjs";
|
|
3
|
-
import
|
|
3
|
+
import baseConfig from "@mongez/config";
|
|
4
4
|
import { cache } from "@warlock.js/cache";
|
|
5
5
|
|
|
6
6
|
//#region ../../@warlock.js/core/src/connectors/cache-connector.ts
|
|
@@ -20,7 +20,7 @@ var CacheConnector = class extends BaseConnector {
|
|
|
20
20
|
* Initialize cache connection
|
|
21
21
|
*/
|
|
22
22
|
async start() {
|
|
23
|
-
const cacheConfig =
|
|
23
|
+
const cacheConfig = baseConfig.get("cache");
|
|
24
24
|
if (!cacheConfig) return;
|
|
25
25
|
cache.setCacheConfigurations(cacheConfig);
|
|
26
26
|
await cache.init();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-connector.mjs","names":[],"sources":["../../../../../../@warlock.js/core/src/connectors/cache-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { cache } from \"@warlock.js/cache\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\r\n\r\n/**\r\n * Cache Connector\r\n * Manages cache engine connection lifecycle\r\n */\r\nexport class CacheConnector extends BaseConnector {\r\n public readonly name = \"cache\";\r\n public readonly priority = ConnectorPriority.CACHE;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\r\n\r\n /**\r\n * Files that trigger cache restart\r\n */\r\n protected readonly watchedFiles = [\"src/config/cache.ts\", \"src/config/cache.tsx\"];\r\n\r\n /**\r\n * Initialize cache connection\r\n */\r\n public async start(): Promise<void> {\r\n const cacheConfig = config.get(\"cache\");\r\n\r\n if (!cacheConfig) return;\r\n\r\n cache.setCacheConfigurations(cacheConfig);\r\n\r\n await cache.init();\r\n\r\n this.active = true;\r\n }\r\n\r\n /**\r\n * Shutdown cache connection\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n // TODO: Implement actual cache disconnection\r\n // - Close all active connections\r\n // - Clean up resources\r\n\r\n this.active = false;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;AASA,IAAa,iBAAb,cAAoC,cAAc;;;cACzB;;;sBAOW,CAAC,uBAAuB,sBAAsB;;;;;CAKhF,MAAa,QAAuB;EAClC,MAAM,
|
|
1
|
+
{"version":3,"file":"cache-connector.mjs","names":["config"],"sources":["../../../../../../@warlock.js/core/src/connectors/cache-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { cache } from \"@warlock.js/cache\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\r\n\r\n/**\r\n * Cache Connector\r\n * Manages cache engine connection lifecycle\r\n */\r\nexport class CacheConnector extends BaseConnector {\r\n public readonly name = \"cache\";\r\n public readonly priority = ConnectorPriority.CACHE;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\r\n\r\n /**\r\n * Files that trigger cache restart\r\n */\r\n protected readonly watchedFiles = [\"src/config/cache.ts\", \"src/config/cache.tsx\"];\r\n\r\n /**\r\n * Initialize cache connection\r\n */\r\n public async start(): Promise<void> {\r\n const cacheConfig = config.get(\"cache\");\r\n\r\n if (!cacheConfig) return;\r\n\r\n cache.setCacheConfigurations(cacheConfig);\r\n\r\n await cache.init();\r\n\r\n this.active = true;\r\n }\r\n\r\n /**\r\n * Shutdown cache connection\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n // TODO: Implement actual cache disconnection\r\n // - Close all active connections\r\n // - Clean up resources\r\n\r\n this.active = false;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;AASA,IAAa,iBAAb,cAAoC,cAAc;;;cACzB;;;sBAOW,CAAC,uBAAuB,sBAAsB;;;;;CAKhF,MAAa,QAAuB;EAClC,MAAM,cAAcA,WAAO,IAAI,OAAO;EAEtC,IAAI,CAAC,aAAa;EAElB,MAAM,uBAAuB,WAAW;EAExC,MAAM,MAAM,KAAK;EAEjB,KAAK,SAAS;CAChB;;;;CAKA,MAAa,WAA0B;EACrC,IAAI,CAAC,KAAK,QACR;EAOF,KAAK,SAAS;CAChB;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { container } from "../container/index.mjs";
|
|
2
2
|
import { ConnectorLifecyclePhase, ConnectorPriority } from "./types.mjs";
|
|
3
3
|
import { BaseConnector } from "./base-connector.mjs";
|
|
4
|
-
import
|
|
4
|
+
import baseConfig from "@mongez/config";
|
|
5
5
|
import { connectToDatabase, dataSourceRegistry } from "@warlock.js/cascade";
|
|
6
6
|
|
|
7
7
|
//#region ../../@warlock.js/core/src/connectors/database-connector.ts
|
|
@@ -21,7 +21,7 @@ var DatabaseConnector = class extends BaseConnector {
|
|
|
21
21
|
* Initialize database connection
|
|
22
22
|
*/
|
|
23
23
|
async start() {
|
|
24
|
-
const databaseConfig =
|
|
24
|
+
const databaseConfig = baseConfig.get("database");
|
|
25
25
|
if (!databaseConfig) return;
|
|
26
26
|
try {
|
|
27
27
|
const source = await connectToDatabase(databaseConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-connector.mjs","names":[],"sources":["../../../../../../@warlock.js/core/src/connectors/database-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { connectToDatabase, dataSourceRegistry } from \"@warlock.js/cascade\";\r\nimport { container } from \"../container\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\r\n\r\n/**\r\n * Database Connector\r\n * Manages database connection lifecycle using @warlock.js/cascade\r\n */\r\nexport class DatabaseConnector extends BaseConnector {\r\n public readonly name = \"database\";\r\n public readonly priority = ConnectorPriority.DATABASE;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\r\n\r\n /**\r\n * Files that trigger database restart\r\n */\r\n protected readonly watchedFiles = [\"src/config/database.ts\", \"src/config/database.tsx\"];\r\n\r\n /**\r\n * Initialize database connection\r\n */\r\n public async start(): Promise<void> {\r\n const databaseConfig = config.get(\"database\");\r\n\r\n if (!databaseConfig) {\r\n return;\r\n }\r\n\r\n try {\r\n const source = await connectToDatabase(databaseConfig);\r\n container.set(\"database.source\", source);\r\n this.active = true;\r\n } catch (error) {\r\n console.error(\"Failed to connect to database:\", error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown database connection\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n try {\r\n // Disconnect all registered data sources\r\n const dataSources = dataSourceRegistry.getAllDataSources();\r\n\r\n for (const dataSource of dataSources) {\r\n if (dataSource.driver.isConnected) {\r\n await dataSource.driver.disconnect();\r\n }\r\n }\r\n\r\n this.active = false;\r\n } catch (error) {\r\n console.error(\"Failed to disconnect from database:\", error);\r\n throw error;\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;AAUA,IAAa,oBAAb,cAAuC,cAAc;;;cAC5B;;;sBAOW,CAAC,0BAA0B,yBAAyB;;;;;CAKtF,MAAa,QAAuB;EAClC,MAAM,
|
|
1
|
+
{"version":3,"file":"database-connector.mjs","names":["config"],"sources":["../../../../../../@warlock.js/core/src/connectors/database-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { connectToDatabase, dataSourceRegistry } from \"@warlock.js/cascade\";\r\nimport { container } from \"../container\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\r\n\r\n/**\r\n * Database Connector\r\n * Manages database connection lifecycle using @warlock.js/cascade\r\n */\r\nexport class DatabaseConnector extends BaseConnector {\r\n public readonly name = \"database\";\r\n public readonly priority = ConnectorPriority.DATABASE;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\r\n\r\n /**\r\n * Files that trigger database restart\r\n */\r\n protected readonly watchedFiles = [\"src/config/database.ts\", \"src/config/database.tsx\"];\r\n\r\n /**\r\n * Initialize database connection\r\n */\r\n public async start(): Promise<void> {\r\n const databaseConfig = config.get(\"database\");\r\n\r\n if (!databaseConfig) {\r\n return;\r\n }\r\n\r\n try {\r\n const source = await connectToDatabase(databaseConfig);\r\n container.set(\"database.source\", source);\r\n this.active = true;\r\n } catch (error) {\r\n console.error(\"Failed to connect to database:\", error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown database connection\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n try {\r\n // Disconnect all registered data sources\r\n const dataSources = dataSourceRegistry.getAllDataSources();\r\n\r\n for (const dataSource of dataSources) {\r\n if (dataSource.driver.isConnected) {\r\n await dataSource.driver.disconnect();\r\n }\r\n }\r\n\r\n this.active = false;\r\n } catch (error) {\r\n console.error(\"Failed to disconnect from database:\", error);\r\n throw error;\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;AAUA,IAAa,oBAAb,cAAuC,cAAc;;;cAC5B;;;sBAOW,CAAC,0BAA0B,yBAAyB;;;;;CAKtF,MAAa,QAAuB;EAClC,MAAM,iBAAiBA,WAAO,IAAI,UAAU;EAE5C,IAAI,CAAC,gBACH;EAGF,IAAI;GACF,MAAM,SAAS,MAAM,kBAAkB,cAAc;GACrD,UAAU,IAAI,mBAAmB,MAAM;GACvC,KAAK,SAAS;EAChB,SAAS,OAAO;GACd,QAAQ,MAAM,kCAAkC,KAAK;GACrD,MAAM;EACR;CACF;;;;CAKA,MAAa,WAA0B;EACrC,IAAI,CAAC,KAAK,QACR;EAGF,IAAI;GAEF,MAAM,cAAc,mBAAmB,kBAAkB;GAEzD,KAAK,MAAM,cAAc,aACvB,IAAI,WAAW,OAAO,aACpB,MAAM,WAAW,OAAO,WAAW;GAIvC,KAAK,SAAS;EAChB,SAAS,OAAO;GACd,QAAQ,MAAM,uCAAuC,KAAK;GAC1D,MAAM;EACR;CACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConnectorLifecyclePhase, ConnectorPriority } from "./types.mjs";
|
|
2
2
|
import { BaseConnector } from "./base-connector.mjs";
|
|
3
|
-
import
|
|
3
|
+
import baseConfig from "@mongez/config";
|
|
4
4
|
import { log } from "@warlock.js/logger";
|
|
5
5
|
|
|
6
6
|
//#region ../../@warlock.js/core/src/connectors/herald-connector.ts
|
|
@@ -20,7 +20,7 @@ var HeraldConnector = class extends BaseConnector {
|
|
|
20
20
|
* Initialize broker connection
|
|
21
21
|
*/
|
|
22
22
|
async start() {
|
|
23
|
-
const heraldConfig =
|
|
23
|
+
const heraldConfig = baseConfig.get("herald");
|
|
24
24
|
if (!heraldConfig) return;
|
|
25
25
|
try {
|
|
26
26
|
const { connectToBroker } = await import("@warlock.js/herald");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"herald-connector.mjs","names":[],"sources":["../../../../../../@warlock.js/core/src/connectors/herald-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { log } from \"@warlock.js/logger\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\r\n\r\n/**\r\n * Herald Connector\r\n * Manages message broker connection lifecycle using @warlock.js/herald\r\n */\r\nexport class HeraldConnector extends BaseConnector {\r\n public readonly name = \"herald\";\r\n public readonly priority = ConnectorPriority.COMMUNICATOR;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\r\n\r\n /**\r\n * Files that trigger herald restart\r\n */\r\n protected readonly watchedFiles = [\"src/config/herald.ts\"];\r\n\r\n /**\r\n * Initialize broker connection\r\n */\r\n public async start(): Promise<void> {\r\n const heraldConfig = config.get(\"herald\");\r\n\r\n if (!heraldConfig) {\r\n return;\r\n }\r\n\r\n try {\r\n const { connectToBroker } = await import(\"@warlock.js/herald\");\r\n\r\n log.info(`herald.${heraldConfig.driver}`, \"connection\", \"Connecting to message broker\");\r\n await connectToBroker(heraldConfig);\r\n log.success(`herald.${heraldConfig.driver}`, \"connection\", \"Connected to message broker\");\r\n this.active = true;\r\n } catch (error) {\r\n log.error(\r\n `herald.${heraldConfig.driver}`,\r\n \"connection\",\r\n \"Failed to connect to message broker\",\r\n );\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown broker connection\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n try {\r\n const { brokerRegistry } = await import(\"@warlock.js/herald\");\r\n\r\n // Disconnect all registered brokers\r\n const brokers = brokerRegistry.getAll();\r\n\r\n for (const broker of brokers) {\r\n if (broker.driver.isConnected) {\r\n await broker.driver.disconnect();\r\n }\r\n }\r\n\r\n // Clear the registry for clean restart\r\n brokerRegistry.clear();\r\n\r\n this.active = false;\r\n } catch (error) {\r\n log.error(\"herald\", \"shutdown\", \"Failed to disconnect from message broker\");\r\n throw error;\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;AASA,IAAa,kBAAb,cAAqC,cAAc;;;cAC1B;;;sBAOW,CAAC,sBAAsB;;;;;CAKzD,MAAa,QAAuB;EAClC,MAAM,
|
|
1
|
+
{"version":3,"file":"herald-connector.mjs","names":["config"],"sources":["../../../../../../@warlock.js/core/src/connectors/herald-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { log } from \"@warlock.js/logger\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\r\n\r\n/**\r\n * Herald Connector\r\n * Manages message broker connection lifecycle using @warlock.js/herald\r\n */\r\nexport class HeraldConnector extends BaseConnector {\r\n public readonly name = \"herald\";\r\n public readonly priority = ConnectorPriority.COMMUNICATOR;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\r\n\r\n /**\r\n * Files that trigger herald restart\r\n */\r\n protected readonly watchedFiles = [\"src/config/herald.ts\"];\r\n\r\n /**\r\n * Initialize broker connection\r\n */\r\n public async start(): Promise<void> {\r\n const heraldConfig = config.get(\"herald\");\r\n\r\n if (!heraldConfig) {\r\n return;\r\n }\r\n\r\n try {\r\n const { connectToBroker } = await import(\"@warlock.js/herald\");\r\n\r\n log.info(`herald.${heraldConfig.driver}`, \"connection\", \"Connecting to message broker\");\r\n await connectToBroker(heraldConfig);\r\n log.success(`herald.${heraldConfig.driver}`, \"connection\", \"Connected to message broker\");\r\n this.active = true;\r\n } catch (error) {\r\n log.error(\r\n `herald.${heraldConfig.driver}`,\r\n \"connection\",\r\n \"Failed to connect to message broker\",\r\n );\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown broker connection\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n try {\r\n const { brokerRegistry } = await import(\"@warlock.js/herald\");\r\n\r\n // Disconnect all registered brokers\r\n const brokers = brokerRegistry.getAll();\r\n\r\n for (const broker of brokers) {\r\n if (broker.driver.isConnected) {\r\n await broker.driver.disconnect();\r\n }\r\n }\r\n\r\n // Clear the registry for clean restart\r\n brokerRegistry.clear();\r\n\r\n this.active = false;\r\n } catch (error) {\r\n log.error(\"herald\", \"shutdown\", \"Failed to disconnect from message broker\");\r\n throw error;\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;AASA,IAAa,kBAAb,cAAqC,cAAc;;;cAC1B;;;sBAOW,CAAC,sBAAsB;;;;;CAKzD,MAAa,QAAuB;EAClC,MAAM,eAAeA,WAAO,IAAI,QAAQ;EAExC,IAAI,CAAC,cACH;EAGF,IAAI;GACF,MAAM,EAAE,oBAAoB,MAAM,OAAO;GAEzC,IAAI,KAAK,UAAU,aAAa,UAAU,cAAc,8BAA8B;GACtF,MAAM,gBAAgB,YAAY;GAClC,IAAI,QAAQ,UAAU,aAAa,UAAU,cAAc,6BAA6B;GACxF,KAAK,SAAS;EAChB,SAAS,OAAO;GACd,IAAI,MACF,UAAU,aAAa,UACvB,cACA,qCACF;GACA,MAAM;EACR;CACF;;;;CAKA,MAAa,WAA0B;EACrC,IAAI,CAAC,KAAK,QACR;EAGF,IAAI;GACF,MAAM,EAAE,mBAAmB,MAAM,OAAO;GAGxC,MAAM,UAAU,eAAe,OAAO;GAEtC,KAAK,MAAM,UAAU,SACnB,IAAI,OAAO,OAAO,aAChB,MAAM,OAAO,OAAO,WAAW;GAKnC,eAAe,MAAM;GAErB,KAAK,SAAS;EAChB,SAAS,OAAO;GACd,IAAI,MAAM,UAAU,YAAY,0CAA0C;GAC1E,MAAM;EACR;CACF;AACF"}
|
|
@@ -8,7 +8,7 @@ import "../application/index.mjs";
|
|
|
8
8
|
import { ConnectorLifecyclePhase, ConnectorPriority } from "./types.mjs";
|
|
9
9
|
import { BaseConnector } from "./base-connector.mjs";
|
|
10
10
|
import { devLogError } from "../dev-server/dev-logger.mjs";
|
|
11
|
-
import
|
|
11
|
+
import baseConfig from "@mongez/config";
|
|
12
12
|
import { log } from "@warlock.js/logger";
|
|
13
13
|
import { colors } from "@mongez/copper";
|
|
14
14
|
|
|
@@ -39,14 +39,14 @@ var HttpConnector = class extends BaseConnector {
|
|
|
39
39
|
* `start()` so it reads the router after app code has registered.
|
|
40
40
|
*/
|
|
41
41
|
async boot() {
|
|
42
|
-
const httpConfig =
|
|
42
|
+
const httpConfig = baseConfig.get("http");
|
|
43
43
|
if (!httpConfig) return;
|
|
44
44
|
const port = httpConfig.port;
|
|
45
45
|
log.info(`http`, "connection", `Starting http server on port ${port} in ${environmentColor(Application.environment)} mode`);
|
|
46
46
|
this.http = startHttpServer(httpConfig.serverOptions);
|
|
47
47
|
container.set("http.server", this.http);
|
|
48
48
|
await registerHttpPlugins(this.http);
|
|
49
|
-
setBaseUrl(
|
|
49
|
+
setBaseUrl(baseConfig.get("app.baseUrl"));
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Initialize HTTP server — bind app-registered routes to Fastify
|
|
@@ -54,7 +54,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
54
54
|
* app code without losing routes.
|
|
55
55
|
*/
|
|
56
56
|
async start() {
|
|
57
|
-
const httpConfig =
|
|
57
|
+
const httpConfig = baseConfig.get("http");
|
|
58
58
|
if (!httpConfig || !this.http) return;
|
|
59
59
|
if (Application.runtimeStrategy === "development") router.scanDevServer(this.http);
|
|
60
60
|
else router.scan(this.http);
|
|
@@ -63,7 +63,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
63
63
|
port: httpConfig.port,
|
|
64
64
|
host: httpConfig.host || "localhost"
|
|
65
65
|
});
|
|
66
|
-
const baseUrl =
|
|
66
|
+
const baseUrl = baseConfig.get("app.baseUrl");
|
|
67
67
|
log.success(`http`, "connection", `Server ready at ${baseUrl}`);
|
|
68
68
|
} catch (error) {
|
|
69
69
|
devLogError("Error while starting http server", error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-connector.mjs","names":[],"sources":["../../../../../../@warlock.js/core/src/connectors/http-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { colors } from \"@mongez/copper\";\r\nimport { log } from \"@warlock.js/logger\";\r\nimport { Application } from \"../application\";\r\nimport { devLogError } from \"../dev-server/dev-logger\";\r\nimport { registerHttpPlugins } from \"../http/plugins\";\r\nimport { FastifyInstance, getHttpServer, startHttpServer } from \"../http/server\";\r\nimport { router } from \"../router/router\";\r\nimport { Environment } from \"../utils\";\r\nimport { setBaseUrl } from \"../utils/urls\";\r\nimport { container } from \"./../container\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\r\n\r\nfunction environmentColor(environment: Environment) {\r\n switch (environment) {\r\n case \"development\":\r\n return colors.magentaBright(environment);\r\n case \"test\":\r\n return colors.yellowBright(environment);\r\n case \"production\":\r\n return colors.greenBright(environment);\r\n default:\r\n return colors.white(environment);\r\n }\r\n}\r\n\r\n/**\r\n * HTTP Connector\r\n * Manages HTTP server (Fastify) lifecycle\r\n */\r\nexport class HttpConnector extends BaseConnector {\r\n public readonly name = \"http\";\r\n public readonly priority = ConnectorPriority.HTTP;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Late;\r\n\r\n /**\r\n * Files that trigger HTTP server restart\r\n * Note: routes.ts changes will be handled by HMR with wildcard routing\r\n * Connectors receive config file paths directly (not .env) thanks to layer-executor\r\n */\r\n protected readonly watchedFiles = [\"src/config/http.ts\", \"src/config/http.tsx\"];\r\n\r\n /**\r\n * Fastify Server instance\r\n */\r\n protected http?: FastifyInstance;\r\n\r\n /**\r\n * Boot the connector — construction only (create Fastify, register\r\n * plugins, populate container). Route scanning is deferred to\r\n * `start()` so it reads the router after app code has registered.\r\n */\r\n public async boot() {\r\n const httpConfig = config.get(\"http\");\r\n\r\n if (!httpConfig) return;\r\n\r\n const port = httpConfig.port;\r\n log.info(\r\n `http`,\r\n \"connection\",\r\n `Starting http server on port ${port} in ${environmentColor(Application.environment)} mode`,\r\n );\r\n\r\n this.http = startHttpServer(httpConfig.serverOptions);\r\n\r\n container.set(\"http.server\", this.http);\r\n\r\n await registerHttpPlugins(this.http);\r\n\r\n const baseUrl = config.get(\"app.baseUrl\");\r\n\r\n // update base url\r\n setBaseUrl(baseUrl);\r\n }\r\n\r\n /**\r\n * Initialize HTTP server — bind app-registered routes to Fastify\r\n * then listen. Scanning here (not in `boot`) lets HTTP boot before\r\n * app code without losing routes.\r\n */\r\n public async start(): Promise<void> {\r\n const httpConfig = config.get(\"http\");\r\n\r\n if (!httpConfig || !this.http) return;\r\n\r\n if (Application.runtimeStrategy === \"development\") {\r\n router.scanDevServer(this.http);\r\n } else {\r\n router.scan(this.http);\r\n }\r\n\r\n try {\r\n // We can use the url of the server\r\n await this.http.listen({\r\n port: httpConfig.port,\r\n host: httpConfig.host || \"localhost\",\r\n });\r\n\r\n const baseUrl = config.get(\"app.baseUrl\");\r\n\r\n log.success(`http`, \"connection\", `Server ready at ${baseUrl}`);\r\n } catch (error) {\r\n devLogError(\"Error while starting http server\", error);\r\n\r\n process.exit(1); // stop the process, exit with error\r\n }\r\n\r\n this.active = true;\r\n }\r\n\r\n /**\r\n * Restart — needs a fresh Fastify instance since `start()` now\r\n * re-runs `router.scan()`, and re-scanning the same Fastify would\r\n * register duplicate route handlers.\r\n */\r\n public async restart(): Promise<void> {\r\n await this.shutdown();\r\n await this.boot();\r\n await this.start();\r\n }\r\n\r\n /**\r\n * Shutdown HTTP server\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n const server = getHttpServer();\r\n\r\n server?.close();\r\n\r\n this.active = false;\r\n }\r\n\r\n /**\r\n * Override shouldRestart to handle routes.ts specially\r\n * routes.ts changes should NOT restart the server (use HMR instead)\r\n * Now receives config file paths directly from layer-executor\r\n */\r\n public shouldRestart(changedFiles: string[]): boolean {\r\n // Only restart for config changes, not routes\r\n return changedFiles.some((file) => {\r\n const relativePath = file.replace(/\\\\/g, \"/\");\r\n return this.watchedFiles.includes(relativePath);\r\n });\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAS,iBAAiB,aAA0B;CAClD,QAAQ,aAAR;EACE,KAAK,eACH,OAAO,OAAO,cAAc,WAAW;EACzC,KAAK,QACH,OAAO,OAAO,aAAa,WAAW;EACxC,KAAK,cACH,OAAO,OAAO,YAAY,WAAW;EACvC,SACE,OAAO,OAAO,MAAM,WAAW;CACnC;AACF;;;;;AAMA,IAAa,gBAAb,cAAmC,cAAc;;;cACxB;;;sBASW,CAAC,sBAAsB,qBAAqB;;;;;;;CAY9E,MAAa,OAAO;EAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"http-connector.mjs","names":["config"],"sources":["../../../../../../@warlock.js/core/src/connectors/http-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { colors } from \"@mongez/copper\";\r\nimport { log } from \"@warlock.js/logger\";\r\nimport { Application } from \"../application\";\r\nimport { devLogError } from \"../dev-server/dev-logger\";\r\nimport { registerHttpPlugins } from \"../http/plugins\";\r\nimport { FastifyInstance, getHttpServer, startHttpServer } from \"../http/server\";\r\nimport { router } from \"../router/router\";\r\nimport { Environment } from \"../utils\";\r\nimport { setBaseUrl } from \"../utils/urls\";\r\nimport { container } from \"./../container\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\r\n\r\nfunction environmentColor(environment: Environment) {\r\n switch (environment) {\r\n case \"development\":\r\n return colors.magentaBright(environment);\r\n case \"test\":\r\n return colors.yellowBright(environment);\r\n case \"production\":\r\n return colors.greenBright(environment);\r\n default:\r\n return colors.white(environment);\r\n }\r\n}\r\n\r\n/**\r\n * HTTP Connector\r\n * Manages HTTP server (Fastify) lifecycle\r\n */\r\nexport class HttpConnector extends BaseConnector {\r\n public readonly name = \"http\";\r\n public readonly priority = ConnectorPriority.HTTP;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Late;\r\n\r\n /**\r\n * Files that trigger HTTP server restart\r\n * Note: routes.ts changes will be handled by HMR with wildcard routing\r\n * Connectors receive config file paths directly (not .env) thanks to layer-executor\r\n */\r\n protected readonly watchedFiles = [\"src/config/http.ts\", \"src/config/http.tsx\"];\r\n\r\n /**\r\n * Fastify Server instance\r\n */\r\n protected http?: FastifyInstance;\r\n\r\n /**\r\n * Boot the connector — construction only (create Fastify, register\r\n * plugins, populate container). Route scanning is deferred to\r\n * `start()` so it reads the router after app code has registered.\r\n */\r\n public async boot() {\r\n const httpConfig = config.get(\"http\");\r\n\r\n if (!httpConfig) return;\r\n\r\n const port = httpConfig.port;\r\n log.info(\r\n `http`,\r\n \"connection\",\r\n `Starting http server on port ${port} in ${environmentColor(Application.environment)} mode`,\r\n );\r\n\r\n this.http = startHttpServer(httpConfig.serverOptions);\r\n\r\n container.set(\"http.server\", this.http);\r\n\r\n await registerHttpPlugins(this.http);\r\n\r\n const baseUrl = config.get(\"app.baseUrl\");\r\n\r\n // update base url\r\n setBaseUrl(baseUrl);\r\n }\r\n\r\n /**\r\n * Initialize HTTP server — bind app-registered routes to Fastify\r\n * then listen. Scanning here (not in `boot`) lets HTTP boot before\r\n * app code without losing routes.\r\n */\r\n public async start(): Promise<void> {\r\n const httpConfig = config.get(\"http\");\r\n\r\n if (!httpConfig || !this.http) return;\r\n\r\n if (Application.runtimeStrategy === \"development\") {\r\n router.scanDevServer(this.http);\r\n } else {\r\n router.scan(this.http);\r\n }\r\n\r\n try {\r\n // We can use the url of the server\r\n await this.http.listen({\r\n port: httpConfig.port,\r\n host: httpConfig.host || \"localhost\",\r\n });\r\n\r\n const baseUrl = config.get(\"app.baseUrl\");\r\n\r\n log.success(`http`, \"connection\", `Server ready at ${baseUrl}`);\r\n } catch (error) {\r\n devLogError(\"Error while starting http server\", error);\r\n\r\n process.exit(1); // stop the process, exit with error\r\n }\r\n\r\n this.active = true;\r\n }\r\n\r\n /**\r\n * Restart — needs a fresh Fastify instance since `start()` now\r\n * re-runs `router.scan()`, and re-scanning the same Fastify would\r\n * register duplicate route handlers.\r\n */\r\n public async restart(): Promise<void> {\r\n await this.shutdown();\r\n await this.boot();\r\n await this.start();\r\n }\r\n\r\n /**\r\n * Shutdown HTTP server\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n const server = getHttpServer();\r\n\r\n server?.close();\r\n\r\n this.active = false;\r\n }\r\n\r\n /**\r\n * Override shouldRestart to handle routes.ts specially\r\n * routes.ts changes should NOT restart the server (use HMR instead)\r\n * Now receives config file paths directly from layer-executor\r\n */\r\n public shouldRestart(changedFiles: string[]): boolean {\r\n // Only restart for config changes, not routes\r\n return changedFiles.some((file) => {\r\n const relativePath = file.replace(/\\\\/g, \"/\");\r\n return this.watchedFiles.includes(relativePath);\r\n });\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAS,iBAAiB,aAA0B;CAClD,QAAQ,aAAR;EACE,KAAK,eACH,OAAO,OAAO,cAAc,WAAW;EACzC,KAAK,QACH,OAAO,OAAO,aAAa,WAAW;EACxC,KAAK,cACH,OAAO,OAAO,YAAY,WAAW;EACvC,SACE,OAAO,OAAO,MAAM,WAAW;CACnC;AACF;;;;;AAMA,IAAa,gBAAb,cAAmC,cAAc;;;cACxB;;;sBASW,CAAC,sBAAsB,qBAAqB;;;;;;;CAY9E,MAAa,OAAO;EAClB,MAAM,aAAaA,WAAO,IAAI,MAAM;EAEpC,IAAI,CAAC,YAAY;EAEjB,MAAM,OAAO,WAAW;EACxB,IAAI,KACF,QACA,cACA,gCAAgC,KAAK,MAAM,iBAAiB,YAAY,WAAW,EAAE,MACvF;EAEA,KAAK,OAAO,gBAAgB,WAAW,aAAa;EAEpD,UAAU,IAAI,eAAe,KAAK,IAAI;EAEtC,MAAM,oBAAoB,KAAK,IAAI;EAKnC,WAHgBA,WAAO,IAAI,aAGV,CAAC;CACpB;;;;;;CAOA,MAAa,QAAuB;EAClC,MAAM,aAAaA,WAAO,IAAI,MAAM;EAEpC,IAAI,CAAC,cAAc,CAAC,KAAK,MAAM;EAE/B,IAAI,YAAY,oBAAoB,eAClC,OAAO,cAAc,KAAK,IAAI;OAE9B,OAAO,KAAK,KAAK,IAAI;EAGvB,IAAI;GAEF,MAAM,KAAK,KAAK,OAAO;IACrB,MAAM,WAAW;IACjB,MAAM,WAAW,QAAQ;GAC3B,CAAC;GAED,MAAM,UAAUA,WAAO,IAAI,aAAa;GAExC,IAAI,QAAQ,QAAQ,cAAc,mBAAmB,SAAS;EAChE,SAAS,OAAO;GACd,YAAY,oCAAoC,KAAK;GAErD,QAAQ,KAAK,CAAC;EAChB;EAEA,KAAK,SAAS;CAChB;;;;;;CAOA,MAAa,UAAyB;EACpC,MAAM,KAAK,SAAS;EACpB,MAAM,KAAK,KAAK;EAChB,MAAM,KAAK,MAAM;CACnB;;;;CAKA,MAAa,WAA0B;EACrC,IAAI,CAAC,KAAK,QACR;EAKF,AAFe,cAEV,GAAG,MAAM;EAEd,KAAK,SAAS;CAChB;;;;;;CAOA,AAAO,cAAc,cAAiC;EAEpD,OAAO,aAAa,MAAM,SAAS;GACjC,MAAM,eAAe,KAAK,QAAQ,OAAO,GAAG;GAC5C,OAAO,KAAK,aAAa,SAAS,YAAY;EAChD,CAAC;CACH;AACF"}
|
|
@@ -2,7 +2,7 @@ import { ConnectorLifecyclePhase, ConnectorPriority } from "./types.mjs";
|
|
|
2
2
|
import { BaseConnector } from "./base-connector.mjs";
|
|
3
3
|
import { setLogConfigurations } from "../logger/logger.mjs";
|
|
4
4
|
import "../logger/index.mjs";
|
|
5
|
-
import
|
|
5
|
+
import baseConfig from "@mongez/config";
|
|
6
6
|
import { log } from "@warlock.js/logger";
|
|
7
7
|
|
|
8
8
|
//#region ../../@warlock.js/core/src/connectors/logger-connector.ts
|
|
@@ -22,7 +22,7 @@ var LoggerConnector = class extends BaseConnector {
|
|
|
22
22
|
* Initialize logger configurations
|
|
23
23
|
*/
|
|
24
24
|
async start() {
|
|
25
|
-
const logConfig =
|
|
25
|
+
const logConfig = baseConfig.get("log");
|
|
26
26
|
if (!logConfig) return;
|
|
27
27
|
try {
|
|
28
28
|
setLogConfigurations(logConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger-connector.mjs","names":[],"sources":["../../../../../../@warlock.js/core/src/connectors/logger-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { log } from \"@warlock.js/logger\";\r\nimport { setLogConfigurations } from \"../logger\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\r\n\r\n/**\r\n * Logger Connector\r\n * Manages logger lifecycle and ensures synchronous flushing on termination\r\n */\r\nexport class LoggerConnector extends BaseConnector {\r\n public readonly name = \"logger\";\r\n public readonly priority = ConnectorPriority.LOGGER;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\r\n\r\n /**\r\n * Files that trigger logger restart\r\n */\r\n protected readonly watchedFiles = [\"src/config/log.ts\", \"src/config/log.tsx\"];\r\n\r\n /**\r\n * Initialize logger configurations\r\n */\r\n public async start(): Promise<void> {\r\n const logConfig = config.get(\"log\");\r\n\r\n if (!logConfig) {\r\n return;\r\n }\r\n\r\n try {\r\n setLogConfigurations(logConfig);\r\n this.active = true;\r\n } catch (error) {\r\n console.error(\"Failed to initialize logger:\", error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown logger and flush messages synchronously\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n try {\r\n log.flushSync();\r\n this.active = false;\r\n } catch (error) {\r\n console.error(\"Failed to flush logger:\", error);\r\n throw error;\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAUA,IAAa,kBAAb,cAAqC,cAAc;;;cAC1B;;;sBAOW,CAAC,qBAAqB,oBAAoB;;;;;CAK5E,MAAa,QAAuB;EAClC,MAAM,
|
|
1
|
+
{"version":3,"file":"logger-connector.mjs","names":["config"],"sources":["../../../../../../@warlock.js/core/src/connectors/logger-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { log } from \"@warlock.js/logger\";\r\nimport { setLogConfigurations } from \"../logger\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\r\n\r\n/**\r\n * Logger Connector\r\n * Manages logger lifecycle and ensures synchronous flushing on termination\r\n */\r\nexport class LoggerConnector extends BaseConnector {\r\n public readonly name = \"logger\";\r\n public readonly priority = ConnectorPriority.LOGGER;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\r\n\r\n /**\r\n * Files that trigger logger restart\r\n */\r\n protected readonly watchedFiles = [\"src/config/log.ts\", \"src/config/log.tsx\"];\r\n\r\n /**\r\n * Initialize logger configurations\r\n */\r\n public async start(): Promise<void> {\r\n const logConfig = config.get(\"log\");\r\n\r\n if (!logConfig) {\r\n return;\r\n }\r\n\r\n try {\r\n setLogConfigurations(logConfig);\r\n this.active = true;\r\n } catch (error) {\r\n console.error(\"Failed to initialize logger:\", error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown logger and flush messages synchronously\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n try {\r\n log.flushSync();\r\n this.active = false;\r\n } catch (error) {\r\n console.error(\"Failed to flush logger:\", error);\r\n throw error;\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAUA,IAAa,kBAAb,cAAqC,cAAc;;;cAC1B;;;sBAOW,CAAC,qBAAqB,oBAAoB;;;;;CAK5E,MAAa,QAAuB;EAClC,MAAM,YAAYA,WAAO,IAAI,KAAK;EAElC,IAAI,CAAC,WACH;EAGF,IAAI;GACF,qBAAqB,SAAS;GAC9B,KAAK,SAAS;EAChB,SAAS,OAAO;GACd,QAAQ,MAAM,gCAAgC,KAAK;GACnD,MAAM;EACR;CACF;;;;CAKA,MAAa,WAA0B;EACrC,IAAI,CAAC,KAAK,QACR;EAGF,IAAI;GACF,IAAI,UAAU;GACd,KAAK,SAAS;EAChB,SAAS,OAAO;GACd,QAAQ,MAAM,2BAA2B,KAAK;GAC9C,MAAM;EACR;CACF;AACF"}
|
|
@@ -3,7 +3,7 @@ import { BaseConnector } from "./base-connector.mjs";
|
|
|
3
3
|
import { setMailConfigurations } from "../mail/config.mjs";
|
|
4
4
|
import { closeAllMailers } from "../mail/mailer-pool.mjs";
|
|
5
5
|
import "../mail/index.mjs";
|
|
6
|
-
import
|
|
6
|
+
import baseConfig from "@mongez/config";
|
|
7
7
|
|
|
8
8
|
//#region ../../@warlock.js/core/src/connectors/mail-connector.ts
|
|
9
9
|
/**
|
|
@@ -26,7 +26,7 @@ var MailerConnector = class extends BaseConnector {
|
|
|
26
26
|
* Initialize mailer configurations
|
|
27
27
|
*/
|
|
28
28
|
async start() {
|
|
29
|
-
const mailConfig =
|
|
29
|
+
const mailConfig = baseConfig.get("mail");
|
|
30
30
|
if (!mailConfig) return;
|
|
31
31
|
try {
|
|
32
32
|
setMailConfigurations(mailConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mail-connector.mjs","names":[],"sources":["../../../../../../@warlock.js/core/src/connectors/mail-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { closeAllMailers, setMailConfigurations } from \"../mail\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\r\n\r\n/**\r\n * Mailer Connector\r\n * Manages mailer lifecycle and ensures graceful pool shutdown\r\n */\r\nexport class MailerConnector extends BaseConnector {\r\n public readonly name = \"mailer\";\r\n public readonly priority = ConnectorPriority.MAILER;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\r\n\r\n /**\r\n * Files that trigger mailer restart\r\n */\r\n protected readonly watchedFiles = [\".env\", \"src/config/mail.ts\", \"src/config/mail.tsx\"];\r\n\r\n /**\r\n * Initialize mailer configurations\r\n */\r\n public async start(): Promise<void> {\r\n const mailConfig = config.get(\"mail\");\r\n\r\n if (!mailConfig) {\r\n return;\r\n }\r\n\r\n try {\r\n setMailConfigurations(mailConfig);\r\n this.active = true;\r\n } catch (error) {\r\n console.error(\"Failed to initialize mailer:\", error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown mailer pool\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n try {\r\n closeAllMailers();\r\n this.active = false;\r\n } catch (error) {\r\n console.error(\"Failed to close all mailers:\", error);\r\n throw error;\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;AASA,IAAa,kBAAb,cAAqC,cAAc;;;cAC1B;;;sBAOW;GAAC;GAAQ;GAAsB;EAAqB;;;;;CAKtF,MAAa,QAAuB;EAClC,MAAM,
|
|
1
|
+
{"version":3,"file":"mail-connector.mjs","names":["config"],"sources":["../../../../../../@warlock.js/core/src/connectors/mail-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { closeAllMailers, setMailConfigurations } from \"../mail\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\r\n\r\n/**\r\n * Mailer Connector\r\n * Manages mailer lifecycle and ensures graceful pool shutdown\r\n */\r\nexport class MailerConnector extends BaseConnector {\r\n public readonly name = \"mailer\";\r\n public readonly priority = ConnectorPriority.MAILER;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\r\n\r\n /**\r\n * Files that trigger mailer restart\r\n */\r\n protected readonly watchedFiles = [\".env\", \"src/config/mail.ts\", \"src/config/mail.tsx\"];\r\n\r\n /**\r\n * Initialize mailer configurations\r\n */\r\n public async start(): Promise<void> {\r\n const mailConfig = config.get(\"mail\");\r\n\r\n if (!mailConfig) {\r\n return;\r\n }\r\n\r\n try {\r\n setMailConfigurations(mailConfig);\r\n this.active = true;\r\n } catch (error) {\r\n console.error(\"Failed to initialize mailer:\", error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown mailer pool\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n try {\r\n closeAllMailers();\r\n this.active = false;\r\n } catch (error) {\r\n console.error(\"Failed to close all mailers:\", error);\r\n throw error;\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;AASA,IAAa,kBAAb,cAAqC,cAAc;;;cAC1B;;;sBAOW;GAAC;GAAQ;GAAsB;EAAqB;;;;;CAKtF,MAAa,QAAuB;EAClC,MAAM,aAAaA,WAAO,IAAI,MAAM;EAEpC,IAAI,CAAC,YACH;EAGF,IAAI;GACF,sBAAsB,UAAU;GAChC,KAAK,SAAS;EAChB,SAAS,OAAO;GACd,QAAQ,MAAM,gCAAgC,KAAK;GACnD,MAAM;EACR;CACF;;;;CAKA,MAAa,WAA0B;EACrC,IAAI,CAAC,KAAK,QACR;EAGF,IAAI;GACF,gBAAgB;GAChB,KAAK,SAAS;EAChB,SAAS,OAAO;GACd,QAAQ,MAAM,gCAAgC,KAAK;GACnD,MAAM;EACR;CACF;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { container } from "../container/index.mjs";
|
|
2
2
|
import { ConnectorLifecyclePhase, ConnectorPriority } from "./types.mjs";
|
|
3
3
|
import { BaseConnector } from "./base-connector.mjs";
|
|
4
|
-
import
|
|
4
|
+
import baseConfig from "@mongez/config";
|
|
5
5
|
import { log } from "@warlock.js/logger";
|
|
6
6
|
import { createServer } from "http";
|
|
7
7
|
import { createServer as createServer$1 } from "https";
|
|
@@ -39,7 +39,7 @@ var SocketConnector = class extends BaseConnector {
|
|
|
39
39
|
* Boot the connector
|
|
40
40
|
*/
|
|
41
41
|
async boot() {
|
|
42
|
-
const socketConfig =
|
|
42
|
+
const socketConfig = baseConfig.get("socket");
|
|
43
43
|
if (!socketConfig) return;
|
|
44
44
|
let SocketServer;
|
|
45
45
|
try {
|
|
@@ -62,7 +62,7 @@ var SocketConnector = class extends BaseConnector {
|
|
|
62
62
|
* Initialize Socket server
|
|
63
63
|
*/
|
|
64
64
|
async start() {
|
|
65
|
-
if (!
|
|
65
|
+
if (!baseConfig.get("socket") || !this.socket) return;
|
|
66
66
|
log.success("socket", "connection", "Established Socket.IO server");
|
|
67
67
|
this.active = true;
|
|
68
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-connector.mjs","names":["createHttpsServer","createHttpServer"],"sources":["../../../../../../@warlock.js/core/src/connectors/socket-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { log } from \"@warlock.js/logger\";\r\nimport { createServer as createHttpServer } from \"http\";\r\nimport { createServer as createHttpsServer } from \"https\";\r\nimport type { Server } from \"socket.io\";\r\nimport { container } from \"../container\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorName, ConnectorPriority } from \"./types\";\r\n\r\n/**\r\n * Shown when a project enables sockets (a `socket` config is present) but the\r\n * optional `socket.io` peer is not installed.\r\n */\r\nconst SOCKET_INSTALL_INSTRUCTIONS = `\r\nRealtime socket server requires the socket.io package.\r\nInstall it with:\r\n\r\n warlock add socket\r\n\r\nOr manually:\r\n\r\n npm install socket.io\r\n pnpm add socket.io\r\n yarn add socket.io\r\n`.trim();\r\n\r\n/**\r\n * Socket Connector\r\n * Manages Socket server (Socket.IO) lifecycle\r\n */\r\nexport class SocketConnector extends BaseConnector {\r\n public readonly name: ConnectorName = \"socket\";\r\n public readonly priority = ConnectorPriority.SOCKET;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Late;\r\n\r\n /**\r\n * Files that trigger Socket server restart\r\n * Note: routes.ts changes will be handled by HMR with wildcard routing\r\n * Connectors receive config file paths directly (not .env) thanks to layer-executor\r\n */\r\n protected readonly watchedFiles = [\"src/config/socket.ts\"];\r\n\r\n protected socket?: Server;\r\n\r\n /**\r\n * Boot the connector\r\n */\r\n public async boot() {\r\n const socketConfig = config.get(\"socket\");\r\n\r\n if (!socketConfig) return;\r\n\r\n // socket.io is an optional peer — load it lazily so projects that don't use\r\n // realtime sockets never need it installed (mirrors the mail/storage drivers).\r\n let SocketServer: typeof import(\"socket.io\").Server;\r\n try {\r\n ({ Server: SocketServer } = await import(\"socket.io\"));\r\n } catch {\r\n throw new Error(SOCKET_INSTALL_INSTRUCTIONS);\r\n }\r\n\r\n log.info(\"socket\", \"connection\", \"Starting Socket.IO server\");\r\n\r\n // now we have two cases\r\n // 1. http is used, then use it\r\n // 2. http is not used, then create a new server\r\n let server;\r\n if (container.has(\"http.server\")) {\r\n const fastify = container.get(\"http.server\");\r\n server = fastify.server;\r\n } else {\r\n server = socketConfig.ssl ? createHttpsServer() : createHttpServer();\r\n server.listen(socketConfig.port);\r\n }\r\n\r\n container.set(\"socket.rawServer\", server);\r\n\r\n this.socket = new SocketServer(server, socketConfig.options);\r\n\r\n container.set(\"socket\", this.socket);\r\n }\r\n\r\n /**\r\n * Initialize Socket server\r\n */\r\n public async start(): Promise<void> {\r\n const socketConfig = config.get(\"socket\");\r\n\r\n // `this.socket` is only set by boot() once a socket config is present —\r\n // use it (not a never-assigned field) to detect a successful boot.\r\n if (!socketConfig || !this.socket) return;\r\n\r\n log.success(\"socket\", \"connection\", \"Established Socket.IO server\");\r\n\r\n this.active = true;\r\n }\r\n\r\n /**\r\n * Shutdown HTTP server\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n if (container.has(\"socket\")) {\r\n const socket = container.get(\"socket\");\r\n socket.close();\r\n }\r\n\r\n if (container.has(\"socket.rawServer\")) {\r\n const server = container.get(\"socket.rawServer\");\r\n server.close();\r\n }\r\n\r\n this.active = false;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,8BAA8B;;;;;;;;;;;EAWlC,KAAK;;;;;AAMP,IAAa,kBAAb,cAAqC,cAAc;;;cACX;;;sBASJ,CAAC,sBAAsB;;;;;CAOzD,MAAa,OAAO;EAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"socket-connector.mjs","names":["config","createHttpsServer","createHttpServer"],"sources":["../../../../../../@warlock.js/core/src/connectors/socket-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { log } from \"@warlock.js/logger\";\r\nimport { createServer as createHttpServer } from \"http\";\r\nimport { createServer as createHttpsServer } from \"https\";\r\nimport type { Server } from \"socket.io\";\r\nimport { container } from \"../container\";\r\nimport { BaseConnector } from \"./base-connector\";\r\nimport { ConnectorLifecyclePhase, ConnectorName, ConnectorPriority } from \"./types\";\r\n\r\n/**\r\n * Shown when a project enables sockets (a `socket` config is present) but the\r\n * optional `socket.io` peer is not installed.\r\n */\r\nconst SOCKET_INSTALL_INSTRUCTIONS = `\r\nRealtime socket server requires the socket.io package.\r\nInstall it with:\r\n\r\n warlock add socket\r\n\r\nOr manually:\r\n\r\n npm install socket.io\r\n pnpm add socket.io\r\n yarn add socket.io\r\n`.trim();\r\n\r\n/**\r\n * Socket Connector\r\n * Manages Socket server (Socket.IO) lifecycle\r\n */\r\nexport class SocketConnector extends BaseConnector {\r\n public readonly name: ConnectorName = \"socket\";\r\n public readonly priority = ConnectorPriority.SOCKET;\r\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Late;\r\n\r\n /**\r\n * Files that trigger Socket server restart\r\n * Note: routes.ts changes will be handled by HMR with wildcard routing\r\n * Connectors receive config file paths directly (not .env) thanks to layer-executor\r\n */\r\n protected readonly watchedFiles = [\"src/config/socket.ts\"];\r\n\r\n protected socket?: Server;\r\n\r\n /**\r\n * Boot the connector\r\n */\r\n public async boot() {\r\n const socketConfig = config.get(\"socket\");\r\n\r\n if (!socketConfig) return;\r\n\r\n // socket.io is an optional peer — load it lazily so projects that don't use\r\n // realtime sockets never need it installed (mirrors the mail/storage drivers).\r\n let SocketServer: typeof import(\"socket.io\").Server;\r\n try {\r\n ({ Server: SocketServer } = await import(\"socket.io\"));\r\n } catch {\r\n throw new Error(SOCKET_INSTALL_INSTRUCTIONS);\r\n }\r\n\r\n log.info(\"socket\", \"connection\", \"Starting Socket.IO server\");\r\n\r\n // now we have two cases\r\n // 1. http is used, then use it\r\n // 2. http is not used, then create a new server\r\n let server;\r\n if (container.has(\"http.server\")) {\r\n const fastify = container.get(\"http.server\");\r\n server = fastify.server;\r\n } else {\r\n server = socketConfig.ssl ? createHttpsServer() : createHttpServer();\r\n server.listen(socketConfig.port);\r\n }\r\n\r\n container.set(\"socket.rawServer\", server);\r\n\r\n this.socket = new SocketServer(server, socketConfig.options);\r\n\r\n container.set(\"socket\", this.socket);\r\n }\r\n\r\n /**\r\n * Initialize Socket server\r\n */\r\n public async start(): Promise<void> {\r\n const socketConfig = config.get(\"socket\");\r\n\r\n // `this.socket` is only set by boot() once a socket config is present —\r\n // use it (not a never-assigned field) to detect a successful boot.\r\n if (!socketConfig || !this.socket) return;\r\n\r\n log.success(\"socket\", \"connection\", \"Established Socket.IO server\");\r\n\r\n this.active = true;\r\n }\r\n\r\n /**\r\n * Shutdown HTTP server\r\n */\r\n public async shutdown(): Promise<void> {\r\n if (!this.active) {\r\n return;\r\n }\r\n\r\n if (container.has(\"socket\")) {\r\n const socket = container.get(\"socket\");\r\n socket.close();\r\n }\r\n\r\n if (container.has(\"socket.rawServer\")) {\r\n const server = container.get(\"socket.rawServer\");\r\n server.close();\r\n }\r\n\r\n this.active = false;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,8BAA8B;;;;;;;;;;;EAWlC,KAAK;;;;;AAMP,IAAa,kBAAb,cAAqC,cAAc;;;cACX;;;sBASJ,CAAC,sBAAsB;;;;;CAOzD,MAAa,OAAO;EAClB,MAAM,eAAeA,WAAO,IAAI,QAAQ;EAExC,IAAI,CAAC,cAAc;EAInB,IAAI;EACJ,IAAI;GACF,CAAC,CAAE,QAAQ,gBAAiB,MAAM,OAAO;EAC3C,QAAQ;GACN,MAAM,IAAI,MAAM,2BAA2B;EAC7C;EAEA,IAAI,KAAK,UAAU,cAAc,2BAA2B;EAK5D,IAAI;EACJ,IAAI,UAAU,IAAI,aAAa,GAE7B,SADgB,UAAU,IAAI,aACf,EAAE;OACZ;GACL,SAAS,aAAa,MAAMC,eAAkB,IAAIC,aAAiB;GACnE,OAAO,OAAO,aAAa,IAAI;EACjC;EAEA,UAAU,IAAI,oBAAoB,MAAM;EAExC,KAAK,SAAS,IAAI,aAAa,QAAQ,aAAa,OAAO;EAE3D,UAAU,IAAI,UAAU,KAAK,MAAM;CACrC;;;;CAKA,MAAa,QAAuB;EAKlC,IAAI,CAJiBF,WAAO,IAAI,QAIhB,KAAK,CAAC,KAAK,QAAQ;EAEnC,IAAI,QAAQ,UAAU,cAAc,8BAA8B;EAElE,KAAK,SAAS;CAChB;;;;CAKA,MAAa,WAA0B;EACrC,IAAI,CAAC,KAAK,QACR;EAGF,IAAI,UAAU,IAAI,QAAQ,GAExB,AADe,UAAU,IAAI,QACxB,EAAE,MAAM;EAGf,IAAI,UAAU,IAAI,kBAAkB,GAElC,AADe,UAAU,IAAI,kBACxB,EAAE,MAAM;EAGf,KAAK,SAAS;CAChB;AACF"}
|
|
@@ -26,7 +26,7 @@ import { Worker } from "worker_threads";
|
|
|
26
26
|
*/
|
|
27
27
|
function createWorker(workerPath, baseUrl, options) {
|
|
28
28
|
const isDevServerCore = env("DEV_SERVER_CORE");
|
|
29
|
-
const workerFilePath = fileURLToPath(new URL(`${workerPath}${isDevServerCore ? ".ts" : ".
|
|
29
|
+
const workerFilePath = fileURLToPath(new URL(`${workerPath}${isDevServerCore ? ".ts" : ".mjs"}`, baseUrl));
|
|
30
30
|
const workerOptions = { ...options };
|
|
31
31
|
if (isDevServerCore) workerOptions.execArgv = [
|
|
32
32
|
...options?.execArgv || [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-worker.mjs","names":[],"sources":["../../../../../../@warlock.js/core/src/dev-server/create-worker.ts"],"sourcesContent":["import { env } from \"@mongez/dotenv\";\nimport { fileURLToPath } from \"url\";\nimport { Worker, type WorkerOptions } from \"worker_threads\";\n\n/**\n * Options for creating a health check worker\n */\nexport type CreateWorkerOptions = WorkerOptions & {\n /**\n * Worker data to pass to the worker thread\n */\n workerData?: Record<string, unknown>;\n};\n\n/**\n * Create a worker that works in both dev (TypeScript) and production (JavaScript) environments.\n *\n * In development mode (DEV_SERVER_CORE env set), workers are loaded with tsx\n * to support TypeScript execution. In production, compiled .js files are used.\n *\n * @param workerPath - Relative path to worker file WITHOUT extension (e.g., \"./workers/ts-health.worker\")\n * @param baseUrl - The import.meta.url of the calling module (used to resolve relative paths)\n * @param options - Additional worker options\n * @returns A new Worker instance\n *\n * @example\n * ```typescript\n * // In FilesHealthcareManager\n * const worker = createWorker(\n * \"./workers/ts-health.worker\",\n * import.meta.url,\n * { workerData: { cwd: process.cwd() } }\n * );\n * ```\n */\nexport function createWorker(\n workerPath: string,\n baseUrl: string,\n options?: CreateWorkerOptions,\n): Worker {\n const isDevServerCore = env(\"DEV_SERVER_CORE\");\n\n // In dev: .ts file with tsx loader
|
|
1
|
+
{"version":3,"file":"create-worker.mjs","names":[],"sources":["../../../../../../@warlock.js/core/src/dev-server/create-worker.ts"],"sourcesContent":["import { env } from \"@mongez/dotenv\";\nimport { fileURLToPath } from \"url\";\nimport { Worker, type WorkerOptions } from \"worker_threads\";\n\n/**\n * Options for creating a health check worker\n */\nexport type CreateWorkerOptions = WorkerOptions & {\n /**\n * Worker data to pass to the worker thread\n */\n workerData?: Record<string, unknown>;\n};\n\n/**\n * Create a worker that works in both dev (TypeScript) and production (JavaScript) environments.\n *\n * In development mode (DEV_SERVER_CORE env set), workers are loaded with tsx\n * to support TypeScript execution. In production, compiled .js files are used.\n *\n * @param workerPath - Relative path to worker file WITHOUT extension (e.g., \"./workers/ts-health.worker\")\n * @param baseUrl - The import.meta.url of the calling module (used to resolve relative paths)\n * @param options - Additional worker options\n * @returns A new Worker instance\n *\n * @example\n * ```typescript\n * // In FilesHealthcareManager\n * const worker = createWorker(\n * \"./workers/ts-health.worker\",\n * import.meta.url,\n * { workerData: { cwd: process.cwd() } }\n * );\n * ```\n */\nexport function createWorker(\n workerPath: string,\n baseUrl: string,\n options?: CreateWorkerOptions,\n): Worker {\n const isDevServerCore = env(\"DEV_SERVER_CORE\");\n\n // In dev (running core from source): .ts file with tsx loader.\n // When published, core ships ESM modules with the .mjs extension (preserveModules).\n const extension = isDevServerCore ? \".ts\" : \".mjs\";\n const workerUrl = new URL(`${workerPath}${extension}`, baseUrl);\n const workerFilePath = fileURLToPath(workerUrl);\n\n const workerOptions: WorkerOptions = {\n ...options,\n };\n\n // Add tsx loader for TypeScript in dev environment\n if (isDevServerCore) {\n workerOptions.execArgv = [...(options?.execArgv || []), \"--import\", \"tsx/esm\"];\n }\n\n return new Worker(workerFilePath, workerOptions);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,aACd,YACA,SACA,SACQ;CACR,MAAM,kBAAkB,IAAI,iBAAiB;CAM7C,MAAM,iBAAiB,cAAc,IADf,IAAI,GAAG,aADX,kBAAkB,QAAQ,UACW,OACV,CAAC;CAE9C,MAAM,gBAA+B,EACnC,GAAG,QACL;CAGA,IAAI,iBACF,cAAc,WAAW;EAAC,GAAI,SAAS,YAAY,CAAC;EAAI;EAAY;CAAS;CAG/E,OAAO,IAAI,OAAO,gBAAgB,aAAa;AACjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { TranspileInit, load } from "./load-hook.mjs";
|
|
2
|
+
import { resolve } from "./resolve-hook.mjs";
|
|
3
|
+
import { MessagePort } from "node:worker_threads";
|
|
4
|
+
|
|
5
|
+
//#region ../../@warlock.js/core/src/dev-server/loader/hook-thread.d.ts
|
|
6
|
+
type InitializeData = {
|
|
7
|
+
port: MessagePort;
|
|
8
|
+
srcRoot: string; /** Transpile config (always present — esbuild transpile is unconditional). */
|
|
9
|
+
transpile: TranspileInit;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* ESM loader hook entry-point.
|
|
13
|
+
*
|
|
14
|
+
* Node's `module.register()` runs this file in a dedicated worker thread.
|
|
15
|
+
* The three exported functions (`initialize`, `resolve`, `load`) are the
|
|
16
|
+
* official hook lifecycle callbacks:
|
|
17
|
+
*
|
|
18
|
+
* - `initialize` — runs once when the hook worker starts; receives the data
|
|
19
|
+
* passed as `{ data }` to `module.register()`. We use it to configure the
|
|
20
|
+
* source-root filter and to wire the `MessageChannel` port that the main
|
|
21
|
+
* thread uses to push version-bump notifications.
|
|
22
|
+
*
|
|
23
|
+
* - `resolve` — intercepts every `import` specifier resolution. The
|
|
24
|
+
* framework's own resolver handles tsconfig `paths` + TS extension/index
|
|
25
|
+
* probing; npm/`node:` fall through to Node default. Stamps a `?v=<N>`
|
|
26
|
+
* version token onto tracked `src/` source-file URLs.
|
|
27
|
+
*
|
|
28
|
+
* - `load` — transpiles every `.ts`/`.tsx` with esbuild (content-hash
|
|
29
|
+
* cached); non-TypeScript falls through to the Node default loader.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Main thread (register-loader.ts):
|
|
33
|
+
* const { port1, port2 } = new MessageChannel();
|
|
34
|
+
* module.register(hookBundleUrl, import.meta.url, {
|
|
35
|
+
* data: { port: port2, srcRoot: "/abs/path/to/src" },
|
|
36
|
+
* transferList: [port2],
|
|
37
|
+
* });
|
|
38
|
+
* // File watcher later:
|
|
39
|
+
* port1.postMessage({ type: "bump", absolutePath: "/abs/path/to/user.model.ts" });
|
|
40
|
+
*/
|
|
41
|
+
declare function initialize({
|
|
42
|
+
port,
|
|
43
|
+
srcRoot,
|
|
44
|
+
transpile
|
|
45
|
+
}: InitializeData): void;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { initialize, load, resolve };
|
|
48
|
+
//# sourceMappingURL=hook-thread.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-thread.d.mts","names":[],"sources":["../../../../../../../@warlock.js/core/src/dev-server/loader/hook-thread.ts"],"mappings":";;;;;KAKK,cAAA;EACH,IAAA,EAAM,WAAA;EACN,OAAA,UAFiB;EAIjB,SAAA,EAAW,aAAa;AAAA;;;;;;;AAAA;AAiC1B;;;;;;;;;;;;;;;;;AAAuE;;;;;;iBAAvD,UAAA,CAAA;EAAa,IAAA;EAAM,OAAA;EAAS;AAAA,GAAa,cAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { configureTranspile, load } from "./load-hook.mjs";
|
|
2
|
+
import { bumpVersion } from "./version-registry.mjs";
|
|
3
|
+
import { resolve, setSrcRoot } from "./resolve-hook.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../../@warlock.js/core/src/dev-server/loader/hook-thread.ts
|
|
6
|
+
/**
|
|
7
|
+
* ESM loader hook entry-point.
|
|
8
|
+
*
|
|
9
|
+
* Node's `module.register()` runs this file in a dedicated worker thread.
|
|
10
|
+
* The three exported functions (`initialize`, `resolve`, `load`) are the
|
|
11
|
+
* official hook lifecycle callbacks:
|
|
12
|
+
*
|
|
13
|
+
* - `initialize` — runs once when the hook worker starts; receives the data
|
|
14
|
+
* passed as `{ data }` to `module.register()`. We use it to configure the
|
|
15
|
+
* source-root filter and to wire the `MessageChannel` port that the main
|
|
16
|
+
* thread uses to push version-bump notifications.
|
|
17
|
+
*
|
|
18
|
+
* - `resolve` — intercepts every `import` specifier resolution. The
|
|
19
|
+
* framework's own resolver handles tsconfig `paths` + TS extension/index
|
|
20
|
+
* probing; npm/`node:` fall through to Node default. Stamps a `?v=<N>`
|
|
21
|
+
* version token onto tracked `src/` source-file URLs.
|
|
22
|
+
*
|
|
23
|
+
* - `load` — transpiles every `.ts`/`.tsx` with esbuild (content-hash
|
|
24
|
+
* cached); non-TypeScript falls through to the Node default loader.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Main thread (register-loader.ts):
|
|
28
|
+
* const { port1, port2 } = new MessageChannel();
|
|
29
|
+
* module.register(hookBundleUrl, import.meta.url, {
|
|
30
|
+
* data: { port: port2, srcRoot: "/abs/path/to/src" },
|
|
31
|
+
* transferList: [port2],
|
|
32
|
+
* });
|
|
33
|
+
* // File watcher later:
|
|
34
|
+
* port1.postMessage({ type: "bump", absolutePath: "/abs/path/to/user.model.ts" });
|
|
35
|
+
*/
|
|
36
|
+
function initialize({ port, srcRoot, transpile }) {
|
|
37
|
+
setSrcRoot(srcRoot);
|
|
38
|
+
configureTranspile(transpile);
|
|
39
|
+
port.on("message", ({ type, absolutePath }) => {
|
|
40
|
+
if (type === "bump") bumpVersion(absolutePath);
|
|
41
|
+
else if (type === "sync") port.postMessage({ type: "sync-ack" });
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { initialize, load, resolve };
|
|
47
|
+
//# sourceMappingURL=hook-thread.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-thread.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/dev-server/loader/hook-thread.ts"],"sourcesContent":["import type { MessagePort } from \"node:worker_threads\";\nimport { configureTranspile, load, type TranspileInit } from \"./load-hook.js\";\nimport { resolve, setSrcRoot } from \"./resolve-hook.js\";\nimport { bumpVersion } from \"./version-registry.js\";\n\ntype InitializeData = {\n port: MessagePort;\n srcRoot: string;\n /** Transpile config (always present — esbuild transpile is unconditional). */\n transpile: TranspileInit;\n};\n\n/**\n * ESM loader hook entry-point.\n *\n * Node's `module.register()` runs this file in a dedicated worker thread.\n * The three exported functions (`initialize`, `resolve`, `load`) are the\n * official hook lifecycle callbacks:\n *\n * - `initialize` — runs once when the hook worker starts; receives the data\n * passed as `{ data }` to `module.register()`. We use it to configure the\n * source-root filter and to wire the `MessageChannel` port that the main\n * thread uses to push version-bump notifications.\n *\n * - `resolve` — intercepts every `import` specifier resolution. The\n * framework's own resolver handles tsconfig `paths` + TS extension/index\n * probing; npm/`node:` fall through to Node default. Stamps a `?v=<N>`\n * version token onto tracked `src/` source-file URLs.\n *\n * - `load` — transpiles every `.ts`/`.tsx` with esbuild (content-hash\n * cached); non-TypeScript falls through to the Node default loader.\n *\n * @example\n * // Main thread (register-loader.ts):\n * const { port1, port2 } = new MessageChannel();\n * module.register(hookBundleUrl, import.meta.url, {\n * data: { port: port2, srcRoot: \"/abs/path/to/src\" },\n * transferList: [port2],\n * });\n * // File watcher later:\n * port1.postMessage({ type: \"bump\", absolutePath: \"/abs/path/to/user.model.ts\" });\n */\nexport function initialize({ port, srcRoot, transpile }: InitializeData): void {\n setSrcRoot(srcRoot);\n configureTranspile(transpile);\n\n port.on(\"message\", ({ type, absolutePath }: { type: string; absolutePath: string }) => {\n if (type === \"bump\") {\n bumpVersion(absolutePath);\n } else if (type === \"sync\") {\n port.postMessage({ type: \"sync-ack\" });\n }\n });\n}\n\nexport { load, resolve };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,WAAW,EAAE,MAAM,SAAS,aAAmC;CAC7E,WAAW,OAAO;CAClB,mBAAmB,SAAS;CAE5B,KAAK,GAAG,YAAY,EAAE,MAAM,mBAA2D;EACrF,IAAI,SAAS,QACX,YAAY,YAAY;OACnB,IAAI,SAAS,QAClB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;CAEzC,CAAC;AACH"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region ../../@warlock.js/core/src/dev-server/loader/load-hook.d.ts
|
|
2
|
+
type LoadContext = {
|
|
3
|
+
format?: string;
|
|
4
|
+
importAttributes?: Record<string, string>;
|
|
5
|
+
};
|
|
6
|
+
type LoadResult = {
|
|
7
|
+
format: string;
|
|
8
|
+
source: string | Buffer;
|
|
9
|
+
shortCircuit?: boolean;
|
|
10
|
+
};
|
|
11
|
+
type NextLoad = (url: string, context?: LoadContext) => Promise<LoadResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Everything the transpile path needs, computed once on the main thread and
|
|
14
|
+
* shipped into the hook worker via `initialize()`. Always present — esbuild
|
|
15
|
+
* transpile is unconditional now (tsx is no longer in the TS path).
|
|
16
|
+
*/
|
|
17
|
+
type TranspileInit = {
|
|
18
|
+
/** Absolute `.warlock/transpile` directory. */cacheDir: string; /** Source-content key salt: esbuild version + epoch + tsconfig blob. */
|
|
19
|
+
fingerprint: string; /** esbuild `target` (e.g. `"node22"` — must match the prod builder). */
|
|
20
|
+
target: string; /** JSON string of `{ compilerOptions }` handed to esbuild as tsconfigRaw. */
|
|
21
|
+
tsconfigRaw: string;
|
|
22
|
+
/**
|
|
23
|
+
* Debug-only: name cache files `<slug>.<hash>.js` and append a trailing
|
|
24
|
+
* `// @source <path>` marker so entries are eyeball-identifiable. Off by
|
|
25
|
+
* default (opaque `<hash>.js`). Cosmetic — never affects keys or lookup.
|
|
26
|
+
*/
|
|
27
|
+
debugNames: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* ESM loader `load()` hook.
|
|
31
|
+
*
|
|
32
|
+
* Owns the transpile for **every** TypeScript file — project `src/`,
|
|
33
|
+
* `@warlock.js/*` framework source, and `warlock.config.ts` alike. There
|
|
34
|
+
* is no tsx in the TypeScript path any more: we read the source, key it by
|
|
35
|
+
* a content hash + options fingerprint, serve the cached JS on a hit, and
|
|
36
|
+
* otherwise transform it with esbuild directly and persist. Non-TypeScript
|
|
37
|
+
* URLs (npm `.js`/`.cjs`/`.mjs`, `node:` builtins, JSON) are not ours —
|
|
38
|
+
* they fall through to the next loader (Node's default).
|
|
39
|
+
*
|
|
40
|
+
* The `?v=<N>` query drives Node's module identity (HMR) for `src/` files
|
|
41
|
+
* and is **never** part of the cache key — the cache is keyed purely by
|
|
42
|
+
* source content, so the two mechanisms are fully orthogonal. Framework
|
|
43
|
+
* and config `.ts` carry no `?v` (no HMR) but are transpiled and cached
|
|
44
|
+
* exactly the same way.
|
|
45
|
+
*
|
|
46
|
+
* The source map esbuild emits is inline base64 with `sourcefile` set to
|
|
47
|
+
* the clean absolute `.ts` path, so V8 (run with source maps enabled)
|
|
48
|
+
* reports stack frames at the original TypeScript location.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // load("file:///src/user.model.ts?v=3") → esbuild transpile + cache
|
|
52
|
+
* // load("file:///@warlock.js/core/src/x.ts") → esbuild transpile + cache
|
|
53
|
+
* // load("file:///node_modules/ms/index.js") → nextLoad (Node default)
|
|
54
|
+
*/
|
|
55
|
+
declare function load(url: string, context: LoadContext, nextLoad: NextLoad): Promise<LoadResult>;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { TranspileInit, load };
|
|
58
|
+
//# sourceMappingURL=load-hook.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-hook.d.mts","names":[],"sources":["../../../../../../../@warlock.js/core/src/dev-server/loader/load-hook.ts"],"mappings":";KAMK,WAAA;EACH,MAAA;EACA,gBAAA,GAAmB,MAAM;AAAA;AAAA,KAGtB,UAAA;EACH,MAAA;EACA,MAAA,WAAiB,MAAM;EACvB,YAAA;AAAA;AAAA,KAGG,QAAA,IAAY,GAAA,UAAa,OAAA,GAAU,WAAA,KAAgB,OAAA,CAAQ,UAAA;AATrC;;;;;AAAA,KAgBf,aAAA;EAXO,+CAajB,QAAA,UAZY;EAcZ,WAAA,UAXG;EAaH,MAAA;EAEA,WAAA;EAf8D;;;;;EAqB9D,UAAA;AAAA;;;;;;;;;AAAU;AAqDZ;;;;;;;;;;;;;;;;;iBAAsB,IAAA,CACpB,GAAA,UACA,OAAA,EAAS,WAAA,EACT,QAAA,EAAU,QAAA,GACT,OAAA,CAAQ,UAAA"}
|