@nu-art/build-and-install 0.400.14 → 0.401.1

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.
Files changed (156) hide show
  1. package/BuildAndInstall.d.ts +40 -0
  2. package/BuildAndInstall.js +155 -0
  3. package/build-and-install-v3.d.ts +1 -32
  4. package/build-and-install-v3.js +1 -154
  5. package/build-and-install.js +11 -11
  6. package/config/consts.d.ts +43 -0
  7. package/config/consts.js +42 -0
  8. package/{core → config}/package/consts.d.ts +1 -1
  9. package/{core → config}/types/project-config.d.ts +3 -0
  10. package/core/FilesCache.d.ts +50 -0
  11. package/core/FilesCache.js +76 -0
  12. package/core/Unit_HelpPrinter.d.ts +16 -0
  13. package/core/Unit_HelpPrinter.js +47 -0
  14. package/core/params/params.d.ts +1 -41
  15. package/core/params/params.js +1 -334
  16. package/core/params.d.ts +50 -0
  17. package/core/params.js +441 -0
  18. package/{v3/core → core}/types.d.ts +1 -1
  19. package/{v3/UnitsDependencyMapper → dependencies}/UnitsDependencyMapper.d.ts +21 -1
  20. package/{v3/UnitsDependencyMapper → dependencies}/UnitsDependencyMapper.js +26 -3
  21. package/dependencies/types.d.ts +1 -0
  22. package/dependencies/types.js +1 -0
  23. package/exceptions/PhaseAggregatedException.d.ts +34 -0
  24. package/{core/exceptions → exceptions}/PhaseAggregatedException.js +26 -0
  25. package/exceptions/UnitPhaseException.d.ts +20 -0
  26. package/exceptions/UnitPhaseException.js +21 -0
  27. package/exports/ExportIndexCache.d.ts +25 -0
  28. package/exports/ExportIndexCache.js +115 -0
  29. package/exports/ExportMapper.d.ts +43 -0
  30. package/exports/ExportMapper.js +519 -0
  31. package/exports/IndicesMcpServer.d.ts +22 -0
  32. package/exports/IndicesMcpServer.js +220 -0
  33. package/exports/types.js +3 -0
  34. package/package.json +20 -9
  35. package/phases/PhaseManager.d.ts +130 -0
  36. package/phases/PhaseManager.js +267 -0
  37. package/{v3/phase → phases/definitions}/consts.d.ts +36 -0
  38. package/{v3/phase → phases/definitions}/consts.js +45 -2
  39. package/phases/definitions/types.d.ts +40 -0
  40. package/phases/index.d.ts +2 -0
  41. package/phases/index.js +2 -0
  42. package/run.js +10 -0
  43. package/runtime/RunningStatusHandler.d.ts +104 -0
  44. package/runtime/RunningStatusHandler.js +153 -0
  45. package/runtime/types.d.ts +1 -0
  46. package/runtime/types.js +2 -0
  47. package/{defaults → templates}/consts.d.ts +9 -0
  48. package/{defaults → templates}/consts.js +12 -2
  49. package/templates/firebase/functions/cloudbuild.yaml +17 -0
  50. package/templates/firebase/functions/dockerfile +19 -0
  51. package/templates/firebase/functions/service.yaml +49 -0
  52. package/{v3/units → units/base}/BaseUnit.d.ts +35 -3
  53. package/{v3/units → units/base}/BaseUnit.js +22 -2
  54. package/units/base/ProjectUnit.d.ts +32 -0
  55. package/units/base/ProjectUnit.js +25 -0
  56. package/units/base/types.js +1 -0
  57. package/units/discovery/UnitsMapper.d.ts +69 -0
  58. package/{v3/UnitsMapper → units/discovery}/UnitsMapper.js +51 -3
  59. package/units/discovery/resolvers/UnitMapper_Base.d.ts +65 -0
  60. package/units/discovery/resolvers/UnitMapper_Base.js +46 -0
  61. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_FirebaseFunction.d.ts +5 -3
  62. package/units/discovery/resolvers/UnitMapper_FirebaseFunction.js +105 -0
  63. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_FirebaseHosting.d.ts +3 -2
  64. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_FirebaseHosting.js +14 -10
  65. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_Node.d.ts +1 -1
  66. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_Node.js +2 -2
  67. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_NodeLib.d.ts +24 -1
  68. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_NodeLib.js +24 -1
  69. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_NodeProject.d.ts +22 -1
  70. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_NodeProject.js +22 -1
  71. package/units/discovery/types.js +1 -0
  72. package/units/implementations/Unit_NodeProject.d.ts +59 -0
  73. package/{v3/units → units/implementations}/Unit_NodeProject.js +67 -6
  74. package/units/implementations/Unit_PackageJson.d.ts +56 -0
  75. package/{v3/units → units/implementations}/Unit_PackageJson.js +39 -3
  76. package/{v3/units → units/implementations}/Unit_TypescriptLib.d.ts +40 -4
  77. package/{v3/units → units/implementations}/Unit_TypescriptLib.js +167 -17
  78. package/units/implementations/firebase/Unit_FirebaseFunctionsApp.d.ts +233 -0
  79. package/units/implementations/firebase/Unit_FirebaseFunctionsApp.js +804 -0
  80. package/units/implementations/firebase/Unit_FirebaseHostingApp.d.ts +113 -0
  81. package/units/implementations/firebase/Unit_FirebaseHostingApp.js +320 -0
  82. package/units/implementations/firebase/common.d.ts +26 -0
  83. package/units/implementations/firebase/common.js +65 -0
  84. package/units/index.d.ts +6 -0
  85. package/units/index.js +6 -0
  86. package/v3/core/Unit_HelpPrinter.d.ts +1 -16
  87. package/v3/core/Unit_HelpPrinter.js +1 -47
  88. package/workspace/Workspace.d.ts +95 -0
  89. package/workspace/Workspace.js +192 -0
  90. package/core/consts.d.ts +0 -13
  91. package/core/consts.js +0 -12
  92. package/core/exceptions/PhaseAggregatedException.d.ts +0 -8
  93. package/core/exceptions/UnitPhaseException.d.ts +0 -5
  94. package/core/exceptions/UnitPhaseException.js +0 -6
  95. package/old/PhaseRunnerDispatcher.d.ts +0 -24
  96. package/old/PhaseRunnerDispatcher.js +0 -32
  97. package/old/runner-dispatchers.d.ts +0 -10
  98. package/old/runner-dispatchers.js +0 -3
  99. package/v3/PhaseManager.d.ts +0 -26
  100. package/v3/PhaseManager.js +0 -158
  101. package/v3/RunningStatusHandler.d.ts +0 -18
  102. package/v3/RunningStatusHandler.js +0 -67
  103. package/v3/UnitsMapper/UnitsMapper.d.ts +0 -21
  104. package/v3/UnitsMapper/resolvers/UnitMapper_Base.d.ts +0 -23
  105. package/v3/UnitsMapper/resolvers/UnitMapper_Base.js +0 -16
  106. package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.js +0 -66
  107. package/v3/core/FilesCache.d.ts +0 -7
  108. package/v3/core/FilesCache.js +0 -33
  109. package/v3/phase/types.d.ts +0 -9
  110. package/v3/units/ProjectUnit.d.ts +0 -18
  111. package/v3/units/ProjectUnit.js +0 -11
  112. package/v3/units/Unit_NodeProject.d.ts +0 -30
  113. package/v3/units/Unit_PackageJson.d.ts +0 -17
  114. package/v3/units/firebase/Unit_FirebaseFunctionsApp.d.ts +0 -64
  115. package/v3/units/firebase/Unit_FirebaseFunctionsApp.js +0 -306
  116. package/v3/units/firebase/Unit_FirebaseHostingApp.d.ts +0 -49
  117. package/v3/units/firebase/Unit_FirebaseHostingApp.js +0 -114
  118. package/v3/units/firebase/common.d.ts +0 -3
  119. package/v3/units/firebase/common.js +0 -13
  120. package/v3/units/index.d.ts +0 -6
  121. package/v3/units/index.js +0 -6
  122. /package/{core → config}/package/consts.js +0 -0
  123. /package/{core → config}/types/configs/firebasejson.d.ts +0 -0
  124. /package/{core → config}/types/configs/firebasejson.js +0 -0
  125. /package/{core → config}/types/configs/firebaserc.d.ts +0 -0
  126. /package/{core → config}/types/configs/firebaserc.js +0 -0
  127. /package/{core → config}/types/configs/index.d.ts +0 -0
  128. /package/{core → config}/types/configs/index.js +0 -0
  129. /package/{core → config}/types/configs/package-json.d.ts +0 -0
  130. /package/{core → config}/types/configs/package-json.js +0 -0
  131. /package/{core → config}/types/core.d.ts +0 -0
  132. /package/{core → config}/types/core.js +0 -0
  133. /package/{core → config}/types/index.d.ts +0 -0
  134. /package/{core → config}/types/index.js +0 -0
  135. /package/{core → config}/types/package/index.d.ts +0 -0
  136. /package/{core → config}/types/package/index.js +0 -0
  137. /package/{core → config}/types/package/package.d.ts +0 -0
  138. /package/{core → config}/types/package/package.js +0 -0
  139. /package/{core → config}/types/package/runtime-package.d.ts +0 -0
  140. /package/{core → config}/types/package/runtime-package.js +0 -0
  141. /package/{core → config}/types/project-config.js +0 -0
  142. /package/{v3/core → core}/types.js +0 -0
  143. /package/{v3/UnitsMapper/types.js → exports/types.d.ts} +0 -0
  144. /package/{v3/phase → phases/definitions}/index.d.ts +0 -0
  145. /package/{v3/phase → phases/definitions}/index.js +0 -0
  146. /package/{v3/phase → phases/definitions}/types.js +0 -0
  147. /package/{v3/units/types.js → run.d.ts} +0 -0
  148. /package/{defaults/backend-proxy → templates/backend/proxy}/proxy._ts +0 -0
  149. /package/{defaults/.firebase_config → templates/firebase/config}/database.rules.json +0 -0
  150. /package/{defaults/.firebase_config → templates/firebase/config}/firestore.indexes.json +0 -0
  151. /package/{defaults/.firebase_config → templates/firebase/config}/firestore.rules +0 -0
  152. /package/{defaults/.firebase_config → templates/firebase/config}/storage.rules +0 -0
  153. /package/{v3/units → units/base}/types.d.ts +0 -0
  154. /package/{v3/UnitsMapper → units/discovery}/resolvers/index.d.ts +0 -0
  155. /package/{v3/UnitsMapper → units/discovery}/resolvers/index.js +0 -0
  156. /package/{v3/UnitsMapper → units/discovery}/types.d.ts +0 -0
