onecore 0.0.27 → 0.0.30

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.27",
3
+ "version": "0.0.30",
4
4
  "description": "onecore",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -1,35 +1,13 @@
1
- export {Locale} from './formatter';
2
-
3
1
  export * from './db';
4
2
 
5
- export {Mapper} from './formatter';
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 {CacheService} from './cache';
15
- export {SyncCacheService} from './cache';
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';
@@ -55,7 +33,6 @@ export * from './mail/model/MailContent';
55
33
  export * from './mail/model/PersonalizationData';
56
34
  export * from './mail/model/MailSettings';
57
35
  export * from './mail/model/ASMOptions';
58
- export * from './mail/service/MailService';
59
36
  export * from './mail/config';
60
37
 
61
38
  export * from './location';
@@ -102,6 +79,7 @@ export class ViewManager<T, ID> implements ViewService<T, ID> {
102
79
  return (this.r.exist ? this.r.exist(id, ctx) : Promise.resolve(false));
103
80
  }
104
81
  }
82
+ // tslint:disable-next-line:max-classes-per-file
105
83
  export class GenericManager<T, ID> extends ViewManager<T, ID> implements GenericService<T, ID, number> {
106
84
  constructor(protected repository: GenericRepository<T, ID>) {
107
85
  super(repository);
@@ -127,6 +105,7 @@ export class GenericManager<T, ID> extends ViewManager<T, ID> implements Generic
127
105
  return (this.repository.delete ? this.repository.delete(id, ctx) : Promise.resolve(-1));
128
106
  }
129
107
  }
