@awsless/awsless 0.0.165 → 0.0.166

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 (35) hide show
  1. package/README.MD +77 -101
  2. package/dist/bin.js +4137 -8341
  3. package/dist/client.js +2 -2
  4. package/dist/server.d.ts +121 -0
  5. package/dist/{index.js → server.js} +48 -55
  6. package/package.json +23 -11
  7. package/dist/app.json +0 -1
  8. package/dist/chunk-PFTL6L4F.js +0 -6
  9. package/dist/features/cognito-client-secret/HASH +0 -1
  10. package/dist/features/cognito-client-secret/bundle.zip +0 -0
  11. package/dist/features/cognito-client-secret/index.js +0 -60
  12. package/dist/features/cognito-client-secret/index.mjs +0 -58
  13. package/dist/features/delete-bucket/HASH +0 -1
  14. package/dist/features/delete-bucket/bundle.zip +0 -0
  15. package/dist/features/delete-bucket/index.js +0 -88
  16. package/dist/features/delete-bucket/index.mjs +0 -86
  17. package/dist/features/delete-hosted-zone/HASH +0 -1
  18. package/dist/features/delete-hosted-zone/bundle.zip +0 -0
  19. package/dist/features/delete-hosted-zone/index.js +0 -130
  20. package/dist/features/delete-hosted-zone/index.mjs +0 -128
  21. package/dist/features/global-exports/HASH +0 -1
  22. package/dist/features/global-exports/bundle.zip +0 -0
  23. package/dist/features/global-exports/index.js +0 -63
  24. package/dist/features/global-exports/index.mjs +0 -61
  25. package/dist/features/invalidate-cache/HASH +0 -1
  26. package/dist/features/invalidate-cache/bundle.zip +0 -0
  27. package/dist/features/invalidate-cache/index.js +0 -63
  28. package/dist/features/invalidate-cache/index.mjs +0 -61
  29. package/dist/features/upload-bucket-asset/HASH +0 -1
  30. package/dist/features/upload-bucket-asset/bundle.zip +0 -0
  31. package/dist/features/upload-bucket-asset/index.js +0 -22015
  32. package/dist/features/upload-bucket-asset/index.mjs +0 -22013
  33. package/dist/index.d.ts +0 -11541
  34. package/dist/json.js +0 -958
  35. package/dist/stack.json +0 -1
