@appwrite.io/console 1.7.0 → 1.9.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.
Files changed (73) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/sdk.js +330 -27
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +331 -28
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/dist/iife/sdk.js +330 -27
  7. package/docs/examples/databases/decrement-document-attribute.md +18 -0
  8. package/docs/examples/databases/increment-document-attribute.md +18 -0
  9. package/docs/examples/databases/upsert-document.md +17 -0
  10. package/docs/examples/databases/upsert-documents.md +1 -1
  11. package/docs/examples/domains/create-record-a-a-a-a.md +1 -1
  12. package/docs/examples/domains/create-record-a.md +1 -1
  13. package/docs/examples/domains/create-record-alias.md +1 -1
  14. package/docs/examples/domains/create-record-c-a-a.md +1 -1
  15. package/docs/examples/domains/create-record-c-n-a-m-e.md +1 -1
  16. package/docs/examples/domains/create-record-h-t-t-p-s.md +1 -1
  17. package/docs/examples/domains/create-record-m-x.md +1 -1
  18. package/docs/examples/domains/create-record-n-s.md +1 -1
  19. package/docs/examples/domains/create-record-s-r-v.md +1 -1
  20. package/docs/examples/domains/create-record-t-x-t.md +1 -1
  21. package/docs/examples/domains/update-record-a-a-a-a.md +1 -1
  22. package/docs/examples/domains/update-record-a.md +1 -1
  23. package/docs/examples/domains/update-record-alias.md +1 -1
  24. package/docs/examples/domains/update-record-c-a-a.md +1 -1
  25. package/docs/examples/domains/update-record-c-n-a-m-e.md +1 -1
  26. package/docs/examples/domains/update-record-h-t-t-p-s.md +1 -1
  27. package/docs/examples/domains/update-record-m-x.md +1 -1
  28. package/docs/examples/domains/update-record-n-s.md +1 -1
  29. package/docs/examples/domains/update-record-s-r-v.md +1 -1
  30. package/docs/examples/domains/update-record-t-x-t.md +1 -1
  31. package/docs/examples/functions/create.md +1 -5
  32. package/docs/examples/health/{get-queue-stats-usage-dump.md → get-queue-billing-project-aggregation.md} +2 -2
  33. package/docs/examples/health/{get-queue-billing-aggregation.md → get-queue-billing-team-aggregation.md} +1 -1
  34. package/docs/examples/organizations/cancel-downgrade.md +13 -0
  35. package/docs/examples/organizations/estimation-create-organization.md +16 -0
  36. package/docs/examples/organizations/estimation-delete-organization.md +13 -0
  37. package/docs/examples/organizations/estimation-update-plan.md +16 -0
  38. package/docs/examples/organizations/get-usage.md +1 -1
  39. package/docs/examples/organizations/validate-payment.md +14 -0
  40. package/docs/examples/proxy/create-redirect-rule.md +4 -2
  41. package/package.json +1 -1
  42. package/src/client.ts +9 -5
  43. package/src/enums/build-runtime.ts +2 -0
  44. package/src/enums/image-format.ts +1 -0
  45. package/src/enums/proxy-resource-type.ts +4 -0
  46. package/src/enums/runtime.ts +2 -0
  47. package/src/index.ts +1 -0
  48. package/src/models.ts +284 -2
  49. package/src/services/databases.ts +141 -1
  50. package/src/services/functions.ts +1 -17
  51. package/src/services/health.ts +28 -3
  52. package/src/services/organizations.ts +197 -0
  53. package/src/services/proxy.ts +16 -1
  54. package/src/services/tokens.ts +1 -1
  55. package/types/enums/build-runtime.d.ts +3 -1
  56. package/types/enums/image-format.d.ts +2 -1
  57. package/types/enums/proxy-resource-type.d.ts +4 -0
  58. package/types/enums/runtime.d.ts +3 -1
  59. package/types/index.d.ts +1 -0
  60. package/types/models.d.ts +284 -2
  61. package/types/services/databases.d.ts +39 -1
  62. package/types/services/functions.d.ts +1 -5
  63. package/types/services/health.d.ts +10 -2
  64. package/types/services/organizations.d.ts +57 -0
  65. package/types/services/proxy.d.ts +4 -1
  66. package/types/services/tokens.d.ts +1 -1
  67. package/docs/examples/functions/create-build.md +0 -15
  68. package/docs/examples/functions/get-function-usage.md +0 -14
  69. package/docs/examples/functions/update-deployment-build.md +0 -14
  70. package/docs/examples/functions/update-deployment.md +0 -14
  71. package/docs/examples/proxy/create-rule.md +0 -15
  72. package/src/enums/resource-type.ts +0 -4
  73. package/types/enums/resource-type.d.ts +0 -4
