sprint-es 0.0.147 → 0.0.149
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/dist/cjs/index.cjs
CHANGED
|
@@ -864,7 +864,10 @@ function createSchemaValidationMiddleware(schema) {
|
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
866
|
if (schema.headers) {
|
|
867
|
-
const
|
|
867
|
+
const normalizedHeaders = Object.fromEntries(Object.entries(req.headers).map(([key, value]) => [key.toLowerCase(), value]));
|
|
868
|
+
const schemaShape = schema.headers._def?.shape?.();
|
|
869
|
+
const normalizedSchema = schemaShape ? schema.headers.constructor.create(Object.fromEntries(Object.entries(schemaShape).map(([key, value]) => [key.toLowerCase(), value]))) : schema.headers;
|
|
870
|
+
const result = normalizedSchema.safeParse(normalizedHeaders);
|
|
868
871
|
if (!result.success) {
|
|
869
872
|
errors.push(...result.error.issues.map((issue) => ({
|
|
870
873
|
location: "headers",
|
|
@@ -53,8 +53,18 @@ function defineRouteSchema(schema) {
|
|
|
53
53
|
if (!result.success) errors.push(...result.errors.map((e) => ({ location: "params", ...e })));
|
|
54
54
|
}
|
|
55
55
|
if (schema.headers) {
|
|
56
|
-
const
|
|
57
|
-
|
|
56
|
+
const normalizedHeaders = Object.fromEntries(Object.entries(req.headers).map(([key, value]) => [key.toLowerCase(), value]));
|
|
57
|
+
const schemaShape = schema.headers.shape;
|
|
58
|
+
const normalizedShape = schemaShape ? Object.fromEntries(Object.entries(schemaShape).map(([key, value]) => [key.toLowerCase(), value])) : null;
|
|
59
|
+
const effectiveSchema = normalizedShape ? schema.headers.constructor.create(normalizedShape) : schema.headers;
|
|
60
|
+
const result = effectiveSchema.safeParse(normalizedHeaders);
|
|
61
|
+
if (!result.success) {
|
|
62
|
+
errors.push(...result.error.issues.map((issue) => ({
|
|
63
|
+
location: "headers",
|
|
64
|
+
path: issue.path.join("."),
|
|
65
|
+
message: issue.message
|
|
66
|
+
})));
|
|
67
|
+
}
|
|
58
68
|
}
|
|
59
69
|
if (schema.sprint?.authorization) {
|
|
60
70
|
const authSchema = schema.sprint.authorization;
|
package/dist/esm/index.js
CHANGED
|
@@ -839,7 +839,10 @@ function createSchemaValidationMiddleware(schema) {
|
|
|
839
839
|
}
|
|
840
840
|
}
|
|
841
841
|
if (schema.headers) {
|
|
842
|
-
const
|
|
842
|
+
const normalizedHeaders = Object.fromEntries(Object.entries(req.headers).map(([key, value]) => [key.toLowerCase(), value]));
|
|
843
|
+
const schemaShape = schema.headers._def?.shape?.();
|
|
844
|
+
const normalizedSchema = schemaShape ? schema.headers.constructor.create(Object.fromEntries(Object.entries(schemaShape).map(([key, value]) => [key.toLowerCase(), value]))) : schema.headers;
|
|
845
|
+
const result = normalizedSchema.safeParse(normalizedHeaders);
|
|
843
846
|
if (!result.success) {
|
|
844
847
|
errors.push(...result.error.issues.map((issue) => ({
|
|
845
848
|
location: "headers",
|
|
@@ -51,8 +51,18 @@ function defineRouteSchema(schema) {
|
|
|
51
51
|
if (!result.success) errors.push(...result.errors.map((e) => ({ location: "params", ...e })));
|
|
52
52
|
}
|
|
53
53
|
if (schema.headers) {
|
|
54
|
-
const
|
|
55
|
-
|
|
54
|
+
const normalizedHeaders = Object.fromEntries(Object.entries(req.headers).map(([key, value]) => [key.toLowerCase(), value]));
|
|
55
|
+
const schemaShape = schema.headers.shape;
|
|
56
|
+
const normalizedShape = schemaShape ? Object.fromEntries(Object.entries(schemaShape).map(([key, value]) => [key.toLowerCase(), value])) : null;
|
|
57
|
+
const effectiveSchema = normalizedShape ? schema.headers.constructor.create(normalizedShape) : schema.headers;
|
|
58
|
+
const result = effectiveSchema.safeParse(normalizedHeaders);
|
|
59
|
+
if (!result.success) {
|
|
60
|
+
errors.push(...result.error.issues.map((issue) => ({
|
|
61
|
+
location: "headers",
|
|
62
|
+
path: issue.path.join("."),
|
|
63
|
+
message: issue.message
|
|
64
|
+
})));
|
|
65
|
+
}
|
|
56
66
|
}
|
|
57
67
|
if (schema.sprint?.authorization) {
|
|
58
68
|
const authSchema = schema.sprint.authorization;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAuB,gBAAgB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAuB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAoGlF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,gBAAgB,EAC7D,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAClC,gBAAgB,CAAC,OAAO,CAAC,CAwB3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,SAAS,IAAI,aAAa,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AAErF,MAAM,MAAM,mBAAmB,GAAG,SAAS,MAAM,EAAE,GAAG,WAAW,MAAM,EAAE,CAAC;AAE1E,MAAM,WAAW,0BAA0B;IACvC,OAAO,CAAC,EAAE,mBAAmB,GAAG,mBAAmB,EAAE,CAAC;CACzD;AAED,iBAAS,+BAA+B,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAKxH;AAED,QAAA,MAAM,aAAa;;CAElB,CAAC;AAEF,QAAA,MAAM,UAAU;;CAEf,CAAC;AAEF,KAAK,cAAc,GAAG,OAAO,UAAU,GAAG,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAQpE,KAAK,aAAa,GAA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