@instantdb/platform 0.22.98 → 0.22.99-experimental.add-user-perm-rules.20792844601.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 (48) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/dist/commonjs/ProgressPromise.js +58 -45
  3. package/dist/commonjs/ProgressPromise.js.map +1 -1
  4. package/dist/commonjs/api.js +412 -366
  5. package/dist/commonjs/api.js.map +1 -1
  6. package/dist/commonjs/migrationUtils.js +4 -16
  7. package/dist/commonjs/migrationUtils.js.map +1 -1
  8. package/dist/commonjs/migrations.js +21 -10
  9. package/dist/commonjs/migrations.js.map +1 -1
  10. package/dist/commonjs/oauth.js +55 -52
  11. package/dist/commonjs/oauth.js.map +1 -1
  12. package/dist/commonjs/oauthCommon.js +0 -2
  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 +14 -8
  17. package/dist/commonjs/schema.js.map +1 -1
  18. package/dist/commonjs/serverOAuth.js +68 -55
  19. package/dist/commonjs/serverOAuth.js.map +1 -1
  20. package/dist/commonjs/typescript-schema.js +2 -1
  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 +58 -45
  25. package/dist/esm/ProgressPromise.js.map +1 -1
  26. package/dist/esm/api.js +412 -366
  27. package/dist/esm/api.js.map +1 -1
  28. package/dist/esm/migrationUtils.js +4 -16
  29. package/dist/esm/migrationUtils.js.map +1 -1
  30. package/dist/esm/migrations.js +21 -10
  31. package/dist/esm/migrations.js.map +1 -1
  32. package/dist/esm/oauth.js +55 -52
  33. package/dist/esm/oauth.js.map +1 -1
  34. package/dist/esm/oauthCommon.js +0 -2
  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 +14 -8
  39. package/dist/esm/schema.js.map +1 -1
  40. package/dist/esm/serverOAuth.js +68 -55
  41. package/dist/esm/serverOAuth.js.map +1 -1
  42. package/dist/esm/typescript-schema.js +2 -1
  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 +660 -690
  47. package/dist/standalone/index.umd.cjs +16 -16
  48. package/package.json +3 -3
@@ -1,7 +1,28 @@
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
+ };
2
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
24
  };
25
+ var _PlatformApi_auth, _PlatformApi_apiURI;
5
26
  Object.defineProperty(exports, "__esModule", { value: true });
6
27
  exports.PlatformApi = exports.PlatformApiMissingAuthError = void 0;
7
28
  exports.apiSchemaToInstantSchemaDef = apiSchemaToInstantSchemaDef;
@@ -12,30 +33,26 @@ const schema_ts_1 = require("./schema.js");
12
33
  const ProgressPromise_ts_1 = require("./ProgressPromise.js");
13
34
  const util_ts_1 = require("./util.js");
14
35
  const serverOAuth_ts_1 = require("./serverOAuth.js");
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
- }
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
+ });
39
56
  }
40
57
  function attrDefForType(type) {
41
58
  switch (type) {
@@ -58,7 +75,7 @@ function attrDefForType(type) {
58
75
  }
59
76
  }
60
77
  function apiSchemaAttrToDataAttrDef(attr, opts) {
61
- const derivedType = (0, util_ts_1.deriveClientType)(attr, opts?.disableTypeInference);
78
+ const derivedType = (0, util_ts_1.deriveClientType)(attr, opts === null || opts === void 0 ? void 0 : opts.disableTypeInference);
62
79
  let i = attrDefForType(derivedType.type);
63
80
  if (attr['unique?']) {
64
81
  i = i.unique();
@@ -122,13 +139,7 @@ function apiSchemaToInstantSchemaDef(apiSchema, opts) {
122
139
  return core_1.i.schema({ entities, links });
123
140
  }
124
141
  function coerceApp(app) {
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
- };
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'] } : {}));
132
143
  // `in` narrows the union, so it’s safe to read `perms` / `schema`
133
144
  // when the property exists. :contentReference[oaicite:0]{index=0}
134
145
  const permsPart = ('perms' in app ? { perms: app.perms } : {});
@@ -137,7 +148,7 @@ function coerceApp(app) {
137
148
  schema: apiSchemaToInstantSchemaDef(app.schema),
138
149
  }
139
150
  : {});
140
- return { ...base, ...permsPart, ...schemaPart };
151
+ return Object.assign(Object.assign(Object.assign({}, base), permsPart), schemaPart);
141
152
  }
142
153
  function coerceOrg(org) {
143
154
  return {
@@ -146,157 +157,167 @@ function coerceOrg(org) {
146
157
  createdAt: new Date(org.created_at),
147
158
  };
148
159
  }
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
- },
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) };
166
180
  });
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
- },
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) };
176
192
  });