@@ -478,7 +478,7 @@ export declare class Databases {
478
478
  * @throws {AppwriteException}
479
479
  * @returns {Promise<Models.DocumentList<Document>>}
480
480
  */
481
- upsertDocuments<Document extends Models.Document>(databaseId: string, collectionId: string, documents?: object[]): Promise<Models.DocumentList<Document>>;
481
+ upsertDocuments<Document extends Models.Document>(databaseId: string, collectionId: string, documents: object[]): Promise<Models.DocumentList<Document>>;
482
482
  /**
483
483
  * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated.
484
484
  *
@@ -511,6 +511,18 @@ export declare class Databases {
511
511
  * @returns {Promise<Document>}
512
512
  */
513
513
  getDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Document>;
514
+ /**
515
+ * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
516
+ *
517
+ * @param {string} databaseId
518
+ * @param {string} collectionId
519
+ * @param {string} documentId
520
+ * @param {object} data
521
+ * @param {string[]} permissions
522
+ * @throws {AppwriteException}
523
+ * @returns {Promise<Document>}
524
+ */
525
+ upsertDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise<Document>;
514
526
  /**
515
527
  * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
516
528
  *
@@ -544,6 +556,32 @@ export declare class Databases {
544
556
  * @returns {Promise<Models.LogList>}
545
557
  */
546
558
  listDocumentLogs(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Models.LogList>;
559
+ /**
560
+ * Decrement a specific attribute of a document by a given value.
561
+ *
562
+ * @param {string} databaseId
563
+ * @param {string} collectionId
564
+ * @param {string} documentId
565
+ * @param {string} attribute
566
+ * @param {number} value
567
+ * @param {number} min
568
+ * @throws {AppwriteException}
569
+ * @returns {Promise<Document>}
570
+ */
571
+ decrementDocumentAttribute<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number): Promise<Document>;
572
+ /**
573
+ * Increment a specific attribute of a document by a given value.
574
+ *
575
+ * @param {string} databaseId
576
+ * @param {string} collectionId
577
+ * @param {string} documentId
578
+ * @param {string} attribute
579
+ * @param {number} value
580
+ * @param {number} max
581
+ * @throws {AppwriteException}
582
+ * @returns {Promise<Document>}
583
+ */
584
+ incrementDocumentAttribute<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number): Promise<Document>;
547
585
  /**
548
586
  * List indexes in the collection.
549
587
  *
@@ -38,14 +38,10 @@ export declare class Functions {
38
38
  * @param {boolean} providerSilentMode
39
39
  * @param {string} providerRootDirectory
40
40
  * @param {string} specification
41
- * @param {string} templateRepository
42
- * @param {string} templateOwner
43
- * @param {string} templateRootDirectory
44
- * @param {string} templateVersion
45
41
  * @throws {AppwriteException}
46
42
  * @returns {Promise<Models.Function>}
47
43
  */
48
- create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string, templateRepository?: string, templateOwner?: string, templateRootDirectory?: string, templateVersion?: string): Promise<Models.Function>;
44
+ create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Function>;
49
45
  /**
50
46
  * Get a list of all runtimes that are currently active on your instance.
51
47
  *
@@ -48,13 +48,21 @@ export declare class Health {
48
48
  */
49
49
  getPubSub(): Promise<Models.HealthStatus>;
50
50
  /**
51
- * Get billing aggregation queue
51
+ * Get billing project aggregation queue
52
52
  *
53
53
  * @param {number} threshold
54
54
  * @throws {AppwriteException}
55
55
  * @returns {Promise<Models.HealthQueue>}
56
56
  */
