node-appwrite 17.2.0 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +67 -2
  2. package/dist/client.js +3 -3
  3. package/dist/client.js.map +1 -1
  4. package/dist/client.mjs +3 -3
  5. package/dist/client.mjs.map +1 -1
  6. package/dist/enums/{v-c-s-deployment-type.js → vcs-deployment-type.js} +1 -1
  7. package/dist/enums/vcs-deployment-type.js.map +1 -0
  8. package/dist/enums/{v-c-s-deployment-type.mjs → vcs-deployment-type.mjs} +2 -2
  9. package/dist/enums/vcs-deployment-type.mjs.map +1 -0
  10. package/dist/index.d.mts +2 -1
  11. package/dist/index.d.ts +2 -1
  12. package/dist/index.js +7 -2
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +2 -1
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/models.d.mts +717 -58
  17. package/dist/models.d.ts +717 -58
  18. package/dist/query.d.mts +70 -0
  19. package/dist/query.d.ts +70 -0
  20. package/dist/query.js +70 -0
  21. package/dist/query.js.map +1 -1
  22. package/dist/query.mjs +70 -0
  23. package/dist/query.mjs.map +1 -1
  24. package/dist/services/account.d.mts +625 -70
  25. package/dist/services/account.d.ts +625 -70
  26. package/dist/services/account.js +592 -292
  27. package/dist/services/account.js.map +1 -1
  28. package/dist/services/account.mjs +592 -292
  29. package/dist/services/account.mjs.map +1 -1
  30. package/dist/services/avatars.d.mts +157 -26
  31. package/dist/services/avatars.d.ts +157 -26
  32. package/dist/services/avatars.js +104 -93
  33. package/dist/services/avatars.js.map +1 -1
  34. package/dist/services/avatars.mjs +104 -93
  35. package/dist/services/avatars.mjs.map +1 -1
  36. package/dist/services/databases.d.mts +1224 -248
  37. package/dist/services/databases.d.ts +1224 -248
  38. package/dist/services/databases.js +877 -611
  39. package/dist/services/databases.js.map +1 -1
  40. package/dist/services/databases.mjs +877 -611
  41. package/dist/services/databases.mjs.map +1 -1
  42. package/dist/services/functions.d.mts +530 -107
  43. package/dist/services/functions.d.ts +530 -107
  44. package/dist/services/functions.js +393 -276
  45. package/dist/services/functions.js.map +1 -1
  46. package/dist/services/functions.mjs +393 -276
  47. package/dist/services/functions.mjs.map +1 -1
  48. package/dist/services/graphql.d.mts +24 -2
  49. package/dist/services/graphql.d.ts +24 -2
  50. package/dist/services/graphql.js +20 -16
  51. package/dist/services/graphql.js.map +1 -1
  52. package/dist/services/graphql.mjs +20 -16
  53. package/dist/services/graphql.mjs.map +1 -1
  54. package/dist/services/health.d.mts +175 -16
  55. package/dist/services/health.d.ts +175 -16
  56. package/dist/services/health.js +144 -115
  57. package/dist/services/health.js.map +1 -1
  58. package/dist/services/health.mjs +144 -115
  59. package/dist/services/health.mjs.map +1 -1
  60. package/dist/services/locale.js.map +1 -1
  61. package/dist/services/locale.mjs.map +1 -1
  62. package/dist/services/messaging.d.mts +1544 -262
  63. package/dist/services/messaging.d.ts +1544 -262
  64. package/dist/services/messaging.js +1417 -592
  65. package/dist/services/messaging.js.map +1 -1
  66. package/dist/services/messaging.mjs +1417 -592
  67. package/dist/services/messaging.mjs.map +1 -1
  68. package/dist/services/sites.d.mts +495 -99
  69. package/dist/services/sites.d.ts +495 -99
  70. package/dist/services/sites.js +371 -258
  71. package/dist/services/sites.js.map +1 -1
  72. package/dist/services/sites.mjs +371 -258
  73. package/dist/services/sites.mjs.map +1 -1
  74. package/dist/services/storage.d.mts +306 -63
  75. package/dist/services/storage.d.ts +306 -63
  76. package/dist/services/storage.js +225 -158
  77. package/dist/services/storage.js.map +1 -1
  78. package/dist/services/storage.mjs +225 -158
  79. package/dist/services/storage.mjs.map +1 -1
  80. package/dist/services/tables-db.d.mts +1549 -0
  81. package/dist/services/tables-db.d.ts +1549 -0
  82. package/dist/services/tables-db.js +2374 -0
  83. package/dist/services/tables-db.js.map +1 -0
  84. package/dist/services/tables-db.mjs +2373 -0
  85. package/dist/services/tables-db.mjs.map +1 -0
  86. package/dist/services/teams.d.mts +233 -39
  87. package/dist/services/teams.d.ts +233 -39
  88. package/dist/services/teams.js +170 -135
  89. package/dist/services/teams.js.map +1 -1
  90. package/dist/services/teams.mjs +170 -135
  91. package/dist/services/teams.mjs.map +1 -1
  92. package/dist/services/tokens.d.mts +76 -11
  93. package/dist/services/tokens.d.ts +76 -11
  94. package/dist/services/tokens.js +60 -45
  95. package/dist/services/tokens.js.map +1 -1
  96. package/dist/services/tokens.mjs +60 -45
  97. package/dist/services/tokens.mjs.map +1 -1
  98. package/dist/services/users.d.mts +842 -115
  99. package/dist/services/users.d.ts +842 -115
  100. package/dist/services/users.js +719 -408
  101. package/dist/services/users.js.map +1 -1
  102. package/dist/services/users.mjs +719 -408
  103. package/dist/services/users.mjs.map +1 -1
  104. package/package.json +1 -1
  105. package/dist/enums/v-c-s-deployment-type.js.map +0 -1
  106. package/dist/enums/v-c-s-deployment-type.mjs.map +0 -1
  107. /package/dist/enums/{v-c-s-deployment-type.d.mts → vcs-deployment-type.d.mts} +0 -0
  108. /package/dist/enums/{v-c-s-deployment-type.d.ts → vcs-deployment-type.d.ts} +0 -0
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Appwrite Node.js SDK
2
2
 
3
3
  ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?style=flat-square)
