@bumidb/admin 0.0.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/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=function(e){return e.Json=`application/json`,e.JsonApi=`application/vnd.api+json`,e.FormData=`multipart/form-data`,e.UrlEncoded=`application/x-www-form-urlencoded`,e.Text=`text/plain`,e}({});var t=class{baseUrl=``;securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:`same-origin`,headers:{},redirect:`follow`,referrerPolicy:`no-referrer`};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t==`number`?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(e=>this.encodeQueryParam(t,e)).join(`&`)}toQueryString(e){let t=e||{};return Object.keys(t).filter(e=>t[e]!==void 0).map(e=>Array.isArray(t[e])?this.addArrayQueryParam(t,e):this.addQueryParam(t,e)).join(`&`)}addQueryParams(e){let t=this.toQueryString(e);return t?`?${t}`:``}contentFormatters={"application/json":e=>e!==null&&(typeof e==`object`||typeof e==`string`)?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e==`object`||typeof e==`string`)?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!=`string`?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{let r=e[n];return t.append(n,r instanceof Blob?r:typeof r==`object`&&r?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){let t=this.abortControllers.get(e);return t?t.signal:void 0}let t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{let t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:i,format:a,baseUrl:o,cancelToken:s,...c})=>{let l=(typeof t==`boolean`?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(c,l),d=i&&this.toQueryString(i),f=this.contentFormatters[r||`application/json`],p=a||u.format;return this.customFetch(`${o||this.baseUrl||``}${n}${d?`?${d}`:``}`,{...u,headers:{...u.headers||{},...r&&r!==`multipart/form-data`?{"Content-Type":r}:{}},signal:(s?this.createAbortSignal(s):u.signal)||null,body:e==null?null:f(e)}).then(async e=>{let t=e;t.data=null,t.error=null;let n=p?e.clone():e,r=p?await n[p]().then(e=>(t.ok?t.data=e:t.error=e,t)).catch(e=>(t.error=e,t)):t;if(s&&this.abortControllers.delete(s),!e.ok)throw r;return r})}},n=class{http;constructor(e){this.http=e}createTenant=(e,t={})=>this.http.request({path:`/api/management/createTenant`,method:`POST`,body:e,type:`application/json`,format:`json`,...t});listTenants=(e={})=>this.http.request({path:`/api/management/listTenants`,method:`POST`,format:`json`,...e});getTenant=(e,t={})=>this.http.request({path:`/api/management/getTenant`,method:`POST`,body:e,type:`application/json`,format:`json`,...t});deleteTenant=(e,t={})=>this.http.request({path:`/api/management/deleteTenant`,method:`POST`,body:e,type:`application/json`,format:`json`,...t});createSession=(e,t={})=>this.http.request({path:`/api/management/createSession`,method:`POST`,body:e,type:`application/json`,format:`json`,...t});tenantUsage=(e,t={})=>this.http.request({path:`/api/management/tenantUsage`,method:`POST`,body:e,type:`application/json`,format:`json`,...t})},r=class extends n{constructor(e){if(!e.apiKey)throw Error(`BumiAdmin requires an apiKey`);let n=new t({baseUrl:e.baseUrl,baseApiParams:{headers:{Authorization:`Bearer ${e.apiKey}`}}});super(n)}};exports.BumiAdmin=r,exports.BumiManagementApi=n,exports.ContentType=e,exports.HttpClient=t;
@@ -0,0 +1,366 @@
1
+ //#region src/generated/index.d.ts
2
+ interface UserInput {
3
+ __type: "User";
4
+ id: string;
5
+ email: string | null;
6
+ display_name: string | null;
7
+ avatar_url: string | null;
8
+ preferences: UserPreferencesInput;
9
+ }
10
+ interface UserPreferencesInput {
11
+ /** @default "system" */
12
+ appearance?: "light" | "dark" | "system";
13
+ defaultProjectId?: string;
14
+ }
15
+ interface User {
16
+ __type: "User";
17
+ id: string;
18
+ email: string | null;
19
+ display_name: string | null;
20
+ avatar_url: string | null;
21
+ preferences: UserPreferences;
22
+ }
23
+ interface UserPreferences {
24
+ /** @default "system" */
25
+ appearance: "light" | "dark" | "system";
26
+ defaultProjectId?: string;
27
+ }
28
+ interface CreateTenantPayload {
29
+ /**
30
+ * @minLength 1
31
+ * @maxLength 255
32
+ */
33
+ name: string;
34
+ /**
35
+ * @minLength 2
36
+ * @maxLength 50
37
+ * @pattern ^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$
38
+ */
39
+ slug?: string;
40
+ }
41
+ interface CreateTenantData {
42
+ id: string;
43
+ project_id: string;
44
+ slug: string | null;
45
+ name: string;
46
+ created_at: string;
47
+ updated_at: string;
48
+ }
49
+ interface ListTenantsData {
50
+ tenants: {
51
+ id: string;
52
+ project_id: string;
53
+ slug: string | null;
54
+ name: string;
55
+ created_at: string;
56
+ updated_at: string;
57
+ }[];
58
+ }
59
+ interface GetTenantPayload {
60
+ /** @minLength 1 */
61
+ id: string;
62
+ }
63
+ interface GetTenantData {
64
+ id: string;
65
+ project_id: string;
66
+ slug: string | null;
67
+ name: string;
68
+ created_at: string;
69
+ updated_at: string;
70
+ }
71
+ interface DeleteTenantPayload {
72
+ /**
73
+ * @format uuid
74
+ * @pattern ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
75
+ */
76
+ id: string;
77
+ }
78
+ interface DeleteTenantData {
79
+ id: string;
80
+ }
81
+ interface CreateSessionPayload {
82
+ /**
83
+ * @format uuid
84
+ * @pattern ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
85
+ */
86
+ tenant_id: string;
87
+ metadata?: Record<string, any>;
88
+ }
89
+ interface CreateSessionData {
90
+ token: string;
91
+ expires_at: string;
92
+ project_id: string;
93
+ tenant_id: string;
94
+ }
95
+ interface TenantUsagePayload {
96
+ /**
97
+ * @format uuid
98
+ * @pattern ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
99
+ */
100
+ tenant_id: string;
101
+ /**
102
+ * @format date-time
103
+ * @pattern ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
104
+ */
105
+ from?: string;
106
+ /**
107
+ * @format date-time
108
+ * @pattern ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
109
+ */
110
+ to?: string;
111
+ }
112
+ interface TenantUsageData {
113
+ tenant_id: string;
114
+ period: {
115
+ from: string;
116
+ to: string;
117
+ };
118
+ sessions: {
119
+ /**
120
+ * @min 0
121
+ * @max 9007199254740991
122
+ */
123
+ mints: number;
124
+ /**
125
+ * @min 0
126
+ * @max 9007199254740991
127
+ */
128
+ active: number;
129
+ /**
130
+ * @min 0
131
+ * @max 9007199254740991
132
+ */
133
+ distinct_end_users: number;
134
+ };
135
+ writes: {
136
+ /**
137
+ * @min 0
138
+ * @max 9007199254740991
139
+ */
140
+ commits: number;
141
+ /**
142
+ * @min 0
143
+ * @max 9007199254740991
144
+ */
145
+ ops: number;
146
+ };
147
+ }
148
+ declare namespace Management {
149
+ /**
150
+ * No description
151
+ * @name CreateTenant
152
+ * @request POST:/api/management/createTenant
153
+ * @response `200` `CreateTenantData` Default Response
154
+ */
155
+ namespace CreateTenant {
156
+ type RequestParams = {};
157
+ type RequestQuery = {};
158
+ type RequestBody = CreateTenantPayload;
159
+ type RequestHeaders = {};
160
+ type ResponseBody = CreateTenantData;
161
+ }
162
+ /**
163
+ * No description
164
+ * @name ListTenants
165
+ * @request POST:/api/management/listTenants
166
+ * @response `200` `ListTenantsData` Default Response
167
+ */
168
+ namespace ListTenants {
169
+ type RequestParams = {};
170
+ type RequestQuery = {};
171
+ type RequestBody = never;
172
+ type RequestHeaders = {};
173
+ type ResponseBody = ListTenantsData;
174
+ }
175
+ /**
176
+ * No description
177
+ * @name GetTenant
178
+ * @request POST:/api/management/getTenant
179
+ * @response `200` `GetTenantData` Default Response
180
+ */
181
+ namespace GetTenant {
182
+ type RequestParams = {};
183
+ type RequestQuery = {};
184
+ type RequestBody = GetTenantPayload;
185
+ type RequestHeaders = {};
186
+ type ResponseBody = GetTenantData;
187
+ }
188
+ /**
189
+ * No description
190
+ * @name DeleteTenant
191
+ * @request POST:/api/management/deleteTenant
192
+ * @response `200` `DeleteTenantData` Default Response
193
+ */
194
+ namespace DeleteTenant {
195
+ type RequestParams = {};
196
+ type RequestQuery = {};
197
+ type RequestBody = DeleteTenantPayload;
198
+ type RequestHeaders = {};
199
+ type ResponseBody = DeleteTenantData;
200
+ }
201
+ /**
202
+ * No description
203
+ * @name CreateSession
204
+ * @request POST:/api/management/createSession
205
+ * @response `200` `CreateSessionData` Default Response
206
+ */
207
+ namespace CreateSession {
208
+ type RequestParams = {};
209
+ type RequestQuery = {};
210
+ type RequestBody = CreateSessionPayload;
211
+ type RequestHeaders = {};
212
+ type ResponseBody = CreateSessionData;
213
+ }
214
+ /**
215
+ * No description
216
+ * @name TenantUsage
217
+ * @request POST:/api/management/tenantUsage
218
+ * @response `200` `TenantUsageData` Default Response
219
+ */
220
+ namespace TenantUsage {
221
+ type RequestParams = {};
222
+ type RequestQuery = {};
223
+ type RequestBody = TenantUsagePayload;
224
+ type RequestHeaders = {};
225
+ type ResponseBody = TenantUsageData;
226
+ }
227
+ }
228
+ type QueryParamsType = Record<string | number, any>;
229
+ type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;
230
+ interface FullRequestParams extends Omit<RequestInit, "body"> {
231
+ /** set parameter to `true` for call `securityWorker` for this request */
232
+ secure?: boolean;
233
+ /** request path */
234
+ path: string;
235
+ /** content type of request body */
236
+ type?: ContentType;
237
+ /** query params */
238
+ query?: QueryParamsType;
239
+ /** format of response (i.e. response.json() -> format: "json") */
240
+ format?: ResponseFormat;
241
+ /** request body */
242
+ body?: unknown;
243
+ /** base url */
244
+ baseUrl?: string;
245
+ /** request cancellation token */
246
+ cancelToken?: CancelToken;
247
+ }
248
+ type RequestParams = Omit<FullRequestParams, "body" | "method" | "query" | "path">;
249
+ interface ApiConfig<SecurityDataType = unknown> {
250
+ baseUrl?: string;
251
+ baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
252
+ securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
253
+ customFetch?: typeof fetch;
254
+ }
255
+ interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
256
+ data: D;
257
+ error: E;
258
+ }
259
+ type CancelToken = Symbol | string | number;
260
+ declare enum ContentType {
261
+ Json = "application/json",
262
+ JsonApi = "application/vnd.api+json",
263
+ FormData = "multipart/form-data",
264
+ UrlEncoded = "application/x-www-form-urlencoded",
265
+ Text = "text/plain"
266
+ }
267
+ declare class HttpClient<SecurityDataType = unknown> {
268
+ baseUrl: string;
269
+ private securityData;
270
+ private securityWorker?;
271
+ private abortControllers;
272
+ private customFetch;
273
+ private baseApiParams;
274
+ constructor(apiConfig?: ApiConfig<SecurityDataType>);
275
+ setSecurityData: (data: SecurityDataType | null) => void;
276
+ protected encodeQueryParam(key: string, value: any): string;
277
+ protected addQueryParam(query: QueryParamsType, key: string): string;
278
+ protected addArrayQueryParam(query: QueryParamsType, key: string): any;
279
+ protected toQueryString(rawQuery?: QueryParamsType): string;
280
+ protected addQueryParams(rawQuery?: QueryParamsType): string;
281
+ private contentFormatters;
282
+ protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams;
283
+ protected createAbortSignal: (cancelToken: CancelToken) => AbortSignal | undefined;
284
+ abortRequest: (cancelToken: CancelToken) => void;
285
+ request: <T = any, E = any>({
286
+ body,
287
+ secure,
288
+ path,
289
+ type,
290
+ query,
291
+ format,
292
+ baseUrl,
293
+ cancelToken,
294
+ ...params
295
+ }: FullRequestParams) => Promise<HttpResponse<T, E>>;
296
+ }
297
+ /**
298
+ * @title SampleApi
299
+ * @version 1.0.0
300
+ *
301
+ * Sample backend service
302
+ */
303
+ declare class BumiManagementApi<SecurityDataType extends unknown> {
304
+ http: HttpClient<SecurityDataType>;
305
+ constructor(http: HttpClient<SecurityDataType>);
306
+ /**
307
+ * No description
308
+ *
309
+ * @name CreateTenant
310
+ * @request POST:/api/management/createTenant
311
+ * @response `200` `CreateTenantData` Default Response
312
+ */
313
+ createTenant: (data: CreateTenantPayload, params?: RequestParams) => Promise<HttpResponse<CreateTenantData, any>>;
314
+ /**
315
+ * No description
316
+ *
317
+ * @name ListTenants
318
+ * @request POST:/api/management/listTenants
319
+ * @response `200` `ListTenantsData` Default Response
320
+ */
321
+ listTenants: (params?: RequestParams) => Promise<HttpResponse<ListTenantsData, any>>;
322
+ /**
323
+ * No description
324
+ *
325
+ * @name GetTenant
326
+ * @request POST:/api/management/getTenant
327
+ * @response `200` `GetTenantData` Default Response
328
+ */
329
+ getTenant: (data: GetTenantPayload, params?: RequestParams) => Promise<HttpResponse<GetTenantData, any>>;
330
+ /**
331
+ * No description
332
+ *
333
+ * @name DeleteTenant
334
+ * @request POST:/api/management/deleteTenant
335
+ * @response `200` `DeleteTenantData` Default Response
336
+ */
337
+ deleteTenant: (data: DeleteTenantPayload, params?: RequestParams) => Promise<HttpResponse<DeleteTenantData, any>>;
338
+ /**
339
+ * No description
340
+ *
341
+ * @name CreateSession
342
+ * @request POST:/api/management/createSession
343
+ * @response `200` `CreateSessionData` Default Response
344
+ */
345
+ createSession: (data: CreateSessionPayload, params?: RequestParams) => Promise<HttpResponse<CreateSessionData, any>>;
346
+ /**
347
+ * No description
348
+ *
349
+ * @name TenantUsage
350
+ * @request POST:/api/management/tenantUsage
351
+ * @response `200` `TenantUsageData` Default Response
352
+ */
353
+ tenantUsage: (data: TenantUsagePayload, params?: RequestParams) => Promise<HttpResponse<TenantUsageData, any>>;
354
+ }
355
+ //#endregion
356
+ //#region src/index.d.ts
357
+ interface BumiAdminConfig {
358
+ baseUrl: string;
359
+ apiKey: string;
360
+ }
361
+ declare class BumiAdmin extends BumiManagementApi<void> {
362
+ constructor(config: BumiAdminConfig);
363
+ }
364
+ //#endregion
365
+ export { ApiConfig, BumiAdmin, BumiAdminConfig, BumiManagementApi, ContentType, CreateSessionData, CreateSessionPayload, CreateTenantData, CreateTenantPayload, DeleteTenantData, DeleteTenantPayload, FullRequestParams, GetTenantData, GetTenantPayload, HttpClient, HttpResponse, ListTenantsData, Management, QueryParamsType, RequestParams, ResponseFormat, TenantUsageData, TenantUsagePayload, User, UserInput, UserPreferences, UserPreferencesInput };
366
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,366 @@
1
+ //#region src/generated/index.d.ts
2
+ interface UserInput {
3
+ __type: "User";
4
+ id: string;
5
+ email: string | null;
6
+ display_name: string | null;
7
+ avatar_url: string | null;
8
+ preferences: UserPreferencesInput;
9
+ }
10
+ interface UserPreferencesInput {
11
+ /** @default "system" */
12
+ appearance?: "light" | "dark" | "system";
13
+ defaultProjectId?: string;
14
+ }
15
+ interface User {
16
+ __type: "User";
17
+ id: string;
18
+ email: string | null;
19
+ display_name: string | null;
20
+ avatar_url: string | null;
21
+ preferences: UserPreferences;
22
+ }
23
+ interface UserPreferences {
24
+ /** @default "system" */
25
+ appearance: "light" | "dark" | "system";
26
+ defaultProjectId?: string;
27
+ }
28
+ interface CreateTenantPayload {
29
+ /**
30
+ * @minLength 1
31
+ * @maxLength 255
32
+ */
33
+ name: string;
34
+ /**
35
+ * @minLength 2
36
+ * @maxLength 50
37
+ * @pattern ^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$
38
+ */
39
+ slug?: string;
40
+ }
41
+ interface CreateTenantData {
42
+ id: string;
43
+ project_id: string;
44
+ slug: string | null;
45
+ name: string;
46
+ created_at: string;
47
+ updated_at: string;
48
+ }
49
+ interface ListTenantsData {
50
+ tenants: {
51
+ id: string;
52
+ project_id: string;
53
+ slug: string | null;
54
+ name: string;
55
+ created_at: string;
56
+ updated_at: string;
57
+ }[];
58
+ }
59
+ interface GetTenantPayload {
60
+ /** @minLength 1 */
61
+ id: string;
62
+ }
63
+ interface GetTenantData {
64
+ id: string;
65
+ project_id: string;
66
+ slug: string | null;
67
+ name: string;
68
+ created_at: string;
69
+ updated_at: string;
70
+ }
71
+ interface DeleteTenantPayload {
72
+ /**
73
+ * @format uuid
74
+ * @pattern ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
75
+ */
76
+ id: string;
77
+ }
78
+ interface DeleteTenantData {
79
+ id: string;
80
+ }
81
+ interface CreateSessionPayload {
82
+ /**
83
+ * @format uuid
84
+ * @pattern ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
85
+ */
86
+ tenant_id: string;
87
+ metadata?: Record<string, any>;
88
+ }
89
+ interface CreateSessionData {
90
+ token: string;
91
+ expires_at: string;
92
+ project_id: string;
93
+ tenant_id: string;
94
+ }
95
+ interface TenantUsagePayload {
96
+ /**
97
+ * @format uuid
98
+ * @pattern ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
99
+ */
100
+ tenant_id: string;
101
+ /**
102
+ * @format date-time
103
+ * @pattern ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
104
+ */
105
+ from?: string;
106
+ /**
107
+ * @format date-time
108
+ * @pattern ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
109
+ */
110
+ to?: string;
111
+ }
112
+ interface TenantUsageData {
113
+ tenant_id: string;
114
+ period: {
115
+ from: string;
116
+ to: string;
117
+ };
118
+ sessions: {
119
+ /**
120
+ * @min 0
121
+ * @max 9007199254740991
122
+ */
123
+ mints: number;
124
+ /**
125
+ * @min 0
126
+ * @max 9007199254740991
127
+ */
128
+ active: number;
129
+ /**
130
+ * @min 0
131
+ * @max 9007199254740991
132
+ */
133
+ distinct_end_users: number;
134
+ };
135
+ writes: {
136
+ /**
137
+ * @min 0
138
+ * @max 9007199254740991
139
+ */
140
+ commits: number;
141
+ /**
142
+ * @min 0
143
+ * @max 9007199254740991
144
+ */
145
+ ops: number;
146
+ };
147
+ }
148
+ declare namespace Management {
149
+ /**
150
+ * No description
151
+ * @name CreateTenant
152
+ * @request POST:/api/management/createTenant
153
+ * @response `200` `CreateTenantData` Default Response
154
+ */
155
+ namespace CreateTenant {
156
+ type RequestParams = {};
157
+ type RequestQuery = {};
158
+ type RequestBody = CreateTenantPayload;
159
+ type RequestHeaders = {};
160
+ type ResponseBody = CreateTenantData;
161
+ }
162
+ /**
163
+ * No description
164
+ * @name ListTenants
165
+ * @request POST:/api/management/listTenants
166
+ * @response `200` `ListTenantsData` Default Response
167
+ */
168
+ namespace ListTenants {
169
+ type RequestParams = {};
170
+ type RequestQuery = {};
171
+ type RequestBody = never;
172
+ type RequestHeaders = {};
173
+ type ResponseBody = ListTenantsData;
174
+ }
175
+ /**
176
+ * No description
177
+ * @name GetTenant
178
+ * @request POST:/api/management/getTenant
179
+ * @response `200` `GetTenantData` Default Response
180
+ */
181
+ namespace GetTenant {
182
+ type RequestParams = {};
183
+ type RequestQuery = {};
184
+ type RequestBody = GetTenantPayload;
185
+ type RequestHeaders = {};
186
+ type ResponseBody = GetTenantData;
187
+ }
188
+ /**
189
+ * No description
190
+ * @name DeleteTenant
191
+ * @request POST:/api/management/deleteTenant
192
+ * @response `200` `DeleteTenantData` Default Response
193
+ */
194
+ namespace DeleteTenant {
195
+ type RequestParams = {};
196
+ type RequestQuery = {};
197
+ type RequestBody = DeleteTenantPayload;
198
+ type RequestHeaders = {};
199
+ type ResponseBody = DeleteTenantData;
200
+ }
201
+ /**
202
+ * No description
203
+ * @name CreateSession
204
+ * @request POST:/api/management/createSession
205
+ * @response `200` `CreateSessionData` Default Response
206
+ */
207
+ namespace CreateSession {
208
+ type RequestParams = {};
209
+ type RequestQuery = {};
210
+ type RequestBody = CreateSessionPayload;
211
+ type RequestHeaders = {};
212
+ type ResponseBody = CreateSessionData;
213
+ }
214
+ /**
215
+ * No description
216
+ * @name TenantUsage
217
+ * @request POST:/api/management/tenantUsage
218
+ * @response `200` `TenantUsageData` Default Response
219
+ */
220
+ namespace TenantUsage {
221
+ type RequestParams = {};
222
+ type RequestQuery = {};
223
+ type RequestBody = TenantUsagePayload;
224
+ type RequestHeaders = {};
225
+ type ResponseBody = TenantUsageData;
226
+ }
227
+ }
228
+ type QueryParamsType = Record<string | number, any>;
229
+ type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;
230
+ interface FullRequestParams extends Omit<RequestInit, "body"> {
231
+ /** set parameter to `true` for call `securityWorker` for this request */
232
+ secure?: boolean;
233
+ /** request path */
234
+ path: string;
235
+ /** content type of request body */
236
+ type?: ContentType;
237
+ /** query params */
238
+ query?: QueryParamsType;
239
+ /** format of response (i.e. response.json() -> format: "json") */
240
+ format?: ResponseFormat;
241
+ /** request body */
242
+ body?: unknown;
243
+ /** base url */
244
+ baseUrl?: string;
245
+ /** request cancellation token */
246
+ cancelToken?: CancelToken;
247
+ }
248
+ type RequestParams = Omit<FullRequestParams, "body" | "method" | "query" | "path">;
249
+ interface ApiConfig<SecurityDataType = unknown> {
250
+ baseUrl?: string;
251
+ baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
252
+ securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
253
+ customFetch?: typeof fetch;
254
+ }
255
+ interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
256
+ data: D;
257
+ error: E;
258
+ }
259
+ type CancelToken = Symbol | string | number;
260
+ declare enum ContentType {
261
+ Json = "application/json",
262
+ JsonApi = "application/vnd.api+json",
263
+ FormData = "multipart/form-data",
264
+ UrlEncoded = "application/x-www-form-urlencoded",
265
+ Text = "text/plain"
266
+ }
267
+ declare class HttpClient<SecurityDataType = unknown> {
268
+ baseUrl: string;
269
+ private securityData;
270
+ private securityWorker?;
271
+ private abortControllers;
272
+ private customFetch;
273
+ private baseApiParams;
274
+ constructor(apiConfig?: ApiConfig<SecurityDataType>);
275
+ setSecurityData: (data: SecurityDataType | null) => void;
276
+ protected encodeQueryParam(key: string, value: any): string;
277
+ protected addQueryParam(query: QueryParamsType, key: string): string;
278
+ protected addArrayQueryParam(query: QueryParamsType, key: string): any;
279
+ protected toQueryString(rawQuery?: QueryParamsType): string;
280
+ protected addQueryParams(rawQuery?: QueryParamsType): string;
281
+ private contentFormatters;
282
+ protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams;
283
+ protected createAbortSignal: (cancelToken: CancelToken) => AbortSignal | undefined;
284
+ abortRequest: (cancelToken: CancelToken) => void;
285
+ request: <T = any, E = any>({
286
+ body,
287
+ secure,
288
+ path,
289
+ type,
290
+ query,
291
+ format,
292
+ baseUrl,
293
+ cancelToken,
294
+ ...params
295
+ }: FullRequestParams) => Promise<HttpResponse<T, E>>;
296
+ }
297
+ /**
298
+ * @title SampleApi
299
+ * @version 1.0.0
300
+ *
301
+ * Sample backend service
302
+ */
303
+ declare class BumiManagementApi<SecurityDataType extends unknown> {
304
+ http: HttpClient<SecurityDataType>;
305
+ constructor(http: HttpClient<SecurityDataType>);
306
+ /**
307
+ * No description
308
+ *
309
+ * @name CreateTenant
310
+ * @request POST:/api/management/createTenant
311
+ * @response `200` `CreateTenantData` Default Response
312
+ */
313
+ createTenant: (data: CreateTenantPayload, params?: RequestParams) => Promise<HttpResponse<CreateTenantData, any>>;
314
+ /**
315
+ * No description
316
+ *
317
+ * @name ListTenants
318
+ * @request POST:/api/management/listTenants
319
+ * @response `200` `ListTenantsData` Default Response
320
+ */
321
+ listTenants: (params?: RequestParams) => Promise<HttpResponse<ListTenantsData, any>>;
322
+ /**
323
+ * No description
324
+ *
325
+ * @name GetTenant
326
+ * @request POST:/api/management/getTenant
327
+ * @response `200` `GetTenantData` Default Response
328
+ */
329
+ getTenant: (data: GetTenantPayload, params?: RequestParams) => Promise<HttpResponse<GetTenantData, any>>;
330
+ /**
331
+ * No description
332
+ *
333
+ * @name DeleteTenant
334
+ * @request POST:/api/management/deleteTenant
335
+ * @response `200` `DeleteTenantData` Default Response
336
+ */
337
+ deleteTenant: (data: DeleteTenantPayload, params?: RequestParams) => Promise<HttpResponse<DeleteTenantData, any>>;
338
+ /**
339
+ * No description
340
+ *
341
+ * @name CreateSession
342
+ * @request POST:/api/management/createSession
343
+ * @response `200` `CreateSessionData` Default Response
344
+ */
345
+ createSession: (data: CreateSessionPayload, params?: RequestParams) => Promise<HttpResponse<CreateSessionData, any>>;
346
+ /**
347
+ * No description
348
+ *
349
+ * @name TenantUsage
350
+ * @request POST:/api/management/tenantUsage
351
+ * @response `200` `TenantUsageData` Default Response
352
+ */
353
+ tenantUsage: (data: TenantUsagePayload, params?: RequestParams) => Promise<HttpResponse<TenantUsageData, any>>;
354
+ }
355
+ //#endregion
356
+ //#region src/index.d.ts
357
+ interface BumiAdminConfig {
358
+ baseUrl: string;
359
+ apiKey: string;
360
+ }
361
+ declare class BumiAdmin extends BumiManagementApi<void> {
362
+ constructor(config: BumiAdminConfig);
363
+ }
364
+ //#endregion
365
+ export { ApiConfig, BumiAdmin, BumiAdminConfig, BumiManagementApi, ContentType, CreateSessionData, CreateSessionPayload, CreateTenantData, CreateTenantPayload, DeleteTenantData, DeleteTenantPayload, FullRequestParams, GetTenantData, GetTenantPayload, HttpClient, HttpResponse, ListTenantsData, Management, QueryParamsType, RequestParams, ResponseFormat, TenantUsageData, TenantUsagePayload, User, UserInput, UserPreferences, UserPreferencesInput };
366
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ let e=function(e){return e.Json=`application/json`,e.JsonApi=`application/vnd.api+json`,e.FormData=`multipart/form-data`,e.UrlEncoded=`application/x-www-form-urlencoded`,e.Text=`text/plain`,e}({});var t=class{baseUrl=``;securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:`same-origin`,headers:{},redirect:`follow`,referrerPolicy:`no-referrer`};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t==`number`?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(e=>this.encodeQueryParam(t,e)).join(`&`)}toQueryString(e){let t=e||{};return Object.keys(t).filter(e=>t[e]!==void 0).map(e=>Array.isArray(t[e])?this.addArrayQueryParam(t,e):this.addQueryParam(t,e)).join(`&`)}addQueryParams(e){let t=this.toQueryString(e);return t?`?${t}`:``}contentFormatters={"application/json":e=>e!==null&&(typeof e==`object`||typeof e==`string`)?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e==`object`||typeof e==`string`)?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!=`string`?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{let r=e[n];return t.append(n,r instanceof Blob?r:typeof r==`object`&&r?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){let t=this.abortControllers.get(e);return t?t.signal:void 0}let t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{let t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:i,format:a,baseUrl:o,cancelToken:s,...c})=>{let l=(typeof t==`boolean`?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(c,l),d=i&&this.toQueryString(i),f=this.contentFormatters[r||`application/json`],p=a||u.format;return this.customFetch(`${o||this.baseUrl||``}${n}${d?`?${d}`:``}`,{...u,headers:{...u.headers||{},...r&&r!==`multipart/form-data`?{"Content-Type":r}:{}},signal:(s?this.createAbortSignal(s):u.signal)||null,body:e==null?null:f(e)}).then(async e=>{let t=e;t.data=null,t.error=null;let n=p?e.clone():e,r=p?await n[p]().then(e=>(t.ok?t.data=e:t.error=e,t)).catch(e=>(t.error=e,t)):t;if(s&&this.abortControllers.delete(s),!e.ok)throw r;return r})}},n=class{http;constructor(e){this.http=e}createTenant=(e,t={})=>this.http.request({path:`/api/management/createTenant`,method:`POST`,body:e,type:`application/json`,format:`json`,...t});listTenants=(e={})=>this.http.request({path:`/api/management/listTenants`,method:`POST`,format:`json`,...e});getTenant=(e,t={})=>this.http.request({path:`/api/management/getTenant`,method:`POST`,body:e,type:`application/json`,format:`json`,...t});deleteTenant=(e,t={})=>this.http.request({path:`/api/management/deleteTenant`,method:`POST`,body:e,type:`application/json`,format:`json`,...t});createSession=(e,t={})=>this.http.request({path:`/api/management/createSession`,method:`POST`,body:e,type:`application/json`,format:`json`,...t});tenantUsage=(e,t={})=>this.http.request({path:`/api/management/tenantUsage`,method:`POST`,body:e,type:`application/json`,format:`json`,...t})},r=class extends n{constructor(e){if(!e.apiKey)throw Error(`BumiAdmin requires an apiKey`);let n=new t({baseUrl:e.baseUrl,baseApiParams:{headers:{Authorization:`Bearer ${e.apiKey}`}}});super(n)}};export{r as BumiAdmin,n as BumiManagementApi,e as ContentType,t as HttpClient};
2
+ //# sourceMappingURL=index.mjs.map
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@bumidb/admin",
3
+ "version": "0.0.1",
4
+ "description": "Server-side admin SDK for bumi — manage tenants, sessions, and projects via the Bumi Management API.",
5
+ "keywords": [
6
+ "bumi",
7
+ "bumidb",
8
+ "admin",
9
+ "sdk",
10
+ "database",
11
+ "management"
12
+ ],
13
+ "homepage": "https://bumi.so",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/mirinhq/bumi.git",
17
+ "directory": "bumidb/admin"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/mirinhq/bumi/issues"
21
+ },
22
+ "author": "Mirin Pte Ltd",
23
+ "license": "UNLICENSED",
24
+ "type": "module",
25
+ "main": "./dist/index.cjs",
26
+ "types": "./dist/index.d.cts",
27
+ "exports": {
28
+ ".": {
29
+ "import": {
30
+ "types": "./dist/index.d.mts",
31
+ "default": "./dist/index.mjs"
32
+ },
33
+ "require": {
34
+ "types": "./dist/index.d.cts",
35
+ "default": "./dist/index.cjs"
36
+ }
37
+ }
38
+ },
39
+ "files": [
40
+ "dist"
41
+ ],
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "dependencies": {
46
+ "axios": "^1.13.4"
47
+ },
48
+ "devDependencies": {
49
+ "swagger-typescript-api": "^13.2.16",
50
+ "tsdown": "^0.22.0",
51
+ "typescript": "^5.7.0"
52
+ },
53
+ "scripts": {
54
+ "build": "tsdown && find dist -name '*.map' -delete",
55
+ "typecheck": "tsc --noEmit",
56
+ "generate:openapi": "pnpm --filter @bumidb/backend generate:openapi -- ../packages/sdk-management/openapi.json --only-prefix=/api/management/",
57
+ "generate": "swagger-typescript-api generate --path ./openapi.json --output ./src/generated --name index.ts --http-client axios --api-class-name BumiManagementApi --single-http-client --extract-request-params --extract-request-body --extract-response-body --responses --route-types --clean-output --templates ./swagger-templates --module-name-index=1",
58
+ "regen": "pnpm run generate:openapi && pnpm run generate"
59
+ },
60
+ "module": "./dist/index.mjs"
61
+ }