57
- getQueueBillingAggregation(threshold?: number): Promise<Models.HealthQueue>;
57
+ getQueueBillingProjectAggregation(threshold?: number): Promise<Models.HealthQueue>;
58
+ /**
59
+ * Get billing team aggregation queue
60
+ *
61
+ * @param {number} threshold
62
+ * @throws {AppwriteException}
63
+ * @returns {Promise<Models.HealthQueue>}
64
+ */
65
+ getQueueBillingTeamAggregation(threshold?: number): Promise<Models.HealthQueue>;
58
66
  /**
59
67
  * Get the number of builds that are waiting to be processed in the Appwrite internal queue server.
60
68
  *
@@ -30,6 +30,17 @@ export declare class Organizations {
30
30
  * @returns {Promise<Models.Organization<Preferences>>}
31
31
  */
32
32
  create<Preferences extends Models.Preferences>(organizationId: string, name: string, billingPlan: BillingPlan, paymentMethodId?: string, billingAddressId?: string, invites?: string[], couponId?: string, taxId?: string, budget?: number): Promise<Models.Organization<Preferences>>;
33
+ /**
34
+ * Get estimation for creating an organization.
35
+ *
36
+ * @param {BillingPlan} billingPlan
37
+ * @param {string} paymentMethodId
38
+ * @param {string[]} invites
39
+ * @param {string} couponId
40
+ * @throws {AppwriteException}
41
+ * @returns {Promise<Models.Estimation>}
42
+ */
43
+ estimationCreateOrganization(billingPlan: BillingPlan, paymentMethodId?: string, invites?: string[], couponId?: string): Promise<Models.Estimation>;
33
44
  /**
34
45
  * Delete an organization.
35
46
  *
@@ -129,6 +140,25 @@ export declare class Organizations {
129
140
  * @returns {Promise<Models.Credit>}
130
141
  */
131
142
  getCredit(organizationId: string, creditId: string): Promise<Models.Credit>;
143
+ /**
144
+ * Get estimation for deleting an organization.
145
+ *
146
+ * @param {string} organizationId
147
+ * @throws {AppwriteException}
148
+ * @returns {Promise<Models.EstimationDeleteOrganization>}
149
+ */
150
+ estimationDeleteOrganization(organizationId: string): Promise<Models.EstimationDeleteOrganization>;
151
+ /**
152
+ * Get estimation for updating the organization plan.
153
+ *
154
+ * @param {string} organizationId
155
+ * @param {BillingPlan} billingPlan
156
+ * @param {string[]} invites
157
+ * @param {string} couponId
158
+ * @throws {AppwriteException}
159
+ * @returns {Promise<Models.EstimationUpdatePlan>}
160
+ */
161
+ estimationUpdatePlan(organizationId: string, billingPlan: BillingPlan, invites?: string[], couponId?: string): Promise<Models.EstimationUpdatePlan>;
132
162
  /**
133
163
  * List all invoices for an organization.
134
164
  *
@@ -251,6 +281,14 @@ export declare class Organizations {
251
281
  * @returns {Promise<Models.Organization<Preferences>>}
252
282
  */
253
283
  updatePlan<Preferences extends Models.Preferences>(organizationId: string, billingPlan: BillingPlan, paymentMethodId?: string, billingAddressId?: string, invites?: string[], couponId?: string, taxId?: string, budget?: number): Promise<Models.Organization<Preferences>>;
284
+ /**
285
+ * Cancel the downgrade initiated for an organization.
286
+ *
287
+ * @param {string} organizationId
288
+ * @throws {AppwriteException}
289
+ * @returns {Promise<Models.Organization<Preferences>>}
290
+ */
291
+ cancelDowngrade<Preferences extends Models.Preferences>(organizationId: string): Promise<Models.Organization<Preferences>>;
254
292
  /**
255
293
  * Get Scopes
256
294
  *
@@ -268,4 +306,23 @@ export declare class Organizations {
268
306
  * @returns {Promise<Models.Organization<Preferences>>}
269
307
  */
270
308
  setBillingTaxId<Preferences extends Models.Preferences>(organizationId: string, taxId: string): Promise<Models.Organization<Preferences>>;
309
+ /**
310
+ * Get the usage data for an organization.
311
+ *
312
+ * @param {string} organizationId
313
+ * @param {string} startDate
314
+ * @param {string} endDate
315
+ * @throws {AppwriteException}
316
+ * @returns {Promise<Models.UsageOrganization>}
317
+ */
318
+ getUsage(organizationId: string, startDate?: string, endDate?: string): Promise<Models.UsageOrganization>;
319
+ /**
320
+ * Validate payment for team after creation or upgrade.
321
+ *
322
+ * @param {string} organizationId
323
+ * @param {string[]} invites
324
+ * @throws {AppwriteException}
325
+ * @returns {Promise<Models.Organization<Preferences>>}
326
+ */
327
+ validatePayment<Preferences extends Models.Preferences>(organizationId: string, invites?: string[]): Promise<Models.Organization<Preferences>>;
271
328
  }