177
- return { orgs: resp.orgs.map(coerceOrg) };
178
193
  }
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
- },
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) };
196
214
  });
197
- return { apps: resp.apps.map(coerceApp) };
198
215
  }
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
- },
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) };
205
225
  });
206
- return { schema: apiSchemaToInstantSchemaDef(schema) };
207
226
  }
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
- },
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
+ });
214
235
  });
215
236
  }
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
- },
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
+ };
230
261
  });
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
- };
243
262
  }
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),
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
+ };
254
279
  });
255
- const withAdminToken = {
256
- ...coerceApp(app),
257
- adminToken: app['admin-token'],
258
- };
259
- return {
260
- app: withAdminToken,
261
- };
262
280
  }
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),
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
+ };
270
295
  });
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
- };
279
296
  }
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),
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) };
288
308
  });
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
- },
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) };
298
320
  });
299
- return { app: coerceApp(app) };
300
321
  }
301
322
  function translatePlanStep(apiStep) {
302
323
  const [stepType, stepParams] = apiStep;
@@ -422,29 +443,27 @@ function translatePushStep(apiStep, jobs) {
422
443
  if (planStep.type !== backgroundJob.type) {
423
444
  throw new Error('Invalid type');
424
445
  }
425
- return { ...planStep, backgroundJob };
446
+ return Object.assign(Object.assign({}, planStep), { backgroundJob });
426
447
  }
427
448
  function translatePushSteps(apiSteps, jobs) {
428
449
  return apiSteps.map((step) => translatePushStep(step, jobs));
429
450
  }
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
- }),
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
+ };
442
466
  });
443
- return {
444
- newSchema: apiSchemaToInstantSchemaDef(resp['new-schema']),
445
- currentSchema: apiSchemaToInstantSchemaDef(resp['current-schema']),
446
- steps: translatePlanSteps(resp['steps']),
447
- };
448
467
  }
449
468
  function allJobsComplete(jobs) {
450
469
  return !!jobs.find((j) => j.job_status === 'completed' || j.job_status === 'errored');
@@ -461,44 +480,47 @@ function latestJobUpdate(jobs) {
461
480
  }, null);
462
481
  return res;
463
482
  }
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;
480
- }
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;
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;
492
508
  }
493
- else {
494
- errorCount++;
495
- interval = Math.min(interval * 2, 10000);
509
+ catch (e) {
510
+ if (errorCount > 3) {
511
+ throw e;
512
+ }
513
+ else {
514
+ errorCount++;
515
+ interval = Math.min(interval * 2, 10000);
516
+ }
496
517
  }
497
518
  }
498
- }
499
- return lastJobs;
519
+ return lastJobs;
520
+ });
500
521
  }
