@zintrust/core 0.4.10 → 0.4.11
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/package.json +1 -1
- package/src/boot/registry/registerRoute.d.ts +1 -1
- package/src/boot/registry/registerRoute.d.ts.map +1 -1
- package/src/boot/registry/registerRoute.js +7 -2
- package/src/cli/commands/RoutesCommand.d.ts.map +1 -1
- package/src/cli/commands/RoutesCommand.js +6 -2
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +5 -1
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +2 -0
- package/src/cli/utils/EnvFileLoader.d.ts +2 -1
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
- package/src/cli/utils/EnvFileLoader.js +23 -7
- package/src/cli/utils/spawn.d.ts.map +1 -1
- package/src/cli/utils/spawn.js +11 -1
- package/src/index.js +3 -3
- package/src/microservices/ServiceManifest.d.ts +13 -0
- package/src/microservices/ServiceManifest.d.ts.map +1 -1
- package/src/microservices/ServiceManifest.js +27 -0
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type IRouter } from '../../routes/Router';
|
|
2
2
|
export declare const isCompiledJsModule: () => boolean;
|
|
3
3
|
export declare const tryImportOptional: <T>(modulePath: string) => Promise<T | undefined>;
|
|
4
4
|
export declare const tryImportOptionalR: <T>(modulePath: string) => Promise<T | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerRoute.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/registerRoute.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"registerRoute.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/registerRoute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAW3D,eAAO,MAAM,kBAAkB,QAAO,OAKrC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAU,CAAC,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAMpF,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAU,CAAC,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAOrF,CAAC;AA0FF,eAAO,MAAM,oBAAoB,GAC/B,kBAAkB,MAAM,EACxB,QAAQ,OAAO,KACd,OAAO,CAAC,IAAI,CAoBd,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { appConfig } from '../../config/index.js';
|
|
2
2
|
import Logger from '../../config/logger.js';
|
|
3
|
+
import { Router } from '../../routes/Router.js';
|
|
3
4
|
import { isObject } from '../../helper/index.js';
|
|
5
|
+
import { getServicePrefix } from '../../microservices/ServiceManifest.js';
|
|
4
6
|
import * as path from '../../node-singletons/path.js';
|
|
5
7
|
import { pathToFileURL } from '../../node-singletons/url.js';
|
|
6
8
|
import { detectRuntime } from '../../runtime/detectRuntime.js';
|
|
@@ -72,8 +74,11 @@ const registerManifestRoutes = async (router) => {
|
|
|
72
74
|
try {
|
|
73
75
|
// eslint-disable-next-line no-await-in-loop
|
|
74
76
|
const mod = await entry.loadRoutes();
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
const registerRoutes = isObject(mod) ? mod.registerRoutes : undefined;
|
|
78
|
+
if (typeof registerRoutes === 'function') {
|
|
79
|
+
Router.group(router, getServicePrefix(entry), (scopedRouter) => {
|
|
80
|
+
registerRoutes(scopedRouter);
|
|
81
|
+
});
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
84
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutesCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/RoutesCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"RoutesCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/RoutesCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA2VvF,eAAO,MAAM,aAAa;cACd,YAAY;EAatB,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -7,6 +7,7 @@ import { Env } from '../../config/env.js';
|
|
|
7
7
|
import { Router } from '../../routes/Router.js';
|
|
8
8
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
9
9
|
import { isObject } from '../../helper/index.js';
|
|
10
|
+
import { getServicePrefix } from '../../microservices/ServiceManifest.js';
|
|
10
11
|
import { ProjectRuntime } from '../../runtime/ProjectRuntime.js';
|
|
11
12
|
const parseGroupBy = (value) => {
|
|
12
13
|
const raw = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
@@ -180,8 +181,11 @@ const registerManifestRoutes = async (router) => {
|
|
|
180
181
|
const beforeCount = Router.getRoutes(router).length;
|
|
181
182
|
// eslint-disable-next-line no-await-in-loop
|
|
182
183
|
const mod = await entry.loadRoutes();
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
const registerRoutes = isObject(mod) ? mod.registerRoutes : undefined;
|
|
185
|
+
if (typeof registerRoutes === 'function') {
|
|
186
|
+
Router.group(router, getServicePrefix(entry), (scopedRouter) => {
|
|
187
|
+
registerRoutes(scopedRouter);
|
|
188
|
+
});
|
|
185
189
|
annotateManifestRoutes(router, beforeCount, entry.id);
|
|
186
190
|
}
|
|
187
191
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/StartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"StartCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/StartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgtBvF,eAAO,MAAM,YAAY;cACb,YAAY;EA6BtB,CAAC"}
|
|
@@ -210,6 +210,10 @@ const buildStartEnv = (projectRoot) => ({
|
|
|
210
210
|
...process.env,
|
|
211
211
|
ZINTRUST_PROJECT_ROOT: projectRoot,
|
|
212
212
|
});
|
|
213
|
+
const ensureStartEnvLoaded = (context) => {
|
|
214
|
+
const extraCwds = context.cwd === context.projectRoot ? [] : [context.cwd];
|
|
215
|
+
EnvFileLoader.ensureLoaded({ cwd: context.projectRoot, extraCwds });
|
|
216
|
+
};
|
|
213
217
|
const isFrameworkRepo = (packageJson) => packageJson.name === '@zintrust/core';
|
|
214
218
|
const hasDevScript = (packageJson) => {
|
|
215
219
|
const scripts = packageJson.scripts;
|
|
@@ -479,7 +483,7 @@ const executeSplitStart = async (cmd, context, _options) => {
|
|
|
479
483
|
const executeStart = async (options, cmd) => {
|
|
480
484
|
const cwd = process.cwd();
|
|
481
485
|
const context = resolveStartContext(cwd);
|
|
482
|
-
|
|
486
|
+
ensureStartEnvLoaded(context);
|
|
483
487
|
const mode = resolveMode(options);
|
|
484
488
|
const port = resolvePort(options);
|
|
485
489
|
const runtime = resolveRuntime(options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceScaffolder.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ServiceScaffolder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IACjC,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,MA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,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB;AAUD;;GAEG;AAEH;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAuB7F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAGnF;AAED;;GAEG;AAEH,wBAAgB,QAAQ,CACtB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,qBAAqB,CAAC,CAiDhC;AAgcD,eAAO,MAAM,iBAAiB;;;;EAI5B,CAAC"}
|
|
@@ -107,6 +107,7 @@ export const serviceManifest: ReadonlyArray<ServiceManifestEntry> = [
|
|
|
107
107
|
id: '${serviceId}',
|
|
108
108
|
domain: '${domain}',
|
|
109
109
|
name: '${options.name}',
|
|
110
|
+
prefix: '${serviceId}',
|
|
110
111
|
port: ${options.port ?? 3001},
|
|
111
112
|
monolithEnabled: true,
|
|
112
113
|
loadRoutes: async () => ${routeImportExpression},
|
|
@@ -147,6 +148,7 @@ function updateServiceManifest(projectRoot, options) {
|
|
|
147
148
|
id: '${serviceId}',
|
|
148
149
|
domain: '${domain}',
|
|
149
150
|
name: '${options.name}',
|
|
151
|
+
prefix: '${serviceId}',
|
|
150
152
|
port: ${options.port ?? 3001},
|
|
151
153
|
monolithEnabled: true,
|
|
152
154
|
loadRoutes: async () => ${routeImportExpression},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
type node_env = 'development' | 'production' | 'testing';
|
|
2
2
|
type LoadOptions = {
|
|
3
3
|
cwd?: string;
|
|
4
|
+
extraCwds?: string[];
|
|
4
5
|
overrideExisting?: boolean;
|
|
5
6
|
};
|
|
6
7
|
type LoadState = {
|
|
@@ -15,7 +16,7 @@ type CliOverrides = {
|
|
|
15
16
|
};
|
|
16
17
|
export declare const EnvFileLoader: Readonly<{
|
|
17
18
|
load: (options?: LoadOptions) => LoadState;
|
|
18
|
-
ensureLoaded: () => LoadState;
|
|
19
|
+
ensureLoaded: (options?: Omit<LoadOptions, "overrideExisting">) => LoadState;
|
|
19
20
|
applyCliOverrides: (overrides: CliOverrides) => void;
|
|
20
21
|
getState: () => LoadState;
|
|
21
22
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvFileLoader.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/EnvFileLoader.ts"],"names":[],"mappings":"AAQA,KAAK,QAAQ,GAAG,aAAa,GAAG,YAAY,GAAG,SAAS,CAAC;AAmIzD,KAAK,WAAW,GAAG;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;
|
|
1
|
+
{"version":3,"file":"EnvFileLoader.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/EnvFileLoader.ts"],"names":[],"mappings":"AAQA,KAAK,QAAQ,GAAG,aAAa,GAAG,YAAY,GAAG,SAAS,CAAC;AAmIzD,KAAK,WAAW,GAAG;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAkHF,eAAO,MAAM,aAAa;qBA7DH,WAAW,KAAQ,SAAS;6BAyBpB,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,KAAQ,SAAS;mCAG/C,YAAY,KAAG,IAAI;oBA+BpC,SAAS;EAO5B,CAAC"}
|
|
@@ -139,11 +139,7 @@ const filesLoader = (cwd, mode) => {
|
|
|
139
139
|
return files;
|
|
140
140
|
};
|
|
141
141
|
let cached;
|
|
142
|
-
const
|
|
143
|
-
if (cached !== undefined)
|
|
144
|
-
return cached;
|
|
145
|
-
const cwd = typeof options.cwd === 'string' && options.cwd !== '' ? options.cwd : process.cwd();
|
|
146
|
-
const overrideExisting = options.overrideExisting ?? true;
|
|
142
|
+
const loadFromCwd = (cwd, overrideExisting) => {
|
|
147
143
|
const mode = resolveAppMode(cwd);
|
|
148
144
|
const files = filesLoader(cwd, mode);
|
|
149
145
|
let baseApplied = false;
|
|
@@ -163,10 +159,30 @@ const load = (options = {}) => {
|
|
|
163
159
|
if (mode !== undefined) {
|
|
164
160
|
safeEnvSet('NODE_ENV', mode);
|
|
165
161
|
}
|
|
166
|
-
|
|
162
|
+
return { loadedFiles: files, mode };
|
|
163
|
+
};
|
|
164
|
+
const load = (options = {}) => {
|
|
165
|
+
if (cached !== undefined)
|
|
166
|
+
return cached;
|
|
167
|
+
const cwd = typeof options.cwd === 'string' && options.cwd !== '' ? options.cwd : process.cwd();
|
|
168
|
+
const extraCwds = Array.isArray(options.extraCwds)
|
|
169
|
+
? options.extraCwds.filter((value) => typeof value === 'string' && value.trim() !== '')
|
|
170
|
+
: [];
|
|
171
|
+
const overrideExisting = options.overrideExisting ?? true;
|
|
172
|
+
const roots = [cwd, ...extraCwds].filter((value, index, items) => items.indexOf(value) === index);
|
|
173
|
+
let mergedMode;
|
|
174
|
+
const loadedFiles = [];
|
|
175
|
+
for (let index = 0; index < roots.length; index += 1) {
|
|
176
|
+
const root = roots[index];
|
|
177
|
+
const state = loadFromCwd(root, index === 0 ? overrideExisting : true);
|
|
178
|
+
if (mergedMode === undefined && state.mode !== undefined)
|
|
179
|
+
mergedMode = state.mode;
|
|
180
|
+
loadedFiles.push(...state.loadedFiles);
|
|
181
|
+
}
|
|
182
|
+
cached = { loadedFiles, mode: mergedMode };
|
|
167
183
|
return cached;
|
|
168
184
|
};
|
|
169
|
-
const ensureLoaded = () => load({ overrideExisting: false });
|
|
185
|
+
const ensureLoaded = (options = {}) => load({ ...options, overrideExisting: false });
|
|
170
186
|
const applyCliOverrides = (overrides) => {
|
|
171
187
|
// Ensure base env is loaded first.
|
|
172
188
|
ensureLoaded();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/spawn.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/spawn.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AA0CD,eAAO,MAAM,SAAS;wBACM,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;EA+E7D,CAAC"}
|
package/src/cli/utils/spawn.js
CHANGED
|
@@ -29,6 +29,16 @@ const resolveLocalBin = (command, cwd) => {
|
|
|
29
29
|
}
|
|
30
30
|
return command;
|
|
31
31
|
};
|
|
32
|
+
const buildCommandNotFoundMessage = (command) => {
|
|
33
|
+
if (command === 'tsx') {
|
|
34
|
+
return [
|
|
35
|
+
"Error: 'tsx' not found on PATH.",
|
|
36
|
+
'Install it in the project with "npm install -D tsx".',
|
|
37
|
+
'If you want a machine-wide fallback, install it globally with "npm install -g tsx".',
|
|
38
|
+
].join(' ');
|
|
39
|
+
}
|
|
40
|
+
return `Error: '${command}' not found on PATH.`;
|
|
41
|
+
};
|
|
32
42
|
export const SpawnUtil = Object.freeze({
|
|
33
43
|
async spawnAndWait(input) {
|
|
34
44
|
const cwd = input.cwd ?? process.cwd();
|
|
@@ -87,7 +97,7 @@ export const SpawnUtil = Object.freeze({
|
|
|
87
97
|
catch (error) {
|
|
88
98
|
const code = error?.code;
|
|
89
99
|
if (code === 'ENOENT') {
|
|
90
|
-
throw ErrorFactory.createCliError(
|
|
100
|
+
throw ErrorFactory.createCliError(buildCommandNotFoundMessage(input.command));
|
|
91
101
|
}
|
|
92
102
|
throw ErrorFactory.createTryCatchError('Failed to spawn child process', error);
|
|
93
103
|
}
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v0.4.
|
|
2
|
+
* @zintrust/core v0.4.11
|
|
3
3
|
*
|
|
4
4
|
* ZinTrust Framework - Production-Grade TypeScript Backend
|
|
5
5
|
* Built for performance, type safety, and exceptional developer experience
|
|
6
6
|
*
|
|
7
7
|
* Build Information:
|
|
8
|
-
* Built: 2026-03-
|
|
8
|
+
* Built: 2026-03-23T13:29:47.237Z
|
|
9
9
|
* Node: >=20.0.0
|
|
10
10
|
* License: MIT
|
|
11
11
|
*
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Available at runtime for debugging and health checks
|
|
22
22
|
*/
|
|
23
23
|
export const ZINTRUST_VERSION = '0.1.41';
|
|
24
|
-
export const ZINTRUST_BUILD_DATE = '2026-03-
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-03-23T13:29:47.153Z'; // Replaced during build
|
|
25
25
|
export { Application } from './boot/Application.js';
|
|
26
26
|
export { AwsSigV4 } from './common/index.js';
|
|
27
27
|
export { SignedRequest } from './security/SignedRequest.js';
|
|
@@ -3,6 +3,7 @@ export interface ServiceManifestEntry {
|
|
|
3
3
|
id: string;
|
|
4
4
|
domain: string;
|
|
5
5
|
name: string;
|
|
6
|
+
prefix?: string;
|
|
6
7
|
version?: string;
|
|
7
8
|
description?: string;
|
|
8
9
|
port?: number;
|
|
@@ -21,6 +22,12 @@ export interface ProjectRuntimeModule {
|
|
|
21
22
|
activeService?: ActiveServiceRuntime;
|
|
22
23
|
}
|
|
23
24
|
export declare const getServiceId: (domain: string, name: string) => string;
|
|
25
|
+
export declare const getDefaultServicePrefix: (domain: string, name: string) => string;
|
|
26
|
+
export declare const getServicePrefix: (args: {
|
|
27
|
+
prefix?: unknown;
|
|
28
|
+
domain?: unknown;
|
|
29
|
+
name?: unknown;
|
|
30
|
+
}) => string;
|
|
24
31
|
export declare const isCanonicalServiceId: (value: unknown) => value is string;
|
|
25
32
|
export declare const toCanonicalServiceId: (args: {
|
|
26
33
|
id?: unknown;
|
|
@@ -34,6 +41,12 @@ export declare const normalizeProjectRuntimeModule: (value: unknown) => ProjectR
|
|
|
34
41
|
export declare const serviceMatchesAllowList: (serviceId: string, serviceName: string, allowList: ReadonlyArray<string>) => boolean;
|
|
35
42
|
declare const _default: Readonly<{
|
|
36
43
|
getServiceId: (domain: string, name: string) => string;
|
|
44
|
+
getDefaultServicePrefix: (domain: string, name: string) => string;
|
|
45
|
+
getServicePrefix: (args: {
|
|
46
|
+
prefix?: unknown;
|
|
47
|
+
domain?: unknown;
|
|
48
|
+
name?: unknown;
|
|
49
|
+
}) => string;
|
|
37
50
|
isCanonicalServiceId: (value: unknown) => value is string;
|
|
38
51
|
toCanonicalServiceId: (args: {
|
|
39
52
|
id?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceManifest.d.ts","sourceRoot":"","sources":["../../../src/microservices/ServiceManifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,eAAe,CAAC,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;IACtD,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACtC;AAED,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,MAA6B,CAAC;AAE1F,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAI9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM;IACz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,KAAG,aAAa,CAAC,oBAAoB,CAAC;2CAWxC,OAAO,KAAG,oBAAoB,GAAG,SAAS;2CAe1C,OAAO,KAAG,oBAAoB;yCAgBtE,MAAM,eACJ,MAAM,aACR,aAAa,CAAC,MAAM,CAAC,KAC/B,OAAO;;AAKV,wBAWG"}
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import { isArray, isFunction, isNonEmptyString, isObject } from '../helper/index.js';
|
|
2
2
|
export const getServiceId = (domain, name) => `${domain}/${name}`;
|
|
3
|
+
export const getDefaultServicePrefix = (domain, name) => `/${getServiceId(domain, name)}`;
|
|
4
|
+
const normalizeServicePrefix = (value) => {
|
|
5
|
+
const trimmed = value.trim();
|
|
6
|
+
if (trimmed === '' || trimmed === '/')
|
|
7
|
+
return '/';
|
|
8
|
+
const segments = trimmed
|
|
9
|
+
.split('/')
|
|
10
|
+
.map((segment) => segment.trim())
|
|
11
|
+
.filter((segment) => segment.length > 0);
|
|
12
|
+
if (segments.length === 0)
|
|
13
|
+
return '/';
|
|
14
|
+
return `/${segments.join('/')}`;
|
|
15
|
+
};
|
|
16
|
+
export const getServicePrefix = (args) => {
|
|
17
|
+
if (typeof args.prefix === 'string')
|
|
18
|
+
return normalizeServicePrefix(args.prefix);
|
|
19
|
+
const domain = isNonEmptyString(args.domain) ? args.domain : 'default';
|
|
20
|
+
const name = isNonEmptyString(args.name) ? args.name : 'unknown';
|
|
21
|
+
return getDefaultServicePrefix(domain, name);
|
|
22
|
+
};
|
|
3
23
|
export const isCanonicalServiceId = (value) => {
|
|
4
24
|
if (!isNonEmptyString(value))
|
|
5
25
|
return false;
|
|
@@ -22,6 +42,10 @@ export const isServiceManifestEntry = (value) => {
|
|
|
22
42
|
return false;
|
|
23
43
|
if (!isNonEmptyString(value['name']))
|
|
24
44
|
return false;
|
|
45
|
+
const prefix = value['prefix'];
|
|
46
|
+
if (prefix !== undefined && typeof prefix !== 'string') {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
25
49
|
const loadRoutes = value['loadRoutes'];
|
|
26
50
|
if (loadRoutes !== undefined && !isFunction(loadRoutes)) {
|
|
27
51
|
return false;
|
|
@@ -34,6 +58,7 @@ export const normalizeServiceManifest = (value) => {
|
|
|
34
58
|
return value.filter(isServiceManifestEntry).map((entry) => ({
|
|
35
59
|
...entry,
|
|
36
60
|
id: toCanonicalServiceId(entry),
|
|
61
|
+
prefix: getServicePrefix(entry),
|
|
37
62
|
monolithEnabled: entry.monolithEnabled !== false,
|
|
38
63
|
}));
|
|
39
64
|
};
|
|
@@ -72,6 +97,8 @@ export const serviceMatchesAllowList = (serviceId, serviceName, allowList) => {
|
|
|
72
97
|
};
|
|
73
98
|
export default Object.freeze({
|
|
74
99
|
getServiceId,
|
|
100
|
+
getDefaultServicePrefix,
|
|
101
|
+
getServicePrefix,
|
|
75
102
|
isCanonicalServiceId,
|
|
76
103
|
toCanonicalServiceId,
|
|
77
104
|
isServiceManifestEntry,
|