@instantdb/admin
Advanced tools
Comparing version 0.8.1 to 0.8.2
{ | ||
"name": "@instantdb/admin", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"description": "Admin SDK for Instant DB", | ||
@@ -27,5 +27,5 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@instantdb/core": "0.8.1", | ||
"@instantdb/core": "0.8.2", | ||
"uuid": "^9.0.1" | ||
} | ||
} |
import { tx, TransactionChunk, getOps } from "@instantdb/core"; | ||
import * as uuid from "uuid"; | ||
import { | ||
Exactly, | ||
Query, | ||
QueryResponse, | ||
User, | ||
AuthToken, | ||
} from "@instantdb/core"; | ||
import { User, AuthToken } from "@instantdb/core"; | ||
// Query Types | ||
// ----- | ||
type WhereClause = { | ||
[key: string]: string | number | boolean; | ||
}; | ||
type $Option = { $?: { where: WhereClause } }; | ||
type Subquery = { [namespace: string]: NamespaceVal }; | ||
type NamespaceVal = $Option | ($Option & Subquery); | ||
interface Query { | ||
[namespace: string]: NamespaceVal; | ||
} | ||
type InstantObject = { | ||
id: string; | ||
[prop: string]: any; | ||
}; | ||
type ResponseObject<K, Schema> = K extends keyof Schema | ||
? { id: string } & Schema[K] | ||
: InstantObject; | ||
type IsEmptyObject<T> = T extends Record<string, never> ? true : false; | ||
type ResponseOf<Q, Schema> = { | ||
[K in keyof Q]: IsEmptyObject<Q[K]> extends true | ||
? ResponseObject<K, Schema>[] | ||
: (ResponseOf<Q[K], Schema> & ResponseObject<K, Schema>)[]; | ||
}; | ||
type Remove$<T> = T extends object | ||
? { [K in keyof T as Exclude<K, "$">]: Remove$<T[K]> } | ||
: T; | ||
type QueryResponse<T, Schema> = ResponseOf< | ||
{ [K in keyof T]: Remove$<T[K]> }, | ||
Schema | ||
>; | ||
/** | ||
* (XXX) | ||
* https://github.com/microsoft/TypeScript/issues/26051 | ||
* | ||
* Typescript can permit extra keys when a generic extends a type. | ||
* | ||
* For some reason, it makes it possible to write a query like so: | ||
* | ||
* dummyQuery({ | ||
* users: { | ||
* $: { where: { "foo": 1 } }, | ||
* posts: { | ||
* $: { "far": {} } | ||
* } | ||
* } | ||
* | ||
* The problem: $: { "far": {} } | ||
* | ||
* This passes, when it should in reality fail. I don't know why | ||
* adding `Exactly` fixes this, but it does. | ||
* | ||
* */ | ||
type Exactly<Parent, Child extends Parent> = Parent & { | ||
[K in keyof Child]: K extends keyof Parent ? Child[K] : never; | ||
}; | ||
type Config = { | ||
@@ -12,0 +76,0 @@ appId: string; |
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1805
20
42
3
63278
1466
196
+ Added@instantdb/core@0.8.2(transitive)
- Removed@instantdb/core@0.8.1(transitive)
Updated@instantdb/core@0.8.2