Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/examples/account/update-prefs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ const client = new Client()
const account = new Account(client);

const result = await account.updatePrefs({
prefs: {}
prefs: {
"language": "en",
"timezone": "UTC",
"darkTheme": true
}
});

console.log(result);
8 changes: 7 additions & 1 deletion docs/examples/databases/create-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ const result = await databases.createDocument({
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
data: {},
data: {
"username": "walter.obrien",
"email": "[email protected]",
"fullName": "Walter O'Brien",
"age": 30,
"isAdmin": false
},
permissions: ["read("any")"] // optional
});

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/databases/decrement-document-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const result = await databases.decrementDocumentAttribute({
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
attribute: '',
value: null, // optional
min: null // optional
value: 0, // optional
min: 0 // optional
});

console.log(result);
4 changes: 2 additions & 2 deletions docs/examples/databases/increment-document-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const result = await databases.incrementDocumentAttribute({
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
attribute: '',
value: null, // optional
max: null // optional
value: 0, // optional
max: 0 // optional
});

console.log(result);
2 changes: 1 addition & 1 deletion docs/examples/storage/create-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const storage = new Storage(client);
const result = await storage.createFile({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
file: await pickSingle(),
file: InputFile.fromPath('/path/to/file', 'filename'),
permissions: ["read("any")"] // optional
});

Expand Down
8 changes: 7 additions & 1 deletion docs/examples/tablesdb/create-row.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ const result = await tablesDB.createRow({
databaseId: '<DATABASE_ID>',
tableId: '<TABLE_ID>',
rowId: '<ROW_ID>',
data: {},
data: {
"username": "walter.obrien",
"email": "[email protected]",
"fullName": "Walter O'Brien",
"age": 30,
"isAdmin": false
},
permissions: ["read("any")"] // optional
});

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/tablesdb/decrement-row-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const result = await tablesDB.decrementRowColumn({
tableId: '<TABLE_ID>',
rowId: '<ROW_ID>',
column: '',
value: null, // optional
min: null // optional
value: 0, // optional
min: 0 // optional
});

console.log(result);
4 changes: 2 additions & 2 deletions docs/examples/tablesdb/increment-row-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const result = await tablesDB.incrementRowColumn({
tableId: '<TABLE_ID>',
rowId: '<ROW_ID>',
column: '',
value: null, // optional
max: null // optional
value: 0, // optional
max: 0 // optional
});

console.log(result);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "react-native-appwrite",
"homepage": "https://appwrite.io/support",
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
"version": "0.12.0",
"version": "0.13.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Client {
'x-sdk-name': 'React Native',
'x-sdk-platform': 'client',
'x-sdk-language': 'reactnative',
'x-sdk-version': '0.12.0',
'x-sdk-version': '0.13.0',
'X-Appwrite-Response-Format': '1.8.0',
};

Expand Down
2 changes: 1 addition & 1 deletion src/enums/credit-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export enum CreditCard {
Mastercard = 'mastercard',
Naranja = 'naranja',
TarjetaShopping = 'targeta-shopping',
UnionChinaPay = 'union-china-pay',
UnionPay = 'unionpay',
Visa = 'visa',
MIR = 'mir',
Maestro = 'maestro',
Expand Down
1 change: 1 addition & 0 deletions src/enums/execution-method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export enum ExecutionMethod {
PATCH = 'PATCH',
DELETE = 'DELETE',
OPTIONS = 'OPTIONS',
HEAD = 'HEAD',
}
158 changes: 153 additions & 5 deletions src/query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type QueryTypesSingle = string | number | boolean;
export type QueryTypesList = string[] | number[] | boolean[] | Query[];
export type QueryTypesList = string[] | number[] | boolean[] | Query[] | any[];
export type QueryTypes = QueryTypesSingle | QueryTypesList;
type AttributesTypes = string | string[];

Expand Down Expand Up @@ -33,10 +33,10 @@ export class Query {
});
}

static equal = (attribute: string, value: QueryTypes): string =>
static equal = (attribute: string, value: QueryTypes | any[]): string =>
new Query("equal", attribute, value).toString();

static notEqual = (attribute: string, value: QueryTypes): string =>
static notEqual = (attribute: string, value: QueryTypes | any[]): string =>
new Query("notEqual", attribute, value).toString();

