@webiny/project 0.0.0-unstable.ac6ebf63c6 → 0.0.0-unstable.c27f4d8a31

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 (186) hide show
  1. package/ProjectSdk.d.ts +1 -0
  2. package/ProjectSdk.js +4 -1
  3. package/ProjectSdk.js.map +1 -1
  4. package/abstractions/features/GetFeatureFlags.d.ts +8 -0
  5. package/abstractions/features/GetFeatureFlags.js +4 -0
  6. package/abstractions/features/GetFeatureFlags.js.map +1 -0
  7. package/abstractions/features/index.d.ts +1 -0
  8. package/abstractions/features/index.js +1 -0
  9. package/abstractions/features/index.js.map +1 -1
  10. package/abstractions/services/WatchedLambdaFunctionsService.d.ts +12 -7
  11. package/abstractions/services/WatchedLambdaFunctionsService.js.map +1 -1
  12. package/components/Wcp.d.ts +2 -0
  13. package/components/Wcp.js +8 -1
  14. package/components/Wcp.js.map +1 -1
  15. package/createProjectSdkContainer.js +4 -1
  16. package/createProjectSdkContainer.js.map +1 -1
  17. package/decorators/DeployAppClearWatchedLambdaFunctions.d.ts +3 -2
  18. package/decorators/DeployAppClearWatchedLambdaFunctions.js +11 -5
  19. package/decorators/DeployAppClearWatchedLambdaFunctions.js.map +1 -1
  20. package/decorators/DeployAppWithWatchedLambdaReplacement.d.ts +3 -2
  21. package/decorators/DeployAppWithWatchedLambdaReplacement.js +16 -7
  22. package/decorators/DeployAppWithWatchedLambdaReplacement.js.map +1 -1
  23. package/decorators/GetFeatureFlagsWithLicense.d.ts +13 -0
  24. package/decorators/GetFeatureFlagsWithLicense.js +71 -0
  25. package/decorators/GetFeatureFlagsWithLicense.js.map +1 -0
  26. package/decorators/index.d.ts +1 -0
  27. package/decorators/index.js +1 -0
  28. package/decorators/index.js.map +1 -1
  29. package/defineExtension/createExtensionReactComponent.js +2 -6
  30. package/defineExtension/createExtensionReactComponent.js.map +1 -1
  31. package/defineExtension/index.d.ts +0 -1
  32. package/defineExtension/index.js +0 -1
  33. package/defineExtension/index.js.map +1 -1
  34. package/defineExtension/models/ExtensionDefinitionModel.d.ts +4 -4
  35. package/defineExtension/models/ExtensionDefinitionModel.js.map +1 -1
  36. package/defineExtension/models/ExtensionInstanceModel.js +1 -1
  37. package/defineExtension/models/ExtensionInstanceModel.js.map +1 -1
  38. package/defineExtension/zodTypes/zodSrcPath.d.ts +2 -1
  39. package/defineExtension/zodTypes/zodSrcPath.js +7 -14
  40. package/defineExtension/zodTypes/zodSrcPath.js.map +1 -1
  41. package/exports/infra/index.d.ts +1 -1
  42. package/exports/infra/index.js +1 -1
  43. package/exports/infra/index.js.map +1 -1
  44. package/extensions/AdminBuildParam.d.ts +5 -0
  45. package/extensions/AdminBuildParam.js +184 -0
  46. package/extensions/AdminBuildParam.js.map +1 -0
  47. package/extensions/AdminExtension.d.ts +5 -0
  48. package/extensions/AdminExtension.js +99 -0
  49. package/extensions/AdminExtension.js.map +1 -0
  50. package/extensions/ApiBuildParam.d.ts +5 -0
  51. package/extensions/ApiBuildParam.js +119 -0
  52. package/extensions/ApiBuildParam.js.map +1 -0
  53. package/extensions/ApiExtension.d.ts +5 -0
  54. package/{defineExtension/defineApiExtension.js → extensions/ApiExtension.js} +14 -22
  55. package/extensions/ApiExtension.js.map +1 -0
  56. package/extensions/DatabaseSetup.d.ts +6 -6
  57. package/extensions/EnvVar.d.ts +1 -7
  58. package/extensions/ExtensionDefinitions.d.ts +1 -5
  59. package/extensions/FeatureFlags.d.ts +18 -0
  60. package/extensions/FeatureFlags.js +43 -0
  61. package/extensions/FeatureFlags.js.map +1 -0
  62. package/extensions/Project/EnsureTelemetryEnabledForOss.js +1 -1
  63. package/extensions/Project/EnsureTelemetryEnabledForOss.js.map +1 -1
  64. package/extensions/Project/SetAdminAppEnvVarsBeforeBuild.js +1 -0
  65. package/extensions/Project/SetAdminAppEnvVarsBeforeBuild.js.map +1 -1
  66. package/extensions/Project/SetAdminAppEnvVarsBeforeWatch.js +1 -0
  67. package/extensions/Project/SetAdminAppEnvVarsBeforeWatch.js.map +1 -1
  68. package/extensions/ProjectDecorator.d.ts +2 -6
  69. package/extensions/ProjectId.d.ts +2 -6
  70. package/extensions/ProjectImplementation.d.ts +2 -8
  71. package/extensions/Telemetry.d.ts +1 -5
  72. package/extensions/hooks/AdminAfterBuild.d.ts +2 -6
  73. package/extensions/hooks/AdminAfterDeploy.d.ts +2 -6
  74. package/extensions/hooks/AdminBeforeBuild.d.ts +2 -6
  75. package/extensions/hooks/AdminBeforeDeploy.d.ts +2 -6
  76. package/extensions/hooks/AdminBeforeWatch.d.ts +2 -6
  77. package/extensions/hooks/AfterBuild.d.ts +2 -6
  78. package/extensions/hooks/AfterDeploy.d.ts +2 -6
  79. package/extensions/hooks/ApiAfterBuild.d.ts +2 -6
  80. package/extensions/hooks/ApiAfterDeploy.d.ts +2 -6
  81. package/extensions/hooks/ApiBeforeBuild.d.ts +2 -6
  82. package/extensions/hooks/ApiBeforeDeploy.d.ts +2 -6
  83. package/extensions/hooks/ApiBeforeWatch.d.ts +2 -6
  84. package/extensions/hooks/BeforeBuild.d.ts +2 -6
  85. package/extensions/hooks/BeforeDeploy.d.ts +2 -6
  86. package/extensions/hooks/BeforeWatch.d.ts +2 -6
  87. package/extensions/hooks/CoreAfterBuild.d.ts +2 -6
  88. package/extensions/hooks/CoreAfterDeploy.d.ts +2 -6
  89. package/extensions/hooks/CoreBeforeBuild.d.ts +2 -6
  90. package/extensions/hooks/CoreBeforeDeploy.d.ts +2 -6
  91. package/extensions/hooks/CoreBeforeWatch.d.ts +2 -6
  92. package/extensions/index.d.ts +46 -53
  93. package/extensions/index.js +12 -2
  94. package/extensions/index.js.map +1 -1
  95. package/extensions/pulumi/AdminPulumi.d.ts +2 -6
  96. package/extensions/pulumi/AdminStackOutputValue.d.ts +1 -7
  97. package/extensions/pulumi/ApiPulumi.d.ts +2 -6
  98. package/extensions/pulumi/ApiStackOutputValue.d.ts +1 -7
  99. package/extensions/pulumi/CorePulumi.d.ts +2 -6
  100. package/extensions/pulumi/CoreStackOutputValue.d.ts +1 -7
  101. package/extensions/pulumi/ProductionEnvironments.d.ts +2 -6
  102. package/extensions/pulumi/PulumiResourceNamePrefix.d.ts +1 -5
  103. package/features/BuildApp/PackagesBuilder/worker.js +1 -1
  104. package/features/BuildApp/PackagesBuilder/worker.js.map +1 -1
  105. package/features/GetFeatureFlags/GetFeatureFlags.d.ts +10 -0
  106. package/features/GetFeatureFlags/GetFeatureFlags.js +29 -0
  107. package/features/GetFeatureFlags/GetFeatureFlags.js.map +1 -0
  108. package/features/GetFeatureFlags/index.d.ts +1 -0
  109. package/features/GetFeatureFlags/index.js +3 -0
  110. package/features/GetFeatureFlags/index.js.map +1 -0
  111. package/features/Watch/Watch.js +1 -0
  112. package/features/Watch/Watch.js.map +1 -1
  113. package/features/Watch/localInvocationWorker.js +5 -1
  114. package/features/Watch/localInvocationWorker.js.map +1 -1
  115. package/features/Watch/replaceLambdaFunctions.d.ts +2 -1
  116. package/features/Watch/replaceLambdaFunctions.js +5 -1
  117. package/features/Watch/replaceLambdaFunctions.js.map +1 -1
  118. package/features/index.d.ts +1 -0
  119. package/features/index.js +1 -0
  120. package/features/index.js.map +1 -1
  121. package/index.d.ts +2 -0
  122. package/index.js +2 -0
  123. package/index.js.map +1 -1
  124. package/package.json +22 -20
  125. package/services/GetProjectConfigService/GetProjectConfigService.js +2 -1
  126. package/services/GetProjectConfigService/GetProjectConfigService.js.map +1 -1
  127. package/services/GetProjectConfigService/WcpProjectLicenseContext.d.ts +1 -0
  128. package/services/GetProjectConfigService/WcpProjectLicenseContext.js +2 -1
  129. package/services/GetProjectConfigService/WcpProjectLicenseContext.js.map +1 -1
  130. package/services/GetProjectConfigService/renderConfigWorker.js +12 -3
  131. package/services/GetProjectConfigService/renderConfigWorker.js.map +1 -1
  132. package/services/GetProjectIdService/GetProjectIdService.js +1 -1
  133. package/services/GetProjectIdService/GetProjectIdService.js.map +1 -1
  134. package/services/InitProjectSdkService/applyWcpEnvVars.js +10 -8
  135. package/services/InitProjectSdkService/applyWcpEnvVars.js.map +1 -1
  136. package/services/InitProjectSdkService/registerDecorators.js +2 -2
  137. package/services/InitProjectSdkService/registerDecorators.js.map +1 -1
  138. package/services/InitProjectSdkService/registerHooks.js +2 -2
  139. package/services/InitProjectSdkService/registerHooks.js.map +1 -1
  140. package/services/InitProjectSdkService/registerImplementations.js +2 -2
  141. package/services/InitProjectSdkService/registerImplementations.js.map +1 -1
  142. package/services/InitProjectSdkService/registerPulumiExtensions.js +2 -2
  143. package/services/InitProjectSdkService/registerPulumiExtensions.js.map +1 -1
  144. package/services/InstallExtensionService/InstallExtensionService.d.ts +1 -1
  145. package/services/InstallExtensionService/InstallExtensionService.js +4 -4
  146. package/services/InstallExtensionService/InstallExtensionService.js.map +1 -1
  147. package/services/InstallExtensionService/mergePackageJson.js +4 -4
  148. package/services/InstallExtensionService/mergePackageJson.js.map +1 -1
  149. package/services/InstallExtensionService/types.d.ts +4 -0
  150. package/services/InstallExtensionService/types.js.map +1 -1
  151. package/services/InstallExtensionService/updateWebinyConfig.js +74 -47
  152. package/services/InstallExtensionService/updateWebinyConfig.js.map +1 -1
  153. package/services/ListAppLambdaFunctionsService/ListAppLambdaFunctionsService.js +1 -1
  154. package/services/ListAppLambdaFunctionsService/ListAppLambdaFunctionsService.js.map +1 -1
  155. package/services/ProjectInfoService/ProjectInfoService.js +2 -2
  156. package/services/ProjectInfoService/ProjectInfoService.js.map +1 -1
  157. package/services/SetProjectIdService/SetProjectIdService.js +28 -18
  158. package/services/SetProjectIdService/SetProjectIdService.js.map +1 -1
  159. package/services/WatchedLambdaFunctionsService/WatchedLambdaFunctionsService.d.ts +4 -4
  160. package/services/WatchedLambdaFunctionsService/WatchedLambdaFunctionsService.js +26 -20
  161. package/services/WatchedLambdaFunctionsService/WatchedLambdaFunctionsService.js.map +1 -1
  162. package/utils/ExtensionSrcResolver.d.ts +33 -0
  163. package/utils/ExtensionSrcResolver.js +120 -0
  164. package/utils/ExtensionSrcResolver.js.map +1 -0
  165. package/utils/index.d.ts +2 -1
  166. package/utils/index.js +2 -1
  167. package/utils/index.js.map +1 -1
  168. package/utils/requireConfig.js +9 -5
  169. package/utils/requireConfig.js.map +1 -1
  170. package/utils/toImportSpecifier.d.ts +5 -0
  171. package/utils/toImportSpecifier.js +12 -0
  172. package/utils/toImportSpecifier.js.map +1 -0
  173. package/defineExtension/defineApiExtension.d.ts +0 -17
  174. package/defineExtension/defineApiExtension.js.map +0 -1
  175. package/exports/extensions.d.ts +0 -1
  176. package/exports/extensions.js +0 -3
  177. package/exports/extensions.js.map +0 -1
  178. package/features/BuildApp/PackagesBuilder/utils/requireConfig.d.ts +0 -18
  179. package/features/BuildApp/PackagesBuilder/utils/requireConfig.js +0 -15
  180. package/features/BuildApp/PackagesBuilder/utils/requireConfig.js.map +0 -1
  181. package/features/Watch/watchers/utils/requireConfig.d.ts +0 -18
  182. package/features/Watch/watchers/utils/requireConfig.js +0 -15
  183. package/features/Watch/watchers/utils/requireConfig.js.map +0 -1
  184. package/utils/ImplPathResolver.d.ts +0 -10
  185. package/utils/ImplPathResolver.js +0 -27
  186. package/utils/ImplPathResolver.js.map +0 -1
