@vercel/build-utils 14.13.0 → 14.13.1
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/CHANGELOG.md +10 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/lambda.d.ts +10 -1
- package/dist/lambda.js +50 -38
- package/dist/types.d.ts +3 -0
- package/package.json +3 -3
package/dist/lambda.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config, Env, Files, FunctionFramework, MaxDuration, TriggerEvent, TriggerEventInput } from './types';
|
|
1
|
+
import type { BuilderFunctions, Config, Env, Files, FunctionFramework, MaxDuration, TriggerEvent, TriggerEventInput } from './types';
|
|
2
2
|
export type { TriggerEvent, TriggerEventInput };
|
|
3
3
|
/**
|
|
4
4
|
* Encodes a function path into a valid consumer name using mnemonic escapes.
|
|
@@ -162,4 +162,13 @@ export declare class Lambda {
|
|
|
162
162
|
*/
|
|
163
163
|
export declare function createLambda(opts: LambdaOptions): Promise<Lambda>;
|
|
164
164
|
export declare function createZip(files: Files): Promise<Buffer>;
|
|
165
|
+
/**
|
|
166
|
+
* Find the `functions` entry that applies to a function. Candidates are tried
|
|
167
|
+
* in order, and for each candidate the first matching pattern wins.
|
|
168
|
+
*/
|
|
169
|
+
export declare function findMatchingFunction(functions: BuilderFunctions | undefined, candidates: readonly string[]): {
|
|
170
|
+
sourceFile: string;
|
|
171
|
+
pattern: string;
|
|
172
|
+
functionConfig: BuilderFunctions[string];
|
|
173
|
+
} | undefined;
|
|
165
174
|
export declare function getLambdaOptionsFromFunction({ sourceFile, config, isScheduleEntrypoint, }: GetLambdaOptionsFromFunctionOptions): Promise<Pick<LambdaOptions, 'architecture' | 'memory' | 'maxDuration' | 'affinity' | 'maxConcurrency' | 'regions' | 'functionFailoverRegions' | 'experimentalTriggers' | 'supportsCancellation'>>;
|
package/dist/lambda.js
CHANGED
|
@@ -31,6 +31,7 @@ __export(lambda_exports, {
|
|
|
31
31
|
Lambda: () => Lambda,
|
|
32
32
|
createLambda: () => createLambda,
|
|
33
33
|
createZip: () => createZip,
|
|
34
|
+
findMatchingFunction: () => findMatchingFunction,
|
|
34
35
|
getLambdaOptionsFromFunction: () => getLambdaOptionsFromFunction,
|
|
35
36
|
sanitizeConsumerName: () => sanitizeConsumerName
|
|
36
37
|
});
|
|
@@ -358,52 +359,62 @@ async function createZip(files) {
|
|
|
358
359
|
});
|
|
359
360
|
return zipBuffer;
|
|
360
361
|
}
|
|
362
|
+
function findMatchingFunction(functions, candidates) {
|
|
363
|
+
if (!functions)
|
|
364
|
+
return void 0;
|
|
365
|
+
for (const sourceFile of candidates) {
|
|
366
|
+
for (const [pattern, functionConfig] of Object.entries(functions)) {
|
|
367
|
+
if (sourceFile === pattern || (0, import_minimatch.default)(sourceFile, pattern)) {
|
|
368
|
+
return { sourceFile, pattern, functionConfig };
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return void 0;
|
|
373
|
+
}
|
|
361
374
|
async function getLambdaOptionsFromFunction({
|
|
362
375
|
sourceFile,
|
|
363
376
|
config,
|
|
364
377
|
isScheduleEntrypoint = false
|
|
365
378
|
}) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
return trigger;
|
|
382
|
-
}
|
|
383
|
-
);
|
|
384
|
-
if (experimentalTriggers && experimentalTriggers.length > 1 && experimentalTriggers.some((t) => t.type === "queue/v2beta")) {
|
|
385
|
-
throw new Error(
|
|
386
|
-
`functions["${pattern}"].experimentalTriggers can only have one item for queue/v2beta`
|
|
387
|
-
);
|
|
388
|
-
}
|
|
389
|
-
if (isScheduleEntrypoint && experimentalTriggers !== void 0 && !(experimentalTriggers.length === 1 && experimentalTriggers[0]?.type === "schedule/v1beta")) {
|
|
390
|
-
throw new Error(
|
|
391
|
-
`functions["${pattern}"].experimentalTriggers conflicts with the schedule entrypoint trigger`
|
|
392
|
-
);
|
|
379
|
+
const match = findMatchingFunction(config?.functions, [sourceFile]);
|
|
380
|
+
if (match) {
|
|
381
|
+
const { pattern, functionConfig: fn } = match;
|
|
382
|
+
const serviceName = typeof config?.serviceName === "string" && config.serviceName !== "" ? config.serviceName : void 0;
|
|
383
|
+
const consumer = sanitizeConsumerName(
|
|
384
|
+
serviceName ? `${serviceName}~${pattern}` : pattern
|
|
385
|
+
);
|
|
386
|
+
const experimentalTriggers = fn.experimentalTriggers?.map(
|
|
387
|
+
(trigger) => {
|
|
388
|
+
if (trigger.type === "queue/v2beta") {
|
|
389
|
+
return {
|
|
390
|
+
...trigger,
|
|
391
|
+
consumer
|
|
392
|
+
};
|
|
393
393
|
}
|
|
394
|
-
return
|
|
395
|
-
architecture: fn.architecture,
|
|
396
|
-
memory: fn.memory,
|
|
397
|
-
maxDuration: fn.maxDuration,
|
|
398
|
-
affinity: fn.affinity,
|
|
399
|
-
maxConcurrency: fn.maxConcurrency,
|
|
400
|
-
regions: fn.regions,
|
|
401
|
-
functionFailoverRegions: fn.functionFailoverRegions,
|
|
402
|
-
experimentalTriggers: isScheduleEntrypoint ? [{ type: "schedule/v1beta" }] : experimentalTriggers,
|
|
403
|
-
supportsCancellation: fn.supportsCancellation
|
|
404
|
-
};
|
|
394
|
+
return trigger;
|
|
405
395
|
}
|
|
396
|
+
);
|
|
397
|
+
if (experimentalTriggers && experimentalTriggers.length > 1 && experimentalTriggers.some((t) => t.type === "queue/v2beta")) {
|
|
398
|
+
throw new Error(
|
|
399
|
+
`functions["${pattern}"].experimentalTriggers can only have one item for queue/v2beta`
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
if (isScheduleEntrypoint && experimentalTriggers !== void 0 && !(experimentalTriggers.length === 1 && experimentalTriggers[0]?.type === "schedule/v1beta")) {
|
|
403
|
+
throw new Error(
|
|
404
|
+
`functions["${pattern}"].experimentalTriggers conflicts with the schedule entrypoint trigger`
|
|
405
|
+
);
|
|
406
406
|
}
|
|
407
|
+
return {
|
|
408
|
+
architecture: fn.architecture,
|
|
409
|
+
memory: fn.memory,
|
|
410
|
+
maxDuration: fn.maxDuration,
|
|
411
|
+
affinity: fn.affinity,
|
|
412
|
+
maxConcurrency: fn.maxConcurrency,
|
|
413
|
+
regions: fn.regions,
|
|
414
|
+
functionFailoverRegions: fn.functionFailoverRegions,
|
|
415
|
+
experimentalTriggers: isScheduleEntrypoint ? [{ type: "schedule/v1beta" }] : experimentalTriggers,
|
|
416
|
+
supportsCancellation: fn.supportsCancellation
|
|
417
|
+
};
|
|
407
418
|
}
|
|
408
419
|
return isScheduleEntrypoint ? { experimentalTriggers: [{ type: "schedule/v1beta" }] } : {};
|
|
409
420
|
}
|
|
@@ -412,6 +423,7 @@ async function getLambdaOptionsFromFunction({
|
|
|
412
423
|
Lambda,
|
|
413
424
|
createLambda,
|
|
414
425
|
createZip,
|
|
426
|
+
findMatchingFunction,
|
|
415
427
|
getLambdaOptionsFromFunction,
|
|
416
428
|
sanitizeConsumerName
|
|
417
429
|
});
|
package/dist/types.d.ts
CHANGED
|
@@ -654,6 +654,9 @@ export interface ScheduleExpression {
|
|
|
654
654
|
export type ScheduleTarget = {
|
|
655
655
|
/** Build output path of the function to invoke, e.g. "api/cron" */
|
|
656
656
|
function: string;
|
|
657
|
+
} | {
|
|
658
|
+
/** Deployment path to invoke over HTTP, like `crons[].path`. Must start with `/`. */
|
|
659
|
+
path: string;
|
|
657
660
|
} | {
|
|
658
661
|
/** Name of the queue topic to publish to */
|
|
659
662
|
topic: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/build-utils",
|
|
3
|
-
"version": "14.13.
|
|
3
|
+
"version": "14.13.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.js",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"vitest": "4.1.10",
|
|
53
53
|
"typescript": "4.9.5",
|
|
54
54
|
"yazl": "2.5.1",
|
|
55
|
-
"@vercel/
|
|
56
|
-
"@vercel/
|
|
55
|
+
"@vercel/error-utils": "2.2.1",
|
|
56
|
+
"@vercel/routing-utils": "6.6.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "node build.mjs",
|