@instantdb/admin 0.22.139 → 0.22.140-experimental.docs-chat-streaming.22116931029.1

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.
@@ -1,5 +1,5 @@
1
1
  import type { Readable } from 'node:stream';
2
- import { tx, lookup, i, id, InstantAPIError, setInstantWarningsEnabled, 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';
2
+ import { tx, lookup, i, id, InstantAPIError, setInstantWarningsEnabled, 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, InstantStream, type WritableStreamCtor, type ReadableStreamCtor, InstantWritableStream } from '@instantdb/core';
3
3
  import { SubscribeQueryCallback, SubscribeQueryResponse, SubscribeQueryPayload, SubscriptionReadyState } from './subscribe.ts';
4
4
  type DebugCheckResult = {
5
5
  /** The ID of the record. */
@@ -25,6 +25,9 @@ export type InstantConfig<Schema extends InstantSchemaDef<any, any, any>, UseDat
25
25
  schema?: Schema;
26
26
  useDateObjects: UseDates;
27
27
  disableValidation?: boolean;
28
+ verbose?: boolean;
29
+ WritableStream?: WritableStreamCtor;
30
+ ReadableStream?: ReadableStreamCtor;
28
31
  };
29
32
  type InstantConfigFilled<Schema extends InstantSchemaDef<any, any, any>, UseDates extends boolean> = InstantConfig<Schema, UseDates> & {
30
33
  apiURI: string;
@@ -350,6 +353,55 @@ declare class Storage {
350
353
  */
351
354
  getDownloadUrl: (pathname: string) => Promise<string>;
352
355
  }
356
+ type CreateReadStreamOpts = {
357
+ clientId?: string | null | undefined;
358
+ streamId?: string | null | undefined;
359
+ byteOffset?: number | null | undefined;
360
+ ruleParams?: RuleParams | null | undefined;
361
+ };
362
+ type CreateWriteStreamOpts = {
363
+ clientId: string;
364
+ /**
365
+ * A function that takes a promise and ensures that the current program stays alive
366
+ * until the promise is resolved.
367
+ *
368
+ * Useful in serverless environments to ensure the writer fully flushes before the
369
+ * environment is shut down.
370
+ *
371
+ * @example
372
+ * import { after } from 'next/server'
373
+ * db.streams.createWriteStream({clientId, waitUntil: after})
374
+ */
375
+ waitUntil?: (promise: Promise<any>) => void | null | undefined;
376
+ ruleParams?: RuleParams | null | undefined;
377
+ };
378
+ /**
379
+ * Functions to manage streams.
380
+ */
381
+ declare class Streams {
382
+ #private;
383
+ constructor(ensureInstantStream: () => InstantStream);
384
+ /**
385
+ * Creates a new ReadableStream for the given clientId.
386
+ *
387
+ * @example
388
+ * const stream = db.streams.createReadStream({clientId: clientId})
389
+ * for await (const chunk of stream) {
390
+ * console.log(chunk);
391
+ * }
392
+ */
393
+ createReadStream: (opts: CreateReadStreamOpts) => ReadableStream<string>;
394
+ /**
395
+ * Creates a new WritableStream for the given clientId.
396
+ *
397
+ * @example
398
+ * const writeStream = db.streams.createWriteStream({clientId: clientId})
399
+ * const writer = writeStream.getWriter();
400
+ * writer.write('Hello world');
401
+ * writer.close();
402
+ */
403
+ createWriteStream: (opts: CreateWriteStreamOpts) => InstantWritableStream<string>;
404
+ }
353
405
  type AdminQueryOpts = {
354
406
  ruleParams?: RuleParams;
355
407
  fetchOpts?: RequestInit;
@@ -364,9 +416,11 @@ type AdminQueryOpts = {
364
416
  * const db = init({ appId: "my-app-id", adminToken: "my-admin-token" })
365
417
  */
366
418
  declare class InstantAdminDatabase<Schema extends InstantSchemaDef<any, any, any>, UseDates extends boolean = false, Config extends InstantConfig<Schema, UseDates> = InstantConfig<Schema, UseDates>> {
419
+ #private;
367
420
  config: InstantConfigFilled<Schema, UseDates>;
368
421
  auth: Auth;
369
422
  storage: Storage;
423
+ streams: Streams;
370
424
  rooms: Rooms<Schema>;
371
425
  impersonationOpts?: ImpersonationOpts;
372
426
  tx: import("@instantdb/core").TxChunk<NonNullable<Schema>>;
@@ -513,5 +567,5 @@ declare class InstantAdminDatabase<Schema extends InstantSchemaDef<any, any, any
513
567
  origin?: string | null | undefined;
514
568
  }) => Promise<DebugTransactResult>;
515
569
  }
516
- export { init, init_experimental, id, tx, lookup, i, createInstantRouteHandler, InstantAPIError, setInstantWarningsEnabled, 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, };
570
+ export { init, init_experimental, id, tx, lookup, i, createInstantRouteHandler, InstantAPIError, setInstantWarningsEnabled, 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 CreateReadStreamOpts, type CreateWriteStreamOpts, type InstantWritableStream, type InstantIssue, };
517
571
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA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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,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAG1B,KAAK,YAAY,GAClB,CAAC"}
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "createInstantRouteHandler", { enumerable: true,
17
17
  const version_ts_1 = __importDefault(require("./version.js"));
18
18
  const subscribe_ts_1 = require("./subscribe.js");
19
19
  const cookie_1 = require("cookie");
20
+ const eventsource_1 = require("eventsource");
20
21
  function configWithDefaults(config) {
21
22
  const defaultConfig = {
22
23
  apiURI: 'https://api.instantdb.com',
@@ -118,6 +119,62 @@ async function jsonFetch(input, init) {
118
119
  }
119
120
  return jsonReject((x) => Promise.reject(x), res);
120
121
  }
122
+ function makeEventSourceWrapper(opts) {
123
+ return class EventSourceWrapper {
124
+ source;
125
+ static OPEN = eventsource_1.EventSource.OPEN;
126
+ static CONNECTING = eventsource_1.EventSource.CONNECTING;
127
+ static CLOSED = eventsource_1.EventSource.CLOSED;
128
+ url;
129
+ constructor(url) {
130
+ this.url = url;
131
+ this.source = this.#createEventSource(url);
132
+ }
133
+ get onopen() {
134
+ return this.source.onopen;
135
+ }
136
+ set onopen(fn) {
137
+ this.source.onopen = fn;
138
+ }
139
+ get onmessage() {
140
+ return this.source.onmessage;
141
+ }
142
+ set onmessage(fn) {
143
+ this.source.onmessage = fn;
144
+ }
145
+ get onerror() {
146
+ return this.source.onerror;
147
+ }
148
+ set onerror(fn) {
149
+ this.source.onerror = fn;
150
+ }
151
+ get readyState() {
152
+ return this.source.readyState;
153
+ }
154
+ close() {
155
+ this.source.close();
156
+ }
157
+ #createEventSource(url) {
158
+ const es = new eventsource_1.EventSource(url, {
159
+ fetch(input, init) {
160
+ return fetch(input, {
161
+ ...init,
162
+ method: 'POST',
163
+ headers: opts.headers,
164
+ body: JSON.stringify({
165
+ 'inference?': opts.inference,
166
+ versions: {
167
+ '@instantdb/admin': version_ts_1.default,
168
+ '@instantdb/core': core_1.version,
169
+ },
170
+ }),
171
+ });
172
+ },
173
+ });
174
+ return es;
175
+ }
176
+ };
177
+ }
121
178
  /**
122
179
  *
123
180
  * The first step: init your application!
@@ -186,7 +243,7 @@ class Rooms {
186
243
  this.config = config;
187
244
  }
188
245
  async getPresence(roomType, roomId) {
189
- const res = await jsonFetch(`${this.config.apiURI}/admin/rooms/presence?room-type=${String(roomType)}&room-id=${roomId}`, {
246
+ const res = await jsonFetch(`${this.config.apiURI}/admin/rooms/presence?app_id=${this.config.appId}&room-type=${String(roomType)}&room-id=${roomId}`, {
190
247
  method: 'GET',
191
248
  headers: authorizedHeaders(this.config),
192
249
  });
@@ -213,7 +270,7 @@ class Auth {
213
270
  * @see https://instantdb.com/docs/backend#custom-magic-codes
214
271
  */
215
272
  generateMagicCode = async (email) => {
216
- return jsonFetch(`${this.config.apiURI}/admin/magic_code`, {
273
+ return jsonFetch(`${this.config.apiURI}/admin/magic_code?app_id=${this.config.appId}`, {
217
274
  method: 'POST',
218
275
  headers: authorizedHeaders(this.config),
219
276
  body: JSON.stringify({ email }),
@@ -230,7 +287,7 @@ class Auth {
230
287
  * @see https://instantdb.com/docs/backend#custom-magic-codes
231
288
  */
232
289
  sendMagicCode = async (email) => {
233
- return jsonFetch(`${this.config.apiURI}/admin/send_magic_code`, {
290
+ return jsonFetch(`${this.config.apiURI}/admin/send_magic_code?app_id=${this.config.appId}`, {
234
291
  method: 'POST',
235
292
  headers: authorizedHeaders(this.config),
236
293
  body: JSON.stringify({ email }),
@@ -246,7 +303,7 @@ class Auth {
246
303
  * @see https://instantdb.com/docs/backend#custom-magic-codes
247
304
  */
248
305
  verifyMagicCode = async (email, code) => {
249
- const { user } = await jsonFetch(`${this.config.apiURI}/admin/verify_magic_code`, {
306
+ const { user } = await jsonFetch(`${this.config.apiURI}/admin/verify_magic_code?app_id=${this.config.appId}`, {
250
307
  method: 'POST',
251
308
  headers: authorizedHeaders(this.config),
252
309
  body: JSON.stringify({ email, code }),
@@ -255,7 +312,7 @@ class Auth {
255
312
  };
256
313
  async createToken(input) {
257
314
  const body = typeof input === 'string' ? { email: input } : input;
258
- const ret = await jsonFetch(`${this.config.apiURI}/admin/refresh_tokens`, {
315
+ const ret = await jsonFetch(`${this.config.apiURI}/admin/refresh_tokens?app_id=${this.config.appId}`, {
259
316
  method: 'POST',
260
317
  headers: authorizedHeaders(this.config),
261
318
  body: JSON.stringify(body),
@@ -279,7 +336,7 @@ class Auth {
279
336
  * @see https://instantdb.com/docs/backend#custom-endpoints
280
337
  */
281
338
  verifyToken = async (token) => {
282
- const res = await jsonFetch(`${this.config.apiURI}/runtime/auth/verify_refresh_token`, {
339
+ const res = await jsonFetch(`${this.config.apiURI}/runtime/auth/verify_refresh_token?app_id=${this.config.appId}`, {
283
340
  method: 'POST',
284
341
  headers: { 'content-type': 'application/json' },
285
342
  body: JSON.stringify({
@@ -306,7 +363,7 @@ class Auth {
306
363
  const qs = Object.entries(params)
307
364
  .map(([k, v]) => `${k}=${encodeURIComponent(v)}`)
308
365
  .join('&');
309
- const response = await jsonFetch(`${this.config.apiURI}/admin/users?${qs}`, {
366
+ const response = await jsonFetch(`${this.config.apiURI}/admin/users?app_id=${this.config.appId}&${qs}`, {
310
367
  method: 'GET',
311
368
  headers: authorizedHeaders(this.config),
312
369
  });
@@ -330,7 +387,7 @@ class Auth {
330
387
  */
331
388
  deleteUser = async (params) => {
332
389
  const qs = Object.entries(params).map(([k, v]) => `${k}=${v}`);
333
- const response = await jsonFetch(`${this.config.apiURI}/admin/users?${qs}`, {
390
+ const response = await jsonFetch(`${this.config.apiURI}/admin/users?app_id=${this.config.appId}&${qs}`, {
334
391
  method: 'DELETE',
335
392
  headers: authorizedHeaders(this.config),
336
393
  });
@@ -342,7 +399,7 @@ class Auth {
342
399
  // accept email strings. Eventually we can remove this
343
400
  const params = typeof input === 'string' ? { email: input } : input;
344
401
  const config = this.config;
345
- await jsonFetch(`${config.apiURI}/admin/sign_out`, {
402
+ await jsonFetch(`${config.apiURI}/admin/sign_out?app_id=${this.config.appId}`, {
346
403
  method: 'POST',
347
404
  headers: authorizedHeaders(config),
348
405
  body: JSON.stringify(params),
@@ -427,7 +484,7 @@ class Storage {
427
484
  body: file,
428
485
  ...(duplex && { duplex }),
429
486
  };
430
- return jsonFetch(`${this.config.apiURI}/admin/storage/upload`, options);
487
+ return jsonFetch(`${this.config.apiURI}/admin/storage/upload?app_id=${this.config.appId}`, options);
431
488
  };
432
489
  /**
433
490
  * Deletes a file by its path name (e.g. "photos/demo.png").
@@ -437,7 +494,7 @@ class Storage {
437
494
  * await db.storage.delete("photos/demo.png");
438
495
  */
439
496
  delete = async (pathname) => {
440
- return jsonFetch(`${this.config.apiURI}/admin/storage/files?filename=${encodeURIComponent(pathname)}`, {
497
+ return jsonFetch(`${this.config.apiURI}/admin/storage/files?app_id=${this.config.appId}&filename=${encodeURIComponent(pathname)}`, {
441
498
  method: 'DELETE',
442
499
  headers: authorizedHeaders(this.config, this.impersonationOpts),
443
500
  });
@@ -450,7 +507,7 @@ class Storage {
450
507
  * await db.storage.deleteMany(["images/1.png", "images/2.png", "images/3.png"]);
451
508
  */
452
509
  deleteMany = async (pathnames) => {
453
- return jsonFetch(`${this.config.apiURI}/admin/storage/files/delete`, {
510
+ return jsonFetch(`${this.config.apiURI}/admin/storage/files/delete?app_id=${this.config.appId}`, {
454
511
  method: 'POST',
455
512
  headers: authorizedHeaders(this.config, this.impersonationOpts),
456
513
  body: JSON.stringify({ filenames: pathnames }),
@@ -461,7 +518,7 @@ class Storage {
461
518
  * instead
462
519
  */
463
520
  upload = async (pathname, file, metadata = {}) => {
464
- const { data: presignedUrl } = await jsonFetch(`${this.config.apiURI}/admin/storage/signed-upload-url`, {
521
+ const { data: presignedUrl } = await jsonFetch(`${this.config.apiURI}/admin/storage/signed-upload-url?app_id=${this.config.appId}`, {
465
522
  method: 'POST',
466
523
  headers: authorizedHeaders(this.config),
467
524
  body: JSON.stringify({
@@ -487,7 +544,7 @@ class Storage {
487
544
  * const files = await db.query({ $files: {}})
488
545
  */
489
546
  list = async () => {
490
- const { data } = await jsonFetch(`${this.config.apiURI}/admin/storage/files`, {
547
+ const { data } = await jsonFetch(`${this.config.apiURI}/admin/storage/files?app_id=${this.config.appId}`, {
491
548
  method: 'GET',
492
549
  headers: authorizedHeaders(this.config),
493
550
  });
@@ -515,6 +572,46 @@ class Storage {
515
572
  return data;
516
573
  };
517
574
  }
575
+ /**
576
+ * Functions to manage streams.
577
+ */
578
+ class Streams {
579
+ #ensureInstantStream;
580
+ constructor(ensureInstantStream) {
581
+ this.#ensureInstantStream = ensureInstantStream;
582
+ }
583
+ /**
584
+ * Creates a new ReadableStream for the given clientId.
585
+ *
586
+ * @example
587
+ * const stream = db.streams.createReadStream({clientId: clientId})
588
+ * for await (const chunk of stream) {
589
+ * console.log(chunk);
590
+ * }
591
+ */
592
+ createReadStream = (opts) => {
593
+ return this.#ensureInstantStream().createReadStream(opts);
594
+ };
595
+ /**
596
+ * Creates a new WritableStream for the given clientId.
597
+ *
598
+ * @example
599
+ * const writeStream = db.streams.createWriteStream({clientId: clientId})
600
+ * const writer = writeStream.getWriter();
601
+ * writer.write('Hello world');
602
+ * writer.close();
603
+ */
604
+ createWriteStream = (opts) => {
605
+ return this.#ensureInstantStream().createWriteStream(opts);
606
+ };
607
+ }
608
+ function createLogger(isEnabled) {
609
+ return {
610
+ info: isEnabled ? (...args) => console.info(...args) : () => { },
611
+ debug: isEnabled ? (...args) => console.debug(...args) : () => { },
612
+ error: isEnabled ? (...args) => console.error(...args) : () => { },
613
+ };
614
+ }
518
615
  /**
519
616
  *
520
617
  * The first step: init your application!
@@ -528,14 +625,21 @@ class InstantAdminDatabase {
528
625
  config;
529
626
  auth;
530
627
  storage;
628
+ streams;
531
629
  rooms;
532
630
  impersonationOpts;
631
+ #sseConnection = null;
632
+ #sseBackoff = 0;
633
+ #instantStream = null;
634
+ #log;
533
635
  tx = (0, core_1.txInit)();
534
636
  constructor(_config) {
535
637
  this.config = instantConfigWithDefaults(_config);
536
638
  this.auth = new Auth(this.config);
537
639
  this.storage = new Storage(this.config, this.impersonationOpts);
640
+ this.streams = new Streams(this.#ensureInstantStream.bind(this));
538
641
  this.rooms = new Rooms(this.config);
642
+ this.#log = createLogger(!!this.config.verbose);
539
643
  }
540
644
  /**
541
645
  * Sometimes you want to scope queries to a specific user.
@@ -578,7 +682,7 @@ class InstantAdminDatabase {
578
682
  }
579
683
  const fetchOpts = opts.fetchOpts || {};
580
684
  const fetchOptsHeaders = fetchOpts['headers'] || {};
581
- return jsonFetch(`${this.config.apiURI}/admin/query`, {
685
+ return jsonFetch(`${this.config.apiURI}/admin/query?app_id=${this.config.appId}`, {
582
686
  ...fetchOpts,
583
687
  method: 'POST',
584
688
  headers: {
@@ -673,7 +777,7 @@ class InstantAdminDatabase {
673
777
  if (!this.config.disableValidation) {
674
778
  (0, core_1.validateTransactions)(inputChunks, this.config.schema);
675
779
  }
676
- return jsonFetch(`${this.config.apiURI}/admin/transact`, {
780
+ return jsonFetch(`${this.config.apiURI}/admin/transact?app_id=${this.config.appId}`, {
677
781
  method: 'POST',
678
782
  headers: authorizedHeaders(this.config, this.impersonationOpts),
679
783
  body: JSON.stringify({
@@ -714,7 +818,7 @@ class InstantAdminDatabase {
714
818
  if (opts?.origin) {
715
819
  body['origin-override'] = opts.origin;
716
820
  }
717
- const response = await jsonFetch(`${this.config.apiURI}/admin/query_perms_check`, {
821
+ const response = await jsonFetch(`${this.config.apiURI}/admin/query_perms_check?app_id=${this.config.appId}`, {
718
822
  method: 'POST',
719
823
  headers: authorizedHeaders(this.config, this.impersonationOpts),
720
824
  body: JSON.stringify(body),
@@ -755,11 +859,140 @@ class InstantAdminDatabase {
755
859
  if (opts?.origin) {
756
860
  body['origin-override'] = opts.origin;
757
861
  }
758
- return jsonFetch(`${this.config.apiURI}/admin/transact_perms_check`, {
862
+ return jsonFetch(`${this.config.apiURI}/admin/transact_perms_check?app_id=${this.config.appId}`, {
759
863
  method: 'POST',
760
864
  headers: authorizedHeaders(this.config, this.impersonationOpts),
761
865
  body: JSON.stringify(body),
762
866
  });
763
867
  };
868
+ #setupSSEConnection() {
869
+ if (this.#sseConnection) {
870
+ this.#sseConnection.close();
871
+ }
872
+ const headers = {
873
+ ...authorizedHeaders(this.config, this.impersonationOpts),
874
+ };
875
+ const inference = !!this.config.schema;
876
+ const ES = makeEventSourceWrapper({ headers, inference });
877
+ const conn = new core_1.SSEConnection(ES, `${this.config.apiURI}/admin/sse?app_id=${this.config.appId}`, `${this.config.apiURI}/admin/sse/push?app_id=${this.config.appId}`);
878
+ conn.onopen = this.#onopen;
879
+ conn.onmessage = this.#onmessage;
880
+ conn.onclose = this.#onclose;
881
+ conn.onerror = this.#onerror;
882
+ this.#sseConnection = conn;
883
+ return conn;
884
+ }
885
+ #ensureSSEConnection() {
886
+ return this.#sseConnection || this.#setupSSEConnection();
887
+ }
888
+ #trySend(eventId, msg) {
889
+ const sseConnection = this.#ensureSSEConnection();
890
+ this.#log.info('[send]', eventId, msg, {
891
+ isOpen: sseConnection.isOpen(),
892
+ });
893
+ if (sseConnection.isOpen()) {
894
+ sseConnection.send({ 'client-event-id': eventId, ...msg });
895
+ }
896
+ }
897
+ #setupInstantStream() {
898
+ this.#ensureSSEConnection();
899
+ const instantStream = new core_1.InstantStream({
900
+ WStream: this.config.WritableStream || WritableStream,
901
+ RStream: this.config.ReadableStream || ReadableStream,
902
+ trySend: (eventId, msg) => {
903
+ this.#trySend(eventId, msg);
904
+ },
905
+ log: this.#log,
906
+ });
907
+ this.#instantStream = instantStream;
908
+ return instantStream;
909
+ }
910
+ #ensureInstantStream() {
911
+ return this.#instantStream || this.#setupInstantStream();
912
+ }
913
+ #onopen = (e) => {
914
+ if (e.target !== this.#sseConnection) {
915
+ this.#log.info('[socket][open]', e.target.id, 'skip; this is no longer the current transport');
916
+ return;
917
+ }
918
+ this.#log.info('[socket][open]', e.target.id);
919
+ this.#sseBackoff = 0;
920
+ this.#instantStream?.onConnectionStatusChange('authenticated');
921
+ };
922
+ #onclose = (e) => {
923
+ if (e.target !== this.#sseConnection) {
924
+ this.#log.info('[socket][close]', e.target.id, 'skip; this is no longer the current transport');
925
+ return;
926
+ }
927
+ this.#log.info('[socket][close]', e.target.id);
928
+ this.#instantStream?.onConnectionStatusChange('closed');
929
+ if (this.#sseConnection) {
930
+ this.#sseConnection = null;
931
+ if (!this.#connectionIsIdle()) {
932
+ // We didn't remove the sse connection, and we have streams we care about, so let's try again
933
+ setTimeout(() => this.#ensureSSEConnection(), this.#sseBackoff);
934
+ this.#sseBackoff = Math.min(15000, Math.max(this.#sseBackoff, 500) * 2);
935
+ }
936
+ }
937
+ };
938
+ #onerror = (e) => {
939
+ if (e.target !== this.#sseConnection) {
940
+ this.#log.info('[socket][error]', e.target.id, 'skip; this is no longer the current transport');
941
+ return;
942
+ }
943
+ this.#log.info('[socket][error]', e.target.id);
944
+ this.#instantStream?.onConnectionStatusChange('closed');
945
+ };
946
+ #connectionIsIdle() {
947
+ return !this.#instantStream || !this.#instantStream.hasActiveStreams();
948
+ }
949
+ #maybeShutdownConnection() {
950
+ if (this.#sseConnection && this.#connectionIsIdle()) {
951
+ const conn = this.#sseConnection;
952
+ this.#log.info('cleaning up unused socket', conn.id);
953
+ this.#sseConnection = null;
954
+ conn.close();
955
+ }
956
+ }
957
+ #onmessage = (e) => {
958
+ if (e.target !== this.#sseConnection) {
959
+ this.#log.info('[socket][message]', e.target.id, 'skip; this is no longer the current transport');
960
+ return;
961
+ }
962
+ const msg = e.message;
963
+ this.#log.info('[receive]', msg);
964
+ switch (msg.op) {
965
+ case 'start-stream-ok': {
966
+ this.#instantStream?.onStartStreamOk(msg);
967
+ break;
968
+ }
969
+ case 'stream-flushed': {
970
+ this.#instantStream?.onStreamFlushed(msg);
971
+ break;
972
+ }
973
+ case 'append-failed': {
974
+ this.#instantStream?.onAppendFailed(msg);
975
+ break;
976
+ }
977
+ case 'stream-append': {
978
+ this.#instantStream?.onStreamAppend(msg);
979
+ break;
980
+ }
981
+ case 'error': {
982
+ switch (msg['original-event']?.op) {
983
+ case 'start-stream':
984
+ case 'append-stream':
985
+ case 'subscribe-stream':
986
+ case 'unsubscribe-stream': {
987
+ this.#instantStream?.onRecieveError(msg);
988
+ break;
989
+ }
990
+ }
991
+ break;
992
+ }
993
+ }
994
+ // Closes the connection if we don't have any items pending
995
+ this.#maybeShutdownConnection();
996
+ };
764
997
  }
765
998
  //# sourceMappingURL=index.js.map