sprint-es 0.0.148 → 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
|
@@ -865,7 +865,9 @@ function createSchemaValidationMiddleware(schema) {
|
|
|
865
865
|
}
|
|
866
866
|
if (schema.headers) {
|
|
867
867
|
const normalizedHeaders = Object.fromEntries(Object.entries(req.headers).map(([key, value]) => [key.toLowerCase(), value]));
|
|
868
|
-
const
|
|
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);
|
|
869
871
|
if (!result.success) {
|
|
870
872
|
errors.push(...result.error.issues.map((issue) => ({
|
|
871
873
|
location: "headers",
|
|
@@ -54,8 +54,17 @@ function defineRouteSchema(schema) {
|
|
|
54
54
|
}
|
|
55
55
|
if (schema.headers) {
|
|
56
56
|
const normalizedHeaders = Object.fromEntries(Object.entries(req.headers).map(([key, value]) => [key.toLowerCase(), value]));
|
|
57
|
-
const
|
|
58
|
-
|
|
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
|
+
}
|
|
59
68
|
}
|
|
60
69
|
if (schema.sprint?.authorization) {
|
|
61
70
|
const authSchema = schema.sprint.authorization;
|
package/dist/esm/index.js
CHANGED
|
@@ -840,7 +840,9 @@ function createSchemaValidationMiddleware(schema) {
|
|
|
840
840
|
}
|
|
841
841
|
if (schema.headers) {
|
|
842
842
|
const normalizedHeaders = Object.fromEntries(Object.entries(req.headers).map(([key, value]) => [key.toLowerCase(), value]));
|
|
843
|
-
const
|
|
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);
|
|
844
846
|
if (!result.success) {
|
|
845
847
|
errors.push(...result.error.issues.map((issue) => ({
|
|
846
848
|
location: "headers",
|
|
@@ -52,8 +52,17 @@ function defineRouteSchema(schema) {
|
|
|
52
52
|
}
|
|
53
53
|
if (schema.headers) {
|
|
54
54
|
const normalizedHeaders = Object.fromEntries(Object.entries(req.headers).map(([key, value]) => [key.toLowerCase(), value]));
|
|
55
|
-
const
|
|
56
|
-
|
|
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
|
+
}
|
|
57
66
|
}
|
|
58
67
|
if (schema.sprint?.authorization) {
|
|
59
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,GAAG,OAAO,CAAC,GAAG;IAC5B,MAAM,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF,QAAA,MAAM,MAAM,EAKN,aAAa,CAAC;AAEpB,OAAO,EAAE,MAAM,IAAI,CAA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