@awsless/awsless 0.0.167 → 0.0.169

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 (2) hide show
  1. package/dist/bin.js +148 -37
  2. package/package.json +6 -6
package/dist/bin.js CHANGED
@@ -244,7 +244,7 @@ var sizeMax = (max) => {
244
244
  // src/feature/function/schema.ts
245
245
  import { days, minutes, seconds } from "@awsless/duration";
246
246
  import { gibibytes, mebibytes } from "@awsless/size";
247
- var MemorySizeSchema = SizeSchema.refine(sizeMin(mebibytes(128)), "Minimum memory size is 128 MB").refine(sizeMax(gibibytes(10)), "Minimum memory size is 10 GB").describe(
247
+ var MemorySizeSchema = SizeSchema.refine(sizeMin(mebibytes(128)), "Minimum memory size is 128 MB").refine(sizeMax(gibibytes(10)), "Maximum memory size is 10 GB").describe(
248
248
  "The amount of memory available to the function at runtime. Increasing the function memory also increases its CPU allocation. The value can be any multiple of 1 MB. You can specify a size value from 128 MB to 10 GB."
249
249
  );
250
250
  var TimeoutSchema = DurationSchema.refine(durationMin(seconds(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(minutes(15)), "Maximum timeout duration is 15 minutes").describe(
@@ -263,12 +263,18 @@ var RetryAttemptsSchema = z7.number().int().min(0).max(2).describe(
263
263
  "The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
264
264
  );
265
265
  var RuntimeSchema = z7.enum(["nodejs18.x", "nodejs20.x"]).describe("The identifier of the function's runtime.");
266
+ var ActionSchema = z7.string();
267
+ var ActionsSchema = z7.union([ActionSchema.transform((v) => [v]), ActionSchema.array()]);
268
+ var ArnSchema = z7.string().startsWith("arn:");
269
+ var WildcardSchema = z7.literal("*");
270
+ var ResourceSchema = z7.union([ArnSchema, WildcardSchema]).transform((v) => v);
271
+ var ResourcesSchema = z7.union([ResourceSchema.transform((v) => [v]), ResourceSchema.array()]);
266
272
  var PermissionSchema = z7.object({
267
273
  effect: z7.enum(["allow", "deny"]).default("allow"),
268
- actions: z7.string().array(),
269
- resources: z7.string().startsWith("arn:").transform((v) => v).array()
274
+ actions: ActionsSchema,
275
+ resources: ResourcesSchema
270
276
  });
271
- var PermissionsSchema = PermissionSchema.array().describe("Add IAM permissions to your function.");
277
+ var PermissionsSchema = z7.union([PermissionSchema.transform((v) => [v]), PermissionSchema.array()]).describe("Add IAM permissions to your function.");
272
278
  var WarmSchema = z7.number().int().min(0).max(10).describe(
273
279
  "Specify how many functions you want to warm up each 5 minutes. You can specify a number from 0 to 10."
274
280
  );
@@ -771,7 +777,126 @@ var CachesSchema = z23.record(
771
777
 
772
778
  // src/feature/search/schema.ts
773
779
  import { z as z24 } from "zod";
774
- var SearchsSchema = z24.array(ResourceIdSchema).optional();
780
+ import { gibibytes as gibibytes2 } from "@awsless/size";
781
+ var VersionSchema = z24.enum([
782
+ "OpenSearch_2.11",
783
+ "OpenSearch_2.9",
784
+ "OpenSearch_2.7",
785
+ "OpenSearch_2.5",
786
+ "OpenSearch_2.3",
787
+ "OpenSearch_1.3"
788
+ ]);
789
+ var TypeSchema2 = z24.enum([
790
+ "t3.small.search",
791
+ "t3.medium.search",
792
+ "t3.large.search",
793
+ "t3.xlarge.search",
794
+ "t3.2xlarge.search",
795
+ "t4g.small.search",
796
+ "t4g.medium.search",
797
+ "m3.medium.search",
798
+ "m3.large.search",
799
+ "m3.xlarge.search",
800
+ "m3.2xlarge.search",
801
+ "m4.large.search",
802
+ "m4.xlarge.search",
803
+ "m4.2xlarge.search",
804
+ "m4.4xlarge.search",
805
+ "m4.10xlarge.search",
806
+ "m5.large.search",
807
+ "m5.xlarge.search",
808
+ "m5.2xlarge.search",
809
+ "m5.4xlarge.search",
810
+ "m5.12xlarge.search",
811
+ "m5.24xlarge.search",
812
+ "r5.large.search",
813
+ "r5.xlarge.search",
814
+ "r5.2xlarge.search",
815
+ "r5.4xlarge.search",
816
+ "r5.12xlarge.search",
817
+ "r5.24xlarge.search",
818
+ "c5.large.search",
819
+ "c5.xlarge.search",
820
+ "c5.2xlarge.search",
821
+ "c5.4xlarge.search",
822
+ "c5.9xlarge.search",
823
+ "c5.18xlarge.search",
824
+ "or1.medium.search",
825
+ "or1.large.search",
826
+ "or1.xlarge.search",
827
+ "or1.2xlarge.search",
828
+ "or1.4xlarge.search",
829
+ "or1.8xlarge.search",
830
+ "or1.12xlarge.search",
831
+ "or1.16xlarge.search",
832
+ "ultrawarm1.medium.search",
833
+ "ultrawarm1.large.search",
834
+ "ultrawarm1.xlarge.search",
835
+ "r3.large.search",
836
+ "r3.xlarge.search",
837
+ "r3.2xlarge.search",
838
+ "r3.4xlarge.search",
839
+ "r3.8xlarge.search",
840
+ "i2.xlarge.search",
841
+ "i2.2xlarge.search",
842
+ "d2.xlarge.search",
843
+ "d2.2xlarge.search",
844
+ "d2.4xlarge.search",
845
+ "d2.8xlarge.search",
846
+ "c4.large.search",
847
+ "c4.xlarge.search",
848
+ "c4.2xlarge.search",
849
+ "c4.4xlarge.search",
850
+ "c4.8xlarge.search",
851
+ "r4.large.search",
852
+ "r4.xlarge.search",
853
+ "r4.2xlarge.search",
854
+ "r4.4xlarge.search",
855
+ "r4.8xlarge.search",
856
+ "r4.16xlarge.search",
857
+ "i3.large.search",
858
+ "i3.xlarge.search",
859
+ "i3.2xlarge.search",
860
+ "i3.4xlarge.search",
861
+ "i3.8xlarge.search",
862
+ "i3.16xlarge.search",
863
+ "r6g.large.search",
864
+ "r6g.xlarge.search",
865
+ "r6g.2xlarge.search",
866
+ "r6g.4xlarge.search",
867
+ "r6g.8xlarge.search",
868
+ "r6g.12xlarge.search",
869
+ "m6g.large.search",
870
+ "m6g.xlarge.search",
871
+ "m6g.2xlarge.search",
872
+ "m6g.4xlarge.search",
873
+ "m6g.8xlarge.search",
874
+ "m6g.12xlarge.search",
875
+ "c6g.large.search",
876
+ "c6g.xlarge.search",
877
+ "c6g.2xlarge.search",
878
+ "c6g.4xlarge.search",
879
+ "c6g.8xlarge.search",
880
+ "c6g.12xlarge.search",
881
+ "r6gd.large.search",
882
+ "r6gd.xlarge.search",
883
+ "r6gd.2xlarge.search",
884
+ "r6gd.4xlarge.search",
885
+ "r6gd.8xlarge.search",
886
+ "r6gd.12xlarge.search",
887
+ "r6gd.16xlarge.search"
888
+ ]);
889
+ var StorageSizeSchema = SizeSchema.refine(sizeMin(gibibytes2(10)), "Minimum storage size is 10 GB").refine(sizeMax(gibibytes2(100)), "Maximum storage size is 100 GB").describe("The size of the function's /tmp directory. You can specify a size value from 512 MB to 10 GiB.");
890
+ var SearchsSchema = z24.record(
891
+ ResourceIdSchema,
892
+ z24.object({
893
+ type: TypeSchema2.default("t3.small.search"),
894
+ count: z24.number().int().min(1).default(1),
895
+ version: VersionSchema.default("OpenSearch_2.11"),
896
+ storage: StorageSizeSchema.default("10 GB"),
897
+ vpc: z24.boolean().default(false)
898
+ })
899
+ ).optional().describe("Define the searches in your stack.");
775
900
 
776
901
  // src/feature/site/schema.ts
777
902
  import { z as z25 } from "zod";
@@ -3051,7 +3176,7 @@ var authFeature = defineFeature({
3051
3176
  },
3052
3177
  onStack(ctx) {
3053
3178
  for (const [id, props] of Object.entries(ctx.stackConfig.auth ?? {})) {
3054
- const group = new Node14(this.name, `id`);
3179
+ const group = new Node14(this.name, id);
3055
3180
  ctx.base.add(group);
3056
3181
  const userPoolId = ctx.app.import("base", `auth-${id}-user-pool-id`);
3057
3182
  const userPoolArn = ctx.app.import("base", `auth-${id}-user-pool-arn`);
@@ -3095,9 +3220,10 @@ var authFeature = defineFeature({
3095
3220
  actions: ["cognito:*"],
3096
3221
  resources: [
3097
3222
  // Not yet known if this is correct way to grant access to all resources
3098
- userPoolId.apply(
3099
- (id2) => `arn:aws:cognito-idp:${ctx.appConfig.region}:${ctx.accountId}:userpool/${id2}`
3100
- )
3223
+ userPoolArn
3224
+ // userPoolId.apply<aws.ARN>(
3225
+ // id => `arn:aws:cognito-idp:${ctx.appConfig.region}:${ctx.accountId}:userpool/${id}`
3226
+ // ),
3101
3227
  // userPoolId.apply<aws.ARN>(
3102
3228
  // id => `arn:aws:cognito-idp:${ctx.appConfig.region}:${ctx.accountId}:userpool/${id}*`
3103
3229
  // ),
@@ -3107,11 +3233,9 @@ var authFeature = defineFeature({
3107
3233
  }
3108
3234
  },
3109
3235
  onApp(ctx) {
3110
- const main = new Node14(this.name, "main");
3111
- ctx.base.add(main);
3112
3236
  for (const [id, props] of Object.entries(ctx.appConfig.defaults.auth ?? {})) {
3113
3237
  const group = new Node14(this.name, id);
3114
- main.add(group);
3238
+ ctx.base.add(group);
3115
3239
  let emailConfig;
3116
3240
  if (props.messaging) {
3117
3241
  const [_, domainName] = props.messaging.fromEmail.split("@");
@@ -3126,7 +3250,7 @@ var authFeature = defineFeature({
3126
3250
  const name = formatGlobalResourceName(ctx.appConfig.name, this.name, id);
3127
3251
  const userPool = new aws14.cognito.UserPool("user-pool", {
3128
3252
  name,
3129
- deletionProtection: true,
3253
+ // deletionProtection: true,
3130
3254
  allowUserRegistration: props.allowUserRegistration,
3131
3255
  username: props.username,
3132
3256
  password: props.password,
@@ -3341,7 +3465,7 @@ var searchFeature = defineFeature({
3341
3465
  const resources = new TypeObject(1);
3342
3466
  for (const stack of ctx.stackConfigs) {
3343
3467
  const list4 = new TypeObject(2);
3344
- for (const id of stack.searchs || []) {
3468
+ for (const id of Object.keys(stack.searchs ?? {})) {
3345
3469
  const name = formatLocalResourceName(ctx.appConfig.name, stack.name, "search", id);
3346
3470
  list4.addType(name, `{ readonly name: '${name}' }`);
3347
3471
  }
@@ -3351,32 +3475,19 @@ var searchFeature = defineFeature({
3351
3475
  await ctx.write("search.d.ts", gen, true);
3352
3476
  },
3353
3477
  onStack(ctx) {
3354
- for (const id of ctx.stackConfig.searchs ?? []) {
3478
+ for (const [id, props] of Object.entries(ctx.stackConfig.searchs ?? {})) {
3355
3479
  const group = new Node16("search", id);
3356
3480
  ctx.stack.add(group);
3357
- const name = formatLocalResourceName(ctx.app.name, ctx.stack.name, "search", id);
3358
- const policy = new aws16.openSearchServerless.SecurityPolicy("security", {
3359
- name,
3360
- type: "encryption",
3361
- policy: JSON.stringify({
3362
- AWSOwnedKey: true,
3363
- Rules: [
3364
- {
3365
- ResourceType: "collection",
3366
- Resource: [`collection/${name}`]
3367
- }
3368
- ]
3369
- })
3370
- });
3371
- group.add(policy);
3372
- const collection = new aws16.openSearchServerless.Collection("collection", {
3373
- name: formatLocalResourceName(ctx.app.name, ctx.stack.name, "search", id),
3374
- type: "search"
3375
- }).dependsOn(policy);
3376
- group.add(collection);
3377
- ctx.onFunction(({ policy: policy2 }) => {
3378
- policy2.addStatement(collection.permissions);
3481
+ const domain = new aws16.openSearch.Domain("domain", {
3482
+ // name: formatLocalResourceName(ctx.app.name, ctx.stack.name, 'search', id),
3483
+ version: props.version,
3484
+ storageSize: props.storage,
3485
+ instance: {
3486
+ type: props.type,
3487
+ count: props.count
3488
+ }
3379
3489
  });
3490
+ group.add(domain);
3380
3491
  }
3381
3492
  }
3382
3493
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.167",
3
+ "version": "0.0.169",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -28,14 +28,14 @@
28
28
  }
29
29
  },
30
30
  "peerDependencies": {
31
+ "@awsless/lambda": "^0.0.18",
32
+ "@awsless/s3": "^0.0.10",
31
33
  "@awsless/redis": "^0.0.12",
32
34
  "@awsless/sns": "^0.0.7",
33
- "@awsless/s3": "^0.0.10",
34
- "@awsless/lambda": "^0.0.18",
35
35
  "@awsless/sqs": "^0.0.7",
36
36
  "@awsless/validate": "^0.0.13",
37
- "@awsless/weak-cache": "^0.0.1",
38
- "@awsless/ssm": "^0.0.7"
37
+ "@awsless/ssm": "^0.0.7",
38
+ "@awsless/weak-cache": "^0.0.1"
39
39
  },
40
40
  "dependencies": {
41
41
  "@aws-appsync/utils": "^1.5.0",
@@ -98,8 +98,8 @@
98
98
  "zod-to-json-schema": "^3.22.3",
99
99
  "@awsless/duration": "^0.0.1",
100
100
  "@awsless/formation": "^0.0.3",
101
- "@awsless/graphql": "^0.0.9",
102
101
  "@awsless/validate": "^0.0.13",
102
+ "@awsless/graphql": "^0.0.9",
103
103
  "@awsless/size": "^0.0.1",
104
104
  "@awsless/code": "^0.0.10"
105
105
  },