Skip to content

Commit 64cf18a

Browse files
committed
chore: update SDKs to new RC version
1 parent 851e598 commit 64cf18a

File tree

8 files changed

+93
-12
lines changed

8 files changed

+93
-12
lines changed

docs/examples/functions/create-execution.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const sdk = require('node-appwrite');
2-
const fs = require('fs');
32

43
const client = new sdk.Client()
54
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint

docs/examples/functions/create.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ const result = await functions.create(
2828
'<TEMPLATE_REPOSITORY>', // templateRepository (optional)
2929
'<TEMPLATE_OWNER>', // templateOwner (optional)
3030
'<TEMPLATE_ROOT_DIRECTORY>', // templateRootDirectory (optional)
31-
'<TEMPLATE_VERSION>' // templateVersion (optional)
31+
'<TEMPLATE_VERSION>', // templateVersion (optional)
32+
'' // specification (optional)
3233
);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const sdk = require('node-appwrite');
2+
3+
const client = new sdk.Client()
4+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('&lt;YOUR_PROJECT_ID&gt;') // Your project ID
6+
.setKey('&lt;YOUR_API_KEY&gt;'); // Your secret API key
7+
8+
const functions = new sdk.Functions(client);
9+
10+
const result = await functions.listSpecifications();

docs/examples/functions/update.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ const result = await functions.update(
2424
'<PROVIDER_REPOSITORY_ID>', // providerRepositoryId (optional)
2525
'<PROVIDER_BRANCH>', // providerBranch (optional)
2626
false, // providerSilentMode (optional)
27-
'<PROVIDER_ROOT_DIRECTORY>' // providerRootDirectory (optional)
27+
'<PROVIDER_ROOT_DIRECTORY>', // providerRootDirectory (optional)
28+
'' // specification (optional)
2829
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "node-appwrite",
33
"homepage": "https://appwrite.io/support",
44
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5-
"version": "14.0.0-rc.2",
5+
"version": "14.0.0-rc.3",
66
"license": "BSD-3-Clause",
77
"main": "dist/index.js",
88
"type": "commonjs",

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AppwriteException extends Error {
3333
}
3434

3535
function getUserAgent() {
36-
let ua = 'AppwriteNodeJSSDK/14.0.0-rc.2';
36+
let ua = 'AppwriteNodeJSSDK/14.0.0-rc.3';
3737

3838
// `process` is a global in Node.js, but not fully available in all runtimes.
3939
const platform: string[] = [];
@@ -82,7 +82,7 @@ class Client {
8282
'x-sdk-name': 'Node.js',
8383
'x-sdk-platform': 'server',
8484
'x-sdk-language': 'nodejs',
85-
'x-sdk-version': '14.0.0-rc.2',
85+
'x-sdk-version': '14.0.0-rc.3',
8686
'user-agent' : getUserAgent(),
8787
'X-Appwrite-Response-Format': '1.6.0',
8888
};

src/models.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,19 @@ export namespace Models {
379379
*/
380380
targets: Target[];
381381
}
382+
/**
383+
* Specifications List
384+
*/
385+
export type SpecificationList = {
386+
/**
387+
* Total number of specifications documents that matched your query.
388+
*/
389+
total: number;
390+
/**
391+
* List of specifications.
392+
*/
393+
specifications: Specification[];
394+
}
382395
/**
383396
* Database
384397
*/
@@ -1728,6 +1741,10 @@ export namespace Models {
17281741
* Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests
17291742
*/
17301743
providerSilentMode: boolean;
1744+
/**
1745+
* Machine specification for builds and executions.
1746+
*/
1747+
specification: string;
17311748
}
17321749
/**
17331750
* Template Function
@@ -2324,6 +2341,27 @@ export namespace Models {
23242341
*/
23252342
value: string;
23262343
}
2344+
/**
2345+
* Specification
2346+
*/
2347+
export type Specification = {
2348+
/**
2349+
* Memory size in MB.
2350+
*/
2351+
memory: number;
2352+
/**
2353+
* Number of CPUs.
2354+
*/
2355+
cpus: number;
2356+
/**
2357+
* Is size enabled.
2358+
*/
2359+
enabled: boolean;
2360+
/**
2361+
* Size slug.
2362+
*/
2363+
slug: string;
2364+
}
23272365
/**
23282366
* MFA Challenge
23292367
*/

src/services/functions.ts

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ export class Functions {
6868
* @param {string} templateOwner
6969
* @param {string} templateRootDirectory
7070
* @param {string} templateVersion
71+
* @param {string} specification
7172
* @throws {AppwriteException}
7273
* @returns {Promise<Models.Function>}
7374
*/
74-
async create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, templateRepository?: string, templateOwner?: string, templateRootDirectory?: string, templateVersion?: string): Promise<Models.Function> {
75+
async create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, templateRepository?: string, templateOwner?: string, templateRootDirectory?: string, templateVersion?: string, specification?: string): Promise<Models.Function> {
7576
if (typeof functionId === 'undefined') {
7677
throw new AppwriteException('Missing required parameter: "functionId"');
7778
}
@@ -146,6 +147,9 @@ export class Functions {
146147
if (typeof templateVersion !== 'undefined') {
147148
payload['templateVersion'] = templateVersion;
148149
}
150+
if (typeof specification !== 'undefined') {
151+
payload['specification'] = specification;
152+
}
149153
const uri = new URL(this.client.config.endpoint + apiPath);
150154

151155
const apiHeaders: { [header: string]: string } = {
@@ -183,6 +187,31 @@ export class Functions {
183187
payload,
184188
);
185189
}
190+
/**
191+
* List available function runtime specifications
192+
*
193+
* List allowed function specifications for this instance.
194+
195+
*
196+
* @throws {AppwriteException}
197+
* @returns {Promise<Models.SpecificationList>}
198+
*/
199+
async listSpecifications(): Promise<Models.SpecificationList> {
200+
const apiPath = '/functions/specifications';
201+
const payload: Payload = {};
202+
const uri = new URL(this.client.config.endpoint + apiPath);
203+
204+
const apiHeaders: { [header: string]: string } = {
205+
'content-type': 'application/json',
206+
}
207+
208+
return await this.client.call(
209+
'get',
210+
uri,
211+
apiHeaders,
212+
payload,
213+
);
214+
}
186215
/**
187216
* List function templates
188217
*
@@ -301,10 +330,11 @@ export class Functions {
301330
* @param {string} providerBranch
302331
* @param {boolean} providerSilentMode
303332
* @param {string} providerRootDirectory
333+
* @param {string} specification
304334
* @throws {AppwriteException}
305335
* @returns {Promise<Models.Function>}
306336
*/
307-
async update(functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string): Promise<Models.Function> {
337+
async update(functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: string[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, specification?: string): Promise<Models.Function> {
308338
if (typeof functionId === 'undefined') {
309339
throw new AppwriteException('Missing required parameter: "functionId"');
310340
}
@@ -361,6 +391,9 @@ export class Functions {
361391
if (typeof providerRootDirectory !== 'undefined') {
362392
payload['providerRootDirectory'] = providerRootDirectory;
363393
}
394+
if (typeof specification !== 'undefined') {
395+
payload['specification'] = specification;
396+
}
364397
const uri = new URL(this.client.config.endpoint + apiPath);
365398

366399
const apiHeaders: { [header: string]: string } = {
@@ -739,7 +772,7 @@ Use the &quot;command&quot; param to set the entrypoint used to execute your cod
739772
* @throws {AppwriteException}
740773
* @returns {Promise<Models.Execution>}
741774
*/
742-
async createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string, onProgress = (progress: UploadProgress) => {}): Promise<Models.Execution> {
775+
async createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise<Models.Execution> {
743776
if (typeof functionId === 'undefined') {
744777
throw new AppwriteException('Missing required parameter: "functionId"');
745778
}
@@ -766,15 +799,14 @@ Use the &quot;command&quot; param to set the entrypoint used to execute your cod
766799
const uri = new URL(this.client.config.endpoint + apiPath);
767800

768801
const apiHeaders: { [header: string]: string } = {
769-
'content-type': 'multipart/form-data',
802+
'content-type': 'application/json',
770803
}
771804

772-
return await this.client.chunkedUpload(
805+
return await this.client.call(
773806
'post',
774807
uri,
775808
apiHeaders,
776809
payload,
777-
onProgress
778810
);
779811
}
780812
/**

0 commit comments

Comments
 (0)