@@ -1,6 +1,7 @@
1
1
  import { Client } from '../client';
2
2
  import type { Models } from '../models';
3
3
  import { StatusCode } from '../enums/status-code';
4
+ import { ProxyResourceType } from '../enums/proxy-resource-type';
4
5
  export declare class Proxy {
5
6
  client: Client;
6
7
  constructor(client: Client);
@@ -37,10 +38,12 @@ export declare class Proxy {
37
38
  * @param {string} domain
38
39
  * @param {string} url
39
40
  * @param {StatusCode} statusCode
41
+ * @param {string} resourceId
42
+ * @param {ProxyResourceType} resourceType
40
43
  * @throws {AppwriteException}
41
44
  * @returns {Promise<Models.ProxyRule>}
42
45
  */
43
- createRedirectRule(domain: string, url: string, statusCode: StatusCode): Promise<Models.ProxyRule>;
46
+ createRedirectRule(domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType): Promise<Models.ProxyRule>;
44
47
  /**
45
48
  * Create a new proxy rule for serving Appwrite Site on custom domain.
46
49
  *
@@ -14,7 +14,7 @@ export declare class Tokens {
14
14
  */
15
15
  list(bucketId: string, fileId: string, queries?: string[]): Promise<Models.ResourceTokenList>;
16
16
  /**
17
- * Create a new token. A token is linked to a file. Token can be passed as a header or request get parameter.
17
+ * Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter.
18
18
  *
19
19
  * @param {string} bucketId
20
20
  * @param {string} fileId
@@ -1,15 +0,0 @@
1
- import { Client, Functions } from "@appwrite.io/console";
2
-
3
- const client = new Client()
4
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
-
7
- const functions = new Functions(client);
8
-
9
- const result = await functions.createBuild(
10
- '<FUNCTION_ID>', // functionId
11
- '<DEPLOYMENT_ID>', // deploymentId
12
- '<BUILD_ID>' // buildId (optional)
13
- );
14
-
15
- console.log(result);
@@ -1,14 +0,0 @@
1
- import { Client, Functions, FunctionUsageRange } from "@appwrite.io/console";
2
-
3
- const client = new Client()
4
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
-
7
- const functions = new Functions(client);
8
-
9
- const result = await functions.getFunctionUsage(
10
- '<FUNCTION_ID>', // functionId
11
- FunctionUsageRange.TwentyFourHours // range (optional)
12
- );
13
-
14
- console.log(result);
@@ -1,14 +0,0 @@
1
- import { Client, Functions } from "@appwrite.io/console";
2
-
3
- const client = new Client()
4
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
-
7
- const functions = new Functions(client);
8
-
9
- const result = await functions.updateDeploymentBuild(
10
- '<FUNCTION_ID>', // functionId
11
- '<DEPLOYMENT_ID>' // deploymentId
12
- );
13
-
14
- console.log(result);
@@ -1,14 +0,0 @@
1
- import { Client, Functions } from "@appwrite.io/console";
2
-
3
- const client = new Client()
4
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
-
7
- const functions = new Functions(client);
8
-
9
- const result = await functions.updateDeployment(
10
- '<FUNCTION_ID>', // functionId
11
- '<DEPLOYMENT_ID>' // deploymentId
12
- );
13
-
14
- console.log(result);
@@ -1,15 +0,0 @@
1
- import { Client, Proxy, } from "@appwrite.io/console";
2
-
3
- const client = new Client()
4
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5
- .setProject('<YOUR_PROJECT_ID>'); // Your project ID
6
-
7
- const proxy = new Proxy(client);
8
-
9
- const result = await proxy.createRule(
10
- '', // domain
11
- .Api, // resourceType
12
- '<RESOURCE_ID>' // resourceId (optional)
13
- );
14
-
15
- console.log(result);
@@ -1,4 +0,0 @@
1
- export enum ResourceType {
2
- Api = 'api',
3
- Function = 'function',
4
- }
@@ -1,4 +0,0 @@
1
- export declare enum ResourceType {
2
- Api = "api",
3
- Function = "function"
4
- }