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

@instantdb/core

Package Overview
Dependencies
Maintainers
0
Versions
206
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@instantdb/core - npm Package Compare versions

Comparing version 0.11.1 to 0.11.2

__tests__/src/schema.test.ts

27

dist/authAPI.js

@@ -12,3 +12,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.signInWithIdToken = exports.exchangeCodeForToken = exports.verifyRefreshToken = exports.verifyMagicCode = exports.sendMagicCode = void 0;
exports.sendMagicCode = sendMagicCode;
exports.verifyMagicCode = verifyMagicCode;
exports.verifyRefreshToken = verifyRefreshToken;
exports.exchangeCodeForToken = exchangeCodeForToken;
exports.signInWithIdToken = signInWithIdToken;
const fetch_1 = require("./utils/fetch");

@@ -22,5 +26,4 @@ function sendMagicCode({ apiURI, appId, email }) {

}
exports.sendMagicCode = sendMagicCode;
function verifyMagicCode({ apiURI, appId, email, code }) {
return __awaiter(this, void 0, void 0, function* () {
function verifyMagicCode(_a) {
return __awaiter(this, arguments, void 0, function* ({ apiURI, appId, email, code }) {
const res = yield (0, fetch_1.jsonFetch)(`${apiURI}/runtime/auth/verify_magic_code`, {

@@ -34,5 +37,4 @@ method: "POST",

}
exports.verifyMagicCode = verifyMagicCode;
function verifyRefreshToken({ apiURI, appId, refreshToken }) {
return __awaiter(this, void 0, void 0, function* () {
function verifyRefreshToken(_a) {
return __awaiter(this, arguments, void 0, function* ({ apiURI, appId, refreshToken }) {
const res = yield (0, fetch_1.jsonFetch)(`${apiURI}/runtime/auth/verify_refresh_token`, {

@@ -49,3 +51,2 @@ method: "POST",

}
exports.verifyRefreshToken = verifyRefreshToken;
/**

@@ -58,4 +59,4 @@ * @param {Object} params

*/
function exchangeCodeForToken({ apiURI, appId, code, codeVerifier, }) {
return __awaiter(this, void 0, void 0, function* () {
function exchangeCodeForToken(_a) {
return __awaiter(this, arguments, void 0, function* ({ apiURI, appId, code, codeVerifier, }) {
const res = yield (0, fetch_1.jsonFetch)(`${apiURI}/runtime/oauth/token`, {

@@ -73,3 +74,2 @@ method: "POST",

}
exports.exchangeCodeForToken = exchangeCodeForToken;
/**

@@ -83,4 +83,4 @@ * @param {Object} params

*/
function signInWithIdToken({ apiURI, appId, nonce, idToken, clientName, }) {
return __awaiter(this, void 0, void 0, function* () {
function signInWithIdToken(_a) {
return __awaiter(this, arguments, void 0, function* ({ apiURI, appId, nonce, idToken, clientName, }) {
const res = yield (0, fetch_1.jsonFetch)(`${apiURI}/runtime/oauth/id_token`, {

@@ -99,3 +99,2 @@ method: "POST",

}
exports.signInWithIdToken = signInWithIdToken;
//# sourceMappingURL=authAPI.js.map
import { QueryResponse, PageInfoResponse } from "./queryTypes";
export declare type User = {
export type User = {
id: string;

@@ -7,3 +7,3 @@ email: string;

};
export declare type AuthResult = {
export type AuthResult = {
user: User | undefined;

@@ -17,3 +17,3 @@ error: undefined;

};
export declare type AuthState = {
export type AuthState = {
isLoading: true;

@@ -36,3 +36,3 @@ error: undefined;

*/
export declare type QueryState<Q, Schema = {}> = {
export type QueryState<Q, Schema = {}> = {
isLoading: true;

@@ -39,0 +39,0 @@ error: undefined;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.query = exports.queryWhere = exports.querySingle = exports.matchPattern = void 0;
exports.matchPattern = matchPattern;
exports.querySingle = querySingle;
exports.queryWhere = queryWhere;
exports.query = query;
// 1. patternMatch

@@ -48,3 +51,2 @@ const store_js_1 = require("./store.js");

}
exports.matchPattern = matchPattern;
// 2. querySingle

@@ -56,3 +58,2 @@ function querySingle(store, pattern, context) {

}
exports.querySingle = querySingle;
// 3. queryWhere

@@ -77,3 +78,2 @@ function queryPattern(store, pattern, contexts) {

}
exports.queryWhere = queryWhere;
// 4. query

@@ -90,3 +90,2 @@ function actualize(context, find) {

}
exports.query = query;
// 5. Index

@@ -93,0 +92,0 @@ function relevantTriples(store, pattern, context) {

@@ -10,12 +10,14 @@ import Reactor from "./Reactor";

import { PresenceOpts, PresenceResponse, PresenceSlice, RoomSchemaShape } from "./presence";
export declare type Config = {
import * as i from "./schema";
export type Config = {
appId: string;
websocketURI?: string;
apiURI?: string;
devtool?: boolean;
};
export declare type TransactionResult = {
export type TransactionResult = {
status: "synced" | "enqueued";
clientId: string;
};
export declare type RoomHandle<PresenceShape, TopicsByKey> = {
export type RoomHandle<PresenceShape, TopicsByKey> = {
leaveRoom: () => void;

@@ -28,4 +30,4 @@ publishTopic: <Key extends keyof TopicsByKey>(topic: Key, data: TopicsByKey[Key]) => void;

};
declare type AuthToken = string;
declare type SubscriptionState<Q, Schema> = {
type AuthToken = string;
type SubscriptionState<Q, Schema> = {
error: {

@@ -41,6 +43,6 @@ message: string;

};
declare type LifecycleSubscriptionState<Q, Schema> = SubscriptionState<Q, Schema> & {
type LifecycleSubscriptionState<Q, Schema> = SubscriptionState<Q, Schema> & {
isLoading: boolean;
};
declare type UnsubscribeFn = () => void;
type UnsubscribeFn = () => void;
/**

@@ -221,3 +223,3 @@ *

clientName: string;
redirectURL;
redirectURL: any;
}) => string;

@@ -285,3 +287,3 @@ /**

declare function coerceQuery(o: any): any;
export { init, id, tx, lookup, getOps, coerceQuery, weakHash, IndexedDBStorage, WindowNetworkListener, InstantCore as InstantClient, Auth, RoomSchemaShape, Query, QueryResponse, InstantObject, Exactly, TransactionChunk, QueryState, AuthState, User, AuthToken, EmptyChunk, SubscriptionState, LifecycleSubscriptionState, PresenceOpts, PresenceSlice, PresenceResponse, };
export { init, id, tx, lookup, i, getOps, coerceQuery, weakHash, IndexedDBStorage, WindowNetworkListener, InstantCore as InstantClient, Auth, RoomSchemaShape, Query, QueryResponse, InstantObject, Exactly, TransactionChunk, QueryState, AuthState, User, AuthToken, EmptyChunk, SubscriptionState, LifecycleSubscriptionState, PresenceOpts, PresenceSlice, PresenceResponse, };
//# sourceMappingURL=index.d.ts.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,3 +29,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.Auth = exports.InstantClient = exports.WindowNetworkListener = exports.IndexedDBStorage = exports.weakHash = exports.coerceQuery = exports.getOps = exports.lookup = exports.tx = exports.id = exports.init = void 0;
exports.Auth = exports.InstantClient = exports.WindowNetworkListener = exports.IndexedDBStorage = exports.weakHash = exports.getOps = exports.i = exports.lookup = exports.tx = exports.id = void 0;
exports.init = init;
exports.coerceQuery = coerceQuery;
const Reactor_1 = __importDefault(require("./Reactor"));

@@ -21,2 +46,6 @@ const instatx_1 = require("./instatx");

exports.WindowNetworkListener = WindowNetworkListener_1.default;
const i = __importStar(require("./schema"));
exports.i = i;
const devtool_1 = require("./devtool");
const defaultOpenDevtool = false;
// consts

@@ -68,5 +97,16 @@ const defaultConfig = {

globalInstantCoreStore[config.appId] = client;
if (typeof window !== "undefined") {
const showDevtool =
// show widget by deafult?
("devtool" in config ? Boolean(config.devtool) : defaultOpenDevtool) &&
// only run on localhost (dev env)
location.hostname === "localhost" &&
// used by dash and other internal consumers
!Boolean(globalThis._nodevtool);
if (showDevtool) {
(0, devtool_1.createDevtool)(config.appId);
}
}
return client;
}
exports.init = init;
class InstantCore {

@@ -319,3 +359,2 @@ constructor(reactor) {

}
exports.coerceQuery = coerceQuery;
//# sourceMappingURL=index.js.map

@@ -6,3 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.transform = exports.getAttrByReverseIdentName = exports.getAttrByFwdIdentName = void 0;
exports.getAttrByFwdIdentName = getAttrByFwdIdentName;
exports.getAttrByReverseIdentName = getAttrByReverseIdentName;
exports.transform = transform;
const instatx_1 = require("./instatx");

@@ -17,3 +19,2 @@ const object_1 = require("./utils/object");

}
exports.getAttrByFwdIdentName = getAttrByFwdIdentName;
function getAttrByReverseIdentName(attrs, inputEtype, inputIdentName) {

@@ -28,3 +29,2 @@ return Object.values(attrs).find((attr) => {

}
exports.getAttrByReverseIdentName = getAttrByReverseIdentName;
function explodeLookupRef(eid) {

@@ -228,3 +228,2 @@ if (Array.isArray(eid)) {

}
exports.transform = transform;
//# sourceMappingURL=instaml.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = query;
const datalog_1 = require("./datalog");

@@ -385,3 +386,2 @@ const uuid_1 = require("./utils/uuid");

}
exports.default = query;
//# sourceMappingURL=instaql.js.map

@@ -1,8 +0,8 @@

declare type Action = "update" | "link" | "unlink" | "delete" | "merge";
declare type EType = string;
declare type Id = string;
declare type Args = any;
declare type LookupRef = [string, any];
declare type Lookup = string;
export declare type Op = [Action, EType, Id | LookupRef, Args];
type Action = "update" | "link" | "unlink" | "delete" | "merge";
type EType = string;
type Id = string;
type Args = any;
type LookupRef = [string, any];
type Lookup = string;
export type Op = [Action, EType, Id | LookupRef, Args];
export interface TransactionChunk {

@@ -9,0 +9,0 @@ __ops: Op[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOps = exports.tx = exports.parseLookup = exports.isLookup = exports.lookup = void 0;
exports.tx = void 0;
exports.lookup = lookup;
exports.isLookup = isLookup;
exports.parseLookup = parseLookup;
exports.getOps = getOps;
function transactionChunk(etype, id, prevOps) {

@@ -27,7 +31,5 @@ return new Proxy({}, {

}
exports.lookup = lookup;
function isLookup(k) {
return k.startsWith("lookup__");
}
exports.isLookup = isLookup;
function parseLookup(k) {

@@ -37,3 +39,2 @@ const [_, eid, ...vJSON] = k.split("__");

}
exports.parseLookup = parseLookup;
function etypeChunk(etype) {

@@ -69,3 +70,2 @@ return new Proxy({}, {

}
exports.getOps = getOps;
//# sourceMappingURL=instatx.js.map

@@ -18,4 +18,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
export function verifyMagicCode({ apiURI, appId, email, code }) {
return __awaiter(this, void 0, void 0, function* () {
export function verifyMagicCode(_a) {
return __awaiter(this, arguments, void 0, function* ({ apiURI, appId, email, code }) {
const res = yield jsonFetch(`${apiURI}/runtime/auth/verify_magic_code`, {

@@ -29,4 +29,4 @@ method: "POST",

}
export function verifyRefreshToken({ apiURI, appId, refreshToken }) {
return __awaiter(this, void 0, void 0, function* () {
export function verifyRefreshToken(_a) {
return __awaiter(this, arguments, void 0, function* ({ apiURI, appId, refreshToken }) {
const res = yield jsonFetch(`${apiURI}/runtime/auth/verify_refresh_token`, {

@@ -50,4 +50,4 @@ method: "POST",

*/
export function exchangeCodeForToken({ apiURI, appId, code, codeVerifier, }) {
return __awaiter(this, void 0, void 0, function* () {
export function exchangeCodeForToken(_a) {
return __awaiter(this, arguments, void 0, function* ({ apiURI, appId, code, codeVerifier, }) {
const res = yield jsonFetch(`${apiURI}/runtime/oauth/token`, {

@@ -73,4 +73,4 @@ method: "POST",

*/
export function signInWithIdToken({ apiURI, appId, nonce, idToken, clientName, }) {
return __awaiter(this, void 0, void 0, function* () {
export function signInWithIdToken(_a) {
return __awaiter(this, arguments, void 0, function* ({ apiURI, appId, nonce, idToken, clientName, }) {
const res = yield jsonFetch(`${apiURI}/runtime/oauth/id_token`, {

@@ -77,0 +77,0 @@ method: "POST",

import { QueryResponse, PageInfoResponse } from "./queryTypes";
export declare type User = {
export type User = {
id: string;

@@ -7,3 +7,3 @@ email: string;

};
export declare type AuthResult = {
export type AuthResult = {
user: User | undefined;

@@ -17,3 +17,3 @@ error: undefined;

};
export declare type AuthState = {
export type AuthState = {
isLoading: true;

@@ -36,3 +36,3 @@ error: undefined;

*/
export declare type QueryState<Q, Schema = {}> = {
export type QueryState<Q, Schema = {}> = {
isLoading: true;

@@ -39,0 +39,0 @@ error: undefined;

@@ -10,12 +10,14 @@ import Reactor from "./Reactor";

import { PresenceOpts, PresenceResponse, PresenceSlice, RoomSchemaShape } from "./presence";
export declare type Config = {
import * as i from "./schema";
export type Config = {
appId: string;
websocketURI?: string;
apiURI?: string;
devtool?: boolean;
};
export declare type TransactionResult = {
export type TransactionResult = {
status: "synced" | "enqueued";
clientId: string;
};
export declare type RoomHandle<PresenceShape, TopicsByKey> = {
export type RoomHandle<PresenceShape, TopicsByKey> = {
leaveRoom: () => void;

@@ -28,4 +30,4 @@ publishTopic: <Key extends keyof TopicsByKey>(topic: Key, data: TopicsByKey[Key]) => void;

};
declare type AuthToken = string;
declare type SubscriptionState<Q, Schema> = {
type AuthToken = string;
type SubscriptionState<Q, Schema> = {
error: {

@@ -41,6 +43,6 @@ message: string;

};
declare type LifecycleSubscriptionState<Q, Schema> = SubscriptionState<Q, Schema> & {
type LifecycleSubscriptionState<Q, Schema> = SubscriptionState<Q, Schema> & {
isLoading: boolean;
};
declare type UnsubscribeFn = () => void;
type UnsubscribeFn = () => void;
/**

@@ -221,3 +223,3 @@ *

clientName: string;
redirectURL;
redirectURL: any;
}) => string;

@@ -285,3 +287,3 @@ /**

declare function coerceQuery(o: any): any;
export { init, id, tx, lookup, getOps, coerceQuery, weakHash, IndexedDBStorage, WindowNetworkListener, InstantCore as InstantClient, Auth, RoomSchemaShape, Query, QueryResponse, InstantObject, Exactly, TransactionChunk, QueryState, AuthState, User, AuthToken, EmptyChunk, SubscriptionState, LifecycleSubscriptionState, PresenceOpts, PresenceSlice, PresenceResponse, };
export { init, id, tx, lookup, i, getOps, coerceQuery, weakHash, IndexedDBStorage, WindowNetworkListener, InstantCore as InstantClient, Auth, RoomSchemaShape, Query, QueryResponse, InstantObject, Exactly, TransactionChunk, QueryState, AuthState, User, AuthToken, EmptyChunk, SubscriptionState, LifecycleSubscriptionState, PresenceOpts, PresenceSlice, PresenceResponse, };
//# sourceMappingURL=index.d.ts.map

@@ -7,2 +7,5 @@ import Reactor from "./Reactor";

import WindowNetworkListener from "./WindowNetworkListener";
import * as i from "./schema";
import { createDevtool } from "./devtool";
const defaultOpenDevtool = false;
// consts

@@ -54,2 +57,14 @@ const defaultConfig = {

globalInstantCoreStore[config.appId] = client;
if (typeof window !== "undefined") {
const showDevtool =
// show widget by deafult?
("devtool" in config ? Boolean(config.devtool) : defaultOpenDevtool) &&
// only run on localhost (dev env)
location.hostname === "localhost" &&
// used by dash and other internal consumers
!Boolean(globalThis._nodevtool);
if (showDevtool) {
createDevtool(config.appId);
}
}
return client;

@@ -302,7 +317,10 @@ }

}
// dev
export {
// bada bing bada boom
init, id, tx, lookup,
// cli
i,
// util
getOps, coerceQuery, weakHash, IndexedDBStorage, WindowNetworkListener, InstantCore as InstantClient, Auth, };
//# sourceMappingURL=index.js.map

@@ -1,8 +0,8 @@

declare type Action = "update" | "link" | "unlink" | "delete" | "merge";
declare type EType = string;
declare type Id = string;
declare type Args = any;
declare type LookupRef = [string, any];
declare type Lookup = string;
export declare type Op = [Action, EType, Id | LookupRef, Args];
type Action = "update" | "link" | "unlink" | "delete" | "merge";
type EType = string;
type Id = string;
type Args = any;
type LookupRef = [string, any];
type Lookup = string;
export type Op = [Action, EType, Id | LookupRef, Args];
export interface TransactionChunk {

@@ -9,0 +9,0 @@ __ops: Op[];

@@ -1,2 +0,2 @@

export declare type RoomSchemaShape = {
export type RoomSchemaShape = {
[k: string]: {

@@ -13,3 +13,3 @@ presence?: {

};
export declare type PresenceOpts<PresenceShape, Keys extends keyof PresenceShape> = {
export type PresenceOpts<PresenceShape, Keys extends keyof PresenceShape> = {
user?: boolean;

@@ -19,3 +19,3 @@ peers?: string[];

};
export declare type PresenceSlice<PresenceShape, Keys extends keyof PresenceShape> = {
export type PresenceSlice<PresenceShape, Keys extends keyof PresenceShape> = {
user?: Pick<PresenceShape, Keys>;

@@ -26,3 +26,3 @@ peers: {

};
export declare type PresenceResponse<PresenceShape, Keys extends keyof PresenceShape> = PresenceSlice<PresenceShape, Keys> & {
export type PresenceResponse<PresenceShape, Keys extends keyof PresenceShape> = PresenceSlice<PresenceShape, Keys> & {
isLoading: boolean;

@@ -29,0 +29,0 @@ error?: string;

@@ -1,16 +0,16 @@

declare type NonEmpty<T> = {
type NonEmpty<T> = {
[K in keyof T]-?: Required<Pick<T, K>>;
}[keyof T];
declare type WhereArgs = {
type WhereArgs = {
in?: (string | number | boolean)[];
};
declare type WhereClauseValue = string | number | boolean | NonEmpty<WhereArgs>;
declare type BaseWhereClause = {
type WhereClauseValue = string | number | boolean | NonEmpty<WhereArgs>;
type BaseWhereClause = {
[key: string]: WhereClauseValue;
};
declare type WhereClauseWithCombinaton = {
type WhereClauseWithCombinaton = {
or?: WhereClause[] | WhereClauseValue;
and?: WhereClause[] | WhereClauseValue;
};
declare type WhereClause = WhereClauseWithCombinaton | (WhereClauseWithCombinaton & BaseWhereClause);
type WhereClause = WhereClauseWithCombinaton | (WhereClauseWithCombinaton & BaseWhereClause);
/**

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

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

@@ -41,27 +41,27 @@ where?: WhereClause;

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

@@ -94,3 +94,3 @@ startCursor: Cursor;

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

@@ -97,0 +97,0 @@ };

@@ -203,3 +203,3 @@ /**

*/
publishPresence<RoomType_1 extends keyof RoomSchema>(roomType: RoomType_1, roomId: string | number, partialData: Partial<RoomSchema[RoomType_1]["presence"]>): void;
publishPresence<RoomType extends keyof RoomSchema>(roomType: RoomType, roomId: string | number, partialData: Partial<RoomSchema[RoomType]["presence"]>): void;
/**

@@ -214,3 +214,3 @@ * @template {keyof RoomSchema} RoomType

*/
subscribePresence<RoomType_2 extends keyof RoomSchema, Keys_1 extends keyof RoomSchema[RoomType_2]["presence"]>(roomType: RoomType_2, roomId: string | number, opts: import("./presence").PresenceOpts<RoomSchema[RoomType_2]["presence"], Keys_1>, cb: (slice: import("./presence").PresenceResponse<RoomSchema[RoomType_2]["presence"], Keys_1>) => void): () => void;
subscribePresence<RoomType extends keyof RoomSchema, Keys extends keyof RoomSchema[RoomType]["presence"]>(roomType: RoomType, roomId: string | number, opts: import("./presence").PresenceOpts<RoomSchema[RoomType]["presence"], Keys>, cb: (slice: import("./presence").PresenceResponse<RoomSchema[RoomType]["presence"], Keys>) => void): () => void;
_notifyPresenceSubs(roomId: any): void;

@@ -217,0 +217,0 @@ _notifyPresenceSub(roomId: any, handler: any): void;

@@ -767,4 +767,4 @@ // @ts-check

_oauthLoginInit() {
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d;
if (typeof window === "undefined" ||

@@ -878,4 +878,4 @@ typeof window.location === "undefined" ||

changeCurrentUser(newUser) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
var _a;
yield this.setCurrentUser(newUser);

@@ -912,4 +912,4 @@ // We need to remove all `result` from querySubs,

}
signInWithMagicCode({ email, code }) {
return __awaiter(this, void 0, void 0, function* () {
signInWithMagicCode(_a) {
return __awaiter(this, arguments, void 0, function* ({ email, code }) {
const res = yield authAPI.verifyMagicCode({

@@ -949,4 +949,4 @@ apiURI: this.config.apiURI,

}
exchangeCodeForToken({ code, codeVerifier }) {
return __awaiter(this, void 0, void 0, function* () {
exchangeCodeForToken(_a) {
return __awaiter(this, arguments, void 0, function* ({ code, codeVerifier }) {
const res = yield authAPI.exchangeCodeForToken({

@@ -972,4 +972,4 @@ apiURI: this.config.apiURI,

*/
signInWithIdToken({ idToken, clientName, nonce }) {
return __awaiter(this, void 0, void 0, function* () {
signInWithIdToken(_a) {
return __awaiter(this, arguments, void 0, function* ({ idToken, clientName, nonce }) {
const res = yield authAPI.signInWithIdToken({

@@ -976,0 +976,0 @@ apiURI: this.config.apiURI,

import { v4 } from "uuid";
export declare function uuidCompare(uuid_a: string, uuid_b: string): 1 | -1 | 0;
export declare function uuidCompare(uuid_a: string, uuid_b: string): 0 | 1 | -1;
export default v4;
//# sourceMappingURL=uuid.d.ts.map

@@ -1,2 +0,2 @@

export declare type RoomSchemaShape = {
export type RoomSchemaShape = {
[k: string]: {

@@ -13,3 +13,3 @@ presence?: {

};
export declare type PresenceOpts<PresenceShape, Keys extends keyof PresenceShape> = {
export type PresenceOpts<PresenceShape, Keys extends keyof PresenceShape> = {
user?: boolean;

@@ -19,3 +19,3 @@ peers?: string[];

};
export declare type PresenceSlice<PresenceShape, Keys extends keyof PresenceShape> = {
export type PresenceSlice<PresenceShape, Keys extends keyof PresenceShape> = {
user?: Pick<PresenceShape, Keys>;

@@ -26,3 +26,3 @@ peers: {

};
export declare type PresenceResponse<PresenceShape, Keys extends keyof PresenceShape> = PresenceSlice<PresenceShape, Keys> & {
export type PresenceResponse<PresenceShape, Keys extends keyof PresenceShape> = PresenceSlice<PresenceShape, Keys> & {
isLoading: boolean;

@@ -29,0 +29,0 @@ error?: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasPresenceResponseChanged = exports.buildPresenceSlice = void 0;
exports.buildPresenceSlice = buildPresenceSlice;
exports.hasPresenceResponseChanged = hasPresenceResponseChanged;
const pick_1 = require("./utils/pick");

@@ -26,3 +27,2 @@ const object_1 = require("./utils/object");

}
exports.buildPresenceSlice = buildPresenceSlice;
/**

@@ -57,3 +57,2 @@ * Compare two presence slices

}
exports.hasPresenceResponseChanged = hasPresenceResponseChanged;
//# sourceMappingURL=presence.js.map

@@ -1,16 +0,16 @@

declare type NonEmpty<T> = {
type NonEmpty<T> = {
[K in keyof T]-?: Required<Pick<T, K>>;
}[keyof T];
declare type WhereArgs = {
type WhereArgs = {
in?: (string | number | boolean)[];
};
declare type WhereClauseValue = string | number | boolean | NonEmpty<WhereArgs>;
declare type BaseWhereClause = {
type WhereClauseValue = string | number | boolean | NonEmpty<WhereArgs>;
type BaseWhereClause = {
[key: string]: WhereClauseValue;
};
declare type WhereClauseWithCombinaton = {
type WhereClauseWithCombinaton = {
or?: WhereClause[] | WhereClauseValue;
and?: WhereClause[] | WhereClauseValue;
};
declare type WhereClause = WhereClauseWithCombinaton | (WhereClauseWithCombinaton & BaseWhereClause);
type WhereClause = WhereClauseWithCombinaton | (WhereClauseWithCombinaton & BaseWhereClause);
/**

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

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

@@ -41,27 +41,27 @@ where?: WhereClause;

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

@@ -94,3 +94,3 @@ startCursor: Cursor;

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

@@ -97,0 +97,0 @@ };

@@ -203,3 +203,3 @@ /**

*/
publishPresence<RoomType_1 extends keyof RoomSchema>(roomType: RoomType_1, roomId: string | number, partialData: Partial<RoomSchema[RoomType_1]["presence"]>): void;
publishPresence<RoomType extends keyof RoomSchema>(roomType: RoomType, roomId: string | number, partialData: Partial<RoomSchema[RoomType]["presence"]>): void;
/**

@@ -214,3 +214,3 @@ * @template {keyof RoomSchema} RoomType

*/
subscribePresence<RoomType_2 extends keyof RoomSchema, Keys_1 extends keyof RoomSchema[RoomType_2]["presence"]>(roomType: RoomType_2, roomId: string | number, opts: import("./presence").PresenceOpts<RoomSchema[RoomType_2]["presence"], Keys_1>, cb: (slice: import("./presence").PresenceResponse<RoomSchema[RoomType_2]["presence"], Keys_1>) => void): () => void;
subscribePresence<RoomType extends keyof RoomSchema, Keys extends keyof RoomSchema[RoomType]["presence"]>(roomType: RoomType, roomId: string | number, opts: import("./presence").PresenceOpts<RoomSchema[RoomType]["presence"], Keys>, cb: (slice: import("./presence").PresenceResponse<RoomSchema[RoomType]["presence"], Keys>) => void): () => void;
_notifyPresenceSubs(roomId: any): void;

@@ -217,0 +217,0 @@ _notifyPresenceSub(roomId: any, handler: any): void;

@@ -795,4 +795,4 @@ "use strict";

_oauthLoginInit() {
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d;
if (typeof window === "undefined" ||

@@ -906,4 +906,4 @@ typeof window.location === "undefined" ||

changeCurrentUser(newUser) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
var _a;
yield this.setCurrentUser(newUser);

@@ -940,4 +940,4 @@ // We need to remove all `result` from querySubs,

}
signInWithMagicCode({ email, code }) {
return __awaiter(this, void 0, void 0, function* () {
signInWithMagicCode(_a) {
return __awaiter(this, arguments, void 0, function* ({ email, code }) {
const res = yield authAPI.verifyMagicCode({

@@ -977,4 +977,4 @@ apiURI: this.config.apiURI,

}
exchangeCodeForToken({ code, codeVerifier }) {
return __awaiter(this, void 0, void 0, function* () {
exchangeCodeForToken(_a) {
return __awaiter(this, arguments, void 0, function* ({ code, codeVerifier }) {
const res = yield authAPI.exchangeCodeForToken({

@@ -1000,4 +1000,4 @@ apiURI: this.config.apiURI,

*/
signInWithIdToken({ idToken, clientName, nonce }) {
return __awaiter(this, void 0, void 0, function* () {
signInWithIdToken(_a) {
return __awaiter(this, arguments, void 0, function* ({ idToken, clientName, nonce }) {
const res = yield authAPI.signInWithIdToken({

@@ -1004,0 +1004,0 @@ apiURI: this.config.apiURI,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transact = exports.getTriples = exports.allMapValues = exports.createStore = void 0;
exports.createStore = createStore;
exports.allMapValues = allMapValues;
exports.getTriples = getTriples;
exports.transact = transact;
const immer_1 = require("immer");

@@ -74,3 +77,2 @@ const object_1 = require("./utils/object");

}
exports.createStore = createStore;
// We may have local triples with lookup refs in them,

@@ -350,3 +352,2 @@ // we need to convert those lookup refs to eids to insert them

}
exports.allMapValues = allMapValues;
function triplesByValue(m, v) {

@@ -432,3 +433,2 @@ const res = [];

}
exports.getTriples = getTriples;
function transact(store, txSteps) {

@@ -441,3 +441,2 @@ return (0, immer_1.produce)(store, (draft) => {

}
exports.transact = transact;
//# sourceMappingURL=store.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractTriples = void 0;
exports.extractTriples = extractTriples;
function _extractTriplesHelper(idNodes, acc = []) {

@@ -28,3 +28,2 @@ idNodes.forEach((idNode) => {

}
exports.extractTriples = extractTriples;
//# sourceMappingURL=triples.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertUnreachable = exports.assert = void 0;
exports.assert = assert;
exports.assertUnreachable = assertUnreachable;
function assert(condition, msg) {

@@ -9,7 +10,5 @@ if (!condition) {

}
exports.assert = assert;
function assertUnreachable(_x) {
throw new Error("[assertion error] TS should prevent us from reaching here");
}
exports.assertUnreachable = assertUnreachable;
//# sourceMappingURL=error.js.map

@@ -12,3 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.jsonFetch = void 0;
exports.jsonFetch = jsonFetch;
function jsonFetch(input, init) {

@@ -23,3 +23,2 @@ return __awaiter(this, void 0, void 0, function* () {

}
exports.jsonFetch = jsonFetch;
//# sourceMappingURL=fetch.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromJSONWithMaps = exports.toJSONWithMaps = void 0;
exports.toJSONWithMaps = toJSONWithMaps;
exports.fromJSONWithMaps = fromJSONWithMaps;
/*

@@ -32,3 +33,2 @@ Stores maps in JSON as custom objects with key __type = 'm'

}
exports.toJSONWithMaps = toJSONWithMaps;
/*

@@ -40,3 +40,2 @@ Parses JSON that was formatted with toJSONWithMaps

}
exports.fromJSONWithMaps = fromJSONWithMaps;
//# sourceMappingURL=json.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isObject = exports.immutableDeepReplace = exports.immutableDeepMerge = exports.areObjectsDeepEqual = exports.areObjectsShallowEqual = exports.areObjectKeysEqual = void 0;
exports.areObjectKeysEqual = areObjectKeysEqual;
exports.areObjectsShallowEqual = areObjectsShallowEqual;
exports.areObjectsDeepEqual = areObjectsDeepEqual;
exports.immutableDeepMerge = immutableDeepMerge;
exports.immutableDeepReplace = immutableDeepReplace;
exports.isObject = isObject;
function areObjectKeysEqual(a, b) {

@@ -9,3 +14,2 @@ const ak = Object.keys(a);

}
exports.areObjectKeysEqual = areObjectKeysEqual;
function areObjectsShallowEqual(obj1, obj2) {

@@ -15,3 +19,2 @@ return (Object.keys(obj1).length === Object.keys(obj2).length &&

}
exports.areObjectsShallowEqual = areObjectsShallowEqual;
function areObjectsDeepEqual(obj1, obj2) {

@@ -29,3 +32,2 @@ if (typeof obj1 !== "object" ||

}
exports.areObjectsDeepEqual = areObjectsDeepEqual;
function immutableDeepMerge(target, source) {

@@ -50,3 +52,2 @@ if (!isObject(target) || !isObject(source)) {

}
exports.immutableDeepMerge = immutableDeepMerge;
function immutableDeepReplace(target, replaceValue, replacementValue) {

@@ -66,7 +67,5 @@ if (!isObject(target)) {

}
exports.immutableDeepReplace = immutableDeepReplace;
function isObject(val) {
return typeof val === "object" && val !== null && !Array.isArray(val);
}
exports.isObject = isObject;
//# sourceMappingURL=object.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pick = void 0;
exports.pick = pick;
function pick(obj, keys) {

@@ -13,3 +13,2 @@ if (!keys)

}
exports.pick = pick;
//# sourceMappingURL=pick.js.map
import { v4 } from "uuid";
export declare function uuidCompare(uuid_a: string, uuid_b: string): 1 | -1 | 0;
export declare function uuidCompare(uuid_a: string, uuid_b: string): 0 | 1 | -1;
export default v4;
//# sourceMappingURL=uuid.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uuidCompare = void 0;
exports.uuidCompare = uuidCompare;
const uuid_1 = require("uuid");

@@ -25,4 +25,3 @@ function uuidToByteArray(uuid) {

}
exports.uuidCompare = uuidCompare;
exports.default = uuid_1.v4;
//# sourceMappingURL=uuid.js.map
{
"name": "@instantdb/core",
"version": "0.11.1",
"version": "0.11.2",
"description": "Instant's core local abstraction",

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

@@ -15,3 +15,2 @@ import Reactor from "./Reactor";

import { QueryState, AuthState, User, AuthResult } from "./clientTypes";
import { assert } from "./utils/error";
import {

@@ -23,3 +22,7 @@ PresenceOpts,

} from "./presence";
import * as i from "./schema";
import { createDevtool } from "./devtool";
const defaultOpenDevtool = false;
// types

@@ -31,2 +34,3 @@

apiURI?: string;
devtool?: boolean;
};

@@ -144,2 +148,17 @@

globalInstantCoreStore[config.appId] = client;
if (typeof window !== "undefined") {
const showDevtool =
// show widget by deafult?
("devtool" in config ? Boolean(config.devtool) : defaultOpenDevtool) &&
// only run on localhost (dev env)
location.hostname === "localhost" &&
// used by dash and other internal consumers
!Boolean((globalThis as any)._nodevtool);
if (showDevtool) {
createDevtool(config.appId);
}
}
return client;

@@ -434,2 +453,4 @@ }

// dev
export {

@@ -442,2 +463,5 @@ // bada bing bada boom

// cli
i,
// util

@@ -444,0 +468,0 @@ getOps,

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

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

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

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

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