Skip to content

Commit 6d2ff1c

Browse files
authored
Merge pull request #143 from appwrite/dev
feat: Node.js SDK update for version 22.1.2
2 parents 4e282f2 + 78b1f9d commit 6d2ff1c

File tree

12 files changed

+226
-128
lines changed

12 files changed

+226
-128
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Change Log
22

3+
## 22.2.0
4+
5+
* Added ttl option to listDocuments for cached responses
6+
* Added getConsolePausing health status endpoint in Health service
7+
* Added Health.getConsolePausing overloads (object and positional)
8+
* Added updateRelationshipAttribute for Databases to manage relationship attributes
9+
* Added console pausing example to health docs
10+
* Made activate optional in createDeployment object parameter
11+
312
## 22.1.2
413

514
* Fix very large double values (for example 1.7976931348623157e+308) from being expanded into giant integer literals

docs/examples/databases/list-documents.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const result = await databases.listDocuments({
1313
collectionId: '<COLLECTION_ID>',
1414
queries: [], // optional
1515
transactionId: '<TRANSACTION_ID>', // optional
16-
total: false // optional
16+
total: false, // optional
17+
ttl: 0 // optional
1718
});
1819
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```javascript
2+
const sdk = require('node-appwrite');
3+
4+
const client = new sdk.Client()
5+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
6+
.setProject('<YOUR_PROJECT_ID>') // Your project ID
7+
.setKey('<YOUR_API_KEY>'); // Your secret API key
8+
9+
const health = new sdk.Health(client);
10+
11+
const result = await health.getConsolePausing({
12+
threshold: null, // optional
13+
inactivityDays: null // optional
14+
});
15+
```

docs/examples/sites/create-deployment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const sites = new sdk.Sites(client);
1212
const result = await sites.createDeployment({
1313
siteId: '<SITE_ID>',
1414
code: InputFile.fromPath('/path/to/file', 'filename'),
15-
activate: false,
1615
installCommand: '<INSTALL_COMMAND>', // optional
1716
buildCommand: '<BUILD_COMMAND>', // optional
18-
outputDirectory: '<OUTPUT_DIRECTORY>' // optional
17+
outputDirectory: '<OUTPUT_DIRECTORY>', // optional
18+
activate: false // optional
1919
});
2020
```

docs/examples/tablesdb/list-rows.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const result = await tablesDB.listRows({
1313
tableId: '<TABLE_ID>',
1414
queries: [], // optional
1515
transactionId: '<TRANSACTION_ID>', // optional
16-
total: false // optional
16+
total: false, // optional
17+
ttl: 0 // optional
1718
});
1819
```

