@instantdb/platform 0.22.99-experimental.add-user-perm-rules.20792844601.1 → 0.22.99

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 (48) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/dist/commonjs/ProgressPromise.js +45 -58
  3. package/dist/commonjs/ProgressPromise.js.map +1 -1
  4. package/dist/commonjs/api.js +366 -412
  5. package/dist/commonjs/api.js.map +1 -1
  6. package/dist/commonjs/migrationUtils.js +16 -4
  7. package/dist/commonjs/migrationUtils.js.map +1 -1
  8. package/dist/commonjs/migrations.js +10 -21
  9. package/dist/commonjs/migrations.js.map +1 -1
  10. package/dist/commonjs/oauth.js +52 -55
  11. package/dist/commonjs/oauth.js.map +1 -1
  12. package/dist/commonjs/oauthCommon.js +2 -0
  13. package/dist/commonjs/oauthCommon.js.map +1 -1
  14. package/dist/commonjs/perms.js +1 -1
  15. package/dist/commonjs/perms.js.map +1 -1
  16. package/dist/commonjs/schema.js +8 -14
  17. package/dist/commonjs/schema.js.map +1 -1
  18. package/dist/commonjs/serverOAuth.js +55 -68
  19. package/dist/commonjs/serverOAuth.js.map +1 -1
  20. package/dist/commonjs/typescript-schema.js +1 -2
  21. package/dist/commonjs/typescript-schema.js.map +1 -1
  22. package/dist/commonjs/util.js +1 -1
  23. package/dist/commonjs/util.js.map +1 -1
  24. package/dist/esm/ProgressPromise.js +45 -58
  25. package/dist/esm/ProgressPromise.js.map +1 -1
  26. package/dist/esm/api.js +366 -412
  27. package/dist/esm/api.js.map +1 -1
  28. package/dist/esm/migrationUtils.js +16 -4
  29. package/dist/esm/migrationUtils.js.map +1 -1
  30. package/dist/esm/migrations.js +10 -21
  31. package/dist/esm/migrations.js.map +1 -1
  32. package/dist/esm/oauth.js +52 -55
  33. package/dist/esm/oauth.js.map +1 -1
  34. package/dist/esm/oauthCommon.js +2 -0
  35. package/dist/esm/oauthCommon.js.map +1 -1
  36. package/dist/esm/perms.js +1 -1
  37. package/dist/esm/perms.js.map +1 -1
  38. package/dist/esm/schema.js +8 -14
  39. package/dist/esm/schema.js.map +1 -1
  40. package/dist/esm/serverOAuth.js +55 -68
  41. package/dist/esm/serverOAuth.js.map +1 -1
  42. package/dist/esm/typescript-schema.js +1 -2
  43. package/dist/esm/typescript-schema.js.map +1 -1
  44. package/dist/esm/util.js +1 -1
  45. package/dist/esm/util.js.map +1 -1
  46. package/dist/standalone/index.js +690 -660
  47. package/dist/standalone/index.umd.cjs +16 -16
  48. package/package.json +3 -3
@@ -1,28 +1,7 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
- if (kind === "m") throw new TypeError("Private method is not writable");
13
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
- };
17
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
19
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
20
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
- };
22
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
4
  };
25
- var _PlatformApi_auth, _PlatformApi_apiURI;
26
5
  Object.defineProperty(exports, "__esModule", { value: true });
27
6
  exports.PlatformApi = exports.PlatformApiMissingAuthError = void 0;
28
7
  exports.apiSchemaToInstantSchemaDef = apiSchemaToInstantSchemaDef;
@@ -33,26 +12,30 @@ const schema_ts_1 = require("./schema.js");
33
12
  const ProgressPromise_ts_1 = require("./ProgressPromise.js");
34
13
  const util_ts_1 = require("./util.js");
35
14
  const serverOAuth_ts_1 = require("./serverOAuth.js");
36
- function jsonFetch(input, init) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- const headers = Object.assign(Object.assign({}, ((init === null || init === void 0 ? void 0 : init.headers) || {})), { 'Instant-Platform-Version': version_ts_1.default, 'Instant-Core-Version': core_1.version, 'X-Instant-Source': 'platform-sdk', 'X-Instant-Version': version_ts_1.default });
39
- const res = yield fetch(input, Object.assign(Object.assign({}, init), { headers }));
40
- if (res.status === 200) {
41
- const json = yield res.json();
42
- return Promise.resolve(json);
43
- }
44
- const body = yield res.text();
45
- try {
46
- const json = JSON.parse(body);
47
- return Promise.reject(new core_1.InstantAPIError({ status: res.status, body: json }));
48
- }
49
- catch (_e) {
50
- return Promise.reject(new core_1.InstantAPIError({
51
- status: res.status,
52
- body: { type: undefined, message: body },
53
- }));
54
- }
55
- });
15
+ async function jsonFetch(input, init) {
16
+ const headers = {
17
+ ...(init?.headers || {}),
18
+ 'Instant-Platform-Version': version_ts_1.default,
19
+ 'Instant-Core-Version': core_1.version,
20
+ 'X-Instant-Source': 'platform-sdk',
21
+ 'X-Instant-Version': version_ts_1.default,
22
+ };
23
+ const res = await fetch(input, { ...init, headers });
24
+ if (res.status === 200) {
25
+ const json = await res.json();
26
+ return Promise.resolve(json);
27
+ }
28
+ const body = await res.text();
29
+ try {
30
+ const json = JSON.parse(body);
31
+ return Promise.reject(new core_1.InstantAPIError({ status: res.status, body: json }));
32
+ }
33
+ catch (_e) {
34
+ return Promise.reject(new core_1.InstantAPIError({
35
+ status: res.status,
36
+ body: { type: undefined, message: body },
37
+ }));
38
+ }
56
39
  }
