@instantdb/admin 0.22.96-experimental.add-posthog-frontend.20386914944.1 → 0.22.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/index.d.ts +2 -2
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +2 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +2 -1
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
|
-
import { tx, lookup, i, id, InstantAPIError, type InstantIssue, type TransactionChunk, type AuthToken, type User, type Query, type QueryResponse, type InstaQLResponse, type InstaQLParams, type ValidQuery, type InstaQLFields, type InstantQuery, type InstantQueryResult, type InstantSchema, type InstantSchemaDatabase, type InstantObject, type InstantEntity, type BackwardsCompatibleSchema, type IInstantDatabase, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type LinkAttrDef, type LinkDef, type InstantUnknownSchemaDef, type LinksDef, type RoomsOf, type RoomsDef, type PresenceOf, type RoomHandle, type ResolveAttrs, type ValueTypes, type InstantSchemaDef, type InstantUnknownSchema, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type InstantRules, type UpdateParams, type CreateParams, type LinkParams, type RuleParams, type FileOpts, type UploadFileResponse, type DeleteFileResponse } from '@instantdb/core';
|
|
2
|
+
import { tx, lookup, i, id, InstantAPIError, type InstantIssue, type TransactionChunk, type AuthToken, type User, type Query, type QueryResponse, type InstaQLResponse, type InstaQLParams, type ValidQuery, type InstaQLFields, type InstantQuery, type InstantQueryResult, type InstantSchema, type InstantSchemaDatabase, type InstantObject, type InstantEntity, type BackwardsCompatibleSchema, type IInstantDatabase, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type LinkAttrDef, type LinkDef, type InstantUnknownSchemaDef, type LinksDef, type RoomsOf, type RoomsDef, type PresenceOf, type RoomHandle, type ResolveAttrs, type ValueTypes, type InstantSchemaDef, type InstantUnknownSchema, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type InstantRules, type UpdateParams, type CreateParams, type LinkParams, type RuleParams, type FileOpts, type UploadFileResponse, type DeleteFileResponse, createInstantRouteHandler } from '@instantdb/core';
|
|
3
3
|
import { SubscribeQueryCallback, SubscribeQueryResponse, SubscribeQueryPayload, SubscriptionReadyState } from './subscribe.ts';
|
|
4
4
|
type DebugCheckResult = {
|
|
5
5
|
/** The ID of the record. */
|
|
@@ -499,5 +499,5 @@ declare class InstantAdminDatabase<Schema extends InstantSchemaDef<any, any, any
|
|
|
499
499
|
rules?: any;
|
|
500
500
|
}) => Promise<DebugTransactResult>;
|
|
501
501
|
}
|
|
502
|
-
export { init, init_experimental, id, tx, lookup, i, InstantAPIError, type Config, type ImpersonationOpts, type TransactionChunk, type DebugCheckResult, type InstantAdminDatabase, type User, type InstaQLParams, type ValidQuery, type Query, type QueryResponse, type InstaQLResponse, type InstantQuery, type InstantUnknownSchemaDef, type InstantQueryResult, type InstantSchema, type InstantSchemaDatabase, type IInstantDatabase, type InstantObject, type InstantEntity, type BackwardsCompatibleSchema, type InstaQLFields, type SubscribeQueryCallback, type SubscribeQueryResponse, type SubscribeQueryPayload, type SubscriptionReadyState, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type RoomsOf, type PresenceOf, type RoomsDef, type RoomHandle, type ValueTypes, type InstantSchemaDef, type InstantUnknownSchema, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type InstantRules, type CreateParams, type UpdateParams, type LinkParams, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type DeleteManyFileResponse, type InstantIssue, };
|
|
502
|
+
export { init, init_experimental, id, tx, lookup, i, createInstantRouteHandler, InstantAPIError, type Config, type ImpersonationOpts, type TransactionChunk, type DebugCheckResult, type InstantAdminDatabase, type User, type InstaQLParams, type ValidQuery, type Query, type QueryResponse, type InstaQLResponse, type InstantQuery, type InstantUnknownSchemaDef, type InstantQueryResult, type InstantSchema, type InstantSchemaDatabase, type IInstantDatabase, type InstantObject, type InstantEntity, type BackwardsCompatibleSchema, type InstaQLFields, type SubscribeQueryCallback, type SubscribeQueryResponse, type SubscribeQueryPayload, type SubscriptionReadyState, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type RoomsOf, type PresenceOf, type RoomsDef, type RoomHandle, type ValueTypes, type InstantSchemaDef, type InstantUnknownSchema, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type InstantRules, type CreateParams, type UpdateParams, type LinkParams, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type DeleteManyFileResponse, type InstantIssue, };
|
|
503
503
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EACL,EAAE,EACF,MAAM,EAEN,CAAC,EACD,EAAE,EAGF,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EACL,EAAE,EACF,MAAM,EA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C3B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAG3B,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,UAAU,EAGf,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAG3B,KAAK,YAAY,GAClB,CAAC"}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.InstantAPIError = exports.i = exports.lookup = exports.tx = exports.id = exports.init_experimental = void 0;
|
|
15
|
+
exports.InstantAPIError = exports.createInstantRouteHandler = exports.i = exports.lookup = exports.tx = exports.id = exports.init_experimental = void 0;
|
|
16
16
|
exports.init = init;
|
|
17
17
|
const core_1 = require("@instantdb/core");
|
|
18
18
|
Object.defineProperty(exports, "tx", { enumerable: true, get: function () { return core_1.tx; } });
|
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "lookup", { enumerable: true, get: function () {
|
|
|
20
20
|
Object.defineProperty(exports, "i", { enumerable: true, get: function () { return core_1.i; } });
|
|
21
21
|
Object.defineProperty(exports, "id", { enumerable: true, get: function () { return core_1.id; } });
|
|
22
22
|
Object.defineProperty(exports, "InstantAPIError", { enumerable: true, get: function () { return core_1.InstantAPIError; } });
|
|
23
|
+
Object.defineProperty(exports, "createInstantRouteHandler", { enumerable: true, get: function () { return core_1.createInstantRouteHandler; } });
|
|
23
24
|
const version_ts_1 = __importDefault(require("./version.js"));
|
|
24
25
|
const subscribe_ts_1 = require("./subscribe.js");
|
|
25
26
|
function configWithDefaults(config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAwlCE,oBAAI;AAtlCN,0CAsEyB;AAmhCvB,mFAxlCA,SAAE,OAwlCA;AACF,uFAxlCA,aAAM,OAwlCA;AACN,kFAvlCA,QAAC,OAulCA;AAHD,mFAnlCA,SAAE,OAmlCA;AAMF,gGAtlCA,sBAAe,OAslCA;AAthCjB,8DAAmC;AAEnC,iDAMwB;AAkDxB,SAAS,kBAAkB,CAAC,MAAc;IACxC,MAAM,aAAa,GAAG;QACpB,MAAM,EAAE,2BAA2B;KACpC,CAAC;IACF,MAAM,CAAC,mCAAQ,aAAa,GAAK,MAAM,CAAE,CAAC;IAC1C,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,yBAAyB,CAIhC,MAAuC;IAEvC,MAAM,aAAa,GAAG;QACpB,MAAM,EAAE,2BAA2B;KACpC,CAAC;IACF,MAAM,CAAC,mCAAQ,aAAa,GAAK,MAAM,CAAE,CAAC;IAC1C,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,iBAAiB,CACxB,OAAkC,EAClC,IAAuB;IAEvB,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;IACnC,CAAC;SAAM,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QAC3B,OAAO,CAAC,UAAU,CAAC,GAA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,\n getOps,\n i,\n id,\n txInit,\n version as coreVersion,\n InstantAPIError,\n type InstantIssue,\n type TransactionChunk,\n type AuthToken,\n type Exactly,\n\n // core types\n type User,\n type Query,\n\n // query types\n type QueryResponse,\n type InstaQLResponse,\n type InstaQLParams,\n type ValidQuery,\n type InstaQLFields,\n type InstantQuery,\n type InstantQueryResult,\n type InstantSchema,\n type InstantSchemaDatabase,\n type InstantObject,\n type InstantEntity,\n type BackwardsCompatibleSchema,\n type IInstantDatabase,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type LinkAttrDef,\n type LinkDef,\n type InstantUnknownSchemaDef,\n type LinksDef,\n type RoomsOf,\n type RoomsDef,\n type PresenceOf,\n type RoomHandle,\n type ResolveAttrs,\n type ValueTypes,\n type InstantSchemaDef,\n type InstantUnknownSchema,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type InstantRules,\n type UpdateParams,\n type CreateParams,\n type LinkParams,\n type RuleParams,\n type TopicsOf,\n type TopicOf,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n validateQuery,\n validateTransactions,\n} from '@instantdb/core';\n\nimport version from './version.ts';\n\nimport {\n subscribe,\n SubscribeQueryCallback,\n SubscribeQueryResponse,\n SubscribeQueryPayload,\n SubscriptionReadyState,\n} from './subscribe.ts';\n\ntype DebugCheckResult = {\n /** The ID of the record. */\n id: string;\n /** The namespace/table of the record. */\n entity: string;\n /** The value of the record. */\n record: Record<string, any>;\n /** The result of evaluating the corresponding permissions rule for a record. */\n check: any;\n};\n\ntype Config = {\n appId: string;\n adminToken?: string;\n apiURI?: string;\n useDateObjects?: boolean;\n disableValidation?: boolean;\n};\n\nexport type InstantConfig<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n> = {\n appId: string;\n adminToken?: string;\n apiURI?: string;\n schema?: Schema;\n useDateObjects: UseDates;\n disableValidation?: boolean;\n};\n\ntype InstantConfigFilled<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean,\n> = InstantConfig<Schema, UseDates> & { apiURI: string };\n\ntype FilledConfig = Config & { apiURI: string };\n\ntype ImpersonationOpts =\n | { email: string }\n | { token: AuthToken }\n | { guest: boolean };\n\ntype DebugTransactResult = {\n 'tx-id': number;\n 'all-checks-ok?': boolean;\n};\n\nfunction configWithDefaults(config: Config): FilledConfig {\n const defaultConfig = {\n apiURI: 'https://api.instantdb.com',\n };\n const r = { ...defaultConfig, ...config };\n return r;\n}\n\nfunction instantConfigWithDefaults<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean,\n>(\n config: InstantConfig<Schema, UseDates>,\n): InstantConfigFilled<Schema, UseDates> {\n const defaultConfig = {\n apiURI: 'https://api.instantdb.com',\n };\n const r = { ...defaultConfig, ...config };\n return r;\n}\n\nfunction withImpersonation(\n headers: { [key: string]: string },\n opts: ImpersonationOpts,\n) {\n if ('email' in opts) {\n headers['as-email'] = opts.email;\n } else if ('token' in opts) {\n headers['as-token'] = opts.token;\n } else if ('guest' in opts) {\n headers['as-guest'] = 'true';\n }\n return headers;\n}\n\nfunction validateConfigAndImpersonation(\n config: FilledConfig,\n impersonationOpts: ImpersonationOpts | undefined,\n) {\n if (\n impersonationOpts &&\n ('token' in impersonationOpts || 'guest' in impersonationOpts)\n ) {\n // adminToken is not required for `token` or `guest` impersonation\n return;\n }\n if (config.adminToken) {\n // An adminToken is provided.\n return;\n }\n if (impersonationOpts && 'email' in impersonationOpts) {\n throw new Error(\n 'Admin token required. To impersonate users with an email you must pass `adminToken` to `init`.',\n );\n }\n throw new Error(\n 'Admin token required. To run this operation pass `adminToken` to `init`, or use `db.asUser`.',\n );\n}\n\nfunction authorizedHeaders(\n config: FilledConfig,\n impersonationOpts?: ImpersonationOpts,\n): Record<string, string> {\n validateConfigAndImpersonation(config, impersonationOpts);\n\n const { adminToken, appId } = config;\n const headers: Record<string, string> = {\n 'content-type': 'application/json',\n 'app-id': appId,\n };\n\n if (adminToken) {\n headers.authorization = `Bearer ${adminToken}`;\n }\n\n return impersonationOpts\n ? withImpersonation(headers, impersonationOpts)\n : headers;\n}\n\n// NextJS 13 and 14 cache fetch requests by default.\n//\n// Since adminDB.query uses fetch, this means that it would also cache by default.\n//\n// We don't want this behavior. `adminDB.query` should return the latest result by default.\n//\n// To get around this, we set an explicit `cache` header for NextJS 13 and 14.\n// This is no longer needed in NextJS 15 onwards, as the default is `no-store` again.\n// Once NextJS 13 and 14 are no longer common, we can remove this code.\nfunction isNextJSVersionThatCachesFetchByDefault() {\n return (\n // NextJS 13 onwards added a `__nextPatched` property to the fetch function\n fetch['__nextPatched'] &&\n // NextJS 15 onwards _also_ added a global `next-patch` symbol.\n !globalThis[Symbol.for('next-patch')]\n );\n}\n\nfunction getDefaultFetchOpts(): RequestInit {\n return isNextJSVersionThatCachesFetchByDefault() ? { cache: 'no-store' } : {};\n}\n\nasync function jsonReject(rejectFn, res) {\n const body = await res.text();\n try {\n const json = JSON.parse(body);\n return rejectFn(new InstantAPIError({ status: res.status, body: json }));\n } catch (_e) {\n return rejectFn(\n new InstantAPIError({\n status: res.status,\n body: { type: undefined, message: body },\n }),\n );\n }\n}\n\nasync function jsonFetch(\n input: RequestInfo,\n init: RequestInit | undefined,\n): Promise<any> {\n const defaultFetchOpts = getDefaultFetchOpts();\n const headers = {\n ...(init?.headers || {}),\n 'Instant-Admin-Version': version,\n 'Instant-Core-Version': coreVersion,\n };\n const res = await fetch(input, { ...defaultFetchOpts, ...init, headers });\n if (res.status === 200) {\n const json = await res.json();\n return Promise.resolve(json);\n }\n\n return jsonReject((x) => Promise.reject(x), res);\n}\n\n/**\n *\n * The first step: init your application!\n *\n * Visit https://instantdb.com/dash to get your `appId` :)\n *\n * @example\n * import { init } from \"@instantdb/admin\"\n *\n * const db = init({\n * appId: process.env.INSTANT_APP_ID!,\n * adminToken: process.env.INSTANT_APP_ADMIN_TOKEN\n * })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@instantdb/admin\"\n * import schema from \"\"../instant.schema.ts\";\n *\n * const db = init({\n * appId: process.env.INSTANT_APP_ID!,\n * adminToken: process.env.INSTANT_APP_ADMIN_TOKEN,\n * schema,\n * })\n * // To learn more: https://instantdb.com/docs/modeling-data\n */\nfunction init<\n Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema,\n UseDates extends boolean = false,\n>(\n // Allows config with missing `useDateObjects`, but keeps `UseDates`\n // as a non-nullable in the InstantConfig type.\n config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {\n useDateObjects?: UseDates;\n },\n): InstantAdminDatabase<Schema, UseDates, InstantConfig<Schema, UseDates>> {\n const configStrict = {\n ...config,\n appId: config.appId?.trim(),\n adminToken: config.adminToken?.trim(),\n useDateObjects: (config.useDateObjects ?? false) as UseDates,\n };\n\n return new InstantAdminDatabase<\n Schema,\n UseDates,\n InstantConfig<Schema, UseDates>\n >(configStrict);\n}\n\n/**\n * @deprecated\n * `init_experimental` is deprecated. You can replace it with `init`.\n *\n * @example\n *\n * // Before\n * import { init_experimental } from \"@instantdb/admin\"\n * const db = init_experimental({ ... });\n *\n * // After\n * import { init } from \"@instantdb/admin\"\n * const db = init({ ... });\n */\nconst init_experimental = init;\n\nfunction steps(inputChunks) {\n const chunks = Array.isArray(inputChunks) ? inputChunks : [inputChunks];\n return chunks.flatMap(getOps);\n}\n\ntype PresenceResult<Data> = {\n [peerId: string]: { data: Data; 'peer-id': string; user: User | null };\n};\n\nclass Rooms<Schema extends InstantSchemaDef<any, any, any>> {\n config: FilledConfig;\n\n constructor(config: FilledConfig) {\n this.config = config;\n }\n\n async getPresence<RoomType extends keyof RoomsOf<Schema>>(\n roomType: RoomType,\n roomId: string,\n ): Promise<PresenceResult<PresenceOf<Schema, RoomType>>> {\n const res = await jsonFetch(\n `${this.config.apiURI}/admin/rooms/presence?room-type=${String(roomType)}&room-id=${roomId}`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return res.sessions || {};\n }\n}\n\nclass Auth {\n config: FilledConfig;\n\n constructor(config: FilledConfig) {\n this.config = config;\n this.createToken = this.createToken.bind(this);\n }\n\n /**\n * Generates a magic code for the user with the given email.\n * This is useful if you want to use your own email provider\n * to send magic codes.\n *\n * @example\n * // Generate a magic code\n * const { code } = await db.auth.generateMagicCode({ email })\n * // Send the magic code to the user with your own email provider\n * await customEmailProvider.sendMagicCode(email, code)\n *\n * @see https://instantdb.com/docs/backend#custom-magic-codes\n */\n generateMagicCode = async (email: string): Promise<{ code: string }> => {\n return jsonFetch(`${this.config.apiURI}/admin/magic_code`, {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({ email }),\n });\n };\n\n /**\n * Sends a magic code to the user with the given email.\n * This uses Instant's built-in email provider.\n *\n * @example\n * // Send an email to user with magic code\n * await db.auth.sendMagicCode({ email })\n *\n * @see https://instantdb.com/docs/backend#custom-magic-codes\n */\n sendMagicCode = async (email: string): Promise<{ code: string }> => {\n return jsonFetch(`${this.config.apiURI}/admin/send_magic_code`, {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({ email }),\n });\n };\n\n /**\n * Verifies a magic code for the user with the given email.\n *\n * @example\n * const user = await db.auth.verifyMagicCode({ email, code })\n * console.log(\"Verified user:\", user)\n *\n * @see https://instantdb.com/docs/backend#custom-magic-codes\n */\n verifyMagicCode = async (email: string, code: string): Promise<User> => {\n const { user } = await jsonFetch(\n `${this.config.apiURI}/admin/verify_magic_code`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({ email, code }),\n },\n );\n return user;\n };\n\n /**\n * Creates a login token for the user with the given email.\n * If that user does not exist, we create one.\n *\n * This is often useful for writing custom auth flows.\n *\n * @example\n * app.post('/custom_sign_in', async (req, res) => {\n * // ... your custom flow for users\n * const token = await db.auth.createToken({ email })\n * return res.status(200).send({ token })\n * })\n *\n * @see https://instantdb.com/docs/backend#custom-auth\n */\n createToken(email: { email: string } | { id: string }): Promise<AuthToken>;\n\n /**\n *\n * @deprecated Passing an email string directly is deprecated.\n *\n * Use an object with the `email` key instead.\n *\n * @example\n * // Before\n * const token = await auth.createToken(email)\n * // After\n * const token = await auth.createToken({ email })\n */\n createToken(email: string): Promise<AuthToken>;\n\n async createToken(\n input: string | { email: string } | { id: string },\n ): Promise<AuthToken> {\n const body = typeof input === 'string' ? { email: input } : input;\n const ret: { user: { refresh_token: string } } = await jsonFetch(\n `${this.config.apiURI}/admin/refresh_tokens`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify(body),\n },\n );\n return ret.user.refresh_token;\n }\n\n /**\n * Verifies a given token and returns the associated user.\n *\n * This is often useful for writing custom endpoints, where you need\n * to authenticate users.\n *\n * @example\n * app.post('/custom_endpoint', async (req, res) => {\n * const user = await db.auth.verifyToken(req.headers['token'])\n * if (!user) {\n * return res.status(401).send('Uh oh, you are not authenticated')\n * }\n * // ...\n * })\n * @see https://instantdb.com/docs/backend#custom-endpoints\n */\n verifyToken = async (token: AuthToken): Promise<User> => {\n const res = await jsonFetch(\n `${this.config.apiURI}/runtime/auth/verify_refresh_token`,\n {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n 'app-id': this.config.appId,\n 'refresh-token': token,\n }),\n },\n );\n return res.user;\n };\n\n /**\n * Retrieves an app user by id, email, or refresh token.\n *\n * @example\n * try {\n * const user = await db.auth.getUser({ email })\n * console.log(\"Found user:\", user)\n * } catch (err) {\n * console.error(\"Failed to retrieve user:\", err.message);\n * }\n *\n * @see https://instantdb.com/docs/backend#retrieve-a-user\n */\n getUser = async (\n params: { email: string } | { id: string } | { refresh_token: string },\n ): Promise<Omit<User, 'refresh_token'>> => {\n const qs = Object.entries(params)\n .map(([k, v]) => `${k}=${encodeURIComponent(v)}`)\n .join('&');\n\n const response: { user: User } = await jsonFetch(\n `${this.config.apiURI}/admin/users?${qs}`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return response.user;\n };\n\n /**\n * Deletes an app user by id, email, or refresh token.\n *\n * NB: This _only_ deletes the user; it does not delete all user data.\n * You will need to handle this manually.\n *\n * @example\n * try {\n * const deletedUser = await db.auth.deleteUser({ email })\n * console.log(\"Deleted user:\", deletedUser)\n * } catch (err) {\n * console.error(\"Failed to delete user:\", err.message);\n * }\n *\n * @see https://instantdb.com/docs/backend#delete-a-user\n */\n deleteUser = async (\n params: { email: string } | { id: string } | { refresh_token: string },\n ): Promise<User> => {\n const qs = Object.entries(params).map(([k, v]) => `${k}=${v}`);\n const response: { deleted: User } = await jsonFetch(\n `${this.config.apiURI}/admin/users?${qs}`,\n {\n method: 'DELETE',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return response.deleted;\n };\n\n /**\n * Signs out the user with the given email.\n * This invalidates any tokens associated with the user.\n * If the user is not found, an error will be thrown.\n *\n * @example\n * try {\n * await auth.signOut({ email: \"alyssa_p_hacker@instantdb.com\" });\n * console.log(\"Successfully signed out\");\n * } catch (err) {\n * console.error(\"Sign out failed:\", err.message);\n * }\n *\n * @see https://instantdb.com/docs/backend#sign-out\n */\n async signOut(\n params: { email: string } | { id: string } | { refresh_token: string },\n ): Promise<void>;\n\n /**\n * @deprecated Passing an email string directly is deprecated.\n * Use an object with the `email` key instead.\n *\n * @example\n * // Before\n * auth.signOut(email)\n *\n * // After\n * auth.signOut({ email })\n */\n async signOut(email: string): Promise<void>;\n\n async signOut(\n input:\n | string\n | { email: string }\n | { id: string }\n | { refresh_token: string },\n ): Promise<void> {\n // If input is a string, we assume it's an email.\n // This is because of backwards compatibility: we used to only\n // accept email strings. Eventually we can remove this\n const params = typeof input === 'string' ? { email: input } : input;\n const config = this.config;\n await jsonFetch(`${config.apiURI}/admin/sign_out`, {\n method: 'POST',\n headers: authorizedHeaders(config),\n body: JSON.stringify(params),\n });\n }\n}\n\ntype StorageFile = {\n key: string;\n name: string;\n size: number;\n etag: string;\n last_modified: number;\n};\n\ntype DeleteManyFileResponse = {\n data: {\n ids: string[] | null;\n };\n};\n\nconst isNodeReadable = (v: any): v is Readable =>\n v &&\n typeof v === 'object' &&\n typeof v.pipe === 'function' &&\n typeof v.read === 'function';\n\nconst isWebReadable = (v: any): v is ReadableStream =>\n v && typeof v.getReader === 'function';\n\n/**\n * Functions to manage file storage.\n */\nclass Storage {\n config: FilledConfig;\n impersonationOpts?: ImpersonationOpts;\n\n constructor(config: FilledConfig, impersonationOpts?: ImpersonationOpts) {\n this.config = config;\n this.impersonationOpts = impersonationOpts;\n }\n\n /**\n * Uploads file at the provided path. Accepts a Buffer or a Readable stream.\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * const buffer = fs.readFileSync('demo.png');\n * const isSuccess = await db.storage.uploadFile('photos/demo.png', buffer);\n */\n uploadFile = async (\n path: string,\n file: Buffer | Readable | ReadableStream | Uint8Array,\n metadata: FileOpts = {},\n ): Promise<UploadFileResponse> => {\n const headers = {\n ...authorizedHeaders(this.config, this.impersonationOpts),\n path,\n };\n if (metadata.contentDisposition) {\n headers['content-disposition'] = metadata.contentDisposition;\n }\n\n // headers.content-type will become \"undefined\" (string)\n // if not removed from the object\n delete headers['content-type'];\n\n if (metadata.contentType) {\n headers['content-type'] = metadata.contentType;\n }\n\n let duplex: 'half' | undefined;\n if (isNodeReadable(file)) {\n duplex = 'half'; // one-way stream\n }\n if (isNodeReadable(file) || isWebReadable(file)) {\n if (!metadata.fileSize) {\n throw new Error(\n 'fileSize is required in metadata when uploading streams',\n );\n }\n headers['content-length'] = metadata.fileSize.toString();\n }\n\n let options = {\n method: 'PUT',\n headers,\n body: file as unknown as BodyInit,\n ...(duplex && { duplex }),\n };\n\n return jsonFetch(`${this.config.apiURI}/admin/storage/upload`, options);\n };\n\n /**\n * Deletes a file by its path name (e.g. \"photos/demo.png\").\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * await db.storage.delete(\"photos/demo.png\");\n */\n delete = async (pathname: string): Promise<DeleteFileResponse> => {\n return jsonFetch(\n `${this.config.apiURI}/admin/storage/files?filename=${encodeURIComponent(\n pathname,\n )}`,\n {\n method: 'DELETE',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n },\n );\n };\n\n /**\n * Deletes multiple files by their path names (e.g. \"photos/demo.png\", \"essays/demo.txt\").\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * await db.storage.deleteMany([\"images/1.png\", \"images/2.png\", \"images/3.png\"]);\n */\n deleteMany = async (pathnames: string[]): Promise<DeleteManyFileResponse> => {\n return jsonFetch(`${this.config.apiURI}/admin/storage/files/delete`, {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({ filenames: pathnames }),\n });\n };\n\n /**\n * @deprecated. This method will be removed in the future. Use `uploadFile`\n * instead\n */\n upload = async (\n pathname: string,\n file: Buffer,\n metadata: FileOpts = {},\n ): Promise<boolean> => {\n const { data: presignedUrl } = await jsonFetch(\n `${this.config.apiURI}/admin/storage/signed-upload-url`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({\n app_id: this.config.appId,\n filename: pathname,\n }),\n },\n );\n const headers = {};\n const contentType = metadata.contentType;\n if (contentType) {\n headers['Content-Type'] = contentType;\n }\n const { ok } = await fetch(presignedUrl, {\n method: 'PUT',\n body: file as unknown as BodyInit,\n headers,\n });\n\n return ok;\n };\n\n /**\n * @deprecated. This method will be removed in the future. Use `query` instead\n * @example\n * const files = await db.query({ $files: {}})\n */\n list = async (): Promise<StorageFile[]> => {\n const { data } = await jsonFetch(\n `${this.config.apiURI}/admin/storage/files`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return data;\n };\n\n /**\n * @deprecated. getDownloadUrl will be removed in the future.\n * Use `query` instead to query and fetch for valid urls\n *\n * db.useQuery({\n * $files: {\n * $: {\n * where: {\n * path: \"moop.png\"\n * }\n * }\n * }\n * })\n */\n getDownloadUrl = async (pathname: string): Promise<string> => {\n const { data } = await jsonFetch(\n `${this.config.apiURI}/admin/storage/signed-download-url?app_id=${this.config.appId}&filename=${encodeURIComponent(pathname)}`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return data;\n };\n}\n\ntype AdminQueryOpts = {\n ruleParams?: RuleParams;\n fetchOpts?: RequestInit;\n};\n\n/**\n *\n * The first step: init your application!\n *\n * Visit https://instantdb.com/dash to get your `appId` and `adminToken` :)\n *\n * @example\n * const db = init({ appId: \"my-app-id\", adminToken: \"my-admin-token\" })\n */\nclass InstantAdminDatabase<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n Config extends InstantConfig<Schema, UseDates> = InstantConfig<\n Schema,\n UseDates\n >,\n> {\n config: InstantConfigFilled<Schema, UseDates>;\n auth: Auth;\n storage: Storage;\n rooms: Rooms<Schema>;\n impersonationOpts?: ImpersonationOpts;\n\n public tx = txInit<NonNullable<Schema>>();\n\n constructor(_config: Config) {\n this.config = instantConfigWithDefaults(_config);\n this.auth = new Auth(this.config);\n this.storage = new Storage(this.config, this.impersonationOpts);\n this.rooms = new Rooms<Schema>(this.config);\n }\n\n /**\n * Sometimes you want to scope queries to a specific user.\n *\n * You can provide a user's auth token, email, or impersonate a guest.\n *\n * @see https://instantdb.com/docs/backend#impersonating-users\n * @example\n * await db.asUser({email: \"stopa@instantdb.com\"}).query({ goals: {} })\n */\n asUser = (\n opts: ImpersonationOpts,\n ): InstantAdminDatabase<Schema, UseDates, Config> => {\n const newClient = new InstantAdminDatabase<Schema, UseDates, Config>({\n ...(this.config as Config),\n });\n newClient.impersonationOpts = opts;\n newClient.storage = new Storage(this.config, opts);\n return newClient;\n };\n\n /**\n * Use this to query your data!\n *\n * @see https://instantdb.com/docs/instaql\n *\n * @example\n * // fetch all goals\n * await db.query({ goals: {} })\n *\n * // goals where the title is \"Get Fit\"\n * await db.query({ goals: { $: { where: { title: \"Get Fit\" } } } })\n *\n * // all goals, _alongside_ their todos\n * await db.query({ goals: { todos: {} } })\n */\n query = <Q extends ValidQuery<Q, Schema>>(\n query: Q,\n opts: AdminQueryOpts = {},\n ): Promise<InstaQLResponse<Schema, Q, UseDates>> => {\n if (query && opts && 'ruleParams' in opts) {\n query = { $$ruleParams: opts['ruleParams'], ...query };\n }\n\n if (!this.config.disableValidation) {\n validateQuery(query, this.config.schema);\n }\n\n const fetchOpts = opts.fetchOpts || {};\n const fetchOptsHeaders = fetchOpts['headers'] || {};\n return jsonFetch(`${this.config.apiURI}/admin/query`, {\n ...fetchOpts,\n method: 'POST',\n headers: {\n ...fetchOptsHeaders,\n ...authorizedHeaders(this.config, this.impersonationOpts),\n },\n body: JSON.stringify({\n query: query,\n 'inference?': !!this.config.schema,\n }),\n });\n };\n\n /**\n * Use this to to get a live view of your data!\n *\n * @see https://www.instantdb.com/docs/backend\n *\n * @example\n * // create a subscription to a query\n * const query = { goals: { $: { where: { title: \"Get Fit\" } } } }\n * const sub = db.subscribeQuery(query);\n *\n * // iterate through the results with an async iterator\n * for await (const payload of sub) {\n * if (payload.error) {\n * console.log(payload.error);\n * // Stop the subscription\n * sub.close();\n * } else {\n * console.log(payload.data);\n * }\n * }\n *\n * // Stop the subscription\n * sub.close();\n *\n * // Create a subscription with a callback\n * const sub = db.subscribeQuery(query, (payload) => {\n * if (payload.error) {\n * console.log(payload.error);\n * // Stop the subscription\n * sub.close();\n * } else {\n * console.log(payload.data);\n * }\n * });\n */\n subscribeQuery<Q extends ValidQuery<Q, Schema>>(\n query: Q,\n cb?: SubscribeQueryCallback<Schema, Q, UseDates>,\n opts: AdminQueryOpts = {},\n ): SubscribeQueryResponse<Schema, Q, UseDates> {\n if (query && opts && 'ruleParams' in opts) {\n query = { $$ruleParams: opts['ruleParams'], ...query };\n }\n\n if (!this.config.disableValidation) {\n validateQuery(query, this.config.schema);\n }\n\n const fetchOpts = opts.fetchOpts || {};\n const fetchOptsHeaders = fetchOpts['headers'] || {};\n\n const headers: HeadersInit = {\n ...fetchOptsHeaders,\n ...authorizedHeaders(this.config, this.impersonationOpts),\n };\n\n const inference = !!this.config.schema;\n\n return subscribe(query, cb, {\n headers,\n inference,\n apiURI: this.config.apiURI,\n });\n }\n\n /**\n * Use this to write data! You can create, update, delete, and link objects\n *\n * @see https://instantdb.com/docs/instaml\n *\n * @example\n * // Create a new object in the `goals` namespace\n * const goalId = id();\n * db.transact(db.tx.goals[goalId].update({title: \"Get fit\"}))\n *\n * // Update the title\n * db.transact(db.tx.goals[goalId].update({title: \"Get super fit\"}))\n *\n * // Delete it\n * db.transact(db.tx.goals[goalId].delete())\n *\n * // Or create an association:\n * todoId = id();\n * db.transact([\n * db.tx.todos[todoId].update({ title: 'Go on a run' }),\n * db.tx.goals[goalId].link({todos: todoId}),\n * ])\n */\n transact = (\n inputChunks: TransactionChunk<any, any> | TransactionChunk<any, any>[],\n ) => {\n if (!this.config.disableValidation) {\n validateTransactions(inputChunks, this.config.schema);\n }\n return jsonFetch(`${this.config.apiURI}/admin/transact`, {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({\n steps: steps(inputChunks),\n 'throw-on-missing-attrs?': !!this.config.schema,\n }),\n });\n };\n\n /**\n * Like `query`, but returns debugging information\n * for permissions checks along with the result.\n * Useful for inspecting the values returned by the permissions checks.\n * Note, this will return debug information for *all* entities\n * that match the query's `where` clauses.\n *\n * Requires a user/guest context to be set with `asUser`,\n * since permissions checks are user-specific.\n *\n * Accepts an optional configuration object with a `rules` key.\n * The provided rules will override the rules in the database for the query.\n *\n * @see https://instantdb.com/docs/instaql\n *\n * @example\n * await db.asUser({ guest: true }).debugQuery(\n * { goals: {} },\n * { rules: { goals: { allow: { read: \"auth.id != null\" } } }\n * )\n */\n debugQuery = async <Q extends ValidQuery<Q, Schema>>(\n query: Q,\n opts?: { rules?: any; ruleParams?: { [key: string]: any } },\n ): Promise<{\n result: InstaQLResponse<Schema, Q, UseDates>;\n checkResults: DebugCheckResult[];\n }> => {\n if (query && opts && 'ruleParams' in opts) {\n query = { $$ruleParams: opts['ruleParams'], ...query };\n }\n\n const response = await jsonFetch(\n `${this.config.apiURI}/admin/query_perms_check`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({ query, 'rules-override': opts?.rules }),\n },\n );\n\n return {\n result: response.result,\n checkResults: response['check-results'],\n };\n };\n\n /**\n * Like `transact`, but does not write to the database.\n * Returns debugging information for permissions checks.\n * Useful for inspecting the values returned by the permissions checks.\n *\n * Requires a user/guest context to be set with `asUser`,\n * since permissions checks are user-specific.\n *\n * Accepts an optional configuration object with a `rules` key.\n * The provided rules will override the rules in the database for the duration of the transaction.\n *\n * @example\n * const goalId = id();\n * db.asUser({ guest: true }).debugTransact(\n * [db.tx.goals[goalId].update({title: \"Get fit\"})],\n * { rules: { goals: { allow: { update: \"auth.id != null\" } } }\n * )\n */\n debugTransact = (\n inputChunks: TransactionChunk<any, any> | TransactionChunk<any, any>[],\n opts?: { rules?: any },\n ): Promise<DebugTransactResult> => {\n return jsonFetch(`${this.config.apiURI}/admin/transact_perms_check`, {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({\n steps: steps(inputChunks),\n 'rules-override': opts?.rules,\n // @ts-expect-error because we're using a private API (for now)\n 'dangerously-commit-tx': opts?.__dangerouslyCommit,\n }),\n });\n };\n}\n\nexport {\n init,\n init_experimental,\n id,\n tx,\n lookup,\n i,\n\n // error\n InstantAPIError,\n\n // types\n type Config,\n type ImpersonationOpts,\n type TransactionChunk,\n type DebugCheckResult,\n type InstantAdminDatabase,\n\n // core types\n type User,\n type InstaQLParams,\n type ValidQuery,\n type Query,\n\n // query types\n type QueryResponse,\n type InstaQLResponse,\n type InstantQuery,\n type InstantUnknownSchemaDef,\n type InstantQueryResult,\n type InstantSchema,\n type InstantSchemaDatabase,\n type IInstantDatabase,\n type InstantObject,\n type InstantEntity,\n type BackwardsCompatibleSchema,\n type InstaQLFields,\n type SubscribeQueryCallback,\n type SubscribeQueryResponse,\n type SubscribeQueryPayload,\n type SubscriptionReadyState,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type RoomsOf,\n type PresenceOf,\n type RoomsDef,\n type RoomHandle,\n type ValueTypes,\n type InstantSchemaDef,\n type InstantUnknownSchema,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type InstantRules,\n type CreateParams,\n type UpdateParams,\n type LinkParams,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n type DeleteManyFileResponse,\n\n // error types\n type InstantIssue,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAwlCE,oBAAI;AAtlCN,0CAsEyB;AAmhCvB,mFAxlCA,SAAE,OAwlCA;AACF,uFAxlCA,aAAM,OAwlCA;AACN,kFAvlCA,QAAC,OAulCA;AAHD,mFAnlCA,SAAE,OAmlCA;AAOF,gGAvlCA,sBAAe,OAulCA;AAHf,0GAvhCA,gCAAyB,OAuhCA;AAphC3B,8DAAmC;AAEnC,iDAMwB;AAkDxB,SAAS,kBAAkB,CAAC,MAAc;IACxC,MAAM,aAAa,GAAG;QACpB,MAAM,EAAE,2BAA2B;KACpC,CAAC;IACF,MAAM,CAAC,mCAAQ,aAAa,GAAK,MAAM,CAAE,CAAC;IAC1C,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,yBAAyB,CAIhC,MAAuC;IAEvC,MAAM,aAAa,GAAG;QACpB,MAAM,EAAE,2BAA2B;KACpC,CAAC;IACF,MAAM,CAAC,mCAAQ,aAAa,GAAK,MAAM,CAAE,CAAC;IAC1C,OAAO,CAAC,CAAC;AACX,CAAC;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,MAAM,CAAC,MAAM,CAAC;QAEvC,OAAO,IAAA,wBAAS,EAAC,KAAK,EAAE,EAAE,EAAE;YAC1B,OAAO;YACP,SAAS;YACT,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;SAC3B,CAAC,CAAC;IACL,CAAC;CAyHF","sourcesContent":["import type { Readable } from 'node:stream';\n\nimport {\n tx,\n lookup,\n getOps,\n i,\n id,\n txInit,\n version as coreVersion,\n InstantAPIError,\n type InstantIssue,\n type TransactionChunk,\n type AuthToken,\n\n // core types\n type User,\n type Query,\n\n // query types\n type QueryResponse,\n type InstaQLResponse,\n type InstaQLParams,\n type ValidQuery,\n type InstaQLFields,\n type InstantQuery,\n type InstantQueryResult,\n type InstantSchema,\n type InstantSchemaDatabase,\n type InstantObject,\n type InstantEntity,\n type BackwardsCompatibleSchema,\n type IInstantDatabase,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type LinkAttrDef,\n type LinkDef,\n type InstantUnknownSchemaDef,\n type LinksDef,\n type RoomsOf,\n type RoomsDef,\n type PresenceOf,\n type RoomHandle,\n type ResolveAttrs,\n type ValueTypes,\n type InstantSchemaDef,\n type InstantUnknownSchema,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type InstantRules,\n type UpdateParams,\n type CreateParams,\n type LinkParams,\n type RuleParams,\n type TopicsOf,\n type TopicOf,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n validateQuery,\n validateTransactions,\n createInstantRouteHandler,\n} from '@instantdb/core';\n\nimport version from './version.ts';\n\nimport {\n subscribe,\n SubscribeQueryCallback,\n SubscribeQueryResponse,\n SubscribeQueryPayload,\n SubscriptionReadyState,\n} from './subscribe.ts';\n\ntype DebugCheckResult = {\n /** The ID of the record. */\n id: string;\n /** The namespace/table of the record. */\n entity: string;\n /** The value of the record. */\n record: Record<string, any>;\n /** The result of evaluating the corresponding permissions rule for a record. */\n check: any;\n};\n\ntype Config = {\n appId: string;\n adminToken?: string;\n apiURI?: string;\n useDateObjects?: boolean;\n disableValidation?: boolean;\n};\n\nexport type InstantConfig<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n> = {\n appId: string;\n adminToken?: string;\n apiURI?: string;\n schema?: Schema;\n useDateObjects: UseDates;\n disableValidation?: boolean;\n};\n\ntype InstantConfigFilled<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean,\n> = InstantConfig<Schema, UseDates> & { apiURI: string };\n\ntype FilledConfig = Config & { apiURI: string };\n\ntype ImpersonationOpts =\n | { email: string }\n | { token: AuthToken }\n | { guest: boolean };\n\ntype DebugTransactResult = {\n 'tx-id': number;\n 'all-checks-ok?': boolean;\n};\n\nfunction configWithDefaults(config: Config): FilledConfig {\n const defaultConfig = {\n apiURI: 'https://api.instantdb.com',\n };\n const r = { ...defaultConfig, ...config };\n return r;\n}\n\nfunction instantConfigWithDefaults<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean,\n>(\n config: InstantConfig<Schema, UseDates>,\n): InstantConfigFilled<Schema, UseDates> {\n const defaultConfig = {\n apiURI: 'https://api.instantdb.com',\n };\n const r = { ...defaultConfig, ...config };\n return r;\n}\n\nfunction withImpersonation(\n headers: { [key: string]: string },\n opts: ImpersonationOpts,\n) {\n if ('email' in opts) {\n headers['as-email'] = opts.email;\n } else if ('token' in opts) {\n headers['as-token'] = opts.token;\n } else if ('guest' in opts) {\n headers['as-guest'] = 'true';\n }\n return headers;\n}\n\nfunction validateConfigAndImpersonation(\n config: FilledConfig,\n impersonationOpts: ImpersonationOpts | undefined,\n) {\n if (\n impersonationOpts &&\n ('token' in impersonationOpts || 'guest' in impersonationOpts)\n ) {\n // adminToken is not required for `token` or `guest` impersonation\n return;\n }\n if (config.adminToken) {\n // An adminToken is provided.\n return;\n }\n if (impersonationOpts && 'email' in impersonationOpts) {\n throw new Error(\n 'Admin token required. To impersonate users with an email you must pass `adminToken` to `init`.',\n );\n }\n throw new Error(\n 'Admin token required. To run this operation pass `adminToken` to `init`, or use `db.asUser`.',\n );\n}\n\nfunction authorizedHeaders(\n config: FilledConfig,\n impersonationOpts?: ImpersonationOpts,\n): Record<string, string> {\n validateConfigAndImpersonation(config, impersonationOpts);\n\n const { adminToken, appId } = config;\n const headers: Record<string, string> = {\n 'content-type': 'application/json',\n 'app-id': appId,\n };\n\n if (adminToken) {\n headers.authorization = `Bearer ${adminToken}`;\n }\n\n return impersonationOpts\n ? withImpersonation(headers, impersonationOpts)\n : headers;\n}\n\n// NextJS 13 and 14 cache fetch requests by default.\n//\n// Since adminDB.query uses fetch, this means that it would also cache by default.\n//\n// We don't want this behavior. `adminDB.query` should return the latest result by default.\n//\n// To get around this, we set an explicit `cache` header for NextJS 13 and 14.\n// This is no longer needed in NextJS 15 onwards, as the default is `no-store` again.\n// Once NextJS 13 and 14 are no longer common, we can remove this code.\nfunction isNextJSVersionThatCachesFetchByDefault() {\n return (\n // NextJS 13 onwards added a `__nextPatched` property to the fetch function\n fetch['__nextPatched'] &&\n // NextJS 15 onwards _also_ added a global `next-patch` symbol.\n !globalThis[Symbol.for('next-patch')]\n );\n}\n\nfunction getDefaultFetchOpts(): RequestInit {\n return isNextJSVersionThatCachesFetchByDefault() ? { cache: 'no-store' } : {};\n}\n\nasync function jsonReject(rejectFn, res) {\n const body = await res.text();\n try {\n const json = JSON.parse(body);\n return rejectFn(new InstantAPIError({ status: res.status, body: json }));\n } catch (_e) {\n return rejectFn(\n new InstantAPIError({\n status: res.status,\n body: { type: undefined, message: body },\n }),\n );\n }\n}\n\nasync function jsonFetch(\n input: RequestInfo,\n init: RequestInit | undefined,\n): Promise<any> {\n const defaultFetchOpts = getDefaultFetchOpts();\n const headers = {\n ...(init?.headers || {}),\n 'Instant-Admin-Version': version,\n 'Instant-Core-Version': coreVersion,\n };\n const res = await fetch(input, { ...defaultFetchOpts, ...init, headers });\n if (res.status === 200) {\n const json = await res.json();\n return Promise.resolve(json);\n }\n\n return jsonReject((x) => Promise.reject(x), res);\n}\n\n/**\n *\n * The first step: init your application!\n *\n * Visit https://instantdb.com/dash to get your `appId` :)\n *\n * @example\n * import { init } from \"@instantdb/admin\"\n *\n * const db = init({\n * appId: process.env.INSTANT_APP_ID!,\n * adminToken: process.env.INSTANT_APP_ADMIN_TOKEN\n * })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@instantdb/admin\"\n * import schema from \"\"../instant.schema.ts\";\n *\n * const db = init({\n * appId: process.env.INSTANT_APP_ID!,\n * adminToken: process.env.INSTANT_APP_ADMIN_TOKEN,\n * schema,\n * })\n * // To learn more: https://instantdb.com/docs/modeling-data\n */\nfunction init<\n Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema,\n UseDates extends boolean = false,\n>(\n // Allows config with missing `useDateObjects`, but keeps `UseDates`\n // as a non-nullable in the InstantConfig type.\n config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {\n useDateObjects?: UseDates;\n },\n): InstantAdminDatabase<Schema, UseDates, InstantConfig<Schema, UseDates>> {\n const configStrict = {\n ...config,\n appId: config.appId?.trim(),\n adminToken: config.adminToken?.trim(),\n useDateObjects: (config.useDateObjects ?? false) as UseDates,\n };\n\n return new InstantAdminDatabase<\n Schema,\n UseDates,\n InstantConfig<Schema, UseDates>\n >(configStrict);\n}\n\n/**\n * @deprecated\n * `init_experimental` is deprecated. You can replace it with `init`.\n *\n * @example\n *\n * // Before\n * import { init_experimental } from \"@instantdb/admin\"\n * const db = init_experimental({ ... });\n *\n * // After\n * import { init } from \"@instantdb/admin\"\n * const db = init({ ... });\n */\nconst init_experimental = init;\n\nfunction steps(inputChunks) {\n const chunks = Array.isArray(inputChunks) ? inputChunks : [inputChunks];\n return chunks.flatMap(getOps);\n}\n\ntype PresenceResult<Data> = {\n [peerId: string]: { data: Data; 'peer-id': string; user: User | null };\n};\n\nclass Rooms<Schema extends InstantSchemaDef<any, any, any>> {\n config: FilledConfig;\n\n constructor(config: FilledConfig) {\n this.config = config;\n }\n\n async getPresence<RoomType extends keyof RoomsOf<Schema>>(\n roomType: RoomType,\n roomId: string,\n ): Promise<PresenceResult<PresenceOf<Schema, RoomType>>> {\n const res = await jsonFetch(\n `${this.config.apiURI}/admin/rooms/presence?room-type=${String(roomType)}&room-id=${roomId}`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return res.sessions || {};\n }\n}\n\nclass Auth {\n config: FilledConfig;\n\n constructor(config: FilledConfig) {\n this.config = config;\n this.createToken = this.createToken.bind(this);\n }\n\n /**\n * Generates a magic code for the user with the given email.\n * This is useful if you want to use your own email provider\n * to send magic codes.\n *\n * @example\n * // Generate a magic code\n * const { code } = await db.auth.generateMagicCode({ email })\n * // Send the magic code to the user with your own email provider\n * await customEmailProvider.sendMagicCode(email, code)\n *\n * @see https://instantdb.com/docs/backend#custom-magic-codes\n */\n generateMagicCode = async (email: string): Promise<{ code: string }> => {\n return jsonFetch(`${this.config.apiURI}/admin/magic_code`, {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({ email }),\n });\n };\n\n /**\n * Sends a magic code to the user with the given email.\n * This uses Instant's built-in email provider.\n *\n * @example\n * // Send an email to user with magic code\n * await db.auth.sendMagicCode({ email })\n *\n * @see https://instantdb.com/docs/backend#custom-magic-codes\n */\n sendMagicCode = async (email: string): Promise<{ code: string }> => {\n return jsonFetch(`${this.config.apiURI}/admin/send_magic_code`, {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({ email }),\n });\n };\n\n /**\n * Verifies a magic code for the user with the given email.\n *\n * @example\n * const user = await db.auth.verifyMagicCode({ email, code })\n * console.log(\"Verified user:\", user)\n *\n * @see https://instantdb.com/docs/backend#custom-magic-codes\n */\n verifyMagicCode = async (email: string, code: string): Promise<User> => {\n const { user } = await jsonFetch(\n `${this.config.apiURI}/admin/verify_magic_code`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({ email, code }),\n },\n );\n return user;\n };\n\n /**\n * Creates a login token for the user with the given email.\n * If that user does not exist, we create one.\n *\n * This is often useful for writing custom auth flows.\n *\n * @example\n * app.post('/custom_sign_in', async (req, res) => {\n * // ... your custom flow for users\n * const token = await db.auth.createToken({ email })\n * return res.status(200).send({ token })\n * })\n *\n * @see https://instantdb.com/docs/backend#custom-auth\n */\n createToken(email: { email: string } | { id: string }): Promise<AuthToken>;\n\n /**\n *\n * @deprecated Passing an email string directly is deprecated.\n *\n * Use an object with the `email` key instead.\n *\n * @example\n * // Before\n * const token = await auth.createToken(email)\n * // After\n * const token = await auth.createToken({ email })\n */\n createToken(email: string): Promise<AuthToken>;\n\n async createToken(\n input: string | { email: string } | { id: string },\n ): Promise<AuthToken> {\n const body = typeof input === 'string' ? { email: input } : input;\n const ret: { user: { refresh_token: string } } = await jsonFetch(\n `${this.config.apiURI}/admin/refresh_tokens`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify(body),\n },\n );\n return ret.user.refresh_token;\n }\n\n /**\n * Verifies a given token and returns the associated user.\n *\n * This is often useful for writing custom endpoints, where you need\n * to authenticate users.\n *\n * @example\n * app.post('/custom_endpoint', async (req, res) => {\n * const user = await db.auth.verifyToken(req.headers['token'])\n * if (!user) {\n * return res.status(401).send('Uh oh, you are not authenticated')\n * }\n * // ...\n * })\n * @see https://instantdb.com/docs/backend#custom-endpoints\n */\n verifyToken = async (token: AuthToken): Promise<User> => {\n const res = await jsonFetch(\n `${this.config.apiURI}/runtime/auth/verify_refresh_token`,\n {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n 'app-id': this.config.appId,\n 'refresh-token': token,\n }),\n },\n );\n return res.user;\n };\n\n /**\n * Retrieves an app user by id, email, or refresh token.\n *\n * @example\n * try {\n * const user = await db.auth.getUser({ email })\n * console.log(\"Found user:\", user)\n * } catch (err) {\n * console.error(\"Failed to retrieve user:\", err.message);\n * }\n *\n * @see https://instantdb.com/docs/backend#retrieve-a-user\n */\n getUser = async (\n params: { email: string } | { id: string } | { refresh_token: string },\n ): Promise<Omit<User, 'refresh_token'>> => {\n const qs = Object.entries(params)\n .map(([k, v]) => `${k}=${encodeURIComponent(v)}`)\n .join('&');\n\n const response: { user: User } = await jsonFetch(\n `${this.config.apiURI}/admin/users?${qs}`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return response.user;\n };\n\n /**\n * Deletes an app user by id, email, or refresh token.\n *\n * NB: This _only_ deletes the user; it does not delete all user data.\n * You will need to handle this manually.\n *\n * @example\n * try {\n * const deletedUser = await db.auth.deleteUser({ email })\n * console.log(\"Deleted user:\", deletedUser)\n * } catch (err) {\n * console.error(\"Failed to delete user:\", err.message);\n * }\n *\n * @see https://instantdb.com/docs/backend#delete-a-user\n */\n deleteUser = async (\n params: { email: string } | { id: string } | { refresh_token: string },\n ): Promise<User> => {\n const qs = Object.entries(params).map(([k, v]) => `${k}=${v}`);\n const response: { deleted: User } = await jsonFetch(\n `${this.config.apiURI}/admin/users?${qs}`,\n {\n method: 'DELETE',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return response.deleted;\n };\n\n /**\n * Signs out the user with the given email.\n * This invalidates any tokens associated with the user.\n * If the user is not found, an error will be thrown.\n *\n * @example\n * try {\n * await auth.signOut({ email: \"alyssa_p_hacker@instantdb.com\" });\n * console.log(\"Successfully signed out\");\n * } catch (err) {\n * console.error(\"Sign out failed:\", err.message);\n * }\n *\n * @see https://instantdb.com/docs/backend#sign-out\n */\n async signOut(\n params: { email: string } | { id: string } | { refresh_token: string },\n ): Promise<void>;\n\n /**\n * @deprecated Passing an email string directly is deprecated.\n * Use an object with the `email` key instead.\n *\n * @example\n * // Before\n * auth.signOut(email)\n *\n * // After\n * auth.signOut({ email })\n */\n async signOut(email: string): Promise<void>;\n\n async signOut(\n input:\n | string\n | { email: string }\n | { id: string }\n | { refresh_token: string },\n ): Promise<void> {\n // If input is a string, we assume it's an email.\n // This is because of backwards compatibility: we used to only\n // accept email strings. Eventually we can remove this\n const params = typeof input === 'string' ? { email: input } : input;\n const config = this.config;\n await jsonFetch(`${config.apiURI}/admin/sign_out`, {\n method: 'POST',\n headers: authorizedHeaders(config),\n body: JSON.stringify(params),\n });\n }\n}\n\ntype StorageFile = {\n key: string;\n name: string;\n size: number;\n etag: string;\n last_modified: number;\n};\n\ntype DeleteManyFileResponse = {\n data: {\n ids: string[] | null;\n };\n};\n\nconst isNodeReadable = (v: any): v is Readable =>\n v &&\n typeof v === 'object' &&\n typeof v.pipe === 'function' &&\n typeof v.read === 'function';\n\nconst isWebReadable = (v: any): v is ReadableStream =>\n v && typeof v.getReader === 'function';\n\n/**\n * Functions to manage file storage.\n */\nclass Storage {\n config: FilledConfig;\n impersonationOpts?: ImpersonationOpts;\n\n constructor(config: FilledConfig, impersonationOpts?: ImpersonationOpts) {\n this.config = config;\n this.impersonationOpts = impersonationOpts;\n }\n\n /**\n * Uploads file at the provided path. Accepts a Buffer or a Readable stream.\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * const buffer = fs.readFileSync('demo.png');\n * const isSuccess = await db.storage.uploadFile('photos/demo.png', buffer);\n */\n uploadFile = async (\n path: string,\n file: Buffer | Readable | ReadableStream | Uint8Array,\n metadata: FileOpts = {},\n ): Promise<UploadFileResponse> => {\n const headers = {\n ...authorizedHeaders(this.config, this.impersonationOpts),\n path,\n };\n if (metadata.contentDisposition) {\n headers['content-disposition'] = metadata.contentDisposition;\n }\n\n // headers.content-type will become \"undefined\" (string)\n // if not removed from the object\n delete headers['content-type'];\n\n if (metadata.contentType) {\n headers['content-type'] = metadata.contentType;\n }\n\n let duplex: 'half' | undefined;\n if (isNodeReadable(file)) {\n duplex = 'half'; // one-way stream\n }\n if (isNodeReadable(file) || isWebReadable(file)) {\n if (!metadata.fileSize) {\n throw new Error(\n 'fileSize is required in metadata when uploading streams',\n );\n }\n headers['content-length'] = metadata.fileSize.toString();\n }\n\n let options = {\n method: 'PUT',\n headers,\n body: file as unknown as BodyInit,\n ...(duplex && { duplex }),\n };\n\n return jsonFetch(`${this.config.apiURI}/admin/storage/upload`, options);\n };\n\n /**\n * Deletes a file by its path name (e.g. \"photos/demo.png\").\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * await db.storage.delete(\"photos/demo.png\");\n */\n delete = async (pathname: string): Promise<DeleteFileResponse> => {\n return jsonFetch(\n `${this.config.apiURI}/admin/storage/files?filename=${encodeURIComponent(\n pathname,\n )}`,\n {\n method: 'DELETE',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n },\n );\n };\n\n /**\n * Deletes multiple files by their path names (e.g. \"photos/demo.png\", \"essays/demo.txt\").\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * await db.storage.deleteMany([\"images/1.png\", \"images/2.png\", \"images/3.png\"]);\n */\n deleteMany = async (pathnames: string[]): Promise<DeleteManyFileResponse> => {\n return jsonFetch(`${this.config.apiURI}/admin/storage/files/delete`, {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({ filenames: pathnames }),\n });\n };\n\n /**\n * @deprecated. This method will be removed in the future. Use `uploadFile`\n * instead\n */\n upload = async (\n pathname: string,\n file: Buffer,\n metadata: FileOpts = {},\n ): Promise<boolean> => {\n const { data: presignedUrl } = await jsonFetch(\n `${this.config.apiURI}/admin/storage/signed-upload-url`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({\n app_id: this.config.appId,\n filename: pathname,\n }),\n },\n );\n const headers = {};\n const contentType = metadata.contentType;\n if (contentType) {\n headers['Content-Type'] = contentType;\n }\n const { ok } = await fetch(presignedUrl, {\n method: 'PUT',\n body: file as unknown as BodyInit,\n headers,\n });\n\n return ok;\n };\n\n /**\n * @deprecated. This method will be removed in the future. Use `query` instead\n * @example\n * const files = await db.query({ $files: {}})\n */\n list = async (): Promise<StorageFile[]> => {\n const { data } = await jsonFetch(\n `${this.config.apiURI}/admin/storage/files`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return data;\n };\n\n /**\n * @deprecated. getDownloadUrl will be removed in the future.\n * Use `query` instead to query and fetch for valid urls\n *\n * db.useQuery({\n * $files: {\n * $: {\n * where: {\n * path: \"moop.png\"\n * }\n * }\n * }\n * })\n */\n getDownloadUrl = async (pathname: string): Promise<string> => {\n const { data } = await jsonFetch(\n `${this.config.apiURI}/admin/storage/signed-download-url?app_id=${this.config.appId}&filename=${encodeURIComponent(pathname)}`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return data;\n };\n}\n\ntype AdminQueryOpts = {\n ruleParams?: RuleParams;\n fetchOpts?: RequestInit;\n};\n\n/**\n *\n * The first step: init your application!\n *\n * Visit https://instantdb.com/dash to get your `appId` and `adminToken` :)\n *\n * @example\n * const db = init({ appId: \"my-app-id\", adminToken: \"my-admin-token\" })\n */\nclass InstantAdminDatabase<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n Config extends InstantConfig<Schema, UseDates> = InstantConfig<\n Schema,\n UseDates\n >,\n> {\n config: InstantConfigFilled<Schema, UseDates>;\n auth: Auth;\n storage: Storage;\n rooms: Rooms<Schema>;\n impersonationOpts?: ImpersonationOpts;\n\n public tx = txInit<NonNullable<Schema>>();\n\n constructor(_config: Config) {\n this.config = instantConfigWithDefaults(_config);\n this.auth = new Auth(this.config);\n this.storage = new Storage(this.config, this.impersonationOpts);\n this.rooms = new Rooms<Schema>(this.config);\n }\n\n /**\n * Sometimes you want to scope queries to a specific user.\n *\n * You can provide a user's auth token, email, or impersonate a guest.\n *\n * @see https://instantdb.com/docs/backend#impersonating-users\n * @example\n * await db.asUser({email: \"stopa@instantdb.com\"}).query({ goals: {} })\n */\n asUser = (\n opts: ImpersonationOpts,\n ): InstantAdminDatabase<Schema, UseDates, Config> => {\n const newClient = new InstantAdminDatabase<Schema, UseDates, Config>({\n ...(this.config as Config),\n });\n newClient.impersonationOpts = opts;\n newClient.storage = new Storage(this.config, opts);\n return newClient;\n };\n\n /**\n * Use this to query your data!\n *\n * @see https://instantdb.com/docs/instaql\n *\n * @example\n * // fetch all goals\n * await db.query({ goals: {} })\n *\n * // goals where the title is \"Get Fit\"\n * await db.query({ goals: { $: { where: { title: \"Get Fit\" } } } })\n *\n * // all goals, _alongside_ their todos\n * await db.query({ goals: { todos: {} } })\n */\n query = <Q extends ValidQuery<Q, Schema>>(\n query: Q,\n opts: AdminQueryOpts = {},\n ): Promise<InstaQLResponse<Schema, Q, UseDates>> => {\n if (query && opts && 'ruleParams' in opts) {\n query = { $$ruleParams: opts['ruleParams'], ...query };\n }\n\n if (!this.config.disableValidation) {\n validateQuery(query, this.config.schema);\n }\n\n const fetchOpts = opts.fetchOpts || {};\n const fetchOptsHeaders = fetchOpts['headers'] || {};\n return jsonFetch(`${this.config.apiURI}/admin/query`, {\n ...fetchOpts,\n method: 'POST',\n headers: {\n ...fetchOptsHeaders,\n ...authorizedHeaders(this.config, this.impersonationOpts),\n },\n body: JSON.stringify({\n query: query,\n 'inference?': !!this.config.schema,\n }),\n });\n };\n\n /**\n * Use this to to get a live view of your data!\n *\n * @see https://www.instantdb.com/docs/backend\n *\n * @example\n * // create a subscription to a query\n * const query = { goals: { $: { where: { title: \"Get Fit\" } } } }\n * const sub = db.subscribeQuery(query);\n *\n * // iterate through the results with an async iterator\n * for await (const payload of sub) {\n * if (payload.error) {\n * console.log(payload.error);\n * // Stop the subscription\n * sub.close();\n * } else {\n * console.log(payload.data);\n * }\n * }\n *\n * // Stop the subscription\n * sub.close();\n *\n * // Create a subscription with a callback\n * const sub = db.subscribeQuery(query, (payload) => {\n * if (payload.error) {\n * console.log(payload.error);\n * // Stop the subscription\n * sub.close();\n * } else {\n * console.log(payload.data);\n * }\n * });\n */\n subscribeQuery<Q extends ValidQuery<Q, Schema>>(\n query: Q,\n cb?: SubscribeQueryCallback<Schema, Q, UseDates>,\n opts: AdminQueryOpts = {},\n ): SubscribeQueryResponse<Schema, Q, UseDates> {\n if (query && opts && 'ruleParams' in opts) {\n query = { $$ruleParams: opts['ruleParams'], ...query };\n }\n\n if (!this.config.disableValidation) {\n validateQuery(query, this.config.schema);\n }\n\n const fetchOpts = opts.fetchOpts || {};\n const fetchOptsHeaders = fetchOpts['headers'] || {};\n\n const headers: HeadersInit = {\n ...fetchOptsHeaders,\n ...authorizedHeaders(this.config, this.impersonationOpts),\n };\n\n const inference = !!this.config.schema;\n\n return subscribe(query, cb, {\n headers,\n inference,\n apiURI: this.config.apiURI,\n });\n }\n\n /**\n * Use this to write data! You can create, update, delete, and link objects\n *\n * @see https://instantdb.com/docs/instaml\n *\n * @example\n * // Create a new object in the `goals` namespace\n * const goalId = id();\n * db.transact(db.tx.goals[goalId].update({title: \"Get fit\"}))\n *\n * // Update the title\n * db.transact(db.tx.goals[goalId].update({title: \"Get super fit\"}))\n *\n * // Delete it\n * db.transact(db.tx.goals[goalId].delete())\n *\n * // Or create an association:\n * todoId = id();\n * db.transact([\n * db.tx.todos[todoId].update({ title: 'Go on a run' }),\n * db.tx.goals[goalId].link({todos: todoId}),\n * ])\n */\n transact = (\n inputChunks: TransactionChunk<any, any> | TransactionChunk<any, any>[],\n ) => {\n if (!this.config.disableValidation) {\n validateTransactions(inputChunks, this.config.schema);\n }\n return jsonFetch(`${this.config.apiURI}/admin/transact`, {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({\n steps: steps(inputChunks),\n 'throw-on-missing-attrs?': !!this.config.schema,\n }),\n });\n };\n\n /**\n * Like `query`, but returns debugging information\n * for permissions checks along with the result.\n * Useful for inspecting the values returned by the permissions checks.\n * Note, this will return debug information for *all* entities\n * that match the query's `where` clauses.\n *\n * Requires a user/guest context to be set with `asUser`,\n * since permissions checks are user-specific.\n *\n * Accepts an optional configuration object with a `rules` key.\n * The provided rules will override the rules in the database for the query.\n *\n * @see https://instantdb.com/docs/instaql\n *\n * @example\n * await db.asUser({ guest: true }).debugQuery(\n * { goals: {} },\n * { rules: { goals: { allow: { read: \"auth.id != null\" } } }\n * )\n */\n debugQuery = async <Q extends ValidQuery<Q, Schema>>(\n query: Q,\n opts?: { rules?: any; ruleParams?: { [key: string]: any } },\n ): Promise<{\n result: InstaQLResponse<Schema, Q, UseDates>;\n checkResults: DebugCheckResult[];\n }> => {\n if (query && opts && 'ruleParams' in opts) {\n query = { $$ruleParams: opts['ruleParams'], ...query };\n }\n\n const response = await jsonFetch(\n `${this.config.apiURI}/admin/query_perms_check`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({ query, 'rules-override': opts?.rules }),\n },\n );\n\n return {\n result: response.result,\n checkResults: response['check-results'],\n };\n };\n\n /**\n * Like `transact`, but does not write to the database.\n * Returns debugging information for permissions checks.\n * Useful for inspecting the values returned by the permissions checks.\n *\n * Requires a user/guest context to be set with `asUser`,\n * since permissions checks are user-specific.\n *\n * Accepts an optional configuration object with a `rules` key.\n * The provided rules will override the rules in the database for the duration of the transaction.\n *\n * @example\n * const goalId = id();\n * db.asUser({ guest: true }).debugTransact(\n * [db.tx.goals[goalId].update({title: \"Get fit\"})],\n * { rules: { goals: { allow: { update: \"auth.id != null\" } } }\n * )\n */\n debugTransact = (\n inputChunks: TransactionChunk<any, any> | TransactionChunk<any, any>[],\n opts?: { rules?: any },\n ): Promise<DebugTransactResult> => {\n return jsonFetch(`${this.config.apiURI}/admin/transact_perms_check`, {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({\n steps: steps(inputChunks),\n 'rules-override': opts?.rules,\n // @ts-expect-error because we're using a private API (for now)\n 'dangerously-commit-tx': opts?.__dangerouslyCommit,\n }),\n });\n };\n}\n\nexport {\n init,\n init_experimental,\n id,\n tx,\n lookup,\n i,\n createInstantRouteHandler,\n\n // error\n InstantAPIError,\n\n // types\n type Config,\n type ImpersonationOpts,\n type TransactionChunk,\n type DebugCheckResult,\n type InstantAdminDatabase,\n\n // core types\n type User,\n type InstaQLParams,\n type ValidQuery,\n type Query,\n\n // query types\n type QueryResponse,\n type InstaQLResponse,\n type InstantQuery,\n type InstantUnknownSchemaDef,\n type InstantQueryResult,\n type InstantSchema,\n type InstantSchemaDatabase,\n type IInstantDatabase,\n type InstantObject,\n type InstantEntity,\n type BackwardsCompatibleSchema,\n type InstaQLFields,\n type SubscribeQueryCallback,\n type SubscribeQueryResponse,\n type SubscribeQueryPayload,\n type SubscriptionReadyState,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type RoomsOf,\n type PresenceOf,\n type RoomsDef,\n type RoomHandle,\n type ValueTypes,\n type InstantSchemaDef,\n type InstantUnknownSchema,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type InstantRules,\n type CreateParams,\n type UpdateParams,\n type LinkParams,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n type DeleteManyFileResponse,\n\n // error types\n type InstantIssue,\n};\n"]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
|
-
import { tx, lookup, i, id, InstantAPIError, type InstantIssue, type TransactionChunk, type AuthToken, type User, type Query, type QueryResponse, type InstaQLResponse, type InstaQLParams, type ValidQuery, type InstaQLFields, type InstantQuery, type InstantQueryResult, type InstantSchema, type InstantSchemaDatabase, type InstantObject, type InstantEntity, type BackwardsCompatibleSchema, type IInstantDatabase, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type LinkAttrDef, type LinkDef, type InstantUnknownSchemaDef, type LinksDef, type RoomsOf, type RoomsDef, type PresenceOf, type RoomHandle, type ResolveAttrs, type ValueTypes, type InstantSchemaDef, type InstantUnknownSchema, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type InstantRules, type UpdateParams, type CreateParams, type LinkParams, type RuleParams, type FileOpts, type UploadFileResponse, type DeleteFileResponse } from '@instantdb/core';
|
|
2
|
+
import { tx, lookup, i, id, InstantAPIError, type InstantIssue, type TransactionChunk, type AuthToken, type User, type Query, type QueryResponse, type InstaQLResponse, type InstaQLParams, type ValidQuery, type InstaQLFields, type InstantQuery, type InstantQueryResult, type InstantSchema, type InstantSchemaDatabase, type InstantObject, type InstantEntity, type BackwardsCompatibleSchema, type IInstantDatabase, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type LinkAttrDef, type LinkDef, type InstantUnknownSchemaDef, type LinksDef, type RoomsOf, type RoomsDef, type PresenceOf, type RoomHandle, type ResolveAttrs, type ValueTypes, type InstantSchemaDef, type InstantUnknownSchema, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type InstantRules, type UpdateParams, type CreateParams, type LinkParams, type RuleParams, type FileOpts, type UploadFileResponse, type DeleteFileResponse, createInstantRouteHandler } from '@instantdb/core';
|
|
3
3
|
import { SubscribeQueryCallback, SubscribeQueryResponse, SubscribeQueryPayload, SubscriptionReadyState } from './subscribe.ts';
|
|
4
4
|
type DebugCheckResult = {
|
|
5
5
|
/** The ID of the record. */
|
|
@@ -499,5 +499,5 @@ declare class InstantAdminDatabase<Schema extends InstantSchemaDef<any, any, any
|
|
|
499
499
|
rules?: any;
|
|
500
500
|
}) => Promise<DebugTransactResult>;
|
|
501
501
|
}
|
|
502
|
-
export { init, init_experimental, id, tx, lookup, i, InstantAPIError, type Config, type ImpersonationOpts, type TransactionChunk, type DebugCheckResult, type InstantAdminDatabase, type User, type InstaQLParams, type ValidQuery, type Query, type QueryResponse, type InstaQLResponse, type InstantQuery, type InstantUnknownSchemaDef, type InstantQueryResult, type InstantSchema, type InstantSchemaDatabase, type IInstantDatabase, type InstantObject, type InstantEntity, type BackwardsCompatibleSchema, type InstaQLFields, type SubscribeQueryCallback, type SubscribeQueryResponse, type SubscribeQueryPayload, type SubscriptionReadyState, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type RoomsOf, type PresenceOf, type RoomsDef, type RoomHandle, type ValueTypes, type InstantSchemaDef, type InstantUnknownSchema, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type InstantRules, type CreateParams, type UpdateParams, type LinkParams, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type DeleteManyFileResponse, type InstantIssue, };
|
|
502
|
+
export { init, init_experimental, id, tx, lookup, i, createInstantRouteHandler, InstantAPIError, type Config, type ImpersonationOpts, type TransactionChunk, type DebugCheckResult, type InstantAdminDatabase, type User, type InstaQLParams, type ValidQuery, type Query, type QueryResponse, type InstaQLResponse, type InstantQuery, type InstantUnknownSchemaDef, type InstantQueryResult, type InstantSchema, type InstantSchemaDatabase, type IInstantDatabase, type InstantObject, type InstantEntity, type BackwardsCompatibleSchema, type InstaQLFields, type SubscribeQueryCallback, type SubscribeQueryResponse, type SubscribeQueryPayload, type SubscriptionReadyState, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type RoomsOf, type PresenceOf, type RoomsDef, type RoomHandle, type ValueTypes, type InstantSchemaDef, type InstantUnknownSchema, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type InstantRules, type CreateParams, type UpdateParams, type LinkParams, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type DeleteManyFileResponse, type InstantIssue, };
|
|
503
503
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EACL,EAAE,EACF,MAAM,EAEN,CAAC,EACD,EAAE,EAGF,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EACL,EAAE,EACF,MAAM,EAEN,CAAC,EACD,EAAE,EAGF,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAGd,KAAK,IAAI,EACT,KAAK,KAAK,EAGV,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EAGrB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,uBAAuB,EAC5B,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KA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eAAe,EAGf,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAGzB,KAAK,IAAI,EACT,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,KAAK,EAGV,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAG3B,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,UAAU,EAGf,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAG3B,KAAK,YAAY,GAClB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { tx, lookup, getOps, i, id, txInit, version as coreVersion, InstantAPIError, validateQuery, validateTransactions, } from '@instantdb/core';
|
|
10
|
+
import { tx, lookup, getOps, i, id, txInit, version as coreVersion, InstantAPIError, validateQuery, validateTransactions, createInstantRouteHandler, } from '@instantdb/core';
|
|
11
11
|
import version from "./version.js";
|
|
12
12
|
import { subscribe, } from "./subscribe.js";
|
|
13
13
|
function configWithDefaults(config) {
|
|
@@ -683,7 +683,7 @@ class InstantAdminDatabase {
|
|
|
683
683
|
});
|
|
684
684
|
}
|
|
685
685
|
}
|
|
686
|
-
export { init, init_experimental, id, tx, lookup, i,
|
|
686
|
+
export { init, init_experimental, id, tx, lookup, i, createInstantRouteHandler,
|
|
687
687
|
// error
|
|
688
688
|
InstantAPIError, };
|
|
689
689
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EACL,EAAE,EACF,MAAM,EACN,MAAM,EACN,CAAC,EACD,EAAE,EACF,MAAM,EACN,OAAO,IAAI,WAAW,EACtB,eAAe,EA4Df,aAAa,EACb,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EACL,SAAS,GAKV,MAAM,gBAAgB,CAAC;AAkDxB,SAAS,kBAAkB,CAAC,MAAc;IACxC,MAAM,aAAa,GAAG;QACpB,MAAM,EAAE,2BAA2B;KACpC,CAAC;IACF,MAAM,CAAC,mCAAQ,aAAa,GAAK,MAAM,CAAE,CAAC;IAC1C,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,yBAAyB,CAIhC,MAAuC;IAEvC,MAAM,aAAa,GAAG;QACpB,MAAM,EAAE,2BAA2B;KACpC,CAAC;IACF,MAAM,CAAC,mCAAQ,aAAa,GAAK,MAAM,CAAE,C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AC,MAAM,CAAC;QAEvC,OAAO,SAAS,CAAC,KAAK,EAAE,EAAE,EAAE;YAC1B,OAAO;YACP,SAAS;YACT,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;SAC3B,CAAC,CAAC;IACL,CAAC;CAyHF;AAED,OAAO,EACL,IAAI,EACJ,iBAAiB,EACjB,EAAE,EACF,EAAE,EACF,MAAM,EACN,CAAC;AAED,QAAQ;AACR,eAAe,GAoEhB,CAAC","sourcesContent":["import type { Readable } from 'node:stream';\n\nimport {\n tx,\n lookup,\n getOps,\n i,\n id,\n txInit,\n version as coreVersion,\n InstantAPIError,\n type InstantIssue,\n type TransactionChunk,\n type AuthToken,\n type Exactly,\n\n // core types\n type User,\n type Query,\n\n // query types\n type QueryResponse,\n type InstaQLResponse,\n type InstaQLParams,\n type ValidQuery,\n type InstaQLFields,\n type InstantQuery,\n type InstantQueryResult,\n type InstantSchema,\n type InstantSchemaDatabase,\n type InstantObject,\n type InstantEntity,\n type BackwardsCompatibleSchema,\n type IInstantDatabase,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type LinkAttrDef,\n type LinkDef,\n type InstantUnknownSchemaDef,\n type LinksDef,\n type RoomsOf,\n type RoomsDef,\n type PresenceOf,\n type RoomHandle,\n type ResolveAttrs,\n type ValueTypes,\n type InstantSchemaDef,\n type InstantUnknownSchema,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type InstantRules,\n type UpdateParams,\n type CreateParams,\n type LinkParams,\n type RuleParams,\n type TopicsOf,\n type TopicOf,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n validateQuery,\n validateTransactions,\n} from '@instantdb/core';\n\nimport version from './version.ts';\n\nimport {\n subscribe,\n SubscribeQueryCallback,\n SubscribeQueryResponse,\n SubscribeQueryPayload,\n SubscriptionReadyState,\n} from './subscribe.ts';\n\ntype DebugCheckResult = {\n /** The ID of the record. */\n id: string;\n /** The namespace/table of the record. */\n entity: string;\n /** The value of the record. */\n record: Record<string, any>;\n /** The result of evaluating the corresponding permissions rule for a record. */\n check: any;\n};\n\ntype Config = {\n appId: string;\n adminToken?: string;\n apiURI?: string;\n useDateObjects?: boolean;\n disableValidation?: boolean;\n};\n\nexport type InstantConfig<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n> = {\n appId: string;\n adminToken?: string;\n apiURI?: string;\n schema?: Schema;\n useDateObjects: UseDates;\n disableValidation?: boolean;\n};\n\ntype InstantConfigFilled<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean,\n> = InstantConfig<Schema, UseDates> & { apiURI: string };\n\ntype FilledConfig = Config & { apiURI: string };\n\ntype ImpersonationOpts =\n | { email: string }\n | { token: AuthToken }\n | { guest: boolean };\n\ntype DebugTransactResult = {\n 'tx-id': number;\n 'all-checks-ok?': boolean;\n};\n\nfunction configWithDefaults(config: Config): FilledConfig {\n const defaultConfig = {\n apiURI: 'https://api.instantdb.com',\n };\n const r = { ...defaultConfig, ...config };\n return r;\n}\n\nfunction instantConfigWithDefaults<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean,\n>(\n config: InstantConfig<Schema, UseDates>,\n): InstantConfigFilled<Schema, UseDates> {\n const defaultConfig = {\n apiURI: 'https://api.instantdb.com',\n };\n const r = { ...defaultConfig, ...config };\n return r;\n}\n\nfunction withImpersonation(\n headers: { [key: string]: string },\n opts: ImpersonationOpts,\n) {\n if ('email' in opts) {\n headers['as-email'] = opts.email;\n } else if ('token' in opts) {\n headers['as-token'] = opts.token;\n } else if ('guest' in opts) {\n headers['as-guest'] = 'true';\n }\n return headers;\n}\n\nfunction validateConfigAndImpersonation(\n config: FilledConfig,\n impersonationOpts: ImpersonationOpts | undefined,\n) {\n if (\n impersonationOpts &&\n ('token' in impersonationOpts || 'guest' in impersonationOpts)\n ) {\n // adminToken is not required for `token` or `guest` impersonation\n return;\n }\n if (config.adminToken) {\n // An adminToken is provided.\n return;\n }\n if (impersonationOpts && 'email' in impersonationOpts) {\n throw new Error(\n 'Admin token required. To impersonate users with an email you must pass `adminToken` to `init`.',\n );\n }\n throw new Error(\n 'Admin token required. To run this operation pass `adminToken` to `init`, or use `db.asUser`.',\n );\n}\n\nfunction authorizedHeaders(\n config: FilledConfig,\n impersonationOpts?: ImpersonationOpts,\n): Record<string, string> {\n validateConfigAndImpersonation(config, impersonationOpts);\n\n const { adminToken, appId } = config;\n const headers: Record<string, string> = {\n 'content-type': 'application/json',\n 'app-id': appId,\n };\n\n if (adminToken) {\n headers.authorization = `Bearer ${adminToken}`;\n }\n\n return impersonationOpts\n ? withImpersonation(headers, impersonationOpts)\n : headers;\n}\n\n// NextJS 13 and 14 cache fetch requests by default.\n//\n// Since adminDB.query uses fetch, this means that it would also cache by default.\n//\n// We don't want this behavior. `adminDB.query` should return the latest result by default.\n//\n// To get around this, we set an explicit `cache` header for NextJS 13 and 14.\n// This is no longer needed in NextJS 15 onwards, as the default is `no-store` again.\n// Once NextJS 13 and 14 are no longer common, we can remove this code.\nfunction isNextJSVersionThatCachesFetchByDefault() {\n return (\n // NextJS 13 onwards added a `__nextPatched` property to the fetch function\n fetch['__nextPatched'] &&\n // NextJS 15 onwards _also_ added a global `next-patch` symbol.\n !globalThis[Symbol.for('next-patch')]\n );\n}\n\nfunction getDefaultFetchOpts(): RequestInit {\n return isNextJSVersionThatCachesFetchByDefault() ? { cache: 'no-store' } : {};\n}\n\nasync function jsonReject(rejectFn, res) {\n const body = await res.text();\n try {\n const json = JSON.parse(body);\n return rejectFn(new InstantAPIError({ status: res.status, body: json }));\n } catch (_e) {\n return rejectFn(\n new InstantAPIError({\n status: res.status,\n body: { type: undefined, message: body },\n }),\n );\n }\n}\n\nasync function jsonFetch(\n input: RequestInfo,\n init: RequestInit | undefined,\n): Promise<any> {\n const defaultFetchOpts = getDefaultFetchOpts();\n const headers = {\n ...(init?.headers || {}),\n 'Instant-Admin-Version': version,\n 'Instant-Core-Version': coreVersion,\n };\n const res = await fetch(input, { ...defaultFetchOpts, ...init, headers });\n if (res.status === 200) {\n const json = await res.json();\n return Promise.resolve(json);\n }\n\n return jsonReject((x) => Promise.reject(x), res);\n}\n\n/**\n *\n * The first step: init your application!\n *\n * Visit https://instantdb.com/dash to get your `appId` :)\n *\n * @example\n * import { init } from \"@instantdb/admin\"\n *\n * const db = init({\n * appId: process.env.INSTANT_APP_ID!,\n * adminToken: process.env.INSTANT_APP_ADMIN_TOKEN\n * })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@instantdb/admin\"\n * import schema from \"\"../instant.schema.ts\";\n *\n * const db = init({\n * appId: process.env.INSTANT_APP_ID!,\n * adminToken: process.env.INSTANT_APP_ADMIN_TOKEN,\n * schema,\n * })\n * // To learn more: https://instantdb.com/docs/modeling-data\n */\nfunction init<\n Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema,\n UseDates extends boolean = false,\n>(\n // Allows config with missing `useDateObjects`, but keeps `UseDates`\n // as a non-nullable in the InstantConfig type.\n config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {\n useDateObjects?: UseDates;\n },\n): InstantAdminDatabase<Schema, UseDates, InstantConfig<Schema, UseDates>> {\n const configStrict = {\n ...config,\n appId: config.appId?.trim(),\n adminToken: config.adminToken?.trim(),\n useDateObjects: (config.useDateObjects ?? false) as UseDates,\n };\n\n return new InstantAdminDatabase<\n Schema,\n UseDates,\n InstantConfig<Schema, UseDates>\n >(configStrict);\n}\n\n/**\n * @deprecated\n * `init_experimental` is deprecated. You can replace it with `init`.\n *\n * @example\n *\n * // Before\n * import { init_experimental } from \"@instantdb/admin\"\n * const db = init_experimental({ ... });\n *\n * // After\n * import { init } from \"@instantdb/admin\"\n * const db = init({ ... });\n */\nconst init_experimental = init;\n\nfunction steps(inputChunks) {\n const chunks = Array.isArray(inputChunks) ? inputChunks : [inputChunks];\n return chunks.flatMap(getOps);\n}\n\ntype PresenceResult<Data> = {\n [peerId: string]: { data: Data; 'peer-id': string; user: User | null };\n};\n\nclass Rooms<Schema extends InstantSchemaDef<any, any, any>> {\n config: FilledConfig;\n\n constructor(config: FilledConfig) {\n this.config = config;\n }\n\n async getPresence<RoomType extends keyof RoomsOf<Schema>>(\n roomType: RoomType,\n roomId: string,\n ): Promise<PresenceResult<PresenceOf<Schema, RoomType>>> {\n const res = await jsonFetch(\n `${this.config.apiURI}/admin/rooms/presence?room-type=${String(roomType)}&room-id=${roomId}`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return res.sessions || {};\n }\n}\n\nclass Auth {\n config: FilledConfig;\n\n constructor(config: FilledConfig) {\n this.config = config;\n this.createToken = this.createToken.bind(this);\n }\n\n /**\n * Generates a magic code for the user with the given email.\n * This is useful if you want to use your own email provider\n * to send magic codes.\n *\n * @example\n * // Generate a magic code\n * const { code } = await db.auth.generateMagicCode({ email })\n * // Send the magic code to the user with your own email provider\n * await customEmailProvider.sendMagicCode(email, code)\n *\n * @see https://instantdb.com/docs/backend#custom-magic-codes\n */\n generateMagicCode = async (email: string): Promise<{ code: string }> => {\n return jsonFetch(`${this.config.apiURI}/admin/magic_code`, {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({ email }),\n });\n };\n\n /**\n * Sends a magic code to the user with the given email.\n * This uses Instant's built-in email provider.\n *\n * @example\n * // Send an email to user with magic code\n * await db.auth.sendMagicCode({ email })\n *\n * @see https://instantdb.com/docs/backend#custom-magic-codes\n */\n sendMagicCode = async (email: string): Promise<{ code: string }> => {\n return jsonFetch(`${this.config.apiURI}/admin/send_magic_code`, {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({ email }),\n });\n };\n\n /**\n * Verifies a magic code for the user with the given email.\n *\n * @example\n * const user = await db.auth.verifyMagicCode({ email, code })\n * console.log(\"Verified user:\", user)\n *\n * @see https://instantdb.com/docs/backend#custom-magic-codes\n */\n verifyMagicCode = async (email: string, code: string): Promise<User> => {\n const { user } = await jsonFetch(\n `${this.config.apiURI}/admin/verify_magic_code`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({ email, code }),\n },\n );\n return user;\n };\n\n /**\n * Creates a login token for the user with the given email.\n * If that user does not exist, we create one.\n *\n * This is often useful for writing custom auth flows.\n *\n * @example\n * app.post('/custom_sign_in', async (req, res) => {\n * // ... your custom flow for users\n * const token = await db.auth.createToken({ email })\n * return res.status(200).send({ token })\n * })\n *\n * @see https://instantdb.com/docs/backend#custom-auth\n */\n createToken(email: { email: string } | { id: string }): Promise<AuthToken>;\n\n /**\n *\n * @deprecated Passing an email string directly is deprecated.\n *\n * Use an object with the `email` key instead.\n *\n * @example\n * // Before\n * const token = await auth.createToken(email)\n * // After\n * const token = await auth.createToken({ email })\n */\n createToken(email: string): Promise<AuthToken>;\n\n async createToken(\n input: string | { email: string } | { id: string },\n ): Promise<AuthToken> {\n const body = typeof input === 'string' ? { email: input } : input;\n const ret: { user: { refresh_token: string } } = await jsonFetch(\n `${this.config.apiURI}/admin/refresh_tokens`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify(body),\n },\n );\n return ret.user.refresh_token;\n }\n\n /**\n * Verifies a given token and returns the associated user.\n *\n * This is often useful for writing custom endpoints, where you need\n * to authenticate users.\n *\n * @example\n * app.post('/custom_endpoint', async (req, res) => {\n * const user = await db.auth.verifyToken(req.headers['token'])\n * if (!user) {\n * return res.status(401).send('Uh oh, you are not authenticated')\n * }\n * // ...\n * })\n * @see https://instantdb.com/docs/backend#custom-endpoints\n */\n verifyToken = async (token: AuthToken): Promise<User> => {\n const res = await jsonFetch(\n `${this.config.apiURI}/runtime/auth/verify_refresh_token`,\n {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n 'app-id': this.config.appId,\n 'refresh-token': token,\n }),\n },\n );\n return res.user;\n };\n\n /**\n * Retrieves an app user by id, email, or refresh token.\n *\n * @example\n * try {\n * const user = await db.auth.getUser({ email })\n * console.log(\"Found user:\", user)\n * } catch (err) {\n * console.error(\"Failed to retrieve user:\", err.message);\n * }\n *\n * @see https://instantdb.com/docs/backend#retrieve-a-user\n */\n getUser = async (\n params: { email: string } | { id: string } | { refresh_token: string },\n ): Promise<Omit<User, 'refresh_token'>> => {\n const qs = Object.entries(params)\n .map(([k, v]) => `${k}=${encodeURIComponent(v)}`)\n .join('&');\n\n const response: { user: User } = await jsonFetch(\n `${this.config.apiURI}/admin/users?${qs}`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return response.user;\n };\n\n /**\n * Deletes an app user by id, email, or refresh token.\n *\n * NB: This _only_ deletes the user; it does not delete all user data.\n * You will need to handle this manually.\n *\n * @example\n * try {\n * const deletedUser = await db.auth.deleteUser({ email })\n * console.log(\"Deleted user:\", deletedUser)\n * } catch (err) {\n * console.error(\"Failed to delete user:\", err.message);\n * }\n *\n * @see https://instantdb.com/docs/backend#delete-a-user\n */\n deleteUser = async (\n params: { email: string } | { id: string } | { refresh_token: string },\n ): Promise<User> => {\n const qs = Object.entries(params).map(([k, v]) => `${k}=${v}`);\n const response: { deleted: User } = await jsonFetch(\n `${this.config.apiURI}/admin/users?${qs}`,\n {\n method: 'DELETE',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return response.deleted;\n };\n\n /**\n * Signs out the user with the given email.\n * This invalidates any tokens associated with the user.\n * If the user is not found, an error will be thrown.\n *\n * @example\n * try {\n * await auth.signOut({ email: \"alyssa_p_hacker@instantdb.com\" });\n * console.log(\"Successfully signed out\");\n * } catch (err) {\n * console.error(\"Sign out failed:\", err.message);\n * }\n *\n * @see https://instantdb.com/docs/backend#sign-out\n */\n async signOut(\n params: { email: string } | { id: string } | { refresh_token: string },\n ): Promise<void>;\n\n /**\n * @deprecated Passing an email string directly is deprecated.\n * Use an object with the `email` key instead.\n *\n * @example\n * // Before\n * auth.signOut(email)\n *\n * // After\n * auth.signOut({ email })\n */\n async signOut(email: string): Promise<void>;\n\n async signOut(\n input:\n | string\n | { email: string }\n | { id: string }\n | { refresh_token: string },\n ): Promise<void> {\n // If input is a string, we assume it's an email.\n // This is because of backwards compatibility: we used to only\n // accept email strings. Eventually we can remove this\n const params = typeof input === 'string' ? { email: input } : input;\n const config = this.config;\n await jsonFetch(`${config.apiURI}/admin/sign_out`, {\n method: 'POST',\n headers: authorizedHeaders(config),\n body: JSON.stringify(params),\n });\n }\n}\n\ntype StorageFile = {\n key: string;\n name: string;\n size: number;\n etag: string;\n last_modified: number;\n};\n\ntype DeleteManyFileResponse = {\n data: {\n ids: string[] | null;\n };\n};\n\nconst isNodeReadable = (v: any): v is Readable =>\n v &&\n typeof v === 'object' &&\n typeof v.pipe === 'function' &&\n typeof v.read === 'function';\n\nconst isWebReadable = (v: any): v is ReadableStream =>\n v && typeof v.getReader === 'function';\n\n/**\n * Functions to manage file storage.\n */\nclass Storage {\n config: FilledConfig;\n impersonationOpts?: ImpersonationOpts;\n\n constructor(config: FilledConfig, impersonationOpts?: ImpersonationOpts) {\n this.config = config;\n this.impersonationOpts = impersonationOpts;\n }\n\n /**\n * Uploads file at the provided path. Accepts a Buffer or a Readable stream.\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * const buffer = fs.readFileSync('demo.png');\n * const isSuccess = await db.storage.uploadFile('photos/demo.png', buffer);\n */\n uploadFile = async (\n path: string,\n file: Buffer | Readable | ReadableStream | Uint8Array,\n metadata: FileOpts = {},\n ): Promise<UploadFileResponse> => {\n const headers = {\n ...authorizedHeaders(this.config, this.impersonationOpts),\n path,\n };\n if (metadata.contentDisposition) {\n headers['content-disposition'] = metadata.contentDisposition;\n }\n\n // headers.content-type will become \"undefined\" (string)\n // if not removed from the object\n delete headers['content-type'];\n\n if (metadata.contentType) {\n headers['content-type'] = metadata.contentType;\n }\n\n let duplex: 'half' | undefined;\n if (isNodeReadable(file)) {\n duplex = 'half'; // one-way stream\n }\n if (isNodeReadable(file) || isWebReadable(file)) {\n if (!metadata.fileSize) {\n throw new Error(\n 'fileSize is required in metadata when uploading streams',\n );\n }\n headers['content-length'] = metadata.fileSize.toString();\n }\n\n let options = {\n method: 'PUT',\n headers,\n body: file as unknown as BodyInit,\n ...(duplex && { duplex }),\n };\n\n return jsonFetch(`${this.config.apiURI}/admin/storage/upload`, options);\n };\n\n /**\n * Deletes a file by its path name (e.g. \"photos/demo.png\").\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * await db.storage.delete(\"photos/demo.png\");\n */\n delete = async (pathname: string): Promise<DeleteFileResponse> => {\n return jsonFetch(\n `${this.config.apiURI}/admin/storage/files?filename=${encodeURIComponent(\n pathname,\n )}`,\n {\n method: 'DELETE',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n },\n );\n };\n\n /**\n * Deletes multiple files by their path names (e.g. \"photos/demo.png\", \"essays/demo.txt\").\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * await db.storage.deleteMany([\"images/1.png\", \"images/2.png\", \"images/3.png\"]);\n */\n deleteMany = async (pathnames: string[]): Promise<DeleteManyFileResponse> => {\n return jsonFetch(`${this.config.apiURI}/admin/storage/files/delete`, {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({ filenames: pathnames }),\n });\n };\n\n /**\n * @deprecated. This method will be removed in the future. Use `uploadFile`\n * instead\n */\n upload = async (\n pathname: string,\n file: Buffer,\n metadata: FileOpts = {},\n ): Promise<boolean> => {\n const { data: presignedUrl } = await jsonFetch(\n `${this.config.apiURI}/admin/storage/signed-upload-url`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({\n app_id: this.config.appId,\n filename: pathname,\n }),\n },\n );\n const headers = {};\n const contentType = metadata.contentType;\n if (contentType) {\n headers['Content-Type'] = contentType;\n }\n const { ok } = await fetch(presignedUrl, {\n method: 'PUT',\n body: file as unknown as BodyInit,\n headers,\n });\n\n return ok;\n };\n\n /**\n * @deprecated. This method will be removed in the future. Use `query` instead\n * @example\n * const files = await db.query({ $files: {}})\n */\n list = async (): Promise<StorageFile[]> => {\n const { data } = await jsonFetch(\n `${this.config.apiURI}/admin/storage/files`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return data;\n };\n\n /**\n * @deprecated. getDownloadUrl will be removed in the future.\n * Use `query` instead to query and fetch for valid urls\n *\n * db.useQuery({\n * $files: {\n * $: {\n * where: {\n * path: \"moop.png\"\n * }\n * }\n * }\n * })\n */\n getDownloadUrl = async (pathname: string): Promise<string> => {\n const { data } = await jsonFetch(\n `${this.config.apiURI}/admin/storage/signed-download-url?app_id=${this.config.appId}&filename=${encodeURIComponent(pathname)}`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return data;\n };\n}\n\ntype AdminQueryOpts = {\n ruleParams?: RuleParams;\n fetchOpts?: RequestInit;\n};\n\n/**\n *\n * The first step: init your application!\n *\n * Visit https://instantdb.com/dash to get your `appId` and `adminToken` :)\n *\n * @example\n * const db = init({ appId: \"my-app-id\", adminToken: \"my-admin-token\" })\n */\nclass InstantAdminDatabase<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n Config extends InstantConfig<Schema, UseDates> = InstantConfig<\n Schema,\n UseDates\n >,\n> {\n config: InstantConfigFilled<Schema, UseDates>;\n auth: Auth;\n storage: Storage;\n rooms: Rooms<Schema>;\n impersonationOpts?: ImpersonationOpts;\n\n public tx = txInit<NonNullable<Schema>>();\n\n constructor(_config: Config) {\n this.config = instantConfigWithDefaults(_config);\n this.auth = new Auth(this.config);\n this.storage = new Storage(this.config, this.impersonationOpts);\n this.rooms = new Rooms<Schema>(this.config);\n }\n\n /**\n * Sometimes you want to scope queries to a specific user.\n *\n * You can provide a user's auth token, email, or impersonate a guest.\n *\n * @see https://instantdb.com/docs/backend#impersonating-users\n * @example\n * await db.asUser({email: \"stopa@instantdb.com\"}).query({ goals: {} })\n */\n asUser = (\n opts: ImpersonationOpts,\n ): InstantAdminDatabase<Schema, UseDates, Config> => {\n const newClient = new InstantAdminDatabase<Schema, UseDates, Config>({\n ...(this.config as Config),\n });\n newClient.impersonationOpts = opts;\n newClient.storage = new Storage(this.config, opts);\n return newClient;\n };\n\n /**\n * Use this to query your data!\n *\n * @see https://instantdb.com/docs/instaql\n *\n * @example\n * // fetch all goals\n * await db.query({ goals: {} })\n *\n * // goals where the title is \"Get Fit\"\n * await db.query({ goals: { $: { where: { title: \"Get Fit\" } } } })\n *\n * // all goals, _alongside_ their todos\n * await db.query({ goals: { todos: {} } })\n */\n query = <Q extends ValidQuery<Q, Schema>>(\n query: Q,\n opts: AdminQueryOpts = {},\n ): Promise<InstaQLResponse<Schema, Q, UseDates>> => {\n if (query && opts && 'ruleParams' in opts) {\n query = { $$ruleParams: opts['ruleParams'], ...query };\n }\n\n if (!this.config.disableValidation) {\n validateQuery(query, this.config.schema);\n }\n\n const fetchOpts = opts.fetchOpts || {};\n const fetchOptsHeaders = fetchOpts['headers'] || {};\n return jsonFetch(`${this.config.apiURI}/admin/query`, {\n ...fetchOpts,\n method: 'POST',\n headers: {\n ...fetchOptsHeaders,\n ...authorizedHeaders(this.config, this.impersonationOpts),\n },\n body: JSON.stringify({\n query: query,\n 'inference?': !!this.config.schema,\n }),\n });\n };\n\n /**\n * Use this to to get a live view of your data!\n *\n * @see https://www.instantdb.com/docs/backend\n *\n * @example\n * // create a subscription to a query\n * const query = { goals: { $: { where: { title: \"Get Fit\" } } } }\n * const sub = db.subscribeQuery(query);\n *\n * // iterate through the results with an async iterator\n * for await (const payload of sub) {\n * if (payload.error) {\n * console.log(payload.error);\n * // Stop the subscription\n * sub.close();\n * } else {\n * console.log(payload.data);\n * }\n * }\n *\n * // Stop the subscription\n * sub.close();\n *\n * // Create a subscription with a callback\n * const sub = db.subscribeQuery(query, (payload) => {\n * if (payload.error) {\n * console.log(payload.error);\n * // Stop the subscription\n * sub.close();\n * } else {\n * console.log(payload.data);\n * }\n * });\n */\n subscribeQuery<Q extends ValidQuery<Q, Schema>>(\n query: Q,\n cb?: SubscribeQueryCallback<Schema, Q, UseDates>,\n opts: AdminQueryOpts = {},\n ): SubscribeQueryResponse<Schema, Q, UseDates> {\n if (query && opts && 'ruleParams' in opts) {\n query = { $$ruleParams: opts['ruleParams'], ...query };\n }\n\n if (!this.config.disableValidation) {\n validateQuery(query, this.config.schema);\n }\n\n const fetchOpts = opts.fetchOpts || {};\n const fetchOptsHeaders = fetchOpts['headers'] || {};\n\n const headers: HeadersInit = {\n ...fetchOptsHeaders,\n ...authorizedHeaders(this.config, this.impersonationOpts),\n };\n\n const inference = !!this.config.schema;\n\n return subscribe(query, cb, {\n headers,\n inference,\n apiURI: this.config.apiURI,\n });\n }\n\n /**\n * Use this to write data! You can create, update, delete, and link objects\n *\n * @see https://instantdb.com/docs/instaml\n *\n * @example\n * // Create a new object in the `goals` namespace\n * const goalId = id();\n * db.transact(db.tx.goals[goalId].update({title: \"Get fit\"}))\n *\n * // Update the title\n * db.transact(db.tx.goals[goalId].update({title: \"Get super fit\"}))\n *\n * // Delete it\n * db.transact(db.tx.goals[goalId].delete())\n *\n * // Or create an association:\n * todoId = id();\n * db.transact([\n * db.tx.todos[todoId].update({ title: 'Go on a run' }),\n * db.tx.goals[goalId].link({todos: todoId}),\n * ])\n */\n transact = (\n inputChunks: TransactionChunk<any, any> | TransactionChunk<any, any>[],\n ) => {\n if (!this.config.disableValidation) {\n validateTransactions(inputChunks, this.config.schema);\n }\n return jsonFetch(`${this.config.apiURI}/admin/transact`, {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({\n steps: steps(inputChunks),\n 'throw-on-missing-attrs?': !!this.config.schema,\n }),\n });\n };\n\n /**\n * Like `query`, but returns debugging information\n * for permissions checks along with the result.\n * Useful for inspecting the values returned by the permissions checks.\n * Note, this will return debug information for *all* entities\n * that match the query's `where` clauses.\n *\n * Requires a user/guest context to be set with `asUser`,\n * since permissions checks are user-specific.\n *\n * Accepts an optional configuration object with a `rules` key.\n * The provided rules will override the rules in the database for the query.\n *\n * @see https://instantdb.com/docs/instaql\n *\n * @example\n * await db.asUser({ guest: true }).debugQuery(\n * { goals: {} },\n * { rules: { goals: { allow: { read: \"auth.id != null\" } } }\n * )\n */\n debugQuery = async <Q extends ValidQuery<Q, Schema>>(\n query: Q,\n opts?: { rules?: any; ruleParams?: { [key: string]: any } },\n ): Promise<{\n result: InstaQLResponse<Schema, Q, UseDates>;\n checkResults: DebugCheckResult[];\n }> => {\n if (query && opts && 'ruleParams' in opts) {\n query = { $$ruleParams: opts['ruleParams'], ...query };\n }\n\n const response = await jsonFetch(\n `${this.config.apiURI}/admin/query_perms_check`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({ query, 'rules-override': opts?.rules }),\n },\n );\n\n return {\n result: response.result,\n checkResults: response['check-results'],\n };\n };\n\n /**\n * Like `transact`, but does not write to the database.\n * Returns debugging information for permissions checks.\n * Useful for inspecting the values returned by the permissions checks.\n *\n * Requires a user/guest context to be set with `asUser`,\n * since permissions checks are user-specific.\n *\n * Accepts an optional configuration object with a `rules` key.\n * The provided rules will override the rules in the database for the duration of the transaction.\n *\n * @example\n * const goalId = id();\n * db.asUser({ guest: true }).debugTransact(\n * [db.tx.goals[goalId].update({title: \"Get fit\"})],\n * { rules: { goals: { allow: { update: \"auth.id != null\" } } }\n * )\n */\n debugTransact = (\n inputChunks: TransactionChunk<any, any> | TransactionChunk<any, any>[],\n opts?: { rules?: any },\n ): Promise<DebugTransactResult> => {\n return jsonFetch(`${this.config.apiURI}/admin/transact_perms_check`, {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({\n steps: steps(inputChunks),\n 'rules-override': opts?.rules,\n // @ts-expect-error because we're using a private API (for now)\n 'dangerously-commit-tx': opts?.__dangerouslyCommit,\n }),\n });\n };\n}\n\nexport {\n init,\n init_experimental,\n id,\n tx,\n lookup,\n i,\n\n // error\n InstantAPIError,\n\n // types\n type Config,\n type ImpersonationOpts,\n type TransactionChunk,\n type DebugCheckResult,\n type InstantAdminDatabase,\n\n // core types\n type User,\n type InstaQLParams,\n type ValidQuery,\n type Query,\n\n // query types\n type QueryResponse,\n type InstaQLResponse,\n type InstantQuery,\n type InstantUnknownSchemaDef,\n type InstantQueryResult,\n type InstantSchema,\n type InstantSchemaDatabase,\n type IInstantDatabase,\n type InstantObject,\n type InstantEntity,\n type BackwardsCompatibleSchema,\n type InstaQLFields,\n type SubscribeQueryCallback,\n type SubscribeQueryResponse,\n type SubscribeQueryPayload,\n type SubscriptionReadyState,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type RoomsOf,\n type PresenceOf,\n type RoomsDef,\n type RoomHandle,\n type ValueTypes,\n type InstantSchemaDef,\n type InstantUnknownSchema,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type InstantRules,\n type CreateParams,\n type UpdateParams,\n type LinkParams,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n type DeleteManyFileResponse,\n\n // error types\n type InstantIssue,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EACL,EAAE,EACF,MAAM,EACN,MAAM,EACN,CAAC,EACD,EAAE,EACF,MAAM,EACN,OAAO,IAAI,WAAW,EACtB,eAAe,EA2Df,aAAa,EACb,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EACL,SAAS,GAKV,MAAM,gBAAgB,CAAC;AAkDxB,SAAS,kBAAkB,CAA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C,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;QACvC,MAAM,gBAAgB,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAEpD,MAAM,OAAO,mCACR,gBAAgB,GAChB,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAC1D,CAAC;QAEF,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAEvC,OAAO,SAAS,CAAC,KAAK,EAAE,EAAE,EAAE;YAC1B,OAAO;YACP,SAAS;YACT,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;SAC3B,CAAC,CAAC;IACL,CAAC;CAyHF;AAED,OAAO,EACL,IAAI,EACJ,iBAAiB,EACjB,EAAE,EACF,EAAE,EACF,MAAM,EACN,CAAC,EACD,yBAAyB;AAEzB,QAAQ;AACR,eAAe,GAoEhB,CAAC","sourcesContent":["import type { Readable } from 'node:stream';\n\nimport {\n tx,\n lookup,\n getOps,\n i,\n id,\n txInit,\n version as coreVersion,\n InstantAPIError,\n type InstantIssue,\n type TransactionChunk,\n type AuthToken,\n\n // core types\n type User,\n type Query,\n\n // query types\n type QueryResponse,\n type InstaQLResponse,\n type InstaQLParams,\n type ValidQuery,\n type InstaQLFields,\n type InstantQuery,\n type InstantQueryResult,\n type InstantSchema,\n type InstantSchemaDatabase,\n type InstantObject,\n type InstantEntity,\n type BackwardsCompatibleSchema,\n type IInstantDatabase,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type LinkAttrDef,\n type LinkDef,\n type InstantUnknownSchemaDef,\n type LinksDef,\n type RoomsOf,\n type RoomsDef,\n type PresenceOf,\n type RoomHandle,\n type ResolveAttrs,\n type ValueTypes,\n type InstantSchemaDef,\n type InstantUnknownSchema,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type InstantRules,\n type UpdateParams,\n type CreateParams,\n type LinkParams,\n type RuleParams,\n type TopicsOf,\n type TopicOf,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n validateQuery,\n validateTransactions,\n createInstantRouteHandler,\n} from '@instantdb/core';\n\nimport version from './version.ts';\n\nimport {\n subscribe,\n SubscribeQueryCallback,\n SubscribeQueryResponse,\n SubscribeQueryPayload,\n SubscriptionReadyState,\n} from './subscribe.ts';\n\ntype DebugCheckResult = {\n /** The ID of the record. */\n id: string;\n /** The namespace/table of the record. */\n entity: string;\n /** The value of the record. */\n record: Record<string, any>;\n /** The result of evaluating the corresponding permissions rule for a record. */\n check: any;\n};\n\ntype Config = {\n appId: string;\n adminToken?: string;\n apiURI?: string;\n useDateObjects?: boolean;\n disableValidation?: boolean;\n};\n\nexport type InstantConfig<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n> = {\n appId: string;\n adminToken?: string;\n apiURI?: string;\n schema?: Schema;\n useDateObjects: UseDates;\n disableValidation?: boolean;\n};\n\ntype InstantConfigFilled<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean,\n> = InstantConfig<Schema, UseDates> & { apiURI: string };\n\ntype FilledConfig = Config & { apiURI: string };\n\ntype ImpersonationOpts =\n | { email: string }\n | { token: AuthToken }\n | { guest: boolean };\n\ntype DebugTransactResult = {\n 'tx-id': number;\n 'all-checks-ok?': boolean;\n};\n\nfunction configWithDefaults(config: Config): FilledConfig {\n const defaultConfig = {\n apiURI: 'https://api.instantdb.com',\n };\n const r = { ...defaultConfig, ...config };\n return r;\n}\n\nfunction instantConfigWithDefaults<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean,\n>(\n config: InstantConfig<Schema, UseDates>,\n): InstantConfigFilled<Schema, UseDates> {\n const defaultConfig = {\n apiURI: 'https://api.instantdb.com',\n };\n const r = { ...defaultConfig, ...config };\n return r;\n}\n\nfunction withImpersonation(\n headers: { [key: string]: string },\n opts: ImpersonationOpts,\n) {\n if ('email' in opts) {\n headers['as-email'] = opts.email;\n } else if ('token' in opts) {\n headers['as-token'] = opts.token;\n } else if ('guest' in opts) {\n headers['as-guest'] = 'true';\n }\n return headers;\n}\n\nfunction validateConfigAndImpersonation(\n config: FilledConfig,\n impersonationOpts: ImpersonationOpts | undefined,\n) {\n if (\n impersonationOpts &&\n ('token' in impersonationOpts || 'guest' in impersonationOpts)\n ) {\n // adminToken is not required for `token` or `guest` impersonation\n return;\n }\n if (config.adminToken) {\n // An adminToken is provided.\n return;\n }\n if (impersonationOpts && 'email' in impersonationOpts) {\n throw new Error(\n 'Admin token required. To impersonate users with an email you must pass `adminToken` to `init`.',\n );\n }\n throw new Error(\n 'Admin token required. To run this operation pass `adminToken` to `init`, or use `db.asUser`.',\n );\n}\n\nfunction authorizedHeaders(\n config: FilledConfig,\n impersonationOpts?: ImpersonationOpts,\n): Record<string, string> {\n validateConfigAndImpersonation(config, impersonationOpts);\n\n const { adminToken, appId } = config;\n const headers: Record<string, string> = {\n 'content-type': 'application/json',\n 'app-id': appId,\n };\n\n if (adminToken) {\n headers.authorization = `Bearer ${adminToken}`;\n }\n\n return impersonationOpts\n ? withImpersonation(headers, impersonationOpts)\n : headers;\n}\n\n// NextJS 13 and 14 cache fetch requests by default.\n//\n// Since adminDB.query uses fetch, this means that it would also cache by default.\n//\n// We don't want this behavior. `adminDB.query` should return the latest result by default.\n//\n// To get around this, we set an explicit `cache` header for NextJS 13 and 14.\n// This is no longer needed in NextJS 15 onwards, as the default is `no-store` again.\n// Once NextJS 13 and 14 are no longer common, we can remove this code.\nfunction isNextJSVersionThatCachesFetchByDefault() {\n return (\n // NextJS 13 onwards added a `__nextPatched` property to the fetch function\n fetch['__nextPatched'] &&\n // NextJS 15 onwards _also_ added a global `next-patch` symbol.\n !globalThis[Symbol.for('next-patch')]\n );\n}\n\nfunction getDefaultFetchOpts(): RequestInit {\n return isNextJSVersionThatCachesFetchByDefault() ? { cache: 'no-store' } : {};\n}\n\nasync function jsonReject(rejectFn, res) {\n const body = await res.text();\n try {\n const json = JSON.parse(body);\n return rejectFn(new InstantAPIError({ status: res.status, body: json }));\n } catch (_e) {\n return rejectFn(\n new InstantAPIError({\n status: res.status,\n body: { type: undefined, message: body },\n }),\n );\n }\n}\n\nasync function jsonFetch(\n input: RequestInfo,\n init: RequestInit | undefined,\n): Promise<any> {\n const defaultFetchOpts = getDefaultFetchOpts();\n const headers = {\n ...(init?.headers || {}),\n 'Instant-Admin-Version': version,\n 'Instant-Core-Version': coreVersion,\n };\n const res = await fetch(input, { ...defaultFetchOpts, ...init, headers });\n if (res.status === 200) {\n const json = await res.json();\n return Promise.resolve(json);\n }\n\n return jsonReject((x) => Promise.reject(x), res);\n}\n\n/**\n *\n * The first step: init your application!\n *\n * Visit https://instantdb.com/dash to get your `appId` :)\n *\n * @example\n * import { init } from \"@instantdb/admin\"\n *\n * const db = init({\n * appId: process.env.INSTANT_APP_ID!,\n * adminToken: process.env.INSTANT_APP_ADMIN_TOKEN\n * })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@instantdb/admin\"\n * import schema from \"\"../instant.schema.ts\";\n *\n * const db = init({\n * appId: process.env.INSTANT_APP_ID!,\n * adminToken: process.env.INSTANT_APP_ADMIN_TOKEN,\n * schema,\n * })\n * // To learn more: https://instantdb.com/docs/modeling-data\n */\nfunction init<\n Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema,\n UseDates extends boolean = false,\n>(\n // Allows config with missing `useDateObjects`, but keeps `UseDates`\n // as a non-nullable in the InstantConfig type.\n config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {\n useDateObjects?: UseDates;\n },\n): InstantAdminDatabase<Schema, UseDates, InstantConfig<Schema, UseDates>> {\n const configStrict = {\n ...config,\n appId: config.appId?.trim(),\n adminToken: config.adminToken?.trim(),\n useDateObjects: (config.useDateObjects ?? false) as UseDates,\n };\n\n return new InstantAdminDatabase<\n Schema,\n UseDates,\n InstantConfig<Schema, UseDates>\n >(configStrict);\n}\n\n/**\n * @deprecated\n * `init_experimental` is deprecated. You can replace it with `init`.\n *\n * @example\n *\n * // Before\n * import { init_experimental } from \"@instantdb/admin\"\n * const db = init_experimental({ ... });\n *\n * // After\n * import { init } from \"@instantdb/admin\"\n * const db = init({ ... });\n */\nconst init_experimental = init;\n\nfunction steps(inputChunks) {\n const chunks = Array.isArray(inputChunks) ? inputChunks : [inputChunks];\n return chunks.flatMap(getOps);\n}\n\ntype PresenceResult<Data> = {\n [peerId: string]: { data: Data; 'peer-id': string; user: User | null };\n};\n\nclass Rooms<Schema extends InstantSchemaDef<any, any, any>> {\n config: FilledConfig;\n\n constructor(config: FilledConfig) {\n this.config = config;\n }\n\n async getPresence<RoomType extends keyof RoomsOf<Schema>>(\n roomType: RoomType,\n roomId: string,\n ): Promise<PresenceResult<PresenceOf<Schema, RoomType>>> {\n const res = await jsonFetch(\n `${this.config.apiURI}/admin/rooms/presence?room-type=${String(roomType)}&room-id=${roomId}`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return res.sessions || {};\n }\n}\n\nclass Auth {\n config: FilledConfig;\n\n constructor(config: FilledConfig) {\n this.config = config;\n this.createToken = this.createToken.bind(this);\n }\n\n /**\n * Generates a magic code for the user with the given email.\n * This is useful if you want to use your own email provider\n * to send magic codes.\n *\n * @example\n * // Generate a magic code\n * const { code } = await db.auth.generateMagicCode({ email })\n * // Send the magic code to the user with your own email provider\n * await customEmailProvider.sendMagicCode(email, code)\n *\n * @see https://instantdb.com/docs/backend#custom-magic-codes\n */\n generateMagicCode = async (email: string): Promise<{ code: string }> => {\n return jsonFetch(`${this.config.apiURI}/admin/magic_code`, {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({ email }),\n });\n };\n\n /**\n * Sends a magic code to the user with the given email.\n * This uses Instant's built-in email provider.\n *\n * @example\n * // Send an email to user with magic code\n * await db.auth.sendMagicCode({ email })\n *\n * @see https://instantdb.com/docs/backend#custom-magic-codes\n */\n sendMagicCode = async (email: string): Promise<{ code: string }> => {\n return jsonFetch(`${this.config.apiURI}/admin/send_magic_code`, {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({ email }),\n });\n };\n\n /**\n * Verifies a magic code for the user with the given email.\n *\n * @example\n * const user = await db.auth.verifyMagicCode({ email, code })\n * console.log(\"Verified user:\", user)\n *\n * @see https://instantdb.com/docs/backend#custom-magic-codes\n */\n verifyMagicCode = async (email: string, code: string): Promise<User> => {\n const { user } = await jsonFetch(\n `${this.config.apiURI}/admin/verify_magic_code`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({ email, code }),\n },\n );\n return user;\n };\n\n /**\n * Creates a login token for the user with the given email.\n * If that user does not exist, we create one.\n *\n * This is often useful for writing custom auth flows.\n *\n * @example\n * app.post('/custom_sign_in', async (req, res) => {\n * // ... your custom flow for users\n * const token = await db.auth.createToken({ email })\n * return res.status(200).send({ token })\n * })\n *\n * @see https://instantdb.com/docs/backend#custom-auth\n */\n createToken(email: { email: string } | { id: string }): Promise<AuthToken>;\n\n /**\n *\n * @deprecated Passing an email string directly is deprecated.\n *\n * Use an object with the `email` key instead.\n *\n * @example\n * // Before\n * const token = await auth.createToken(email)\n * // After\n * const token = await auth.createToken({ email })\n */\n createToken(email: string): Promise<AuthToken>;\n\n async createToken(\n input: string | { email: string } | { id: string },\n ): Promise<AuthToken> {\n const body = typeof input === 'string' ? { email: input } : input;\n const ret: { user: { refresh_token: string } } = await jsonFetch(\n `${this.config.apiURI}/admin/refresh_tokens`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify(body),\n },\n );\n return ret.user.refresh_token;\n }\n\n /**\n * Verifies a given token and returns the associated user.\n *\n * This is often useful for writing custom endpoints, where you need\n * to authenticate users.\n *\n * @example\n * app.post('/custom_endpoint', async (req, res) => {\n * const user = await db.auth.verifyToken(req.headers['token'])\n * if (!user) {\n * return res.status(401).send('Uh oh, you are not authenticated')\n * }\n * // ...\n * })\n * @see https://instantdb.com/docs/backend#custom-endpoints\n */\n verifyToken = async (token: AuthToken): Promise<User> => {\n const res = await jsonFetch(\n `${this.config.apiURI}/runtime/auth/verify_refresh_token`,\n {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n 'app-id': this.config.appId,\n 'refresh-token': token,\n }),\n },\n );\n return res.user;\n };\n\n /**\n * Retrieves an app user by id, email, or refresh token.\n *\n * @example\n * try {\n * const user = await db.auth.getUser({ email })\n * console.log(\"Found user:\", user)\n * } catch (err) {\n * console.error(\"Failed to retrieve user:\", err.message);\n * }\n *\n * @see https://instantdb.com/docs/backend#retrieve-a-user\n */\n getUser = async (\n params: { email: string } | { id: string } | { refresh_token: string },\n ): Promise<Omit<User, 'refresh_token'>> => {\n const qs = Object.entries(params)\n .map(([k, v]) => `${k}=${encodeURIComponent(v)}`)\n .join('&');\n\n const response: { user: User } = await jsonFetch(\n `${this.config.apiURI}/admin/users?${qs}`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return response.user;\n };\n\n /**\n * Deletes an app user by id, email, or refresh token.\n *\n * NB: This _only_ deletes the user; it does not delete all user data.\n * You will need to handle this manually.\n *\n * @example\n * try {\n * const deletedUser = await db.auth.deleteUser({ email })\n * console.log(\"Deleted user:\", deletedUser)\n * } catch (err) {\n * console.error(\"Failed to delete user:\", err.message);\n * }\n *\n * @see https://instantdb.com/docs/backend#delete-a-user\n */\n deleteUser = async (\n params: { email: string } | { id: string } | { refresh_token: string },\n ): Promise<User> => {\n const qs = Object.entries(params).map(([k, v]) => `${k}=${v}`);\n const response: { deleted: User } = await jsonFetch(\n `${this.config.apiURI}/admin/users?${qs}`,\n {\n method: 'DELETE',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return response.deleted;\n };\n\n /**\n * Signs out the user with the given email.\n * This invalidates any tokens associated with the user.\n * If the user is not found, an error will be thrown.\n *\n * @example\n * try {\n * await auth.signOut({ email: \"alyssa_p_hacker@instantdb.com\" });\n * console.log(\"Successfully signed out\");\n * } catch (err) {\n * console.error(\"Sign out failed:\", err.message);\n * }\n *\n * @see https://instantdb.com/docs/backend#sign-out\n */\n async signOut(\n params: { email: string } | { id: string } | { refresh_token: string },\n ): Promise<void>;\n\n /**\n * @deprecated Passing an email string directly is deprecated.\n * Use an object with the `email` key instead.\n *\n * @example\n * // Before\n * auth.signOut(email)\n *\n * // After\n * auth.signOut({ email })\n */\n async signOut(email: string): Promise<void>;\n\n async signOut(\n input:\n | string\n | { email: string }\n | { id: string }\n | { refresh_token: string },\n ): Promise<void> {\n // If input is a string, we assume it's an email.\n // This is because of backwards compatibility: we used to only\n // accept email strings. Eventually we can remove this\n const params = typeof input === 'string' ? { email: input } : input;\n const config = this.config;\n await jsonFetch(`${config.apiURI}/admin/sign_out`, {\n method: 'POST',\n headers: authorizedHeaders(config),\n body: JSON.stringify(params),\n });\n }\n}\n\ntype StorageFile = {\n key: string;\n name: string;\n size: number;\n etag: string;\n last_modified: number;\n};\n\ntype DeleteManyFileResponse = {\n data: {\n ids: string[] | null;\n };\n};\n\nconst isNodeReadable = (v: any): v is Readable =>\n v &&\n typeof v === 'object' &&\n typeof v.pipe === 'function' &&\n typeof v.read === 'function';\n\nconst isWebReadable = (v: any): v is ReadableStream =>\n v && typeof v.getReader === 'function';\n\n/**\n * Functions to manage file storage.\n */\nclass Storage {\n config: FilledConfig;\n impersonationOpts?: ImpersonationOpts;\n\n constructor(config: FilledConfig, impersonationOpts?: ImpersonationOpts) {\n this.config = config;\n this.impersonationOpts = impersonationOpts;\n }\n\n /**\n * Uploads file at the provided path. Accepts a Buffer or a Readable stream.\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * const buffer = fs.readFileSync('demo.png');\n * const isSuccess = await db.storage.uploadFile('photos/demo.png', buffer);\n */\n uploadFile = async (\n path: string,\n file: Buffer | Readable | ReadableStream | Uint8Array,\n metadata: FileOpts = {},\n ): Promise<UploadFileResponse> => {\n const headers = {\n ...authorizedHeaders(this.config, this.impersonationOpts),\n path,\n };\n if (metadata.contentDisposition) {\n headers['content-disposition'] = metadata.contentDisposition;\n }\n\n // headers.content-type will become \"undefined\" (string)\n // if not removed from the object\n delete headers['content-type'];\n\n if (metadata.contentType) {\n headers['content-type'] = metadata.contentType;\n }\n\n let duplex: 'half' | undefined;\n if (isNodeReadable(file)) {\n duplex = 'half'; // one-way stream\n }\n if (isNodeReadable(file) || isWebReadable(file)) {\n if (!metadata.fileSize) {\n throw new Error(\n 'fileSize is required in metadata when uploading streams',\n );\n }\n headers['content-length'] = metadata.fileSize.toString();\n }\n\n let options = {\n method: 'PUT',\n headers,\n body: file as unknown as BodyInit,\n ...(duplex && { duplex }),\n };\n\n return jsonFetch(`${this.config.apiURI}/admin/storage/upload`, options);\n };\n\n /**\n * Deletes a file by its path name (e.g. \"photos/demo.png\").\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * await db.storage.delete(\"photos/demo.png\");\n */\n delete = async (pathname: string): Promise<DeleteFileResponse> => {\n return jsonFetch(\n `${this.config.apiURI}/admin/storage/files?filename=${encodeURIComponent(\n pathname,\n )}`,\n {\n method: 'DELETE',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n },\n );\n };\n\n /**\n * Deletes multiple files by their path names (e.g. \"photos/demo.png\", \"essays/demo.txt\").\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * await db.storage.deleteMany([\"images/1.png\", \"images/2.png\", \"images/3.png\"]);\n */\n deleteMany = async (pathnames: string[]): Promise<DeleteManyFileResponse> => {\n return jsonFetch(`${this.config.apiURI}/admin/storage/files/delete`, {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({ filenames: pathnames }),\n });\n };\n\n /**\n * @deprecated. This method will be removed in the future. Use `uploadFile`\n * instead\n */\n upload = async (\n pathname: string,\n file: Buffer,\n metadata: FileOpts = {},\n ): Promise<boolean> => {\n const { data: presignedUrl } = await jsonFetch(\n `${this.config.apiURI}/admin/storage/signed-upload-url`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config),\n body: JSON.stringify({\n app_id: this.config.appId,\n filename: pathname,\n }),\n },\n );\n const headers = {};\n const contentType = metadata.contentType;\n if (contentType) {\n headers['Content-Type'] = contentType;\n }\n const { ok } = await fetch(presignedUrl, {\n method: 'PUT',\n body: file as unknown as BodyInit,\n headers,\n });\n\n return ok;\n };\n\n /**\n * @deprecated. This method will be removed in the future. Use `query` instead\n * @example\n * const files = await db.query({ $files: {}})\n */\n list = async (): Promise<StorageFile[]> => {\n const { data } = await jsonFetch(\n `${this.config.apiURI}/admin/storage/files`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return data;\n };\n\n /**\n * @deprecated. getDownloadUrl will be removed in the future.\n * Use `query` instead to query and fetch for valid urls\n *\n * db.useQuery({\n * $files: {\n * $: {\n * where: {\n * path: \"moop.png\"\n * }\n * }\n * }\n * })\n */\n getDownloadUrl = async (pathname: string): Promise<string> => {\n const { data } = await jsonFetch(\n `${this.config.apiURI}/admin/storage/signed-download-url?app_id=${this.config.appId}&filename=${encodeURIComponent(pathname)}`,\n {\n method: 'GET',\n headers: authorizedHeaders(this.config),\n },\n );\n\n return data;\n };\n}\n\ntype AdminQueryOpts = {\n ruleParams?: RuleParams;\n fetchOpts?: RequestInit;\n};\n\n/**\n *\n * The first step: init your application!\n *\n * Visit https://instantdb.com/dash to get your `appId` and `adminToken` :)\n *\n * @example\n * const db = init({ appId: \"my-app-id\", adminToken: \"my-admin-token\" })\n */\nclass InstantAdminDatabase<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n Config extends InstantConfig<Schema, UseDates> = InstantConfig<\n Schema,\n UseDates\n >,\n> {\n config: InstantConfigFilled<Schema, UseDates>;\n auth: Auth;\n storage: Storage;\n rooms: Rooms<Schema>;\n impersonationOpts?: ImpersonationOpts;\n\n public tx = txInit<NonNullable<Schema>>();\n\n constructor(_config: Config) {\n this.config = instantConfigWithDefaults(_config);\n this.auth = new Auth(this.config);\n this.storage = new Storage(this.config, this.impersonationOpts);\n this.rooms = new Rooms<Schema>(this.config);\n }\n\n /**\n * Sometimes you want to scope queries to a specific user.\n *\n * You can provide a user's auth token, email, or impersonate a guest.\n *\n * @see https://instantdb.com/docs/backend#impersonating-users\n * @example\n * await db.asUser({email: \"stopa@instantdb.com\"}).query({ goals: {} })\n */\n asUser = (\n opts: ImpersonationOpts,\n ): InstantAdminDatabase<Schema, UseDates, Config> => {\n const newClient = new InstantAdminDatabase<Schema, UseDates, Config>({\n ...(this.config as Config),\n });\n newClient.impersonationOpts = opts;\n newClient.storage = new Storage(this.config, opts);\n return newClient;\n };\n\n /**\n * Use this to query your data!\n *\n * @see https://instantdb.com/docs/instaql\n *\n * @example\n * // fetch all goals\n * await db.query({ goals: {} })\n *\n * // goals where the title is \"Get Fit\"\n * await db.query({ goals: { $: { where: { title: \"Get Fit\" } } } })\n *\n * // all goals, _alongside_ their todos\n * await db.query({ goals: { todos: {} } })\n */\n query = <Q extends ValidQuery<Q, Schema>>(\n query: Q,\n opts: AdminQueryOpts = {},\n ): Promise<InstaQLResponse<Schema, Q, UseDates>> => {\n if (query && opts && 'ruleParams' in opts) {\n query = { $$ruleParams: opts['ruleParams'], ...query };\n }\n\n if (!this.config.disableValidation) {\n validateQuery(query, this.config.schema);\n }\n\n const fetchOpts = opts.fetchOpts || {};\n const fetchOptsHeaders = fetchOpts['headers'] || {};\n return jsonFetch(`${this.config.apiURI}/admin/query`, {\n ...fetchOpts,\n method: 'POST',\n headers: {\n ...fetchOptsHeaders,\n ...authorizedHeaders(this.config, this.impersonationOpts),\n },\n body: JSON.stringify({\n query: query,\n 'inference?': !!this.config.schema,\n }),\n });\n };\n\n /**\n * Use this to to get a live view of your data!\n *\n * @see https://www.instantdb.com/docs/backend\n *\n * @example\n * // create a subscription to a query\n * const query = { goals: { $: { where: { title: \"Get Fit\" } } } }\n * const sub = db.subscribeQuery(query);\n *\n * // iterate through the results with an async iterator\n * for await (const payload of sub) {\n * if (payload.error) {\n * console.log(payload.error);\n * // Stop the subscription\n * sub.close();\n * } else {\n * console.log(payload.data);\n * }\n * }\n *\n * // Stop the subscription\n * sub.close();\n *\n * // Create a subscription with a callback\n * const sub = db.subscribeQuery(query, (payload) => {\n * if (payload.error) {\n * console.log(payload.error);\n * // Stop the subscription\n * sub.close();\n * } else {\n * console.log(payload.data);\n * }\n * });\n */\n subscribeQuery<Q extends ValidQuery<Q, Schema>>(\n query: Q,\n cb?: SubscribeQueryCallback<Schema, Q, UseDates>,\n opts: AdminQueryOpts = {},\n ): SubscribeQueryResponse<Schema, Q, UseDates> {\n if (query && opts && 'ruleParams' in opts) {\n query = { $$ruleParams: opts['ruleParams'], ...query };\n }\n\n if (!this.config.disableValidation) {\n validateQuery(query, this.config.schema);\n }\n\n const fetchOpts = opts.fetchOpts || {};\n const fetchOptsHeaders = fetchOpts['headers'] || {};\n\n const headers: HeadersInit = {\n ...fetchOptsHeaders,\n ...authorizedHeaders(this.config, this.impersonationOpts),\n };\n\n const inference = !!this.config.schema;\n\n return subscribe(query, cb, {\n headers,\n inference,\n apiURI: this.config.apiURI,\n });\n }\n\n /**\n * Use this to write data! You can create, update, delete, and link objects\n *\n * @see https://instantdb.com/docs/instaml\n *\n * @example\n * // Create a new object in the `goals` namespace\n * const goalId = id();\n * db.transact(db.tx.goals[goalId].update({title: \"Get fit\"}))\n *\n * // Update the title\n * db.transact(db.tx.goals[goalId].update({title: \"Get super fit\"}))\n *\n * // Delete it\n * db.transact(db.tx.goals[goalId].delete())\n *\n * // Or create an association:\n * todoId = id();\n * db.transact([\n * db.tx.todos[todoId].update({ title: 'Go on a run' }),\n * db.tx.goals[goalId].link({todos: todoId}),\n * ])\n */\n transact = (\n inputChunks: TransactionChunk<any, any> | TransactionChunk<any, any>[],\n ) => {\n if (!this.config.disableValidation) {\n validateTransactions(inputChunks, this.config.schema);\n }\n return jsonFetch(`${this.config.apiURI}/admin/transact`, {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({\n steps: steps(inputChunks),\n 'throw-on-missing-attrs?': !!this.config.schema,\n }),\n });\n };\n\n /**\n * Like `query`, but returns debugging information\n * for permissions checks along with the result.\n * Useful for inspecting the values returned by the permissions checks.\n * Note, this will return debug information for *all* entities\n * that match the query's `where` clauses.\n *\n * Requires a user/guest context to be set with `asUser`,\n * since permissions checks are user-specific.\n *\n * Accepts an optional configuration object with a `rules` key.\n * The provided rules will override the rules in the database for the query.\n *\n * @see https://instantdb.com/docs/instaql\n *\n * @example\n * await db.asUser({ guest: true }).debugQuery(\n * { goals: {} },\n * { rules: { goals: { allow: { read: \"auth.id != null\" } } }\n * )\n */\n debugQuery = async <Q extends ValidQuery<Q, Schema>>(\n query: Q,\n opts?: { rules?: any; ruleParams?: { [key: string]: any } },\n ): Promise<{\n result: InstaQLResponse<Schema, Q, UseDates>;\n checkResults: DebugCheckResult[];\n }> => {\n if (query && opts && 'ruleParams' in opts) {\n query = { $$ruleParams: opts['ruleParams'], ...query };\n }\n\n const response = await jsonFetch(\n `${this.config.apiURI}/admin/query_perms_check`,\n {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({ query, 'rules-override': opts?.rules }),\n },\n );\n\n return {\n result: response.result,\n checkResults: response['check-results'],\n };\n };\n\n /**\n * Like `transact`, but does not write to the database.\n * Returns debugging information for permissions checks.\n * Useful for inspecting the values returned by the permissions checks.\n *\n * Requires a user/guest context to be set with `asUser`,\n * since permissions checks are user-specific.\n *\n * Accepts an optional configuration object with a `rules` key.\n * The provided rules will override the rules in the database for the duration of the transaction.\n *\n * @example\n * const goalId = id();\n * db.asUser({ guest: true }).debugTransact(\n * [db.tx.goals[goalId].update({title: \"Get fit\"})],\n * { rules: { goals: { allow: { update: \"auth.id != null\" } } }\n * )\n */\n debugTransact = (\n inputChunks: TransactionChunk<any, any> | TransactionChunk<any, any>[],\n opts?: { rules?: any },\n ): Promise<DebugTransactResult> => {\n return jsonFetch(`${this.config.apiURI}/admin/transact_perms_check`, {\n method: 'POST',\n headers: authorizedHeaders(this.config, this.impersonationOpts),\n body: JSON.stringify({\n steps: steps(inputChunks),\n 'rules-override': opts?.rules,\n // @ts-expect-error because we're using a private API (for now)\n 'dangerously-commit-tx': opts?.__dangerouslyCommit,\n }),\n });\n };\n}\n\nexport {\n init,\n init_experimental,\n id,\n tx,\n lookup,\n i,\n createInstantRouteHandler,\n\n // error\n InstantAPIError,\n\n // types\n type Config,\n type ImpersonationOpts,\n type TransactionChunk,\n type DebugCheckResult,\n type InstantAdminDatabase,\n\n // core types\n type User,\n type InstaQLParams,\n type ValidQuery,\n type Query,\n\n // query types\n type QueryResponse,\n type InstaQLResponse,\n type InstantQuery,\n type InstantUnknownSchemaDef,\n type InstantQueryResult,\n type InstantSchema,\n type InstantSchemaDatabase,\n type IInstantDatabase,\n type InstantObject,\n type InstantEntity,\n type BackwardsCompatibleSchema,\n type InstaQLFields,\n type SubscribeQueryCallback,\n type SubscribeQueryResponse,\n type SubscribeQueryPayload,\n type SubscriptionReadyState,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type RoomsOf,\n type PresenceOf,\n type RoomsDef,\n type RoomHandle,\n type ValueTypes,\n type InstantSchemaDef,\n type InstantUnknownSchema,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type InstantRules,\n type CreateParams,\n type UpdateParams,\n type LinkParams,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n type DeleteManyFileResponse,\n\n // error types\n type InstantIssue,\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instantdb/admin",
|
|
3
|
-
"version": "0.22.96
|
|
3
|
+
"version": "0.22.96",
|
|
4
4
|
"description": "Admin SDK for Instant DB",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/instantdb/instant/tree/main/client/packages/admin",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"eventsource": "^4.0.0",
|
|
51
|
-
"@instantdb/core": "0.22.96
|
|
52
|
-
"@instantdb/version": "0.22.96
|
|
51
|
+
"@instantdb/core": "0.22.96",
|
|
52
|
+
"@instantdb/version": "0.22.96"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"test": "vitest",
|
package/src/index.ts
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
type InstantIssue,
|
|
13
13
|
type TransactionChunk,
|
|
14
14
|
type AuthToken,
|
|
15
|
-
type Exactly,
|
|
16
15
|
|
|
17
16
|
// core types
|
|
18
17
|
type User,
|
|
@@ -70,6 +69,7 @@ import {
|
|
|
70
69
|
type DeleteFileResponse,
|
|
71
70
|
validateQuery,
|
|
72
71
|
validateTransactions,
|
|
72
|
+
createInstantRouteHandler,
|
|
73
73
|
} from '@instantdb/core';
|
|
74
74
|
|
|
75
75
|
import version from './version.ts';
|
|
@@ -1116,6 +1116,7 @@ export {
|
|
|
1116
1116
|
tx,
|
|
1117
1117
|
lookup,
|
|
1118
1118
|
i,
|
|
1119
|
+
createInstantRouteHandler,
|
|
1119
1120
|
|
|
1120
1121
|
// error
|
|
1121
1122
|
InstantAPIError,
|