@nu-art/ts-common 0.200.45 → 0.200.47

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": "@nu-art/ts-common",
3
- "version": "0.200.45",
3
+ "version": "0.200.47",
4
4
  "description": "js and ts infra",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -15,6 +15,9 @@ export declare function _setTimeout(handler: TimerHandler, sleepMs?: number, ...
15
15
  export declare function _clearTimeout(handlerId?: number): void;
16
16
  export declare function _setInterval(handler: TimerHandler, sleepMs?: number, ...args: any[]): number;
17
17
  export declare function _clearInterval(handlerId?: number): void;
18
+ /**
19
+ * @param comment @deprecated
20
+ */
18
21
  export declare function auditBy(user: string, comment?: string, timestamp?: number): AuditBy;
19
22
  export declare function currentTimeMillis(): number;
20
23
  export declare function specificTimeTodayMillis(hours: number, minutes: number): number;
@@ -63,6 +63,9 @@ function _clearInterval(handlerId) {
63
63
  return clearInterval(handlerId);
64
64
  }
65
65
  exports._clearInterval = _clearInterval;
66
+ /**
67
+ * @param comment @deprecated
68
+ */
66
69
  function auditBy(user, comment, timestamp = currentTimeMillis()) {
67
70
  const _auditBy = {
68
71
  auditBy: user,
@@ -1,3 +1,4 @@
1
- import { DB_Object } from './types';
1
+ import { DB_Object, OmitDBObject } from './types';
2
2
  export declare const KeysOfDB_Object: (keyof DB_Object)[];
3
3
  export declare function dbObjectToId(i: DB_Object): string;
4
+ export declare function removeDBObjectKeys<T extends DB_Object>(instance: T): OmitDBObject<T>;
@@ -1,8 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dbObjectToId = exports.KeysOfDB_Object = void 0;
3
+ exports.removeDBObjectKeys = exports.dbObjectToId = exports.KeysOfDB_Object = void 0;
4
+ const object_tools_1 = require("./object-tools");
4
5
  exports.KeysOfDB_Object = ['_id', '_v', '__created', '__updated'];
5
6
  function dbObjectToId(i) {
6
7
  return i._id;
7
8
  }
8
9
  exports.dbObjectToId = dbObjectToId;
10
+ function removeDBObjectKeys(instance) {
11
+ const _instance = (0, object_tools_1.deepClone)(instance);
12
+ exports.KeysOfDB_Object.forEach(key => delete _instance[key]);
13
+ return _instance;
14
+ }
15
+ exports.removeDBObjectKeys = removeDBObjectKeys;
package/utils/types.d.ts CHANGED
@@ -90,3 +90,5 @@ export type RangeTimestamp = {
90
90
  };
91
91
  export type ValidReturnValue = string | number | object;
92
92
  export type NarrowArray<Default, T1, T2, T3, T4, T5, T6> = T6 extends ValidReturnValue ? [T1, T2, T3, T4, T5, T6] : T5 extends ValidReturnValue ? [T1, T2, T3, T4, T5] : T4 extends ValidReturnValue ? [T1, T2, T3, T4] : T3 extends ValidReturnValue ? [T1, T2, T3] : T2 extends ValidReturnValue ? [T1, T2] : T1 extends ValidReturnValue ? [T1] : Default;
93
+ export type MergeTypes<T extends unknown[]> = T extends [a: infer A, ...rest: infer R] ? A & MergeTypes<R> : {};
94
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;