@appwrite.io/console 0.1.0-preview-0.0 → 0.1.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.
package/dist/iife/sdk.js CHANGED
@@ -96,7 +96,7 @@
96
96
  'x-sdk-name': 'Console',
97
97
  'x-sdk-platform': 'console',
98
98
  'x-sdk-language': 'web',
99
- 'x-sdk-version': '0.1.0-preview-0.0',
99
+ 'x-sdk-version': '0.1.0',
100
100
  'X-Appwrite-Response-Format': '1.0.0',
101
101
  };
102
102
  this.realtime = {
@@ -881,7 +881,7 @@
881
881
  * password combination. This route will create a new session for the user.
882
882
  *
883
883
  * A user is limited to 10 active sessions at a time by default. [Learn more
884
- * about session limits](/docs/authentication#limits).
884
+ * about session limits](/docs/authentication-security#limits).
885
885
  *
886
886
  * @param {string} email
887
887
  * @param {string} password
@@ -926,7 +926,7 @@
926
926
  * your Appwrite instance by default.
927
927
  *
928
928
  * A user is limited to 10 active sessions at a time by default. [Learn more
929
- * about session limits](/docs/authentication#limits).
929
+ * about session limits](/docs/authentication-security#limits).
930
930
  *
931
931
  * @param {string} userId
932
932
  * @param {string} email
@@ -1017,7 +1017,7 @@
1017
1017
  * user.
1018
1018
  *
1019
1019
  * A user is limited to 10 active sessions at a time by default. [Learn more
1020
- * about session limits](/docs/authentication#limits).
1020
+ * about session limits](/docs/authentication-security#limits).
1021
1021
  *
1022
1022
  *
1023
1023
  * @param {string} provider
@@ -1065,7 +1065,7 @@
1065
1065
  * is valid for 15 minutes.
1066
1066
  *
1067
1067
  * A user is limited to 10 active sessions at a time by default. [Learn more
1068
- * about session limits](/docs/authentication#limits).
1068
+ * about session limits](/docs/authentication-security#limits).
1069
1069
  *
1070
1070
  * @param {string} userId
1071
1071
  * @param {string} phone
@@ -2723,6 +2723,64 @@
2723
2723
  }, payload);
2724
2724
  });
2725
2725
  }
