node-appwrite 13.0.0 → 14.0.0-rc.2

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 (62) hide show
  1. package/README.md +2 -2
  2. package/dist/client.js +7 -3
  3. package/dist/client.js.map +1 -1
  4. package/dist/client.mjs +7 -3
  5. package/dist/client.mjs.map +1 -1
  6. package/dist/enums/name.d.mts +1 -1
  7. package/dist/enums/name.d.ts +1 -1
  8. package/dist/enums/name.js +1 -1
  9. package/dist/enums/name.js.map +1 -1
  10. package/dist/enums/name.mjs +1 -1
  11. package/dist/enums/name.mjs.map +1 -1
  12. package/dist/enums/runtime.d.mts +2 -1
  13. package/dist/enums/runtime.d.ts +2 -1
  14. package/dist/enums/runtime.js +1 -0
  15. package/dist/enums/runtime.js.map +1 -1
  16. package/dist/enums/runtime.mjs +1 -0
  17. package/dist/enums/runtime.mjs.map +1 -1
  18. package/dist/id.d.mts +15 -0
  19. package/dist/id.d.ts +15 -0
  20. package/dist/id.js +18 -2
  21. package/dist/id.js.map +1 -1
  22. package/dist/id.mjs +18 -2
  23. package/dist/id.mjs.map +1 -1
  24. package/dist/models.d.mts +192 -0
  25. package/dist/models.d.ts +192 -0
  26. package/dist/permission.d.mts +36 -0
  27. package/dist/permission.d.ts +36 -0
  28. package/dist/permission.js +33 -0
  29. package/dist/permission.js.map +1 -1
  30. package/dist/permission.mjs +33 -0
  31. package/dist/permission.mjs.map +1 -1
  32. package/dist/query.d.mts +160 -0
  33. package/dist/query.d.ts +160 -0
  34. package/dist/query.js +157 -0
  35. package/dist/query.js.map +1 -1
  36. package/dist/query.mjs +157 -0
  37. package/dist/query.mjs.map +1 -1
  38. package/dist/services/account.d.mts +5 -6
  39. package/dist/services/account.d.ts +5 -6
  40. package/dist/services/account.js +6 -13
  41. package/dist/services/account.js.map +1 -1
  42. package/dist/services/account.mjs +6 -13
  43. package/dist/services/account.mjs.map +1 -1
  44. package/dist/services/avatars.d.mts +2 -0
  45. package/dist/services/avatars.d.ts +2 -0
  46. package/dist/services/avatars.js +2 -0
  47. package/dist/services/avatars.js.map +1 -1
  48. package/dist/services/avatars.mjs +2 -0
  49. package/dist/services/avatars.mjs.map +1 -1
  50. package/dist/services/functions.d.mts +57 -10
  51. package/dist/services/functions.d.ts +57 -10
  52. package/dist/services/functions.js +155 -18
  53. package/dist/services/functions.js.map +1 -1
  54. package/dist/services/functions.mjs +155 -18
  55. package/dist/services/functions.mjs.map +1 -1
  56. package/dist/services/users.d.mts +12 -0
  57. package/dist/services/users.d.ts +12 -0
  58. package/dist/services/users.js +34 -0
  59. package/dist/services/users.js.map +1 -1
  60. package/dist/services/users.mjs +34 -0
  61. package/dist/services/users.mjs.map +1 -1
  62. package/package.json +1 -1
package/dist/query.d.mts CHANGED
@@ -2,33 +2,193 @@ type QueryTypesSingle = string | number | boolean;
2
2
  type QueryTypesList = string[] | number[] | boolean[] | Query[];
3
3
  type QueryTypes = QueryTypesSingle | QueryTypesList;
4
4
  type AttributesTypes = string | string[];
