@kalutskii/foundation 0.6.4 → 0.6.5
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/index.d.ts +2 -2
- package/dist/index.js +31 -29
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -104,8 +104,8 @@ declare function fetchAndThrow<TResult extends APIContractResult<unknown>>(fetch
|
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
106
106
|
declare const paginationSchema: z.ZodObject<{
|
|
107
|
-
offset: z.ZodOptional<z.ZodNumber
|
|
108
|
-
limit: z.ZodOptional<z.ZodNumber
|
|
107
|
+
offset: z.ZodOptional<z.ZodPreprocess<z.ZodNumber>>;
|
|
108
|
+
limit: z.ZodOptional<z.ZodPreprocess<z.ZodNumber>>;
|
|
109
109
|
}, z.core.$strip>;
|
|
110
110
|
/**
|
|
111
111
|
* A TypeScript type representing the pagination options validated by the `paginationSchema`.
|
package/dist/index.js
CHANGED
|
@@ -131,10 +131,38 @@ async function fetchAndThrow(fetcher) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// src/pagination/pagination.schemas.ts
|
|
134
|
+
import z2 from "zod";
|
|
135
|
+
|
|
136
|
+
// src/validation/validation.refiners.ts
|
|
134
137
|
import z from "zod";
|
|
135
|
-
var
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
var asQueryNumber = (schema) => z.preprocess((value) => {
|
|
139
|
+
if (typeof value !== "string")
|
|
140
|
+
return value;
|
|
141
|
+
if (value.trim() === "")
|
|
142
|
+
return value;
|
|
143
|
+
return Number(value);
|
|
144
|
+
}, schema);
|
|
145
|
+
var asQueryBoolean = (schema) => {
|
|
146
|
+
const POSITIVE_VALUES = ["1", "true", "yes", "y", "on"];
|
|
147
|
+
const NEGATIVE_VALUES = ["0", "false", "no", "n", "off"];
|
|
148
|
+
return z.preprocess((value) => {
|
|
149
|
+
if (typeof value === "boolean")
|
|
150
|
+
return value;
|
|
151
|
+
if (typeof value === "string") {
|
|
152
|
+
const normalized = value.trim().toLowerCase();
|
|
153
|
+
if (POSITIVE_VALUES.includes(normalized))
|
|
154
|
+
return true;
|
|
155
|
+
if (NEGATIVE_VALUES.includes(normalized))
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
return value;
|
|
159
|
+
}, schema);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// src/pagination/pagination.schemas.ts
|
|
163
|
+
var paginationSchema = z2.object({
|
|
164
|
+
offset: asQueryNumber(z2.number().int().nonnegative()).optional(),
|
|
165
|
+
limit: asQueryNumber(z2.number().int().positive()).optional()
|
|
138
166
|
});
|
|
139
167
|
|
|
140
168
|
// src/pagination/pagination.refiners.ts
|
|
@@ -166,32 +194,6 @@ async function measureExecutionTime(execution) {
|
|
|
166
194
|
return { result, executionTime: Math.round(executionTime) };
|
|
167
195
|
}
|
|
168
196
|
|
|
169
|
-
// src/validation/validation.refiners.ts
|
|
170
|
-
import z2 from "zod";
|
|
171
|
-
var asQueryNumber = (schema) => z2.preprocess((value) => {
|
|
172
|
-
if (typeof value !== "string")
|
|
173
|
-
return value;
|
|
174
|
-
if (value.trim() === "")
|
|
175
|
-
return value;
|
|
176
|
-
return Number(value);
|
|
177
|
-
}, schema);
|
|
178
|
-
var asQueryBoolean = (schema) => {
|
|
179
|
-
const POSITIVE_VALUES = ["1", "true", "yes", "y", "on"];
|
|
180
|
-
const NEGATIVE_VALUES = ["0", "false", "no", "n", "off"];
|
|
181
|
-
return z2.preprocess((value) => {
|
|
182
|
-
if (typeof value === "boolean")
|
|
183
|
-
return value;
|
|
184
|
-
if (typeof value === "string") {
|
|
185
|
-
const normalized = value.trim().toLowerCase();
|
|
186
|
-
if (POSITIVE_VALUES.includes(normalized))
|
|
187
|
-
return true;
|
|
188
|
-
if (NEGATIVE_VALUES.includes(normalized))
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
return value;
|
|
192
|
-
}, schema);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
197
|
// src/zod-jwt/zod-jwt.schemas.ts
|
|
196
198
|
import { decode as decodeJWT, sign as signJWT, verify as verifyJWT } from "hono/jwt";
|
|
197
199
|
var ZodJWTService = class {
|