@xrystal/core 3.52.6 → 3.52.9

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.
@@ -107,16 +107,19 @@ export function resolveProjectContext(startDir = process.cwd()) {
107
107
 
108
108
  const hints = []
109
109
  if (kind === 'workspace-root') {
110
- hints.push('Outer tmp: ./tmp.yml · inner tmp: each api|admin|web project')
111
- hints.push('xry sync — all linked inner projects + ~/.xrystal registry')
112
- hints.push('xry workspaces — global registry (~/.xrystal), not this folder alone')
110
+ hints.push('Outer tmp: ./tmp.yml · inner tmp: each api|web|mobile project (admin → web/)')
111
+ hints.push('xry sync — all linked projects + ~/.xrystal registry')
112
+ hints.push('xry sync --all — same from any folder under this workspace')
113
+ hints.push('xry workspaces — global registry (~/.xrystal), not repo tmp files')
113
114
  } else if (kind === 'workspace-service') {
114
115
  hints.push(`Outer workspace: ${workspaceRoot}`)
115
- hints.push('xry tmp — inner x/tmp.yml · xry project — this view')
116
- hints.push('Run xry sync from workspace root to pin @xrystal/core on all services')
116
+ hints.push('xry sync — this service only (tsconfig + @xrystal/core pin)')
117
+ hints.push('xry sync --all — every linked api/web/mobile project + registry')
118
+ hints.push('xry tmp — inner x/tmp.yml · configs.global.type drives loader profile')
117
119
  } else {
118
- hints.push('xry tmp — seed inner x/tmp.yml')
119
- hints.push('@xrystal/core is the global library (npm) powering this service')
120
+ hints.push('xry sync — tsconfig + @xrystal/core pin for this repo')
121
+ hints.push('xry tmp — seed inner x/tmp.yml (api-service | frontend | …)')
122
+ hints.push('configs.global.type: frontend skips mongo/redis/kafka unless enabled in tmp')
120
123
  }
121
124
 
122
125
  return {
@@ -0,0 +1,76 @@
1
+ import path from 'node:path'
2
+
3
+ import chalk from 'chalk'
4
+
5
+ import { syncCliRuntime } from './project-artifacts.mjs'
6
+ import { syncCoreDependency } from './sync-core-dependency.mjs'
7
+ import { syncProjectToolchain } from './toolchain-config.mjs'
8
+ import { ensureTmpSchemaVersion } from './tmp-schema-version.mjs'
9
+ import { packageDefaults } from './package-defaults.mjs'
10
+
11
+ export function syncOneProject(entry, coreVersion, { dryRun = false, tmpPath = null } = {}) {
12
+ const label = entry.name ? `${entry.name} (${entry.type ?? 'project'})` : path.basename(entry.path)
13
+ const lines = []
14
+
15
+ if (dryRun) {
16
+ const preview = syncProjectToolchain(entry.path, { write: false })
17
+ lines.push({ level: 'gray', text: `would update ${preview.tsconfigRel ?? 'tsconfig.json'}` })
18
+ const core = syncCoreDependency(entry.path, coreVersion, { dryRun: true })
19
+ if (core.synced) {
20
+ lines.push({ level: 'gray', text: `would pin ${packageDefaults.packageName}@${coreVersion} (from ${core.current ?? core.declared})` })
21
+ } else if (core.reason === 'up-to-date') {
22
+ lines.push({ level: 'gray', text: `${packageDefaults.packageName}@${coreVersion} (ok)` })
23
+ } else if (core.reason === 'no core dependency') {
24
+ lines.push({ level: 'yellow', text: `skip core pin (${core.reason})` })
25
+ }
26
+ return { label, path: entry.path, lines, failed: false }
27
+ }
28
+
29
+ try {
30
+ syncCliRuntime(entry.path, { force: false })
31
+ const result = syncProjectToolchain(entry.path, { write: true })
32
+ lines.push({
33
+ level: 'green',
34
+ text: result.created
35
+ ? `created ${result.tsconfigRel}`
36
+ : `updated ${result.tsconfigRel}`,
37
+ })
38
+
39
+ const core = syncCoreDependency(entry.path, coreVersion, { dryRun: false })
40
+ if (core.synced) {
41
+ lines.push({ level: 'green', text: `pinned ${packageDefaults.packageName}@${coreVersion}` })
42
+ } else if (core.reason === 'up-to-date') {
43
+ lines.push({ level: 'gray', text: `${packageDefaults.packageName}@${coreVersion} (ok)` })
44
+ } else if (core.reason === 'no core dependency') {
45
+ lines.push({ level: 'yellow', text: `skip core pin (${core.reason})` })
46
+ }
47
+
48
+ if (tmpPath) {
49
+ const schema = ensureTmpSchemaVersion(tmpPath)
50
+ if (schema.patched) {
51
+ lines.push({ level: 'green', text: `tmp end.version → ${schema.schemaVersion} (schema)` })
52
+ }
53
+ }
54
+
55
+ return { label, path: entry.path, lines, failed: false }
56
+ } catch (error) {
57
+ return {
58
+ label,
59
+ path: entry.path,
60
+ lines: [{ level: 'red', text: `failed: ${error.message}` }],
61
+ failed: true,
62
+ }
63
+ }
64
+ }
65
+
66
+ export function printSyncProjectResult(result) {
67
+ console.log(chalk.cyan(`\n→ ${result.label}`))
68
+ console.log(chalk.gray(` path: ${result.path}`))
69
+ for (const line of result.lines) {
70
+ const paint = line.level === 'green' ? chalk.green
71
+ : line.level === 'red' ? chalk.red
72
+ : line.level === 'yellow' ? chalk.yellow
73
+ : chalk.gray
74
+ console.log(` ${paint(line.text)}`)
75
+ }
76
+ }
@@ -0,0 +1,71 @@
1
+ import path from 'node:path'
2
+
3
+ import { findEntries, findWorkspaceRoot } from './workspace-resolve.mjs'
4
+ import { resolveProjectRoot } from './project-root.mjs'
5
+
6
+ /**
7
+ * Resolve what `xry sync` should touch.
8
+ *
9
+ * | Context | default | --self | --all / --workspace |
10
+ * |--------------------|-----------|-------------|---------------------|
11
+ * | Standalone service | this repo | — | — |
12
+ * | Workspace root | all links | — | all links |
13
+ * | Inner service | this repo | this repo | all links + registry|
14
+ */
15
+ export function resolveSyncScope(cwd = process.cwd(), options = {}) {
16
+ const resolvedCwd = path.resolve(cwd)
17
+ const workspaceRoot = findWorkspaceRoot(resolvedCwd)
18
+ const projectRoot = resolveProjectRoot(resolvedCwd)
19
+ const atWorkspaceRoot = workspaceRoot != null && path.resolve(workspaceRoot) === resolvedCwd
20
+
21
+ const wantAll = Boolean(options.all || options.workspace)
22
+ const wantSelf = Boolean(options.self)
23
+
24
+ if (wantAll && wantSelf) {
25
+ throw new Error('Use either --self or --all, not both')
26
+ }
27
+
28
+ if (!workspaceRoot) {
29
+ return {
30
+ mode: 'standalone',
31
+ label: 'standalone project',
32
+ targetRoot: projectRoot,
33
+ workspaceRoot: null,
34
+ entries: [{ path: projectRoot, name: path.basename(projectRoot), type: 'project' }],
35
+ }
36
+ }
37
+
38
+ const entries = findEntries(workspaceRoot)
39
+
40
+ if (atWorkspaceRoot || wantAll) {
41
+ return {
42
+ mode: 'workspace-all',
43
+ label: wantAll && !atWorkspaceRoot ? 'workspace (all linked projects)' : 'workspace root',
44
+ targetRoot: workspaceRoot,
45
+ workspaceRoot,
46
+ entries,
47
+ }
48
+ }
49
+
50
+ if (wantSelf) {
51
+ const self = entries.find((entry) => path.resolve(entry.path) === path.resolve(projectRoot))
52
+ return {
53
+ mode: 'self',
54
+ label: 'current linked project',
55
+ targetRoot: projectRoot,
56
+ workspaceRoot,
57
+ entries: self ? [self] : [{ path: projectRoot, name: path.basename(projectRoot), type: 'project' }],
58
+ }
59
+ }
60
+
61
+ // Inner service default: sync only this project (clear, predictable).
62
+ const self = entries.find((entry) => path.resolve(entry.path) === path.resolve(projectRoot))
63
+ return {
64
+ mode: 'self',
65
+ label: 'current linked project (default)',
66
+ targetRoot: projectRoot,
67
+ workspaceRoot,
68
+ entries: self ? [self] : [{ path: projectRoot, name: path.basename(projectRoot), type: 'project' }],
69
+ hintAll: `Run ${options.cliName ?? 'xry'} sync --all from here to sync every linked api/web/mobile project`,
70
+ }
71
+ }
@@ -22,6 +22,22 @@ export function resolveProtocolsFromConfig(configs = {}) {
22
22
  return (Array.isArray(raw) ? raw : [raw]).map(parseProtocolValue)
23
23
  }
24
24
 
25
+ function summarizeInfraLoaders(depends) {
26
+ const loaders = depends?.loaders ?? {}
27
+ const readEnabled = (key, fallback) => {
28
+ const opts = loaders?.[key]?.options
29
+ if (opts && typeof opts === 'object' && 'enabled' in opts) return opts.enabled !== false
30
+ return fallback
31
+ }
32
+ const type = depends?.globalType ?? null
33
+ const isFrontend = type === 'frontend'
34
+ return {
35
+ kafka: readEnabled('kafka', !isFrontend),
36
+ redis: readEnabled('redis', !isFrontend),
37
+ mongo: readEnabled('mongo', !isFrontend),
38
+ }
39
+ }
40
+
25
41
  export function summarizeLoaders(tmp = {}) {
26
42
  const configs = tmp.configs ?? {}
27
43
  const global = readTmpGlobalBlock(configs)
@@ -29,8 +45,10 @@ export function summarizeLoaders(tmp = {}) {
29
45
 
30
46
  return {
31
47
  framework: global.framework ?? packageDefaults.framework,
48
+ globalType: global.type ?? '-',
32
49
  protocols: resolveProtocolsFromConfig(depends),
33
50
  project: tmp.project?.name ?? '-',
51
+ infra: summarizeInfraLoaders({ loaders: depends.loaders, globalType: global.type }),
34
52
  items: [
35
53
  depends.loaders?.dto && { key: 'dto', detail: formatLoaderDetail(depends.loaders?.dto) },
36
54
  depends.loaders?.loggers && { key: 'loggers', detail: formatLoaderDetail(depends.loaders?.loggers) },
@@ -58,9 +76,16 @@ function formatLoaderDetail(obj) {
58
76
 
59
77
  export function formatLoaderSummary(summary) {
60
78
  const lines = [
79
+ `type: ${summary.globalType ?? '-'}`,
61
80
  `framework: ${summary.framework}`,
62
81
  `protocols: ${summary.protocols.join(', ')}`,
63
82
  ]
83
+ if (summary.infra) {
84
+ const flags = ['kafka', 'redis', 'mongo']
85
+ .map((key) => `${key}:${summary.infra[key] ? 'on' : 'off'}`)
86
+ .join(' · ')
87
+ lines.push(`infra: ${flags}`)
88
+ }
64
89
  if (summary.project) lines.push(`project: ${summary.project}`)
65
90
  for (const item of summary.items) {
66
91
  lines.push(`${item.key}: ${item.detail}`)
@@ -4,6 +4,8 @@ export {
4
4
  findEntries,
5
5
  findWorkspaceRoot,
6
6
  normalizeGlobalType,
7
+ parseFolderStructure,
8
+ readTmpFile,
7
9
  readWorkspaceCoreTmp,
8
10
  resolveEntryPath,
9
11
  workspaceProjectName,
@@ -2,7 +2,7 @@ export { resolveKafkaJsSsl } from './resolve-ssl.js';
2
2
  import { Kafka as KafkaClient, logLevel } from "kafkajs";
3
3
  import { bindLoaderTmpSync } from '../../utils/helpers/tmp/loader-tmp-sync.js';
4
4
  import { resolveKafkaJsSsl } from './resolve-ssl.js';
5
- import { readKafkaLoaderOptions } from '../../utils/helpers/kafka-loader-options/index.js';
5
+ import { readKafkaLoaderOptions } from '../../utils/helpers/loader-options/index.js';
6
6
  export default class KafkaForCore {
7
7
  _instance;
8
8
  _producer;
@@ -23,13 +23,18 @@ export default class KafkaForCore {
23
23
  await this.syncFromTmp();
24
24
  bindLoaderTmpSync(this);
25
25
  };
26
+ #resolveDependsLoaders = () => {
27
+ const configs = this.#system?.tmp?.configs;
28
+ return configs?.depends?.loaders ?? configs?.service?.loaders;
29
+ };
26
30
  syncFromTmp = async () => {
27
31
  await this.teardownKafka();
28
32
  this.clientId = this.#configs.all?.kafkaClientId;
29
33
  this.brokers = this.#configs.all?.kafkaBrokers;
30
34
  this.username = this.#configs.all?.kafkaUsername;
31
35
  this.password = this.#configs.all?.kafkaPassword;
32
- const kafkaOpts = readKafkaLoaderOptions(this.#system?.tmp?.configs?.service?.loaders);
36
+ const loaders = this.#resolveDependsLoaders();
37
+ const kafkaOpts = readKafkaLoaderOptions(loaders);
33
38
  if (!kafkaOpts.enabled) {
34
39
  return;
35
40
  }
@@ -60,13 +60,15 @@ export default class Logger {
60
60
  };
61
61
  syncFromTmp = async () => {
62
62
  await this.teardownLogger();
63
- this.serviceName = this.#system?.tmp?.configs?.service?.name ?? '';
63
+ const configs = this.#system?.tmp?.configs;
64
+ const loaders = configs?.depends?.loaders ?? configs?.service?.loaders;
65
+ this.serviceName = configs?.deploymentName ?? configs?.service?.name ?? '';
64
66
  this.kafkaLogsTopic = this.#configs?.all?.kafkaLogsTopic;
65
67
  winston.addColors(customColors);
66
- const loggersConfigs = this.#system?.tmp?.configs?.service?.loaders?.loggers;
68
+ const loggersConfigs = (loaders?.loggers ?? {});
67
69
  const { kafkaBrokers } = this.#configs.all;
68
70
  const brokers = kafkaBrokers ? String(kafkaBrokers).split(',').map((b) => b.trim()) : [];
69
- const kafkaOpts = readKafkaLoaderOptions(this.#system?.tmp?.configs?.service?.loaders);
71
+ const kafkaOpts = readKafkaLoaderOptions(loaders);
70
72
  const isKafkaLogEnabled = kafkaOpts.enabled && kafkaOpts.queueLogEnabled && brokers.length > 0;
71
73
  if (isKafkaLogEnabled && this.#kafka.instance) {
72
74
  this.kafkaProducer = this.#kafka.instance.producer({
@@ -81,9 +83,9 @@ export default class Logger {
81
83
  this.isKafkaReady = false;
82
84
  }
83
85
  }
84
- const logPath = loggersConfigs?.loadPath || 'logs';
85
- const loggerLevel = loggersConfigs?.logLevel || loggersConfigs?.loggerLevel || 'info';
86
- const queueLogLevel = normalizeLoggerLayer(loggersConfigs?.queueLogLevel ?? loggersConfigs?.kafkaLogLevel, LoggerLayerEnum.WARN);
86
+ const logPath = String(loggersConfigs.loadPath ?? 'logs');
87
+ const loggerLevel = String(loggersConfigs.logLevel ?? loggersConfigs.loggerLevel ?? 'info');
88
+ const queueLogLevel = normalizeLoggerLayer((loggersConfigs.queueLogLevel ?? loggersConfigs.kafkaLogLevel), LoggerLayerEnum.WARN);
87
89
  this.queueLogLevel = queueLogLevel;
88
90
  this.winstonLoader({
89
91
  loadPath: path.join(this.#configs.all.rootFolderPath, logPath),
@@ -1,6 +1,7 @@
1
1
  export { resolveMongoConnectOptions } from './resolve-connect.js';
2
2
  import { MongoClient } from 'mongodb';
3
3
  import { bindLoaderTmpSync } from '../../utils/helpers/tmp/loader-tmp-sync.js';
4
+ import { readInfraLoaderEnabled } from '../../utils/helpers/loader-options/index.js';
4
5
  import { resolveMongoConnectOptions } from './resolve-connect.js';
5
6
  export default class MongoForCore {
6
7
  #client = null;
@@ -18,8 +19,16 @@ export default class MongoForCore {
18
19
  await this.syncFromTmp();
19
20
  bindLoaderTmpSync(this);
20
21
  };
22
+ #resolveDependsLoaders = () => {
23
+ const configs = this.#system?.tmp?.configs;
24
+ return configs?.depends?.loaders ?? configs?.service?.loaders;
25
+ };
21
26
  syncFromTmp = async () => {
22
27
  await this.teardown();
28
+ const loaders = this.#resolveDependsLoaders();
29
+ if (!readInfraLoaderEnabled(loaders, 'mongo', true)) {
30
+ return;
31
+ }
23
32
  if (this.#configs.all.isMongoPassive) {
24
33
  return;
25
34
  }
@@ -1,6 +1,7 @@
1
1
  export { resolveRedisSocketOptions } from './resolve-socket.js';
2
2
  import { createClient } from 'redis';
3
3
  import { bindLoaderTmpSync } from '../../utils/helpers/tmp/loader-tmp-sync.js';
4
+ import { readInfraLoaderEnabled } from '../../utils/helpers/loader-options/index.js';
4
5
  import { resolveRedisSocketOptions } from './resolve-socket.js';
5
6
  export default class RedisForCore {
6
7
  #client = null;
@@ -17,8 +18,16 @@ export default class RedisForCore {
17
18
  await this.syncFromTmp();
18
19
  bindLoaderTmpSync(this);
19
20
  };
21
+ #resolveDependsLoaders = () => {
22
+ const configs = this.#system?.tmp?.configs;
23
+ return configs?.depends?.loaders ?? configs?.service?.loaders;
24
+ };
20
25
  syncFromTmp = async () => {
21
26
  await this.teardown();
27
+ const loaders = this.#resolveDependsLoaders();
28
+ if (!readInfraLoaderEnabled(loaders, 'redis', true)) {
29
+ return;
30
+ }
22
31
  if (this.#configs.all.isRedisPassive) {
23
32
  return;
24
33
  }
@@ -1,5 +1,6 @@
1
1
  export { ensureCoreTmpEntry, isCorePackageRoot } from '../utils/helpers/core/tmp-layout';
2
2
  export { getTmpSnapshot } from '../utils/helpers/tmp/tmp-loader';
3
+ export { resolveLoaderBootPlan } from '../utils/helpers/tmp/loader-boot-plan';
3
4
  export declare const core: {
4
5
  _: Record<string, unknown>;
5
6
  };
@@ -4,8 +4,11 @@ import { System, Configs, Logger, Events, Localizations, DtoRuntime, Clients, Co
4
4
  import { Constants, getCore, x } from '../utils/index.js';
5
5
  import { ensureCoreTmpEntry, isCorePackageRoot } from '../utils/helpers/core/tmp-layout.js';
6
6
  import { getTmpSnapshot } from '../utils/helpers/tmp/tmp-loader.js';
7
+ import { resolveLoaderBootPlan } from '../utils/helpers/tmp/loader-boot-plan.js';
8
+ import { resolveTmpRuntimeConfigs } from '../utils/helpers/tmp/tmp-schema.js';
7
9
  export { ensureCoreTmpEntry, isCorePackageRoot } from '../utils/helpers/core/tmp-layout.js';
8
10
  export { getTmpSnapshot } from '../utils/helpers/tmp/tmp-loader.js';
11
+ export { resolveLoaderBootPlan } from '../utils/helpers/tmp/loader-boot-plan.js';
9
12
  export const core = getCore();
10
13
  export const coreInit = async (params) => {
11
14
  const { locales } = params;
@@ -16,29 +19,33 @@ let coreHasRun = false;
16
19
  const projectModuleDir = path.dirname(fileURLToPath(import.meta.url));
17
20
  const loaderGlob = path.join(projectModuleDir, '..', 'loader', '**/*.{ts,js}');
18
21
  const loaderExcludeGlob = path.join(projectModuleDir, '..', 'utils', '**/class.x.{ts,js}');
22
+ function buildLoaderInitList(plan, coreRef) {
23
+ const entries = [
24
+ { service: System, props: { core: coreRef } },
25
+ { service: Configs, props: {} },
26
+ ];
27
+ if (plan.kafka)
28
+ entries.push({ service: KafkaForCore, props: {} });
29
+ if (plan.redis)
30
+ entries.push({ service: RedisForCore, props: {} });
31
+ if (plan.mongo)
32
+ entries.push({ service: MongoForCore, props: {} });
33
+ entries.push({ service: Logger, props: {} }, { service: Events, props: {} }, { service: Localizations, props: {} }, { service: DtoRuntime, props: {} }, { service: Controller, props: {} }, { service: Clients, props: {} });
34
+ return entries;
35
+ }
19
36
  const coreLoader = async (_params = {}) => {
20
37
  if (coreHasRun)
21
38
  return core;
22
39
  const root = process.cwd();
23
40
  if (isCorePackageRoot(root))
24
41
  ensureCoreTmpEntry(root);
25
- getTmpSnapshot();
42
+ const snapshot = getTmpSnapshot();
43
+ const runtimeConfigs = resolveTmpRuntimeConfigs(snapshot);
44
+ const plan = resolveLoaderBootPlan(runtimeConfigs);
26
45
  try {
27
46
  await (await x.load([loaderGlob], {
28
47
  exclude: [loaderExcludeGlob],
29
- })).initialize([
30
- { service: System, props: { core } },
31
- { service: Configs, props: {} },
32
- { service: KafkaForCore, props: {} },
33
- { service: RedisForCore, props: {} },
34
- { service: MongoForCore, props: {} },
35
- { service: Logger, props: {} },
36
- { service: Events, props: {} },
37
- { service: Localizations, props: {} },
38
- { service: DtoRuntime, props: {} },
39
- { service: Controller, props: {} },
40
- { service: Clients, props: {} },
41
- ]);
48
+ })).initialize(buildLoaderInitList(plan, core));
42
49
  coreHasRun = true;
43
50
  return core;
44
51
  }
@@ -0,0 +1,5 @@
1
+ export type InfraLoaderOptions = {
2
+ enabled: boolean;
3
+ };
4
+ export declare function readInfraLoaderEnabled(loaders: Record<string, unknown> | undefined, key: string, defaultEnabled: boolean): boolean;
5
+ export { readKafkaLoaderOptions, type KafkaLoaderOptions } from '../../../utils/helpers/kafka-loader-options';
@@ -0,0 +1,16 @@
1
+ function readOptionsBlock(loaders, key) {
2
+ const block = loaders?.[key];
3
+ if (typeof block !== 'object' || block === null)
4
+ return {};
5
+ const options = block.options;
6
+ if (typeof options !== 'object' || options === null)
7
+ return {};
8
+ return options;
9
+ }
10
+ export function readInfraLoaderEnabled(loaders, key, defaultEnabled) {
11
+ const options = readOptionsBlock(loaders, key);
12
+ if ('enabled' in options)
13
+ return options.enabled !== false;
14
+ return defaultEnabled;
15
+ }
16
+ export { readKafkaLoaderOptions } from '../../../utils/helpers/kafka-loader-options/index.js';
@@ -2,6 +2,7 @@ export { setRuntimeTmpConfigs, getRuntimeTmpConfigs, onRuntimeTmpChange, notifyR
2
2
  export { getTmpLoader, getTmpLoaderPath, getTmpSnapshot, onTmpReload, resetTmpLoaderForTests, stopTmpLoader, } from '../../../utils/helpers/tmp/tmp-loader';
3
3
  export { bindLoaderTmpSync, type ITmpSyncLoader, } from '../../../utils/helpers/tmp/loader-tmp-sync';
4
4
  export { resolveTmpWatchIntervalMs } from '../../../utils/helpers/tmp/tmp-watch';
5
+ export { resolveLoaderBootPlan, type LoaderBootPlan, type LoaderBootProfile, } from '../../../utils/helpers/tmp/loader-boot-plan';
5
6
  export { normalizeTmpDocument, normalizeRootFolder, normalizeSourceFolder, normalizeRuntime, normalizeBundler, resolveEffectiveBundler, readTmpDependsBlock, readTmpBuildBlock, readTmpGlobalBlock, assertNoLegacyTmpKeys, resolveTmpDeploymentName, readTmpGlobalPathsBlock, applyTmpGlobalVars, resolveMergedPaths, resolveTmpRuntimeConfigs, resolveProjectRootFromTmpPath, resolveTmpAbsPath, normalizeGlobalType, } from '../../../utils/helpers/tmp/tmp-schema';
6
7
  export { loadSeedFromBundledTmp, seedFromTmp, type SeedFromTmp, } from '../../../utils/helpers/tmp/seed-from-tmp';
7
8
  export { normalizeLayoutPaths, type LayoutPaths, } from '../../../utils/helpers/tmp/path-normalize';
@@ -2,6 +2,7 @@ export { setRuntimeTmpConfigs, getRuntimeTmpConfigs, onRuntimeTmpChange, notifyR
2
2
  export { getTmpLoader, getTmpLoaderPath, getTmpSnapshot, onTmpReload, resetTmpLoaderForTests, stopTmpLoader, } from '../../../utils/helpers/tmp/tmp-loader.js';
3
3
  export { bindLoaderTmpSync, } from '../../../utils/helpers/tmp/loader-tmp-sync.js';
4
4
  export { resolveTmpWatchIntervalMs } from '../../../utils/helpers/tmp/tmp-watch.js';
5
+ export { resolveLoaderBootPlan, } from '../../../utils/helpers/tmp/loader-boot-plan.js';
5
6
  export { normalizeTmpDocument, normalizeRootFolder, normalizeSourceFolder, normalizeRuntime, normalizeBundler, resolveEffectiveBundler, readTmpDependsBlock, readTmpBuildBlock, readTmpGlobalBlock, assertNoLegacyTmpKeys, resolveTmpDeploymentName, readTmpGlobalPathsBlock, applyTmpGlobalVars, resolveMergedPaths, resolveTmpRuntimeConfigs, resolveProjectRootFromTmpPath, resolveTmpAbsPath, normalizeGlobalType, } from '../../../utils/helpers/tmp/tmp-schema.js';
6
7
  export { loadSeedFromBundledTmp, seedFromTmp, } from '../../../utils/helpers/tmp/seed-from-tmp.js';
7
8
  export { normalizeLayoutPaths, } from '../../../utils/helpers/tmp/path-normalize.js';
@@ -0,0 +1,10 @@
1
+ import type { TmpRuntimeConfigs } from '../../../utils/helpers/tmp/tmp-schema';
2
+ export type LoaderBootProfile = 'api-service' | 'frontend' | 'workspace' | 'minimal';
3
+ export type LoaderBootPlan = {
4
+ profile: LoaderBootProfile;
5
+ projectType: string | undefined;
6
+ kafka: boolean;
7
+ redis: boolean;
8
+ mongo: boolean;
9
+ };
10
+ export declare function resolveLoaderBootPlan(configs?: TmpRuntimeConfigs | null): LoaderBootPlan;
@@ -0,0 +1,36 @@
1
+ import { GlobalTypeEnum } from '../../../utils/models/enums/index.js';
2
+ import { readInfraLoaderEnabled, readKafkaLoaderOptions } from '../../../utils/helpers/loader-options/index.js';
3
+ function loadersBlock(configs) {
4
+ const loaders = configs?.depends?.loaders;
5
+ return typeof loaders === 'object' && loaders !== null ? loaders : undefined;
6
+ }
7
+ export function resolveLoaderBootPlan(configs) {
8
+ const type = configs?.global?.type;
9
+ const loaders = loadersBlock(configs);
10
+ if (type === GlobalTypeEnum.FRONTEND) {
11
+ return {
12
+ profile: 'frontend',
13
+ projectType: type,
14
+ kafka: readInfraLoaderEnabled(loaders, 'kafka', false),
15
+ redis: readInfraLoaderEnabled(loaders, 'redis', false),
16
+ mongo: readInfraLoaderEnabled(loaders, 'mongo', false),
17
+ };
18
+ }
19
+ if (type === GlobalTypeEnum.WORKSPACE) {
20
+ return {
21
+ profile: 'workspace',
22
+ projectType: type,
23
+ kafka: false,
24
+ redis: false,
25
+ mongo: false,
26
+ };
27
+ }
28
+ const kafkaOpts = readKafkaLoaderOptions(loaders);
29
+ return {
30
+ profile: type === GlobalTypeEnum.API_SERVICE ? 'api-service' : 'minimal',
31
+ projectType: type ?? GlobalTypeEnum.API_SERVICE,
32
+ kafka: kafkaOpts.enabled,
33
+ redis: readInfraLoaderEnabled(loaders, 'redis', true),
34
+ mongo: readInfraLoaderEnabled(loaders, 'mongo', true),
35
+ };
36
+ }
@@ -94,16 +94,38 @@ export function resolveMergedPaths(configs) {
94
94
  tmpRelPath: `${root}/${tmpName}`.replace(/\/+/g, '/'),
95
95
  };
96
96
  }
97
+ function readWorkspaceGlobalBlock(global) {
98
+ const pathsRaw = isRecord(global.paths) ? global.paths : {};
99
+ const root = typeof pathsRaw.root === 'string' && pathsRaw.root.trim() ? pathsRaw.root.trim() : '.';
100
+ const optionsRaw = isRecord(global.options) ? global.options : undefined;
101
+ return {
102
+ type: GlobalTypeEnum.WORKSPACE,
103
+ runtime: RuntimeEnum.BUN,
104
+ framework: '',
105
+ paths: {
106
+ root,
107
+ tmp: typeof pathsRaw.tmp === 'string' ? pathsRaw.tmp : 'tmp.yml',
108
+ },
109
+ vars: isRecord(global.vars) ? { ...global.vars } : {},
110
+ options: optionsRaw
111
+ ? { fileWatchIntervalMs: readWatchIntervalValue(optionsRaw.fileWatchIntervalMs) }
112
+ : undefined,
113
+ };
114
+ }
97
115
  export function readTmpGlobalBlock(configs) {
98
116
  const global = isRecord(configs?.global) ? configs.global : {};
99
117
  const varsRaw = isRecord(global.vars) ? global.vars : {};
100
118
  const typeRaw = global.type;
119
+ const type = typeRaw !== undefined ? normalizeGlobalType(typeRaw) : undefined;
120
+ if (type === GlobalTypeEnum.WORKSPACE) {
121
+ return readWorkspaceGlobalBlock(global);
122
+ }
101
123
  if (typeof global.framework !== 'string' || !global.framework.trim()) {
102
124
  throw new Error(`${defaults.packageName}: configs.global.framework is required`);
103
125
  }
104
126
  return {
105
127
  runtime: normalizeRuntime(global.runtime),
106
- type: typeRaw !== undefined ? normalizeGlobalType(typeRaw) : undefined,
128
+ type,
107
129
  framework: global.framework.trim(),
108
130
  paths: readTmpGlobalPathsBlock(configs),
109
131
  vars: { ...varsRaw },
@@ -177,6 +199,15 @@ export function resolveTmpRuntimeConfigs(tmp) {
177
199
  assertNoLegacyTmpKeys(configs);
178
200
  const global = readTmpGlobalBlock(configs);
179
201
  const depends = readTmpDependsBlock(configs);
202
+ if (global.type === GlobalTypeEnum.WORKSPACE) {
203
+ return {
204
+ global: { ...global, build: {} },
205
+ depends: buildNormalizedDepends(depends),
206
+ deploymentName: resolveTmpDeploymentName(tmp),
207
+ rootFolderPath: '.',
208
+ tmpRelPath: global.paths.tmp ?? 'tmp.yml',
209
+ };
210
+ }
180
211
  const merged = resolveMergedPaths(configs);
181
212
  return {
182
213
  global: {
@@ -3,8 +3,8 @@ export declare const TMP_FILE = "tmp.yml";
3
3
  export declare const SKIP_DIRS: Set<string>;
4
4
  export type FolderStructure = {
5
5
  api: string;
6
- admin: string;
7
6
  web: string;
7
+ mobile: string;
8
8
  };
9
9
  export declare const DEFAULT_FOLDER_STRUCTURE: FolderStructure;
10
10
  export type TmpMeta = {
@@ -17,19 +17,26 @@ export type TmpMeta = {
17
17
  pathsRoot?: string;
18
18
  folderStructure: FolderStructure;
19
19
  };
20
+ export type WorkspaceSlot = keyof FolderStructure;
20
21
  export type WorkspaceEntry = {
21
22
  name: string;
22
23
  type: GlobalTypeEnum.API_SERVICE | GlobalTypeEnum.FRONTEND;
23
24
  path: string;
24
25
  tmp: string;
25
- slot: keyof FolderStructure;
26
+ slot: WorkspaceSlot;
26
27
  cluster?: string;
27
28
  };
28
29
  export declare function readTmpFile(filePath: string): TmpMeta;
29
30
  export declare function parseFolderStructure(text: string): FolderStructure;
31
+ type DiscoverySlot = {
32
+ slot: WorkspaceSlot;
33
+ folder: string;
34
+ frontendOnly: boolean;
35
+ };
36
+ export declare function workspaceDiscoverySlots(fsMap: FolderStructure): DiscoverySlot[];
30
37
  export { normalizeGlobalType } from '../../../utils/helpers/tmp/tmp-schema';
31
38
  export declare function entryName(meta: TmpMeta): string | null;
32
- export declare function entryType(meta: TmpMeta, slot: keyof FolderStructure): GlobalTypeEnum | null;
39
+ export declare function entryType(meta: TmpMeta, slot: WorkspaceSlot): GlobalTypeEnum | null;
33
40
  export declare function findWorkspaceRoot(startDir?: string): string | null;
34
41
  export declare function findEntries(workspaceRoot: string): WorkspaceEntry[];
35
42
  export declare function findApiServices(workspaceRoot: string): WorkspaceEntry[];