5
+ /**
6
+ * Helper class to generate query strings.
7
+ */
5
8
  declare class Query {
6
9
  method: string;
7
10
  attribute: AttributesTypes | undefined;
8
11
  values: QueryTypesList | undefined;
12
+ /**
13
+ * Constructor for Query class.
14
+ *
15
+ * @param {string} method
16
+ * @param {AttributesTypes} attribute
17
+ * @param {QueryTypes} values
18
+ */
9
19
  constructor(method: string, attribute?: AttributesTypes, values?: QueryTypes);
20
+ /**
21
+ * Convert the query object to a JSON string.
22
+ *
23
+ * @returns {string}
24
+ */
10
25
  toString(): string;
26
+ /**
27
+ * Filter resources where attribute is equal to value.
28
+ *
29
+ * @param {string} attribute
30
+ * @param {QueryTypes} value
31
+ * @returns {string}
32
+ */
11
33
  static equal: (attribute: string, value: QueryTypes) => string;
34
+ /**
35
+ * Filter resources where attribute is not equal to value.
36
+ *
37
+ * @param {string} attribute
38
+ * @param {QueryTypes} value
39
+ * @returns {string}
40
+ */
12
41
  static notEqual: (attribute: string, value: QueryTypes) => string;
42
+ /**
43
+ * Filter resources where attribute is less than value.
44
+ *
45
+ * @param {string} attribute
46
+ * @param {QueryTypes} value
47
+ * @returns {string}
48
+ */
13
49
  static lessThan: (attribute: string, value: QueryTypes) => string;
50
+ /**
51
+ * Filter resources where attribute is less than or equal to value.
52
+ *
53
+ * @param {string} attribute
54
+ * @param {QueryTypes} value
55
+ * @returns {string}
56
+ */
14
57
  static lessThanEqual: (attribute: string, value: QueryTypes) => string;
58
+ /**
59
+ * Filter resources where attribute is greater than value.
60
+ *
61
+ * @param {string} attribute
62
+ * @param {QueryTypes} value
63
+ * @returns {string}
64
+ */
15
65
  static greaterThan: (attribute: string, value: QueryTypes) => string;
66
+ /**
67
+ * Filter resources where attribute is greater than or equal to value.
68
+ *
69
+ * @param {string} attribute
70
+ * @param {QueryTypes} value
71
+ * @returns {string}
72
+ */
16
73
  static greaterThanEqual: (attribute: string, value: QueryTypes) => string;
74
+ /**
75
+ * Filter resources where attribute is null.
76
+ *
77
+ * @param {string} attribute
78
+ * @returns {string}
79
+ */
17
80
  static isNull: (attribute: string) => string;
81
+ /**
82
+ * Filter resources where attribute is not null.
83
+ *
84
+ * @param {string} attribute
85
+ * @returns {string}
86
+ */
18
87
  static isNotNull: (attribute: string) => string;
88
+ /**
89
+ * Filter resources where attribute is between start and end (inclusive).
90
+ *
91
+ * @param {string} attribute
92
+ * @param {string | number} start
93
+ * @param {string | number} end
94
+ * @returns {string}
95
+ */
19
96
  static between: (attribute: string, start: string | number, end: string | number) => string;
97
+ /**
98
+ * Filter resources where attribute starts with value.
99
+ *
100
+ * @param {string} attribute
101
+ * @param {string} value
102
+ * @returns {string}
103
+ */
20
104
  static startsWith: (attribute: string, value: string) => string;
105
+ /**
106
+ * Filter resources where attribute ends with value.
107
+ *
108
+ * @param {string} attribute
109
+ * @param {string} value
110
+ * @returns {string}
111
+ */
21
112
  static endsWith: (attribute: string, value: string) => string;
113
+ /**
114
+ * Specify which attributes should be returned by the API call.
115
+ *
116
+ * @param {string[]} attributes
117
+ * @returns {string}
118
+ */
22
119
  static select: (attributes: string[]) => string;
120
+ /**
121
+ * Filter resources by searching attribute for value.
122
+ * A fulltext index on attribute is required for this query to work.
123
+ *
124
+ * @param {string} attribute
125
+ * @param {string} value
126
+ * @returns {string}
127
+ */
23
128
  static search: (attribute: string, value: string) => string;
129
+ /**
130
+ * Sort results by attribute descending.
131
+ *
132
+ * @param {string} attribute
133
+ * @returns {string}
134
+ */
24
135
  static orderDesc: (attribute: string) => string;
136
+ /**
137
+ * Sort results by attribute ascending.
138
+ *
139
+ * @param {string} attribute
140
+ * @returns {string}
141
+ */
25
142
  static orderAsc: (attribute: string) => string;
143
+ /**
144
+ * Return results after documentId.
145
+ *
146
+ * @param {string} documentId
147
+ * @returns {string}
148
+ */
26
149
  static cursorAfter: (documentId: string) => string;
150
+ /**
151
+ * Return results before documentId.
152
+ *
153
+ * @param {string} documentId
154
+ * @returns {string}
155
+ */
27
156
  static cursorBefore: (documentId: string) => string;
157
+ /**
158
+ * Return only limit results.
159
+ *
160
+ * @param {number} limit
161
+ * @returns {string}
162
+ */
28
163
  static limit: (limit: number) => string;
164
+ /**
165
+ * Filter resources by skipping the first offset results.
166
+ *
167
+ * @param {number} offset
168
+ * @returns {string}
169
+ */
29
170
  static offset: (offset: number) => string;
171
+ /**
172
+ * Filter resources where attribute contains the specified value.
173
+ *
174
+ * @param {string} attribute
175
+ * @param {string | string[]} value
176
+ * @returns {string}
177
+ */
30
178
  static contains: (attribute: string, value: string | string[]) => string;
179
+ /**
180
+ * Combine multiple queries using logical OR operator.
181
+ *
182
+ * @param {string[]} queries
183
+ * @returns {string}
184
+ */
31
185
  static or: (queries: string[]) => string;
186
+ /**
187
+ * Combine multiple queries using logical AND operator.
188
+ *
189
+ * @param {string[]} queries
190
+ * @returns {string}
191
+ */
32
192
  static and: (queries: string[]) => string;
33
193
  }
