@instantdb/admin
Advanced tools
Comparing version 0.12.22 to 0.12.23
@@ -67,14 +67,14 @@ import { tx, lookup, TransactionChunk, i, User, AuthToken, id } from "@instantdb/core"; | ||
[LinkAttrName in keyof Entities[EntityName]["links"]]?: any; | ||
}, WithCardinalityInference> = { | ||
[QueryPropName in keyof Query]: Entities[EntityName]["links"][QueryPropName] extends i.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 i.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 i.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>; | ||
type InstaQLQueryResult<Entities extends i.EntitiesDef, Query, WithCardinalityInference = false> = { | ||
type InstaQLQueryResult<Entities extends i.EntitiesDef, Query, WithCardinalityInference extends boolean> = { | ||
[QueryPropName in keyof Query]: QueryPropName extends keyof Entities ? InstaQLQueryEntityResult<Entities, QueryPropName, Query[QueryPropName], WithCardinalityInference>[] : never; | ||
}; | ||
type QueryResponse<T, Schema, WithCardinalityInference = false> = Schema extends i.InstantGraph<infer E, any> ? InstaQLQueryResult<E, T, WithCardinalityInference> : ResponseOf<{ | ||
type QueryResponse<T, Schema, WithCardinalityInference extends boolean> = Schema extends i.InstantGraph<infer E, any> ? InstaQLQueryResult<E, T, WithCardinalityInference> : ResponseOf<{ | ||
[K in keyof T]: Remove$<T[K]>; | ||
@@ -163,7 +163,7 @@ }, Schema>; | ||
*/ | ||
declare function init<Schema = {}>(config: Config): InstantAdmin<Schema>; | ||
declare function init<Schema = {}>(config: Config): InstantAdmin<Schema, false>; | ||
declare function init_experimental<Schema extends i.InstantGraph<any, any, any>, WithCardinalityInference extends boolean = true>(config: Config & { | ||
schema: Schema; | ||
cardinalityInference?: WithCardinalityInference; | ||
}): InstantAdmin<Schema>; | ||
}): InstantAdmin<Schema, WithCardinalityInference>; | ||
/** | ||
@@ -178,3 +178,3 @@ * | ||
*/ | ||
declare class InstantAdmin<Schema extends i.InstantGraph<any, any> | {} = {}> { | ||
declare class InstantAdmin<Schema extends i.InstantGraph<any, any> | {}, WithCardinalityInference extends boolean> { | ||
config: FilledConfig; | ||
@@ -195,3 +195,3 @@ auth: Auth; | ||
*/ | ||
asUser: (opts: ImpersonationOpts) => InstantAdmin<Schema>; | ||
asUser: (opts: ImpersonationOpts) => InstantAdmin<Schema, WithCardinalityInference>; | ||
/** | ||
@@ -212,3 +212,3 @@ * Use this to query your data! | ||
*/ | ||
query: <Q extends Schema extends i.InstantGraph<any, any> ? InstaQLQueryParams<Schema> : Exactly<Query, Q>>(query: Q) => Promise<QueryResponse<Q, Schema>>; | ||
query: <Q extends Schema extends i.InstantGraph<any, any> ? InstaQLQueryParams<Schema> : Exactly<Query, Q>>(query: Q) => Promise<QueryResponse<Q, Schema, WithCardinalityInference>>; | ||
/** | ||
@@ -262,3 +262,3 @@ * Use this to write data! You can create, update, delete, and link objects | ||
}) => Promise<{ | ||
result: QueryResponse<Q, Schema>; | ||
result: QueryResponse<Q, Schema, WithCardinalityInference>; | ||
checkResults: DebugCheckResult[]; | ||
@@ -265,0 +265,0 @@ }>; |
@@ -67,14 +67,14 @@ import { tx, lookup, TransactionChunk, i, User, AuthToken, id } from "@instantdb/core"; | ||
[LinkAttrName in keyof Entities[EntityName]["links"]]?: any; | ||
}, WithCardinalityInference> = { | ||
[QueryPropName in keyof Query]: Entities[EntityName]["links"][QueryPropName] extends i.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 i.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 i.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>; | ||
type InstaQLQueryResult<Entities extends i.EntitiesDef, Query, WithCardinalityInference = false> = { | ||
type InstaQLQueryResult<Entities extends i.EntitiesDef, Query, WithCardinalityInference extends boolean> = { | ||
[QueryPropName in keyof Query]: QueryPropName extends keyof Entities ? InstaQLQueryEntityResult<Entities, QueryPropName, Query[QueryPropName], WithCardinalityInference>[] : never; | ||
}; | ||
type QueryResponse<T, Schema, WithCardinalityInference = false> = Schema extends i.InstantGraph<infer E, any> ? InstaQLQueryResult<E, T, WithCardinalityInference> : ResponseOf<{ | ||
type QueryResponse<T, Schema, WithCardinalityInference extends boolean> = Schema extends i.InstantGraph<infer E, any> ? InstaQLQueryResult<E, T, WithCardinalityInference> : ResponseOf<{ | ||
[K in keyof T]: Remove$<T[K]>; | ||
@@ -163,7 +163,7 @@ }, Schema>; | ||
*/ | ||
declare function init<Schema = {}>(config: Config): InstantAdmin<Schema>; | ||
declare function init<Schema = {}>(config: Config): InstantAdmin<Schema, false>; | ||
declare function init_experimental<Schema extends i.InstantGraph<any, any, any>, WithCardinalityInference extends boolean = true>(config: Config & { | ||
schema: Schema; | ||
cardinalityInference?: WithCardinalityInference; | ||
}): InstantAdmin<Schema>; | ||
}): InstantAdmin<Schema, WithCardinalityInference>; | ||
/** | ||
@@ -178,3 +178,3 @@ * | ||
*/ | ||
declare class InstantAdmin<Schema extends i.InstantGraph<any, any> | {} = {}> { | ||
declare class InstantAdmin<Schema extends i.InstantGraph<any, any> | {}, WithCardinalityInference extends boolean> { | ||
config: FilledConfig; | ||
@@ -195,3 +195,3 @@ auth: Auth; | ||
*/ | ||
asUser: (opts: ImpersonationOpts) => InstantAdmin<Schema>; | ||
asUser: (opts: ImpersonationOpts) => InstantAdmin<Schema, WithCardinalityInference>; | ||
/** | ||
@@ -212,3 +212,3 @@ * Use this to query your data! | ||
*/ | ||
query: <Q extends Schema extends i.InstantGraph<any, any> ? InstaQLQueryParams<Schema> : Exactly<Query, Q>>(query: Q) => Promise<QueryResponse<Q, Schema>>; | ||
query: <Q extends Schema extends i.InstantGraph<any, any> ? InstaQLQueryParams<Schema> : Exactly<Query, Q>>(query: Q) => Promise<QueryResponse<Q, Schema, WithCardinalityInference>>; | ||
/** | ||
@@ -262,3 +262,3 @@ * Use this to write data! You can create, update, delete, and link objects | ||
}) => Promise<{ | ||
result: QueryResponse<Q, Schema>; | ||
result: QueryResponse<Q, Schema, WithCardinalityInference>; | ||
checkResults: DebugCheckResult[]; | ||
@@ -265,0 +265,0 @@ }>; |
{ | ||
"name": "@instantdb/admin", | ||
"version": "v0.12.22", | ||
"version": "v0.12.23", | ||
"description": "Admin SDK for Instant DB", | ||
@@ -27,4 +27,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@instantdb/core": "v0.12.22" | ||
"@instantdb/core": "v0.12.23" | ||
} | ||
} |
@@ -118,3 +118,3 @@ import { | ||
}, | ||
WithCardinalityInference, | ||
WithCardinalityInference extends boolean, | ||
> = { | ||
@@ -132,3 +132,4 @@ [QueryPropName in keyof Query]: Entities[EntityName]["links"][QueryPropName] extends i.LinkAttrDef< | ||
LinkedEntityName, | ||
Query[QueryPropName] | ||
Query[QueryPropName], | ||
WithCardinalityInference | ||
> | ||
@@ -139,3 +140,4 @@ | undefined | ||
LinkedEntityName, | ||
Query[QueryPropName] | ||
Query[QueryPropName], | ||
WithCardinalityInference | ||
>[] | ||
@@ -145,3 +147,4 @@ : InstaQLQueryEntityResult< | ||
LinkedEntityName, | ||
Query[QueryPropName] | ||
Query[QueryPropName], | ||
WithCardinalityInference | ||
>[] | ||
@@ -158,3 +161,3 @@ : never | ||
}, | ||
WithCardinalityInference = false, | ||
WithCardinalityInference extends boolean, | ||
> = { id: string } & InstaQLQueryEntityAttrsResult<Entities, EntityName> & | ||
@@ -171,3 +174,3 @@ InstaQLQueryEntityLinksResult< | ||
Query, | ||
WithCardinalityInference = false, | ||
WithCardinalityInference extends boolean, | ||
> = { | ||
@@ -184,3 +187,3 @@ [QueryPropName in keyof Query]: QueryPropName extends keyof Entities | ||
type QueryResponse<T, Schema, WithCardinalityInference = false> = | ||
type QueryResponse<T, Schema, WithCardinalityInference extends boolean> = | ||
Schema extends i.InstantGraph<infer E, any> | ||
@@ -355,3 +358,3 @@ ? InstaQLQueryResult<E, T, WithCardinalityInference> | ||
function init<Schema = {}>(config: Config) { | ||
return new InstantAdmin<Schema>(config); | ||
return new InstantAdmin<Schema, false>(config); | ||
} | ||
@@ -368,3 +371,3 @@ | ||
) { | ||
return new InstantAdmin<Schema>(config); | ||
return new InstantAdmin<Schema, WithCardinalityInference>(config); | ||
} | ||
@@ -381,3 +384,6 @@ | ||
*/ | ||
class InstantAdmin<Schema extends i.InstantGraph<any, any> | {} = {}> { | ||
class InstantAdmin< | ||
Schema extends i.InstantGraph<any, any> | {}, | ||
WithCardinalityInference extends boolean, | ||
> { | ||
config: FilledConfig; | ||
@@ -410,4 +416,8 @@ auth: Auth; | ||
*/ | ||
asUser = (opts: ImpersonationOpts): InstantAdmin<Schema> => { | ||
const newClient = new InstantAdmin<Schema>({ ...this.config }); | ||
asUser = ( | ||
opts: ImpersonationOpts, | ||
): InstantAdmin<Schema, WithCardinalityInference> => { | ||
const newClient = new InstantAdmin<Schema, WithCardinalityInference>({ | ||
...this.config, | ||
}); | ||
newClient.impersonationOpts = opts; | ||
@@ -438,3 +448,3 @@ return newClient; | ||
query: Q, | ||
): Promise<QueryResponse<Q, Schema>> => { | ||
): Promise<QueryResponse<Q, Schema, WithCardinalityInference>> => { | ||
const withInference = | ||
@@ -515,3 +525,3 @@ "cardinalityInference" in this.config | ||
): Promise<{ | ||
result: QueryResponse<Q, Schema>; | ||
result: QueryResponse<Q, Schema, WithCardinalityInference>; | ||
checkResults: DebugCheckResult[]; | ||
@@ -518,0 +528,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
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
128704
2617
Updated@instantdb/core@v0.12.23