@digitraffic/common 2026.5.24-1-beta → 2026.5.26-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.
|
@@ -18,37 +18,37 @@ function getHandler(builder) {
|
|
|
18
18
|
describe("FunctionBuilder.withAssetCode", () => {
|
|
19
19
|
test("uses lambdaName as default path", () => {
|
|
20
20
|
const stack = createStack();
|
|
21
|
-
const builder = FunctionBuilder.create(stack, "
|
|
21
|
+
const builder = FunctionBuilder.create(stack, "feature/subfeature/lambda-implementation");
|
|
22
22
|
const code = getCode(builder);
|
|
23
23
|
expect(code).toBeInstanceOf(AssetCode);
|
|
24
|
-
expect(code.path).toBe("dist/lambda/
|
|
24
|
+
expect(code.path).toBe("dist/lambda/feature/subfeature/lambda-implementation");
|
|
25
25
|
});
|
|
26
26
|
test("uses custom path when provided", () => {
|
|
27
27
|
const stack = createStack();
|
|
28
|
-
const builder = FunctionBuilder.create(stack, "
|
|
28
|
+
const builder = FunctionBuilder.create(stack, "feature/subfeature/lambda-implementation").withAssetCode("feature/subfeature/lambda-implementation");
|
|
29
29
|
const code = getCode(builder);
|
|
30
|
-
expect(code.path).toBe("dist/lambda/
|
|
30
|
+
expect(code.path).toBe("dist/lambda/feature/subfeature/lambda-implementation");
|
|
31
31
|
});
|
|
32
32
|
test("returns this for chaining when called without exclude", () => {
|
|
33
33
|
const stack = createStack();
|
|
34
|
-
const builder = FunctionBuilder.create(stack, "
|
|
35
|
-
expect(builder.withAssetCode("
|
|
34
|
+
const builder = FunctionBuilder.create(stack, "feature/subfeature/lambda-implementation");
|
|
35
|
+
expect(builder.withAssetCode("feature/subfeature/lambda-implementation")).toBe(builder);
|
|
36
36
|
});
|
|
37
37
|
test("accepts exclude list and uses correct path", () => {
|
|
38
38
|
const stack = createStack();
|
|
39
|
-
const builder = FunctionBuilder.create(stack, "
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
39
|
+
const builder = FunctionBuilder.create(stack, "feature/shared").withAssetCode("feature/shared", [
|
|
40
|
+
"handler-a/**",
|
|
41
|
+
"handler-b/**",
|
|
42
|
+
"handler-c/**",
|
|
43
43
|
]);
|
|
44
44
|
const code = getCode(builder);
|
|
45
45
|
expect(code).toBeInstanceOf(AssetCode);
|
|
46
|
-
expect(code.path).toBe("dist/lambda/
|
|
46
|
+
expect(code.path).toBe("dist/lambda/feature/shared");
|
|
47
47
|
});
|
|
48
48
|
test("returns this for chaining when called with exclude", () => {
|
|
49
49
|
const stack = createStack();
|
|
50
|
-
const builder = FunctionBuilder.create(stack, "
|
|
51
|
-
expect(builder.withAssetCode("
|
|
50
|
+
const builder = FunctionBuilder.create(stack, "feature/shared");
|
|
51
|
+
expect(builder.withAssetCode("feature/shared", ["handler-a/**"])).toBe(builder);
|
|
52
52
|
});
|
|
53
53
|
test("exclude is optional — undefined behaves same as no exclude", () => {
|
|
54
54
|
const stack = createStack();
|
|
@@ -60,11 +60,11 @@ describe("FunctionBuilder.withAssetCode", () => {
|
|
|
60
60
|
test("handler uses basename(path), not the full path", () => {
|
|
61
61
|
const stack = createStack();
|
|
62
62
|
// Without explicit withAssetCode — constructor default
|
|
63
|
-
const builderDefault = FunctionBuilder.create(stack, "
|
|
64
|
-
expect(getHandler(builderDefault)).toBe("
|
|
63
|
+
const builderDefault = FunctionBuilder.create(stack, "feature/shared");
|
|
64
|
+
expect(getHandler(builderDefault)).toBe("shared.handler");
|
|
65
65
|
// With explicit withAssetCode (e.g. to pass exclude) — must also use basename
|
|
66
|
-
const builderExplicit = FunctionBuilder.create(stack, "
|
|
67
|
-
expect(getHandler(builderExplicit)).toBe("
|
|
66
|
+
const builderExplicit = FunctionBuilder.create(stack, "feature/shared2").withAssetCode("feature/shared2", ["handler-a/**"]);
|
|
67
|
+
expect(getHandler(builderExplicit)).toBe("shared2.handler");
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
//# sourceMappingURL=dt-function.test.js.map
|
|
@@ -139,11 +139,9 @@ describe("FunctionBuilder test", () => {
|
|
|
139
139
|
});
|
|
140
140
|
});
|
|
141
141
|
test("Lambda handler module is resolved from path last element", () => {
|
|
142
|
-
const template = createTemplate((_builder) => { }, false, "api/
|
|
143
|
-
// const lambdas = template.findResources("AWS::Lambda::Function");
|
|
144
|
-
// console.debug(JSON.stringify(lambdas, null, 2));
|
|
142
|
+
const template = createTemplate((_builder) => { }, false, "api/feature/v1/get-items");
|
|
145
143
|
template.hasResourceProperties("AWS::Lambda::Function", {
|
|
146
|
-
Handler: "
|
|
144
|
+
Handler: "get-items.handler",
|
|
147
145
|
});
|
|
148
146
|
});
|
|
149
147
|
test("Lambda handler module is same as lambda name", () => {
|
|
@@ -49,7 +49,7 @@ export declare class FunctionBuilder {
|
|
|
49
49
|
* @param exclude - optional glob patterns to exclude from the asset bundle.
|
|
50
50
|
* Patterns are relative to the asset root (`dist/lambda/${path}/`) — do NOT use a leading slash.
|
|
51
51
|
* Use `**` to match files recursively.
|
|
52
|
-
* Example: `["datex2-36
|
|
52
|
+
* Example: `["datex2-36", "datex2-37", "statuses"]` excludes sibling lambda subdirectories
|
|
53
53
|
* that would otherwise be bundled into this lambda's deployment package.
|
|
54
54
|
*/
|
|
55
55
|
withAssetCode(path?: string, exclude?: string[]): this;
|
|
@@ -66,7 +66,7 @@ export class FunctionBuilder {
|
|
|
66
66
|
* @param exclude - optional glob patterns to exclude from the asset bundle.
|
|
67
67
|
* Patterns are relative to the asset root (`dist/lambda/${path}/`) — do NOT use a leading slash.
|
|
68
68
|
* Use `**` to match files recursively.
|
|
69
|
-
* Example: `["datex2-36
|
|
69
|
+
* Example: `["datex2-36", "datex2-37", "statuses"]` excludes sibling lambda subdirectories
|
|
70
70
|
* that would otherwise be bundled into this lambda's deployment package.
|
|
71
71
|
*/
|
|
72
72
|
withAssetCode(path = this._name, exclude) {
|