@boltic/sdk 0.1.3 → 0.1.4

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.
@@ -172,6 +172,7 @@ export declare class BolticClient {
172
172
  private indexResource;
173
173
  private databaseResource;
174
174
  private workflowResource;
175
+ private serverlessResource;
175
176
  private currentDatabase;
176
177
  private clientOptions;
177
178
  constructor(apiKey: string, options?: ClientOptions);
@@ -311,6 +312,48 @@ export declare class BolticClient {
311
312
  getIntegrationResource: (params: GetIntegrationResourceParams) => Promise<BolticErrorResponse | BolticSuccessResponse<IntegrationResourceData>>;
312
313
  getIntegrationForm: (params: GetIntegrationFormParams) => Promise<BolticErrorResponse | BolticSuccessResponse<Record<string, unknown> | IntegrationFormJsonSchema>>;
313
314
  };
315
+ /**
316
+ * Serverless function operations.
317
+ *
318
+ * @example
319
+ * ```typescript
320
+ * // List all serverless functions
321
+ * const list = await client.serverless.list();
322
+ *
323
+ * // Create a new serverless function
324
+ * const fn = await client.serverless.create({
325
+ * Name: 'my-api',
326
+ * Runtime: 'code',
327
+ * CodeOpts: { Language: 'nodejs/20', Code: '...' },
328
+ * Resources: { CPU: 0.1, MemoryMB: 128, MemoryMaxMB: 128 },
329
+ * Scaling: { AutoStop: false, Min: 1, Max: 1, MaxIdleTime: 0 },
330
+ * });
331
+ *
332
+ * // Get a serverless function by ID
333
+ * const details = await client.serverless.get('serverless-id');
334
+ *
335
+ * // Get builds
336
+ * const builds = await client.serverless.getBuilds({ appId: 'id' });
337
+ *
338
+ * // Get runtime logs
339
+ * const logs = await client.serverless.getLogs({ appId: 'id' });
340
+ * ```
341
+ */
342
+ get serverless(): {
343
+ list: (params?: ListServerlessParams) => Promise<BolticErrorResponse | BolticSuccessResponse<ListServerlessData>>;
344
+ get: (appId: string) => Promise<BolticErrorResponse | BolticSuccessResponse<ServerlessData>>;
345
+ create: (params: CreateServerlessParams) => Promise<BolticErrorResponse | BolticSuccessResponse<ServerlessData>>;
346
+ createAndWait: (params: CreateServerlessParams) => Promise<BolticErrorResponse | BolticSuccessResponse<ServerlessData>>;
347
+ update: (params: UpdateServerlessParams) => Promise<BolticErrorResponse | BolticSuccessResponse<ServerlessData>>;
348
+ updateAndWait: (params: UpdateServerlessParams) => Promise<BolticErrorResponse | BolticSuccessResponse<ServerlessData>>;
349
+ getBuilds: (params: GetBuildsParams) => Promise<BolticErrorResponse | BolticSuccessResponse<GetBuildsData>>;
350
+ getLogs: (params: GetLogsParams) => Promise<BolticErrorResponse | BolticSuccessResponse<GetLogsData>>;
351
+ getBuildLogs: (params: GetBuildLogsParams) => Promise<BolticErrorResponse | BolticSuccessResponse<GetBuildLogsData>>;
352
+ pollStatus: (appId: string, options?: {
353
+ intervalMs?: number;
354
+ maxAttempts?: number;
355
+ }) => Promise<BolticErrorResponse | BolticSuccessResponse<ServerlessData>>;
356
+ };
314
357
  getSqlResource(): SqlResource;
315
358
  updateApiKey(newApiKey: string): void;
316
359
  updateConfig(updates: Partial<ClientConfig>): void;
@@ -482,6 +525,22 @@ export declare function createClient(apiKey: string, options?: ClientOptions): B
482
525
  */
483
526
  export declare function createErrorWithContext(message: string, context?: Record<string, unknown>): Error;
484
527
 
528
+ export declare type CreateServerlessData = ServerlessData;
529
+
530
+ export declare interface CreateServerlessParams {
531
+ Name: string;
532
+ Description?: string;
533
+ Runtime: ServerlessRuntime;
534
+ Env?: Record<string, string>;
535
+ PortMap?: ServerlessPortMap[];
536
+ Scaling?: ServerlessScaling;
537
+ Resources?: ServerlessResources;
538
+ Timeout?: number;
539
+ Validations?: unknown;
540
+ CodeOpts?: ServerlessCodeOpts;
541
+ ContainerOpts?: ServerlessContainerOpts;
542
+ }
543
+
485
544
  /** Data returned from the get-credentials API */
486
545
  export declare type CredentialsListData = Record<string, unknown>;
487
546
 
@@ -623,6 +682,21 @@ declare const DateFormatEnum: Readonly<{
623
682
 
624
683
  declare type DecimalType = '00' | '0.0' | '0.00' | '0.000' | '0.0000' | '0.00000' | '0.000000';
625
684
 
685
+ /** Default resource allocation for new serverless functions */
686
+ export declare const DEFAULT_RESOURCES: {
687
+ readonly CPU: 0.1;
688
+ readonly MemoryMB: 128;
689
+ readonly MemoryMaxMB: 128;
690
+ };
691
+
692
+ /** Default scaling configuration for new serverless functions */
693
+ export declare const DEFAULT_SCALING: {
694
+ readonly AutoStop: false;
695
+ readonly Min: 1;
696
+ readonly Max: 1;
697
+ readonly MaxIdleTime: 0;
698
+ };
699
+
626
700
  declare interface DeleteIndexResponse {
627
701
  message?: string;
628
702
  }
@@ -755,6 +829,26 @@ export declare interface FormField {
755
829
  };
756
830
  }
757
831
 
832
+ export declare type GetBuildLogsData = ServerlessBuildLogEntry[];
833
+
834
+ export declare interface GetBuildLogsParams {
835
+ /** The serverless function ID. */
836
+ appId: string;
837
+ /** The build ID. */
838
+ buildId: string;
839
+ }
840
+
841
+ export declare type GetBuildsData = ServerlessBuild[];
842
+
843
+ export declare interface GetBuildsParams {
844
+ /** The serverless function ID. */
845
+ appId: string;
846
+ /** Page number (1-based). @defaultValue 1 */
847
+ page?: number;
848
+ /** Items per page. @defaultValue 20 */
849
+ limit?: number;
850
+ }
851
+
758
852
  /** Parameters accepted by `workflow.getCredentials()`. */
759
853
  export declare interface GetCredentialsParams {
760
854
  /** Integration name (e.g. "freshsales"). Automatically uppercased by the SDK. */
@@ -823,6 +917,30 @@ export declare interface GetIntegrationsParams {
823
917
  per_page?: number;
824
918
  }
825
919
 
920
+ export declare type GetLogsData = ServerlessLogEntry[];
921
+
922
+ export declare interface GetLogsParams {
923
+ /** The serverless function ID. */
924
+ appId: string;
925
+ /** Page number (1-based). @defaultValue 1 */
926
+ page?: number;
927
+ /** Items per page. @defaultValue 50 */
928
+ limit?: number;
929
+ /** Sort direction. @defaultValue 'DESC' */
930
+ sortOrder?: 'ASC' | 'DESC';
931
+ /** Unix epoch start (seconds). Defaults to 24h ago. */
932
+ timestampStart?: number;
933
+ /** Unix epoch end (seconds). Defaults to now. */
934
+ timestampEnd?: number;
935
+ }
936
+
937
+ export declare type GetServerlessData = ServerlessData;
938
+
939
+ export declare interface GetServerlessParams {
940
+ /** The serverless function ID. */
941
+ appId: string;
942
+ }
943
+
826
944
  declare interface HttpAdapter {
827
945
  request<T = unknown>(config: HttpRequestConfig): Promise<HttpResponse<T>>;
828
946
  }
@@ -947,6 +1065,24 @@ declare interface ListIndexesResponse {
947
1065
  };
948
1066
  }
949
1067
 
1068
+ export declare type ListServerlessData = ServerlessData[];
1069
+
1070
+ export declare interface ListServerlessParams {
1071
+ /** Page number (1-based). @defaultValue 1 */
1072
+ page?: number;
1073
+ /** Items per page. @defaultValue 20 */
1074
+ limit?: number;
1075
+ /** Field to sort by. @defaultValue 'CreatedAt' */
1076
+ sortBy?: string;
1077
+ /** Sort direction. @defaultValue 'desc' */
1078
+ sortOrder?: 'asc' | 'desc';
1079
+ /** Search query string to filter by name. */
1080
+ query?: string;
1081
+ }
1082
+
1083
+ /** Maximum number of status polling attempts before timeout */
1084
+ export declare const MAX_STATUS_POLLING_ATTEMPTS = 60;
1085
+
950
1086
  export declare interface PaginationInfo {
951
1087
  total_count: number;
952
1088
  total_pages: number;
@@ -1223,11 +1359,313 @@ export declare interface RetryConfig {
1223
1359
  maximum_interval: number;
1224
1360
  }
1225
1361
 
1362
+ export declare class ServerlessApiClient extends BaseApiClient {
1363
+ constructor(apiKey: string, config?: Omit<BaseApiClientConfig, 'apiKey'>);
1364
+ /**
1365
+ * List all serverless functions with optional pagination and search.
1366
+ */
1367
+ list(params?: ListServerlessParams): Promise<ServerlessResponse<ListServerlessData>>;
1368
+ /**
1369
+ * Get a serverless function by its ID.
1370
+ */
1371
+ get(appId: string): Promise<ServerlessResponse<GetServerlessData>>;
1372
+ /**
1373
+ * Create a new serverless function.
1374
+ */
1375
+ create(payload: CreateServerlessParams): Promise<ServerlessResponse<CreateServerlessData>>;
1376
+ /**
1377
+ * Update an existing serverless function.
1378
+ */
1379
+ update(params: UpdateServerlessParams): Promise<ServerlessResponse<UpdateServerlessData>>;
1380
+ /**
1381
+ * List builds for a serverless function.
1382
+ */
1383
+ getBuilds(params: GetBuildsParams): Promise<ServerlessResponse<GetBuildsData>>;
1384
+ /**
1385
+ * Get runtime logs for a serverless function.
1386
+ */
1387
+ getLogs(params: GetLogsParams): Promise<ServerlessResponse<GetLogsData>>;
1388
+ /**
1389
+ * Get build logs for a specific build of a serverless function.
1390
+ */
1391
+ getBuildLogs(params: GetBuildLogsParams): Promise<ServerlessResponse<GetBuildLogsData>>;
1392
+ }
1393
+
1394
+ export declare interface ServerlessApiEndpoint {
1395
+ path: string;
1396
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
1397
+ authenticated: boolean;
1398
+ }
1399
+
1400
+ export declare interface ServerlessAppDomain {
1401
+ DomainName: string;
1402
+ BaseUrl?: string;
1403
+ }
1404
+
1405
+ export declare interface ServerlessBuild {
1406
+ ID: string;
1407
+ Version?: number;
1408
+ Status?: string;
1409
+ StatusHistory?: ServerlessBuildStatusEntry[];
1410
+ CreatedAt?: string;
1411
+ [key: string]: unknown;
1412
+ }
1413
+
1414
+ export declare interface ServerlessBuildLogEntry {
1415
+ Log?: string;
1416
+ Timestamp?: number;
1417
+ Message?: string;
1418
+ [key: string]: unknown;
1419
+ }
1420
+
1421
+ export declare interface ServerlessBuildStatusEntry {
1422
+ Status: string;
1423
+ Timestamp?: string;
1424
+ }
1425
+
1426
+ export declare interface ServerlessCodeOpts {
1427
+ Language: string;
1428
+ Packages?: string[];
1429
+ Code?: string;
1430
+ }
1431
+
1432
+ export declare interface ServerlessConfig {
1433
+ Name: string;
1434
+ Description?: string;
1435
+ Runtime: ServerlessRuntime;
1436
+ Env?: Record<string, string>;
1437
+ PortMap?: ServerlessPortMap[];
1438
+ Scaling?: ServerlessScaling;
1439
+ Resources?: ServerlessResources;
1440
+ Timeout?: number;
1441
+ Validations?: unknown;
1442
+ CodeOpts?: ServerlessCodeOpts;
1443
+ ContainerOpts?: ServerlessContainerOpts;
1444
+ }
1445
+
1446
+ export declare interface ServerlessContainerOpts {
1447
+ Image: string;
1448
+ Args?: string[];
1449
+ Command?: string;
1450
+ }
1451
+
1452
+ export declare interface ServerlessData {
1453
+ ID: string;
1454
+ ParentID?: string;
1455
+ Status: ServerlessStatus;
1456
+ Config: ServerlessConfig;
1457
+ Links?: {
1458
+ Git?: {
1459
+ Repository?: ServerlessGitRepository;
1460
+ };
1461
+ };
1462
+ AppDomain?: ServerlessAppDomain[];
1463
+ RegionID?: string;
1464
+ CreatedAt?: string;
1465
+ UpdatedAt?: string;
1466
+ [key: string]: unknown;
1467
+ }
1468
+
1469
+ export declare interface ServerlessGitRepository {
1470
+ SshURL?: string;
1471
+ HtmlURL?: string;
1472
+ CloneURL?: string;
1473
+ }
1474
+
1475
+ export declare interface ServerlessLogEntry {
1476
+ Timestamp?: number;
1477
+ Severity?: string;
1478
+ Log?: string;
1479
+ [key: string]: unknown;
1480
+ }
1481
+
1482
+ export declare interface ServerlessPortMap {
1483
+ ContainerPort?: number;
1484
+ HostPort?: number;
1485
+ Protocol?: string;
1486
+ }
1487
+
1488
+ export declare class ServerlessResource extends BaseResource {
1489
+ private apiClient;
1490
+ constructor(client: BaseClient);
1491
+ /**
1492
+ * List all serverless functions with optional pagination and search.
1493
+ *
1494
+ * @param params - Optional pagination and filter parameters
1495
+ * @returns Paginated list of serverless functions
1496
+ *
1497
+ * @example
1498
+ * ```typescript
1499
+ * const list = await client.serverless.list();
1500
+ * const filtered = await client.serverless.list({ query: 'my-func', limit: 10 });
1501
+ * ```
1502
+ */
1503
+ list(params?: ListServerlessParams): Promise<BolticSuccessResponse<ListServerlessData> | BolticErrorResponse>;
1504
+ /**
1505
+ * Get a serverless function by its ID.
1506
+ *
1507
+ * @param appId - The serverless function ID
1508
+ * @returns The serverless function details
1509
+ *
1510
+ * @example
1511
+ * ```typescript
1512
+ * const fn = await client.serverless.get('serverless-id');
1513
+ * ```
1514
+ */
1515
+ get(appId: string): Promise<BolticSuccessResponse<GetServerlessData> | BolticErrorResponse>;
1516
+ /**
1517
+ * Create a new serverless function.
1518
+ *
1519
+ * Supports three runtime types:
1520
+ * - `code` — deploy code directly (blueprint)
1521
+ * - `git` — deploy from a Git repository
1522
+ * - `container` — deploy a Docker container
1523
+ *
1524
+ * @param params - The serverless creation payload
1525
+ * @returns The created serverless function
1526
+ *
1527
+ * @example
1528
+ * ```typescript
1529
+ * const fn = await client.serverless.create({
1530
+ * Name: 'my-api',
1531
+ * Runtime: 'code',
1532
+ * Resources: { CPU: 0.1, MemoryMB: 128, MemoryMaxMB: 128 },
1533
+ * Scaling: { AutoStop: false, Min: 1, Max: 1, MaxIdleTime: 0 },
1534
+ * CodeOpts: { Language: 'nodejs/20', Code: 'module.exports.handler = ...' },
1535
+ * });
1536
+ * ```
1537
+ */
1538
+ create(params: CreateServerlessParams): Promise<BolticSuccessResponse<CreateServerlessData> | BolticErrorResponse>;
1539
+ /**
1540
+ * Create a serverless function and poll until it reaches a terminal state.
1541
+ *
1542
+ * Combines `create()` + `pollStatus()` for a simpler workflow.
1543
+ *
1544
+ * @param params - The serverless creation payload
1545
+ * @returns The final serverless state after reaching a terminal status
1546
+ *
1547
+ * @example
1548
+ * ```typescript
1549
+ * const fn = await client.serverless.createAndWait({
1550
+ * Name: 'my-api',
1551
+ * Runtime: 'code',
1552
+ * CodeOpts: { Language: 'nodejs/20', Code: '...' },
1553
+ * Resources: { CPU: 0.1, MemoryMB: 128, MemoryMaxMB: 128 },
1554
+ * Scaling: { AutoStop: false, Min: 1, Max: 1, MaxIdleTime: 0 },
1555
+ * });
1556
+ * ```
1557
+ */
1558
+ createAndWait(params: CreateServerlessParams): Promise<BolticSuccessResponse<ServerlessData> | BolticErrorResponse>;
1559
+ /**
1560
+ * Update an existing serverless function.
1561
+ *
1562
+ * @param params - The update parameters (appId + partial payload)
1563
+ * @returns The updated serverless function
1564
+ *
1565
+ * @example
1566
+ * ```typescript
1567
+ * const updated = await client.serverless.update({
1568
+ * appId: 'serverless-id',
1569
+ * payload: { Scaling: { AutoStop: true, Min: 0, Max: 3, MaxIdleTime: 300 } },
1570
+ * });
1571
+ * ```
1572
+ */
1573
+ update(params: UpdateServerlessParams): Promise<BolticSuccessResponse<UpdateServerlessData> | BolticErrorResponse>;
1574
+ /**
1575
+ * Update a serverless function and poll until it reaches a terminal state.
1576
+ *
1577
+ * @param params - The update parameters (appId + partial payload)
1578
+ * @returns The final serverless state after reaching a terminal status
1579
+ */
1580
+ updateAndWait(params: UpdateServerlessParams): Promise<BolticSuccessResponse<ServerlessData> | BolticErrorResponse>;
1581
+ /**
1582
+ * List builds for a serverless function.
1583
+ *
1584
+ * @param params - The app ID and optional pagination
1585
+ * @returns List of builds
1586
+ *
1587
+ * @example
1588
+ * ```typescript
1589
+ * const builds = await client.serverless.getBuilds({ appId: 'serverless-id' });
1590
+ * ```
1591
+ */
1592
+ getBuilds(params: GetBuildsParams): Promise<BolticSuccessResponse<GetBuildsData> | BolticErrorResponse>;
1593
+ /**
1594
+ * Get runtime logs for a serverless function.
1595
+ *
1596
+ * @param params - The app ID and optional time range / pagination
1597
+ * @returns Log entries
1598
+ *
1599
+ * @example
1600
+ * ```typescript
1601
+ * const logs = await client.serverless.getLogs({ appId: 'serverless-id' });
1602
+ * const recentLogs = await client.serverless.getLogs({
1603
+ * appId: 'serverless-id',
1604
+ * limit: 100,
1605
+ * sortOrder: 'DESC',
1606
+ * });
1607
+ * ```
1608
+ */
1609
+ getLogs(params: GetLogsParams): Promise<BolticSuccessResponse<GetLogsData> | BolticErrorResponse>;
1610
+ /**
1611
+ * Get build logs for a specific build.
1612
+ *
1613
+ * @param params - The app ID and build ID
1614
+ * @returns Build log entries
1615
+ *
1616
+ * @example
1617
+ * ```typescript
1618
+ * const logs = await client.serverless.getBuildLogs({
1619
+ * appId: 'serverless-id',
1620
+ * buildId: 'build-id',
1621
+ * });
1622
+ * ```
1623
+ */
1624
+ getBuildLogs(params: GetBuildLogsParams): Promise<BolticSuccessResponse<GetBuildLogsData> | BolticErrorResponse>;
1625
+ /**
1626
+ * Poll a serverless function until it reaches a terminal status
1627
+ * (running, failed, degraded, or suspended).
1628
+ *
1629
+ * @param appId - The serverless function ID to poll
1630
+ * @param options - Optional polling configuration overrides
1631
+ * @returns The final serverless state or a timeout error
1632
+ *
1633
+ * @example
1634
+ * ```typescript
1635
+ * const result = await client.serverless.pollStatus('serverless-id');
1636
+ * ```
1637
+ */
1638
+ pollStatus(appId: string, options?: {
1639
+ intervalMs?: number;
1640
+ maxAttempts?: number;
1641
+ }): Promise<BolticSuccessResponse<ServerlessData> | BolticErrorResponse>;
1642
+ }
1643
+
1644
+ export declare interface ServerlessResources {
1645
+ CPU: number;
1646
+ MemoryMB: number;
1647
+ MemoryMaxMB: number;
1648
+ }
1649
+
1650
+ declare type ServerlessResponse<T> = BolticSuccessResponse<T> | BolticErrorResponse;
1651
+
1652
+ export declare type ServerlessRuntime = 'code' | 'git' | 'container';
1653
+
1654
+ export declare interface ServerlessScaling {
1655
+ AutoStop: boolean;
1656
+ Min: number;
1657
+ Max: number;
1658
+ MaxIdleTime: number;
1659
+ }
1660
+
1661
+ export declare type ServerlessStatus = 'running' | 'draft' | 'building' | 'pending' | 'stopped' | 'failed' | 'degraded' | 'suspended';
1662
+
1226
1663
  /** Well-known service paths used across the SDK */
1227
1664
  export declare const SERVICE_PATHS: {
1228
1665
  readonly DATABASES: "/service/sdk/boltic-tables/v1";
1229
1666
  readonly WORKFLOW_TEMPORAL: "/service/panel/temporal/v1.0";
1230
1667
  readonly INTEGRATION: "/service/panel/integration/v1";
1668
+ readonly SERVERLESS: "/service/panel/serverless/v1.0";
1231
1669
  };
1232
1670
 
1233
1671
  export declare interface ServiceAuthConfig extends AuthConfig_2 {
@@ -1266,6 +1704,9 @@ declare class SqlResource {
1266
1704
  executeSQL(query: string, dbId?: string): Promise<ExecuteSQLApiResponse | BolticErrorResponse>;
1267
1705
  }
1268
1706
 
1707
+ /** Polling interval in milliseconds between status checks */
1708
+ export declare const STATUS_POLLING_INTERVAL_MS = 5000;
1709
+
1269
1710
  /**
1270
1711
  * Table Builder - provides a fluent interface for creating tables
1271
1712
  */
@@ -1541,6 +1982,9 @@ declare interface TableUpdateRequest {
1541
1982
  fields?: Array<keyof TableRecord>;
1542
1983
  }
1543
1984
 
1985
+ /** Serverless statuses that indicate the function has reached a terminal state */
1986
+ export declare const TERMINAL_STATUSES: readonly ["running", "failed", "degraded", "suspended"];
1987
+
1544
1988
  declare interface TextToSQLOptions {
1545
1989
  currentQuery?: string;
1546
1990
  }
@@ -1584,6 +2028,15 @@ export declare function transformFormToDefaults(fields: FormField[], skipFields?
1584
2028
  */
1585
2029
  export declare function transformFormToJsonSchema(fields: FormField[], skipFields?: Set<string>): IntegrationFormJsonSchema;
1586
2030
 
2031
+ export declare type UpdateServerlessData = ServerlessData;
2032
+
2033
+ export declare interface UpdateServerlessParams {
2034
+ /** The serverless function ID to update. */
2035
+ appId: string;
2036
+ /** The update payload — partial config fields to update. */
2037
+ payload: Partial<CreateServerlessParams>;
2038
+ }
2039
+
1587
2040
  export declare const VERSION = "1.0.0";
1588
2041
 
1589
2042
  export declare interface WhereCondition {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boltic/sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "TypeScript SDK for Boltic databases infrastructure",
5
5
  "main": "dist/sdk.js",
6
6
  "module": "dist/sdk.mjs",