@webiny/project-aws 6.4.12-beta.6 → 6.4.12-beta.7

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.
@@ -11,7 +11,7 @@ const BackgroundTasks = defineExtension({
11
11
  runtimeContext: "project"
12
12
  },
13
13
  description: "Configure default settings for background tasks. The retention value is used as the default when no admin has explicitly set a value via the Settings UI.",
14
- paramsSchema: paramsSchema,
14
+ paramsSchema,
15
15
  render (params) {
16
16
  return /*#__PURE__*/ react.createElement(BuildParam, {
17
17
  paramName: "BackgroundTasks.RetentionDays",
@@ -1 +1 @@
1
- {"version":3,"file":"extensions/BackgroundTasks.js","sources":["../../src/extensions/BackgroundTasks.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { defineExtension } from \"@webiny/project/defineExtension/index.js\";\nimport { BuildParam } from \"@webiny/project/extensions/index.js\";\n\nconst paramsSchema = z.object({\n retentionDays: z\n .number()\n .int()\n .min(0)\n .max(3650)\n .describe(\n \"Default retention period (in days) for completed background task runs. 0 = never delete. Max 3650.\"\n )\n});\n\nexport const BackgroundTasks = defineExtension({\n type: \"Api/BackgroundTasks\",\n tags: { runtimeContext: \"project\" },\n description:\n \"Configure default settings for background tasks. The retention value is used as the default when no admin has explicitly set a value via the Settings UI.\",\n paramsSchema,\n render(params) {\n return (\n <BuildParam paramName=\"BackgroundTasks.RetentionDays\" value={params.retentionDays} />\n );\n }\n});\n"],"names":["paramsSchema","z","BackgroundTasks","defineExtension","params","BuildParam"],"mappings":";;;;AAKA,MAAMA,eAAeC,EAAE,MAAM,CAAC;IAC1B,eAAeA,EAAAA,MACJ,GACN,GAAG,GACH,GAAG,CAAC,GACJ,GAAG,CAAC,MACJ,QAAQ,CACL;AAEZ;AAEO,MAAMC,kBAAkBC,gBAAgB;IAC3C,MAAM;IACN,MAAM;QAAE,gBAAgB;IAAU;IAClC,aACI;IACJH,cAAAA;IACA,QAAOI,MAAM;QACT,OAAO,WAAP,GACI,oBAACC,YAAUA;YAAC,WAAU;YAAgC,OAAOD,OAAO,aAAa;;IAEzF;AACJ"}
1
+ {"version":3,"file":"extensions/BackgroundTasks.js","sources":["../../src/extensions/BackgroundTasks.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { defineExtension } from \"@webiny/project/defineExtension/index.js\";\nimport { BuildParam } from \"@webiny/project/extensions/index.js\";\n\nconst paramsSchema = z.object({\n retentionDays: z\n .number()\n .int()\n .min(0)\n .max(3650)\n .describe(\n \"Default retention period (in days) for completed background task runs. 0 = never delete. Max 3650.\"\n )\n});\n\nexport const BackgroundTasks = defineExtension({\n type: \"Api/BackgroundTasks\",\n tags: { runtimeContext: \"project\" },\n description:\n \"Configure default settings for background tasks. The retention value is used as the default when no admin has explicitly set a value via the Settings UI.\",\n paramsSchema,\n render(params) {\n return (\n <BuildParam paramName=\"BackgroundTasks.RetentionDays\" value={params.retentionDays} />\n );\n }\n});\n"],"names":["paramsSchema","z","BackgroundTasks","defineExtension","params","BuildParam"],"mappings":";;;;AAKA,MAAMA,eAAeC,EAAE,MAAM,CAAC;IAC1B,eAAeA,EAAAA,MACJ,GACN,GAAG,GACH,GAAG,CAAC,GACJ,GAAG,CAAC,MACJ,QAAQ,CACL;AAEZ;AAEO,MAAMC,kBAAkBC,gBAAgB;IAC3C,MAAM;IACN,MAAM;QAAE,gBAAgB;IAAU;IAClC,aACI;IACJH;IACA,QAAOI,MAAM;QACT,OAAO,WAAP,GACI,oBAACC,YAAUA;YAAC,WAAU;YAAgC,OAAOD,OAAO,aAAa;;IAEzF;AACJ"}
@@ -11,7 +11,7 @@ const ModelFieldCompression = defineExtension({
11
11
  runtimeContext: "project"
12
12
  },
13
13
  description: "Enable or disable compression of Headless CMS model fields at the database storage level.",
14
- paramsSchema: paramsSchema,
14
+ paramsSchema,
15
15
  render (params) {
16
16
  return /*#__PURE__*/ react.createElement(BuildParam, {
17
17
  paramName: "ContentModelFieldCompression",
@@ -1 +1 @@
1
- {"version":3,"file":"extensions/Cms/ModelFieldCompression.js","sources":["../../../src/extensions/Cms/ModelFieldCompression.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { defineExtension } from \"@webiny/project/defineExtension/index.js\";\nimport { BuildParam } from \"@webiny/project/extensions/index.js\";\n\nconst paramsSchema = z.object({\n enabled: z\n .boolean()\n .describe(\"Enable compression of model fields before storing in the database.\")\n});\n\nexport const ModelFieldCompression = defineExtension({\n type: \"Api/Cms/ModelFieldCompression\",\n tags: { runtimeContext: \"project\" },\n description:\n \"Enable or disable compression of Headless CMS model fields at the database storage level.\",\n paramsSchema,\n render(params) {\n return <BuildParam paramName=\"ContentModelFieldCompression\" value={params.enabled} />;\n }\n});\n"],"names":["paramsSchema","z","ModelFieldCompression","defineExtension","params","BuildParam"],"mappings":";;;;AAKA,MAAMA,eAAeC,EAAE,MAAM,CAAC;IAC1B,SAASA,EAAAA,OACG,GACP,QAAQ,CAAC;AAClB;AAEO,MAAMC,wBAAwBC,gBAAgB;IACjD,MAAM;IACN,MAAM;QAAE,gBAAgB;IAAU;IAClC,aACI;IACJH,cAAAA;IACA,QAAOI,MAAM;QACT,OAAO,WAAP,GAAO,oBAACC,YAAUA;YAAC,WAAU;YAA+B,OAAOD,OAAO,OAAO;;IACrF;AACJ"}
1
+ {"version":3,"file":"extensions/Cms/ModelFieldCompression.js","sources":["../../../src/extensions/Cms/ModelFieldCompression.tsx"],"sourcesContent":["import React from \"react\";\nimport { z } from \"zod\";\nimport { defineExtension } from \"@webiny/project/defineExtension/index.js\";\nimport { BuildParam } from \"@webiny/project/extensions/index.js\";\n\nconst paramsSchema = z.object({\n enabled: z\n .boolean()\n .describe(\"Enable compression of model fields before storing in the database.\")\n});\n\nexport const ModelFieldCompression = defineExtension({\n type: \"Api/Cms/ModelFieldCompression\",\n tags: { runtimeContext: \"project\" },\n description:\n \"Enable or disable compression of Headless CMS model fields at the database storage level.\",\n paramsSchema,\n render(params) {\n return <BuildParam paramName=\"ContentModelFieldCompression\" value={params.enabled} />;\n }\n});\n"],"names":["paramsSchema","z","ModelFieldCompression","defineExtension","params","BuildParam"],"mappings":";;;;AAKA,MAAMA,eAAeC,EAAE,MAAM,CAAC;IAC1B,SAASA,EAAAA,OACG,GACP,QAAQ,CAAC;AAClB;AAEO,MAAMC,wBAAwBC,gBAAgB;IACjD,MAAM;IACN,MAAM;QAAE,gBAAgB;IAAU;IAClC,aACI;IACJH;IACA,QAAOI,MAAM;QACT,OAAO,WAAP,GAAO,oBAACC,YAAUA;YAAC,WAAU;YAA+B,OAAOD,OAAO,OAAO;;IACrF;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/project-aws",
3
- "version": "6.4.12-beta.6",
3
+ "version": "6.4.12-beta.7",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -17,34 +17,34 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@pulumi/aws": "^7.47.0",
21
- "@pulumi/pulumi": "^3.263.0",
22
- "@pulumi/random": "4.21.2",
23
- "@webiny/api-headless-cms": "6.4.12-beta.6",
24
- "@webiny/aws-layers": "6.4.12-beta.6",
25
- "@webiny/aws-sdk": "6.4.12-beta.6",
26
- "@webiny/cli-core": "6.4.12-beta.6",
20
+ "@pulumi/aws": "^7.54.0",
21
+ "@pulumi/pulumi": "^3.274.1",
22
+ "@pulumi/random": "4.21.6",
23
+ "@webiny/api-headless-cms": "6.4.12-beta.7",
24
+ "@webiny/aws-layers": "6.4.12-beta.7",
25
+ "@webiny/aws-sdk": "6.4.12-beta.7",
26
+ "@webiny/cli-core": "6.4.12-beta.7",
27
27
  "@webiny/di": "1.1.0",
28
- "@webiny/project": "6.4.12-beta.6",
29
- "@webiny/pulumi": "6.4.12-beta.6",
30
- "@webiny/utils": "6.4.12-beta.6",
31
- "chalk": "6.0.0",
28
+ "@webiny/project": "6.4.12-beta.7",
29
+ "@webiny/pulumi": "6.4.12-beta.7",
30
+ "@webiny/utils": "6.4.12-beta.7",
31
+ "chalk": "6.0.1",
32
32
  "email-addresses": "5.0.0",
33
33
  "find-up": "8.0.0",
34
34
  "invariant": "2.2.4",
35
35
  "lodash": "4.18.1",
36
- "mime": "4.1.0",
36
+ "mime": "4.1.2",
37
37
  "react": "18.3.1",
38
38
  "replace-in-path": "1.1.0",
39
39
  "ts-morph": "28.0.0",
40
- "zod": "4.6.5"
40
+ "zod": "4.6.7"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/lodash": "4.17.25",
43
+ "@types/lodash": "4.17.27",
44
44
  "@types/ncp": "2.0.8",
45
- "@webiny/build-tools": "6.4.12-beta.6",
45
+ "@webiny/build-tools": "6.4.12-beta.7",
46
46
  "typescript": "6.0.3",
47
- "vitest": "5.0.1"
47
+ "vitest": "5.1.0"
48
48
  },
49
49
  "adio": {
50
50
  "ignoreDirs": [
@@ -171,7 +171,7 @@ const configureS3BucketMalwareProtection = (app)=>{
171
171
  }
172
172
  }
173
173
  });
174
- app.addResource(__rspack_external__pulumi_aws_9e2bee2d.iam.RolePolicyAttachment, {
174
+ const attachment = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.iam.RolePolicyAttachment, {
175
175
  name: "fm-bucket-malware-protection-role-policy-attachment",
176
176
  config: {
177
177
  role: role.output.name,
@@ -187,6 +187,11 @@ const configureS3BucketMalwareProtection = (app)=>{
187
187
  bucketName: bucket.bucket
188
188
  }
189
189
  }
190
+ },
191
+ opts: {
192
+ dependsOn: [
193
+ attachment.output
194
+ ]
190
195
  }
191
196
  });
192
197
  const eventBridgeRole = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.iam.Role, {
@@ -206,7 +211,7 @@ const configureS3BucketMalwareProtection = (app)=>{
206
211
  })
207
212
  }
208
213
  });
209
- app.addResource(__rspack_external__pulumi_aws_9e2bee2d.iam.RolePolicy, {
214
+ const forwardEventsPolicy = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.iam.RolePolicy, {
210
215
  name: "guard-duty-forward-events-policy",
211
216
  config: {
212
217
  role: eventBridgeRole.output,
@@ -250,6 +255,11 @@ const configureS3BucketMalwareProtection = (app)=>{
250
255
  roleArn: eventBridgeRole.output.arn,
251
256
  eventBusName: "default",
252
257
  arn: eventBus.output.arn
258
+ },
259
+ opts: {
260
+ dependsOn: [
261
+ forwardEventsPolicy.output
262
+ ]
253
263
  }
254
264
  });
255
265
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pulumi/apps/core/configureS3BucketMalwareProtection.js","sources":["../../../../src/pulumi/apps/core/configureS3BucketMalwareProtection.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport type { CorePulumiApp } from \"~/pulumi/apps/core/index.js\";\nimport { getAwsAccountId, getAwsRegion } from \"~/pulumi/apps/awsUtils.js\";\n\nexport const configureS3BucketMalwareProtection = (app: CorePulumiApp) => {\n const awsAccountId = getAwsAccountId(app);\n const awsRegion = getAwsRegion(app);\n const eventBus = app.resources.eventBus;\n\n const bucket = app.resources.fileManagerBucket.output;\n\n const currentAccount = {\n StringEquals: {\n \"aws:ResourceAccount\": awsAccountId\n }\n };\n\n const managedByGuardDuty = {\n StringEquals: {\n \"events:ManagedBy\": \"malware-protection-plan.guardduty.amazonaws.com\"\n }\n };\n\n const assumeRole = aws.iam.getPolicyDocument({\n statements: [\n {\n effect: \"Allow\",\n principals: [\n {\n type: \"Service\",\n identifiers: [\"malware-protection-plan.guardduty.amazonaws.com\"]\n }\n ],\n actions: [\"sts:AssumeRole\"]\n }\n ]\n });\n\n const role = app.addResource(aws.iam.Role, {\n name: \"fm-bucket-guardduty-role\",\n config: {\n assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json)\n }\n });\n\n const policy = app.addResource(aws.iam.Policy, {\n name: `fm-bucket-guardduty-role-policy`,\n config: {\n description: \"This policy enables GuardDuty to interact with the S3 bucket.\",\n policy: {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"AllowManagedRuleToSendS3EventsToGuardDuty\",\n Effect: \"Allow\",\n Action: [\"events:PutRule\"],\n Resource: [\n pulumi.interpolate`arn:aws:events:${awsRegion}:${awsAccountId}:rule/DO-NOT-DELETE-AmazonGuardDutyMalwareProtectionS3*`\n ],\n Condition: {\n ...managedByGuardDuty,\n \"ForAllValues:StringEquals\": {\n \"events:source\": \"aws.s3\",\n \"events:detail-type\": [\n \"Object Created\",\n \"AWS API Call via CloudTrail\"\n ]\n },\n Null: {\n \"events:source\": \"false\",\n \"events:detail-type\": \"false\"\n }\n }\n },\n {\n Sid: \"AllowUpdateTargetAndDeleteManagedRule\",\n Effect: \"Allow\",\n Action: [\"events:DeleteRule\", \"events:PutTargets\", \"events:RemoveTargets\"],\n Resource: [\n pulumi.interpolate`arn:aws:events:${awsRegion}:${awsAccountId}:rule/DO-NOT-DELETE-AmazonGuardDutyMalwareProtectionS3*`\n ],\n Condition: {\n ...managedByGuardDuty\n }\n },\n {\n Sid: \"AllowGuardDutyToMonitorEventBridgeManagedRule\",\n Effect: \"Allow\",\n Action: [\"events:DescribeRule\", \"events:ListTargetsByRule\"],\n Resource: [\n pulumi.interpolate`arn:aws:events:${awsRegion}:${awsAccountId}:rule/DO-NOT-DELETE-AmazonGuardDutyMalwareProtectionS3*`\n ]\n },\n {\n Sid: \"AllowPostScanTag\",\n Effect: \"Allow\",\n Action: [\n \"s3:GetObjectTagging\",\n \"s3:GetObjectVersionTagging\",\n \"s3:PutObjectTagging\",\n \"s3:PutObjectVersionTagging\"\n ],\n Resource: [pulumi.interpolate`arn:aws:s3:::${bucket.bucket}/*`],\n Condition: {\n ...currentAccount\n }\n },\n {\n Sid: \"AllowEnableS3EventBridgeEvents\",\n Effect: \"Allow\",\n Action: [\"s3:PutBucketNotification\", \"s3:GetBucketNotification\"],\n Resource: [pulumi.interpolate`arn:aws:s3:::${bucket.bucket}`],\n Condition: {\n ...currentAccount\n }\n },\n {\n Sid: \"AllowPutValidationObject\",\n Effect: \"Allow\",\n Action: [\"s3:PutObject\"],\n Resource: [\n pulumi.interpolate`arn:aws:s3:::${bucket.bucket}/malware-protection-resource-validation-object`\n ],\n Condition: {\n ...currentAccount\n }\n },\n {\n Sid: \"AllowCheckBucketOwnership\",\n Effect: \"Allow\",\n Action: [\"s3:ListBucket\"],\n Resource: [pulumi.interpolate`arn:aws:s3:::${bucket.bucket}`],\n Condition: {\n ...currentAccount\n }\n },\n {\n Sid: \"AllowMalwareScan\",\n Effect: \"Allow\",\n Action: [\"s3:GetObject\", \"s3:GetObjectVersion\"],\n Resource: [pulumi.interpolate`arn:aws:s3:::${bucket.bucket}/*`],\n Condition: {\n ...currentAccount\n }\n }\n ]\n }\n }\n });\n\n app.addResource(aws.iam.RolePolicyAttachment, {\n name: `fm-bucket-malware-protection-role-policy-attachment`,\n config: {\n role: role.output.name,\n policyArn: policy.output.arn\n }\n });\n\n app.addResource(aws.guardduty.MalwareProtectionPlan, {\n name: `fm-bucket-malware-protection-plan`,\n config: {\n role: role.output.arn,\n protectedResource: {\n s3Bucket: {\n bucketName: bucket.bucket\n }\n }\n }\n });\n\n // FORWARD EVENTS FROM \"DEFAULT\" TO CUSTOM EVENT BUS.\n\n // Create an IAM Role for EventBridge to forward events\n const eventBridgeRole = app.addResource(aws.iam.Role, {\n name: \"guard-duty-forward-events-role\",\n config: {\n assumeRolePolicy: JSON.stringify({\n Version: \"2012-10-17\",\n Statement: [\n {\n Effect: \"Allow\",\n Principal: { Service: \"events.amazonaws.com\" },\n Action: \"sts:AssumeRole\"\n }\n ]\n })\n }\n });\n\n // Attach Policy to Allow EventBridge to PutEvents on Custom Event Bus\n app.addResource(aws.iam.RolePolicy, {\n name: \"guard-duty-forward-events-policy\",\n config: {\n role: eventBridgeRole.output,\n policy: pulumi.output(eventBus.output.arn).apply(arn =>\n JSON.stringify({\n Version: \"2012-10-17\",\n Statement: [\n {\n Effect: \"Allow\",\n Action: \"events:PutEvents\",\n Resource: arn\n }\n ]\n })\n )\n }\n });\n\n const forwardToCustomBusRule = app.addResource(aws.cloudwatch.EventRule, {\n name: \"forward-events-from-default-to-custom-bus-rule\",\n config: {\n eventBusName: \"default\",\n eventPattern: bucket.bucket.apply(name =>\n JSON.stringify({\n source: [\"aws.guardduty\"],\n \"detail-type\": [\"GuardDuty Malware Protection Object Scan Result\"],\n detail: {\n s3ObjectDetails: {\n bucketName: [name]\n }\n }\n })\n )\n }\n });\n\n // Target: Send events to the custom event bus\n app.addResource(aws.cloudwatch.EventTarget, {\n name: \"forward-events-from-default-to-custom-bus-target\",\n config: {\n rule: forwardToCustomBusRule.output.name,\n roleArn: eventBridgeRole.output.arn,\n eventBusName: \"default\",\n arn: eventBus.output.arn\n }\n });\n};\n"],"names":["configureS3BucketMalwareProtection","app","awsAccountId","getAwsAccountId","awsRegion","getAwsRegion","eventBus","bucket","currentAccount","managedByGuardDuty","assumeRole","aws","role","policy","pulumi","eventBridgeRole","JSON","arn","forwardToCustomBusRule","name"],"mappings":";;;AAKO,MAAMA,qCAAqC,CAACC;IAC/C,MAAMC,eAAeC,gBAAgBF;IACrC,MAAMG,YAAYC,aAAaJ;IAC/B,MAAMK,WAAWL,IAAI,SAAS,CAAC,QAAQ;IAEvC,MAAMM,SAASN,IAAI,SAAS,CAAC,iBAAiB,CAAC,MAAM;IAErD,MAAMO,iBAAiB;QACnB,cAAc;YACV,uBAAuBN;QAC3B;IACJ;IAEA,MAAMO,qBAAqB;QACvB,cAAc;YACV,oBAAoB;QACxB;IACJ;IAEA,MAAMC,aAAaC,uCAAAA,GAAAA,CAAAA,iBAAyB,CAAC;QACzC,YAAY;YACR;gBACI,QAAQ;gBACR,YAAY;oBACR;wBACI,MAAM;wBACN,aAAa;4BAAC;yBAAkD;oBACpE;iBACH;gBACD,SAAS;oBAAC;iBAAiB;YAC/B;SACH;IACL;IAEA,MAAMC,OAAOX,IAAI,WAAW,CAACU,uCAAAA,GAAAA,CAAAA,IAAY,EAAE;QACvC,MAAM;QACN,QAAQ;YACJ,k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AM;QACN,QAAQ;YACJ,kBAAkBK,KAAK,SAAS,CAAC;gBAC7B,SAAS;gBACT,WAAW;oBACP;wBACI,QAAQ;wBACR,WAAW;4BAAE,SAAS;wBAAuB;wBAC7C,QAAQ;oBACZ;iBACH;YACL;QACJ;IACJ;IAGAf,IAAI,WAAW,CAACU,uCAAAA,GAAAA,CAAAA,UAAkB,EAAE;QAChC,MAAM;QACN,QAAQ;YACJ,MAAMI,gBAAgB,MAAM;YAC5B,QAAQD,0CAAAA,MAAa,CAACR,SAAS,MAAM,CAAC,GAAG,EAAE,KAAK,CAACW,CAAAA,MAC7CD,KAAK,SAAS,CAAC;oBACX,SAAS;oBACT,WAAW;wBACP;4BACI,QAAQ;4BACR,QAAQ;4BACR,UAAUC;wBACd;qBACH;gBACL;QAER;IACJ;IAEA,MAAMC,yBAAyBjB,IAAI,WAAW,CAACU,uCAAAA,UAAAA,CAAAA,SAAwB,EAAE;QACrE,MAAM;QACN,QAAQ;YACJ,cAAc;YACd,cAAcJ,OAAO,MAAM,CAAC,KAAK,CAACY,CAAAA,OAC9BH,KAAK,SAAS,CAAC;oBACX,QAAQ;wBAAC;qBAAgB;oBACzB,eAAe;wBAAC;qBAAkD;oBAClE,QAAQ;wBACJ,iBAAiB;4BACb,YAAY;gCAACG;6BAAK;wBACtB;oBACJ;gBACJ;QAER;IACJ;IAGAlB,IAAI,WAAW,CAACU,uCAAAA,UAAAA,CAAAA,WAA0B,EAAE;QACxC,MAAM;QACN,QAAQ;YACJ,MAAMO,uBAAuB,MAAM,CAAC,IAAI;YACxC,SAASH,gBAAgB,MAAM,CAAC,GAAG;YACnC,cAAc;YACd,KAAKT,SAAS,MAAM,CAAC,GAAG;QAC5B;IACJ;AACJ"}
1
+ {"version":3,"file":"pulumi/apps/core/configureS3BucketMalwareProtection.js","sources":["../../../../src/pulumi/apps/core/configureS3BucketMalwareProtection.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport type { CorePulumiApp } from \"~/pulumi/apps/core/index.js\";\nimport { getAwsAccountId, getAwsRegion } from \"~/pulumi/apps/awsUtils.js\";\n\nexport const configureS3BucketMalwareProtection = (app: CorePulumiApp) => {\n const awsAccountId = getAwsAccountId(app);\n const awsRegion = getAwsRegion(app);\n const eventBus = app.resources.eventBus;\n\n const bucket = app.resources.fileManagerBucket.output;\n\n const currentAccount = {\n StringEquals: {\n \"aws:ResourceAccount\": awsAccountId\n }\n };\n\n const managedByGuardDuty = {\n StringEquals: {\n \"events:ManagedBy\": \"malware-protection-plan.guardduty.amazonaws.com\"\n }\n };\n\n const assumeRole = aws.iam.getPolicyDocument({\n statements: [\n {\n effect: \"Allow\",\n principals: [\n {\n type: \"Service\",\n identifiers: [\"malware-protection-plan.guardduty.amazonaws.com\"]\n }\n ],\n actions: [\"sts:AssumeRole\"]\n }\n ]\n });\n\n const role = app.addResource(aws.iam.Role, {\n name: \"fm-bucket-guardduty-role\",\n config: {\n assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json)\n }\n });\n\n const policy = app.addResource(aws.iam.Policy, {\n name: `fm-bucket-guardduty-role-policy`,\n config: {\n description: \"This policy enables GuardDuty to interact with the S3 bucket.\",\n policy: {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"AllowManagedRuleToSendS3EventsToGuardDuty\",\n Effect: \"Allow\",\n Action: [\"events:PutRule\"],\n Resource: [\n pulumi.interpolate`arn:aws:events:${awsRegion}:${awsAccountId}:rule/DO-NOT-DELETE-AmazonGuardDutyMalwareProtectionS3*`\n ],\n Condition: {\n ...managedByGuardDuty,\n \"ForAllValues:StringEquals\": {\n \"events:source\": \"aws.s3\",\n \"events:detail-type\": [\n \"Object Created\",\n \"AWS API Call via CloudTrail\"\n ]\n },\n Null: {\n \"events:source\": \"false\",\n \"events:detail-type\": \"false\"\n }\n }\n },\n {\n Sid: \"AllowUpdateTargetAndDeleteManagedRule\",\n Effect: \"Allow\",\n Action: [\"events:DeleteRule\", \"events:PutTargets\", \"events:RemoveTargets\"],\n Resource: [\n pulumi.interpolate`arn:aws:events:${awsRegion}:${awsAccountId}:rule/DO-NOT-DELETE-AmazonGuardDutyMalwareProtectionS3*`\n ],\n Condition: {\n ...managedByGuardDuty\n }\n },\n {\n Sid: \"AllowGuardDutyToMonitorEventBridgeManagedRule\",\n Effect: \"Allow\",\n Action: [\"events:DescribeRule\", \"events:ListTargetsByRule\"],\n Resource: [\n pulumi.interpolate`arn:aws:events:${awsRegion}:${awsAccountId}:rule/DO-NOT-DELETE-AmazonGuardDutyMalwareProtectionS3*`\n ]\n },\n {\n Sid: \"AllowPostScanTag\",\n Effect: \"Allow\",\n Action: [\n \"s3:GetObjectTagging\",\n \"s3:GetObjectVersionTagging\",\n \"s3:PutObjectTagging\",\n \"s3:PutObjectVersionTagging\"\n ],\n Resource: [pulumi.interpolate`arn:aws:s3:::${bucket.bucket}/*`],\n Condition: {\n ...currentAccount\n }\n },\n {\n Sid: \"AllowEnableS3EventBridgeEvents\",\n Effect: \"Allow\",\n Action: [\"s3:PutBucketNotification\", \"s3:GetBucketNotification\"],\n Resource: [pulumi.interpolate`arn:aws:s3:::${bucket.bucket}`],\n Condition: {\n ...currentAccount\n }\n },\n {\n Sid: \"AllowPutValidationObject\",\n Effect: \"Allow\",\n Action: [\"s3:PutObject\"],\n Resource: [\n pulumi.interpolate`arn:aws:s3:::${bucket.bucket}/malware-protection-resource-validation-object`\n ],\n Condition: {\n ...currentAccount\n }\n },\n {\n Sid: \"AllowCheckBucketOwnership\",\n Effect: \"Allow\",\n Action: [\"s3:ListBucket\"],\n Resource: [pulumi.interpolate`arn:aws:s3:::${bucket.bucket}`],\n Condition: {\n ...currentAccount\n }\n },\n {\n Sid: \"AllowMalwareScan\",\n Effect: \"Allow\",\n Action: [\"s3:GetObject\", \"s3:GetObjectVersion\"],\n Resource: [pulumi.interpolate`arn:aws:s3:::${bucket.bucket}/*`],\n Condition: {\n ...currentAccount\n }\n }\n ]\n }\n }\n });\n\n const attachment = app.addResource(aws.iam.RolePolicyAttachment, {\n name: `fm-bucket-malware-protection-role-policy-attachment`,\n config: {\n role: role.output.name,\n policyArn: policy.output.arn\n }\n });\n\n app.addResource(aws.guardduty.MalwareProtectionPlan, {\n name: `fm-bucket-malware-protection-plan`,\n config: {\n role: role.output.arn,\n protectedResource: {\n s3Bucket: {\n bucketName: bucket.bucket\n }\n }\n },\n opts: {\n /**\n * The plan needs the role's permissions when it's created, and when it's deleted\n * (to remove its EventBridge rule). Without this dependency, Pulumi can create the\n * plan before the policy is attached, and delete the attachment before the plan.\n */\n dependsOn: [attachment.output]\n }\n });\n\n // FORWARD EVENTS FROM \"DEFAULT\" TO CUSTOM EVENT BUS.\n\n // Create an IAM Role for EventBridge to forward events\n const eventBridgeRole = app.addResource(aws.iam.Role, {\n name: \"guard-duty-forward-events-role\",\n config: {\n assumeRolePolicy: JSON.stringify({\n Version: \"2012-10-17\",\n Statement: [\n {\n Effect: \"Allow\",\n Principal: { Service: \"events.amazonaws.com\" },\n Action: \"sts:AssumeRole\"\n }\n ]\n })\n }\n });\n\n // Attach Policy to Allow EventBridge to PutEvents on Custom Event Bus\n const forwardEventsPolicy = app.addResource(aws.iam.RolePolicy, {\n name: \"guard-duty-forward-events-policy\",\n config: {\n role: eventBridgeRole.output,\n policy: pulumi.output(eventBus.output.arn).apply(arn =>\n JSON.stringify({\n Version: \"2012-10-17\",\n Statement: [\n {\n Effect: \"Allow\",\n Action: \"events:PutEvents\",\n Resource: arn\n }\n ]\n })\n )\n }\n });\n\n const forwardToCustomBusRule = app.addResource(aws.cloudwatch.EventRule, {\n name: \"forward-events-from-default-to-custom-bus-rule\",\n config: {\n eventBusName: \"default\",\n eventPattern: bucket.bucket.apply(name =>\n JSON.stringify({\n source: [\"aws.guardduty\"],\n \"detail-type\": [\"GuardDuty Malware Protection Object Scan Result\"],\n detail: {\n s3ObjectDetails: {\n bucketName: [name]\n }\n }\n })\n )\n }\n });\n\n // Target: Send events to the custom event bus\n app.addResource(aws.cloudwatch.EventTarget, {\n name: \"forward-events-from-default-to-custom-bus-target\",\n config: {\n rule: forwardToCustomBusRule.output.name,\n roleArn: eventBridgeRole.output.arn,\n eventBusName: \"default\",\n arn: eventBus.output.arn\n },\n opts: {\n // The target uses the role to forward events, so the role's policy must exist first.\n dependsOn: [forwardEventsPolicy.output]\n }\n });\n};\n"],"names":["configureS3BucketMalwareProtection","app","awsAccountId","getAwsAccountId","awsRegion","getAwsRegion","eventBus","bucket","currentAccount","managedByGuardDuty","assumeRole","aws","role","policy","pulumi","attachment","eventBridgeRole","JSON","forwardEventsPolicy","arn","forwardToCustomBusRule","name"],"mappings":";;;AAKO,MAAMA,qCAAqC,CAACC;IAC/C,MAAMC,eAAeC,gBAAgBF;IACrC,MAAMG,YAAYC,aAAaJ;IAC/B,MAAMK,WAAWL,IAAI,SAAS,CAAC,QAAQ;IAEvC,MAAMM,SAASN,IAAI,SAAS,CAAC,iBAAiB,CAAC,MAAM;IAErD,MAAMO,iBAAiB;QACnB,cAAc;YACV,uBAAuBN;QAC3B;IACJ;IAEA,MAAMO,qBAAqB;QACvB,cAAc;YACV,oBAAoB;QACxB;IACJ;IAEA,MAAMC,aAAaC,uCAAAA,GAAAA,CAAAA,iBAAyB,CAAC;QACzC,YAAY;YACR;gBACI,QAAQ;gBACR,YAAY;oBACR;wBACI,MAAM;wBACN,aAAa;4BAAC;yBAAkD;oBACpE;iBACH;gBACD,SAAS;oBAAC;iBAAiB;YAC/B;SACH;IACL;IAEA,MAAMC,OAAOX,IAAI,WAAW,CAACU,uCAAAA,GAAAA,CAAAA,IAAY,EAAE;QACvC,MAAM;QACN,QAAQ;YACJ,kBAAkBD,WAAW,IAAI,CAACA,CAAAA,aAAcA,WAAW,IAAI;QACnE;IACJ;IAEA,MAAMG,SAASZ,IAAI,WAAW,CAACU,uCAAAA,GAAAA,CAAAA,MAAc,EAAE;QAC3C,MAAM;QACN,QAAQ;YACJ,aAAa;YACb,QAAQ;gBACJ,SAAS;g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,QAAQ;oBACZ;iBACH;YACL;QACJ;IACJ;IAGA,MAAMC,sBAAsBjB,IAAI,WAAW,CAACU,uCAAAA,GAAAA,CAAAA,UAAkB,EAAE;QAC5D,MAAM;QACN,QAAQ;YACJ,MAAMK,gBAAgB,MAAM;YAC5B,QAAQF,0CAAAA,MAAa,CAACR,SAAS,MAAM,CAAC,GAAG,EAAE,KAAK,CAACa,CAAAA,MAC7CF,KAAK,SAAS,CAAC;oBACX,SAAS;oBACT,WAAW;wBACP;4BACI,QAAQ;4BACR,QAAQ;4BACR,UAAUE;wBACd;qBACH;gBACL;QAER;IACJ;IAEA,MAAMC,yBAAyBnB,IAAI,WAAW,CAACU,uCAAAA,UAAAA,CAAAA,SAAwB,EAAE;QACrE,MAAM;QACN,QAAQ;YACJ,cAAc;YACd,cAAcJ,OAAO,MAAM,CAAC,KAAK,CAACc,CAAAA,OAC9BJ,KAAK,SAAS,CAAC;oBACX,QAAQ;wBAAC;qBAAgB;oBACzB,eAAe;wBAAC;qBAAkD;oBAClE,QAAQ;wBACJ,iBAAiB;4BACb,YAAY;gCAACI;6BAAK;wBACtB;oBACJ;gBACJ;QAER;IACJ;IAGApB,IAAI,WAAW,CAACU,uCAAAA,UAAAA,CAAAA,WAA0B,EAAE;QACxC,MAAM;QACN,QAAQ;YACJ,MAAMS,uBAAuB,MAAM,CAAC,IAAI;YACxC,SAASJ,gBAAgB,MAAM,CAAC,GAAG;YACnC,cAAc;YACd,KAAKV,SAAS,MAAM,CAAC,GAAG;QAC5B;QACA,MAAM;YAEF,WAAW;gBAACY,oBAAoB,MAAM;aAAC;QAC3C;IACJ;AACJ"}
@@ -34,7 +34,7 @@ function withCommonLambdaEnvVariables(app) {
34
34
  app.decorateProgram(async (program, app)=>{
35
35
  const output = await program({
36
36
  ...app,
37
- setCommonLambdaEnvVariables: setCommonLambdaEnvVariables
37
+ setCommonLambdaEnvVariables
38
38
  });
39
39
  app.addHandler(()=>{
40
40
  sealEnvVariables();
@@ -43,7 +43,7 @@ function withCommonLambdaEnvVariables(app) {
43
43
  });
44
44
  return {
45
45
  ...app,
46
- setCommonLambdaEnvVariables: setCommonLambdaEnvVariables
46
+ setCommonLambdaEnvVariables
47
47
  };
48
48
  }
49
49
  export { getCommonLambdaEnvVariables, sealEnvVariables, withCommonLambdaEnvVariables };
@@ -1 +1 @@
1
- {"version":3,"file":"pulumi/utils/lambdaEnvVariables.js","sources":["../../../src/pulumi/utils/lambdaEnvVariables.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport type { PulumiApp } from \"@webiny/pulumi\";\n\ntype EnvVariables = Record<string, string | pulumi.Output<string>>;\n\nconst variablesRegistry: EnvVariables = {};\n\nif (process.env.DEBUG === \"true\") {\n variablesRegistry.NODE_OPTIONS = \"--enable-source-maps\";\n}\n\nexport let sealEnvVariables: () => void;\n\nconst magicPrefixes = [\n \"WEBINY_\",\n \"WEBINY_API_\",\n // Added WCP vars separately. We don't need any other `WCP_PROJECT_` variables, apart from these.\n // WEBINY_PROJECT_API_KEY is the new naming (preferred), WCP_PROJECT_ENVIRONMENT_API_KEY is for backward compatibility.\n // This will be later removed because we'll be using `Api.BuildParam` extension.\n \"WEBINY_PROJECT_API_KEY\",\n \"WCP_PROJECT_ENVIRONMENT\",\n \"WCP_PROJECT_ENVIRONMENT_API_KEY\",\n \"OKTA_\",\n \"AUTH0_\"\n];\n\nconst variablesPromise = new Promise<EnvVariables>(resolve => {\n sealEnvVariables = () => {\n // Apart from a couple of basic environment variables like DEBUG,\n // we also take into consideration variables that have `WEBINY_` and `WCP_` prefix in their names.\n const baseVariables = Object.keys(process.env).reduce<EnvVariables>(\n (current, environmentVariableName) => {\n const hasMagicPrefix = magicPrefixes.some(prefix =>\n environmentVariableName.startsWith(prefix)\n );\n\n if (hasMagicPrefix && process.env[environmentVariableName] !== undefined) {\n current[environmentVariableName] = String(process.env[environmentVariableName]);\n }\n return current;\n },\n {\n // Among other things, this determines the amount of information we reveal on runtime errors.\n // https://www.webiny.com/docs/how-to-guides/environment-variables/#debug-environment-variable\n DEBUG: String(process.env.DEBUG),\n // This flag means that Lambda was deployed using the new Pulumi Apps architecture.\n PULUMI_APPS: \"true\"\n }\n );\n\n resolve(Object.assign({}, baseVariables, variablesRegistry));\n };\n});\n\nexport function getCommonLambdaEnvVariables(): pulumi.Output<EnvVariables> {\n return pulumi.output(variablesPromise);\n}\n\nfunction setCommonLambdaEnvVariables(variables: EnvVariables) {\n Object.assign(variablesRegistry, variables);\n}\n\nexport interface SetCommonLambdaEnvVariables {\n (variables: EnvVariables): void;\n}\n\nexport interface WithCommonLambdaEnvVariables {\n /**\n * Set ENV variables that wil be assigned to all Lambda functions in the current Pulumi app.\n */\n setCommonLambdaEnvVariables: SetCommonLambdaEnvVariables;\n}\n\n/**\n * Augment the given app with `setCommonLambdaEnvVariables` functionality.\n * @param {PulumiApp} app\n */\nexport function withCommonLambdaEnvVariables<T extends PulumiApp>(\n app: T\n): T & WithCommonLambdaEnvVariables {\n app.decorateProgram<{ setCommonLambdaEnvVariables: typeof setCommonLambdaEnvVariables }>(\n async (program, app) => {\n const output = await program({\n ...app,\n setCommonLambdaEnvVariables\n });\n\n // Once the program is executed, we need to seal the variables (this will resolve the pulumi.output promise).\n app.addHandler(() => {\n sealEnvVariables();\n });\n\n return output;\n }\n );\n\n // Augment the original PulumiApp.\n return {\n ...app,\n setCommonLambdaEnvVariables\n };\n}\n"],"names":["variablesRegistry","process","sealEnvVariables","magicPrefixes","variablesPromise","Promise","resolve","baseVariables","Object","current","environmentVariableName","hasMagicPrefix","prefix","undefined","String","getCommonLambdaEnvVariables","pulumi","setCommonLambdaEnvVariables","variables","withCommonLambdaEnvVariables","app","program","output"],"mappings":";AAKA,MAAMA,oBAAkC,CAAC;AAEzC,IAAIC,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK,EACjBD,kBAAkB,YAAY,GAAG;AAG9B,IAAIE;AAEX,MAAMC,gBAAgB;IAClB;IACA;IAIA;IACA;IACA;IACA;IACA;CACH;AAED,MAAMC,mBAAmB,IAAIC,QAAsBC,CAAAA;IAC/CJ,mBAAmB;QAGf,MAAMK,gBAAgBC,OAAO,IAAI,CAACP,QAAQ,GAAG,EAAE,MAAM,CACjD,CAACQ,SAASC;YACN,MAAMC,iBAAiBR,cAAc,IAAI,CAACS,CAAAA,SACtCF,wBAAwB,UAAU,CAACE;YAGvC,IAAID,kBAAkBV,AAAyCY,WAAzCZ,QAAQ,GAAG,CAACS,wBAAwB,EACtDD,OAAO,CAACC,wBAAwB,GAAGI,OAAOb,QAAQ,GAAG,CAACS,wBAAwB;YAElF,OAAOD;QACX,GACA;YAGI,OAAOK,OAAOb,QAAQ,GAAG,CAAC,KAAK;YAE/B,aAAa;QACjB;QAGJK,QAAQE,OAAO,MAAM,CAAC,CAAC,GAAGD,eAAeP;IAC7C;AACJ;AAEO,SAASe;IACZ,OAAOC,0CAAAA,MAAa,CAACZ;AACzB;AAEA,SAASa,4BAA4BC,SAAuB;IACxDV,OAAO,MAAM,CAACR,mBAAmBkB;AACrC;AAiBO,SAASC,6BACZC,GAAM;IAENA,IAAI,eAAe,CACf,OAAOC,SAASD;QACZ,MAAME,SAAS,MAAMD,QAAQ;YACzB,GAAGD,GAAG;YACNH,6BAAAA;QACJ;QAGAG,IAAI,UAAU,CAAC;YACXlB;QACJ;QAEA,OAAOoB;IACX;IAIJ,OAAO;QACH,GAAGF,GAAG;QACNH,6BAAAA;IACJ;AACJ"}
1
+ {"version":3,"file":"pulumi/utils/lambdaEnvVariables.js","sources":["../../../src/pulumi/utils/lambdaEnvVariables.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport type { PulumiApp } from \"@webiny/pulumi\";\n\ntype EnvVariables = Record<string, string | pulumi.Output<string>>;\n\nconst variablesRegistry: EnvVariables = {};\n\nif (process.env.DEBUG === \"true\") {\n variablesRegistry.NODE_OPTIONS = \"--enable-source-maps\";\n}\n\nexport let sealEnvVariables: () => void;\n\nconst magicPrefixes = [\n \"WEBINY_\",\n \"WEBINY_API_\",\n // Added WCP vars separately. We don't need any other `WCP_PROJECT_` variables, apart from these.\n // WEBINY_PROJECT_API_KEY is the new naming (preferred), WCP_PROJECT_ENVIRONMENT_API_KEY is for backward compatibility.\n // This will be later removed because we'll be using `Api.BuildParam` extension.\n \"WEBINY_PROJECT_API_KEY\",\n \"WCP_PROJECT_ENVIRONMENT\",\n \"WCP_PROJECT_ENVIRONMENT_API_KEY\",\n \"OKTA_\",\n \"AUTH0_\"\n];\n\nconst variablesPromise = new Promise<EnvVariables>(resolve => {\n sealEnvVariables = () => {\n // Apart from a couple of basic environment variables like DEBUG,\n // we also take into consideration variables that have `WEBINY_` and `WCP_` prefix in their names.\n const baseVariables = Object.keys(process.env).reduce<EnvVariables>(\n (current, environmentVariableName) => {\n const hasMagicPrefix = magicPrefixes.some(prefix =>\n environmentVariableName.startsWith(prefix)\n );\n\n if (hasMagicPrefix && process.env[environmentVariableName] !== undefined) {\n current[environmentVariableName] = String(process.env[environmentVariableName]);\n }\n return current;\n },\n {\n // Among other things, this determines the amount of information we reveal on runtime errors.\n // https://www.webiny.com/docs/how-to-guides/environment-variables/#debug-environment-variable\n DEBUG: String(process.env.DEBUG),\n // This flag means that Lambda was deployed using the new Pulumi Apps architecture.\n PULUMI_APPS: \"true\"\n }\n );\n\n resolve(Object.assign({}, baseVariables, variablesRegistry));\n };\n});\n\nexport function getCommonLambdaEnvVariables(): pulumi.Output<EnvVariables> {\n return pulumi.output(variablesPromise);\n}\n\nfunction setCommonLambdaEnvVariables(variables: EnvVariables) {\n Object.assign(variablesRegistry, variables);\n}\n\nexport interface SetCommonLambdaEnvVariables {\n (variables: EnvVariables): void;\n}\n\nexport interface WithCommonLambdaEnvVariables {\n /**\n * Set ENV variables that wil be assigned to all Lambda functions in the current Pulumi app.\n */\n setCommonLambdaEnvVariables: SetCommonLambdaEnvVariables;\n}\n\n/**\n * Augment the given app with `setCommonLambdaEnvVariables` functionality.\n * @param {PulumiApp} app\n */\nexport function withCommonLambdaEnvVariables<T extends PulumiApp>(\n app: T\n): T & WithCommonLambdaEnvVariables {\n app.decorateProgram<{ setCommonLambdaEnvVariables: typeof setCommonLambdaEnvVariables }>(\n async (program, app) => {\n const output = await program({\n ...app,\n setCommonLambdaEnvVariables\n });\n\n // Once the program is executed, we need to seal the variables (this will resolve the pulumi.output promise).\n app.addHandler(() => {\n sealEnvVariables();\n });\n\n return output;\n }\n );\n\n // Augment the original PulumiApp.\n return {\n ...app,\n setCommonLambdaEnvVariables\n };\n}\n"],"names":["variablesRegistry","process","sealEnvVariables","magicPrefixes","variablesPromise","Promise","resolve","baseVariables","Object","current","environmentVariableName","hasMagicPrefix","prefix","undefined","String","getCommonLambdaEnvVariables","pulumi","setCommonLambdaEnvVariables","variables","withCommonLambdaEnvVariables","app","program","output"],"mappings":";AAKA,MAAMA,oBAAkC,CAAC;AAEzC,IAAIC,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK,EACjBD,kBAAkB,YAAY,GAAG;AAG9B,IAAIE;AAEX,MAAMC,gBAAgB;IAClB;IACA;IAIA;IACA;IACA;IACA;IACA;CACH;AAED,MAAMC,mBAAmB,IAAIC,QAAsBC,CAAAA;IAC/CJ,mBAAmB;QAGf,MAAMK,gBAAgBC,OAAO,IAAI,CAACP,QAAQ,GAAG,EAAE,MAAM,CACjD,CAACQ,SAASC;YACN,MAAMC,iBAAiBR,cAAc,IAAI,CAACS,CAAAA,SACtCF,wBAAwB,UAAU,CAACE;YAGvC,IAAID,kBAAkBV,AAAyCY,WAAzCZ,QAAQ,GAAG,CAACS,wBAAwB,EACtDD,OAAO,CAACC,wBAAwB,GAAGI,OAAOb,QAAQ,GAAG,CAACS,wBAAwB;YAElF,OAAOD;QACX,GACA;YAGI,OAAOK,OAAOb,QAAQ,GAAG,CAAC,KAAK;YAE/B,aAAa;QACjB;QAGJK,QAAQE,OAAO,MAAM,CAAC,CAAC,GAAGD,eAAeP;IAC7C;AACJ;AAEO,SAASe;IACZ,OAAOC,0CAAAA,MAAa,CAACZ;AACzB;AAEA,SAASa,4BAA4BC,SAAuB;IACxDV,OAAO,MAAM,CAACR,mBAAmBkB;AACrC;AAiBO,SAASC,6BACZC,GAAM;IAENA,IAAI,eAAe,CACf,OAAOC,SAASD;QACZ,MAAME,SAAS,MAAMD,QAAQ;YACzB,GAAGD,GAAG;YACNH;QACJ;QAGAG,IAAI,UAAU,CAAC;YACXlB;QACJ;QAEA,OAAOoB;IACX;IAIJ,OAAO;QACH,GAAGF,GAAG;QACNH;IACJ;AACJ"}