Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@instantdb/admin

Package Overview
Dependencies
Maintainers
0
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@instantdb/admin - npm Package Compare versions

Comparing version 0.11.0 to 0.11.1

93

dist/index.d.ts
import { tx, lookup, TransactionChunk } from "@instantdb/core";
import { User, AuthToken } from "@instantdb/core";
type NonEmpty<T> = {
declare type NonEmpty<T> = {
[K in keyof T]-?: Required<Pick<T, K>>;
}[keyof T];
type WhereArgs = {
declare type WhereArgs = {
in?: (string | number | boolean)[];
};
type WhereClauseValue = string | number | boolean | NonEmpty<WhereArgs>;
type BaseWhereClause = {
declare type WhereClauseValue = string | number | boolean | NonEmpty<WhereArgs>;
declare type BaseWhereClause = {
[key: string]: WhereClauseValue;
};
type WhereClauseWithCombinaton = {
declare type WhereClauseWithCombinaton = {
or?: WhereClause[] | WhereClauseValue;
and?: WhereClause[] | WhereClauseValue;
};
type WhereClause = WhereClauseWithCombinaton | (WhereClauseWithCombinaton & BaseWhereClause);
declare type WhereClause = WhereClauseWithCombinaton | (WhereClauseWithCombinaton & BaseWhereClause);
/**

@@ -25,8 +25,8 @@ * A tuple representing a cursor.

*/
type Cursor = [string, string, any, number];
type Direction = "asc" | "desc";
type Order = {
declare type Cursor = [string, string, any, number];
declare type Direction = "asc" | "desc";
declare type Order = {
serverCreatedAt: Direction;
};
type $Option = {
declare type $Option = {
$?: {

@@ -43,24 +43,24 @@ where?: WhereClause;

};
type Subquery = {
declare type Subquery = {
[namespace: string]: NamespaceVal;
};
type NamespaceVal = $Option | ($Option & Subquery);
declare type NamespaceVal = $Option | ($Option & Subquery);
interface Query {
[namespace: string]: NamespaceVal;
}
type InstantObject = {
declare type InstantObject = {
id: string;
[prop: string]: any;
};
type ResponseObject<K, Schema> = K extends keyof Schema ? {
declare 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> = {
declare type IsEmptyObject<T> = T extends Record<string, never> ? true : false;
declare 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 ? {
declare type Remove$<T> = T extends object ? {
[K in keyof T as Exclude<K, "$">]: Remove$<T[K]>;
} : T;
type QueryResponse<T, Schema> = ResponseOf<{
declare type QueryResponse<T, Schema> = ResponseOf<{
[K in keyof T]: Remove$<T[K]>;

@@ -71,3 +71,3 @@ }, Schema>;

*/
export type DebugCheckResult = {
export declare type DebugCheckResult = {
/** The ID of the record. */

@@ -104,6 +104,6 @@ id: string;

* */
type Exactly<Parent, Child extends Parent> = Parent & {
declare type Exactly<Parent, Child extends Parent> = Parent & {
[K in keyof Child]: K extends keyof Parent ? Child[K] : never;
};
type Config = {
declare type Config = {
appId: string;

@@ -113,6 +113,6 @@ adminToken: string;

};
type FilledConfig = Config & {
declare type FilledConfig = Config & {
apiURI: string;
};
type ImpersonationOpts = {
declare type ImpersonationOpts = {
email: string;

@@ -185,3 +185,3 @@ } | {

*/
query: <Q extends Query>(query: Exactly<Query, Q>) => Promise<QueryResponse<Q, Schema>>;
query: <Q extends Query>(query: Exactly<Query, Q>) => Promise<ResponseOf<{ [K in keyof Q]: Remove$<Q[K]>; }, Schema>>;
/**

@@ -235,3 +235,3 @@ * Use this to write data! You can create, update, delete, and link objects

}) => Promise<{
result: QueryResponse<Q, Schema>;
result: ResponseOf<{ [K in keyof Q]: Remove$<Q[K]>; }, Schema>;
checkResults: DebugCheckResult[];

@@ -298,2 +298,45 @@ }>;

/**
* Retrieves an app user by id, email, or refresh token.
*
* @example
* try {
* const user = await db.auth.getUser({ email })
* console.log("Found user:", user)
* } catch (err) {
* console.error("Failed to retrieve user:", err.message);
* }
*
* @see https://docs.instantdb.com/docs/backend#retrieve-a-user
*/
getUser: (params: {
email: string;
} | {
id: string;
} | {
refresh_token: string;
}) => Promise<User>;
/**
* Deletes an app user by id, email, or refresh token.
*
* NB: This _only_ deletes the user; it does not delete all user data.
* You will need to handle this manually.
*
* @example
* try {
* const deletedUser = await db.auth.deleteUser({ email })
* console.log("Deleted user:", deletedUser)
* } catch (err) {
* console.error("Failed to delete user:", err.message);
* }
*
* @see https://docs.instantdb.com/docs/backend#delete-a-user
*/
deleteUser: (params: {
email: string;
} | {
id: string;
} | {
refresh_token: string;
}) => Promise<User>;
/**
* Signs out the user with the given email.

@@ -300,0 +343,0 @@ * This invalidates any tokens associated with the user.

@@ -35,4 +35,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.lookup = exports.tx = exports.id = void 0;
exports.init = init;
exports.lookup = exports.tx = exports.id = exports.init = void 0;
const core_1 = require("@instantdb/core");

@@ -124,2 +123,3 @@ Object.defineProperty(exports, "tx", { enumerable: true, get: function () { return core_1.tx; } });

}
exports.init = init;
/**

@@ -324,2 +324,47 @@ *

});
/**
* Retrieves an app user by id, email, or refresh token.
*
* @example
* try {
* const user = await db.auth.getUser({ email })
* console.log("Found user:", user)
* } catch (err) {
* console.error("Failed to retrieve user:", err.message);
* }
*
* @see https://docs.instantdb.com/docs/backend#retrieve-a-user
*/
this.getUser = (params) => __awaiter(this, void 0, void 0, function* () {
const qs = Object.entries(params).map(([k, v]) => `${k}=${v}`);
const response = yield jsonFetch(`${this.config.apiURI}/admin/users?${qs}`, {
method: "GET",
headers: authorizedHeaders(this.config),
});
return response.user;
});
/**
* Deletes an app user by id, email, or refresh token.
*
* NB: This _only_ deletes the user; it does not delete all user data.
* You will need to handle this manually.
*
* @example
* try {
* const deletedUser = await db.auth.deleteUser({ email })
* console.log("Deleted user:", deletedUser)
* } catch (err) {
* console.error("Failed to delete user:", err.message);
* }
*
* @see https://docs.instantdb.com/docs/backend#delete-a-user
*/
this.deleteUser = (params) => __awaiter(this, void 0, void 0, function* () {
const qs = Object.entries(params).map(([k, v]) => `${k}=${v}`);
const response = yield jsonFetch(`${this.config.apiURI}/admin/users?${qs}`, {
method: "DELETE",
headers: authorizedHeaders(this.config),
});
return response.deleted;
});
this.config = config;

@@ -326,0 +371,0 @@ }

import { tx, lookup, TransactionChunk } from "@instantdb/core";
import { User, AuthToken } from "@instantdb/core";
type NonEmpty<T> = {
declare type NonEmpty<T> = {
[K in keyof T]-?: Required<Pick<T, K>>;
}[keyof T];
type WhereArgs = {
declare type WhereArgs = {
in?: (string | number | boolean)[];
};
type WhereClauseValue = string | number | boolean | NonEmpty<WhereArgs>;
type BaseWhereClause = {
declare type WhereClauseValue = string | number | boolean | NonEmpty<WhereArgs>;
declare type BaseWhereClause = {
[key: string]: WhereClauseValue;
};
type WhereClauseWithCombinaton = {
declare type WhereClauseWithCombinaton = {
or?: WhereClause[] | WhereClauseValue;
and?: WhereClause[] | WhereClauseValue;
};
type WhereClause = WhereClauseWithCombinaton | (WhereClauseWithCombinaton & BaseWhereClause);
declare type WhereClause = WhereClauseWithCombinaton | (WhereClauseWithCombinaton & BaseWhereClause);
/**

@@ -25,8 +25,8 @@ * A tuple representing a cursor.

*/
type Cursor = [string, string, any, number];
type Direction = "asc" | "desc";
type Order = {
declare type Cursor = [string, string, any, number];
declare type Direction = "asc" | "desc";
declare type Order = {
serverCreatedAt: Direction;
};
type $Option = {
declare type $Option = {
$?: {

@@ -43,24 +43,24 @@ where?: WhereClause;

};
type Subquery = {
declare type Subquery = {
[namespace: string]: NamespaceVal;
};
type NamespaceVal = $Option | ($Option & Subquery);
declare type NamespaceVal = $Option | ($Option & Subquery);
interface Query {
[namespace: string]: NamespaceVal;
}
type InstantObject = {
declare type InstantObject = {
id: string;
[prop: string]: any;
};
type ResponseObject<K, Schema> = K extends keyof Schema ? {
declare 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> = {
declare type IsEmptyObject<T> = T extends Record<string, never> ? true : false;
declare 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 ? {
declare type Remove$<T> = T extends object ? {
[K in keyof T as Exclude<K, "$">]: Remove$<T[K]>;
} : T;
type QueryResponse<T, Schema> = ResponseOf<{
declare type QueryResponse<T, Schema> = ResponseOf<{
[K in keyof T]: Remove$<T[K]>;

@@ -71,3 +71,3 @@ }, Schema>;

*/
export type DebugCheckResult = {
export declare type DebugCheckResult = {
/** The ID of the record. */

@@ -104,6 +104,6 @@ id: string;

* */
type Exactly<Parent, Child extends Parent> = Parent & {
declare type Exactly<Parent, Child extends Parent> = Parent & {
[K in keyof Child]: K extends keyof Parent ? Child[K] : never;
};
type Config = {
declare type Config = {
appId: string;

@@ -113,6 +113,6 @@ adminToken: string;

};
type FilledConfig = Config & {
declare type FilledConfig = Config & {
apiURI: string;
};
type ImpersonationOpts = {
declare type ImpersonationOpts = {
email: string;

@@ -185,3 +185,3 @@ } | {

*/
query: <Q extends Query>(query: Exactly<Query, Q>) => Promise<QueryResponse<Q, Schema>>;
query: <Q extends Query>(query: Exactly<Query, Q>) => Promise<ResponseOf<{ [K in keyof Q]: Remove$<Q[K]>; }, Schema>>;
/**

@@ -235,3 +235,3 @@ * Use this to write data! You can create, update, delete, and link objects

}) => Promise<{
result: QueryResponse<Q, Schema>;
result: ResponseOf<{ [K in keyof Q]: Remove$<Q[K]>; }, Schema>;
checkResults: DebugCheckResult[];

@@ -298,2 +298,45 @@ }>;

/**
* Retrieves an app user by id, email, or refresh token.
*
* @example
* try {
* const user = await db.auth.getUser({ email })
* console.log("Found user:", user)
* } catch (err) {
* console.error("Failed to retrieve user:", err.message);
* }
*
* @see https://docs.instantdb.com/docs/backend#retrieve-a-user
*/
getUser: (params: {
email: string;
} | {
id: string;
} | {
refresh_token: string;
}) => Promise<User>;
/**
* Deletes an app user by id, email, or refresh token.
*
* NB: This _only_ deletes the user; it does not delete all user data.
* You will need to handle this manually.
*
* @example
* try {
* const deletedUser = await db.auth.deleteUser({ email })
* console.log("Deleted user:", deletedUser)
* } catch (err) {
* console.error("Failed to delete user:", err.message);
* }
*
* @see https://docs.instantdb.com/docs/backend#delete-a-user
*/
deleteUser: (params: {
email: string;
} | {
id: string;
} | {
refresh_token: string;
}) => Promise<User>;
/**
* Signs out the user with the given email.

@@ -300,0 +343,0 @@ * This invalidates any tokens associated with the user.

@@ -292,2 +292,47 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

});
/**
* Retrieves an app user by id, email, or refresh token.
*
* @example
* try {
* const user = await db.auth.getUser({ email })
* console.log("Found user:", user)
* } catch (err) {
* console.error("Failed to retrieve user:", err.message);
* }
*
* @see https://docs.instantdb.com/docs/backend#retrieve-a-user
*/
this.getUser = (params) => __awaiter(this, void 0, void 0, function* () {
const qs = Object.entries(params).map(([k, v]) => `${k}=${v}`);
const response = yield jsonFetch(`${this.config.apiURI}/admin/users?${qs}`, {
method: "GET",
headers: authorizedHeaders(this.config),
});
return response.user;
});
/**
* Deletes an app user by id, email, or refresh token.
*
* NB: This _only_ deletes the user; it does not delete all user data.
* You will need to handle this manually.
*
* @example
* try {
* const deletedUser = await db.auth.deleteUser({ email })
* console.log("Deleted user:", deletedUser)
* } catch (err) {
* console.error("Failed to delete user:", err.message);
* }
*
* @see https://docs.instantdb.com/docs/backend#delete-a-user
*/
this.deleteUser = (params) => __awaiter(this, void 0, void 0, function* () {
const qs = Object.entries(params).map(([k, v]) => `${k}=${v}`);
const response = yield jsonFetch(`${this.config.apiURI}/admin/users?${qs}`, {
method: "DELETE",
headers: authorizedHeaders(this.config),
});
return response.deleted;
});
this.config = config;

@@ -294,0 +339,0 @@ }

{
"name": "@instantdb/admin",
"version": "0.11.0",
"version": "0.11.1",
"description": "Admin SDK for Instant DB",

@@ -27,5 +27,5 @@ "main": "dist/index.js",

"dependencies": {
"@instantdb/core": "0.11.0",
"@instantdb/core": "0.11.1",
"uuid": "^9.0.1"
}
}

@@ -477,3 +477,63 @@ import { tx, lookup, TransactionChunk, getOps } from "@instantdb/core";

};
/**
* Retrieves an app user by id, email, or refresh token.
*
* @example
* try {
* const user = await db.auth.getUser({ email })
* console.log("Found user:", user)
* } catch (err) {
* console.error("Failed to retrieve user:", err.message);
* }
*
* @see https://docs.instantdb.com/docs/backend#retrieve-a-user
*/
getUser = async (
params: { email: string } | { id: string } | { refresh_token: string },
): Promise<User> => {
const qs = Object.entries(params).map(([k, v]) => `${k}=${v}`);
const response: { user: User } = await jsonFetch(
`${this.config.apiURI}/admin/users?${qs}`,
{
method: "GET",
headers: authorizedHeaders(this.config),
},
);
return response.user;
};
/**
* Deletes an app user by id, email, or refresh token.
*
* NB: This _only_ deletes the user; it does not delete all user data.
* You will need to handle this manually.
*
* @example
* try {
* const deletedUser = await db.auth.deleteUser({ email })
* console.log("Deleted user:", deletedUser)
* } catch (err) {
* console.error("Failed to delete user:", err.message);
* }
*
* @see https://docs.instantdb.com/docs/backend#delete-a-user
*/
deleteUser = async (
params: { email: string } | { id: string } | { refresh_token: string },
): Promise<User> => {
const qs = Object.entries(params).map(([k, v]) => `${k}=${v}`);
const response: { deleted: User } = await jsonFetch(
`${this.config.apiURI}/admin/users?${qs}`,
{
method: "DELETE",
headers: authorizedHeaders(this.config),
},
);
return response.deleted;
};
/**
* Signs out the user with the given email.

@@ -480,0 +540,0 @@ * This invalidates any tokens associated with the user.

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc