diff --git a/docs/api/04-standard-library/cloud/bucket.md b/docs/api/04-standard-library/cloud/bucket.md index 329cb52cfc0..39720d2d74b 100644 --- a/docs/api/04-standard-library/cloud/bucket.md +++ b/docs/api/04-standard-library/cloud/bucket.md @@ -105,25 +105,27 @@ By default, buckets are configured with CORS for any origin. When a bucket is pr ```js playground example bring cloud; +bring http; let uploads = new cloud.Bucket( // these are the default values public: false, cors: true, corsOptions: { - allowedMethods: [http.HttpMethod.GET, http.HttpMethod.POST, http.HttpMethod.PUT, http.HttpMethod.DELETE, http.HttpMethod.HEAD] + allowedMethods: [http.HttpMethod.GET, http.HttpMethod.POST, http.HttpMethod.PUT, http.HttpMethod.DELETE, http.HttpMethod.HEAD], allowedOrigins: ["*"], allowedHeaders: ["*"], exposeHeaders: [], maxAge: 0s }, -) +); ``` The CORS configuration can be disabled by passing `cors: false` to the constructor. CORS rules can also be configured after the bucket is created by calling the `addCorsRule` method: ```js playground example bring cloud; +bring http; let bucket = new cloud.Bucket( cors: false, // disable any default CORS rules @@ -131,6 +133,7 @@ let bucket = new cloud.Bucket( bucket.addCorsRule({ allowedOrigins: ["https://example.com"], + allowedMethods: [http.HttpMethod.GET], }); ``` diff --git a/packages/@winglang/platform-awscdk/test/__snapshots__/schedule.test.ts.snap b/packages/@winglang/platform-awscdk/test/__snapshots__/schedule.test.ts.snap index 1ebc7b47fbd..6a0c83f049c 100644 --- a/packages/@winglang/platform-awscdk/test/__snapshots__/schedule.test.ts.snap +++ b/packages/@winglang/platform-awscdk/test/__snapshots__/schedule.test.ts.snap @@ -12,7 +12,7 @@ exports[`convert single dayOfWeek from Unix to AWS 1`] = ` "Resources": { "Schedule251B1F83": { "Properties": { - "ScheduleExpression": "cron(* * ? * 0 *)", + "ScheduleExpression": "cron(* * ? * 1 *)", "State": "ENABLED", "Targets": [ { @@ -167,7 +167,7 @@ exports[`convert the list of dayOfWeek from Unix to AWS 1`] = ` "Resources": { "Schedule251B1F83": { "Properties": { - "ScheduleExpression": "cron(* * ? * 0,2,4,6 *)", + "ScheduleExpression": "cron(* * ? * 1,3,5,7 *)", "State": "ENABLED", "Targets": [ { @@ -322,7 +322,7 @@ exports[`convert the range of dayOfWeek from Unix to AWS 1`] = ` "Resources": { "Schedule251B1F83": { "Properties": { - "ScheduleExpression": "cron(* * ? * 0-6 *)", + "ScheduleExpression": "cron(* * ? * 1-7 *)", "State": "ENABLED", "Targets": [ { diff --git a/packages/@winglang/platform-awscdk/test/schedule.test.ts b/packages/@winglang/platform-awscdk/test/schedule.test.ts index 34924728dbb..6f0b5135612 100644 --- a/packages/@winglang/platform-awscdk/test/schedule.test.ts +++ b/packages/@winglang/platform-awscdk/test/schedule.test.ts @@ -48,7 +48,7 @@ test("convert single dayOfWeek from Unix to AWS", () => { // GIVEN const app = new AwsCdkApp(); const schedule = new cloud.Schedule(app, "Schedule", { - cron: "* * * * 1", + cron: "* * * * 0", }); schedule.onTick(INFLIGHT_CODE); const output = app.synth(); @@ -57,7 +57,7 @@ test("convert single dayOfWeek from Unix to AWS", () => { const template = Template.fromJSON(JSON.parse(output)); template.resourceCountIs("AWS::Events::Rule", 1); template.hasResourceProperties("AWS::Events::Rule", { - ScheduleExpression: "cron(* * ? * 0 *)", + ScheduleExpression: "cron(* * ? * 1 *)", }); expect(awscdkSanitize(template)).toMatchSnapshot(); }); @@ -66,7 +66,7 @@ test("convert the range of dayOfWeek from Unix to AWS", () => { // GIVEN const app = new AwsCdkApp(); const schedule = new cloud.Schedule(app, "Schedule", { - cron: "* * * * 1-7", + cron: "* * * * 0-6", }); schedule.onTick(INFLIGHT_CODE); const output = app.synth(); @@ -75,7 +75,7 @@ test("convert the range of dayOfWeek from Unix to AWS", () => { const template = Template.fromJSON(JSON.parse(output)); template.resourceCountIs("AWS::Events::Rule", 1); template.hasResourceProperties("AWS::Events::Rule", { - ScheduleExpression: "cron(* * ? * 0-6 *)", + ScheduleExpression: "cron(* * ? * 1-7 *)", }); expect(awscdkSanitize(template)).toMatchSnapshot(); }); @@ -84,7 +84,7 @@ test("convert the list of dayOfWeek from Unix to AWS", () => { // GIVEN const app = new AwsCdkApp(); const schedule = new cloud.Schedule(app, "Schedule", { - cron: "* * * * 1,3,5,7", + cron: "* * * * 0,2,4,6", }); schedule.onTick(INFLIGHT_CODE); const output = app.synth(); @@ -93,7 +93,7 @@ test("convert the list of dayOfWeek from Unix to AWS", () => { const template = Template.fromJSON(JSON.parse(output)); template.resourceCountIs("AWS::Events::Rule", 1); template.hasResourceProperties("AWS::Events::Rule", { - ScheduleExpression: "cron(* * ? * 0,2,4,6 *)", + ScheduleExpression: "cron(* * ? * 1,3,5,7 *)", }); expect(awscdkSanitize(template)).toMatchSnapshot(); }); diff --git a/packages/@winglang/sdk/src/cloud/bucket.md b/packages/@winglang/sdk/src/cloud/bucket.md index aea715d7193..a17f72777ab 100644 --- a/packages/@winglang/sdk/src/cloud/bucket.md +++ b/packages/@winglang/sdk/src/cloud/bucket.md @@ -105,6 +105,7 @@ By default, buckets are configured with CORS for any origin. When a bucket is pr ```js playground example bring cloud; +bring http; let uploads = new cloud.Bucket( // these are the default values diff --git a/packages/@winglang/sdk/src/shared-aws/schedule.ts b/packages/@winglang/sdk/src/shared-aws/schedule.ts index d2c81f30aca..2193d48003c 100644 --- a/packages/@winglang/sdk/src/shared-aws/schedule.ts +++ b/packages/@winglang/sdk/src/shared-aws/schedule.ts @@ -59,7 +59,7 @@ const convertDayOfWeekFromUnixToAWS = (dayOfWeek: string): string => { if (numbers) { for (const number of numbers) { - dayOfWeek = dayOfWeek.replace(number, (parseInt(number) - 1).toString()); + dayOfWeek = dayOfWeek.replace(number, (parseInt(number) + 1).toString()); } } diff --git a/packages/@winglang/sdk/test/target-tf-aws/__snapshots__/schedule.test.ts.snap b/packages/@winglang/sdk/test/target-tf-aws/__snapshots__/schedule.test.ts.snap index 1ad2cfbd41b..5bc1a45ddef 100644 --- a/packages/@winglang/sdk/test/target-tf-aws/__snapshots__/schedule.test.ts.snap +++ b/packages/@winglang/sdk/test/target-tf-aws/__snapshots__/schedule.test.ts.snap @@ -5,7 +5,7 @@ exports[`convert single dayOfWeek from Unix to AWS 1`] = ` "resource": { "aws_cloudwatch_event_rule": { "Schedule_15669BF1": { - "schedule_expression": "cron(* * ? * 0 *)", + "schedule_expression": "cron(* * ? * 1 *)", }, }, "aws_cloudwatch_event_target": { @@ -291,7 +291,7 @@ exports[`convert the list of dayOfWeek from Unix to AWS 1`] = ` "resource": { "aws_cloudwatch_event_rule": { "Schedule_15669BF1": { - "schedule_expression": "cron(* * ? * 0,2,4,6 *)", + "schedule_expression": "cron(* * ? * 1,3,5,7 *)", }, }, "aws_cloudwatch_event_target": { @@ -577,7 +577,7 @@ exports[`convert the range of dayOfWeek from Unix to AWS 1`] = ` "resource": { "aws_cloudwatch_event_rule": { "Schedule_15669BF1": { - "schedule_expression": "cron(* * ? * 0-6 *)", + "schedule_expression": "cron(* * ? * 1-7 *)", }, }, "aws_cloudwatch_event_target": { diff --git a/packages/@winglang/sdk/test/target-tf-aws/schedule.test.ts b/packages/@winglang/sdk/test/target-tf-aws/schedule.test.ts index cdaf2d5746b..0f18b679f0b 100644 --- a/packages/@winglang/sdk/test/target-tf-aws/schedule.test.ts +++ b/packages/@winglang/sdk/test/target-tf-aws/schedule.test.ts @@ -85,7 +85,7 @@ test("convert single dayOfWeek from Unix to AWS", () => { // GIVEN const app = new AwsApp(); const schedule = new cloud.Schedule(app, "Schedule", { - cron: "* * * * 1", + cron: "* * * * 0", }); schedule.onTick(CODE_LOG_EVENT); const output = app.synth(); @@ -108,7 +108,7 @@ test("convert single dayOfWeek from Unix to AWS", () => { output, "aws_cloudwatch_event_rule", { - schedule_expression: "cron(* * ? * 0 *)", + schedule_expression: "cron(* * ? * 1 *)", } ) ).toEqual(true); @@ -120,7 +120,7 @@ test("convert the range of dayOfWeek from Unix to AWS", () => { // GIVEN const app = new AwsApp(); const schedule = new cloud.Schedule(app, "Schedule", { - cron: "* * * * 1-7", + cron: "* * * * 0-6", }); schedule.onTick(CODE_LOG_EVENT); const output = app.synth(); @@ -143,7 +143,7 @@ test("convert the range of dayOfWeek from Unix to AWS", () => { output, "aws_cloudwatch_event_rule", { - schedule_expression: "cron(* * ? * 0-6 *)", + schedule_expression: "cron(* * ? * 1-7 *)", } ) ).toEqual(true); @@ -155,7 +155,7 @@ test("convert the list of dayOfWeek from Unix to AWS", () => { // GIVEN const app = new AwsApp(); const schedule = new cloud.Schedule(app, "Schedule", { - cron: "* * * * 1,3,5,7", + cron: "* * * * 0,2,4,6", }); schedule.onTick(CODE_LOG_EVENT); const output = app.synth(); @@ -178,7 +178,7 @@ test("convert the list of dayOfWeek from Unix to AWS", () => { output, "aws_cloudwatch_event_rule", { - schedule_expression: "cron(* * ? * 0,2,4,6 *)", + schedule_expression: "cron(* * ? * 1,3,5,7 *)", } ) ).toEqual(true);