@instantdb/core 0.22.96-experimental.drewh-ts-target.20761590091.1 → 0.22.96-experimental.surgical.20765334274.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.
Files changed (126) hide show
  1. package/dist/commonjs/Connection.js +51 -50
  2. package/dist/commonjs/Connection.js.map +1 -1
  3. package/dist/commonjs/InMemoryStorage.js +32 -13
  4. package/dist/commonjs/InMemoryStorage.js.map +1 -1
  5. package/dist/commonjs/IndexedDBStorage.js +217 -193
  6. package/dist/commonjs/IndexedDBStorage.js.map +1 -1
  7. package/dist/commonjs/InstantError.js +0 -1
  8. package/dist/commonjs/InstantError.js.map +1 -1
  9. package/dist/commonjs/Reactor.js +610 -566
  10. package/dist/commonjs/Reactor.js.map +1 -1
  11. package/dist/commonjs/StorageAPI.js +70 -51
  12. package/dist/commonjs/StorageAPI.js.map +1 -1
  13. package/dist/commonjs/SyncTable.js +81 -68
  14. package/dist/commonjs/SyncTable.js.map +1 -1
  15. package/dist/commonjs/WindowNetworkListener.js +13 -2
  16. package/dist/commonjs/WindowNetworkListener.js.map +1 -1
  17. package/dist/commonjs/__types__/fieldsTypeTest.js +16 -8
  18. package/dist/commonjs/__types__/fieldsTypeTest.js.map +1 -1
  19. package/dist/commonjs/__types__/useDatesTypeTest.js +6 -3
  20. package/dist/commonjs/__types__/useDatesTypeTest.js.map +1 -1
  21. package/dist/commonjs/authAPI.js +79 -62
  22. package/dist/commonjs/authAPI.js.map +1 -1
  23. package/dist/commonjs/createRouteHandler.js +15 -5
  24. package/dist/commonjs/createRouteHandler.js.map +1 -1
  25. package/dist/commonjs/datalog.js +1 -1
  26. package/dist/commonjs/datalog.js.map +1 -1
  27. package/dist/commonjs/devtool.js +8 -26
  28. package/dist/commonjs/devtool.js.map +1 -1
  29. package/dist/commonjs/framework.d.ts.map +1 -1
  30. package/dist/commonjs/framework.js +152 -142
  31. package/dist/commonjs/framework.js.map +1 -1
  32. package/dist/commonjs/index.js +190 -204
  33. package/dist/commonjs/index.js.map +1 -1
  34. package/dist/commonjs/instaml.js +30 -44
  35. package/dist/commonjs/instaml.js.map +1 -1
  36. package/dist/commonjs/instaql.js +33 -25
  37. package/dist/commonjs/instaql.js.map +1 -1
  38. package/dist/commonjs/parseSchemaFromJSON.js +7 -6
  39. package/dist/commonjs/parseSchemaFromJSON.js.map +1 -1
  40. package/dist/commonjs/presence.js +8 -7
  41. package/dist/commonjs/presence.js.map +1 -1
  42. package/dist/commonjs/queryValidation.js +2 -1
  43. package/dist/commonjs/queryValidation.js.map +1 -1
  44. package/dist/commonjs/schema.js +6 -8
  45. package/dist/commonjs/schema.js.map +1 -1
  46. package/dist/commonjs/schemaTypes.js +3 -22
  47. package/dist/commonjs/schemaTypes.js.map +1 -1
  48. package/dist/commonjs/store.js +38 -29
  49. package/dist/commonjs/store.js.map +1 -1
  50. package/dist/commonjs/transactionValidation.js +2 -1
  51. package/dist/commonjs/transactionValidation.js.map +1 -1
  52. package/dist/commonjs/utils/Deferred.js +0 -3
  53. package/dist/commonjs/utils/Deferred.js.map +1 -1
  54. package/dist/commonjs/utils/PersistedObject.js +233 -216
  55. package/dist/commonjs/utils/PersistedObject.js.map +1 -1
  56. package/dist/commonjs/utils/fetch.js +19 -9
  57. package/dist/commonjs/utils/fetch.js.map +1 -1
  58. package/dist/commonjs/utils/linkIndex.js +4 -2
  59. package/dist/commonjs/utils/linkIndex.js.map +1 -1
  60. package/dist/commonjs/utils/object.js +1 -1
  61. package/dist/commonjs/utils/object.js.map +1 -1
  62. package/dist/esm/Connection.js +51 -50
  63. package/dist/esm/Connection.js.map +1 -1
  64. package/dist/esm/InMemoryStorage.js +32 -13
  65. package/dist/esm/InMemoryStorage.js.map +1 -1
  66. package/dist/esm/IndexedDBStorage.js +217 -193
  67. package/dist/esm/IndexedDBStorage.js.map +1 -1
  68. package/dist/esm/InstantError.js +0 -1
  69. package/dist/esm/InstantError.js.map +1 -1
  70. package/dist/esm/Reactor.js +610 -566
  71. package/dist/esm/Reactor.js.map +1 -1
  72. package/dist/esm/StorageAPI.js +70 -51
  73. package/dist/esm/StorageAPI.js.map +1 -1
  74. package/dist/esm/SyncTable.js +81 -68
  75. package/dist/esm/SyncTable.js.map +1 -1
  76. package/dist/esm/WindowNetworkListener.js +13 -2
  77. package/dist/esm/WindowNetworkListener.js.map +1 -1
  78. package/dist/esm/__types__/fieldsTypeTest.js +16 -8
  79. package/dist/esm/__types__/fieldsTypeTest.js.map +1 -1
  80. package/dist/esm/__types__/useDatesTypeTest.js +6 -3
  81. package/dist/esm/__types__/useDatesTypeTest.js.map +1 -1
  82. package/dist/esm/authAPI.js +79 -62
  83. package/dist/esm/authAPI.js.map +1 -1
  84. package/dist/esm/createRouteHandler.js +15 -5
  85. package/dist/esm/createRouteHandler.js.map +1 -1
  86. package/dist/esm/datalog.js +1 -1
  87. package/dist/esm/datalog.js.map +1 -1
  88. package/dist/esm/devtool.js +8 -26
  89. package/dist/esm/devtool.js.map +1 -1
  90. package/dist/esm/framework.d.ts.map +1 -1
  91. package/dist/esm/framework.js +152 -142
  92. package/dist/esm/framework.js.map +1 -1
  93. package/dist/esm/index.js +190 -204
  94. package/dist/esm/index.js.map +1 -1
  95. package/dist/esm/instaml.js +30 -44
  96. package/dist/esm/instaml.js.map +1 -1
  97. package/dist/esm/instaql.js +33 -25
  98. package/dist/esm/instaql.js.map +1 -1
  99. package/dist/esm/parseSchemaFromJSON.js +7 -6
  100. package/dist/esm/parseSchemaFromJSON.js.map +1 -1
  101. package/dist/esm/presence.js +8 -7
  102. package/dist/esm/presence.js.map +1 -1
  103. package/dist/esm/queryValidation.js +2 -1
  104. package/dist/esm/queryValidation.js.map +1 -1
  105. package/dist/esm/schema.js +6 -8
  106. package/dist/esm/schema.js.map +1 -1
  107. package/dist/esm/schemaTypes.js +3 -22
  108. package/dist/esm/schemaTypes.js.map +1 -1
  109. package/dist/esm/store.js +38 -29
  110. package/dist/esm/store.js.map +1 -1
  111. package/dist/esm/transactionValidation.js +2 -1
  112. package/dist/esm/transactionValidation.js.map +1 -1
  113. package/dist/esm/utils/Deferred.js +0 -3
  114. package/dist/esm/utils/Deferred.js.map +1 -1
  115. package/dist/esm/utils/PersistedObject.js +233 -216
  116. package/dist/esm/utils/PersistedObject.js.map +1 -1
  117. package/dist/esm/utils/fetch.js +19 -9
  118. package/dist/esm/utils/fetch.js.map +1 -1
  119. package/dist/esm/utils/linkIndex.js +4 -2
  120. package/dist/esm/utils/linkIndex.js.map +1 -1
  121. package/dist/esm/utils/object.js +1 -1
  122. package/dist/esm/utils/object.js.map +1 -1
  123. package/dist/standalone/index.js +2367 -2610
  124. package/dist/standalone/index.umd.cjs +3 -3
  125. package/package.json +2 -2
  126. package/src/framework.ts +1 -0
package/dist/esm/index.js CHANGED
@@ -25,12 +25,14 @@ const defaultConfig = {
25
25
  };
26
26
  // hmr
27
27
  function initSchemaHashStore() {
28
+ var _a;
28
29
  globalThis.__instantDbSchemaHashStore =
29
- globalThis.__instantDbSchemaHashStore ?? new WeakMap();
30
+ (_a = globalThis.__instantDbSchemaHashStore) !== null && _a !== void 0 ? _a : new WeakMap();
30
31
  return globalThis.__instantDbSchemaHashStore;
31
32
  }
32
33
  function initGlobalInstantCoreStore() {
33
- globalThis.__instantDbStore = globalThis.__instantDbStore ?? {};
34
+ var _a;
35
+ globalThis.__instantDbStore = (_a = globalThis.__instantDbStore) !== null && _a !== void 0 ? _a : {};
34
36
  return globalThis.__instantDbStore;
35
37
  }
