node-appwrite 16.1.0-rc.1 → 17.1.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 (92) hide show
  1. package/README.md +2 -2
  2. package/dist/client.js +7 -6
  3. package/dist/client.js.map +1 -1
  4. package/dist/client.mjs +7 -6
  5. package/dist/client.mjs.map +1 -1
  6. package/dist/enums/adapter.d.mts +6 -0
  7. package/dist/enums/adapter.d.ts +6 -0
  8. package/dist/enums/adapter.js +11 -0
  9. package/dist/enums/adapter.js.map +1 -0
  10. package/dist/enums/adapter.mjs +10 -0
  11. package/dist/enums/adapter.mjs.map +1 -0
  12. package/dist/enums/build-runtime.d.mts +69 -0
  13. package/dist/enums/build-runtime.d.ts +69 -0
  14. package/dist/enums/build-runtime.js +74 -0
  15. package/dist/enums/build-runtime.js.map +1 -0
  16. package/dist/enums/build-runtime.mjs +73 -0
  17. package/dist/enums/build-runtime.mjs.map +1 -0
  18. package/dist/enums/deployment-download-type.d.mts +6 -0
  19. package/dist/enums/deployment-download-type.d.ts +6 -0
  20. package/dist/enums/deployment-download-type.js +11 -0
  21. package/dist/enums/deployment-download-type.js.map +1 -0
  22. package/dist/enums/deployment-download-type.mjs +10 -0
  23. package/dist/enums/deployment-download-type.mjs.map +1 -0
  24. package/dist/enums/framework.d.mts +18 -0
  25. package/dist/enums/framework.d.ts +18 -0
  26. package/dist/enums/framework.js +23 -0
  27. package/dist/enums/framework.js.map +1 -0
  28. package/dist/enums/framework.mjs +22 -0
  29. package/dist/enums/framework.mjs.map +1 -0
  30. package/dist/enums/image-format.d.mts +2 -2
  31. package/dist/enums/image-format.d.ts +2 -2
  32. package/dist/enums/image-format.js +1 -1
  33. package/dist/enums/image-format.js.map +1 -1
  34. package/dist/enums/image-format.mjs +1 -1
  35. package/dist/enums/image-format.mjs.map +1 -1
  36. package/dist/enums/runtime.d.mts +7 -1
  37. package/dist/enums/runtime.d.ts +7 -1
  38. package/dist/enums/runtime.js +6 -0
  39. package/dist/enums/runtime.js.map +1 -1
  40. package/dist/enums/runtime.mjs +6 -0
  41. package/dist/enums/runtime.mjs.map +1 -1
  42. package/dist/enums/v-c-s-deployment-type.d.mts +7 -0
  43. package/dist/enums/v-c-s-deployment-type.d.ts +7 -0
  44. package/dist/enums/v-c-s-deployment-type.js +12 -0
  45. package/dist/enums/v-c-s-deployment-type.js.map +1 -0
  46. package/dist/enums/v-c-s-deployment-type.mjs +11 -0
  47. package/dist/enums/v-c-s-deployment-type.mjs.map +1 -0
  48. package/dist/index.d.mts +7 -0
  49. package/dist/index.d.ts +7 -0
  50. package/dist/index.js +35 -0
  51. package/dist/index.js.map +1 -1
  52. package/dist/index.mjs +7 -0
  53. package/dist/index.mjs.map +1 -1
  54. package/dist/models.d.mts +286 -48
  55. package/dist/models.d.ts +286 -48
  56. package/dist/services/databases.d.mts +27 -6
  57. package/dist/services/databases.d.ts +27 -6
  58. package/dist/services/databases.js +78 -20
  59. package/dist/services/databases.js.map +1 -1
  60. package/dist/services/databases.mjs +78 -20
  61. package/dist/services/databases.mjs.map +1 -1
  62. package/dist/services/functions.d.mts +56 -30
  63. package/dist/services/functions.d.ts +56 -30
  64. package/dist/services/functions.js +185 -87
  65. package/dist/services/functions.js.map +1 -1
  66. package/dist/services/functions.mjs +185 -87
  67. package/dist/services/functions.mjs.map +1 -1
  68. package/dist/services/sites.d.mts +286 -0
  69. package/dist/services/sites.d.ts +286 -0
  70. package/dist/services/sites.js +923 -0
  71. package/dist/services/sites.js.map +1 -0
  72. package/dist/services/sites.mjs +922 -0
  73. package/dist/services/sites.mjs.map +1 -0
  74. package/dist/services/storage.d.mts +6 -3
  75. package/dist/services/storage.d.ts +6 -3
  76. package/dist/services/storage.js +15 -3
  77. package/dist/services/storage.js.map +1 -1
  78. package/dist/services/storage.mjs +15 -3
  79. package/dist/services/storage.mjs.map +1 -1
  80. package/dist/services/tokens.d.mts +55 -0
  81. package/dist/services/tokens.d.ts +55 -0
  82. package/dist/services/tokens.js +149 -0
  83. package/dist/services/tokens.js.map +1 -0
  84. package/dist/services/tokens.mjs +148 -0
  85. package/dist/services/tokens.mjs.map +1 -0
  86. package/dist/services/users.d.mts +3 -1
  87. package/dist/services/users.d.ts +3 -1
  88. package/dist/services/users.js +9 -1
  89. package/dist/services/users.js.map +1 -1
  90. package/dist/services/users.mjs +9 -1
  91. package/dist/services/users.mjs.map +1 -1
  92. package/package.json +1 -1
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.6.2-blue.svg?style=flat-square)
4
+ ![Version](https://img.shields.io/badge/api%20version-1.7.4-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.6.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.7.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)
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/16.1.0-rc.1";
18
+ let ua = "AppwriteNodeJSSDK/17.1.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": "16.1.0-rc.1",
54
+ "x-sdk-version": "17.1.0",
55
55
  "user-agent": getUserAgent(),
56
- "X-Appwrite-Response-Format": "1.6.0"
56
+ "X-Appwrite-Response-Format": "1.7.0"
57
57
  };