src/models.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,7 +2413,7 @@ export namespace Models {
24132413
*/
24142414
$id: string;
24152415
/**
2416-
* Row automatically incrementing ID.
2416+
* Row sequence ID.
24172417
*/
24182418
$sequence: number;
24192419
/**
@@ -2452,7 +2452,7 @@ export namespace Models {
24522452
*/
24532453
$id: string;
24542454
/**
2455-
* Document automatically incrementing ID.
2455+
* Document sequence ID.
24562456
*/
24572457
$sequence: number;
24582458
/**

src/services/databases.ts

Lines changed: 100 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ export class Databases {
11341134
*
11351135
*
11361136
* @param {string} params.databaseId - Database ID.
1137-
* @param {string} params.collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
1137+
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
11381138
* @param {string} params.key - Attribute Key.
11391139
* @param {boolean} params.required - Is attribute required?
11401140
* @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required.
@@ -1149,7 +1149,7 @@ export class Databases {
11491149
*
11501150
*
11511151
* @param {string} databaseId - Database ID.
1152-
* @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
1152+
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
11531153
* @param {string} key - Attribute Key.
11541154
* @param {boolean} required - Is attribute required?
11551155
* @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required.
@@ -3606,6 +3606,90 @@ export class Databases {
36063606
);
36073607
}
36083608

3609+
/**
3610+
* Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes).
3611+
*
3612+
*
3613+
* @param {string} params.databaseId - Database ID.
3614+
* @param {string} params.collectionId - Collection ID.
3615+
* @param {string} params.key - Attribute Key.
3616+
* @param {RelationMutate} params.onDelete - Constraints option
3617+
* @param {string} params.newKey - New Attribute Key.
3618+
* @throws {AppwriteException}
3619+
* @returns {Promise<Models.AttributeRelationship>}
3620+
* @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead.
3621+
*/
3622+
updateRelationshipAttribute(params: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }): Promise<Models.AttributeRelationship>;
3623+
/**
3624+
* Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes).
3625+
*
3626+
*
3627+
* @param {string} databaseId - Database ID.
3628+
* @param {string} collectionId - Collection ID.
3629+
* @param {string} key - Attribute Key.
3630+
* @param {RelationMutate} onDelete - Constraints option
3631+
* @param {string} newKey - New Attribute Key.
3632+
* @throws {AppwriteException}
3633+
* @returns {Promise<Models.AttributeRelationship>}
3634+
* @deprecated Use the object parameter style method for a better developer experience.
3635+
*/
3636+
updateRelationshipAttribute(databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise<Models.AttributeRelationship>;
3637+
updateRelationshipAttribute(
3638+
paramsOrFirst: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string } | string,
3639+
...rest: [(string)?, (string)?, (RelationMutate)?, (string)?]
3640+
): Promise<Models.AttributeRelationship> {
3641+
let params: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string };
3642+
3643+
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
3644+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string };
3645+
} else {
3646+
params = {
3647+
databaseId: paramsOrFirst as string,
3648+
collectionId: rest[0] as string,
3649+
key: rest[1] as string,
3650+
onDelete: rest[2] as RelationMutate,
3651+
newKey: rest[3] as string
3652+
};
3653+
}
3654+
3655+
const databaseId = params.databaseId;
3656+
const collectionId = params.collectionId;
3657+
const key = params.key;
3658+
const onDelete = params.onDelete;
3659+
const newKey = params.newKey;
3660+
3661+
if (typeof databaseId === 'undefined') {
3662+
throw new AppwriteException('Missing required parameter: "databaseId"');
3663+
}
3664+
if (typeof collectionId === 'undefined') {
3665+
throw new AppwriteException('Missing required parameter: "collectionId"');
3666+
}
3667+
if (typeof key === 'undefined') {
3668+
throw new AppwriteException('Missing required parameter: "key"');
3669+
}
3670+
3671+
const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
3672+
const payload: Payload = {};
3673+
if (typeof onDelete !== 'undefined') {
3674+
payload['onDelete'] = onDelete;
3675+
}
3676+
if (typeof newKey !== 'undefined') {
3677+
payload['newKey'] = newKey;
3678+
}
3679+
const uri = new URL(this.client.config.endpoint + apiPath);
3680+
3681+
const apiHeaders: { [header: string]: string } = {
3682+
'content-type': 'application/json',
3683+
}
3684+
3685+
return this.client.call(
3686+
'patch',
3687+
uri,
3688+
apiHeaders,
3689+
payload,
3690+
);
3691+
}
3692+
36093693
/**
36103694
* Create a string attribute.
36113695
*
@@ -4568,90 +4652,6 @@ export class Databases {
45684652
);
45694653
}
45704654

4571-
/**
4572-
* Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes).
4573-
*
4574-
*
4575-
* @param {string} params.databaseId - Database ID.
4576-
* @param {string} params.collectionId - Collection ID.
4577-
* @param {string} params.key - Attribute Key.
4578-
* @param {RelationMutate} params.onDelete - Constraints option
4579-
* @param {string} params.newKey - New Attribute Key.
4580-
* @throws {AppwriteException}
4581-
* @returns {Promise<Models.AttributeRelationship>}
4582-
* @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead.
4583-
*/
4584-
updateRelationshipAttribute(params: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }): Promise<Models.AttributeRelationship>;
4585-
/**
4586-
* Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes).
4587-
*
4588-
*
4589-
* @param {string} databaseId - Database ID.
4590-
* @param {string} collectionId - Collection ID.
4591-
* @param {string} key - Attribute Key.
4592-
* @param {RelationMutate} onDelete - Constraints option
4593-
* @param {string} newKey - New Attribute Key.
4594-
* @throws {AppwriteException}
4595-
* @returns {Promise<Models.AttributeRelationship>}
4596-
* @deprecated Use the object parameter style method for a better developer experience.
4597-
*/
4598-
updateRelationshipAttribute(databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise<Models.AttributeRelationship>;
4599-
updateRelationshipAttribute(
4600-
paramsOrFirst: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string } | string,
4601-
...rest: [(string)?, (string)?, (RelationMutate)?, (string)?]
4602-
): Promise<Models.AttributeRelationship> {
4603-
let params: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string };
4604-
4605-
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
4606-
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string };
4607-
} else {
4608-
params = {
4609-
databaseId: paramsOrFirst as string,
4610-
collectionId: rest[0] as string,
4611-
key: rest[1] as string,
4612-
onDelete: rest[2] as RelationMutate,
4613-
newKey: rest[3] as string
4614-
};
4615-
}
4616-
4617-
const databaseId = params.databaseId;
4618-
const collectionId = params.collectionId;
4619-
const key = params.key;
4620-
const onDelete = params.onDelete;
4621-
const newKey = params.newKey;
4622-
4623-
if (typeof databaseId === 'undefined') {
4624-
throw new AppwriteException('Missing required parameter: "databaseId"');
4625-
}
4626-
if (typeof collectionId === 'undefined') {
4627-
throw new AppwriteException('Missing required parameter: "collectionId"');
4628-
}
4629-
if (typeof key === 'undefined') {
4630-
throw new AppwriteException('Missing required parameter: "key"');
4631-
}
4632-
4633-
const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
4634-
const payload: Payload = {};
4635-
if (typeof onDelete !== 'undefined') {
4636-
payload['onDelete'] = onDelete;
4637-
}
4638-
if (typeof newKey !== 'undefined') {
4639-
payload['newKey'] = newKey;
4640-
}
4641-
const uri = new URL(this.client.config.endpoint + apiPath);
4642-
4643-
const apiHeaders: { [header: string]: string } = {
4644-
'content-type': 'application/json',
4645-
}
4646-
4647-
return this.client.call(
4648-
'patch',
4649-
uri,
4650-
apiHeaders,
4651-
payload,
4652-
);
4653-
}
4654-
46554655
/**
46564656
* Get a list of all the user's documents in a given collection. You can use the query params to filter your results.
46574657
*
@@ -4660,11 +4660,12 @@ export class Databases {
46604660
* @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.
46614661
* @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction.
46624662
* @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated.
4663+
* @param {number} params.ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours).
46634664
* @throws {AppwriteException}
46644665
* @returns {Promise<Models.DocumentList<Document>>}
46654666
* @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.
46664667
*/
4667-
listDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean }): Promise<Models.DocumentList<Document>>;
4668+
listDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise<Models.DocumentList<Document>>;
46684669
/**
46694670
* Get a list of all the user's documents in a given collection. You can use the query params to filter your results.
46704671
*
@@ -4673,26 +4674,28 @@ export class Databases {
46734674
* @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.
46744675
* @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction.
46754676
* @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated.
4677+
* @param {number} ttl - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours).
46764678
* @throws {AppwriteException}
46774679
* @returns {Promise<Models.DocumentList<Document>>}
46784680
* @deprecated Use the object parameter style method for a better developer experience.
46794681
*/
4680-
listDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean): Promise<Models.DocumentList<Document>>;
4682+
listDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise<Models.DocumentList<Document>>;
46814683
listDocuments<Document extends Models.Document = Models.DefaultDocument>(
4682-
paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean } | string,
4683-
...rest: [(string)?, (string[])?, (string)?, (boolean)?]
4684+
paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string,
4685+
...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?]
46844686
): Promise<Models.DocumentList<Document>> {
4685-
let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean };
4687+
let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number };
46864688

46874689
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
4688-
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean };
4690+
params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number };
46894691
} else {
46904692
params = {
46914693
databaseId: paramsOrFirst as string,
46924694
collectionId: rest[0] as string,
46934695
queries: rest[1] as string[],
46944696
transactionId: rest[2] as string,
4695-
total: rest[3] as boolean
4697+
total: rest[3] as boolean,
4698+
ttl: rest[4] as number
46964699
};
46974700
}
46984701

@@ -4701,6 +4704,7 @@ export class Databases {
47014704
const queries = params.queries;
47024705
const transactionId = params.transactionId;
47034706
const total = params.total;
4707+
const ttl = params.ttl;
47044708

47054709
if (typeof databaseId === 'undefined') {
47064710
throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -4720,6 +4724,9 @@ export class Databases {
47204724
if (typeof total !== 'undefined') {
47214725
payload['total'] = total;
47224726
}
4727+
if (typeof ttl !== 'undefined') {
4728+
payload['ttl'] = ttl;
4729+
}
47234730
const uri = new URL(this.client.config.endpoint + apiPath);
47244731

47254732
const apiHeaders: { [header: string]: string } = {

0 commit comments

Comments
 (0)