cogsbox-shape 0.5.185 → 0.5.186

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.
Files changed (2) hide show
  1. package/dist/schema.js +14 -13
  2. package/package.json +1 -1
package/dist/schema.js CHANGED
@@ -9,21 +9,21 @@ export function currentTimeStamp() {
9
9
  }
10
10
  export const s = {
11
11
  clientInput: (value) => {
12
- const actualValue = isFunction(value) ? value({ uuid }) : value;
12
+ const sample = isFunction(value) ? value({ uuid }) : value;
13
13
  let inferredZodType;
14
- if (typeof actualValue === "string") {
14
+ if (typeof sample === "string") {
15
15
  inferredZodType = z.string();
16
16
  }
17
- else if (typeof actualValue === "number") {
17
+ else if (typeof sample === "number") {
18
18
  inferredZodType = z.number();
19
19
  }
20
- else if (typeof actualValue === "boolean") {
20
+ else if (typeof sample === "boolean") {
21
21
  inferredZodType = z.boolean();
22
22
  }
23
- else if (actualValue instanceof Date) {
23
+ else if (sample instanceof Date) {
24
24
  inferredZodType = z.date();
25
25
  }
26
- else if (actualValue === null) {
26
+ else if (sample === null) {
27
27
  inferredZodType = z.null();
28
28
  }
29
29
  else {
@@ -33,7 +33,7 @@ export const s = {
33
33
  stage: "clientInput",
34
34
  sqlConfig: null,
35
35
  sqlZod: z.undefined(),
36
- initialValue: actualValue,
36
+ initialValue: value,
37
37
  clientZod: inferredZodType,
38
38
  validationZod: inferredZodType,
39
39
  });
@@ -185,7 +185,7 @@ function createBuilder(config) {
185
185
  let actualValue = config.initialValue;
186
186
  let finalSchema;
187
187
  if (value !== undefined) {
188
- actualValue = isFunction(value) ? value({ uuid }) : value;
188
+ actualValue = value;
189
189
  }
190
190
  else if (schemaOrModifier &&
191
191
  typeof schemaOrModifier === "object" &&
@@ -203,15 +203,16 @@ function createBuilder(config) {
203
203
  }
204
204
  else {
205
205
  if (value !== undefined) {
206
- if (typeof actualValue === "string")
206
+ const sample = isFunction(value) ? value({ uuid }) : value;
207
+ if (typeof sample === "string")
207
208
  baseSchema = z.string();
208
- else if (typeof actualValue === "number")
209
+ else if (typeof sample === "number")
209
210
  baseSchema = z.number();
210
- else if (typeof actualValue === "boolean")
211
+ else if (typeof sample === "boolean")
211
212
  baseSchema = z.boolean();
212
- else if (actualValue instanceof Date)
213
+ else if (sample instanceof Date)
213
214
  baseSchema = z.date();
214
- else if (actualValue === null)
215
+ else if (sample === null)
215
216
  baseSchema = z.null();
216
217
  else
217
218
  baseSchema = z.any();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.185",
3
+ "version": "0.5.186",
4
4
  "description": "A TypeScript library for creating type-safe database schemas with Zod validation, SQL type definitions, and automatic client/server transformations. Unifies client, server, and database types through a single schema definition, with built-in support for relationships and serialization.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",