108
+ // tslint:disable-next-line:max-classes-per-file
130
109
  export class Manager<T, ID, F extends Filter> extends GenericManager<T, ID> implements GenericSearchService<T, ID, number, F> {
131
110
  constructor(public find: Search<T, F>, repo: GenericRepository<T, ID>) {
132
111
  super(repo);
package/src/location.ts CHANGED
@@ -141,3 +141,12 @@ export interface TourFilter extends Filter {
141
141
  endTime?: Date|DateRange;
142
142
  locations?: string[];
143
143
  }
144
+ export interface Rate {
145
+ id: string;
146
+ locationId: string;
147
+ rateTime: Date;
148
+ userId: string;
149
+ rate: number;
150
+ review: string;
151
+ version?: number;
152
+ }
@@ -1,6 +1,28 @@
1
+ import {EmailData} from './model/EmailData';
1
2
  import {MailData} from './model/MailData';
2
3
 
3
- export interface SendGridConfig {
4
- from: MailData;
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;
@@ -125,12 +129,24 @@ export interface DiffModel<T, ID> {
125
129
  value: T;
126
130
  }
127
131
 
132
+ export interface Achievement {
133
+ subject: string;
134
+ description: string;
135
+ }
136
+ export interface Skill {
137
+ skill: string;
138
+ hirable: boolean;
139
+ }
128
140
  export interface UserFilter extends Filter {
129
141
  userId?: string;
130
142
  username?: string;
131
143
  email?: string;
132
144
  displayName?: string;
145
+ dateOfBirth?: DateRange;
133
146
  status?: string[]|string;
147
+ interests?: string[];
148
+ skills?: Skill[];
149
+ achievements?: Achievement[];
134
150
  }
135
151
  export interface RoleFilter extends Filter {
136
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;
@@ -3,7 +3,12 @@ import {ViewRepository} from './ViewRepository';
3
3
  export interface GenericRepository<T, ID> extends ViewRepository<T, ID> {
4
4
  insert(obj: T, ctx?: any): Promise<number>;
5
5
  update(obj: T, ctx?: any): Promise<number>;
6
- patch?(obj: T, ctx?: any): Promise<number>;
7
- save?(obj: T, ctx?: any): Promise<number>;
8
- delete?(id: ID, ctx?: any): Promise<number>;
6
+ patch(obj: T, ctx?: any): Promise<number>;
7
+ delete(id: ID, ctx?: any): Promise<number>;
8
+ }
9
+ export interface Repository<T, ID> extends ViewRepository<T, ID> {
10
+ insert(obj: T, ctx?: any): Promise<number>;
11
+ update(obj: T, ctx?: any): Promise<number>;
12
+ patch(obj: T, ctx?: any): Promise<number>;
13
+ delete(id: ID, ctx?: any): Promise<number>;
9
14
  }
@@ -3,7 +3,5 @@ import {Attributes} from '../metadata';
3
3
  export interface ViewRepository<T, ID> {
4
4
  metadata?(): Attributes|undefined;
5
5
  keys?(): string[];
6
- all?(ctx?: any): Promise<T[]>;
7
6
  load(id: ID, ctx?: any): Promise<T|null>;
8
- exist?(id: ID, ctx?: any): Promise<boolean>;
9
7
  }
@@ -3,7 +3,6 @@ import {ViewService} from './ViewService';
3
3
  export interface GenericService<T, ID, R> extends ViewService<T, ID> {
4
4
  insert(obj: T, ctx?: any): Promise<R>;
5
5
  update(obj: T, ctx?: any): Promise<R>;
6
- patch?(obj: T, ctx?: any): Promise<R>;
7
- save?(obj: T, ctx?: any): Promise<R>;
8
- delete?(id: ID, ctx?: any): Promise<number>;
6
+ patch(obj: T, ctx?: any): Promise<R>;
7
+ delete(id: ID, ctx?: any): Promise<number>;
9
8
  }
@@ -3,7 +3,5 @@ import {Attributes} from '../metadata';
3
3
  export interface ViewService<T, ID> {
4
4
  metadata?(): Attributes|undefined;
5
5
  keys?(): string[];
6
- all?(ctx?: any): Promise<T[]>;
7
6
  load(id: ID, ctx?: any): Promise<T|null>;
8
- exist?(id: ID, ctx?: any): Promise<boolean>;
9
7
  }
package/src/video.ts CHANGED
@@ -58,13 +58,13 @@ export interface StringMap {
58
58
  [key: string]: string;
59
59
  }
60
60
  export interface ListResult<T> {
61
- list?: T[];
61
+ list: T[];
62
62
  total?: number;
63
63
  limit?: number;
64
64
  nextPageToken?: string;
65
65
  }
66
66
  export type ChannelSortType = 'title' | 'count' | 'date';
67
- export interface ChannelSM {
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 PlaylistSM {
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;
@@ -90,19 +90,19 @@ export interface PlaylistSM {
90
90
  relevanceLanguage?: string;
91
91
  safeSearch?: string; // moderate, none, strict
92
92
  }
93
- export type ChannelType = 'show' | 'any' | '';
94
- export type EventType = 'completed' | 'live' | 'upcoming' | '';
95
- export type ItemType = 'video' | 'channel' | 'playlist' | 'any' | '';
96
- export type Duration = 'long' | 'medium' | 'short' | 'any' | '';
97
- export type Caption = 'closedCaption' | 'none' | 'any' | '';
98
- export type Definition = 'high' | 'standard' | 'any' | '';
99
- export type Dimension = '2d' | '3d' | 'any' | '';
100
- export type EmbeddableType = 'true' | 'any' | '';
101
- export type LicenseType = 'creativeCommon' | 'youtube' | 'any' | '';
102
- export type SyndicatedType = 'true' | 'any' | '';
103
- export type VideoType = 'movie' | 'episode' | 'any' | '';
104
- export type SortType = 'rating' | 'date' | 'count' | 'relevance' | 'title' | 'viewCount' | '';
105
- export interface ItemSM {
93
+ export type ChannelType = 'show' | 'any';
94
+ export type EventType = 'completed' | 'live' | 'upcoming';
95
+ export type ItemType = 'video' | 'channel' | 'playlist' | 'any';
96
+ export type Duration = 'long' | 'medium' | 'short' | 'any';
97
+ export type Caption = 'closedCaption' | 'none' | 'any';
98
+ export type Definition = 'high' | 'standard' | 'any';
99
+ export type Dimension = '2d' | '3d' | 'any';
100
+ export type EmbeddableType = 'true' | 'any';
101
+ export type LicenseType = 'creativeCommon' | 'youtube' | 'any';
102
+ export type SyndicatedType = 'true' | 'any';
103
+ export type VideoType = 'movie' | 'episode' | 'any';
104
+ export type SortType = 'rating' | 'date' | 'count' | 'relevance' | 'title' | 'viewCount';
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,15 +127,17 @@ export interface ItemSM {
127
127
  syndicated?: SyndicatedType; // any, true
128
128
  videoType?: SyndicatedType; // any, episode, movie
129
129
  }
130
- export interface Item extends Title, Thumbnail, ChannelInfo {
130
+ export interface VideoItem extends Title, Thumbnail, ChannelInfo {
131
131
  kind?: string; // video, channel, playlist
132
- id?: string;
132
+ id: string;
133
133
  liveBroadcastContent?: string; // upcoming, live, none
134
134
  publishTime: Date;
135
+ duration?: number;
136
+ definition?: number; // 0: 144, 1: 240, 2: 360, 3: 480, 4: 720, 5: 1080, 6: 1440, 7: 2160
135
137
  }
136
138
  export interface ItemInfo extends Title, Thumbnail, ChannelInfo, LocalizedTitle {
137
139
  kind?: string;
138
- id?: string;
140
+ id: string;
139
141
  }
140
142
  export interface VideoCategory {
141
143
  id: string;
@@ -192,10 +194,10 @@ export interface Video extends ItemInfo, BigThumbnail, VideoDetail, VideoInfo {
192
194
  export interface VideoDetail {
193
195
  duration: number;
194
196
  dimension: string;
195
- definition: number; // 0: 144, 1: 240, 2: 360, 3: 480, 4: 720, 5: 1080, 6: 1440, 7: 2160
196
- caption: boolean;
197
+ definition?: number; // 0: 144, 1: 240, 2: 360, 3: 480, 4: 720, 5: 1080, 6: 1440, 7: 2160
198
+ caption?: boolean;
197
199
  licensedContent: boolean;
198
- projection: string;
200
+ projection?: string;
199
201
  }
200
202
  export interface Thumbnail {
201
203
  thumbnail?: string;
@@ -221,7 +223,7 @@ export interface Thumbnails {
221
223
  export interface Title {
222
224
  title?: string;
223
225
  description?: string;
224
- publishedAt?: Date;
226
+ publishedAt: Date;
225
227
  }
226
228
  export interface LocalizedTitle {
227
229
  localizedTitle?: string;
@@ -244,7 +246,7 @@ export interface ChannelDetail {
244
246
  export interface RelatedPlaylists {
245
247
  likes?: string;
246
248
  favorites?: string;
247
- uploads?: string;
249
+ uploads: string;
248
250
  }
249
251
  export interface VideoItemDetail {
250
252
  videoId: string;
@@ -270,7 +272,7 @@ export interface BaseSnippet extends Title, ChannelInfo {
270
272
  export interface SearchSnippet extends Title, ChannelInfo {
271
273
  thumbnails: Thumbnails;
272
274
  liveBroadcastContent?: string;
273
- publishTime?: Date;
275
+ publishTime: Date;
274
276
  }
275
277
  export interface SearchId {
276
278
  kind?: string;
@@ -305,90 +307,34 @@ export interface YoutubeListResult<T> extends YoutubeKind {
305
307
  export interface ListItem<ID, T, D> extends YoutubeKind {
306
308
  id: ID;
307
309
  etag?: string;
308
- snippet?: T;
309
- contentDetails?: D;
310
+ snippet: T;
311
+ contentDetails: D;
310
312
  }
311
313
  export interface CategorySnippet {
312
314
  title: string;
313
315
  assignable: boolean;
314
316
  channelId: string;
315
317
  }
316
- export interface ChannelSubscriptions {
317
- id: string;
318
- data: Channel[]|string[];
319
- }
320
- export interface SubscriptionSnippet extends Title {
321
- title: string;
322
- resourceId: SubscriptionResource;
323
- thumbnails: Thumbnails;
324
- }
325
- export interface SubscriptionResource {
326
- kind: string;
327
- channelId: string;
328
- }
329
-
330
- export interface ChannelSync {
331
- id: string;
332
- uploads?: string;
333
- syncTime?: Date;
334
- level?: number;
335
- }
336
- export interface PlaylistCollection {
337
- id: string;
338
- videos: string[];
339
- }
340
- export interface CategoryCollection {
341
- id: string;
342
- data: VideoCategory[];
343
- }
344
-
345
- export interface SyncRepository {
346
- getChannelSync(channelId: string): Promise<ChannelSync>;
347
- saveChannel(channel: Channel): Promise<number>;
348
- savePlaylist(playlist: Playlist): Promise<number>;
349
- savePlaylists(playlist: Playlist[]): Promise<number>;
350
- saveChannelSync(channel: ChannelSync): Promise<number>;
351
- saveVideos(videos: Video[]): Promise<number>;
352
- savePlaylistVideos(playlistId: string, videos: string[]): Promise<number>;
353
- getVideoIds(id: string[]): Promise<string[]>;
354
- }
355
- export interface SyncClient {
356
- getChannel(id: string): Promise<Channel>;
357
- getPlaylist(id: string): Promise<Playlist>;
358
- getChannelPlaylists(channelId: string, max?: number, nextPageToken?: string): Promise<ListResult<Playlist>>;
359
- getPlaylistVideos(playlistId: string, max?: number, nextPageToken?: string): Promise<ListResult<PlaylistVideo>>;
360
- getVideos(ids: string[]): Promise<Video[]>;
361
- getSubscriptions(channelId: string): Promise<Channel[]>;
362
- }
363
- export interface SyncService {
364
- syncChannel(channelId: string): Promise<number>;
365
- syncChannels(channelIds: string[]): Promise<number>;
366
- syncPlaylist(playlistId: string, level?: number): Promise<number>;
367
- syncPlaylists(playlistIds: string[], level?: number): Promise<number>;
368
- }
369
318
 
370
- export interface SubscriptionsService {
371
- getSubscriptions(channelId: string, fields?: string[]): Promise<Channel[]>;
372
- }
373
- export type CommentOrder = 'time' | 'relevance' | '';
374
- export type TextFormat = 'html' | 'plainText' | '';
319
+ export type CommentOrder = 'time' | 'relevance';
320
+ export type TextFormat = 'html' | 'plainText';
375
321
  export interface VideoService {
376
322
  getCagetories(regionCode?: string): Promise<VideoCategory[]>;
377
323
  getChannels(ids: string[], fields?: string[]): Promise<Channel[]>;
378
- getChannel(id: string, fields?: string[]): Promise<Channel>;
324
+ getChannel(id: string, fields?: string[]): Promise<Channel|null|undefined>;
379
325
  getChannelPlaylists(channelId: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<Playlist>>;
380
326
  getPlaylists(ids: string[], fields?: string[]): Promise<Playlist[]>;
381
- getPlaylist(id: string, fields?: string[]): Promise<Playlist>;
327
+ getPlaylist(id: string, fields?: string[]): Promise<Playlist|null|undefined>;
382
328
  getChannelVideos(channelId: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<PlaylistVideo>>;
383
329
  getPlaylistVideos(playlistId: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<PlaylistVideo>>;
384
330
  getPopularVideos(regionCode?: string, videoCategoryId?: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<Video>>;
385
331
  getVideos(ids: string[], fields?: string[]): Promise<Video[]>;
386
- getVideo(id: string, fields?: string[]): Promise<Video>;
387
- search(sm: ItemSM, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<Item>>;
388
- getRelatedVideos?(videoId: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<Item>>;
389
- searchVideos?(sm: ItemSM, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<Item>>;
390
- searchPlaylists?(sm: PlaylistSM, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<Playlist>>;
391
- searchChannels?(sm: ChannelSM, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<Channel>>;
332
+ getVideo(id: string, fields?: string[]): Promise<Video|null|undefined>;
333
+ search(sm: ItemFilter, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<VideoItem>>;
334
+ getRelatedVideos?(videoId: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<VideoItem>>;
335
+ searchVideos(sm: ItemFilter, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<VideoItem>>;
336
+ searchPlaylists(sm: PlaylistFilter, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<Playlist>>;
337
+ searchChannels(sm: ChannelFilter, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<Channel>>;
392
338
  /**
393
339
  * @param videoId
394
340
  * @param order relevance, time (default)
@@ -396,13 +342,6 @@ export interface VideoService {
396
342
  */
397
343
  getCommentThreads?(videoId: string, order?: CommentOrder, max?: number, nextPageToken?: string): Promise<ListResult<CommentThead>>;
398
344
  getComments?(id: string, max?: number, nextPageToken?: string): Promise<ListResult<Comment>>;
399
- getPopularVideosByRegion?(regionCode?: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<Video>>;
400
- getPopularVideosByCategory?(videoCategoryId?: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<Video>>;
401
- }
402
- export interface CacheItem<T> {
403
- item: T;
404
- timestamp: Date;
405
- }
406
- export interface Cache<T> {
407
- [key: string]: CacheItem<T>;
345
+ getPopularVideosByRegion(regionCode?: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<Video>>;
346
+ getPopularVideosByCategory(videoCategoryId?: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<Video>>;
408
347
  }
@@ -1,5 +0,0 @@
1
- import {MailData} from '../model/MailData';
2
-
3
- export interface MailService {
4
- sendMail(mail: MailData): Promise<boolean>;
5
- }