appwrite-cli 13.4.0 → 13.6.0

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 (75) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +2 -2
  3. package/cli.ts +4 -2
  4. package/dist/bundle-win-arm64.mjs +1633 -2075
  5. package/dist/cli.cjs +1633 -2075
  6. package/dist/index.cjs +109645 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +780 -1831
  10. package/dist/lib/commands/generators/base.d.ts +16 -5
  11. package/dist/lib/commands/generators/base.d.ts.map +1 -1
  12. package/dist/lib/commands/generators/typescript/databases.d.ts.map +1 -1
  13. package/dist/lib/commands/push.d.ts +1 -0
  14. package/dist/lib/commands/push.d.ts.map +1 -1
  15. package/dist/lib/commands/schema.d.ts.map +1 -1
  16. package/dist/lib/commands/services/activities.d.ts +3 -0
  17. package/dist/lib/commands/services/activities.d.ts.map +1 -0
  18. package/dist/lib/commands/services/backups.d.ts +3 -0
  19. package/dist/lib/commands/services/backups.d.ts.map +1 -0
  20. package/dist/lib/commands/utils/attributes.d.ts +3 -1
  21. package/dist/lib/commands/utils/attributes.d.ts.map +1 -1
  22. package/dist/lib/commands/utils/pools.d.ts +3 -1
  23. package/dist/lib/commands/utils/pools.d.ts.map +1 -1
  24. package/dist/lib/constants.d.ts +1 -1
  25. package/dist/lib/json.d.ts.map +1 -1
  26. package/dist/lib/utils.d.ts +1 -0
  27. package/dist/lib/utils.d.ts.map +1 -1
  28. package/docs/examples/account/create-key.md +5 -0
  29. package/docs/examples/account/delete-key.md +4 -0
  30. package/docs/examples/account/get-key.md +4 -0
  31. package/docs/examples/account/list-keys.md +3 -0
  32. package/docs/examples/account/update-key.md +6 -0
  33. package/docs/examples/activities/get-event.md +4 -0
  34. package/docs/examples/activities/list-events.md +3 -0
  35. package/docs/examples/backups/create-archive.md +4 -0
  36. package/docs/examples/backups/create-policy.md +7 -0
  37. package/docs/examples/backups/create-restoration.md +5 -0
  38. package/docs/examples/backups/delete-archive.md +4 -0
  39. package/docs/examples/backups/delete-policy.md +4 -0
  40. package/docs/examples/backups/get-archive.md +4 -0
  41. package/docs/examples/backups/get-policy.md +4 -0
  42. package/docs/examples/backups/get-restoration.md +4 -0
  43. package/docs/examples/backups/list-archives.md +3 -0
  44. package/docs/examples/backups/list-policies.md +3 -0
  45. package/docs/examples/backups/list-restorations.md +3 -0
  46. package/docs/examples/backups/update-policy.md +4 -0
  47. package/docs/examples/projects/create-schedule.md +7 -0
  48. package/docs/examples/projects/get-schedule.md +5 -0
  49. package/docs/examples/projects/list-schedules.md +4 -0
  50. package/index.ts +1 -0
  51. package/install.ps1 +2 -2
  52. package/install.sh +1 -1
  53. package/lib/commands/generators/base.ts +30 -9
  54. package/lib/commands/generators/typescript/databases.ts +12 -18
  55. package/lib/commands/push.ts +276 -201
  56. package/lib/commands/schema.ts +1 -3
  57. package/lib/commands/services/account.ts +234 -0
  58. package/lib/commands/services/activities.ts +51 -0
  59. package/lib/commands/services/backups.ts +184 -0
  60. package/lib/commands/services/health.ts +55 -0
  61. package/lib/commands/services/migrations.ts +1 -1
  62. package/lib/commands/services/projects.ts +51 -0
  63. package/lib/commands/services/storage.ts +2 -2
  64. package/lib/commands/utils/attributes.ts +9 -6
  65. package/lib/commands/utils/pools.ts +9 -6
  66. package/lib/constants.ts +1 -1
  67. package/lib/json.ts +14 -7
  68. package/lib/utils.ts +15 -0
  69. package/package.json +19 -5
  70. package/scoop/appwrite.config.json +3 -3
  71. package/dist/lib/commands/services/console.d.ts +0 -3
  72. package/dist/lib/commands/services/console.d.ts.map +0 -1
  73. package/docs/examples/console/get-resource.md +0 -5
  74. package/docs/examples/console/variables.md +0 -3
  75. package/lib/commands/services/console.ts +0 -49
