cogsbox-shape 0.5.126 → 0.5.127
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/schema.d.ts +46 -4
- package/package.json +1 -1
package/dist/schema.d.ts
CHANGED
|
@@ -288,7 +288,7 @@ type _DeriveViewShape<TTableName extends keyof TRegistry, TSelection, TRegistry
|
|
|
288
288
|
1
|
|
289
289
|
]>>> : never : never : never;
|
|
290
290
|
}> : OmitRelationFields<BaseShape, TRegistry[TTableName]["rawSchema"]> : never;
|
|
291
|
-
type
|
|
291
|
+
type DeriveViewDefaults<TTableName extends keyof TRegistry, TSelection, TRegistry extends RegistryShape, Depth extends any[] = []> = Prettify<TRegistry[TTableName]["zodSchemas"]["defaultValues"] & (TSelection extends Record<string, any> ? {
|
|
292
292
|
-readonly [K in keyof TSelection & keyof TRegistry[TTableName]["rawSchema"]]?: TRegistry[TTableName]["rawSchema"][K] extends {
|
|
293
293
|
config: {
|
|
294
294
|
sql: {
|
|
@@ -296,19 +296,61 @@ type _Internal_DeriveViewDefaults<TTableName extends keyof TRegistry, TSelection
|
|
|
296
296
|
schema: any;
|
|
297
297
|
};
|
|
298
298
|
};
|
|
299
|
-
} ? GetRelationRegistryKey<TRegistry[TTableName]["rawSchema"][K], TRegistry> extends infer TargetKey ? TargetKey extends keyof TRegistry ? RelType extends "hasMany" | "manyToMany" ?
|
|
299
|
+
} ? GetRelationRegistryKey<TRegistry[TTableName]["rawSchema"][K], TRegistry> extends infer TargetKey ? TargetKey extends keyof TRegistry ? RelType extends "hasMany" | "manyToMany" ? DeriveViewDefaults<TargetKey, TSelection[K], TRegistry, [
|
|
300
300
|
...Depth,
|
|
301
301
|
1
|
|
302
|
-
]>[] :
|
|
302
|
+
]>[] : DeriveViewDefaults<TargetKey, TSelection[K], TRegistry, [
|
|
303
303
|
...Depth,
|
|
304
304
|
1
|
|
305
305
|
]> | null : never : never : never;
|
|
306
306
|
} : {})>;
|
|
307
|
+
export type DeriveViewResultFromBox<TBox extends CreateSchemaBoxReturn<any, any>, TTableName extends keyof TBox, TSelection extends TBox[TTableName]["RelationSelection"]> = {
|
|
308
|
+
sql: TBox[TTableName]["schemas"]["sql"];
|
|
309
|
+
client: z.ZodObject<_DeriveViewShape<TTableName, TSelection, {
|
|
310
|
+
[K in keyof TBox]: {
|
|
311
|
+
rawSchema: TBox[K]["definition"];
|
|
312
|
+
zodSchemas: {
|
|
313
|
+
sqlSchema: TBox[K]["schemas"]["sql"];
|
|
314
|
+
clientSchema: TBox[K]["schemas"]["client"];
|
|
315
|
+
validationSchema: TBox[K]["schemas"]["validation"];
|
|
316
|
+
defaultValues: TBox[K]["defaults"];
|
|
317
|
+
toClient: TBox[K]["transforms"]["toClient"];
|
|
318
|
+
toDb: TBox[K]["transforms"]["toDb"];
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
}, "clientSchema">>;
|
|
322
|
+
validation: z.ZodObject<_DeriveViewShape<TTableName, TSelection, {
|
|
323
|
+
[K in keyof TBox]: {
|
|
324
|
+
rawSchema: TBox[K]["definition"];
|
|
325
|
+
zodSchemas: {
|
|
326
|
+
sqlSchema: TBox[K]["schemas"]["sql"];
|
|
327
|
+
clientSchema: TBox[K]["schemas"]["client"];
|
|
328
|
+
validationSchema: TBox[K]["schemas"]["validation"];
|
|
329
|
+
defaultValues: TBox[K]["defaults"];
|
|
330
|
+
toClient: TBox[K]["transforms"]["toClient"];
|
|
331
|
+
toDb: TBox[K]["transforms"]["toDb"];
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
}, "validationSchema">>;
|
|
335
|
+
defaults: DeriveViewDefaults<TTableName, TSelection, {
|
|
336
|
+
[K in keyof TBox]: {
|
|
337
|
+
rawSchema: TBox[K]["definition"];
|
|
338
|
+
zodSchemas: {
|
|
339
|
+
sqlSchema: TBox[K]["schemas"]["sql"];
|
|
340
|
+
clientSchema: TBox[K]["schemas"]["client"];
|
|
341
|
+
validationSchema: TBox[K]["schemas"]["validation"];
|
|
342
|
+
defaultValues: TBox[K]["defaults"];
|
|
343
|
+
toClient: TBox[K]["transforms"]["toClient"];
|
|
344
|
+
toDb: TBox[K]["transforms"]["toDb"];
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
}>;
|
|
348
|
+
};
|
|
307
349
|
export type DeriveViewResult<TTableName extends keyof TRegistry, TSelection, TRegistry extends RegistryShape> = {
|
|
308
350
|
sql: TRegistry[TTableName]["zodSchemas"]["sqlSchema"];
|
|
309
351
|
client: z.ZodObject<_DeriveViewShape<TTableName, TSelection, TRegistry, "clientSchema">>;
|
|
310
352
|
validation: z.ZodObject<_DeriveViewShape<TTableName, TSelection, TRegistry, "validationSchema">>;
|
|
311
|
-
defaults:
|
|
353
|
+
defaults: DeriveViewDefaults<TTableName, TSelection, TRegistry>;
|
|
312
354
|
};
|
|
313
355
|
type NavigationProxy<CurrentTable extends string, Registry extends RegistryShape> = CurrentTable extends keyof Registry ? {
|
|
314
356
|
[K in keyof Registry[CurrentTable]["rawSchema"] as IsRelationField<Registry[CurrentTable]["rawSchema"][K]> extends true ? K : never]: GetRelationRegistryKey<Registry[CurrentTable]["rawSchema"][K], Registry> extends infer TargetKey ? TargetKey extends keyof Registry ? NavigationProxy<TargetKey & string, Registry> : never : never;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cogsbox-shape",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.127",
|
|
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",
|