2726
+ /**
2727
+ * Create Relationship Attribute
2728
+ *
2729
+ * Create relationship attribute. [Learn more about relationship
2730
+ * attributes](docs/databases-relationships#relationship-attributes).
2731
+ *
2732
+ *
2733
+ * @param {string} databaseId
2734
+ * @param {string} collectionId
2735
+ * @param {string} relatedCollectionId
2736
+ * @param {string} type
2737
+ * @param {boolean} twoWay
2738
+ * @param {string} key
2739
+ * @param {string} twoWayKey
2740
+ * @param {string} onDelete
2741
+ * @throws {AppwriteException}
2742
+ * @returns {Promise}
2743
+ */
2744
+ createRelationshipAttribute(databaseId, collectionId, relatedCollectionId, type, twoWay, key, twoWayKey, onDelete) {
2745
+ return __awaiter(this, void 0, void 0, function* () {
2746
+ if (typeof databaseId === 'undefined') {
2747
+ throw new AppwriteException('Missing required parameter: "databaseId"');
2748
+ }
2749
+ if (typeof collectionId === 'undefined') {
2750
+ throw new AppwriteException('Missing required parameter: "collectionId"');
2751
+ }
2752
+ if (typeof relatedCollectionId === 'undefined') {
2753
+ throw new AppwriteException('Missing required parameter: "relatedCollectionId"');
2754
+ }
2755
+ if (typeof type === 'undefined') {
2756
+ throw new AppwriteException('Missing required parameter: "type"');
2757
+ }
2758
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
2759
+ let payload = {};
2760
+ if (typeof relatedCollectionId !== 'undefined') {
2761
+ payload['relatedCollectionId'] = relatedCollectionId;
2762
+ }
2763
+ if (typeof type !== 'undefined') {
2764
+ payload['type'] = type;
2765
+ }
2766
+ if (typeof twoWay !== 'undefined') {
2767
+ payload['twoWay'] = twoWay;
2768
+ }
2769
+ if (typeof key !== 'undefined') {
2770
+ payload['key'] = key;
2771
+ }
2772
+ if (typeof twoWayKey !== 'undefined') {
2773
+ payload['twoWayKey'] = twoWayKey;
2774
+ }
2775
+ if (typeof onDelete !== 'undefined') {
2776
+ payload['onDelete'] = onDelete;
2777
+ }
2778
+ const uri = new URL(this.client.config.endpoint + path);
2779
+ return yield this.client.call('post', uri, {
2780
+ 'content-type': 'application/json',
2781
+ }, payload);
2782
+ });
2783
+ }
2726
2784
  /**
2727
2785
  * Create String Attribute
2728
2786
  *
@@ -2978,6 +3036,42 @@
2978
3036
  }, payload);
2979
3037
  });
2980
3038
  }
3039
+ /**
3040
+ * Update Relationship Attribute
3041
+ *
3042
+ * Update relationship attribute. [Learn more about relationship
3043
+ * attributes](docs/databases-relationships#relationship-attributes).
3044
+ *
3045
+ *
3046
+ * @param {string} databaseId
3047
+ * @param {string} collectionId
3048
+ * @param {string} key
3049
+ * @param {string} onDelete
3050
+ * @throws {AppwriteException}
3051
+ * @returns {Promise}
3052
+ */
3053
+ updateRelationshipAttribute(databaseId, collectionId, key, onDelete) {
3054
+ return __awaiter(this, void 0, void 0, function* () {
3055
+ if (typeof databaseId === 'undefined') {
3056
+ throw new AppwriteException('Missing required parameter: "databaseId"');
3057
+ }
3058
+ if (typeof collectionId === 'undefined') {
3059
+ throw new AppwriteException('Missing required parameter: "collectionId"');
3060
+ }
3061
+ if (typeof key === 'undefined') {
3062
+ throw new AppwriteException('Missing required parameter: "key"');
3063
+ }
3064
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
3065
+ let payload = {};
3066
+ if (typeof onDelete !== 'undefined') {
3067
+ payload['onDelete'] = onDelete;
3068
+ }
3069
+ const uri = new URL(this.client.config.endpoint + path);
3070
+ return yield this.client.call('patch', uri, {
3071
+ 'content-type': 'application/json',
3072
+ }, payload);
3073
+ });
3074
+ }
2981
3075
  /**
2982
3076
  * List Documents
2983
3077
  *
@@ -3065,10 +3159,11 @@
3065
3159
  * @param {string} databaseId
3066
3160
  * @param {string} collectionId
3067
3161
  * @param {string} documentId
3162
+ * @param {string[]} queries
3068
3163
  * @throws {AppwriteException}
3069
3164
  * @returns {Promise}
3070
3165
  */
