@webiny/project-aws 0.0.0-unstable.0d717d18dd → 0.0.0-unstable.5387e5f7c8

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 (48) hide show
  1. package/_templates/appTemplates/api/graphql/src/index.ts +12 -1
  2. package/_templates/extensions/OpenSearch/api/graphql/src/index.ts +9 -1
  3. package/apps/createApiApp.d.ts +8 -0
  4. package/extensions/ApiRoute.d.ts +1 -1
  5. package/extensions/ApiRoute.js +17 -2
  6. package/extensions/ApiRoute.js.map +1 -1
  7. package/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.d.ts +1 -1
  8. package/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.js +1 -2
  9. package/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.js.map +1 -1
  10. package/extensions/ProjectAws/EnsureAwsCredentialsBeforeDeploy.js +1 -1
  11. package/extensions/ProjectAws/EnsureAwsCredentialsBeforeDeploy.js.map +1 -1
  12. package/extensions/ProjectAws/UploadAdminAppToS3.js +1 -1
  13. package/extensions/ProjectAws/UploadAdminAppToS3.js.map +1 -1
  14. package/extensions/ProjectAws.js.map +1 -1
  15. package/extensions/RegisterRoutesPulumi.js +3 -6
  16. package/extensions/RegisterRoutesPulumi.js.map +1 -1
  17. package/extensions/routePath.d.ts +20 -0
  18. package/extensions/routePath.js +13 -0
  19. package/extensions/routePath.js.map +1 -0
  20. package/features/InvokeLambdaFunction.js +1 -1
  21. package/features/InvokeLambdaFunction.js.map +1 -1
  22. package/features/Watch/AwsWatch.js +3 -3
  23. package/features/Watch/AwsWatch.js.map +1 -1
  24. package/package.json +14 -14
  25. package/project.d.ts +25 -17
  26. package/project.js +3 -2
  27. package/project.js.map +1 -1
  28. package/pulumi/apps/api/ApiCloudfront.js +103 -1
  29. package/pulumi/apps/api/ApiCloudfront.js.map +1 -1
  30. package/pulumi/apps/api/ApiGraphqlStream.d.ts +29 -0
  31. package/pulumi/apps/api/ApiGraphqlStream.js +58 -0
  32. package/pulumi/apps/api/ApiGraphqlStream.js.map +1 -0
  33. package/pulumi/apps/api/createApiPulumiApp.d.ts +8 -0
  34. package/pulumi/apps/api/createApiPulumiApp.js +24 -17
  35. package/pulumi/apps/api/createApiPulumiApp.js.map +1 -1
  36. package/pulumi/apps/api/index.d.ts +1 -0
  37. package/pulumi/apps/api/index.js +1 -0
  38. package/pulumi/apps/awsUtils.d.ts +1 -1
  39. package/pulumi/apps/core/createCorePulumiApp.js +1 -1
  40. package/pulumi/apps/core/createCorePulumiApp.js.map +1 -1
  41. package/pulumi/apps/syncSystem/SyncSystemLambda.d.ts +1 -1
  42. package/pulumi/apps/syncSystem/SyncSystemLambda.js +1 -1
  43. package/pulumi/apps/syncSystem/SyncSystemLambda.js.map +1 -1
  44. package/pulumi/extensions/index.d.ts +16 -16
  45. package/pulumi/utils/lambdaEnvVariables.js.map +1 -1
  46. package/services/GetPulumiService/GetPulumiService.d.ts +1 -2
  47. package/services/GetPulumiService/GetPulumiService.js +1 -1
  48. package/services/GetPulumiService/GetPulumiService.js.map +1 -1
@@ -4,8 +4,19 @@
4
4
  * The composition root lives in @webiny/api-event-handler-aws-ddb (`createAwsDdbApiHandler`) so the wiring
5
5
  * is a real, testable package rather than template code. This file only supplies project-specific
6
6
  * extensions.
7
+ *
8
+ * Two handlers are exported from this one bundle and deployed as two Lambda functions:
9
+ * - `handler` — behind API Gateway, buffered responses. Everything except streaming routes.
10
+ * - `streamHandler` — behind a Lambda Function URL with `InvokeMode: RESPONSE_STREAM`, for routes that
11
+ * stream (e.g. `/stream/*`). A separate function is required because a Lambda's handler entry is
12
+ * fixed per function, and API Gateway buffers the whole response so it cannot stream at all.
7
13
  */
8
- import { createAwsDdbApiHandler } from "@webiny/api-event-handler-aws-ddb";
14
+ import {
15
+ createAwsDdbApiHandler,
16
+ createAwsDdbStreamApiHandler
17
+ } from "@webiny/api-event-handler-aws-ddb";
9
18
  import { extensions } from "./extensions";
10
19
 
11
20
  export const handler = createAwsDdbApiHandler({ extensions });
21
+
22
+ export const streamHandler = createAwsDdbStreamApiHandler({ extensions });
@@ -5,8 +5,16 @@
5
5
  * wiring is a real, testable package rather than template code. The OpenSearch extension's
6
6
  * ReplaceApiLambdaFnHandlers copies this file over the api workspace when OpenSearch is enabled.
7
7
  * This file only supplies project-specific extensions.
8
+ *
9
+ * Exports both the buffered (API Gateway) and the response-streaming (Function URL) handler; see the
10
+ * DynamoDB variant of this file for why streaming needs its own Lambda function.
8
11
  */
9
- import { createAwsDdbOsApiHandler } from "@webiny/api-event-handler-aws-ddb-os";
12
+ import {
13
+ createAwsDdbOsApiHandler,
14
+ createAwsDdbOsStreamApiHandler
15
+ } from "@webiny/api-event-handler-aws-ddb-os";
10
16
  import { extensions } from "./extensions";
11
17
 
12
18
  export const handler = createAwsDdbOsApiHandler({ extensions });
19
+
20
+ export const streamHandler = createAwsDdbOsStreamApiHandler({ extensions });
@@ -22,6 +22,14 @@ export declare function createApiApp(): {
22
22
  };
23
23
  addRoute: (routeParams: import("~/pulumi/index.js").AddRouteParams) => any;
24
24
  };