34
194
 
package/dist/query.d.ts CHANGED
@@ -2,33 +2,193 @@ type QueryTypesSingle = string | number | boolean;
2
2
  type QueryTypesList = string[] | number[] | boolean[] | Query[];
3
3
  type QueryTypes = QueryTypesSingle | QueryTypesList;
4
4
  type AttributesTypes = string | string[];
5
+ /**
6
+ * Helper class to generate query strings.
7
+ */
5
8
  declare class Query {
6
9
  method: string;
7
10
  attribute: AttributesTypes | undefined;
8
11
  values: QueryTypesList | undefined;
12
+ /**
13
+ * Constructor for Query class.
14
+ *
15
+ * @param {string} method
16
+ * @param {AttributesTypes} attribute
17
+ * @param {QueryTypes} values
18
+ */
9
19
  constructor(method: string, attribute?: AttributesTypes, values?: QueryTypes);
20
+ /**
21
+ * Convert the query object to a JSON string.
22
+ *
23
+ * @returns {string}
24
+ */
10
25
  toString(): string;
26
+ /**
27
+ * Filter resources where attribute is equal to value.
28
+ *
29
+ * @param {string} attribute
30
+ * @param {QueryTypes} value
31
+ * @returns {string}
32
+ */
11
33
  static equal: (attribute: string, value: QueryTypes) => string;
34
+ /**
35
+ * Filter resources where attribute is not equal to value.
36
+ *
37
+ * @param {string} attribute
38
+ * @param {QueryTypes} value
39
+ * @returns {string}
40
+ */
12
41
  static notEqual: (attribute: string, value: QueryTypes) => string;
42
+ /**
43
+ * Filter resources where attribute is less than value.
44
+ *
45
+ * @param {string} attribute
46
+ * @param {QueryTypes} value
47
+ * @returns {string}
48
+ */
13
49
  static lessThan: (attribute: string, value: QueryTypes) => string;
50
+ /**
51
+ * Filter resources where attribute is less than or equal to value.
52
+ *
53
+ * @param {string} attribute
54
+ * @param {QueryTypes} value
55
+ * @returns {string}
56
+ */
14
57
  static lessThanEqual: (attribute: string, value: QueryTypes) => string;
58
+ /**
59
+ * Filter resources where attribute is greater than value.
60
+ *
61
+ * @param {string} attribute
62
+ * @param {QueryTypes} value
63
+ * @returns {string}
64
+ */
15
65
  static greaterThan: (attribute: string, value: QueryTypes) => string;
66
+ /**
67
+ * Filter resources where attribute is greater than or equal to value.
68
+ *
69
+ * @param {string} attribute
70
+ * @param {QueryTypes} value
71
+ * @returns {string}
72
+ */
16
73
  static greaterThanEqual: (attribute: string, value: QueryTypes) => string;
74
+ /**
75
+ * Filter resources where attribute is null.
76
+ *
77
+ * @param {string} attribute
78
+ * @returns {string}
79
+ */
17
80
  static isNull: (attribute: string) => string;
81
+ /**
82
+ * Filter resources where attribute is not null.
83
+ *
84
+ * @param {string} attribute
85
+ * @returns {string}
86
+ */
18
87
  static isNotNull: (attribute: string) => string;
88
+ /**
89
+ * Filter resources where attribute is between start and end (inclusive).
90
+ *
91
+ * @param {string} attribute
92
+ * @param {string | number} start
93
+ * @param {string | number} end
94
+ * @returns {string}
95
+ */
19
96
  static between: (attribute: string, start: string | number, end: string | number) => string;
97
+ /**
98
+ * Filter resources where attribute starts with value.
99
+ *
100
+ * @param {string} attribute
101
+ * @param {string} value
102
+ * @returns {string}
103
+ */
20
104
  static startsWith: (attribute: string, value: string) => string;
105
+ /**
106
+ * Filter resources where attribute ends with value.
107
+ *
108
+ * @param {string} attribute
109
+ * @param {string} value
110
+ * @returns {string}
111
+ */
21
112
  static endsWith: (attribute: string, value: string) => string;
113
+ /**
114
+ * Specify which attributes should be returned by the API call.
115
+ *
116
+ * @param {string[]} attributes
117
+ * @returns {string}
118
+ */
22
119
  static select: (attributes: string[]) => string;
120
+ /**
121
+ * Filter resources by searching attribute for value.
122
+ * A fulltext index on attribute is required for this query to work.
123
+ *
124
+ * @param {string} attribute
125
+ * @param {string} value
126
+ * @returns {string}
127
+ */
23
128
  static search: (attribute: string, value: string) => string;
129
+ /**
130
+ * Sort results by attribute descending.
131
+ *
132
+ * @param {string} attribute
133
+ * @returns {string}
134
+ */
24
135
  static orderDesc: (attribute: string) => string;
136
+ /**
137
+ * Sort results by attribute ascending.
138
+ *
139
+ * @param {string} attribute
140
+ * @returns {string}
141
+ */
25
142
  static orderAsc: (attribute: string) => string;
143
+ /**
144
+ * Return results after documentId.
145
+ *
146
+ * @param {string} documentId
147
+ * @returns {string}
148
+ */
26
149
  static cursorAfter: (documentId: string) => string;
150
+ /**
151
+ * Return results before documentId.
152
+ *
153
+ * @param {string} documentId
154
+ * @returns {string}
155
+ */
27
156
  static cursorBefore: (documentId: string) => string;
157
+ /**
158
+ * Return only limit results.
159
+ *
160
+ * @param {number} limit
161
+ * @returns {string}
162
+ */
28
163
  static limit: (limit: number) => string;
164
+ /**
165
+ * Filter resources by skipping the first offset results.
166
+ *
167
+ * @param {number} offset
168
+ * @returns {string}
169
+ */
29
170
  static offset: (offset: number) => string;
171
+ /**
172
+ * Filter resources where attribute contains the specified value.
173
+ *
174
+ * @param {string} attribute
175
+ * @param {string | string[]} value
176
+ * @returns {string}
177
+ */
30
178
  static contains: (attribute: string, value: string | string[]) => string;
179
+ /**
180
+ * Combine multiple queries using logical OR operator.
181
+ *
182
+ * @param {string[]} queries
183
+ * @returns {string}
184
+ */
31
185
  static or: (queries: string[]) => string;
186
+ /**
187
+ * Combine multiple queries using logical AND operator.
188
+ *
189
+ * @param {string[]} queries
190
+ * @returns {string}
191
+ */
32
192
  static and: (queries: string[]) => string;
33
193
  }