static lessThan = (attribute: string, value: QueryTypes): string =>
Expand Down Expand Up @@ -97,7 +97,7 @@ export class Query {
* @param {string | string[]} value
* @returns {string}
*/
static contains = (attribute: string, value: string | string[]): string =>
static contains = (attribute: string, value: string | any[]): string =>
new Query("contains", attribute, value).toString();

/**
Expand All @@ -107,7 +107,7 @@ export class Query {
* @param {string | string[]} value
* @returns {string}
*/
static notContains = (attribute: string, value: string | string[]): string =>
static notContains = (attribute: string, value: string | any[]): string =>
new Query("notContains", attribute, value).toString();

/**
Expand Down Expand Up @@ -170,6 +170,16 @@ export class Query {
static createdAfter = (value: string): string =>
new Query("createdAfter", undefined, value).toString();

/**
* Filter resources where document was created between dates.
*
* @param {string} start
* @param {string} end
* @returns {string}
*/
static createdBetween = (start: string, end: string): string =>
new Query("createdBetween", undefined, [start, end] as QueryTypesList).toString();

/**
* Filter resources where document was updated before date.
*
Expand All @@ -188,9 +198,147 @@ export class Query {
static updatedAfter = (value: string): string =>
new Query("updatedAfter", undefined, value).toString();

/**
* Filter resources where document was updated between dates.
*
* @param {string} start
* @param {string} end
* @returns {string}
*/
static updatedBetween = (start: string, end: string): string =>
new Query("updatedBetween", undefined, [start, end] as QueryTypesList).toString();

static or = (queries: string[]) =>
new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString();

static and = (queries: string[]) =>
new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString();

/**
* Filter resources where attribute is at a specific distance from the given coordinates.
*
* @param {string} attribute
* @param {any[]} values
* @param {number} distance
* @param {boolean} meters
* @returns {string}
*/
static distanceEqual = (attribute: string, values: any[], distance: number, meters: boolean = true): string =>
new Query("distanceEqual", attribute, [[values, distance, meters]] as QueryTypesList).toString();

/**
* Filter resources where attribute is not at a specific distance from the given coordinates.
*
* @param {string} attribute
* @param {any[]} values
* @param {number} distance
* @param {boolean} meters
* @returns {string}
*/
static distanceNotEqual = (attribute: string, values: any[], distance: number, meters: boolean = true): string =>
new Query("distanceNotEqual", attribute, [[values, distance, meters]] as QueryTypesList).toString();

/**
* Filter resources where attribute is at a distance greater than the specified value from the given coordinates.
*
* @param {string} attribute
* @param {any[]} values
* @param {number} distance
* @param {boolean} meters
* @returns {string}
*/
static distanceGreaterThan = (attribute: string, values: any[], distance: number, meters: boolean = true): string =>
new Query("distanceGreaterThan", attribute, [[values, distance, meters]] as QueryTypesList).toString();

/**
* Filter resources where attribute is at a distance less than the specified value from the given coordinates.
*
* @param {string} attribute
* @param {any[]} values
* @param {number} distance
* @param {boolean} meters
* @returns {string}
*/
static distanceLessThan = (attribute: string, values: any[], distance: number, meters: boolean = true): string =>
new Query("distanceLessThan", attribute, [[values, distance, meters]] as QueryTypesList).toString();

/**
* Filter resources where attribute intersects with the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static intersects = (attribute: string, values: any[]): string =>
new Query("intersects", attribute, [values]).toString();

/**
* Filter resources where attribute does not intersect with the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static notIntersects = (attribute: string, values: any[]): string =>
new Query("notIntersects", attribute, [values]).toString();

/**
* Filter resources where attribute crosses the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static crosses = (attribute: string, values: any[]): string =>
new Query("crosses", attribute, [values]).toString();

/**
* Filter resources where attribute does not cross the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static notCrosses = (attribute: string, values: any[]): string =>
new Query("notCrosses", attribute, [values]).toString();

/**
* Filter resources where attribute overlaps with the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static overlaps = (attribute: string, values: any[]): string =>
new Query("overlaps", attribute, [values]).toString();

/**
* Filter resources where attribute does not overlap with the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static notOverlaps = (attribute: string, values: any[]): string =>
new Query("notOverlaps", attribute, [values]).toString();

/**
* Filter resources where attribute touches the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static touches = (attribute: string, values: any[]): string =>
new Query("touches", attribute, [values]).toString();

/**
* Filter resources where attribute does not touch the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static notTouches = (attribute: string, values: any[]): string =>
new Query("notTouches", attribute, [values]).toString();
}
4 changes: 2 additions & 2 deletions src/services/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ export class Account extends Service {
* @param {string} params.secret - Valid verification token.
* @throws {AppwriteException}
* @returns {Promise}
* @deprecated This API has been deprecated.
* @deprecated This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.
*/
updateMagicURLSession(params: { userId: string, secret: string }): Promise<Models.Session>;
/**
Expand Down Expand Up @@ -1668,7 +1668,7 @@ export class Account extends Service {
* @param {string} params.secret - Valid verification token.
* @throws {AppwriteException}
* @returns {Promise}
* @deprecated This API has been deprecated.
* @deprecated This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.
*/
updatePhoneSession(params: { userId: string, secret: string }): Promise<Models.Session>;
/**
Expand Down
4 changes: 2 additions & 2 deletions src/services/avatars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class Avatars extends Service {
* When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px.
*
*
* @param {CreditCard} params.code - Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay.
* @param {CreditCard} params.code - Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, unionpay, visa, mir, maestro, rupay.
* @param {number} params.width - Image width. Pass an integer between 0 to 2000. Defaults to 100.
* @param {number} params.height - Image height. Pass an integer between 0 to 2000. Defaults to 100.
* @param {number} params.quality - Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
Expand All @@ -115,7 +115,7 @@ export class Avatars extends Service {
* When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px.
*
*
* @param {CreditCard} code - Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay.
* @param {CreditCard} code - Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, unionpay, visa, mir, maestro, rupay.
* @param {number} width - Image width. Pass an integer between 0 to 2000. Defaults to 100.
* @param {number} height - Image height. Pass an integer between 0 to 2000. Defaults to 100.
* @param {number} quality - Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
Expand Down
9 changes: 0 additions & 9 deletions src/services/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ export class Databases extends Service {
throw new AppwriteException('Missing required parameter: "data"');
}

delete data?.$sequence;
delete data?.$collectionId;
delete data?.$databaseId;
const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
const payload: Payload = {};

Expand Down Expand Up @@ -301,9 +298,6 @@ export class Databases extends Service {
throw new AppwriteException('Missing required parameter: "data"');
}

delete data?.$sequence;
delete data?.$collectionId;
delete data?.$databaseId;
const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
const payload: Payload = {};

Expand Down Expand Up @@ -383,9 +377,6 @@ export class Databases extends Service {
throw new AppwriteException('Missing required parameter: "documentId"');
}

delete data?.$sequence;
delete data?.$collectionId;
delete data?.$databaseId;
const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
const payload: Payload = {};

Expand Down
Loading