@@ -0,0 +1,46 @@
1
+ import { Logger } from '@nu-art/ts-common';
2
+ /**
3
+ * Base class for unit mapper resolvers.
4
+ *
5
+ * **Purpose**: Each mapper resolver checks if a directory path matches its unit type
6
+ * and creates the appropriate unit instance if it matches.
7
+ *
8
+ * **Resolution Process**:
9
+ * 1. `resolveUnit()` is called for each directory during workspace scan
10
+ * 2. Mapper checks if path matches its criteria (package.json type, file presence, etc.)
11
+ * 3. If match, creates and returns unit instance
12
+ * 4. If no match, returns undefined (next mapper tries)
13
+ *
14
+ * **Configuration**:
15
+ * - `validator`: Validates unit config JSON (e.g., package.json.unitConfig.type)
16
+ * - `baiConfig`: BAI configuration (set by UnitsMapper)
17
+ * - `runtimeParams`: Runtime parameters (set by UnitsMapper)
18
+ *
19
+ * **Usage**: Extended by specific mappers (UnitMapper_NodeLib, UnitMapper_FirebaseFunction, etc.)
20
+ * to implement unit-specific discovery logic.
21
+ */
22
+ export class UnitMapper_Base extends Logger {
23
+ validator;
24
+ baiConfig;
25
+ runtimeParams;
26
+ constructor(validator) {
27
+ super();
28
+ this.validator = validator;
29
+ }
30
+ /**
31
+ * Sets runtime parameters for the mapper.
32
+ *
33
+ * Called by UnitsMapper to provide runtime context.
34
+ */
35
+ setRuntimeParams(runtimeParams) {
36
+ this.runtimeParams = runtimeParams;
37
+ }
38
+ /**
39
+ * Sets BAI configuration for the mapper.
40
+ *
41
+ * Called by UnitsMapper to provide configuration context.
42
+ */
43
+ setConfig(config) {
44
+ this.baiConfig = config;
45
+ }
46
+ }
@@ -1,10 +1,9 @@
1
1
  import { TypedMap } from '@nu-art/ts-common';