@@ -10,27 +10,27 @@ import fs from "fs";
10
10
  const serializePropsToJsx = props => {
11
11
  const attributes = [];
12
12
  for (const [key, value] of Object.entries(props)) {
13
- // Skip undefined values
13
+ // Skip undefined values.
14
14
  if (value === undefined) {
15
15
  continue;
16
16
  }
17
17
 
18
- // Determine the serialization based on value type
18
+ // Determine the serialization based on value type.
19
19
  let serializedValue;
20
20
  if (typeof value === "string") {
21
- // Strings: use JSON.stringify to handle escaping, then wrap in curly braces
21
+ // Strings: use JSON.stringify to handle escaping, then wrap in curly braces.
22
22
  serializedValue = `{${JSON.stringify(value)}}`;
23
23
  } else if (typeof value === "number" || typeof value === "boolean") {
24
- // Numbers and booleans: wrap in curly braces without quotes
24
+ // Numbers and booleans: wrap in curly braces without quotes.
25
25
  serializedValue = `{${value}}`;
26
26
  } else if (value === null) {
27
- // Null values
27
+ // Null values.
28
28
  serializedValue = `{null}`;
29
29
  } else if (Array.isArray(value) || typeof value === "object") {
30
- // Arrays and objects: use JSON.stringify, then wrap in curly braces
30
+ // Arrays and objects: use JSON.stringify, then wrap in curly braces.
31
31
  serializedValue = `{${JSON.stringify(value)}}`;
32
32
  } else {
33
- // Fallback for any other types
33
+ // Fallback for any other types.
34
34
  serializedValue = `{${JSON.stringify(value)}}`;
35
35
  }
36
36
  attributes.push(`${key}=${serializedValue}`);
@@ -38,6 +38,48 @@ const serializePropsToJsx = props => {
38
38
  return attributes.join(" ");
39
39
  };
40
40
 
41
+ /**
42
+ * Adds a component to the Extensions function in the webiny.config.tsx content.
43
+ */
44
+ const addComponentToExtensions = (content, componentName, props) => {
45
+ // Serialize props to JSX attributes.
46
+ const propsString = props ? serializePropsToJsx(props) : "";
47
+
48
+ // Generate component tag with or without props.
49
+ const componentTag = propsString ? `<${componentName} ${propsString} />` : `<${componentName} />`;
50
+
51
+ // Check if component already exists.
52
+ if (content.includes(componentTag)) {
53
+ return content;
54
+ }
55
+
56
+ // Find the Extensions function's return statement and add component before the final </>.
57
+ // Strategy: Find "export const Extensions" block, then find the last </> and insert before it.
58
+ const extensionsFuncRegex = /export const Extensions = \(\) => \{[\s\S]*?\};/;
59
+ const extensionsFuncMatch = content.match(extensionsFuncRegex);
60
+ if (!extensionsFuncMatch) {
61
+ return content;
62
+ }
63
+ const funcContent = extensionsFuncMatch[0];
64
+ // Find all </> in the function - the last one closes the return statement.
65
+ const closingTags = [...funcContent.matchAll(/<\/>/g)];
66
+ if (closingTags.length === 0) {
67
+ return content;
68
+ }
69
+ const lastClosingTag = closingTags[closingTags.length - 1];
70
+ const lastClosingTagIndex = lastClosingTag.index;
71
+
72
+ // Find the indentation of the line containing the last </>.
73
+ const beforeClosing = funcContent.substring(0, lastClosingTagIndex);
74
+ const lines = beforeClosing.split("\n");
75
+ const lastLine = lines[lines.length - 1];
76
+ const indent = lastLine.match(/^(\s*)/)?.[1] || " ";
77
+
78
+ // Insert the component before the last </>.
79
+ const newFuncContent = funcContent.substring(0, lastClosingTagIndex) + `${indent}${componentTag}\n${indent}` + funcContent.substring(lastClosingTagIndex);
80
+ return content.replace(extensionsFuncRegex, newFuncContent);
81
+ };
82
+
41
83
  /**
42
84
  * Update the webiny.config.tsx file to add extension imports and component.
43
85
  */
@@ -54,62 +96,47 @@ export const updateWebinyConfig = async params => {
54
96
  // Add imports at the top (after existing imports)
55
97
  if (webinyConfigTsx.imports && webinyConfigTsx.imports.length > 0) {
56
98
  for (const importStatement of webinyConfigTsx.imports) {
57
- const importLine = `import { ${importStatement.specifier} } from "${importStatement.path}";`;
99
+ // Check if we need to add to an existing import from the same path.
100
+ const existingImportRegex = new RegExp(`import\\s+{([^}]+)}\\s+from\\s+["']${importStatement.path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["'];?`, "m");
101
+ const existingImportMatch = content.match(existingImportRegex);
102
+ if (existingImportMatch) {
103
+ // Import from this path exists, check if specifier is already imported.
104
+ const existingSpecifiers = existingImportMatch[1].split(",").map(s => s.trim());
105
+ if (!existingSpecifiers.includes(importStatement.specifier)) {
106
+ // Append the new specifier to the existing import.
107
+ const updatedSpecifiers = [...existingSpecifiers, importStatement.specifier].join(", ");
108
+ const updatedImportLine = `import { ${updatedSpecifiers} } from "${importStatement.path}";`;
109
+ content = content.replace(existingImportRegex, updatedImportLine);
110
+ }
111
+ } else {
112
+ // No existing import from this path, add a new import line.
113
+ const importLine = `import { ${importStatement.specifier} } from "${importStatement.path}";`;
58
114
 
59
- // Check if import already exists
60
- if (!content.includes(importLine)) {
61
- // Find the position after the last import or at the beginning
115
+ // Find the position after the last import or at the beginning.
62
116
  const importRegex = /^import\s+.*?from\s+["'].*?["'];?\s*$/gm;
63
117
  const matches = Array.from(content.matchAll(importRegex));
64
118
  if (matches.length > 0) {
65
- // Add after the last import
119
+ // Add after the last import.
66
120
  const lastImport = matches[matches.length - 1];
67
121
  const lastImportEnd = lastImport.index + lastImport[0].length;
68
122
  content = content.slice(0, lastImportEnd) + "\n" + importLine + content.slice(lastImportEnd);
69
123
  } else {
70
- // No imports found, add at the beginning
124
+ // No imports found, add at the beginning.
71
125
  content = importLine + "\n\n" + content;
72
126
  }
73
127
  }
74
128
  }
75
129
  }
76
130
 
77
- // Add component to the Extensions function
131
+ // Add component to the Extensions function.
78
132
  if (webinyConfigTsx.component) {
79
- const componentName = webinyConfigTsx.component.name;
80
- const props = webinyConfigTsx.component.props;
81
-
82
- // Serialize props to JSX attributes
83
- const propsString = props ? serializePropsToJsx(props) : "";
84
-
85
- // Generate component tag with or without props
86
- const componentTag = propsString ? `<${componentName} ${propsString} />` : `<${componentName} />`;
87
-
88
- // Check if component already exists
89
- if (!content.includes(componentTag)) {
90
- // Find the Extensions function's return statement and add component before the final </>
91
- // Strategy: Find "export const Extensions" block, then find the last </> and insert before it
92
- const extensionsFuncRegex = /export const Extensions = \(\) => \{[\s\S]*?\};/;
93
- const extensionsFuncMatch = content.match(extensionsFuncRegex);
94
- if (extensionsFuncMatch) {
95
- const funcContent = extensionsFuncMatch[0];
96
- // Find all </> in the function - the last one closes the return statement
97
- const closingTags = [...funcContent.matchAll(/<\/>/g)];
98
- if (closingTags.length > 0) {
99
- const lastClosingTag = closingTags[closingTags.length - 1];
100
- const lastClosingTagIndex = lastClosingTag.index;
101
-
102
- // Find the indentation of the line containing the last </>
103
- const beforeClosing = funcContent.substring(0, lastClosingTagIndex);
104
- const lines = beforeClosing.split("\n");
105
- const lastLine = lines[lines.length - 1];
106
- const indent = lastLine.match(/^(\s*)/)?.[1] || " ";
133
+ content = addComponentToExtensions(content, webinyConfigTsx.component.name, webinyConfigTsx.component.props);
134
+ }
107
135
 
108
- // Insert the component before the last </>
109
- const newFuncContent = funcContent.substring(0, lastClosingTagIndex) + `${indent}${componentTag}\n${indent}` + funcContent.substring(lastClosingTagIndex);
110
- content = content.replace(extensionsFuncRegex, newFuncContent);
111
- }
112
- }
136
+ // Add multiple components to the Extensions function.
137
+ if (webinyConfigTsx.components && webinyConfigTsx.components.length > 0) {
138
+ for (const component of webinyConfigTsx.components) {
139
+ content = addComponentToExtensions(content, component.name, component.props);
113
140
  }
114
141
  }
115
142
 
@@ -1 +1 @@
1
- {"version":3,"names":["fs","serializePropsToJsx","props","attributes","key","value","Object","entries","undefined","serializedValue","JSON","stringify","Array","isArray","push","join","updateWebinyConfig","params","projectRoot","webinyConfigTsx","webinyConfigPath","content","readFileSync","imports","length","importStatement","importLine","specifier","path","includes","importRegex","matches","from","matchAll","lastImport","lastImportEnd","index","slice","component","componentName","name","propsString","componentTag","extensionsFuncRegex","extensionsFuncMatch","match","funcContent","closingTags","lastClosingTag","lastClosingTagIndex","beforeClosing","substring","lines","split","lastLine","indent","newFuncContent","replace","writeFileSync"],"sources":["updateWebinyConfig.ts"],"sourcesContent":["import fs from \"fs\";\nimport { ExtensionWebinyConfigTsx } from \"./types.js\";\n\ninterface UpdateWebinyConfigParams {\n projectRoot: string;\n webinyConfigTsx: ExtensionWebinyConfigTsx;\n}\n\n/**\n * Serializes a props object to JSX attribute syntax.\n * Examples:\n * - { secretKey: \"value\" } => 'secretKey={\"value\"}'\n * - { enabled: true } => 'enabled={true}'\n * - { count: 42 } => 'count={42}'\n * - { config: { key: \"value\" } } => 'config={{\"key\":\"value\"}}'\n */\nconst serializePropsToJsx = (props: Record<string, any>): string => {\n const attributes: string[] = [];\n\n for (const [key, value] of Object.entries(props)) {\n // Skip undefined values\n if (value === undefined) {\n continue;\n }\n\n // Determine the serialization based on value type\n let serializedValue: string;\n\n if (typeof value === \"string\") {\n // Strings: use JSON.stringify to handle escaping, then wrap in curly braces\n serializedValue = `{${JSON.stringify(value)}}`;\n } else if (typeof value === \"number\" || typeof value === \"boolean\") {\n // Numbers and booleans: wrap in curly braces without quotes\n serializedValue = `{${value}}`;\n } else if (value === null) {\n // Null values\n serializedValue = `{null}`;\n } else if (Array.isArray(value) || typeof value === \"object\") {\n // Arrays and objects: use JSON.stringify, then wrap in curly braces\n serializedValue = `{${JSON.stringify(value)}}`;\n } else {\n // Fallback for any other types\n serializedValue = `{${JSON.stringify(value)}}`;\n }\n\n attributes.push(`${key}=${serializedValue}`);\n }\n\n return attributes.join(\" \");\n};\n\n/**\n * Update the webiny.config.tsx file to add extension imports and component.\n */\nexport const updateWebinyConfig = async (params: UpdateWebinyConfigParams): Promise<void> => {\n const { projectRoot, webinyConfigTsx } = params;\n\n const webinyConfigPath = `${projectRoot}/webiny.config.tsx`;\n\n // Read the current webiny.config.tsx\n let content = fs.readFileSync(webinyConfigPath, \"utf-8\");\n\n // Add imports at the top (after existing imports)\n if (webinyConfigTsx.imports && webinyConfigTsx.imports.length > 0) {\n for (const importStatement of webinyConfigTsx.imports) {\n const importLine = `import { ${importStatement.specifier} } from \"${importStatement.path}\";`;\n\n // Check if import already exists\n if (!content.includes(importLine)) {\n // Find the position after the last import or at the beginning\n const importRegex = /^import\\s+.*?from\\s+[\"'].*?[\"'];?\\s*$/gm;\n const matches = Array.from(content.matchAll(importRegex));\n\n if (matches.length > 0) {\n // Add after the last import\n const lastImport = matches[matches.length - 1];\n const lastImportEnd = lastImport.index! + lastImport[0].length;\n content =\n content.slice(0, lastImportEnd) +\n \"\\n\" +\n importLine +\n content.slice(lastImportEnd);\n } else {\n // No imports found, add at the beginning\n content = importLine + \"\\n\\n\" + content;\n }\n }\n }\n }\n\n // Add component to the Extensions function\n if (webinyConfigTsx.component) {\n const componentName = webinyConfigTsx.component.name;\n const props = webinyConfigTsx.component.props;\n\n // Serialize props to JSX attributes\n const propsString = props ? serializePropsToJsx(props) : \"\";\n\n // Generate component tag with or without props\n const componentTag = propsString\n ? `<${componentName} ${propsString} />`\n : `<${componentName} />`;\n\n // Check if component already exists\n if (!content.includes(componentTag)) {\n // Find the Extensions function's return statement and add component before the final </>\n // Strategy: Find \"export const Extensions\" block, then find the last </> and insert before it\n const extensionsFuncRegex = /export const Extensions = \\(\\) => \\{[\\s\\S]*?\\};/;\n const extensionsFuncMatch = content.match(extensionsFuncRegex);\n\n if (extensionsFuncMatch) {\n const funcContent = extensionsFuncMatch[0];\n // Find all </> in the function - the last one closes the return statement\n const closingTags = [...funcContent.matchAll(/<\\/>/g)];\n\n if (closingTags.length > 0) {\n const lastClosingTag = closingTags[closingTags.length - 1];\n const lastClosingTagIndex = lastClosingTag.index!;\n\n // Find the indentation of the line containing the last </>\n const beforeClosing = funcContent.substring(0, lastClosingTagIndex);\n const lines = beforeClosing.split(\"\\n\");\n const lastLine = lines[lines.length - 1];\n const indent = lastLine.match(/^(\\s*)/)?.[1] || \" \";\n\n // Insert the component before the last </>\n const newFuncContent =\n funcContent.substring(0, lastClosingTagIndex) +\n `${indent}${componentTag}\\n${indent}` +\n funcContent.substring(lastClosingTagIndex);\n\n content = content.replace(extensionsFuncRegex, newFuncContent);\n }\n }\n }\n }\n\n // Write the updated content back\n fs.writeFileSync(webinyConfigPath, content, \"utf-8\");\n};\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAQnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,GAAIC,KAA0B,IAAa;EAChE,MAAMC,UAAoB,GAAG,EAAE;EAE/B,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,KAAK,CAAC,EAAE;IAC9C;IACA,IAAIG,KAAK,KAAKG,SAAS,EAAE;MACrB;IACJ;;IAEA;IACA,IAAIC,eAAuB;IAE3B,IAAI,OAAOJ,KAAK,KAAK,QAAQ,EAAE;MAC3B;MACAI,eAAe,GAAG,IAAIC,IAAI,CAACC,SAAS,CAACN,KAAK,CAAC,GAAG;IAClD,CAAC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,SAAS,EAAE;MAChE;MACAI,eAAe,GAAG,IAAIJ,KAAK,GAAG;IAClC,CAAC,MAAM,IAAIA,KAAK,KAAK,IAAI,EAAE;MACvB;M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GAAGD,cAAc,CAACZ,KAAM;;UAEjD;UACA,MAAMc,aAAa,GAAGJ,WAAW,CAACK,SAAS,CAAC,CAAC,EAAEF,mBAAmB,CAAC;UACnE,MAAMG,KAAK,GAAGF,aAAa,CAACG,KAAK,CAAC,IAAI,CAAC;UACvC,MAAMC,QAAQ,GAAGF,KAAK,CAACA,KAAK,CAAC5B,MAAM,GAAG,CAAC,CAAC;UACxC,MAAM+B,MAAM,GAAGD,QAAQ,CAACT,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,UAAU;;UAE1D;UACA,MAAMW,cAAc,GAChBV,WAAW,CAACK,SAAS,CAAC,CAAC,EAAEF,mBAAmB,CAAC,GAC7C,GAAGM,MAAM,GAAGb,YAAY,KAAKa,MAAM,EAAE,GACrCT,WAAW,CAACK,SAAS,CAACF,mBAAmB,CAAC;UAE9C5B,OAAO,GAAGA,OAAO,CAACoC,OAAO,CAACd,mBAAmB,EAAEa,cAAc,CAAC;QAClE;MACJ;IACJ;EACJ;;EAEA;EACAxD,EAAE,CAAC0D,aAAa,CAACtC,gBAAgB,EAAEC,OAAO,EAAE,OAAO,CAAC;AACxD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["fs","serializePropsToJsx","props","attributes","key","value","Object","entries","undefined","serializedValue","JSON","stringify","Array","isArray","push","join","addComponentToExtensions","content","componentName","propsString","componentTag","includes","extensionsFuncRegex","extensionsFuncMatch","match","funcContent","closingTags","matchAll","length","lastClosingTag","lastClosingTagIndex","index","beforeClosing","substring","lines","split","lastLine","indent","newFuncContent","replace","updateWebinyConfig","params","projectRoot","webinyConfigTsx","webinyConfigPath","readFileSync","imports","importStatement","existingImportRegex","RegExp","path","existingImportMatch","existingSpecifiers","map","s","trim","specifier","updatedSpecifiers","updatedImportLine","importLine","importRegex","matches","from","lastImport","lastImportEnd","slice","component","name","components","writeFileSync"],"sources":["updateWebinyConfig.ts"],"sourcesContent":["import fs from \"fs\";\nimport { ExtensionWebinyConfigTsx } from \"./types.js\";\n\ninterface UpdateWebinyConfigParams {\n projectRoot: string;\n webinyConfigTsx: ExtensionWebinyConfigTsx;\n}\n\n/**\n * Serializes a props object to JSX attribute syntax.\n * Examples:\n * - { secretKey: \"value\" } => 'secretKey={\"value\"}'\n * - { enabled: true } => 'enabled={true}'\n * - { count: 42 } => 'count={42}'\n * - { config: { key: \"value\" } } => 'config={{\"key\":\"value\"}}'\n */\nconst serializePropsToJsx = (props: Record<string, any>): string => {\n const attributes: string[] = [];\n\n for (const [key, value] of Object.entries(props)) {\n // Skip undefined values.\n if (value === undefined) {\n continue;\n }\n\n // Determine the serialization based on value type.\n let serializedValue: string;\n\n if (typeof value === \"string\") {\n // Strings: use JSON.stringify to handle escaping, then wrap in curly braces.\n serializedValue = `{${JSON.stringify(value)}}`;\n } else if (typeof value === \"number\" || typeof value === \"boolean\") {\n // Numbers and booleans: wrap in curly braces without quotes.\n serializedValue = `{${value}}`;\n } else if (value === null) {\n // Null values.\n serializedValue = `{null}`;\n } else if (Array.isArray(value) || typeof value === \"object\") {\n // Arrays and objects: use JSON.stringify, then wrap in curly braces.\n serializedValue = `{${JSON.stringify(value)}}`;\n } else {\n // Fallback for any other types.\n serializedValue = `{${JSON.stringify(value)}}`;\n }\n\n attributes.push(`${key}=${serializedValue}`);\n }\n\n return attributes.join(\" \");\n};\n\n/**\n * Adds a component to the Extensions function in the webiny.config.tsx content.\n */\nconst addComponentToExtensions = (\n content: string,\n componentName: string,\n props?: Record<string, any>\n): string => {\n // Serialize props to JSX attributes.\n const propsString = props ? serializePropsToJsx(props) : \"\";\n\n // Generate component tag with or without props.\n const componentTag = propsString\n ? `<${componentName} ${propsString} />`\n : `<${componentName} />`;\n\n // Check if component already exists.\n if (content.includes(componentTag)) {\n return content;\n }\n\n // Find the Extensions function's return statement and add component before the final </>.\n // Strategy: Find \"export const Extensions\" block, then find the last </> and insert before it.\n const extensionsFuncRegex = /export const Extensions = \\(\\) => \\{[\\s\\S]*?\\};/;\n const extensionsFuncMatch = content.match(extensionsFuncRegex);\n\n if (!extensionsFuncMatch) {\n return content;\n }\n\n const funcContent = extensionsFuncMatch[0];\n // Find all </> in the function - the last one closes the return statement.\n const closingTags = [...funcContent.matchAll(/<\\/>/g)];\n\n if (closingTags.length === 0) {\n return content;\n }\n\n const lastClosingTag = closingTags[closingTags.length - 1];\n const lastClosingTagIndex = lastClosingTag.index!;\n\n // Find the indentation of the line containing the last </>.\n const beforeClosing = funcContent.substring(0, lastClosingTagIndex);\n const lines = beforeClosing.split(\"\\n\");\n const lastLine = lines[lines.length - 1];\n const indent = lastLine.match(/^(\\s*)/)?.[1] || \" \";\n\n // Insert the component before the last </>.\n const newFuncContent =\n funcContent.substring(0, lastClosingTagIndex) +\n `${indent}${componentTag}\\n${indent}` +\n funcContent.substring(lastClosingTagIndex);\n\n return content.replace(extensionsFuncRegex, newFuncContent);\n};\n\n/**\n * Update the webiny.config.tsx file to add extension imports and component.\n */\nexport const updateWebinyConfig = async (params: UpdateWebinyConfigParams): Promise<void> => {\n const { projectRoot, webinyConfigTsx } = params;\n\n const webinyConfigPath = `${projectRoot}/webiny.config.tsx`;\n\n // Read the current webiny.config.tsx\n let content = fs.readFileSync(webinyConfigPath, \"utf-8\");\n\n // Add imports at the top (after existing imports)\n if (webinyConfigTsx.imports && webinyConfigTsx.imports.length > 0) {\n for (const importStatement of webinyConfigTsx.imports) {\n // Check if we need to add to an existing import from the same path.\n const existingImportRegex = new RegExp(\n `import\\\\s+{([^}]+)}\\\\s+from\\\\s+[\"']${importStatement.path.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}[\"'];?`,\n \"m\"\n );\n const existingImportMatch = content.match(existingImportRegex);\n\n if (existingImportMatch) {\n // Import from this path exists, check if specifier is already imported.\n const existingSpecifiers = existingImportMatch[1].split(\",\").map(s => s.trim());\n\n if (!existingSpecifiers.includes(importStatement.specifier)) {\n // Append the new specifier to the existing import.\n const updatedSpecifiers = [\n ...existingSpecifiers,\n importStatement.specifier\n ].join(\", \");\n const updatedImportLine = `import { ${updatedSpecifiers} } from \"${importStatement.path}\";`;\n content = content.replace(existingImportRegex, updatedImportLine);\n }\n } else {\n // No existing import from this path, add a new import line.\n const importLine = `import { ${importStatement.specifier} } from \"${importStatement.path}\";`;\n\n // Find the position after the last import or at the beginning.\n const importRegex = /^import\\s+.*?from\\s+[\"'].*?[\"'];?\\s*$/gm;\n const matches = Array.from(content.matchAll(importRegex));\n\n if (matches.length > 0) {\n // Add after the last import.\n const lastImport = matches[matches.length - 1];\n const lastImportEnd = lastImport.index! + lastImport[0].length;\n content =\n content.slice(0, lastImportEnd) +\n \"\\n\" +\n importLine +\n content.slice(lastImportEnd);\n } else {\n // No imports found, add at the beginning.\n content = importLine + \"\\n\\n\" + content;\n }\n }\n }\n }\n\n // Add component to the Extensions function.\n if (webinyConfigTsx.component) {\n content = addComponentToExtensions(\n content,\n webinyConfigTsx.component.name,\n webinyConfigTsx.component.props\n );\n }\n\n // Add multiple components to the Extensions function.\n if (webinyConfigTsx.components && webinyConfigTsx.components.length > 0) {\n for (const component of webinyConfigTsx.components) {\n content = addComponentToExtensions(content, component.name, component.props);\n }\n }\n\n // Write the updated content back\n fs.writeFileSync(webinyConfigPath, content, \"utf-8\");\n};\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAQnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,GAAIC,KAA0B,IAAa;EAChE,MAAMC,UAAoB,GAAG,EAAE;EAE/B,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,KAAK,CAAC,EAAE;IAC9C;IACA,IAAIG,KAAK,KAAKG,SAAS,EAAE;MACrB;IACJ;;IAEA;IACA,IAAIC,eAAuB;IAE3B,IAAI,OAAOJ,KAAK,KAAK,QAAQ,EAAE;MAC3B;MACAI,eAAe,GAAG,IAAIC,IAAI,CAACC,SAAS,CAACN,KAAK,CAAC,G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UAAU,CAAChC,KAAK,GAAIgC,UAAU,CAAC,CAAC,CAAC,CAACnC,MAAM;UAC9DX,OAAO,GACHA,OAAO,CAACgD,KAAK,CAAC,CAAC,EAAED,aAAa,CAAC,GAC/B,IAAI,GACJL,UAAU,GACV1C,OAAO,CAACgD,KAAK,CAACD,aAAa,CAAC;QACpC,CAAC,MAAM;UACH;UACA/C,OAAO,GAAG0C,UAAU,GAAG,MAAM,GAAG1C,OAAO;QAC3C;MACJ;IACJ;EACJ;;EAEA;EACA,IAAI0B,eAAe,CAACuB,SAAS,EAAE;IAC3BjD,OAAO,GAAGD,wBAAwB,CAC9BC,OAAO,EACP0B,eAAe,CAACuB,SAAS,CAACC,IAAI,EAC9BxB,eAAe,CAACuB,SAAS,CAAChE,KAC9B,CAAC;EACL;;EAEA;EACA,IAAIyC,eAAe,CAACyB,UAAU,IAAIzB,eAAe,CAACyB,UAAU,CAACxC,MAAM,GAAG,CAAC,EAAE;IACrE,KAAK,MAAMsC,SAAS,IAAIvB,eAAe,CAACyB,UAAU,EAAE;MAChDnD,OAAO,GAAGD,wBAAwB,CAACC,OAAO,EAAEiD,SAAS,CAACC,IAAI,EAAED,SAAS,CAAChE,KAAK,CAAC;IAChF;EACJ;;EAEA;EACAF,EAAE,CAACqE,aAAa,CAACzB,gBAAgB,EAAE3B,OAAO,EAAE,OAAO,CAAC;AACxD,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import { createImplementation } from "@webiny/di";
2
2
  import { ListAppLambdaFunctionsService, PulumiExportService, LoggerService } from "../../abstractions/index.js";
3
3
  import path from "path";
4
- import minimatch from "minimatch";
4
+ import { minimatch } from "minimatch";
5
5
  export class DefaultListAppLambdaFunctionsService {
6
6
  constructor(pulumiExportService, loggerService) {
7
7
  this.pulumiExportService = pulumiExportService;
@@ -1 +1 @@
1
- {"version":3,"names":["createImplementation","ListAppLambdaFunctionsService","PulumiExportService","LoggerService","path","minimatch","DefaultListAppLambdaFunctionsService","constructor","pulumiExportService","loggerService","execute","app","params","stackExport","list","meta","count","totalCount","resources","deployment","allFunctionsList","filter","r","type","resource","isAuthorizerFunction","inputs","name","includes","filteredFunctionsList","code","assets","map","fnName","handlerBuildFolderPath","handlerPath","join","whitelist","length","functionNamesToMatch","Array","isArray","fn","some","pattern","listAppLambdaFunctionsService","abstraction","implementation","dependencies"],"sources":["ListAppLambdaFunctionsService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n ListAppLambdaFunctionsService,\n PulumiExportService,\n LoggerService\n} from \"~/abstractions/index.js\";\nimport { type AppModel } from \"~/models/index.js\";\nimport path from \"path\";\nimport minimatch from \"minimatch\";\n\ninterface ExpectedStackExport {\n deployment: {\n resources: Array<{\n type: string;\n inputs: {\n name: string;\n code: {\n assets: Record<string, { path: string }>;\n };\n };\n }>;\n };\n}\n\nexport class DefaultListAppLambdaFunctionsService\n implements ListAppLambdaFunctionsService.Interface\n{\n constructor(\n private pulumiExportService: PulumiExportService.Interface,\n private loggerService: LoggerService.Interface\n ) {}\n\n async execute(app: AppModel, params?: ListAppLambdaFunctionsService.Params) {\n const stackExport = await this.pulumiExportService.execute<ExpectedStackExport>(app);\n\n if (!stackExport) {\n // If no stack export is found, return an empty array. This is a valid scenario.\n // For example, watching the Admin app locally, but not deploying it.\n return {\n list: [],\n meta: {\n count: 0,\n totalCount: 0\n }\n };\n }\n\n // If an app is not deployed, resources will not exist.\n const resources = stackExport.deployment?.resources ?? [];\n\n const allFunctionsList = resources\n .filter(r => r.type === \"aws:lambda/function:Function\")\n // We don't need to watch the authorizer function.\n .filter(resource => {\n const isAuthorizerFunction = resource.inputs.name.includes(\n \"watch-command-iot-authorizer\"\n );\n return !isAuthorizerFunction;\n });\n\n let filteredFunctionsList = allFunctionsList\n // First, this filter ensures that Lambda@Edge functions are excluded. Second,\n // it also ensures a function is filtered out if a `pulumi refresh` was called.\n // This is because, when called, the paths in Pulumi state file disappear, and\n // we can't determine the path to the handler. Probably needs revisiting. 🤦‍♂️\n .filter(resource => {\n return \".\" in resource.inputs.code.assets;\n })\n .map(resource => {\n const fnName = resource.inputs.name;\n const handlerBuildFolderPath = resource.inputs.code.assets[\".\"].path;\n\n const handlerPath = path.join(handlerBuildFolderPath, \"handler.mjs\");\n return {\n name: fnName,\n path: handlerPath\n };\n });\n\n if (params?.whitelist?.length) {\n const functionNamesToMatch = Array.isArray(params.whitelist)\n ? params.whitelist\n : [params.whitelist];\n\n // `functionNamesToWatch` is an array of glob patterns, which denote which functions to watch.\n filteredFunctionsList = filteredFunctionsList.filter(fn => {\n return functionNamesToMatch.some(pattern => {\n if (pattern.includes(\"*\")) {\n return minimatch(fn.name, pattern);\n }\n\n return fn.name.includes(pattern);\n });\n });\n } else {\n // We've hardcoded this filtering here just because of lack of time.\n // With v5, these \"presets\" were located within `webiny.application.ts` files.\n if (app.name === \"api\") {\n filteredFunctionsList = filteredFunctionsList.filter(fn => {\n return fn.name.includes(\"graphql\");\n });\n }\n }\n\n return {\n list: filteredFunctionsList,\n meta: { count: filteredFunctionsList.length, totalCount: allFunctionsList.length }\n };\n }\n}\n\nexport const listAppLambdaFunctionsService = createImplementation({\n abstraction: ListAppLambdaFunctionsService,\n implementation: DefaultListAppLambdaFunctionsService,\n dependencies: [PulumiExportService, LoggerService]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SACIC,6BAA6B,EAC7BC,mBAAmB,EACnBC,aAAa;AAGjB,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,SAAS,MAAM,WAAW;AAgBjC,OAAO,MAAMC,oCAAoC,CAEjD;EACIC,WAAWA,CACCC,mBAAkD,EAClDC,aAAsC,EAChD;IAAA,KAFUD,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,aAAsC,GAAtCA,aAAsC;EAC/C;EAEH,MAAMC,OAAOA,CAACC,GAAa,EAAEC,MAA6C,EAAE;IACxE,MAAMC,WAAW,GAAG,MAAM,IAAI,CAACL,mBAAmB,CAACE,O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SAAS,GAChB,CAACzB,MAAM,CAACyB,SAAS,CAAC;;MAExB;MACAR,qBAAqB,GAAGA,qBAAqB,CAACR,MAAM,CAACqB,EAAE,IAAI;QACvD,OAAOH,oBAAoB,CAACI,IAAI,CAACC,OAAO,IAAI;UACxC,IAAIA,OAAO,CAAChB,QAAQ,CAAC,GAAG,CAAC,EAAE;YACvB,OAAOvB,SAAS,CAACqC,EAAE,CAACf,IAAI,EAAEiB,OAAO,CAAC;UACtC;UAEA,OAAOF,EAAE,CAACf,IAAI,CAACC,QAAQ,CAACgB,OAAO,CAAC;QACpC,CAAC,CAAC;MACN,CAAC,CAAC;IACN,CAAC,MAAM;MACH;MACA;MACA,IAAIjC,GAAG,CAACgB,IAAI,KAAK,KAAK,EAAE;QACpBE,qBAAqB,GAAGA,qBAAqB,CAACR,MAAM,CAACqB,EAAE,IAAI;UACvD,OAAOA,EAAE,CAACf,IAAI,CAACC,QAAQ,CAAC,SAAS,CAAC;QACtC,CAAC,CAAC;MACN;IACJ;IAEA,OAAO;MACHd,IAAI,EAAEe,qBAAqB;MAC3Bd,IAAI,EAAE;QAAEC,KAAK,EAAEa,qBAAqB,CAACS,MAAM;QAAErB,UAAU,EAAEG,gBAAgB,CAACkB;MAAO;IACrF,CAAC;EACL;AACJ;AAEA,OAAO,MAAMO,6BAA6B,GAAG7C,oBAAoB,CAAC;EAC9D8C,WAAW,EAAE7C,6BAA6B;EAC1C8C,cAAc,EAAEzC,oCAAoC;EACpD0C,YAAY,EAAE,CAAC9C,mBAAmB,EAAEC,aAAa;AACrD,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createImplementation","ListAppLambdaFunctionsService","PulumiExportService","LoggerService","path","minimatch","DefaultListAppLambdaFunctionsService","constructor","pulumiExportService","loggerService","execute","app","params","stackExport","list","meta","count","totalCount","resources","deployment","allFunctionsList","filter","r","type","resource","isAuthorizerFunction","inputs","name","includes","filteredFunctionsList","code","assets","map","fnName","handlerBuildFolderPath","handlerPath","join","whitelist","length","functionNamesToMatch","Array","isArray","fn","some","pattern","listAppLambdaFunctionsService","abstraction","implementation","dependencies"],"sources":["ListAppLambdaFunctionsService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n ListAppLambdaFunctionsService,\n PulumiExportService,\n LoggerService\n} from \"~/abstractions/index.js\";\nimport { type AppModel } from \"~/models/index.js\";\nimport path from \"path\";\nimport { minimatch } from \"minimatch\";\n\ninterface ExpectedStackExport {\n deployment: {\n resources: Array<{\n type: string;\n inputs: {\n name: string;\n code: {\n assets: Record<string, { path: string }>;\n };\n };\n }>;\n };\n}\n\nexport class DefaultListAppLambdaFunctionsService\n implements ListAppLambdaFunctionsService.Interface\n{\n constructor(\n private pulumiExportService: PulumiExportService.Interface,\n private loggerService: LoggerService.Interface\n ) {}\n\n async execute(app: AppModel, params?: ListAppLambdaFunctionsService.Params) {\n const stackExport = await this.pulumiExportService.execute<ExpectedStackExport>(app);\n\n if (!stackExport) {\n // If no stack export is found, return an empty array. This is a valid scenario.\n // For example, watching the Admin app locally, but not deploying it.\n return {\n list: [],\n meta: {\n count: 0,\n totalCount: 0\n }\n };\n }\n\n // If an app is not deployed, resources will not exist.\n const resources = stackExport.deployment?.resources ?? [];\n\n const allFunctionsList = resources\n .filter(r => r.type === \"aws:lambda/function:Function\")\n // We don't need to watch the authorizer function.\n .filter(resource => {\n const isAuthorizerFunction = resource.inputs.name.includes(\n \"watch-command-iot-authorizer\"\n );\n return !isAuthorizerFunction;\n });\n\n let filteredFunctionsList = allFunctionsList\n // First, this filter ensures that Lambda@Edge functions are excluded. Second,\n // it also ensures a function is filtered out if a `pulumi refresh` was called.\n // This is because, when called, the paths in Pulumi state file disappear, and\n // we can't determine the path to the handler. Probably needs revisiting. 🤦‍♂️\n .filter(resource => {\n return \".\" in resource.inputs.code.assets;\n })\n .map(resource => {\n const fnName = resource.inputs.name;\n const handlerBuildFolderPath = resource.inputs.code.assets[\".\"].path;\n\n const handlerPath = path.join(handlerBuildFolderPath, \"handler.mjs\");\n return {\n name: fnName,\n path: handlerPath\n };\n });\n\n if (params?.whitelist?.length) {\n const functionNamesToMatch = Array.isArray(params.whitelist)\n ? params.whitelist\n : [params.whitelist];\n\n // `functionNamesToWatch` is an array of glob patterns, which denote which functions to watch.\n filteredFunctionsList = filteredFunctionsList.filter(fn => {\n return functionNamesToMatch.some(pattern => {\n if (pattern.includes(\"*\")) {\n return minimatch(fn.name, pattern);\n }\n\n return fn.name.includes(pattern);\n });\n });\n } else {\n // We've hardcoded this filtering here just because of lack of time.\n // With v5, these \"presets\" were located within `webiny.application.ts` files.\n if (app.name === \"api\") {\n filteredFunctionsList = filteredFunctionsList.filter(fn => {\n return fn.name.includes(\"graphql\");\n });\n }\n }\n\n return {\n list: filteredFunctionsList,\n meta: { count: filteredFunctionsList.length, totalCount: allFunctionsList.length }\n };\n }\n}\n\nexport const listAppLambdaFunctionsService = createImplementation({\n abstraction: ListAppLambdaFunctionsService,\n implementation: DefaultListAppLambdaFunctionsService,\n dependencies: [PulumiExportService, LoggerService]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SACIC,6BAA6B,EAC7BC,mBAAmB,EACnBC,aAAa;AAGjB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,SAAS,QAAQ,WAAW;AAgBrC,OAAO,MAAMC,oCAAoC,CAEjD;EACIC,WAAWA,CACCC,mBAAkD,EAClDC,aAAsC,EAChD;IAAA,KAFUD,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,aAAsC,GAAtCA,aAAsC;EAC/C;EAEH,MAAMC,OAAOA,CAACC,GAAa,EAAEC,MAA6C,EAAE;IACxE,MAAMC,WAAW,GAAG,MAAM,IAAI,CAACL,mBAAmB,CAACE,OAAO,CAAsBC,GAAG,CAAC;IAEpF,IAAI,CAACE,WAAW,EAAE;MACd;MACA;MACA,OAAO;QACHC,IAAI,EAAE,EAAE;QACRC,IAAI,EAAE;UACFC,KAAK,EAAE,CAAC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AAI,CAACC,OAAO,IAAI;UACxC,IAAIA,OAAO,CAAChB,QAAQ,CAAC,GAAG,CAAC,EAAE;YACvB,OAAOvB,SAAS,CAACqC,EAAE,CAACf,IAAI,EAAEiB,OAAO,CAAC;UACtC;UAEA,OAAOF,EAAE,CAACf,IAAI,CAACC,QAAQ,CAACgB,OAAO,CAAC;QACpC,CAAC,CAAC;MACN,CAAC,CAAC;IACN,CAAC,MAAM;MACH;MACA;MACA,IAAIjC,GAAG,CAACgB,IAAI,KAAK,KAAK,EAAE;QACpBE,qBAAqB,GAAGA,qBAAqB,CAACR,MAAM,CAACqB,EAAE,IAAI;UACvD,OAAOA,EAAE,CAACf,IAAI,CAACC,QAAQ,CAAC,SAAS,CAAC;QACtC,CAAC,CAAC;MACN;IACJ;IAEA,OAAO;MACHd,IAAI,EAAEe,qBAAqB;MAC3Bd,IAAI,EAAE;QAAEC,KAAK,EAAEa,qBAAqB,CAACS,MAAM;QAAErB,UAAU,EAAEG,gBAAgB,CAACkB;MAAO;IACrF,CAAC;EACL;AACJ;AAEA,OAAO,MAAMO,6BAA6B,GAAG7C,oBAAoB,CAAC;EAC9D8C,WAAW,EAAE7C,6BAA6B;EAC1C8C,cAAc,EAAEzC,oCAAoC;EACpD0C,YAAY,EAAE,CAAC9C,mBAAmB,EAAEC,aAAa;AACrD,CAAC,CAAC","ignoreList":[]}
@@ -10,10 +10,10 @@ export class DefaultProjectInfoService {
10
10
  this.getProjectVersion = getProjectVersion;
11
11
  }
12
12
  async execute() {
13
- const wcpProjectId = process.env.WCP_PROJECT_ID || "";
13
+ const wcpProjectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID || "";
14
14
  // const wcpUser = await getUser().catch(() => null);
15
15
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
- const wcpUsingProjectEnvironmentApiKey = Boolean(process.env.WCP_ENVIRONMENT_API_KEY);
16
+ const wcpUsingProjectEnvironmentApiKey = Boolean(process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY || process.env.WCP_ENVIRONMENT_API_KEY);
17
17
  const isCI = this.getIsCi.execute();
18
18
  const npmVersion = this.getNpmVersion.execute();
19
19
  const npxVersion = this.getNpxVersion.execute();
@@ -1 +1 @@
1
- {"version":3,"names":["createImplementation","ProjectInfoService","GetIsCiService","GetNpmVersionService","GetNpxVersionService","GetPulumiVersionService","GetYarnVersionService","GetProjectVersionService","DefaultProjectInfoService","constructor","getIsCi","getNpmVersion","getNpxVersion","getPulumiVersion","getYarnVersion","getProjectVersion","execute","wcpProjectId","process","env","WCP_PROJECT_ID","wcpUsingProjectEnvironmentApiKey","Boolean","WCP_ENVIRONMENT_API_KEY","isCI","npmVersion","npxVersion","yarnVersion","pulumiVersion","pulumiAwsVersion","webiny","version","debugEnabled","DEBUG","featureFlags","WEBINY_FEATURE_FLAGS","wcp","projectId","usingProjectEnvironmentApiKey","host","os","platform","arch","nodeJs","npm","npx","yarn","pulumi","secretsProvider","PULUMI_SECRETS_PROVIDER","usingPassword","PULUMI_CONFIG_PASSPHRASE","projectInfoService","abstraction","implementation","dependencies"],"sources":["ProjectInfoService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n ProjectInfoService,\n GetIsCiService,\n GetNpmVersionService,\n GetNpxVersionService,\n GetPulumiVersionService,\n GetYarnVersionService,\n GetProjectVersionService\n} from \"~/abstractions/index.js\";\nimport { IProjectInfoServiceResult } from \"~/abstractions/services/ProjectInfoService/ProjectInfoService.js\";\n\nexport class DefaultProjectInfoService implements ProjectInfoService.Interface {\n constructor(\n private getIsCi: GetIsCiService.Interface,\n private getNpmVersion: GetNpmVersionService.Interface,\n private getNpxVersion: GetNpxVersionService.Interface,\n private getPulumiVersion: GetPulumiVersionService.Interface,\n private getYarnVersion: GetYarnVersionService.Interface,\n private getProjectVersion: GetProjectVersionService.Interface\n ) {}\n\n async execute() {\n const wcpProjectId = process.env.WCP_PROJECT_ID || \"\";\n // const wcpUser = await getUser().catch(() => null);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const wcpUsingProjectEnvironmentApiKey = Boolean(process.env.WCP_ENVIRONMENT_API_KEY);\n\n const isCI = this.getIsCi.execute();\n const npmVersion = this.getNpmVersion.execute();\n const npxVersion = this.getNpxVersion.execute();\n const yarnVersion = this.getYarnVersion.execute();\n const [pulumiVersion, pulumiAwsVersion] = this.getPulumiVersion.execute();\n\n return {\n webiny: {\n version: this.getProjectVersion.execute(),\n debugEnabled: process.env.DEBUG === \"true\",\n featureFlags: process.env.WEBINY_FEATURE_FLAGS || {}\n },\n wcp: {\n projectId: wcpProjectId,\n // user: wcpUser?.email || \"N/A\",\n usingProjectEnvironmentApiKey: false // wcpUsingProject\n },\n host: {\n os: `${process.platform} (${process.arch})`,\n nodeJs: process.version,\n npm: npmVersion,\n npx: npxVersion,\n yarn: yarnVersion,\n isCI: isCI\n },\n pulumi: {\n \"@pulumi/pulumi\": pulumiVersion,\n \"@pulumi/aws\": pulumiAwsVersion,\n secretsProvider: process.env.PULUMI_SECRETS_PROVIDER || \"\",\n usingPassword: !!process.env.PULUMI_CONFIG_PASSPHRASE\n }\n } as IProjectInfoServiceResult;\n }\n}\n\nexport const projectInfoService = createImplementation({\n abstraction: ProjectInfoService,\n implementation: DefaultProjectInfoService,\n dependencies: [\n GetIsCiService,\n GetNpmVersionService,\n GetNpxVersionService,\n GetPulumiVersionService,\n GetYarnVersionService,\n GetProjectVersionService\n ]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SACIC,kBAAkB,EAClBC,cAAc,EACdC,oBAAoB,EACpBC,oBAAoB,EACpBC,uBAAuB,EACvBC,qBAAqB,EACrBC,wBAAwB;AAI5B,OAAO,MAAMC,yBAAyB,CAAyC;EAC3EC,WAAWA,CACCC,OAAiC,EACjCC,aAA6C,EAC7CC,aAA6C,EAC7CC,gBAAmD,EACnDC,cAA+C,EAC/CC,iBAAqD,EAC/D;IAAA,KANUL,OA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,OAAO,CAACa,OAAO;QACvBa,GAAG,EAAEnB,UAAU;QACfoB,GAAG,EAAEnB,UAAU;QACfoB,IAAI,EAAEnB,WAAW;QACjBH,IAAI,EAAEA;MACV,CAAC;MACDuB,MAAM,EAAE;QACJ,gBAAgB,EAAEnB,aAAa;QAC/B,aAAa,EAAEC,gBAAgB;QAC/BmB,eAAe,EAAE9B,OAAO,CAACC,GAAG,CAAC8B,uBAAuB,IAAI,EAAE;QAC1DC,aAAa,EAAE,CAAC,CAAChC,OAAO,CAACC,GAAG,CAACgC;MACjC;IACJ,CAAC;EACL;AACJ;AAEA,OAAO,MAAMC,kBAAkB,GAAGpD,oBAAoB,CAAC;EACnDqD,WAAW,EAAEpD,kBAAkB;EAC/BqD,cAAc,EAAE9C,yBAAyB;EACzC+C,YAAY,EAAE,CACVrD,cAAc,EACdC,oBAAoB,EACpBC,oBAAoB,EACpBC,uBAAuB,EACvBC,qBAAqB,EACrBC,wBAAwB;AAEhC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createImplementation","ProjectInfoService","GetIsCiService","GetNpmVersionService","GetNpxVersionService","GetPulumiVersionService","GetYarnVersionService","GetProjectVersionService","DefaultProjectInfoService","constructor","getIsCi","getNpmVersion","getNpxVersion","getPulumiVersion","getYarnVersion","getProjectVersion","execute","wcpProjectId","process","env","WEBINY_PROJECT_ID","WCP_PROJECT_ID","wcpUsingProjectEnvironmentApiKey","Boolean","WEBINY_PROJECT_API_KEY","WCP_PROJECT_ENVIRONMENT_API_KEY","WCP_ENVIRONMENT_API_KEY","isCI","npmVersion","npxVersion","yarnVersion","pulumiVersion","pulumiAwsVersion","webiny","version","debugEnabled","DEBUG","featureFlags","WEBINY_FEATURE_FLAGS","wcp","projectId","usingProjectEnvironmentApiKey","host","os","platform","arch","nodeJs","npm","npx","yarn","pulumi","secretsProvider","PULUMI_SECRETS_PROVIDER","usingPassword","PULUMI_CONFIG_PASSPHRASE","projectInfoService","abstraction","implementation","dependencies"],"sources":["ProjectInfoService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n ProjectInfoService,\n GetIsCiService,\n GetNpmVersionService,\n GetNpxVersionService,\n GetPulumiVersionService,\n GetYarnVersionService,\n GetProjectVersionService\n} from \"~/abstractions/index.js\";\nimport { IProjectInfoServiceResult } from \"~/abstractions/services/ProjectInfoService/ProjectInfoService.js\";\n\nexport class DefaultProjectInfoService implements ProjectInfoService.Interface {\n constructor(\n private getIsCi: GetIsCiService.Interface,\n private getNpmVersion: GetNpmVersionService.Interface,\n private getNpxVersion: GetNpxVersionService.Interface,\n private getPulumiVersion: GetPulumiVersionService.Interface,\n private getYarnVersion: GetYarnVersionService.Interface,\n private getProjectVersion: GetProjectVersionService.Interface\n ) {}\n\n async execute() {\n const wcpProjectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID || \"\";\n // const wcpUser = await getUser().catch(() => null);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const wcpUsingProjectEnvironmentApiKey = Boolean(\n process.env.WEBINY_PROJECT_API_KEY ||\n process.env.WCP_PROJECT_ENVIRONMENT_API_KEY ||\n process.env.WCP_ENVIRONMENT_API_KEY\n );\n\n const isCI = this.getIsCi.execute();\n const npmVersion = this.getNpmVersion.execute();\n const npxVersion = this.getNpxVersion.execute();\n const yarnVersion = this.getYarnVersion.execute();\n const [pulumiVersion, pulumiAwsVersion] = this.getPulumiVersion.execute();\n\n return {\n webiny: {\n version: this.getProjectVersion.execute(),\n debugEnabled: process.env.DEBUG === \"true\",\n featureFlags: process.env.WEBINY_FEATURE_FLAGS || {}\n },\n wcp: {\n projectId: wcpProjectId,\n // user: wcpUser?.email || \"N/A\",\n usingProjectEnvironmentApiKey: false // wcpUsingProject\n },\n host: {\n os: `${process.platform} (${process.arch})`,\n nodeJs: process.version,\n npm: npmVersion,\n npx: npxVersion,\n yarn: yarnVersion,\n isCI: isCI\n },\n pulumi: {\n \"@pulumi/pulumi\": pulumiVersion,\n \"@pulumi/aws\": pulumiAwsVersion,\n secretsProvider: process.env.PULUMI_SECRETS_PROVIDER || \"\",\n usingPassword: !!process.env.PULUMI_CONFIG_PASSPHRASE\n }\n } as IProjectInfoServiceResult;\n }\n}\n\nexport const projectInfoService = createImplementation({\n abstraction: ProjectInfoService,\n implementation: DefaultProjectInfoService,\n dependencies: [\n GetIsCiService,\n GetNpmVersionService,\n GetNpxVersionService,\n GetPulumiVersionService,\n GetYarnVersionService,\n GetProjectVersionService\n ]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SACIC,kBAAkB,EAClBC,cAAc,EACdC,oBAAoB,EACpBC,oBAAoB,EACpBC,uBAAuB,EACvBC,qBAAqB,EACrBC,wBAAwB;AAI5B,OAAO,MAAMC,yBAAyB,CAAyC;EAC3EC,WAAWA,CACCC,OAAiC,EACjCC,aAA6C,EAC7CC,aAA6C,EAC7CC,gBAAmD,EACnDC,cAA+C,EAC/CC,iBAAqD,EAC/D;IAAA,KANUL,OAAiC,GAAjCA,OAAiC;IAAA,KACjCC,aAA6C,GAA7CA,aAA6C;IAAA,KAC7CC,aAA6C,GAA7CA,aAA6C;IAAA,KAC7CC,gBAAmD,GAAnDA,gBAAmD;IAAA,KACnDC,cAA+C,GAA/CA,cAA+C;IAAA,KAC/CC,iBAAqD,GAArDA,iBAAqD;EAC9D;EAEH,MAAMC,OAAOA,CAAA,EAAG;IACZ,MAAMC,YAAY,GAAGC,OAAO,CAACC,GAAG,CAACC,iBAAiB,IAAIF,OAAO,CAACC,GAAG,CAACE,cAAc,IAAI,EAAE;IACtF;IACA;IACA,MAAMC,gCAAgC,GAAGC,OAAO,CAC5CL,OAAO,CAACC,GAAG,CAACK,sBAAsB,IAC9BN,OAAO,CAACC,GAAG,CAACM,+BAA+B,IAC3CP,OAAO,CAACC,GAAG,CAACO,uBACpB,CAAC;IAED,MAAMC,IAAI,GAAG,IAAI,CAACjB,OAAO,CAACM,OAAO,CAAC,CAAC;IACnC,MAAMY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BAAyB;EACzCkD,YAAY,EAAE,CACVxD,cAAc,EACdC,oBAAoB,EACpBC,oBAAoB,EACpBC,uBAAuB,EACvBC,qBAAqB,EACrBC,wBAAwB;AAEhC,CAAC,CAAC","ignoreList":[]}
@@ -11,7 +11,7 @@ class DefaultSetProjectIdService {
11
11
  const tsMorphProject = new TsMorphProject();
12
12
  const sourceFile = tsMorphProject.addSourceFileAtPath(webinyConfigFileTsx);
13
13
 
14
- // Ensure import { Project } from "webiny/extensions";
14
+ // Ensure import { Project } from "webiny/extensions".
15
15
  const hasProjectImport = sourceFile.getImportDeclarations().some(decl => decl.getModuleSpecifierValue() === "webiny/extensions" && decl.getNamedImports().some(imp => imp.getName() === "Project"));
16
16
  if (!hasProjectImport) {
17
17
  sourceFile.insertImportDeclaration(0, {
@@ -19,31 +19,41 @@ class DefaultSetProjectIdService {
19
19
  moduleSpecifier: "webiny/extensions"
20
20
  });
21
21
  }
22
-
23
- // Find <Webiny />
24
22
  const jsxElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement);
25
- const webinyEl = jsxElements.find(el => el.getTagNameNode().getText() === "Webiny");
26
- if (!webinyEl) {
27
- throw new Error(`Could not find <Webiny /> in ${webinyConfigFileTsx}`);
28
- }
29
23
 
30
- // Check for <Project.Id />
31
- const hasProjectId = jsxElements.some(el => el.getTagNameNode().getText() === "Project.Id");
32
- if (hasProjectId) {
24
+ // Check for existing <Project.Id />.
25
+ const existingProjectIdEl = jsxElements.find(el => el.getTagNameNode().getText() === "Project.Id");
26
+ if (existingProjectIdEl) {
33
27
  if (options.force !== true) {
34
28
  throw new Error("Project.Id already exists in the file.");
29
+ }
30
+ // Update the id attribute in-place.
31
+ const idAttr = existingProjectIdEl.getAttributes().find(attr => attr.getFirstChildByKind(SyntaxKind.Identifier)?.getText() === "id");
32
+ if (idAttr) {
33
+ idAttr.replaceWithText(`id={"${id}"}`);
35
34
  } else {
36
- // Remove existing <Project.Id />
37
- const projectIdEl = jsxElements.find(el => el.getTagNameNode().getText() === "Project.Id");
38
- if (projectIdEl) {
39
- projectIdEl.replaceWithText("");
40
- }
35
+ existingProjectIdEl.replaceWithText(`<Project.Id id={"${id}"} />`);
41
36
  }
37
+ await sourceFile.save();
38
+ return;
42
39
  }
43
40
 
44
- // Insert after <Webiny />
45
- const insertPos = webinyEl.getEnd();
46
- sourceFile.insertText(insertPos, `\n <Project.Id id={"${id}"} />`);
41
+ /* Determine the insertion point — after the last <Project.*> element that is a
42
+ direct child of the outermost JSX fragment (i.e. not inside a conditional expression).
43
+ Fall back to inserting after the opening tag of the outermost JSX fragment. */
44
+ const fragment = sourceFile.getFirstDescendantByKind(SyntaxKind.JsxFragment);
45
+ const projectEls = jsxElements.filter(el => el.getTagNameNode().getText().startsWith("Project.") && el.getParent()?.getParent() === fragment);
46
+ if (projectEls.length > 0) {
47
+ const lastProjectEl = projectEls[projectEls.length - 1];
48
+ sourceFile.insertText(lastProjectEl.getEnd(), `\n <Project.Id id={"${id}"} />`);
49
+ } else {
50
+ // Fallback: insert as first child of the outermost JSX fragment.
51
+ if (!fragment) {
52
+ throw new Error(`Could not find a JSX fragment or <Project.*> element to anchor <Project.Id /> in ${webinyConfigFileTsx}`);
53
+ }
54
+ const openingFragment = fragment.getOpeningFragment();
55
+ sourceFile.insertText(openingFragment.getEnd(), `\n <Project.Id id={"${id}"} />`);
56
+ }
47
57
  await sourceFile.save();
48
58
  }
49
59
  }
@@ -1 +1 @@
1
- {"version":3,"names":["createImplementation","GetProjectService","SetProjectIdService","Project","TsMorphProject","SyntaxKind","DefaultSetProjectIdService","constructor","getProjectService","execute","id","options","project","webinyConfigFileTsx","paths","webinyConfigFile","toString","tsMorphProject","sourceFile","addSourceFileAtPath","hasProjectImport","getImportDeclarations","some","decl","getModuleSpecifierValue","getNamedImports","imp","getName","insertImportDeclaration","namedImports","moduleSpecifier","jsxElements","getDescendantsOfKind","JsxSelfClosingElement","webinyEl","find","el","getTagNameNode","getText","Error","hasProjectId","force","projectIdEl","replaceWithText","insertPos","getEnd","insertText","save","setProjectIdService","abstraction","implementation","dependencies"],"sources":["SetProjectIdService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { GetProjectService, SetProjectIdService } from \"~/abstractions/index.js\";\nimport { Project as TsMorphProject, SyntaxKind } from \"ts-morph\";\n\nclass DefaultSetProjectIdService implements SetProjectIdService.Interface {\n constructor(private getProjectService: GetProjectService.Interface) {}\n\n async execute(id: string, options: SetProjectIdService.Options = {}) {\n const project = this.getProjectService.execute();\n const webinyConfigFileTsx = project.paths.webinyConfigFile.toString();\n\n const tsMorphProject = new TsMorphProject();\n const sourceFile = tsMorphProject.addSourceFileAtPath(webinyConfigFileTsx);\n\n // Ensure import { Project } from \"webiny/extensions\";\n const hasProjectImport = sourceFile\n .getImportDeclarations()\n .some(\n decl =>\n decl.getModuleSpecifierValue() === \"webiny/extensions\" &&\n decl.getNamedImports().some(imp => imp.getName() === \"Project\")\n );\n if (!hasProjectImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"Project\"],\n moduleSpecifier: \"webiny/extensions\"\n });\n }\n\n // Find <Webiny />\n const jsxElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement);\n const webinyEl = jsxElements.find(el => el.getTagNameNode().getText() === \"Webiny\");\n if (!webinyEl) {\n throw new Error(`Could not find <Webiny /> in ${webinyConfigFileTsx}`);\n }\n\n // Check for <Project.Id />\n const hasProjectId = jsxElements.some(el => el.getTagNameNode().getText() === \"Project.Id\");\n if (hasProjectId) {\n if (options.force !== true) {\n throw new Error(\"Project.Id already exists in the file.\");\n } else {\n // Remove existing <Project.Id />\n const projectIdEl = jsxElements.find(\n el => el.getTagNameNode().getText() === \"Project.Id\"\n );\n if (projectIdEl) {\n projectIdEl.replaceWithText(\"\");\n }\n }\n }\n\n // Insert after <Webiny />\n const insertPos = webinyEl.getEnd();\n sourceFile.insertText(insertPos, `\\n <Project.Id id={\"${id}\"} />`);\n\n await sourceFile.save();\n }\n}\n\nexport const setProjectIdService = createImplementation({\n abstraction: SetProjectIdService,\n implementation: DefaultSetProjectIdService,\n dependencies: [GetProjectService]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SAASC,iBAAiB,EAAEC,mBAAmB;AAC/C,SAASC,OAAO,IAAIC,cAAc,EAAEC,UAAU,QAAQ,UAAU;AAEhE,MAAMC,0BAA0B,CAA0C;EACtEC,WAAWA,CAASC,iBAA8C,EAAE;IAAA,KAAhDA,iBAA8C,GAA9CA,iBAA8C;EAAG;EAErE,MAAMC,OAAOA,CAACC,EAAU,EAAEC,OAAoC,GAAG,CAAC,CAAC,EAAE;IACjE,MAAMC,OAAO,GAAG,IAAI,CAACJ,iBAAiB,CAACC,OAAO,CAAC,CAAC;IAChD,MAAMI,mBAAmB,GAAGD,OAAO,CAACE,KAAK,CAACC,gBAAgB,CAACC,QAAQ,CAAC,CAAC;IAErE,MAAMC,cAAc,GAAG,IAAIb,cAAc,CAAC,CAAC;IAC3C,MAAMc,UAAU,GAAGD,cAAc,CAACE,mBAAmB,CAACN,mBAAmB,CAAC;;IAE1E;IACA,MAAMO,gBAAgB,GAAGF,UAAU,CAC9BG,qBAAqB,CAAC,CAAC,CACvBC,IAAI,CACDC,IAAI,IACAA,IAAI,CAACC,uBAAuB,CAAC,CAAC,KAAK,mBAAmB,IACtDD,IAAI,CAACE,eAAe,CAAC,CAAC,CAACH,IAAI,CAACI,GAAG,IAAIA,GAAG,CAACC,OAAO,CAAC,CAAC,KAAK,SAAS,CACtE,CAAC;IACL,IAAI,CAACP,gBAAgB,EAAE;MACnBF,UAAU,CAACU,uBAAuB,CAAC,CAAC,EAAE;QAClCC,YAAY,EAAE,CAAC,SAAS,CAAC;QACzBC,eAAe,EAAE;MACrB,CAAC,CAAC;IACN;;IAEA;IACA,MAAMC,WAAW,GAAGb,UAAU,CAACc,oBAAoB,CAAC3B,UAAU,CAAC4B,qBAAqB,CAAC;IACrF,MAAMC,QAAQ,GAAGH,WAAW,CAACI,IAAI,CAACC,EAAE,IAAIA,EAAE,CAACC,cAAc,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,KAAK,QAAQ,CAAC;IACnF,IAAI,CAACJ,QAAQ,EAAE;MACX,MAAM,IAAIK,KAAK,CAAC,gCAAgC1B,mBAAmB,EAAE,CAAC;IAC1E;;IAEA;IACA,MAAM2B,YAAY,GAAGT,WAAW,CAACT,IAAI,CAACc,EAAE,IAAIA,EAAE,CAACC,cAAc,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,KAAK,YAAY,CAAC;IAC3F,IAAIE,YAAY,EAAE;MACd,IAAI7B,OAAO,CAAC8B,KAAK,KAAK,IAAI,EAAE;QACxB,MAAM,IAAIF,KAAK,CAAC,wCAAwC,CAAC;MAC7D,CAAC,MAAM;QACH;QACA,MAAMG,WAAW,GAAGX,WAAW,CAACI,IAAI,CAChCC,EAAE,IAAIA,EAAE,CAACC,cAAc,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,KAAK,YAC5C,CAAC;QACD,IAAII,WAAW,EAAE;UACbA,WAAW,CAACC,eAAe,CAAC,EAAE,CAAC;QACnC;MACJ;IACJ;;IAEA;IACA,MAAMC,SAAS,GAAGV,QAAQ,CAACW,MAAM,CAAC,CAAC;IACnC3B,UAAU,CAAC4B,UAAU,CAACF,SAAS,EAAE,kCAAkClC,EAAE,OAAO,CAAC;IAE7E,MAAMQ,UAAU,CAAC6B,IAAI,CAAC,CAAC;EAC3B;AACJ;AAEA,OAAO,MAAMC,mBAAmB,GAAGhD,oBAAoB,CAAC;EACpDiD,WAAW,EAAE/C,mBAAmB;EAChCgD,cAAc,EAAE5C,0BAA0B;EAC1C6C,YAAY,EAAE,CAAClD,iBAAiB;AACpC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createImplementation","GetProjectService","SetProjectIdService","Project","TsMorphProject","SyntaxKind","DefaultSetProjectIdService","constructor","getProjectService","execute","id","options","project","webinyConfigFileTsx","paths","webinyConfigFile","toString","tsMorphProject","sourceFile","addSourceFileAtPath","hasProjectImport","getImportDeclarations","some","decl","getModuleSpecifierValue","getNamedImports","imp","getName","insertImportDeclaration","namedImports","moduleSpecifier","jsxElements","getDescendantsOfKind","JsxSelfClosingElement","existingProjectIdEl","find","el","getTagNameNode","getText","force","Error","idAttr","getAttributes","attr","getFirstChildByKind","Identifier","replaceWithText","save","fragment","getFirstDescendantByKind","JsxFragment","projectEls","filter","startsWith","getParent","length","lastProjectEl","insertText","getEnd","openingFragment","getOpeningFragment","setProjectIdService","abstraction","implementation","dependencies"],"sources":["SetProjectIdService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { GetProjectService, SetProjectIdService } from \"~/abstractions/index.js\";\nimport { Project as TsMorphProject, SyntaxKind } from \"ts-morph\";\n\nclass DefaultSetProjectIdService implements SetProjectIdService.Interface {\n constructor(private getProjectService: GetProjectService.Interface) {}\n\n async execute(id: string, options: SetProjectIdService.Options = {}) {\n const project = this.getProjectService.execute();\n const webinyConfigFileTsx = project.paths.webinyConfigFile.toString();\n\n const tsMorphProject = new TsMorphProject();\n const sourceFile = tsMorphProject.addSourceFileAtPath(webinyConfigFileTsx);\n\n // Ensure import { Project } from \"webiny/extensions\".\n const hasProjectImport = sourceFile\n .getImportDeclarations()\n .some(\n decl =>\n decl.getModuleSpecifierValue() === \"webiny/extensions\" &&\n decl.getNamedImports().some(imp => imp.getName() === \"Project\")\n );\n if (!hasProjectImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"Project\"],\n moduleSpecifier: \"webiny/extensions\"\n });\n }\n\n const jsxElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement);\n\n // Check for existing <Project.Id />.\n const existingProjectIdEl = jsxElements.find(\n el => el.getTagNameNode().getText() === \"Project.Id\"\n );\n if (existingProjectIdEl) {\n if (options.force !== true) {\n throw new Error(\"Project.Id already exists in the file.\");\n }\n // Update the id attribute in-place.\n const idAttr = existingProjectIdEl\n .getAttributes()\n .find(attr => attr.getFirstChildByKind(SyntaxKind.Identifier)?.getText() === \"id\");\n if (idAttr) {\n idAttr.replaceWithText(`id={\"${id}\"}`);\n } else {\n existingProjectIdEl.replaceWithText(`<Project.Id id={\"${id}\"} />`);\n }\n await sourceFile.save();\n return;\n }\n\n /* Determine the insertion point — after the last <Project.*> element that is a\n direct child of the outermost JSX fragment (i.e. not inside a conditional expression).\n Fall back to inserting after the opening tag of the outermost JSX fragment. */\n const fragment = sourceFile.getFirstDescendantByKind(SyntaxKind.JsxFragment);\n const projectEls = jsxElements.filter(\n el =>\n el.getTagNameNode().getText().startsWith(\"Project.\") &&\n el.getParent()?.getParent() === fragment\n );\n\n if (projectEls.length > 0) {\n const lastProjectEl = projectEls[projectEls.length - 1];\n sourceFile.insertText(\n lastProjectEl.getEnd(),\n `\\n <Project.Id id={\"${id}\"} />`\n );\n } else {\n // Fallback: insert as first child of the outermost JSX fragment.\n if (!fragment) {\n throw new Error(\n `Could not find a JSX fragment or <Project.*> element to anchor <Project.Id /> in ${webinyConfigFileTsx}`\n );\n }\n const openingFragment = fragment.getOpeningFragment();\n sourceFile.insertText(\n openingFragment.getEnd(),\n `\\n <Project.Id id={\"${id}\"} />`\n );\n }\n\n await sourceFile.save();\n }\n}\n\nexport const setProjectIdService = createImplementation({\n abstraction: SetProjectIdService,\n implementation: DefaultSetProjectIdService,\n dependencies: [GetProjectService]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SAASC,iBAAiB,EAAEC,mBAAmB;AAC/C,SAASC,OAAO,IAAIC,cAAc,EAAEC,UAAU,QAAQ,UAAU;AAEhE,MAAMC,0BAA0B,CAA0C;EACtEC,WAAWA,CAASC,iBAA8C,EAAE;IAAA,KAAhDA,iBAA8C,GAA9CA,iBAA8C;EAAG;EAErE,MAAMC,OAAOA,CAACC,EAAU,EAAEC,OAAoC,GAAG,CAAC,CAAC,EAAE;IACjE,MAAMC,OAAO,GAAG,IA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EAAEzD,0BAA0B;EAC1C0D,YAAY,EAAE,CAAC/D,iBAAiB;AACpC,CAAC,CAAC","ignoreList":[]}
@@ -1,12 +1,12 @@
1
1
  import { WatchedLambdaFunctionsService, LocalStorageService } from "../../abstractions/index.js";
2
- import { type AppName } from "../../abstractions/types.js";
3
2
  export declare class DefaultWatchedLambdaFunctionsService implements WatchedLambdaFunctionsService.Interface {
4
3
  private localStorageService;
5
4
  constructor(localStorageService: LocalStorageService.Interface);
6
- markDirty(app: AppName, functionUrns: string[]): void;
7
- getDirty(app: AppName): string[];
8
- clearDirty(app: AppName): void;
5
+ markDirty(params: WatchedLambdaFunctionsService.Params, functionUrns: string[]): void;
6
+ getDirty(params: WatchedLambdaFunctionsService.Params): string[];
7
+ clearDirty(params: WatchedLambdaFunctionsService.Params): void;
9
8
  clearAll(): void;
9
+ private getCacheKey;
10
10
  private getData;
11
11
  private setData;
12
12
  }
@@ -5,34 +5,40 @@ export class DefaultWatchedLambdaFunctionsService {
5
5
  constructor(localStorageService) {
6
6
  this.localStorageService = localStorageService;
7
7
  }
8
- markDirty(app, functionUrns) {
9
- const data = this.getData();
10
- if (!data[app]) {
11
- data[app] = [];
8
+ markDirty(params, functionUrns) {
9
+ const key = this.getCacheKey(params);
10
+ const data = this.getData(key);
11
+ if (!data[params.name]) {
12
+ data[params.name] = [];
12
13
  }
13
14
 
14
- // Add new URNs, avoiding duplicates
15
+ // Add new URNs, avoiding duplicates.
15
16
  for (const urn of functionUrns) {
16
- if (!data[app].includes(urn)) {
17
- data[app].push(urn);
17
+ if (!data[params.name].includes(urn)) {
18
+ data[params.name].push(urn);
18
19
  }
19
20
  }
20
- this.setData(data);
21
+ this.setData(key, data);
21
22
  }
22
- getDirty(app) {
23
- const data = this.getData();
24
- return data[app] || [];
23
+ getDirty(params) {
24
+ const key = this.getCacheKey(params);
25
+ const data = this.getData(key);
26
+ return data[params.name] || [];
25
27
  }
26
- clearDirty(app) {
27
- const data = this.getData();
28
- delete data[app];
29
- this.setData(data);
28
+ clearDirty(params) {
29
+ const key = this.getCacheKey(params);
30
+ const data = this.getData(key);
31
+ delete data[params.name];
32
+ this.setData(key, data);
30
33
  }
31
34
  clearAll() {
32
- this.setData({});
35
+ this.setData(WATCHED_LAMBDA_FUNCTIONS_KEY, {});
33
36
  }
34
- getData() {
35
- const data = this.localStorageService.get(WATCHED_LAMBDA_FUNCTIONS_KEY);
37
+ getCacheKey(params) {
38
+ return params.deploymentId ? `${WATCHED_LAMBDA_FUNCTIONS_KEY}-${params.deploymentId}` : WATCHED_LAMBDA_FUNCTIONS_KEY;
39
+ }
40
+ getData(key) {
41
+ const data = this.localStorageService.get(key);
36
42
  if (!data) {
37
43
  return {};
38
44
  }
@@ -42,8 +48,8 @@ export class DefaultWatchedLambdaFunctionsService {
42
48
  return {};
43
49
  }
44
50
  }
45
- setData(data) {
46
- this.localStorageService.set(WATCHED_LAMBDA_FUNCTIONS_KEY, data);
51
+ setData(key, data) {
52
+ this.localStorageService.set(key, data);
47
53
  }
48
54
  }
49
55
  export const watchedLambdaFunctionsService = createImplementation({
@@ -1 +1 @@
1
- {"version":3,"names":["createImplementation","WatchedLambdaFunctionsService","LocalStorageService","WATCHED_LAMBDA_FUNCTIONS_KEY","DefaultWatchedLambdaFunctionsService","constructor","localStorageService","markDirty","app","functionUrns","data","getData","urn","includes","push","setData","getDirty","clearDirty","clearAll","get","JSON","parse","set","watchedLambdaFunctionsService","abstraction","implementation","dependencies"],"sources":["WatchedLambdaFunctionsService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { WatchedLambdaFunctionsService, LocalStorageService } from \"~/abstractions/index.js\";\nimport { type AppName } from \"~/abstractions/types.js\";\n\nconst WATCHED_LAMBDA_FUNCTIONS_KEY = \"watchedLambdaFunctions\";\n\ninterface WatchedLambdaFunctionsData {\n [app: string]: string[]; // app name -> array of Lambda URNs\n}\n\nexport class DefaultWatchedLambdaFunctionsService\n implements WatchedLambdaFunctionsService.Interface\n{\n constructor(private localStorageService: LocalStorageService.Interface) {}\n\n markDirty(app: AppName, functionUrns: string[]): void {\n const data = this.getData();\n\n if (!data[app]) {\n data[app] = [];\n }\n\n // Add new URNs, avoiding duplicates\n for (const urn of functionUrns) {\n if (!data[app].includes(urn)) {\n data[app].push(urn);\n }\n }\n\n this.setData(data);\n }\n\n getDirty(app: AppName): string[] {\n const data = this.getData();\n return data[app] || [];\n }\n\n clearDirty(app: AppName): void {\n const data = this.getData();\n delete data[app];\n this.setData(data);\n }\n\n clearAll(): void {\n this.setData({});\n }\n\n private getData(): WatchedLambdaFunctionsData {\n const data = this.localStorageService.get(WATCHED_LAMBDA_FUNCTIONS_KEY);\n if (!data) {\n return {};\n }\n\n try {\n return typeof data === \"string\" ? JSON.parse(data) : data;\n } catch {\n return {};\n }\n }\n\n private setData(data: WatchedLambdaFunctionsData): void {\n this.localStorageService.set(WATCHED_LAMBDA_FUNCTIONS_KEY, data);\n }\n}\n\nexport const watchedLambdaFunctionsService = createImplementation({\n abstraction: WatchedLambdaFunctionsService,\n implementation: DefaultWatchedLambdaFunctionsService,\n dependencies: [LocalStorageService]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SAASC,6BAA6B,EAAEC,mBAAmB;AAG3D,MAAMC,4BAA4B,GAAG,wBAAwB;AAM7D,OAAO,MAAMC,oCAAoC,CAEjD;EACIC,WAAWA,CAASC,mBAAkD,EAAE;IAAA,KAApDA,mBAAkD,GAAlDA,mBAAkD;EAAG;EAEzEC,SAASA,CAACC,GAAY,EAAEC,YAAsB,EAAQ;IAClD,MAAMC,IAAI,GAAG,IAAI,CAACC,OAAO,CAAC,CAAC;IAE3B,IAAI,CAACD,IAAI,CAACF,GAAG,CAAC,EAAE;MACZE,IAAI,CAACF,GAAG,CAAC,GAAG,EAAE;IAClB;;IAEA;IACA,KAAK,MAAMI,GAAG,IAAIH,YAAY,EAAE;MAC5B,IAAI,CAACC,IAAI,CAACF,GAAG,CAAC,CAACK,QAAQ,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StorageService","WATCHED_LAMBDA_FUNCTIONS_KEY","DefaultWatchedLambdaFunctionsService","constructor","localStorageService","markDirty","params","functionUrns","key","getCacheKey","data","getData","name","urn","includes","push","setData","getDirty","clearDirty","clearAll","deploymentId","get","JSON","parse","set","watchedLambdaFunctionsService","abstraction","implementation","dependencies"],"sources":["WatchedLambdaFunctionsService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { WatchedLambdaFunctionsService, LocalStorageService } from \"~/abstractions/index.js\";\n\nconst WATCHED_LAMBDA_FUNCTIONS_KEY = \"watchedLambdaFunctions\";\n\ninterface WatchedLambdaFunctionsData {\n [app: string]: string[]; // app name -> array of Lambda URNs\n}\n\nexport class DefaultWatchedLambdaFunctionsService\n implements WatchedLambdaFunctionsService.Interface\n{\n constructor(private localStorageService: LocalStorageService.Interface) {}\n\n markDirty(params: WatchedLambdaFunctionsService.Params, functionUrns: string[]): void {\n const key = this.getCacheKey(params);\n const data = this.getData(key);\n\n if (!data[params.name]) {\n data[params.name] = [];\n }\n\n // Add new URNs, avoiding duplicates.\n for (const urn of functionUrns) {\n if (!data[params.name].includes(urn)) {\n data[params.name].push(urn);\n }\n }\n\n this.setData(key, data);\n }\n\n getDirty(params: WatchedLambdaFunctionsService.Params): string[] {\n const key = this.getCacheKey(params);\n const data = this.getData(key);\n return data[params.name] || [];\n }\n\n clearDirty(params: WatchedLambdaFunctionsService.Params): void {\n const key = this.getCacheKey(params);\n const data = this.getData(key);\n delete data[params.name];\n this.setData(key, data);\n }\n\n clearAll(): void {\n this.setData(WATCHED_LAMBDA_FUNCTIONS_KEY, {});\n }\n\n private getCacheKey(params: WatchedLambdaFunctionsService.Params): string {\n return params.deploymentId\n ? `${WATCHED_LAMBDA_FUNCTIONS_KEY}-${params.deploymentId}`\n : WATCHED_LAMBDA_FUNCTIONS_KEY;\n }\n\n private getData(key: string): WatchedLambdaFunctionsData {\n const data = this.localStorageService.get(key);\n if (!data) {\n return {};\n }\n\n try {\n return typeof data === \"string\" ? JSON.parse(data) : data;\n } catch {\n return {};\n }\n }\n\n private setData(key: string, data: WatchedLambdaFunctionsData): void {\n this.localStorageService.set(key, data);\n }\n}\n\nexport const watchedLambdaFunctionsService = createImplementation({\n abstraction: WatchedLambdaFunctionsService,\n implementation: DefaultWatchedLambdaFunctionsService,\n dependencies: [LocalStorageService]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SAASC,6BAA6B,EAAEC,mBAAmB;AAE3D,MAAMC,4BAA4B,GAAG,wBAAwB;AAM7D,OAAO,MAAMC,oCAAoC,CAEjD;EACIC,WAAWA,CAASC,mBAAkD,EAAE;IAAA,KAApDA,mBAAkD,GAAlDA,mBAAkD;EAAG;EAEzEC,SAASA,CAACC,MAA4C,EAAEC,YAAsB,EAAQ;IAClF,MAAMC,GAAG,GAAG,IAAI,CAACC,WAAW,CAACH,MAAM,CAAC;IACpC,MAAMI,IAAI,GAAG,IAAI,CAACC,OAAO,CAACH,GAAG,CAAC;IAE9B,IAAI,CAACE,IAAI,CAACJ,MAAM,CAACM,IAAI,CAAC,EAAE;MACpBF,IAAI,CAACJ,MAAM,CAACM,IAAI,CAAC,GAAG,EAAE;IAC1B;;IAEA;IACA,KAAK,MAAMC,GAAG,IAAIN,YAAY,EAAE;MAC5B,IAAI,CAACG,IAAI,CAACJ,MAAM,CAACM,IAAI,CAAC,CAACE,QAAQ,CAACD,GAAG,CAAC,EAAE;QAClCH,IAAI,CAACJ,MAAM,CAACM,IAAI,CAAC,CAACG,IAAI,CAACF,GAAG,CAAC;MAC/B;IACJ;IAEA,IAAI,CAACG,OAAO,CAACR,GAAG,EAAEE,IAAI,CAAC;EAC3B;EAEAO,QAAQA,CAACX,MAA4C,EAAY;IAC7D,MAAME,GAAG,GAAG,IAAI,CAACC,WAAW,CAACH,MAAM,CAAC;IACpC,MAAMI,IAAI,GAAG,IAAI,CAACC,OAAO,CAACH,GAAG,CAAC;IAC9B,OAAOE,IAAI,CAACJ,MAA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Model } from "../abstractions/models/index.js";
2
+ export declare class ExtensionSrcResolver {
3
+ private static pathMappings;
4
+ /**
5
+ * Import a module from a given file path.
6
+ * - If path starts with "/extensions/", it resolves from project root
7
+ * - If path matches tsconfig path alias (e.g., "@/*"), it resolves using tsconfig
8
+ * - Otherwise, treats path as absolute
9
+ * Returns the default export or named export matching the filename.
10
+ */
11
+ static importFromPath(filePath: string, project: IProjectModel): Promise<any>;
12
+ /**
13
+ * Resolve a file path to an absolute path.
14
+ * - If path starts with "/extensions/", it resolves from project root
15
+ * - If path matches tsconfig path alias (e.g., "@/*"), it resolves using tsconfig
16
+ * - Otherwise, treats path as absolute
17
+ * Returns the absolute path without importing.
18
+ */
19
+ static resolvePath(filePath: string, project: IProjectModel): string;
20
+ /**
21
+ * Check if a file exists at the given path.
22
+ * Resolves the path using the same logic as resolvePath before checking.
23
+ * - If path starts with "/extensions/", it resolves from project root
24
+ * - If path matches tsconfig path alias (e.g., "@/*"), it resolves using tsconfig
25
+ * - Otherwise, treats path as absolute
26
+ * Returns true if the file exists, false otherwise.
27
+ */
28
+ static existsSync(filePath: string, project: IProjectModel): boolean;
29
+ private static resolvePathAlias;
30
+ private static loadPathMappings;
31
+ private static matchPattern;
32
+ private static replacePlaceholder;
33
+ }