@appwrite.io/console 1.4.4 → 1.4.5

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.
package/dist/iife/sdk.js CHANGED
@@ -281,12 +281,13 @@
281
281
  'x-sdk-name': 'Console',
282
282
  'x-sdk-platform': 'console',
283
283
  'x-sdk-language': 'web',
284
- 'x-sdk-version': '1.4.4',
284
+ 'x-sdk-version': '1.4.5',
285
285
  'X-Appwrite-Response-Format': '1.6.0',
286
286
  };
287
287
  this.realtime = {
288
288
  socket: undefined,
289
289
  timeout: undefined,
290
+ heartbeat: undefined,
290
291
  url: '',
291
292
  channels: new Set(),
292
293
  subscriptions: new Map(),
@@ -312,6 +313,17 @@
312
313
  return 60000;
313
314
  }
314
315
  },
316
+ createHeartbeat: () => {
317
+ if (this.realtime.heartbeat) {
318
+ clearTimeout(this.realtime.heartbeat);
319
+ }
320
+ this.realtime.heartbeat = window === null || window === void 0 ? void 0 : window.setInterval(() => {
321
+ var _a;
322
+ (_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify({
323
+ type: 'ping'
324
+ }));
325
+ }, 20000);
326
+ },
315
327
  createSocket: () => {
316
328
  var _a, _b, _c;
317
329
  if (this.realtime.channels.size < 1) {
@@ -340,6 +352,7 @@
340
352
  this.realtime.socket.addEventListener('message', this.realtime.onMessage);
341
353
  this.realtime.socket.addEventListener('open', _event => {
342
354
  this.realtime.reconnectAttempts = 0;
355
+ this.realtime.createHeartbeat();
343
356
  });
344
357
  this.realtime.socket.addEventListener('close', event => {
345
358
  var _a, _b, _c;
@@ -966,6 +979,28 @@
966
979
  return yield this.client.call('delete', uri, apiHeaders, payload);
967
980
  });
968
981
  }
982
+ /**
983
+ * Get coupon details
984
+ *
985
+ *
986
+ * @param {string} couponId
987
+ * @throws {AppwriteException}
988
+ * @returns {Promise<Models.Coupon>}
989
+ */
990
+ getCoupon(couponId) {
991
+ return __awaiter(this, void 0, void 0, function* () {
992
+ if (typeof couponId === 'undefined') {
993
+ throw new AppwriteException('Missing required parameter: "couponId"');
994
+ }
995
+ const apiPath = '/account/coupons/{couponId}'.replace('{couponId}', couponId);
996
+ const payload = {};
997
+ const uri = new URL(this.client.config.endpoint + apiPath);
998
+ const apiHeaders = {
999
+ 'content-type': 'application/json',
1000
+ };
1001
+ return yield this.client.call('get', uri, apiHeaders, payload);
1002
+ });
1003
+ }
969
1004
  /**
970
1005
  * Update email
971
1006
  *
@@ -2190,7 +2225,7 @@
2190
2225
  /**
2191
2226
  * Create magic URL token
2192
2227
  *
2193
- * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user&#039;s email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.
2228
+ * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user&#039;s email address is valid for 1 hour.
2194
2229
 
2195
2230
  A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
2196
2231
 
@@ -3157,6 +3192,28 @@
3157
3192
  return yield this.client.call('get', uri, apiHeaders, payload);
3158
3193
  });
3159
3194
  }
3195
+ /**
3196
+ * Create program membership
3197
+ *
3198
+ *
3199
+ * @param {string} programId
3200
+ * @throws {AppwriteException}
3201
+ * @returns {Promise<{}>}
3202
+ */
3203
+ createProgramMembership(programId) {
3204
+ return __awaiter(this, void 0, void 0, function* () {
3205
+ if (typeof programId === 'undefined') {
3206
+ throw new AppwriteException('Missing required parameter: "programId"');
3207
+ }
3208
+ const apiPath = '/console/programs/{programId}/memberships'.replace('{programId}', programId);
3209
+ const payload = {};
3210
+ const uri = new URL(this.client.config.endpoint + apiPath);
3211
+ const apiHeaders = {
3212
+ 'content-type': 'application/json',
3213
+ };
3214
+ return yield this.client.call('post', uri, apiHeaders, payload);
3215
+ });
3216
+ }
3160
3217
  /**
3161
3218
  * Get Regions
3162
3219
  *
@@ -9096,7 +9153,7 @@
9096
9153
  });
9097
9154
  }
9098
9155
  /**
9099
- * Migrate Firebase data (Service Account)
9156
+ * Migrate Firebase data
9100
9157
  *
9101
9158
  *
9102
9159
  * @param {string[]} resources
@@ -9127,74 +9184,6 @@
9127
9184
  return yield this.client.call('post', uri, apiHeaders, payload);
9128
9185
  });
9129
9186
  }
9130
- /**
9131
- * Revoke Appwrite&#039;s authorization to access Firebase projects
9132
- *
9133
- *
9134
- * @throws {AppwriteException}
9135
- * @returns {Promise<{}>}
9136
- */
9137
- deleteFirebaseAuth() {
9138
- return __awaiter(this, void 0, void 0, function* () {
9139
- const apiPath = '/migrations/firebase/deauthorize';
9140
- const payload = {};
9141
- const uri = new URL(this.client.config.endpoint + apiPath);
9142
- const apiHeaders = {
9143
- 'content-type': 'application/json',
9144
- };
9145
- return yield this.client.call('get', uri, apiHeaders, payload);
9146
- });
9147
- }
9148
- /**
9149
- * Migrate Firebase data (OAuth)
9150
- *
9151
- *
9152
- * @param {string[]} resources
9153
- * @param {string} projectId
9154
- * @throws {AppwriteException}
9155
- * @returns {Promise<Models.Migration>}
9156
- */
9157
- createFirebaseOAuthMigration(resources, projectId) {
9158
- return __awaiter(this, void 0, void 0, function* () {
9159
- if (typeof resources === 'undefined') {
9160
- throw new AppwriteException('Missing required parameter: "resources"');
9161
- }
9162
- if (typeof projectId === 'undefined') {
9163
- throw new AppwriteException('Missing required parameter: "projectId"');
9164
- }
9165
- const apiPath = '/migrations/firebase/oauth';
9166
- const payload = {};
9167
- if (typeof resources !== 'undefined') {
9168
- payload['resources'] = resources;
9169
- }
9170
- if (typeof projectId !== 'undefined') {
9171
- payload['projectId'] = projectId;
9172
- }
9173
- const uri = new URL(this.client.config.endpoint + apiPath);
9174
- const apiHeaders = {
9175
- 'content-type': 'application/json',
9176
- };
9177
- return yield this.client.call('post', uri, apiHeaders, payload);
9178
- });
9179
- }
9180
- /**
9181
- * List Firebase projects
9182
- *
9183
- *
9184
- * @throws {AppwriteException}
9185
- * @returns {Promise<Models.FirebaseProjectList>}
9186
- */
9187
- listFirebaseProjects() {
9188
- return __awaiter(this, void 0, void 0, function* () {
9189
- const apiPath = '/migrations/firebase/projects';
9190
- const payload = {};
9191
- const uri = new URL(this.client.config.endpoint + apiPath);
9192
- const apiHeaders = {
9193
- 'content-type': 'application/json',
9194
- };
9195
- return yield this.client.call('get', uri, apiHeaders, payload);
9196
- });
9197
- }
9198
9187
  /**
9199
9188
  * Generate a report on Firebase data
9200
9189
  *
@@ -9227,38 +9216,6 @@
9227
9216
  return yield this.client.call('get', uri, apiHeaders, payload);
9228
9217
  });
9229
9218
  }
9230
- /**
9231
- * Generate a report on Firebase data using OAuth
9232
- *
9233
- *
9234
- * @param {string[]} resources
9235
- * @param {string} projectId
9236
- * @throws {AppwriteException}
9237
- * @returns {Promise<Models.MigrationReport>}
9238
- */
9239
- getFirebaseReportOAuth(resources, projectId) {
9240
- return __awaiter(this, void 0, void 0, function* () {
9241
- if (typeof resources === 'undefined') {
9242
- throw new AppwriteException('Missing required parameter: "resources"');
9243
- }
9244
- if (typeof projectId === 'undefined') {
9245
- throw new AppwriteException('Missing required parameter: "projectId"');
9246
- }
9247
- const apiPath = '/migrations/firebase/report/oauth';
9248
- const payload = {};
9249
- if (typeof resources !== 'undefined') {
9250
- payload['resources'] = resources;
9251
- }
9252
- if (typeof projectId !== 'undefined') {
9253
- payload['projectId'] = projectId;
9254
- }
9255
- const uri = new URL(this.client.config.endpoint + apiPath);
9256
- const apiHeaders = {
9257
- 'content-type': 'application/json',
9258
- };
9259
- return yield this.client.call('get', uri, apiHeaders, payload);
9260
- });
9261
- }
9262
9219
  /**
9263
9220
  * Migrate NHost data
9264
9221
  *
@@ -9732,7 +9689,7 @@
9732
9689
  * @param {string} organizationId
9733
9690
  * @param {string} aggregationId
9734
9691
  * @throws {AppwriteException}
9735
- * @returns {Promise<Models.AggregationTeam>}
9692
+ * @returns {Promise<Models.Invoice>}
9736
9693
  */
9737
9694
  getAggregation(organizationId, aggregationId) {
9738
9695
  return __awaiter(this, void 0, void 0, function* () {
@@ -10024,7 +9981,7 @@
10024
9981
  });
10025
9982
  }
10026
9983
  /**
10027
- * View invoice in PDF
9984
+ * Download invoice in PDF
10028
9985
  *
10029
9986
  *
10030
9987
  * @param {string} organizationId
@@ -15589,6 +15546,7 @@
15589
15546
  Runtime["Bun11"] = "bun-1.1";
15590
15547
  Runtime["Go123"] = "go-1.23";
15591
15548
  Runtime["Static1"] = "static-1";
15549
+ Runtime["Flutter324"] = "flutter-3.24";
15592
15550
  })(exports.Runtime || (exports.Runtime = {}));
15593
15551
 
15594
15552
  exports.FunctionUsageRange = void 0;
@@ -1,11 +1,13 @@
1
- import { Client, Migrations } from "@appwrite.io/console";
1
+ import { Client, Account } from "@appwrite.io/console";
2
2
 
3
3
  const client = new Client()
4
4
  .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
5
  .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
6
 
7
- const migrations = new Migrations(client);
7
+ const account = new Account(client);
8
8
 
9
- const result = await migrations.deleteFirebaseAuth();
9
+ const result = await account.getCoupon(
10
+ '<COUPON_ID>' // couponId
11
+ );
10
12
 
11
13
  console.log(result);
@@ -9,7 +9,7 @@ const account = new Account(client);
9
9
  const result = await account.updatePaymentMethod(
10
10
  '<PAYMENT_METHOD_ID>', // paymentMethodId
11
11
  1, // expiryMonth
12
- 2024 // expiryYear
12
+ 2025 // expiryYear
13
13
  );
14
14
 
15
15
  console.log(result);
@@ -0,0 +1,13 @@
1
+ import { Client, Console } from "@appwrite.io/console";
2
+
3
+ const client = new Client()
4
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
+ .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
+
7
+ const console = new Console(client);
8
+
9
+ const result = await console.createProgramMembership(
10
+ '<PROGRAM_ID>' // programId
11
+ );
12
+
13
+ console.log(result);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@appwrite.io/console",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5
- "version": "1.4.4",
5
+ "version": "1.4.5",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
package/src/client.ts CHANGED
@@ -19,9 +19,9 @@ type Headers = {
19
19
  */
20
20
  type RealtimeResponse = {
21
21
  /**
22
- * Type of the response: 'error', 'event', 'connected', or 'response'.
22
+ * Type of the response: 'error', 'event', 'connected', 'pong', or 'response'.
23
23
  */
24
- type: 'error' | 'event' | 'connected' | 'response';
24
+ type: 'error' | 'event' | 'connected' | 'response' | 'pong';
25
25
 
26
26
  /**
27
27
  * Data associated with the response based on the response type.
@@ -129,6 +129,8 @@ type RealtimeRequestAuthenticate = {
129
129
  session: string;
130
130
  }
131
131
 
132
+ type TimeoutHandle = ReturnType<typeof setTimeout> | number;
133
+
132
134
  /**
133
135
  * Realtime interface representing the structure of a realtime communication object.
134
136
  */
@@ -139,9 +141,14 @@ type Realtime = {
139
141
  socket?: WebSocket;
140
142
 
141
143
  /**
142
- * Timeout duration for communication operations.
144
+ * Timeout for reconnect operations.
143
145
  */
144
- timeout?: number;
146
+ timeout?: TimeoutHandle;
147
+
148
+ /**
149
+ * Heartbeat interval for the realtime connection.
150
+ */
151
+ heartbeat?: TimeoutHandle;
145
152
 
146
153
  /**
147
154
  * URL for establishing the WebSocket connection.
@@ -196,6 +203,11 @@ type Realtime = {
196
203
  */
197
204
  createSocket: () => void;
198
205
 
206
+ /**
207
+ * Function to create a new heartbeat interval.
208
+ */
209
+ createHeartbeat: () => void;
210
+
199
211
  /**
200
212
  * Function to clean up resources associated with specified channels.
201
213
  *
@@ -304,7 +316,7 @@ class Client {
304
316
  'x-sdk-name': 'Console',
305
317
  'x-sdk-platform': 'console',
306
318
  'x-sdk-language': 'web',
307
- 'x-sdk-version': '1.4.4',
319
+ 'x-sdk-version': '1.4.5',
308
320
  'X-Appwrite-Response-Format': '1.6.0',
309
321
  };
310
322
 
@@ -407,6 +419,7 @@ class Client {
407
419
  private realtime: Realtime = {
408
420
  socket: undefined,
409
421
  timeout: undefined,
422
+ heartbeat: undefined,
410
423
  url: '',
411
424
  channels: new Set(),
412
425
  subscriptions: new Map(),
@@ -432,6 +445,17 @@ class Client {
432
445
  return 60_000;
433
446
  }
434
447
  },
448
+ createHeartbeat: () => {
449
+ if (this.realtime.heartbeat) {
450
+ clearTimeout(this.realtime.heartbeat);
451
+ }
452
+
453
+ this.realtime.heartbeat = window?.setInterval(() => {
454
+ this.realtime.socket?.send(JSON.stringify({
455
+ type: 'ping'
456
+ }));
457
+ }, 20_000);
458
+ },
435
459
  createSocket: () => {
436
460
  if (this.realtime.channels.size < 1) {
437
461
  this.realtime.reconnect = false;
@@ -465,6 +489,7 @@ class Client {
465
489
  this.realtime.socket.addEventListener('message', this.realtime.onMessage);
466
490
  this.realtime.socket.addEventListener('open', _event => {
467
491
  this.realtime.reconnectAttempts = 0;
492
+ this.realtime.createHeartbeat();
468
493
  });
469
494
  this.realtime.socket.addEventListener('close', event => {
470
495
  if (
@@ -54,4 +54,5 @@ export enum Runtime {
54
54
  Bun11 = 'bun-1.1',
55
55
  Go123 = 'go-1.23',
56
56
  Static1 = 'static-1',
57
+ Flutter324 = 'flutter-3.24',
57
58
  }
package/src/models.ts CHANGED
@@ -496,19 +496,6 @@ export namespace Models {
496
496
  */
497
497
  migrations: Migration[];
498
498
  }
499
- /**
500
- * Migrations Firebase Projects List
501
- */
502
- export type FirebaseProjectList = {
503
- /**
504
- * Total number of projects documents that matched your query.
505
- */
506
- total: number;
507
- /**
508
- * List of projects.
509
- */
510
- projects: FirebaseProject[];
511
- }
512
499
  /**
513
500
  * Specifications List
514
501
  */
@@ -1941,7 +1928,7 @@ export namespace Models {
1941
1928
  */
1942
1929
  events: string[];
1943
1930
  /**
1944
- * Function execution schedult in CRON format.
1931
+ * Function execution schedule in CRON format.
1945
1932
  */
1946
1933
  schedule: string;
1947
1934
  /**
@@ -4086,19 +4073,6 @@ export namespace Models {
4086
4073
  */
4087
4074
  version: string;
4088
4075
  }
4089
- /**
4090
- * MigrationFirebaseProject
4091
- */
4092
- export type FirebaseProject = {
4093
- /**
4094
- * Project ID.
4095
- */
4096
- projectId: string;
4097
- /**
4098
- * Project display name.
4099
- */
4100
- displayName: string;
4101
- }
4102
4076
  /**
4103
4077
  * AdditionalResource
4104
4078
  */
@@ -4319,6 +4293,10 @@ export namespace Models {
4319
4293
  * Plan name
4320
4294
  */
4321
4295
  name: string;
4296
+ /**
4297
+ * Plan order
4298
+ */
4299
+ order: number;
4322
4300
  /**
4323
4301
  * Price
4324
4302
  */
@@ -4411,6 +4389,26 @@ export namespace Models {
4411
4389
  * Can user change the plan themselves
4412
4390
  */
4413
4391
  selfService: boolean;
4392
+ /**
4393
+ * Does plan enable premium support
4394
+ */
4395
+ premiumSupport: boolean;
4396
+ /**
4397
+ * Does plan support budget cap
4398
+ */
4399
+ budgeting: boolean;
4400
+ /**
4401
+ * Does plan support mock numbers
4402
+ */
4403
+ supportsMockNumbers: boolean;
4404
+ /**
4405
+ * Does plan support backup policies.
4406
+ */
4407
+ backupsEnabled: boolean;
4408
+ /**
4409
+ * How many policies does plan support
4410
+ */
4411
+ backupPolicies: number;
4414
4412
  }
4415
4413
  /**
4416
4414
  * Campaign
@@ -4692,7 +4690,7 @@ export namespace Models {
4692
4690
  /**
4693
4691
  * Project budget limit
4694
4692
  */
4695
- budgetAlerts: string[];
4693
+ budgetAlerts: number[];
4696
4694
  /**
4697
4695
  * Billing plan selected. Can be one of `tier-0`, `tier-1` or `tier-2`.
4698
4696
  */
@@ -5028,6 +5026,10 @@ export namespace Models {
5028
5026
  * Aggregated stats for function executions.
5029
5027
  */
5030
5028
  executions: Metric[];
5029
+ /**
5030
+ * Aggregated stats for phone authentication.
5031
+ */
5032
+ authPhone: Metric;
5031
5033
  /**
5032
5034
  * Aggregated stats for total users.
5033
5035
  */
@@ -5068,6 +5070,10 @@ export namespace Models {
5068
5070
  * Aggregated stats for total storage.
5069
5071
  */
5070
5072
  storageTotal: number;
5073
+ /**
5074
+ * Breakdown of phone authentication stats by country code.
5075
+ */
5076
+ authPhoneBreakdown: MetricBreakdown;
5071
5077
  /**
5072
5078
  * Aggregated stats for each projects.
5073
5079
  */
@@ -320,6 +320,34 @@ export class Account {
320
320
  payload
321
321
  );
322
322
  }
323
+ /**
324
+ * Get coupon details
325
+ *
326
+ *
327
+ * @param {string} couponId
328
+ * @throws {AppwriteException}
329
+ * @returns {Promise<Models.Coupon>}
330
+ */
331
+ async getCoupon(couponId: string): Promise<Models.Coupon> {
332
+ if (typeof couponId === 'undefined') {
333
+ throw new AppwriteException('Missing required parameter: "couponId"');
334
+ }
335
+ const apiPath = '/account/coupons/{couponId}'.replace('{couponId}', couponId);
336
+ const payload: Payload = {};
337
+ const uri = new URL(this.client.config.endpoint + apiPath);
338
+
339
+ const apiHeaders: { [header: string]: string } = {
340
+ 'content-type': 'application/json',
341
+ }
342
+
343
+
344
+ return await this.client.call(
345
+ 'get',
346
+ uri,
347
+ apiHeaders,
348
+ payload
349
+ );
350
+ }
323
351
  /**
324
352
  * Update email
325
353
  *
@@ -1817,7 +1845,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about
1817
1845
  /**
1818
1846
  * Create magic URL token
1819
1847
  *
1820
- * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user&#039;s email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.
1848
+ * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user&#039;s email address is valid for 1 hour.
1821
1849
 
1822
1850
  A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
1823
1851
 
@@ -89,6 +89,34 @@ export class Console {
89
89
  payload
90
90
  );
91
91
  }
92
+ /**
93
+ * Create program membership
94
+ *
95
+ *
96
+ * @param {string} programId
97
+ * @throws {AppwriteException}
98
+ * @returns {Promise<{}>}
99
+ */
100
+ async createProgramMembership(programId: string): Promise<{}> {
101
+ if (typeof programId === 'undefined') {
102
+ throw new AppwriteException('Missing required parameter: "programId"');
103
+ }
104
+ const apiPath = '/console/programs/{programId}/memberships'.replace('{programId}', programId);
105
+ const payload: Payload = {};
106
+ const uri = new URL(this.client.config.endpoint + apiPath);
107
+
108
+ const apiHeaders: { [header: string]: string } = {
109
+ 'content-type': 'application/json',
110
+ }
111
+
112
+
113
+ return await this.client.call(
114
+ 'post',
115
+ uri,
116
+ apiHeaders,
117
+ payload
118
+ );
119
+ }
92
120
  /**
93
121
  * Get Regions
94
122
  *