2
2
  import { UnitConfigJSON_Node, UnitMapper_Node, UnitMapper_NodeContext } from './UnitMapper_Node.js';
3
- import { Unit_FirebaseFunctionsApp } from '../../units/firebase/Unit_FirebaseFunctionsApp.js';
3
+ import { FunctionConfig, Unit_FirebaseFunctionsApp } from '../../implementations/firebase/Unit_FirebaseFunctionsApp.js';
4
4
  type EnvConfig = {
5
5
  defaultConfig?: string;
6
6
  envConfig?: string;
7
- identityAccount?: string;
8
7
  projectId: string;
9
8
  isLocal?: boolean;
10
9
  };
@@ -15,6 +14,7 @@ type UnitConfigJSON_FirebaseFunction = UnitConfigJSON_Node & {
15
14
  ignore?: string[];
16
15
  sslKey?: string;
17
16
  sslCert?: string;
17
+ functions: string[] | FunctionConfig[];
18
18
  };
19
19
  export declare class UnitMapper_FirebaseFunction_Class extends UnitMapper_Node<Unit_FirebaseFunctionsApp, UnitConfigJSON_FirebaseFunction> {
20
20
  static tsValidator_FirebaseFunction: {
@@ -29,11 +29,12 @@ export declare class UnitMapper_FirebaseFunction_Class extends UnitMapper_Node<U
29
29
  basePort: import("@nu-art/ts-common").Validator<number>;
30
30
  sslKey: import("@nu-art/ts-common").Validator<string>;
31
31
  sslCert: import("@nu-art/ts-common").Validator<string>;
32
+ functions: import("@nu-art/ts-common").Validator<FunctionConfig[]>;
33
+ containerDeployment: (import("@nu-art/ts-common").ValidatorImpl<any> | ((input?: object | undefined) => string | object | undefined))[];
32
34
  };
33
35
  constructor();
34
36
  protected resolveNodeUnit(context: UnitMapper_NodeContext<UnitConfigJSON_FirebaseFunction>): Promise<Unit_FirebaseFunctionsApp<{
35
37
  envConfig: {
36
- identityAccount: string | undefined;
37
38
  defaultConfig: string | undefined;
38
39
  envConfig: string | undefined;
39
40
  projectId: string;
@@ -52,6 +53,7 @@ export declare class UnitMapper_FirebaseFunction_Class extends UnitMapper_Node<U
52
53
  basePort: number;
53
54
  envs: TypedMap<EnvConfig>;
54
55
  ignore?: string[] | undefined;
56
+ functions: string[] | FunctionConfig[];
55
57
  pathToFirebaseConfig: string;
56
58
  pathToEmulatorData: string;
57
59
  fullPath: import("@nu-art/ts-common").AbsolutePath;
@@ -0,0 +1,105 @@
1
+ import { ImplementationMissingException, tsValidate_OptionalArray, tsValidateAnyNumber, tsValidateAnyString, tsValidateBoolean, tsValidateDynamicObject, tsValidateOptionalAnyNumber, tsValidateOptionalAnyString, tsValidateOptionalObject, tsValidateRegexp, tsValidateResult, tsValidateValue } from '@nu-art/ts-common';
2
+ import { UnitMapper_Node } from './UnitMapper_Node.js';
3
+ import { Unit_FirebaseFunctionsApp } from '../../implementations/firebase/Unit_FirebaseFunctionsApp.js';
4
+ import { resolve } from 'path';
5
+ import { BaiParam_SetEnv } from '../../../core/params.js';
6
+ const valuesValidator = {
7
+ defaultConfig: tsValidateOptionalAnyString,
8
+ envConfig: tsValidateOptionalAnyString,
9
+ projectId: tsValidateAnyString,
10
+ isLocal: tsValidateBoolean(false),
11
+ };
12
+ // Docker image name validation: lowercase, alphanumeric with dots, underscores, hyphens
13
+ // Cannot start/end with separators, no consecutive separators
14
+ // Pattern: starts with alphanumeric, optionally followed by (separator + alphanumeric) groups
15
+ const imageNameRegex = /^[a-z0-9]+([._-][a-z0-9]+)*$/;
16
+ const containerDeploymentValidator = {
17
+ artifactRegistry: {
18
+ region: tsValidateAnyString,
19
+ repository: tsValidateAnyString,
20
+ projectId: tsValidateAnyString,
21
+ },
22
+ imageName: tsValidateRegexp(imageNameRegex, true), // Required: Docker image name matching Artifact Registry rules
23
+ dockerfile: tsValidateOptionalAnyString,
24
+ };
25
+ // Validator for FunctionResourceConfig
26
+ const functionResourceConfigValidator = {
27
+ cpu: tsValidateAnyNumber,
28
+ memory: tsValidateOptionalAnyString,
29
+ timeout: tsValidateOptionalAnyNumber,
30
+ concurrency: tsValidateOptionalAnyNumber,
31
+ minInstances: tsValidateOptionalAnyNumber,
32
+ maxInstances: tsValidateOptionalAnyNumber,
33
+ };
34
+ // Validator for FunctionConfig
35
+ const functionConfigValidator = {
36
+ name: tsValidateAnyString,
37
+ trigger: tsValidateValue(['http', 'schedule', 'eventarc']),
38
+ schedule: tsValidateOptionalAnyString,
39
+ serviceAccountName: tsValidateOptionalAnyString,
40
+ resources: tsValidateOptionalObject(functionResourceConfigValidator),
41
+ };
42
+ // Validator for functions array: accepts either string[] or FunctionConfig[]
43
+ // Uses custom validator to check type first, then validate accordingly
44
+ const functionItemValidator = (input) => {
45
+ if (typeof input === 'string') {
46
+ // Legacy format: just a string (function name)
47
+ return tsValidateResult(input, tsValidateAnyString);
48
+ }
49
+ if (typeof input === 'object' && input !== null) {
50
+ // New format: FunctionConfig object
51
+ return tsValidateResult(input, tsValidateOptionalObject(functionConfigValidator));
52
+ }
53
+ return 'Function item must be either a string (function name) or an object (FunctionConfig)';
54
+ };
55
+ const functionsArrayValidator = tsValidate_OptionalArray(functionItemValidator);
56
+ export class UnitMapper_FirebaseFunction_Class extends UnitMapper_Node {
57
+ static tsValidator_FirebaseFunction = {
58
+ type: tsValidateValue(['firebase-function']),
59
+ ignore: tsValidate_OptionalArray(tsValidateOptionalAnyString),
60
+ envs: tsValidateDynamicObject(valuesValidator, tsValidateAnyString),
61
+ debugPort: tsValidateOptionalAnyNumber,
62
+ basePort: tsValidateOptionalAnyNumber,
63
+ sslKey: tsValidateOptionalAnyString,
64
+ sslCert: tsValidateOptionalAnyString,
65
+ functions: functionsArrayValidator, // Required: non-empty array validated in process, accepts string[] or FunctionConfig[]
66
+ containerDeployment: tsValidateOptionalObject(containerDeploymentValidator),
67
+ ...UnitMapper_Node.tsValidator_Node,
68
+ };
69
+ constructor() {
70
+ super(UnitMapper_FirebaseFunction_Class.tsValidator_FirebaseFunction);
71
+ }
72
+ async resolveNodeUnit(context) {
73
+ const outputDir = context.packageJson.publishConfig?.directory;
74
+ const env = this.runtimeParams[BaiParam_SetEnv.keyName];
75
+ const envUnitConfig = context.packageJson.unitConfig.envs[env];
76
+ if (!envUnitConfig)
77
+ throw new ImplementationMissingException(`Missing configuration for env: ${env}`);
78
+ const envConfig = {
79
+ defaultConfig: envUnitConfig.defaultConfig,
80
+ envConfig: envUnitConfig.envConfig,
81
+ projectId: envUnitConfig.projectId,
82
+ isLocal: envUnitConfig.isLocal ?? env === 'local'
83
+ };
84
+ const { type, ...unitConfig } = context.packageJson.unitConfig;
85
+ // Validate functions array is required and non-empty
86
+ if (!unitConfig.functions || !Array.isArray(unitConfig.functions) || unitConfig.functions.length === 0) {
87
+ throw new ImplementationMissingException(`Missing or empty 'functions' array in unit config for ${context.baseConfig.key}. Functions must be explicitly declared.`);
88
+ }
89
+ return new Unit_FirebaseFunctionsApp({
90
+ ...context.baseConfig,
91
+ ...Unit_FirebaseFunctionsApp.DefaultConfig_FirebaseFunction,
92
+ ...unitConfig,
93
+ envConfig,
94
+ isTopLevelApp: true,
95
+ hasSelfHotReload: unitConfig.hasSelfHotReload ?? false,
96
+ packageJson: context.packageJson,
97
+ customESLintConfig: context.customESLintConfig,
98
+ customTSConfig: context.customTSConfig,
99
+ output: resolve(context.baseConfig.fullPath, outputDir ?? Unit_FirebaseFunctionsApp.DefaultConfig_FirebaseFunction.output),
100
+ sslCert: resolve(context.baseConfig.fullPath, unitConfig.sslCert ?? Unit_FirebaseFunctionsApp.DefaultConfig_FirebaseFunction.sslCert),
101
+ sslKey: resolve(context.baseConfig.fullPath, unitConfig.sslKey ?? Unit_FirebaseFunctionsApp.DefaultConfig_FirebaseFunction.sslKey),
102
+ });
103
+ }
104
+ }
105
+ export const UnitMapper_FirebaseFunction = new UnitMapper_FirebaseFunction_Class();
@@ -1,6 +1,6 @@
1
1
  import { TypedMap } from '@nu-art/ts-common';
2
2
  import { UnitMapper_Node, UnitMapper_NodeContext } from './UnitMapper_Node.js';
3
- import { FirebaseHosting_EnvConfig, Unit_FirebaseHostingApp, UnitConfigJSON_FirebaseHosting } from '../../units/firebase/Unit_FirebaseHostingApp.js';
3
+ import { FirebaseHosting_EnvConfig, Unit_FirebaseHostingApp, UnitConfigJSON_FirebaseHosting } from '../../implementations/firebase/Unit_FirebaseHostingApp.js';
4
4
  export declare class UnitMapper_FirebaseHosting_Class extends UnitMapper_Node<Unit_FirebaseHostingApp, UnitConfigJSON_FirebaseHosting> {
5
5
  static tsValidator_FirebaseHosting: {
6
6
  label: import("@nu-art/ts-common").Validator<string>;
@@ -11,6 +11,7 @@ export declare class UnitMapper_FirebaseHosting_Class extends UnitMapper_Node<Un
11
11
  servingPort: import("@nu-art/ts-common").Validator<number>;
12
12
  envs: (import("@nu-art/ts-common").ValidatorImpl<any> | ((input?: TypedMap<FirebaseHosting_EnvConfig> | undefined) => import("@nu-art/ts-common").InvalidResultObject<TypedMap<FirebaseHosting_EnvConfig>> | undefined))[];
13
13
  hostingConfig: import("@nu-art/ts-common").ValidatorImpl<any>;
14
+ hostingDeployment: (import("@nu-art/ts-common").ValidatorImpl<any> | ((input?: object | undefined) => string | object | undefined))[];
14
15
  };
15
16
  constructor();
16
17
  protected resolveNodeUnit(context: UnitMapper_NodeContext<UnitConfigJSON_FirebaseHosting>): Promise<Unit_FirebaseHostingApp<{
@@ -27,7 +28,7 @@ export declare class UnitMapper_FirebaseHosting_Class extends UnitMapper_Node<Un
27
28
  packageJson: import("../types.js").TS_PackageJSON<UnitConfigJSON_FirebaseHosting>;
28
29
  label: string;
29
30
  servingPort: number;
30
- hostingConfig?: import("../../units/firebase/Unit_FirebaseHostingApp.js").FirebaseHostingConfig | undefined;
31
+ hostingConfig?: import("../../implementations/firebase/Unit_FirebaseHostingApp.js").FirebaseHostingConfig | undefined;
31
32
  envs: TypedMap<FirebaseHosting_EnvConfig>;
32
33
  fullPath: import("@nu-art/ts-common").AbsolutePath;
33
34
  relativePath: import("@nu-art/ts-common").RelativePath;
@@ -1,19 +1,27 @@
1
- import { tsValidateAnyString, tsValidateBoolean, tsValidateDynamicObject, tsValidateMustExist, tsValidateOptional, tsValidateOptionalAnyNumber, tsValidateValue } from '@nu-art/ts-common';
1
+ import { ImplementationMissingException, tsValidateAnyString, tsValidateBoolean, tsValidateDynamicObject, tsValidateMustExist, tsValidateOptional, tsValidateOptionalAnyNumber, tsValidateOptionalObject, tsValidateValue } from '@nu-art/ts-common';
2
2
  import { UnitMapper_Node } from './UnitMapper_Node.js';
3
- import { Unit_FirebaseHostingApp } from '../../units/firebase/Unit_FirebaseHostingApp.js';
3
+ import { Unit_FirebaseHostingApp } from '../../implementations/firebase/Unit_FirebaseHostingApp.js';
4
4
  import { resolve } from 'path';
5
- import { BaiParam_SetEnv } from '../../../core/params/params.js';
5
+ import { BaiParam_SetEnv } from '../../../core/params.js';
6
6
  const valuesValidator = {
7
7
  config: tsValidateMustExist,
8
8
  projectId: tsValidateAnyString,
9
9
  isLocal: tsValidateBoolean(false),
10
10
  };
11
+ const hostingDeploymentValidator = {
12
+ artifactRegistry: {
13
+ region: tsValidateAnyString,
14
+ repository: tsValidateAnyString,
15
+ projectId: tsValidateAnyString,
16
+ },
17
+ };
11
18
  export class UnitMapper_FirebaseHosting_Class extends UnitMapper_Node {
12
19
  static tsValidator_FirebaseHosting = {
13
20
  type: tsValidateValue(['firebase-hosting']),
14
21
  servingPort: tsValidateOptionalAnyNumber,
15
22
  envs: tsValidateDynamicObject(valuesValidator, tsValidateAnyString),
16
23
  hostingConfig: tsValidateOptional,
24
+ hostingDeployment: tsValidateOptionalObject(hostingDeploymentValidator),
17
25
  ...UnitMapper_Node.tsValidator_Node,
18
26
  };
19
27
  constructor() {
@@ -22,14 +30,10 @@ export class UnitMapper_FirebaseHosting_Class extends UnitMapper_Node {
22
30
  async resolveNodeUnit(context) {
23
31
  const outputDir = context.packageJson.publishConfig?.directory;
24
32
  const env = this.runtimeParams[BaiParam_SetEnv.keyName];
25
- let envUnitConfig = context.packageJson.unitConfig.envs[env];
33
+ const envUnitConfig = context.packageJson.unitConfig.envs[env];
26
34
  if (!envUnitConfig) {
27
- this.logWarning(`Missing EnvConfig in unit ${context.baseConfig.key}`);
28
- envUnitConfig = {
29
- config: {},
30
- projectId: '',
31
- isLocal: true
32
- };
35
+ this.logWarning('Package Json config:', context.packageJson.unitConfig);
36
+ throw new ImplementationMissingException(`Missing configuration for env: ${env}`);
33
37
  }
34
38
  const envConfig = {
35
39
  config: envUnitConfig.config,
@@ -1,6 +1,6 @@
1
1
  import { TS_PackageJSON } from '../types.js';
2
2
  import { TypeValidator } from '@nu-art/ts-common';
3
- import { BaseUnit } from '../../units/index.js';
3
+ import { BaseUnit } from '../../index.js';
4
4
  import { BaseUnitConfig, UnitConfigJSON_Base, UnitMapper_Base } from './UnitMapper_Base.js';
5
5
  export type UnitConfigJSON_Node = UnitConfigJSON_Base & {
6
6
  label: string;
@@ -1,5 +1,5 @@
1
1
  import { _keys, deepClone, tsValidate, tsValidateBoolean, tsValidateOptionalAnyString, tsValidateResult } from '@nu-art/ts-common';
2
- import { FilesCache } from '../../core/FilesCache.js';
2
+ import { FilesCache } from '../../../core/FilesCache.js';
3
3
  import { UnitMapper_Base } from './UnitMapper_Base.js';
4
4
  import { FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
5
5
  export class UnitMapper_Node extends UnitMapper_Base {
@@ -32,7 +32,7 @@ export class UnitMapper_Node extends UnitMapper_Base {
32
32
  if (tsValidateResult(packageJson.unitConfig.type, this.validator.type))
33
33
  return; // not the expected type for this mapper
34
34
  packageJson = deepClone(packageJson);
35
- tsValidate(packageJson.unitConfig, this.validator, false);
35
+ tsValidate(packageJson.unitConfig, this.validator);
36
36
  const dependencies = packageJson.dependencies;
37
37
  if (dependencies)
38
38
  packageJson.dependencies = _keys(dependencies).reduce((acc, key) => {
@@ -1,5 +1,21 @@
1
- import { Unit_TypescriptLib } from '../../units/index.js';
1
+ import { Unit_TypescriptLib } from '../../implementations/Unit_TypescriptLib.js';
2
2
  import { UnitMapper_Node, UnitMapper_NodeContext } from './UnitMapper_Node.js';
3
+ /**
4
+ * Mapper for discovering TypeScript library units.
5
+ *
6
+ * **Discovery Criteria**:
7
+ * - Must have `package.json` with `unitConfig.type === 'typescript-lib'`
8
+ * - Must have `publishConfig.directory` (output directory)
9
+ * - Must have TypeScript source files
10
+ *
11
+ * **Unit Creation**:
12
+ * - Creates `Unit_TypescriptLib` instance
13
+ * - Configures output directory from `publishConfig.directory`
14
+ * - Sets hot reload flag from `unitConfig.hasSelfHotReload`
15
+ * - Detects custom ESLint/TSConfig files
16
+ *
17
+ * **Usage**: Automatically registered by `BuildAndInstall.prepareUnitsMapper()`.
18
+ */
3
19
  export declare class UnitMapper_NodeLib_Class extends UnitMapper_Node<Unit_TypescriptLib> {
4
20
  static tsValidator_NodeProject: {
5
21
  label: import("@nu-art/ts-common").Validator<string>;
@@ -9,6 +25,13 @@ export declare class UnitMapper_NodeLib_Class extends UnitMapper_Node<Unit_Types
9
25
  type: import("@nu-art/ts-common").Validator<any>;
10
26
  };
11
27
  constructor();
28
+ /**
29
+ * Creates a Unit_TypescriptLib instance from resolved context.
30
+ *
31
+ * @param context - Resolved node unit context
32
+ * @returns Unit_TypescriptLib instance
33
+ * @throws BadImplementationException if publishConfig.directory is missing
34
+ */
12
35
  protected resolveNodeUnit(context: UnitMapper_NodeContext): Promise<Unit_TypescriptLib<{
13
36
  hasSelfHotReload: boolean;
14
37
  customESLintConfig: boolean;
@@ -1,7 +1,23 @@
1
- import { Unit_TypescriptLib } from '../../units/index.js';
1
+ import { Unit_TypescriptLib } from '../../implementations/Unit_TypescriptLib.js';
2
2
  import { BadImplementationException, tsValidateValue } from '@nu-art/ts-common';
3
3
  import { UnitMapper_Node } from './UnitMapper_Node.js';
4
4
  import { resolve } from 'path';
5
+ /**
6
+ * Mapper for discovering TypeScript library units.
7
+ *
8
+ * **Discovery Criteria**:
9
+ * - Must have `package.json` with `unitConfig.type === 'typescript-lib'`
10
+ * - Must have `publishConfig.directory` (output directory)
11
+ * - Must have TypeScript source files
12
+ *
13
+ * **Unit Creation**:
14
+ * - Creates `Unit_TypescriptLib` instance
15
+ * - Configures output directory from `publishConfig.directory`
16
+ * - Sets hot reload flag from `unitConfig.hasSelfHotReload`
17
+ * - Detects custom ESLint/TSConfig files
18
+ *
19
+ * **Usage**: Automatically registered by `BuildAndInstall.prepareUnitsMapper()`.
20
+ */
5
21
  export class UnitMapper_NodeLib_Class extends UnitMapper_Node {
6
22
  static tsValidator_NodeProject = {
7
23
  type: tsValidateValue(['typescript-lib']),
@@ -10,6 +26,13 @@ export class UnitMapper_NodeLib_Class extends UnitMapper_Node {
10
26
  constructor() {
11
27
  super(UnitMapper_NodeLib_Class.tsValidator_NodeProject);
12
28
  }
29
+ /**
30
+ * Creates a Unit_TypescriptLib instance from resolved context.
31
+ *
32
+ * @param context - Resolved node unit context
33
+ * @returns Unit_TypescriptLib instance
34
+ * @throws BadImplementationException if publishConfig.directory is missing
35
+ */
13
36
  async resolveNodeUnit(context) {
14
37
  const outputDir = context.packageJson.publishConfig?.directory;
15
38
  if (!outputDir)
@@ -1,5 +1,20 @@
1
- import { Unit_NodeProject } from '../../units/index.js';
1
+ import { Unit_NodeProject } from '../../implementations/Unit_NodeProject.js';
2
2
  import { UnitMapper_Node, UnitMapper_NodeContext } from './UnitMapper_Node.js';
3
+ /**
4
+ * Mapper for discovering root NodeProject unit.
5
+ *
6
+ * **Discovery Criteria**:
7
+ * - Must have `package.json` with `unitConfig.type === 'node-project'`
8
+ * - Typically the monorepo root
9
+ *
10
+ * **Unit Creation**:
11
+ * - Creates `Unit_NodeProject` instance
12
+ * - Marks as root and top-level app
13
+ * - Enables hot reload
14
+ *
15
+ * **Usage**: Automatically registered by `BuildAndInstall.prepareUnitsMapper()`.
16
+ * There should typically be only one NodeProject unit per workspace.
17
+ */
3
18
  export declare class UnitMapper_NodeProject_Class extends UnitMapper_Node<Unit_NodeProject> {
4
19
  static tsValidator_NodeProject: {
5
20
  label: import("@nu-art/ts-common").Validator<string>;
@@ -9,6 +24,12 @@ export declare class UnitMapper_NodeProject_Class extends UnitMapper_Node<Unit_N
9
24
  type: import("@nu-art/ts-common").Validator<any>;
10
25
  };
11
26
  constructor();
27
+ /**
28
+ * Creates a Unit_NodeProject instance from resolved context.
29
+ *
30
+ * @param context - Resolved node unit context
31
+ * @returns Unit_NodeProject instance
32
+ */
12
33
  protected resolveNodeUnit(context: UnitMapper_NodeContext): Promise<Unit_NodeProject<{
13
34
  isTopLevelApp: true;
14
35
  isRoot: true;
@@ -1,6 +1,21 @@
1
- import { Unit_NodeProject } from '../../units/index.js';
1
+ import { Unit_NodeProject } from '../../implementations/Unit_NodeProject.js';
2
2
  import { tsValidateValue } from '@nu-art/ts-common';
3
3
  import { UnitMapper_Node } from './UnitMapper_Node.js';
4
+ /**
5
+ * Mapper for discovering root NodeProject unit.
6
+ *
7
+ * **Discovery Criteria**:
8
+ * - Must have `package.json` with `unitConfig.type === 'node-project'`
9
+ * - Typically the monorepo root
10
+ *
11
+ * **Unit Creation**:
12
+ * - Creates `Unit_NodeProject` instance
13
+ * - Marks as root and top-level app
14
+ * - Enables hot reload
15
+ *
16
+ * **Usage**: Automatically registered by `BuildAndInstall.prepareUnitsMapper()`.
17
+ * There should typically be only one NodeProject unit per workspace.
18
+ */
4
19
  export class UnitMapper_NodeProject_Class extends UnitMapper_Node {
5
20
  static tsValidator_NodeProject = {
6
21
  type: tsValidateValue(['node-project']),
@@ -9,6 +24,12 @@ export class UnitMapper_NodeProject_Class extends UnitMapper_Node {
9
24
  constructor() {
10
25
  super(UnitMapper_NodeProject_Class.tsValidator_NodeProject);
11
26
  }
27
+ /**
28
+ * Creates a Unit_NodeProject instance from resolved context.
29
+ *
30
+ * @param context - Resolved node unit context
31
+ * @returns Unit_NodeProject instance
32
+ */
12
33
  async resolveNodeUnit(context) {
13
34
  return new Unit_NodeProject({
14
35
  ...context.baseConfig,
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,59 @@
1
+ import { UnitPhaseImplementor } from '../../core/types.js';
2
+ import { StringMap } from '@nu-art/ts-common/utils/types';
3
+ import { Unit_PackageJson, Unit_PackageJson_Config } from './Unit_PackageJson.js';
4
+ import { ProjectUnit } from '../base/ProjectUnit.js';
5
+ import { Phase_Install, Phase_IndicesMcpServer, Phase_PostPublish, Phase_Watch } from '../../phases/definitions/index.js';
6
+ /**
7
+ * Configuration for NodeProject (root project unit).
8
+ */
9
+ type Unit_TypescriptProject_Config = Unit_PackageJson_Config & {
10
+ globalPackages?: StringMap;
11
+ isRoot: true;
12
+ };
13
+ /**
14
+ * Root project unit representing the entire monorepo/workspace.
15
+ *
16
+ * **Key Responsibilities**:
17
+ * - Manages child units (all packages in workspace)
18
+ * - Handles workspace-level operations (install, watch)
19
+ * - Creates PNPM workspace configuration
20
+ * - Manages file watching for hot reload
21
+ *
22
+ * **Phases Implemented**:
23
+ * - `install()`: Installs all packages using PNPM workspace
24
+ * - `watch()`: Watches file changes and triggers incremental compilation
25
+ * - `postPublish()`: Post-publish operations
26
+ *
27
+ * **Watch Mode**:
28
+ * - Watches TypeScript, SCSS, JSON, SVG files in all child units
29
+ * - Uses chokidar for file watching
30
+ * - Debounces changes and compiles affected units in dependency order
31
+ * - Supports hot reload for units with `hasSelfHotReload` flag
32
+ *
33
+ * **Workspace Management**:
34
+ * - Creates `pnpm-workspace.yaml` with all child unit paths
35
+ * - Manages global packages installation
36
+ * - Handles dependency tree for watch compilation
37
+ */
38
+ export declare class Unit_NodeProject<C extends Unit_TypescriptProject_Config = Unit_TypescriptProject_Config> extends Unit_PackageJson<C> implements UnitPhaseImplementor<[Phase_Install, Phase_Watch, Phase_PostPublish, Phase_IndicesMcpServer]> {
39
+ private watcher?;
40
+ readonly innerUnits: Unit_PackageJson[];
41
+ private readonly suffixesToWatch;
42
+ constructor(config: Unit_NodeProject<C>['config']);
43
+ protected deriveDistDependencies(): StringMap;
44
+ assignUnit(units: ProjectUnit[]): void;
45
+ /**
46
+ * Resolve all paths to watch in all project libs
47
+ * @private
48
+ * @returns string[]
49
+ */
50
+ private prepareWatchPaths;
51
+ stopWatch(): Promise<void | undefined>;
52
+ private findUnit;
53
+ install(): Promise<void>;
54
+ watch(timeout?: number, maxTimeout?: number): Promise<void>;
55
+ purge(): Promise<void>;
56
+ postPublish(): Promise<void>;
57
+ indicesMcpServer(): Promise<void>;
58
+ }
59
+ export {};
@@ -6,13 +6,39 @@ import { Commando_PNPM } from '@nu-art/commando/shell/plugins/pnpm';
6
6
  import { PNPM } from '@nu-art/commando/shell/services/pnpm';
7
7
  import { Unit_PackageJson } from './Unit_PackageJson.js';
8
8
  import { resolve } from 'path';
9
- import { PhaseManager } from '../PhaseManager.js';
10
- import { phase_CompileWatch } from '../phase/index.js';
11
- import { UnitsDependencyMapper } from '../UnitsDependencyMapper/UnitsDependencyMapper.js';
9
+ import { PhaseManager } from '../../phases/PhaseManager.js';
10
+ import { phase_CompileWatch } from '../../phases/definitions/index.js';
11
+ import { UnitsDependencyMapper } from '../../dependencies/UnitsDependencyMapper.js';
12
12
  import { CommandoException } from '@nu-art/commando/shell/core/CliError';
13
- import { CONST_PNPM_LOCK, CONST_PNPM_WORKSPACE } from '../../core/consts.js';
14
- import { RunningStatusHandler } from '../RunningStatusHandler.js';
13
+ import { CONST_PNPM_LOCK, CONST_PNPM_WORKSPACE } from '../../config/consts.js';
14
+ import { RunningStatusHandler } from '../../runtime/RunningStatusHandler.js';
15
15
  import { FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
16
+ import { IndicesMcpServer } from '../../exports/IndicesMcpServer.js';
17
+ /**
18
+ * Root project unit representing the entire monorepo/workspace.
19
+ *
20
+ * **Key Responsibilities**:
21
+ * - Manages child units (all packages in workspace)
22
+ * - Handles workspace-level operations (install, watch)
23
+ * - Creates PNPM workspace configuration
24
+ * - Manages file watching for hot reload
25
+ *
26
+ * **Phases Implemented**:
27
+ * - `install()`: Installs all packages using PNPM workspace
28
+ * - `watch()`: Watches file changes and triggers incremental compilation
29
+ * - `postPublish()`: Post-publish operations
30
+ *
31
+ * **Watch Mode**:
32
+ * - Watches TypeScript, SCSS, JSON, SVG files in all child units
33
+ * - Uses chokidar for file watching
34
+ * - Debounces changes and compiles affected units in dependency order
35
+ * - Supports hot reload for units with `hasSelfHotReload` flag
36
+ *
37
+ * **Workspace Management**:
38
+ * - Creates `pnpm-workspace.yaml` with all child unit paths
39
+ * - Manages global packages installation
40
+ * - Handles dependency tree for watch compilation
41
+ */
16
42
  export class Unit_NodeProject extends Unit_PackageJson {
17
43
  watcher;
18
44
  innerUnits = [];
@@ -162,7 +188,8 @@ export class Unit_NodeProject extends Unit_PackageJson {
162
188
  noBuild: false,
163
189
  continue: false
164
190
  };
165
- const phaseManager = new PhaseManager(new RunningStatusHandler(this.config.fullPath, watchRuntimeParams).isolate(), [[phase_CompileWatch]], unitDependencyTree);
191
+ const activeUnitKeys = this.runtimeContext.childUnits.map(unit => unit.config.key);
192
+ const phaseManager = new PhaseManager(new RunningStatusHandler(this.config.fullPath, watchRuntimeParams).isolate(), [[phase_CompileWatch]], unitDependencyTree, activeUnitKeys, activeUnitKeys);
166
193
  // @ts-ignore
167
194
  phaseManager.setTag('PhaseManager-Watcher');
168
195
  const executionPlan = await phaseManager.calculateExecutionSteps();
@@ -240,4 +267,38 @@ export class Unit_NodeProject extends Unit_PackageJson {
240
267
  }
241
268
  async postPublish() {
242
269
  }
270
+ async indicesMcpServer() {
271
+ this.setStatus('Starting Export Indices MCP Server', 'start');
272
+ const projectRoot = this.config.fullPath;
273
+ const port = this.runtimeContext.runtimeParams.indicesMcpPort || 3001;
274
+ // Get active TypeScriptLib packages
275
+ const packages = this.innerUnits.filter(unit => unit.isInstanceOf(Unit_TypescriptLib));
276
+ if (packages.length === 0) {
277
+ this.logWarning('No TypeScriptLib packages found. MCP server will have no packages to expose.');
278
+ }
279
+ const server = new IndicesMcpServer(port, projectRoot, packages);
280
+ // Handle graceful shutdown
281
+ const shutdown = async () => {
282
+ this.logInfo('Shutting down Export Indices MCP Server...');
283
+ await server.stop();
284
+ process.exit(0);
285
+ };
286
+ process.on('SIGINT', shutdown);
287
+ process.on('SIGTERM', shutdown);
288
+ try {
289
+ await server.start();
290
+ this.setStatus('Export Indices MCP Server running', 'end');
291
+ this.logInfo(`Export Indices MCP Server is running on http://localhost:${port}`);
292
+ this.logInfo('Press Ctrl+C to stop the server');
293
+ // Keep process alive - return a promise that never resolves
294
+ return new Promise(() => {
295
+ // This promise never resolves, keeping the process alive
296
+ });
297
+ }
298
+ catch (error) {
299
+ this.logError('Failed to start Export Indices MCP Server:', error);
300
+ this.setStatus('Export Indices MCP Server failed', 'end');
301
+ throw error;
302
+ }
303
+ }
243
304
  }
@@ -0,0 +1,56 @@
1
+ import { StringMap } from '@nu-art/ts-common';
2
+ import { UnitPhaseImplementor } from '../../core/types.js';
3
+ import { Config_ProjectUnit, ProjectUnit } from '../base/ProjectUnit.js';
4
+ import { TS_PackageJSON } from '../discovery/types.js';
5
+ import { Phase_Prepare, Phase_Purge } from '../../phases/definitions/index.js';
6
+ /**
7
+ * Configuration for PackageJson units (units with package.json).
8
+ */
9
+ export type Unit_PackageJson_Config = Config_ProjectUnit & {
10
+ packageJson: TS_PackageJSON;
11
+ };
12
+ /**
13
+ * Base class for all units that have a package.json file.
14
+ *
15
+ * **Key Responsibilities**:
16
+ * - Manages package.json template transformation
17
+ * - Handles dependency derivation (lib and dist dependencies)
18
+ * - Implements prepare and purge phases
19
+ *
20
+ * **Dependency Management**:
21
+ * - `deriveLibDependencies()`: Creates workspace dependencies for development
22
+ * - `deriveDistDependencies()`: Creates versioned dependencies for distribution
23
+ *
24
+ * **Template System**: Uses FileSystemUtils to transform package.json templates
25
+ * with runtime parameters (THUNDERSTORM_VERSION, __ENV__, etc.).
26
+ *
27
+ * **Phases Implemented**:
28
+ * - `prepare()`: Generates package.json from template with resolved dependencies
29
+ * - `purge()`: Deletes package.json and node_modules
30
+ *
31
+ * **Base For**: Unit_NodeProject, Unit_TypescriptLib, Unit_FirebaseHosting, etc.
32
+ */
33
+ export declare class Unit_PackageJson<C extends Unit_PackageJson_Config = Unit_PackageJson_Config> extends ProjectUnit<C> implements UnitPhaseImplementor<[Phase_Purge, Phase_Prepare]> {
34
+ constructor(config: C);
35
+ protected npmCommand(command: string): string;
36
+ protected deriveDistDependencies(): StringMap;
37
+ protected deriveLibDependencies(): StringMap;
38
+ /**
39
+ * Prepares package.json by generating it from template with resolved dependencies.
40
+ *
41
+ * **Process**:
42
+ * 1. Derives lib dependencies (workspace:* for development)
43
+ * 2. Transforms package.json template with params
44
+ * 3. Writes transformed package.json to disk
45
+ *
46
+ * **Template Params**: Includes THUNDERSTORM_VERSION, __ENV__, and child unit versions.
47
+ */
48
+ prepare(): Promise<void>;
49
+ /**
50
+ * Purges package.json and node_modules folder.
51
+ *
52
+ * Used by `--purge` flag to clean up before reinstall.
53
+ */
54
+ purge(): Promise<void>;
55
+ protected releasePorts(allPorts: string[]): Promise<void>;
56
+ }