4
- ![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square)
4
+ ![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square)
5
5
  [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
6
6
  [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
7
7
  [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
8
8
 
9
- **This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).**
9
+ **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).**
10
10
 
11
11
  > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code.
12
12
  If you're looking to integrate from the browser, you should check [appwrite/sdk-for-web](https://github.com/appwrite/sdk-for-web)
@@ -27,6 +27,7 @@ npm install node-appwrite --save
27
27
  ## Getting Started
28
28
 
29
29
  ### Init your SDK
30
+
30
31
  Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key project API keys section.
31
32
 
32
33
  ```js
@@ -43,6 +44,7 @@ client
43
44
  ```
44
45
 
45
46
  ### Make Your First Request
47
+
46
48
  Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
47
49
 
48
50
  ```js
@@ -80,7 +82,70 @@ promise.then(function (response) {
80
82
  });
81
83
  ```
82
84
 
85
+ ### Type Safety with Models
86
+
87
+ The Appwrite Node SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a generic type parameter that allows you to specify your custom model type for full type safety.
88
+
89
+ **TypeScript:**
90
+ ```typescript
91
+ interface Book {
92
+ name: string;
93
+ author: string;
94
+ releaseYear?: string;
95
+ category?: string;
96
+ genre?: string[];
97
+ isCheckedOut: boolean;
98
+ }
99
+
100
+ const databases = new Databases(client);
101
+
102
+ try {
103
+ const documents = await databases.listDocuments<Book>(
104
+ 'your-database-id',
105
+ 'your-collection-id'
106
+ );
107
+
108
+ documents.documents.forEach(book => {
109
+ console.log(`Book: ${book.name} by ${book.author}`); // Now you have full type safety
110
+ });
111
+ } catch (error) {
112
+ console.error('Appwrite error:', error);
113
+ }
114
+ ```
115
+
116
+ **JavaScript (with JSDoc for type hints):**
117
+ ```javascript
118
+ /**
119
+ * @typedef {Object} Book
120
+ * @property {string} name
121
+ * @property {string} author
122
+ * @property {string} [releaseYear]
123
+ * @property {string} [category]
124
+ * @property {string[]} [genre]
125
+ * @property {boolean} isCheckedOut
126
+ */
127
+
128
+ const databases = new Databases(client);
129
+
130
+ try {
131
+ /** @type {Models.DocumentList<Book>} */
132
+ const documents = await databases.listDocuments(
133
+ 'your-database-id',
134
+ 'your-collection-id'
135
+ );
136
+
137
+ documents.documents.forEach(book => {
138
+ console.log(`Book: ${book.name} by ${book.author}`); // Type hints available in IDE
139
+ });
140
+ } catch (error) {
141
+ console.error('Appwrite error:', error);
142
+ }
143
+ ```
144
+
145
+ **Tip**: You can use the `appwrite types` command to automatically generate TypeScript interfaces based on your Appwrite database schema. Learn more about [type generation](https://appwrite.io/docs/products/databases/type-generation).
146
+
83
147
  ### Error Handling
148
+
84
149
  The Appwrite Node SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.
85
150
 
86
151
  ```js
package/dist/client.js CHANGED
@@ -15,7 +15,7 @@ class AppwriteException extends Error {
15
15
  }
16
16
  }
17
17
  function getUserAgent() {
18
- let ua = "AppwriteNodeJSSDK/17.2.0";
18
+ let ua = "AppwriteNodeJSSDK/18.0.0";
19
19
  const platform = [];
20
20
  if (typeof process !== "undefined") {
21
21
  if (typeof process.platform === "string")
@@ -51,9 +51,9 @@ const _Client = class _Client {
51
51
  "x-sdk-name": "Node.js",
52
52
  "x-sdk-platform": "server",
53
53
  "x-sdk-language": "nodejs",
54
- "x-sdk-version": "17.2.0",
54
+ "x-sdk-version": "18.0.0",
55
55
  "user-agent": getUserAgent(),
56
- "X-Appwrite-Response-Format": "1.7.0"
56
+ "X-Appwrite-Response-Format": "1.8.0"
57
57
  };
58
58
  }
59
59
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"names":[],"mappings":"AAAA,SAAS,OAAO,UAAU,YAAY;AACtC,SAAS,mBAAmB;AAmB5B,MAAM,0BAA0B,MAAM;AAAA,EAIlC,YAAY,SAAiB,OAAe,GAAG,OAAe,I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I,eAAe;AACnB,YAAI,cAAS,QAAQ,IAAI,cAAc,MAAnC,mBAAsC,SAAS,wBAAuB,iBAAiB,eAAe;AACtG,uBAAe,KAAK,UAAU,IAAI;AAAA,MACtC,OAAO;AACH,uBAAe,6BAAM;AAAA,MACzB;AACA,YAAM,IAAI,kBAAkB,6BAAM,SAAS,SAAS,QAAQ,6BAAM,MAAM,YAAY;AAAA,IACxF;AAEA,WAAO;AAAA,EACX;AAAA,EAEA,OAAO,QAAQ,MAAe,SAAS,IAAa;AAChD,QAAI,SAAkB,CAAC;AAEvB,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAC7C,UAAI,WAAW,SAAS,SAAS,MAAM,MAAK,MAAM;AAClD,UAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,iBAAS,EAAE,GAAG,QAAQ,GAAG,QAAO,QAAQ,OAAO,QAAQ,EAAE;AAAA,MAC7D,OAAO;AACH,eAAO,QAAQ,IAAI;AAAA,MACvB;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AACJ;AA5TM,QACK,aAAa,OAAO,OAAO;AADtC,IAAM,SAAN;AA+TA,SAAS,aAAa","sourcesContent":["import { fetch, FormData, File } from 'node-fetch-native-with-agent';\nimport { createAgent } from 'node-fetch-native-with-agent/agent';\nimport { Models } from './models';\n\ntype Payload = {\n [key: string]: any;\n}\n\ntype UploadProgress = {\n $id: string;\n progress: number;\n sizeUploaded: number;\n chunksTotal: number;\n chunksUploaded: number;\n}\n\ntype Headers = {\n [key: string]: string;\n}\n\nclass AppwriteException extends Error {\n code: number;\n response: string;\n type: string;\n constructor(message: string, code: number = 0, type: string = '', response: string = '') {\n super(message);\n this.name = 'AppwriteException';\n this.message = message;\n this.code = code;\n this.type = type;\n this.response = response;\n }\n}\n\nfunction getUserAgent() {\n let ua = 'AppwriteNodeJSSDK/17.2.0';\n\n // `process` is a global in Node.js, but not fully available in all runtimes.\n const platform: string[] = [];\n if (typeof process !== 'undefined') {\n if (typeof process.platform === 'string') platform.push(process.platform);\n if (typeof process.arch === 'string') platform.push(process.arch);\n } \n if (platform.length > 0) {\n ua += ` (${platform.join('; ')})`;\n }\n\n // `navigator.userAgent` is available in Node.js 21 and later.\n // It's also part of the WinterCG spec, so many edge runtimes provide it.\n // https://common-min-api.proposal.wintercg.org/#requirements-for-navigatoruseragent\n // @ts-ignore\n if (typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string') {\n // @ts-ignore\n ua += ` ${navigator.userAgent}`;\n\n // @ts-ignore\n } else if (typeof globalThis.EdgeRuntime === 'string') {\n ua += ` EdgeRuntime`;\n\n // Older Node.js versions don't have `navigator.userAgent`, so we have to use `process.version`.\n } else if (typeof process !== 'undefined' && typeof process.version === 'string') {\n ua += ` Node.js/${process.version}`;\n }\n\n return ua;\n}\n\nclass Client {\n static CHUNK_SIZE = 1024 * 1024 * 5;\n\n config = {\n endpoint: 'https://cloud.appwrite.io/v1',\n selfSigned: false,\n project: '',\n key: '',\n jwt: '',\n locale: '',\n session: '',\n forwardeduseragent: '',\n };\n headers: Headers = {\n 'x-sdk-name': 'Node.js',\n 'x-sdk-platform': 'server',\n 'x-sdk-language': 'nodejs',\n 'x-sdk-version': '17.2.0',\n 'user-agent' : getUserAgent(),\n 'X-Appwrite-Response-Format': '1.7.0',\n };\n\n /**\n * Set Endpoint\n *\n * Your project endpoint\n *\n * @param {string} endpoint\n *\n * @returns {this}\n */\n setEndpoint(endpoint: string): this {\n if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {\n throw new AppwriteException('Invalid endpoint URL: ' + endpoint);\n }\n\n this.config.endpoint = endpoint;\n return this;\n }\n\n /**\n * Set self-signed\n *\n * @param {boolean} selfSigned\n *\n * @returns {this}\n */\n setSelfSigned(selfSigned: boolean): this {\n // @ts-ignore\n if (typeof globalThis.EdgeRuntime !== 'undefined') {\n console.warn('setSelfSigned is not supported in edge runtimes.');\n }\n\n this.config.selfSigned = selfSigned;\n\n return this;\n }\n\n /**\n * Add header\n *\n * @param {string} header\n * @param {string} value\n *\n * @returns {this}\n */\n addHeader(header: string, value: string): this {\n this.headers[header.toLowerCase()] = value;\n\n return this;\n }\n\n /**\n * Set Project\n *\n * Your project ID\n *\n * @param value string\n *\n * @return {this}\n */\n setProject(value: string): this {\n this.headers['X-Appwrite-Project'] = value;\n this.config.project = value;\n return this;\n }\n /**\n * Set Key\n *\n * Your secret API key\n *\n * @param value string\n *\n * @return {this}\n */\n setKey(value: string): this {\n this.headers['X-Appwrite-Key'] = value;\n this.config.key = value;\n return this;\n }\n /**\n * Set JWT\n *\n * Your secret JSON Web Token\n *\n * @param value string\n *\n * @return {this}\n */\n setJWT(value: string): this {\n this.headers['X-Appwrite-JWT'] = value;\n this.config.jwt = value;\n return this;\n }\n /**\n * Set Locale\n *\n * @param value string\n *\n * @return {this}\n */\n setLocale(value: string): this {\n this.headers['X-Appwrite-Locale'] = value;\n this.config.locale = value;\n return this;\n }\n /**\n * Set Session\n *\n * The user session to authenticate with\n *\n * @param value string\n *\n * @return {this}\n */\n setSession(value: string): this {\n this.headers['X-Appwrite-Session'] = value;\n this.config.session = value;\n return this;\n }\n /**\n * Set ForwardedUserAgent\n *\n * The user agent string of the client that made the request\n *\n * @param value string\n *\n * @return {this}\n */\n setForwardedUserAgent(value: string): this {\n this.headers['X-Forwarded-User-Agent'] = value;\n this.config.forwardeduseragent = value;\n return this;\n }\n\n prepareRequest(method: string, url: URL, headers: Headers = {}, params: Payload = {}): { uri: string, options: RequestInit } {\n method = method.toUpperCase();\n\n headers = Object.assign({}, this.headers, headers);\n\n let options: RequestInit = {\n method,\n headers,\n ...createAgent(this.config.endpoint, { rejectUnauthorized: !this.config.selfSigned }),\n };\n\n if (method === 'GET') {\n for (const [key, value] of Object.entries(Client.flatten(params))) {\n url.searchParams.append(key, value);\n }\n } else {\n switch (headers['content-type']) {\n case 'application/json':\n options.body = JSON.stringify(params);\n break;\n\n case 'multipart/form-data':\n const formData = new FormData();\n\n for (const [key, value] of Object.entries(params)) {\n if (value instanceof File) {\n formData.append(key, value, value.name);\n } else if (Array.isArray(value)) {\n for (const nestedValue of value) {\n formData.append(`${key}[]`, nestedValue);\n }\n } else {\n formData.append(key, value);\n }\n }\n\n options.body = formData;\n delete headers['content-type'];\n break;\n }\n }\n\n return { uri: url.toString(), options };\n }\n\n async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {\n const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? [];\n\n if (!file || !fileParam) {\n throw new Error('File not found in payload');\n }\n\n if (file.size <= Client.CHUNK_SIZE) {\n return await this.call(method, url, headers, originalPayload);\n }\n\n let start = 0;\n let response = null;\n\n while (start < file.size) {\n let end = start + Client.CHUNK_SIZE; // Prepare end for the next chunk\n if (end >= file.size) {\n end = file.size; // Adjust for the last chunk to include the last byte\n }\n\n headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`;\n const chunk = file.slice(start, end);\n\n let payload = { ...originalPayload };\n payload[fileParam] = new File([chunk], file.name);\n\n response = await this.call(method, url, headers, payload);\n\n if (onProgress && typeof onProgress === 'function') {\n onProgress({\n $id: response.$id,\n progress: Math.round((end / file.size) * 100),\n sizeUploaded: end,\n chunksTotal: Math.ceil(file.size / Client.CHUNK_SIZE),\n chunksUploaded: Math.ceil(end / Client.CHUNK_SIZE)\n });\n }\n\n if (response && response.$id) {\n headers['x-appwrite-id'] = response.$id;\n }\n\n start = end;\n }\n\n return response;\n }\n\n async ping(): Promise<string> {\n return this.call('GET', new URL(this.config.endpoint + '/ping'));\n }\n\n async redirect(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise<string> {\n const { uri, options } = this.prepareRequest(method, url, headers, params);\n \n const response = await fetch(uri, {\n ...options,\n redirect: 'manual'\n });\n\n if (response.status !== 301 && response.status !== 302) {\n throw new AppwriteException('Invalid redirect', response.status);\n }\n\n return response.headers.get('location') || '';\n }\n\n async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise<any> {\n const { uri, options } = this.prepareRequest(method, url, headers, params);\n\n let data: any = null;\n\n const response = await fetch(uri, options);\n\n const warnings = response.headers.get('x-appwrite-warning');\n if (warnings) {\n warnings.split(';').forEach((warning: string) => console.warn('Warning: ' + warning));\n }\n\n if (response.headers.get('content-type')?.includes('application/json')) {\n data = await response.json();\n } else if (responseType === 'arrayBuffer') {\n data = await response.arrayBuffer();\n } else {\n data = {\n message: await response.text()\n };\n }\n\n if (400 <= response.status) {\n let responseText = '';\n if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') {\n responseText = JSON.stringify(data);\n } else {\n responseText = data?.message;\n }\n throw new AppwriteException(data?.message, response.status, data?.type, responseText);\n }\n\n return data;\n }\n\n static flatten(data: Payload, prefix = ''): Payload {\n let output: Payload = {};\n\n for (const [key, value] of Object.entries(data)) {\n let finalKey = prefix ? prefix + '[' + key +']' : key;\n if (Array.isArray(value)) {\n output = { ...output, ...Client.flatten(value, finalKey) };\n } else {\n output[finalKey] = value;\n }\n }\n\n return output;\n }\n}\n\nexport { Client, AppwriteException };\nexport { Query } from './query';\nexport type { Models, Payload, UploadProgress };\nexport type { QueryTypes, QueryTypesList } from './query';\n"]}
1
+ {"version":3,"sources":["../src/client.ts"],"names":[],"mappings":"AAAA,SAAS,OAAO,UAAU,YAAY;AACtC,SAAS,mBAAmB;AAmB5B,MAAM,0BAA0B,MAAM;AAAA,EAIlC,YAAY,SAAiB,OAAe,GAAG,OAAe,IAAI,WAAmB,IAAI;AACrF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EACpB;AACJ;AAEA,SAAS,eAAe;AACpB,MAAI,KAAK;AAGT,QAAM,WAAqB,CAAC;AAC5B,MAAI,OAAO,YAAY,aAAa;AAChC,QAAI,OAAO,QAAQ,aAAa;AAAU,eAAS,KAAK,QAA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,OAAO,QAAQ,MAAe,SAAS,IAAa;AAChD,QAAI,SAAkB,CAAC;AAEvB,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAC7C,UAAI,WAAW,SAAS,SAAS,MAAM,MAAK,MAAM;AAClD,UAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,iBAAS,EAAE,GAAG,QAAQ,GAAG,QAAO,QAAQ,OAAO,QAAQ,EAAE;AAAA,MAC7D,OAAO;AACH,eAAO,QAAQ,IAAI;AAAA,MACvB;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AACJ;AA5TM,QACK,aAAa,OAAO,OAAO;AADtC,IAAM,SAAN;AA+TA,SAAS,aAAa","sourcesContent":["import { fetch, FormData, File } from 'node-fetch-native-with-agent';\nimport { createAgent } from 'node-fetch-native-with-agent/agent';\nimport { Models } from './models';\n\ntype Payload = {\n [key: string]: any;\n}\n\ntype UploadProgress = {\n $id: string;\n progress: number;\n sizeUploaded: number;\n chunksTotal: number;\n chunksUploaded: number;\n}\n\ntype Headers = {\n [key: string]: string;\n}\n\nclass AppwriteException extends Error {\n code: number;\n response: string;\n type: string;\n constructor(message: string, code: number = 0, type: string = '', response: string = '') {\n super(message);\n this.name = 'AppwriteException';\n this.message = message;\n this.code = code;\n this.type = type;\n this.response = response;\n }\n}\n\nfunction getUserAgent() {\n let ua = 'AppwriteNodeJSSDK/18.0.0';\n\n // `process` is a global in Node.js, but not fully available in all runtimes.\n const platform: string[] = [];\n if (typeof process !== 'undefined') {\n if (typeof process.platform === 'string') platform.push(process.platform);\n if (typeof process.arch === 'string') platform.push(process.arch);\n } \n if (platform.length > 0) {\n ua += ` (${platform.join('; ')})`;\n }\n\n // `navigator.userAgent` is available in Node.js 21 and later.\n // It's also part of the WinterCG spec, so many edge runtimes provide it.\n // https://common-min-api.proposal.wintercg.org/#requirements-for-navigatoruseragent\n // @ts-ignore\n if (typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string') {\n // @ts-ignore\n ua += ` ${navigator.userAgent}`;\n\n // @ts-ignore\n } else if (typeof globalThis.EdgeRuntime === 'string') {\n ua += ` EdgeRuntime`;\n\n // Older Node.js versions don't have `navigator.userAgent`, so we have to use `process.version`.\n } else if (typeof process !== 'undefined' && typeof process.version === 'string') {\n ua += ` Node.js/${process.version}`;\n }\n\n return ua;\n}\n\nclass Client {\n static CHUNK_SIZE = 1024 * 1024 * 5;\n\n config = {\n endpoint: 'https://cloud.appwrite.io/v1',\n selfSigned: false,\n project: '',\n key: '',\n jwt: '',\n locale: '',\n session: '',\n forwardeduseragent: '',\n };\n headers: Headers = {\n 'x-sdk-name': 'Node.js',\n 'x-sdk-platform': 'server',\n 'x-sdk-language': 'nodejs',\n 'x-sdk-version': '18.0.0',\n 'user-agent' : getUserAgent(),\n 'X-Appwrite-Response-Format': '1.8.0',\n };\n\n /**\n * Set Endpoint\n *\n * Your project endpoint\n *\n * @param {string} endpoint\n *\n * @returns {this}\n */\n setEndpoint(endpoint: string): this {\n if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {\n throw new AppwriteException('Invalid endpoint URL: ' + endpoint);\n }\n\n this.config.endpoint = endpoint;\n return this;\n }\n\n /**\n * Set self-signed\n *\n * @param {boolean} selfSigned\n *\n * @returns {this}\n */\n setSelfSigned(selfSigned: boolean): this {\n // @ts-ignore\n if (typeof globalThis.EdgeRuntime !== 'undefined') {\n console.warn('setSelfSigned is not supported in edge runtimes.');\n }\n\n this.config.selfSigned = selfSigned;\n\n return this;\n }\n\n /**\n * Add header\n *\n * @param {string} header\n * @param {string} value\n *\n * @returns {this}\n */\n addHeader(header: string, value: string): this {\n this.headers[header.toLowerCase()] = value;\n\n return this;\n }\n\n /**\n * Set Project\n *\n * Your project ID\n *\n * @param value string\n *\n * @return {this}\n */\n setProject(value: string): this {\n this.headers['X-Appwrite-Project'] = value;\n this.config.project = value;\n return this;\n }\n /**\n * Set Key\n *\n * Your secret API key\n *\n * @param value string\n *\n * @return {this}\n */\n setKey(value: string): this {\n this.headers['X-Appwrite-Key'] = value;\n this.config.key = value;\n return this;\n }\n /**\n * Set JWT\n *\n * Your secret JSON Web Token\n *\n * @param value string\n *\n * @return {this}\n */\n setJWT(value: string): this {\n this.headers['X-Appwrite-JWT'] = value;\n this.config.jwt = value;\n return this;\n }\n /**\n * Set Locale\n *\n * @param value string\n *\n * @return {this}\n */\n setLocale(value: string): this {\n this.headers['X-Appwrite-Locale'] = value;\n this.config.locale = value;\n return this;\n }\n /**\n * Set Session\n *\n * The user session to authenticate with\n *\n * @param value string\n *\n * @return {this}\n */\n setSession(value: string): this {\n this.headers['X-Appwrite-Session'] = value;\n this.config.session = value;\n return this;\n }\n /**\n * Set ForwardedUserAgent\n *\n * The user agent string of the client that made the request\n *\n * @param value string\n *\n * @return {this}\n */\n setForwardedUserAgent(value: string): this {\n this.headers['X-Forwarded-User-Agent'] = value;\n this.config.forwardeduseragent = value;\n return this;\n }\n\n prepareRequest(method: string, url: URL, headers: Headers = {}, params: Payload = {}): { uri: string, options: RequestInit } {\n method = method.toUpperCase();\n\n headers = Object.assign({}, this.headers, headers);\n\n let options: RequestInit = {\n method,\n headers,\n ...createAgent(this.config.endpoint, { rejectUnauthorized: !this.config.selfSigned }),\n };\n\n if (method === 'GET') {\n for (const [key, value] of Object.entries(Client.flatten(params))) {\n url.searchParams.append(key, value);\n }\n } else {\n switch (headers['content-type']) {\n case 'application/json':\n options.body = JSON.stringify(params);\n break;\n\n case 'multipart/form-data':\n const formData = new FormData();\n\n for (const [key, value] of Object.entries(params)) {\n if (value instanceof File) {\n formData.append(key, value, value.name);\n } else if (Array.isArray(value)) {\n for (const nestedValue of value) {\n formData.append(`${key}[]`, nestedValue);\n }\n } else {\n formData.append(key, value);\n }\n }\n\n options.body = formData;\n delete headers['content-type'];\n break;\n }\n }\n\n return { uri: url.toString(), options };\n }\n\n async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {\n const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? [];\n\n if (!file || !fileParam) {\n throw new Error('File not found in payload');\n }\n\n if (file.size <= Client.CHUNK_SIZE) {\n return await this.call(method, url, headers, originalPayload);\n }\n\n let start = 0;\n let response = null;\n\n while (start < file.size) {\n let end = start + Client.CHUNK_SIZE; // Prepare end for the next chunk\n if (end >= file.size) {\n end = file.size; // Adjust for the last chunk to include the last byte\n }\n\n headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`;\n const chunk = file.slice(start, end);\n\n let payload = { ...originalPayload };\n payload[fileParam] = new File([chunk], file.name);\n\n response = await this.call(method, url, headers, payload);\n\n if (onProgress && typeof onProgress === 'function') {\n onProgress({\n $id: response.$id,\n progress: Math.round((end / file.size) * 100),\n sizeUploaded: end,\n chunksTotal: Math.ceil(file.size / Client.CHUNK_SIZE),\n chunksUploaded: Math.ceil(end / Client.CHUNK_SIZE)\n });\n }\n\n if (response && response.$id) {\n headers['x-appwrite-id'] = response.$id;\n }\n\n start = end;\n }\n\n return response;\n }\n\n async ping(): Promise<string> {\n return this.call('GET', new URL(this.config.endpoint + '/ping'));\n }\n\n async redirect(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise<string> {\n const { uri, options } = this.prepareRequest(method, url, headers, params);\n \n const response = await fetch(uri, {\n ...options,\n redirect: 'manual'\n });\n\n if (response.status !== 301 && response.status !== 302) {\n throw new AppwriteException('Invalid redirect', response.status);\n }\n\n return response.headers.get('location') || '';\n }\n\n async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise<any> {\n const { uri, options } = this.prepareRequest(method, url, headers, params);\n\n let data: any = null;\n\n const response = await fetch(uri, options);\n\n const warnings = response.headers.get('x-appwrite-warning');\n if (warnings) {\n warnings.split(';').forEach((warning: string) => console.warn('Warning: ' + warning));\n }\n\n if (response.headers.get('content-type')?.includes('application/json')) {\n data = await response.json();\n } else if (responseType === 'arrayBuffer') {\n data = await response.arrayBuffer();\n } else {\n data = {\n message: await response.text()\n };\n }\n\n if (400 <= response.status) {\n let responseText = '';\n if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') {\n responseText = JSON.stringify(data);\n } else {\n responseText = data?.message;\n }\n throw new AppwriteException(data?.message, response.status, data?.type, responseText);\n }\n\n return data;\n }\n\n static flatten(data: Payload, prefix = ''): Payload {\n let output: Payload = {};\n\n for (const [key, value] of Object.entries(data)) {\n let finalKey = prefix ? prefix + '[' + key +']' : key;\n if (Array.isArray(value)) {\n output = { ...output, ...Client.flatten(value, finalKey) };\n } else {\n output[finalKey] = value;\n }\n }\n\n return output;\n }\n}\n\nexport { Client, AppwriteException };\nexport { Query } from './query';\nexport type { Models, Payload, UploadProgress };\nexport type { QueryTypes, QueryTypesList } from './query';\n"]}
package/dist/client.mjs CHANGED
@@ -14,7 +14,7 @@ var AppwriteException = class extends Error {
14
14
  }
15
15
  };
16
16
  function getUserAgent() {
17
- let ua = "AppwriteNodeJSSDK/17.2.0";
17
+ let ua = "AppwriteNodeJSSDK/18.0.0";
18
18
  const platform = [];
19
19
  if (typeof process !== "undefined") {
20
20
  if (typeof process.platform === "string")
@@ -50,9 +50,9 @@ var _Client = class _Client {
50
50
  "x-sdk-name": "Node.js",
51
51
  "x-sdk-platform": "server",
52
52
  "x-sdk-language": "nodejs",
53
- "x-sdk-version": "17.2.0",
53
+ "x-sdk-version": "18.0.0",
54
54
  "user-agent": getUserAgent(),
55
- "X-Appwrite-Response-Format": "1.7.0"
55
+ "X-Appwrite-Response-Format": "1.8.0"
56
56
  };
57
57
  }
58
58
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"names":[],"mappings":";AAAA,SAAS,OAAO,UAAU,YAAY;AACtC,SAAS,mBAAmB;AAiY5B,SAAS,aAAa;AA9WtB,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAIlC,YAAY,SAAiB,OAAe,GAAG,OAAe,IAAI,WAAmB,IAAI;AACrF,UAAM,OAAO;AACb,S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Ac,MAAnC,mBAAsC,SAAS,wBAAuB,iBAAiB,eAAe;AACtG,uBAAe,KAAK,UAAU,IAAI;AAAA,MACtC,OAAO;AACH,uBAAe,6BAAM;AAAA,MACzB;AACA,YAAM,IAAI,kBAAkB,6BAAM,SAAS,SAAS,QAAQ,6BAAM,MAAM,YAAY;AAAA,IACxF;AAEA,WAAO;AAAA,EACX;AAAA,EAEA,OAAO,QAAQ,MAAe,SAAS,IAAa;AAChD,QAAI,SAAkB,CAAC;AAEvB,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAC7C,UAAI,WAAW,SAAS,SAAS,MAAM,MAAK,MAAM;AAClD,UAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,iBAAS,EAAE,GAAG,QAAQ,GAAG,QAAO,QAAQ,OAAO,QAAQ,EAAE;AAAA,MAC7D,OAAO;AACH,eAAO,QAAQ,IAAI;AAAA,MACvB;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AACJ;AA5TM,QACK,aAAa,OAAO,OAAO;AADtC,IAAM,SAAN","sourcesContent":["import { fetch, FormData, File } from 'node-fetch-native-with-agent';\nimport { createAgent } from 'node-fetch-native-with-agent/agent';\nimport { Models } from './models';\n\ntype Payload = {\n [key: string]: any;\n}\n\ntype UploadProgress = {\n $id: string;\n progress: number;\n sizeUploaded: number;\n chunksTotal: number;\n chunksUploaded: number;\n}\n\ntype Headers = {\n [key: string]: string;\n}\n\nclass AppwriteException extends Error {\n code: number;\n response: string;\n type: string;\n constructor(message: string, code: number = 0, type: string = '', response: string = '') {\n super(message);\n this.name = 'AppwriteException';\n this.message = message;\n this.code = code;\n this.type = type;\n this.response = response;\n }\n}\n\nfunction getUserAgent() {\n let ua = 'AppwriteNodeJSSDK/17.2.0';\n\n // `process` is a global in Node.js, but not fully available in all runtimes.\n const platform: string[] = [];\n if (typeof process !== 'undefined') {\n if (typeof process.platform === 'string') platform.push(process.platform);\n if (typeof process.arch === 'string') platform.push(process.arch);\n } \n if (platform.length > 0) {\n ua += ` (${platform.join('; ')})`;\n }\n\n // `navigator.userAgent` is available in Node.js 21 and later.\n // It's also part of the WinterCG spec, so many edge runtimes provide it.\n // https://common-min-api.proposal.wintercg.org/#requirements-for-navigatoruseragent\n // @ts-ignore\n if (typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string') {\n // @ts-ignore\n ua += ` ${navigator.userAgent}`;\n\n // @ts-ignore\n } else if (typeof globalThis.EdgeRuntime === 'string') {\n ua += ` EdgeRuntime`;\n\n // Older Node.js versions don't have `navigator.userAgent`, so we have to use `process.version`.\n } else if (typeof process !== 'undefined' && typeof process.version === 'string') {\n ua += ` Node.js/${process.version}`;\n }\n\n return ua;\n}\n\nclass Client {\n static CHUNK_SIZE = 1024 * 1024 * 5;\n\n config = {\n endpoint: 'https://cloud.appwrite.io/v1',\n selfSigned: false,\n project: '',\n key: '',\n jwt: '',\n locale: '',\n session: '',\n forwardeduseragent: '',\n };\n headers: Headers = {\n 'x-sdk-name': 'Node.js',\n 'x-sdk-platform': 'server',\n 'x-sdk-language': 'nodejs',\n 'x-sdk-version': '17.2.0',\n 'user-agent' : getUserAgent(),\n 'X-Appwrite-Response-Format': '1.7.0',\n };\n\n /**\n * Set Endpoint\n *\n * Your project endpoint\n *\n * @param {string} endpoint\n *\n * @returns {this}\n */\n setEndpoint(endpoint: string): this {\n if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {\n throw new AppwriteException('Invalid endpoint URL: ' + endpoint);\n }\n\n this.config.endpoint = endpoint;\n return this;\n }\n\n /**\n * Set self-signed\n *\n * @param {boolean} selfSigned\n *\n * @returns {this}\n */\n setSelfSigned(selfSigned: boolean): this {\n // @ts-ignore\n if (typeof globalThis.EdgeRuntime !== 'undefined') {\n console.warn('setSelfSigned is not supported in edge runtimes.');\n }\n\n this.config.selfSigned = selfSigned;\n\n return this;\n }\n\n /**\n * Add header\n *\n * @param {string} header\n * @param {string} value\n *\n * @returns {this}\n */\n addHeader(header: string, value: string): this {\n this.headers[header.toLowerCase()] = value;\n\n return this;\n }\n\n /**\n * Set Project\n *\n * Your project ID\n *\n * @param value string\n *\n * @return {this}\n */\n setProject(value: string): this {\n this.headers['X-Appwrite-Project'] = value;\n this.config.project = value;\n return this;\n }\n /**\n * Set Key\n *\n * Your secret API key\n *\n * @param value string\n *\n * @return {this}\n */\n setKey(value: string): this {\n this.headers['X-Appwrite-Key'] = value;\n this.config.key = value;\n return this;\n }\n /**\n * Set JWT\n *\n * Your secret JSON Web Token\n *\n * @param value string\n *\n * @return {this}\n */\n setJWT(value: string): this {\n this.headers['X-Appwrite-JWT'] = value;\n this.config.jwt = value;\n return this;\n }\n /**\n * Set Locale\n *\n * @param value string\n *\n * @return {this}\n */\n setLocale(value: string): this {\n this.headers['X-Appwrite-Locale'] = value;\n this.config.locale = value;\n return this;\n }\n /**\n * Set Session\n *\n * The user session to authenticate with\n *\n * @param value string\n *\n * @return {this}\n */\n setSession(value: string): this {\n this.headers['X-Appwrite-Session'] = value;\n this.config.session = value;\n return this;\n }\n /**\n * Set ForwardedUserAgent\n *\n * The user agent string of the client that made the request\n *\n * @param value string\n *\n * @return {this}\n */\n setForwardedUserAgent(value: string): this {\n this.headers['X-Forwarded-User-Agent'] = value;\n this.config.forwardeduseragent = value;\n return this;\n }\n\n prepareRequest(method: string, url: URL, headers: Headers = {}, params: Payload = {}): { uri: string, options: RequestInit } {\n method = method.toUpperCase();\n\n headers = Object.assign({}, this.headers, headers);\n\n let options: RequestInit = {\n method,\n headers,\n ...createAgent(this.config.endpoint, { rejectUnauthorized: !this.config.selfSigned }),\n };\n\n if (method === 'GET') {\n for (const [key, value] of Object.entries(Client.flatten(params))) {\n url.searchParams.append(key, value);\n }\n } else {\n switch (headers['content-type']) {\n case 'application/json':\n options.body = JSON.stringify(params);\n break;\n\n case 'multipart/form-data':\n const formData = new FormData();\n\n for (const [key, value] of Object.entries(params)) {\n if (value instanceof File) {\n formData.append(key, value, value.name);\n } else if (Array.isArray(value)) {\n for (const nestedValue of value) {\n formData.append(`${key}[]`, nestedValue);\n }\n } else {\n formData.append(key, value);\n }\n }\n\n options.body = formData;\n delete headers['content-type'];\n break;\n }\n }\n\n return { uri: url.toString(), options };\n }\n\n async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {\n const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? [];\n\n if (!file || !fileParam) {\n throw new Error('File not found in payload');\n }\n\n if (file.size <= Client.CHUNK_SIZE) {\n return await this.call(method, url, headers, originalPayload);\n }\n\n let start = 0;\n let response = null;\n\n while (start < file.size) {\n let end = start + Client.CHUNK_SIZE; // Prepare end for the next chunk\n if (end >= file.size) {\n end = file.size; // Adjust for the last chunk to include the last byte\n }\n\n headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`;\n const chunk = file.slice(start, end);\n\n let payload = { ...originalPayload };\n payload[fileParam] = new File([chunk], file.name);\n\n response = await this.call(method, url, headers, payload);\n\n if (onProgress && typeof onProgress === 'function') {\n onProgress({\n $id: response.$id,\n progress: Math.round((end / file.size) * 100),\n sizeUploaded: end,\n chunksTotal: Math.ceil(file.size / Client.CHUNK_SIZE),\n chunksUploaded: Math.ceil(end / Client.CHUNK_SIZE)\n });\n }\n\n if (response && response.$id) {\n headers['x-appwrite-id'] = response.$id;\n }\n\n start = end;\n }\n\n return response;\n }\n\n async ping(): Promise<string> {\n return this.call('GET', new URL(this.config.endpoint + '/ping'));\n }\n\n async redirect(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise<string> {\n const { uri, options } = this.prepareRequest(method, url, headers, params);\n \n const response = await fetch(uri, {\n ...options,\n redirect: 'manual'\n });\n\n if (response.status !== 301 && response.status !== 302) {\n throw new AppwriteException('Invalid redirect', response.status);\n }\n\n return response.headers.get('location') || '';\n }\n\n async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise<any> {\n const { uri, options } = this.prepareRequest(method, url, headers, params);\n\n let data: any = null;\n\n const response = await fetch(uri, options);\n\n const warnings = response.headers.get('x-appwrite-warning');\n if (warnings) {\n warnings.split(';').forEach((warning: string) => console.warn('Warning: ' + warning));\n }\n\n if (response.headers.get('content-type')?.includes('application/json')) {\n data = await response.json();\n } else if (responseType === 'arrayBuffer') {\n data = await response.arrayBuffer();\n } else {\n data = {\n message: await response.text()\n };\n }\n\n if (400 <= response.status) {\n let responseText = '';\n if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') {\n responseText = JSON.stringify(data);\n } else {\n responseText = data?.message;\n }\n throw new AppwriteException(data?.message, response.status, data?.type, responseText);\n }\n\n return data;\n }\n\n static flatten(data: Payload, prefix = ''): Payload {\n let output: Payload = {};\n\n for (const [key, value] of Object.entries(data)) {\n let finalKey = prefix ? prefix + '[' + key +']' : key;\n if (Array.isArray(value)) {\n output = { ...output, ...Client.flatten(value, finalKey) };\n } else {\n output[finalKey] = value;\n }\n }\n\n return output;\n }\n}\n\nexport { Client, AppwriteException };\nexport { Query } from './query';\nexport type { Models, Payload, UploadProgress };\nexport type { QueryTypes, QueryTypesList } from './query';\n"]}
1
+ {"version":3,"sources":["../src/client.ts"],"names":[],"mappings":";AAAA,SAAS,OAAO,UAAU,YAAY;AACtC,SAAS,mBAAmB;AAiY5B,SAAS,aAAa;AA9WtB,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAIlC,YAAY,SAAiB,OAAe,GAAG,OAAe,IAAI,WAAmB,IAAI;AACrF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EACpB;AACJ;AAEA,SAAS,eAAe;AACpB,MAAI,KAAK;AAGT,QAAM,WAAqB,CAAC;AAC5B,MAAI,OAAO,YAAY,aAAa;AAChC,QAAI,OAAO,QAAQ,aAAa;AAAU,eAAS,KAAK,QAAQ,QAAQ;AACxE,QAAI,OAAO,QAAQ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ChD,QAAI,SAAkB,CAAC;AAEvB,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAC7C,UAAI,WAAW,SAAS,SAAS,MAAM,MAAK,MAAM;AAClD,UAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,iBAAS,EAAE,GAAG,QAAQ,GAAG,QAAO,QAAQ,OAAO,QAAQ,EAAE;AAAA,MAC7D,OAAO;AACH,eAAO,QAAQ,IAAI;AAAA,MACvB;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AACJ;AA5TM,QACK,aAAa,OAAO,OAAO;AADtC,IAAM,SAAN","sourcesContent":["import { fetch, FormData, File } from 'node-fetch-native-with-agent';\nimport { createAgent } from 'node-fetch-native-with-agent/agent';\nimport { Models } from './models';\n\ntype Payload = {\n [key: string]: any;\n}\n\ntype UploadProgress = {\n $id: string;\n progress: number;\n sizeUploaded: number;\n chunksTotal: number;\n chunksUploaded: number;\n}\n\ntype Headers = {\n [key: string]: string;\n}\n\nclass AppwriteException extends Error {\n code: number;\n response: string;\n type: string;\n constructor(message: string, code: number = 0, type: string = '', response: string = '') {\n super(message);\n this.name = 'AppwriteException';\n this.message = message;\n this.code = code;\n this.type = type;\n this.response = response;\n }\n}\n\nfunction getUserAgent() {\n let ua = 'AppwriteNodeJSSDK/18.0.0';\n\n // `process` is a global in Node.js, but not fully available in all runtimes.\n const platform: string[] = [];\n if (typeof process !== 'undefined') {\n if (typeof process.platform === 'string') platform.push(process.platform);\n if (typeof process.arch === 'string') platform.push(process.arch);\n } \n if (platform.length > 0) {\n ua += ` (${platform.join('; ')})`;\n }\n\n // `navigator.userAgent` is available in Node.js 21 and later.\n // It's also part of the WinterCG spec, so many edge runtimes provide it.\n // https://common-min-api.proposal.wintercg.org/#requirements-for-navigatoruseragent\n // @ts-ignore\n if (typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string') {\n // @ts-ignore\n ua += ` ${navigator.userAgent}`;\n\n // @ts-ignore\n } else if (typeof globalThis.EdgeRuntime === 'string') {\n ua += ` EdgeRuntime`;\n\n // Older Node.js versions don't have `navigator.userAgent`, so we have to use `process.version`.\n } else if (typeof process !== 'undefined' && typeof process.version === 'string') {\n ua += ` Node.js/${process.version}`;\n }\n\n return ua;\n}\n\nclass Client {\n static CHUNK_SIZE = 1024 * 1024 * 5;\n\n config = {\n endpoint: 'https://cloud.appwrite.io/v1',\n selfSigned: false,\n project: '',\n key: '',\n jwt: '',\n locale: '',\n session: '',\n forwardeduseragent: '',\n };\n headers: Headers = {\n 'x-sdk-name': 'Node.js',\n 'x-sdk-platform': 'server',\n 'x-sdk-language': 'nodejs',\n 'x-sdk-version': '18.0.0',\n 'user-agent' : getUserAgent(),\n 'X-Appwrite-Response-Format': '1.8.0',\n };\n\n /**\n * Set Endpoint\n *\n * Your project endpoint\n *\n * @param {string} endpoint\n *\n * @returns {this}\n */\n setEndpoint(endpoint: string): this {\n if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {\n throw new AppwriteException('Invalid endpoint URL: ' + endpoint);\n }\n\n this.config.endpoint = endpoint;\n return this;\n }\n\n /**\n * Set self-signed\n *\n * @param {boolean} selfSigned\n *\n * @returns {this}\n */\n setSelfSigned(selfSigned: boolean): this {\n // @ts-ignore\n if (typeof globalThis.EdgeRuntime !== 'undefined') {\n console.warn('setSelfSigned is not supported in edge runtimes.');\n }\n\n this.config.selfSigned = selfSigned;\n\n return this;\n }\n\n /**\n * Add header\n *\n * @param {string} header\n * @param {string} value\n *\n * @returns {this}\n */\n addHeader(header: string, value: string): this {\n this.headers[header.toLowerCase()] = value;\n\n return this;\n }\n\n /**\n * Set Project\n *\n * Your project ID\n *\n * @param value string\n *\n * @return {this}\n */\n setProject(value: string): this {\n this.headers['X-Appwrite-Project'] = value;\n this.config.project = value;\n return this;\n }\n /**\n * Set Key\n *\n * Your secret API key\n *\n * @param value string\n *\n * @return {this}\n */\n setKey(value: string): this {\n this.headers['X-Appwrite-Key'] = value;\n this.config.key = value;\n return this;\n }\n /**\n * Set JWT\n *\n * Your secret JSON Web Token\n *\n * @param value string\n *\n * @return {this}\n */\n setJWT(value: string): this {\n this.headers['X-Appwrite-JWT'] = value;\n this.config.jwt = value;\n return this;\n }\n /**\n * Set Locale\n *\n * @param value string\n *\n * @return {this}\n */\n setLocale(value: string): this {\n this.headers['X-Appwrite-Locale'] = value;\n this.config.locale = value;\n return this;\n }\n /**\n * Set Session\n *\n * The user session to authenticate with\n *\n * @param value string\n *\n * @return {this}\n */\n setSession(value: string): this {\n this.headers['X-Appwrite-Session'] = value;\n this.config.session = value;\n return this;\n }\n /**\n * Set ForwardedUserAgent\n *\n * The user agent string of the client that made the request\n *\n * @param value string\n *\n * @return {this}\n */\n setForwardedUserAgent(value: string): this {\n this.headers['X-Forwarded-User-Agent'] = value;\n this.config.forwardeduseragent = value;\n return this;\n }\n\n prepareRequest(method: string, url: URL, headers: Headers = {}, params: Payload = {}): { uri: string, options: RequestInit } {\n method = method.toUpperCase();\n\n headers = Object.assign({}, this.headers, headers);\n\n let options: RequestInit = {\n method,\n headers,\n ...createAgent(this.config.endpoint, { rejectUnauthorized: !this.config.selfSigned }),\n };\n\n if (method === 'GET') {\n for (const [key, value] of Object.entries(Client.flatten(params))) {\n url.searchParams.append(key, value);\n }\n } else {\n switch (headers['content-type']) {\n case 'application/json':\n options.body = JSON.stringify(params);\n break;\n\n case 'multipart/form-data':\n const formData = new FormData();\n\n for (const [key, value] of Object.entries(params)) {\n if (value instanceof File) {\n formData.append(key, value, value.name);\n } else if (Array.isArray(value)) {\n for (const nestedValue of value) {\n formData.append(`${key}[]`, nestedValue);\n }\n } else {\n formData.append(key, value);\n }\n }\n\n options.body = formData;\n delete headers['content-type'];\n break;\n }\n }\n\n return { uri: url.toString(), options };\n }\n\n async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {\n const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? [];\n\n if (!file || !fileParam) {\n throw new Error('File not found in payload');\n }\n\n if (file.size <= Client.CHUNK_SIZE) {\n return await this.call(method, url, headers, originalPayload);\n }\n\n let start = 0;\n let response = null;\n\n while (start < file.size) {\n let end = start + Client.CHUNK_SIZE; // Prepare end for the next chunk\n if (end >= file.size) {\n end = file.size; // Adjust for the last chunk to include the last byte\n }\n\n headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`;\n const chunk = file.slice(start, end);\n\n let payload = { ...originalPayload };\n payload[fileParam] = new File([chunk], file.name);\n\n response = await this.call(method, url, headers, payload);\n\n if (onProgress && typeof onProgress === 'function') {\n onProgress({\n $id: response.$id,\n progress: Math.round((end / file.size) * 100),\n sizeUploaded: end,\n chunksTotal: Math.ceil(file.size / Client.CHUNK_SIZE),\n chunksUploaded: Math.ceil(end / Client.CHUNK_SIZE)\n });\n }\n\n if (response && response.$id) {\n headers['x-appwrite-id'] = response.$id;\n }\n\n start = end;\n }\n\n return response;\n }\n\n async ping(): Promise<string> {\n return this.call('GET', new URL(this.config.endpoint + '/ping'));\n }\n\n async redirect(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise<string> {\n const { uri, options } = this.prepareRequest(method, url, headers, params);\n \n const response = await fetch(uri, {\n ...options,\n redirect: 'manual'\n });\n\n if (response.status !== 301 && response.status !== 302) {\n throw new AppwriteException('Invalid redirect', response.status);\n }\n\n return response.headers.get('location') || '';\n }\n\n async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise<any> {\n const { uri, options } = this.prepareRequest(method, url, headers, params);\n\n let data: any = null;\n\n const response = await fetch(uri, options);\n\n const warnings = response.headers.get('x-appwrite-warning');\n if (warnings) {\n warnings.split(';').forEach((warning: string) => console.warn('Warning: ' + warning));\n }\n\n if (response.headers.get('content-type')?.includes('application/json')) {\n data = await response.json();\n } else if (responseType === 'arrayBuffer') {\n data = await response.arrayBuffer();\n } else {\n data = {\n message: await response.text()\n };\n }\n\n if (400 <= response.status) {\n let responseText = '';\n if (response.headers.get('content-type')?.includes('application/json') || responseType === 'arrayBuffer') {\n responseText = JSON.stringify(data);\n } else {\n responseText = data?.message;\n }\n throw new AppwriteException(data?.message, response.status, data?.type, responseText);\n }\n\n return data;\n }\n\n static flatten(data: Payload, prefix = ''): Payload {\n let output: Payload = {};\n\n for (const [key, value] of Object.entries(data)) {\n let finalKey = prefix ? prefix + '[' + key +']' : key;\n if (Array.isArray(value)) {\n output = { ...output, ...Client.flatten(value, finalKey) };\n } else {\n output[finalKey] = value;\n }\n }\n\n return output;\n }\n}\n\nexport { Client, AppwriteException };\nexport { Query } from './query';\nexport type { Models, Payload, UploadProgress };\nexport type { QueryTypes, QueryTypesList } from './query';\n"]}
@@ -9,4 +9,4 @@ var VCSDeploymentType = /* @__PURE__ */ ((VCSDeploymentType2) => {
9
9
 
10
10
  exports.VCSDeploymentType = VCSDeploymentType;
11
11
  //# sourceMappingURL=out.js.map
12
- //# sourceMappingURL=v-c-s-deployment-type.js.map
12
+ //# sourceMappingURL=vcs-deployment-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/enums/vcs-deployment-type.ts"],"names":["VCSDeploymentType"],"mappings":"AAAO,IAAK,oBAAL,kBAAKA,uBAAL;AACH,EAAAA,mBAAA,YAAS;AACT,EAAAA,mBAAA,YAAS;AACT,EAAAA,mBAAA,SAAM;AAHE,SAAAA;AAAA,GAAA","sourcesContent":["export enum VCSDeploymentType {\n Branch = 'branch',\n Commit = 'commit',\n Tag = 'tag',\n}"]}
@@ -1,4 +1,4 @@
1
- // src/enums/v-c-s-deployment-type.ts
1
+ // src/enums/vcs-deployment-type.ts
2
2
  var VCSDeploymentType = /* @__PURE__ */ ((VCSDeploymentType2) => {
3
3
  VCSDeploymentType2["Branch"] = "branch";
4
4
  VCSDeploymentType2["Commit"] = "commit";
@@ -8,4 +8,4 @@ var VCSDeploymentType = /* @__PURE__ */ ((VCSDeploymentType2) => {
8
8
 
9
9
  export { VCSDeploymentType };
10
10
  //# sourceMappingURL=out.js.map
11
- //# sourceMappingURL=v-c-s-deployment-type.mjs.map
11
+ //# sourceMappingURL=vcs-deployment-type.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/enums/vcs-deployment-type.ts"],"names":["VCSDeploymentType"],"mappings":";AAAO,IAAK,oBAAL,kBAAKA,uBAAL;AACH,EAAAA,mBAAA,YAAS;AACT,EAAAA,mBAAA,YAAS;AACT,EAAAA,mBAAA,SAAM;AAHE,SAAAA;AAAA,GAAA","sourcesContent":["export enum VCSDeploymentType {\n Branch = 'branch',\n Commit = 'commit',\n Tag = 'tag',\n}"]}
package/dist/index.d.mts CHANGED
@@ -9,6 +9,7 @@ export { Locale } from './services/locale.mjs';
9
9
  export { Messaging } from './services/messaging.mjs';
10
10
  export { Sites } from './services/sites.mjs';
11
11
  export { Storage } from './services/storage.mjs';
12
+ export { TablesDB } from './services/tables-db.mjs';
12
13
  export { Teams } from './services/teams.mjs';
13
14
  export { Tokens } from './services/tokens.mjs';
14
15
  export { Users } from './services/users.mjs';
@@ -26,7 +27,7 @@ export { RelationshipType } from './enums/relationship-type.mjs';
26
27
  export { RelationMutate } from './enums/relation-mutate.mjs';
27
28
  export { IndexType } from './enums/index-type.mjs';
28
29
  export { Runtime } from './enums/runtime.mjs';
29
- export { VCSDeploymentType } from './enums/v-c-s-deployment-type.mjs';
30
+ export { VCSDeploymentType } from './enums/vcs-deployment-type.mjs';
30
31
  export { DeploymentDownloadType } from './enums/deployment-download-type.mjs';
31
32
  export { ExecutionMethod } from './enums/execution-method.mjs';
32
33
  export { Name } from './enums/name.mjs';
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { Locale } from './services/locale.js';
9
9
  export { Messaging } from './services/messaging.js';
10
10
  export { Sites } from './services/sites.js';
11
11
  export { Storage } from './services/storage.js';
12
+ export { TablesDB } from './services/tables-db.js';
12
13
  export { Teams } from './services/teams.js';
13
14
  export { Tokens } from './services/tokens.js';
14
15
  export { Users } from './services/users.js';
@@ -26,7 +27,7 @@ export { RelationshipType } from './enums/relationship-type.js';
26
27
  export { RelationMutate } from './enums/relation-mutate.js';
27
28
  export { IndexType } from './enums/index-type.js';
28
29
  export { Runtime } from './enums/runtime.js';
29
- export { VCSDeploymentType } from './enums/v-c-s-deployment-type.js';
30
+ export { VCSDeploymentType } from './enums/vcs-deployment-type.js';
30
31
  export { DeploymentDownloadType } from './enums/deployment-download-type.js';
31
32
  export { ExecutionMethod } from './enums/execution-method.js';
32
33
  export { Name } from './enums/name.js';
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ var locale = require('./services/locale');
11
11
  var messaging = require('./services/messaging');
12
12
  var sites = require('./services/sites');
13
13
  var storage = require('./services/storage');
14
+ var tablesDb = require('./services/tables-db');
14
15
  var teams = require('./services/teams');
15
16
  var tokens = require('./services/tokens');
16
17
  var users = require('./services/users');
@@ -27,7 +28,7 @@ var relationshipType = require('./enums/relationship-type');
27
28
  var relationMutate = require('./enums/relation-mutate');
28
29
  var indexType = require('./enums/index-type');
29
30
  var runtime = require('./enums/runtime');
30
- var vCSDeploymentType = require('./enums/v-c-s-deployment-type');
31
+ var vcsDeploymentType = require('./enums/vcs-deployment-type');
31
32
  var deploymentDownloadType = require('./enums/deployment-download-type');
32
33
  var executionMethod = require('./enums/execution-method');
33
34
  var name = require('./enums/name');
@@ -96,6 +97,10 @@ Object.defineProperty(exports, 'Storage', {
96
97
  enumerable: true,
97
98
  get: function () { return storage.Storage; }
98
99
  });
100
+ Object.defineProperty(exports, 'TablesDB', {
101
+ enumerable: true,
102
+ get: function () { return tablesDb.TablesDB; }
103
+ });
99
104
  Object.defineProperty(exports, 'Teams', {
100
105
  enumerable: true,
101
106
  get: function () { return teams.Teams; }
@@ -162,7 +167,7 @@ Object.defineProperty(exports, 'Runtime', {
162
167
  });
163
168
  Object.defineProperty(exports, 'VCSDeploymentType', {
164
169
  enumerable: true,
165
- get: function () { return vCSDeploymentType.VCSDeploymentType; }
170
+ get: function () { return vcsDeploymentType.VCSDeploymentType; }
166
171
  });
167
172
  Object.defineProperty(exports, 'DeploymentDownloadType', {
168
173
  enumerable: true,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS,QAAQ,OAAO,yBAAyB;AACjD,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,aAAa;AAGtB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAChC,SAAS,YAAY;AACrB,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B","sourcesContent":["export { Client, Query, AppwriteException } from './client';\nexport { Account } from './services/account';\nexport { Avatars } from './services/avatars';\nexport { Databases } from './services/databases';\nexport { Functions } from './services/functions';\nexport { Graphql } from './services/graphql';\nexport { Health } from './services/health';\nexport { Locale } from './services/locale';\nexport { Messaging } from './services/messaging';\nexport { Sites } from './services/sites';\nexport { Storage } from './services/storage';\nexport { Teams } from './services/teams';\nexport { Tokens } from './services/tokens';\nexport { Users } from './services/users';\nexport type { Models, Payload, UploadProgress } from './client';\nexport type { QueryTypes, QueryTypesList } from './query';\nexport { Permission } from './permission';\nexport { Role } from './role';\nexport { ID } from './id';\nexport { AuthenticatorType } from './enums/authenticator-type';\nexport { AuthenticationFactor } from './enums/authentication-factor';\nexport { OAuthProvider } from './enums/o-auth-provider';\nexport { Browser } from './enums/browser';\nexport { CreditCard } from './enums/credit-card';\nexport { Flag } from './enums/flag';\nexport { RelationshipType } from './enums/relationship-type';\nexport { RelationMutate } from './enums/relation-mutate';\nexport { IndexType } from './enums/index-type';\nexport { Runtime } from './enums/runtime';\nexport { VCSDeploymentType } from './enums/v-c-s-deployment-type';\nexport { DeploymentDownloadType } from './enums/deployment-download-type';\nexport { ExecutionMethod } from './enums/execution-method';\nexport { Name } from './enums/name';\nexport { MessagePriority } from './enums/message-priority';\nexport { SmtpEncryption } from './enums/smtp-encryption';\nexport { Framework } from './enums/framework';\nexport { BuildRuntime } from './enums/build-runtime';\nexport { Adapter } from './enums/adapter';\nexport { Compression } from './enums/compression';\nexport { ImageGravity } from './enums/image-gravity';\nexport { ImageFormat } from './enums/image-format';\nexport { PasswordHash } from './enums/password-hash';\nexport { MessagingProviderType } from './enums/messaging-provider-type';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS,QAAQ,OAAO,yBAAyB;AACjD,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,aAAa;AAGtB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAChC,SAAS,YAAY;AACrB,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B","sourcesContent":["export { Client, Query, AppwriteException } from './client';\nexport { Account } from './services/account';\nexport { Avatars } from './services/avatars';\nexport { Databases } from './services/databases';\nexport { Functions } from './services/functions';\nexport { Graphql } from './services/graphql';\nexport { Health } from './services/health';\nexport { Locale } from './services/locale';\nexport { Messaging } from './services/messaging';\nexport { Sites } from './services/sites';\nexport { Storage } from './services/storage';\nexport { TablesDB } from './services/tables-db';\nexport { Teams } from './services/teams';\nexport { Tokens } from './services/tokens';\nexport { Users } from './services/users';\nexport type { Models, Payload, UploadProgress } from './client';\nexport type { QueryTypes, QueryTypesList } from './query';\nexport { Permission } from './permission';\nexport { Role } from './role';\nexport { ID } from './id';\nexport { AuthenticatorType } from './enums/authenticator-type';\nexport { AuthenticationFactor } from './enums/authentication-factor';\nexport { OAuthProvider } from './enums/o-auth-provider';\nexport { Browser } from './enums/browser';\nexport { CreditCard } from './enums/credit-card';\nexport { Flag } from './enums/flag';\nexport { RelationshipType } from './enums/relationship-type';\nexport { RelationMutate } from './enums/relation-mutate';\nexport { IndexType } from './enums/index-type';\nexport { Runtime } from './enums/runtime';\nexport { VCSDeploymentType } from './enums/vcs-deployment-type';\nexport { DeploymentDownloadType } from './enums/deployment-download-type';\nexport { ExecutionMethod } from './enums/execution-method';\nexport { Name } from './enums/name';\nexport { MessagePriority } from './enums/message-priority';\nexport { SmtpEncryption } from './enums/smtp-encryption';\nexport { Framework } from './enums/framework';\nexport { BuildRuntime } from './enums/build-runtime';\nexport { Adapter } from './enums/adapter';\nexport { Compression } from './enums/compression';\nexport { ImageGravity } from './enums/image-gravity';\nexport { ImageFormat } from './enums/image-format';\nexport { PasswordHash } from './enums/password-hash';\nexport { MessagingProviderType } from './enums/messaging-provider-type';\n"]}
package/dist/index.mjs CHANGED
@@ -9,6 +9,7 @@ export { Locale } from './services/locale.mjs';
9
9
  export { Messaging } from './services/messaging.mjs';
10
10
  export { Sites } from './services/sites.mjs';
11
11
  export { Storage } from './services/storage.mjs';
12
+ export { TablesDB } from './services/tables-db.mjs';
12
13
  export { Teams } from './services/teams.mjs';
13
14
  export { Tokens } from './services/tokens.mjs';
14
15
  export { Users } from './services/users.mjs';
@@ -25,7 +26,7 @@ export { RelationshipType } from './enums/relationship-type.mjs';
25
26
  export { RelationMutate } from './enums/relation-mutate.mjs';
26
27
  export { IndexType } from './enums/index-type.mjs';
27
28
  export { Runtime } from './enums/runtime.mjs';
28
- export { VCSDeploymentType } from './enums/v-c-s-deployment-type.mjs';
29
+ export { VCSDeploymentType } from './enums/vcs-deployment-type.mjs';
29
30
  export { DeploymentDownloadType } from './enums/deployment-download-type.mjs';
30
31
  export { ExecutionMethod } from './enums/execution-method.mjs';
31
32
  export { Name } from './enums/name.mjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AAAA,SAAS,QAAQ,OAAO,yBAAyB;AACjD,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,aAAa;AAGtB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAChC,SAAS,YAAY;AACrB,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B","sourcesContent":["export { Client, Query, AppwriteException } from './client';\nexport { Account } from './services/account';\nexport { Avatars } from './services/avatars';\nexport { Databases } from './services/databases';\nexport { Functions } from './services/functions';\nexport { Graphql } from './services/graphql';\nexport { Health } from './services/health';\nexport { Locale } from './services/locale';\nexport { Messaging } from './services/messaging';\nexport { Sites } from './services/sites';\nexport { Storage } from './services/storage';\nexport { Teams } from './services/teams';\nexport { Tokens } from './services/tokens';\nexport { Users } from './services/users';\nexport type { Models, Payload, UploadProgress } from './client';\nexport type { QueryTypes, QueryTypesList } from './query';\nexport { Permission } from './permission';\nexport { Role } from './role';\nexport { ID } from './id';\nexport { AuthenticatorType } from './enums/authenticator-type';\nexport { AuthenticationFactor } from './enums/authentication-factor';\nexport { OAuthProvider } from './enums/o-auth-provider';\nexport { Browser } from './enums/browser';\nexport { CreditCard } from './enums/credit-card';\nexport { Flag } from './enums/flag';\nexport { RelationshipType } from './enums/relationship-type';\nexport { RelationMutate } from './enums/relation-mutate';\nexport { IndexType } from './enums/index-type';\nexport { Runtime } from './enums/runtime';\nexport { VCSDeploymentType } from './enums/v-c-s-deployment-type';\nexport { DeploymentDownloadType } from './enums/deployment-download-type';\nexport { ExecutionMethod } from './enums/execution-method';\nexport { Name } from './enums/name';\nexport { MessagePriority } from './enums/message-priority';\nexport { SmtpEncryption } from './enums/smtp-encryption';\nexport { Framework } from './enums/framework';\nexport { BuildRuntime } from './enums/build-runtime';\nexport { Adapter } from './enums/adapter';\nexport { Compression } from './enums/compression';\nexport { ImageGravity } from './enums/image-gravity';\nexport { ImageFormat } from './enums/image-format';\nexport { PasswordHash } from './enums/password-hash';\nexport { MessagingProviderType } from './enums/messaging-provider-type';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AAAA,SAAS,QAAQ,OAAO,yBAAyB;AACjD,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,aAAa;AAGtB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAChC,SAAS,YAAY;AACrB,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B","sourcesContent":["export { Client, Query, AppwriteException } from './client';\nexport { Account } from './services/account';\nexport { Avatars } from './services/avatars';\nexport { Databases } from './services/databases';\nexport { Functions } from './services/functions';\nexport { Graphql } from './services/graphql';\nexport { Health } from './services/health';\nexport { Locale } from './services/locale';\nexport { Messaging } from './services/messaging';\nexport { Sites } from './services/sites';\nexport { Storage } from './services/storage';\nexport { TablesDB } from './services/tables-db';\nexport { Teams } from './services/teams';\nexport { Tokens } from './services/tokens';\nexport { Users } from './services/users';\nexport type { Models, Payload, UploadProgress } from './client';\nexport type { QueryTypes, QueryTypesList } from './query';\nexport { Permission } from './permission';\nexport { Role } from './role';\nexport { ID } from './id';\nexport { AuthenticatorType } from './enums/authenticator-type';\nexport { AuthenticationFactor } from './enums/authentication-factor';\nexport { OAuthProvider } from './enums/o-auth-provider';\nexport { Browser } from './enums/browser';\nexport { CreditCard } from './enums/credit-card';\nexport { Flag } from './enums/flag';\nexport { RelationshipType } from './enums/relationship-type';\nexport { RelationMutate } from './enums/relation-mutate';\nexport { IndexType } from './enums/index-type';\nexport { Runtime } from './enums/runtime';\nexport { VCSDeploymentType } from './enums/vcs-deployment-type';\nexport { DeploymentDownloadType } from './enums/deployment-download-type';\nexport { ExecutionMethod } from './enums/execution-method';\nexport { Name } from './enums/name';\nexport { MessagePriority } from './enums/message-priority';\nexport { SmtpEncryption } from './enums/smtp-encryption';\nexport { Framework } from './enums/framework';\nexport { BuildRuntime } from './enums/build-runtime';\nexport { Adapter } from './enums/adapter';\nexport { Compression } from './enums/compression';\nexport { ImageGravity } from './enums/image-gravity';\nexport { ImageFormat } from './enums/image-format';\nexport { PasswordHash } from './enums/password-hash';\nexport { MessagingProviderType } from './enums/messaging-provider-type';\n"]}