@gigadrive/network-config 1.0.0 → 2.0.0
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/LICENSE +201 -0
- package/dist/index.d.mts +127 -0
- package/dist/index.d.ts +127 -0
- package/dist/index.js +15971 -2
- package/dist/index.js.map +1 -7
- package/dist/index.mjs +393 -0
- package/dist/index.mjs.map +1 -0
- package/dist/v4/schema.json +334 -0
- package/package.json +27 -12
- package/src/v4/schema.json +334 -0
- package/tsconfig.json +7 -0
- package/dist/build-output-v3/index.js +0 -1
- package/dist/build-output-v3/index.js.map +0 -7
- package/dist/build-output-v3/parse.js +0 -2
- package/dist/build-output-v3/parse.js.map +0 -7
- package/dist/normalized-config.js +0 -2
- package/dist/normalized-config.js.map +0 -7
- package/dist/parse-raw-config.js +0 -2
- package/dist/parse-raw-config.js.map +0 -7
- package/dist/regions.js +0 -2
- package/dist/regions.js.map +0 -7
- package/dist/runtime.js +0 -2
- package/dist/runtime.js.map +0 -7
- package/dist/v4/index.js +0 -1
- package/dist/v4/index.js.map +0 -7
- package/dist/v4/parse.js +0 -2
- package/dist/v4/parse.js.map +0 -7
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Config V4",
|
|
4
|
+
"description": "Configuration schema for version 4",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["version"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"version": {
|
|
9
|
+
"type": "integer",
|
|
10
|
+
"enum": [4],
|
|
11
|
+
"description": "The version of the configuration file"
|
|
12
|
+
},
|
|
13
|
+
"presets": {
|
|
14
|
+
"type": ["array", "null"],
|
|
15
|
+
"items": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"format": "uri"
|
|
18
|
+
},
|
|
19
|
+
"description": "A list of presets to apply to the project. Each preset will be applied in order."
|
|
20
|
+
},
|
|
21
|
+
"assets": {
|
|
22
|
+
"type": ["string", "null"],
|
|
23
|
+
"description": "The folder which holds the assets to be deployed to the edge. Defaults to none."
|
|
24
|
+
},
|
|
25
|
+
"populateAssetCache": {
|
|
26
|
+
"type": ["boolean", "null"],
|
|
27
|
+
"description": "If true, the assets will be cached at the edge during deployment. This may increase the deployment time, depending on the size of the assets. Defaults to false."
|
|
28
|
+
},
|
|
29
|
+
"regions": {
|
|
30
|
+
"type": ["array", "null"],
|
|
31
|
+
"description": "The regions to which the project will be deployed. Use \"global\" to deploy to all regions. More regions will incur higher costs.",
|
|
32
|
+
"items": {
|
|
33
|
+
"type": "string"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"build_commands": {
|
|
37
|
+
"type": ["array", "null"],
|
|
38
|
+
"description": "The commands to run to build the project. For example, `bun install` or `npm install`.",
|
|
39
|
+
"items": {
|
|
40
|
+
"type": "string"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"functions": {
|
|
44
|
+
"type": ["object", "null"],
|
|
45
|
+
"description": "The serverless functions to deploy.",
|
|
46
|
+
"additionalProperties": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"properties": {
|
|
49
|
+
"memory": {
|
|
50
|
+
"type": "number",
|
|
51
|
+
"description": "The memory in MB to allocate to the function. Defaults to 128.",
|
|
52
|
+
"maximum": 3009,
|
|
53
|
+
"minimum": 128
|
|
54
|
+
},
|
|
55
|
+
"max_duration": {
|
|
56
|
+
"type": "number",
|
|
57
|
+
"description": "The max duration in seconds for the function after which it will be terminated. Defaults to 30.",
|
|
58
|
+
"maximum": 900,
|
|
59
|
+
"minimum": 1
|
|
60
|
+
},
|
|
61
|
+
"runtime": {
|
|
62
|
+
"$ref": "#/$defs/runtimes",
|
|
63
|
+
"description": "The runtime to use for the function."
|
|
64
|
+
},
|
|
65
|
+
"schedule": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "An expression to schedule the function to run at specific times.",
|
|
68
|
+
"pattern": "^(?:rate[(](?:(?:1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/][0-9]+))?)*)))|(?:(?:(?:(?:(?:[1-3]?[0-9])W?)|LW|[L*])(?:(?:[-](?:(?:(?:[1-3]?[0-9])W?)|LW|[L*]))|(?:[/][0-9]+))?(?:[,](?:(?:(?:[1-3]?[0-9])W?)|LW|[L*])(?:(?:[-](?:(?:(?:[1-3]?[0-9])W?)|LW|[L*]))|(?:[/][0-9]+))?)*)[ ]+(?:(?:(?:[1]?[0-9])|(?:JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)|[*])(?:(?:[-](?:(?:[1]?[0-9])|(?:JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)|[*])(?:[/][0-9]+)?)|(?:[/][0-9]+))?(?:[,](?:(?:[1]?[0-9])|(?:JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)|[*])(?:(?:[-](?:(?:[1]?[0-9])|(?:JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)|[*])(?:[/][0-9]+)?)|(?:[/][0-9]+))?)*)[ ]+[?]))[ ]+(?:(?:(?:[12][0-9]{3})|[*])(?:(?:[-](?:(?:[12][0-9]{3})|[*]))|(?:[/][0-9]+))?(?:[,](?:(?:[12][0-9]{3})|[*])(?:(?:[-](?:(?:[12][0-9]{3})|[*]))|(?:[/][0-9]+))?)*)[)])$"
|
|
69
|
+
},
|
|
70
|
+
"symlinks": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"description": "A list of symbolic links to create in the function's package.",
|
|
73
|
+
"maxProperties": 100,
|
|
74
|
+
"minProperties": 1,
|
|
75
|
+
"patternProperties": {
|
|
76
|
+
"^.{1,256}$": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"maxLength": 256
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"additionalProperties": false
|
|
82
|
+
},
|
|
83
|
+
"excludeFiles": {
|
|
84
|
+
"oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }],
|
|
85
|
+
"description": "A glob pattern to match files that should be excluded from your Serverless Function. If you're using a Community Runtime, the behavior might vary."
|
|
86
|
+
},
|
|
87
|
+
"includeFiles": {
|
|
88
|
+
"oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }],
|
|
89
|
+
"description": "A glob pattern to match files that should be included in your Serverless Function. If you're using a Community Runtime, the behavior might vary."
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"env": {
|
|
95
|
+
"type": "object",
|
|
96
|
+
"maxProperties": 100,
|
|
97
|
+
"minProperties": 0,
|
|
98
|
+
"patternProperties": {
|
|
99
|
+
".+": {
|
|
100
|
+
"maxLength": 65536,
|
|
101
|
+
"minLength": 0,
|
|
102
|
+
"type": "string"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"additionalProperties": false,
|
|
106
|
+
"description": "Additional environment variables to set during runtime and build."
|
|
107
|
+
},
|
|
108
|
+
"routes": {
|
|
109
|
+
"type": ["array", "null"],
|
|
110
|
+
"description": "A list of route definitions.",
|
|
111
|
+
"maxItems": 1024,
|
|
112
|
+
"items": {
|
|
113
|
+
"type": "object",
|
|
114
|
+
"required": ["source", "destination"],
|
|
115
|
+
"properties": {
|
|
116
|
+
"source": {
|
|
117
|
+
"description": "A pattern that matches each incoming pathname (excluding querystring).",
|
|
118
|
+
"type": "string",
|
|
119
|
+
"maxLength": 4096
|
|
120
|
+
},
|
|
121
|
+
"destination": {
|
|
122
|
+
"description": "An absolute pathname to an existing resource or an external URL.",
|
|
123
|
+
"type": "string",
|
|
124
|
+
"maxLength": 4096
|
|
125
|
+
},
|
|
126
|
+
"has": {
|
|
127
|
+
"$ref": "#/$defs/matchRequirements"
|
|
128
|
+
},
|
|
129
|
+
"missing": {
|
|
130
|
+
"$ref": "#/$defs/matchRequirements"
|
|
131
|
+
},
|
|
132
|
+
"statusCode": {
|
|
133
|
+
"description": "An optional integer to override the status code of the response.",
|
|
134
|
+
"type": "integer",
|
|
135
|
+
"minimum": 100,
|
|
136
|
+
"maximum": 999
|
|
137
|
+
},
|
|
138
|
+
"redirect": {
|
|
139
|
+
"type": "boolean",
|
|
140
|
+
"description": "An optional boolean to force a redirect response."
|
|
141
|
+
},
|
|
142
|
+
"methods": {
|
|
143
|
+
"type": "array",
|
|
144
|
+
"description": "The HTTP methods to match for the route. Defaults to all methods.",
|
|
145
|
+
"items": {
|
|
146
|
+
"type": "string",
|
|
147
|
+
"enum": ["ANY", "GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"headers": {
|
|
151
|
+
"type": "object",
|
|
152
|
+
"description": "Additional headers to add to the response.",
|
|
153
|
+
"additionalProperties": {
|
|
154
|
+
"type": "string"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"services": {
|
|
161
|
+
"type": "object",
|
|
162
|
+
"description": "Optionally, specify additional services like databases to deploy.",
|
|
163
|
+
"properties": {
|
|
164
|
+
"redis": {
|
|
165
|
+
"oneOf": [
|
|
166
|
+
{
|
|
167
|
+
"type": "null"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"type": "object",
|
|
171
|
+
"properties": {
|
|
172
|
+
"envBindings": {
|
|
173
|
+
"type": "object",
|
|
174
|
+
"description": "Optionally, specify what environment variables the credentials will be bound to. For example: `{ url: 'REDIS_URL' }` will bind the `url` environment variable to the Redis URL. If you don't specify any bindings, they will be bound to the REDIS_URL, REDIS_HOST, REDIS_PORT, REDIS_PASSWORD, REDIS_DB, and REDIS_SSL environment variables.",
|
|
175
|
+
"additionalProperties": false,
|
|
176
|
+
"properties": {
|
|
177
|
+
"url": { "type": "string" },
|
|
178
|
+
"host": { "type": "string" },
|
|
179
|
+
"port": { "type": "string" },
|
|
180
|
+
"password": { "type": "string" },
|
|
181
|
+
"db": { "type": "string" },
|
|
182
|
+
"ssl": { "type": "string" }
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
"primaryRegion": {
|
|
186
|
+
"type": "string",
|
|
187
|
+
"description": "The primary region to deploy the Redis instance to.",
|
|
188
|
+
"enum": [
|
|
189
|
+
"us-east-1",
|
|
190
|
+
"us-east-2",
|
|
191
|
+
"us-west-1",
|
|
192
|
+
"us-west-2",
|
|
193
|
+
"eu-central-1",
|
|
194
|
+
"eu-west-1",
|
|
195
|
+
"eu-west-2",
|
|
196
|
+
"sa-east-1",
|
|
197
|
+
"ap-south-1",
|
|
198
|
+
"ap-northeast-1",
|
|
199
|
+
"ap-southeast-1",
|
|
200
|
+
"ap-southeast-2",
|
|
201
|
+
"us-central1"
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
"readRegions": {
|
|
205
|
+
"type": "array",
|
|
206
|
+
"description": "Optionally, add additional regions to read from. More regions will incur higher costs.",
|
|
207
|
+
"items": {
|
|
208
|
+
"type": "string",
|
|
209
|
+
"enum": [
|
|
210
|
+
"us-east-1",
|
|
211
|
+
"us-east-2",
|
|
212
|
+
"us-west-1",
|
|
213
|
+
"us-west-2",
|
|
214
|
+
"eu-central-1",
|
|
215
|
+
"eu-west-1",
|
|
216
|
+
"eu-west-2",
|
|
217
|
+
"sa-east-1",
|
|
218
|
+
"ap-south-1",
|
|
219
|
+
"ap-northeast-1",
|
|
220
|
+
"ap-southeast-1",
|
|
221
|
+
"ap-southeast-2"
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
"eviction": {
|
|
226
|
+
"type": "boolean",
|
|
227
|
+
"description": "Optionally, enable Redis eviction. This will evict the least recently used keys in order to make space for new ones."
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
"postgres": {
|
|
234
|
+
"oneOf": [
|
|
235
|
+
{
|
|
236
|
+
"type": "null"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"type": "object",
|
|
240
|
+
"properties": {
|
|
241
|
+
"envBindings": {
|
|
242
|
+
"type": "object",
|
|
243
|
+
"description": "Optionally, specify what environment variables the credentials will be bound to. For example: `{ url: 'POSTGRES_URL' }` will bind the `url` environment variable to the Postgres URL. If you don't specify any bindings, they will be bound to the POSTGRES_URL, POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DATABASE environment variables.",
|
|
244
|
+
"additionalProperties": false,
|
|
245
|
+
"properties": {
|
|
246
|
+
"url": { "type": "string" },
|
|
247
|
+
"host": { "type": "string" },
|
|
248
|
+
"port": { "type": "string" },
|
|
249
|
+
"user": { "type": "string" },
|
|
250
|
+
"password": { "type": "string" },
|
|
251
|
+
"database": { "type": "string" }
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
"postgresVersion": {
|
|
255
|
+
"type": "string",
|
|
256
|
+
"description": "The version of Postgres to deploy.",
|
|
257
|
+
"enum": ["17", "16", "15", "14"]
|
|
258
|
+
},
|
|
259
|
+
"region": {
|
|
260
|
+
"type": "string",
|
|
261
|
+
"description": "The region to deploy the Postgres instance to.",
|
|
262
|
+
"enum": [
|
|
263
|
+
"us-east-1",
|
|
264
|
+
"us-east-2",
|
|
265
|
+
"us-west-2",
|
|
266
|
+
"ap-southeast-1",
|
|
267
|
+
"ap-southeast-2",
|
|
268
|
+
"eu-central-1",
|
|
269
|
+
"eu-west-2",
|
|
270
|
+
"sa-east-1"
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
"$defs": {
|
|
281
|
+
"runtimes": {
|
|
282
|
+
"type": "string",
|
|
283
|
+
"enum": ["php-83", "php-82", "php-81", "php-80", "node-20", "node-18", "node-16", "bun-1"]
|
|
284
|
+
},
|
|
285
|
+
"matchRequirements": {
|
|
286
|
+
"description": "An array of requirements that are needed to match",
|
|
287
|
+
"type": "array",
|
|
288
|
+
"maxItems": 16,
|
|
289
|
+
"items": {
|
|
290
|
+
"anyOf": [
|
|
291
|
+
{
|
|
292
|
+
"type": "object",
|
|
293
|
+
"additionalProperties": false,
|
|
294
|
+
"required": ["type", "value"],
|
|
295
|
+
"properties": {
|
|
296
|
+
"type": {
|
|
297
|
+
"description": "The type of request element to check",
|
|
298
|
+
"type": "string",
|
|
299
|
+
"enum": ["host"]
|
|
300
|
+
},
|
|
301
|
+
"value": {
|
|
302
|
+
"description": "A regular expression used to match the value. Named groups can be used in the destination",
|
|
303
|
+
"type": "string",
|
|
304
|
+
"maxLength": 4096
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
"type": "object",
|
|
310
|
+
"additionalProperties": false,
|
|
311
|
+
"required": ["type", "key"],
|
|
312
|
+
"properties": {
|
|
313
|
+
"type": {
|
|
314
|
+
"description": "The type of request element to check",
|
|
315
|
+
"type": "string",
|
|
316
|
+
"enum": ["header", "cookie", "query"]
|
|
317
|
+
},
|
|
318
|
+
"key": {
|
|
319
|
+
"description": "The name of the element contained in the particular type",
|
|
320
|
+
"type": "string",
|
|
321
|
+
"maxLength": 4096
|
|
322
|
+
},
|
|
323
|
+
"value": {
|
|
324
|
+
"description": "A regular expression used to match the value. Named groups can be used in the destination",
|
|
325
|
+
"type": "string",
|
|
326
|
+
"maxLength": 4096
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
]
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import w from"fs";import s from"path";import".";import{getFilesForPattern as j}from"../../../build-utils/src/get-files-for-pattern";import{parseRawConfig as z}from"../parse-raw-config";const R=".vercel/output/config.json",S=".vercel/output/functions/*.func/.vc-config.json",A=async(o,n)=>{const e=await h(s.join(n,R));return!e||e.version<3||(await E(e,o,n),await b(e,o)),o},b=async(o,n)=>{n.assets||(n.assets={paths:[],prefixToStrip:""}),n.assets.overrides={...n.assets.overrides??{},...o.overrides}},E=async(o,n,e)=>{const C=await j(S,e);for(const c of C){const i=await h(s.join(e,c));if(!i){n.errors.push(`Failed to read function config at ${c}`);continue}const r=s.basename(s.dirname(c)).replace(/\.func$/,""),a=M(i.runtime);if(!a){n.errors.push(`Unsupported runtime for function ${r}: ${i.runtime}`);continue}const y=`.vercel/output/functions/${r}.func`,u=i.handler,N=i.maxDuration,v=i.memory;n.regions=Array.from(new Set([...n.regions??[],...(i.regions??["us-east-1"]).map(t=>O(t))]));const d={},f=i.environment;if(f!=null&&typeof f=="object")for(const t of Object.values(f))for(const[m,x]of Object.entries(t))d[m]=x;const g=a==null||a.startsWith("node-")||a.startsWith("bun-"),p={};for(const[t,m]of Object.entries(i.filePathMap??{}))p[s.join(e,t)]=m;n.entrypoints.push({displayName:r,runtime:a,path:u,memory:v??1024,maxDuration:N??15,environmentVariables:d,streaming:g,package:{rootOverwrite:s.join(e,y),filePathMap:p}});const l=g?"SERVERLESS_FUNCTION_STREAMING":"SERVERLESS_FUNCTION";[{path:`/${r}`,methods:["ANY"],headers:{},destination:u,handler:l},...o.routes?.filter(t=>t.dest===`/${r}`).map(t=>({path:t.src??`/${r}`,methods:["ANY"],headers:{},destination:u,handler:l}))??[]].forEach(t=>{n.routes.push(t)})}},h=async o=>w.existsSync(o)?await z(o):null,M=o=>{switch(o){case"nodejs12.x":case"nodejs14.x":case"nodejs16.x":case"nodejs18.x":return"node-18";case"nodejs20.x":case"nodejs22.x":return"node-20";default:return null}},O=o=>({arn1:"eu-north-1",bom1:"ap-south-1",cdg1:"eu-west-3",cle1:"us-east-2",cpt1:"af-south-1",dub1:"eu-west-1",fra1:"eu-central-1",gru1:"sa-east-1",hkg1:"ap-east-1",hnd1:"ap-northeast-1",iad1:"us-east-1",icn1:"ap-northeast-2",kix1:"ap-northeast-3",lhr1:"eu-west-2",pdx1:"us-west-2",sfo1:"us-west-1",sin1:"ap-southeast-1",syd1:"ap-southeast-2"})[o.toLowerCase()]??"us-east-1";export{E as loadFunctions,A as parseVercelBuildOutputV3,h as readConfigFile,O as translateVercelRegion,M as translateVercelRuntime};
|
|
2
|
-
//# sourceMappingURL=parse.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/build-output-v3/parse.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport { type Config, type Route, type ServerlessFunctionConfig } from '.';\nimport { getFilesForPattern } from '../../../build-utils/src/get-files-for-pattern';\nimport type {\n NormalizedConfig,\n NormalizedConfigRoute,\n NormalizedConfigRouteHandler,\n NormalizedConfigRouteMethod,\n} from '../normalized-config';\nimport { parseRawConfig } from '../parse-raw-config';\nimport type { Region } from '../regions';\nimport type { Runtime } from '../runtime';\n\nconst configPath = '.vercel/output/config.json';\nconst functionConfigsPattern = '.vercel/output/functions/*.func/.vc-config.json';\n\n/**\n * Transforms a parsed config file using Vercel's Build Output API v3\n * @param parseResult The result of parsing the existing config file\n * @param projectFolder The path to the project folder\n * @returns\n */\nexport const parseVercelBuildOutputV3 = async (\n parseResult: NormalizedConfig,\n projectFolder: string\n): Promise<NormalizedConfig> => {\n // read config file\n const config = await readConfigFile<Config>(path.join(projectFolder, configPath));\n\n if (!config || config.version < 3) {\n // TODO: Log error\n return parseResult;\n }\n\n // TODO: Routes\n // TODO: Images\n // TODO: Wildcards\n // TODO: Cache\n // TODO: Cron\n // TODO: Edge Functions\n // TODO: Prerender Functions\n\n await loadFunctions(config, parseResult, projectFolder);\n await loadAssetOverrides(config, parseResult);\n\n return parseResult;\n};\n\nconst loadAssetOverrides = async (config: Config, parseResult: NormalizedConfig) => {\n if (!parseResult.assets) {\n parseResult.assets = {\n paths: [],\n prefixToStrip: '',\n };\n }\n\n parseResult.assets.overrides = {\n ...(parseResult.assets.overrides ?? {}),\n ...config.overrides,\n };\n};\n\nexport const loadFunctions = async (config: Config, parseResult: NormalizedConfig, projectFolder: string) => {\n const functionConfigs = await getFilesForPattern(functionConfigsPattern, projectFolder);\n\n // console.debug('functionConfigs', functionConfigs);\n\n for (const functionConfigPath of functionConfigs) {\n const functionConfig = await readConfigFile<ServerlessFunctionConfig>(path.join(projectFolder, functionConfigPath));\n\n if (!functionConfig) {\n parseResult.errors.push(`Failed to read function config at ${functionConfigPath}`);\n continue;\n }\n\n const functionName: string = path.basename(path.dirname(functionConfigPath)).replace(/\\.func$/, '');\n const runtime = translateVercelRuntime(functionConfig.runtime);\n\n if (!runtime) {\n parseResult.errors.push(`Unsupported runtime for function ${functionName}: ${functionConfig.runtime}`);\n continue;\n }\n\n const functionDirectory = `.vercel/output/functions/${functionName}.func`;\n const handler = functionConfig.handler;\n const maxDuration = functionConfig.maxDuration;\n const memory = functionConfig.memory;\n\n // add regions and filter duplicates\n parseResult.regions = Array.from(\n new Set([\n ...(parseResult.regions ?? []),\n ...(functionConfig.regions ?? ['us-east-1']).map((r) => translateVercelRegion(r)),\n ])\n ) as Region[];\n\n const environmentVariables: Record<string, string> = {};\n\n const functionEnv = functionConfig.environment;\n\n if (functionEnv != null && typeof functionEnv === 'object') {\n for (const env of Object.values(functionEnv)) {\n for (const [key, value] of Object.entries(env)) {\n environmentVariables[key] = value;\n }\n }\n }\n\n const streaming: boolean = runtime == null || runtime.startsWith('node-') || runtime.startsWith('bun-');\n\n // translate filePathMap relative paths to absolute paths\n const filePathMap: Record<string, string> = {};\n for (const [key, value] of Object.entries(functionConfig.filePathMap ?? {})) {\n filePathMap[path.join(projectFolder, key)] = value;\n }\n\n parseResult.entrypoints.push({\n displayName: functionName,\n runtime,\n path: handler,\n memory: memory ?? 1024,\n maxDuration: maxDuration ?? 15,\n environmentVariables,\n streaming,\n package: {\n rootOverwrite: path.join(projectFolder, functionDirectory),\n filePathMap: filePathMap,\n },\n });\n\n const handlerType: NormalizedConfigRouteHandler = streaming\n ? 'SERVERLESS_FUNCTION_STREAMING'\n : 'SERVERLESS_FUNCTION';\n\n (\n [\n {\n path: `/${functionName}`,\n methods: ['ANY'],\n headers: {},\n destination: handler,\n handler: handlerType,\n },\n ...(config.routes\n ?.filter((r) => r.dest === `/${functionName}`)\n .map((r: Route) => ({\n path: r.src ?? `/${functionName}`,\n methods: ['ANY'] as NormalizedConfigRouteMethod[],\n headers: {},\n destination: handler,\n handler: handlerType,\n })) ?? []),\n ] as NormalizedConfigRoute[]\n ).forEach((route) => {\n parseResult.routes.push(route);\n });\n }\n};\n\nexport const readConfigFile = async <T>(configFilePath: string): Promise<T | null> => {\n if (!fs.existsSync(configFilePath)) {\n // skip vercel transformation if no vercel output exists\n return null;\n }\n\n const parsed = await parseRawConfig(configFilePath);\n\n return parsed as T;\n};\n\nexport const translateVercelRuntime = (runtime: string): Runtime | null => {\n switch (runtime) {\n case 'nodejs12.x':\n case 'nodejs14.x':\n case 'nodejs16.x':\n case 'nodejs18.x':\n return 'node-18';\n case 'nodejs20.x':\n case 'nodejs22.x': // TODO: Update when Lambda supports Node.js 22\n return 'node-20';\n default:\n return null;\n }\n};\n\n/**\n * @link https://vercel.com/docs/edge-network/regions#region-list\n */\nexport const translateVercelRegion = (region: string): string => {\n const regionMap: Record<string, string> = {\n arn1: 'eu-north-1',\n bom1: 'ap-south-1',\n cdg1: 'eu-west-3',\n cle1: 'us-east-2',\n cpt1: 'af-south-1',\n dub1: 'eu-west-1',\n fra1: 'eu-central-1',\n gru1: 'sa-east-1',\n hkg1: 'ap-east-1',\n hnd1: 'ap-northeast-1',\n iad1: 'us-east-1',\n icn1: 'ap-northeast-2',\n kix1: 'ap-northeast-3',\n lhr1: 'eu-west-2',\n pdx1: 'us-west-2',\n sfo1: 'us-west-1',\n sin1: 'ap-southeast-1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ACA,QAASC,GAAU,CACnB1B,EAAY,OAAO,KAAK0B,CAAK,CAC/B,CAAC,CACH,CACF,EAEavB,EAAiB,MAAUwB,GACjClC,EAAG,WAAWkC,CAAc,EAKlB,MAAM/B,EAAe+B,CAAc,EAHzC,KAQEhB,EAA0BD,GAAoC,CACzE,OAAQA,EAAS,CACf,IAAK,aACL,IAAK,aACL,IAAK,aACL,IAAK,aACH,MAAO,UACT,IAAK,aACL,IAAK,aACH,MAAO,UACT,QACE,OAAO,IACX,CACF,EAKaO,EAAyBW,IACM,CACxC,KAAM,aACN,KAAM,aACN,KAAM,YACN,KAAM,YACN,KAAM,aACN,KAAM,YACN,KAAM,eACN,KAAM,YACN,KAAM,YACN,KAAM,iBACN,KAAM,YACN,KAAM,iBACN,KAAM,iBACN,KAAM,YACN,KAAM,YACN,KAAM,YACN,KAAM,iBACN,KAAM,gBACR,GAEiBA,EAAO,YAAY,CAAC,GAAK",
|
|
6
|
-
"names": ["fs", "path", "getFilesForPattern", "parseRawConfig", "configPath", "functionConfigsPattern", "parseVercelBuildOutputV3", "parseResult", "projectFolder", "config", "readConfigFile", "loadFunctions", "loadAssetOverrides", "functionConfigs", "functionConfigPath", "functionConfig", "functionName", "runtime", "translateVercelRuntime", "functionDirectory", "handler", "maxDuration", "memory", "r", "translateVercelRegion", "environmentVariables", "functionEnv", "env", "key", "value", "streaming", "filePathMap", "handlerType", "route", "configFilePath", "region"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/normalized-config.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Region } from './regions';\nimport { type Runtime } from './runtime';\n\n/**\n * The object structure that all config versions will be parsed into.\n * This is done to provide a consistent interface for the rest of the codebase and easily provision the necessary resources, regardless of the config version.\n */\nexport interface NormalizedConfig {\n /**\n * The regions to deploy the project to.\n */\n regions: Region[];\n\n assets?: {\n /**\n * The relative file paths of the static assets to be deployed to the edge.\n */\n paths?: string[];\n\n /**\n * The prefix to strip from the asset path when serving.\n */\n prefixToStrip?: string;\n\n /**\n * Overrides for specific assets. Can be used to change the path or Content-Type of an asset.\n */\n overrides?: Record<\n string,\n {\n path?: string;\n contentType?: string;\n }\n >;\n\n /**\n * Whether routes for the assets should be generated during deployment.\n */\n dynamicRoutes?: boolean;\n\n /**\n * If true, the assets will be cached at the edge during deployment.\n */\n populateCache?: boolean;\n };\n\n /**\n * Additional environment variables to set during runtime and build.\n */\n environmentVariables: Record<string, string>;\n\n /**\n * The bash commands that will be run to build the project.\n */\n commands: string[];\n\n entrypoints: Array<NormalizedConfigEntrypoint>;\n\n routes: Array<NormalizedConfigRoute>;\n\n services?: Array<NormalizedConfigService>;\n\n /**\n * Warning codes to be printed to the output during deployment.\n */\n warnings: string[];\n\n /**\n * Error codes to be printed to the output during deployment.\n */\n errors: string[];\n}\n\nexport interface NormalizedConfigService {\n type: NormalizedConfigServiceType;\n}\n\nexport type NormalizedConfigServiceType = 'redis' | 'postgres';\n\nexport type UpstashAWSRegion =\n | 'us-east-1'\n | 'us-east-2'\n | 'us-west-1'\n | 'us-west-2'\n | 'eu-central-1'\n | 'eu-west-1'\n | 'eu-west-2'\n | 'sa-east-1'\n | 'ap-south-1'\n | 'ap-northeast-1'\n | 'ap-southeast-1'\n | 'ap-southeast-2';\n\nexport interface NormalizedConfigServiceRedis extends NormalizedConfigService {\n envBindings?: Record<'url' | 'host' | 'port' | 'password' | 'db' | 'ssl', string>;\n primaryRegion?: UpstashAWSRegion | 'us-central1';\n readRegions?: UpstashAWSRegion[];\n eviction?: boolean;\n}\n\nexport type NeonAWSRegion =\n | 'us-east-1'\n | 'us-east-2'\n | 'us-west-2'\n | 'ap-southeast-1'\n | 'ap-southeast-2'\n | 'eu-central-1'\n | 'eu-west-2'\n | 'sa-east-1';\n\nexport interface NormalizedConfigServicePostgres extends NormalizedConfigService {\n envBindings?: Record<'url' | 'host' | 'port' | 'user' | 'password' | 'database', string>;\n postgresVersion?: '17' | '16' | '15' | '14';\n region?: NeonAWSRegion;\n}\n\nexport interface NormalizedConfigEntrypoint {\n displayName?: string;\n path: string;\n runtime: Runtime;\n memory: number;\n maxDuration: number;\n schedule?: string;\n symlinks?: Record<string, string>;\n environmentVariables?: Record<string, string>;\n streaming?: boolean;\n package?: {\n rootOverwrite?: string;\n filePathMap?: Record<string, string>;\n };\n}\n\nexport interface NormalizedConfigRoute {\n path: string;\n destination: string;\n handler: NormalizedConfigRouteHandler | undefined;\n methods: NormalizedConfigRouteMethod[];\n headers: Record<string, string>;\n positiveRequirements?: NormalizedConfigRouteMatchRequirements;\n negativeRequirements?: NormalizedConfigRouteMatchRequirements;\n status?: number;\n}\n\nexport type NormalizedConfigRouteHandler =\n | 'SERVERLESS_FUNCTION'\n | 'SERVERLESS_FUNCTION_STREAMING'\n | 'HTTP_REDIRECT'\n | 'HTTP_PROXY'\n | 'ASSET';\n\nexport type NormalizedConfigRouteMethod = 'ANY' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';\n\nexport type NormalizedConfigRouteMatchRequirements =\n | []\n | [\n | {\n /**\n * The type of request element to check\n */\n type: 'host';\n /**\n * A regular expression used to match the value. Named groups can be used in the destination\n */\n value: string;\n }\n | {\n /**\n * The type of request element to check\n */\n type: 'header' | 'cookie' | 'query';\n /**\n * The name of the element contained in the particular type\n */\n key: string;\n /**\n * A regular expression used to match the value. Named groups can be used in the destination\n */\n value?: string;\n },\n ];\n"],
|
|
5
|
-
"mappings": "AAAA,MAA4B,YAC5B,MAA6B",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/parse-raw-config.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import i from"fs";import f from"path";import{parse as t}from"yaml";const w=async r=>{if(!i.existsSync(r))throw new Error(`Config file not found at ${r}`);const o=i.readFileSync(r,"utf8");if(o.length===0)throw new Error(`Config file is empty at ${r}`);const n=f.extname(r).toLowerCase();let e;try{n===".json"?e=JSON.parse(o):[".yml",".yaml"].includes(n)?e=t(o):e=t(o)}catch(s){throw new Error(`Failed to parse config file at ${r}: ${s instanceof Error?s.message:"Unknown error"}`)}if(e===void 0)throw new Error(`Config file could not be parsed at ${r}`);if(typeof e.version!="number")throw new Error(`Config file is missing version at ${r}`);return e};export{w as parseRawConfig};
|
|
2
|
-
//# sourceMappingURL=parse-raw-config.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/parse-raw-config.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport { parse as parseYaml } from 'yaml';\n\nexport const parseRawConfig = async (filePath: string): Promise<any> => {\n // check if the file exists\n if (!fs.existsSync(filePath)) {\n throw new Error(`Config file not found at ${filePath}`);\n }\n\n // read the file\n const fileContents = fs.readFileSync(filePath, 'utf8');\n\n if (fileContents.length === 0) {\n throw new Error(`Config file is empty at ${filePath}`);\n }\n\n // determine file type based on extension\n const fileExtension = path.extname(filePath).toLowerCase();\n\n // parse the file based on its extension\n let parsed;\n try {\n if (fileExtension === '.json') {\n parsed = JSON.parse(fileContents);\n } else if (['.yml', '.yaml'].includes(fileExtension)) {\n parsed = parseYaml(fileContents);\n } else {\n // Try to parse as YAML by default, which is more forgiving\n parsed = parseYaml(fileContents);\n }\n } catch (error) {\n throw new Error(\n `Failed to parse config file at ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n\n if (parsed === undefined) {\n throw new Error(`Config file could not be parsed at ${filePath}`);\n }\n\n // check if the version is present\n if (typeof parsed.version !== 'number') {\n throw new Error(`Config file is missing version at ${filePath}`);\n }\n\n return parsed;\n};\n"],
|
|
5
|
-
"mappings": "AAAA,OAAOA,MAAQ,KACf,OAAOC,MAAU,OACjB,OAAS,SAASC,MAAiB,OAE5B,MAAMC,EAAiB,MAAOC,GAAmC,CAEtE,GAAI,CAACJ,EAAG,WAAWI,CAAQ,EACzB,MAAM,IAAI,MAAM,4BAA4BA,CAAQ,EAAE,EAIxD,MAAMC,EAAeL,EAAG,aAAaI,EAAU,MAAM,EAErD,GAAIC,EAAa,SAAW,EAC1B,MAAM,IAAI,MAAM,2BAA2BD,CAAQ,EAAE,EAIvD,MAAME,EAAgBL,EAAK,QAAQG,CAAQ,EAAE,YAAY,EAGzD,IAAIG,EACJ,GAAI,CACED,IAAkB,QACpBC,EAAS,KAAK,MAAMF,CAAY,EACvB,CAAC,OAAQ,OAAO,EAAE,SAASC,CAAa,EACjDC,EAASL,EAAUG,CAAY,EAG/BE,EAASL,EAAUG,CAAY,CAEnC,OAASG,EAAO,CACd,MAAM,IAAI,MACR,kCAAkCJ,CAAQ,KAAKI,aAAiB,MAAQA,EAAM,QAAU,eAAe,EACzG,CACF,CAEA,GAAID,IAAW,OACb,MAAM,IAAI,MAAM,sCAAsCH,CAAQ,EAAE,EAIlE,GAAI,OAAOG,EAAO,SAAY,SAC5B,MAAM,IAAI,MAAM,qCAAqCH,CAAQ,EAAE,EAGjE,OAAOG,CACT",
|
|
6
|
-
"names": ["fs", "path", "parseYaml", "parseRawConfig", "filePath", "fileContents", "fileExtension", "parsed", "error"]
|
|
7
|
-
}
|
package/dist/regions.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const t=["us-east-1","us-east-2","us-west-1","us-west-2","ap-south-1","ap-northeast-3","ap-northeast-2","ap-southeast-1","ap-southeast-2","ap-northeast-1","ca-central-1","eu-central-1","eu-west-1","eu-west-2","eu-west-3","eu-north-1","sa-east-1"],e=[...t];export{e as AVAILABLE_REGIONS};
|
|
2
|
-
//# sourceMappingURL=regions.js.map
|
package/dist/regions.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/regions.ts"],
|
|
4
|
-
"sourcesContent": ["// Define all available runtimes in a single array\nconst REGION_DEFINITIONS = [\n 'us-east-1',\n 'us-east-2',\n 'us-west-1',\n 'us-west-2',\n 'ap-south-1',\n 'ap-northeast-3',\n 'ap-northeast-2',\n 'ap-southeast-1',\n 'ap-southeast-2',\n 'ap-northeast-1',\n 'ca-central-1',\n 'eu-central-1',\n 'eu-west-1',\n 'eu-west-2',\n 'eu-west-3',\n 'eu-north-1',\n 'sa-east-1',\n] as const;\n\n// Generate the Runtime type from the array\nexport type Region = (typeof REGION_DEFINITIONS)[number];\n\n// Export the available runtimes\nexport const AVAILABLE_REGIONS: Region[] = [...REGION_DEFINITIONS];\n"],
|
|
5
|
-
"mappings": "AACA,MAAMA,EAAqB,CACzB,YACA,YACA,YACA,YACA,aACA,iBACA,iBACA,iBACA,iBACA,iBACA,eACA,eACA,YACA,YACA,YACA,aACA,WACF,EAMaC,EAA8B,CAAC,GAAGD,CAAkB",
|
|
6
|
-
"names": ["REGION_DEFINITIONS", "AVAILABLE_REGIONS"]
|
|
7
|
-
}
|
package/dist/runtime.js
DELETED
package/dist/runtime.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/runtime.ts"],
|
|
4
|
-
"sourcesContent": ["// Define all available runtimes in a single array\nconst RUNTIME_DEFINITIONS = [\n 'php-84',\n 'php-83',\n 'php-81',\n 'node-22',\n 'node-20',\n 'node-18',\n 'node-16',\n 'bun-1',\n] as const;\n\n// Generate the Runtime type from the array\nexport type Runtime = (typeof RUNTIME_DEFINITIONS)[number];\n\n// Export the available runtimes\nexport const AVAILABLE_RUNTIMES: Runtime[] = [...RUNTIME_DEFINITIONS];\n"],
|
|
5
|
-
"mappings": "AACA,MAAMA,EAAsB,CAC1B,SACA,SACA,SACA,UACA,UACA,UACA,UACA,OACF,EAMaC,EAAgC,CAAC,GAAGD,CAAmB",
|
|
6
|
-
"names": ["RUNTIME_DEFINITIONS", "AVAILABLE_RUNTIMES"]
|
|
7
|
-
}
|
package/dist/v4/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=index.js.map
|
package/dist/v4/index.js.map
DELETED
package/dist/v4/parse.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import m from"fs";import{minimatch as y}from"minimatch";import{getFilesForPattern as C}from"../../../build-utils/src/get-files-for-pattern";import{AVAILABLE_REGIONS as R}from"../regions";const w=async(t,r)=>{const n=t.regions?.includes("global")===!0?R:t.regions?.filter(e=>e!=="global")??["global"],l=t.populateAssetCache??!1,s=t.env??{},f=t.build_commands??[],d=[],h=[],p=[];if(t.functions!=null)for(const[e,o]of Object.entries(t.functions)){const i=x(e,t);if(i==null)throw new Error(`Settings invalid for function at path '${e}'`);(await C(e,r,o.excludeFiles)).forEach(a=>{d.find(u=>u.path===a)||t.functions!=null&&Object.keys(t.functions).find(u=>u===a&&u!==e)||d.push({path:a,runtime:i.runtime??"node-20",memory:i.memory??128,maxDuration:i.max_duration??30,schedule:o.schedule,symlinks:o.symlinks,streaming:i.runtime==null||i.runtime.startsWith("node-")||i.runtime.startsWith("bun-")})})}const c=[];if(t.assets!=null){const e=`${r}/${t.assets}`;if(m.existsSync(e)&&m.statSync(e).isDirectory())for(const o of m.readdirSync(`${r}/${t.assets}`,{recursive:!0})){if(m.statSync(`${r}/${t.assets}/${o}`).isDirectory())continue;const i=[".htaccess",".htpasswd"],a=o.toString();i.some(u=>a.toLowerCase().endsWith(u.toLowerCase()))||c.push(`${t.assets}/${a}`)}}const g=t.routes??[];return{regions:n,assets:{paths:c.sort(),prefixToStrip:(t.assets??"")+"/",dynamicRoutes:!0,populateCache:l},environmentVariables:s,commands:f,entrypoints:d,errors:h,warnings:p,routes:g.map(e=>{const o=e.destination.toLowerCase().startsWith("http://")||e.destination.toLowerCase().startsWith("https://")?e.redirect===!0?"HTTP_REDIRECT":"HTTP_PROXY":e.redirect===!0?"HTTP_REDIRECT":"SERVERLESS_FUNCTION";return{path:e.source,destination:e.destination,handler:o,headers:e.headers??{},methods:e.methods??["ANY"],positiveRequirements:e.has,negativeRequirements:e.missing,status:e.statusCode}})}},x=(t,r)=>{let n;for(const[l,s]of Object.entries(r.functions??{}))(y(t,l)||new RegExp(l).test(t))&&(n==null&&(n={memory:128,max_duration:30,schedule:void 0,symlinks:void 0,excludeFiles:void 0,includeFiles:void 0}),s.runtime!=null&&(n.runtime=s.runtime),s.memory!=null&&(n.memory=s.memory),s.max_duration!=null&&(n.max_duration=s.max_duration),s.schedule!=null&&(n.schedule=s.schedule),s.symlinks!=null&&(n.symlinks=s.symlinks),s.excludeFiles!=null&&(n.excludeFiles=s.excludeFiles),s.includeFiles!=null&&(n.includeFiles=s.includeFiles));return n};export{x as getFunctionSettings,w as parseConfigV4};
|
|
2
|
-
//# sourceMappingURL=parse.js.map
|
package/dist/v4/parse.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/v4/parse.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'fs';\nimport { minimatch } from 'minimatch';\nimport type { ConfigV4, ConfigV4FunctionSettings } from '.';\nimport { getFilesForPattern } from '../../../build-utils/src/get-files-for-pattern';\nimport type {\n NormalizedConfig,\n NormalizedConfigEntrypoint,\n NormalizedConfigRoute,\n NormalizedConfigRouteHandler,\n} from '../normalized-config';\nimport { AVAILABLE_REGIONS, type Region } from '../regions';\n\nexport const parseConfigV4 = async (config: ConfigV4, projectFolder: string): Promise<NormalizedConfig> => {\n const regions =\n config.regions?.includes('global') === true\n ? AVAILABLE_REGIONS\n : (config.regions?.filter((region) => region !== 'global') ?? ['global']);\n\n const populateAssetCache = config.populateAssetCache ?? false;\n const environmentVariables = config.env ?? {};\n const commands = config.build_commands ?? [];\n const entrypoints: NormalizedConfigEntrypoint[] = [];\n const errors: string[] = [];\n const warnings: string[] = [];\n\n if (config.functions != null) {\n for (const [path, func] of Object.entries(config.functions)) {\n const settings = getFunctionSettings(path, config);\n\n if (settings == null) {\n throw new Error(`Settings invalid for function at path '${path}'`);\n }\n\n (await getFilesForPattern(path, projectFolder, func.excludeFiles)).forEach((file) => {\n // check if file is already in entrypoints, or if the path has a definition other than this one that matches it exactly\n if (entrypoints.find((entrypoint) => entrypoint.path === file)) {\n return;\n }\n\n if (config.functions != null && Object.keys(config.functions).find((func) => func === file && func !== path)) {\n return;\n }\n\n entrypoints.push({\n path: file,\n runtime: settings.runtime ?? 'node-20',\n memory: settings.memory ?? 128,\n maxDuration: settings.max_duration ?? 30,\n schedule: func.schedule,\n symlinks: func.symlinks,\n streaming:\n settings.runtime == null || settings.runtime.startsWith('node-') || settings.runtime.startsWith('bun-'),\n });\n });\n }\n }\n\n const assets: string[] = [];\n\n if (config.assets != null) {\n // list all files in assets folder recursively\n\n const assetsPath = `${projectFolder}/${config.assets}`;\n\n if (fs.existsSync(assetsPath) && fs.statSync(assetsPath).isDirectory()) {\n // console.debug('---- ASSET DEBUG ----');\n // console.debug('projectFolder', fs.readdirSync(assetsPath, { recursive: true }));\n\n // find all files in assets folder using fs\n for (const asset of fs.readdirSync(`${projectFolder}/${config.assets}`, {\n recursive: true,\n })) {\n // if file is a directory, skip it\n if (fs.statSync(`${projectFolder}/${config.assets}/${asset}`).isDirectory()) {\n continue;\n }\n\n const disallowedExtensions = ['.htaccess', '.htpasswd'];\n\n const assetName = asset.toString();\n\n if (disallowedExtensions.some((ext) => assetName.toLowerCase().endsWith(ext.toLowerCase()))) {\n continue;\n }\n\n assets.push(`${config.assets}/${assetName}`);\n }\n }\n }\n\n const routes = config.routes ?? [];\n\n return {\n regions: regions as Region[],\n assets: {\n paths: assets.sort(),\n prefixToStrip: (config.assets ?? '') + '/',\n dynamicRoutes: true,\n populateCache: populateAssetCache,\n },\n environmentVariables,\n commands,\n entrypoints,\n errors,\n warnings,\n routes: routes.map((route) => {\n // check if the destination has a protocol, if so use REDIRECT handler\n const handler: NormalizedConfigRouteHandler =\n route.destination.toLowerCase().startsWith('http://') || route.destination.toLowerCase().startsWith('https://')\n ? route.redirect === true\n ? 'HTTP_REDIRECT'\n : 'HTTP_PROXY'\n : route.redirect === true\n ? 'HTTP_REDIRECT'\n : 'SERVERLESS_FUNCTION';\n\n return {\n path: route.source,\n destination: route.destination,\n handler,\n headers: route.headers ?? {},\n methods: route.methods ?? ['ANY'],\n positiveRequirements: route.has,\n negativeRequirements: route.missing,\n status: route.statusCode,\n } as NormalizedConfigRoute;\n }),\n };\n};\n\n/**\n * Gets the runtime, memory and max duration for a given path.\n * @param path\n * @param config\n * @returns The runtime, memory and max duration for the given path. Should return undefined when a path should not be deployed as a function.\n */\nexport const getFunctionSettings = (path: string, config: ConfigV4): ConfigV4FunctionSettings | undefined => {\n // functions don't have to state all their options.\n // some function definitions might be glob or regex patterns.\n // go through all function definitions, find those that match the path and merge them.\n\n let functionSettings: ConfigV4FunctionSettings | undefined;\n\n for (const [key, value] of Object.entries(config.functions ?? {})) {\n // make sure to check for both glob and regex patterns\n if (minimatch(path, key) || new RegExp(key).test(path)) {\n if (functionSettings == null) {\n functionSettings = {\n memory: 128,\n max_duration: 30,\n schedule: undefined,\n symlinks: undefined,\n excludeFiles: undefined,\n includeFiles: undefined,\n };\n }\n\n if (value.runtime != null) {\n functionSettings.runtime = value.runtime;\n }\n\n if (value.memory != null) {\n functionSettings.memory = value.memory;\n }\n\n if (value.max_duration != null) {\n functionSettings.max_duration = value.max_duration;\n }\n\n if (value.schedule != null) {\n functionSettings.schedule = value.schedule;\n }\n\n if (value.symlinks != null) {\n functionSettings.symlinks = value.symlinks;\n }\n\n if (value.excludeFiles != null) {\n functionSettings.excludeFiles = value.excludeFiles;\n }\n\n if (value.includeFiles != null) {\n functionSettings.includeFiles = value.includeFiles;\n }\n }\n }\n\n return functionSettings;\n};\n"],
|
|
5
|
-
"mappings": "AAAA,OAAOA,MAAQ,KACf,OAAS,aAAAC,MAAiB,YAE1B,OAAS,sBAAAC,MAA0B,iDAOnC,OAAS,qBAAAC,MAAsC,aAExC,MAAMC,EAAgB,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CACjB,OAAQ,IACR,aAAc,GACd,SAAU,OACV,SAAU,OACV,aAAc,OACd,aAAc,MAChB,GAGEE,EAAM,SAAW,OACnBF,EAAiB,QAAUE,EAAM,SAG/BA,EAAM,QAAU,OAClBF,EAAiB,OAASE,EAAM,QAG9BA,EAAM,cAAgB,OACxBF,EAAiB,aAAeE,EAAM,cAGpCA,EAAM,UAAY,OACpBF,EAAiB,SAAWE,EAAM,UAGhCA,EAAM,UAAY,OACpBF,EAAiB,SAAWE,EAAM,UAGhCA,EAAM,cAAgB,OACxBF,EAAiB,aAAeE,EAAM,cAGpCA,EAAM,cAAgB,OACxBF,EAAiB,aAAeE,EAAM,eAK5C,OAAOF,CACT",
|
|
6
|
-
"names": ["fs", "minimatch", "getFilesForPattern", "AVAILABLE_REGIONS", "parseConfigV4", "config", "projectFolder", "regions", "region", "populateAssetCache", "environmentVariables", "commands", "entrypoints", "errors", "warnings", "path", "func", "settings", "getFunctionSettings", "file", "entrypoint", "assets", "assetsPath", "asset", "disallowedExtensions", "assetName", "ext", "routes", "route", "handler", "functionSettings", "key", "value"]
|
|
7
|
-
}
|