@@ -1,130 +0,0 @@
1
- 'use strict';
2
-
3
- var clientRoute53 = require('@aws-sdk/client-route-53');
4
-
5
- const send = async (event, id, status, data, reason = '')=>{
6
- const body = JSON.stringify({
7
- Status: status,
8
- Reason: reason,
9
- PhysicalResourceId: id,
10
- StackId: event.StackId,
11
- RequestId: event.RequestId,
12
- LogicalResourceId: event.LogicalResourceId,
13
- NoEcho: false,
14
- Data: data
15
- });
16
- await fetch(event.ResponseURL, {
17
- method: 'PUT',
18
- // @ts-ignore
19
- port: 443,
20
- body,
21
- headers: {
22
- 'content-type': '',
23
- 'content-length': Buffer.from(body).byteLength.toString()
24
- }
25
- });
26
- };
27
-
28
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
29
-
30
- function getDefaultExportFromCjs (x) {
31
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
32
- }
33
-
34
- var chunk$1 = {exports: {}};
35
-
36
- (function (module, exports) {
37
-
38
- (function () {
39
- function chunk(collection, size) {
40
- var result = [];
41
-
42
- // default size to two item
43
- size = parseInt(size) || 2;
44
-
45
- // add each chunk to the result
46
- for (var x = 0; x < Math.ceil(collection.length / size); x++) {
47
- var start = x * size;
48
- var end = start + size;
49
-
50
- result.push(collection.slice(start, end));
51
- }
52
-
53
- return result;
54
- }
55
-
56
- // export in node or browser
57
- {
58
- if (module.exports) {
59
- exports = module.exports = chunk;
60
- }
61
- exports.chunk = chunk;
62
- }
63
- }.call(commonjsGlobal));
64
- } (chunk$1, chunk$1.exports));
65
-
66
- var chunkExports = chunk$1.exports;
67
- var chunk = /*@__PURE__*/getDefaultExportFromCjs(chunkExports);
68
-
69
- const client = new clientRoute53.Route53Client({});
70
- const handler = async (event)=>{
71
- const type = event.RequestType;
72
- const hostedZoneId = event.ResourceProperties.hostedZoneId;
73
- console.log('Type:', type);
74
- console.log('HostedZoneId:', hostedZoneId);
75
- try {
76
- if (type === 'Delete') {
77
- const records = await listHostedZoneRecords(hostedZoneId);
78
- console.log('Records:', records);
79
- await deleteHostedZoneRecords(hostedZoneId, records);
80
- }
81
- await send(event, hostedZoneId, 'SUCCESS');
82
- } catch (error) {
83
- if (error instanceof Error) {
84
- await send(event, hostedZoneId, 'FAILED', {}, error.message);
85
- } else {
86
- await send(event, hostedZoneId, 'FAILED', {}, 'Unknown error');
87
- }
88
- console.error(error);
89
- }
90
- };
91
- const deleteHostedZoneRecords = async (hostedZoneId, records)=>{
92
- records = records.filter((record)=>![
93
- 'SOA',
94
- 'NS'
95
- ].includes(record.Type));
96
- if (records.length === 0) {
97
- return;
98
- }
99
- await Promise.all(chunk(records, 100).map(async (records)=>{
100
- await client.send(new clientRoute53.ChangeResourceRecordSetsCommand({
101
- HostedZoneId: hostedZoneId,
102
- ChangeBatch: {
103
- Changes: records.map((record)=>({
104
- Action: 'DELETE',
105
- ResourceRecordSet: record
106
- }))
107
- }
108
- }));
109
- }));
110
- };
111
- const listHostedZoneRecords = async (hostedZoneId)=>{
112
- const records = [];
113
- let token;
114
- while(true){
115
- const result = await client.send(new clientRoute53.ListResourceRecordSetsCommand({
116
- HostedZoneId: hostedZoneId,
117
- StartRecordName: token
118
- }));
119
- if (result.ResourceRecordSets && result.ResourceRecordSets.length) {
120
- records.push(...result.ResourceRecordSets);
121
- }
122
- if (result.NextRecordName) {
123
- token = result.NextRecordName;
124
- } else {
125
- return records;
126
- }
127
- }
128
- };
129
-
130
- exports.handler = handler;
@@ -1,128 +0,0 @@
1
- import { Route53Client, ChangeResourceRecordSetsCommand, ListResourceRecordSetsCommand } from '@aws-sdk/client-route-53';
2
-
3
- const send = async (event, id, status, data, reason = '')=>{
4
- const body = JSON.stringify({
5
- Status: status,
6
- Reason: reason,
7
- PhysicalResourceId: id,
8
- StackId: event.StackId,
9
- RequestId: event.RequestId,
10
- LogicalResourceId: event.LogicalResourceId,
11
- NoEcho: false,
12
- Data: data
13
- });
14
- await fetch(event.ResponseURL, {
15
- method: 'PUT',
16
- // @ts-ignore
17
- port: 443,
18
- body,
19
- headers: {
20
- 'content-type': '',
21
- 'content-length': Buffer.from(body).byteLength.toString()
22
- }
23
- });
24
- };
25
-
26
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
27
-
28
- function getDefaultExportFromCjs (x) {
29
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
30
- }
31
-
32
- var chunk$1 = {exports: {}};
33
-
34
- (function (module, exports) {
35
-
36
- (function () {
37
- function chunk(collection, size) {
38
- var result = [];
39
-
40
- // default size to two item
41
- size = parseInt(size) || 2;
42
-
43
- // add each chunk to the result
44
- for (var x = 0; x < Math.ceil(collection.length / size); x++) {
45
- var start = x * size;
46
- var end = start + size;
47
-
48
- result.push(collection.slice(start, end));
49
- }
50
-
51
- return result;
52
- }
53
-
54
- // export in node or browser
55
- {
56
- if (module.exports) {
57
- exports = module.exports = chunk;
58
- }
59
- exports.chunk = chunk;
60
- }
61
- }.call(commonjsGlobal));
62
- } (chunk$1, chunk$1.exports));
63
-
64
- var chunkExports = chunk$1.exports;
65
- var chunk = /*@__PURE__*/getDefaultExportFromCjs(chunkExports);
66
-
67
- const client = new Route53Client({});
68
- const handler = async (event)=>{
69
- const type = event.RequestType;
70
- const hostedZoneId = event.ResourceProperties.hostedZoneId;
71
- console.log('Type:', type);
72
- console.log('HostedZoneId:', hostedZoneId);
73
- try {
74
- if (type === 'Delete') {
75
- const records = await listHostedZoneRecords(hostedZoneId);
76
- console.log('Records:', records);
77
- await deleteHostedZoneRecords(hostedZoneId, records);
78
- }
79
- await send(event, hostedZoneId, 'SUCCESS');
80
- } catch (error) {
81
- if (error instanceof Error) {
82
- await send(event, hostedZoneId, 'FAILED', {}, error.message);
83
- } else {
84
- await send(event, hostedZoneId, 'FAILED', {}, 'Unknown error');
85
- }
86
- console.error(error);
87
- }
88
- };
89
- const deleteHostedZoneRecords = async (hostedZoneId, records)=>{
90
- records = records.filter((record)=>![
91
- 'SOA',
92
- 'NS'
93
- ].includes(record.Type));
94
- if (records.length === 0) {
95
- return;
96
- }
97
- await Promise.all(chunk(records, 100).map(async (records)=>{
98
- await client.send(new ChangeResourceRecordSetsCommand({
99
- HostedZoneId: hostedZoneId,
100
- ChangeBatch: {
101
- Changes: records.map((record)=>({
102
- Action: 'DELETE',
103
- ResourceRecordSet: record
104
- }))
105
- }
106
- }));
107
- }));
108
- };
109
- const listHostedZoneRecords = async (hostedZoneId)=>{
110
- const records = [];
111
- let token;
112
- while(true){
113
- const result = await client.send(new ListResourceRecordSetsCommand({
114
- HostedZoneId: hostedZoneId,
115
- StartRecordName: token
116
- }));
117
- if (result.ResourceRecordSets && result.ResourceRecordSets.length) {
118
- records.push(...result.ResourceRecordSets);
119
- }
120
- if (result.NextRecordName) {
121
- token = result.NextRecordName;
122
- } else {
123
- return records;
124
- }
125
- }
126
- };
127
-
128
- export { handler };
@@ -1 +0,0 @@
1
- 24e4c709abee1432751de78eedbf776fa574e8e4
@@ -1,63 +0,0 @@
1
- 'use strict';
2
-
3
- var clientCloudformation = require('@aws-sdk/client-cloudformation');
4
-
5
- const send = async (event, id, status, data, reason = '')=>{
6
- const body = JSON.stringify({
7
- Status: status,
8
- Reason: reason,
9
- PhysicalResourceId: id,
10
- StackId: event.StackId,
11
- RequestId: event.RequestId,
12
- LogicalResourceId: event.LogicalResourceId,
13
- NoEcho: false,
14
- Data: data
15
- });
16
- await fetch(event.ResponseURL, {
17
- method: 'PUT',
18
- // @ts-ignore
19
- port: 443,
20
- body,
21
- headers: {
22
- 'content-type': '',
23
- 'content-length': Buffer.from(body).byteLength.toString()
24
- }
25
- });
26
- };
27
-
28
- const handler = async (event)=>{
29
- const region = event.ResourceProperties.region;
30
- try {
31
- const data = await listExports(region);
32
- await send(event, region, 'SUCCESS', data);
33
- } catch (error) {
34
- if (error instanceof Error) {
35
- await send(event, region, 'FAILED', {}, error.message);
36
- } else {
37
- await send(event, region, 'FAILED', {}, 'Unknown error');
38
- }
39
- console.error(error);
40
- }
41
- };
42
- const listExports = async (region)=>{
43
- const client = new clientCloudformation.CloudFormationClient({
44
- region
45
- });
46
- const data = {};
47
- let token;
48
- while(true){
49
- const result = await client.send(new clientCloudformation.ListExportsCommand({
50
- NextToken: token
51
- }));
52
- result.Exports?.forEach((item)=>{
53
- data[item.Name] = item.Value;
54
- });
55
- if (result.NextToken) {
56
- token = result.NextToken;
57
- } else {
58
- return data;
59
- }
60
- }
61
- };
62
-
63
- exports.handler = handler;
@@ -1,61 +0,0 @@
1
- import { CloudFormationClient, ListExportsCommand } from '@aws-sdk/client-cloudformation';
2
-
3
- const send = async (event, id, status, data, reason = '')=>{
4
- const body = JSON.stringify({
5
- Status: status,
6
- Reason: reason,
7
- PhysicalResourceId: id,
8
- StackId: event.StackId,
9
- RequestId: event.RequestId,
10
- LogicalResourceId: event.LogicalResourceId,
11
- NoEcho: false,
12
- Data: data
13
- });
14
- await fetch(event.ResponseURL, {
15
- method: 'PUT',
16
- // @ts-ignore
17
- port: 443,
18
- body,
19
- headers: {
20
- 'content-type': '',
21
- 'content-length': Buffer.from(body).byteLength.toString()
22
- }
23
- });
24
- };
25
-
26
- const handler = async (event)=>{
27
- const region = event.ResourceProperties.region;
28
- try {
29
- const data = await listExports(region);
30
- await send(event, region, 'SUCCESS', data);
31
- } catch (error) {
32
- if (error instanceof Error) {
33
- await send(event, region, 'FAILED', {}, error.message);
34
- } else {
35
- await send(event, region, 'FAILED', {}, 'Unknown error');
36
- }
37
- console.error(error);
38
- }
39
- };
40
- const listExports = async (region)=>{
41
- const client = new CloudFormationClient({
42
- region
43
- });
44
- const data = {};
45
- let token;
46
- while(true){
47
- const result = await client.send(new ListExportsCommand({
48
- NextToken: token
49
- }));
50
- result.Exports?.forEach((item)=>{
51
- data[item.Name] = item.Value;
52
- });
53
- if (result.NextToken) {
54
- token = result.NextToken;
55
- } else {
56
- return data;
57
- }
58
- }
59
- };
60
-
61
- export { handler };
@@ -1 +0,0 @@
1
- 57596b321a7e724d843a87434ff5bb3cc0b46931
@@ -1,63 +0,0 @@
1
- 'use strict';
2
-
3
- var clientCloudfront = require('@aws-sdk/client-cloudfront');
4
-
5
- const send = async (event, id, status, data, reason = '')=>{
6
- const body = JSON.stringify({
7
- Status: status,
8
- Reason: reason,
9
- PhysicalResourceId: id,
10
- StackId: event.StackId,
11
- RequestId: event.RequestId,
12
- LogicalResourceId: event.LogicalResourceId,
13
- NoEcho: false,
14
- Data: data
15
- });
16
- await fetch(event.ResponseURL, {
17
- method: 'PUT',
18
- // @ts-ignore
19
- port: 443,
20
- body,
21
- headers: {
22
- 'content-type': '',
23
- 'content-length': Buffer.from(body).byteLength.toString()
24
- }
25
- });
26
- };
27
-
28
- const client = new clientCloudfront.CloudFrontClient({});
29
- const handler = async (event)=>{
30
- const type = event.RequestType;
31
- const { distributionId, paths } = event.ResourceProperties;
32
- console.log('Type', type);
33
- console.log('DistributionId', distributionId);
34
- console.log('Paths', paths);
35
- try {
36
- if (type === 'Update') {
37
- await invalidateCache(distributionId, paths);
38
- }
39
- await send(event, distributionId, 'SUCCESS');
40
- } catch (error) {
41
- if (error instanceof Error) {
42
- await send(event, distributionId, 'FAILED', {}, error.message);
43
- } else {
44
- await send(event, distributionId, 'FAILED', {}, 'Unknown error');
45
- }
46
- console.error(error);
47
- }
48
- };
49
- const invalidateCache = async (distributionId, paths)=>{
50
- const result = await client.send(new clientCloudfront.CreateInvalidationCommand({
51
- DistributionId: distributionId,
52
- InvalidationBatch: {
53
- CallerReference: Date.now().toString(),
54
- Paths: {
55
- Quantity: paths.length,
56
- Items: paths
57
- }
58
- }
59
- }));
60
- return result.Invalidation.Id;
61
- };
62
-
63
- exports.handler = handler;
@@ -1,61 +0,0 @@
1
- import { CloudFrontClient, CreateInvalidationCommand } from '@aws-sdk/client-cloudfront';
2
-
3
- const send = async (event, id, status, data, reason = '')=>{
4
- const body = JSON.stringify({
5
- Status: status,
6
- Reason: reason,
7
- PhysicalResourceId: id,
8
- StackId: event.StackId,
9
- RequestId: event.RequestId,
10
- LogicalResourceId: event.LogicalResourceId,
11
- NoEcho: false,
12
- Data: data
13
- });
14
- await fetch(event.ResponseURL, {
15
- method: 'PUT',
16
- // @ts-ignore
17
- port: 443,
18
- body,
19
- headers: {
20
- 'content-type': '',
21
- 'content-length': Buffer.from(body).byteLength.toString()
22
- }
23
- });
24
- };
25
-
26
- const client = new CloudFrontClient({});
27
- const handler = async (event)=>{
28
- const type = event.RequestType;
29
- const { distributionId, paths } = event.ResourceProperties;
30
- console.log('Type', type);
31
- console.log('DistributionId', distributionId);
32
- console.log('Paths', paths);
33
- try {
34
- if (type === 'Update') {
35
- await invalidateCache(distributionId, paths);
36
- }
37
- await send(event, distributionId, 'SUCCESS');
38
- } catch (error) {
39
- if (error instanceof Error) {
40
- await send(event, distributionId, 'FAILED', {}, error.message);
41
- } else {
42
- await send(event, distributionId, 'FAILED', {}, 'Unknown error');
43
- }
44
- console.error(error);
45
- }
46
- };
47
- const invalidateCache = async (distributionId, paths)=>{
48
- const result = await client.send(new CreateInvalidationCommand({
49
- DistributionId: distributionId,
50
- InvalidationBatch: {
51
- CallerReference: Date.now().toString(),
52
- Paths: {
53
- Quantity: paths.length,
54
- Items: paths
55
- }
56
- }
57
- }));
58
- return result.Invalidation.Id;
59
- };
60
-
61
- export { handler };
@@ -1 +0,0 @@
1
- 022a1f0af1891993ff757275d5ed82fc70eabb74