58
58
  }
59
59
  /**
@@ -218,8 +218,8 @@ const _Client = class _Client {
218
218
  return { uri: url.toString(), options };
219
219
  }
220
220
  async chunkedUpload(method, url, headers = {}, originalPayload = {}, onProgress) {
221
- const file = Object.values(originalPayload).find((value) => value instanceof nodeFetchNativeWithAgent.File);
222
- if (!file) {
221
+ const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof nodeFetchNativeWithAgent.File) ?? [];
222
+ if (!file || !fileParam) {
223
223
  throw new Error("File not found in payload");
224
224
  }
225
225
  if (file.size <= _Client.CHUNK_SIZE) {
@@ -234,7 +234,8 @@ const _Client = class _Client {
234
234
  }
235
235
  headers["content-range"] = `bytes ${start}-${end - 1}/${file.size}`;
236
236
  const chunk = file.slice(start, end);
237
- let payload = { ...originalPayload, file: new nodeFetchNativeWithAgent.File([chunk], file.name) };
237
+ let payload = { ...originalPayload };
238
+ payload[fileParam] = new nodeFetchNativeWithAgent.File([chunk], file.name);
238
239
  response = await this.call(method, url, headers, payload);
239
240
  if (onProgress && typeof onProgress === "function") {
240
241
  onProgress({
@@ -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,IAAI,WAAmB,IAAI;AACrF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,WAAW;A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,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;AA3TM,QACK,aAAa,OAAO,OAAO;AADtC,IAAM,SAAN;AA8TA,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/16.1.0-rc.1';\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': '16.1.0-rc.1',\n 'user-agent' : getUserAgent(),\n 'X-Appwrite-Response-Format': '1.6.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 file = Object.values(originalPayload).find((value) => value instanceof File);\n\n if (!file) {\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, file: 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,QAAQ,QAAQ;AACxE,QAAI,OAAO,QAAQ,SAAS;AAAU,eAAS,KAAK,QAAQ,IAAI;AAAA,EACpE;AACA,MAAI,SAAS,SAAS,GAAG;AACrB,UAAM,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,EAClC;AAMA,MAAI,OAAO,cAAc,eAAe,OAAO,UAAU,cAAc,UAAU;AAE7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AAG,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.1.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.1.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"]}
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/16.1.0-rc.1";
17
+ let ua = "AppwriteNodeJSSDK/17.1.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": "16.1.0-rc.1",
53
+ "x-sdk-version": "17.1.0",
54
54
  "user-agent": getUserAgent(),
55
- "X-Appwrite-Response-Format": "1.6.0"
55
+ "X-Appwrite-Response-Format": "1.7.0"
56
56
  };
57
57
  }
58
58
  /**
@@ -217,8 +217,8 @@ var _Client = class _Client {
217
217
  return { uri: url.toString(), options };
218
218
  }
219
219
  async chunkedUpload(method, url, headers = {}, originalPayload = {}, onProgress) {
220
- const file = Object.values(originalPayload).find((value) => value instanceof File);
221
- if (!file) {
220
+ const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? [];
221
+ if (!file || !fileParam) {
222
222
  throw new Error("File not found in payload");
223
223
  }
224
224
  if (file.size <= _Client.CHUNK_SIZE) {
@@ -233,7 +233,8 @@ var _Client = class _Client {
233
233
  }
234
234
  headers["content-range"] = `bytes ${start}-${end - 1}/${file.size}`;
235
235
  const chunk = file.slice(start, end);
236
- let payload = { ...originalPayload, file: new File([chunk], file.name) };
236
+ let payload = { ...originalPayload };
237
+ payload[fileParam] = new File([chunk], file.name);
237
238
  response = await this.call(method, url, headers, payload);
238
239
  if (onProgress && typeof onProgress === "function") {
239
240
  onProgress({
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"names":[],"mappings":";AAAA,SAAS,OAAO,UAAU,YAAY;AACtC,SAAS,mBAAmB;AAgY5B,SAAS,aAAa;AA7WtB,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,SAAS;AAAU,eAAS,KAAK,QAAQ,IAAI;AAAA,EACpE;AACA,MAAI,SAAS,SAAS,GAAG;AACrB,UAAM,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,EAClC;AAMA,MAAI,OAAO,cAAc,eAAe,OAAO,UAAU,cAAc,UAAU;AAE7E,UAAM,IAAI,UAAU,SAAS;AAAA,EAGjC,WAAW,OAAO,WAAW,gBAAgB,UAAU;AACnD,UAAM;AAAA,EAGV,WAAW,OAAO,YAAY,eAAe,OAAO,QAAQ,YAAY,UAAU;AAC9E,UAAM,YAAY,QAAQ,OAAO;AAAA,EACrC;AAEA,SAAO;AACX;AAEA,IAAM,UAAN,MAAM,QAAO;AAAA,EAAb;AAGI,kBAAS;AAAA,MACL,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,KAAK;AAAA,MACL,KAAK;AAAA,MACL,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,oBAAo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sC,SAAS,qBAAqB;AACpE,aAAO,MAAM,SAAS,KAAK;AAAA,IAC/B,WAAW,iBAAiB,eAAe;AACvC,aAAO,MAAM,SAAS,YAAY;AAAA,IACtC,OAAO;AACH,aAAO;AAAA,QACH,SAAS,MAAM,SAAS,KAAK;AAAA,MACjC;AAAA,IACJ;AAEA,QAAI,OAAO,SAAS,QAAQ;AACxB,UAAI,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;AA3TM,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/16.1.0-rc.1';\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': '16.1.0-rc.1',\n 'user-agent' : getUserAgent(),\n 'X-Appwrite-Response-Format': '1.6.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 file = Object.values(originalPayload).find((value) => value instanceof File);\n\n if (!file) {\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, file: 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,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S,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.1.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.1.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"]}
@@ -0,0 +1,6 @@
1
+ declare enum Adapter {
2
+ Static = "static",
3
+ Ssr = "ssr"
4
+ }
5
+
6
+ export { Adapter };
@@ -0,0 +1,6 @@
1
+ declare enum Adapter {
2
+ Static = "static",
3
+ Ssr = "ssr"
4
+ }
5
+
6
+ export { Adapter };
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var Adapter = /* @__PURE__ */ ((Adapter2) => {
4
+ Adapter2["Static"] = "static";
5
+ Adapter2["Ssr"] = "ssr";
6
+ return Adapter2;
7
+ })(Adapter || {});
8
+
9
+ exports.Adapter = Adapter;
10
+ //# sourceMappingURL=out.js.map
11
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/enums/adapter.ts"],"names":["Adapter"],"mappings":"AAAO,IAAK,UAAL,kBAAKA,aAAL;AACH,EAAAA,SAAA,YAAS;AACT,EAAAA,SAAA,SAAM;AAFE,SAAAA;AAAA,GAAA","sourcesContent":["export enum Adapter {\n Static = 'static',\n Ssr = 'ssr',\n}"]}
@@ -0,0 +1,10 @@
1
+ // src/enums/adapter.ts
2
+ var Adapter = /* @__PURE__ */ ((Adapter2) => {
3
+ Adapter2["Static"] = "static";
4
+ Adapter2["Ssr"] = "ssr";
5
+ return Adapter2;
6
+ })(Adapter || {});
7
+
8
+ export { Adapter };
9
+ //# sourceMappingURL=out.js.map
10
+ //# sourceMappingURL=adapter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/enums/adapter.ts"],"names":["Adapter"],"mappings":";AAAO,IAAK,UAAL,kBAAKA,aAAL;AACH,EAAAA,SAAA,YAAS;AACT,EAAAA,SAAA,SAAM;AAFE,SAAAA;AAAA,GAAA","sourcesContent":["export enum Adapter {\n Static = 'static',\n Ssr = 'ssr',\n}"]}
@@ -0,0 +1,69 @@
1
+ declare enum BuildRuntime {
2
+ Node145 = "node-14.5",
3
+ Node160 = "node-16.0",
4
+ Node180 = "node-18.0",
5
+ Node190 = "node-19.0",
6
+ Node200 = "node-20.0",
7
+ Node210 = "node-21.0",
8
+ Node22 = "node-22",
9
+ Php80 = "php-8.0",
10
+ Php81 = "php-8.1",
11
+ Php82 = "php-8.2",
12
+ Php83 = "php-8.3",
13
+ Ruby30 = "ruby-3.0",
14
+ Ruby31 = "ruby-3.1",
15
+ Ruby32 = "ruby-3.2",
16
+ Ruby33 = "ruby-3.3",
17
+ Python38 = "python-3.8",
18
+ Python39 = "python-3.9",
19
+ Python310 = "python-3.10",
20
+ Python311 = "python-3.11",
21
+ Python312 = "python-3.12",
22
+ Pythonml311 = "python-ml-3.11",
23
+ Pythonml312 = "python-ml-3.12",
24
+ Deno121 = "deno-1.21",
25
+ Deno124 = "deno-1.24",
26
+ Deno135 = "deno-1.35",
27
+ Deno140 = "deno-1.40",
28
+ Deno146 = "deno-1.46",
29
+ Deno20 = "deno-2.0",
30
+ Dart215 = "dart-2.15",
31
+ Dart216 = "dart-2.16",
32
+ Dart217 = "dart-2.17",
33
+ Dart218 = "dart-2.18",
34
+ Dart219 = "dart-2.19",
35
+ Dart30 = "dart-3.0",
36
+ Dart31 = "dart-3.1",
37
+ Dart33 = "dart-3.3",
38
+ Dart35 = "dart-3.5",
39
+ Dart38 = "dart-3.8",
40
+ Dotnet60 = "dotnet-6.0",
41
+ Dotnet70 = "dotnet-7.0",
42
+ Dotnet80 = "dotnet-8.0",
43
+ Java80 = "java-8.0",
44
+ Java110 = "java-11.0",
45
+ Java170 = "java-17.0",
46
+ Java180 = "java-18.0",
47
+ Java210 = "java-21.0",
48
+ Java22 = "java-22",
49
+ Swift55 = "swift-5.5",
50
+ Swift58 = "swift-5.8",
51
+ Swift59 = "swift-5.9",
52
+ Swift510 = "swift-5.10",
53
+ Kotlin16 = "kotlin-1.6",
54
+ Kotlin18 = "kotlin-1.8",
55
+ Kotlin19 = "kotlin-1.9",
56
+ Kotlin20 = "kotlin-2.0",
57
+ Cpp17 = "cpp-17",
58
+ Cpp20 = "cpp-20",
59
+ Bun10 = "bun-1.0",
60
+ Bun11 = "bun-1.1",
61
+ Go123 = "go-1.23",
62
+ Static1 = "static-1",
63
+ Flutter324 = "flutter-3.24",
64
+ Flutter327 = "flutter-3.27",
65
+ Flutter329 = "flutter-3.29",
66
+ Flutter332 = "flutter-3.32"
67
+ }
68
+
69
+ export { BuildRuntime };
@@ -0,0 +1,69 @@
1
+ declare enum BuildRuntime {
2
+ Node145 = "node-14.5",
3
+ Node160 = "node-16.0",
4
+ Node180 = "node-18.0",
5
+ Node190 = "node-19.0",
6
+ Node200 = "node-20.0",
7
+ Node210 = "node-21.0",
8
+ Node22 = "node-22",
9
+ Php80 = "php-8.0",
10
+ Php81 = "php-8.1",
11
+ Php82 = "php-8.2",
12
+ Php83 = "php-8.3",
13
+ Ruby30 = "ruby-3.0",
14
+ Ruby31 = "ruby-3.1",
15
+ Ruby32 = "ruby-3.2",
16
+ Ruby33 = "ruby-3.3",
17
+ Python38 = "python-3.8",
18
+ Python39 = "python-3.9",
19
+ Python310 = "python-3.10",
20
+ Python311 = "python-3.11",
21
+ Python312 = "python-3.12",
22
+ Pythonml311 = "python-ml-3.11",
23
+ Pythonml312 = "python-ml-3.12",
24
+ Deno121 = "deno-1.21",
25
+ Deno124 = "deno-1.24",
26
+ Deno135 = "deno-1.35",
27
+ Deno140 = "deno-1.40",
28
+ Deno146 = "deno-1.46",
29
+ Deno20 = "deno-2.0",
30
+ Dart215 = "dart-2.15",
31
+ Dart216 = "dart-2.16",
32
+ Dart217 = "dart-2.17",
33
+ Dart218 = "dart-2.18",
34
+ Dart219 = "dart-2.19",
35
+ Dart30 = "dart-3.0",
36
+ Dart31 = "dart-3.1",
37
+ Dart33 = "dart-3.3",
38
+ Dart35 = "dart-3.5",
39
+ Dart38 = "dart-3.8",
40
+ Dotnet60 = "dotnet-6.0",
41
+ Dotnet70 = "dotnet-7.0",
42
+ Dotnet80 = "dotnet-8.0",
43
+ Java80 = "java-8.0",
44
+ Java110 = "java-11.0",
45
+ Java170 = "java-17.0",
46
+ Java180 = "java-18.0",
47
+ Java210 = "java-21.0",
48
+ Java22 = "java-22",
49
+ Swift55 = "swift-5.5",
50
+ Swift58 = "swift-5.8",
51
+ Swift59 = "swift-5.9",
52
+ Swift510 = "swift-5.10",
53
+ Kotlin16 = "kotlin-1.6",
54
+ Kotlin18 = "kotlin-1.8",
55
+ Kotlin19 = "kotlin-1.9",
56
+ Kotlin20 = "kotlin-2.0",
57
+ Cpp17 = "cpp-17",
58
+ Cpp20 = "cpp-20",
59
+ Bun10 = "bun-1.0",
60
+ Bun11 = "bun-1.1",
61
+ Go123 = "go-1.23",
62
+ Static1 = "static-1",
63
+ Flutter324 = "flutter-3.24",
64
+ Flutter327 = "flutter-3.27",
65
+ Flutter329 = "flutter-3.29",
66
+ Flutter332 = "flutter-3.32"
67
+ }
68
+
69
+ export { BuildRuntime };
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ var BuildRuntime = /* @__PURE__ */ ((BuildRuntime2) => {
4
+ BuildRuntime2["Node145"] = "node-14.5";
5
+ BuildRuntime2["Node160"] = "node-16.0";
6
+ BuildRuntime2["Node180"] = "node-18.0";
7
+ BuildRuntime2["Node190"] = "node-19.0";
8
+ BuildRuntime2["Node200"] = "node-20.0";
9
+ BuildRuntime2["Node210"] = "node-21.0";
10
+ BuildRuntime2["Node22"] = "node-22";
11
+ BuildRuntime2["Php80"] = "php-8.0";
12
+ BuildRuntime2["Php81"] = "php-8.1";
13
+ BuildRuntime2["Php82"] = "php-8.2";
14
+ BuildRuntime2["Php83"] = "php-8.3";
15
+ BuildRuntime2["Ruby30"] = "ruby-3.0";
16
+ BuildRuntime2["Ruby31"] = "ruby-3.1";
17
+ BuildRuntime2["Ruby32"] = "ruby-3.2";
18
+ BuildRuntime2["Ruby33"] = "ruby-3.3";
19
+ BuildRuntime2["Python38"] = "python-3.8";
20
+ BuildRuntime2["Python39"] = "python-3.9";
21
+ BuildRuntime2["Python310"] = "python-3.10";
22
+ BuildRuntime2["Python311"] = "python-3.11";
23
+ BuildRuntime2["Python312"] = "python-3.12";
24
+ BuildRuntime2["Pythonml311"] = "python-ml-3.11";
25
+ BuildRuntime2["Pythonml312"] = "python-ml-3.12";
26
+ BuildRuntime2["Deno121"] = "deno-1.21";
27
+ BuildRuntime2["Deno124"] = "deno-1.24";
28
+ BuildRuntime2["Deno135"] = "deno-1.35";
29
+ BuildRuntime2["Deno140"] = "deno-1.40";
30
+ BuildRuntime2["Deno146"] = "deno-1.46";
31
+ BuildRuntime2["Deno20"] = "deno-2.0";
32
+ BuildRuntime2["Dart215"] = "dart-2.15";
33
+ BuildRuntime2["Dart216"] = "dart-2.16";
34
+ BuildRuntime2["Dart217"] = "dart-2.17";
35
+ BuildRuntime2["Dart218"] = "dart-2.18";
36
+ BuildRuntime2["Dart219"] = "dart-2.19";
37
+ BuildRuntime2["Dart30"] = "dart-3.0";
38
+ BuildRuntime2["Dart31"] = "dart-3.1";
39
+ BuildRuntime2["Dart33"] = "dart-3.3";
40
+ BuildRuntime2["Dart35"] = "dart-3.5";
41
+ BuildRuntime2["Dart38"] = "dart-3.8";
42
+ BuildRuntime2["Dotnet60"] = "dotnet-6.0";
43
+ BuildRuntime2["Dotnet70"] = "dotnet-7.0";
44
+ BuildRuntime2["Dotnet80"] = "dotnet-8.0";
45
+ BuildRuntime2["Java80"] = "java-8.0";
46
+ BuildRuntime2["Java110"] = "java-11.0";
47
+ BuildRuntime2["Java170"] = "java-17.0";
48
+ BuildRuntime2["Java180"] = "java-18.0";
49
+ BuildRuntime2["Java210"] = "java-21.0";
50
+ BuildRuntime2["Java22"] = "java-22";
51
+ BuildRuntime2["Swift55"] = "swift-5.5";
52
+ BuildRuntime2["Swift58"] = "swift-5.8";
53
+ BuildRuntime2["Swift59"] = "swift-5.9";
54
+ BuildRuntime2["Swift510"] = "swift-5.10";
55
+ BuildRuntime2["Kotlin16"] = "kotlin-1.6";
56
+ BuildRuntime2["Kotlin18"] = "kotlin-1.8";
57
+ BuildRuntime2["Kotlin19"] = "kotlin-1.9";
58
+ BuildRuntime2["Kotlin20"] = "kotlin-2.0";
59
+ BuildRuntime2["Cpp17"] = "cpp-17";
60
+ BuildRuntime2["Cpp20"] = "cpp-20";
61
+ BuildRuntime2["Bun10"] = "bun-1.0";
62
+ BuildRuntime2["Bun11"] = "bun-1.1";
63
+ BuildRuntime2["Go123"] = "go-1.23";
64
+ BuildRuntime2["Static1"] = "static-1";
65
+ BuildRuntime2["Flutter324"] = "flutter-3.24";
66
+ BuildRuntime2["Flutter327"] = "flutter-3.27";
67
+ BuildRuntime2["Flutter329"] = "flutter-3.29";
68
+ BuildRuntime2["Flutter332"] = "flutter-3.32";
69
+ return BuildRuntime2;
70
+ })(BuildRuntime || {});
71
+
72
+ exports.BuildRuntime = BuildRuntime;
73
+ //# sourceMappingURL=out.js.map
74
+ //# sourceMappingURL=build-runt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AAU;AACV,EAAAA,cAAA,YAAS;AACT,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,aAAU;AACV,EAAAA,cAAA,gBAAa;AACb,EAAAA,cAAA,gBAAa;AACb,EAAAA,cAAA,gBAAa;AACb,EAAAA,cAAA,gBAAa;AAjEL,SAAAA;AAAA,GAAA","sourcesContent":["export enum BuildRuntime {\n Node145 = 'node-14.5',\n Node160 = 'node-16.0',\n Node180 = 'node-18.0',\n Node190 = 'node-19.0',\n Node200 = 'node-20.0',\n Node210 = 'node-21.0',\n Node22 = 'node-22',\n Php80 = 'php-8.0',\n Php81 = 'php-8.1',\n Php82 = 'php-8.2',\n Php83 = 'php-8.3',\n Ruby30 = 'ruby-3.0',\n Ruby31 = 'ruby-3.1',\n Ruby32 = 'ruby-3.2',\n Ruby33 = 'ruby-3.3',\n Python38 = 'python-3.8',\n Python39 = 'python-3.9',\n Python310 = 'python-3.10',\n Python311 = 'python-3.11',\n Python312 = 'python-3.12',\n Pythonml311 = 'python-ml-3.11',\n Pythonml312 = 'python-ml-3.12',\n Deno121 = 'deno-1.21',\n Deno124 = 'deno-1.24',\n Deno135 = 'deno-1.35',\n Deno140 = 'deno-1.40',\n Deno146 = 'deno-1.46',\n Deno20 = 'deno-2.0',\n Dart215 = 'dart-2.15',\n Dart216 = 'dart-2.16',\n Dart217 = 'dart-2.17',\n Dart218 = 'dart-2.18',\n Dart219 = 'dart-2.19',\n Dart30 = 'dart-3.0',\n Dart31 = 'dart-3.1',\n Dart33 = 'dart-3.3',\n Dart35 = 'dart-3.5',\n Dart38 = 'dart-3.8',\n Dotnet60 = 'dotnet-6.0',\n Dotnet70 = 'dotnet-7.0',\n Dotnet80 = 'dotnet-8.0',\n Java80 = 'java-8.0',\n Java110 = 'java-11.0',\n Java170 = 'java-17.0',\n Java180 = 'java-18.0',\n Java210 = 'java-21.0',\n Java22 = 'java-22',\n Swift55 = 'swift-5.5',\n Swift58 = 'swift-5.8',\n Swift59 = 'swift-5.9',\n Swift510 = 'swift-5.10',\n Kotlin16 = 'kotlin-1.6',\n Kotlin18 = 'kotlin-1.8',\n Kotlin19 = 'kotlin-1.9',\n Kotlin20 = 'kotlin-2.0',\n Cpp17 = 'cpp-17',\n Cpp20 = 'cpp-20',\n Bun10 = 'bun-1.0',\n Bun11 = 'bun-1.1',\n Go123 = 'go-1.23',\n Static1 = 'static-1',\n Flutter324 = 'flutter-3.24',\n Flutter327 = 'flutter-3.27',\n Flutter329 = 'flutter-3.29',\n Flutter332 = 'flutter-3.32',\n}"]}
@@ -0,0 +1,73 @@
1
+ // src/enums/build-runtime.ts
2
+ var BuildRuntime = /* @__PURE__ */ ((BuildRuntime2) => {
3
+ BuildRuntime2["Node145"] = "node-14.5";
4
+ BuildRuntime2["Node160"] = "node-16.0";
5
+ BuildRuntime2["Node180"] = "node-18.0";
6
+ BuildRuntime2["Node190"] = "node-19.0";
7
+ BuildRuntime2["Node200"] = "node-20.0";
8
+ BuildRuntime2["Node210"] = "node-21.0";
9
+ BuildRuntime2["Node22"] = "node-22";
10
+ BuildRuntime2["Php80"] = "php-8.0";
11
+ BuildRuntime2["Php81"] = "php-8.1";
12
+ BuildRuntime2["Php82"] = "php-8.2";
13
+ BuildRuntime2["Php83"] = "php-8.3";
14
+ BuildRuntime2["Ruby30"] = "ruby-3.0";
15
+ BuildRuntime2["Ruby31"] = "ruby-3.1";
16
+ BuildRuntime2["Ruby32"] = "ruby-3.2";
17
+ BuildRuntime2["Ruby33"] = "ruby-3.3";
18
+ BuildRuntime2["Python38"] = "python-3.8";
19
+ BuildRuntime2["Python39"] = "python-3.9";
20
+ BuildRuntime2["Python310"] = "python-3.10";
21
+ BuildRuntime2["Python311"] = "python-3.11";
22
+ BuildRuntime2["Python312"] = "python-3.12";
23
+ BuildRuntime2["Pythonml311"] = "python-ml-3.11";
24
+ BuildRuntime2["Pythonml312"] = "python-ml-3.12";
25
+ BuildRuntime2["Deno121"] = "deno-1.21";
26
+ BuildRuntime2["Deno124"] = "deno-1.24";
27
+ BuildRuntime2["Deno135"] = "deno-1.35";
28
+ BuildRuntime2["Deno140"] = "deno-1.40";
29
+ BuildRuntime2["Deno146"] = "deno-1.46";
30
+ BuildRuntime2["Deno20"] = "deno-2.0";
31
+ BuildRuntime2["Dart215"] = "dart-2.15";
32
+ BuildRuntime2["Dart216"] = "dart-2.16";
33
+ BuildRuntime2["Dart217"] = "dart-2.17";
34
+ BuildRuntime2["Dart218"] = "dart-2.18";
35
+ BuildRuntime2["Dart219"] = "dart-2.19";
36
+ BuildRuntime2["Dart30"] = "dart-3.0";
37
+ BuildRuntime2["Dart31"] = "dart-3.1";
38
+ BuildRuntime2["Dart33"] = "dart-3.3";
39
+ BuildRuntime2["Dart35"] = "dart-3.5";
40
+ BuildRuntime2["Dart38"] = "dart-3.8";
41
+ BuildRuntime2["Dotnet60"] = "dotnet-6.0";
42
+ BuildRuntime2["Dotnet70"] = "dotnet-7.0";
43
+ BuildRuntime2["Dotnet80"] = "dotnet-8.0";
44
+ BuildRuntime2["Java80"] = "java-8.0";
45
+ BuildRuntime2["Java110"] = "java-11.0";
46
+ BuildRuntime2["Java170"] = "java-17.0";
47
+ BuildRuntime2["Java180"] = "java-18.0";
48
+ BuildRuntime2["Java210"] = "java-21.0";
49
+ BuildRuntime2["Java22"] = "java-22";
50
+ BuildRuntime2["Swift55"] = "swift-5.5";
51
+ BuildRuntime2["Swift58"] = "swift-5.8";
52
+ BuildRuntime2["Swift59"] = "swift-5.9";
53
+ BuildRuntime2["Swift510"] = "swift-5.10";
54
+ BuildRuntime2["Kotlin16"] = "kotlin-1.6";
55
+ BuildRuntime2["Kotlin18"] = "kotlin-1.8";
56
+ BuildRuntime2["Kotlin19"] = "kotlin-1.9";
57
+ BuildRuntime2["Kotlin20"] = "kotlin-2.0";
58
+ BuildRuntime2["Cpp17"] = "cpp-17";
59
+ BuildRuntime2["Cpp20"] = "cpp-20";
60
+ BuildRuntime2["Bun10"] = "bun-1.0";
61
+ BuildRuntime2["Bun11"] = "bun-1.1";
62
+ BuildRuntime2["Go123"] = "go-1.23";
63
+ BuildRuntime2["Static1"] = "static-1";
64
+ BuildRuntime2["Flutter324"] = "flutter-3.24";
65
+ BuildRuntime2["Flutter327"] = "flutter-3.27";
66
+ BuildRuntime2["Flutter329"] = "flutter-3.29";
67
+ BuildRuntime2["Flutter332"] = "flutter-3.32";
68
+ return BuildRuntime2;
69
+ })(BuildRuntime || {});
70
+
71
+ export { BuildRuntime };
72
+ //# sourceMappingURL=out.js.map
73
+ //# sourceMappingURL=build-runtime.mjs.map