cogsbox-shape 0.5.115 → 0.5.117
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 +7 -9
- package/dist/schema.js +2 -2
- package/package.json +1 -1
package/dist/schema.d.ts
CHANGED
|
@@ -308,25 +308,23 @@ type RegistryShape = Record<string, {
|
|
|
308
308
|
toDb: (clientObject: any) => any;
|
|
309
309
|
};
|
|
310
310
|
}>;
|
|
311
|
-
type DeriveViewDefaults<TTableName extends keyof TRegistry, TSelection, TRegistry extends RegistryShape, Depth extends any[] = []> = Depth["length"] extends 10 ? any :
|
|
312
|
-
DeriveDefaults<TRegistry[TTableName]["rawSchema"]> & (TSelection extends Record<string, any> ? {
|
|
311
|
+
type DeriveViewDefaults<TTableName extends keyof TRegistry, TSelection, TRegistry extends RegistryShape, Depth extends any[] = []> = Depth["length"] extends 10 ? any : Prettify<DeriveDefaults<TRegistry[TTableName]["rawSchema"]> & (TSelection extends Record<string, any> ? {
|
|
313
312
|
-readonly [K in keyof TSelection & keyof TRegistry[TTableName]["rawSchema"]]?: TRegistry[TTableName]["rawSchema"][K] extends {
|
|
314
313
|
config: {
|
|
315
314
|
sql: {
|
|
316
315
|
type: infer RelType;
|
|
317
|
-
schema:
|
|
316
|
+
schema: any;
|
|
318
317
|
};
|
|
319
318
|
};
|
|
320
|
-
} ?
|
|
321
|
-
_tableName: infer Target;
|
|
322
|
-
} ? Target extends keyof TRegistry ? RelType extends "hasMany" | "manyToMany" ? DeriveViewDefaults<Target, TSelection[K], TRegistry, [
|
|
319
|
+
} ? GetRelationRegistryKey<TRegistry[TTableName]["rawSchema"][K], TRegistry> extends infer TargetKey ? TargetKey extends keyof TRegistry ? RelType extends "hasMany" | "manyToMany" ? DeriveViewDefaults<TargetKey, TSelection[K], TRegistry, [
|
|
323
320
|
...Depth,
|
|
324
321
|
1
|
|
325
|
-
]>[] :
|
|
322
|
+
]>[] : // Recursively call with the CORRECT key (TargetKey)
|
|
323
|
+
DeriveViewDefaults<TargetKey, TSelection[K], TRegistry, [
|
|
326
324
|
...Depth,
|
|
327
325
|
1
|
|
328
|
-
]> | null
|
|
329
|
-
} : {})
|
|
326
|
+
]> | null : never : never : never;
|
|
327
|
+
} : {})>;
|
|
330
328
|
type CreateSchemaBoxReturn<S extends Record<string, SchemaWithPlaceholders>, R extends ResolutionMap<S>, Resolved extends RegistryShape = ResolvedRegistryWithSchemas<S, R> extends RegistryShape ? ResolvedRegistryWithSchemas<S, R> : RegistryShape> = {
|
|
331
329
|
[K in keyof Resolved]: {
|
|
332
330
|
definition: Resolved[K]["rawSchema"];
|
package/dist/schema.js
CHANGED
|
@@ -590,7 +590,7 @@ export function createSchemaBox(schemas, resolver) {
|
|
|
590
590
|
},
|
|
591
591
|
});
|
|
592
592
|
const resolutionConfig = resolver(schemaProxy);
|
|
593
|
-
const resolvedSchemas =
|
|
593
|
+
const resolvedSchemas = schemas;
|
|
594
594
|
// STAGE 1: Resolve references
|
|
595
595
|
for (const tableName in schemas) {
|
|
596
596
|
for (const fieldName in schemas[tableName]) {
|
|
@@ -692,7 +692,7 @@ export function createSchemaBox(schemas, resolver) {
|
|
|
692
692
|
nav: createNavProxy(tableName, finalRegistry),
|
|
693
693
|
// Add this
|
|
694
694
|
RelationSelection: {},
|
|
695
|
-
createView:
|
|
695
|
+
createView: (selection) => {
|
|
696
696
|
const view = createViewObject(tableName, selection, finalRegistry);
|
|
697
697
|
const defaults = computeViewDefaults(tableName, selection, finalRegistry);
|
|
698
698
|
console.log("View defaults:", defaults); // ADD THIS
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cogsbox-shape",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.117",
|
|
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",
|