@bref.sh/layers 2.0.20 → 2.0.22

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.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ NPM package to use Bref runtimes on AWS Lambda.
2
+
3
+ This package is useful is you need to reference the Bref layers from a NodeJS application. For example if you use the **AWS CDK**, **Pulumi**, etc.
4
+
5
+ > **Note**
6
+ >
7
+ > If you are using the AWS CDK, you might be interested in [the `@bref.sh/constructs` package](https://github.com/brefphp/constructs) instead.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @bref/layers
13
+ ```
14
+
15
+ ## Version compatibility with Bref
16
+
17
+ This package is compatible with Bref 2.0 and above.
18
+
19
+ This NPM package and Bref are compatible as long as they have the same **major** version. For example:
20
+
21
+ - v**2**.x.y of this package is compatible with v**2**.z.w of Bref
22
+ - v**3**.x.y of this package is **NOT** compatible with v**2**.z.w of Bref
23
+ - v**2**.x.y of this package is **NOT** compatible with v**1**.z.w of Bref
24
+ - etc.
25
+
26
+ All minor and patch versions are not important. Only the major version matters. That means you can upgrade Bref separately from upgrading this package (though it's always good to stay on the latest versions).
27
+
28
+ ## Usage
29
+
30
+ Get a layer version:
31
+
32
+ ```js
33
+ import { layerVersions } from '@bref.sh/layers';
34
+
35
+ console.log(layerVersions['php-82']['us-east-1']);
36
+ console.log(layerVersions['php-82-fpm']['eu-west-3']);
37
+ ```
38
+
39
+ Helpers to get a full ARN:
40
+
41
+ ```js
42
+ import { functionLayerArn, fpmLayerArn, consoleLayerArn } from '@bref.sh/layers';
43
+
44
+ console.log(functionLayerArn(region, '8.2'));
45
+ console.log(functionLayerArn(region, '8.1', 'arm'));
46
+
47
+ console.log(fpmLayerArn(region, '8.2'));
48
+ console.log(fpmLayerArn(region, '8.1', 'arm'));
49
+
50
+ console.log(consoleLayerArn(region));
51
+ ```
package/layers.js CHANGED
@@ -8,12 +8,15 @@ const layerVersions = require('./layers.json');
8
8
  * @param {'x86'|'arm'} platform
9
9
  * @returns {string} Layer ARN
10
10
  */
11
- function functionLayerArn(region, phpVersion, platform) {
11
+ function functionLayerArn(region, phpVersion, platform = 'x86') {
12
12
  let layerName = 'php-' + phpVersion.replace('.', '');
13
13
  if (platform === 'arm') {
14
14
  layerName = 'arm-' + layerName;
15
15
  }
16
- const version = layerVersions[layerName][region];
16
+ const version = layerVersions[layerName]?.[region];
17
+ if (!version) {
18
+ throw new Error(`PHP version ${phpVersion} in ${region} is not supported`);
19
+ }
17
20
  return `arn:aws:lambda:${region}:534081306603:layer:${layerName}:${version}`;
18
21
  }
19
22
 
@@ -24,12 +27,15 @@ function functionLayerArn(region, phpVersion, platform) {
24
27
  * @param {'x86'|'arm'} platform
25
28
  * @returns {string} Layer ARN
26
29
  */
27
- function fpmLayerArn(region, phpVersion, platform) {
30
+ function fpmLayerArn(region, phpVersion, platform = 'x86') {
28
31
  let layerName = 'php-' + phpVersion.replace('.', '') + '-fpm';
29
32
  if (platform === 'arm') {
30
33
  layerName = 'arm-' + layerName;
31
34
  }
32
- const version = layerVersions[layerName][region];
35
+ const version = layerVersions[layerName]?.[region];
36
+ if (!version) {
37
+ throw new Error(`PHP version ${phpVersion} in ${region} is not supported`);
38
+ }
33
39
  return `arn:aws:lambda:${region}:534081306603:layer:${layerName}:${version}`;
34
40
  }
35
41
 
@@ -40,6 +46,9 @@ function fpmLayerArn(region, phpVersion, platform) {
40
46
  */
41
47
  function consoleLayerArn(region) {
42
48
  const version = layerVersions.console[region];
49
+ if (!version) {
50
+ throw new Error(`Console layer does not exist in region ${region}`);
51
+ }
43
52
  return `arn:aws:lambda:${region}:534081306603:layer:console:${version}`;
44
53
  }
45
54
 
package/layers.json CHANGED
@@ -1,209 +1,255 @@
1
1
  {
2
2
  "php-82": {
3
- "af-south-1": "10",
4
- "ap-east-1": "10",
5
- "ap-northeast-1": "10",
6
- "ap-northeast-2": "10",
7
- "ap-northeast-3": "10",
8
- "ap-south-1": "10",
9
- "ap-southeast-1": "10",
10
- "ap-southeast-2": "10",
11
- "ca-central-1": "10",
12
- "eu-central-1": "10",
13
- "eu-north-1": "10",
14
- "eu-south-1": "10",
15
- "eu-west-1": "10",
16
- "eu-west-2": "10",
17
- "eu-west-3": "10",
18
- "me-south-1": "10",
19
- "sa-east-1": "10",
20
- "us-east-1": "10",
21
- "us-east-2": "10",
22
- "us-west-1": "10",
23
- "us-west-2": "10"
24
- },
25
- "php-82-fpm": {
26
- "af-south-1": "10",
27
- "ap-east-1": "10",
28
- "ap-northeast-1": "10",
29
- "ap-northeast-2": "10",
30
- "ap-northeast-3": "10",
31
- "ap-south-1": "10",
32
- "ap-southeast-1": "10",
33
- "ap-southeast-2": "10",
34
- "ca-central-1": "10",
35
- "eu-central-1": "10",
36
- "eu-north-1": "10",
37
- "eu-south-1": "10",
38
- "eu-west-1": "10",
39
- "eu-west-2": "10",
40
- "eu-west-3": "10",
41
- "me-south-1": "10",
42
- "sa-east-1": "10",
43
- "us-east-1": "10",
44
- "us-east-2": "10",
45
- "us-west-1": "10",
46
- "us-west-2": "10"
47
- },
48
- "php-81": {
49
3
  "af-south-1": "12",
50
4
  "ap-east-1": "12",
51
- "ap-northeast-1": "19",
52
- "ap-northeast-2": "19",
53
- "ap-northeast-3": "19",
54
- "ap-south-1": "19",
55
- "ap-southeast-1": "19",
56
- "ap-southeast-2": "19",
57
- "ca-central-1": "20",
58
- "eu-central-1": "20",
59
- "eu-north-1": "20",
5
+ "ap-northeast-1": "12",
6
+ "ap-northeast-2": "12",
7
+ "ap-northeast-3": "12",
8
+ "ap-south-1": "12",
9
+ "ap-southeast-1": "12",
10
+ "ap-southeast-2": "12",
11
+ "ca-central-1": "12",
12
+ "eu-central-1": "12",
13
+ "eu-north-1": "12",
60
14
  "eu-south-1": "12",
61
- "eu-west-1": "20",
62
- "eu-west-2": "20",
63
- "eu-west-3": "20",
15
+ "eu-west-1": "12",
16
+ "eu-west-2": "12",
17
+ "eu-west-3": "12",
64
18
  "me-south-1": "12",
65
- "sa-east-1": "20",
66
- "us-east-1": "20",
67
- "us-east-2": "20",
68
- "us-west-1": "20",
69
- "us-west-2": "20"
19
+ "sa-east-1": "12",
20
+ "us-east-1": "12",
21
+ "us-east-2": "12",
22
+ "us-west-1": "12",
23
+ "us-west-2": "12"
70
24
  },
71
- "php-81-fpm": {
25
+ "php-82-fpm": {
72
26
  "af-south-1": "12",
73
27
  "ap-east-1": "12",
74
- "ap-northeast-1": "19",
75
- "ap-northeast-2": "19",
76
- "ap-northeast-3": "19",
77
- "ap-south-1": "19",
78
- "ap-southeast-1": "19",
79
- "ap-southeast-2": "19",
80
- "ca-central-1": "20",
81
- "eu-central-1": "20",
82
- "eu-north-1": "20",
28
+ "ap-northeast-1": "12",
29
+ "ap-northeast-2": "12",
30
+ "ap-northeast-3": "12",
31
+ "ap-south-1": "12",
32
+ "ap-southeast-1": "12",
33
+ "ap-southeast-2": "12",
34
+ "ca-central-1": "12",
35
+ "eu-central-1": "12",
36
+ "eu-north-1": "12",
83
37
  "eu-south-1": "12",
84
- "eu-west-1": "20",
85
- "eu-west-2": "20",
86
- "eu-west-3": "20",
38
+ "eu-west-1": "12",
39
+ "eu-west-2": "12",
40
+ "eu-west-3": "12",
87
41
  "me-south-1": "12",
88
- "sa-east-1": "20",
89
- "us-east-1": "20",
90
- "us-east-2": "20",
91
- "us-west-1": "20",
92
- "us-west-2": "20"
42
+ "sa-east-1": "12",
43
+ "us-east-1": "12",
44
+ "us-east-2": "12",
45
+ "us-west-1": "12",
46
+ "us-west-2": "12"
93
47
  },
94
- "php-80": {
95
- "af-south-1": "12",
96
- "ap-east-1": "12",
97
- "ap-northeast-1": "19",
98
- "ap-northeast-2": "19",
99
- "ap-northeast-3": "19",
48
+ "php-81": {
49
+ "af-south-1": "14",
50
+ "ap-east-1": "14",
51
+ "ap-northeast-1": "21",
52
+ "ap-northeast-2": "21",
53
+ "ap-northeast-3": "21",
100
54
  "ap-south-1": "21",
101
- "ap-southeast-1": "19",
55
+ "ap-southeast-1": "21",
102
56
  "ap-southeast-2": "21",
103
57
  "ca-central-1": "22",
104
58
  "eu-central-1": "22",
105
59
  "eu-north-1": "22",
106
- "eu-south-1": "12",
60
+ "eu-south-1": "14",
107
61
  "eu-west-1": "22",
108
62
  "eu-west-2": "22",
109
63
  "eu-west-3": "22",
110
- "me-south-1": "12",
64
+ "me-south-1": "14",
65
+ "sa-east-1": "22",
66
+ "us-east-1": "22",
67
+ "us-east-2": "22",
68
+ "us-west-1": "22",
69
+ "us-west-2": "22"
70
+ },
71
+ "php-81-fpm": {
72
+ "af-south-1": "14",
73
+ "ap-east-1": "14",
74
+ "ap-northeast-1": "21",
75
+ "ap-northeast-2": "21",
76
+ "ap-northeast-3": "21",
77
+ "ap-south-1": "21",
78
+ "ap-southeast-1": "21",
79
+ "ap-southeast-2": "21",
80
+ "ca-central-1": "22",
81
+ "eu-central-1": "22",
82
+ "eu-north-1": "22",
83
+ "eu-south-1": "14",
84
+ "eu-west-1": "22",
85
+ "eu-west-2": "22",
86
+ "eu-west-3": "22",
87
+ "me-south-1": "14",
111
88
  "sa-east-1": "22",
112
89
  "us-east-1": "22",
113
90
  "us-east-2": "22",
114
91
  "us-west-1": "22",
115
92
  "us-west-2": "22"
116
93
  },
94
+ "php-80": {
95
+ "af-south-1": "14",
96
+ "ap-east-1": "14",
97
+ "ap-northeast-1": "21",
98
+ "ap-northeast-2": "21",
99
+ "ap-northeast-3": "21",
100
+ "ap-south-1": "23",
101
+ "ap-southeast-1": "21",
102
+ "ap-southeast-2": "23",
103
+ "ca-central-1": "24",
104
+ "eu-central-1": "24",
105
+ "eu-north-1": "24",
106
+ "eu-south-1": "14",
107
+ "eu-west-1": "24",
108
+ "eu-west-2": "24",
109
+ "eu-west-3": "24",
110
+ "me-south-1": "14",
111
+ "sa-east-1": "24",
112
+ "us-east-1": "24",
113
+ "us-east-2": "24",
114
+ "us-west-1": "24",
115
+ "us-west-2": "24"
116
+ },
117
117
  "php-80-fpm": {
118
- "af-south-1": "12",
119
- "ap-east-1": "12",
120
- "ap-northeast-1": "19",
121
- "ap-northeast-2": "19",
122
- "ap-northeast-3": "19",
123
- "ap-south-1": "19",
124
- "ap-southeast-1": "19",
125
- "ap-southeast-2": "19",
126
- "ca-central-1": "20",
127
- "eu-central-1": "20",
128
- "eu-north-1": "20",
129
- "eu-south-1": "12",
130
- "eu-west-1": "20",
131
- "eu-west-2": "20",
132
- "eu-west-3": "20",
133
- "me-south-1": "12",
134
- "sa-east-1": "20",
135
- "us-east-1": "20",
136
- "us-east-2": "20",
137
- "us-west-1": "20",
138
- "us-west-2": "20"
118
+ "af-south-1": "14",
119
+ "ap-east-1": "14",
120
+ "ap-northeast-1": "21",
121
+ "ap-northeast-2": "21",
122
+ "ap-northeast-3": "21",
123
+ "ap-south-1": "21",
124
+ "ap-southeast-1": "21",
125
+ "ap-southeast-2": "21",
126
+ "ca-central-1": "22",
127
+ "eu-central-1": "22",
128
+ "eu-north-1": "22",
129
+ "eu-south-1": "14",
130
+ "eu-west-1": "22",
131
+ "eu-west-2": "22",
132
+ "eu-west-3": "22",
133
+ "me-south-1": "14",
134
+ "sa-east-1": "22",
135
+ "us-east-1": "22",
136
+ "us-east-2": "22",
137
+ "us-west-1": "22",
138
+ "us-west-2": "22"
139
+ },
140
+ "arm-php-81": {
141
+ "af-south-1": "2",
142
+ "ap-east-1": "2",
143
+ "ap-northeast-1": "2",
144
+ "ap-northeast-2": "2",
145
+ "ap-northeast-3": "2",
146
+ "ap-south-1": "2",
147
+ "ap-southeast-1": "2",
148
+ "ap-southeast-2": "2",
149
+ "ca-central-1": "2",
150
+ "eu-central-1": "2",
151
+ "eu-north-1": "2",
152
+ "eu-south-1": "2",
153
+ "eu-west-1": "2",
154
+ "eu-west-2": "2",
155
+ "eu-west-3": "2",
156
+ "me-south-1": "2",
157
+ "sa-east-1": "2",
158
+ "us-east-1": "2",
159
+ "us-east-2": "2",
160
+ "us-west-1": "2",
161
+ "us-west-2": "2"
162
+ },
163
+ "arm-php-81-fpm": {
164
+ "af-south-1": "2",
165
+ "ap-east-1": "2",
166
+ "ap-northeast-1": "2",
167
+ "ap-northeast-2": "2",
168
+ "ap-northeast-3": "2",
169
+ "ap-south-1": "2",
170
+ "ap-southeast-1": "2",
171
+ "ap-southeast-2": "2",
172
+ "ca-central-1": "2",
173
+ "eu-central-1": "2",
174
+ "eu-north-1": "2",
175
+ "eu-south-1": "2",
176
+ "eu-west-1": "2",
177
+ "eu-west-2": "2",
178
+ "eu-west-3": "2",
179
+ "me-south-1": "2",
180
+ "sa-east-1": "2",
181
+ "us-east-1": "2",
182
+ "us-east-2": "2",
183
+ "us-west-1": "2",
184
+ "us-west-2": "2"
139
185
  },
140
186
  "arm-php-80": {
141
- "af-south-1": "13",
142
- "ap-east-1": "13",
143
- "ap-northeast-1": "20",
144
- "ap-northeast-2": "20",
145
- "ap-northeast-3": "20",
146
- "ap-south-1": "20",
147
- "ap-southeast-1": "20",
148
- "ap-southeast-2": "20",
149
- "ca-central-1": "21",
150
- "eu-central-1": "20",
151
- "eu-north-1": "21",
152
- "eu-south-1": "13",
153
- "eu-west-1": "21",
154
- "eu-west-2": "21",
155
- "eu-west-3": "21",
156
- "me-south-1": "13",
157
- "sa-east-1": "21",
158
- "us-east-1": "21",
159
- "us-east-2": "21",
160
- "us-west-1": "21",
161
- "us-west-2": "21"
187
+ "af-south-1": "15",
188
+ "ap-east-1": "15",
189
+ "ap-northeast-1": "22",
190
+ "ap-northeast-2": "22",
191
+ "ap-northeast-3": "22",
192
+ "ap-south-1": "22",
193
+ "ap-southeast-1": "22",
194
+ "ap-southeast-2": "22",
195
+ "ca-central-1": "23",
196
+ "eu-central-1": "22",
197
+ "eu-north-1": "23",
198
+ "eu-south-1": "15",
199
+ "eu-west-1": "23",
200
+ "eu-west-2": "23",
201
+ "eu-west-3": "23",
202
+ "me-south-1": "15",
203
+ "sa-east-1": "23",
204
+ "us-east-1": "23",
205
+ "us-east-2": "23",
206
+ "us-west-1": "23",
207
+ "us-west-2": "23"
162
208
  },
163
209
  "arm-php-80-fpm": {
164
- "af-south-1": "12",
165
- "ap-east-1": "12",
166
- "ap-northeast-1": "19",
167
- "ap-northeast-2": "19",
168
- "ap-northeast-3": "19",
169
- "ap-south-1": "19",
170
- "ap-southeast-1": "19",
171
- "ap-southeast-2": "19",
172
- "ca-central-1": "20",
173
- "eu-central-1": "20",
174
- "eu-north-1": "20",
175
- "eu-south-1": "12",
176
- "eu-west-1": "20",
177
- "eu-west-2": "20",
178
- "eu-west-3": "20",
179
- "me-south-1": "12",
180
- "sa-east-1": "20",
181
- "us-east-1": "20",
182
- "us-east-2": "20",
183
- "us-west-1": "20",
184
- "us-west-2": "20"
210
+ "af-south-1": "14",
211
+ "ap-east-1": "14",
212
+ "ap-northeast-1": "21",
213
+ "ap-northeast-2": "21",
214
+ "ap-northeast-3": "21",
215
+ "ap-south-1": "21",
216
+ "ap-southeast-1": "21",
217
+ "ap-southeast-2": "21",
218
+ "ca-central-1": "22",
219
+ "eu-central-1": "22",
220
+ "eu-north-1": "22",
221
+ "eu-south-1": "14",
222
+ "eu-west-1": "22",
223
+ "eu-west-2": "22",
224
+ "eu-west-3": "22",
225
+ "me-south-1": "14",
226
+ "sa-east-1": "22",
227
+ "us-east-1": "22",
228
+ "us-east-2": "22",
229
+ "us-west-1": "22",
230
+ "us-west-2": "22"
185
231
  },
186
232
  "console": {
187
- "af-south-1": "12",
188
- "ap-east-1": "12",
189
- "ap-northeast-1": "19",
190
- "ap-northeast-2": "19",
191
- "ap-northeast-3": "19",
192
- "ap-south-1": "19",
193
- "ap-southeast-1": "19",
194
- "ap-southeast-2": "19",
195
- "ca-central-1": "20",
196
- "eu-central-1": "20",
197
- "eu-north-1": "20",
198
- "eu-south-1": "12",
199
- "eu-west-1": "20",
200
- "eu-west-2": "20",
201
- "eu-west-3": "20",
202
- "me-south-1": "12",
203
- "sa-east-1": "20",
204
- "us-east-1": "20",
205
- "us-east-2": "20",
206
- "us-west-1": "20",
207
- "us-west-2": "20"
233
+ "af-south-1": "14",
234
+ "ap-east-1": "14",
235
+ "ap-northeast-1": "21",
236
+ "ap-northeast-2": "21",
237
+ "ap-northeast-3": "21",
238
+ "ap-south-1": "21",
239
+ "ap-southeast-1": "21",
240
+ "ap-southeast-2": "21",
241
+ "ca-central-1": "22",
242
+ "eu-central-1": "22",
243
+ "eu-north-1": "22",
244
+ "eu-south-1": "14",
245
+ "eu-west-1": "22",
246
+ "eu-west-2": "22",
247
+ "eu-west-3": "22",
248
+ "me-south-1": "14",
249
+ "sa-east-1": "22",
250
+ "us-east-1": "22",
251
+ "us-east-2": "22",
252
+ "us-west-1": "22",
253
+ "us-west-2": "22"
208
254
  }
209
255
  }
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@bref.sh/layers",
3
- "version": "2.0.20",
3
+ "version": "2.0.22",
4
4
  "description": "Bref.sh AWS Lambda layers",
5
5
  "repository": "brefphp/layers.js",
6
6
  "license": "MIT",
7
7
  "main": "layers.js",
8
8
  "scripts": {
9
- "update": "node scripts/update.js"
9
+ "update": "node scripts/update.js",
10
+ "test": "vitest"
10
11
  },
11
12
  "devDependencies": {
12
13
  "@aws-sdk/client-lambda": "^3.192.0",
13
- "chunk": "^0.0.3"
14
+ "chunk": "^0.0.3",
15
+ "vitest": "^0.25.8"
14
16
  },
15
17
  "engines": {
16
18
  "node": ">=12.12"
package/vite.config.js ADDED
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ // ...
6
+ },
7
+ })