cogsbox-shape 0.5.67 → 0.5.68

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.d.ts +6 -16
  2. package/package.json +1 -1
package/dist/schema.d.ts CHANGED
@@ -57,10 +57,10 @@ type SQLToZodType<T extends SQLType, TDefault extends boolean> = T["pk"] extends
57
57
  type ZodTypeFromPrimitive<T> = T extends string ? z.ZodString : T extends number ? z.ZodNumber : T extends boolean ? z.ZodBoolean : T extends Date ? z.ZodDate : z.ZodAny;
58
58
  interface IBuilderMethods<T extends SQLType | RelationConfig<any>, TSql extends z.ZodTypeAny, TNew extends z.ZodTypeAny, TInitialValue, TClient extends z.ZodTypeAny, TValidation extends z.ZodTypeAny> {
59
59
  initialState: {
60
- <TResult>(defaultValue: () => TResult): TResult extends z.ZodTypeAny ? Prettify<Builder<"new", T, TSql, TResult, z.infer<TResult>, InferSmartClientType<TSql, TResult>, InferSmartClientType<TSql, TResult>>> : Prettify<Builder<"new", T, TSql, ZodTypeFromPrimitive<TResult>, TResult, InferSmartClientType<TSql, ZodTypeFromPrimitive<TResult>>, InferSmartClientType<TSql, ZodTypeFromPrimitive<TResult>>>>;
61
- <TNewNext extends z.ZodTypeAny, TDefaultNext>(schema: ((tools: {
60
+ <const TResult>(defaultValue: TResult): TResult extends () => infer R ? R extends z.ZodTypeAny ? Prettify<Builder<"new", T, TSql, R, z.infer<R>, InferSmartClientType<TSql, R>, InferSmartClientType<TSql, R>>> : Prettify<Builder<"new", T, TSql, z.ZodLiteral<R>, R, z.ZodUnion<[TSql, z.ZodLiteral<R>]>, z.ZodUnion<[TSql, z.ZodLiteral<R>]>>> : TResult extends z.ZodTypeAny ? Prettify<Builder<"new", T, TSql, TResult, z.infer<TResult>, InferSmartClientType<TSql, TResult>, InferSmartClientType<TSql, TResult>>> : TResult extends string | number | boolean ? Prettify<Builder<"new", T, TSql, z.ZodLiteral<TResult>, TResult, z.ZodUnion<[TSql, z.ZodLiteral<TResult>]>, z.ZodUnion<[TSql, z.ZodLiteral<TResult>]>>> : Prettify<Builder<"new", T, TSql, ZodTypeFromPrimitive<TResult>, TResult, InferSmartClientType<TSql, ZodTypeFromPrimitive<TResult>>, InferSmartClientType<TSql, ZodTypeFromPrimitive<TResult>>>>;
61
+ <TNewNext extends z.ZodTypeAny, const TDefaultNext>(schema: ((tools: {
62
62
  sql: TSql;
63
- }) => TNewNext) | TNewNext, defaultValue: () => TDefaultNext): Prettify<Builder<"new", T, TSql, TNewNext, z.infer<TNewNext>, InferSmartClientType<TSql, TNewNext>, InferSmartClientType<TSql, TNewNext>>>;
63
+ }) => TNewNext) | TNewNext, defaultValue: TDefaultNext | (() => TDefaultNext)): Prettify<Builder<"new", T, TSql, TNewNext, TDefaultNext extends () => infer R ? R : TDefaultNext, InferSmartClientType<TSql, TNewNext>, InferSmartClientType<TSql, TNewNext>>>;
64
64
  };
65
65
  client: <TClientNext extends z.ZodTypeAny>(schema: ((tools: {
66
66
  sql: TSql;
@@ -220,7 +220,7 @@ type SchemaDefinition = {
220
220
  [key: string]: any;
221
221
  };
222
222
  type InferSchemaByKey<T, Key extends "zodSqlSchema" | "zodClientSchema" | "zodValidationSchema", Depth extends any[] = []> = Depth["length"] extends 10 ? any : {
223
- [K in keyof T as K extends "_tableName" ? never : K]: T[K] extends {
223
+ [K in keyof T as K extends "_tableName" | typeof SchemaWrapperBrand ? never : K]: T[K] extends {
224
224
  config: {
225
225
  sql: {
226
226
  type: "hasMany" | "manyToMany";
@@ -229,7 +229,7 @@ type InferSchemaByKey<T, Key extends "zodSqlSchema" | "zodClientSchema" | "zodVa
229
229
  };
230
230
  } ? z.ZodArray<S extends {
231
231
  _tableName: string;
232
- } ? z.ZodObject<InferSchemaByKey<S, Key, [...Depth, 1]>> : z.ZodObject<any>> : T[K] extends {
232
+ } ? z.ZodObject<Omit<InferSchemaByKey<S, Key, [...Depth, 1]>, typeof SchemaWrapperBrand>> : z.ZodObject<any>> : T[K] extends {
233
233
  config: {
234
234
  sql: {
235
235
  type: "hasOne" | "belongsTo";
@@ -238,17 +238,7 @@ type InferSchemaByKey<T, Key extends "zodSqlSchema" | "zodClientSchema" | "zodVa
238
238
  };
239
239
  } ? S extends {
240
240
  _tableName: string;
241
- } ? z.ZodObject<InferSchemaByKey<S, Key, [...Depth, 1]>> : z.ZodObject<any> : T[K] extends () => {
242
- type: "hasMany" | "manyToMany";
243
- schema: infer S extends {
244
- _tableName: string;
245
- };
246
- } ? z.ZodArray<z.ZodObject<InferSchemaByKey<S, Key, [...Depth, 1]>>> : T[K] extends () => {
247
- type: "hasOne" | "belongsTo";
248
- schema: infer S extends {
249
- _tableName: string;
250
- };
251
- } ? z.ZodObject<InferSchemaByKey<S, Key, [...Depth, 1]>> : T[K] extends {
241
+ } ? z.ZodObject<Omit<InferSchemaByKey<S, Key, [...Depth, 1]>, typeof SchemaWrapperBrand>> : z.ZodObject<any> : T[K] extends {
252
242
  type: "reference";
253
243
  to: () => infer RefField;
254
244
  } ? RefField extends {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.67",
3
+ "version": "0.5.68",
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",