@instantdb/admin
Advanced tools
Comparing version 0.5.7 to 0.5.8
@@ -6,3 +6,3 @@ import * as instatx from "./instatx"; | ||
adminToken: string; | ||
apiURI: string; | ||
apiURI?: string; | ||
}; | ||
@@ -9,0 +9,0 @@ export declare function init(config: Config): void; |
@@ -38,3 +38,9 @@ "use strict"; | ||
const uuid = __importStar(require("uuid")); | ||
let _GLOBAL_CONFIG = null; | ||
let _GLOBAL_CONFIG = undefined; | ||
function configWithDefaults(config) { | ||
const defaultConfig = { | ||
apiURI: "https://api.instantdb.com", | ||
}; | ||
return Object.assign(Object.assign({}, defaultConfig), config); | ||
} | ||
function assert(condition, msg) { | ||
@@ -68,3 +74,3 @@ if (!condition) { | ||
function init(config) { | ||
_GLOBAL_CONFIG = config; | ||
_GLOBAL_CONFIG = configWithDefaults(config); | ||
} | ||
@@ -71,0 +77,0 @@ exports.init = init; |
@@ -6,3 +6,3 @@ import * as instatx from "./instatx"; | ||
adminToken: string; | ||
apiURI: string; | ||
apiURI?: string; | ||
}; | ||
@@ -9,0 +9,0 @@ export declare function init(config: Config): void; |
@@ -12,3 +12,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import * as uuid from "uuid"; | ||
let _GLOBAL_CONFIG = null; | ||
let _GLOBAL_CONFIG = undefined; | ||
function configWithDefaults(config) { | ||
const defaultConfig = { | ||
apiURI: "https://api.instantdb.com", | ||
}; | ||
return Object.assign(Object.assign({}, defaultConfig), config); | ||
} | ||
function assert(condition, msg) { | ||
@@ -42,3 +48,3 @@ if (!condition) { | ||
export function init(config) { | ||
_GLOBAL_CONFIG = config; | ||
_GLOBAL_CONFIG = configWithDefaults(config); | ||
} | ||
@@ -45,0 +51,0 @@ export function query(query) { |
{ | ||
"name": "@instantdb/admin", | ||
"version": "0.5.7", | ||
"version": "0.5.8", | ||
"description": "Admin SDK for Instant DB", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
import * as instatx from "./instatx"; | ||
import * as uuid from "uuid"; | ||
let _GLOBAL_CONFIG = null; | ||
export type Config = { | ||
appId: string; | ||
adminToken: string; | ||
apiURI: string; | ||
apiURI?: string; | ||
}; | ||
type FilledConfig = Config & { apiURI: string }; | ||
let _GLOBAL_CONFIG: FilledConfig | undefined = undefined; | ||
function configWithDefaults(config: Config): FilledConfig { | ||
const defaultConfig = { | ||
apiURI: "https://api.instantdb.com", | ||
}; | ||
return { ...defaultConfig, ...config }; | ||
} | ||
function assert(condition: any, msg?: string): asserts condition { | ||
@@ -17,3 +27,3 @@ if (!condition) { | ||
function authorizedHeaders(config: Config) { | ||
function authorizedHeaders(config: FilledConfig) { | ||
const { adminToken, appId } = config; | ||
@@ -38,3 +48,3 @@ return { | ||
function getConfig(): Config { | ||
function getConfig(): FilledConfig { | ||
assert( | ||
@@ -49,3 +59,3 @@ _GLOBAL_CONFIG, | ||
export function init(config: Config) { | ||
_GLOBAL_CONFIG = config; | ||
_GLOBAL_CONFIG = configWithDefaults(config); | ||
} | ||
@@ -52,0 +62,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
26020
478