@awsless/awsless 0.0.166 → 0.0.168

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 +146 -37
  2. package/package.json +7 -7
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,16 @@ 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 ResourceSchema = z7.string().startsWith("arn:").transform((v) => v);
269
+ var ResourcesSchema = z7.union([ResourceSchema.transform((v) => [v]), ResourceSchema.array()]);
266
270
  var PermissionSchema = z7.object({
267
271
  effect: z7.enum(["allow", "deny"]).default("allow"),
268
- actions: z7.string().array(),
269
- resources: z7.string().startsWith("arn:").transform((v) => v).array()
272
+ actions: ActionsSchema,
273
+ resources: ResourcesSchema
270
274
  });
271
- var PermissionsSchema = PermissionSchema.array().describe("Add IAM permissions to your function.");
275
+ var PermissionsSchema = z7.union([PermissionSchema.transform((v) => [v]), PermissionSchema.array()]).describe("Add IAM permissions to your function.");
272
276
  var WarmSchema = z7.number().int().min(0).max(10).describe(
273
277
  "Specify how many functions you want to warm up each 5 minutes. You can specify a number from 0 to 10."
274
278
  );
@@ -771,7 +775,126 @@ var CachesSchema = z23.record(
771
775
 
772
776
  // src/feature/search/schema.ts
773
777
  import { z as z24 } from "zod";
774
- var SearchsSchema = z24.array(ResourceIdSchema).optional();
778
+ import { gibibytes as gibibytes2 } from "@awsless/size";
779
+ var VersionSchema = z24.enum([
780
+ "OpenSearch_2.11",
781
+ "OpenSearch_2.9",
782
+ "OpenSearch_2.7",
783
+ "OpenSearch_2.5",
784
+ "OpenSearch_2.3",
785
+ "OpenSearch_1.3"
786
+ ]);
787
+ var TypeSchema2 = z24.enum([
788
+ "t3.small.search",
789
+ "t3.medium.search",
790
+ "t3.large.search",
791
+ "t3.xlarge.search",
792
+ "t3.2xlarge.search",
793
+ "t4g.small.search",
794
+ "t4g.medium.search",
795
+ "m3.medium.search",
796
+ "m3.large.search",
797
+ "m3.xlarge.search",
798
+ "m3.2xlarge.search",
799
+ "m4.large.search",
800
+ "m4.xlarge.search",
801
+ "m4.2xlarge.search",
802
+ "m4.4xlarge.search",
803
+ "m4.10xlarge.search",
804
+ "m5.large.search",
805
+ "m5.xlarge.search",
806
+ "m5.2xlarge.search",
807
+ "m5.4xlarge.search",
808
+ "m5.12xlarge.search",
809
+ "m5.24xlarge.search",
810
+ "r5.large.search",
811
+ "r5.xlarge.search",
812
+ "r5.2xlarge.search",
813
+ "r5.4xlarge.search",
814
+ "r5.12xlarge.search",
815
+ "r5.24xlarge.search",
816
+ "c5.large.search",
817
+ "c5.xlarge.search",
818
+ "c5.2xlarge.search",
819
+ "c5.4xlarge.search",
820
+ "c5.9xlarge.search",
821
+ "c5.18xlarge.search",
822
+ "or1.medium.search",
823
+ "or1.large.search",
824
+ "or1.xlarge.search",
825
+ "or1.2xlarge.search",
826
+ "or1.4xlarge.search",
827
+ "or1.8xlarge.search",
828
+ "or1.12xlarge.search",
829
+ "or1.16xlarge.search",
830
+ "ultrawarm1.medium.search",
831
+ "ultrawarm1.large.search",
832
+ "ultrawarm1.xlarge.search",
833
+ "r3.large.search",
834
+ "r3.xlarge.search",
835
+ "r3.2xlarge.search",
836
+ "r3.4xlarge.search",
837
+ "r3.8xlarge.search",
838
+ "i2.xlarge.search",
839
+ "i2.2xlarge.search",
840
+ "d2.xlarge.search",
841
+ "d2.2xlarge.search",
842
+ "d2.4xlarge.search",
843
+ "d2.8xlarge.search",
844
+ "c4.large.search",
845
+ "c4.xlarge.search",
846
+ "c4.2xlarge.search",
847
+ "c4.4xlarge.search",
848
+ "c4.8xlarge.search",
849
+ "r4.large.search",
850
+ "r4.xlarge.search",
851
+ "r4.2xlarge.search",
852
+ "r4.4xlarge.search",
853
+ "r4.8xlarge.search",
854
+ "r4.16xlarge.search",
855
+ "i3.large.search",
856
+ "i3.xlarge.search",
857
+ "i3.2xlarge.search",
858
+ "i3.4xlarge.search",
859
+ "i3.8xlarge.search",
860
+ "i3.16xlarge.search",
861
+ "r6g.large.search",
862
+ "r6g.xlarge.search",
863
+ "r6g.2xlarge.search",
864
+ "r6g.4xlarge.search",
865
+ "r6g.8xlarge.search",
866
+ "r6g.12xlarge.search",
867
+ "m6g.large.search",
868
+ "m6g.xlarge.search",
869
+ "m6g.2xlarge.search",
870
+ "m6g.4xlarge.search",
871
+ "m6g.8xlarge.search",
872
+ "m6g.12xlarge.search",
873
+ "c6g.large.search",
874
+ "c6g.xlarge.search",
875
+ "c6g.2xlarge.search",
876
+ "c6g.4xlarge.search",
877
+ "c6g.8xlarge.search",
878
+ "c6g.12xlarge.search",
879
+ "r6gd.large.search",
880
+ "r6gd.xlarge.search",
881
+ "r6gd.2xlarge.search",
882
+ "r6gd.4xlarge.search",
883
+ "r6gd.8xlarge.search",
884
+ "r6gd.12xlarge.search",
885
+ "r6gd.16xlarge.search"
886
+ ]);
887
+ 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.");
888
+ var SearchsSchema = z24.record(
889
+ ResourceIdSchema,
890
+ z24.object({
891
+ type: TypeSchema2.default("t3.small.search"),
892
+ count: z24.number().int().min(1).default(1),
893
+ version: VersionSchema.default("OpenSearch_2.11"),
894
+ storage: StorageSizeSchema.default("10 GB"),
895
+ vpc: z24.boolean().default(false)
896
+ })
897
+ ).optional().describe("Define the searches in your stack.");
775
898
 
776
899
  // src/feature/site/schema.ts
777
900
  import { z as z25 } from "zod";
@@ -3051,7 +3174,7 @@ var authFeature = defineFeature({
3051
3174
  },
3052
3175
  onStack(ctx) {
3053
3176
  for (const [id, props] of Object.entries(ctx.stackConfig.auth ?? {})) {
3054
- const group = new Node14(this.name, `id`);
3177
+ const group = new Node14(this.name, id);
3055
3178
  ctx.base.add(group);
3056
3179
  const userPoolId = ctx.app.import("base", `auth-${id}-user-pool-id`);
3057
3180
  const userPoolArn = ctx.app.import("base", `auth-${id}-user-pool-arn`);
@@ -3095,9 +3218,10 @@ var authFeature = defineFeature({
3095
3218
  actions: ["cognito:*"],
3096
3219
  resources: [
3097
3220
  // 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
- )
3221
+ userPoolArn
3222
+ // userPoolId.apply<aws.ARN>(
3223
+ // id => `arn:aws:cognito-idp:${ctx.appConfig.region}:${ctx.accountId}:userpool/${id}`
3224
+ // ),
3101
3225
  // userPoolId.apply<aws.ARN>(
3102
3226
  // id => `arn:aws:cognito-idp:${ctx.appConfig.region}:${ctx.accountId}:userpool/${id}*`
3103
3227
  // ),
@@ -3107,11 +3231,9 @@ var authFeature = defineFeature({
3107
3231
  }
3108
3232
  },
3109
3233
  onApp(ctx) {
3110
- const main = new Node14(this.name, "main");
3111
- ctx.base.add(main);
3112
3234
  for (const [id, props] of Object.entries(ctx.appConfig.defaults.auth ?? {})) {
3113
3235
  const group = new Node14(this.name, id);
3114
- main.add(group);
3236
+ ctx.base.add(group);
3115
3237
  let emailConfig;
3116
3238
  if (props.messaging) {
3117
3239
  const [_, domainName] = props.messaging.fromEmail.split("@");
@@ -3126,7 +3248,7 @@ var authFeature = defineFeature({
3126
3248
  const name = formatGlobalResourceName(ctx.appConfig.name, this.name, id);
3127
3249
  const userPool = new aws14.cognito.UserPool("user-pool", {
3128
3250
  name,
3129
- deletionProtection: true,
3251
+ // deletionProtection: true,
3130
3252
  allowUserRegistration: props.allowUserRegistration,
3131
3253
  username: props.username,
3132
3254
  password: props.password,
@@ -3341,7 +3463,7 @@ var searchFeature = defineFeature({
3341
3463
  const resources = new TypeObject(1);
3342
3464
  for (const stack of ctx.stackConfigs) {
3343
3465
  const list4 = new TypeObject(2);
3344
- for (const id of stack.searchs || []) {
3466
+ for (const id of Object.keys(stack.searchs ?? {})) {
3345
3467
  const name = formatLocalResourceName(ctx.appConfig.name, stack.name, "search", id);
3346
3468
  list4.addType(name, `{ readonly name: '${name}' }`);
3347
3469
  }
@@ -3351,32 +3473,19 @@ var searchFeature = defineFeature({
3351
3473
  await ctx.write("search.d.ts", gen, true);
3352
3474
  },
3353
3475
  onStack(ctx) {
3354
- for (const id of ctx.stackConfig.searchs ?? []) {
3476
+ for (const [id, props] of Object.entries(ctx.stackConfig.searchs ?? {})) {
3355
3477
  const group = new Node16("search", id);
3356
3478
  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);
3479
+ const domain = new aws16.openSearch.Domain("domain", {
3480
+ // name: formatLocalResourceName(ctx.app.name, ctx.stack.name, 'search', id),
3481
+ version: props.version,
3482
+ storageSize: props.storage,
3483
+ instance: {
3484
+ type: props.type,
3485
+ count: props.count
3486
+ }
3379
3487
  });
3488
+ group.add(domain);
3380
3489
  }
3381
3490
  }
3382
3491
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.166",
3
+ "version": "0.0.168",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -29,12 +29,12 @@
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@awsless/lambda": "^0.0.18",
32
- "@awsless/sqs": "^0.0.7",
33
- "@awsless/s3": "^0.0.10",
34
32
  "@awsless/redis": "^0.0.12",
35
33
  "@awsless/sns": "^0.0.7",
36
- "@awsless/validate": "^0.0.13",
34
+ "@awsless/sqs": "^0.0.7",
35
+ "@awsless/s3": "^0.0.10",
37
36
  "@awsless/ssm": "^0.0.7",
37
+ "@awsless/validate": "^0.0.13",
38
38
  "@awsless/weak-cache": "^0.0.1"
39
39
  },
40
40
  "dependencies": {
@@ -97,11 +97,11 @@
97
97
  "zod": "^3.21.4",
98
98
  "zod-to-json-schema": "^3.22.3",
99
99
  "@awsless/duration": "^0.0.1",
100
- "@awsless/formation": "^0.0.1",
101
100
  "@awsless/graphql": "^0.0.9",
102
- "@awsless/validate": "^0.0.13",
103
101
  "@awsless/size": "^0.0.1",
104
- "@awsless/code": "^0.0.10"
102
+ "@awsless/validate": "^0.0.13",
103
+ "@awsless/code": "^0.0.10",
104
+ "@awsless/formation": "^0.0.3"
105
105
  },
106
106
  "scripts": {
107
107
  "test": "pnpm code test",