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

@instantdb/core

Package Overview
Dependencies
Maintainers
3
Versions
205
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.7.1 to 0.7.2

2

dist/index.d.ts

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

*/
declare function init<Schema = {}>(config: Config, Storage?: any, NetworkListener?: any): InstantCore<{}>;
declare function init<Schema = {}>(config: Config, Storage?: any, NetworkListener?: any): InstantCore<Schema>;
declare class InstantCore<Schema = {}> {

@@ -50,0 +50,0 @@ _reactor: Reactor;

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

*/
declare function init<Schema = {}>(config: Config, Storage?: any, NetworkListener?: any): InstantCore<{}>;
declare function init<Schema = {}>(config: Config, Storage?: any, NetworkListener?: any): InstantCore<Schema>;
declare class InstantCore<Schema = {}> {

@@ -50,0 +50,0 @@ _reactor: Reactor;

@@ -20,5 +20,6 @@ type WhereClause = {

};
type ResponseObject<K, Schema> = K extends keyof Schema ? InstantObject & 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 ? K extends keyof Schema ? (InstantObject & Schema[K])[] : InstantObject[] : (ResponseOf<Q[K], Schema> & InstantObject)[];
[K in keyof Q]: IsEmptyObject<Q[K]> extends true ? ResponseObject<K, Schema>[] : (ResponseOf<Q[K], Schema> & ResponseObject<K, Schema>)[];
};

@@ -25,0 +26,0 @@ type Remove$<T> = T extends object ? {

@@ -17,2 +17,5 @@ // Query

}
function dummySchemaQuery(_query) {
return 1;
}
const sanityCheckQueries = () => {

@@ -81,3 +84,11 @@ // -----------

};
function sanityCheckSchemaQueries() {
// simple response
const r1 = dummySchemaQuery({ users: {} });
// nested response
const r2 = dummySchemaQuery({
users: { posts: {} },
});
}
export {};
//# sourceMappingURL=queryTypes.js.map

@@ -20,5 +20,6 @@ type WhereClause = {

};
type ResponseObject<K, Schema> = K extends keyof Schema ? InstantObject & 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 ? K extends keyof Schema ? (InstantObject & Schema[K])[] : InstantObject[] : (ResponseOf<Q[K], Schema> & InstantObject)[];
[K in keyof Q]: IsEmptyObject<Q[K]> extends true ? ResponseObject<K, Schema>[] : (ResponseOf<Q[K], Schema> & ResponseObject<K, Schema>)[];
};

@@ -25,0 +26,0 @@ type Remove$<T> = T extends object ? {

@@ -19,2 +19,5 @@ "use strict";

}
function dummySchemaQuery(_query) {
return 1;
}
const sanityCheckQueries = () => {

@@ -83,2 +86,10 @@ // -----------

};
function sanityCheckSchemaQueries() {
// simple response
const r1 = dummySchemaQuery({ users: {} });
// nested response
const r2 = dummySchemaQuery({
users: { posts: {} },
});
}
//# sourceMappingURL=queryTypes.js.map
{
"name": "@instantdb/core",
"version": "0.7.1",
"version": "0.7.2",
"description": "Instant's core local abstraction",

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

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

function initGlobalInstantCoreStore(): Record<string, InstantCore> {
function initGlobalInstantCoreStore(): Record<string, InstantCore<any>> {
if (typeof window !== "undefined") {

@@ -78,3 +78,3 @@ // @ts-expect-error

NetworkListener?: any,
) {
): InstantCore<Schema> {
if (globalInstantCoreStore[config.appId]) {

@@ -81,0 +81,0 @@ const client = globalInstantCoreStore[config.appId];

@@ -23,11 +23,12 @@ // Query

type ResponseObject<K, Schema> = K extends keyof Schema
? InstantObject & Schema[K]
: InstantObject;
type IsEmptyObject<T> = T extends Record<string, never> ? true : false;
// Updated ResponseOf type to use Schema
type ResponseOf<Q, Schema> = {
[K in keyof Q]: IsEmptyObject<Q[K]> extends true
? K extends keyof Schema
? (InstantObject & Schema[K])[]
: InstantObject[]
: (ResponseOf<Q[K], Schema> & InstantObject)[];
? ResponseObject<K, Schema>[]
: (ResponseOf<Q[K], Schema> & ResponseObject<K, Schema>)[];
};

@@ -39,3 +40,2 @@

// Updated QueryResponse type to use Schema
type QueryResponse<T, Schema> = ResponseOf<

@@ -86,8 +86,28 @@ { [K in keyof T]: Remove$<T[K]> },

*/
function dummyQuery<Q extends Query, Schema>(
function dummyQuery<Q extends Query>(
_query: Exactly<Query, Q>,
): ResponseOf<Remove$<Q>, Schema> {
): ResponseOf<Remove$<Q>, unknown> {
return 1 as any;
}
interface ExUser {
name: string;
}
interface ExPost {
title: string;
}
interface ExSchema {
users: ExUser;
posts: ExPost;
}
function dummySchemaQuery<Q extends Query>(
_query: Exactly<Query, Q>,
): ResponseOf<Remove$<Q>, ExSchema> {
return 1 as any;
}
const sanityCheckQueries = () => {

@@ -170,1 +190,10 @@ // -----------

};
function sanityCheckSchemaQueries() {
// simple response
const r1: { users: ExUser[] } = dummySchemaQuery({ users: {} });
// nested response
const r2: { users: ({ posts: ExPost[] } & ExUser)[] } = dummySchemaQuery({
users: { posts: {} },
});
}

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