25
+ graphqlStream: {
26
+ role: import("@webiny/pulumi/PulumiAppResource").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
27
+ functions: {
28
+ graphqlStream: import("@webiny/pulumi/PulumiAppResource").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
29
+ };
30
+ functionUrl: import("@webiny/pulumi/PulumiAppResource").PulumiAppResource<typeof import("@pulumi/aws/lambda/functionUrl").FunctionUrl>;
31
+ functionUrlDomain: import("@pulumi/pulumi").Output<string>;
32
+ };
25
33
  apiGateway: {
26
34
  api: import("@webiny/pulumi/PulumiAppResource").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/api").Api>;
27
35
  stage: import("@webiny/pulumi/PulumiAppResource").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/stage").Stage>;
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- export declare const ApiRoute: import("@webiny/project/extensions").ExtensionComponent<z.ZodObject<{
2
+ export declare const ApiRoute: import("@webiny/project/defineExtension/defineExtension.js").ExtensionComponent<z.ZodObject<{
3
3
  path: z.ZodString;
4
4
  method: z.ZodEnum<{
5
5
  ANY: "ANY";
@@ -8,6 +8,7 @@ import { zodSrcPath } from "@webiny/project/defineExtension/zodTypes/zodSrcPath.
8
8
  import { ExtensionSrcResolver } from "@webiny/project/utils/index.js";
9
9
  import { ApiPulumi } from "../pulumi/extensions/ApiPulumi.js";
10
10
  import { createPathResolver } from "@webiny/project";
11
+ import { deriveRouteName, toRouterPath } from "./routePath.js";
11
12
  const p = createPathResolver(import.meta.dirname);
12
13
  const HTTP_METHODS = [
13
14
  "DELETE",
@@ -53,7 +54,9 @@ const ApiRoute = defineExtension({
53
54
  moduleSpecifier: importPath
54
55
  });
55
56
  const registerExtensionPluginPath = "@webiny/handler/plugins/RegisterExtensionPlugin.js";
56
- if (!source.getImportDeclaration(registerExtensionPluginPath)) {
57
+ const existingRegisterExtensionPluginImport = source.getImportDeclaration(registerExtensionPluginPath);
58
+ if (existingRegisterExtensionPluginImport && !existingRegisterExtensionPluginImport.getNamedImports().some((i)=>"createRegisterExtensionPlugin" === i.getName())) existingRegisterExtensionPluginImport.addNamedImport("createRegisterExtensionPlugin");
59
+ else if (!existingRegisterExtensionPluginImport) {
57
60
  const lastIdx = source.getImportDeclarations()[source.getImportDeclarations().length - 1].getChildIndex() + 1;
58
61
  source.insertImportDeclaration(lastIdx, {
59
62
  namedImports: [
@@ -62,8 +65,20 @@ const ApiRoute = defineExtension({
62
65
  moduleSpecifier: registerExtensionPluginPath
63
66
  });
64
67
  }
68
+ const eventHandlerCorePath = "@webiny/event-handler-core";
69
+ if (!source.getImportDeclaration(eventHandlerCorePath)) {
70
+ const lastIdx = source.getImportDeclarations()[source.getImportDeclarations().length - 1].getChildIndex() + 1;
71
+ source.insertImportDeclaration(lastIdx, {
72
+ namedImports: [
73
+ "createHttpRouteDefinition"
74
+ ],
75
+ moduleSpecifier: eventHandlerCorePath
76
+ });
77
+ }
65
78
  const pluginsArray = source.getFirstDescendant((node)=>Node.isArrayLiteralExpression(node));
66
- pluginsArray.addElement(`\ncreateRegisterExtensionPlugin(ctx => {\n\tregisterExtension(ctx.container, ${alias});\n})`);
79
+ const routerPath = toRouterPath(params.path);
80
+ const routeName = params.routeName ?? deriveRouteName(params.path, params.method);
81
+ pluginsArray.addElement(`\ncreateRegisterExtensionPlugin(ctx => {\n\tctx.container.register(\n\t\tcreateHttpRouteDefinition({\n\t\t\tname: "${routeName}",\n\t\t\tmethod: "${params.method}",\n\t\t\tpath: "${routerPath}",\n\t\t\thandler: ${alias}\n\t\t})\n\t);\n})`);
67
82
  await source.save();
68
83
  },
69
84
  render () {
@@ -1 +1 @@
1
- {"version":3,"file":"extensions/ApiRoute.js","sources":["../../src/extensions/ApiRoute.tsx"],"sourcesContent":["import React from \"react\";\nimport path from \"path\";\nimport crypto from \"crypto\";\nimport { z } from \"zod\";\nimport { Node, Project, ArrayLiteralExpression } from \"ts-morph\";\nimport { defineExtension } from \"@webiny/project/defineExtension/index.js\";\nimport { zodSrcPath } from \"@webiny/project/defineExtension/zodTypes/zodSrcPath.js\";\nimport { ExtensionSrcResolver } from \"@webiny/project/utils/index.js\";\nimport { ApiPulumi } from \"~/pulumi/extensions/ApiPulumi.js\";\nimport { createPathResolver } from \"@webiny/project\";\n\nconst p = createPathResolver(import.meta.dirname);\n\nconst HTTP_METHODS = [\"DELETE\", \"GET\", \"HEAD\", \"PATCH\", \"POST\", \"PUT\", \"OPTIONS\", \"ANY\"] as const;\n\nexport const ApiRoute = defineExtension({\n type: \"Api/Route\",\n tags: { runtimeContext: \"app-build\", appName: \"api\" },\n description: \"Register a custom REST route on the API Gateway + GraphQL Lambda.\",\n multiple: true,\n paramsSchema: ({ project }) => {\n return z.object({\n path: z.string().startsWith(\"/\"),\n method: z.enum(HTTP_METHODS),\n // The `src` file must default-export an HttpRoute implementation\n // (HttpRoute.createImplementation from @webiny/event-handler-core), the same shape as\n // the framework's own routes (e.g. createCmsRoute). Its `method`/`path` must match the\n // `method`/`path` params here (used to configure the API Gateway route).\n src: zodSrcPath({ project }),\n routeName: z.string().optional()\n });\n },\n async build(params, ctx) {\n const extensionsTsFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"extensions.ts\")\n .toString();\n\n const absoluteSrcFilePath = ExtensionSrcResolver.resolvePath(params.src, ctx.project);\n\n // Stable alias to avoid naming conflicts across multiple routes.\n const hash = crypto.createHash(\"sha256\").update(params.src).digest(\"hex\");\n const alias = `ApiRoute_${hash.slice(-10)}`;\n\n const importPath = path\n .relative(path.dirname(extensionsTsFilePath), absoluteSrcFilePath)\n .replace(/\\.tsx?$/, \".js\");\n\n const tsProject = new Project();\n tsProject.addSourceFileAtPath(extensionsTsFilePath);\n const source = tsProject.getSourceFileOrThrow(extensionsTsFilePath);\n\n // Skip if the route handler is already registered.\n if (source.getImportDeclaration(importPath)) {\n return;\n }\n\n // Insert handler import after the last existing import.\n let insertIndex = 1;\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n insertIndex = importDeclarations[importDeclarations.length - 1].getChildIndex() + 1;\n }\n\n source.insertImportDeclaration(insertIndex, {\n defaultImport: alias,\n moduleSpecifier: importPath\n });\n\n // Ensure createRegisterExtensionPlugin import exists.\n const registerExtensionPluginPath = \"@webiny/handler/plugins/RegisterExtensionPlugin.js\";\n if (!source.getImportDeclaration(registerExtensionPluginPath)) {\n const lastIdx =\n source\n .getImportDeclarations()\n [source.getImportDeclarations().length - 1].getChildIndex() + 1;\n source.insertImportDeclaration(lastIdx, {\n namedImports: [\"createRegisterExtensionPlugin\"],\n moduleSpecifier: registerExtensionPluginPath\n });\n }\n\n const pluginsArray = source.getFirstDescendant(node =>\n Node.isArrayLiteralExpression(node)\n ) as ArrayLiteralExpression;\n\n // Register the route's HttpRoute implementation in the DI container. The DI HttpRouter\n // resolves every registered HttpRoute and dispatches by matching the request method/path\n // against each route's own `method`/`path` — no explicit route wiring needed.\n pluginsArray.addElement(\n `\\ncreateRegisterExtensionPlugin(ctx => {\\n\\tregisterExtension(ctx.container, ${alias});\\n})`\n );\n\n await source.save();\n },\n render() {\n return <ApiPulumi src={p(\"RegisterRoutesPulumi.js\")} />;\n }\n});\n"],"names":["p","createPathResolver","HTTP_METHODS","ApiRoute","defineExtension","project","z","zodSrcPath","params","ctx","extensionsTsFilePath","absoluteSrcFilePath","ExtensionSrcResolver","hash","crypto","alias","importPath","path","tsProject","Project","source","insertIndex","importDeclarations","registerExtensionPluginPath","lastIdx","pluginsArray","node","Node","ApiPulumi"],"mappings":";;;;;;;;;;AAWA,MAAMA,IAAIC,mBAAmB,YAAY,OAAO;AAEhD,MAAMC,eAAe;IAAC;IAAU;IAAO;IAAQ;IAAS;IAAQ;IAAO;IAAW;CAAM;AAEjF,MAAMC,WAAWC,gBAAgB;IACpC,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAa,SAAS;IAAM;IACpD,aAAa;IACb,UAAU;IACV,cAAc,CAAC,EAAEC,OAAO,EAAE,GACfC,EAAE,MAAM,CAAC;YACZ,MAAMA,EAAE,MAAM,GAAG,UAAU,CAAC;YAC5B,QAAQA,CAAC,CAADA,OAAM,CAACJ;YAKf,KAAKK,WAAW;gBAAEF;YAAQ;YAC1B,WAAWC,EAAE,MAAM,GAAG,QAAQ;QAClC;IAEJ,MAAM,OAAME,MAAM,EAAEC,GAAG;QACnB,MAAMC,uBAAuBD,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe,CACzD,IAAI,CAAC,QAAQ,OAAO,WAAW,OAAO,iBACtC,QAAQ;QAEb,MAAME,sBAAsBC,qBAAqB,WAAW,CAACJ,OAAO,GAAG,EAAEC,IAAI,OAAO;QAGpF,MAAMI,OAAOC,SAAAA,UAAiB,CAAC,UAAU,MAAM,CAACN,OAAO,GAAG,EAAE,MAAM,CAAC;QACnE,MAAMO,QAAQ,CAAC,SAAS,EAAEF,KAAK,KAAK,CAAC,MAAM;QAE3C,MAAMG,aAAaC,KAAAA,QACN,CAACA,KAAK,OAAO,CAACP,uBAAuBC,qBAC7C,OAAO,CAAC,WAAW;QAExB,MAAMO,YAAY,IAAIC;QACtBD,UAAU,mBAAmB,CAACR;QAC9B,MAAMU,SAASF,UAAU,oBAAoB,CAACR;QAG9C,IAAIU,OAAO,oBAAoB,CAACJ,aAC5B;QAIJ,IAAIK,cAAc;QAClB,MAAMC,qBAAqBF,OAAO,qBAAqB;QACvD,IAAIE,mBAAmB,MAAM,EACzBD,cAAcC,kBAAkB,CAACA,mBAAmB,MAAM,GAAG,EAAE,CAAC,aAAa,KAAK;QAGtFF,OAAO,uBAAuB,CAACC,aAAa;YACxC,eAAeN;YACf,iBAAiBC;QACrB;QAGA,MAAMO,8BAA8B;QACpC,IAAI,CAACH,OAAO,oBAAoB,CAACG,8BAA8B;YAC3D,MAAMC,UACFJ,OACK,qBAAqB,EACtB,CAACA,OAAO,qBAAqB,GAAG,MAAM,GAAG,EAAE,CAAC,aAAa,KAAK;YACtEA,OAAO,uBAAuB,CAACI,SAAS;gBACpC,cAAc;oBAAC;iBAAgC;gBAC/C,iBAAiBD;YACrB;QACJ;QAEA,MAAME,eAAeL,OAAO,kBAAkB,CAACM,CAAAA,OAC3CC,KAAK,wBAAwB,CAACD;QAMlCD,aAAa,UAAU,CACnB,CAAC,6EAA6E,EAAEV,MAAM,MAAM,CAAC;QAGjG,MAAMK,OAAO,IAAI;IACrB;IACA;QACI,OAAO,WAAP,GAAO,oBAACQ,WAASA;YAAC,KAAK5B,EAAE;;IAC7B;AACJ"}
1
+ {"version":3,"file":"extensions/ApiRoute.js","sources":["../../src/extensions/ApiRoute.tsx"],"sourcesContent":["import React from \"react\";\nimport path from \"path\";\nimport crypto from \"crypto\";\nimport { z } from \"zod\";\nimport { Node, Project, ArrayLiteralExpression } from \"ts-morph\";\nimport { defineExtension } from \"@webiny/project/defineExtension/index.js\";\nimport { zodSrcPath } from \"@webiny/project/defineExtension/zodTypes/zodSrcPath.js\";\nimport { ExtensionSrcResolver } from \"@webiny/project/utils/index.js\";\nimport { ApiPulumi } from \"~/pulumi/extensions/ApiPulumi.js\";\nimport { createPathResolver } from \"@webiny/project\";\nimport { deriveRouteName, toRouterPath } from \"./routePath.js\";\n\nconst p = createPathResolver(import.meta.dirname);\n\nconst HTTP_METHODS = [\"DELETE\", \"GET\", \"HEAD\", \"PATCH\", \"POST\", \"PUT\", \"OPTIONS\", \"ANY\"] as const;\n\nexport const ApiRoute = defineExtension({\n type: \"Api/Route\",\n tags: { runtimeContext: \"app-build\", appName: \"api\" },\n description: \"Register a custom REST route on the API Gateway + GraphQL Lambda.\",\n multiple: true,\n paramsSchema: ({ project }) => {\n return z.object({\n // Path parameters may be written `{orderId}` (API Gateway) or `:orderId` (the DI\n // router). Both are accepted and converted per consumer — see `routePath.ts`.\n path: z.string().startsWith(\"/\"),\n method: z.enum(HTTP_METHODS),\n // The `src` file must default-export a route HANDLER — the result of\n // `HttpRouteHandler.createImplementation` from `@webiny/event-handler-core`. It does\n // NOT declare its own method/path: the `HttpRouteDefinition` the router matches on is\n // generated below from the props here, so the route the gateway forwards to and the\n // route the router matches cannot drift apart.\n src: zodSrcPath({ project }),\n // Doubles as the route's DI name, so a decorator on HttpRouteDefinition can pick this\n // route out by it. Derived from path + method when omitted, same as the Pulumi name.\n routeName: z.string().optional()\n });\n },\n async build(params, ctx) {\n const extensionsTsFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"extensions.ts\")\n .toString();\n\n const absoluteSrcFilePath = ExtensionSrcResolver.resolvePath(params.src, ctx.project);\n\n // Stable alias to avoid naming conflicts across multiple routes.\n const hash = crypto.createHash(\"sha256\").update(params.src).digest(\"hex\");\n const alias = `ApiRoute_${hash.slice(-10)}`;\n\n const importPath = path\n .relative(path.dirname(extensionsTsFilePath), absoluteSrcFilePath)\n .replace(/\\.tsx?$/, \".js\");\n\n const tsProject = new Project();\n tsProject.addSourceFileAtPath(extensionsTsFilePath);\n const source = tsProject.getSourceFileOrThrow(extensionsTsFilePath);\n\n // Skip if the route handler is already registered.\n if (source.getImportDeclaration(importPath)) {\n return;\n }\n\n // Insert handler import after the last existing import.\n let insertIndex = 1;\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n insertIndex = importDeclarations[importDeclarations.length - 1].getChildIndex() + 1;\n }\n\n source.insertImportDeclaration(insertIndex, {\n defaultImport: alias,\n moduleSpecifier: importPath\n });\n\n // Ensure createRegisterExtensionPlugin import exists.\n const registerExtensionPluginPath = \"@webiny/handler/plugins/RegisterExtensionPlugin.js\";\n const existingRegisterExtensionPluginImport = source.getImportDeclaration(\n registerExtensionPluginPath\n );\n if (\n existingRegisterExtensionPluginImport &&\n !existingRegisterExtensionPluginImport\n .getNamedImports()\n .some(i => i.getName() === \"createRegisterExtensionPlugin\")\n ) {\n // BuildParam imports `createRegisterBuildParamPlugin` from the same path.\n existingRegisterExtensionPluginImport.addNamedImport(\"createRegisterExtensionPlugin\");\n } else if (!existingRegisterExtensionPluginImport) {\n const lastIdx =\n source\n .getImportDeclarations()\n [source.getImportDeclarations().length - 1].getChildIndex() + 1;\n source.insertImportDeclaration(lastIdx, {\n namedImports: [\"createRegisterExtensionPlugin\"],\n moduleSpecifier: registerExtensionPluginPath\n });\n }\n\n // Ensure createHttpRouteDefinition import exists.\n const eventHandlerCorePath = \"@webiny/event-handler-core\";\n if (!source.getImportDeclaration(eventHandlerCorePath)) {\n const lastIdx =\n source\n .getImportDeclarations()\n [source.getImportDeclarations().length - 1].getChildIndex() + 1;\n source.insertImportDeclaration(lastIdx, {\n namedImports: [\"createHttpRouteDefinition\"],\n moduleSpecifier: eventHandlerCorePath\n });\n }\n\n const pluginsArray = source.getFirstDescendant(node =>\n Node.isArrayLiteralExpression(node)\n ) as ArrayLiteralExpression;\n\n // Register an HttpRouteDefinition built from the props above. The router matches on\n // definitions and only then builds the handler, so registering the handler alone would\n // leave the route unreachable: it deploys, API Gateway forwards to the Lambda, and dispatch\n // finds nothing. The path is converted to the router's `:param` syntax.\n const routerPath = toRouterPath(params.path);\n const routeName = params.routeName ?? deriveRouteName(params.path, params.method);\n\n pluginsArray.addElement(\n `\\ncreateRegisterExtensionPlugin(ctx => {\\n\\tctx.container.register(\\n\\t\\tcreateHttpRouteDefinition({\\n\\t\\t\\tname: \"${routeName}\",\\n\\t\\t\\tmethod: \"${params.method}\",\\n\\t\\t\\tpath: \"${routerPath}\",\\n\\t\\t\\thandler: ${alias}\\n\\t\\t})\\n\\t);\\n})`\n );\n\n await source.save();\n },\n render() {\n return <ApiPulumi src={p(\"RegisterRoutesPulumi.js\")} />;\n }\n});\n"],"names":["p","createPathResolver","HTTP_METHODS","ApiRoute","defineExtension","project","z","zodSrcPath","params","ctx","extensionsTsFilePath","absoluteSrcFilePath","ExtensionSrcResolver","hash","crypto","alias","importPath","path","tsProject","Project","source","insertIndex","importDeclarations","registerExtensionPluginPath","existingRegisterExtensionPluginImport","i","lastIdx","eventHandlerCorePath","pluginsArray","node","Node","routerPath","toRouterPath","routeName","deriveRouteName","ApiPulumi"],"mappings":";;;;;;;;;;;AAYA,MAAMA,IAAIC,mBAAmB,YAAY,OAAO;AAEhD,MAAMC,eAAe;IAAC;IAAU;IAAO;IAAQ;IAAS;IAAQ;IAAO;IAAW;CAAM;AAEjF,MAAMC,WAAWC,gBAAgB;IACpC,MAAM;IACN,MAAM;QAAE,gBAAgB;QAAa,SAAS;IAAM;IACpD,aAAa;IACb,UAAU;IACV,cAAc,CAAC,EAAEC,OAAO,EAAE,GACfC,EAAE,MAAM,CAAC;YAGZ,MAAMA,EAAE,MAAM,GAAG,UAAU,CAAC;YAC5B,QAAQA,CAAC,CAADA,OAAM,CAACJ;YAMf,KAAKK,WAAW;gBAAEF;YAAQ;YAG1B,WAAWC,EAAE,MAAM,GAAG,QAAQ;QAClC;IAEJ,MAAM,OAAME,MAAM,EAAE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,MAAMI,uBAAuB;QAC7B,IAAI,CAACP,OAAO,oBAAoB,CAACO,uBAAuB;YACpD,MAAMD,UACFN,OACK,qBAAqB,EACtB,CAACA,OAAO,qBAAqB,GAAG,MAAM,GAAG,EAAE,CAAC,aAAa,KAAK;YACtEA,OAAO,uBAAuB,CAACM,SAAS;gBACpC,cAAc;oBAAC;iBAA4B;gBAC3C,iBAAiBC;YACrB;QACJ;QAEA,MAAMC,eAAeR,OAAO,kBAAkB,CAACS,CAAAA,OAC3CC,KAAK,wBAAwB,CAACD;QAOlC,MAAME,aAAaC,aAAaxB,OAAO,IAAI;QAC3C,MAAMyB,YAAYzB,OAAO,SAAS,IAAI0B,gBAAgB1B,OAAO,IAAI,EAAEA,OAAO,MAAM;QAEhFoB,aAAa,UAAU,CACnB,CAAC,mHAAmH,EAAEK,UAAU,mBAAmB,EAAEzB,OAAO,MAAM,CAAC,iBAAiB,EAAEuB,WAAW,mBAAmB,EAAEhB,MAAM,kBAAkB,CAAC;QAGnP,MAAMK,OAAO,IAAI;IACrB;IACA;QACI,OAAO,WAAP,GAAO,oBAACe,WAASA;YAAC,KAAKnC,EAAE;;IAC7B;AACJ"}
@@ -1,7 +1,7 @@
1
1
  import { ApiAfterDeploy } from "@webiny/project/abstractions/index.js";
2
2
  import { UiService } from "@webiny/project/abstractions/services/UiService.js";
3
3
  import { LoggerService } from "@webiny/project/abstractions/services/LoggerService.js";
4
- import { GetProjectConfigService } from "@webiny/project/abstractions";
4
+ import { GetProjectConfigService } from "@webiny/project/abstractions/index.js";
5
5
  import { ApiGqlClient } from "../../../abstractions/ApiGqlClient.js";
6
6
  declare class AutoInstallAfterApiDeployImpl implements ApiAfterDeploy.Interface {
7
7
  private apiGqlClient;
@@ -1,7 +1,6 @@
1
- import { ApiAfterDeploy } from "@webiny/project/abstractions/index.js";
1
+ import { ApiAfterDeploy, GetProjectConfigService } from "@webiny/project/abstractions/index.js";
2
2
  import { UiService } from "@webiny/project/abstractions/services/UiService.js";
3
3
  import { LoggerService } from "@webiny/project/abstractions/services/LoggerService.js";
4
- import { GetProjectConfigService } from "@webiny/project/abstractions";
5
4
  import { ApiGqlClient } from "../../../abstractions/ApiGqlClient.js";
6
5
  const IS_INSTALLED_QUERY = `
7
6
  query IsSystemInstalled {
@@ -1 +1 @@
1
- {"version":3,"file":"extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.js","sources":["../../../../src/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.ts"],"sourcesContent":["import { ApiAfterDeploy } from \"@webiny/project/abstractions/index.js\";\nimport { UiService } from \"@webiny/project/abstractions/services/UiService.js\";\nimport { LoggerService } from \"@webiny/project/abstractions/services/LoggerService.js\";\nimport { GetProjectConfigService } from \"@webiny/project/abstractions\";\nimport { ApiGqlClient } from \"~/abstractions/ApiGqlClient.js\";\n\nconst IS_INSTALLED_QUERY = `\n query IsSystemInstalled {\n system {\n isSystemInstalled {\n data\n error {\n message\n code\n }\n }\n }\n }\n`;\n\nconst INSTALL_MUTATION = `\n mutation InstallSystem($installationInput: JSON!) {\n system {\n installSystem(installationInput: $installationInput) {\n data\n error {\n message\n code\n }\n }\n }\n }\n`;\n\ninterface IsInstalledResponse {\n system: {\n isSystemInstalled: {\n data: boolean;\n error?: {\n message: string;\n code: string;\n };\n };\n };\n}\n\ninterface InstallResponse {\n system: {\n installSystem: {\n data: boolean;\n error?: {\n message: string;\n code: string;\n };\n };\n };\n}\n\nclass AutoInstallAfterApiDeployImpl implements ApiAfterDeploy.Interface {\n constructor(\n private apiGqlClient: ApiGqlClient.Interface,\n private ui: UiService.Interface,\n private getProjectConfig: GetProjectConfigService.Interface,\n private logger: LoggerService.Interface\n ) {}\n\n async execute(params: ApiAfterDeploy.Params): Promise<void> {\n if (params.preview) {\n // Skip auto-install on preview deployments\n return;\n }\n\n const projectConfig = await this.getProjectConfig.execute();\n const adminAutoInstallExtensions = projectConfig.extensionsByType(\"Project/AutoInstall\");\n\n if (adminAutoInstallExtensions.length === 0) {\n return;\n }\n\n const config = adminAutoInstallExtensions[0].params;\n\n // Check if system is already installed\n this.ui.info(\"Checking if system is already installed...\");\n\n try {\n const isInstalledResponse = await this.apiGqlClient.query<IsInstalledResponse>({\n query: IS_INSTALLED_QUERY\n });\n\n if (isInstalledResponse.data?.system.isSystemInstalled.data === true) {\n this.ui.info(\"System is already installed, skipping auto-install.\");\n return;\n }\n } catch (error: any) {\n this.logger.error(\"Failed to check installation status\", { error });\n this.ui.warning(`Could not check installation status: ${error.message}`);\n return;\n }\n\n this.ui.info(\"Auto-installing...\");\n /**\n * Type Error introduced with Zod v4. V3 had any type.\n */\n // @ts-expect-error\n const adminUser = config.adminUser || {\n firstName: \"John\",\n lastName: \"Smith\",\n email: \"admin@webiny.com\",\n password: \"12345678\"\n };\n\n const variables = {\n installationInput: [\n {\n app: \"Cognito\",\n data: adminUser\n }\n ]\n };\n\n const installResponse = await this.apiGqlClient.mutation<InstallResponse>({\n mutation: INSTALL_MUTATION,\n variables\n });\n\n if (installResponse.data?.system.installSystem.error) {\n const { message, code } = installResponse.data.system.installSystem.error;\n this.logger.error(\"Installation failed\", { message, code });\n this.ui.error(`Installation failed: ${message} (${code})`);\n throw new Error(message);\n }\n\n this.ui.success(\"System installed successfully!\");\n this.ui.info(\"Admin credentials:\");\n this.ui.info(` Email: ${adminUser.email}`);\n this.ui.info(` Password: ${adminUser.password}`);\n }\n}\n\nexport const AutoInstallAfterApiDeploy = ApiAfterDeploy.createImplementation({\n implementation: AutoInstallAfterApiDeployImpl,\n dependencies: [ApiGqlClient, UiService, GetProjectConfigService, LoggerService]\n});\n"],"names":["IS_INSTALLED_QUERY","INSTALL_MUTATION","AutoInstallAfterApiDeployImpl","apiGqlClient","ui","getProjectConfig","logger","params","projectConfig","adminAutoInstallExtensions","config","isInstalledResponse","error","adminUser","variables","installResponse","message","code","Error","AutoInstallAfterApiDeploy","ApiAfterDeploy","ApiGqlClient","UiService","GetProjectConfigService","LoggerService"],"mappings":";;;;;AAMA,MA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CAAkB;YACtE,UAAUd;YACVa;QACJ;QAEA,IAAIC,gBAAgB,IAAI,EAAE,OAAO,cAAc,OAAO;YAClD,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAGF,gBAAgB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK;YACzE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB;gBAAEC;gBAASC;YAAK;YACzD,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,qBAAqB,EAAED,QAAQ,EAAE,EAAEC,KAAK,CAAC,CAAC;YACzD,MAAM,IAAIC,MAAMF;QACpB;QAEA,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;QAChB,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;QACb,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAEH,UAAU,KAAK,EAAE;QACzC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAEA,UAAU,QAAQ,EAAE;IACnD;AACJ;AAEO,MAAMM,4BAA4BC,eAAe,oBAAoB,CAAC;IACzE,gBAAgBlB;IAChB,cAAc;QAACmB;QAAcC;QAAWC;QAAyBC;KAAc;AACnF"}
1
+ {"version":3,"file":"extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.js","sources":["../../../../src/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.ts"],"sourcesContent":["import { ApiAfterDeploy } from \"@webiny/project/abstractions/index.js\";\nimport { UiService } from \"@webiny/project/abstractions/services/UiService.js\";\nimport { LoggerService } from \"@webiny/project/abstractions/services/LoggerService.js\";\nimport { GetProjectConfigService } from \"@webiny/project/abstractions/index.js\";\nimport { ApiGqlClient } from \"~/abstractions/ApiGqlClient.js\";\n\nconst IS_INSTALLED_QUERY = `\n query IsSystemInstalled {\n system {\n isSystemInstalled {\n data\n error {\n message\n code\n }\n }\n }\n }\n`;\n\nconst INSTALL_MUTATION = `\n mutation InstallSystem($installationInput: JSON!) {\n system {\n installSystem(installationInput: $installationInput) {\n data\n error {\n message\n code\n }\n }\n }\n }\n`;\n\ninterface IsInstalledResponse {\n system: {\n isSystemInstalled: {\n data: boolean;\n error?: {\n message: string;\n code: string;\n };\n };\n };\n}\n\ninterface InstallResponse {\n system: {\n installSystem: {\n data: boolean;\n error?: {\n message: string;\n code: string;\n };\n };\n };\n}\n\nclass AutoInstallAfterApiDeployImpl implements ApiAfterDeploy.Interface {\n constructor(\n private apiGqlClient: ApiGqlClient.Interface,\n private ui: UiService.Interface,\n private getProjectConfig: GetProjectConfigService.Interface,\n private logger: LoggerService.Interface\n ) {}\n\n async execute(params: ApiAfterDeploy.Params): Promise<void> {\n if (params.preview) {\n // Skip auto-install on preview deployments\n return;\n }\n\n const projectConfig = await this.getProjectConfig.execute();\n const adminAutoInstallExtensions = projectConfig.extensionsByType(\"Project/AutoInstall\");\n\n if (adminAutoInstallExtensions.length === 0) {\n return;\n }\n\n const config = adminAutoInstallExtensions[0].params;\n\n // Check if system is already installed\n this.ui.info(\"Checking if system is already installed...\");\n\n try {\n const isInstalledResponse = await this.apiGqlClient.query<IsInstalledResponse>({\n query: IS_INSTALLED_QUERY\n });\n\n if (isInstalledResponse.data?.system.isSystemInstalled.data === true) {\n this.ui.info(\"System is already installed, skipping auto-install.\");\n return;\n }\n } catch (error: any) {\n this.logger.error(\"Failed to check installation status\", { error });\n this.ui.warning(`Could not check installation status: ${error.message}`);\n return;\n }\n\n this.ui.info(\"Auto-installing...\");\n /**\n * Type Error introduced with Zod v4. V3 had any type.\n */\n // @ts-expect-error\n const adminUser = config.adminUser || {\n firstName: \"John\",\n lastName: \"Smith\",\n email: \"admin@webiny.com\",\n password: \"12345678\"\n };\n\n const variables = {\n installationInput: [\n {\n app: \"Cognito\",\n data: adminUser\n }\n ]\n };\n\n const installResponse = await this.apiGqlClient.mutation<InstallResponse>({\n mutation: INSTALL_MUTATION,\n variables\n });\n\n if (installResponse.data?.system.installSystem.error) {\n const { message, code } = installResponse.data.system.installSystem.error;\n this.logger.error(\"Installation failed\", { message, code });\n this.ui.error(`Installation failed: ${message} (${code})`);\n throw new Error(message);\n }\n\n this.ui.success(\"System installed successfully!\");\n this.ui.info(\"Admin credentials:\");\n this.ui.info(` Email: ${adminUser.email}`);\n this.ui.info(` Password: ${adminUser.password}`);\n }\n}\n\nexport const AutoInstallAfterApiDeploy = ApiAfterDeploy.createImplementation({\n implementation: AutoInstallAfterApiDeployImpl,\n dependencies: [ApiGqlClient, UiService, GetProjectConfigService, LoggerService]\n});\n"],"names":["IS_INSTALLED_QUERY","INSTALL_MUTATION","AutoInstallAfterApiDeployImpl","apiGqlClient","ui","getProjectConfig","logger","params","projectConfig","adminAutoInstallExtensions","config","isInstalledResponse","error","adminUser","variables","installResponse","message","code","Error","AutoInstallAfterApiDeploy","ApiAfterDeploy","ApiGqlClient","UiService","GetProjectConfigService","LoggerService"],"mappings":";;;;AAMA,MAAMA,qBAAqB,CAAC;;;;;;;;;;;;AAY5B,CAAC;AAED,MAAMC,mBAAmB,CAAC;;;;;;;;;;;;AAY1B,CAAC;AA0BD,MAAMC;IACF,YACYC,YAAoC,EACpCC,EAAuB,EACvBC,gBAAmD,EACnDC,MAA+B,CACzC;aAJUH,YAAY,GAAZA;aACAC,EAAE,GAAFA;aACAC,gBAAgB,GAAhBA;aACAC,MAAM,GAANA;IACT;IAEH,MAAM,QAAQC,MAA6B,EAAiB;QACxD,IAAIA,OAAO,OAAO,EAEd;QAGJ,MAAMC,gBAAgB,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO;QACzD,MAAMC,6BAA6BD,cAAc,gBAAgB,CAAC;QAElE,IAAIC,AAAsC,MAAtCA,2BAA2B,MAAM,EACjC;QAGJ,MAAMC,SAASD,0BAA0B,CAAC,EAAE,CAAC,MAAM;QAGnD,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;QAEb,IAAI;YACA,MAAME,sBAAsB,MAAM,IAAI,CAAC,YAAY,CAAC,KA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;AAEO,MAAMM,4BAA4BC,eAAe,oBAAoB,CAAC;IACzE,gBAAgBlB;IAChB,cAAc;QAACmB;QAAcC;QAAWC;QAAyBC;KAAc;AACnF"}
@@ -1,11 +1,11 @@
1
1
  import { BeforeDeploy, LoggerService } from "@webiny/project/abstractions/index.js";
2
2
  import { GracefulError } from "@webiny/project";
3
- import { STS } from "@webiny/aws-sdk/client-sts";
4
3
  class EnsureAwsCredentialsBeforeDeployImpl {
5
4
  constructor(loggerService){
6
5
  this.loggerService = loggerService;
7
6
  }
8
7
  async execute() {
8
+ const { STS } = await import("@webiny/aws-sdk/client-sts/index.js");
9
9
  process.env.AWS_SDK_LOAD_CONFIG = "true";
10
10
  const sts = new STS({});
11
11
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"extensions/ProjectAws/EnsureAwsCredentialsBeforeDeploy.js","sources":["../../../src/extensions/ProjectAws/EnsureAwsCredentialsBeforeDeploy.ts"],"sourcesContent":["import { BeforeDeploy, LoggerService } from \"@webiny/project/abstractions/index.js\";\nimport { GracefulError } from \"@webiny/project\";\nimport { STS } from \"@webiny/aws-sdk/client-sts\";\n\nclass EnsureAwsCredentialsBeforeDeployImpl implements BeforeDeploy.Interface {\n constructor(private loggerService: LoggerService.Interface) {}\n\n async execute() {\n process.env.AWS_SDK_LOAD_CONFIG = \"true\";\n const sts = new STS({});\n\n try {\n await sts.getCallerIdentity({});\n } catch (err) {\n this.loggerService.debug({ err }, \"AWS credentials error.\");\n throw GracefulError.from(\n new Error(\"AWS credentials are not configured correctly.\"),\n 'No valid AWS credentials were found. Run \"aws configure\" or set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables before deploying. Learn more: https://webiny.link/aws-credentials'\n );\n }\n\n const region = await sts.config.region();\n if (!region) {\n throw GracefulError.from(\n new Error(\"AWS region is not defined.\"),\n \"No AWS region is set. Define the AWS_REGION environment variable or set a default region in your AWS profile. Learn more: https://webiny.link/aws-region\"\n );\n }\n\n process.env.AWS_REGION = region;\n\n const { accessKeyId } = await sts.config.credentials();\n const profile = process.env.AWS_PROFILE;\n\n if (profile) {\n this.loggerService.info(`Using profile \"${profile}\" in \"${region}\" region.`);\n } else {\n this.loggerService.info(`Using access key ID \"${accessKeyId}\" in \"${region}\" region.`);\n }\n }\n}\n\nexport const EnsureAwsCredentialsBeforeDeploy = BeforeDeploy.createImplementation({\n implementation: EnsureAwsCredentialsBeforeDeployImpl,\n dependencies: [LoggerService]\n});\n"],"names":["EnsureAwsCredentialsBeforeDeployImpl","loggerService","process","sts","STS","err","GracefulError","Error","region","accessKeyId","profile","EnsureAwsCredentialsBeforeDeploy","BeforeDeploy","LoggerService"],"mappings":";;;AAIA,MAAMA;IACF,YAAoBC,aAAsC,CAAE;aAAxCA,aAAa,GAAbA;IAAyC;IAE7D,MAAM,UAAU;QACZC,QAAQ,GAAG,CAAC,mBAAmB,GAAG;QAClC,MAAMC,MAAM,IAAIC,IAAI,CAAC;QAErB,IAAI;YACA,MAAMD,IAAI,iBAAiB,CAAC,CAAC;QACjC,EAAE,OAAOE,KAAK;YACV,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;gBAAEA;YAAI,GAAG;YAClC,MAAMC,cAAc,IAAI,CACpB,IAAIC,MAAM,kDACV;QAER;QAEA,MAAMC,SAAS,MAAML,IAAI,MAAM,CAAC,MAAM;QACtC,IAAI,CAACK,QACD,MAAMF,cAAc,IAAI,CACpB,IAAIC,MAAM,+BACV;QAIRL,QAAQ,GAAG,CAAC,UAAU,GAAGM;QAEzB,MAAM,EAAEC,WAAW,EAAE,GAAG,MAAMN,IAAI,MAAM,CAAC,WAAW;QACpD,MAAMO,UAAUR,QAAQ,GAAG,CAAC,WAAW;QAEvC,IAAIQ,SACA,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,eAAe,EAAEA,QAAQ,MAAM,EAAEF,OAAO,SAAS,CAAC;aAE3E,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAEC,YAAY,MAAM,EAAED,OAAO,SAAS,CAAC;IAE7F;AACJ;AAEO,MAAMG,mCAAmCC,aAAa,oBAAoB,CAAC;IAC9E,gBAAgBZ;IAChB,cAAc;QAACa;KAAc;AACjC"}
1
+ {"version":3,"file":"extensions/ProjectAws/EnsureAwsCredentialsBeforeDeploy.js","sources":["../../../src/extensions/ProjectAws/EnsureAwsCredentialsBeforeDeploy.ts"],"sourcesContent":["import { BeforeDeploy, LoggerService } from \"@webiny/project/abstractions/index.js\";\nimport { GracefulError } from \"@webiny/project\";\n\nclass EnsureAwsCredentialsBeforeDeployImpl implements BeforeDeploy.Interface {\n constructor(private loggerService: LoggerService.Interface) {}\n\n async execute() {\n // Loaded here rather than at the top of the file. Validating the project config imports this\n // hook on every command, and only a deploy needs the STS client.\n const { STS } = await import(\"@webiny/aws-sdk/client-sts/index.js\");\n\n process.env.AWS_SDK_LOAD_CONFIG = \"true\";\n const sts = new STS({});\n\n try {\n await sts.getCallerIdentity({});\n } catch (err) {\n this.loggerService.debug({ err }, \"AWS credentials error.\");\n throw GracefulError.from(\n new Error(\"AWS credentials are not configured correctly.\"),\n 'No valid AWS credentials were found. Run \"aws configure\" or set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables before deploying. Learn more: https://webiny.link/aws-credentials'\n );\n }\n\n const region = await sts.config.region();\n if (!region) {\n throw GracefulError.from(\n new Error(\"AWS region is not defined.\"),\n \"No AWS region is set. Define the AWS_REGION environment variable or set a default region in your AWS profile. Learn more: https://webiny.link/aws-region\"\n );\n }\n\n process.env.AWS_REGION = region;\n\n const { accessKeyId } = await sts.config.credentials();\n const profile = process.env.AWS_PROFILE;\n\n if (profile) {\n this.loggerService.info(`Using profile \"${profile}\" in \"${region}\" region.`);\n } else {\n this.loggerService.info(`Using access key ID \"${accessKeyId}\" in \"${region}\" region.`);\n }\n }\n}\n\nexport const EnsureAwsCredentialsBeforeDeploy = BeforeDeploy.createImplementation({\n implementation: EnsureAwsCredentialsBeforeDeployImpl,\n dependencies: [LoggerService]\n});\n"],"names":["EnsureAwsCredentialsBeforeDeployImpl","loggerService","STS","process","sts","err","GracefulError","Error","region","accessKeyId","profile","EnsureAwsCredentialsBeforeDeploy","BeforeDeploy","LoggerService"],"mappings":";;AAGA,MAAMA;IACF,YAAoBC,aAAsC,CAAE;aAAxCA,aAAa,GAAbA;IAAyC;IAE7D,MAAM,UAAU;QAGZ,MAAM,EAAEC,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC;QAE7BC,QAAQ,GAAG,CAAC,mBAAmB,GAAG;QAClC,MAAMC,MAAM,IAAIF,IAAI,CAAC;QAErB,IAAI;YACA,MAAME,IAAI,iBAAiB,CAAC,CAAC;QACjC,EAAE,OAAOC,KAAK;YACV,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;gBAAEA;YAAI,GAAG;YAClC,MAAMC,cAAc,IAAI,CACpB,IAAIC,MAAM,kDACV;QAER;QAEA,MAAMC,SAAS,MAAMJ,IAAI,MAAM,CAAC,MAAM;QACtC,IAAI,CAACI,QACD,MAAMF,cAAc,IAAI,CACpB,IAAIC,MAAM,+BACV;QAIRJ,QAAQ,GAAG,CAAC,UAAU,GAAGK;QAEzB,MAAM,EAAEC,WAAW,EAAE,GAAG,MAAML,IAAI,MAAM,CAAC,WAAW;QACpD,MAAMM,UAAUP,QAAQ,GAAG,CAAC,WAAW;QAEvC,IAAIO,SACA,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,eAAe,EAAEA,QAAQ,MAAM,EAAEF,OAAO,SAAS,CAAC;aAE3E,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAEC,YAAY,MAAM,EAAED,OAAO,SAAS,CAAC;IAE7F;AACJ;AAEO,MAAMG,mCAAmCC,aAAa,oBAAoB,CAAC;IAC9E,gBAAgBZ;IAChB,cAAc;QAACa;KAAc;AACjC"}
@@ -1,6 +1,5 @@
1
1
  import { AdminAfterDeploy, GetApp, UiService } from "@webiny/project/abstractions/index.js";
2
2
  import fs from "fs";
3
- import { uploadFolderToS3 } from "../../pulumi/index.js";
4
3
  import { AdminStackOutputService } from "../../abstractions/index.js";
5
4
  class UploadAdminAppToS3Impl {
6
5
  constructor(ui, getApp, adminStackOutputService){
@@ -18,6 +17,7 @@ class UploadAdminAppToS3Impl {
18
17
  const start = new Date().getTime();
19
18
  const appOutput = await this.adminStackOutputService.execute();
20
19
  if (!appOutput) throw new Error("Missing app stack output.");
20
+ const { uploadFolderToS3 } = await import("../../pulumi/utils/uploadFolderToS3.js");
21
21
  await uploadFolderToS3({
22
22
  path: buildFolderPath,
23
23
  bucket: appOutput.appStorage,
@@ -1 +1 @@
1
- {"version":3,"file":"extensions/ProjectAws/UploadAdminAppToS3.js","sources":["../../../src/extensions/ProjectAws/UploadAdminAppToS3.ts"],"sourcesContent":["import { AdminAfterDeploy, GetApp, UiService } from \"@webiny/project/abstractions/index.js\";\nimport fs from \"fs\";\nimport { uploadFolderToS3 } from \"~/pulumi/index.js\";\nimport { type IDefaultStackOutput } from \"~/pulumi/types.js\";\nimport { AdminStackOutputService } from \"~/abstractions/index.js\";\n\nclass UploadAdminAppToS3Impl implements AdminAfterDeploy.Interface {\n constructor(\n private ui: UiService.Interface,\n private getApp: GetApp.Interface,\n private adminStackOutputService: AdminStackOutputService.Interface\n ) {}\n\n async execute(params: AdminAfterDeploy.Params) {\n // No need to upload the app if we're doing a preview.\n if (params.preview) {\n return;\n }\n\n const ui = this.ui;\n ui.info(\"Uploading React application...\");\n\n const app = this.getApp.execute(params.app);\n\n const buildFolderPath = app.paths.workspaceFolder.join(\"build\").toString();\n if (!fs.existsSync(buildFolderPath)) {\n throw new Error(\"Cannot continue, build folder not found.\");\n }\n\n const start = new Date().getTime();\n const appOutput = await this.adminStackOutputService.execute<IDefaultStackOutput>();\n if (!appOutput) {\n throw new Error(\"Missing app stack output.\");\n }\n\n await uploadFolderToS3({\n path: buildFolderPath,\n bucket: appOutput.appStorage,\n acl: \"private\",\n cacheControl: [\n {\n pattern: /index\\.html/,\n value: \"no-cache, no-store, must-revalidate\"\n },\n {\n pattern: /robots\\.txt/,\n value: \"no-cache, no-store, must-revalidate\"\n },\n {\n pattern: /.*/,\n value: \"max-age=31536000\"\n }\n ],\n onFileUploadSuccess: ({ paths }) => {\n ui.success(paths.relative);\n },\n onFileUploadError: ({ paths, error }) => {\n ui.error(\"Failed to upload %s\", paths.relative);\n ui.text(error.message);\n },\n onFileUploadSkip: ({ paths }) => {\n ui.info(`Skipping %s, already exists.`, paths.relative);\n }\n });\n\n const duration = (new Date().getTime() - start) / 1000;\n\n ui.success(`React application successfully uploaded in %ss.`, duration);\n }\n}\n\nexport const UploadAdminAppToS3 = AdminAfterDeploy.createImplementation({\n implementation: UploadAdminAppToS3Impl,\n dependencies: [UiService, GetApp, AdminStackOutputService]\n});\n"],"names":["UploadAdminAppToS3Impl","ui","getApp","adminStackOutputService","params","app","buildFolderPath","fs","Error","start","Date","appOutput","uploadFolderToS3","paths","error","duration","UploadAdminAppToS3","AdminAfterDeploy","UiService","GetApp","AdminStackOutputService"],"mappings":";;;;AAMA,MAAMA;IACF,YACYC,EAAuB,EACvBC,MAAwB,EACxBC,uBAA0D,CACpE;aAHUF,EAAE,GAAFA;aACAC,MAAM,GAANA;aACAC,uBAAuB,GAAvBA;IACT;IAEH,MAAM,QAAQC,MAA+B,EAAE;QAE3C,IAAIA,OAAO,OAAO,EACd;QAGJ,MAAMH,KAAK,IAAI,CAAC,EAAE;QAClBA,GAAG,IAAI,CAAC;QAER,MAAMI,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAACD,OAAO,GAAG;QAE1C,MAAME,kBAAkBD,IAAI,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,QAAQ;QACxE,IAAI,CAACE,GAAG,UAAU,CAACD,kBACf,MAAM,IAAIE,MAAM;QAGpB,MAAMC,QAAQ,IAAIC,OAAO,OAAO;QAChC,MAAMC,YAAY,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO;QAC5D,IAAI,CAACA,WACD,MAAM,IAAIH,MAAM;QAGpB,MAAMI,iBAAiB;YACnB,MAAMN;YACN,QAAQK,UAAU,UAAU;YAC5B,KAAK;YACL,cAAc;gBACV;oBACI,SAAS;oBACT,OAAO;gBACX;gBACA;oBACI,SAAS;oBACT,OAAO;gBACX;gBACA;oBACI,SAAS;oBACT,OAAO;gBACX;aACH;YACD,qBAAqB,CAAC,EAAEE,KAAK,EAAE;gBAC3BZ,GAAG,OAAO,CAACY,MAAM,QAAQ;YAC7B;YACA,mBAAmB,CAAC,EAAEA,KAAK,EAAEC,KAAK,EAAE;gBAChCb,GAAG,KAAK,CAAC,uBAAuBY,MAAM,QAAQ;gBAC9CZ,GAAG,IAAI,CAACa,MAAM,OAAO;YACzB;YACA,kBAAkB,CAAC,EAAED,KAAK,EAAE;gBACxBZ,GAAG,IAAI,CAAC,gCAAgCY,MAAM,QAAQ;YAC1D;QACJ;QAEA,MAAME,WAAY,KAAIL,OAAO,OAAO,KAAKD,KAAI,IAAK;QAElDR,GAAG,OAAO,CAAC,mDAAmDc;IAClE;AACJ;AAEO,MAAMC,qBAAqBC,iBAAiB,oBAAoB,CAAC;IACpE,gBAAgBjB;IAChB,cAAc;QAACkB;QAAWC;QAAQC;KAAwB;AAC9D"}
1
+ {"version":3,"file":"extensions/ProjectAws/UploadAdminAppToS3.js","sources":["../../../src/extensions/ProjectAws/UploadAdminAppToS3.ts"],"sourcesContent":["import { AdminAfterDeploy, GetApp, UiService } from \"@webiny/project/abstractions/index.js\";\nimport fs from \"fs\";\nimport { type IDefaultStackOutput } from \"~/pulumi/types.js\";\nimport { AdminStackOutputService } from \"~/abstractions/index.js\";\n\nclass UploadAdminAppToS3Impl implements AdminAfterDeploy.Interface {\n constructor(\n private ui: UiService.Interface,\n private getApp: GetApp.Interface,\n private adminStackOutputService: AdminStackOutputService.Interface\n ) {}\n\n async execute(params: AdminAfterDeploy.Params) {\n // No need to upload the app if we're doing a preview.\n if (params.preview) {\n return;\n }\n\n const ui = this.ui;\n ui.info(\"Uploading React application...\");\n\n const app = this.getApp.execute(params.app);\n\n const buildFolderPath = app.paths.workspaceFolder.join(\"build\").toString();\n if (!fs.existsSync(buildFolderPath)) {\n throw new Error(\"Cannot continue, build folder not found.\");\n }\n\n const start = new Date().getTime();\n const appOutput = await this.adminStackOutputService.execute<IDefaultStackOutput>();\n if (!appOutput) {\n throw new Error(\"Missing app stack output.\");\n }\n\n // Imported here rather than at the top of the file. Every CLI command imports this hook when\n // the project SDK registers its extensions, even `webiny --help`, and a top-level import used\n // to come through the `~/pulumi` barrel, which loads all of Pulumi and the AWS SDK: about\n // 2,700 modules. The upload is the only thing that needs it, so the upload pays for it.\n const { uploadFolderToS3 } = await import(\"~/pulumi/utils/uploadFolderToS3.js\");\n\n await uploadFolderToS3({\n path: buildFolderPath,\n bucket: appOutput.appStorage,\n acl: \"private\",\n cacheControl: [\n {\n pattern: /index\\.html/,\n value: \"no-cache, no-store, must-revalidate\"\n },\n {\n pattern: /robots\\.txt/,\n value: \"no-cache, no-store, must-revalidate\"\n },\n {\n pattern: /.*/,\n value: \"max-age=31536000\"\n }\n ],\n onFileUploadSuccess: ({ paths }) => {\n ui.success(paths.relative);\n },\n onFileUploadError: ({ paths, error }) => {\n ui.error(\"Failed to upload %s\", paths.relative);\n ui.text(error.message);\n },\n onFileUploadSkip: ({ paths }) => {\n ui.info(`Skipping %s, already exists.`, paths.relative);\n }\n });\n\n const duration = (new Date().getTime() - start) / 1000;\n\n ui.success(`React application successfully uploaded in %ss.`, duration);\n }\n}\n\nexport const UploadAdminAppToS3 = AdminAfterDeploy.createImplementation({\n implementation: UploadAdminAppToS3Impl,\n dependencies: [UiService, GetApp, AdminStackOutputService]\n});\n"],"names":["UploadAdminAppToS3Impl","ui","getApp","adminStackOutputService","params","app","buildFolderPath","fs","Error","start","Date","appOutput","uploadFolderToS3","paths","error","duration","UploadAdminAppToS3","AdminAfterDeploy","UiService","GetApp","Ad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ME,WAAY,KAAIL,OAAO,OAAO,KAAKD,KAAI,IAAK;QAElDR,GAAG,OAAO,CAAC,mDAAmDc;IAClE;AACJ;AAEO,MAAMC,qBAAqBC,iBAAiB,oBAAoB,CAAC;IACpE,gBAAgBjB;IAChB,cAAc;QAACkB;QAAWC;QAAQC;KAAwB;AAC9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"extensions/ProjectAws.js","sources":["../../src/extensions/ProjectAws.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n AdminAfterDeploy,\n AdminBeforeBuild,\n AdminBeforeWatch,\n AfterDeploy,\n ApiAfterDeploy,\n ApiBeforeDeploy,\n ApiBeforeWatch,\n BeforeDeploy,\n CoreBeforeDeploy,\n DatabaseSetup,\n ExtensionDefinitions,\n Project,\n ProjectImplementation\n} from \"@webiny/project/extensions/index.js\";\nimport { createPathResolver } from \"@webiny/project\";\nimport { CliCommand } from \"@webiny/cli-core/extensions/index.js\";\nimport { CorePulumi } from \"~/pulumi/extensions/CorePulumi.js\";\n\nconst p = createPathResolver(import.meta.dirname);\n\nexport const ProjectAws = () => {\n return (\n <>\n <Project />\n\n {/* Database Setup - default to DynamoDB only */}\n <DatabaseSetup setupName=\"ddb\" />\n\n {/* Set database setup output value in Core stack */}\n <CorePulumi src={p(\"ProjectAws/SetDatabaseSetupOutput.js\")} />\n\n {/* Stack Output Services */}\n <ProjectImplementation src={p(\"ProjectAws/CoreStackOutputService.js\")} singleton />\n <ProjectImplementation src={p(\"ProjectAws/ApiStackOutputService.js\")} singleton />\n <ProjectImplementation src={p(\"ProjectAws/AdminStackOutputService.js\")} singleton />\n\n <ProjectImplementation src={p(\"../features/InvokeLambdaFunction.js\")} singleton />\n <ProjectImplementation src={p(\"../features/ApiGqlClient.js\")} singleton />\n\n <AdminAfterDeploy src={p(\"ProjectAws/UploadAdminAppToS3.js\")} />\n\n <ApiAfterDeploy src={p(\"ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.js\")} />\n <ExtensionDefinitions src={p(\"definitions.js\")} />\n <ExtensionDefinitions src={p(\"ProjectAws/definitions.js\")} />\n\n {/* Admin env vars */}\n <AdminBeforeBuild src={p(\"ProjectAws/SetAdminEnvVars/SetAdminEnvVarsBeforeBuild.js\")} />\n <AdminBeforeWatch src={p(\"ProjectAws/SetAdminEnvVars/SetAdminEnvVarsBeforeWatch.js\")} />\n\n {/* Deployment gates — AWS-only (there is no Pulumi stack output to check off-AWS) */}\n <ApiBeforeWatch src={p(\"ProjectAws/EnsureApiDeployedBeforeWatch.js\")} />\n <AdminBeforeBuild src={p(\"ProjectAws/EnsureApiDeployedBeforeAdminBuild.js\")} />\n <AdminBeforeWatch src={p(\"ProjectAws/EnsureApiDeployedBeforeAdminWatch.js\")} />\n <ApiBeforeDeploy src={p(\"ProjectAws/EnsureCoreDeployedBeforeApiDeploy.js\")} />\n <CoreBeforeDeploy src={p(\"ProjectAws/ValidateProductionPulumiState.js\")} />\n\n {/* Deploy-time hooks — server hosting type has no deploy command, so these are AWS-only */}\n <BeforeDeploy src={p(\"ProjectAws/EnsureTelemetryEnabledForOss.js\")} />\n <BeforeDeploy src={p(\"ProjectAws/ValidateEncryptionBeforeDeploy.js\")} />\n <AdminAfterDeploy src={p(\"ProjectAws/TelemetryNoLongerNewUser.js\")} />\n\n {/* AWS credentials check */}\n <BeforeDeploy src={p(\"ProjectAws/EnsureAwsCredentialsBeforeDeploy.js\")} />\n\n {/* Blue-green */}\n <CliCommand src={p(\"ProjectAws/BlueGreenDeployments/SetPrimaryVariantCliCommand.js\")} />\n <BeforeDeploy src={p(\"ProjectAws/BlueGreenDeployments/EnsureVariantBeforeDeploy.js\")} />\n <AfterDeploy\n src={p(\"ProjectAws/BlueGreenDeployments/PrintDeploymentInfoAfterDeploy.js\")}\n />\n </>\n );\n};\n"],"names":["p","createPathResolver","ProjectAws","Project","DatabaseSetup","CorePulumi","ProjectImplementation","AdminAfterDeploy","ApiAfterDeploy","ExtensionDefinitions","AdminBeforeBuild","AdminBeforeWatch","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,cAAYA;QAAC,KAAKf,EAAE;sBACrB,oBAACiB,aAAWA;QACR,KAAKjB,EAAE"}
1
+ {"version":3,"file":"extensions/ProjectAws.js","sources":["../../src/extensions/ProjectAws.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n AdminAfterDeploy,\n AdminBeforeBuild,\n AdminBeforeWatch,\n AfterDeploy,\n ApiAfterDeploy,\n ApiBeforeDeploy,\n ApiBeforeWatch,\n BeforeDeploy,\n CoreBeforeDeploy,\n DatabaseSetup,\n ExtensionDefinitions,\n Project,\n ProjectImplementation\n} from \"@webiny/project/extensions/index.js\";\nimport { createPathResolver } from \"@webiny/project\";\nimport { CliCommand } from \"@webiny/cli-core/extensions/index.js\";\nimport { CorePulumi } from \"~/pulumi/extensions/CorePulumi.js\";\n\nconst p = createPathResolver(import.meta.dirname);\n\nexport const ProjectAws = () => {\n return (\n <>\n <Project />\n\n {/* Database Setup - default to DynamoDB only */}\n <DatabaseSetup setupName=\"ddb\" />\n\n {/* Set database setup output value in Core stack */}\n <CorePulumi src={p(\"ProjectAws/SetDatabaseSetupOutput.js\")} />\n\n {/* Stack Output Services */}\n <ProjectImplementation src={p(\"ProjectAws/CoreStackOutputService.js\")} singleton />\n <ProjectImplementation src={p(\"ProjectAws/ApiStackOutputService.js\")} singleton />\n <ProjectImplementation src={p(\"ProjectAws/AdminStackOutputService.js\")} singleton />\n\n <ProjectImplementation src={p(\"../features/InvokeLambdaFunction.js\")} singleton />\n <ProjectImplementation src={p(\"../features/ApiGqlClient.js\")} singleton />\n\n <AdminAfterDeploy src={p(\"ProjectAws/UploadAdminAppToS3.js\")} />\n\n <ApiAfterDeploy src={p(\"ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.js\")} />\n <ExtensionDefinitions src={p(\"definitions.js\")} />\n <ExtensionDefinitions src={p(\"ProjectAws/definitions.js\")} />\n\n {/* Admin env vars */}\n <AdminBeforeBuild src={p(\"ProjectAws/SetAdminEnvVars/SetAdminEnvVarsBeforeBuild.js\")} />\n <AdminBeforeWatch src={p(\"ProjectAws/SetAdminEnvVars/SetAdminEnvVarsBeforeWatch.js\")} />\n\n {/* Deployment gates — AWS-only (there is no Pulumi stack output to check off-AWS) */}\n <ApiBeforeWatch src={p(\"ProjectAws/EnsureApiDeployedBeforeWatch.js\")} />\n <AdminBeforeBuild src={p(\"ProjectAws/EnsureApiDeployedBeforeAdminBuild.js\")} />\n <AdminBeforeWatch src={p(\"ProjectAws/EnsureApiDeployedBeforeAdminWatch.js\")} />\n <ApiBeforeDeploy src={p(\"ProjectAws/EnsureCoreDeployedBeforeApiDeploy.js\")} />\n <CoreBeforeDeploy src={p(\"ProjectAws/ValidateProductionPulumiState.js\")} />\n\n {/* Deploy-time hooks — standalone hosting type has no deploy command, so these are AWS-only */}\n <BeforeDeploy src={p(\"ProjectAws/EnsureTelemetryEnabledForOss.js\")} />\n <BeforeDeploy src={p(\"ProjectAws/ValidateEncryptionBeforeDeploy.js\")} />\n <AdminAfterDeploy src={p(\"ProjectAws/TelemetryNoLongerNewUser.js\")} />\n\n {/* AWS credentials check */}\n <BeforeDeploy src={p(\"ProjectAws/EnsureAwsCredentialsBeforeDeploy.js\")} />\n\n {/* Blue-green */}\n <CliCommand src={p(\"ProjectAws/BlueGreenDeployments/SetPrimaryVariantCliCommand.js\")} />\n <BeforeDeploy src={p(\"ProjectAws/BlueGreenDeployments/EnsureVariantBeforeDeploy.js\")} />\n <AfterDeploy\n src={p(\"ProjectAws/BlueGreenDeployments/PrintDeploymentInfoAfterDeploy.js\")}\n />\n </>\n );\n};\n"],"names":["p","createPathResolver","ProjectAws","Project","DatabaseSetup","CorePulumi","ProjectImplementation","AdminAfterDeploy","ApiAfterDeploy","ExtensionDefinitions","AdminBeforeBuild","AdminBeforeWatch","ApiBeforeWatch","ApiBeforeDeploy","CoreBeforeDeploy","BeforeDeploy","CliCommand","AfterDeploy"],"mappings":";;;;;AAoBA,MAAMA,IAAIC,mBAAmB,YAAY,OAAO;AAEzC,MAAMC,aAAa,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iPulumi } from "../abstractions/features/pulumi/index.js";
3
3
  import { ApiRoute } from "./ApiRoute.js";
4
- import { ApiGraphql } from "../pulumi/apps/api/ApiGraphql.js";
5
- function deriveRouteName(routePath, method) {
6
- const pathPart = routePath.replace(/^\//, "").replace(/\{[^}]*\}/g, "").replace(/\/+/g, "-").replace(/^-+|-+$/g, "").toLowerCase();
7
- return `${pathPart}-${method.toLowerCase()}`;
8
- }
4
+ import { deriveRouteName, toApiGatewayPath } from "./routePath.js";
9
5
  class RegisterRoutesPulumiImpl {
10
6
  constructor(getProjectConfigService){
11
7
  this.getProjectConfigService = getProjectConfigService;
@@ -14,13 +10,14 @@ class RegisterRoutesPulumiImpl {
14
10
  const projectConfig = await this.getProjectConfigService.execute();
15
11
  const routeExtensions = projectConfig.extensionsByType(ApiRoute);
16
12
  if (!routeExtensions.length) return;
13
+ const { ApiGraphql } = await import("../pulumi/apps/api/ApiGraphql.js");
17
14
  const graphqlModule = app.getModule(ApiGraphql);
18
15
  for (const ext of routeExtensions){
19
16
  const { path: routePath, method, routeName } = ext.params;
20
17
  const name = routeName ?? deriveRouteName(routePath, method);
21
18
  graphqlModule.addRoute({
22
19
  name,
23
- path: routePath,
20
+ path: toApiGatewayPath(routePath),
24
21
  method
25
22
  });
26
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"extensions/RegisterRoutesPulumi.js","sources":["../../src/extensions/RegisterRoutesPulumi.ts"],"sourcesContent":["import { GetProjectConfigService } from \"@webiny/project/abstractions/index.js\";\nimport { ApiPulumi } from \"~/abstractions/features/pulumi/index.js\";\nimport type { ApiPulumiApp } from \"~/pulumi/apps/api/createApiPulumiApp.js\";\nimport { ApiRoute } from \"./ApiRoute.js\";\nimport { ApiGraphql } from \"~/pulumi/apps/api/ApiGraphql.js\";\n\nfunction deriveRouteName(routePath: string, method: string): string {\n // /asd/{id}/xs + POST → asd-xs-post\n const pathPart = routePath\n .replace(/^\\//, \"\")\n .replace(/\\{[^}]*\\}/g, \"\")\n .replace(/\\/+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .toLowerCase();\n\n return `${pathPart}-${method.toLowerCase()}`;\n}\n\nclass RegisterRoutesPulumiImpl implements ApiPulumi.Interface {\n constructor(private getProjectConfigService: GetProjectConfigService.Interface) {}\n\n async execute(app: ApiPulumiApp): Promise<void> {\n // No tags filter — finds ApiRestRoute extensions regardless of their runtimeContext.\n const projectConfig = await this.getProjectConfigService.execute();\n const routeExtensions = projectConfig.extensionsByType(ApiRoute);\n\n if (!routeExtensions.length) {\n return;\n }\n\n const graphqlModule = app.getModule(ApiGraphql);\n\n for (const ext of routeExtensions) {\n const { path: routePath, method, routeName } = ext.params;\n const name = routeName ?? deriveRouteName(routePath, method);\n graphqlModule.addRoute({\n name,\n path: routePath as `/${string}`,\n method\n });\n }\n }\n}\n\nexport const RegisterRoutesPulumi = ApiPulumi.createImplementation({\n implementation: RegisterRoutesPulumiImpl,\n dependencies: [GetProjectConfigService]\n});\n"],"names":["deriveRouteName","routePath","method","pathPart","RegisterRoutesPulumiImpl","getProjectConfigService","app","projectConfig","routeExtensions","ApiRoute","graphqlModule","ApiGraphql","ext","routeName","name","RegisterRoutesPulumi","ApiPulumi","GetProjectConfigService"],"mappings":";;;;AAMA,SAASA,gBAAgBC,SAAiB,EAAEC,MAAc;IAEtD,MAAMC,WAAWF,UACZ,OAAO,CAAC,OAAO,IACf,OAAO,CAAC,cAAc,IACtB,OAAO,CAAC,QAAQ,KAChB,OAAO,CAAC,YAAY,IACpB,WAAW;IAEhB,OAAO,GAAGE,SAAS,CAAC,EAAED,OAAO,WAAW,IAAI;AAChD;AAEA,MAAME;IACF,YAAoBC,uBAA0D,CAAE;aAA5DA,uBAAuB,GAAvBA;IAA6D;IAEjF,MAAM,QAAQC,GAAiB,EAAiB;QAE5C,MAAMC,gBAAgB,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO;QAChE,MAAMC,kBAAkBD,cAAc,gBAAgB,CAACE;QAEvD,IAAI,CAACD,gBAAgB,MAAM,EACvB;QAGJ,MAAME,gBAAgBJ,IAAI,SAAS,CAACK;QAEpC,KAAK,MAAMC,OAAOJ,gBAAiB;YAC/B,MAAM,EAAE,MAAMP,SAAS,EAAEC,MAAM,EAAEW,SAAS,EAAE,GAAGD,IAAI,MAAM;YACzD,MAAME,OAAOD,aAAab,gBAAgBC,WAAWC;YACrDQ,cAAc,QAAQ,CAAC;gBACnBI;gBACA,MAAMb;gBACNC;YACJ;QACJ;IACJ;AACJ;AAEO,MAAMa,uBAAuBC,UAAU,oBAAoB,CAAC;IAC/D,gBAAgBZ;IAChB,cAAc;QAACa;KAAwB;AAC3C"}
1
+ {"version":3,"file":"extensions/RegisterRoutesPulumi.js","sources":["../../src/extensions/RegisterRoutesPulumi.ts"],"sourcesContent":["import { GetProjectConfigService } from \"@webiny/project/abstractions/index.js\";\nimport { ApiPulumi } from \"~/abstractions/features/pulumi/index.js\";\nimport type { ApiPulumiApp } from \"~/pulumi/apps/api/createApiPulumiApp.js\";\nimport { ApiRoute } from \"./ApiRoute.js\";\nimport { deriveRouteName, toApiGatewayPath } from \"./routePath.js\";\n\nclass RegisterRoutesPulumiImpl implements ApiPulumi.Interface {\n constructor(private getProjectConfigService: GetProjectConfigService.Interface) {}\n\n async execute(app: ApiPulumiApp): Promise<void> {\n // No tags filter — finds ApiRestRoute extensions regardless of their runtimeContext.\n const projectConfig = await this.getProjectConfigService.execute();\n const routeExtensions = projectConfig.extensionsByType(ApiRoute);\n\n if (!routeExtensions.length) {\n return;\n }\n\n // Imported here rather than at the top of the file. Every CLI command imports this extension\n // when the project SDK registers it, even `webiny --help`, and `ApiGraphql` pulls in all of\n // Pulumi and the AWS SDK: about 2,700 modules. By the time `execute` runs we are inside a\n // Pulumi program that has already loaded all of that, so importing it here costs nothing.\n const { ApiGraphql } = await import(\"~/pulumi/apps/api/ApiGraphql.js\");\n\n const graphqlModule = app.getModule(ApiGraphql);\n\n for (const ext of routeExtensions) {\n const { path: routePath, method, routeName } = ext.params;\n const name = routeName ?? deriveRouteName(routePath, method);\n graphqlModule.addRoute({\n name,\n // The prop accepts `:id` too; API Gateway only understands `{id}`.\n path: toApiGatewayPath(routePath) as `/${string}`,\n method\n });\n }\n }\n}\n\nexport const RegisterRoutesPulumi = ApiPulumi.createImplementation({\n implementation: RegisterRoutesPulumiImpl,\n dependencies: [GetProjectConfigService]\n});\n"],"names":["RegisterRoutesPulumiImpl","getProjectConfigService","app","projectConfig","routeExtensions","ApiRoute","ApiGraphql","graphqlModule","ext","routePath","method","routeName","name","deriveRouteName","toApiGatewayPath","RegisterRoutesPulumi","ApiPulumi","GetProjectConfigService"],"mappings":";;;;AAMA,MAAMA;IACF,YAAoBC,uBAA0D,CAAE;aAA5DA,uBAAuB,GAAvBA;IAA6D;IAEjF,MAAM,QAAQC,GAAiB,EAAiB;QAE5C,MAAMC,gBAAgB,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO;QAChE,MAAMC,kBAAkBD,cAAc,gBAAgB,CAACE;QAEvD,IAAI,CAACD,gBAAgB,MAAM,EACvB;QAOJ,MAAM,EAAEE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC;QAEpC,MAAMC,gBAAgBL,IAAI,SAAS,CAACI;QAEpC,KAAK,MAAME,OAAOJ,gBAAiB;YAC/B,MAAM,EAAE,MAAMK,SAAS,EAAEC,MAAM,EAAEC,SAAS,EAAE,GAAGH,IAAI,MAAM;YACzD,MAAMI,OAAOD,aAAaE,gBAAgBJ,WAAWC;YACrDH,cAAc,QAAQ,CAAC;gBACnBK;gBAEA,MAAME,iBAAiBL;gBACvBC;YACJ;QACJ;IACJ;AACJ;AAEO,MAAMK,uBAAuBC,UAAU,oBAAoB,CAAC;IAC/D,gBAAgBhB;IAChB,cAAc;QAACiB;KAAwB;AAC3C"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The `path` prop on `<Api.Route>` feeds two consumers that spell path parameters differently:
3
+ * API Gateway wants `{orderId}`, the DI `HttpRouter` wants `:orderId`. Rather than pick a winner and
4
+ * break whichever projects already used the other, accept both and convert per consumer.
5
+ *
6
+ * Wildcards are left alone. `HttpRouter` matches a trailing `/*`, API Gateway spells the same thing
7
+ * `{proxy+}`, and translating between them changes what the route captures — so a wildcard route
8
+ * has to be written for the target it's aimed at.
9
+ */
10
+ /** `/orders/:orderId` → `/orders/{orderId}`. Already-braced segments pass through. */
11
+ export declare function toApiGatewayPath(path: string): string;
12
+ /** `/orders/{orderId}` → `/orders/:orderId`. Already-colon segments pass through. */
13
+ export declare function toRouterPath(path: string): string;
14
+ /**
15
+ * `/asd/{id}/xs` + POST → `asd-xs-post`. Handles either parameter syntax.
16
+ *
17
+ * Used for BOTH the Pulumi resource name and the route's DI name, so the name a decorator matches
18
+ * on is the same one that shows up in infrastructure.
19
+ */
20
+ export declare function deriveRouteName(routePath: string, method: string): string;
@@ -0,0 +1,13 @@
1
+ function toApiGatewayPath(path) {
2
+ return path.replace(/(^|\/):([^/]+)/g, (_match, prefix, name)=>`${prefix}{${name}}`);
3
+ }
4
+ function toRouterPath(path) {
5
+ return path.replace(/\{([^}]+)\}/g, (_match, name)=>`:${name}`);
6
+ }
7
+ function deriveRouteName(routePath, method) {
8
+ const pathPart = routePath.replace(/^\//, "").replace(/\{[^}]*\}/g, "").replace(/(^|\/):[^/]+/g, "$1").replace(/\/+/g, "-").replace(/^-+|-+$/g, "").toLowerCase();
9
+ return `${pathPart}-${method.toLowerCase()}`;
10
+ }
11
+ export { deriveRouteName, toApiGatewayPath, toRouterPath };
12
+
13
+ //# sourceMappingURL=routePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions/routePath.js","sources":["../../src/extensions/routePath.ts"],"sourcesContent":["/**\n * The `path` prop on `<Api.Route>` feeds two consumers that spell path parameters differently:\n * API Gateway wants `{orderId}`, the DI `HttpRouter` wants `:orderId`. Rather than pick a winner and\n * break whichever projects already used the other, accept both and convert per consumer.\n *\n * Wildcards are left alone. `HttpRouter` matches a trailing `/*`, API Gateway spells the same thing\n * `{proxy+}`, and translating between them changes what the route captures — so a wildcard route\n * has to be written for the target it's aimed at.\n */\n\n/** `/orders/:orderId` → `/orders/{orderId}`. Already-braced segments pass through. */\nexport function toApiGatewayPath(path: string): string {\n return path.replace(/(^|\\/):([^/]+)/g, (_match, prefix: string, name: string) => {\n return `${prefix}{${name}}`;\n });\n}\n\n/** `/orders/{orderId}` → `/orders/:orderId`. Already-colon segments pass through. */\nexport function toRouterPath(path: string): string {\n return path.replace(/\\{([^}]+)\\}/g, (_match, name: string) => {\n return `:${name}`;\n });\n}\n\n/**\n * `/asd/{id}/xs` + POST → `asd-xs-post`. Handles either parameter syntax.\n *\n * Used for BOTH the Pulumi resource name and the route's DI name, so the name a decorator matches\n * on is the same one that shows up in infrastructure.\n */\nexport function deriveRouteName(routePath: string, method: string): string {\n // /asd/{id}/xs + POST → asd-xs-post. Strips parameters in either syntax.\n const pathPart = routePath\n .replace(/^\\//, \"\")\n .replace(/\\{[^}]*\\}/g, \"\")\n .replace(/(^|\\/):[^/]+/g, \"$1\")\n .replace(/\\/+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .toLowerCase();\n\n return `${pathPart}-${method.toLowerCase()}`;\n}\n"],"names":["toApiGatewayPath","path","_match","prefix","name","toRouterPath","deriveRouteName","routePath","method","pathPart"],"mappings":"AAWO,SAASA,iBAAiBC,IAAY;IACzC,OAAOA,KAAK,OAAO,CAAC,mBAAmB,CAACC,QAAQC,QAAgBC,OACrD,GAAGD,OAAO,CAAC,EAAEC,KAAK,CAAC,CAAC;AAEnC;AAGO,SAASC,aAAaJ,IAAY;IACrC,OAAOA,KAAK,OAAO,CAAC,gBAAgB,CAACC,QAAQE,OAClC,CAAC,CAAC,EAAEA,MAAM;AAEzB;AAQO,SAASE,gBAAgBC,SAAiB,EAAEC,MAAc;IAE7D,MAAMC,WAAWF,UACZ,OAAO,CAAC,OAAO,IACf,OAAO,CAAC,cAAc,IACtB,OAAO,CAAC,iBAAiB,MACzB,OAAO,CAAC,QAAQ,KAChB,OAAO,CAAC,YAAY,IACpB,WAAW;IAEhB,OAAO,GAAGE,SAAS,CAAC,EAAED,OAAO,WAAW,IAAI;AAChD"}
@@ -1,4 +1,3 @@
1
- import { InvokeCommand, LambdaClient } from "@webiny/aws-sdk/client-lambda/index.js";
2
1
  import { GetAppStackOutput } from "@webiny/project/abstractions/index.js";
3
2
  import { InvokeLambdaFunction } from "../abstractions/InvokeLambdaFunction.js";
4
3
  class InvokeLambdaFunctionImpl {
@@ -8,6 +7,7 @@ class InvokeLambdaFunctionImpl {
8
7
  async execute(params) {
9
8
  const stackOutput = await this.getAppStackOutput.execute("api");
10
9
  if (!stackOutput) throw new Error("Could not retrieve API stack output for Lambda invocation.");
10
+ const { LambdaClient, InvokeCommand } = await import("@webiny/aws-sdk/client-lambda/index.js");
11
11
  const { region } = stackOutput;
12
12
  const lambdaClient = new LambdaClient({
13
13
  region
@@ -1 +1 @@
1
- {"version":3,"file":"features/InvokeLambdaFunction.js","sources":["../../src/features/InvokeLambdaFunction.ts"],"sourcesContent":["import { LambdaClient, InvokeCommand } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport { GetAppStackOutput } from \"@webiny/project/abstractions/index.js\";\nimport { InvokeLambdaFunction as InvokeLambdaFunctionAbstraction } from \"~/abstractions/InvokeLambdaFunction.js\";\nimport { IDefaultStackOutput } from \"~/pulumi/types.js\";\n\nexport class InvokeLambdaFunctionImpl implements InvokeLambdaFunctionAbstraction.Interface {\n constructor(private getAppStackOutput: GetAppStackOutput.Interface) {}\n\n async execute<T = any>(\n params: InvokeLambdaFunctionAbstraction.Params\n ): Promise<InvokeLambdaFunctionAbstraction.Result<T>> {\n // Get region from stack output\n const stackOutput = await this.getAppStackOutput.execute<IDefaultStackOutput>(\"api\");\n\n if (!stackOutput) {\n throw new Error(\"Could not retrieve API stack output for Lambda invocation.\");\n }\n\n const { region } = stackOutput;\n const lambdaClient = new LambdaClient({ region });\n\n const response = await lambdaClient.send(\n new InvokeCommand({\n FunctionName: params.functionName,\n InvocationType: params.invocationType || \"RequestResponse\",\n Payload: JSON.stringify(params.payload)\n })\n );\n\n const decoder = new TextDecoder(\"utf-8\");\n const payload = JSON.parse(decoder.decode(response.Payload));\n\n return {\n statusCode: response.StatusCode,\n payload\n };\n }\n}\n\nexport const InvokeLambdaFunction = InvokeLambdaFunctionAbstraction.createImplementation({\n implementation: InvokeLambdaFunctionImpl,\n dependencies: [GetAppStackOutput]\n});\n"],"names":["InvokeLambdaFunctionImpl","getAppStackOutput","params","stackOutput","Error","region","lambdaClient","LambdaClient","response","InvokeCommand","JSON","decoder","TextDecoder","payload","InvokeLambdaFunction","InvokeLambdaFunctionAbstraction","GetAppStackOutput"],"mappings":";;;AAKO,MAAMA;IACT,YAAoBC,iBAA8C,CAAE;aAAhDA,iBAAiB,GAAjBA;IAAiD;IAErE,MAAM,QACFC,MAA8C,EACI;QAElD,MAAMC,cAAc,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAsB;QAE9E,IAAI,CAACA,aACD,MAAM,IAAIC,MAAM;QAGpB,MAAM,EAAEC,MAAM,EAAE,GAAGF;QACnB,MAAMG,eAAe,IAAIC,aAAa;YAAEF;QAAO;QAE/C,MAAMG,WAAW,MAAMF,aAAa,IAAI,CACpC,IAAIG,cAAc;YACd,cAAcP,OAAO,YAAY;YACjC,gBAAgBA,OAAO,cAAc,IAAI;YACzC,SAASQ,KAAK,SAAS,CAACR,OAAO,OAAO;QAC1C;QAGJ,MAAMS,UAAU,IAAIC,YAAY;QAChC,MAAMC,UAAUH,KAAK,KAAK,CAACC,QAAQ,MAAM,CAACH,SAAS,OAAO;QAE1D,OAAO;YACH,YAAYA,SAAS,UAAU;YAC/BK;QACJ;IACJ;AACJ;AAEO,MAAMC,4CAAuBC,qBAAAA,oBAAoD,CAAC;IACrF,gBAAgBf;IAChB,cAAc;QAACgB;KAAkB;AACrC"}
1
+ {"version":3,"file":"features/InvokeLambdaFunction.js","sources":["../../src/features/InvokeLambdaFunction.ts"],"sourcesContent":["import { GetAppStackOutput } from \"@webiny/project/abstractions/index.js\";\nimport { InvokeLambdaFunction as InvokeLambdaFunctionAbstraction } from \"~/abstractions/InvokeLambdaFunction.js\";\nimport { IDefaultStackOutput } from \"~/pulumi/types.js\";\n\nexport class InvokeLambdaFunctionImpl implements InvokeLambdaFunctionAbstraction.Interface {\n constructor(private getAppStackOutput: GetAppStackOutput.Interface) {}\n\n async execute<T = any>(\n params: InvokeLambdaFunctionAbstraction.Params\n ): Promise<InvokeLambdaFunctionAbstraction.Result<T>> {\n // Get region from stack output\n const stackOutput = await this.getAppStackOutput.execute<IDefaultStackOutput>(\"api\");\n\n if (!stackOutput) {\n throw new Error(\"Could not retrieve API stack output for Lambda invocation.\");\n }\n\n // Loaded here rather than at the top of the file. Validating the project config imports this\n // file on every command, and only an actual invocation needs the Lambda client.\n const { LambdaClient, InvokeCommand } =\n await import(\"@webiny/aws-sdk/client-lambda/index.js\");\n\n const { region } = stackOutput;\n const lambdaClient = new LambdaClient({ region });\n\n const response = await lambdaClient.send(\n new InvokeCommand({\n FunctionName: params.functionName,\n InvocationType: params.invocationType || \"RequestResponse\",\n Payload: JSON.stringify(params.payload)\n })\n );\n\n const decoder = new TextDecoder(\"utf-8\");\n const payload = JSON.parse(decoder.decode(response.Payload));\n\n return {\n statusCode: response.StatusCode,\n payload\n };\n }\n}\n\nexport const InvokeLambdaFunction = InvokeLambdaFunctionAbstraction.createImplementation({\n implementation: InvokeLambdaFunctionImpl,\n dependencies: [GetAppStackOutput]\n});\n"],"names":["InvokeLambdaFunctionImpl","getAppStackOutput","params","stackOutput","Error","LambdaClient","InvokeCommand","region","lambdaClient","response","JSON","decoder","TextDecoder","payload","InvokeLambdaFunction","InvokeLambdaFunctionAbstraction","GetAppStackOutput"],"mappings":";;AAIO,MAAMA;IACT,YAAoBC,iBAA8C,CAAE;aAAhDA,iBAAiB,GAAjBA;IAAiD;IAErE,MAAM,QACFC,MAA8C,EACI;QAElD,MAAMC,cAAc,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAsB;QAE9E,IAAI,CAACA,aACD,MAAM,IAAIC,MAAM;QAKpB,MAAM,EAAEC,YAAY,EAAEC,aAAa,EAAE,GACjC,MAAM,MAAM,CAAC;QAEjB,MAAM,EAAEC,MAAM,EAAE,GAAGJ;QACnB,MAAMK,eAAe,IAAIH,aAAa;YAAEE;QAAO;QAE/C,MAAME,WAAW,MAAMD,aAAa,IAAI,CACpC,IAAIF,cAAc;YACd,cAAcJ,OAAO,YAAY;YACjC,gBAAgBA,OAAO,cAAc,IAAI;YACzC,SAASQ,KAAK,SAAS,CAACR,OAAO,OAAO;QAC1C;QAGJ,MAAMS,UAAU,IAAIC,YAAY;QAChC,MAAMC,UAAUH,KAAK,KAAK,CAACC,QAAQ,MAAM,CAACF,SAAS,OAAO;QAE1D,OAAO;YACH,YAAYA,SAAS,UAAU;YAC/BI;QACJ;IACJ;AACJ;AAEO,MAAMC,4CAAuBC,qBAAAA,oBAAoD,CAAC;IACrF,gBAAgBf;IAChB,cAAc;QAACgB;KAAkB;AACrC"}
@@ -1,8 +1,5 @@
1
1
  import { GetApp, ListAppLambdaFunctionsService, LoggerService, ProjectSdkParamsService, PulumiExportService, PulumiGetStackOutputService, UiService, Watch, WatchedLambdaFunctionsService } from "@webiny/project/abstractions/index.js";
2
2
  import chalk from "chalk";
3
- import { getIotEndpoint } from "./getIotEndpoint.js";
4
- import { replaceLambdaFunctions } from "./replaceLambdaFunctions.js";
5
- import { initInvocationForwarding } from "@webiny/project/features/Watch/initInvocationForwarding.js";
6
3
  class AwsWatch {
7
4
  constructor(getApp, logger, listAppLambdaFunctionsService, ui, pulumiGetStackOutputService, pulumiExportService, watchedLambdaFunctionsService, projectSdkParamsService, decoratee){
8
5
  this.getApp = getApp;
@@ -52,6 +49,9 @@ class AwsWatch {
52
49
  if (!coreStackOutput) throw new Error(`You must deploy the ${chalk.bold("core")} app before you can start a watch session. To do that, run: ${chalk.bold(`yarn webiny deploy core --env ${sdkParams.env}`)}`);
53
50
  const deploymentId = coreStackOutput?.deploymentId;
54
51
  const iotEndpointTopic = `webiny-watch-${deploymentId}`;
52
+ const { getIotEndpoint } = await import("./getIotEndpoint.js");
53
+ const { replaceLambdaFunctions } = await import("./replaceLambdaFunctions.js");
54
+ const { initInvocationForwarding } = await import("@webiny/project/features/Watch/initInvocationForwarding.js");
55
55
  const iotEndpoint = await getIotEndpoint(coreStackOutput);
56
56
  const sessionId = new Date().getTime();
57
57
  const increaseTimeout = params.increaseTimeout;
@@ -1 +1 @@
1
- {"version":3,"file":"features/Watch/AwsWatch.js","sources":["../../../src/features/Watch/AwsWatch.ts"],"sourcesContent":["import {\n GetApp,\n ListAppLambdaFunctionsService,\n LoggerService,\n ProjectSdkParamsService,\n PulumiExportService,\n PulumiGetStackOutputService,\n UiService,\n Watch,\n WatchedLambdaFunctionsService\n} from \"@webiny/project/abstractions/index.js\";\nimport chalk from \"chalk\";\nimport type inspectorType from \"inspector\";\nimport { type ICoreStackOutput } from \"@webiny/project/abstractions/features/GetAppStackOutput.js\";\nimport { getIotEndpoint } from \"./getIotEndpoint.js\";\nimport { replaceLambdaFunctions } from \"./replaceLambdaFunctions.js\";\nimport { initInvocationForwarding } from \"@webiny/project/features/Watch/initInvocationForwarding.js\";\n\nexport class AwsWatch implements Watch.Interface {\n constructor(\n private getApp: GetApp.Interface,\n private logger: LoggerService.Interface,\n private listAppLambdaFunctionsService: ListAppLambdaFunctionsService.Interface,\n private ui: UiService.Interface,\n private pulumiGetStackOutputService: PulumiGetStackOutputService.Interface,\n private pulumiExportService: PulumiExportService.Interface,\n private watchedLambdaFunctionsService: WatchedLambdaFunctionsService.Interface,\n private projectSdkParamsService: ProjectSdkParamsService.Interface,\n private decoratee: Watch.Interface\n ) {}\n\n async execute(params: Watch.Params): Promise<Watch.Result> {\n // Validate Lambda-specific params before the base runs workspace build.\n if (\"app\" in params && params.increaseTimeout && params.increaseTimeout > 900) {\n throw new Error(\n `When increasing the timeout, the maximum value that can be passed is 900 seconds (15 minutes).`\n );\n }\n\n const result = await this.decoratee.execute(params);\n\n // No Lambda machinery for package-only watch.\n if (!(\"app\" in params)) {\n return result;\n }\n\n const app = this.getApp.execute(params.app);\n const sdkParams = this.projectSdkParamsService.get();\n const ui = this.ui;\n const logger = this.logger;\n\n const functionsWhitelist = Array.isArray(params.function)\n ? params.function\n : ([params.function].filter(Boolean) as string[]);\n\n const functionsList = await this.listAppLambdaFunctionsService.execute(app, {\n whitelist: functionsWhitelist\n });\n\n const deployCommand = `yarn webiny deploy ${app.name} --env ${sdkParams.env}`;\n const learnMoreLink = \"https://webiny.link/local-aws-lambda-development\";\n const troubleshootingLink = learnMoreLink + \"#troubleshooting\";\n\n if (functionsList.meta.count === 0) {\n if (functionsList.meta.totalCount > 0) {\n ui.info(\n [\n \"No AWS Lambda functions will be invoked locally. If this is unexpected, you can try the following:\",\n \" ‣ stop the current development session\",\n \" ‣ redeploy the %s application by running %s command\",\n \" ‣ start a new %s session by rerunning %s command\",\n \"\",\n \"Learn more: %s\"\n ].join(\"\\n\"),\n app.name,\n deployCommand,\n \"webiny watch\",\n \"webiny watch\",\n troubleshootingLink\n );\n }\n return result;\n }\n\n ui.info(`Local AWS Lambda development session started.`);\n ui.warning(\n `Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,\n app.getDisplayName(),\n \"MUST\",\n deployCommand,\n learnMoreLink\n );\n\n logger.debug(\n \"The events for following AWS Lambda functions will be forwarded locally: \",\n functionsList.list.map(fn => fn.name)\n );\n\n ui.emptyLine();\n const { default: exitHook } = await import(/* webpackChunkName: \"exit-hook\" */ \"exit-hook\");\n\n exitHook(() => {\n console.log();\n console.log();\n\n ui.info(`Terminating local AWS Lambda development session.`);\n ui.warning(\n `Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,\n app?.getDisplayName(),\n \"MUST\",\n deployCommand,\n learnMoreLink\n );\n });\n\n const coreApp = this.getApp.execute(\"core\");\n const coreStackOutput =\n await this.pulumiGetStackOutputService.execute<ICoreStackOutput>(coreApp);\n\n if (!coreStackOutput) {\n throw new Error(\n `You must deploy the ${chalk.bold(\n \"core\"\n )} app before you can start a watch session. To do that, run: ${chalk.bold(\n `yarn webiny deploy core --env ${sdkParams.env}`\n )}`\n );\n }\n\n const deploymentId = coreStackOutput?.deploymentId;\n const iotEndpointTopic = `webiny-watch-${deploymentId}`;\n const iotEndpoint = await getIotEndpoint(coreStackOutput);\n\n const sessionId = new Date().getTime();\n const increaseTimeout = params.increaseTimeout;\n const localExecutionHandshakeTimeout = params.increaseHandshakeTimeout || 5;\n\n replaceLambdaFunctions({\n app,\n deploymentId,\n dependencies: {\n uiService: ui,\n loggerService: logger,\n pulumiExportService: this.pulumiExportService,\n watchedLambdaFunctionsService: this.watchedLambdaFunctionsService\n },\n iotEndpoint,\n iotEndpointTopic,\n sessionId,\n functionsList,\n increaseTimeout,\n localExecutionHandshakeTimeout\n });\n\n let inspector: typeof inspectorType | undefined = undefined;\n if (params.inspect) {\n inspector = await import(\"inspector\");\n inspector!.open(9229, \"127.0.0.1\");\n ui.emptyLine();\n\n exitHook(() => {\n inspector!.close();\n });\n }\n\n initInvocationForwarding({\n iotEndpoint,\n iotEndpointTopic,\n functionsList,\n sessionId\n });\n\n return result;\n }\n}\n\nexport const awsWatch = Watch.createDecorator({\n decorator: AwsWatch,\n dependencies: [\n GetApp,\n LoggerService,\n ListAppLambdaFunctionsService,\n UiService,\n PulumiGetStackOutputService,\n PulumiExportService,\n WatchedLambdaFunctionsService,\n ProjectSdkParamsService\n ]\n});\n"],"names":["AwsWatch","getApp","logger","listAppLambdaFunctionsService","ui","pulumiGetStackOutputService","pulumiExportService","watchedLambdaFunctionsService","projectSdkParamsService","decoratee","params","Error","result","app","sdkParams","functionsWhitelist","Array","Boolean","functionsList","deployCommand","learnMoreLink","troubleshootingLink","fn","exitHook","console","coreApp","coreStackOutput","chalk","deploymentId","iotEndpointTopic","iotEndpoint","getIotEndpoint","sessionId","Date","increaseTimeout","localExecutionHandshakeTimeout","replaceLambdaFunctions","inspector","initInvocationForwarding","awsWatch","Watch","GetApp","LoggerService","ListAppLambdaFunctionsService","UiService","PulumiGetStackOutputService","PulumiExportService","WatchedLambdaFunctionsService","ProjectSdkParamsService"],"mappings":";;;;;AAkBO,MAAMA;IACT,YACYC,MAAwB,EACxBC,MAA+B,EAC/BC,6BAAsE,EACtEC,EAAuB,EACvBC,2BAAkE,EAClEC,mBAAkD,EAClDC,6BAAsE,EACtEC,uBAA0D,EAC1DC,SAA0B,CACpC;aATUR,MAAM,GAANA;aACAC,MAAM,GAANA;aACAC,6BAA6B,GAA7BA;aACAC,EAAE,GAAFA;aACAC,2BAA2B,GAA3BA;aACAC,mBAAmB,GAAnBA;aACAC,6BAA6B,GAA7BA;aACAC,uBAAuB,GAAvBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QAAQC,MAAoB,EAAyB;QAEvD,IAAI,SAASA,UAAUA,OAAO,eAAe,IAAIA,OAAO,eAAe,GAAG,KACtE,MAAM,IAAIC,MACN;QAIR,MAAMC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACF;QAG5C,IAAI,CAAE,UAASA,MAAK,GAChB,OAAOE;QAGX,MAAMC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAACH,OAAO,GAAG;QAC1C,MAAMI,YAAY,IAAI,CAAC,uBAAuB,CAAC,GAAG;QAClD,MAAMV,KAAK,IAAI,CAAC,EAAE;QAClB,MAAMF,SAAS,IAAI,CAAC,MAAM;QAE1B,MAAMa,qBAAqBC,MAAM,OAAO,CAACN,OAAO,QAAQ,IAClDA,OAAO,QAAQ,GACd;YAACA,OAAO,QAAQ;SAAC,CAAC,MAAM,CAACO;QAEhC,MAAMC,gBAAgB,MAAM,IAAI,CAAC,6BAA6B,CAAC,OAAO,CAACL,KAAK;YACxE,WAAWE;QACf;QAEA,MAAMI,g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wB,IAAI;QAE1E0B,uBAAuB;YACnBvB;YACAe;YACA,cAAc;gBACV,WAAWxB;gBACX,eAAeF;gBACf,qBAAqB,IAAI,CAAC,mBAAmB;gBAC7C,+BAA+B,IAAI,CAAC,6BAA6B;YACrE;YACA4B;YACAD;YACAG;YACAd;YACAgB;YACAC;QACJ;QAEA,IAAIE;QACJ,IAAI3B,OAAO,OAAO,EAAE;YAChB2B,YAAY,MAAM,MAAM,CAAC;YACzBA,UAAW,IAAI,CAAC,MAAM;YACtBjC,GAAG,SAAS;YAEZmB,SAAS;gBACLc,UAAW,KAAK;YACpB;QACJ;QAEAC,yBAAyB;YACrBR;YACAD;YACAX;YACAc;QACJ;QAEA,OAAOpB;IACX;AACJ;AAEO,MAAM2B,WAAWC,MAAM,eAAe,CAAC;IAC1C,WAAWxC;IACX,cAAc;QACVyC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"features/Watch/AwsWatch.js","sources":["../../../src/features/Watch/AwsWatch.ts"],"sourcesContent":["import {\n GetApp,\n ListAppLambdaFunctionsService,\n LoggerService,\n ProjectSdkParamsService,\n PulumiExportService,\n PulumiGetStackOutputService,\n UiService,\n Watch,\n WatchedLambdaFunctionsService\n} from \"@webiny/project/abstractions/index.js\";\nimport chalk from \"chalk\";\nimport type inspectorType from \"inspector\";\nimport { type ICoreStackOutput } from \"@webiny/project/abstractions/features/GetAppStackOutput.js\";\n\nexport class AwsWatch implements Watch.Interface {\n constructor(\n private getApp: GetApp.Interface,\n private logger: LoggerService.Interface,\n private listAppLambdaFunctionsService: ListAppLambdaFunctionsService.Interface,\n private ui: UiService.Interface,\n private pulumiGetStackOutputService: PulumiGetStackOutputService.Interface,\n private pulumiExportService: PulumiExportService.Interface,\n private watchedLambdaFunctionsService: WatchedLambdaFunctionsService.Interface,\n private projectSdkParamsService: ProjectSdkParamsService.Interface,\n private decoratee: Watch.Interface\n ) {}\n\n async execute(params: Watch.Params): Promise<Watch.Result> {\n // Validate Lambda-specific params before the base runs workspace build.\n if (\"app\" in params && params.increaseTimeout && params.increaseTimeout > 900) {\n throw new Error(\n `When increasing the timeout, the maximum value that can be passed is 900 seconds (15 minutes).`\n );\n }\n\n const result = await this.decoratee.execute(params);\n\n // No Lambda machinery for package-only watch.\n if (!(\"app\" in params)) {\n return result;\n }\n\n const app = this.getApp.execute(params.app);\n const sdkParams = this.projectSdkParamsService.get();\n const ui = this.ui;\n const logger = this.logger;\n\n const functionsWhitelist = Array.isArray(params.function)\n ? params.function\n : ([params.function].filter(Boolean) as string[]);\n\n const functionsList = await this.listAppLambdaFunctionsService.execute(app, {\n whitelist: functionsWhitelist\n });\n\n const deployCommand = `yarn webiny deploy ${app.name} --env ${sdkParams.env}`;\n const learnMoreLink = \"https://webiny.link/local-aws-lambda-development\";\n const troubleshootingLink = learnMoreLink + \"#troubleshooting\";\n\n if (functionsList.meta.count === 0) {\n if (functionsList.meta.totalCount > 0) {\n ui.info(\n [\n \"No AWS Lambda functions will be invoked locally. If this is unexpected, you can try the following:\",\n \" ‣ stop the current development session\",\n \" ‣ redeploy the %s application by running %s command\",\n \" ‣ start a new %s session by rerunning %s command\",\n \"\",\n \"Learn more: %s\"\n ].join(\"\\n\"),\n app.name,\n deployCommand,\n \"webiny watch\",\n \"webiny watch\",\n troubleshootingLink\n );\n }\n return result;\n }\n\n ui.info(`Local AWS Lambda development session started.`);\n ui.warning(\n `Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,\n app.getDisplayName(),\n \"MUST\",\n deployCommand,\n learnMoreLink\n );\n\n logger.debug(\n \"The events for following AWS Lambda functions will be forwarded locally: \",\n functionsList.list.map(fn => fn.name)\n );\n\n ui.emptyLine();\n const { default: exitHook } = await import(/* webpackChunkName: \"exit-hook\" */ \"exit-hook\");\n\n exitHook(() => {\n console.log();\n console.log();\n\n ui.info(`Terminating local AWS Lambda development session.`);\n ui.warning(\n `Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,\n app?.getDisplayName(),\n \"MUST\",\n deployCommand,\n learnMoreLink\n );\n });\n\n const coreApp = this.getApp.execute(\"core\");\n const coreStackOutput =\n await this.pulumiGetStackOutputService.execute<ICoreStackOutput>(coreApp);\n\n if (!coreStackOutput) {\n throw new Error(\n `You must deploy the ${chalk.bold(\n \"core\"\n )} app before you can start a watch session. To do that, run: ${chalk.bold(\n `yarn webiny deploy core --env ${sdkParams.env}`\n )}`\n );\n }\n\n const deploymentId = coreStackOutput?.deploymentId;\n const iotEndpointTopic = `webiny-watch-${deploymentId}`;\n // Loaded here rather than at the top of the file. This decorator is registered for every\n // command, and these pull in the AWS IoT and Lambda clients and mqtt, which only a watch\n // session needs.\n const { getIotEndpoint } = await import(\"./getIotEndpoint.js\");\n const { replaceLambdaFunctions } = await import(\"./replaceLambdaFunctions.js\");\n const { initInvocationForwarding } =\n await import(\"@webiny/project/features/Watch/initInvocationForwarding.js\");\n\n const iotEndpoint = await getIotEndpoint(coreStackOutput);\n\n const sessionId = new Date().getTime();\n const increaseTimeout = params.increaseTimeout;\n const localExecutionHandshakeTimeout = params.increaseHandshakeTimeout || 5;\n\n replaceLambdaFunctions({\n app,\n deploymentId,\n dependencies: {\n uiService: ui,\n loggerService: logger,\n pulumiExportService: this.pulumiExportService,\n watchedLambdaFunctionsService: this.watchedLambdaFunctionsService\n },\n iotEndpoint,\n iotEndpointTopic,\n sessionId,\n functionsList,\n increaseTimeout,\n localExecutionHandshakeTimeout\n });\n\n let inspector: typeof inspectorType | undefined = undefined;\n if (params.inspect) {\n inspector = await import(\"inspector\");\n inspector!.open(9229, \"127.0.0.1\");\n ui.emptyLine();\n\n exitHook(() => {\n inspector!.close();\n });\n }\n\n initInvocationForwarding({\n iotEndpoint,\n iotEndpointTopic,\n functionsList,\n sessionId\n });\n\n return result;\n }\n}\n\nexport const awsWatch = Watch.createDecorator({\n decorator: AwsWatch,\n dependencies: [\n GetApp,\n LoggerService,\n ListAppLambdaFunctionsService,\n UiService,\n PulumiGetStackOutputService,\n PulumiExportService,\n WatchedLambdaFunctionsService,\n ProjectSdkParamsService\n ]\n});\n"],"names":["AwsWatch","getApp","logger","listAppLambdaFunctionsService","ui","pulumiGetStackOutputService","pulumiExportService","watchedLambdaFunctionsService","projectSdkParamsService","decoratee","params","Error","result","app","sdkParams","functionsWhitelist","Array","Boolean","functionsList","deployCommand","learnMoreLink","troubleshootingLink","fn","exitHook","console","coreApp","coreStackOutput","chalk","deploymentId","iotEndpointTopic","getIotEndpoint","replaceLambdaFunctions","initInvocationForwarding","iotEndpoint","sessionId","Date","increaseTimeout","localExecutionHandshakeTimeout","inspector","awsWatch","Watch","GetApp","LoggerService","ListAppLambdaFunctionsService","UiService","PulumiGetStackOutputService","PulumiExportService","WatchedLambdaFunctionsService","ProjectSdkParamsService"],"mappings":";;AAeO,MAAMA;IACT,YACYC,MAAwB,EACxBC,MAA+B,EAC/BC,6BAAsE,EACtEC,EAAuB,EACvBC,2BAAkE,EAClEC,mBAAkD,EAClDC,6BAAsE,EACtEC,uBAA0D,EAC1DC,SAA0B,CACpC;aATUR,MAAM,GAANA;aACAC,MAAM,GAANA;aACAC,6BAA6B,GAA7BA;aACAC,EAAE,GAAFA;aACAC,2BAA2B,GAA3BA;aACAC,mBAAmB,GAAnBA;aACAC,6BAA6B,GAA7BA;aACAC,uBAAuB,GAAvBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QAAQC,MAAoB,EAAyB;QAEvD,IAAI,SAASA,UAAUA,OAAO,eAAe,IAAIA,OAAO,eAAe,GAAG,KACtE,MAAM,IAAIC,MACN;QAIR,MAAMC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACF;QAG5C,IAAI,CAAE,UAASA,MAAK,GAChB,OAAOE;QAGX,MAAMC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAACH,OAAO,GAAG;QAC1C,MAAMI,YAAY,IAAI,CAAC,uBAAuB,C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AI,CAC7B,QACF,4DAA4D,EAAEA,MAAM,IAAI,CACtE,CAAC,8BAA8B,EAAEb,UAAU,GAAG,EAAE,GACjD;QAIX,MAAMc,eAAeF,iBAAiB;QACtC,MAAMG,mBAAmB,CAAC,aAAa,EAAED,cAAc;QAIvD,MAAM,EAAEE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC;QACxC,MAAM,EAAEC,sBAAsB,EAAE,GAAG,MAAM,MAAM,CAAC;QAChD,MAAM,EAAEC,wBAAwB,EAAE,GAC9B,MAAM,MAAM,CAAC;QAEjB,MAAMC,cAAc,MAAMH,eAAeJ;QAEzC,MAAMQ,YAAY,IAAIC,OAAO,OAAO;QACpC,MAAMC,kBAAkB1B,OAAO,eAAe;QAC9C,MAAM2B,iCAAiC3B,OAAO,wBAAwB,IAAI;QAE1EqB,uBAAuB;YACnBlB;YACAe;YACA,cAAc;gBACV,WAAWxB;gBACX,eAAeF;gBACf,qBAAqB,IAAI,CAAC,mBAAmB;gBAC7C,+BAA+B,IAAI,CAAC,6BAA6B;YACrE;YACA+B;YACAJ;YACAK;YACAhB;YACAkB;YACAC;QACJ;QAEA,IAAIC;QACJ,IAAI5B,OAAO,OAAO,EAAE;YAChB4B,YAAY,MAAM,MAAM,CAAC;YACzBA,UAAW,IAAI,CAAC,MAAM;YACtBlC,GAAG,SAAS;YAEZmB,SAAS;gBACLe,UAAW,KAAK;YACpB;QACJ;QAEAN,yBAAyB;YACrBC;YACAJ;YACAX;YACAgB;QACJ;QAEA,OAAOtB;IACX;AACJ;AAEO,MAAM2B,WAAWC,MAAM,eAAe,CAAC;IAC1C,WAAWxC;IACX,cAAc;QACVyC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/project-aws",
3
- "version": "0.0.0-unstable.0d717d18dd",
3
+ "version": "0.0.0-unstable.5387e5f7c8",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -17,18 +17,18 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@pulumi/aws": "^7.40.0",
21
- "@pulumi/pulumi": "^3.255.0",
20
+ "@pulumi/aws": "^7.43.0",
21
+ "@pulumi/pulumi": "^3.259.0",
22
22
  "@pulumi/random": "4.21.1",
23
- "@webiny/aws-layers": "0.0.0-unstable.0d717d18dd",
24
- "@webiny/aws-sdk": "0.0.0-unstable.0d717d18dd",
25
- "@webiny/cli-core": "0.0.0-unstable.0d717d18dd",
26
- "@webiny/di": "1.0.2",
27
- "@webiny/global-config": "0.0.0-unstable.0d717d18dd",
28
- "@webiny/project": "0.0.0-unstable.0d717d18dd",
29
- "@webiny/pulumi": "0.0.0-unstable.0d717d18dd",
30
- "@webiny/pulumi-sdk": "0.0.0-unstable.0d717d18dd",
31
- "@webiny/utils": "0.0.0-unstable.0d717d18dd",
23
+ "@webiny/aws-layers": "0.0.0-unstable.5387e5f7c8",
24
+ "@webiny/aws-sdk": "0.0.0-unstable.5387e5f7c8",
25
+ "@webiny/cli-core": "0.0.0-unstable.5387e5f7c8",
26
+ "@webiny/di": "2.0.0",
27
+ "@webiny/global-config": "0.0.0-unstable.5387e5f7c8",
28
+ "@webiny/project": "0.0.0-unstable.5387e5f7c8",
29
+ "@webiny/pulumi": "0.0.0-unstable.5387e5f7c8",
30
+ "@webiny/pulumi-sdk": "0.0.0-unstable.5387e5f7c8",
31
+ "@webiny/utils": "0.0.0-unstable.5387e5f7c8",
32
32
  "chalk": "6.0.0",
33
33
  "email-addresses": "5.0.0",
34
34
  "exit-hook": "5.1.0",
@@ -45,9 +45,9 @@
45
45
  "devDependencies": {
46
46
  "@types/lodash": "4.17.25",
47
47
  "@types/ncp": "2.0.8",
48
- "@webiny/build-tools": "0.0.0-unstable.0d717d18dd",
48
+ "@webiny/build-tools": "0.0.0-unstable.5387e5f7c8",
49
49
  "typescript": "7.0.2",
50
- "vitest": "4.1.10"
50
+ "vitest": "4.1.11"
51
51
  },
52
52
  "adio": {
53
53
  "ignoreDirs": [