@instantdb/core
Advanced tools
Comparing version 0.12.22 to 0.12.23
@@ -33,3 +33,3 @@ import Reactor from "./Reactor"; | ||
type AuthToken = string; | ||
type SubscriptionState<Q, Schema, WithCardinalityInference = false> = { | ||
type SubscriptionState<Q, Schema, WithCardinalityInference extends boolean> = { | ||
error: { | ||
@@ -45,3 +45,3 @@ message: string; | ||
}; | ||
type LifecycleSubscriptionState<Q, Schema, WithCardinalityInference = false> = SubscriptionState<Q, Schema, WithCardinalityInference> & { | ||
type LifecycleSubscriptionState<Q, Schema, WithCardinalityInference extends boolean> = SubscriptionState<Q, Schema, WithCardinalityInference> & { | ||
isLoading: boolean; | ||
@@ -48,0 +48,0 @@ }; |
@@ -10,11 +10,11 @@ import { DataAttrDef, InstantGraph, LinkAttrDef } from "./schema"; | ||
type UpdateParams<Schema extends InstantGraph<any, any>, EntityName extends keyof Schema["entities"]> = { | ||
[AttrName in keyof Schema["entities"][EntityName]["attrs"]]?: Schema["entities"][EntityName]["attrs"][AttrName] extends DataAttrDef<infer ValueType, any> ? ValueType : never; | ||
} & { | ||
[AttrName in keyof Schema["entities"][EntityName]["attrs"]]?: Schema["entities"][EntityName]["attrs"][AttrName] extends DataAttrDef<infer ValueType, infer IsRequired> ? IsRequired extends true ? ValueType : ValueType | null : never; | ||
} & (Schema extends InstantGraph<any, any> ? {} : { | ||
[attribute: string]: any; | ||
}; | ||
}); | ||
type LinkParams<Schema extends InstantGraph<any, any>, EntityName extends keyof Schema["entities"]> = { | ||
[LinkName in keyof Schema["entities"][EntityName]["links"]]?: Schema["entities"][EntityName]["links"][LinkName] extends LinkAttrDef<infer Cardinality, any> ? Cardinality extends "one" ? string : string | string[] : never; | ||
} & { | ||
[attribute: string]: string | string[]; | ||
}; | ||
} & (Schema extends InstantGraph<any, any> ? {} : { | ||
[attribute: string]: any; | ||
}); | ||
export interface TransactionChunk<Schema extends InstantGraph<any, any, any>, EntityName extends keyof Schema["entities"]> { | ||
@@ -21,0 +21,0 @@ __ops: Op[]; |
@@ -33,3 +33,3 @@ import Reactor from "./Reactor"; | ||
type AuthToken = string; | ||
type SubscriptionState<Q, Schema, WithCardinalityInference = false> = { | ||
type SubscriptionState<Q, Schema, WithCardinalityInference extends boolean> = { | ||
error: { | ||
@@ -45,3 +45,3 @@ message: string; | ||
}; | ||
type LifecycleSubscriptionState<Q, Schema, WithCardinalityInference = false> = SubscriptionState<Q, Schema, WithCardinalityInference> & { | ||
type LifecycleSubscriptionState<Q, Schema, WithCardinalityInference extends boolean> = SubscriptionState<Q, Schema, WithCardinalityInference> & { | ||
isLoading: boolean; | ||
@@ -48,0 +48,0 @@ }; |
@@ -10,11 +10,11 @@ import { DataAttrDef, InstantGraph, LinkAttrDef } from "./schema"; | ||
type UpdateParams<Schema extends InstantGraph<any, any>, EntityName extends keyof Schema["entities"]> = { | ||
[AttrName in keyof Schema["entities"][EntityName]["attrs"]]?: Schema["entities"][EntityName]["attrs"][AttrName] extends DataAttrDef<infer ValueType, any> ? ValueType : never; | ||
} & { | ||
[AttrName in keyof Schema["entities"][EntityName]["attrs"]]?: Schema["entities"][EntityName]["attrs"][AttrName] extends DataAttrDef<infer ValueType, infer IsRequired> ? IsRequired extends true ? ValueType : ValueType | null : never; | ||
} & (Schema extends InstantGraph<any, any> ? {} : { | ||
[attribute: string]: any; | ||
}; | ||
}); | ||
type LinkParams<Schema extends InstantGraph<any, any>, EntityName extends keyof Schema["entities"]> = { | ||
[LinkName in keyof Schema["entities"][EntityName]["links"]]?: Schema["entities"][EntityName]["links"][LinkName] extends LinkAttrDef<infer Cardinality, any> ? Cardinality extends "one" ? string : string | string[] : never; | ||
} & { | ||
[attribute: string]: string | string[]; | ||
}; | ||
} & (Schema extends InstantGraph<any, any> ? {} : { | ||
[attribute: string]: any; | ||
}); | ||
export interface TransactionChunk<Schema extends InstantGraph<any, any, any>, EntityName extends keyof Schema["entities"]> { | ||
@@ -21,0 +21,0 @@ __ops: Op[]; |
@@ -62,3 +62,3 @@ import { DataAttrDef, EntitiesDef, InstantGraph, LinkAttrDef } from "./schema"; | ||
} : T; | ||
type QueryResponse<T, Schema, WithCardinalityInference = false> = Schema extends InstantGraph<infer E, any> ? InstaQLQueryResult<E, T, WithCardinalityInference> : ResponseOf<{ | ||
type QueryResponse<T, Schema, WithCardinalityInference extends boolean = false> = Schema extends InstantGraph<infer E, any> ? InstaQLQueryResult<E, T, WithCardinalityInference> : ResponseOf<{ | ||
[K in keyof T]: Remove$<T[K]>; | ||
@@ -105,11 +105,11 @@ }, Schema>; | ||
[LinkAttrName in keyof Entities[EntityName]["links"]]?: any; | ||
}, WithCardinalityInference> = { | ||
[QueryPropName in keyof Query]: Entities[EntityName]["links"][QueryPropName] extends LinkAttrDef<infer Cardinality, infer LinkedEntityName> ? LinkedEntityName extends keyof Entities ? WithCardinalityInference extends true ? Cardinality extends "one" ? InstaQLQueryEntityResult<Entities, LinkedEntityName, Query[QueryPropName]> | undefined : InstaQLQueryEntityResult<Entities, LinkedEntityName, Query[QueryPropName]>[] : InstaQLQueryEntityResult<Entities, LinkedEntityName, Query[QueryPropName]>[] : never : never; | ||
}, WithCardinalityInference extends boolean> = { | ||
[QueryPropName in keyof Query]: Entities[EntityName]["links"][QueryPropName] extends LinkAttrDef<infer Cardinality, infer LinkedEntityName> ? LinkedEntityName extends keyof Entities ? WithCardinalityInference extends true ? Cardinality extends "one" ? InstaQLQueryEntityResult<Entities, LinkedEntityName, Query[QueryPropName], WithCardinalityInference> | undefined : InstaQLQueryEntityResult<Entities, LinkedEntityName, Query[QueryPropName], WithCardinalityInference>[] : InstaQLQueryEntityResult<Entities, LinkedEntityName, Query[QueryPropName], WithCardinalityInference>[] : never : never; | ||
}; | ||
type InstaQLQueryEntityResult<Entities extends EntitiesDef, EntityName extends keyof Entities, Query extends { | ||
[QueryPropName in keyof Entities[EntityName]["links"]]?: any; | ||
}, WithCardinalityInference = false> = { | ||
}, WithCardinalityInference extends boolean> = { | ||
id: string; | ||
} & InstaQLQueryEntityAttrsResult<Entities, EntityName> & InstaQLQueryEntityLinksResult<Entities, EntityName, Query, WithCardinalityInference>; | ||
export type InstaQLQueryResult<Entities extends EntitiesDef, Query, WithCardinalityInference = false> = { | ||
export type InstaQLQueryResult<Entities extends EntitiesDef, Query, WithCardinalityInference extends boolean> = { | ||
[QueryPropName in keyof Query]: QueryPropName extends keyof Entities ? InstaQLQueryEntityResult<Entities, QueryPropName, Query[QueryPropName], WithCardinalityInference>[] : never; | ||
@@ -116,0 +116,0 @@ }; |
@@ -55,3 +55,3 @@ import type { RoomSchemaShape } from "./presence"; | ||
declare function boolean(): DataAttrDef<boolean, true>; | ||
declare function json<T extends JSONValue>(): DataAttrDef<T, true>; | ||
declare function json<T = any>(): DataAttrDef<T, true>; | ||
declare function any(): DataAttrDef<JSONValue, true>; | ||
@@ -58,0 +58,0 @@ declare class LinkAttrDef<Cardinality extends CardinalityKind, EntityName extends string> { |
@@ -62,3 +62,3 @@ import { DataAttrDef, EntitiesDef, InstantGraph, LinkAttrDef } from "./schema"; | ||
} : T; | ||
type QueryResponse<T, Schema, WithCardinalityInference = false> = Schema extends InstantGraph<infer E, any> ? InstaQLQueryResult<E, T, WithCardinalityInference> : ResponseOf<{ | ||
type QueryResponse<T, Schema, WithCardinalityInference extends boolean = false> = Schema extends InstantGraph<infer E, any> ? InstaQLQueryResult<E, T, WithCardinalityInference> : ResponseOf<{ | ||
[K in keyof T]: Remove$<T[K]>; | ||
@@ -105,11 +105,11 @@ }, Schema>; | ||
[LinkAttrName in keyof Entities[EntityName]["links"]]?: any; | ||
}, WithCardinalityInference> = { | ||
[QueryPropName in keyof Query]: Entities[EntityName]["links"][QueryPropName] extends LinkAttrDef<infer Cardinality, infer LinkedEntityName> ? LinkedEntityName extends keyof Entities ? WithCardinalityInference extends true ? Cardinality extends "one" ? InstaQLQueryEntityResult<Entities, LinkedEntityName, Query[QueryPropName]> | undefined : InstaQLQueryEntityResult<Entities, LinkedEntityName, Query[QueryPropName]>[] : InstaQLQueryEntityResult<Entities, LinkedEntityName, Query[QueryPropName]>[] : never : never; | ||
}, WithCardinalityInference extends boolean> = { | ||
[QueryPropName in keyof Query]: Entities[EntityName]["links"][QueryPropName] extends LinkAttrDef<infer Cardinality, infer LinkedEntityName> ? LinkedEntityName extends keyof Entities ? WithCardinalityInference extends true ? Cardinality extends "one" ? InstaQLQueryEntityResult<Entities, LinkedEntityName, Query[QueryPropName], WithCardinalityInference> | undefined : InstaQLQueryEntityResult<Entities, LinkedEntityName, Query[QueryPropName], WithCardinalityInference>[] : InstaQLQueryEntityResult<Entities, LinkedEntityName, Query[QueryPropName], WithCardinalityInference>[] : never : never; | ||
}; | ||
type InstaQLQueryEntityResult<Entities extends EntitiesDef, EntityName extends keyof Entities, Query extends { | ||
[QueryPropName in keyof Entities[EntityName]["links"]]?: any; | ||
}, WithCardinalityInference = false> = { | ||
}, WithCardinalityInference extends boolean> = { | ||
id: string; | ||
} & InstaQLQueryEntityAttrsResult<Entities, EntityName> & InstaQLQueryEntityLinksResult<Entities, EntityName, Query, WithCardinalityInference>; | ||
export type InstaQLQueryResult<Entities extends EntitiesDef, Query, WithCardinalityInference = false> = { | ||
export type InstaQLQueryResult<Entities extends EntitiesDef, Query, WithCardinalityInference extends boolean> = { | ||
[QueryPropName in keyof Query]: QueryPropName extends keyof Entities ? InstaQLQueryEntityResult<Entities, QueryPropName, Query[QueryPropName], WithCardinalityInference>[] : never; | ||
@@ -116,0 +116,0 @@ }; |
@@ -55,3 +55,3 @@ import type { RoomSchemaShape } from "./presence"; | ||
declare function boolean(): DataAttrDef<boolean, true>; | ||
declare function json<T extends JSONValue>(): DataAttrDef<T, true>; | ||
declare function json<T = any>(): DataAttrDef<T, true>; | ||
declare function any(): DataAttrDef<JSONValue, true>; | ||
@@ -58,0 +58,0 @@ declare class LinkAttrDef<Cardinality extends CardinalityKind, EntityName extends string> { |
{ | ||
"name": "@instantdb/core", | ||
"version": "v0.12.22", | ||
"version": "v0.12.23", | ||
"description": "Instant's core local abstraction", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -74,3 +74,3 @@ import Reactor from "./Reactor"; | ||
type SubscriptionState<Q, Schema, WithCardinalityInference = false> = | ||
type SubscriptionState<Q, Schema, WithCardinalityInference extends boolean> = | ||
| { error: { message: string }; data: undefined; pageInfo: undefined } | ||
@@ -86,3 +86,3 @@ | { | ||
Schema, | ||
WithCardinalityInference = false, | ||
WithCardinalityInference extends boolean, | ||
> = SubscriptionState<Q, Schema, WithCardinalityInference> & { | ||
@@ -89,0 +89,0 @@ isLoading: boolean; |
@@ -17,9 +17,13 @@ import { DataAttrDef, InstantGraph, LinkAttrDef } from "./schema"; | ||
infer ValueType, | ||
any | ||
infer IsRequired | ||
> | ||
? ValueType | ||
? IsRequired extends true | ||
? ValueType | ||
: ValueType | null | ||
: never; | ||
} & { | ||
[attribute: string]: any; | ||
}; | ||
} & (Schema extends InstantGraph<any, any> | ||
? {} | ||
: { | ||
[attribute: string]: any; | ||
}); | ||
@@ -38,5 +42,3 @@ type LinkParams< | ||
: never; | ||
} & { | ||
[attribute: string]: string | string[]; | ||
}; | ||
} & (Schema extends InstantGraph<any, any> ? {} : { [attribute: string]: any }); | ||
@@ -43,0 +45,0 @@ export interface TransactionChunk< |
@@ -85,3 +85,7 @@ // Query | ||
type QueryResponse<T, Schema, WithCardinalityInference = false> = | ||
type QueryResponse< | ||
T, | ||
Schema, | ||
WithCardinalityInference extends boolean = false, | ||
> = | ||
Schema extends InstantGraph<infer E, any> | ||
@@ -151,3 +155,3 @@ ? InstaQLQueryResult<E, T, WithCardinalityInference> | ||
}, | ||
WithCardinalityInference, | ||
WithCardinalityInference extends boolean, | ||
> = { | ||
@@ -165,3 +169,4 @@ [QueryPropName in keyof Query]: Entities[EntityName]["links"][QueryPropName] extends LinkAttrDef< | ||
LinkedEntityName, | ||
Query[QueryPropName] | ||
Query[QueryPropName], | ||
WithCardinalityInference | ||
> | ||
@@ -172,3 +177,4 @@ | undefined | ||
LinkedEntityName, | ||
Query[QueryPropName] | ||
Query[QueryPropName], | ||
WithCardinalityInference | ||
>[] | ||
@@ -178,3 +184,4 @@ : InstaQLQueryEntityResult< | ||
LinkedEntityName, | ||
Query[QueryPropName] | ||
Query[QueryPropName], | ||
WithCardinalityInference | ||
>[] | ||
@@ -191,3 +198,3 @@ : never | ||
}, | ||
WithCardinalityInference = false, | ||
WithCardinalityInference extends boolean, | ||
> = { id: string } & InstaQLQueryEntityAttrsResult<Entities, EntityName> & | ||
@@ -204,3 +211,3 @@ InstaQLQueryEntityLinksResult< | ||
Query, | ||
WithCardinalityInference = false, | ||
WithCardinalityInference extends boolean, | ||
> = { | ||
@@ -207,0 +214,0 @@ [QueryPropName in keyof Query]: QueryPropName extends keyof Entities |
@@ -103,3 +103,3 @@ import type { RoomSchemaShape } from "./presence"; | ||
function json<T extends JSONValue>(): DataAttrDef<T, true> { | ||
function json<T = any>(): DataAttrDef<T, true> { | ||
return new DataAttrDef("json", true); | ||
@@ -106,0 +106,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
1914408
39179