@dnax/core 0.21.1 → 0.21.3

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/app/hono.ts CHANGED
@@ -534,6 +534,10 @@ function HonoInstance(): typeof app {
534
534
  c.status(err.code || 500);
535
535
  return c.json({
536
536
  message: err?.message || err,
537
+ code: err?.code || 500,
538
+ timestamp: new Date().toISOString(),
539
+ success: false,
540
+ meta: err?.code || {},
537
541
  });
538
542
  }
539
543
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.21.1",
3
+ "version": "0.21.3",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {
package/types/index.ts CHANGED
@@ -206,6 +206,27 @@ export type hooksCtx = (ctx: {
206
206
  error: typeof fn.error;
207
207
  }) => any;
208
208
 
209
+ export type beforeOperationCtx = (ctx: {
210
+ filter?: any;
211
+ result?: any | null | object | undefined;
212
+ driver?: "mongodb" | "postgres";
213
+ data?: object;
214
+ params?: findParam;
215
+ options?: {};
216
+ count?: number;
217
+ id?: string;
218
+ ids?: string[];
219
+ update?: updateParams;
220
+ pipeline?: Array<object>;
221
+ sharedData?: any;
222
+ action?: Actions;
223
+ c?: Context;
224
+ rest: InstanceType<typeof useRest>;
225
+ session?: sessionCtx;
226
+ io: socketIoType;
227
+ error: typeof fn.error;
228
+ }) => any;
229
+
209
230
  export type ctxApi = {
210
231
  rest: useRest;
211
232
  data?: any;
package/utils/index.ts CHANGED
@@ -336,16 +336,21 @@ function getEntryBykeys(obj: object = {}, keys: string[] = []) {
336
336
  return resultat;
337
337
  }
338
338
 
339
- class contextError extends Error {
340
- constructor(message: string, code: number) {
339
+ class ContextError extends Error {
340
+ code: number;
341
+ meta: any;
342
+
343
+ constructor(message: string, code: number, meta?: object) {
341
344
  super(message);
342
345
  this.code = code;
346
+ this.meta = meta;
347
+ Object.setPrototypeOf(this, ContextError.prototype);
343
348
  }
344
349
  }
345
350
 
346
351
  const fn = {
347
352
  error: (message: string, code: number) => {
348
- throw new contextError(message || "", code);
353
+ throw new ContextError(message || "", code);
349
354
  },
350
355
  };
351
356
 
@@ -374,7 +379,7 @@ export {
374
379
  freeze, // Lock object properties
375
380
  resolvePath,
376
381
  isDate, // Check if date
377
- contextError,
382
+ ContextError,
378
383
  jwt, // Jwt utils
379
384
  _, // Moment utils
380
385
  generateUniqueId, // Generate unique id