34
194
 
package/dist/query.js CHANGED
@@ -1,6 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const _Query = class _Query {
4
+ /**
5
+ * Constructor for Query class.
6
+ *
7
+ * @param {string} method
8
+ * @param {AttributesTypes} attribute
9
+ * @param {QueryTypes} values
10
+ */
4
11
  constructor(method, attribute, values) {
5
12
  this.method = method;
6
13
  this.attribute = attribute;
@@ -12,6 +19,11 @@ const _Query = class _Query {
12
19
  }
13
20
  }
14
21
  }
22
+ /**
23
+ * Convert the query object to a JSON string.
24
+ *
25
+ * @returns {string}
26
+ */
15
27
  toString() {
16
28
  return JSON.stringify({
17
29
  method: this.method,
@@ -20,27 +32,172 @@ const _Query = class _Query {
20
32
  });
21
33
  }
22
34
  };
35
+ /**
36
+ * Filter resources where attribute is equal to value.
37
+ *
38
+ * @param {string} attribute
39
+ * @param {QueryTypes} value
40
+ * @returns {string}
41
+ */
23
42
  _Query.equal = (attribute, value) => new _Query("equal", attribute, value).toString();
43
+ /**
44
+ * Filter resources where attribute is not equal to value.
45
+ *
46
+ * @param {string} attribute
47
+ * @param {QueryTypes} value
48
+ * @returns {string}
49
+ */
24
50
  _Query.notEqual = (attribute, value) => new _Query("notEqual", attribute, value).toString();
51
+ /**
52
+ * Filter resources where attribute is less than value.
53
+ *
54
+ * @param {string} attribute
55
+ * @param {QueryTypes} value
56
+ * @returns {string}
57
+ */
25
58
  _Query.lessThan = (attribute, value) => new _Query("lessThan", attribute, value).toString();
59
+ /**
60
+ * Filter resources where attribute is less than or equal to value.
61
+ *
62
+ * @param {string} attribute
63
+ * @param {QueryTypes} value
64
+ * @returns {string}
65
+ */
26
66
  _Query.lessThanEqual = (attribute, value) => new _Query("lessThanEqual", attribute, value).toString();
