@nu-art/ts-common 0.202.30 → 0.202.32

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/db/types.d.ts CHANGED
@@ -10,7 +10,11 @@ export type DBIndex<T extends DB_Object> = {
10
10
  };
11
11
  export type Default_UniqueKey = '_id';
12
12
  export type VersionType = string;
13
- export type VersionsDeclaration<T extends DB_Object, Versions extends VersionType[] = ['1.0.0'], Types extends [T, ...DB_Object[]] = [T, ...DB_Object[]]> = {
13
+ export type VersionsDeclaration<Versions extends VersionType[] = ['1.0.0'], Types extends {
14
+ [V in Versions[number]]: DB_Object;
15
+ } = {
16
+ [V in Versions[number]]: DB_Object;
17
+ }> = {
14
18
  versions: Versions;
15
19
  types: Types;
16
20
  };
@@ -21,7 +25,7 @@ export type InnerDependencies<T extends DB_Object, K extends SubsetKeys<keyof T,
21
25
  type Exact<T, Shape> = T & {
22
26
  [K in Exclude<keyof Shape, keyof T>]?: never;
23
27
  };
24
- export type Proto_DB_Object<T extends DB_Object, GeneratedKeys extends keyof T | never, Versions extends VersionsDeclaration<T, any, any>, UniqueKeys extends keyof T = Default_UniqueKey, Dependencies extends Exact<{
28
+ export type Proto_DB_Object<T extends DB_Object, GeneratedKeys extends keyof T | never, Versions extends VersionsDeclaration<VersionType[]>, UniqueKeys extends keyof T = Default_UniqueKey, Dependencies extends Exact<{
25
29
  [K in SubsetKeys<keyof T, T, string | string[]>]?: DBProto<any>;
26
30
  }, Dependencies> = never> = {
27
31
  type: T;
@@ -30,7 +34,7 @@ export type Proto_DB_Object<T extends DB_Object, GeneratedKeys extends keyof T |
30
34
  uniqueKeys: UniqueKeys;
31
35
  dependencies: Dependencies;
32
36
  };
33
- export type DBProto<P extends Proto_DB_Object<any, any, any, any, any>, ModifiableSubType = Omit<P['type'], P['generatedKeys'] | keyof DB_Object>, GeneratedSubType = SubsetObjectByKeys<P['type'], P['generatedKeys']>> = {
37
+ export type DBProto<P extends Proto_DB_Object<any, any, VersionsDeclaration<VersionType[]>, any, any>, ModifiableSubType = Omit<P['type'], P['generatedKeys'] | keyof DB_Object>, GeneratedSubType = SubsetObjectByKeys<P['type'], P['generatedKeys']>> = {
34
38
  uiType: ModifiableSubType & Partial<GeneratedSubType> & Partial<DB_Object>;
35
39
  preDbType: ModifiableSubType & Partial<GeneratedSubType>;
36
40
  dbType: P['type'];
@@ -38,7 +42,7 @@ export type DBProto<P extends Proto_DB_Object<any, any, any, any, any>, Modifiab
38
42
  modifiablePropsValidator: ValidatorTypeResolver<ModifiableSubType>;
39
43
  uniqueKeys: P['uniqueKeys'][];
40
44
  generatedProps: P['generatedKeys'][];
41
- versions: P['versions']['versions'];
45
+ versions: P['versions'];
42
46
  indices: DBIndex<P['type']>[];
43
47
  uniqueParam: UniqueId | {
44
48
  [K in P['uniqueKeys']]: P['type'][K];
@@ -55,7 +59,7 @@ export type DBDef_V3<P extends DBProto<any, any, any>> = {
55
59
  generatedPropsValidator: P['generatedPropsValidator'];
56
60
  modifiablePropsValidator: P['modifiablePropsValidator'];
57
61
  uniqueKeys?: P['uniqueKeys'];
58
- versions?: P['versions'];
62
+ versions?: P['versions']['versions'];
59
63
  indices?: P['indices'];
60
64
  lockKeys?: P['lockKeys'];
61
65
  metadata?: P['metadata'];
@@ -97,36 +101,4 @@ export type MetadataNested<T extends any> = T extends (infer I)[] ? MetadataProp
97
101
  export type Metadata<T extends any> = T extends (infer I)[] ? MetadataProperty<T> & {
98
102
  metadata: Metadata<I>;
99
103
  } : T extends object ? MetadataObject<T> : MetadataProperty<T>;
100
- export declare const DB_Object_Metadata: {
101
- _id: {
102
- optional: boolean;
103
- valueType: string;
104
- description: string;
105
- };
106
- _v: {
107
- optional: boolean;
108
- valueType: string;
109
- description: string;
110
- };
111
- _originDocId: {
112
- optional: boolean;
113
- valueType: string;
114
- description: string;
115
- };
116
- __hardDelete: {
117
- optional: boolean;
118
- valueType: string;
119
- description: string;
120
- };
121
- __created: {
122
- optional: boolean;
123
- valueType: string;
124
- description: string;
125
- };
126
- __updated: {
127
- optional: boolean;
128
- valueType: string;
129
- description: string;
130
- };
131
- };
132
104
  export {};
package/db/types.js CHANGED
@@ -1,38 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DB_Object_Metadata = void 0;
4
- exports.DB_Object_Metadata = {
5
- _id: { optional: false, valueType: 'string', description: 'unique key' },
6
- _v: { optional: false, valueType: 'string', description: 'version' },
7
- _originDocId: { optional: true, valueType: 'string', description: 'previous doc id' },
8
- __hardDelete: { optional: true, valueType: 'boolean', description: 'is hard delete' },
9
- __created: { optional: false, valueType: 'number', description: 'timestamp of creation' },
10
- __updated: { optional: false, valueType: 'number', description: 'timestamp of last time modified' }
11
- };
12
- //@ts-ignore
13
- const pah = {
14
- a: { optional: false, description: 'aaa', valueType: 'string' },
15
- b: { optional: true, description: 'aaa', valueType: 'number' },
16
- c: {
17
- optional: true,
18
- description: 'harti barti',
19
- valueType: 'array',
20
- metadata: { optional: false, description: 'aaa', valueType: 'string' }
21
- },
22
- d: {
23
- optional: true,
24
- description: 'harti barti',
25
- valueType: 'object',
26
- metadata: {
27
- k: { optional: false, description: 'aaa', valueType: 'string' },
28
- l: { optional: false, description: 'aaa', valueType: 'number' }
29
- }
30
- },
31
- e: {
32
- optional: true,
33
- description: 'harti barti',
34
- valueType: 'object',
35
- metadata: { ashpa: { optional: false, description: 'aaa', valueType: 'string' } }
36
- }
37
- };
38
- // console.log(pah);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/ts-common",
3
- "version": "0.202.30",
3
+ "version": "0.202.32",
4
4
  "description": "js and ts infra",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -1,8 +1,6 @@
1
1
  import { DB_Object, OmitDBObject, SubsetObjectByKeys, TS_Object } from './types';
2
- import { DBProto } from '../db/types';
3
2
  export declare const KeysOfDB_Object: (keyof DB_Object)[];
4
3
  export declare function dbObjectToId(i: DB_Object): string;
5
- export declare function dbObjectToId_V3<Proto extends DBProto<any>>(i: Proto['dbType']): any;
6
4
  export declare function removeDBObjectKeys<T extends DB_Object>(instance: T): OmitDBObject<T>;
7
5
  export declare function deleteKeysObject<T extends DB_Object, Ks extends keyof T>(instance: T, keysToRemove: Ks[]): Omit<T, Ks>;
8
6
  export declare function keepDBObjectKeys<T extends DB_Object>(instance: T): DB_Object;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.keepPartialObject = exports.keepDBObjectKeys = exports.deleteKeysObject = exports.removeDBObjectKeys = exports.dbObjectToId_V3 = exports.dbObjectToId = exports.KeysOfDB_Object = void 0;
3
+ exports.keepPartialObject = exports.keepDBObjectKeys = exports.deleteKeysObject = exports.removeDBObjectKeys = exports.dbObjectToId = exports.KeysOfDB_Object = void 0;
4
4
  const object_tools_1 = require("./object-tools");
5
5
  const tools_1 = require("./tools");
6
6
  exports.KeysOfDB_Object = ['_id', '_v', '__created', '__updated'];
@@ -8,10 +8,6 @@ function dbObjectToId(i) {
8
8
  return i._id;
9
9
  }
10
10
  exports.dbObjectToId = dbObjectToId;
11
- function dbObjectToId_V3(i) {
12
- return i._id;
13
- }
14
- exports.dbObjectToId_V3 = dbObjectToId_V3;
15
11
  function removeDBObjectKeys(instance) {
16
12
  const _instance = (0, object_tools_1.deepClone)(instance);
17
13
  exports.KeysOfDB_Object.forEach(key => delete _instance[key]);