@appwrite.io/console 2.0.0 → 2.1.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.
- package/CHANGELOG.md +8 -0
- package/README.md +2 -2
- package/dist/cjs/sdk.js +81 -15
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +77 -15
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +3838 -15
- package/docs/examples/account/update-payment-method.md +1 -1
- package/docs/examples/projects/update-labels.md +14 -0
- package/package.json +7 -1
- package/rollup.config.js +40 -24
- package/src/client.ts +49 -10
- package/src/models.ts +432 -424
- package/src/query.ts +14 -11
- package/src/services/account.ts +20 -20
- package/src/services/avatars.ts +117 -117
- package/src/services/backups.ts +18 -18
- package/src/services/console.ts +24 -24
- package/src/services/databases.ts +119 -119
- package/src/services/domains.ts +204 -204
- package/src/services/functions.ts +30 -30
- package/src/services/health.ts +146 -146
- package/src/services/messaging.ts +54 -54
- package/src/services/migrations.ts +36 -36
- package/src/services/organizations.ts +42 -42
- package/src/services/projects.ts +146 -83
- package/src/services/sites.ts +30 -30
- package/src/services/storage.ts +49 -49
- package/src/services/tables-db.ts +119 -119
- package/src/services/users.ts +39 -39
- package/types/client.d.ts +27 -1
- package/types/models.d.ts +432 -424
- package/types/query.d.ts +8 -8
- package/types/services/account.d.ts +11 -11
- package/types/services/avatars.d.ts +82 -82
- package/types/services/backups.d.ts +8 -8
- package/types/services/console.d.ts +14 -14
- package/types/services/databases.d.ts +70 -70
- package/types/services/domains.d.ts +104 -104
- package/types/services/functions.d.ts +15 -15
- package/types/services/health.d.ts +72 -72
- package/types/services/messaging.d.ts +24 -24
- package/types/services/migrations.d.ts +16 -16
- package/types/services/organizations.d.ts +22 -22
- package/types/services/projects.d.ts +60 -38
- package/types/services/sites.d.ts +15 -15
- package/types/services/storage.d.ts +34 -34
- package/types/services/tables-db.d.ts +70 -70
- package/types/services/users.d.ts +24 -24
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Client, Projects } from "@appwrite.io/console";
|
|
2
|
+
|
|
3
|
+
const client = new Client()
|
|
4
|
+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
|
|
5
|
+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
|
|
6
|
+
|
|
7
|
+
const projects = new Projects(client);
|
|
8
|
+
|
|
9
|
+
const result = await projects.updateLabels({
|
|
10
|
+
projectId: '<PROJECT_ID>',
|
|
11
|
+
labels: []
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
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 abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.1.1",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "dist/cjs/sdk.js",
|
|
8
8
|
"exports": {
|
|
@@ -24,8 +24,14 @@
|
|
|
24
24
|
"build:types": "tsc --declaration --emitDeclarationOnly --outDir types",
|
|
25
25
|
"build:libs": "rollup -c"
|
|
26
26
|
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"json-bigint": "1.0.0"
|
|
29
|
+
},
|
|
27
30
|
"devDependencies": {
|
|
31
|
+
"@rollup/plugin-commonjs": "22.0.0",
|
|
32
|
+
"@rollup/plugin-node-resolve": "13.3.0",
|
|
28
33
|
"@rollup/plugin-typescript": "8.3.2",
|
|
34
|
+
"@types/json-bigint": "1.0.4",
|
|
29
35
|
"playwright": "1.56.1",
|
|
30
36
|
"rollup": "2.79.2",
|
|
31
37
|
"serve-handler": "6.1.0",
|
package/rollup.config.js
CHANGED
|
@@ -1,27 +1,43 @@
|
|
|
1
1
|
import pkg from "./package.json";
|
|
2
2
|
import typescript from "@rollup/plugin-typescript";
|
|
3
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
4
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
const external = Object.keys(pkg.dependencies ?? {});
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
{
|
|
10
|
+
input: "src/index.ts",
|
|
11
|
+
external,
|
|
12
|
+
plugins: [typescript()],
|
|
13
|
+
output: [
|
|
14
|
+
{
|
|
15
|
+
format: "cjs",
|
|
16
|
+
file: pkg.main,
|
|
17
|
+
esModule: false,
|
|
18
|
+
sourcemap: true,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
format: "es",
|
|
22
|
+
file: pkg.module,
|
|
23
|
+
sourcemap: true,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
input: "src/index.ts",
|
|
29
|
+
plugins: [
|
|
30
|
+
resolve({ browser: true }),
|
|
31
|
+
commonjs(),
|
|
32
|
+
typescript()
|
|
33
|
+
],
|
|
34
|
+
output: [
|
|
35
|
+
{
|
|
36
|
+
format: "iife",
|
|
37
|
+
file: pkg.jsdelivr,
|
|
38
|
+
name: "Appwrite",
|
|
39
|
+
extend: true,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
}
|
|
43
|
+
];
|
package/src/client.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Models } from './models';
|
|
2
|
+
import JSONbigModule from 'json-bigint';
|
|
3
|
+
const JSONbig = JSONbigModule({ useNativeBigInt: true });
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Payload type representing a key-value pair with string keys and any values.
|
|
@@ -303,7 +305,15 @@ class Client {
|
|
|
303
305
|
config: {
|
|
304
306
|
endpoint: string;
|
|
305
307
|
endpointRealtime: string;
|
|
306
|
-
|
|
308
|
+
project: string;
|
|
309
|
+
key: string;
|
|
310
|
+
jwt: string;
|
|
311
|
+
locale: string;
|
|
312
|
+
mode: string;
|
|
313
|
+
cookie: string;
|
|
314
|
+
platform: string;
|
|
315
|
+
selfSigned: boolean;
|
|
316
|
+
session?: string;
|
|
307
317
|
} = {
|
|
308
318
|
endpoint: 'https://cloud.appwrite.io/v1',
|
|
309
319
|
endpointRealtime: '',
|
|
@@ -312,7 +322,10 @@ class Client {
|
|
|
312
322
|
jwt: '',
|
|
313
323
|
locale: '',
|
|
314
324
|
mode: '',
|
|
325
|
+
cookie: '',
|
|
315
326
|
platform: '',
|
|
327
|
+
selfSigned: false,
|
|
328
|
+
session: undefined,
|
|
316
329
|
};
|
|
317
330
|
/**
|
|
318
331
|
* Custom headers for API requests.
|
|
@@ -321,7 +334,7 @@ class Client {
|
|
|
321
334
|
'x-sdk-name': 'Console',
|
|
322
335
|
'x-sdk-platform': 'console',
|
|
323
336
|
'x-sdk-language': 'web',
|
|
324
|
-
'x-sdk-version': '2.
|
|
337
|
+
'x-sdk-version': '2.1.1',
|
|
325
338
|
'X-Appwrite-Response-Format': '1.8.0',
|
|
326
339
|
};
|
|
327
340
|
|
|
@@ -369,6 +382,18 @@ class Client {
|
|
|
369
382
|
return this;
|
|
370
383
|
}
|
|
371
384
|
|
|
385
|
+
/**
|
|
386
|
+
* Set self-signed
|
|
387
|
+
*
|
|
388
|
+
* @param {boolean} selfSigned
|
|
389
|
+
*
|
|
390
|
+
* @returns {this}
|
|
391
|
+
*/
|
|
392
|
+
setSelfSigned(selfSigned: boolean): this {
|
|
393
|
+
this.config.selfSigned = selfSigned;
|
|
394
|
+
return this;
|
|
395
|
+
}
|
|
396
|
+
|
|
372
397
|
/**
|
|
373
398
|
* Set Project
|
|
374
399
|
*
|
|
@@ -435,6 +460,20 @@ class Client {
|
|
|
435
460
|
this.config.mode = value;
|
|
436
461
|
return this;
|
|
437
462
|
}
|
|
463
|
+
/**
|
|
464
|
+
* Set Cookie
|
|
465
|
+
*
|
|
466
|
+
* The user cookie to authenticate with
|
|
467
|
+
*
|
|
468
|
+
* @param value string
|
|
469
|
+
*
|
|
470
|
+
* @return {this}
|
|
471
|
+
*/
|
|
472
|
+
setCookie(value: string): this {
|
|
473
|
+
this.headers['Cookie'] = value;
|
|
474
|
+
this.config.cookie = value;
|
|
475
|
+
return this;
|
|
476
|
+
}
|
|
438
477
|
/**
|
|
439
478
|
* Set Platform
|
|
440
479
|
*
|
|
@@ -485,7 +524,7 @@ class Client {
|
|
|
485
524
|
}
|
|
486
525
|
|
|
487
526
|
this.realtime.heartbeat = window?.setInterval(() => {
|
|
488
|
-
this.realtime.socket?.send(
|
|
527
|
+
this.realtime.socket?.send(JSONbig.stringify({
|
|
489
528
|
type: 'ping'
|
|
490
529
|
}));
|
|
491
530
|
}, 20_000);
|
|
@@ -499,7 +538,7 @@ class Client {
|
|
|
499
538
|
|
|
500
539
|
const channels = new URLSearchParams();
|
|
501
540
|
if (this.config.project) {
|
|
502
|
-
channels.set('project', this.config.project);
|
|
541
|
+
channels.set('project', this.config.project as string);
|
|
503
542
|
}
|
|
504
543
|
this.realtime.channels.forEach(channel => {
|
|
505
544
|
channels.append('channels[]', channel);
|
|
@@ -551,19 +590,19 @@ class Client {
|
|
|
551
590
|
},
|
|
552
591
|
onMessage: (event) => {
|
|
553
592
|
try {
|
|
554
|
-
const message: RealtimeResponse =
|
|
593
|
+
const message: RealtimeResponse = JSONbig.parse(event.data);
|
|
555
594
|
this.realtime.lastMessage = message;
|
|
556
595
|
switch (message.type) {
|
|
557
596
|
case 'connected':
|
|
558
597
|
let session = this.config.session;
|
|
559
598
|
if (!session) {
|
|
560
|
-
const cookie =
|
|
599
|
+
const cookie = JSONbig.parse(window.localStorage.getItem('cookieFallback') ?? '{}');
|
|
561
600
|
session = cookie?.[`a_session_${this.config.project}`];
|
|
562
601
|
}
|
|
563
602
|
|
|
564
603
|
const messageData = <RealtimeResponseConnected>message.data;
|
|
565
604
|
if (session && !messageData.user) {
|
|
566
|
-
this.realtime.socket?.send(
|
|
605
|
+
this.realtime.socket?.send(JSONbig.stringify(<RealtimeRequest>{
|
|
567
606
|
type: 'authentication',
|
|
568
607
|
data: {
|
|
569
608
|
session
|
|
@@ -684,7 +723,7 @@ class Client {
|
|
|
684
723
|
} else {
|
|
685
724
|
switch (headers['content-type']) {
|
|
686
725
|
case 'application/json':
|
|
687
|
-
options.body =
|
|
726
|
+
options.body = JSONbig.stringify(params);
|
|
688
727
|
break;
|
|
689
728
|
|
|
690
729
|
case 'multipart/form-data':
|
|
@@ -786,7 +825,7 @@ class Client {
|
|
|
786
825
|
}
|
|
787
826
|
|
|
788
827
|
if (response.headers.get('content-type')?.includes('application/json')) {
|
|
789
|
-
data = await response.
|
|
828
|
+
data = JSONbig.parse(await response.text());
|
|
790
829
|
} else if (responseType === 'arrayBuffer') {
|
|
791
830
|
data = await response.arrayBuffer();
|
|
792
831
|
} else {
|
|
@@ -798,7 +837,7 @@ class Client {
|
|
|
798
837
|
if (400 <= response.status) {
|
|
799
838
|
let responseText = '';
|
|
800
839
|
if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') {
|
|
801
|
-
responseText =
|
|
840
|
+
responseText = JSONbig.stringify(data);
|
|
802
841
|
} else {
|
|
803
842
|
responseText = data?.message;
|
|
804
843
|
}
|