diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9e8e716..41c7a69 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,6 +5,10 @@ on: types: [published] workflow_dispatch: +permissions: + id-token: write + contents: read + jobs: publish: runs-on: ubuntu-latest @@ -12,14 +16,15 @@ jobs: steps: - uses: actions/checkout@v4 - # Setup Node.js environment - name: Use Node.js uses: actions/setup-node@v4 with: - node-version: '20.x' + node-version: '22' registry-url: 'https://registry.npmjs.org' - # Determine release tag based on the tag name + - name: Update npm to latest version for OIDC support + run: npm install -g npm@latest + - name: Determine release tag id: release_tag run: | @@ -29,14 +34,10 @@ jobs: echo "tag=latest" >> "$GITHUB_OUTPUT" fi - # Install dependencies (if any) and build your project (if necessary) - name: Install dependencies and build run: | npm install npm run build - # Publish to NPM with the appropriate tag - name: Publish - run: npm publish --tag ${{ steps.release_tag.outputs.tag }} - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_NO_ORG }} + run: npm publish --provenance --access public --tag ${{ steps.release_tag.outputs.tag }} diff --git a/CHANGELOG.md b/CHANGELOG.md index da425ad..354429f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 21.1.1 + +* Update SDK as per latest server specs, these include - + * Updates to Runtime enums + * `Output` is now renamed to `ImageFormat` - Note that this is a breaking change + * Introduces Backups module for managing Database backups + * Introduces Organization module + ## 21.1.0 * Added ability to create columns and indexes synchronously while creating a table @@ -7,7 +15,8 @@ ## 21.0.0 * Rename `VCSDeploymentType` enum to `VCSReferenceType` -* Change `createTemplateDeployment` method signature: replace `version` parameter with `type` (TemplateReferenceType) and `reference` parameters +* Change `createTemplateDeployment` method signature: replace `version` parameter with `type` (TemplateReferenceType) + and `reference` parameters * Add `getScreenshot` method to `Avatars` service * Add `Theme`, `Timezone` and `Output` enums @@ -54,7 +63,8 @@ ## 16.0.0 * Fix: remove content-type from GET requests -* Update (breaking): min and max params are now optional in `updateFloatAttribute` and `updateIntegerAttribute` methods (changes their positioning in method definition) +* Update (breaking): min and max params are now optional in `updateFloatAttribute` and `updateIntegerAttribute` + methods (changes their positioning in method definition) ## 15.0.1 @@ -96,4 +106,5 @@ * Rename `templateBranch` to `templateVersion` in `createFunction()`. * Rename `downloadDeployment()` to `getDeploymentDownload()` -> You can find the new syntax for breaking changes in the [Appwrite API references](https://appwrite.io/docs/references). Select version `1.6.x`. \ No newline at end of file +> You can find the new syntax for breaking changes in +> the [Appwrite API references](https://appwrite.io/docs/references). Select version `1.6.x`. \ No newline at end of file diff --git a/LICENSE b/LICENSE index c1602fc..6f8702b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2026 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index 9cb41a6..764e488 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ # Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.1-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).** +**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).** > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web) -Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Node.js SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Node.js SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) ![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png) diff --git a/docs/examples/account/create-jwt.md b/docs/examples/account/create-jwt.md index 76d52e1..f5ddd7b 100644 --- a/docs/examples/account/create-jwt.md +++ b/docs/examples/account/create-jwt.md @@ -7,4 +7,6 @@ const client = new sdk.Client() const account = new sdk.Account(client); -const result = await account.createJWT(); +const result = await account.createJWT({ + duration: 0 // optional +}); diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index dc63102..537670c 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -30,5 +30,5 @@ const result = await avatars.getScreenshot({ width: 800, // optional height: 600, // optional quality: 85, // optional - output: sdk.Output.Jpg // optional + output: sdk.ImageFormat.Jpg // optional }); diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md new file mode 100644 index 0000000..5c7764f --- /dev/null +++ b/docs/examples/backups/create-archive.md @@ -0,0 +1,13 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const backups = new sdk.Backups(client); + +const result = await backups.createArchive({ + services: [], + resourceId: '' // optional +}); diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md new file mode 100644 index 0000000..9314301 --- /dev/null +++ b/docs/examples/backups/create-policy.md @@ -0,0 +1,18 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const backups = new sdk.Backups(client); + +const result = await backups.createPolicy({ + policyId: '', + services: [], + retention: 1, + schedule: '', + name: '', // optional + resourceId: '', // optional + enabled: false // optional +}); diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md new file mode 100644 index 0000000..6791302 --- /dev/null +++ b/docs/examples/backups/create-restoration.md @@ -0,0 +1,15 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const backups = new sdk.Backups(client); + +const result = await backups.createRestoration({ + archiveId: '', + services: [], + newResourceId: '', // optional + newResourceName: '' // optional +}); diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md new file mode 100644 index 0000000..5127449 --- /dev/null +++ b/docs/examples/backups/delete-archive.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const backups = new sdk.Backups(client); + +const result = await backups.deleteArchive({ + archiveId: '' +}); diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md new file mode 100644 index 0000000..c22b1ed --- /dev/null +++ b/docs/examples/backups/delete-policy.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const backups = new sdk.Backups(client); + +const result = await backups.deletePolicy({ + policyId: '' +}); diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md new file mode 100644 index 0000000..046bd4b --- /dev/null +++ b/docs/examples/backups/get-archive.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const backups = new sdk.Backups(client); + +const result = await backups.getArchive({ + archiveId: '' +}); diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md new file mode 100644 index 0000000..1a3610d --- /dev/null +++ b/docs/examples/backups/get-policy.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const backups = new sdk.Backups(client); + +const result = await backups.getPolicy({ + policyId: '' +}); diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md new file mode 100644 index 0000000..181d4cd --- /dev/null +++ b/docs/examples/backups/get-restoration.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const backups = new sdk.Backups(client); + +const result = await backups.getRestoration({ + restorationId: '' +}); diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md new file mode 100644 index 0000000..31567b7 --- /dev/null +++ b/docs/examples/backups/list-archives.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const backups = new sdk.Backups(client); + +const result = await backups.listArchives({ + queries: [] // optional +}); diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md new file mode 100644 index 0000000..ef22e42 --- /dev/null +++ b/docs/examples/backups/list-policies.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const backups = new sdk.Backups(client); + +const result = await backups.listPolicies({ + queries: [] // optional +}); diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md new file mode 100644 index 0000000..59b8978 --- /dev/null +++ b/docs/examples/backups/list-restorations.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const backups = new sdk.Backups(client); + +const result = await backups.listRestorations({ + queries: [] // optional +}); diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md new file mode 100644 index 0000000..7938912 --- /dev/null +++ b/docs/examples/backups/update-policy.md @@ -0,0 +1,16 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +const backups = new sdk.Backups(client); + +const result = await backups.updatePolicy({ + policyId: '', + name: '', // optional + retention: 1, // optional + schedule: '', // optional + enabled: false // optional +}); diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index d33d78d..7e1a8c5 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -11,7 +11,13 @@ const result = await databases.updateDocument({ databaseId: '', collectionId: '', documentId: '', - data: {}, // optional + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": false + }, // optional permissions: [sdk.Permission.read(sdk.Role.any())], // optional transactionId: '' // optional }); diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index dc79e43..038ed1a 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -10,7 +10,13 @@ const databases = new sdk.Databases(client); const result = await databases.updateDocuments({ databaseId: '', collectionId: '', - data: {}, // optional + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": false + }, // optional queries: [], // optional transactionId: '' // optional }); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 8fe4b35..55156bd 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -11,7 +11,13 @@ const result = await databases.upsertDocument({ databaseId: '', collectionId: '', documentId: '', - data: {}, + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + }, // optional permissions: [sdk.Permission.read(sdk.Role.any())], // optional transactionId: '' // optional }); diff --git a/docs/examples/organizations/delete.md b/docs/examples/organizations/delete.md new file mode 100644 index 0000000..891c7fc --- /dev/null +++ b/docs/examples/organizations/delete.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const organizations = new sdk.Organizations(client); + +const result = await organizations.delete({ + organizationId: '' +}); diff --git a/docs/examples/organizations/estimation-delete-organization.md b/docs/examples/organizations/estimation-delete-organization.md new file mode 100644 index 0000000..9a4db46 --- /dev/null +++ b/docs/examples/organizations/estimation-delete-organization.md @@ -0,0 +1,12 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const organizations = new sdk.Organizations(client); + +const result = await organizations.estimationDeleteOrganization({ + organizationId: '' +}); diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index d5d2ee3..8c003bf 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -11,7 +11,13 @@ const result = await tablesDB.updateRow({ databaseId: '', tableId: '', rowId: '', - data: {}, // optional + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": false + }, // optional permissions: [sdk.Permission.read(sdk.Role.any())], // optional transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index d66fc28..b41f0c2 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -10,7 +10,13 @@ const tablesDB = new sdk.TablesDB(client); const result = await tablesDB.updateRows({ databaseId: '', tableId: '', - data: {}, // optional + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": false + }, // optional queries: [], // optional transactionId: '' // optional }); diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index f48b0da..2905b31 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -11,7 +11,13 @@ const result = await tablesDB.upsertRow({ databaseId: '', tableId: '', rowId: '', - data: {}, // optional + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": false + }, // optional permissions: [sdk.Permission.read(sdk.Role.any())], // optional transactionId: '' // optional }); diff --git a/package.json b/package.json index 560a05f..a0212a0 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "node-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": "21.1.0", + "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", + "version": "21.1.1", "license": "BSD-3-Clause", "main": "dist/index.js", "type": "commonjs", @@ -41,6 +41,7 @@ "url": "https://github.com/appwrite/sdk-for-node" }, "devDependencies": { + "@types/json-bigint": "1.0.4", "@types/node": "20.11.25", "tsup": "7.2.0", "esbuild-plugin-file-path-extensions": "^2.0.0", @@ -48,6 +49,7 @@ "typescript": "5.4.2" }, "dependencies": { + "json-bigint": "1.0.0", "node-fetch-native-with-agent": "1.7.2" } } diff --git a/src/client.ts b/src/client.ts index 564b24a..42772dd 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,6 +1,8 @@ import { fetch, FormData, File } from 'node-fetch-native-with-agent'; import { createAgent } from 'node-fetch-native-with-agent/agent'; import { Models } from './models'; +import JSONbigModule from 'json-bigint'; +const JSONbig = JSONbigModule({ useNativeBigInt: true }); type Payload = { [key: string]: any; @@ -33,7 +35,7 @@ class AppwriteException extends Error { } function getUserAgent() { - let ua = 'AppwriteNodeJSSDK/21.1.0'; + let ua = 'AppwriteNodeJSSDK/21.1.1'; // `process` is a global in Node.js, but not fully available in all runtimes. const platform: string[] = []; @@ -82,7 +84,7 @@ class Client { 'x-sdk-name': 'Node.js', 'x-sdk-platform': 'server', 'x-sdk-language': 'nodejs', - 'x-sdk-version': '21.1.0', + 'x-sdk-version': '21.1.1', 'user-agent' : getUserAgent(), 'X-Appwrite-Response-Format': '1.8.0', }; @@ -97,6 +99,10 @@ class Client { * @returns {this} */ setEndpoint(endpoint: string): this { + if (!endpoint || typeof endpoint !== 'string') { + throw new AppwriteException('Endpoint must be a valid string'); + } + if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) { throw new AppwriteException('Invalid endpoint URL: ' + endpoint); } @@ -238,7 +244,7 @@ class Client { } else { switch (headers['content-type']) { case 'application/json': - options.body = JSON.stringify(params); + options.body = JSONbig.stringify(params); break; case 'multipart/form-data': @@ -345,7 +351,7 @@ class Client { } if (response.headers.get('content-type')?.includes('application/json')) { - data = await response.json(); + data = JSONbig.parse(await response.text()); } else if (responseType === 'arrayBuffer') { data = await response.arrayBuffer(); } else { @@ -357,7 +363,7 @@ class Client { if (400 <= response.status) { let responseText = ''; if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') { - responseText = JSON.stringify(data); + responseText = JSONbig.stringify(data); } else { responseText = data?.message; } diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts index 25dca77..e25a893 100644 --- a/src/enums/build-runtime.ts +++ b/src/enums/build-runtime.ts @@ -21,9 +21,6 @@ export enum BuildRuntime { Python312 = 'python-3.12', Pythonml311 = 'python-ml-3.11', Pythonml312 = 'python-ml-3.12', - Deno121 = 'deno-1.21', - Deno124 = 'deno-1.24', - Deno135 = 'deno-1.35', Deno140 = 'deno-1.40', Deno146 = 'deno-1.46', Deno20 = 'deno-2.0', diff --git a/src/enums/name.ts b/src/enums/name.ts index 76e8469..8cd297b 100644 --- a/src/enums/name.ts +++ b/src/enums/name.ts @@ -9,6 +9,7 @@ export enum Name { V1webhooks = 'v1-webhooks', V1certificates = 'v1-certificates', V1builds = 'v1-builds', + V1screenshots = 'v1-screenshots', V1messaging = 'v1-messaging', V1migrations = 'v1-migrations', } \ No newline at end of file diff --git a/src/enums/o-auth-provider.ts b/src/enums/o-auth-provider.ts index 7a3fcb3..3382e3b 100644 --- a/src/enums/o-auth-provider.ts +++ b/src/enums/o-auth-provider.ts @@ -38,5 +38,4 @@ export enum OAuthProvider { Yandex = 'yandex', Zoho = 'zoho', Zoom = 'zoom', - Mock = 'mock', } \ No newline at end of file diff --git a/src/enums/output.ts b/src/enums/output.ts deleted file mode 100644 index c339a51..0000000 --- a/src/enums/output.ts +++ /dev/null @@ -1,9 +0,0 @@ -export enum Output { - Jpg = 'jpg', - Jpeg = 'jpeg', - Png = 'png', - Webp = 'webp', - Heic = 'heic', - Avif = 'avif', - Gif = 'gif', -} \ No newline at end of file diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts index ecdc452..ee7606f 100644 --- a/src/enums/runtime.ts +++ b/src/enums/runtime.ts @@ -21,9 +21,6 @@ export enum Runtime { Python312 = 'python-3.12', Pythonml311 = 'python-ml-3.11', Pythonml312 = 'python-ml-3.12', - Deno121 = 'deno-1.21', - Deno124 = 'deno-1.24', - Deno135 = 'deno-1.35', Deno140 = 'deno-1.40', Deno146 = 'deno-1.46', Deno20 = 'deno-2.0', diff --git a/src/index.ts b/src/index.ts index 7dbc903..653a21e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,12 +1,14 @@ export { Client, Query, AppwriteException } from './client'; export { Account } from './services/account'; export { Avatars } from './services/avatars'; +export { Backups } from './services/backups'; export { Databases } from './services/databases'; export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; export { Health } from './services/health'; export { Locale } from './services/locale'; export { Messaging } from './services/messaging'; +export { Organizations } from './services/organizations'; export { Sites } from './services/sites'; export { Storage } from './services/storage'; export { TablesDB } from './services/tables-db'; @@ -27,7 +29,7 @@ export { CreditCard } from './enums/credit-card'; export { Flag } from './enums/flag'; export { Theme } from './enums/theme'; export { Timezone } from './enums/timezone'; -export { Output } from './enums/output'; +export { ImageFormat } from './enums/image-format'; export { RelationshipType } from './enums/relationship-type'; export { RelationMutate } from './enums/relation-mutate'; export { IndexType } from './enums/index-type'; @@ -44,7 +46,6 @@ export { BuildRuntime } from './enums/build-runtime'; export { Adapter } from './enums/adapter'; export { Compression } from './enums/compression'; export { ImageGravity } from './enums/image-gravity'; -export { ImageFormat } from './enums/image-format'; export { PasswordHash } from './enums/password-hash'; export { MessagingProviderType } from './enums/messaging-provider-type'; export { DatabaseType } from './enums/database-type'; diff --git a/src/models.ts b/src/models.ts index 7c27b05..c09abeb 100644 --- a/src/models.ts +++ b/src/models.ts @@ -548,6 +548,14 @@ export namespace Models { * Database type. */ type: DatabaseType; + /** + * Database backup policies. + */ + policies: Index[]; + /** + * Database backup archives. + */ + archives: Collection[]; } /** @@ -699,11 +707,11 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number; + min?: number | bigint; /** * Maximum value to enforce for new documents. */ - max?: number; + max?: number | bigint; /** * Default value for attribute when not provided. Cannot be set when attribute is required. */ @@ -1373,11 +1381,11 @@ export namespace Models { /** * Minimum value to enforce for new documents. */ - min?: number; + min?: number | bigint; /** * Maximum value to enforce for new documents. */ - max?: number; + max?: number | bigint; /** * Default value for column when not provided. Cannot be set when column is required. */ @@ -2665,6 +2673,14 @@ export namespace Models { * Total number of chunks uploaded */ chunksUploaded: number; + /** + * Whether file contents are encrypted at rest. + */ + encryption: boolean; + /** + * Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + */ + compression: string; } /** @@ -2708,7 +2724,7 @@ export namespace Models { */ allowedFileExtensions: string[]; /** - * Compression algorithm choosen for compression. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + * Compression algorithm chosen for compression. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). */ compression: string; /** @@ -2723,6 +2739,10 @@ export namespace Models { * Image transformations are enabled. */ transformations: boolean; + /** + * Total size of this bucket in bytes. + */ + totalSize: number; } /** @@ -3950,4 +3970,334 @@ export namespace Models { */ expired: boolean; } + + /** + * Archive + */ + export type BackupArchive = { + /** + * Archive ID. + */ + $id: string; + /** + * Archive creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Archive update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Archive policy ID. + */ + policyId: string; + /** + * Archive size in bytes. + */ + size: number; + /** + * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed. + */ + status: string; + /** + * The backup start time. + */ + startedAt: string; + /** + * Migration ID. + */ + migrationId: string; + /** + * The services that are backed up by this archive. + */ + services: string[]; + /** + * The resources that are backed up by this archive. + */ + resources: string[]; + /** + * The resource ID to backup. Set only if this archive should backup a single resource. + */ + resourceId?: string; + /** + * The resource type to backup. Set only if this archive should backup a single resource. + */ + resourceType?: string; + } + + /** + * Invoice + */ + export type Invoice = { + /** + * Invoice ID. + */ + $id: string; + /** + * Invoice creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Invoice update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Invoice permissions. [Learn more about permissions](/docs/permissions). + */ + $permissions: string[]; + /** + * Project ID + */ + teamId: string; + /** + * Aggregation ID + */ + aggregationId: string; + /** + * Billing plan selected. Can be one of `tier-0`, `tier-1` or `tier-2`. + */ + plan: string; + /** + * Usage breakdown per resource + */ + usage: UsageResources[]; + /** + * Invoice Amount + */ + amount: number; + /** + * Tax percentage + */ + tax: number; + /** + * Tax amount + */ + taxAmount: number; + /** + * VAT percentage + */ + vat: number; + /** + * VAT amount + */ + vatAmount: number; + /** + * Gross amount after vat, tax, and discounts applied. + */ + grossAmount: number; + /** + * Credits used. + */ + creditsUsed: number; + /** + * Currency the invoice is in + */ + currency: string; + /** + * Client secret for processing failed payments in front-end + */ + clientSecret: string; + /** + * Invoice status + */ + status: string; + /** + * Last payment error associated with the invoice + */ + lastError: string; + /** + * Invoice due date. + */ + dueAt: string; + /** + * Beginning date of the invoice + */ + from: string; + /** + * End date of the invoice + */ + to: string; + } + + /** + * backup + */ + export type BackupPolicy = { + /** + * Backup policy ID. + */ + $id: string; + /** + * Backup policy name. + */ + name: string; + /** + * Policy creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Policy update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * The services that are backed up by this policy. + */ + services: string[]; + /** + * The resources that are backed up by this policy. + */ + resources: string[]; + /** + * The resource ID to backup. Set only if this policy should backup a single resource. + */ + resourceId?: string; + /** + * The resource type to backup. Set only if this policy should backup a single resource. + */ + resourceType?: string; + /** + * How many days to keep the backup before it will be automatically deleted. + */ + retention: number; + /** + * Policy backup schedule in CRON format. + */ + schedule: string; + /** + * Is this policy enabled. + */ + enabled: boolean; + } + + /** + * Restoration + */ + export type BackupRestoration = { + /** + * Restoration ID. + */ + $id: string; + /** + * Restoration creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Restoration update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Backup archive ID. + */ + archiveId: string; + /** + * Backup policy ID. + */ + policyId: string; + /** + * The status of the restoration. Possible values: pending, downloading, processing, completed, failed. + */ + status: string; + /** + * The backup start time. + */ + startedAt: string; + /** + * Migration ID. + */ + migrationId: string; + /** + * The services that are backed up by this policy. + */ + services: string[]; + /** + * The resources that are backed up by this policy. + */ + resources: string[]; + /** + * Optional data in key-value object. + */ + options: string; + } + + /** + * UsageResource + */ + export type UsageResources = { + /** + * Invoice name + */ + name: string; + /** + * Invoice value + */ + value: number; + /** + * Invoice amount + */ + amount: number; + /** + * Invoice rate + */ + rate: number; + /** + * Invoice description + */ + desc: string; + /** + * Resource ID + */ + resourceId: string; + } + + /** + * EstimationDeleteOrganization + */ + export type EstimationDeleteOrganization = { + /** + * List of unpaid invoices + */ + unpaidInvoices: Invoice[]; + } + + /** + * Backup archive list + */ + export type BackupArchiveList = { + /** + * Total number of archives that matched your query. + */ + total: number; + /** + * List of archives. + */ + archives: BackupArchive[]; + } + + /** + * Backup policy list + */ + export type BackupPolicyList = { + /** + * Total number of policies that matched your query. + */ + total: number; + /** + * List of policies. + */ + policies: BackupPolicy[]; + } + + /** + * Backup restoration list + */ + export type BackupRestorationList = { + /** + * Total number of restorations that matched your query. + */ + total: number; + /** + * List of restorations. + */ + restorations: BackupRestoration[]; + } } diff --git a/src/query.ts b/src/query.ts index 4ebd532..a6fb328 100644 --- a/src/query.ts +++ b/src/query.ts @@ -1,5 +1,8 @@ -type QueryTypesSingle = string | number | boolean; -export type QueryTypesList = string[] | number[] | boolean[] | Query[] | any[]; +import JSONbigModule from 'json-bigint'; +const JSONbig = JSONbigModule({ useNativeBigInt: true }); + +type QueryTypesSingle = string | number | bigint | boolean; +export type QueryTypesList = string[] | number[] | bigint[] | boolean[] | Query[] | any[]; export type QueryTypes = QueryTypesSingle | QueryTypesList; type AttributesTypes = string | string[]; @@ -41,7 +44,7 @@ export class Query { * @returns {string} */ toString(): string { - return JSON.stringify({ + return JSONbig.stringify({ method: this.method, attribute: this.attribute, values: this.values, @@ -130,11 +133,11 @@ export class Query { * Filter resources where attribute is between start and end (inclusive). * * @param {string} attribute - * @param {string | number} start - * @param {string | number} end + * @param {string | number | bigint} start + * @param {string | number | bigint} end * @returns {string} */ - static between = (attribute: string, start: string | number, end: string | number): string => + static between = (attribute: string, start: string | number | bigint, end: string | number | bigint): string => new Query("between", attribute, [start, end] as QueryTypesList).toString(); /** @@ -274,11 +277,11 @@ export class Query { * Filter resources where attribute is not between start and end (exclusive). * * @param {string} attribute - * @param {string | number} start - * @param {string | number} end + * @param {string | number | bigint} start + * @param {string | number | bigint} end * @returns {string} */ - static notBetween = (attribute: string, start: string | number, end: string | number): string => + static notBetween = (attribute: string, start: string | number | bigint, end: string | number | bigint): string => new Query("notBetween", attribute, [start, end] as QueryTypesList).toString(); /** @@ -364,7 +367,7 @@ export class Query { * @returns {string} */ static or = (queries: string[]) => - new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString(); + new Query("or", undefined, queries.map((query) => JSONbig.parse(query))).toString(); /** * Combine multiple queries using logical AND operator. @@ -373,7 +376,7 @@ export class Query { * @returns {string} */ static and = (queries: string[]) => - new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString(); + new Query("and", undefined, queries.map((query) => JSONbig.parse(query))).toString(); /** * Filter resources where attribute is at a specific distance from the given coordinates. diff --git a/src/services/account.ts b/src/services/account.ts index 26bd2bc..3464e98 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -302,13 +302,41 @@ export class Account { /** * Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. * + * @param {number} params.duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. * @throws {AppwriteException} * @returns {Promise} */ - createJWT(): Promise { + createJWT(params?: { duration?: number }): Promise; + /** + * Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. + * + * @param {number} duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createJWT(duration?: number): Promise; + createJWT( + paramsOrFirst?: { duration?: number } | number + ): Promise { + let params: { duration?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { duration?: number }; + } else { + params = { + duration: paramsOrFirst as number + }; + } + + const duration = params.duration; + const apiPath = '/account/jwts'; const payload: Payload = {}; + if (typeof duration !== 'undefined') { + payload['duration'] = duration; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 68e83d1..a27b0e5 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -6,7 +6,7 @@ import { CreditCard } from '../enums/credit-card'; import { Flag } from '../enums/flag'; import { Theme } from '../enums/theme'; import { Timezone } from '../enums/timezone'; -import { Output } from '../enums/output'; +import { ImageFormat } from '../enums/image-format'; export class Avatars { client: Client; @@ -579,11 +579,11 @@ export class Avatars { * @param {number} params.width - Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width). * @param {number} params.height - Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height). * @param {number} params.quality - Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. - * @param {Output} params.output - Output format type (jpeg, jpg, png, gif and webp). + * @param {ImageFormat} params.output - Output format type (jpeg, jpg, png, gif and webp). * @throws {AppwriteException} * @returns {Promise} */ - getScreenshot(params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output }): Promise; + getScreenshot(params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }): Promise; /** * Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. * @@ -610,20 +610,20 @@ export class Avatars { * @param {number} width - Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width). * @param {number} height - Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height). * @param {number} quality - Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. - * @param {Output} output - Output format type (jpeg, jpg, png, gif and webp). + * @param {ImageFormat} output - Output format type (jpeg, jpg, png, gif and webp). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getScreenshot(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output): Promise; + getScreenshot(url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat): Promise; getScreenshot( - paramsOrFirst: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output } | string, - ...rest: [(object)?, (number)?, (number)?, (number)?, (Theme)?, (string)?, (boolean)?, (string)?, (Timezone)?, (number)?, (number)?, (number)?, (boolean)?, (string[])?, (number)?, (number)?, (number)?, (number)?, (Output)?] + paramsOrFirst: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat } | string, + ...rest: [(object)?, (number)?, (number)?, (number)?, (Theme)?, (string)?, (boolean)?, (string)?, (Timezone)?, (number)?, (number)?, (number)?, (boolean)?, (string[])?, (number)?, (number)?, (number)?, (number)?, (ImageFormat)?] ): Promise { - let params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output }; + let params: { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: Output }; + params = (paramsOrFirst || {}) as { url: string, headers?: object, viewportWidth?: number, viewportHeight?: number, scale?: number, theme?: Theme, userAgent?: string, fullpage?: boolean, locale?: string, timezone?: Timezone, latitude?: number, longitude?: number, accuracy?: number, touch?: boolean, permissions?: string[], sleep?: number, width?: number, height?: number, quality?: number, output?: ImageFormat }; } else { params = { url: paramsOrFirst as string, @@ -645,7 +645,7 @@ export class Avatars { width: rest[15] as number, height: rest[16] as number, quality: rest[17] as number, - output: rest[18] as Output + output: rest[18] as ImageFormat }; } diff --git a/src/services/backups.ts b/src/services/backups.ts new file mode 100644 index 0000000..15f77f4 --- /dev/null +++ b/src/services/backups.ts @@ -0,0 +1,752 @@ +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + + +export class Backups { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * List all archives for a project. + * + * @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. + * @throws {AppwriteException} + * @returns {Promise} + */ + listArchives(params?: { queries?: string[] }): Promise; + /** + * List all archives for a project. + * + * @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. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listArchives(queries?: string[]): Promise; + listArchives( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + + const apiPath = '/backups/archives'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new archive asynchronously for a project. + * + * @param {string[]} params.services - Array of services to backup + * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @throws {AppwriteException} + * @returns {Promise} + */ + createArchive(params: { services: string[], resourceId?: string }): Promise; + /** + * Create a new archive asynchronously for a project. + * + * @param {string[]} services - Array of services to backup + * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createArchive(services: string[], resourceId?: string): Promise; + createArchive( + paramsOrFirst: { services: string[], resourceId?: string } | string[], + ...rest: [(string)?] + ): Promise { + let params: { services: string[], resourceId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { services: string[], resourceId?: string }; + } else { + params = { + services: paramsOrFirst as string[], + resourceId: rest[0] as string + }; + } + + const services = params.services; + const resourceId = params.resourceId; + + if (typeof services === 'undefined') { + throw new AppwriteException('Missing required parameter: "services"'); + } + + const apiPath = '/backups/archives'; + const payload: Payload = {}; + if (typeof services !== 'undefined') { + payload['services'] = services; + } + if (typeof resourceId !== 'undefined') { + payload['resourceId'] = resourceId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a backup archive using it's ID. + * + * @param {string} params.archiveId - Archive ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + getArchive(params: { archiveId: string }): Promise; + /** + * Get a backup archive using it's ID. + * + * @param {string} archiveId - Archive ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getArchive(archiveId: string): Promise; + getArchive( + paramsOrFirst: { archiveId: string } | string + ): Promise { + let params: { archiveId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { archiveId: string }; + } else { + params = { + archiveId: paramsOrFirst as string + }; + } + + const archiveId = params.archiveId; + + if (typeof archiveId === 'undefined') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + + const apiPath = '/backups/archives/{archiveId}'.replace('{archiveId}', archiveId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete an existing archive for a project. + * + * @param {string} params.archiveId - Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteArchive(params: { archiveId: string }): Promise<{}>; + /** + * Delete an existing archive for a project. + * + * @param {string} archiveId - Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteArchive(archiveId: string): Promise<{}>; + deleteArchive( + paramsOrFirst: { archiveId: string } | string + ): Promise<{}> { + let params: { archiveId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { archiveId: string }; + } else { + params = { + archiveId: paramsOrFirst as string + }; + } + + const archiveId = params.archiveId; + + if (typeof archiveId === 'undefined') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + + const apiPath = '/backups/archives/{archiveId}'.replace('{archiveId}', archiveId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * List all policies for a project. + * + * @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. + * @throws {AppwriteException} + * @returns {Promise} + */ + listPolicies(params?: { queries?: string[] }): Promise; + /** + * List all policies for a project. + * + * @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. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPolicies(queries?: string[]): Promise; + listPolicies( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + + const apiPath = '/backups/policies'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create a new backup policy. + * + * @param {string} params.policyId - Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string[]} params.services - Array of services to backup + * @param {number} params.retention - Days to keep backups before deletion + * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {boolean} params.enabled - Is policy enabled? When set to 'disabled', no backups will be taken + * @throws {AppwriteException} + * @returns {Promise} + */ + createPolicy(params: { policyId: string, services: string[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean }): Promise; + /** + * Create a new backup policy. + * + * @param {string} policyId - Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string[]} services - Array of services to backup + * @param {number} retention - Days to keep backups before deletion + * @param {string} schedule - Schedule CRON syntax. + * @param {string} name - Policy name. Max length: 128 chars. + * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {boolean} enabled - Is policy enabled? When set to 'disabled', no backups will be taken + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPolicy(policyId: string, services: string[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean): Promise; + createPolicy( + paramsOrFirst: { policyId: string, services: string[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean } | string, + ...rest: [(string[])?, (number)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise { + let params: { policyId: string, services: string[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { policyId: string, services: string[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean }; + } else { + params = { + policyId: paramsOrFirst as string, + services: rest[0] as string[], + retention: rest[1] as number, + schedule: rest[2] as string, + name: rest[3] as string, + resourceId: rest[4] as string, + enabled: rest[5] as boolean + }; + } + + const policyId = params.policyId; + const services = params.services; + const retention = params.retention; + const schedule = params.schedule; + const name = params.name; + const resourceId = params.resourceId; + const enabled = params.enabled; + + if (typeof policyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + if (typeof services === 'undefined') { + throw new AppwriteException('Missing required parameter: "services"'); + } + if (typeof retention === 'undefined') { + throw new AppwriteException('Missing required parameter: "retention"'); + } + if (typeof schedule === 'undefined') { + throw new AppwriteException('Missing required parameter: "schedule"'); + } + + const apiPath = '/backups/policies'; + const payload: Payload = {}; + if (typeof policyId !== 'undefined') { + payload['policyId'] = policyId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof services !== 'undefined') { + payload['services'] = services; + } + if (typeof resourceId !== 'undefined') { + payload['resourceId'] = resourceId; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof retention !== 'undefined') { + payload['retention'] = retention; + } + if (typeof schedule !== 'undefined') { + payload['schedule'] = schedule; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get a backup policy using it's ID. + * + * @param {string} params.policyId - Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + getPolicy(params: { policyId: string }): Promise; + /** + * Get a backup policy using it's ID. + * + * @param {string} policyId - Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPolicy(policyId: string): Promise; + getPolicy( + paramsOrFirst: { policyId: string } | string + ): Promise { + let params: { policyId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { policyId: string }; + } else { + params = { + policyId: paramsOrFirst as string + }; + } + + const policyId = params.policyId; + + if (typeof policyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + + const apiPath = '/backups/policies/{policyId}'.replace('{policyId}', policyId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Update an existing policy using it's ID. + * + * @param {string} params.policyId - Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {number} params.retention - Days to keep backups before deletion + * @param {string} params.schedule - Cron expression + * @param {boolean} params.enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePolicy(params: { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean }): Promise; + /** + * Update an existing policy using it's ID. + * + * @param {string} policyId - Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Policy name. Max length: 128 chars. + * @param {number} retention - Days to keep backups before deletion + * @param {string} schedule - Cron expression + * @param {boolean} enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePolicy(policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean): Promise; + updatePolicy( + paramsOrFirst: { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean } | string, + ...rest: [(string)?, (number)?, (string)?, (boolean)?] + ): Promise { + let params: { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean }; + } else { + params = { + policyId: paramsOrFirst as string, + name: rest[0] as string, + retention: rest[1] as number, + schedule: rest[2] as string, + enabled: rest[3] as boolean + }; + } + + const policyId = params.policyId; + const name = params.name; + const retention = params.retention; + const schedule = params.schedule; + const enabled = params.enabled; + + if (typeof policyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + + const apiPath = '/backups/policies/{policyId}'.replace('{policyId}', policyId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof retention !== 'undefined') { + payload['retention'] = retention; + } + if (typeof schedule !== 'undefined') { + payload['schedule'] = schedule; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } + + /** + * Delete a policy using it's ID. + * + * @param {string} params.policyId - Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePolicy(params: { policyId: string }): Promise<{}>; + /** + * Delete a policy using it's ID. + * + * @param {string} policyId - Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePolicy(policyId: string): Promise<{}>; + deletePolicy( + paramsOrFirst: { policyId: string } | string + ): Promise<{}> { + let params: { policyId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { policyId: string }; + } else { + params = { + policyId: paramsOrFirst as string + }; + } + + const policyId = params.policyId; + + if (typeof policyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + + const apiPath = '/backups/policies/{policyId}'.replace('{policyId}', policyId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Create and trigger a new restoration for a backup on a project. + * + * @param {string} params.archiveId - Backup archive ID to restore + * @param {string[]} params.services - Array of services to restore + * @param {string} params.newResourceId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.newResourceName - Database name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + createRestoration(params: { archiveId: string, services: string[], newResourceId?: string, newResourceName?: string }): Promise; + /** + * Create and trigger a new restoration for a backup on a project. + * + * @param {string} archiveId - Backup archive ID to restore + * @param {string[]} services - Array of services to restore + * @param {string} newResourceId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} newResourceName - Database name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRestoration(archiveId: string, services: string[], newResourceId?: string, newResourceName?: string): Promise; + createRestoration( + paramsOrFirst: { archiveId: string, services: string[], newResourceId?: string, newResourceName?: string } | string, + ...rest: [(string[])?, (string)?, (string)?] + ): Promise { + let params: { archiveId: string, services: string[], newResourceId?: string, newResourceName?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { archiveId: string, services: string[], newResourceId?: string, newResourceName?: string }; + } else { + params = { + archiveId: paramsOrFirst as string, + services: rest[0] as string[], + newResourceId: rest[1] as string, + newResourceName: rest[2] as string + }; + } + + const archiveId = params.archiveId; + const services = params.services; + const newResourceId = params.newResourceId; + const newResourceName = params.newResourceName; + + if (typeof archiveId === 'undefined') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + if (typeof services === 'undefined') { + throw new AppwriteException('Missing required parameter: "services"'); + } + + const apiPath = '/backups/restoration'; + const payload: Payload = {}; + if (typeof archiveId !== 'undefined') { + payload['archiveId'] = archiveId; + } + if (typeof services !== 'undefined') { + payload['services'] = services; + } + if (typeof newResourceId !== 'undefined') { + payload['newResourceId'] = newResourceId; + } + if (typeof newResourceName !== 'undefined') { + payload['newResourceName'] = newResourceName; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload, + ); + } + + /** + * List all backup restorations for a project. + * + * @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. + * @throws {AppwriteException} + * @returns {Promise} + */ + listRestorations(params?: { queries?: string[] }): Promise; + /** + * List all backup restorations for a project. + * + * @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. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRestorations(queries?: string[]): Promise; + listRestorations( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + + const apiPath = '/backups/restorations'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get the current status of a backup restoration. + * + * @param {string} params.restorationId - Restoration ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise} + */ + getRestoration(params: { restorationId: string }): Promise; + /** + * Get the current status of a backup restoration. + * + * @param {string} restorationId - Restoration ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRestoration(restorationId: string): Promise; + getRestoration( + paramsOrFirst: { restorationId: string } | string + ): Promise { + let params: { restorationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { restorationId: string }; + } else { + params = { + restorationId: paramsOrFirst as string + }; + } + + const restorationId = params.restorationId; + + if (typeof restorationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + + const apiPath = '/backups/restorations/{restorationId}'.replace('{restorationId}', restorationId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload, + ); + } +} diff --git a/src/services/databases.ts b/src/services/databases.ts index ad69b3e..4505473 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -2154,15 +2154,15 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value - * @param {number} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} params.array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIntegerColumn` instead. */ - createIntegerAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }): Promise; + createIntegerAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise; /** * Create an integer attribute. Optionally, minimum and maximum values can be provided. * @@ -2171,32 +2171,32 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number} min - Minimum value - * @param {number} max - Maximum value - * @param {number} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. * @param {boolean} array - Is attribute an array? * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise; + createIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise; createIntegerAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (boolean)?] + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number, - max: rest[4] as number, - xdefault: rest[5] as number, + min: rest[3] as number | bigint, + max: rest[4] as number | bigint, + xdefault: rest[5] as number | bigint, array: rest[6] as boolean }; } @@ -2265,15 +2265,15 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @param {boolean} params.required - Is attribute required? - * @param {number} params.xdefault - Default value. Cannot be set when attribute is required. - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value + * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value * @param {string} params.newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead. */ - updateIntegerAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }): Promise; + updateIntegerAttribute(params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise; /** * Update an integer attribute. Changing the `default` value will not update already existing documents. * @@ -2282,32 +2282,32 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @param {boolean} required - Is attribute required? - * @param {number} xdefault - Default value. Cannot be set when attribute is required. - * @param {number} min - Minimum value - * @param {number} max - Maximum value + * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value * @param {string} newKey - New Attribute Key. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise; + updateIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise; updateIntegerAttribute( - paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (string)?] + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] ): Promise { - let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number, - min: rest[4] as number, - max: rest[5] as number, + xdefault: rest[3] as number | bigint, + min: rest[4] as number | bigint, + max: rest[5] as number | bigint, newKey: rest[6] as string }; } @@ -3632,10 +3632,10 @@ export class Databases { * @param {string} params.collectionId - Collection ID. * @param {string} params.key - Attribute Key. * @throws {AppwriteException} - * @returns {Promise<{}>} + * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getColumn` instead. */ - getAttribute(params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + getAttribute(params: { databaseId: string, collectionId: string, key: string }): Promise; /** * Get attribute by ID. * @@ -3643,14 +3643,14 @@ export class Databases { * @param {string} collectionId - Collection ID. * @param {string} key - Attribute Key. * @throws {AppwriteException} - * @returns {Promise<{}>} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getAttribute(databaseId: string, collectionId: string, key: string): Promise<{}>; + getAttribute(databaseId: string, collectionId: string, key: string): Promise; getAttribute( paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, ...rest: [(string)?, (string)?] - ): Promise<{}> { + ): Promise { let params: { databaseId: string, collectionId: string, key: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { @@ -4429,7 +4429,7 @@ export class Databases { * @returns {Promise} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead. */ - upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; + upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise; /** * 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. * @@ -4443,15 +4443,15 @@ export class Databases { * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - upsertDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; + upsertDocument(databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise; upsertDocument( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string, ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?, (string)?] ): Promise { - let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + let params: { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data?: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, @@ -4479,9 +4479,6 @@ export class Databases { if (typeof documentId === 'undefined') { throw new AppwriteException('Missing required parameter: "documentId"'); } - if (typeof data === 'undefined') { - throw new AppwriteException('Missing required parameter: "data"'); - } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); const payload: Payload = {}; diff --git a/src/services/organizations.ts b/src/services/organizations.ts new file mode 100644 index 0000000..ab206de --- /dev/null +++ b/src/services/organizations.ts @@ -0,0 +1,115 @@ +import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + + +export class Organizations { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + /** + * Delete an organization. + * + * @param {string} params.organizationId - Team ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { organizationId: string }): Promise<{}>; + /** + * Delete an organization. + * + * @param {string} organizationId - Team ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(organizationId: string): Promise<{}>; + delete( + paramsOrFirst: { organizationId: string } | string + ): Promise<{}> { + let params: { organizationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { organizationId: string }; + } else { + params = { + organizationId: paramsOrFirst as string + }; + } + + const organizationId = params.organizationId; + + if (typeof organizationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "organizationId"'); + } + + const apiPath = '/organizations/{organizationId}'.replace('{organizationId}', organizationId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload, + ); + } + + /** + * Get estimation for deleting an organization. + * + * @param {string} params.organizationId - Team ID. + * @throws {AppwriteException} + * @returns {Promise} + */ + estimationDeleteOrganization(params: { organizationId: string }): Promise; + /** + * Get estimation for deleting an organization. + * + * @param {string} organizationId - Team ID. + * @throws {AppwriteException} + * @returns {Promise} + * @deprecated Use the object parameter style method for a better developer experience. + */ + estimationDeleteOrganization(organizationId: string): Promise; + estimationDeleteOrganization( + paramsOrFirst: { organizationId: string } | string + ): Promise { + let params: { organizationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { organizationId: string }; + } else { + params = { + organizationId: paramsOrFirst as string + }; + } + + const organizationId = params.organizationId; + + if (typeof organizationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "organizationId"'); + } + + const apiPath = '/organizations/{organizationId}/estimations/delete-organization'.replace('{organizationId}', organizationId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload, + ); + } +} diff --git a/src/services/storage.ts b/src/services/storage.ts index 3a115aa..1537754 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -86,9 +86,9 @@ export class Storage { * @param {string[]} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 30MB. + * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} params.compression - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} params.transformations - Are image transformations enabled? @@ -104,9 +104,9 @@ export class Storage { * @param {string[]} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 30MB. + * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} compression - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} transformations - Are image transformations enabled? @@ -266,9 +266,9 @@ export class Storage { * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 30MB. + * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} params.compression - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} params.transformations - Are image transformations enabled? @@ -284,9 +284,9 @@ export class Storage { * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. - * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 30MB. + * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - * @param {Compression} compression - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled * @param {boolean} transformations - Are image transformations enabled? @@ -669,10 +669,10 @@ export class Storage { /** * Update a file by its unique ID. Only users with write permissions have access to update this resource. * - * @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). - * @param {string} params.fileId - File unique ID. - * @param {string} params.name - Name of the file - * @param {string[]} params.permissions - An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.bucketId - Bucket unique ID. + * @param {string} params.fileId - File ID. + * @param {string} params.name - File name. + * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise} */ @@ -680,10 +680,10 @@ export class Storage { /** * Update a file by its unique ID. Only users with write permissions have access to update this resource. * - * @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). - * @param {string} fileId - File unique ID. - * @param {string} name - Name of the file - * @param {string[]} permissions - An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} bucketId - Bucket unique ID. + * @param {string} fileId - File ID. + * @param {string} name - File name. + * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index 846718c..9fa5afd 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -2131,14 +2131,14 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value - * @param {number} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. * @param {boolean} params.array - Is column an array? * @throws {AppwriteException} * @returns {Promise} */ - createIntegerColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }): Promise; + createIntegerColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise; /** * Create an integer column. Optionally, minimum and maximum values can be provided. * @@ -2147,32 +2147,32 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number} min - Minimum value - * @param {number} max - Maximum value - * @param {number} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. * @param {boolean} array - Is column an array? * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - createIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise; + createIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise; createIntegerColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (boolean)?] + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - min: rest[3] as number, - max: rest[4] as number, - xdefault: rest[5] as number, + min: rest[3] as number | bigint, + max: rest[4] as number | bigint, + xdefault: rest[5] as number | bigint, array: rest[6] as boolean }; } @@ -2241,14 +2241,14 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @param {boolean} params.required - Is column required? - * @param {number} params.xdefault - Default value. Cannot be set when column is required. - * @param {number} params.min - Minimum value - * @param {number} params.max - Maximum value + * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value * @param {string} params.newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise} */ - updateIntegerColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }): Promise; + updateIntegerColumn(params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise; /** * Update an integer column. Changing the `default` value will not update already existing rows. * @@ -2257,32 +2257,32 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @param {boolean} required - Is column required? - * @param {number} xdefault - Default value. Cannot be set when column is required. - * @param {number} min - Minimum value - * @param {number} max - Maximum value + * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value * @param {string} newKey - New Column Key. * @throws {AppwriteException} * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - updateIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise; + updateIntegerColumn(databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise; updateIntegerColumn( - paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string } | string, - ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (string)?] + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] ): Promise { - let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; } else { params = { databaseId: paramsOrFirst as string, tableId: rest[0] as string, key: rest[1] as string, required: rest[2] as boolean, - xdefault: rest[3] as number, - min: rest[4] as number, - max: rest[5] as number, + xdefault: rest[3] as number | bigint, + min: rest[4] as number | bigint, + max: rest[5] as number | bigint, newKey: rest[6] as string }; } @@ -3594,9 +3594,9 @@ export class TablesDB { * @param {string} params.tableId - Table ID. * @param {string} params.key - Column Key. * @throws {AppwriteException} - * @returns {Promise<{}>} + * @returns {Promise} */ - getColumn(params: { databaseId: string, tableId: string, key: string }): Promise<{}>; + getColumn(params: { databaseId: string, tableId: string, key: string }): Promise; /** * Get column by ID. * @@ -3604,14 +3604,14 @@ export class TablesDB { * @param {string} tableId - Table ID. * @param {string} key - Column Key. * @throws {AppwriteException} - * @returns {Promise<{}>} + * @returns {Promise} * @deprecated Use the object parameter style method for a better developer experience. */ - getColumn(databaseId: string, tableId: string, key: string): Promise<{}>; + getColumn(databaseId: string, tableId: string, key: string): Promise; getColumn( paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, ...rest: [(string)?, (string)?] - ): Promise<{}> { + ): Promise { let params: { databaseId: string, tableId: string, key: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {