@flink-app/flink 0.14.2 → 0.14.3
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 +7 -0
- package/dist/src/FlinkApp.js +2 -2
- package/dist/src/FlinkHttpHandler.d.ts +6 -1
- package/dist/src/utils.js +3 -0
- package/package.json +1 -1
- package/spec/utils.spec.ts +27 -0
- package/src/FlinkApp.ts +2 -2
- package/src/FlinkHttpHandler.ts +6 -1
- package/src/utils.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @flink-app/flink
|
|
2
2
|
|
|
3
|
+
## 0.14.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 52eba74: Fix Query type constraint to allow user-defined interfaces without explicit index signatures. The Query type now uses explicit index signature syntax, making it easier for developers to define query parameter interfaces for their handlers without TypeScript compilation errors.
|
|
8
|
+
- b37faa5: Improve schema validation error messages to show specific additional property names. When validation fails due to additional properties, the error now displays which properties are not allowed instead of a generic message.
|
|
9
|
+
|
|
3
10
|
## 0.14.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/dist/src/FlinkApp.js
CHANGED
|
@@ -364,7 +364,7 @@ var FlinkApp = /** @class */ (function () {
|
|
|
364
364
|
error: {
|
|
365
365
|
id: (0, uuid_1.v4)(),
|
|
366
366
|
title: "Bad request",
|
|
367
|
-
detail:
|
|
367
|
+
detail: formattedErrors,
|
|
368
368
|
},
|
|
369
369
|
})];
|
|
370
370
|
}
|
|
@@ -442,7 +442,7 @@ var FlinkApp = /** @class */ (function () {
|
|
|
442
442
|
error: {
|
|
443
443
|
id: (0, uuid_1.v4)(),
|
|
444
444
|
title: "Bad response",
|
|
445
|
-
detail:
|
|
445
|
+
detail: formattedErrors,
|
|
446
446
|
},
|
|
447
447
|
})];
|
|
448
448
|
}
|
|
@@ -15,8 +15,13 @@ type Params = Request["params"];
|
|
|
15
15
|
* Query type for request query parameters.
|
|
16
16
|
* Does currently not allow nested objects, although
|
|
17
17
|
* underlying express Request does allow it.
|
|
18
|
+
*
|
|
19
|
+
* Uses index signature to allow both Record types and interface types
|
|
20
|
+
* to be assignable to Query without requiring explicit index signatures.
|
|
18
21
|
*/
|
|
19
|
-
type Query =
|
|
22
|
+
type Query = {
|
|
23
|
+
[x: string]: string | string[] | undefined;
|
|
24
|
+
};
|
|
20
25
|
/**
|
|
21
26
|
* Flink request extends express Request but adds reqId and user object.
|
|
22
27
|
*/
|
package/dist/src/utils.js
CHANGED
|
@@ -223,6 +223,9 @@ function formatValidationErrors(errors, data, maxDataLength) {
|
|
|
223
223
|
else if (error.keyword === "type") {
|
|
224
224
|
formatted.push(" - Invalid type at ".concat(error.schemaPath, ": expected ").concat(error.params.type, ", got ").concat(typeof dataAtPath));
|
|
225
225
|
}
|
|
226
|
+
else if (error.keyword === "additionalProperties") {
|
|
227
|
+
formatted.push(" - Additional property not allowed: ".concat(error.params.additionalProperty));
|
|
228
|
+
}
|
|
226
229
|
else if (error.keyword === "anyOf" || error.keyword === "oneOf") {
|
|
227
230
|
formatted.push(" - ".concat(error.message));
|
|
228
231
|
}
|
package/package.json
CHANGED
package/spec/utils.spec.ts
CHANGED
|
@@ -148,6 +148,33 @@ describe("Utils", () => {
|
|
|
148
148
|
expect(formatted).toContain('Missing required property: email');
|
|
149
149
|
expect(formatted).toContain('Missing required property: age');
|
|
150
150
|
});
|
|
151
|
+
|
|
152
|
+
it("should show specific additional property names", () => {
|
|
153
|
+
const errors = [
|
|
154
|
+
{
|
|
155
|
+
instancePath: "",
|
|
156
|
+
schemaPath: "#/additionalProperties",
|
|
157
|
+
keyword: "additionalProperties",
|
|
158
|
+
params: { additionalProperty: "extraField1" },
|
|
159
|
+
message: "must NOT have additional properties",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
instancePath: "",
|
|
163
|
+
schemaPath: "#/additionalProperties",
|
|
164
|
+
keyword: "additionalProperties",
|
|
165
|
+
params: { additionalProperty: "extraField2" },
|
|
166
|
+
message: "must NOT have additional properties",
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
const data = { name: "John", age: 30, extraField1: "value1", extraField2: "value2" };
|
|
170
|
+
|
|
171
|
+
const formatted = formatValidationErrors(errors, data);
|
|
172
|
+
|
|
173
|
+
// This formatted output is used in HTTP error responses (400/500) in the error.detail field
|
|
174
|
+
expect(formatted).toContain('Path: /');
|
|
175
|
+
expect(formatted).toContain('Additional property not allowed: extraField1');
|
|
176
|
+
expect(formatted).toContain('Additional property not allowed: extraField2');
|
|
177
|
+
});
|
|
151
178
|
});
|
|
152
179
|
});
|
|
153
180
|
|
package/src/FlinkApp.ts
CHANGED
|
@@ -562,7 +562,7 @@ export class FlinkApp<C extends FlinkContext> {
|
|
|
562
562
|
error: {
|
|
563
563
|
id: v4(),
|
|
564
564
|
title: "Bad request",
|
|
565
|
-
detail:
|
|
565
|
+
detail: formattedErrors,
|
|
566
566
|
},
|
|
567
567
|
});
|
|
568
568
|
}
|
|
@@ -645,7 +645,7 @@ export class FlinkApp<C extends FlinkContext> {
|
|
|
645
645
|
error: {
|
|
646
646
|
id: v4(),
|
|
647
647
|
title: "Bad response",
|
|
648
|
-
detail:
|
|
648
|
+
detail: formattedErrors,
|
|
649
649
|
},
|
|
650
650
|
});
|
|
651
651
|
}
|
package/src/FlinkHttpHandler.ts
CHANGED
|
@@ -18,8 +18,13 @@ type Params = Request["params"];
|
|
|
18
18
|
* Query type for request query parameters.
|
|
19
19
|
* Does currently not allow nested objects, although
|
|
20
20
|
* underlying express Request does allow it.
|
|
21
|
+
*
|
|
22
|
+
* Uses index signature to allow both Record types and interface types
|
|
23
|
+
* to be assignable to Query without requiring explicit index signatures.
|
|
21
24
|
*/
|
|
22
|
-
type Query =
|
|
25
|
+
type Query = {
|
|
26
|
+
[x: string]: string | string[] | undefined;
|
|
27
|
+
};
|
|
23
28
|
|
|
24
29
|
/**
|
|
25
30
|
* Flink request extends express Request but adds reqId and user object.
|
package/src/utils.ts
CHANGED
|
@@ -165,6 +165,8 @@ export function formatValidationErrors(errors: any[] | null | undefined, data: a
|
|
|
165
165
|
formatted.push(` - Missing required property: ${error.params.missingProperty}`);
|
|
166
166
|
} else if (error.keyword === "type") {
|
|
167
167
|
formatted.push(` - Invalid type at ${error.schemaPath}: expected ${error.params.type}, got ${typeof dataAtPath}`);
|
|
168
|
+
} else if (error.keyword === "additionalProperties") {
|
|
169
|
+
formatted.push(` - Additional property not allowed: ${error.params.additionalProperty}`);
|
|
168
170
|
} else if (error.keyword === "anyOf" || error.keyword === "oneOf") {
|
|
169
171
|
formatted.push(` - ${error.message}`);
|
|
170
172
|
} else {
|