@revenexx/sdk 0.0.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.
- package/LICENSE +21 -0
- package/README.md +148 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/sdk.js +16340 -0
- package/dist/cjs/sdk.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/sdk.js +16250 -0
- package/dist/esm/sdk.js.map +1 -0
- package/dist/iife/sdk.js +20101 -0
- package/package.json +56 -0
- package/src/channel.ts +158 -0
- package/src/client.ts +950 -0
- package/src/enums/adapter.ts +4 -0
- package/src/enums/attribute-boolean-status.ts +7 -0
- package/src/enums/attribute-datetime-status.ts +7 -0
- package/src/enums/attribute-email-status.ts +7 -0
- package/src/enums/attribute-enum-status.ts +7 -0
- package/src/enums/attribute-float-status.ts +7 -0
- package/src/enums/attribute-integer-status.ts +7 -0
- package/src/enums/attribute-ip-status.ts +7 -0
- package/src/enums/attribute-line-status.ts +7 -0
- package/src/enums/attribute-longtext-status.ts +7 -0
- package/src/enums/attribute-mediumtext-status.ts +7 -0
- package/src/enums/attribute-point-status.ts +7 -0
- package/src/enums/attribute-polygon-status.ts +7 -0
- package/src/enums/attribute-relationship-status.ts +7 -0
- package/src/enums/attribute-string-status.ts +7 -0
- package/src/enums/attribute-text-status.ts +7 -0
- package/src/enums/attribute-url-status.ts +7 -0
- package/src/enums/attribute-varchar-status.ts +7 -0
- package/src/enums/build-runtime.ts +73 -0
- package/src/enums/code.ts +16 -0
- package/src/enums/collection.ts +4 -0
- package/src/enums/column-boolean-status.ts +7 -0
- package/src/enums/column-datetime-status.ts +7 -0
- package/src/enums/column-email-status.ts +7 -0
- package/src/enums/column-enum-status.ts +7 -0
- package/src/enums/column-float-status.ts +7 -0
- package/src/enums/column-integer-status.ts +7 -0
- package/src/enums/column-ip-status.ts +7 -0
- package/src/enums/column-line-status.ts +7 -0
- package/src/enums/column-longtext-status.ts +7 -0
- package/src/enums/column-mediumtext-status.ts +7 -0
- package/src/enums/column-point-status.ts +7 -0
- package/src/enums/column-polygon-status.ts +7 -0
- package/src/enums/column-relationship-status.ts +7 -0
- package/src/enums/column-string-status.ts +7 -0
- package/src/enums/column-text-status.ts +7 -0
- package/src/enums/column-url-status.ts +7 -0
- package/src/enums/column-varchar-status.ts +7 -0
- package/src/enums/compression.ts +5 -0
- package/src/enums/database-type.ts +4 -0
- package/src/enums/deployment-status.ts +8 -0
- package/src/enums/execution-status.ts +7 -0
- package/src/enums/execution-trigger.ts +5 -0
- package/src/enums/framework.ts +17 -0
- package/src/enums/gravity.ts +11 -0
- package/src/enums/health-antivirus-status.ts +5 -0
- package/src/enums/health-status-status.ts +4 -0
- package/src/enums/index-status.ts +7 -0
- package/src/enums/message-status.ts +7 -0
- package/src/enums/method.ts +9 -0
- package/src/enums/output.ts +9 -0
- package/src/enums/permissions.ts +22 -0
- package/src/enums/priority.ts +4 -0
- package/src/enums/range.ts +5 -0
- package/src/enums/runtime.ts +73 -0
- package/src/enums/runtimes.ts +73 -0
- package/src/enums/scopes.ts +57 -0
- package/src/enums/theme.ts +4 -0
- package/src/enums/timezone.ts +421 -0
- package/src/enums/type.ts +5 -0
- package/src/enums/use-cases.ts +9 -0
- package/src/id.ts +47 -0
- package/src/index.ts +92 -0
- package/src/models.ts +6013 -0
- package/src/operator.ts +308 -0
- package/src/permission.ts +57 -0
- package/src/query.ts +576 -0
- package/src/role.ts +100 -0
- package/src/service.ts +30 -0
- package/src/services/apps.ts +2473 -0
- package/src/services/avatars.ts +744 -0
- package/src/services/carts.ts +1057 -0
- package/src/services/channels.ts +227 -0
- package/src/services/customers.ts +729 -0
- package/src/services/greetings.ts +294 -0
- package/src/services/locale.ts +198 -0
- package/src/services/markets.ts +796 -0
- package/src/services/messaging.ts +3463 -0
- package/src/services/products.ts +3100 -0
- package/src/services/realtime.ts +537 -0
- package/src/services/search.ts +346 -0
- package/src/services/sites.ts +1847 -0
- package/src/services/storage.ts +1076 -0
- package/src/services/tokens.ts +314 -0
- package/types/channel.d.ts +74 -0
- package/types/client.d.ts +211 -0
- package/types/enums/adapter.d.ts +4 -0
- package/types/enums/attribute-boolean-status.d.ts +7 -0
- package/types/enums/attribute-datetime-status.d.ts +7 -0
- package/types/enums/attribute-email-status.d.ts +7 -0
- package/types/enums/attribute-enum-status.d.ts +7 -0
- package/types/enums/attribute-float-status.d.ts +7 -0
- package/types/enums/attribute-integer-status.d.ts +7 -0
- package/types/enums/attribute-ip-status.d.ts +7 -0
- package/types/enums/attribute-line-status.d.ts +7 -0
- package/types/enums/attribute-longtext-status.d.ts +7 -0
- package/types/enums/attribute-mediumtext-status.d.ts +7 -0
- package/types/enums/attribute-point-status.d.ts +7 -0
- package/types/enums/attribute-polygon-status.d.ts +7 -0
- package/types/enums/attribute-relationship-status.d.ts +7 -0
- package/types/enums/attribute-string-status.d.ts +7 -0
- package/types/enums/attribute-text-status.d.ts +7 -0
- package/types/enums/attribute-url-status.d.ts +7 -0
- package/types/enums/attribute-varchar-status.d.ts +7 -0
- package/types/enums/build-runtime.d.ts +73 -0
- package/types/enums/code.d.ts +16 -0
- package/types/enums/collection.d.ts +4 -0
- package/types/enums/column-boolean-status.d.ts +7 -0
- package/types/enums/column-datetime-status.d.ts +7 -0
- package/types/enums/column-email-status.d.ts +7 -0
- package/types/enums/column-enum-status.d.ts +7 -0
- package/types/enums/column-float-status.d.ts +7 -0
- package/types/enums/column-integer-status.d.ts +7 -0
- package/types/enums/column-ip-status.d.ts +7 -0
- package/types/enums/column-line-status.d.ts +7 -0
- package/types/enums/column-longtext-status.d.ts +7 -0
- package/types/enums/column-mediumtext-status.d.ts +7 -0
- package/types/enums/column-point-status.d.ts +7 -0
- package/types/enums/column-polygon-status.d.ts +7 -0
- package/types/enums/column-relationship-status.d.ts +7 -0
- package/types/enums/column-string-status.d.ts +7 -0
- package/types/enums/column-text-status.d.ts +7 -0
- package/types/enums/column-url-status.d.ts +7 -0
- package/types/enums/column-varchar-status.d.ts +7 -0
- package/types/enums/compression.d.ts +5 -0
- package/types/enums/database-type.d.ts +4 -0
- package/types/enums/deployment-status.d.ts +8 -0
- package/types/enums/execution-status.d.ts +7 -0
- package/types/enums/execution-trigger.d.ts +5 -0
- package/types/enums/framework.d.ts +17 -0
- package/types/enums/gravity.d.ts +11 -0
- package/types/enums/health-antivirus-status.d.ts +5 -0
- package/types/enums/health-status-status.d.ts +4 -0
- package/types/enums/index-status.d.ts +7 -0
- package/types/enums/message-status.d.ts +7 -0
- package/types/enums/method.d.ts +9 -0
- package/types/enums/output.d.ts +9 -0
- package/types/enums/permissions.d.ts +22 -0
- package/types/enums/priority.d.ts +4 -0
- package/types/enums/range.d.ts +5 -0
- package/types/enums/runtime.d.ts +73 -0
- package/types/enums/runtimes.d.ts +73 -0
- package/types/enums/scopes.d.ts +57 -0
- package/types/enums/theme.d.ts +4 -0
- package/types/enums/timezone.d.ts +421 -0
- package/types/enums/type.d.ts +5 -0
- package/types/enums/use-cases.d.ts +9 -0
- package/types/id.d.ts +20 -0
- package/types/index.d.ts +92 -0
- package/types/models.d.ts +5830 -0
- package/types/operator.d.ts +180 -0
- package/types/permission.d.ts +43 -0
- package/types/query.d.ts +442 -0
- package/types/role.d.ts +70 -0
- package/types/service.d.ts +11 -0
- package/types/services/apps.d.ts +932 -0
- package/types/services/avatars.d.ts +318 -0
- package/types/services/carts.d.ts +352 -0
- package/types/services/channels.d.ts +75 -0
- package/types/services/customers.d.ts +231 -0
- package/types/services/greetings.d.ts +101 -0
- package/types/services/locale.d.ts +64 -0
- package/types/services/markets.d.ts +274 -0
- package/types/services/messaging.d.ts +1324 -0
- package/types/services/products.d.ts +1014 -0
- package/types/services/realtime.d.ts +134 -0
- package/types/services/search.d.ts +131 -0
- package/types/services/sites.d.ts +689 -0
- package/types/services/storage.d.ts +421 -0
- package/types/services/tokens.d.ts +119 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { Service } from '../service';
|
|
2
|
+
import { RevenexxException, Client, type Payload, UploadProgress } from '../client';
|
|
3
|
+
import type { Models } from '../models';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class Tokens {
|
|
7
|
+
client: Client;
|
|
8
|
+
|
|
9
|
+
constructor(client: Client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* List all the tokens created for a specific file or bucket. You can use the query params to filter your results.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
17
|
+
* @param {string} params.fileId - File unique ID.
|
|
18
|
+
* @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire
|
|
19
|
+
* @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
|
|
20
|
+
* @throws {RevenexxException}
|
|
21
|
+
* @returns {Promise<Models.ResourceTokenList>}
|
|
22
|
+
*/
|
|
23
|
+
tokensList(params: { bucketId: string, fileId: string, queries?: string[], total?: boolean }): Promise<Models.ResourceTokenList>;
|
|
24
|
+
/**
|
|
25
|
+
* List all the tokens created for a specific file or bucket. You can use the query params to filter your results.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
28
|
+
* @param {string} fileId - File unique ID.
|
|
29
|
+
* @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire
|
|
30
|
+
* @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
|
|
31
|
+
* @throws {RevenexxException}
|
|
32
|
+
* @returns {Promise<Models.ResourceTokenList>}
|
|
33
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
34
|
+
*/
|
|
35
|
+
tokensList(bucketId: string, fileId: string, queries?: string[], total?: boolean): Promise<Models.ResourceTokenList>;
|
|
36
|
+
tokensList(
|
|
37
|
+
paramsOrFirst: { bucketId: string, fileId: string, queries?: string[], total?: boolean } | string,
|
|
38
|
+
...rest: [(string)?, (string[])?, (boolean)?]
|
|
39
|
+
): Promise<Models.ResourceTokenList> {
|
|
40
|
+
let params: { bucketId: string, fileId: string, queries?: string[], total?: boolean };
|
|
41
|
+
|
|
42
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
43
|
+
params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, queries?: string[], total?: boolean };
|
|
44
|
+
} else {
|
|
45
|
+
params = {
|
|
46
|
+
bucketId: paramsOrFirst as string,
|
|
47
|
+
fileId: rest[0] as string,
|
|
48
|
+
queries: rest[1] as string[],
|
|
49
|
+
total: rest[2] as boolean
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const bucketId = params.bucketId;
|
|
54
|
+
const fileId = params.fileId;
|
|
55
|
+
const queries = params.queries;
|
|
56
|
+
const total = params.total;
|
|
57
|
+
|
|
58
|
+
if (typeof bucketId === 'undefined') {
|
|
59
|
+
throw new RevenexxException('Missing required parameter: "bucketId"');
|
|
60
|
+
}
|
|
61
|
+
if (typeof fileId === 'undefined') {
|
|
62
|
+
throw new RevenexxException('Missing required parameter: "fileId"');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const apiPath = '/v1/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
66
|
+
const payload: Payload = {};
|
|
67
|
+
if (typeof queries !== 'undefined') {
|
|
68
|
+
payload['queries'] = queries;
|
|
69
|
+
}
|
|
70
|
+
if (typeof total !== 'undefined') {
|
|
71
|
+
payload['total'] = total;
|
|
72
|
+
}
|
|
73
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
74
|
+
|
|
75
|
+
const apiHeaders: { [header: string]: string } = {
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return this.client.call(
|
|
79
|
+
'get',
|
|
80
|
+
uri,
|
|
81
|
+
apiHeaders,
|
|
82
|
+
payload
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
90
|
+
* @param {string} params.fileId - File unique ID.
|
|
91
|
+
* @param {string} params.expire - Token expiry date
|
|
92
|
+
* @throws {RevenexxException}
|
|
93
|
+
* @returns {Promise<Models.ResourceToken>}
|
|
94
|
+
*/
|
|
95
|
+
tokensCreateFileToken(params: { bucketId: string, fileId: string, expire?: string }): Promise<Models.ResourceToken>;
|
|
96
|
+
/**
|
|
97
|
+
* Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).
|
|
100
|
+
* @param {string} fileId - File unique ID.
|
|
101
|
+
* @param {string} expire - Token expiry date
|
|
102
|
+
* @throws {RevenexxException}
|
|
103
|
+
* @returns {Promise<Models.ResourceToken>}
|
|
104
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
105
|
+
*/
|
|
106
|
+
tokensCreateFileToken(bucketId: string, fileId: string, expire?: string): Promise<Models.ResourceToken>;
|
|
107
|
+
tokensCreateFileToken(
|
|
108
|
+
paramsOrFirst: { bucketId: string, fileId: string, expire?: string } | string,
|
|
109
|
+
...rest: [(string)?, (string)?]
|
|
110
|
+
): Promise<Models.ResourceToken> {
|
|
111
|
+
let params: { bucketId: string, fileId: string, expire?: string };
|
|
112
|
+
|
|
113
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
114
|
+
params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, expire?: string };
|
|
115
|
+
} else {
|
|
116
|
+
params = {
|
|
117
|
+
bucketId: paramsOrFirst as string,
|
|
118
|
+
fileId: rest[0] as string,
|
|
119
|
+
expire: rest[1] as string
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const bucketId = params.bucketId;
|
|
124
|
+
const fileId = params.fileId;
|
|
125
|
+
const expire = params.expire;
|
|
126
|
+
|
|
127
|
+
if (typeof bucketId === 'undefined') {
|
|
128
|
+
throw new RevenexxException('Missing required parameter: "bucketId"');
|
|
129
|
+
}
|
|
130
|
+
if (typeof fileId === 'undefined') {
|
|
131
|
+
throw new RevenexxException('Missing required parameter: "fileId"');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const apiPath = '/v1/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
135
|
+
const payload: Payload = {};
|
|
136
|
+
if (typeof expire !== 'undefined') {
|
|
137
|
+
payload['expire'] = expire;
|
|
138
|
+
}
|
|
139
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
140
|
+
|
|
141
|
+
const apiHeaders: { [header: string]: string } = {
|
|
142
|
+
'content-type': 'application/json',
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return this.client.call(
|
|
146
|
+
'post',
|
|
147
|
+
uri,
|
|
148
|
+
apiHeaders,
|
|
149
|
+
payload
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Delete a token by its unique ID.
|
|
155
|
+
*
|
|
156
|
+
* @param {string} params.tokenId - Token ID.
|
|
157
|
+
* @throws {RevenexxException}
|
|
158
|
+
* @returns {Promise<{}>}
|
|
159
|
+
*/
|
|
160
|
+
tokensDelete(params: { tokenId: string }): Promise<{}>;
|
|
161
|
+
/**
|
|
162
|
+
* Delete a token by its unique ID.
|
|
163
|
+
*
|
|
164
|
+
* @param {string} tokenId - Token ID.
|
|
165
|
+
* @throws {RevenexxException}
|
|
166
|
+
* @returns {Promise<{}>}
|
|
167
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
168
|
+
*/
|
|
169
|
+
tokensDelete(tokenId: string): Promise<{}>;
|
|
170
|
+
tokensDelete(
|
|
171
|
+
paramsOrFirst: { tokenId: string } | string
|
|
172
|
+
): Promise<{}> {
|
|
173
|
+
let params: { tokenId: string };
|
|
174
|
+
|
|
175
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
176
|
+
params = (paramsOrFirst || {}) as { tokenId: string };
|
|
177
|
+
} else {
|
|
178
|
+
params = {
|
|
179
|
+
tokenId: paramsOrFirst as string
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const tokenId = params.tokenId;
|
|
184
|
+
|
|
185
|
+
if (typeof tokenId === 'undefined') {
|
|
186
|
+
throw new RevenexxException('Missing required parameter: "tokenId"');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const apiPath = '/v1/tokens/{tokenId}'.replace('{tokenId}', tokenId);
|
|
190
|
+
const payload: Payload = {};
|
|
191
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
192
|
+
|
|
193
|
+
const apiHeaders: { [header: string]: string } = {
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return this.client.call(
|
|
197
|
+
'delete',
|
|
198
|
+
uri,
|
|
199
|
+
apiHeaders,
|
|
200
|
+
payload
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Get a token by its unique ID.
|
|
206
|
+
*
|
|
207
|
+
* @param {string} params.tokenId - Token ID.
|
|
208
|
+
* @throws {RevenexxException}
|
|
209
|
+
* @returns {Promise<Models.ResourceToken>}
|
|
210
|
+
*/
|
|
211
|
+
tokensGet(params: { tokenId: string }): Promise<Models.ResourceToken>;
|
|
212
|
+
/**
|
|
213
|
+
* Get a token by its unique ID.
|
|
214
|
+
*
|
|
215
|
+
* @param {string} tokenId - Token ID.
|
|
216
|
+
* @throws {RevenexxException}
|
|
217
|
+
* @returns {Promise<Models.ResourceToken>}
|
|
218
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
219
|
+
*/
|
|
220
|
+
tokensGet(tokenId: string): Promise<Models.ResourceToken>;
|
|
221
|
+
tokensGet(
|
|
222
|
+
paramsOrFirst: { tokenId: string } | string
|
|
223
|
+
): Promise<Models.ResourceToken> {
|
|
224
|
+
let params: { tokenId: string };
|
|
225
|
+
|
|
226
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
227
|
+
params = (paramsOrFirst || {}) as { tokenId: string };
|
|
228
|
+
} else {
|
|
229
|
+
params = {
|
|
230
|
+
tokenId: paramsOrFirst as string
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const tokenId = params.tokenId;
|
|
235
|
+
|
|
236
|
+
if (typeof tokenId === 'undefined') {
|
|
237
|
+
throw new RevenexxException('Missing required parameter: "tokenId"');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const apiPath = '/v1/tokens/{tokenId}'.replace('{tokenId}', tokenId);
|
|
241
|
+
const payload: Payload = {};
|
|
242
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
243
|
+
|
|
244
|
+
const apiHeaders: { [header: string]: string } = {
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return this.client.call(
|
|
248
|
+
'get',
|
|
249
|
+
uri,
|
|
250
|
+
apiHeaders,
|
|
251
|
+
payload
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Update a token by its unique ID. Use this endpoint to update a token's expiry date.
|
|
257
|
+
*
|
|
258
|
+
* @param {string} params.tokenId - Token unique ID.
|
|
259
|
+
* @param {string} params.expire - File token expiry date
|
|
260
|
+
* @throws {RevenexxException}
|
|
261
|
+
* @returns {Promise<Models.ResourceToken>}
|
|
262
|
+
*/
|
|
263
|
+
tokensUpdate(params: { tokenId: string, expire?: string }): Promise<Models.ResourceToken>;
|
|
264
|
+
/**
|
|
265
|
+
* Update a token by its unique ID. Use this endpoint to update a token's expiry date.
|
|
266
|
+
*
|
|
267
|
+
* @param {string} tokenId - Token unique ID.
|
|
268
|
+
* @param {string} expire - File token expiry date
|
|
269
|
+
* @throws {RevenexxException}
|
|
270
|
+
* @returns {Promise<Models.ResourceToken>}
|
|
271
|
+
* @deprecated Use the object parameter style method for a better developer experience.
|
|
272
|
+
*/
|
|
273
|
+
tokensUpdate(tokenId: string, expire?: string): Promise<Models.ResourceToken>;
|
|
274
|
+
tokensUpdate(
|
|
275
|
+
paramsOrFirst: { tokenId: string, expire?: string } | string,
|
|
276
|
+
...rest: [(string)?]
|
|
277
|
+
): Promise<Models.ResourceToken> {
|
|
278
|
+
let params: { tokenId: string, expire?: string };
|
|
279
|
+
|
|
280
|
+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
|
|
281
|
+
params = (paramsOrFirst || {}) as { tokenId: string, expire?: string };
|
|
282
|
+
} else {
|
|
283
|
+
params = {
|
|
284
|
+
tokenId: paramsOrFirst as string,
|
|
285
|
+
expire: rest[0] as string
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const tokenId = params.tokenId;
|
|
290
|
+
const expire = params.expire;
|
|
291
|
+
|
|
292
|
+
if (typeof tokenId === 'undefined') {
|
|
293
|
+
throw new RevenexxException('Missing required parameter: "tokenId"');
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const apiPath = '/v1/tokens/{tokenId}'.replace('{tokenId}', tokenId);
|
|
297
|
+
const payload: Payload = {};
|
|
298
|
+
if (typeof expire !== 'undefined') {
|
|
299
|
+
payload['expire'] = expire;
|
|
300
|
+
}
|
|
301
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
302
|
+
|
|
303
|
+
const apiHeaders: { [header: string]: string } = {
|
|
304
|
+
'content-type': 'application/json',
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return this.client.call(
|
|
308
|
+
'patch',
|
|
309
|
+
uri,
|
|
310
|
+
apiHeaders,
|
|
311
|
+
payload
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
interface Database {
|
|
2
|
+
_db: any;
|
|
3
|
+
}
|
|
4
|
+
interface Collection {
|
|
5
|
+
_coll: any;
|
|
6
|
+
}
|
|
7
|
+
interface Document {
|
|
8
|
+
_doc: any;
|
|
9
|
+
}
|
|
10
|
+
interface TablesDB {
|
|
11
|
+
_tdb: any;
|
|
12
|
+
}
|
|
13
|
+
interface Table {
|
|
14
|
+
_tbl: any;
|
|
15
|
+
}
|
|
16
|
+
interface Row {
|
|
17
|
+
_row: any;
|
|
18
|
+
}
|
|
19
|
+
interface Bucket {
|
|
20
|
+
_bkt: any;
|
|
21
|
+
}
|
|
22
|
+
interface File {
|
|
23
|
+
_file: any;
|
|
24
|
+
}
|
|
25
|
+
interface Func {
|
|
26
|
+
_fn: any;
|
|
27
|
+
}
|
|
28
|
+
interface Execution {
|
|
29
|
+
_exec: any;
|
|
30
|
+
}
|
|
31
|
+
interface Team {
|
|
32
|
+
_team: any;
|
|
33
|
+
}
|
|
34
|
+
interface Membership {
|
|
35
|
+
_mem: any;
|
|
36
|
+
}
|
|
37
|
+
interface Resolved {
|
|
38
|
+
_res: any;
|
|
39
|
+
}
|
|
40
|
+
type Actionable = Document | Row | File | Team | Membership;
|
|
41
|
+
export declare class Channel<T> {
|
|
42
|
+
private readonly segments;
|
|
43
|
+
_type: T;
|
|
44
|
+
private constructor();
|
|
45
|
+
private next;
|
|
46
|
+
private resolve;
|
|
47
|
+
toString(): string;
|
|
48
|
+
collection(this: Channel<Database>, id: string): Channel<Collection>;
|
|
49
|
+
document(this: Channel<Collection>, id?: string): Channel<Document>;
|
|
50
|
+
table(this: Channel<TablesDB>, id: string): Channel<Table>;
|
|
51
|
+
row(this: Channel<Table>, id?: string): Channel<Row>;
|
|
52
|
+
file(this: Channel<Bucket>, id?: string): Channel<File>;
|
|
53
|
+
create(this: Channel<Actionable>): Channel<Resolved>;
|
|
54
|
+
upsert(this: Channel<Document | Row>): Channel<Resolved>;
|
|
55
|
+
update(this: Channel<Actionable>): Channel<Resolved>;
|
|
56
|
+
delete(this: Channel<Actionable>): Channel<Resolved>;
|
|
57
|
+
static database(id: string): Channel<Database>;
|
|
58
|
+
static execution(id: string): Channel<Execution>;
|
|
59
|
+
static tablesdb(id: string): Channel<TablesDB>;
|
|
60
|
+
static bucket(id: string): Channel<Bucket>;
|
|
61
|
+
static function(id: string): Channel<Func>;
|
|
62
|
+
static team(id: string): Channel<Team>;
|
|
63
|
+
static membership(id: string): Channel<Membership>;
|
|
64
|
+
static account(): string;
|
|
65
|
+
static documents(): string;
|
|
66
|
+
static rows(): string;
|
|
67
|
+
static files(): string;
|
|
68
|
+
static executions(): string;
|
|
69
|
+
static teams(): string;
|
|
70
|
+
static memberships(): string;
|
|
71
|
+
}
|
|
72
|
+
export type ActionableChannel = Channel<Document> | Channel<Row> | Channel<File> | Channel<Execution> | Channel<Team> | Channel<Membership>;
|
|
73
|
+
export type ResolvedChannel = Channel<Resolved>;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { Models } from './models';
|
|
2
|
+
import { Channel, ActionableChannel, ResolvedChannel } from './channel';
|
|
3
|
+
import { Query } from './query';
|
|
4
|
+
/**
|
|
5
|
+
* Payload type representing a key-value pair with string keys and any values.
|
|
6
|
+
*/
|
|
7
|
+
type Payload = {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Headers type representing a key-value pair with string keys and string values.
|
|
12
|
+
*/
|
|
13
|
+
type Headers = {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Realtime event response structure with generic payload type.
|
|
18
|
+
*/
|
|
19
|
+
type RealtimeResponseEvent<T extends unknown> = {
|
|
20
|
+
/**
|
|
21
|
+
* List of event names associated with the response.
|
|
22
|
+
*/
|
|
23
|
+
events: string[];
|
|
24
|
+
/**
|
|
25
|
+
* List of channel names associated with the response.
|
|
26
|
+
*/
|
|
27
|
+
channels: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Timestamp indicating the time of the event.
|
|
30
|
+
*/
|
|
31
|
+
timestamp: string;
|
|
32
|
+
/**
|
|
33
|
+
* Payload containing event-specific data.
|
|
34
|
+
*/
|
|
35
|
+
payload: T;
|
|
36
|
+
/**
|
|
37
|
+
* Subscription IDs this event matches (from backend, optional).
|
|
38
|
+
*/
|
|
39
|
+
subscriptions?: string[];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Type representing upload progress information.
|
|
43
|
+
*/
|
|
44
|
+
type UploadProgress = {
|
|
45
|
+
/**
|
|
46
|
+
* Identifier for the upload progress.
|
|
47
|
+
*/
|
|
48
|
+
$id: string;
|
|
49
|
+
/**
|
|
50
|
+
* Current progress of the upload (in percentage).
|
|
51
|
+
*/
|
|
52
|
+
progress: number;
|
|
53
|
+
/**
|
|
54
|
+
* Total size uploaded (in bytes) during the upload process.
|
|
55
|
+
*/
|
|
56
|
+
sizeUploaded: number;
|
|
57
|
+
/**
|
|
58
|
+
* Total number of chunks that need to be uploaded.
|
|
59
|
+
*/
|
|
60
|
+
chunksTotal: number;
|
|
61
|
+
/**
|
|
62
|
+
* Number of chunks that have been successfully uploaded.
|
|
63
|
+
*/
|
|
64
|
+
chunksUploaded: number;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Exception thrown by the package
|
|
68
|
+
*/
|
|
69
|
+
declare class RevenexxException extends Error {
|
|
70
|
+
/**
|
|
71
|
+
* The error code associated with the exception.
|
|
72
|
+
*/
|
|
73
|
+
code: number;
|
|
74
|
+
/**
|
|
75
|
+
* The response string associated with the exception.
|
|
76
|
+
*/
|
|
77
|
+
response: string;
|
|
78
|
+
/**
|
|
79
|
+
* Error type.
|
|
80
|
+
* See [Error Types](https://revenexx.com/docs/response-codes#errorTypes) for more information.
|
|
81
|
+
*/
|
|
82
|
+
type: string;
|
|
83
|
+
/**
|
|
84
|
+
* Initializes a Revenexx Exception.
|
|
85
|
+
*
|
|
86
|
+
* @param {string} message - The error message.
|
|
87
|
+
* @param {number} code - The error code. Default is 0.
|
|
88
|
+
* @param {string} type - The error type. Default is an empty string.
|
|
89
|
+
* @param {string} response - The response string. Default is an empty string.
|
|
90
|
+
*/
|
|
91
|
+
constructor(message: string, code?: number, type?: string, response?: string);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Client that handles requests to Revenexx
|
|
95
|
+
*/
|
|
96
|
+
declare class Client {
|
|
97
|
+
static CHUNK_SIZE: number;
|
|
98
|
+
/**
|
|
99
|
+
* Holds configuration such as project.
|
|
100
|
+
*/
|
|
101
|
+
config: {
|
|
102
|
+
endpoint: string;
|
|
103
|
+
endpointRealtime: string;
|
|
104
|
+
tenant: string;
|
|
105
|
+
apikeyauth: string;
|
|
106
|
+
bearerauth: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Custom headers for API requests.
|
|
110
|
+
*/
|
|
111
|
+
headers: Headers;
|
|
112
|
+
/**
|
|
113
|
+
* Set Endpoint
|
|
114
|
+
*
|
|
115
|
+
* Your project endpoint
|
|
116
|
+
*
|
|
117
|
+
* @param {string} endpoint
|
|
118
|
+
*
|
|
119
|
+
* @returns {this}
|
|
120
|
+
*/
|
|
121
|
+
setEndpoint(endpoint: string): this;
|
|
122
|
+
/**
|
|
123
|
+
* Set Realtime Endpoint
|
|
124
|
+
*
|
|
125
|
+
* @param {string} endpointRealtime
|
|
126
|
+
*
|
|
127
|
+
* @returns {this}
|
|
128
|
+
*/
|
|
129
|
+
setEndpointRealtime(endpointRealtime: string): this;
|
|
130
|
+
/**
|
|
131
|
+
* Set Tenant
|
|
132
|
+
*
|
|
133
|
+
* The tenant slug your requests are scoped to, sent as the
|
|
134
|
+
* X-Revenexx-Tenant header on every request.
|
|
135
|
+
*
|
|
136
|
+
* @param value string
|
|
137
|
+
*
|
|
138
|
+
* @return {this}
|
|
139
|
+
*/
|
|
140
|
+
setTenant(value: string): this;
|
|
141
|
+
/**
|
|
142
|
+
* Set ApiKeyAuth
|
|
143
|
+
*
|
|
144
|
+
* A gateway-managed scoped API key (rvxk_…).
|
|
145
|
+
*
|
|
146
|
+
* @param value string
|
|
147
|
+
*
|
|
148
|
+
* @return {this}
|
|
149
|
+
*/
|
|
150
|
+
setApiKeyAuth(value: string): this;
|
|
151
|
+
/**
|
|
152
|
+
* Set BearerAuth
|
|
153
|
+
*
|
|
154
|
+
* A Zitadel-issued JWT (Cockpit / interactive callers).
|
|
155
|
+
*
|
|
156
|
+
* @param value string
|
|
157
|
+
*
|
|
158
|
+
* @return {this}
|
|
159
|
+
*/
|
|
160
|
+
setBearerAuth(value: string): this;
|
|
161
|
+
private realtime;
|
|
162
|
+
/**
|
|
163
|
+
* Subscribes to Revenexx events and passes you the payload in realtime.
|
|
164
|
+
*
|
|
165
|
+
* @deprecated Use the Realtime service instead.
|
|
166
|
+
* @see Realtime
|
|
167
|
+
*
|
|
168
|
+
* @param {string|string[]|Channel<any>|ActionableChannel|ResolvedChannel|(Channel<any>|ActionableChannel|ResolvedChannel)[]} channels
|
|
169
|
+
* Channel to subscribe - pass a single channel as a string or Channel builder instance, or multiple with an array.
|
|
170
|
+
*
|
|
171
|
+
* Possible channels are:
|
|
172
|
+
* - account
|
|
173
|
+
* - collections
|
|
174
|
+
* - collections.[ID]
|
|
175
|
+
* - collections.[ID].documents
|
|
176
|
+
* - documents
|
|
177
|
+
* - documents.[ID]
|
|
178
|
+
* - files
|
|
179
|
+
* - files.[ID]
|
|
180
|
+
* - executions
|
|
181
|
+
* - executions.[ID]
|
|
182
|
+
* - functions.[ID]
|
|
183
|
+
* - teams
|
|
184
|
+
* - teams.[ID]
|
|
185
|
+
* - memberships
|
|
186
|
+
* - memberships.[ID]
|
|
187
|
+
*
|
|
188
|
+
* You can also use Channel builders:
|
|
189
|
+
* - Channel.database('db').collection('col').document('doc').create()
|
|
190
|
+
* - Channel.bucket('bucket').file('file').update()
|
|
191
|
+
* - Channel.function('func').execution('exec').delete()
|
|
192
|
+
* - Channel.team('team').create()
|
|
193
|
+
* - Channel.membership('membership').update()
|
|
194
|
+
* @param {(payload: RealtimeMessage) => void} callback Is called on every realtime update.
|
|
195
|
+
* @returns {() => void} Unsubscribes from events.
|
|
196
|
+
*/
|
|
197
|
+
subscribe<T extends unknown>(channels: string | string[] | Channel<any> | ActionableChannel | ResolvedChannel | (Channel<any> | ActionableChannel | ResolvedChannel)[], callback: (payload: RealtimeResponseEvent<T>) => void, queries?: (string | Query)[]): () => void;
|
|
198
|
+
prepareRequest(method: string, url: URL, headers?: Headers, params?: Payload): {
|
|
199
|
+
uri: string;
|
|
200
|
+
options: RequestInit;
|
|
201
|
+
};
|
|
202
|
+
chunkedUpload(method: string, url: URL, headers: Headers | undefined, originalPayload: Payload | undefined, onProgress: (progress: UploadProgress) => void): Promise<any>;
|
|
203
|
+
ping(): Promise<string>;
|
|
204
|
+
call(method: string, url: URL, headers?: Headers, params?: Payload, responseType?: string): Promise<any>;
|
|
205
|
+
static flatten(data: Payload, prefix?: string): Payload;
|
|
206
|
+
}
|
|
207
|
+
export { Client, RevenexxException };
|
|
208
|
+
export { Query } from './query';
|
|
209
|
+
export type { Models, Payload, UploadProgress };
|
|
210
|
+
export type { RealtimeResponseEvent };
|
|
211
|
+
export type { QueryTypes, QueryTypesList } from './query';
|