3071
- getDocument(databaseId, collectionId, documentId) {
3166
+ getDocument(databaseId, collectionId, documentId, queries) {
3072
3167
  return __awaiter(this, void 0, void 0, function* () {
3073
3168
  if (typeof databaseId === 'undefined') {
3074
3169
  throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -3081,6 +3176,9 @@
3081
3176
  }
3082
3177
  let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
3083
3178
  let payload = {};
3179
+ if (typeof queries !== 'undefined') {
3180
+ payload['queries'] = queries;
3181
+ }
3084
3182
  const uri = new URL(this.client.config.endpoint + path);
3085
3183
  return yield this.client.call('get', uri, {
3086
3184
  'content-type': 'application/json',
@@ -0,0 +1,18 @@
1
+ import { Client, Databases } from "@appwrite.io/console";
2
+
3
+ const client = new Client();
4
+
5
+ const databases = new Databases(client);
6
+
7
+ client
8
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
9
+ .setProject('5df5acd0d48c2') // Your project ID
10
+ ;
11
+
12
+ const promise = databases.createRelationshipAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '[RELATED_COLLECTION_ID]', 'oneToOne');
13
+
14
+ promise.then(function (response) {
15
+ console.log(response); // Success
16
+ }, function (error) {
17
+ console.log(error); // Failure
18
+ });
@@ -1,15 +1,15 @@
1
- import { Client, Teams } from "appwrite";
1
+ import { Client, Databases } from "@appwrite.io/console";
2
2
 
3
3
  const client = new Client();
4
4
 
5
- const teams = new Teams(client);
5
+ const databases = new Databases(client);
6
6
 
7
7
  client
8
8
  .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
9
9
  .setProject('5df5acd0d48c2') // Your project ID
10
10
  ;
11
11
 
12
- const promise = teams.update('[TEAM_ID]', '[NAME]');
12
+ const promise = databases.updateRelationshipAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '');
13
13
 
14
14
  promise.then(function (response) {
15
15
  console.log(response); // Success
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": "0.1.0-preview-0.0",
5
+ "version": "0.1.0",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
package/src/client.ts CHANGED
@@ -104,7 +104,7 @@ class Client {
104
104
  'x-sdk-name': 'Console',
105
105
  'x-sdk-platform': 'console',
106
106
  'x-sdk-language': 'web',
107
- 'x-sdk-version': '0.1.0-preview-0.0',
107
+ 'x-sdk-version': '0.1.0',
108
108
  'X-Appwrite-Response-Format': '1.0.0',
109
109
  };
110
110
 
package/src/models.ts CHANGED
@@ -721,6 +721,55 @@ export namespace Models {
721
721
  */
722
722
  default?: string;
723
723
  }
724
+ /**
725
+ * AttributeRelationship
726
+ */
727
+ export type AttributeRelationship = {
728
+ /**
729
+ * Attribute Key.
730
+ */
731
+ key: string;
732
+ /**
733
+ * Attribute type.
734
+ */
735
+ type: string;
736
+ /**
737
+ * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
738
+ */
739
+ status: string;
740
+ /**
741
+ * Is attribute required?
742
+ */
743
+ required: boolean;
744
+ /**
745
+ * Is attribute an array?
746
+ */
747
+ array?: boolean;
748
+ /**
749
+ * The ID of the related collection.
750
+ */
751
+ relatedCollection: string;
752
+ /**
753
+ * The type of the relationship.
754
+ */
755
+ relationType: string;
756
+ /**
757
+ * Is the relationship two-way?
758
+ */
759
+ twoWay: boolean;
760
+ /**
761
+ * The key of the two-way relationship.
762
+ */
763
+ twoWayKey: string;
764
+ /**
765
+ * How deleting the parent document will propagate to child documents.
766
+ */
767
+ onDelete: string;
768
+ /**
769
+ * Whether this is the parent or child side of the relationship
770
+ */
771
+ side: string;
772
+ }
724
773
  /**
725
774
  * Index
726
775
  */
@@ -888,15 +937,15 @@ export namespace Models {
888
937
  /**
889
938
  * Hashed user password.
890
939
  */
891
- password: string;
940
+ password?: string;
892
941
  /**
893
942
  * Password hashing algorithm.
894
943
  */
895
- hash: string;
944
+ hash?: string;
896
945
  /**
897
946
  * Password hashing algorithm configuration.
898
947
  */
899
- hashOptions: object;
948
+ hashOptions?: object;
900
949
  /**
901
950
  * User registration date in ISO 8601 format.
902
951
  */
@@ -1033,59 +1082,6 @@ export namespace Models {
1033
1082
  */
1034
1083
  threads: number;
1035
1084
  }
1036
- /**
1037
- * Account
1038
- */
1039
- export type Account<Preferences extends Models.Preferences> = {
1040
- /**
1041
- * User ID.
1042
- */
1043
- $id: string;
1044
- /**
1045
- * User creation date in ISO 8601 format.
1046
- */
1047
- $createdAt: string;
1048
- /**
1049
- * User update date in ISO 8601 format.
1050
- */
1051
- $updatedAt: string;
1052
- /**
1053
- * User name.
1054
- */
1055
- name: string;
1056
- /**
1057
- * User registration date in ISO 8601 format.
1058
- */
1059
- registration: string;
1060
- /**
1061
- * User status. Pass `true` for enabled and `false` for disabled.
1062
- */
1063
- status: boolean;
1064
- /**
1065
- * Password update time in ISO 8601 format.
1066
- */
1067
- passwordUpdate: string;
1068
- /**
1069
- * User email address.
1070
- */
1071
- email: string;
1072
- /**
1073
- * User phone number in E.164 format.
1074
- */
1075
- phone: string;
1076
- /**
1077
- * Email verification status.
1078
- */
1079
- emailVerification: boolean;
1080
- /**
1081
- * Phone verification status.
1082
- */
1083
- phoneVerification: boolean;
1084
- /**
1085
- * User preferences as a key-value object
1086
- */
1087
- prefs: Preferences;
1088
- }
1089
1085
  /**
1090
1086
  * Preferences
1091
1087
  */
@@ -211,7 +211,7 @@ export class Account extends Service {
211
211
  * @throws {AppwriteException}
212
212
  * @returns {Promise}
213
213
  */
214
- async updatePassword<Preferences extends Models.Preferences>(password: string, oldPassword?: string): Promise<Models.Account<Preferences>> {
214
+ async updatePassword<Preferences extends Models.Preferences>(password: string, oldPassword?: string): Promise<Models.User<Preferences>> {
215
215
  if (typeof password === 'undefined') {
216
216
  throw new AppwriteException('Missing required parameter: "password"');
217
217
  }
@@ -493,7 +493,7 @@ export class Account extends Service {
493
493
  * password combination. This route will create a new session for the user.
494
494
  *
495
495
  * A user is limited to 10 active sessions at a time by default. [Learn more
496
- * about session limits](/docs/authentication#limits).
496
+ * about session limits](/docs/authentication-security#limits).
497
497
  *
498
498
  * @param {string} email
499
499
  * @param {string} password
@@ -542,7 +542,7 @@ export class Account extends Service {
542
542
  * your Appwrite instance by default.
543
543
  *
544
544
  * A user is limited to 10 active sessions at a time by default. [Learn more
545
- * about session limits](/docs/authentication#limits).
545
+ * about session limits](/docs/authentication-security#limits).
546
546
  *
547
547
  * @param {string} userId
548
548
  * @param {string} email
@@ -642,7 +642,7 @@ export class Account extends Service {
642
642
  * user.
643
643
  *
644
644
  * A user is limited to 10 active sessions at a time by default. [Learn more
645
- * about session limits](/docs/authentication#limits).
645
+ * about session limits](/docs/authentication-security#limits).
646
646
  *
647
647
  *
648
648
  * @param {string} provider
@@ -697,7 +697,7 @@ export class Account extends Service {
697
697
  * is valid for 15 minutes.
698
698
  *
699
699
  * A user is limited to 10 active sessions at a time by default. [Learn more
700
- * about session limits](/docs/authentication#limits).
700
+ * about session limits](/docs/authentication-security#limits).
701
701
  *
702
702
  * @param {string} userId
703
703
  * @param {string} phone
@@ -855,7 +855,7 @@ export class Account extends Service {
855
855
  * @throws {AppwriteException}
856
856
  * @returns {Promise}
857
857
  */
858
- async updateStatus<Preferences extends Models.Preferences>(): Promise<Models.Account<Preferences>> {
858
+ async updateStatus<Preferences extends Models.Preferences>(): Promise<Models.User<Preferences>> {
859
859
  let path = '/account/status';
860
860
  let payload: Payload = {};
861
861
 
@@ -1239,6 +1239,74 @@ export class Databases extends Service {
1239
1239
  }, payload);
1240
1240
  }
1241
1241
 
1242
+ /**
1243
+ * Create Relationship Attribute
1244
+ *
1245
+ * Create relationship attribute. [Learn more about relationship
1246
+ * attributes](docs/databases-relationships#relationship-attributes).
1247
+ *
1248
+ *
1249
+ * @param {string} databaseId
1250
+ * @param {string} collectionId
1251
+ * @param {string} relatedCollectionId
1252
+ * @param {string} type
1253
+ * @param {boolean} twoWay
1254
+ * @param {string} key
1255
+ * @param {string} twoWayKey
1256
+ * @param {string} onDelete
1257
+ * @throws {AppwriteException}
1258
+ * @returns {Promise}
1259
+ */
1260
+ async createRelationshipAttribute(databaseId: string, collectionId: string, relatedCollectionId: string, type: string, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: string): Promise<Models.AttributeRelationship> {
1261
+ if (typeof databaseId === 'undefined') {
1262
+ throw new AppwriteException('Missing required parameter: "databaseId"');
1263
+ }
1264
+
1265
+ if (typeof collectionId === 'undefined') {
1266
+ throw new AppwriteException('Missing required parameter: "collectionId"');
1267
+ }
1268
+
1269
+ if (typeof relatedCollectionId === 'undefined') {
1270
+ throw new AppwriteException('Missing required parameter: "relatedCollectionId"');
1271
+ }
1272
+
1273
+ if (typeof type === 'undefined') {
1274
+ throw new AppwriteException('Missing required parameter: "type"');
1275
+ }
1276
+
1277
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
1278
+ let payload: Payload = {};
1279
+
1280
+ if (typeof relatedCollectionId !== 'undefined') {
1281
+ payload['relatedCollectionId'] = relatedCollectionId;
1282
+ }
1283
+
1284
+ if (typeof type !== 'undefined') {
1285
+ payload['type'] = type;
1286
+ }
1287
+
1288
+ if (typeof twoWay !== 'undefined') {
1289
+ payload['twoWay'] = twoWay;
1290
+ }
1291
+
1292
+ if (typeof key !== 'undefined') {
1293
+ payload['key'] = key;
1294
+ }
1295
+
1296
+ if (typeof twoWayKey !== 'undefined') {
1297
+ payload['twoWayKey'] = twoWayKey;
1298
+ }
1299
+
1300
+ if (typeof onDelete !== 'undefined') {
1301
+ payload['onDelete'] = onDelete;
1302
+ }
1303
+
1304
+ const uri = new URL(this.client.config.endpoint + path);
1305
+ return await this.client.call('post', uri, {
1306
+ 'content-type': 'application/json',
1307
+ }, payload);
1308
+ }
1309
+
1242
1310
  /**
1243
1311
  * Create String Attribute
1244
1312
  *
@@ -1532,6 +1600,46 @@ export class Databases extends Service {
1532
1600
  }, payload);
1533
1601
  }
1534
1602
 
1603
+ /**
1604
+ * Update Relationship Attribute
1605
+ *
1606
+ * Update relationship attribute. [Learn more about relationship
1607
+ * attributes](docs/databases-relationships#relationship-attributes).
1608
+ *
1609
+ *
1610
+ * @param {string} databaseId
1611
+ * @param {string} collectionId
1612
+ * @param {string} key
1613
+ * @param {string} onDelete
1614
+ * @throws {AppwriteException}
1615
+ * @returns {Promise}
1616
+ */
1617
+ async updateRelationshipAttribute(databaseId: string, collectionId: string, key: string, onDelete?: string): Promise<Models.AttributeRelationship> {
1618
+ if (typeof databaseId === 'undefined') {
1619
+ throw new AppwriteException('Missing required parameter: "databaseId"');
1620
+ }
1621
+
1622
+ if (typeof collectionId === 'undefined') {
1623
+ throw new AppwriteException('Missing required parameter: "collectionId"');
1624
+ }
1625
+
1626
+ if (typeof key === 'undefined') {
1627
+ throw new AppwriteException('Missing required parameter: "key"');
1628
+ }
1629
+
1630
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
1631
+ let payload: Payload = {};
1632
+
1633
+ if (typeof onDelete !== 'undefined') {
1634
+ payload['onDelete'] = onDelete;
1635
+ }
1636
+
1637
+ const uri = new URL(this.client.config.endpoint + path);
1638
+ return await this.client.call('patch', uri, {
1639
+ 'content-type': 'application/json',
1640
+ }, payload);
1641
+ }
1642
+
1535
1643
  /**
1536
1644
  * List Documents
1537
1645
  *
@@ -1629,10 +1737,11 @@ export class Databases extends Service {
1629
1737
  * @param {string} databaseId
1630
1738
  * @param {string} collectionId
1631
1739
  * @param {string} documentId
1740
+ * @param {string[]} queries
1632
1741
  * @throws {AppwriteException}
1633
1742
  * @returns {Promise}
1634
1743
  */
1635
- async getDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string): Promise<Document> {
1744
+ async getDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Document> {
1636
1745
  if (typeof databaseId === 'undefined') {
1637
1746
  throw new AppwriteException('Missing required parameter: "databaseId"');
1638
1747
  }
@@ -1648,6 +1757,10 @@ export class Databases extends Service {
1648
1757
  let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
1649
1758
  let payload: Payload = {};
1650
1759
 
1760
+ if (typeof queries !== 'undefined') {
1761
+ payload['queries'] = queries;
1762
+ }
1763
+
1651
1764
  const uri = new URL(this.client.config.endpoint + path);
1652
1765
  return await this.client.call('get', uri, {
1653
1766
  'content-type': 'application/json',