@bunbase-ae/js 2.2.1-next.91.0a68695 → 2.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunbase-ae/js",
3
- "version": "2.2.1-next.91.0a68695",
3
+ "version": "2.3.1",
4
4
  "type": "module",
5
5
  "description": "TypeScript/JavaScript SDK for BunBase",
6
6
  "license": "UNLICENSED",
package/src/admin.ts CHANGED
@@ -966,6 +966,97 @@ class AdminMigrationsClient {
966
966
  }
967
967
  }
968
968
 
969
+ // ─── Named queries ────────────────────────────────────────────────────────────
970
+
971
+ export type NamedQueryParamType = "string" | "number" | "boolean" | "timestamp";
972
+
973
+ export interface NamedQueryParamDef {
974
+ type: NamedQueryParamType;
975
+ required?: boolean;
976
+ }
977
+
978
+ export interface NamedQuery {
979
+ name: string;
980
+ description: string | null;
981
+ sql: string;
982
+ params: Record<string, NamedQueryParamDef>;
983
+ access: AccessRule;
984
+ row_limit: number;
985
+ timeout_ms: number;
986
+ result_cache_ttl_s: number;
987
+ created_at: number;
988
+ updated_at: number;
989
+ }
990
+
991
+ export interface NamedQueryExecuteResult {
992
+ rows: Record<string, unknown>[];
993
+ row_count: number;
994
+ cached: boolean;
995
+ elapsed_ms: number;
996
+ }
997
+
998
+ export interface CreateNamedQueryInput {
999
+ name: string;
1000
+ description?: string | null;
1001
+ sql: string;
1002
+ params?: Record<string, NamedQueryParamDef>;
1003
+ access?: AccessRule;
1004
+ row_limit?: number;
1005
+ timeout_ms?: number;
1006
+ result_cache_ttl_s?: number;
1007
+ }
1008
+
1009
+ export type UpdateNamedQueryInput = Partial<Omit<CreateNamedQueryInput, "name">>;
1010
+
1011
+ class AdminNamedQueriesClient {
1012
+ constructor(private readonly http: HttpClient) {}
1013
+
1014
+ async list(): Promise<NamedQuery[]> {
1015
+ return this.http.request<NamedQuery[]>("GET", "/api/v1/admin/queries");
1016
+ }
1017
+
1018
+ async get(name: string): Promise<NamedQuery | null> {
1019
+ try {
1020
+ return await this.http.request<NamedQuery>(
1021
+ "GET",
1022
+ `/api/v1/admin/queries/${encodeURIComponent(name)}`,
1023
+ );
1024
+ } catch (err) {
1025
+ if (err instanceof Error && "status" in err && (err as { status: number }).status === 404) {
1026
+ return null;
1027
+ }
1028
+ throw err;
1029
+ }
1030
+ }
1031
+
1032
+ async create(input: CreateNamedQueryInput): Promise<NamedQuery> {
1033
+ return this.http.request<NamedQuery>("POST", "/api/v1/admin/queries", { body: input });
1034
+ }
1035
+
1036
+ async update(name: string, input: UpdateNamedQueryInput): Promise<NamedQuery> {
1037
+ return this.http.request<NamedQuery>(
1038
+ "PATCH",
1039
+ `/api/v1/admin/queries/${encodeURIComponent(name)}`,
1040
+ { body: input },
1041
+ );
1042
+ }
1043
+
1044
+ async delete(name: string): Promise<void> {
1045
+ await this.http.request("DELETE", `/api/v1/admin/queries/${encodeURIComponent(name)}`);
1046
+ }
1047
+
1048
+ async execute(
1049
+ name: string,
1050
+ params: Record<string, unknown> = {},
1051
+ ): Promise<NamedQueryExecuteResult> {
1052
+ return this.http.request<NamedQueryExecuteResult>(
1053
+ "POST",
1054
+ `/api/v1/queries/${encodeURIComponent(name)}/execute`,
1055
+ { body: params },
1056
+ );
1057
+ }
1058
+ }
1059
+
969
1060
  // ─── Main AdminClient ─────────────────────────────────────────────────────────
970
1061
 
971
1062
  export class AdminClient {
@@ -977,6 +1068,7 @@ export class AdminClient {
977
1068
  readonly settings: AdminSettingsClient;
978
1069
  readonly backups: AdminBackupsClient;
979
1070
  readonly migrations: AdminMigrationsClient;
1071
+ readonly queries: AdminNamedQueriesClient;
980
1072
  readonly logs: AdminLogsClient;
981
1073
  readonly system: AdminSystemClient;
982
1074
 
@@ -989,6 +1081,7 @@ export class AdminClient {
989
1081
  this.settings = new AdminSettingsClient(http);
990
1082
  this.backups = new AdminBackupsClient(http);
991
1083
  this.migrations = new AdminMigrationsClient(http);
1084
+ this.queries = new AdminNamedQueriesClient(http);
992
1085
  this.logs = new AdminLogsClient(http);
993
1086
  this.system = new AdminSystemClient(http);
994
1087
  }
package/src/index.ts CHANGED
@@ -16,6 +16,7 @@ export {
16
16
  type CollectionStats,
17
17
  type ColumnInfo,
18
18
  type ConfigResponse,
19
+ type CreateNamedQueryInput,
19
20
  type CreateRelationParams,
20
21
  type EmailTemplate,
21
22
  type HealthResponse,
@@ -23,6 +24,10 @@ export {
23
24
  type IndexInfo,
24
25
  type MigrationStatus,
25
26
  type MinuteBucket,
27
+ type NamedQuery,
28
+ type NamedQueryExecuteResult,
29
+ type NamedQueryParamDef,
30
+ type NamedQueryParamType,
26
31
  type Relation,
27
32
  type RelationOnDelete,
28
33
  type RelationType,
@@ -31,6 +36,7 @@ export {
31
36
  type StatsResponse,
32
37
  type StorageBucket,
33
38
  type TemplateName,
39
+ type UpdateNamedQueryInput,
34
40
  type UpdateUserParams,
35
41
  type WebhookLogRow,
36
42
  } from "./admin";