onecore 0.0.17 → 0.0.21

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": "onecore",
3
- "version": "0.0.17",
3
+ "version": "0.0.21",
4
4
  "description": "onecore",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "git@github.com/common-ts/onecore"
20
+ "url": "git@github.com/core-ts/onecore"
21
21
  },
22
22
  "keywords": [
23
23
  "one",
package/src/index.ts CHANGED
@@ -7,8 +7,7 @@ export {LocaleFormatter} from './formatter';
7
7
  export {StringFormatter} from './formatter';
8
8
  export {LocaleStringFormatter} from './formatter';
9
9
 
10
- export {Model} from './metadata';
11
- export {Attribute} from './metadata';
10
+ export * from './metadata';
12
11
 
13
12
  export {CacheService} from './cache';
14
13
  export {SyncCacheService} from './cache';
@@ -27,12 +26,18 @@ export {DataLoader} from './loader';
27
26
 
28
27
  export * from './model';
29
28
 
29
+ import {GenericSearchRepository} from './repository/GenericSearchRepository';
30
+ export {GenericSearchRepository as Repository};
31
+
30
32
  export * from './repository/ViewRepository';
31
33
  export * from './repository/GenericRepository';
32
34
  export * from './repository/SearchRepository';
33
35
  export * from './repository/ViewSearchRepository';
34
36
  export * from './repository/GenericSearchRepository';
35
37
 
38
+ import {GenericSearchService} from './service/GenericSearchService';
39
+ export {GenericSearchService as Service};
40
+
36
41
  export * from './service/ViewService';
37
42
  export * from './service/GenericService';
38
43
  export * from './service/SearchService';
package/src/logger.ts ADDED
@@ -0,0 +1,31 @@
1
+ export interface SimpleMap {
2
+ [key: string]: string|number|boolean|Date;
3
+ }
4
+ export interface LogMap {
5
+ time: string;
6
+ level: string;
7
+ msg: string;
8
+ }
9
+ export interface LogMapConfig {
10
+ time?: string;
11
+ level?: string;
12
+ msg?: string;
13
+ }
14
+ export interface Logger {
15
+ level: number;
16
+ trace(msg: string, m?: SimpleMap, ctx?: any): void;
17
+ debug(msg: string, m?: SimpleMap, ctx?: any): void;
18
+ info(msg: string, m?: SimpleMap, ctx?: any): void;
19
+ warn(msg: string, m?: SimpleMap, ctx?: any): void;
20
+ error(msg: string, m?: SimpleMap, ctx?: any): void;
21
+ panic(msg: string, m?: SimpleMap, ctx?: any): void;
22
+ fatal(msg: string, m?: SimpleMap, ctx?: any): void;
23
+ isLevelEnabled(level: number): boolean;
24
+ isTraceEnabled(): boolean;
25
+ isDebugEnabled(): boolean;
26
+ isInfoEnabled(): boolean;
27
+ isWarnEnabled(): boolean;
28
+ isErrorEnabled(): boolean;
29
+ isPanicEnabled(): boolean;
30
+ isFatalEnabled(): boolean;
31
+ }
package/src/metadata.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export type DataType = 'ObjectId' | 'date' | 'datetime' | 'time'
2
2
  | 'boolean' | 'number' | 'integer' | 'string' | 'text'
3
- | 'object' | 'array' | 'primitives' | 'binary';
3
+ | 'object' | 'array' | 'binary'
4
+ | 'primitives' | 'booleans' | 'numbers' | 'integers' | 'strings' | 'dates' | 'datetimes' | 'times';
4
5
  export type FormatType = 'currency' | 'percentage' | 'email' | 'url' | 'phone' | 'fax' | 'ipv4' | 'ipv6';
5
6
  export type MatchType = 'equal' | 'prefix' | 'contain' | 'max' | 'min'; // contain: default for string, min: default for Date, number
6
7
 
@@ -8,6 +9,7 @@ export interface Model {
8
9
  name?: string;
9
10
  attributes: Attributes;
10
11
  source?: string;
12
+ table?: string;
11
13
  collection?: string;
12
14
  model?: any;
13
15
  schema?: any;
@@ -16,6 +18,7 @@ export interface Model {
16
18
  export interface Attribute {
17
19
  name?: string;
18
20
  field?: string;
21
+ column?: string;
19
22
  type?: DataType;
20
23
  format?: FormatType;
21
24
  required?: boolean;
@@ -23,6 +26,7 @@ export interface Attribute {
23
26
  defaultValue?: any;
24
27
  key?: boolean;
25
28
  unique?: boolean;
29
+ enum?: string[]|number[];
26
30
  q?: boolean;
27
31
  noinsert?: boolean;
28
32
  noupdate?: boolean;
package/src/model.ts CHANGED
@@ -58,16 +58,26 @@ export interface CodeText {
58
58
  }
59
59
 
60
60
  export interface DateRange {
61
+ min?: Date;
62
+ max?: Date;
63
+ bottom?: Date;
64
+ top?: Date;
61
65
  startDate?: Date;
62
66
  endDate?: Date;
63
67
  }
64
68
  export interface TimeRange {
69
+ min?: Date;
70
+ max?: Date;
71
+ bottom?: Date;
72
+ top?: Date;
65
73
  startTime?: Date;
66
74
  endTime?: Date;
67
75
  }
68
76
  export interface NumberRange {
69
77
  min?: number;
70
78
  max?: number;
79
+ bottom?: number;
80
+ top?: number;
71
81
  lower?: number;
72
82
  upper?: number;
73
83
  }
package/src/mq.ts CHANGED
@@ -8,37 +8,54 @@ export interface Message<T, ID, R> {
8
8
  timestamp?: Date;
9
9
  raw?: R;
10
10
  }
11
- export interface Publisher<T, ID> {
12
- publish(data: T, attributes?: StringMap, id?: ID): Promise<boolean|void>;
11
+ export interface Producer<T, R, ID> {
12
+ produce(data: T, attributes?: StringMap, id?: ID): Promise<R>;
13
13
  }
14
- export interface Sender<T, ID> {
15
- send(data: T, attributes?: StringMap, id?: ID): Promise<boolean|void>;
14
+ export interface Publisher<T, R, ID> {
15
+ publish(data: T, attributes?: StringMap, id?: ID): Promise<R>;
16
16
  }
17
- export interface Writer<T, ID> {
18
- write(data: T, attributes?: StringMap, id?: ID): Promise<boolean|void>;
17
+ export interface Sender<T, R, ID> {
18
+ send(data: T, attributes?: StringMap, id?: ID): Promise<R>;
19
+ }
20
+ export interface Writer<T, R, ID> {
21
+ write(data: T, attributes?: StringMap, id?: ID): Promise<R>;
19
22
  }
20
23
 
21
- export interface SimpleSubscriber<T> {
22
- subscribe(data: T, attributes?: StringMap, err?: any): Promise<boolean|void>;
24
+ export interface Producer<T, R, ID> {
25
+ produce(to: string, data: T, attributes?: StringMap, id?: ID): Promise<R>;
26
+ }
27
+ export interface Publisher<T, R, ID> {
28
+ publish(to: string, data: T, attributes?: StringMap, id?: ID): Promise<R>;
23
29
  }
24
- export interface Subscriber<T, ID, R> {
25
- subscribe(data: Message<T, ID, R>, attributes?: StringMap, err?: any): Promise<boolean|void>;
30
+ export interface Sender<T, R, ID> {
31
+ send(to: string, data: T, attributes?: StringMap, id?: ID): Promise<R>;
26
32
  }
27
- export interface SimpleConsumer<T> {
28
- consume(data: T, attributes?: StringMap, err?: any): Promise<boolean|void>;
33
+ export interface Writer<T, R, ID> {
34
+ write(to: string, data: T, attributes?: StringMap, id?: ID): Promise<R>;
35
+ }
36
+
37
+ export interface SimpleConsumer<T, R> {
38
+ consume(handle: (data: T, attributes?: StringMap, raw?: R) => Promise<number>): void;
29
39
  }
30
- export interface Consumer<T, ID, R> {
31
- consume(data: Message<T, ID, R>, attributes?: StringMap, err?: any): Promise<boolean|void>;
40
+ export interface SimpleSubscriber<T, R> {
41
+ subscribe(handle: (data: T, attributes?: StringMap, raw?: R) => Promise<number>): void;
32
42
  }
33
- export interface SimpleReader<T> {
34
- read(data: T, attributes?: StringMap, err?: any): Promise<boolean|void>;
43
+ export interface SimpleReceiver<T, R> {
44
+ receive(handle: (data: T, attributes?: StringMap, raw?: R) => Promise<number>): void;
45
+ }
46
+ export interface SimpleReader<T, R> {
47
+ read(handle: (data: T, attributes?: StringMap, raw?: R) => Promise<number>): void;
48
+ }
49
+
50
+ export interface MessageConsumer<T, ID, R> {
51
+ consume(data: Message<T, ID, R>): void;
35
52
  }
36
- export interface Consumer<T, ID, R> {
37
- read(data: Message<T, ID, R>, attributes?: StringMap, err?: any): Promise<boolean|void>;
53
+ export interface MessageSubscriber<T, ID, R> {
54
+ subscribe(handle: (data: Message<T, ID, R>) => Promise<number>): void;
38
55
  }
39
- export interface SimpleReceiver<T> {
40
- receive(data: T, attributes?: StringMap, err?: any): Promise<boolean|void>;
56
+ export interface MessageReceiver<T, ID, R> {
57
+ receive(handle: (data: Message<T, ID, R>) => Promise<number>): void;
41
58
  }
42
- export interface Receiver<T, ID, R> {
43
- receive(data: Message<T, ID, R>, attributes?: StringMap, err?: any): Promise<boolean|void>;
59
+ export interface MessageReader<T, ID, R> {
60
+ read(handle: (data: Message<T, ID, R>) => Promise<number>): void;
44
61
  }
@@ -1,9 +1,9 @@
1
1
  import {Attributes} from '../metadata';
2
2
 
3
3
  export interface ViewRepository<T, ID> {
4
- metadata(): Attributes;
5
- keys(): string[];
4
+ metadata?(): Attributes|undefined;
5
+ keys?(): string[];
6
6
  all?(ctx?: any): Promise<T[]>;
7
- load(id: ID, ctx?: any): Promise<T>;
7
+ load(id: ID, ctx?: any): Promise<T|null>;
8
8
  exist?(id: ID, ctx?: any): Promise<boolean>;
9
9
  }
@@ -1,9 +1,9 @@
1
1
  import {Attributes} from '../metadata';
2
2
 
3
3
  export interface ViewService<T, ID> {
4
- metadata?(): Attributes;
4
+ metadata?(): Attributes|undefined;
5
5
  keys?(): string[];
6
6
  all?(ctx?: any): Promise<T[]>;
7
- load(id: ID, ctx?: any): Promise<T>;
7
+ load(id: ID, ctx?: any): Promise<T|null>;
8
8
  exist?(id: ID, ctx?: any): Promise<boolean>;
9
9
  }
package/tsconfig.json CHANGED
@@ -6,6 +6,7 @@
6
6
  "outDir": "./lib",
7
7
  "module": "commonjs",
8
8
  "moduleResolution": "node",
9
+ "strict": true,
9
10
  "pretty": true,
10
11
  "sourceMap": false,
11
12
  "declaration": false,