67
+ /**
68
+ * Filter resources where attribute is greater than value.
69
+ *
70
+ * @param {string} attribute
71
+ * @param {QueryTypes} value
72
+ * @returns {string}
73
+ */
27
74
  _Query.greaterThan = (attribute, value) => new _Query("greaterThan", attribute, value).toString();
75
+ /**
76
+ * Filter resources where attribute is greater than or equal to value.
77
+ *
78
+ * @param {string} attribute
79
+ * @param {QueryTypes} value
80
+ * @returns {string}
81
+ */
28
82
  _Query.greaterThanEqual = (attribute, value) => new _Query("greaterThanEqual", attribute, value).toString();
83
+ /**
84
+ * Filter resources where attribute is null.
85
+ *
86
+ * @param {string} attribute
87
+ * @returns {string}
88
+ */
29
89
  _Query.isNull = (attribute) => new _Query("isNull", attribute).toString();
90
+ /**
91
+ * Filter resources where attribute is not null.
92
+ *
93
+ * @param {string} attribute
94
+ * @returns {string}
95
+ */
30
96
  _Query.isNotNull = (attribute) => new _Query("isNotNull", attribute).toString();
97
+ /**
98
+ * Filter resources where attribute is between start and end (inclusive).
99
+ *
100
+ * @param {string} attribute
101
+ * @param {string | number} start
102
+ * @param {string | number} end
103
+ * @returns {string}
104
+ */
31
105
  _Query.between = (attribute, start, end) => new _Query("between", attribute, [start, end]).toString();
106
+ /**
107
+ * Filter resources where attribute starts with value.
108
+ *
109
+ * @param {string} attribute
110
+ * @param {string} value
111
+ * @returns {string}
112
+ */
32
113
  _Query.startsWith = (attribute, value) => new _Query("startsWith", attribute, value).toString();
114
+ /**
115
+ * Filter resources where attribute ends with value.
116
+ *
117
+ * @param {string} attribute
118
+ * @param {string} value
119
+ * @returns {string}
120
+ */
33
121
  _Query.endsWith = (attribute, value) => new _Query("endsWith", attribute, value).toString();
122
+ /**
123
+ * Specify which attributes should be returned by the API call.
124
+ *
125
+ * @param {string[]} attributes
126
+ * @returns {string}
127
+ */
34
128
  _Query.select = (attributes) => new _Query("select", void 0, attributes).toString();
129
+ /**
130
+ * Filter resources by searching attribute for value.
131
+ * A fulltext index on attribute is required for this query to work.
132
+ *
133
+ * @param {string} attribute
134
+ * @param {string} value
135
+ * @returns {string}
136
+ */
35
137
  _Query.search = (attribute, value) => new _Query("search", attribute, value).toString();
138
+ /**
139
+ * Sort results by attribute descending.
140
+ *
141
+ * @param {string} attribute
142
+ * @returns {string}
143
+ */
36
144
  _Query.orderDesc = (attribute) => new _Query("orderDesc", attribute).toString();
145
+ /**
146
+ * Sort results by attribute ascending.
147
+ *
148
+ * @param {string} attribute
149
+ * @returns {string}
150
+ */
37
151
  _Query.orderAsc = (attribute) => new _Query("orderAsc", attribute).toString();
152
+ /**
153
+ * Return results after documentId.
154
+ *
155
+ * @param {string} documentId
156
+ * @returns {string}
157
+ */
38
158
  _Query.cursorAfter = (documentId) => new _Query("cursorAfter", void 0, documentId).toString();
159
+ /**
160
+ * Return results before documentId.
161
+ *
162
+ * @param {string} documentId
163
+ * @returns {string}
164
+ */
39
165
  _Query.cursorBefore = (documentId) => new _Query("cursorBefore", void 0, documentId).toString();
166
+ /**
167
+ * Return only limit results.
168
+ *
169
+ * @param {number} limit
170
+ * @returns {string}
171
+ */
40
172
  _Query.limit = (limit) => new _Query("limit", void 0, limit).toString();
173
+ /**
174
+ * Filter resources by skipping the first offset results.
175
+ *
176
+ * @param {number} offset
177
+ * @returns {string}
178
+ */
41
179
  _Query.offset = (offset) => new _Query("offset", void 0, offset).toString();
180
+ /**
181
+ * Filter resources where attribute contains the specified value.
182
+ *
183
+ * @param {string} attribute
184
+ * @param {string | string[]} value
185
+ * @returns {string}
186
+ */
42
187
  _Query.contains = (attribute, value) => new _Query("contains", attribute, value).toString();
188
+ /**
189
+ * Combine multiple queries using logical OR operator.
190
+ *
191
+ * @param {string[]} queries
192
+ * @returns {string}
193
+ */
43
194
  _Query.or = (queries) => new _Query("or", void 0, queries.map((query) => JSON.parse(query))).toString();
