convex-selections
Advanced tools
Comparing version 0.0.3 to 0.0.4
import { UnionToIntersection } from 'type-fest'; | ||
import { GenericId } from 'convex/values'; | ||
import { Validator, GenericId } from 'convex/values'; | ||
type Relation<$TableName extends string> = `__RELATION__:${$TableName}`; | ||
type Relation<$TableName extends string> = Validator<`__RELATION__:${$TableName}` | undefined, true, never>; | ||
type RelationArray<$TableName extends string> = Validator<`__RELATION__:${$TableName}`[] | undefined, true, never>; | ||
@@ -9,2 +10,4 @@ type SelectInputFromDataModel<$DataModel, $TableName extends string> = { | ||
select: SelectInputFromDataModel<$DataModel, $SelectedTableName>; | ||
} : NonNullable<$Item> extends RelationArray<infer $SelectedTableName> ? { | ||
select: SelectInputFromDataModel<$DataModel, $SelectedTableName>; | ||
} : NonNullable<$Item> extends Relation<infer $SelectedTableName> ? { | ||
@@ -14,2 +17,4 @@ select: SelectInputFromDataModel<$DataModel, $SelectedTableName>; | ||
select: SelectInputFromDataModel<$DataModel, $SelectedTableName>; | ||
} : NonNullable<$DataModel[$TableName]['document'][K]> extends RelationArray<infer $SelectedTableName> ? { | ||
select: SelectInputFromDataModel<$DataModel, $SelectedTableName>; | ||
} : NonNullable<$DataModel[$TableName]['document'][K]> extends Relation<infer $SelectedTableName> ? { | ||
@@ -69,2 +74,2 @@ select: SelectInputFromDataModel<$DataModel, $SelectedTableName>; | ||
export { type ExpandMapping, type ExpandSelections, type InferSelectionDefinition, type ProcedureReturnType, type RecursivelyExpandSelection, type Relation, type SchemaFromProcedureCallback, type SelectInputFromDataModel, type SelectOutputFromDataModel, type SelectionDefinition, type SelectionSelect, type Selections, type WithOptions, combineSelections, createSelectionFunction, createWithSelection, defineSelectionMappings, expandSelections, unscopeSelections }; | ||
export { type ExpandMapping, type ExpandSelections, type InferSelectionDefinition, type ProcedureReturnType, type RecursivelyExpandSelection, type Relation, type RelationArray, type SchemaFromProcedureCallback, type SelectInputFromDataModel, type SelectOutputFromDataModel, type SelectionDefinition, type SelectionSelect, type Selections, type WithOptions, combineSelections, createSelectionFunction, createWithSelection, defineSelectionMappings, expandSelections, unscopeSelections }; |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"exports": { | ||
@@ -8,0 +8,0 @@ ".": "./index.js", |
@@ -1,1 +0,3 @@ | ||
export type Relation<$TableName extends string> = `__RELATION__:${$TableName}`; | ||
import { Validator } from 'convex/values'; | ||
export type Relation<$TableName extends string> = Validator<`__RELATION__:${$TableName}` | undefined, true, never>; | ||
export type RelationArray<$TableName extends string> = Validator<`__RELATION__:${$TableName}`[] | undefined, true, never>; |
import type { GenericId } from 'convex/values'; | ||
import type { Relation } from '../types/relation.js'; | ||
import type { Relation, RelationArray } from '../types/relation.js'; | ||
export type SelectInputFromDataModel<$DataModel, $TableName extends string> = { | ||
[K in keyof $DataModel[$TableName]['document']]?: NonNullable<$DataModel[$TableName]['document'][K]> extends Array<infer $Item> ? NonNullable<$Item> extends GenericId<infer $SelectedTableName> ? { | ||
select: SelectInputFromDataModel<$DataModel, $SelectedTableName>; | ||
} : NonNullable<$Item> extends RelationArray<infer $SelectedTableName> ? { | ||
select: SelectInputFromDataModel<$DataModel, $SelectedTableName>; | ||
} : NonNullable<$Item> extends Relation<infer $SelectedTableName> ? { | ||
@@ -10,2 +12,4 @@ select: SelectInputFromDataModel<$DataModel, $SelectedTableName>; | ||
select: SelectInputFromDataModel<$DataModel, $SelectedTableName>; | ||
} : NonNullable<$DataModel[$TableName]['document'][K]> extends RelationArray<infer $SelectedTableName> ? { | ||
select: SelectInputFromDataModel<$DataModel, $SelectedTableName>; | ||
} : NonNullable<$DataModel[$TableName]['document'][K]> extends Relation<infer $SelectedTableName> ? { | ||
@@ -12,0 +16,0 @@ select: SelectInputFromDataModel<$DataModel, $SelectedTableName>; |
@@ -1,2 +0,3 @@ | ||
export declare function vRelation<$ForeignTableName extends string, $ForeignProperty>(foreignTableName: $ForeignTableName, _foreignProperty: $ForeignProperty): import("convex/values").Validator<`__RELATION__:${$ForeignTableName}` | undefined, true, never>; | ||
export declare function vRelationArray<$ForeignTableName extends string, $ForeignProperty>(foreignTableName: $ForeignTableName, _foreignProperty: $ForeignProperty): import("convex/values").Validator<`__RELATION__:${$ForeignTableName}`[] | undefined, true, never>; | ||
import type { Relation, RelationArray } from '../types/relation.js'; | ||
export declare function vRelation<$ForeignTableName extends string, $ForeignProperty>(foreignTableName: $ForeignTableName, _foreignProperty: $ForeignProperty): Relation<$ForeignTableName>; | ||
export declare function vRelationArray<$ForeignTableName extends string, $ForeignProperty>(foreignTableName: $ForeignTableName, _foreignProperty: $ForeignProperty): RelationArray<$ForeignTableName>; |
31232
420