57
40
  function attrDefForType(type) {
58
41
  switch (type) {
@@ -75,7 +58,7 @@ function attrDefForType(type) {
75
58
  }
76
59
  }
77
60
  function apiSchemaAttrToDataAttrDef(attr, opts) {
78
- const derivedType = (0, util_ts_1.deriveClientType)(attr, opts === null || opts === void 0 ? void 0 : opts.disableTypeInference);
61
+ const derivedType = (0, util_ts_1.deriveClientType)(attr, opts?.disableTypeInference);
79
62
  let i = attrDefForType(derivedType.type);
80
63
  if (attr['unique?']) {
81
64
  i = i.unique();
@@ -139,7 +122,13 @@ function apiSchemaToInstantSchemaDef(apiSchema, opts) {
139
122
  return core_1.i.schema({ entities, links });
140
123
  }
141
124
  function coerceApp(app) {
142
- const base = Object.assign({ id: app.id, title: app.title, createdAt: new Date(app.created_at), orgId: app.org_id }, (app['admin-token'] ? { adminToken: app['admin-token'] } : {}));
125
+ const base = {
126
+ id: app.id,
127
+ title: app.title,
128
+ createdAt: new Date(app.created_at),
129
+ orgId: app.org_id,
130
+ ...(app['admin-token'] ? { adminToken: app['admin-token'] } : {}),
131
+ };
143
132
  // `in` narrows the union, so it’s safe to read `perms` / `schema`
144
133
  // when the property exists. :contentReference[oaicite:0]{index=0}
145
134
  const permsPart = ('perms' in app ? { perms: app.perms } : {});
@@ -148,7 +137,7 @@ function coerceApp(app) {
148
137
  schema: apiSchemaToInstantSchemaDef(app.schema),
149
138
  }
150
139
  : {});
151
- return Object.assign(Object.assign(Object.assign({}, base), permsPart), schemaPart);
140
+ return { ...base, ...permsPart, ...schemaPart };
152
141
  }
153
142
  function coerceOrg(org) {
154
143
  return {
@@ -157,167 +146,157 @@ function coerceOrg(org) {
157
146
  createdAt: new Date(org.created_at),
158
147
  };
159
148
  }
160
- function getApps(apiURI, token, opts) {
161
- return __awaiter(this, void 0, void 0, function* () {
162
- const url = new URL(`${apiURI}/superadmin/apps`);
163
- const include = [];
164
- if (opts === null || opts === void 0 ? void 0 : opts.includePerms) {
165
- include.push('perms');
166
- }
167
- if (opts === null || opts === void 0 ? void 0 : opts.includeSchema) {
168
- include.push('schema');
169
- }
170
- if (include.length) {
171
- url.searchParams.set('include', include.join(','));
172
- }
173
- const resp = yield jsonFetch(url.toString(), {
174
- method: 'GET',
175
- headers: {
176
- Authorization: `Bearer ${token}`,
177
- },
178
- });
179
- return { apps: resp.apps.map(coerceApp) };
149
+ async function getApps(apiURI, token, opts) {
150
+ const url = new URL(`${apiURI}/superadmin/apps`);
151
+ const include = [];
152
+ if (opts?.includePerms) {
153
+ include.push('perms');
154
+ }
155
+ if (opts?.includeSchema) {
156
+ include.push('schema');
157
+ }
158
+ if (include.length) {
159
+ url.searchParams.set('include', include.join(','));
160
+ }
161
+ const resp = await jsonFetch(url.toString(), {
162
+ method: 'GET',
163
+ headers: {
164
+ Authorization: `Bearer ${token}`,
165
+ },
180
166
  });
181
- }
182
- function getOrgs(apiURI, token) {
183
- return __awaiter(this, void 0, void 0, function* () {
184
- const url = new URL(`${apiURI}/superadmin/orgs`);
185
- const resp = yield jsonFetch(url.toString(), {
186
- method: 'GET',
187
- headers: {
188
- Authorization: `Bearer ${token}`,
189
- },
190
- });
191
- return { orgs: resp.orgs.map(coerceOrg) };
167
+ return { apps: resp.apps.map(coerceApp) };
168
+ }
169
+ async function getOrgs(apiURI, token) {
170
+ const url = new URL(`${apiURI}/superadmin/orgs`);
171
+ const resp = await jsonFetch(url.toString(), {
172
+ method: 'GET',
173
+ headers: {
174
+ Authorization: `Bearer ${token}`,
175
+ },
192
176
  });
177
+ return { orgs: resp.orgs.map(coerceOrg) };
193
178
  }
194
- function getAppsForOrg(apiURI, token, orgId, opts) {
195
- return __awaiter(this, void 0, void 0, function* () {
196
- const url = new URL(`${apiURI}/superadmin/orgs/${orgId}/apps`);
197
- const include = [];
198
- if (opts === null || opts === void 0 ? void 0 : opts.includePerms) {
199
- include.push('perms');
200
- }
201
- if (opts === null || opts === void 0 ? void 0 : opts.includeSchema) {
202
- include.push('schema');
203
- }
204
- if (include.length) {
205
- url.searchParams.set('include', include.join(','));
206
- }
207
- const resp = yield jsonFetch(url.toString(), {
208
- method: 'GET',
209
- headers: {
210
- Authorization: `Bearer ${token}`,
211
- },
212
- });
213
- return { apps: resp.apps.map(coerceApp) };
179
+ async function getAppsForOrg(apiURI, token, orgId, opts) {
180
+ const url = new URL(`${apiURI}/superadmin/orgs/${orgId}/apps`);
181
+ const include = [];
182
+ if (opts?.includePerms) {
183
+ include.push('perms');
184
+ }
185
+ if (opts?.includeSchema) {
186
+ include.push('schema');
187
+ }
188
+ if (include.length) {
189
+ url.searchParams.set('include', include.join(','));
190
+ }
191
+ const resp = await jsonFetch(url.toString(), {
192
+ method: 'GET',
193
+ headers: {
194
+ Authorization: `Bearer ${token}`,
195
+ },
214
196
  });
197
+ return { apps: resp.apps.map(coerceApp) };
215
198
  }
216
- function getAppSchema(apiURI, token, appId) {
217
- return __awaiter(this, void 0, void 0, function* () {
218
- const { schema } = yield jsonFetch(`${apiURI}/superadmin/apps/${appId}/schema`, {
219
- method: 'GET',
220
- headers: {
221
- Authorization: `Bearer ${token}`,
222
- },
223
- });
224
- return { schema: apiSchemaToInstantSchemaDef(schema) };
199
+ async function getAppSchema(apiURI, token, appId) {
200
+ const { schema } = await jsonFetch(`${apiURI}/superadmin/apps/${appId}/schema`, {
201
+ method: 'GET',
202
+ headers: {
203
+ Authorization: `Bearer ${token}`,
204
+ },
225
205
  });
206
+ return { schema: apiSchemaToInstantSchemaDef(schema) };
226
207
  }
227
- function getAppPerms(apiURI, token, appId) {
228
- return __awaiter(this, void 0, void 0, function* () {
229
- return yield jsonFetch(`${apiURI}/superadmin/apps/${appId}/perms`, {
230
- method: 'GET',
231
- headers: {
232
- Authorization: `Bearer ${token}`,
233
- },
234
- });
208
+ async function getAppPerms(apiURI, token, appId) {
209
+ return await jsonFetch(`${apiURI}/superadmin/apps/${appId}/perms`, {
210
+ method: 'GET',
211
+ headers: {
212
+ Authorization: `Bearer ${token}`,
213
+ },
235
214
  });
236
215
  }
237
- function getApp(apiURI, token, appId, opts) {
238
- return __awaiter(this, void 0, void 0, function* () {
239
- let permsPromise = null;
240
- let schemaPromise = null;
241
- if (opts === null || opts === void 0 ? void 0 : opts.includePerms) {
242
- permsPromise = getAppPerms(apiURI, token, appId);
243
- }
244
- if (opts === null || opts === void 0 ? void 0 : opts.includeSchema) {
245
- schemaPromise = getAppSchema(apiURI, token, appId);
246
- }
247
- const { app: apiApp } = yield jsonFetch(`${apiURI}/superadmin/apps/${appId}`, {
248
- method: 'GET',
249
- headers: {
250
- Authorization: `Bearer ${token}`,
251
- },
252
- });
253
- if (!permsPromise && !schemaPromise) {
254
- const app = coerceApp(apiApp);
255
- return { app };
256
- }
257
- const app = Object.assign(Object.assign(Object.assign({}, coerceApp(apiApp)), (permsPromise ? { perms: (yield permsPromise).perms } : {})), (schemaPromise ? { schema: (yield schemaPromise).schema } : {}));
258
- return {
259
- app,
260
- };
216
+ async function getApp(apiURI, token, appId, opts) {
217
+ let permsPromise = null;
218
+ let schemaPromise = null;
219
+ if (opts?.includePerms) {
220
+ permsPromise = getAppPerms(apiURI, token, appId);
221
+ }
222
+ if (opts?.includeSchema) {
223
+ schemaPromise = getAppSchema(apiURI, token, appId);
224
+ }
225
+ const { app: apiApp } = await jsonFetch(`${apiURI}/superadmin/apps/${appId}`, {
226
+ method: 'GET',
227
+ headers: {
228
+ Authorization: `Bearer ${token}`,
229
+ },
261
230
  });
231
+ if (!permsPromise && !schemaPromise) {
232
+ const app = coerceApp(apiApp);
233
+ return { app };
234
+ }
235
+ const app = {
236
+ ...coerceApp(apiApp),
237
+ ...(permsPromise ? { perms: (await permsPromise).perms } : {}),
238
+ ...(schemaPromise ? { schema: (await schemaPromise).schema } : {}),
239
+ };
240
+ return {
241
+ app,
242
+ };
262
243
  }
263
- function createApp(apiURI, token, fields) {
264
- return __awaiter(this, void 0, void 0, function* () {
265
- const apiFields = fields;
266
- apiFields.org_id = fields.orgId;
267
- const { app } = yield jsonFetch(`${apiURI}/superadmin/apps`, {
268
- method: 'POST',
269
- headers: {
270
- 'Content-Type': 'application/json',
271
- Authorization: `Bearer ${token}`,
272
- },
273
- body: JSON.stringify(apiFields),
274
- });
275
- const withAdminToken = Object.assign(Object.assign({}, coerceApp(app)), { adminToken: app['admin-token'] });
276
- return {
277
- app: withAdminToken,
278
- };
244
+ async function createApp(apiURI, token, fields) {
245
+ const apiFields = fields;
246
+ apiFields.org_id = fields.orgId;
247
+ const { app } = await jsonFetch(`${apiURI}/superadmin/apps`, {
248
+ method: 'POST',
249
+ headers: {
250
+ 'Content-Type': 'application/json',
251
+ Authorization: `Bearer ${token}`,
252
+ },
253
+ body: JSON.stringify(apiFields),
279
254
  });
255
+ const withAdminToken = {
256
+ ...coerceApp(app),
257
+ adminToken: app['admin-token'],
258
+ };
259
+ return {
260
+ app: withAdminToken,
261
+ };
280
262
  }
281
- function createTemporaryApp(apiURI, fields) {
282
- return __awaiter(this, void 0, void 0, function* () {
283
- const response = yield jsonFetch(`${apiURI}/dash/apps/ephemeral`, {
284
- method: 'POST',
285
- headers: {
286
- 'Content-Type': 'application/json',
287
- },
288
- body: JSON.stringify(fields),
289
- });
290
- const withAdminToken = Object.assign(Object.assign({}, coerceApp(response.app)), { adminToken: response.app['admin-token'] });
291
- return {
292
- app: withAdminToken,
293
- expiresMs: response.expires_ms,
294
- };
263
+ async function createTemporaryApp(apiURI, fields) {
264
+ const response = await jsonFetch(`${apiURI}/dash/apps/ephemeral`, {
265
+ method: 'POST',
266
+ headers: {
267
+ 'Content-Type': 'application/json',
268
+ },
269
+ body: JSON.stringify(fields),
295
270
  });
271
+ const withAdminToken = {
272
+ ...coerceApp(response.app),
273
+ adminToken: response.app['admin-token'],
274
+ };
275
+ return {
276
+ app: withAdminToken,
277
+ expiresMs: response.expires_ms,
278
+ };
296
279
  }
297
- function updateApp(apiURI, token, appId, fields) {
298
- return __awaiter(this, void 0, void 0, function* () {
299
- const { app } = yield jsonFetch(`${apiURI}/superadmin/apps/${appId}`, {
300
- method: 'POST',
301
- headers: {
302
- 'Content-Type': 'application/json',
303
- Authorization: `Bearer ${token}`,
304
- },
305
- body: JSON.stringify(fields),
306
- });
307
- return { app: coerceApp(app) };
280
+ async function updateApp(apiURI, token, appId, fields) {
281
+ const { app } = await jsonFetch(`${apiURI}/superadmin/apps/${appId}`, {
282
+ method: 'POST',
283
+ headers: {
284
+ 'Content-Type': 'application/json',
285
+ Authorization: `Bearer ${token}`,
286
+ },
287
+ body: JSON.stringify(fields),
308
288
  });
309
- }
310
- function deleteApp(apiURI, token, appId) {
311
- return __awaiter(this, void 0, void 0, function* () {
312
- const { app } = yield jsonFetch(`${apiURI}/superadmin/apps/${appId}`, {
313
- method: 'DELETE',
314
- headers: {
315
- 'Content-Type': 'application/json',
316
- Authorization: `Bearer ${token}`,
317
- },
318
- });
319
- return { app: coerceApp(app) };
289
+ return { app: coerceApp(app) };
290
+ }
291
+ async function deleteApp(apiURI, token, appId) {
292
+ const { app } = await jsonFetch(`${apiURI}/superadmin/apps/${appId}`, {
293
+ method: 'DELETE',
294
+ headers: {
295
+ 'Content-Type': 'application/json',
296
+ Authorization: `Bearer ${token}`,
297
+ },
320
298
  });
299
+ return { app: coerceApp(app) };
321
300
  }
322
301
  function translatePlanStep(apiStep) {
323
302
  const [stepType, stepParams] = apiStep;
@@ -443,27 +422,29 @@ function translatePushStep(apiStep, jobs) {
443
422
  if (planStep.type !== backgroundJob.type) {
444
423
  throw new Error('Invalid type');
445
424
  }
446
- return Object.assign(Object.assign({}, planStep), { backgroundJob });
425
+ return { ...planStep, backgroundJob };
447
426
  }
448
427
  function translatePushSteps(apiSteps, jobs) {
449
428
  return apiSteps.map((step) => translatePushStep(step, jobs));
450
429
  }
451
- function planSchemaPush(apiURI, token, appId, body) {
452
- return __awaiter(this, void 0, void 0, function* () {
453
- const resp = yield jsonFetch(`${apiURI}/superadmin/apps/${appId}/schema/push/plan`, {
454
- method: 'POST',
455
- headers: {
456
- 'Content-Type': 'application/json',
457
- Authorization: `Bearer ${token}`,
458
- },
459
- body: JSON.stringify(Object.assign(Object.assign({}, body), { check_types: true, supports_background_updates: true })),
460
- });
461
- return {
462
- newSchema: apiSchemaToInstantSchemaDef(resp['new-schema']),
463
- currentSchema: apiSchemaToInstantSchemaDef(resp['current-schema']),
464
- steps: translatePlanSteps(resp['steps']),
465
- };
430
+ async function planSchemaPush(apiURI, token, appId, body) {
431
+ const resp = await jsonFetch(`${apiURI}/superadmin/apps/${appId}/schema/push/plan`, {
432
+ method: 'POST',
433
+ headers: {
434
+ 'Content-Type': 'application/json',
435
+ Authorization: `Bearer ${token}`,
436
+ },
437
+ body: JSON.stringify({
438
+ ...body,
439
+ check_types: true,
440
+ supports_background_updates: true,
441
+ }),
466
442
  });
443
+ return {
444
+ newSchema: apiSchemaToInstantSchemaDef(resp['new-schema']),
445
+ currentSchema: apiSchemaToInstantSchemaDef(resp['current-schema']),
446
+ steps: translatePlanSteps(resp['steps']),
447
+ };
467
448
  }
468
449
  function allJobsComplete(jobs) {
469
450
  return !!jobs.find((j) => j.job_status === 'completed' || j.job_status === 'errored');
@@ -480,47 +461,44 @@ function latestJobUpdate(jobs) {
480
461
  }, null);
481
462
  return res;
482
463
  }
483
- function jobFetchLoop(apiURI, token, appId, groupId, startingJobs, onFetch) {
484
- return __awaiter(this, void 0, void 0, function* () {
485
- let interval = 100;
486
- let lastJobs = startingJobs;
487
- let errorCount = 0;
488
- while (!allJobsComplete(lastJobs)) {
489
- yield new Promise((resolve) => setTimeout(resolve, interval));
490
- try {
491
- const nextJobs = (yield jsonFetch(`${apiURI}/dash/apps/${appId}/indexing-jobs/group/${groupId}`, {
492
- method: 'GET',
493
- headers: {
494
- Authorization: `Bearer ${token}`,
495
- },
496
- })).jobs;
497
- onFetch(nextJobs);
498
- if (allJobsComplete(nextJobs)) {
499
- return nextJobs;
500
- }
501
- errorCount = 0;
502
- const lastUpdate = latestJobUpdate(lastJobs);
503
- const thisUpdate = latestJobUpdate(nextJobs);
504
- interval =
505
- thisUpdate === null || (lastUpdate && lastUpdate >= thisUpdate)
506
- ? Math.min(interval * 2, 10000)
507
- : 100;
464
+ async function jobFetchLoop(apiURI, token, appId, groupId, startingJobs, onFetch) {
465
+ let interval = 100;
466
+ let lastJobs = startingJobs;
467
+ let errorCount = 0;
468
+ while (!allJobsComplete(lastJobs)) {
469
+ await new Promise((resolve) => setTimeout(resolve, interval));
470
+ try {
471
+ const nextJobs = (await jsonFetch(`${apiURI}/dash/apps/${appId}/indexing-jobs/group/${groupId}`, {
472
+ method: 'GET',
473
+ headers: {
474
+ Authorization: `Bearer ${token}`,
475
+ },
476
+ })).jobs;
477
+ onFetch(nextJobs);
478
+ if (allJobsComplete(nextJobs)) {
479
+ return nextJobs;
508
480
  }
509
- catch (e) {
510
- if (errorCount > 3) {
511
- throw e;
512
- }
513
- else {
514
- errorCount++;
515
- interval = Math.min(interval * 2, 10000);
516
- }
481
+ errorCount = 0;
482
+ const lastUpdate = latestJobUpdate(lastJobs);
483
+ const thisUpdate = latestJobUpdate(nextJobs);
484
+ interval =
485
+ thisUpdate === null || (lastUpdate && lastUpdate >= thisUpdate)
486
+ ? Math.min(interval * 2, 10000)
487
+ : 100;
488
+ }
489
+ catch (e) {
490
+ if (errorCount > 3) {
491
+ throw e;
492
+ }
493
+ else {
494
+ errorCount++;
495
+ interval = Math.min(interval * 2, 10000);
517
496
  }
518
497
  }
519
- return lastJobs;
520
- });
498
+ }
499
+ return lastJobs;
521
500
  }
522
501
  function formatJob(job) {
523
- var _a;
524
502
  const baseJob = {
525
503
  id: job.id,
526
504
  createdAt: new Date(job.created_at),
@@ -529,7 +507,7 @@ function formatJob(job) {
529
507
  workEstimate: job.work_estimate,
530
508
  workCompleted: job.work_completed,
531
509
  error: job.error,
532
- invalidTriplesSample: (_a = job.invalid_triples_sample) === null || _a === void 0 ? void 0 : _a.map((s) => {
510
+ invalidTriplesSample: job.invalid_triples_sample?.map((s) => {
533
511
  return { entityId: s.entity_id, value: s.value, jsonType: s.json_type };
534
512
  }),
535
513
  };
@@ -540,13 +518,21 @@ function formatJob(job) {
540
518
  case 'required':
541
519
  case 'remove-required':
542
520
  case 'remove-unique': {
543
- return Object.assign(Object.assign({}, baseJob), { type: job.job_type });
521
+ return { ...baseJob, type: job.job_type };
544
522
  }
545
523
  case 'check-data-type': {
546
- return Object.assign(Object.assign({}, baseJob), { type: job.job_type, checkedDataType: job.checked_data_type });
524
+ return {
525
+ ...baseJob,
526
+ type: job.job_type,
527
+ checkedDataType: job.checked_data_type,
528
+ };
547
529
  }
548
530
  case 'unique': {
549
- return Object.assign(Object.assign({}, baseJob), { type: job.job_type, invalidUniqueValue: job.invalid_unique_value });
531
+ return {
532
+ ...baseJob,
533
+ type: job.job_type,
534
+ invalidUniqueValue: job.invalid_unique_value,
535
+ };
550
536
  }
551
537
  default: {
552
538
  const neverType = job.job_type;
@@ -577,23 +563,27 @@ function stepSummary(steps) {
577
563
  };
578
564
  }
579
565
  function schemaPush(apiURI, token, appId, body) {
580
- return new ProgressPromise_ts_1.ProgressPromise((progress, resolve, reject) => __awaiter(this, void 0, void 0, function* () {
566
+ return new ProgressPromise_ts_1.ProgressPromise(async (progress, resolve, reject) => {
581
567
  try {
582
- const resp = yield jsonFetch(`${apiURI}/superadmin/apps/${appId}/schema/push/apply`, {
568
+ const resp = await jsonFetch(`${apiURI}/superadmin/apps/${appId}/schema/push/apply`, {
583
569
  method: 'POST',
584
570
  headers: {
585
571
  'Content-Type': 'application/json',
586
572
  Authorization: `Bearer ${token}`,
587
573
  },
588
- body: JSON.stringify(Object.assign(Object.assign({}, body), { check_types: true, supports_background_updates: true })),
574
+ body: JSON.stringify({
575
+ ...body,
576
+ check_types: true,
577
+ supports_background_updates: true,
578
+ }),
589
579
  });
590
580
  const indexingJobs = resp['indexing-jobs'];
591
581
  const jobs = !indexingJobs
592
582
  ? []
593
- : yield jobFetchLoop(apiURI, token, appId, indexingJobs['group-id'], indexingJobs['jobs'], (jobs) => {
583
+ : await jobFetchLoop(apiURI, token, appId, indexingJobs['group-id'], indexingJobs['jobs'], (jobs) => {
594
584
  progress(stepSummary(translatePushSteps(resp.steps, jobs)));
595
585
  });
596
- const schemaRes = yield getAppSchema(apiURI, token, appId);
586
+ const schemaRes = await getAppSchema(apiURI, token, appId);
597
587
  resolve({
598
588
  newSchema: schemaRes.schema,
599
589
  steps: translatePushSteps(resp.steps, jobs),
@@ -603,32 +593,28 @@ function schemaPush(apiURI, token, appId, body) {
603
593
  catch (e) {
604
594
  reject(e);
605
595
  }
606
- }));
596
+ });
607
597
  }
608
- function pushPerms(apiURI, token, appId, body) {
609
- return __awaiter(this, void 0, void 0, function* () {
610
- const result = yield jsonFetch(`${apiURI}/superadmin/apps/${appId}/perms`, {
611
- method: 'POST',
612
- headers: {
613
- 'Content-Type': 'application/json',
614
- Authorization: `Bearer ${token}`,
615
- },
616
- body: JSON.stringify({ code: body.perms }),
617
- });
618
- return { perms: result.rules.code };
598
+ async function pushPerms(apiURI, token, appId, body) {
599
+ const result = await jsonFetch(`${apiURI}/superadmin/apps/${appId}/perms`, {
600
+ method: 'POST',
601
+ headers: {
602
+ 'Content-Type': 'application/json',
603
+ Authorization: `Bearer ${token}`,
604
+ },
605
+ body: JSON.stringify({ code: body.perms }),
619
606
  });
607
+ return { perms: result.rules.code };
620
608
  }
621
- function tokenInfo(apiURI, token) {
622
- return __awaiter(this, void 0, void 0, function* () {
623
- const result = yield jsonFetch(`${apiURI}/platform/oauth/token-info?access_token=${token}`, {
624
- method: 'GET',
625
- });
626
- return {
627
- tokenType: result.token_type,
628
- scopes: result.scopes,
629
- expiresAt: new Date(Date.now() + (result.expires_in - 60) * 1000),
630
- };
609
+ async function tokenInfo(apiURI, token) {
610
+ const result = await jsonFetch(`${apiURI}/platform/oauth/token-info?access_token=${token}`, {
611
+ method: 'GET',
631
612
  });
613
+ return {
614
+ tokenType: result.token_type,
615
+ scopes: result.scopes,
616
+ expiresAt: new Date(Date.now() + (result.expires_in - 60) * 1000),
617
+ };
632
618
  }
633
619
  class PlatformApiMissingAuthError extends Error {
634
620
  constructor() {
@@ -652,6 +638,8 @@ exports.PlatformApiMissingAuthError = PlatformApiMissingAuthError;
652
638
  * ```
653
639
  */
654
640
  class PlatformApi {
641
+ #auth;
642
+ #apiURI;
655
643
  /**
656
644
  * @param config – Runtime configuration.
657
645
  * @param config.auth.token – OAuth access-token obtained via the oauth flow
@@ -659,83 +647,76 @@ class PlatformApi {
659
647
  * @throws {Error} When `token` is missing.
660
648
  */
661
649
  constructor(config) {
662
- _PlatformApi_auth.set(this, void 0);
663
- _PlatformApi_apiURI.set(this, void 0);
664
- __classPrivateFieldSet(this, _PlatformApi_auth, config === null || config === void 0 ? void 0 : config.auth, "f");
665
- __classPrivateFieldSet(this, _PlatformApi_apiURI, (config === null || config === void 0 ? void 0 : config.apiURI) || 'https://api.instantdb.com', "f");
650
+ this.#auth = config?.auth;
651
+ this.#apiURI = config?.apiURI || 'https://api.instantdb.com';
666
652
  }
667
653
  token() {
668
- if (!__classPrivateFieldGet(this, _PlatformApi_auth, "f")) {
654
+ if (!this.#auth) {
669
655
  throw new PlatformApiMissingAuthError();
670
656
  }
671
- if ('token' in __classPrivateFieldGet(this, _PlatformApi_auth, "f")) {
672
- return __classPrivateFieldGet(this, _PlatformApi_auth, "f").token;
657
+ if ('token' in this.#auth) {
658
+ return this.#auth.token;
673
659
  }
674
- return __classPrivateFieldGet(this, _PlatformApi_auth, "f").accessToken;
660
+ return this.#auth.accessToken;
675
661
  }
676
662
  canRefreshToken() {
677
- if (!__classPrivateFieldGet(this, _PlatformApi_auth, "f")) {
663
+ if (!this.#auth) {
678
664
  throw new PlatformApiMissingAuthError();
679
665
  }
680
- return ('refreshToken' in __classPrivateFieldGet(this, _PlatformApi_auth, "f") &&
681
- 'clientId' in __classPrivateFieldGet(this, _PlatformApi_auth, "f") &&
682
- 'clientSecret' in __classPrivateFieldGet(this, _PlatformApi_auth, "f") &&
683
- __classPrivateFieldGet(this, _PlatformApi_auth, "f").refreshToken != null &&
684
- __classPrivateFieldGet(this, _PlatformApi_auth, "f").clientId != null &&
685
- __classPrivateFieldGet(this, _PlatformApi_auth, "f").clientSecret != null);
666
+ return ('refreshToken' in this.#auth &&
667
+ 'clientId' in this.#auth &&
668
+ 'clientSecret' in this.#auth &&
669
+ this.#auth.refreshToken != null &&
670
+ this.#auth.clientId != null &&
671
+ this.#auth.clientSecret != null);
686
672
  }
687
- refreshToken() {
688
- return __awaiter(this, void 0, void 0, function* () {
689
- if (!__classPrivateFieldGet(this, _PlatformApi_auth, "f")) {
690
- throw new PlatformApiMissingAuthError();
691
- }
692
- if (!this.canRefreshToken() ||
693
- // Checked in canRefreshToken, but this lets
694
- // typescript refine this.#auth here
695
- !('clientId' in __classPrivateFieldGet(this, _PlatformApi_auth, "f"))) {
696
- return null;
697
- }
698
- const token = yield (0, serverOAuth_ts_1.exchangeRefreshToken)({
699
- apiURI: __classPrivateFieldGet(this, _PlatformApi_apiURI, "f"),
700
- clientId: __classPrivateFieldGet(this, _PlatformApi_auth, "f").clientId,
701
- clientSecret: __classPrivateFieldGet(this, _PlatformApi_auth, "f").clientSecret,
702
- refreshToken: __classPrivateFieldGet(this, _PlatformApi_auth, "f").refreshToken,
703
- });
704
- __classPrivateFieldGet(this, _PlatformApi_auth, "f").accessToken = token.accessToken;
705
- if (__classPrivateFieldGet(this, _PlatformApi_auth, "f").onRefresh) {
706
- yield __classPrivateFieldGet(this, _PlatformApi_auth, "f").onRefresh(token);
707
- }
708
- return token;
673
+ async refreshToken() {
674
+ if (!this.#auth) {
675
+ throw new PlatformApiMissingAuthError();
676
+ }
677
+ if (!this.canRefreshToken() ||
678
+ // Checked in canRefreshToken, but this lets
679
+ // typescript refine this.#auth here
680
+ !('clientId' in this.#auth)) {
681
+ return null;
682
+ }
683
+ const token = await (0, serverOAuth_ts_1.exchangeRefreshToken)({
684
+ apiURI: this.#apiURI,
685
+ clientId: this.#auth.clientId,
686
+ clientSecret: this.#auth.clientSecret,
687
+ refreshToken: this.#auth.refreshToken,
709
688
  });
689
+ this.#auth.accessToken = token.accessToken;
690
+ if (this.#auth.onRefresh) {
691
+ await this.#auth.onRefresh(token);
692
+ }
693
+ return token;
710
694
  }
711
- withRetry(f, args) {
712
- return __awaiter(this, void 0, void 0, function* () {
713
- var _a, _b;
714
- let attempt = 0;
715
- const [apiURI, tokenInArg, ...restArgs] = args;
716
- let token = tokenInArg;
717
- while (attempt < 2) {
718
- try {
719
- return yield f(apiURI, token, ...restArgs);
720
- }
721
- catch (e) {
722
- if (e instanceof core_1.InstantAPIError &&
723
- (e.status === 401 ||
724
- ((_a = e.body) === null || _a === void 0 ? void 0 : _a.type) === 'record-expired' ||
725
- (((_b = e.body) === null || _b === void 0 ? void 0 : _b.type) === 'record-not-found' &&
726
- e.body.hint['record-type'].match(/token/i))) &&
727
- this.canRefreshToken()) {
728
- const refreshedToken = yield this.refreshToken();
729
- if (refreshedToken) {
730
- token = refreshedToken.accessToken;
731
- attempt++;
732
- continue;
733
- }
695
+ async withRetry(f, args) {
696
+ let attempt = 0;
697
+ const [apiURI, tokenInArg, ...restArgs] = args;
698
+ let token = tokenInArg;
699
+ while (attempt < 2) {
700
+ try {
701
+ return await f(apiURI, token, ...restArgs);
702
+ }
703
+ catch (e) {
704
+ if (e instanceof core_1.InstantAPIError &&
705
+ (e.status === 401 ||
706
+ e.body?.type === 'record-expired' ||
707
+ (e.body?.type === 'record-not-found' &&
708
+ e.body.hint['record-type'].match(/token/i))) &&
709
+ this.canRefreshToken()) {
710
+ const refreshedToken = await this.refreshToken();
711
+ if (refreshedToken) {
712
+ token = refreshedToken.accessToken;
713
+ attempt++;
714
+ continue;
734
715
  }
735
- throw e;
736
716
  }
717
+ throw e;
737
718
  }
738
- });
719
+ }
739
720
  }
740
721
  /**
741
722
  * Fetch a single app by its id.
@@ -754,10 +735,8 @@ class PlatformApi {
754
735
  * @returns A typed wrapper containing the app, whose shape is expanded
755
736
  * according to `Opts`.
756
737
  */
757
- getApp(appId, opts) {
758
- return __awaiter(this, void 0, void 0, function* () {
759
- return this.withRetry(getApp, [__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), this.token(), appId, opts]);
760
- });
738
+ async getApp(appId, opts) {
739
+ return this.withRetry(getApp, [this.#apiURI, this.token(), appId, opts]);
761
740
  }
762
741
  /**
763
742
  * List **all apps** owned by the auth owner.
@@ -773,10 +752,8 @@ class PlatformApi {
773
752
  * @param opts – `{ includeSchema?: boolean; includePerms?: boolean }`
774
753
  * @returns An array wrapper; each element’s shape follows `Opts`.
775
754
  */
776
- getApps(opts) {
777
- return __awaiter(this, void 0, void 0, function* () {
778
- return this.withRetry(getApps, [__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), this.token(), opts]);
779
- });
755
+ async getApps(opts) {
756
+ return this.withRetry(getApps, [this.#apiURI, this.token(), opts]);
780
757
  }
781
758
  /**
782
759
  * List **all orgs** that the auth owner is a member of.
@@ -787,10 +764,8 @@ class PlatformApi {
787
764
  *
788
765
  * @returns An array of orgs
789
766
  */
790
- getOrgs() {
791
- return __awaiter(this, void 0, void 0, function* () {
792
- return this.withRetry(getOrgs, [__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), this.token()]);
793
- });
767
+ async getOrgs() {
768
+ return this.withRetry(getOrgs, [this.#apiURI, this.token()]);
794
769
  }
795
770
  /**
796
771
  * List **all apps** owned by the auth owner.
@@ -806,15 +781,13 @@ class PlatformApi {
806
781
  * @param opts – `{ includeSchema?: boolean; includePerms?: boolean }`
807
782
  * @returns An array wrapper; each element’s shape follows `Opts`.
808
783
  */
809
- getAppsForOrg(orgId, opts) {
810
- return __awaiter(this, void 0, void 0, function* () {
811
- return this.withRetry(getAppsForOrg, [
812
- __classPrivateFieldGet(this, _PlatformApi_apiURI, "f"),
813
- this.token(),
814
- orgId,
815
- opts,
816
- ]);
817
- });
784
+ async getAppsForOrg(orgId, opts) {
785
+ return this.withRetry(getAppsForOrg, [
786
+ this.#apiURI,
787
+ this.token(),
788
+ orgId,
789
+ opts,
790
+ ]);
818
791
  }
819
792
  /**
820
793
  * Gets the schema for an app by its id.
@@ -825,10 +798,8 @@ class PlatformApi {
825
798
  *
826
799
  * @param appId -- UUID of the app
827
800
  */
828
- getSchema(appId) {
829
- return __awaiter(this, void 0, void 0, function* () {
830
- return this.withRetry(getAppSchema, [__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), this.token(), appId]);
831
- });
801
+ async getSchema(appId) {
802
+ return this.withRetry(getAppSchema, [this.#apiURI, this.token(), appId]);
832
803
  }
833
804
  /**
834
805
  * Gets the permissions for an app by its id.
@@ -839,10 +810,8 @@ class PlatformApi {
839
810
  *
840
811
  * @param appId -- UUID of the app
841
812
  */
842
- getPerms(appId) {
843
- return __awaiter(this, void 0, void 0, function* () {
844
- return this.withRetry(getAppPerms, [__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), this.token(), appId]);
845
- });
813
+ async getPerms(appId) {
814
+ return this.withRetry(getAppPerms, [this.#apiURI, this.token(), appId]);
846
815
  }
847
816
  /**
848
817
  * Create a new app.
@@ -870,10 +839,8 @@ class PlatformApi {
870
839
  * @param fields.perms -- Optional permissions for the app
871
840
  * @param fields.orgId -- Optional id of the org that the app will be placed in
872
841
  */
873
- createApp(fields) {
874
- return __awaiter(this, void 0, void 0, function* () {
875
- return this.withRetry(createApp, [__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), this.token(), fields]);
876
- });
842
+ async createApp(fields) {
843
+ return this.withRetry(createApp, [this.#apiURI, this.token(), fields]);
877
844
  }
878
845
  /**
879
846
  * Create a new temporary app.
@@ -897,10 +864,8 @@ class PlatformApi {
897
864
  * @param fields.schema -- Optional schema for the app
898
865
  * @param fields.perms -- Optional permissions for the app
899
866
  */
900
- createTemporaryApp(fields) {
901
- return __awaiter(this, void 0, void 0, function* () {
902
- return createTemporaryApp(__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), fields);
903
- });
867
+ async createTemporaryApp(fields) {
868
+ return createTemporaryApp(this.#apiURI, fields);
904
869
  }
905
870
  /**
906
871
  * Update the title of an app by its id.
@@ -914,15 +879,13 @@ class PlatformApi {
914
879
  * @param appId -- UUID of the app
915
880
  * @param fields.title -- New title for the app
916
881
  */
917
- updateApp(appId, fields) {
918
- return __awaiter(this, void 0, void 0, function* () {
919
- return this.withRetry(updateApp, [
920
- __classPrivateFieldGet(this, _PlatformApi_apiURI, "f"),
921
- this.token(),
922
- appId,
923
- fields,
924
- ]);
925
- });
882
+ async updateApp(appId, fields) {
883
+ return this.withRetry(updateApp, [
884
+ this.#apiURI,
885
+ this.token(),
886
+ appId,
887
+ fields,
888
+ ]);
926
889
  }
927
890
  /**
928
891
  * Delete an app by its id.
@@ -933,10 +896,8 @@ class PlatformApi {
933
896
  *
934
897
  * @param appId -- UUID of the app
935
898
  */
936
- deleteApp(appId) {
937
- return __awaiter(this, void 0, void 0, function* () {
938
- return this.withRetry(deleteApp, [__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), this.token(), appId]);
939
- });
899
+ async deleteApp(appId) {
900
+ return this.withRetry(deleteApp, [this.#apiURI, this.token(), appId]);
940
901
  }
941
902
  /**
942
903
  * Dry-run a **schema push** and receive a _plan_ of steps the server would
@@ -946,15 +907,13 @@ class PlatformApi {
946
907
  * const { steps } = await api.planSchemaPush(appId, body);
947
908
  * ```
948
909
  */
949
- planSchemaPush(appId, body) {
950
- return __awaiter(this, void 0, void 0, function* () {
951
- return this.withRetry(planSchemaPush, [
952
- __classPrivateFieldGet(this, _PlatformApi_apiURI, "f"),
953
- this.token(),
954
- appId,
955
- body,
956
- ]);
957
- });
910
+ async planSchemaPush(appId, body) {
911
+ return this.withRetry(planSchemaPush, [
912
+ this.#apiURI,
913
+ this.token(),
914
+ appId,
915
+ body,
916
+ ]);
958
917
  }
959
918
  /**
960
919
  * Execute a **schema push**. The server returns a long-running job
@@ -983,19 +942,19 @@ class PlatformApi {
983
942
  * ```
984
943
  */
985
944
  schemaPush(appId, body) {
986
- if (!__classPrivateFieldGet(this, _PlatformApi_auth, "f")) {
945
+ if (!this.#auth) {
987
946
  throw new PlatformApiMissingAuthError();
988
947
  }
989
- return new ProgressPromise_ts_1.ProgressPromise((progress, resolve, reject) => __awaiter(this, void 0, void 0, function* () {
948
+ return new ProgressPromise_ts_1.ProgressPromise(async (progress, resolve, reject) => {
990
949
  // It's tricky to add withRetry to the background process that fetches the jobs,
991
950
  // so we'll just refresh the token at the start.
992
951
  if (this.canRefreshToken()) {
993
952
  try {
994
- yield this.refreshToken();
953
+ await this.refreshToken();
995
954
  }
996
955
  catch (_e) { }
997
956
  }
998
- schemaPush(__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), this.token(), appId, body).subscribe({
957
+ schemaPush(this.#apiURI, this.token(), appId, body).subscribe({
999
958
  complete(v) {
1000
959
  resolve(v);
1001
960
  },
@@ -1006,7 +965,7 @@ class PlatformApi {
1006
965
  progress(v);
1007
966
  },
1008
967
  });
1009
- }));
968
+ });
1010
969
  }
1011
970
  /**
1012
971
  * Update permission rules for an app by its id.
@@ -1022,23 +981,18 @@ class PlatformApi {
1022
981
  * });
1023
982
  * ```
1024
983
  */
1025
- pushPerms(appId, body) {
1026
- return __awaiter(this, void 0, void 0, function* () {
1027
- if (!__classPrivateFieldGet(this, _PlatformApi_auth, "f")) {
1028
- throw new PlatformApiMissingAuthError();
1029
- }
1030
- return this.withRetry(pushPerms, [__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), this.token(), appId, body]);
1031
- });
984
+ async pushPerms(appId, body) {
985
+ if (!this.#auth) {
986
+ throw new PlatformApiMissingAuthError();
987
+ }
988
+ return this.withRetry(pushPerms, [this.#apiURI, this.token(), appId, body]);
1032
989
  }
1033
- tokenInfo() {
1034
- return __awaiter(this, void 0, void 0, function* () {
1035
- if (!__classPrivateFieldGet(this, _PlatformApi_auth, "f")) {
1036
- throw new PlatformApiMissingAuthError();
1037
- }
1038
- return this.withRetry(tokenInfo, [__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), this.token()]);
1039
- });
990
+ async tokenInfo() {
991
+ if (!this.#auth) {
992
+ throw new PlatformApiMissingAuthError();
993
+ }
994
+ return this.withRetry(tokenInfo, [this.#apiURI, this.token()]);
1040
995
  }
1041
996
  }
1042
997
  exports.PlatformApi = PlatformApi;
1043
- _PlatformApi_auth = new WeakMap(), _PlatformApi_apiURI = new WeakMap();
1044
998
  //# sourceMappingURL=api.js.map