501
522
  function formatJob(job) {
523
+ var _a;
502
524
  const baseJob = {
503
525
  id: job.id,
504
526
  createdAt: new Date(job.created_at),
@@ -507,7 +529,7 @@ function formatJob(job) {
507
529
  workEstimate: job.work_estimate,
508
530
  workCompleted: job.work_completed,
509
531
  error: job.error,
510
- invalidTriplesSample: job.invalid_triples_sample?.map((s) => {
532
+ invalidTriplesSample: (_a = job.invalid_triples_sample) === null || _a === void 0 ? void 0 : _a.map((s) => {
511
533
  return { entityId: s.entity_id, value: s.value, jsonType: s.json_type };
512
534
  }),
513
535
  };
@@ -518,21 +540,13 @@ function formatJob(job) {
518
540
  case 'required':
519
541
  case 'remove-required':
520
542
  case 'remove-unique': {
521
- return { ...baseJob, type: job.job_type };
543
+ return Object.assign(Object.assign({}, baseJob), { type: job.job_type });
522
544
  }
523
545
  case 'check-data-type': {
524
- return {
525
- ...baseJob,
526
- type: job.job_type,
527
- checkedDataType: job.checked_data_type,
528
- };
546
+ return Object.assign(Object.assign({}, baseJob), { type: job.job_type, checkedDataType: job.checked_data_type });
529
547
  }
530
548
  case 'unique': {
531
- return {
532
- ...baseJob,
533
- type: job.job_type,
534
- invalidUniqueValue: job.invalid_unique_value,
535
- };
549
+ return Object.assign(Object.assign({}, baseJob), { type: job.job_type, invalidUniqueValue: job.invalid_unique_value });
536
550
  }
537
551
  default: {
538
552
  const neverType = job.job_type;
@@ -563,27 +577,23 @@ function stepSummary(steps) {
563
577
  };
564
578
  }
565
579
  function schemaPush(apiURI, token, appId, body) {
566
- return new ProgressPromise_ts_1.ProgressPromise(async (progress, resolve, reject) => {
580
+ return new ProgressPromise_ts_1.ProgressPromise((progress, resolve, reject) => __awaiter(this, void 0, void 0, function* () {
567
581
  try {
568
- const resp = await jsonFetch(`${apiURI}/superadmin/apps/${appId}/schema/push/apply`, {
582
+ const resp = yield jsonFetch(`${apiURI}/superadmin/apps/${appId}/schema/push/apply`, {
569
583
  method: 'POST',
570
584
  headers: {
571
585
  'Content-Type': 'application/json',
572
586
  Authorization: `Bearer ${token}`,
573
587
  },
574
- body: JSON.stringify({
575
- ...body,
576
- check_types: true,
577
- supports_background_updates: true,
578
- }),
588
+ body: JSON.stringify(Object.assign(Object.assign({}, body), { check_types: true, supports_background_updates: true })),
579
589
  });
580
590
  const indexingJobs = resp['indexing-jobs'];
581
591
  const jobs = !indexingJobs
582
592
  ? []
583
- : await jobFetchLoop(apiURI, token, appId, indexingJobs['group-id'], indexingJobs['jobs'], (jobs) => {
593
+ : yield jobFetchLoop(apiURI, token, appId, indexingJobs['group-id'], indexingJobs['jobs'], (jobs) => {
584
594
  progress(stepSummary(translatePushSteps(resp.steps, jobs)));
585
595
  });
586
- const schemaRes = await getAppSchema(apiURI, token, appId);
596
+ const schemaRes = yield getAppSchema(apiURI, token, appId);
587
597
  resolve({
588
598
  newSchema: schemaRes.schema,
589
599
  steps: translatePushSteps(resp.steps, jobs),
@@ -593,28 +603,32 @@ function schemaPush(apiURI, token, appId, body) {
593
603
  catch (e) {
594
604
  reject(e);
595
605
  }
596
- });
606
+ }));
597
607
  }
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 }),
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 };
606
619
  });
607
- return { perms: result.rules.code };
608
620
  }
609
- async function tokenInfo(apiURI, token) {
610
- const result = await jsonFetch(`${apiURI}/platform/oauth/token-info?access_token=${token}`, {
611
- method: 'GET',
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
+ };
612
631
  });
613
- return {
614
- tokenType: result.token_type,
615
- scopes: result.scopes,
616
- expiresAt: new Date(Date.now() + (result.expires_in - 60) * 1000),
617
- };
618
632
  }
619
633
  class PlatformApiMissingAuthError extends Error {
620
634
  constructor() {
@@ -638,8 +652,6 @@ exports.PlatformApiMissingAuthError = PlatformApiMissingAuthError;
638
652
  * ```
639
653
  */
640
654
  class PlatformApi {
641
- #auth;
642
- #apiURI;
643
655
  /**
644
656
  * @param config – Runtime configuration.
645
657
  * @param config.auth.token – OAuth access-token obtained via the oauth flow
@@ -647,76 +659,83 @@ class PlatformApi {
647
659
  * @throws {Error} When `token` is missing.
648
660
  */
649
661
  constructor(config) {
650
- this.#auth = config?.auth;
651
- this.#apiURI = config?.apiURI || 'https://api.instantdb.com';
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");
652
666
  }
653
667
  token() {
654
- if (!this.#auth) {
668
+ if (!__classPrivateFieldGet(this, _PlatformApi_auth, "f")) {
655
669
  throw new PlatformApiMissingAuthError();
656
670
  }
657
- if ('token' in this.#auth) {
658
- return this.#auth.token;
671
+ if ('token' in __classPrivateFieldGet(this, _PlatformApi_auth, "f")) {
672
+ return __classPrivateFieldGet(this, _PlatformApi_auth, "f").token;
659
673
  }
660
- return this.#auth.accessToken;
674
+ return __classPrivateFieldGet(this, _PlatformApi_auth, "f").accessToken;
661
675
  }
662
676
  canRefreshToken() {
663
- if (!this.#auth) {
677
+ if (!__classPrivateFieldGet(this, _PlatformApi_auth, "f")) {
664
678
  throw new PlatformApiMissingAuthError();
665
679
  }
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);
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);
672
686
  }
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,
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;
688
709
  });
689
- this.#auth.accessToken = token.accessToken;
690
- if (this.#auth.onRefresh) {
691
- await this.#auth.onRefresh(token);
692
- }
693
- return token;
694
710
  }
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;
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
+ }
715
734
  }
735
+ throw e;
716
736
  }
717
- throw e;
718
737
  }
719
- }
738
+ });
720
739
  }
721
740
  /**
722
741
  * Fetch a single app by its id.
@@ -735,8 +754,10 @@ class PlatformApi {
735
754
  * @returns A typed wrapper containing the app, whose shape is expanded
736
755
  * according to `Opts`.
737
756
  */
738
- async getApp(appId, opts) {
739
- return this.withRetry(getApp, [this.#apiURI, this.token(), appId, opts]);
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
+ });
740
761
  }
741
762
  /**
742
763
  * List **all apps** owned by the auth owner.
@@ -752,8 +773,10 @@ class PlatformApi {
752
773
  * @param opts – `{ includeSchema?: boolean; includePerms?: boolean }`
753
774
  * @returns An array wrapper; each element’s shape follows `Opts`.
754
775
  */
755
- async getApps(opts) {
756
- return this.withRetry(getApps, [this.#apiURI, this.token(), opts]);
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
+ });
757
780
  }
758
781
  /**
759
782
  * List **all orgs** that the auth owner is a member of.
@@ -764,8 +787,10 @@ class PlatformApi {
764
787
  *
765
788
  * @returns An array of orgs
766
789
  */
767
- async getOrgs() {
768
- return this.withRetry(getOrgs, [this.#apiURI, this.token()]);
790
+ getOrgs() {
791
+ return __awaiter(this, void 0, void 0, function* () {
792
+ return this.withRetry(getOrgs, [__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), this.token()]);
793
+ });
769
794
  }
770
795
  /**
771
796
  * List **all apps** owned by the auth owner.
@@ -781,13 +806,15 @@ class PlatformApi {
781
806
  * @param opts – `{ includeSchema?: boolean; includePerms?: boolean }`
782
807
  * @returns An array wrapper; each element’s shape follows `Opts`.
783
808
  */
784
- async getAppsForOrg(orgId, opts) {
785
- return this.withRetry(getAppsForOrg, [
786
- this.#apiURI,
787
- this.token(),
788
- orgId,
789
- opts,
790
- ]);
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
+ });
791
818
  }
792
819
  /**
793
820
  * Gets the schema for an app by its id.
@@ -798,8 +825,10 @@ class PlatformApi {
798
825
  *
799
826
  * @param appId -- UUID of the app
800
827
  */
801
- async getSchema(appId) {
802
- return this.withRetry(getAppSchema, [this.#apiURI, this.token(), appId]);
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
+ });
803
832
  }
804
833
  /**
805
834
  * Gets the permissions for an app by its id.
@@ -810,8 +839,10 @@ class PlatformApi {
810
839
  *
811
840
  * @param appId -- UUID of the app
812
841
  */
813
- async getPerms(appId) {
814
- return this.withRetry(getAppPerms, [this.#apiURI, this.token(), appId]);
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
+ });
815
846
  }
816
847
  /**
817
848
  * Create a new app.
@@ -839,8 +870,10 @@ class PlatformApi {
839
870
  * @param fields.perms -- Optional permissions for the app
840
871
  * @param fields.orgId -- Optional id of the org that the app will be placed in
841
872
  */
842
- async createApp(fields) {
843
- return this.withRetry(createApp, [this.#apiURI, this.token(), fields]);
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
+ });
844
877
  }
845
878
  /**
846
879
  * Create a new temporary app.
@@ -864,8 +897,10 @@ class PlatformApi {
864
897
  * @param fields.schema -- Optional schema for the app
865
898
  * @param fields.perms -- Optional permissions for the app
866
899
  */
867
- async createTemporaryApp(fields) {
868
- return createTemporaryApp(this.#apiURI, fields);
900
+ createTemporaryApp(fields) {
901
+ return __awaiter(this, void 0, void 0, function* () {
902
+ return createTemporaryApp(__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), fields);
903
+ });
869
904
  }
870
905
  /**
871
906
  * Update the title of an app by its id.
@@ -879,13 +914,15 @@ class PlatformApi {
879
914
  * @param appId -- UUID of the app
880
915
  * @param fields.title -- New title for the app
881
916
  */
882
- async updateApp(appId, fields) {
883
- return this.withRetry(updateApp, [
884
- this.#apiURI,
885
- this.token(),
886
- appId,
887
- fields,
888
- ]);
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
+ });
889
926
  }
890
927
  /**
891
928
  * Delete an app by its id.
@@ -896,8 +933,10 @@ class PlatformApi {
896
933
  *
897
934
  * @param appId -- UUID of the app
898
935
  */
899
- async deleteApp(appId) {
900
- return this.withRetry(deleteApp, [this.#apiURI, this.token(), appId]);
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
+ });
901
940
  }
902
941
  /**
903
942
  * Dry-run a **schema push** and receive a _plan_ of steps the server would
@@ -907,13 +946,15 @@ class PlatformApi {
907
946
  * const { steps } = await api.planSchemaPush(appId, body);
908
947
  * ```
909
948
  */
910
- async planSchemaPush(appId, body) {
911
- return this.withRetry(planSchemaPush, [
912
- this.#apiURI,
913
- this.token(),
914
- appId,
915
- body,
916
- ]);
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
+ });
917
958
  }
918
959
  /**
919
960
  * Execute a **schema push**. The server returns a long-running job
@@ -942,19 +983,19 @@ class PlatformApi {
942
983
  * ```
943
984
  */
944
985
  schemaPush(appId, body) {
945
- if (!this.#auth) {
986
+ if (!__classPrivateFieldGet(this, _PlatformApi_auth, "f")) {
946
987
  throw new PlatformApiMissingAuthError();
947
988
  }
948
- return new ProgressPromise_ts_1.ProgressPromise(async (progress, resolve, reject) => {
989
+ return new ProgressPromise_ts_1.ProgressPromise((progress, resolve, reject) => __awaiter(this, void 0, void 0, function* () {
949
990
  // It's tricky to add withRetry to the background process that fetches the jobs,
950
991
  // so we'll just refresh the token at the start.
951
992
  if (this.canRefreshToken()) {
952
993
  try {
953
- await this.refreshToken();
994
+ yield this.refreshToken();
954
995
  }
955
996
  catch (_e) { }
956
997
  }
957
- schemaPush(this.#apiURI, this.token(), appId, body).subscribe({
998
+ schemaPush(__classPrivateFieldGet(this, _PlatformApi_apiURI, "f"), this.token(), appId, body).subscribe({
958
999
  complete(v) {
959
1000
  resolve(v);
960
1001
  },
@@ -965,7 +1006,7 @@ class PlatformApi {
965
1006
  progress(v);
966
1007
  },
967
1008
  });
968
- });
1009
+ }));
969
1010
  }
970
1011
  /**
971
1012
  * Update permission rules for an app by its id.
@@ -981,18 +1022,23 @@ class PlatformApi {
981
1022
  * });
982
1023
  * ```
983
1024
  */
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]);
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
+ });
989
1032
  }
990
- async tokenInfo() {
991
- if (!this.#auth) {
992
- throw new PlatformApiMissingAuthError();
993
- }
994
- return this.withRetry(tokenInfo, [this.#apiURI, this.token()]);
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
+ });
995
1040
  }
996
1041
  }
997
1042
  exports.PlatformApi = PlatformApi;
1043
+ _PlatformApi_auth = new WeakMap(), _PlatformApi_apiURI = new WeakMap();
998
1044
  //# sourceMappingURL=api.js.map