@bshsolutions/sdk-beta 0.0.2-beta

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.
@@ -0,0 +1,20 @@
1
+ // src/services/core/index.ts
2
+ var CoreEntities = {
3
+ BshEntities: "BshEntities",
4
+ BshSchemas: "BshSchemas",
5
+ BshTypes: "BshTypes",
6
+ BshUsers: "BshUsers",
7
+ BshPolicies: "BshPolicies",
8
+ BshRoles: "BshRoles",
9
+ BshFiles: "BshFiles",
10
+ BshConfigurations: "BshConfigurations",
11
+ BshEmails: "BshEmails",
12
+ BshEmailTemplates: "BshEmailTemplates",
13
+ BshEventLogs: "BshEventLogs",
14
+ BshTriggers: "BshTriggers",
15
+ BshTriggerInstances: "BshTriggerInstances"
16
+ };
17
+
18
+ export { CoreEntities };
19
+ //# sourceMappingURL=index.js.map
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/services/core/index.ts"],"names":[],"mappings":";AAAO,IAAM,YAAA,GAAe;AAAA,EACxB,WAAA,EAAa,aAAA;AAAA,EACb,UAAA,EAAY,YAAA;AAAA,EACZ,QAAA,EAAU,UAAA;AAAA,EAEV,QAAA,EAAU,UAAA;AAAA,EACV,WAAA,EAAa,aAAA;AAAA,EACb,QAAA,EAAU,UAAA;AAAA,EAEV,QAAA,EAAU,UAAA;AAAA,EAEV,iBAAA,EAAmB,mBAAA;AAAA,EAEnB,SAAA,EAAW,WAAA;AAAA,EACX,iBAAA,EAAmB,mBAAA;AAAA,EAEnB,YAAA,EAAc,cAAA;AAAA,EACd,WAAA,EAAa,aAAA;AAAA,EACb,mBAAA,EAAqB;AACzB","file":"index.js","sourcesContent":["export const CoreEntities = {\n BshEntities: 'BshEntities',\n BshSchemas: 'BshSchemas',\n BshTypes: 'BshTypes',\n\n BshUsers: 'BshUsers',\n BshPolicies: 'BshPolicies',\n BshRoles: 'BshRoles',\n\n BshFiles: 'BshFiles',\n\n BshConfigurations: 'BshConfigurations',\n\n BshEmails: 'BshEmails',\n BshEmailTemplates: 'BshEmailTemplates',\n\n BshEventLogs: 'BshEventLogs',\n BshTriggers: 'BshTriggers',\n BshTriggerInstances: 'BshTriggerInstances',\n} as const;\n\nexport type CoreEntities = keyof typeof CoreEntities\n"]}
@@ -0,0 +1,2 @@
1
+ import '../types/index.js';
2
+ export { s as ApiKeyService, p as AuthService, j as BshCallbackParams, k as BshCallbackParamsWithPayload, l as BshSearchCallbackParams, q as BshUtilsService, C as CacheRemoveResponse, r as CachingService, E as EntityFnParams, m as EntityFnParamsWithPayload, n as EntitySearchFnParams, o as EntityService, I as ImageService, M as MailingService, S as SettingsService, U as UserService } from '../types-lV042-cm.js';
@@ -0,0 +1,3 @@
1
+ export { ApiKeyService, AuthService, BshUtilsService, CachingService, EntityService, ImageService, MailingService, SettingsService, UserService } from '../chunk-HHI43U6W.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,408 @@
1
+ type BshDate = {
2
+ $date: string;
3
+ };
4
+ type BshObject = {
5
+ persistenceId: string;
6
+ CreatedAt?: BshDate;
7
+ CreatedBy?: string;
8
+ LastUpdatedAt?: BshDate;
9
+ LastUpdatedBy?: string;
10
+ };
11
+ type BshObjectPure<T> = Omit<T, 'persistenceId' | 'CreatedAt' | 'CreatedBy' | 'LastUpdatedAt' | 'LastUpdatedBy'>;
12
+
13
+ type BshResponse<T> = {
14
+ data: T[];
15
+ timestamp: number;
16
+ code: number;
17
+ status: string;
18
+ error: string;
19
+ meta?: {
20
+ type?: string;
21
+ sql?: string;
22
+ error?: string;
23
+ tips?: {
24
+ [key: string]: string;
25
+ };
26
+ };
27
+ endpoint?: string;
28
+ api?: string;
29
+ validations?: {
30
+ field: string;
31
+ error: string;
32
+ }[];
33
+ };
34
+ declare const isOk: (response: BshResponse<unknown> | undefined) => boolean;
35
+ declare class BshError extends Error {
36
+ status: number;
37
+ endpoint: string;
38
+ response?: BshResponse<unknown> | undefined;
39
+ constructor(status: number, endpoint: string, response?: BshResponse<unknown> | undefined);
40
+ }
41
+
42
+ type CaseInsensitive<T extends string> = T | Uppercase<T>;
43
+ type BshSearch<T = unknown> = {
44
+ entity?: string;
45
+ alias?: string;
46
+ fields?: keyof T | string[];
47
+ filters?: Filter<T>[];
48
+ groupBy?: GroupBy<T>;
49
+ sort?: Sort<T>[];
50
+ pagination?: Pagination;
51
+ from?: BshSearch<unknown>;
52
+ };
53
+ type LogicalOperator = CaseInsensitive<"and" | "or">;
54
+ type ComparisonOperator = CaseInsensitive<"eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "like" | "ilike" | "contains" | "icontains" | "starts" | "istarts" | "in" | "nin" | "between" | "isnull" | "notnull">;
55
+ type Filter<T = unknown> = {
56
+ operator?: ComparisonOperator | LogicalOperator;
57
+ field?: string | keyof T;
58
+ value?: unknown;
59
+ type?: string;
60
+ filters?: Filter<T>[];
61
+ };
62
+ type GroupBy<T = unknown> = {
63
+ fields?: string[] | keyof T[];
64
+ aggregate?: Aggregate<T>[];
65
+ };
66
+ type AggregateFunction = "COUNT" | "SUM" | "AVG" | "MIN" | "MAX";
67
+ type Aggregate<T = unknown> = {
68
+ function?: AggregateFunction;
69
+ field?: string | keyof T;
70
+ alias?: string;
71
+ };
72
+ type Sort<T> = {
73
+ field?: string | keyof T;
74
+ direction?: -1 | 1;
75
+ };
76
+ type Pagination = {
77
+ page?: number;
78
+ size?: number;
79
+ };
80
+
81
+ type BshEntities = {
82
+ name: string;
83
+ dbTable: string;
84
+ dbSchema: string;
85
+ type: 'Table' | 'View' | 'Function';
86
+ dbSource: string;
87
+ updateStrategy: 'Replace' | 'Upsert';
88
+ insertDuplicate: 'Upsert' | 'Error';
89
+ bshSchema?: string;
90
+ plugin?: string;
91
+ auditable?: boolean;
92
+ pks: {
93
+ key: string;
94
+ strategy: 'AutoIncrement' | 'UUID' | 'Fixed';
95
+ type: 'string' | 'number';
96
+ }[];
97
+ permissions?: {
98
+ write?: boolean;
99
+ read?: boolean;
100
+ delete?: boolean;
101
+ update?: boolean;
102
+ };
103
+ } & BshObject;
104
+ type BshEntitiesPure = BshObjectPure<BshEntities>;
105
+ declare const BshEntityTypes: readonly ["Table", "View", "Function"];
106
+ declare const BshUpdateStrategies: readonly ["Replace", "Upsert"];
107
+ declare const BshInsertDuplicates: readonly ["Upsert", "Error"];
108
+ declare const BshPKStrategies: readonly ["AutoIncrement", "UUID", "Fixed"];
109
+ declare const BshPKTypes: readonly ["string", "number"];
110
+ type BshEntityPermissions = 'read' | 'write' | 'update' | 'delete';
111
+ declare const BshEntityPermissions: readonly ["read", "write", "update", "delete"];
112
+ type BshSchemas = {
113
+ name: string;
114
+ label: string;
115
+ description: string;
116
+ plugin: string;
117
+ properties: {
118
+ type: string;
119
+ name: string;
120
+ displayName: string;
121
+ description: string;
122
+ required: boolean;
123
+ unique: boolean;
124
+ default: string;
125
+ length: number;
126
+ maxLength: number;
127
+ minLength: number;
128
+ pattern: string;
129
+ }[];
130
+ } & BshObject;
131
+ type BshSchemasPure = BshObjectPure<BshSchemas>;
132
+ type BshSchemaProperty = BshSchemas['properties'][number];
133
+ type BshTypes = {
134
+ name: string;
135
+ label: string;
136
+ plugin?: string;
137
+ baseType?: string;
138
+ schema?: string;
139
+ meta?: {
140
+ description?: string;
141
+ pattern?: string;
142
+ maxLength?: number;
143
+ minLength?: number;
144
+ max?: number;
145
+ min?: number;
146
+ };
147
+ } & BshObject;
148
+ type BshTypesPure = BshObjectPure<BshTypes>;
149
+
150
+ type BshUser = {
151
+ userId: string;
152
+ email: string;
153
+ password?: string;
154
+ roles: string[];
155
+ status: 'ACTIVATED' | 'REQUIRED_ACTIVATION' | 'DISABLED' | 'REQUIRED_RESET_PASSWORD';
156
+ profile?: {
157
+ firstName?: string;
158
+ lastName?: string;
159
+ phone?: string;
160
+ picture?: string;
161
+ tags?: string[];
162
+ [k: string]: unknown;
163
+ };
164
+ } & BshObject;
165
+ type BshUserInit = {
166
+ email: string;
167
+ password?: string;
168
+ roles?: string[];
169
+ profile: BshUser['profile'];
170
+ };
171
+ type BshUserPure = BshObjectPure<BshUser>;
172
+ type BshRole = {
173
+ name: string;
174
+ public?: boolean;
175
+ description?: string;
176
+ } & BshObject;
177
+ type BshRolePure = BshObjectPure<BshRole>;
178
+ type BshPolicy = {
179
+ name: string;
180
+ description?: string;
181
+ principals: {
182
+ type: Uppercase<'user' | 'group' | 'role' | 'apiKey' | 'any'>;
183
+ value: string[];
184
+ }[];
185
+ permissions: {
186
+ entity: string[];
187
+ actions: ('READ' | 'WRITE' | 'DELETE' | 'UPDATE' | 'SEARCH' | '*')[];
188
+ allow: boolean;
189
+ }[];
190
+ enabled: boolean;
191
+ priority?: number;
192
+ apiKeyId?: number;
193
+ } & BshObject;
194
+ type BshPolicyPure = BshObjectPure<BshPolicy>;
195
+ declare const PrincipalType: readonly ["user", "role", "any", "apiKey"];
196
+ declare const PolicyActions: readonly ["*", "READ", "WRITE", "DELETE", "UPDATE", "SEARCH"];
197
+ type BshApiKeysScopes = {
198
+ read: boolean;
199
+ write: boolean;
200
+ delete: boolean;
201
+ update: boolean;
202
+ };
203
+ type BshApiKeysForm = {
204
+ name: string;
205
+ description?: string;
206
+ duration: number;
207
+ type: 'PERSONAL' | 'MACHINE';
208
+ scopes: string[];
209
+ };
210
+ type BshApiKeys = BshApiKeysForm & {
211
+ id: number;
212
+ apiKey: string;
213
+ startedAt: BshDate;
214
+ expiresAt?: BshDate;
215
+ status: 'ACTIVE' | 'REVOKED';
216
+ userId?: string;
217
+ } & BshObject;
218
+
219
+ type BshEventLogs = {
220
+ id: string;
221
+ start: BshDate;
222
+ end: BshDate;
223
+ duration: number;
224
+ payload: string;
225
+ error?: string;
226
+ stack?: string;
227
+ plugin?: string;
228
+ } & BshObject;
229
+ type BshTrigger<Event = BshTriggerEvent> = {
230
+ name: string;
231
+ displayName: string;
232
+ criteria?: string;
233
+ entity: string;
234
+ action: ('READ' | 'INSERT' | 'UPDATE' | 'SEARCH' | 'DELETE' | 'COLUMNS' | 'EXPORT')[];
235
+ events: Event[];
236
+ enabled: boolean;
237
+ } & BshObject;
238
+ type BshTriggerPure = BshObjectPure<BshTrigger<BshTriggerEventPure>>;
239
+ type BshTriggerEvent = {
240
+ name: string;
241
+ plugin: string;
242
+ entity?: string;
243
+ criteria?: string;
244
+ input?: object;
245
+ output?: object;
246
+ failed?: object;
247
+ enabled: boolean;
248
+ } & BshObject;
249
+ type BshTriggerEventPure = BshObjectPure<BshTriggerEvent>;
250
+ type BshTriggerInstance = {
251
+ Id: number;
252
+ trigger: {
253
+ name: string;
254
+ entity: string;
255
+ };
256
+ event: {
257
+ name: string;
258
+ plugin: string;
259
+ };
260
+ payload: object;
261
+ output: object;
262
+ input: object;
263
+ status: 'InProgress' | 'Success' | 'Failed';
264
+ error?: string;
265
+ trac?: string;
266
+ } & BshObject;
267
+ type BshTriggerPlugin = {
268
+ name: string;
269
+ category: string;
270
+ input: object;
271
+ output: object;
272
+ };
273
+ type BshTriggerAction = {
274
+ name: string;
275
+ };
276
+
277
+ type BshConfigurations<T extends Record<string, unknown> = Record<string, unknown>> = {
278
+ name: string;
279
+ description: string;
280
+ config?: T;
281
+ } & BshObject;
282
+ type BshSettings = {
283
+ name: string;
284
+ api: {
285
+ response?: {
286
+ showSql?: boolean;
287
+ };
288
+ auth?: {
289
+ enableRegister?: boolean;
290
+ };
291
+ };
292
+ };
293
+ declare const defaultSettings: BshSettings;
294
+
295
+ type SentEmail = {
296
+ Id: string;
297
+ subject: string;
298
+ from: string;
299
+ to: string;
300
+ } & BshObject;
301
+ type BshEmailTemplate = {
302
+ name: string;
303
+ subject: string;
304
+ body: string;
305
+ html: boolean;
306
+ } & BshObject;
307
+ type BshEmailTemplatePure = BshObjectPure<BshEmailTemplate>;
308
+ type MailingPayload = {
309
+ to: string;
310
+ subject: string;
311
+ body: string;
312
+ html: boolean;
313
+ };
314
+ type GmailConfig = {
315
+ email: string;
316
+ password: string;
317
+ host: string;
318
+ port: number;
319
+ protocol: string;
320
+ auth: boolean;
321
+ starttls: boolean;
322
+ from: string;
323
+ };
324
+ type MailDevConfig = GmailConfig;
325
+ type EmailProvider = 'gmail' | 'maildev';
326
+ type EmailConfiguration = BshConfigurations & {
327
+ enabled: EmailProvider;
328
+ gmail?: GmailConfig;
329
+ maildev?: MailDevConfig;
330
+ };
331
+
332
+ type StorageProvider = 'cloudinary';
333
+ type CloudinaryConfig = {
334
+ url: string;
335
+ folder?: string;
336
+ };
337
+ type StorageConfiguration = BshConfigurations & {
338
+ enabled?: StorageProvider;
339
+ cloudinary: CloudinaryConfig;
340
+ };
341
+ type BshFiles = {
342
+ uri: string;
343
+ folder: string;
344
+ secureUri: string;
345
+ tags?: string[];
346
+ assetId: string;
347
+ bytes: number;
348
+ context?: {
349
+ [key: string]: string;
350
+ };
351
+ publicId: string;
352
+ fileId: string;
353
+ width: number;
354
+ height: number;
355
+ format: string;
356
+ } & BshObject;
357
+ type UploadOptions = {
358
+ tags: string[];
359
+ context: {
360
+ [key: string]: unknown;
361
+ };
362
+ [key: string]: unknown;
363
+ };
364
+ type UploadResponse = {
365
+ fileId: string;
366
+ publicId: string;
367
+ assetId: string;
368
+ uri: string;
369
+ secureUri: string;
370
+ tags: string[];
371
+ context: {
372
+ [key: string]: unknown;
373
+ };
374
+ };
375
+ declare const formatFileSize: (file: BshFiles) => string;
376
+
377
+ type CacheInfo = {
378
+ name: string;
379
+ estimatedSize: number;
380
+ requestCount: number;
381
+ hitCount: number;
382
+ hitRate: number;
383
+ missCount: number;
384
+ missRate: number;
385
+ expireAfterWrite: number | null;
386
+ expireAfterAccess: number | null;
387
+ maximumSize: number;
388
+ currentSize: number;
389
+ evictionCount: number;
390
+ evictionWeight: number;
391
+ loadCount: number;
392
+ totalLoadTime: number;
393
+ averageLoadPenalty: number;
394
+ loadSuccessCount: number;
395
+ loadFailureCount: number;
396
+ loadFailureRate: number;
397
+ };
398
+
399
+ type LoginParams = {
400
+ email: string;
401
+ password: string;
402
+ };
403
+ type AuthTokens = {
404
+ access: string;
405
+ refresh: string;
406
+ };
407
+
408
+ export { type Aggregate, type AggregateFunction, type AuthTokens, type BshApiKeys, type BshApiKeysForm, type BshApiKeysScopes, type BshConfigurations, type BshDate, type BshEmailTemplate, type BshEmailTemplatePure, type BshEntities, type BshEntitiesPure, BshEntityPermissions, BshEntityTypes, BshError, type BshEventLogs, type BshFiles, BshInsertDuplicates, type BshObject, type BshObjectPure, BshPKStrategies, BshPKTypes, type BshPolicy, type BshPolicyPure, type BshResponse, type BshRole, type BshRolePure, type BshSchemaProperty, type BshSchemas, type BshSchemasPure, type BshSearch, type BshSettings, type BshTrigger, type BshTriggerAction, type BshTriggerEvent, type BshTriggerEventPure, type BshTriggerInstance, type BshTriggerPlugin, type BshTriggerPure, type BshTypes, type BshTypesPure, BshUpdateStrategies, type BshUser, type BshUserInit, type BshUserPure, type CacheInfo, type CloudinaryConfig, type ComparisonOperator, type EmailConfiguration, type EmailProvider, type Filter, type GmailConfig, type GroupBy, type LogicalOperator, type LoginParams, type MailDevConfig, type MailingPayload, type Pagination, PolicyActions, PrincipalType, type SentEmail, type Sort, type StorageConfiguration, type StorageProvider, type UploadOptions, type UploadResponse, defaultSettings, formatFileSize, isOk };
@@ -0,0 +1,3 @@
1
+ export { BshEntityPermissions, BshEntityTypes, BshError, BshInsertDuplicates, BshPKStrategies, BshPKTypes, BshUpdateStrategies, PolicyActions, PrincipalType, defaultSettings, formatFileSize, isOk } from '../chunk-WMHRN3IR.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}