@@ -24,7 +24,11 @@ import {
24
24
  type CollectionType,
25
25
  } from "./config.js";
26
26
  import { parseWithBetterErrors } from "./utils/error-formatter.js";
27
- import { createSettingsObject } from "../utils.js";
27
+ import {
28
+ createSettingsObject,
29
+ checkDeployConditions,
30
+ arrayEqualsUnordered,
31
+ } from "../utils.js";
28
32
  import { Spinner, SPINNER_DOTS } from "../spinner.js";
29
33
  import { paginate } from "../paginate.js";
30
34
  import { pushDeployment } from "./utils/deployment.js";
@@ -72,7 +76,6 @@ import {
72
76
  Client,
73
77
  Query,
74
78
  } from "@appwrite.io/console";
75
- import { checkDeployConditions } from "../utils.js";
76
79
  import { Pools } from "./utils/pools.js";
77
80
  import { Attributes, Collection } from "./utils/attributes.js";
78
81
  import {
@@ -98,6 +101,7 @@ export interface PushOptions {
98
101
  topics?: boolean;
99
102
  skipDeprecated?: boolean;
100
103
  skipConfirmation?: boolean;
104
+ force?: boolean;
101
105
  functionOptions?: {
102
106
  async?: boolean;
103
107
  code?: boolean;
@@ -200,207 +204,219 @@ export class Push {
200
204
  results: Record<string, any>;
201
205
  errors: any[];
202
206
  }> {
203
- const { skipDeprecated = true } = options;
204
- const results: Record<string, any> = {};
205
- const allErrors: any[] = [];
206
- const shouldPushAll = options.all === true;
207
-
208
- // Push settings
209
- if (
210
- (shouldPushAll || options.settings) &&
211
- (config.projectName || config.settings)
212
- ) {
213
- try {
214
- this.log("Pushing settings ...");
215
- await this.pushSettings({
216
- projectId: config.projectId,
217
- projectName: config.projectName,
218
- settings: config.settings,
219
- });
220
- this.success(
221
- `Successfully pushed ${chalk.bold("all")} project settings.`,
222
- );
223
- results.settings = { success: true };
224
- } catch (e: any) {
225
- allErrors.push(e);
226
- results.settings = { success: false, error: e.message };
227
- }
207
+ const previousForce = cliConfig.force;
208
+ if (options.force !== undefined) {
209
+ cliConfig.force = options.force;
228
210
  }
229
211
 
230
- // Push buckets
231
- if (
232
- (shouldPushAll || options.buckets) &&
233
- config.buckets &&
234
- config.buckets.length > 0
235
- ) {
236
- try {
237
- this.log("Pushing buckets ...");
238
- const result = await this.pushBuckets(config.buckets);
239
- this.success(
240
- `Successfully pushed ${chalk.bold(result.successfullyPushed)} buckets.`,
241
- );
242
- results.buckets = result;
243
- allErrors.push(...result.errors);
244
- } catch (e: any) {
245
- allErrors.push(e);
246
- results.buckets = { successfullyPushed: 0, errors: [e] };
212
+ try {
213
+ const { skipDeprecated = true } = options;
214
+ const results: Record<string, any> = {};
215
+ const allErrors: any[] = [];
216
+ const shouldPushAll = options.all === true;
217
+
218
+ // Push settings
219
+ if (
220
+ (shouldPushAll || options.settings) &&
221
+ (config.projectName || config.settings)
222
+ ) {
223
+ try {
224
+ this.log("Pushing settings ...");
225
+ await this.pushSettings({
226
+ projectId: config.projectId,
227
+ projectName: config.projectName,
228
+ settings: config.settings,
229
+ });
230
+ this.success(
231
+ `Successfully pushed ${chalk.bold("all")} project settings.`,
232
+ );
233
+ results.settings = { success: true };
234
+ } catch (e: any) {
235
+ allErrors.push(e);
236
+ results.settings = { success: false, error: e.message };
237
+ }
247
238
  }
248
- }
249
239
 
250
- // Push teams
251
- if (
252
- (shouldPushAll || options.teams) &&
253
- config.teams &&
254
- config.teams.length > 0
255
- ) {
256
- try {
257
- this.log("Pushing teams ...");
258
- const result = await this.pushTeams(config.teams);
259
- this.success(
260
- `Successfully pushed ${chalk.bold(result.successfullyPushed)} teams.`,
261
- );
262
- results.teams = result;
263
- allErrors.push(...result.errors);
264
- } catch (e: any) {
265
- allErrors.push(e);
266
- results.teams = { successfullyPushed: 0, errors: [e] };
240
+ // Push buckets
241
+ if (
242
+ (shouldPushAll || options.buckets) &&
243
+ config.buckets &&
244
+ config.buckets.length > 0
245
+ ) {
246
+ try {
247
+ this.log("Pushing buckets ...");
248
+ const result = await this.pushBuckets(config.buckets);
249
+ this.success(
250
+ `Successfully pushed ${chalk.bold(result.successfullyPushed)} buckets.`,
251
+ );
252
+ results.buckets = result;
253
+ allErrors.push(...result.errors);
254
+ } catch (e: any) {
255
+ allErrors.push(e);
256
+ results.buckets = { successfullyPushed: 0, errors: [e] };
257
+ }
267
258
  }
268
- }
269
259
 
270
- // Push messaging topics
271
- if (
272
- (shouldPushAll || options.topics) &&
273
- config.topics &&
274
- config.topics.length > 0
275
- ) {
276
- try {
277
- this.log("Pushing topics ...");
278
- const result = await this.pushMessagingTopics(config.topics);
279
- this.success(
280
- `Successfully pushed ${chalk.bold(result.successfullyPushed)} topics.`,
281
- );
282
- results.topics = result;
283
- allErrors.push(...result.errors);
284
- } catch (e: any) {
285
- allErrors.push(e);
286
- results.topics = { successfullyPushed: 0, errors: [e] };
260
+ // Push teams
261
+ if (
262
+ (shouldPushAll || options.teams) &&
263
+ config.teams &&
264
+ config.teams.length > 0
265
+ ) {
266
+ try {
267
+ this.log("Pushing teams ...");
268
+ const result = await this.pushTeams(config.teams);
269
+ this.success(
270
+ `Successfully pushed ${chalk.bold(result.successfullyPushed)} teams.`,
271
+ );
272
+ results.teams = result;
273
+ allErrors.push(...result.errors);
274
+ } catch (e: any) {
275
+ allErrors.push(e);
276
+ results.teams = { successfullyPushed: 0, errors: [e] };
277
+ }
287
278
  }
288
- }
289
279
 
290
- // Push functions
291
- if (
292
- (shouldPushAll || options.functions) &&
293
- config.functions &&
294
- config.functions.length > 0
295
- ) {
296
- try {
297
- this.log("Pushing functions ...");
298
- const result = await this.pushFunctions(
299
- config.functions,
300
- options.functionOptions,
301
- );
302
- this.success(
303
- `Successfully pushed ${chalk.bold(result.successfullyPushed)} functions.`,
304
- );
305
- results.functions = result;
306
- allErrors.push(...result.errors);
307
- } catch (e: any) {
308
- allErrors.push(e);
309
- results.functions = {
310
- successfullyPushed: 0,
311
- successfullyDeployed: 0,
312
- failedDeployments: [],
313
- errors: [e],
314
- };
280
+ // Push messaging topics
281
+ if (
282
+ (shouldPushAll || options.topics) &&
283
+ config.topics &&
284
+ config.topics.length > 0
285
+ ) {
286
+ try {
287
+ this.log("Pushing topics ...");
288
+ const result = await this.pushMessagingTopics(config.topics);
289
+ this.success(
290
+ `Successfully pushed ${chalk.bold(result.successfullyPushed)} topics.`,
291
+ );
292
+ results.topics = result;
293
+ allErrors.push(...result.errors);
294
+ } catch (e: any) {
295
+ allErrors.push(e);
296
+ results.topics = { successfullyPushed: 0, errors: [e] };
297
+ }
315
298
  }
316
- }
317
299
 
318
- // Push sites
319
- if (
320
- (shouldPushAll || options.sites) &&
321
- config.sites &&
322
- config.sites.length > 0
323
- ) {
324
- try {
325
- this.log("Pushing sites ...");
326
- const result = await this.pushSites(config.sites, options.siteOptions);
327
- this.success(
328
- `Successfully pushed ${chalk.bold(result.successfullyPushed)} sites.`,
329
- );
330
- results.sites = result;
331
- allErrors.push(...result.errors);
332
- } catch (e: any) {
333
- allErrors.push(e);
334
- results.sites = {
335
- successfullyPushed: 0,
336
- successfullyDeployed: 0,
337
- failedDeployments: [],
338
- errors: [e],
339
- };
300
+ // Push functions
301
+ if (
302
+ (shouldPushAll || options.functions) &&
303
+ config.functions &&
304
+ config.functions.length > 0
305
+ ) {
306
+ try {
307
+ this.log("Pushing functions ...");
308
+ const result = await this.pushFunctions(
309
+ config.functions,
310
+ options.functionOptions,
311
+ );
312
+ this.success(
313
+ `Successfully pushed ${chalk.bold(result.successfullyPushed)} functions.`,
314
+ );
315
+ results.functions = result;
316
+ allErrors.push(...result.errors);
317
+ } catch (e: any) {
318
+ allErrors.push(e);
319
+ results.functions = {
320
+ successfullyPushed: 0,
321
+ successfullyDeployed: 0,
322
+ failedDeployments: [],
323
+ errors: [e],
324
+ };
325
+ }
340
326
  }
341
- }
342
327
 
343
- // Push tables
344
- if (
345
- (shouldPushAll || options.tables) &&
346
- config.tables &&
347
- config.tables.length > 0
348
- ) {
349
- try {
350
- this.log("Pushing tables ...");
351
- const result = await this.pushTables(config.tables, {
352
- attempts: options.tableOptions?.attempts,
353
- skipConfirmation: options.skipConfirmation,
354
- });
355
- this.success(
356
- `Successfully pushed ${chalk.bold(result.successfullyPushed)} tables.`,
357
- );
358
- results.tables = result;
359
- allErrors.push(...result.errors);
360
- } catch (e: any) {
361
- allErrors.push(e);
362
- results.tables = { successfullyPushed: 0, errors: [e] };
328
+ // Push sites
329
+ if (
330
+ (shouldPushAll || options.sites) &&
331
+ config.sites &&
332
+ config.sites.length > 0
333
+ ) {
334
+ try {
335
+ this.log("Pushing sites ...");
336
+ const result = await this.pushSites(
337
+ config.sites,
338
+ options.siteOptions,
339
+ );
340
+ this.success(
341
+ `Successfully pushed ${chalk.bold(result.successfullyPushed)} sites.`,
342
+ );
343
+ results.sites = result;
344
+ allErrors.push(...result.errors);
345
+ } catch (e: any) {
346
+ allErrors.push(e);
347
+ results.sites = {
348
+ successfullyPushed: 0,
349
+ successfullyDeployed: 0,
350
+ failedDeployments: [],
351
+ errors: [e],
352
+ };
353
+ }
363
354
  }
364
- }
365
355
 
366
- // Push collections (skipDeprecated only applies when pushing all, explicit collections option takes precedence)
367
- if (
368
- (options.collections || (shouldPushAll && !skipDeprecated)) &&
369
- config.collections &&
370
- config.collections.length > 0
371
- ) {
372
- try {
373
- this.log("Pushing collections ...");
374
- // Add database names to collections
375
- const collectionsWithDbNames = config.collections.map(
376
- (collection: any) => {
377
- const database = config.databases?.find(
378
- (db: any) => db.$id === collection.databaseId,
379
- );
380
- return {
381
- ...collection,
382
- databaseName: database?.name ?? collection.databaseId,
383
- };
384
- },
385
- );
386
- const result = await this.pushCollections(collectionsWithDbNames, {
387
- skipConfirmation: options.skipConfirmation,
388
- });
389
- this.success(
390
- `Successfully pushed ${chalk.bold(result.successfullyPushed)} collections.`,
391
- );
392
- results.collections = result;
393
- allErrors.push(...result.errors);
394
- } catch (e: any) {
395
- allErrors.push(e);
396
- results.collections = { successfullyPushed: 0, errors: [e] };
356
+ // Push tables
357
+ if (
358
+ (shouldPushAll || options.tables) &&
359
+ config.tables &&
360
+ config.tables.length > 0
361
+ ) {
362
+ try {
363
+ this.log("Pushing tables ...");
364
+ const result = await this.pushTables(config.tables, {
365
+ attempts: options.tableOptions?.attempts,
366
+ skipConfirmation: options.skipConfirmation,
367
+ });
368
+ this.success(
369
+ `Successfully pushed ${chalk.bold(result.successfullyPushed)} tables.`,
370
+ );
371
+ results.tables = result;
372
+ allErrors.push(...result.errors);
373
+ } catch (e: any) {
374
+ allErrors.push(e);
375
+ results.tables = { successfullyPushed: 0, errors: [e] };
376
+ }
397
377
  }
398
- }
399
378
 
400
- return {
401
- results,
402
- errors: allErrors,
403
- };
379
+ // Push collections (skipDeprecated only applies when pushing all, explicit collections option takes precedence)
380
+ if (
381
+ (options.collections || (shouldPushAll && !skipDeprecated)) &&
382
+ config.collections &&
383
+ config.collections.length > 0
384
+ ) {
385
+ try {
386
+ this.log("Pushing collections ...");
387
+ // Add database names to collections
388
+ const collectionsWithDbNames = config.collections.map(
389
+ (collection: any) => {
390
+ const database = config.databases?.find(
391
+ (db: any) => db.$id === collection.databaseId,
392
+ );
393
+ return {
394
+ ...collection,
395
+ databaseName: database?.name ?? collection.databaseId,
396
+ };
397
+ },
398
+ );
399
+ const result = await this.pushCollections(collectionsWithDbNames, {
400
+ skipConfirmation: options.skipConfirmation,
401
+ });
402
+ this.success(
403
+ `Successfully pushed ${chalk.bold(result.successfullyPushed)} collections.`,
404
+ );
405
+ results.collections = result;
406
+ allErrors.push(...result.errors);
407
+ } catch (e: any) {
408
+ allErrors.push(e);
409
+ results.collections = { successfullyPushed: 0, errors: [e] };
410
+ }
411
+ }
412
+
413
+ return {
414
+ results,
415
+ errors: allErrors,
416
+ };
417
+ } finally {
418
+ cliConfig.force = previousForce;
419
+ }
404
420
  }
405
421
 
406
422
  public async pushSettings(config: {
@@ -489,13 +505,54 @@ export class Push {
489
505
  let successfullyPushed = 0;
490
506
  const errors: any[] = [];
491
507
 
508
+ const hasBucketChanges = (remoteBucket: any, localBucket: any): boolean => {
509
+ const scalarFields = [
510
+ "name",
511
+ "fileSecurity",
512
+ "enabled",
513
+ "maximumFileSize",
514
+ "encryption",
515
+ "antivirus",
516
+ "compression",
517
+ ] as const;
518
+
519
+ if (
520
+ scalarFields.some((field) => remoteBucket[field] !== localBucket[field])
521
+ ) {
522
+ return true;
523
+ }
524
+
525
+ if (
526
+ !arrayEqualsUnordered(
527
+ remoteBucket["$permissions"],
528
+ localBucket["$permissions"],
529
+ )
530
+ ) {
531
+ return true;
532
+ }
533
+
534
+ return !arrayEqualsUnordered(
535
+ remoteBucket.allowedFileExtensions,
536
+ localBucket.allowedFileExtensions,
537
+ );
538
+ };
539
+
492
540
  for (const bucket of buckets) {
493
541
  try {
494
542
  this.log(`Pushing bucket ${chalk.bold(bucket["name"])} ...`);
495
543
  const storageService = await getStorageService(this.projectClient);
496
544
 
497
545
  try {
498
- await storageService.getBucket(bucket["$id"]);
546
+ const remoteBucket = await storageService.getBucket(bucket["$id"]);
547
+ const hasChanges = hasBucketChanges(remoteBucket, bucket);
548
+
549
+ if (!hasChanges) {
550
+ this.log(
551
+ `No changes detected for bucket ${chalk.bold(bucket["name"])}. Skipping.`,
552
+ );
553
+ continue;
554
+ }
555
+
499
556
  await storageService.updateBucket({
500
557
  bucketId: bucket["$id"],
501
558
  name: bucket.name,
@@ -508,6 +565,7 @@ export class Push {
508
565
  antivirus: bucket.antivirus,
509
566
  compression: bucket.compression,
510
567
  });
568
+ successfullyPushed++;
511
569
  } catch (e: unknown) {
512
570
  if (e instanceof AppwriteException && Number(e.code) === 404) {
513
571
  await storageService.createBucket({
@@ -522,12 +580,11 @@ export class Push {
522
580
  encryption: bucket.encryption,
523
581
  antivirus: bucket.antivirus,
524
582
  });
583
+ successfullyPushed++;
525
584
  } else {
526
585
  throw e;
527
586
  }
528
587
  }
529
-
530
- successfullyPushed++;
531
588
  } catch (e: any) {
532
589
  errors.push(e);
533
590
  this.error(`Failed to push bucket ${bucket["name"]}: ${e.message}`);
@@ -1360,8 +1417,12 @@ export class Push {
1360
1417
  }> {
1361
1418
  const { attempts, skipConfirmation = false } = options;
1362
1419
  const pollMaxDebounces = attempts ?? POLL_DEFAULT_VALUE;
1363
- const pools = new Pools(pollMaxDebounces);
1364
- const attributes = new Attributes(pools, skipConfirmation);
1420
+ const pools = new Pools(pollMaxDebounces, this.projectClient);
1421
+ const attributes = new Attributes(
1422
+ pools,
1423
+ skipConfirmation,
1424
+ this.projectClient,
1425
+ );
1365
1426
 
1366
1427
  let tablesChanged = new Set();
1367
1428
  const errors: any[] = [];
@@ -1454,6 +1515,11 @@ export class Push {
1454
1515
  hadChanges = columnsResult.hasChanges || indexesResult.hasChanges;
1455
1516
 
1456
1517
  if (!hadChanges && columns.length <= 0 && indexes.length <= 0) {
1518
+ if (!tablesChanged.has(table["$id"])) {
1519
+ this.log(
1520
+ `No changes detected for table ${chalk.bold(table["name"])}. Skipping.`,
1521
+ );
1522
+ }
1457
1523
  continue;
1458
1524
  }
1459
1525
  }
@@ -1493,8 +1559,12 @@ export class Push {
1493
1559
  errors: Error[];
1494
1560
  }> {
1495
1561
  const { skipConfirmation = false } = options;
1496
- const pools = new Pools(POLL_DEFAULT_VALUE);
1497
- const attributesHelper = new Attributes(pools, skipConfirmation);
1562
+ const pools = new Pools(POLL_DEFAULT_VALUE, this.projectClient);
1563
+ const attributesHelper = new Attributes(
1564
+ pools,
1565
+ skipConfirmation,
1566
+ this.projectClient,
1567
+ );
1498
1568
 
1499
1569
  const errors: Error[] = [];
1500
1570
 
@@ -1935,15 +2005,17 @@ const pushSite = async ({
1935
2005
  const { name, deployment, $id } = failed;
1936
2006
  const projectId = localConfig.getProject().projectId;
1937
2007
  const endpoint = localConfig.getEndpoint() || globalConfig.getEndpoint();
1938
- let region = '';
2008
+ let region = "";
1939
2009
  try {
1940
2010
  const hostname = new URL(endpoint).hostname;
1941
- const firstSubdomain = hostname.split('.')[0];
2011
+ const firstSubdomain = hostname.split(".")[0];
1942
2012
  if (firstSubdomain.length === 3) {
1943
2013
  region = firstSubdomain;
1944
2014
  }
1945
2015
  } catch {}
1946
- const projectSlug = region ? `project-${region}-${projectId}` : `project-${projectId}`;
2016
+ const projectSlug = region
2017
+ ? `project-${region}-${projectId}`
2018
+ : `project-${projectId}`;
1947
2019
  const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/${projectSlug}/sites/site-${$id}/deployments/deployment-${deployment}`;
1948
2020
 
1949
2021
  error(
@@ -2074,15 +2146,17 @@ const pushFunction = async ({
2074
2146
  const { name, deployment, $id } = failed;
2075
2147
  const projectId = localConfig.getProject().projectId;
2076
2148
  const endpoint = localConfig.getEndpoint() || globalConfig.getEndpoint();
2077
- let region = '';
2149
+ let region = "";
2078
2150
  try {
2079
2151
  const hostname = new URL(endpoint).hostname;
2080
- const firstSubdomain = hostname.split('.')[0];
2152
+ const firstSubdomain = hostname.split(".")[0];
2081
2153
  if (firstSubdomain.length === 3) {
2082
2154
  region = firstSubdomain;
2083
2155
  }
2084
2156
  } catch {}
2085
- const projectSlug = region ? `project-${region}-${projectId}` : `project-${projectId}`;
2157
+ const projectSlug = region
2158
+ ? `project-${region}-${projectId}`
2159
+ : `project-${projectId}`;
2086
2160
  const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/${projectSlug}/functions/function-${$id}/deployment-${deployment}`;
2087
2161
 
2088
2162
  error(
@@ -2316,12 +2390,13 @@ const pushCollection = async (): Promise<void> => {
2316
2390
  const localDatabase = localConfig.getDatabase(collection.databaseId);
2317
2391
  collection.databaseName = localDatabase.name ?? collection.databaseId;
2318
2392
  });
2393
+ const projectClient = await sdkForProject();
2319
2394
 
2320
2395
  if (
2321
2396
  !(await approveChanges(
2322
2397
  collections,
2323
2398
  async (args: any) => {
2324
- const databasesService = await getDatabasesService();
2399
+ const databasesService = await getDatabasesService(projectClient);
2325
2400
  return await databasesService.getCollection(
2326
2401
  args.databaseId,
2327
2402
  args.collectionId,
@@ -4,13 +4,11 @@ import { ConfigSchema } from "./config.js";
4
4
  import { Pull, PullOptions } from "./pull.js";
5
5
  import { Push, PushOptions } from "./push.js";
6
6
  import { parseWithBetterErrors } from "./utils/error-formatter.js";
7
- import JSONbig from "json-bigint";
7
+ import { JSONBig } from "../json.js";
8
8
  import * as fs from "fs";
9
9
  import * as path from "path";
10
10
  import { TypeScriptDatabasesGenerator } from "./generators/typescript/databases.js";
11
11
 
12
- const JSONBig = JSONbig({ useNativeBigInt: true });
13
-
14
12
  export class Schema {
15
13
  private pullCommand: Pull;
16
14
  private pushCommand: Push;