36
38
  function reactorKey(config) {
@@ -54,199 +56,197 @@ const schemaHashStore = initSchemaHashStore();
54
56
  * @see https://instantdb.com/docs/auth
55
57
  */
56
58
  class Auth {
57
- db;
58
59
  constructor(db) {
59
60
  this.db = db;
61
+ /**
62
+ * Sends a magic code to the user's email address.
63
+ *
64
+ * Once you send the magic code, see {@link auth.signInWithMagicCode} to let the
65
+ * user verify.
66
+ *
67
+ * @see https://instantdb.com/docs/auth
68
+ * @example
69
+ * db.auth.sendMagicCode({email: "example@gmail.com"})
70
+ * .catch((err) => console.error(err.body?.message))
71
+ */
72
+ this.sendMagicCode = (params) => {
73
+ return this.db.sendMagicCode(params);
74
+ };
75
+ /**
76
+ * Verify a magic code that was sent to the user's email address.
77
+ *
78
+ * @see https://instantdb.com/docs/auth
79
+ *
80
+ * @example
81
+ * db.auth.signInWithMagicCode({email: "example@gmail.com", code: "123456"})
82
+ * .catch((err) => console.error(err.body?.message))
83
+ */
84
+ this.signInWithMagicCode = (params) => {
85
+ return this.db.signInWithMagicCode(params);
86
+ };
87
+ /**
88
+ * Sign in a user with a refresh token
89
+ *
90
+ * @see https://instantdb.com/docs/backend#frontend-auth-sign-in-with-token
91
+ *
92
+ * @example
93
+ * // Get the token from your backend
94
+ * const token = await fetch('/signin', ...);
95
+ * //Sign in
96
+ * db.auth.signInWithToken(token);
97
+ */
98
+ this.signInWithToken = (token) => {
99
+ return this.db.signInWithCustomToken(token);
100
+ };
101
+ /**
102
+ * Sign in as guest, creating a new user without email
103
+ *
104
+ * @see https://instantdb.com/docs/auth
105
+ *
106
+ * @example
107
+ * db.auth.signInAsGuest();
108
+ */
109
+ this.signInAsGuest = () => {
110
+ return this.db.signInAsGuest();
111
+ };
112
+ /**
113
+ * Create an authorization url to sign in with an external provider.
114
+ *
115
+ * @see https://instantdb.com/docs/auth
116
+ *
117
+ * @example
118
+ * // Get the authorization url from your backend
119
+ * const url = db.auth.createAuthorizationUrl({
120
+ * clientName: "google",
121
+ * redirectURL: window.location.href,
122
+ * });
123
+ *
124
+ * // Put it in a sign in link
125
+ * <a href={url}>Log in with Google</a>
126
+ */
127
+ this.createAuthorizationURL = (params) => {
128
+ return this.db.createAuthorizationURL(params);
129
+ };
130
+ /**
131
+ * Sign in with the id_token from an external provider like Google
132
+ *
133
+ * @see https://instantdb.com/docs/auth
134
+ * @example
135
+ * db.auth
136
+ * .signInWithIdToken({
137
+ * // Token from external service
138
+ * idToken: id_token,
139
+ * // The name you gave the client when you registered it with Instant
140
+ * clientName: "google",
141
+ * // The nonce, if any, that you used when you initiated the auth flow
142
+ * // with the external service.
143
+ * nonce: your_nonce
144
+ * })
145
+ * .catch((err) => console.error(err.body?.message));
146
+ *
147
+ */
148
+ this.signInWithIdToken = (params) => {
149
+ return this.db.signInWithIdToken(params);
150
+ };
151
+ /**
152
+ * Sign in with the id_token from an external provider like Google
153
+ *
154
+ * @see https://instantdb.com/docs/auth
155
+ * @example
156
+ * db.auth
157
+ * .exchangeOAuthCode({
158
+ * // code received in redirect from OAuth callback
159
+ * code: code
160
+ * // The PKCE code_verifier, if any, that you used when you
161
+ * // initiated the auth flow
162
+ * codeVerifier: your_code_verifier
163
+ * })
164
+ * .catch((err) => console.error(err.body?.message));
165
+ *
166
+ */
167
+ this.exchangeOAuthCode = (params) => {
168
+ return this.db.exchangeCodeForToken(params);
169
+ };
170
+ /**
171
+ * OpenID Discovery path for use with tools like
172
+ * expo-auth-session that use auto-discovery of
173
+ * OAuth parameters.
174
+ *
175
+ * @see https://instantdb.com/docs/auth
176
+ * @example
177
+ * const discovery = useAutoDiscovery(
178
+ * db.auth.issuerURI()
179
+ * );
180
+ */
181
+ this.issuerURI = () => {
182
+ return this.db.issuerURI();
183
+ };
184
+ /**
185
+ * Sign out the current user
186
+ */
187
+ this.signOut = (opts = { invalidateToken: true }) => {
188
+ return this.db.signOut(opts);
189
+ };
60
190
  }
61
- /**
62
- * Sends a magic code to the user's email address.
63
- *
64
- * Once you send the magic code, see {@link auth.signInWithMagicCode} to let the
65
- * user verify.
66
- *
67
- * @see https://instantdb.com/docs/auth
68
- * @example
69
- * db.auth.sendMagicCode({email: "example@gmail.com"})
70
- * .catch((err) => console.error(err.body?.message))
71
- */
72
- sendMagicCode = (params) => {
73
- return this.db.sendMagicCode(params);
74
- };
75
- /**
76
- * Verify a magic code that was sent to the user's email address.
77
- *
78
- * @see https://instantdb.com/docs/auth
79
- *
80
- * @example
81
- * db.auth.signInWithMagicCode({email: "example@gmail.com", code: "123456"})
82
- * .catch((err) => console.error(err.body?.message))
83
- */
84
- signInWithMagicCode = (params) => {
85
- return this.db.signInWithMagicCode(params);
86
- };
87
- /**
88
- * Sign in a user with a refresh token
89
- *
90
- * @see https://instantdb.com/docs/backend#frontend-auth-sign-in-with-token
91
- *
92
- * @example
93
- * // Get the token from your backend
94
- * const token = await fetch('/signin', ...);
95
- * //Sign in
96
- * db.auth.signInWithToken(token);
97
- */
98
- signInWithToken = (token) => {
99
- return this.db.signInWithCustomToken(token);
100
- };
101
- /**
102
- * Sign in as guest, creating a new user without email
103
- *
104
- * @see https://instantdb.com/docs/auth
105
- *
106
- * @example
107
- * db.auth.signInAsGuest();
108
- */
109
- signInAsGuest = () => {
110
- return this.db.signInAsGuest();
111
- };
112
- /**
113
- * Create an authorization url to sign in with an external provider.
114
- *
115
- * @see https://instantdb.com/docs/auth
116
- *
117
- * @example
118
- * // Get the authorization url from your backend
119
- * const url = db.auth.createAuthorizationUrl({
120
- * clientName: "google",
121
- * redirectURL: window.location.href,
122
- * });
123
- *
124
- * // Put it in a sign in link
125
- * <a href={url}>Log in with Google</a>
126
- */
127
- createAuthorizationURL = (params) => {
128
- return this.db.createAuthorizationURL(params);
129
- };
130
- /**
131
- * Sign in with the id_token from an external provider like Google
132
- *
133
- * @see https://instantdb.com/docs/auth
134
- * @example
135
- * db.auth
136
- * .signInWithIdToken({
137
- * // Token from external service
138
- * idToken: id_token,
139
- * // The name you gave the client when you registered it with Instant
140
- * clientName: "google",
141
- * // The nonce, if any, that you used when you initiated the auth flow
142
- * // with the external service.
143
- * nonce: your_nonce
144
- * })
145
- * .catch((err) => console.error(err.body?.message));
146
- *
147
- */
148
- signInWithIdToken = (params) => {
149
- return this.db.signInWithIdToken(params);
150
- };
151
- /**
152
- * Sign in with the id_token from an external provider like Google
153
- *
154
- * @see https://instantdb.com/docs/auth
155
- * @example
156
- * db.auth
157
- * .exchangeOAuthCode({
158
- * // code received in redirect from OAuth callback
159
- * code: code
160
- * // The PKCE code_verifier, if any, that you used when you
161
- * // initiated the auth flow
162
- * codeVerifier: your_code_verifier
163
- * })
164
- * .catch((err) => console.error(err.body?.message));
165
- *
166
- */
167
- exchangeOAuthCode = (params) => {
168
- return this.db.exchangeCodeForToken(params);
169
- };
170
- /**
171
- * OpenID Discovery path for use with tools like
172
- * expo-auth-session that use auto-discovery of
173
- * OAuth parameters.
174
- *
175
- * @see https://instantdb.com/docs/auth
176
- * @example
177
- * const discovery = useAutoDiscovery(
178
- * db.auth.issuerURI()
179
- * );
180
- */
181
- issuerURI = () => {
182
- return this.db.issuerURI();
183
- };
184
- /**
185
- * Sign out the current user
186
- */
187
- signOut = (opts = { invalidateToken: true }) => {
188
- return this.db.signOut(opts);
189
- };
190
191
  }
191
192
  /**
192
193
  * Functions to manage file storage.
193
194
  */
194
195
  class Storage {
195
- db;
196
196
  constructor(db) {
197
197
  this.db = db;
198
+ /**
199
+ * Uploads file at the provided path.
200
+ *
201
+ * @see https://instantdb.com/docs/storage
202
+ * @example
203
+ * const [file] = e.target.files; // result of file input
204
+ * const data = await db.storage.uploadFile('photos/demo.png', file);
205
+ */
206
+ this.uploadFile = (path, file, opts = {}) => {
207
+ return this.db.uploadFile(path, file, opts);
208
+ };
209
+ /**
210
+ * Deletes a file by path name.
211
+ *
212
+ * @see https://instantdb.com/docs/storage
213
+ * @example
214
+ * await db.storage.delete('photos/demo.png');
215
+ */
216
+ this.delete = (pathname) => {
217
+ return this.db.deleteFile(pathname);
218
+ };
219
+ // Deprecated Storage API (Jan 2025)
220
+ // ---------------------------------
221
+ /**
222
+ * @deprecated. Use `db.storage.uploadFile` instead
223
+ * remove in the future.
224
+ */
225
+ this.upload = (pathname, file) => {
226
+ return this.db.upload(pathname, file);
227
+ };
228
+ /**
229
+ * @deprecated Use `db.storage.uploadFile` instead
230
+ */
231
+ this.put = this.upload;
232
+ /**
233
+ * @deprecated. getDownloadUrl will be removed in the future.
234
+ * Use `useQuery` instead to query and fetch for valid urls
235
+ *
236
+ * db.useQuery({
237
+ * $files: {
238
+ * $: {
239
+ * where: {
240
+ * path: "moop.png"
241
+ * }
242
+ * }
243
+ * }
244
+ * })
245
+ */
246
+ this.getDownloadUrl = (pathname) => {
247
+ return this.db.getDownloadUrl(pathname);
248
+ };
198
249
  }
199
- /**
200
- * Uploads file at the provided path.
201
- *
202
- * @see https://instantdb.com/docs/storage
203
- * @example
204
- * const [file] = e.target.files; // result of file input
205
- * const data = await db.storage.uploadFile('photos/demo.png', file);
206
- */
207
- uploadFile = (path, file, opts = {}) => {
208
- return this.db.uploadFile(path, file, opts);
209
- };
210
- /**
211
- * Deletes a file by path name.
212
- *
213
- * @see https://instantdb.com/docs/storage
214
- * @example
215
- * await db.storage.delete('photos/demo.png');
216
- */
217
- delete = (pathname) => {
218
- return this.db.deleteFile(pathname);
219
- };
220
- // Deprecated Storage API (Jan 2025)
221
- // ---------------------------------
222
- /**
223
- * @deprecated. Use `db.storage.uploadFile` instead
224
- * remove in the future.
225
- */
226
- upload = (pathname, file) => {
227
- return this.db.upload(pathname, file);
228
- };
229
- /**
230
- * @deprecated Use `db.storage.uploadFile` instead
231
- */
232
- put = this.upload;
233
- /**
234
- * @deprecated. getDownloadUrl will be removed in the future.
235
- * Use `useQuery` instead to query and fetch for valid urls
236
- *
237
- * db.useQuery({
238
- * $files: {
239
- * $: {
240
- * where: {
241
- * path: "moop.png"
242
- * }
243
- * }
244
- * }
245
- * })
246
- */
247
- getDownloadUrl = (pathname) => {
248
- return this.db.getDownloadUrl(pathname);
249
- };
250
250
  }
251
251
  // util
252
252
  function coerceQuery(o) {
@@ -254,11 +254,8 @@ function coerceQuery(o) {
254
254
  return JSON.parse(JSON.stringify(o));
255
255
  }
256
256
  class InstantCoreDatabase {
257
- _reactor;
258
- auth;
259
- storage;
260
- tx = txInit();
261
257
  constructor(reactor) {
258
+ this.tx = txInit();
262
259
  this._reactor = reactor;
263
260
  this.auth = new Auth(this._reactor);
264
261
  this.storage = new Storage(this._reactor);
@@ -392,7 +389,7 @@ class InstantCoreDatabase {
392
389
  * room.leaveRoom();
393
390
  */
394
391
  joinRoom(roomType = '_defaultRoomType', roomId = '_defaultRoomId', opts) {
395
- const leaveRoom = this._reactor.joinRoom(roomId, opts?.initialPresence);
392
+ const leaveRoom = this._reactor.joinRoom(roomId, opts === null || opts === void 0 ? void 0 : opts.initialPresence);
396
393
  return {
397
394
  leaveRoom,
398
395
  subscribeTopic: (topic, onEvent) => this._reactor.subscribeTopic(roomId, topic, onEvent),
@@ -476,11 +473,8 @@ function init(
476
473
  // Allows config with missing `useDateObjects`, but keeps `UseDates`
477
474
  // as a non-nullable in the InstantConfig type.
478
475
  config, Storage, NetworkListener, versions, EventSourceImpl) {
479
- const configStrict = {
480
- ...config,
481
- appId: config.appId?.trim(),
482
- useDateObjects: (config.useDateObjects ?? false),
483
- };
476
+ var _a, _b;
477
+ const configStrict = Object.assign(Object.assign({}, config), { appId: (_a = config.appId) === null || _a === void 0 ? void 0 : _a.trim(), useDateObjects: ((_b = config.useDateObjects) !== null && _b !== void 0 ? _b : false) });
484
478
  const existingClient = globalInstantCoreStore[reactorKey(configStrict)];
485
479
  if (existingClient) {
486
480
  if (schemaChanged(existingClient, configStrict.schema)) {
@@ -488,11 +482,7 @@ config, Storage, NetworkListener, versions, EventSourceImpl) {
488
482
  }
489
483
  return existingClient;
490
484
  }
491
- const reactor = new Reactor({
492
- ...defaultConfig,
493
- ...configStrict,
494
- cardinalityInference: configStrict.schema ? true : false,
495
- }, Storage || IndexedDBStorage, NetworkListener || WindowNetworkListener, { ...(versions || {}), '@instantdb/core': version }, EventSourceImpl);
485
+ const reactor = new Reactor(Object.assign(Object.assign(Object.assign({}, defaultConfig), configStrict), { cardinalityInference: configStrict.schema ? true : false }), Storage || IndexedDBStorage, NetworkListener || WindowNetworkListener, Object.assign(Object.assign({}, (versions || {})), { '@instantdb/core': version }), EventSourceImpl);
496
486
  const client = new InstantCoreDatabase(reactor);
497
487
  globalInstantCoreStore[reactorKey(configStrict)] = client;
498
488
  handleDevtool(configStrict.appId, configStrict.devtool);
@@ -507,11 +497,7 @@ function handleDevtool(appId, devtool) {
507
497
  if (typeof devtool === 'boolean' && !devtool) {
508
498
  return;
509
499
  }
510
- const config = {
511
- position: 'bottom-right',
512
- allowedHosts: ['localhost'],
513
- ...(typeof devtool === 'object' ? devtool : {}),
514
- };
500
+ const config = Object.assign({ position: 'bottom-right', allowedHosts: ['localhost'] }, (typeof devtool === 'object' ? devtool : {}));
515
501
  if (!config.allowedHosts.includes(window.location.hostname)) {
516
502
  return;
517
503
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EACL,EAAE,EACF,MAAM,EACN,MAAM,EACN,MAAM,GAGP,MAAM,cAAc,CAAC;AACtB,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,MAAM,eAAe,CAAC;AAC/B,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,gBAAgB,GAEjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAgF/D,OAAO,EAAE,eAAe,EAAwB,MAAM,gBAAgB,CAAC;AAWvE,OAAO,EAAE,eAAe,EAAq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AE,EACF,MAAM,EACN,MAAM,EACN,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe;AAEf,QAAQ;AACR,eAAe;AAEf,MAAM;AACN,CAAC;AAED,OAAO;AACP,MAAM,EACN,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,IAAI,EACJ,OAAO,EACP,OAAO,EACP,YAAY;AAEZ,mBAAmB;AACnB,0BAA0B;AA4G1B,qCAAqC;AACrC,gBAAgB,EAEhB,yBAAyB,GAC1B,CAAC","sourcesContent":["import Reactor from './Reactor.js';\nimport {\n tx,\n txInit,\n lookup,\n getOps,\n type TxChunk,\n type TransactionChunk,\n} from './instatx.js';\nimport weakHash from './utils/weakHash.js';\nimport id from './utils/id.ts';\nimport IndexedDBStorage from './IndexedDBStorage.ts';\nimport { coerceToDate } from './utils/dates.js';\nimport WindowNetworkListener from './WindowNetworkListener.js';\nimport { i } from './schema.js';\nimport { createDevtool } from './devtool.js';\nimport version from './version.ts';\nimport { validateQuery, QueryValidationError } from './queryValidation.ts';\nimport {\n validateTransactions,\n TransactionValidationError,\n} from './transactionValidation.ts';\n\nimport {\n StorageInterface,\n type StorageInterfaceStoreName,\n} from './utils/PersistedObject.ts';\nimport { createInstantRouteHandler } from './createRouteHandler.ts';\nimport { parseSchemaFromJSON } from './parseSchemaFromJSON.ts';\n\nimport type {\n PresenceOpts,\n PresenceResponse,\n PresenceSlice,\n RoomSchemaShape,\n} from './presence.ts';\nimport type {\n DevtoolConfig,\n IDatabase,\n IInstantDatabase,\n StrictDevtoolConfig,\n} from './coreTypes.ts';\nimport type {\n Query,\n QueryResponse,\n InstaQLResponse,\n PageInfoResponse,\n Exactly,\n InstantObject,\n InstaQLParams,\n InstaQLOptions,\n InstaQLQueryParams,\n InstaQLEntity,\n InstaQLEntitySubquery,\n InstaQLResult,\n InstaQLFields,\n ValidQuery,\n} from './queryTypes.ts';\nimport type { PresencePeer } from './presenceTypes.ts';\nimport type {\n AuthState,\n User,\n AuthResult,\n ConnectionStatus,\n} from './clientTypes.ts';\nimport type {\n InstantQuery,\n InstantQueryResult,\n InstantSchema,\n InstantEntity,\n InstantSchemaDatabase,\n} from './helperTypes.ts';\nimport type {\n InstantDBAttr,\n InstantDBAttrOnDelete,\n InstantDBCheckedDataType,\n InstantDBIdent,\n InstantDBInferredType,\n} from './attrTypes.ts';\nimport type {\n AttrsDefs,\n CardinalityKind,\n DataAttrDef,\n EntitiesDef,\n EntitiesWithLinks,\n EntityDef,\n RoomsDef,\n InstantSchemaDef,\n InstantGraph,\n LinkAttrDef,\n LinkDef,\n LinksDef,\n PresenceOf,\n ResolveAttrs,\n RoomsOf,\n TopicsOf,\n TopicOf,\n ValueTypes,\n InstantUnknownSchema,\n InstantUnknownSchemaDef,\n BackwardsCompatibleSchema,\n UpdateParams,\n LinkParams,\n CreateParams,\n RuleParams,\n} from './schemaTypes.ts';\nimport type { InstantRules } from './rulesTypes.ts';\nimport type { UploadFileResponse, DeleteFileResponse } from './StorageAPI.ts';\nimport { FrameworkClient, type FrameworkConfig } from './framework.ts';\n\nimport type {\n ExchangeCodeForTokenParams,\n SendMagicCodeParams,\n SendMagicCodeResponse,\n SignInWithIdTokenParams,\n VerifyMagicCodeParams,\n VerifyResponse,\n} from './authAPI.ts';\n\nimport { InstantAPIError, type InstantIssue } from './utils/fetch.js';\nimport { InstantError } from './InstantError.ts';\nimport { EventSourceType } from './Connection.ts';\nimport { CallbackEventType as SyncTableCallbackEventType } from './SyncTable.ts';\nimport type {\n SyncTableCallback,\n CallbackEvent as SyncTableCallbackEvent,\n InitialSyncBatch as SyncTableInitialSyncBatch,\n InitialSyncComplete as SyncTableInitialSyncComplete,\n SyncTransaction as SyncTableSyncTransaction,\n LoadFromStorage as SyncTableLoadFromStorage,\n SetupError as SyncTableSetupError,\n} from './SyncTable.ts';\n\nconst defaultOpenDevtool = true;\n\n// types\n\ntype ExactlyOne<T> = {\n [K in keyof T]: Pick<T, K> & Partial<Record<Exclude<keyof T, K>, never>>;\n}[keyof T];\n\nexport type Config = {\n appId: string;\n websocketURI?: string;\n apiURI?: string;\n devtool?: boolean | DevtoolConfig;\n verbose?: boolean;\n queryCacheLimit?: number;\n useDateObjects: boolean;\n disableValidation?: boolean;\n};\n\nexport type InstantConfig<\n S extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n> = {\n appId: string;\n schema?: S;\n websocketURI?: string;\n firstPartyPath?: string;\n apiURI?: string;\n devtool?: boolean | DevtoolConfig;\n verbose?: boolean;\n queryCacheLimit?: number;\n useDateObjects: UseDates;\n disableValidation?: boolean;\n};\n\nexport type ConfigWithSchema<S extends InstantGraph<any, any>> = Config & {\n schema: S;\n};\n\nexport type TransactionResult = {\n status: 'synced' | 'enqueued';\n clientId: string;\n};\n\nexport type PublishTopic<TopicsByKey> = <Key extends keyof TopicsByKey>(\n topic: Key,\n data: TopicsByKey[Key],\n) => void;\n\nexport type SubscribeTopic<PresenceShape, TopicsByKey> = <\n Key extends keyof TopicsByKey,\n>(\n topic: Key,\n onEvent: (event: TopicsByKey[Key], peer: PresenceShape) => void,\n) => () => void;\n\nexport type GetPresence<PresenceShape> = <Keys extends keyof PresenceShape>(\n opts: PresenceOpts<PresenceShape, Keys>,\n) => PresenceResponse<PresenceShape, Keys> | null;\n\nexport type SubscribePresence<PresenceShape> = <\n Keys extends keyof PresenceShape,\n>(\n opts: PresenceOpts<PresenceShape, Keys>,\n onChange: (slice: PresenceResponse<PresenceShape, Keys>) => void,\n) => () => void;\n\nexport type RoomHandle<PresenceShape, TopicsByKey> = {\n leaveRoom: () => void;\n publishTopic: PublishTopic<TopicsByKey>;\n subscribeTopic: SubscribeTopic<PresenceShape, TopicsByKey>;\n publishPresence: (data: Partial<PresenceShape>) => void;\n getPresence: GetPresence<PresenceShape>;\n subscribePresence: SubscribePresence<PresenceShape>;\n};\n\ntype AuthToken = string;\n\ntype SubscriptionState<Q, Schema, WithCardinalityInference extends boolean> =\n | { error: { message: string }; data: undefined; pageInfo: undefined }\n | {\n error: undefined;\n data: QueryResponse<Q, Schema, WithCardinalityInference>;\n pageInfo: PageInfoResponse<Q>;\n };\n\ntype InstaQLSubscriptionState<Schema, Q, UseDates extends boolean> =\n | { error: { message: string }; data: undefined; pageInfo: undefined }\n | {\n error: undefined;\n data: InstaQLResponse<Schema, Q, UseDates>;\n pageInfo: PageInfoResponse<Q>;\n };\n\ntype LifecycleSubscriptionState<\n Q,\n Schema,\n WithCardinalityInference extends boolean,\n> = SubscriptionState<Q, Schema, WithCardinalityInference> & {\n isLoading: boolean;\n};\n\ntype InstaQLLifecycleState<Schema, Q, UseDates extends boolean = false> =\n | (InstaQLSubscriptionState<Schema, Q, UseDates> & {\n isLoading: boolean;\n })\n | {\n isLoading: true;\n data: undefined;\n pageInfo: undefined;\n error: undefined;\n };\n\ntype UnsubscribeFn = () => void;\n\n// consts\n\nconst defaultConfig = {\n apiURI: 'https://api.instantdb.com',\n websocketURI: 'wss://api.instantdb.com/runtime/session',\n};\n\n// hmr\nfunction initSchemaHashStore(): WeakMap<any, string> {\n globalThis.__instantDbSchemaHashStore =\n globalThis.__instantDbSchemaHashStore ?? new WeakMap<any, string>();\n return globalThis.__instantDbSchemaHashStore;\n}\n\nfunction initGlobalInstantCoreStore(): Record<string, any> {\n globalThis.__instantDbStore = globalThis.__instantDbStore ?? {};\n return globalThis.__instantDbStore;\n}\n\nfunction reactorKey(config: InstantConfig<any, boolean>): string {\n // @ts-expect-error\n const adminToken = config.__adminToken;\n return (\n config.appId +\n '_' +\n (config.websocketURI || 'default_ws_uri') +\n '_' +\n (config.apiURI || 'default_api_uri') +\n '_' +\n (adminToken || 'client_only') +\n '_' +\n config.useDateObjects\n );\n}\n\nconst globalInstantCoreStore = initGlobalInstantCoreStore();\nconst schemaHashStore = initSchemaHashStore();\n\ntype SignoutOpts = {\n invalidateToken?: boolean;\n};\n\n/**\n * Functions to log users in and out.\n *\n * @see https://instantdb.com/docs/auth\n */\nclass Auth {\n constructor(private db: Reactor) {}\n\n /**\n * Sends a magic code to the user's email address.\n *\n * Once you send the magic code, see {@link auth.signInWithMagicCode} to let the\n * user verify.\n *\n * @see https://instantdb.com/docs/auth\n * @example\n * db.auth.sendMagicCode({email: \"example@gmail.com\"})\n * .catch((err) => console.error(err.body?.message))\n */\n sendMagicCode = (\n params: SendMagicCodeParams,\n ): Promise<SendMagicCodeResponse> => {\n return this.db.sendMagicCode(params);\n };\n\n /**\n * Verify a magic code that was sent to the user's email address.\n *\n * @see https://instantdb.com/docs/auth\n *\n * @example\n * db.auth.signInWithMagicCode({email: \"example@gmail.com\", code: \"123456\"})\n * .catch((err) => console.error(err.body?.message))\n */\n signInWithMagicCode = (\n params: VerifyMagicCodeParams,\n ): Promise<VerifyResponse> => {\n return this.db.signInWithMagicCode(params);\n };\n\n /**\n * Sign in a user with a refresh token\n *\n * @see https://instantdb.com/docs/backend#frontend-auth-sign-in-with-token\n *\n * @example\n * // Get the token from your backend\n * const token = await fetch('/signin', ...);\n * //Sign in\n * db.auth.signInWithToken(token);\n */\n signInWithToken = (token: AuthToken): Promise<VerifyResponse> => {\n return this.db.signInWithCustomToken(token);\n };\n\n /**\n * Sign in as guest, creating a new user without email\n *\n * @see https://instantdb.com/docs/auth\n *\n * @example\n * db.auth.signInAsGuest();\n */\n signInAsGuest = (): Promise<VerifyResponse> => {\n return this.db.signInAsGuest();\n };\n\n /**\n * Create an authorization url to sign in with an external provider.\n *\n * @see https://instantdb.com/docs/auth\n *\n * @example\n * // Get the authorization url from your backend\n * const url = db.auth.createAuthorizationUrl({\n * clientName: \"google\",\n * redirectURL: window.location.href,\n * });\n *\n * // Put it in a sign in link\n * <a href={url}>Log in with Google</a>\n */\n createAuthorizationURL = (params: {\n clientName: string;\n redirectURL: string;\n }): string => {\n return this.db.createAuthorizationURL(params);\n };\n\n /**\n * Sign in with the id_token from an external provider like Google\n *\n * @see https://instantdb.com/docs/auth\n * @example\n * db.auth\n * .signInWithIdToken({\n * // Token from external service\n * idToken: id_token,\n * // The name you gave the client when you registered it with Instant\n * clientName: \"google\",\n * // The nonce, if any, that you used when you initiated the auth flow\n * // with the external service.\n * nonce: your_nonce\n * })\n * .catch((err) => console.error(err.body?.message));\n *\n */\n signInWithIdToken = (\n params: SignInWithIdTokenParams,\n ): Promise<VerifyResponse> => {\n return this.db.signInWithIdToken(params);\n };\n\n /**\n * Sign in with the id_token from an external provider like Google\n *\n * @see https://instantdb.com/docs/auth\n * @example\n * db.auth\n * .exchangeOAuthCode({\n * // code received in redirect from OAuth callback\n * code: code\n * // The PKCE code_verifier, if any, that you used when you\n * // initiated the auth flow\n * codeVerifier: your_code_verifier\n * })\n * .catch((err) => console.error(err.body?.message));\n *\n */\n exchangeOAuthCode = (params: ExchangeCodeForTokenParams) => {\n return this.db.exchangeCodeForToken(params);\n };\n\n /**\n * OpenID Discovery path for use with tools like\n * expo-auth-session that use auto-discovery of\n * OAuth parameters.\n *\n * @see https://instantdb.com/docs/auth\n * @example\n * const discovery = useAutoDiscovery(\n * db.auth.issuerURI()\n * );\n */\n issuerURI = (): string => {\n return this.db.issuerURI();\n };\n\n /**\n * Sign out the current user\n */\n signOut = (opts: SignoutOpts = { invalidateToken: true }): Promise<void> => {\n return this.db.signOut(opts);\n };\n}\n\ntype FileOpts = {\n contentType?: string;\n contentDisposition?: string;\n fileSize?: number; // Required for streaming uploads\n};\n\n/**\n * Functions to manage file storage.\n */\nclass Storage {\n constructor(private db: Reactor) {}\n\n /**\n * Uploads file at the provided path.\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * const [file] = e.target.files; // result of file input\n * const data = await db.storage.uploadFile('photos/demo.png', file);\n */\n uploadFile = (\n path: string,\n file: File | Blob,\n opts: FileOpts = {},\n ): Promise<UploadFileResponse> => {\n return this.db.uploadFile(path, file, opts);\n };\n\n /**\n * Deletes a file by path name.\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * await db.storage.delete('photos/demo.png');\n */\n delete = (pathname: string) => {\n return this.db.deleteFile(pathname);\n };\n\n // Deprecated Storage API (Jan 2025)\n // ---------------------------------\n\n /**\n * @deprecated. Use `db.storage.uploadFile` instead\n * remove in the future.\n */\n upload = (pathname: string, file: File) => {\n return this.db.upload(pathname, file);\n };\n\n /**\n * @deprecated Use `db.storage.uploadFile` instead\n */\n put = this.upload;\n\n /**\n * @deprecated. getDownloadUrl will be removed in the future.\n * Use `useQuery` 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 = (pathname: string) => {\n return this.db.getDownloadUrl(pathname);\n };\n}\n\n// util\n\nfunction coerceQuery(o: any) {\n // stringify and parse to remove undefined values\n return JSON.parse(JSON.stringify(o));\n}\n\nclass InstantCoreDatabase<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n> implements IInstantDatabase<Schema>\n{\n public _reactor: Reactor<RoomsOf<Schema>>;\n public auth: Auth;\n public storage: Storage;\n\n public tx = txInit<Schema>();\n\n constructor(reactor: Reactor<RoomsOf<Schema>>) {\n this._reactor = reactor;\n this.auth = new Auth(this._reactor);\n this.storage = new Storage(this._reactor);\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 chunks: TransactionChunk<any, any> | TransactionChunk<any, any>[],\n ): Promise<TransactionResult> {\n return this._reactor.pushTx(chunks);\n }\n\n getLocalId(name: string): Promise<string> {\n return this._reactor.getLocalId(name);\n }\n\n /**\n * Use this to query your data!\n *\n * @see https://instantdb.com/docs/instaql\n *\n * @example\n * // listen to all goals\n * db.subscribeQuery({ goals: {} }, (resp) => {\n * console.log(resp.data.goals)\n * })\n *\n * // goals where the title is \"Get Fit\"\n * db.subscribeQuery(\n * { goals: { $: { where: { title: \"Get Fit\" } } } },\n * (resp) => {\n * console.log(resp.data.goals)\n * }\n * )\n *\n * // all goals, _alongside_ their todos\n * db.subscribeQuery({ goals: { todos: {} } }, (resp) => {\n * console.log(resp.data.goals)\n * });\n */\n subscribeQuery<\n Q extends ValidQuery<Q, Schema>,\n UseDatesLocal extends boolean = UseDates,\n >(\n query: Q,\n cb: (resp: InstaQLSubscriptionState<Schema, Q, UseDatesLocal>) => void,\n opts?: InstaQLOptions,\n ) {\n return this._reactor.subscribeQuery(query, cb, opts);\n }\n\n /**\n * Listen for the logged in state. This is useful\n * for deciding when to show a login screen.\n *\n * @see https://instantdb.com/docs/auth\n * @example\n * const unsub = db.subscribeAuth((auth) => {\n * if (auth.user) {\n * console.log('logged in as', auth.user.email)\n * } else {\n * console.log('logged out')\n * }\n * })\n */\n subscribeAuth(cb: (auth: AuthResult) => void): UnsubscribeFn {\n return this._reactor.subscribeAuth(cb);\n }\n\n /**\n * One time query for the logged in state. This is useful\n * for scenarios where you want to know the current auth\n * state without subscribing to changes.\n *\n * @see https://instantdb.com/docs/auth\n * @example\n * const user = await db.getAuth();\n * console.log('logged in as', user.email)\n */\n getAuth(): Promise<User | null> {\n return this._reactor.getAuth();\n }\n\n /**\n * Listen for connection status changes to Instant. This is useful\n * for building things like connectivity indicators\n *\n * @see https://www.instantdb.com/docs/patterns#connection-status\n * @example\n * const unsub = db.subscribeConnectionStatus((status) => {\n * const connectionState =\n * status === 'connecting' || status === 'opened'\n * ? 'authenticating'\n * : status === 'authenticated'\n * ? 'connected'\n * : status === 'closed'\n * ? 'closed'\n * : status === 'errored'\n * ? 'errored'\n * : 'unexpected state';\n *\n * console.log('Connection status:', connectionState);\n * });\n */\n subscribeConnectionStatus(\n cb: (status: ConnectionStatus) => void,\n ): UnsubscribeFn {\n return this._reactor.subscribeConnectionStatus(cb);\n }\n\n /**\n * Join a room to publish and subscribe to topics and presence.\n *\n * @see https://instantdb.com/docs/presence-and-topics\n * @example\n * // init\n * const db = init();\n * const room = db.joinRoom(roomType, roomId);\n * // usage\n * const unsubscribeTopic = room.subscribeTopic(\"foo\", console.log);\n * const unsubscribePresence = room.subscribePresence({}, console.log);\n * room.publishTopic(\"hello\", { message: \"hello world!\" });\n * room.publishPresence({ name: \"joe\" });\n * // later\n * unsubscribePresence();\n * unsubscribeTopic();\n * room.leaveRoom();\n */\n joinRoom<RoomType extends keyof RoomsOf<Schema>>(\n roomType: RoomType = '_defaultRoomType' as RoomType,\n roomId: string = '_defaultRoomId',\n opts?: {\n initialPresence?: Partial<PresenceOf<Schema, RoomType>>;\n },\n ): RoomHandle<PresenceOf<Schema, RoomType>, TopicsOf<Schema, RoomType>> {\n const leaveRoom = this._reactor.joinRoom(roomId, opts?.initialPresence);\n\n return {\n leaveRoom,\n subscribeTopic: (topic, onEvent) =>\n this._reactor.subscribeTopic(roomId, topic, onEvent),\n subscribePresence: (opts, onChange) =>\n this._reactor.subscribePresence(roomType, roomId, opts, onChange),\n publishTopic: (topic, data) =>\n this._reactor.publishTopic({ roomType, roomId, topic, data }),\n publishPresence: (data) =>\n this._reactor.publishPresence(roomType, roomId, data),\n getPresence: (opts) => this._reactor.getPresence(roomType, roomId, opts),\n };\n }\n\n shutdown() {\n delete globalInstantCoreStore[reactorKey(this._reactor.config)];\n this._reactor.shutdown();\n }\n\n /**\n * Use this for one-off queries.\n * Returns local data if available, otherwise fetches from the server.\n * Because we want to avoid stale data, this method will throw an error\n * if the user is offline or there is no active connection to the server.\n *\n * @see https://instantdb.com/docs/instaql\n *\n * @example\n *\n * const resp = await db.queryOnce({ goals: {} });\n * console.log(resp.data.goals)\n */\n queryOnce<Q extends ValidQuery<Q, Schema>>(\n query: Q,\n opts?: InstaQLOptions,\n ): Promise<{\n data: InstaQLResponse<Schema, Q, UseDates>;\n pageInfo: PageInfoResponse<Q>;\n }> {\n return this._reactor.queryOnce(query, opts);\n }\n\n /**\n * @deprecated This is an experimental function that is not yet ready for production use.\n * Use this function to sync an entire namespace.\n * It has many limitations that will be removed in the future:\n * 1. Must be used with an admin token\n * 2. Does not support permissions\n * 3. Does not support where clauses\n * 4. Does not support links\n * It also does not support multiple top-level namespaces. For example,\n * {posts: {}, users: {}} is invalid. Only `posts` or `users` is allowed, but not both.\n */\n _syncTableExperimental<Q extends ValidQuery<Q, Schema>>(\n query: ExactlyOne<Q>,\n cb: SyncTableCallback<Schema, Q, UseDates>,\n ): (\n opts?: { keepSubscription: boolean | null | undefined } | null | undefined,\n ) => void {\n return this._reactor.subscribeTable(query, cb);\n }\n}\n\nfunction schemaHash(schema?: InstantSchemaDef<any, any, any>): string {\n if (!schema) {\n return '0';\n }\n\n const fromStore = schemaHashStore.get(schema);\n if (fromStore) {\n return fromStore;\n }\n const hash = weakHash(schema);\n schemaHashStore.set(schema, hash);\n return hash;\n}\n\nfunction schemaChanged(\n existingClient: InstantCoreDatabase<any, boolean>,\n newSchema?: InstantSchemaDef<any, any, any>,\n): boolean {\n return (\n schemaHash(existingClient._reactor.config.schema) !== schemaHash(newSchema)\n );\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/core\"\n *\n * const db = init({ appId: \"my-app-id\" })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@instantdb/core\"\n * import schema from \"\"../instant.schema.ts\";\n *\n * const db = init({ appId: \"my-app-id\", 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 Storage?: any,\n NetworkListener?: any,\n versions?: { [key: string]: string },\n EventSourceImpl?: any,\n): InstantCoreDatabase<Schema, UseDates> {\n const configStrict = {\n ...config,\n appId: config.appId?.trim(),\n useDateObjects: (config.useDateObjects ?? false) as UseDates,\n };\n const existingClient = globalInstantCoreStore[\n reactorKey(configStrict)\n ] as InstantCoreDatabase<any, UseDates>;\n\n if (existingClient) {\n if (schemaChanged(existingClient, configStrict.schema)) {\n existingClient._reactor.updateSchema(configStrict.schema);\n }\n return existingClient;\n }\n\n const reactor = new Reactor<RoomsOf<Schema>>(\n {\n ...defaultConfig,\n ...configStrict,\n cardinalityInference: configStrict.schema ? true : false,\n },\n Storage || IndexedDBStorage,\n NetworkListener || WindowNetworkListener,\n { ...(versions || {}), '@instantdb/core': version },\n EventSourceImpl,\n );\n\n const client = new InstantCoreDatabase<any, UseDates>(reactor);\n globalInstantCoreStore[reactorKey(configStrict)] = client;\n\n handleDevtool(configStrict.appId, configStrict.devtool);\n\n return client;\n}\n\nfunction handleDevtool(\n appId: string,\n devtool: boolean | DevtoolConfig | null | undefined,\n) {\n if (\n typeof window === 'undefined' ||\n typeof window.location === 'undefined' ||\n typeof document === 'undefined'\n ) {\n return;\n }\n\n if (typeof devtool === 'boolean' && !devtool) {\n return;\n }\n\n const config: StrictDevtoolConfig = {\n position: 'bottom-right' as const,\n allowedHosts: ['localhost'],\n ...(typeof devtool === 'object' ? devtool : {}),\n };\n\n if (!config.allowedHosts.includes(window.location.hostname)) {\n return;\n }\n\n createDevtool(appId, config);\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/core\"\n * const db = init_experimental({ ... });\n *\n * // After\n * import { init } from \"@instantdb/core\"\n * const db = init({ ... });\n */\nconst init_experimental = init;\n\nexport {\n // bada bing bada boom\n init,\n init_experimental,\n id,\n tx,\n txInit,\n lookup,\n validateQuery,\n QueryValidationError,\n validateTransactions,\n parseSchemaFromJSON,\n TransactionValidationError,\n FrameworkClient,\n\n // error\n InstantAPIError,\n\n // cli\n i,\n\n // util\n getOps,\n coerceQuery,\n weakHash,\n coerceToDate,\n IndexedDBStorage,\n WindowNetworkListener,\n InstantCoreDatabase,\n Auth,\n Storage,\n version,\n InstantError,\n\n // sync table enums\n SyncTableCallbackEventType,\n\n // og types\n type IDatabase,\n type RoomSchemaShape,\n type Query,\n type QueryResponse,\n type InstaQLResponse,\n type PageInfoResponse,\n type InstantObject,\n type Exactly,\n type TransactionChunk,\n type AuthState,\n type ConnectionStatus,\n type User,\n type AuthToken,\n type TxChunk,\n type SubscriptionState,\n type InstaQLSubscriptionState,\n type LifecycleSubscriptionState,\n type InstaQLLifecycleState,\n\n // presence types\n type PresenceOpts,\n type PresenceSlice,\n type PresenceResponse,\n type PresencePeer,\n\n // new query types\n type InstaQLParams,\n type ValidQuery,\n type InstaQLOptions,\n type InstaQLQueryParams,\n type InstantQuery,\n type InstantQueryResult,\n type InstantSchema,\n type InstantEntity,\n type InstantSchemaDatabase,\n type InstaQLFields,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type InstantUnknownSchemaDef,\n type EntitiesWithLinks,\n type EntityDef,\n type RoomsDef,\n type InstantGraph,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type ValueTypes,\n type RoomsOf,\n type PresenceOf,\n type TopicsOf,\n type TopicOf,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type InstantSchemaDef,\n type InstantUnknownSchema,\n type IInstantDatabase,\n type BackwardsCompatibleSchema,\n type InstantRules,\n type UpdateParams,\n type LinkParams,\n type CreateParams,\n type RuleParams,\n\n // attr types\n type InstantDBAttr,\n type InstantDBAttrOnDelete,\n type InstantDBCheckedDataType,\n type InstantDBIdent,\n type InstantDBInferredType,\n\n // auth types\n type ExchangeCodeForTokenParams,\n type SendMagicCodeParams,\n type SendMagicCodeResponse,\n type SignInWithIdTokenParams,\n type VerifyMagicCodeParams,\n type VerifyResponse,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n\n // SSE\n type EventSourceType,\n type FrameworkConfig,\n\n // sync table types\n type SyncTableCallback,\n type SyncTableCallbackEvent,\n type SyncTableInitialSyncBatch,\n type SyncTableInitialSyncComplete,\n type SyncTableSyncTransaction,\n type SyncTableLoadFromStorage,\n type SyncTableSetupError,\n\n // error types\n type InstantIssue,\n\n // storage (e.g. indexeddb) interface\n StorageInterface,\n type StorageInterfaceStoreName,\n createInstantRouteHandler,\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EACL,EAAE,EACF,MAAM,EACN,MAAM,EACN,MAAM,GAGP,MAAM,cAAc,CAAC;AACtB,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,MAAM,eAAe,CAAC;AAC/B,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,gBAAgB,GAEjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,y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AAiB,GAAG,IAAI,CAAC;AAE/B,OAAO;AACL,sBAAsB;AACtB,IAAI,EACJ,iBAAiB,EACjB,EAAE,EACF,EAAE,EACF,MAAM,EACN,MAAM,EACN,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe;AAEf,QAAQ;AACR,eAAe;AAEf,MAAM;AACN,CAAC;AAED,OAAO;AACP,MAAM,EACN,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,IAAI,EACJ,OAAO,EACP,OAAO,EACP,YAAY;AAEZ,mBAAmB;AACnB,0BAA0B;AA4G1B,qCAAqC;AACrC,gBAAgB,EAEhB,yBAAyB,GAC1B,CAAC","sourcesContent":["import Reactor from './Reactor.js';\nimport {\n tx,\n txInit,\n lookup,\n getOps,\n type TxChunk,\n type TransactionChunk,\n} from './instatx.js';\nimport weakHash from './utils/weakHash.js';\nimport id from './utils/id.ts';\nimport IndexedDBStorage from './IndexedDBStorage.ts';\nimport { coerceToDate } from './utils/dates.js';\nimport WindowNetworkListener from './WindowNetworkListener.js';\nimport { i } from './schema.js';\nimport { createDevtool } from './devtool.js';\nimport version from './version.ts';\nimport { validateQuery, QueryValidationError } from './queryValidation.ts';\nimport {\n validateTransactions,\n TransactionValidationError,\n} from './transactionValidation.ts';\n\nimport {\n StorageInterface,\n type StorageInterfaceStoreName,\n} from './utils/PersistedObject.ts';\nimport { createInstantRouteHandler } from './createRouteHandler.ts';\nimport { parseSchemaFromJSON } from './parseSchemaFromJSON.ts';\n\nimport type {\n PresenceOpts,\n PresenceResponse,\n PresenceSlice,\n RoomSchemaShape,\n} from './presence.ts';\nimport type {\n DevtoolConfig,\n IDatabase,\n IInstantDatabase,\n StrictDevtoolConfig,\n} from './coreTypes.ts';\nimport type {\n Query,\n QueryResponse,\n InstaQLResponse,\n PageInfoResponse,\n Exactly,\n InstantObject,\n InstaQLParams,\n InstaQLOptions,\n InstaQLQueryParams,\n InstaQLEntity,\n InstaQLEntitySubquery,\n InstaQLResult,\n InstaQLFields,\n ValidQuery,\n} from './queryTypes.ts';\nimport type { PresencePeer } from './presenceTypes.ts';\nimport type {\n AuthState,\n User,\n AuthResult,\n ConnectionStatus,\n} from './clientTypes.ts';\nimport type {\n InstantQuery,\n InstantQueryResult,\n InstantSchema,\n InstantEntity,\n InstantSchemaDatabase,\n} from './helperTypes.ts';\nimport type {\n InstantDBAttr,\n InstantDBAttrOnDelete,\n InstantDBCheckedDataType,\n InstantDBIdent,\n InstantDBInferredType,\n} from './attrTypes.ts';\nimport type {\n AttrsDefs,\n CardinalityKind,\n DataAttrDef,\n EntitiesDef,\n EntitiesWithLinks,\n EntityDef,\n RoomsDef,\n InstantSchemaDef,\n InstantGraph,\n LinkAttrDef,\n LinkDef,\n LinksDef,\n PresenceOf,\n ResolveAttrs,\n RoomsOf,\n TopicsOf,\n TopicOf,\n ValueTypes,\n InstantUnknownSchema,\n InstantUnknownSchemaDef,\n BackwardsCompatibleSchema,\n UpdateParams,\n LinkParams,\n CreateParams,\n RuleParams,\n} from './schemaTypes.ts';\nimport type { InstantRules } from './rulesTypes.ts';\nimport type { UploadFileResponse, DeleteFileResponse } from './StorageAPI.ts';\nimport { FrameworkClient, type FrameworkConfig } from './framework.ts';\n\nimport type {\n ExchangeCodeForTokenParams,\n SendMagicCodeParams,\n SendMagicCodeResponse,\n SignInWithIdTokenParams,\n VerifyMagicCodeParams,\n VerifyResponse,\n} from './authAPI.ts';\n\nimport { InstantAPIError, type InstantIssue } from './utils/fetch.js';\nimport { InstantError } from './InstantError.ts';\nimport { EventSourceType } from './Connection.ts';\nimport { CallbackEventType as SyncTableCallbackEventType } from './SyncTable.ts';\nimport type {\n SyncTableCallback,\n CallbackEvent as SyncTableCallbackEvent,\n InitialSyncBatch as SyncTableInitialSyncBatch,\n InitialSyncComplete as SyncTableInitialSyncComplete,\n SyncTransaction as SyncTableSyncTransaction,\n LoadFromStorage as SyncTableLoadFromStorage,\n SetupError as SyncTableSetupError,\n} from './SyncTable.ts';\n\nconst defaultOpenDevtool = true;\n\n// types\n\ntype ExactlyOne<T> = {\n [K in keyof T]: Pick<T, K> & Partial<Record<Exclude<keyof T, K>, never>>;\n}[keyof T];\n\nexport type Config = {\n appId: string;\n websocketURI?: string;\n apiURI?: string;\n devtool?: boolean | DevtoolConfig;\n verbose?: boolean;\n queryCacheLimit?: number;\n useDateObjects: boolean;\n disableValidation?: boolean;\n};\n\nexport type InstantConfig<\n S extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n> = {\n appId: string;\n schema?: S;\n websocketURI?: string;\n firstPartyPath?: string;\n apiURI?: string;\n devtool?: boolean | DevtoolConfig;\n verbose?: boolean;\n queryCacheLimit?: number;\n useDateObjects: UseDates;\n disableValidation?: boolean;\n};\n\nexport type ConfigWithSchema<S extends InstantGraph<any, any>> = Config & {\n schema: S;\n};\n\nexport type TransactionResult = {\n status: 'synced' | 'enqueued';\n clientId: string;\n};\n\nexport type PublishTopic<TopicsByKey> = <Key extends keyof TopicsByKey>(\n topic: Key,\n data: TopicsByKey[Key],\n) => void;\n\nexport type SubscribeTopic<PresenceShape, TopicsByKey> = <\n Key extends keyof TopicsByKey,\n>(\n topic: Key,\n onEvent: (event: TopicsByKey[Key], peer: PresenceShape) => void,\n) => () => void;\n\nexport type GetPresence<PresenceShape> = <Keys extends keyof PresenceShape>(\n opts: PresenceOpts<PresenceShape, Keys>,\n) => PresenceResponse<PresenceShape, Keys> | null;\n\nexport type SubscribePresence<PresenceShape> = <\n Keys extends keyof PresenceShape,\n>(\n opts: PresenceOpts<PresenceShape, Keys>,\n onChange: (slice: PresenceResponse<PresenceShape, Keys>) => void,\n) => () => void;\n\nexport type RoomHandle<PresenceShape, TopicsByKey> = {\n leaveRoom: () => void;\n publishTopic: PublishTopic<TopicsByKey>;\n subscribeTopic: SubscribeTopic<PresenceShape, TopicsByKey>;\n publishPresence: (data: Partial<PresenceShape>) => void;\n getPresence: GetPresence<PresenceShape>;\n subscribePresence: SubscribePresence<PresenceShape>;\n};\n\ntype AuthToken = string;\n\ntype SubscriptionState<Q, Schema, WithCardinalityInference extends boolean> =\n | { error: { message: string }; data: undefined; pageInfo: undefined }\n | {\n error: undefined;\n data: QueryResponse<Q, Schema, WithCardinalityInference>;\n pageInfo: PageInfoResponse<Q>;\n };\n\ntype InstaQLSubscriptionState<Schema, Q, UseDates extends boolean> =\n | { error: { message: string }; data: undefined; pageInfo: undefined }\n | {\n error: undefined;\n data: InstaQLResponse<Schema, Q, UseDates>;\n pageInfo: PageInfoResponse<Q>;\n };\n\ntype LifecycleSubscriptionState<\n Q,\n Schema,\n WithCardinalityInference extends boolean,\n> = SubscriptionState<Q, Schema, WithCardinalityInference> & {\n isLoading: boolean;\n};\n\ntype InstaQLLifecycleState<Schema, Q, UseDates extends boolean = false> =\n | (InstaQLSubscriptionState<Schema, Q, UseDates> & {\n isLoading: boolean;\n })\n | {\n isLoading: true;\n data: undefined;\n pageInfo: undefined;\n error: undefined;\n };\n\ntype UnsubscribeFn = () => void;\n\n// consts\n\nconst defaultConfig = {\n apiURI: 'https://api.instantdb.com',\n websocketURI: 'wss://api.instantdb.com/runtime/session',\n};\n\n// hmr\nfunction initSchemaHashStore(): WeakMap<any, string> {\n globalThis.__instantDbSchemaHashStore =\n globalThis.__instantDbSchemaHashStore ?? new WeakMap<any, string>();\n return globalThis.__instantDbSchemaHashStore;\n}\n\nfunction initGlobalInstantCoreStore(): Record<string, any> {\n globalThis.__instantDbStore = globalThis.__instantDbStore ?? {};\n return globalThis.__instantDbStore;\n}\n\nfunction reactorKey(config: InstantConfig<any, boolean>): string {\n // @ts-expect-error\n const adminToken = config.__adminToken;\n return (\n config.appId +\n '_' +\n (config.websocketURI || 'default_ws_uri') +\n '_' +\n (config.apiURI || 'default_api_uri') +\n '_' +\n (adminToken || 'client_only') +\n '_' +\n config.useDateObjects\n );\n}\n\nconst globalInstantCoreStore = initGlobalInstantCoreStore();\nconst schemaHashStore = initSchemaHashStore();\n\ntype SignoutOpts = {\n invalidateToken?: boolean;\n};\n\n/**\n * Functions to log users in and out.\n *\n * @see https://instantdb.com/docs/auth\n */\nclass Auth {\n constructor(private db: Reactor) {}\n\n /**\n * Sends a magic code to the user's email address.\n *\n * Once you send the magic code, see {@link auth.signInWithMagicCode} to let the\n * user verify.\n *\n * @see https://instantdb.com/docs/auth\n * @example\n * db.auth.sendMagicCode({email: \"example@gmail.com\"})\n * .catch((err) => console.error(err.body?.message))\n */\n sendMagicCode = (\n params: SendMagicCodeParams,\n ): Promise<SendMagicCodeResponse> => {\n return this.db.sendMagicCode(params);\n };\n\n /**\n * Verify a magic code that was sent to the user's email address.\n *\n * @see https://instantdb.com/docs/auth\n *\n * @example\n * db.auth.signInWithMagicCode({email: \"example@gmail.com\", code: \"123456\"})\n * .catch((err) => console.error(err.body?.message))\n */\n signInWithMagicCode = (\n params: VerifyMagicCodeParams,\n ): Promise<VerifyResponse> => {\n return this.db.signInWithMagicCode(params);\n };\n\n /**\n * Sign in a user with a refresh token\n *\n * @see https://instantdb.com/docs/backend#frontend-auth-sign-in-with-token\n *\n * @example\n * // Get the token from your backend\n * const token = await fetch('/signin', ...);\n * //Sign in\n * db.auth.signInWithToken(token);\n */\n signInWithToken = (token: AuthToken): Promise<VerifyResponse> => {\n return this.db.signInWithCustomToken(token);\n };\n\n /**\n * Sign in as guest, creating a new user without email\n *\n * @see https://instantdb.com/docs/auth\n *\n * @example\n * db.auth.signInAsGuest();\n */\n signInAsGuest = (): Promise<VerifyResponse> => {\n return this.db.signInAsGuest();\n };\n\n /**\n * Create an authorization url to sign in with an external provider.\n *\n * @see https://instantdb.com/docs/auth\n *\n * @example\n * // Get the authorization url from your backend\n * const url = db.auth.createAuthorizationUrl({\n * clientName: \"google\",\n * redirectURL: window.location.href,\n * });\n *\n * // Put it in a sign in link\n * <a href={url}>Log in with Google</a>\n */\n createAuthorizationURL = (params: {\n clientName: string;\n redirectURL: string;\n }): string => {\n return this.db.createAuthorizationURL(params);\n };\n\n /**\n * Sign in with the id_token from an external provider like Google\n *\n * @see https://instantdb.com/docs/auth\n * @example\n * db.auth\n * .signInWithIdToken({\n * // Token from external service\n * idToken: id_token,\n * // The name you gave the client when you registered it with Instant\n * clientName: \"google\",\n * // The nonce, if any, that you used when you initiated the auth flow\n * // with the external service.\n * nonce: your_nonce\n * })\n * .catch((err) => console.error(err.body?.message));\n *\n */\n signInWithIdToken = (\n params: SignInWithIdTokenParams,\n ): Promise<VerifyResponse> => {\n return this.db.signInWithIdToken(params);\n };\n\n /**\n * Sign in with the id_token from an external provider like Google\n *\n * @see https://instantdb.com/docs/auth\n * @example\n * db.auth\n * .exchangeOAuthCode({\n * // code received in redirect from OAuth callback\n * code: code\n * // The PKCE code_verifier, if any, that you used when you\n * // initiated the auth flow\n * codeVerifier: your_code_verifier\n * })\n * .catch((err) => console.error(err.body?.message));\n *\n */\n exchangeOAuthCode = (params: ExchangeCodeForTokenParams) => {\n return this.db.exchangeCodeForToken(params);\n };\n\n /**\n * OpenID Discovery path for use with tools like\n * expo-auth-session that use auto-discovery of\n * OAuth parameters.\n *\n * @see https://instantdb.com/docs/auth\n * @example\n * const discovery = useAutoDiscovery(\n * db.auth.issuerURI()\n * );\n */\n issuerURI = (): string => {\n return this.db.issuerURI();\n };\n\n /**\n * Sign out the current user\n */\n signOut = (opts: SignoutOpts = { invalidateToken: true }): Promise<void> => {\n return this.db.signOut(opts);\n };\n}\n\ntype FileOpts = {\n contentType?: string;\n contentDisposition?: string;\n fileSize?: number; // Required for streaming uploads\n};\n\n/**\n * Functions to manage file storage.\n */\nclass Storage {\n constructor(private db: Reactor) {}\n\n /**\n * Uploads file at the provided path.\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * const [file] = e.target.files; // result of file input\n * const data = await db.storage.uploadFile('photos/demo.png', file);\n */\n uploadFile = (\n path: string,\n file: File | Blob,\n opts: FileOpts = {},\n ): Promise<UploadFileResponse> => {\n return this.db.uploadFile(path, file, opts);\n };\n\n /**\n * Deletes a file by path name.\n *\n * @see https://instantdb.com/docs/storage\n * @example\n * await db.storage.delete('photos/demo.png');\n */\n delete = (pathname: string) => {\n return this.db.deleteFile(pathname);\n };\n\n // Deprecated Storage API (Jan 2025)\n // ---------------------------------\n\n /**\n * @deprecated. Use `db.storage.uploadFile` instead\n * remove in the future.\n */\n upload = (pathname: string, file: File) => {\n return this.db.upload(pathname, file);\n };\n\n /**\n * @deprecated Use `db.storage.uploadFile` instead\n */\n put = this.upload;\n\n /**\n * @deprecated. getDownloadUrl will be removed in the future.\n * Use `useQuery` 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 = (pathname: string) => {\n return this.db.getDownloadUrl(pathname);\n };\n}\n\n// util\n\nfunction coerceQuery(o: any) {\n // stringify and parse to remove undefined values\n return JSON.parse(JSON.stringify(o));\n}\n\nclass InstantCoreDatabase<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n> implements IInstantDatabase<Schema>\n{\n public _reactor: Reactor<RoomsOf<Schema>>;\n public auth: Auth;\n public storage: Storage;\n\n public tx = txInit<Schema>();\n\n constructor(reactor: Reactor<RoomsOf<Schema>>) {\n this._reactor = reactor;\n this.auth = new Auth(this._reactor);\n this.storage = new Storage(this._reactor);\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 chunks: TransactionChunk<any, any> | TransactionChunk<any, any>[],\n ): Promise<TransactionResult> {\n return this._reactor.pushTx(chunks);\n }\n\n getLocalId(name: string): Promise<string> {\n return this._reactor.getLocalId(name);\n }\n\n /**\n * Use this to query your data!\n *\n * @see https://instantdb.com/docs/instaql\n *\n * @example\n * // listen to all goals\n * db.subscribeQuery({ goals: {} }, (resp) => {\n * console.log(resp.data.goals)\n * })\n *\n * // goals where the title is \"Get Fit\"\n * db.subscribeQuery(\n * { goals: { $: { where: { title: \"Get Fit\" } } } },\n * (resp) => {\n * console.log(resp.data.goals)\n * }\n * )\n *\n * // all goals, _alongside_ their todos\n * db.subscribeQuery({ goals: { todos: {} } }, (resp) => {\n * console.log(resp.data.goals)\n * });\n */\n subscribeQuery<\n Q extends ValidQuery<Q, Schema>,\n UseDatesLocal extends boolean = UseDates,\n >(\n query: Q,\n cb: (resp: InstaQLSubscriptionState<Schema, Q, UseDatesLocal>) => void,\n opts?: InstaQLOptions,\n ) {\n return this._reactor.subscribeQuery(query, cb, opts);\n }\n\n /**\n * Listen for the logged in state. This is useful\n * for deciding when to show a login screen.\n *\n * @see https://instantdb.com/docs/auth\n * @example\n * const unsub = db.subscribeAuth((auth) => {\n * if (auth.user) {\n * console.log('logged in as', auth.user.email)\n * } else {\n * console.log('logged out')\n * }\n * })\n */\n subscribeAuth(cb: (auth: AuthResult) => void): UnsubscribeFn {\n return this._reactor.subscribeAuth(cb);\n }\n\n /**\n * One time query for the logged in state. This is useful\n * for scenarios where you want to know the current auth\n * state without subscribing to changes.\n *\n * @see https://instantdb.com/docs/auth\n * @example\n * const user = await db.getAuth();\n * console.log('logged in as', user.email)\n */\n getAuth(): Promise<User | null> {\n return this._reactor.getAuth();\n }\n\n /**\n * Listen for connection status changes to Instant. This is useful\n * for building things like connectivity indicators\n *\n * @see https://www.instantdb.com/docs/patterns#connection-status\n * @example\n * const unsub = db.subscribeConnectionStatus((status) => {\n * const connectionState =\n * status === 'connecting' || status === 'opened'\n * ? 'authenticating'\n * : status === 'authenticated'\n * ? 'connected'\n * : status === 'closed'\n * ? 'closed'\n * : status === 'errored'\n * ? 'errored'\n * : 'unexpected state';\n *\n * console.log('Connection status:', connectionState);\n * });\n */\n subscribeConnectionStatus(\n cb: (status: ConnectionStatus) => void,\n ): UnsubscribeFn {\n return this._reactor.subscribeConnectionStatus(cb);\n }\n\n /**\n * Join a room to publish and subscribe to topics and presence.\n *\n * @see https://instantdb.com/docs/presence-and-topics\n * @example\n * // init\n * const db = init();\n * const room = db.joinRoom(roomType, roomId);\n * // usage\n * const unsubscribeTopic = room.subscribeTopic(\"foo\", console.log);\n * const unsubscribePresence = room.subscribePresence({}, console.log);\n * room.publishTopic(\"hello\", { message: \"hello world!\" });\n * room.publishPresence({ name: \"joe\" });\n * // later\n * unsubscribePresence();\n * unsubscribeTopic();\n * room.leaveRoom();\n */\n joinRoom<RoomType extends keyof RoomsOf<Schema>>(\n roomType: RoomType = '_defaultRoomType' as RoomType,\n roomId: string = '_defaultRoomId',\n opts?: {\n initialPresence?: Partial<PresenceOf<Schema, RoomType>>;\n },\n ): RoomHandle<PresenceOf<Schema, RoomType>, TopicsOf<Schema, RoomType>> {\n const leaveRoom = this._reactor.joinRoom(roomId, opts?.initialPresence);\n\n return {\n leaveRoom,\n subscribeTopic: (topic, onEvent) =>\n this._reactor.subscribeTopic(roomId, topic, onEvent),\n subscribePresence: (opts, onChange) =>\n this._reactor.subscribePresence(roomType, roomId, opts, onChange),\n publishTopic: (topic, data) =>\n this._reactor.publishTopic({ roomType, roomId, topic, data }),\n publishPresence: (data) =>\n this._reactor.publishPresence(roomType, roomId, data),\n getPresence: (opts) => this._reactor.getPresence(roomType, roomId, opts),\n };\n }\n\n shutdown() {\n delete globalInstantCoreStore[reactorKey(this._reactor.config)];\n this._reactor.shutdown();\n }\n\n /**\n * Use this for one-off queries.\n * Returns local data if available, otherwise fetches from the server.\n * Because we want to avoid stale data, this method will throw an error\n * if the user is offline or there is no active connection to the server.\n *\n * @see https://instantdb.com/docs/instaql\n *\n * @example\n *\n * const resp = await db.queryOnce({ goals: {} });\n * console.log(resp.data.goals)\n */\n queryOnce<Q extends ValidQuery<Q, Schema>>(\n query: Q,\n opts?: InstaQLOptions,\n ): Promise<{\n data: InstaQLResponse<Schema, Q, UseDates>;\n pageInfo: PageInfoResponse<Q>;\n }> {\n return this._reactor.queryOnce(query, opts);\n }\n\n /**\n * @deprecated This is an experimental function that is not yet ready for production use.\n * Use this function to sync an entire namespace.\n * It has many limitations that will be removed in the future:\n * 1. Must be used with an admin token\n * 2. Does not support permissions\n * 3. Does not support where clauses\n * 4. Does not support links\n * It also does not support multiple top-level namespaces. For example,\n * {posts: {}, users: {}} is invalid. Only `posts` or `users` is allowed, but not both.\n */\n _syncTableExperimental<Q extends ValidQuery<Q, Schema>>(\n query: ExactlyOne<Q>,\n cb: SyncTableCallback<Schema, Q, UseDates>,\n ): (\n opts?: { keepSubscription: boolean | null | undefined } | null | undefined,\n ) => void {\n return this._reactor.subscribeTable(query, cb);\n }\n}\n\nfunction schemaHash(schema?: InstantSchemaDef<any, any, any>): string {\n if (!schema) {\n return '0';\n }\n\n const fromStore = schemaHashStore.get(schema);\n if (fromStore) {\n return fromStore;\n }\n const hash = weakHash(schema);\n schemaHashStore.set(schema, hash);\n return hash;\n}\n\nfunction schemaChanged(\n existingClient: InstantCoreDatabase<any, boolean>,\n newSchema?: InstantSchemaDef<any, any, any>,\n): boolean {\n return (\n schemaHash(existingClient._reactor.config.schema) !== schemaHash(newSchema)\n );\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/core\"\n *\n * const db = init({ appId: \"my-app-id\" })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@instantdb/core\"\n * import schema from \"\"../instant.schema.ts\";\n *\n * const db = init({ appId: \"my-app-id\", 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 Storage?: any,\n NetworkListener?: any,\n versions?: { [key: string]: string },\n EventSourceImpl?: any,\n): InstantCoreDatabase<Schema, UseDates> {\n const configStrict = {\n ...config,\n appId: config.appId?.trim(),\n useDateObjects: (config.useDateObjects ?? false) as UseDates,\n };\n const existingClient = globalInstantCoreStore[\n reactorKey(configStrict)\n ] as InstantCoreDatabase<any, UseDates>;\n\n if (existingClient) {\n if (schemaChanged(existingClient, configStrict.schema)) {\n existingClient._reactor.updateSchema(configStrict.schema);\n }\n return existingClient;\n }\n\n const reactor = new Reactor<RoomsOf<Schema>>(\n {\n ...defaultConfig,\n ...configStrict,\n cardinalityInference: configStrict.schema ? true : false,\n },\n Storage || IndexedDBStorage,\n NetworkListener || WindowNetworkListener,\n { ...(versions || {}), '@instantdb/core': version },\n EventSourceImpl,\n );\n\n const client = new InstantCoreDatabase<any, UseDates>(reactor);\n globalInstantCoreStore[reactorKey(configStrict)] = client;\n\n handleDevtool(configStrict.appId, configStrict.devtool);\n\n return client;\n}\n\nfunction handleDevtool(\n appId: string,\n devtool: boolean | DevtoolConfig | null | undefined,\n) {\n if (\n typeof window === 'undefined' ||\n typeof window.location === 'undefined' ||\n typeof document === 'undefined'\n ) {\n return;\n }\n\n if (typeof devtool === 'boolean' && !devtool) {\n return;\n }\n\n const config: StrictDevtoolConfig = {\n position: 'bottom-right' as const,\n allowedHosts: ['localhost'],\n ...(typeof devtool === 'object' ? devtool : {}),\n };\n\n if (!config.allowedHosts.includes(window.location.hostname)) {\n return;\n }\n\n createDevtool(appId, config);\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/core\"\n * const db = init_experimental({ ... });\n *\n * // After\n * import { init } from \"@instantdb/core\"\n * const db = init({ ... });\n */\nconst init_experimental = init;\n\nexport {\n // bada bing bada boom\n init,\n init_experimental,\n id,\n tx,\n txInit,\n lookup,\n validateQuery,\n QueryValidationError,\n validateTransactions,\n parseSchemaFromJSON,\n TransactionValidationError,\n FrameworkClient,\n\n // error\n InstantAPIError,\n\n // cli\n i,\n\n // util\n getOps,\n coerceQuery,\n weakHash,\n coerceToDate,\n IndexedDBStorage,\n WindowNetworkListener,\n InstantCoreDatabase,\n Auth,\n Storage,\n version,\n InstantError,\n\n // sync table enums\n SyncTableCallbackEventType,\n\n // og types\n type IDatabase,\n type RoomSchemaShape,\n type Query,\n type QueryResponse,\n type InstaQLResponse,\n type PageInfoResponse,\n type InstantObject,\n type Exactly,\n type TransactionChunk,\n type AuthState,\n type ConnectionStatus,\n type User,\n type AuthToken,\n type TxChunk,\n type SubscriptionState,\n type InstaQLSubscriptionState,\n type LifecycleSubscriptionState,\n type InstaQLLifecycleState,\n\n // presence types\n type PresenceOpts,\n type PresenceSlice,\n type PresenceResponse,\n type PresencePeer,\n\n // new query types\n type InstaQLParams,\n type ValidQuery,\n type InstaQLOptions,\n type InstaQLQueryParams,\n type InstantQuery,\n type InstantQueryResult,\n type InstantSchema,\n type InstantEntity,\n type InstantSchemaDatabase,\n type InstaQLFields,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type InstantUnknownSchemaDef,\n type EntitiesWithLinks,\n type EntityDef,\n type RoomsDef,\n type InstantGraph,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type ValueTypes,\n type RoomsOf,\n type PresenceOf,\n type TopicsOf,\n type TopicOf,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type InstantSchemaDef,\n type InstantUnknownSchema,\n type IInstantDatabase,\n type BackwardsCompatibleSchema,\n type InstantRules,\n type UpdateParams,\n type LinkParams,\n type CreateParams,\n type RuleParams,\n\n // attr types\n type InstantDBAttr,\n type InstantDBAttrOnDelete,\n type InstantDBCheckedDataType,\n type InstantDBIdent,\n type InstantDBInferredType,\n\n // auth types\n type ExchangeCodeForTokenParams,\n type SendMagicCodeParams,\n type SendMagicCodeResponse,\n type SignInWithIdTokenParams,\n type VerifyMagicCodeParams,\n type VerifyResponse,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n\n // SSE\n type EventSourceType,\n type FrameworkConfig,\n\n // sync table types\n type SyncTableCallback,\n type SyncTableCallbackEvent,\n type SyncTableInitialSyncBatch,\n type SyncTableInitialSyncComplete,\n type SyncTableSyncTransaction,\n type SyncTableLoadFromStorage,\n type SyncTableSetupError,\n\n // error types\n type InstantIssue,\n\n // storage (e.g. indexeddb) interface\n StorageInterface,\n type StorageInterfaceStoreName,\n createInstantRouteHandler,\n};\n"]}