nodestack-client 2.1.0 → 2.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.
package/dist/Client.d.ts CHANGED
@@ -8,6 +8,8 @@ import { DemoService } from './services/DemoService';
8
8
  import { SnapshotService } from './services/SnapshotService';
9
9
  import { WebhookService } from './services/WebhookService';
10
10
  import { AppService } from './services/AppService';
11
+ import { FunctionService } from './services/FunctionService';
12
+ import { FlowService } from './services/FlowService';
11
13
  import type { ClientOptions, SendOptions, RecordModel, ChaosOptions } from './types';
12
14
  /**
13
15
  * Main NodeStack Client SDK entry point.
@@ -24,6 +26,8 @@ export declare class NodeStackClient<TCollections extends Record<string, any> =
24
26
  readonly demo: DemoService;
25
27
  readonly webhooks: WebhookService;
26
28
  readonly apps: AppService;
29
+ readonly functions: FunctionService;
30
+ readonly flows: FlowService;
27
31
  readonly appSlug?: string;
28
32
  private customFetch?;
29
33
  private defaultHeaders;
@@ -1 +1 @@
1
- {"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../src/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EACV,aAAa,EACb,WAA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;;OAEG;IACI,QAAQ,IAAI,YAAY,GAAG,IAAI,CAErC;IAED;;;;OAIG;IACI,UAAU,CAAC,CAAC,SAAS,MAAM,YAAY,EAAE,IAAI,EAAE,CAAC,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAClF,UAAU,CAAC,CAAC,GAAG,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAWnE;;;OAGG;IACU,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,CA0J9E;IAED;;OAEG;IACU,MAAM,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC,CAErE;IAED;;OAEG;IACU,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,CAEpC;IAED;;OAEG;IACU,IAAI,CAAC,IAAI,SAAI,EAAE,OAAO,SAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAKtD;IAED;;OAEG;IACU,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAEnC;IAED;;;OAGG;IACI,GAAG,CAAC,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAClF,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GACnC,eAAe,CAAC,eAAe,CAAC,CAUlC;CACF"}
package/dist/index.cjs CHANGED
@@ -28,6 +28,8 @@ __export(index_exports, {
28
28
  CollectionService: () => CollectionService,
29
29
  DemoService: () => DemoService,
30
30
  FileService: () => FileService,
31
+ FlowService: () => FlowService,
32
+ FunctionService: () => FunctionService,
31
33
  LocalAuthStore: () => LocalAuthStore,
32
34
  MemoryAuthStore: () => MemoryAuthStore,
33
35
  NodeStackClient: () => NodeStackClient,
@@ -234,7 +236,6 @@ var BaseService = class {
234
236
  constructor(client) {
235
237
  this.client = client;
236
238
  }
237
- client;
238
239
  send(path, options = {}) {
239
240
  return this.client.send(path, options);
240
241
  }
@@ -246,7 +247,6 @@ var RecordService = class extends BaseService {
246
247
  super(client);
247
248
  this.collectionName = collectionName;
248
249
  }
249
- collectionName;
250
250
  get clientWithRealtime() {
251
251
  return this.client;
252
252
  }
@@ -1330,6 +1330,139 @@ var AppService = class extends BaseService {
1330
1330
  }
1331
1331
  };
1332
1332
 
1333
+ // src/services/FunctionService.ts
1334
+ var FunctionService = class extends BaseService {
1335
+ /**
1336
+ * Invokes a serverless function by name or ID.
1337
+ * Scoped to the client's configured application if specified.
1338
+ */
1339
+ async invoke(name, body, options = {}) {
1340
+ const encodedName = encodeURIComponent(name);
1341
+ const appPrefix = this.client.appSlug ? `/api/apps/${encodeURIComponent(this.client.appSlug)}` : "/api";
1342
+ const path = `${appPrefix}/functions/${encodedName}/invoke`;
1343
+ return this.send(path, {
1344
+ method: options.method || "POST",
1345
+ body,
1346
+ ...options
1347
+ });
1348
+ }
1349
+ /**
1350
+ * Fetch all functions configured in the active application scope (requires admin auth).
1351
+ */
1352
+ async getList(options) {
1353
+ const appPrefix = this.client.appSlug ? `/api/apps/${encodeURIComponent(this.client.appSlug)}` : "/api";
1354
+ return this.send(`${appPrefix}/functions`, {
1355
+ method: "GET",
1356
+ query: options
1357
+ });
1358
+ }
1359
+ /**
1360
+ * Fetch a single function by ID or name (requires admin auth).
1361
+ */
1362
+ async getOne(idOrName) {
1363
+ const appPrefix = this.client.appSlug ? `/api/apps/${encodeURIComponent(this.client.appSlug)}` : "/api";
1364
+ return this.send(`${appPrefix}/functions/${encodeURIComponent(idOrName)}`, {
1365
+ method: "GET"
1366
+ });
1367
+ }
1368
+ /**
1369
+ * Test execute a function in sandboxed runner (requires admin auth).
1370
+ */
1371
+ async test(id, testPayload = {}) {
1372
+ const appPrefix = this.client.appSlug ? `/api/apps/${encodeURIComponent(this.client.appSlug)}` : "/api";
1373
+ return this.send(`${appPrefix}/functions/${encodeURIComponent(id)}/test`, {
1374
+ method: "POST",
1375
+ body: testPayload
1376
+ });
1377
+ }
1378
+ };
1379
+
1380
+ // src/services/FlowService.ts
1381
+ var FlowService = class extends BaseService {
1382
+ /**
1383
+ * Triggers or executes a Flow state machine by ID or name.
1384
+ * If wait is true (default), returns the finished FlowExecution object.
1385
+ */
1386
+ async execute(flowIdOrName, input, options = {}) {
1387
+ const encoded = encodeURIComponent(flowIdOrName);
1388
+ const appPrefix = this.client.appSlug ? `/api/apps/${encodeURIComponent(this.client.appSlug)}` : "/api";
1389
+ const path = `${appPrefix}/flows/${encoded}/execute`;
1390
+ const wait = options.wait !== false;
1391
+ return this.send(path, {
1392
+ method: "POST",
1393
+ body: input || {},
1394
+ query: { wait: wait ? "true" : "false" },
1395
+ ...options
1396
+ });
1397
+ }
1398
+ /**
1399
+ * Fetch all flows configured in the active application scope (requires admin auth).
1400
+ */
1401
+ async getList(options) {
1402
+ const appPrefix = this.client.appSlug ? `/api/apps/${encodeURIComponent(this.client.appSlug)}` : "/api";
1403
+ return this.send(`${appPrefix}/flows`, {
1404
+ method: "GET",
1405
+ query: options
1406
+ });
1407
+ }
1408
+ /**
1409
+ * Fetch a single flow by ID or name (requires admin auth).
1410
+ */
1411
+ async getOne(idOrName) {
1412
+ const appPrefix = this.client.appSlug ? `/api/apps/${encodeURIComponent(this.client.appSlug)}` : "/api";
1413
+ return this.send(`${appPrefix}/flows/${encodeURIComponent(idOrName)}`, {
1414
+ method: "GET"
1415
+ });
1416
+ }
1417
+ /**
1418
+ * Fetch executions history for a specific flow or across all flows (requires admin auth).
1419
+ */
1420
+ async getExecutions(options) {
1421
+ const appPrefix = this.client.appSlug ? `/api/apps/${encodeURIComponent(this.client.appSlug)}` : "/api";
1422
+ const flowId = options?.flowId ? `/${encodeURIComponent(options.flowId)}/executions` : "/executions";
1423
+ return this.send(
1424
+ `${appPrefix}/flows${flowId}`,
1425
+ {
1426
+ method: "GET",
1427
+ query: options
1428
+ }
1429
+ );
1430
+ }
1431
+ /**
1432
+ * Fetch a single execution record by ID (requires admin auth).
1433
+ */
1434
+ async getExecution(executionId) {
1435
+ const appPrefix = this.client.appSlug ? `/api/apps/${encodeURIComponent(this.client.appSlug)}` : "/api";
1436
+ return this.send(
1437
+ `${appPrefix}/flows/executions/${encodeURIComponent(executionId)}`,
1438
+ { method: "GET" }
1439
+ );
1440
+ }
1441
+ /**
1442
+ * Resumes an orphaned or interrupted running flow from its last completed checkpoint.
1443
+ */
1444
+ async resumeExecution(executionId) {
1445
+ const appPrefix = this.client.appSlug ? `/api/apps/${encodeURIComponent(this.client.appSlug)}` : "/api";
1446
+ return this.send(
1447
+ `${appPrefix}/flows/executions/${encodeURIComponent(executionId)}/resume`,
1448
+ { method: "POST" }
1449
+ );
1450
+ }
1451
+ /**
1452
+ * Aborts an orphaned running flow gracefully with status: 'aborted'.
1453
+ */
1454
+ async abortExecution(executionId, reason) {
1455
+ const appPrefix = this.client.appSlug ? `/api/apps/${encodeURIComponent(this.client.appSlug)}` : "/api";
1456
+ return this.send(
1457
+ `${appPrefix}/flows/executions/${encodeURIComponent(executionId)}/abort`,
1458
+ {
1459
+ method: "POST",
1460
+ body: { reason }
1461
+ }
1462
+ );
1463
+ }
1464
+ };
1465
+
1333
1466
  // src/Client.ts
1334
1467
  var NodeStackClient = class _NodeStackClient {
1335
1468
  baseUrl;
@@ -1343,6 +1476,8 @@ var NodeStackClient = class _NodeStackClient {
1343
1476
  demo;
1344
1477
  webhooks;
1345
1478
  apps;
1479
+ functions;
1480
+ flows;
1346
1481
  appSlug;
1347
1482
  customFetch;
1348
1483
  defaultHeaders;
@@ -1366,6 +1501,8 @@ var NodeStackClient = class _NodeStackClient {
1366
1501
  this.demo = new DemoService(this);
1367
1502
  this.webhooks = new WebhookService(this);
1368
1503
  this.apps = new AppService(this);
1504
+ this.functions = new FunctionService(this);
1505
+ this.flows = new FlowService(this);
1369
1506
  }
1370
1507
  /**
1371
1508
  * Dynamically configure latency & chaos simulation options for all future requests.