@veroxm/sdk 0.1.1 → 0.3.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.
@@ -0,0 +1,21 @@
1
+ import type { VeroXMApp } from './client.js';
2
+ type Query = Record<string, string | number | boolean | undefined>;
3
+ /**
4
+ * Project functions with an HTTP trigger (Developer > Functions). Who may call one is the function's own setting:
5
+ * anyone with one of the project's keys, signed-in end users, or server keys only.
6
+ *
7
+ * Answers come back as the function returned them: JSON parsed, text as a string, and `null` when it returned
8
+ * nothing. A failure rejects with VeroXMApiError: `code` is "function_error" (500, the error is in the call log),
9
+ * "function_timeout" (504), "function_limit" (429, the month's limit is used up) or "functions_disabled" (503).
10
+ */
11
+ export declare class FunctionsResource {
12
+ private readonly app;
13
+ constructor(app: VeroXMApp);
14
+ /** POST /functions/:name with `body` (an object or array) as JSON; the function reads it as `request.body`. */
15
+ call<T = unknown>(name: string, body?: Record<string, unknown> | unknown[], options?: {
16
+ query?: Query;
17
+ }): Promise<T>;
18
+ /** GET /functions/:name (the function reads `query` as `request.query`). */
19
+ get<T = unknown>(name: string, query?: Query): Promise<T>;
20
+ }
21
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Project functions with an HTTP trigger (Developer > Functions). Who may call one is the function's own setting:
3
+ * anyone with one of the project's keys, signed-in end users, or server keys only.
4
+ *
5
+ * Answers come back as the function returned them: JSON parsed, text as a string, and `null` when it returned
6
+ * nothing. A failure rejects with VeroXMApiError: `code` is "function_error" (500, the error is in the call log),
7
+ * "function_timeout" (504), "function_limit" (429, the month's limit is used up) or "functions_disabled" (503).
8
+ */
9
+ export class FunctionsResource {
10
+ constructor(app) {
11
+ this.app = app;
12
+ }
13
+ /** POST /functions/:name with `body` (an object or array) as JSON; the function reads it as `request.body`. */
14
+ async call(name, body, options = {}) {
15
+ return (await this.app.request({ method: 'POST', path: path(name), json: body, query: options.query }));
16
+ }
17
+ /** GET /functions/:name (the function reads `query` as `request.query`). */
18
+ async get(name, query = {}) {
19
+ return (await this.app.request({ path: path(name), query }));
20
+ }
21
+ }
22
+ function path(name) {
23
+ return `/functions/${encodeURIComponent(name)}`;
24
+ }