onecore 0.0.25 → 0.0.28
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 +1 -1
- package/src/index.ts +22 -39
- package/src/mail/config.ts +24 -2
- package/src/model.ts +17 -0
- package/src/mq.ts +22 -0
- package/src/repository/GenericRepository.ts +7 -0
- package/src/repository/GenericSearchRepository.ts +2 -2
- package/src/repository/SearchRepository.ts +2 -2
- package/src/repository/ViewSearchRepository.ts +2 -2
- package/src/service/GenericSearchDiffApprService.ts +1 -1
- package/src/service/GenericSearchService.ts +6 -3
- package/src/service/SearchService.ts +2 -2
- package/src/service/ViewSearchService.ts +2 -2
- package/src/video.ts +9 -9
- package/src/mail/service/MailService.ts +0 -5
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,35 +1,13 @@
|
|
|
1
|
-
export {Locale} from './formatter';
|
|
2
|
-
|
|
3
1
|
export * from './db';
|
|
4
2
|
|
|
5
|
-
export
|
|
6
|
-
export {LocaleMapper} from './formatter';
|
|
7
|
-
export {Formatter} from './formatter';
|
|
8
|
-
export {LocaleFormatter} from './formatter';
|
|
9
|
-
export {StringFormatter} from './formatter';
|
|
10
|
-
export {LocaleStringFormatter} from './formatter';
|
|
11
|
-
|
|
3
|
+
export * from './formatter';
|
|
12
4
|
export * from './metadata';
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
export {Validator} from './validator';
|
|
18
|
-
export {SyncValidator} from './validator';
|
|
19
|
-
|
|
20
|
-
export {ValueGenerator} from './loader';
|
|
21
|
-
export {IdGenerator} from './loader';
|
|
22
|
-
|
|
23
|
-
export {Generator} from './loader';
|
|
24
|
-
export {Loader} from './loader';
|
|
25
|
-
export {UniqueValueBuilder} from './loader';
|
|
26
|
-
|
|
27
|
-
export {DataLoader} from './loader';
|
|
28
|
-
|
|
5
|
+
export * from './cache';
|
|
6
|
+
export * from './validator';
|
|
7
|
+
export * from './loader';
|
|
29
8
|
export * from './model';
|
|
30
9
|
|
|
31
10
|
import {GenericRepository} from './repository/GenericRepository';
|
|
32
|
-
export {GenericRepository as Repository};
|
|
33
11
|
|
|
34
12
|
export * from './repository/ViewRepository';
|
|
35
13
|
export * from './repository/GenericRepository';
|
|
@@ -37,9 +15,6 @@ export * from './repository/SearchRepository';
|
|
|
37
15
|
export * from './repository/ViewSearchRepository';
|
|
38
16
|
export * from './repository/GenericSearchRepository';
|
|
39
17
|
|
|
40
|
-
import {GenericSearchService} from './service/GenericSearchService';
|
|
41
|
-
export {GenericSearchService as Service};
|
|
42
|
-
|
|
43
18
|
export * from './service/ViewService';
|
|
44
19
|
export * from './service/GenericService';
|
|
45
20
|
export * from './service/SearchService';
|
|
@@ -58,7 +33,6 @@ export * from './mail/model/MailContent';
|
|
|
58
33
|
export * from './mail/model/PersonalizationData';
|
|
59
34
|
export * from './mail/model/MailSettings';
|
|
60
35
|
export * from './mail/model/ASMOptions';
|
|
61
|
-
export * from './mail/service/MailService';
|
|
62
36
|
export * from './mail/config';
|
|
63
37
|
|
|
64
38
|
export * from './location';
|
|
@@ -66,16 +40,23 @@ export * from './video';
|
|
|
66
40
|
export * from './health';
|
|
67
41
|
export * from './logger';
|
|
68
42
|
|
|
43
|
+
export type Log = (msg: string) => void;
|
|
44
|
+
export type LogFunc = Log;
|
|
45
|
+
|
|
69
46
|
import { Attributes } from './metadata';
|
|
70
47
|
import { Filter, SearchResult } from './model';
|
|
71
48
|
// import { GenericRepository } from './repository/GenericRepository';
|
|
72
49
|
import { ViewRepository } from './repository/ViewRepository';
|
|
50
|
+
import { GenericSearchService } from './service/GenericSearchService';
|
|
73
51
|
// import { GenericSearchService } from './service/GenericSearchService';
|
|
74
52
|
import { GenericService } from './service/GenericService';
|
|
75
53
|
import { ViewService } from './service/ViewService';
|
|
76
54
|
|
|
55
|
+
export type Search<T, F> = (s: F, limit?: number, offset?: number | string, fields?: string[]) => Promise<SearchResult<T>>;
|
|
56
|
+
export type SearchFunc<T, F> = Search<T, F>;
|
|
57
|
+
|
|
77
58
|
export class ViewManager<T, ID> implements ViewService<T, ID> {
|
|
78
|
-
constructor(private
|
|
59
|
+
constructor(private r: ViewRepository<T, ID>) {
|
|
79
60
|
this.metadata = this.metadata.bind(this);
|
|
80
61
|
this.keys = this.keys.bind(this);
|
|
81
62
|
this.all = this.all.bind(this);
|
|
@@ -83,21 +64,22 @@ export class ViewManager<T, ID> implements ViewService<T, ID> {
|
|
|
83
64
|
this.exist = this.exist.bind(this);
|
|
84
65
|
}
|
|
85
66
|
metadata(): Attributes|undefined {
|
|
86
|
-
return (this.
|
|
67
|
+
return (this.r.metadata ? this.r.metadata() : undefined);
|
|
87
68
|
}
|
|
88
69
|
keys(): string[] {
|
|
89
|
-
return (this.
|
|
70
|
+
return (this.r.keys ? this.r.keys() : []);
|
|
90
71
|
}
|
|
91
72
|
all(ctx?: any): Promise<T[]> {
|
|
92
|
-
return (this.
|
|
73
|
+
return (this.r.all ? this.r.all() : Promise.resolve([]));
|
|
93
74
|
}
|
|
94
75
|
load(id: ID, ctx?: any): Promise<T | null> {
|
|
95
|
-
return this.
|
|
76
|
+
return this.r.load(id, ctx);
|
|
96
77
|
}
|
|
97
78
|
exist(id: ID, ctx?: any): Promise<boolean> {
|
|
98
|
-
return (this.
|
|
79
|
+
return (this.r.exist ? this.r.exist(id, ctx) : Promise.resolve(false));
|
|
99
80
|
}
|
|
100
81
|
}
|
|
82
|
+
// tslint:disable-next-line:max-classes-per-file
|
|
101
83
|
export class GenericManager<T, ID> extends ViewManager<T, ID> implements GenericService<T, ID, number> {
|
|
102
84
|
constructor(protected repository: GenericRepository<T, ID>) {
|
|
103
85
|
super(repository);
|
|
@@ -123,12 +105,13 @@ export class GenericManager<T, ID> extends ViewManager<T, ID> implements Generic
|
|
|
123
105
|
return (this.repository.delete ? this.repository.delete(id, ctx) : Promise.resolve(-1));
|
|
124
106
|
}
|
|
125
107
|
}
|
|
126
|
-
|
|
127
|
-
|
|
108
|
+
// tslint:disable-next-line:max-classes-per-file
|
|
109
|
+
export class Manager<T, ID, F extends Filter> extends GenericManager<T, ID> implements GenericSearchService<T, ID, number, F> {
|
|
110
|
+
constructor(public find: Search<T, F>, repo: GenericRepository<T, ID>) {
|
|
128
111
|
super(repo);
|
|
129
112
|
this.search = this.search.bind(this);
|
|
130
113
|
}
|
|
131
|
-
search(s:
|
|
114
|
+
search(s: F, limit?: number, offset?: number|string, fields?: string[]): Promise<SearchResult<T>> {
|
|
132
115
|
return this.find(s, limit, offset, fields);
|
|
133
116
|
}
|
|
134
117
|
}
|
package/src/mail/config.ts
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
|
+
import {EmailData} from './model/EmailData';
|
|
1
2
|
import {MailData} from './model/MailData';
|
|
2
3
|
|
|
3
|
-
export interface
|
|
4
|
-
|
|
4
|
+
export interface MailConfig {
|
|
5
|
+
provider?: string;
|
|
6
|
+
from: EmailData;
|
|
5
7
|
key: string;
|
|
8
|
+
smtp?: SmtpConfig;
|
|
9
|
+
}
|
|
10
|
+
export interface Address {
|
|
11
|
+
name: string;
|
|
12
|
+
address: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SmtpConfig {
|
|
15
|
+
host: string;
|
|
16
|
+
port: number;
|
|
17
|
+
secure?: boolean;
|
|
18
|
+
auth: Auth;
|
|
19
|
+
}
|
|
20
|
+
export interface Auth {
|
|
21
|
+
user: string;
|
|
22
|
+
pass: string;
|
|
23
|
+
}
|
|
24
|
+
export type Send = (mailData: MailData) => Promise<boolean>;
|
|
25
|
+
export type SendMail = Send;
|
|
26
|
+
export interface MailService {
|
|
27
|
+
send(mailData: MailData): Promise<boolean>;
|
|
6
28
|
}
|
package/src/model.ts
CHANGED
|
@@ -36,6 +36,10 @@ export interface Domain {
|
|
|
36
36
|
name?: string;
|
|
37
37
|
status?: string;
|
|
38
38
|
}
|
|
39
|
+
export interface Item {
|
|
40
|
+
value: string;
|
|
41
|
+
text?: string;
|
|
42
|
+
}
|
|
39
43
|
export interface ValueText {
|
|
40
44
|
value: string;
|
|
41
45
|
text?: string;
|
|
@@ -117,6 +121,7 @@ export interface ResultInfo<T> {
|
|
|
117
121
|
value?: T;
|
|
118
122
|
message?: string;
|
|
119
123
|
}
|
|
124
|
+
export type Result<T> = number | ResultInfo<T>;
|
|
120
125
|
|
|
121
126
|
export interface DiffModel<T, ID> {
|
|
122
127
|
id?: ID;
|
|
@@ -124,12 +129,24 @@ export interface DiffModel<T, ID> {
|
|
|
124
129
|
value: T;
|
|
125
130
|
}
|
|
126
131
|
|
|
132
|
+
export interface Achievement {
|
|
133
|
+
subject: string;
|
|
134
|
+
description: string;
|
|
135
|
+
}
|
|
136
|
+
export interface Skill {
|
|
137
|
+
skill: string;
|
|
138
|
+
hirable: boolean;
|
|
139
|
+
}
|
|
127
140
|
export interface UserFilter extends Filter {
|
|
128
141
|
userId?: string;
|
|
129
142
|
username?: string;
|
|
130
143
|
email?: string;
|
|
131
144
|
displayName?: string;
|
|
145
|
+
dateOfBirth?: DateRange;
|
|
132
146
|
status?: string[]|string;
|
|
147
|
+
interests: string[];
|
|
148
|
+
skills: Skill[];
|
|
149
|
+
achievements: Achievement[];
|
|
133
150
|
}
|
|
134
151
|
export interface RoleFilter extends Filter {
|
|
135
152
|
roleId?: string;
|
package/src/mq.ts
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
interface StringMap {
|
|
2
2
|
[key: string]: string;
|
|
3
3
|
}
|
|
4
|
+
export interface NumberMap {
|
|
5
|
+
[key: number]: number;
|
|
6
|
+
}
|
|
7
|
+
export type Handle<T> = (data: T, header?: StringMap) => Promise<number>;
|
|
8
|
+
export type Consume<T> = (handle: (data: T, header?: StringMap) => Promise<number>) => void;
|
|
9
|
+
export type Read<T> = Consume<T>;
|
|
10
|
+
export type Subscribe<T> = Consume<T>;
|
|
11
|
+
export type Receive<T> = Consume<T>;
|
|
12
|
+
export type Get<T> = Consume<T>;
|
|
13
|
+
export type Fetch<T> = Consume<T>;
|
|
14
|
+
export type Produce<T, R> = (data: T) => Promise<R>;
|
|
15
|
+
export type Write<T, R> = Produce<T, R>;
|
|
16
|
+
export type Publish<T, R> = Produce<T, R>;
|
|
17
|
+
export type Send<T, R> = Produce<T, R>;
|
|
18
|
+
export type Put<T, R> = Produce<T, R>;
|
|
19
|
+
export type Set<T, R> = Produce<T, R>;
|
|
20
|
+
|
|
21
|
+
export interface RetryConfig {
|
|
22
|
+
name: string;
|
|
23
|
+
limit: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
4
26
|
export interface Message<T, ID, R> {
|
|
5
27
|
id?: ID;
|
|
6
28
|
data?: T;
|
|
@@ -7,3 +7,10 @@ export interface GenericRepository<T, ID> extends ViewRepository<T, ID> {
|
|
|
7
7
|
save?(obj: T, ctx?: any): Promise<number>;
|
|
8
8
|
delete?(id: ID, ctx?: any): Promise<number>;
|
|
9
9
|
}
|
|
10
|
+
export interface Repository<T, ID> extends ViewRepository<T, ID> {
|
|
11
|
+
insert(obj: T, ctx?: any): Promise<number>;
|
|
12
|
+
update(obj: T, ctx?: any): Promise<number>;
|
|
13
|
+
patch?(obj: T, ctx?: any): Promise<number>;
|
|
14
|
+
save?(obj: T, ctx?: any): Promise<number>;
|
|
15
|
+
delete?(id: ID, ctx?: any): Promise<number>;
|
|
16
|
+
}
|
|
@@ -2,6 +2,6 @@ import {Filter} from '../model';
|
|
|
2
2
|
import {GenericRepository} from './GenericRepository';
|
|
3
3
|
import {SearchRepository} from './SearchRepository';
|
|
4
4
|
|
|
5
|
-
export interface GenericSearchRepository<T, ID,
|
|
6
|
-
extends GenericRepository<T, ID>, SearchRepository<T,
|
|
5
|
+
export interface GenericSearchRepository<T, ID, F extends Filter>
|
|
6
|
+
extends GenericRepository<T, ID>, SearchRepository<T, F> {
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Filter} from '../model';
|
|
2
2
|
import {SearchResult} from '../model';
|
|
3
3
|
|
|
4
|
-
export interface SearchRepository<T,
|
|
5
|
-
search(s:
|
|
4
|
+
export interface SearchRepository<T, F extends Filter> {
|
|
5
|
+
search(s: F, limit?: number, offset?: number|string, fields?: string[], ctx?: any): Promise<SearchResult<T>>;
|
|
6
6
|
}
|
|
@@ -2,6 +2,6 @@ import {Filter} from '../model';
|
|
|
2
2
|
import {SearchRepository} from './SearchRepository';
|
|
3
3
|
import {ViewRepository} from './ViewRepository';
|
|
4
4
|
|
|
5
|
-
export interface ViewSearchRepository<T, ID,
|
|
6
|
-
extends ViewRepository<T, ID>, SearchRepository<T,
|
|
5
|
+
export interface ViewSearchRepository<T, ID, F extends Filter>
|
|
6
|
+
extends ViewRepository<T, ID>, SearchRepository<T, F> {
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@ import {Filter} from '../model';
|
|
|
2
2
|
import {DiffApprService} from './DiffApprService';
|
|
3
3
|
import {GenericSearchService} from './GenericSearchService';
|
|
4
4
|
|
|
5
|
-
export interface GenericSearchDiffApprService<T, ID, R,
|
|
5
|
+
export interface GenericSearchDiffApprService<T, ID, R, F extends Filter> extends GenericSearchService<T, ID, R, F>, DiffApprService<T, ID> {
|
|
6
6
|
|
|
7
7
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {Filter} from '../model';
|
|
1
|
+
import {Filter, Result} from '../model';
|
|
2
2
|
import {GenericService} from './GenericService';
|
|
3
3
|
import {SearchService} from './SearchService';
|
|
4
4
|
|
|
5
|
-
export interface GenericSearchService<T, ID, R,
|
|
6
|
-
extends GenericService<T, ID, R>, SearchService<T,
|
|
5
|
+
export interface GenericSearchService<T, ID, R, F extends Filter>
|
|
6
|
+
extends GenericService<T, ID, R>, SearchService<T, F> {
|
|
7
|
+
}
|
|
8
|
+
export interface Service<T, ID, F extends Filter> extends GenericSearchService<T, ID, Result<T>, F> {
|
|
9
|
+
|
|
7
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Filter} from '../model';
|
|
2
2
|
import {SearchResult} from '../model';
|
|
3
3
|
|
|
4
|
-
export interface SearchService<T,
|
|
4
|
+
export interface SearchService<T, F extends Filter> {
|
|
5
5
|
keys?(): string[];
|
|
6
|
-
search(s:
|
|
6
|
+
search(s: F, limit?: number, offset?: number|string, fields?: string[], ctx?: any): Promise<SearchResult<T>>;
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@ import {Filter} from '../model';
|
|
|
2
2
|
import {SearchService} from './SearchService';
|
|
3
3
|
import {ViewService} from './ViewService';
|
|
4
4
|
|
|
5
|
-
export interface ViewSearchService<T, ID,
|
|
6
|
-
extends ViewService<T, ID>, SearchService<T,
|
|
5
|
+
export interface ViewSearchService<T, ID, F extends Filter>
|
|
6
|
+
extends ViewService<T, ID>, SearchService<T, F> {
|
|
7
7
|
}
|
package/src/video.ts
CHANGED
|
@@ -64,7 +64,7 @@ export interface ListResult<T> {
|
|
|
64
64
|
nextPageToken?: string;
|
|
65
65
|
}
|
|
66
66
|
export type ChannelSortType = 'title' | 'count' | 'date';
|
|
67
|
-
export interface
|
|
67
|
+
export interface ChannelFilter {
|
|
68
68
|
q?: string;
|
|
69
69
|
sort?: SortType; // date, rating, relevance, title, count (for channels)
|
|
70
70
|
forMine?: boolean;
|
|
@@ -78,7 +78,7 @@ export interface ChannelSM {
|
|
|
78
78
|
topicId?: string;
|
|
79
79
|
}
|
|
80
80
|
export type PlaylistSortType = 'title' | 'count' | 'date';
|
|
81
|
-
export interface
|
|
81
|
+
export interface PlaylistFilter {
|
|
82
82
|
q?: string;
|
|
83
83
|
sort?: SortType; // date, rating, relevance, title, count (for channels), viewCount (for live broadcast)
|
|
84
84
|
forMine?: boolean;
|
|
@@ -102,7 +102,7 @@ export type LicenseType = 'creativeCommon' | 'youtube' | 'any' | '';
|
|
|
102
102
|
export type SyndicatedType = 'true' | 'any' | '';
|
|
103
103
|
export type VideoType = 'movie' | 'episode' | 'any' | '';
|
|
104
104
|
export type SortType = 'rating' | 'date' | 'count' | 'relevance' | 'title' | 'viewCount' | '';
|
|
105
|
-
export interface
|
|
105
|
+
export interface ItemFilter {
|
|
106
106
|
q?: string;
|
|
107
107
|
type?: ItemType; // video, channel, playlist
|
|
108
108
|
duration?: Duration; // any, long (more than 20 minutes), medium (from 4 minutes to 20 minutes), short (less than 4 minutes)
|
|
@@ -127,7 +127,7 @@ export interface ItemSM {
|
|
|
127
127
|
syndicated?: SyndicatedType; // any, true
|
|
128
128
|
videoType?: SyndicatedType; // any, episode, movie
|
|
129
129
|
}
|
|
130
|
-
export interface
|
|
130
|
+
export interface VideoItem extends Title, Thumbnail, ChannelInfo {
|
|
131
131
|
kind?: string; // video, channel, playlist
|
|
132
132
|
id?: string;
|
|
133
133
|
liveBroadcastContent?: string; // upcoming, live, none
|
|
@@ -384,11 +384,11 @@ export interface VideoService {
|
|
|
384
384
|
getPopularVideos(regionCode?: string, videoCategoryId?: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<Video>>;
|
|
385
385
|
getVideos(ids: string[], fields?: string[]): Promise<Video[]>;
|
|
386
386
|
getVideo(id: string, fields?: string[]): Promise<Video>;
|
|
387
|
-
search(sm:
|
|
388
|
-
getRelatedVideos?(videoId: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<
|
|
389
|
-
searchVideos?(sm:
|
|
390
|
-
searchPlaylists?(sm:
|
|
391
|
-
searchChannels?(sm:
|
|
387
|
+
search(sm: ItemFilter, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<VideoItem>>;
|
|
388
|
+
getRelatedVideos?(videoId: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<VideoItem>>;
|
|
389
|
+
searchVideos?(sm: ItemFilter, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<VideoItem>>;
|
|
390
|
+
searchPlaylists?(sm: PlaylistFilter, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<Playlist>>;
|
|
391
|
+
searchChannels?(sm: ChannelFilter, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<Channel>>;
|
|
392
392
|
/**
|
|
393
393
|
* @param videoId
|
|
394
394
|
* @param order relevance, time (default)
|