195
+ /**
196
+ * Combine multiple queries using logical AND operator.
197
+ *
198
+ * @param {string[]} queries
199
+ * @returns {string}
200
+ */
44
201
  _Query.and = (queries) => new _Query("and", void 0, queries.map((query) => JSON.parse(query))).toString();
45
202
  let Query = _Query;
46
203
 
package/dist/query.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/query.ts"],"names":[],"mappings":"AAKO,MAAM,SAAN,MAAM,OAAM;AAAA,EAKjB,YACE,QACA,WACA,QACA;AACA,SAAK,SAAS;AACd,SAAK,YAAY;AAEjB,QAAI,WAAW,QAAW;AACxB,UAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,aAAK,SAAS;AAAA,MAChB,OAAO;AACL,aAAK,SAAS,CAAC,MAAM;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAmB;AACjB,WAAO,KAAK,UAAU;AAAA,MACpB,QAAQ,KAAK;AAAA,MACb,WAAW,KAAK;AAAA,MAChB,QAAQ,KAAK;AAAA,IACf,CAAC;AAAA,EACH;AAmEF;AA/Fa,OA8BJ,QAAQ,CAAC,WAAmB,UACjC,IAAI,OAAM,SAAS,WAAW,KAAK,EAAE,SAAS;AA/BrC,OAiCJ,WAAW,CAAC,WAAmB,UACpC,IAAI,OAAM,YAAY,WAAW,KAAK,EAAE,SAAS;AAlCxC,OAoCJ,WAAW,CAAC,WAAmB,UACpC,IAAI,OAAM,YAAY,WAAW,KAAK,EAAE,SAAS;AAr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AAS,CAAC,WACf,IAAI,OAAM,UAAU,QAAW,MAAM,EAAE,SAAS;AArFvC,OAuFJ,WAAW,CAAC,WAAmB,UACpC,IAAI,OAAM,YAAY,WAAW,KAAK,EAAE,SAAS;AAxFxC,OA0FJ,KAAK,CAAC,YACX,IAAI,OAAM,MAAM,QAAW,QAAQ,IAAI,CAAC,UAAU,KAAK,MAAM,KAAK,CAAC,CAAC,EAAE,SAAS;AA3FtE,OA6FJ,MAAM,CAAC,YACZ,IAAI,OAAM,OAAO,QAAW,QAAQ,IAAI,CAAC,UAAU,KAAK,MAAM,KAAK,CAAC,CAAC,EAAE,SAAS;AA9F7E,IAAM,QAAN","sourcesContent":["type QueryTypesSingle = string | number | boolean;\nexport type QueryTypesList = string[] | number[] | boolean[] | Query[];\nexport type QueryTypes = QueryTypesSingle | QueryTypesList;\ntype AttributesTypes = string | string[];\n\nexport class Query {\n method: string;\n attribute: AttributesTypes | undefined;\n values: QueryTypesList | undefined;\n\n constructor(\n method: string,\n attribute?: AttributesTypes,\n values?: QueryTypes\n ) {\n this.method = method;\n this.attribute = attribute;\n\n if (values !== undefined) {\n if (Array.isArray(values)) {\n this.values = values;\n } else {\n this.values = [values] as QueryTypesList;\n }\n }\n }\n\n toString(): string {\n return JSON.stringify({\n method: this.method,\n attribute: this.attribute,\n values: this.values,\n });\n }\n\n static equal = (attribute: string, value: QueryTypes): string =>\n new Query(\"equal\", attribute, value).toString();\n\n static notEqual = (attribute: string, value: QueryTypes): string =>\n new Query(\"notEqual\", attribute, value).toString();\n\n static lessThan = (attribute: string, value: QueryTypes): string =>\n new Query(\"lessThan\", attribute, value).toString();\n\n static lessThanEqual = (attribute: string, value: QueryTypes): string =>\n new Query(\"lessThanEqual\", attribute, value).toString();\n\n static greaterThan = (attribute: string, value: QueryTypes): string =>\n new Query(\"greaterThan\", attribute, value).toString();\n\n static greaterThanEqual = (attribute: string, value: QueryTypes): string =>\n new Query(\"greaterThanEqual\", attribute, value).toString();\n\n static isNull = (attribute: string): string =>\n new Query(\"isNull\", attribute).toString();\n\n static isNotNull = (attribute: string): string =>\n new Query(\"isNotNull\", attribute).toString();\n\n static between = (attribute: string, start: string | number, end: string | number) =>\n new Query(\"between\", attribute, [start, end] as QueryTypesList).toString();\n\n static startsWith = (attribute: string, value: string): string =>\n new Query(\"startsWith\", attribute, value).toString();\n\n static endsWith = (attribute: string, value: string): string =>\n new Query(\"endsWith\", attribute, value).toString();\n\n static select = (attributes: string[]): string =>\n new Query(\"select\", undefined, attributes).toString();\n\n static search = (attribute: string, value: string): string =>\n new Query(\"search\", attribute, value).toString();\n\n static orderDesc = (attribute: string): string =>\n new Query(\"orderDesc\", attribute).toString();\n\n static orderAsc = (attribute: string): string =>\n new Query(\"orderAsc\", attribute).toString();\n\n static cursorAfter = (documentId: string): string =>\n new Query(\"cursorAfter\", undefined, documentId).toString();\n\n static cursorBefore = (documentId: string): string =>\n new Query(\"cursorBefore\", undefined, documentId).toString();\n\n static limit = (limit: number): string =>\n new Query(\"limit\", undefined, limit).toString();\n\n static offset = (offset: number): string =>\n new Query(\"offset\", undefined, offset).toString();\n\n static contains = (attribute: string, value: string | string[]): string =>\n new Query(\"contains\", attribute, value).toString();\n\n static or = (queries: string[]) =>\n new Query(\"or\", undefined, queries.map((query) => JSON.parse(query))).toString();\n\n static and = (queries: string[]) =>\n new Query(\"and\", undefined, queries.map((query) => JSON.parse(query))).toString();\n}\n"]}
1
+ {"version":3,"sources":["../src/query.ts"],"names":[],"mappings":"AAQO,MAAM,SAAN,MAAM,OAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYjB,YACE,QACA,WACA,QACA;AACA,SAAK,SAAS;AACd,SAAK,YAAY;AAEjB,QAAI,WAAW,QAAW;AACxB,UAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,aAAK,SAAS;AAAA,MAChB,OAAO;AACL,aAAK,SAAS,CAAC,MAAM;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AAAA;AAAA;A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,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA/NvC,OAwOJ,WAAW,CAAC,WAAmB,UACpC,IAAI,OAAM,YAAY,WAAW,KAAK,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAzOxC,OAiPJ,KAAK,CAAC,YACX,IAAI,OAAM,MAAM,QAAW,QAAQ,IAAI,CAAC,UAAU,KAAK,MAAM,KAAK,CAAC,CAAC,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAlPtE,OA0PJ,MAAM,CAAC,YACZ,IAAI,OAAM,OAAO,QAAW,QAAQ,IAAI,CAAC,UAAU,KAAK,MAAM,KAAK,CAAC,CAAC,EAAE,SAAS;AA3P7E,IAAM,QAAN","sourcesContent":["type QueryTypesSingle = string | number | boolean;\nexport type QueryTypesList = string[] | number[] | boolean[] | Query[];\nexport type QueryTypes = QueryTypesSingle | QueryTypesList;\ntype AttributesTypes = string | string[];\n\n/**\n * Helper class to generate query strings.\n */\nexport class Query {\n method: string;\n attribute: AttributesTypes | undefined;\n values: QueryTypesList | undefined;\n\n /**\n * Constructor for Query class.\n *\n * @param {string} method\n * @param {AttributesTypes} attribute\n * @param {QueryTypes} values\n */\n constructor(\n method: string,\n attribute?: AttributesTypes,\n values?: QueryTypes\n ) {\n this.method = method;\n this.attribute = attribute;\n\n if (values !== undefined) {\n if (Array.isArray(values)) {\n this.values = values;\n } else {\n this.values = [values] as QueryTypesList;\n }\n }\n }\n\n /**\n * Convert the query object to a JSON string.\n *\n * @returns {string}\n */\n toString(): string {\n return JSON.stringify({\n method: this.method,\n attribute: this.attribute,\n values: this.values,\n });\n }\n\n /**\n * Filter resources where attribute is equal to value.\n *\n * @param {string} attribute\n * @param {QueryTypes} value\n * @returns {string}\n */\n static equal = (attribute: string, value: QueryTypes): string =>\n new Query(\"equal\", attribute, value).toString();\n\n /**\n * Filter resources where attribute is not equal to value.\n *\n * @param {string} attribute\n * @param {QueryTypes} value\n * @returns {string}\n */\n static notEqual = (attribute: string, value: QueryTypes): string =>\n new Query(\"notEqual\", attribute, value).toString();\n\n /**\n * Filter resources where attribute is less than value.\n *\n * @param {string} attribute\n * @param {QueryTypes} value\n * @returns {string}\n */\n static lessThan = (attribute: string, value: QueryTypes): string =>\n new Query(\"lessThan\", attribute, value).toString();\n\n /**\n * Filter resources where attribute is less than or equal to value.\n *\n * @param {string} attribute\n * @param {QueryTypes} value\n * @returns {string}\n */\n static lessThanEqual = (attribute: string, value: QueryTypes): string =>\n new Query(\"lessThanEqual\", attribute, value).toString();\n\n /**\n * Filter resources where attribute is greater than value.\n *\n * @param {string} attribute\n * @param {QueryTypes} value\n * @returns {string}\n */\n static greaterThan = (attribute: string, value: QueryTypes): string =>\n new Query(\"greaterThan\", attribute, value).toString();\n\n /**\n * Filter resources where attribute is greater than or equal to value.\n *\n * @param {string} attribute\n * @param {QueryTypes} value\n * @returns {string}\n */\n static greaterThanEqual = (attribute: string, value: QueryTypes): string =>\n new Query(\"greaterThanEqual\", attribute, value).toString();\n\n /**\n * Filter resources where attribute is null.\n *\n * @param {string} attribute\n * @returns {string}\n */\n static isNull = (attribute: string): string =>\n new Query(\"isNull\", attribute).toString();\n\n /**\n * Filter resources where attribute is not null.\n *\n * @param {string} attribute\n * @returns {string}\n */\n static isNotNull = (attribute: string): string =>\n new Query(\"isNotNull\", attribute).toString();\n\n /**\n * Filter resources where attribute is between start and end (inclusive).\n *\n * @param {string} attribute\n * @param {string | number} start\n * @param {string | number} end\n * @returns {string}\n */\n static between = (attribute: string, start: string | number, end: string | number): string =>\n new Query(\"between\", attribute, [start, end] as QueryTypesList).toString();\n\n /**\n * Filter resources where attribute starts with value.\n *\n * @param {string} attribute\n * @param {string} value\n * @returns {string}\n */\n static startsWith = (attribute: string, value: string): string =>\n new Query(\"startsWith\", attribute, value).toString();\n\n /**\n * Filter resources where attribute ends with value.\n *\n * @param {string} attribute\n * @param {string} value\n * @returns {string}\n */\n static endsWith = (attribute: string, value: string): string =>\n new Query(\"endsWith\", attribute, value).toString();\n\n /**\n * Specify which attributes should be returned by the API call.\n *\n * @param {string[]} attributes\n * @returns {string}\n */\n static select = (attributes: string[]): string =>\n new Query(\"select\", undefined, attributes).toString();\n\n /**\n * Filter resources by searching attribute for value.\n * A fulltext index on attribute is required for this query to work.\n *\n * @param {string} attribute\n * @param {string} value\n * @returns {string}\n */\n static search = (attribute: string, value: string): string =>\n new Query(\"search\", attribute, value).toString();\n\n /**\n * Sort results by attribute descending.\n *\n * @param {string} attribute\n * @returns {string}\n */\n static orderDesc = (attribute: string): string =>\n new Query(\"orderDesc\", attribute).toString();\n\n /**\n * Sort results by attribute ascending.\n *\n * @param {string} attribute\n * @returns {string}\n */\n static orderAsc = (attribute: string): string =>\n new Query(\"orderAsc\", attribute).toString();\n\n /**\n * Return results after documentId.\n *\n * @param {string} documentId\n * @returns {string}\n */\n static cursorAfter = (documentId: string): string =>\n new Query(\"cursorAfter\", undefined, documentId).toString();\n\n /**\n * Return results before documentId.\n *\n * @param {string} documentId\n * @returns {string}\n */\n static cursorBefore = (documentId: string): string =>\n new Query(\"cursorBefore\", undefined, documentId).toString();\n\n /**\n * Return only limit results.\n *\n * @param {number} limit\n * @returns {string}\n */\n static limit = (limit: number): string =>\n new Query(\"limit\", undefined, limit).toString();\n\n /**\n * Filter resources by skipping the first offset results.\n *\n * @param {number} offset\n * @returns {string}\n */\n static offset = (offset: number): string =>\n new Query(\"offset\", undefined, offset).toString();\n\n /**\n * Filter resources where attribute contains the specified value.\n *\n * @param {string} attribute\n * @param {string | string[]} value\n * @returns {string}\n */\n static contains = (attribute: string, value: string | string[]): string =>\n new Query(\"contains\", attribute, value).toString();\n\n /**\n * Combine multiple queries using logical OR operator.\n *\n * @param {string[]} queries\n * @returns {string}\n */\n static or = (queries: string[]) =>\n new Query(\"or\", undefined, queries.map((query) => JSON.parse(query))).toString();\n\n /**\n * Combine multiple queries using logical AND operator.\n *\n * @param {string[]} queries\n * @returns {string}\n */\n static and = (queries: string[]) =>\n new Query(\"and\", undefined, queries.map((query) => JSON.parse(query))).toString();\n}\n"]}