@centia-io/sdk 0.2.0 → 0.2.1

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.
@@ -2431,6 +2431,98 @@
2431
2431
  }
2432
2432
  };
2433
2433
 
2434
+ //#endregion
2435
+ //#region src/provisioning/Functions.ts
2436
+ /**
2437
+ * Lambda-like functions: manage (CRUD), invoke (sync/async/dry-run) and read
2438
+ * the generated TypeScript interface.
2439
+ */
2440
+ var Functions = class {
2441
+ constructor(client) {
2442
+ this.client = client;
2443
+ }
2444
+ async getFunctions(name) {
2445
+ var _this = this;
2446
+ const path = name ? `api/v4/functions/${encodeURIComponent(name)}` : "api/v4/functions";
2447
+ return _this.client.request({
2448
+ path,
2449
+ method: "GET"
2450
+ });
2451
+ }
2452
+ /** Create one or more functions. Returns the Location of the created resource. */
2453
+ async postFunction(body) {
2454
+ var _this2 = this;
2455
+ var _res$getHeader;
2456
+ return { location: (_res$getHeader = (await _this2.client.requestFull({
2457
+ path: "api/v4/functions",
2458
+ method: "POST",
2459
+ body,
2460
+ expectedStatus: 201
2461
+ })).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
2462
+ }
2463
+ /** Update a function. Changing the code bumps its version. */
2464
+ async patchFunction(name, body) {
2465
+ var _this3 = this;
2466
+ var _res$getHeader2;
2467
+ return { location: (_res$getHeader2 = (await _this3.client.requestFull({
2468
+ path: `api/v4/functions/${encodeURIComponent(name)}`,
2469
+ method: "PATCH",
2470
+ body,
2471
+ expectedStatus: 303
2472
+ })).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
2473
+ }
2474
+ /** Delete a function. */
2475
+ async deleteFunction(name) {
2476
+ await this.client.request({
2477
+ path: `api/v4/functions/${encodeURIComponent(name)}`,
2478
+ method: "DELETE",
2479
+ expectedStatus: 204
2480
+ });
2481
+ }
2482
+ /** Invoke a function synchronously and return its result. */
2483
+ async invoke(name, event = {}) {
2484
+ return this.client.request({
2485
+ path: `api/v4/functions/${encodeURIComponent(name)}/invocations`,
2486
+ method: "POST",
2487
+ body: event
2488
+ });
2489
+ }
2490
+ /** Queue a function invocation; returns immediately with 202 and an id to poll. */
2491
+ async invokeAsync(name, event = {}) {
2492
+ return this.client.request({
2493
+ path: `api/v4/functions/${encodeURIComponent(name)}/invocations`,
2494
+ method: "POST",
2495
+ body: event,
2496
+ query: { async: "true" },
2497
+ expectedStatus: 202
2498
+ });
2499
+ }
2500
+ /** Run once to infer and store input/output type schemas (for TypeScript generation). */
2501
+ async dryRun(name, event = {}) {
2502
+ return this.client.request({
2503
+ path: `api/v4/functions/${encodeURIComponent(name)}/invocations`,
2504
+ method: "POST",
2505
+ body: event,
2506
+ query: { dry: "true" }
2507
+ });
2508
+ }
2509
+ /** Get a stored invocation record (e.g. to poll an async invocation). */
2510
+ async getInvocation(name, id) {
2511
+ return this.client.request({
2512
+ path: `api/v4/functions/${encodeURIComponent(name)}/invocations/${encodeURIComponent(id)}`,
2513
+ method: "GET"
2514
+ });
2515
+ }
2516
+ /** Get the generated TypeScript `Functions` interface (from dry-run schemas). */
2517
+ async getInterfaces() {
2518
+ return this.client.request({
2519
+ path: "api/v4/function-interfaces",
2520
+ method: "GET",
2521
+ accept: "text/plain"
2522
+ });
2523
+ }
2524
+ };
2525
+
2434
2526
  //#endregion
2435
2527
  //#region src/provisioning/MetadataWrite.ts
2436
2528
  var MetadataWrite = class {
@@ -2566,6 +2658,7 @@
2566
2658
  rules: new Rules(http),
2567
2659
  privileges: new Privileges(http),
2568
2660
  rpcMethods: new RpcMethods(http),
2661
+ functions: new Functions(http),
2569
2662
  metadata: new MetadataWrite(http),
2570
2663
  typeScript: new TypeScriptInterfaces(http),
2571
2664
  fileImport: new FileImport(http),
package/node.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './dist/centia-io-sdk-node'
1
+ export * from './dist/centia-io-sdk-node'
package/package.json CHANGED
@@ -1,48 +1,48 @@
1
- {
2
- "name": "@centia-io/sdk",
3
- "version": "0.2.0",
4
- "description": "Centia-io TypeScript SDK",
5
- "author": "Martin Høgh",
6
- "license": "MIT",
7
- "type": "module",
8
- "main": "./dist/centia-io-sdk.cjs",
9
- "module": "./dist/centia-io-sdk.js",
10
- "types": "./dist/centia-io-sdk.d.cts",
11
- "exports": {
12
- ".": {
13
- "require": "./dist/centia-io-sdk.cjs",
14
- "import": "./dist/centia-io-sdk.js"
15
- },
16
- "./node": {
17
- "import": { "types": "./dist/centia-io-sdk-node.d.ts", "default": "./dist/centia-io-sdk-node.js" },
18
- "require": { "types": "./dist/centia-io-sdk-node.d.cts", "default": "./dist/centia-io-sdk-node.cjs" }
19
- },
20
- "./package.json": "./package.json"
21
- },
22
- "files": [
23
- "dist",
24
- "node.d.ts"
25
- ],
26
- "scripts": {
27
- "build": "tsdown",
28
- "build-watch": "tsdown --watch",
29
- "test": "vitest run",
30
- "test:watch": "vitest"
31
- },
32
- "dependencies": {
33
- "configstore": "^7.0.0",
34
- "proper-lockfile": "^4.1.2"
35
- },
36
- "devDependencies": {
37
- "@types/configstore": "^6.0.2",
38
- "@types/proper-lockfile": "^4.1.4",
39
- "tsdown": "^0.17.3",
40
- "tsx": "^4.19.0",
41
- "typescript": "^5.6.3",
42
- "vitest": "^4.0.18"
43
- },
44
- "private": false,
45
- "engines": {
46
- "node": ">=18"
47
- }
48
- }
1
+ {
2
+ "name": "@centia-io/sdk",
3
+ "version": "0.2.1",
4
+ "description": "Centia-io TypeScript SDK",
5
+ "author": "Martin Høgh",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./dist/centia-io-sdk.cjs",
9
+ "module": "./dist/centia-io-sdk.js",
10
+ "types": "./dist/centia-io-sdk.d.cts",
11
+ "exports": {
12
+ ".": {
13
+ "require": "./dist/centia-io-sdk.cjs",
14
+ "import": "./dist/centia-io-sdk.js"
15
+ },
16
+ "./node": {
17
+ "import": { "types": "./dist/centia-io-sdk-node.d.ts", "default": "./dist/centia-io-sdk-node.js" },
18
+ "require": { "types": "./dist/centia-io-sdk-node.d.cts", "default": "./dist/centia-io-sdk-node.cjs" }
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "node.d.ts"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsdown",
28
+ "build-watch": "tsdown --watch",
29
+ "test": "vitest run",
30
+ "test:watch": "vitest"
31
+ },
32
+ "dependencies": {
33
+ "configstore": "^7.0.0",
34
+ "proper-lockfile": "^4.1.2"
35
+ },
36
+ "devDependencies": {
37
+ "@types/configstore": "^6.0.2",
38
+ "@types/proper-lockfile": "^4.1.4",
39
+ "tsdown": "^0.17.3",
40
+ "tsx": "^4.19.0",
41
+ "typescript": "^5.6.3",
42
+ "vitest": "^4.0.18"
43
+ },
44
+ "private": false,
45
+ "engines": {
46
+ "node": ">=18"
47
+ }
48
+ }