onecore 0.0.15 → 0.0.19

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.15",
3
+ "version": "0.0.19",
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/location.ts CHANGED
@@ -1,24 +1,36 @@
1
+ import {DateRange, Filter, NumberRange} from './model';
2
+
1
3
  export interface Article {
2
4
  id?: string;
3
5
  title?: string;
6
+ type?: string;
4
7
  description?: string;
5
8
  content?: string;
6
9
  tags?: string[];
7
10
  status?: string;
8
11
  }
12
+ export interface ArticleFilter extends Filter {
13
+ id?: string;
14
+ title?: string;
15
+ type?: string;
16
+ tags?: string[];
17
+ status?: string[]|string;
18
+ }
19
+
9
20
  export interface Location {
10
21
  id?: string;
11
22
  name?: string;
12
23
  type?: string;
13
24
  description?: string;
14
- longitude?: number;
15
- latitude?: number;
25
+ status?: string;
16
26
  imageURL?: string;
17
- customUrl?: string;
27
+ latitude?: number;
28
+ longitude?: number;
29
+ customURL?: string;
18
30
  info?: LocationInfo;
19
31
  }
20
32
  export interface LocationInfo {
21
- id?: string; // locationID
33
+ id?: string;
22
34
  viewCount: number;
23
35
  rate: number;
24
36
  rate1: number;
@@ -27,29 +39,66 @@ export interface LocationInfo {
27
39
  rate4: number;
28
40
  rate5: number;
29
41
  }
30
- export interface Event {
42
+ export interface LocationFilter extends Filter {
31
43
  id?: string;
32
44
  name?: string;
33
45
  type?: string;
34
- startTime: Date;
35
- endTime: Date;
46
+ status?: string[]|string;
47
+ latitude?: number;
36
48
  longitude?: number;
49
+ radius?: number;
50
+ }
51
+
52
+ export interface Event {
53
+ id?: string;
54
+ name?: string;
55
+ type?: string;
56
+ description?: string;
57
+ status?: string;
58
+ imageURL?: string;
59
+ startTime?: Date;
60
+ endTime?: Date;
37
61
  latitude?: number;
62
+ longitude?: number;
63
+ customURL?: string;
38
64
  locationId?: string;
39
65
  }
66
+ export interface EventFilter extends Filter {
67
+ id?: string;
68
+ name?: string;
69
+ type?: string;
70
+ status?: string[]|string;
71
+ startTime?: Date|DateRange;
72
+ endTime?: Date|DateRange;
73
+ latitude?: number;
74
+ longitude?: number;
75
+ locationId?: string[]|string;
76
+ }
77
+
40
78
  export interface Bookable {
41
79
  id?: string;
42
80
  name?: string;
43
81
  type?: string;
44
82
  description?: string;
45
- capacity?: number;
83
+ status?: string;
46
84
  imageURL?: string;
85
+ customURL?: string;
86
+ capacity?: number;
47
87
  locationId?: string;
48
88
  }
89
+ export interface BookableFilter extends Filter {
90
+ id?: string;
91
+ name?: string;
92
+ type?: string;
93
+ status?: string[]|string;
94
+ capacity?: number|NumberRange;
95
+ locationId?: string[]|string;
96
+ }
97
+
49
98
  export interface Booking {
50
- bookingId: string;
51
- userId: string;
99
+ bookingId?: string;
52
100
  id?: string;
101
+ userId?: string;
53
102
  name?: string;
54
103
  type?: string;
55
104
  description?: string;
@@ -58,3 +107,37 @@ export interface Booking {
58
107
  endTime: Date;
59
108
  status?: string;
60
109
  }
110
+ export interface BookingFilter extends Filter {
111
+ bookingId?: string;
112
+ id?: string;
113
+ userId?: string;
114
+ name?: string;
115
+ type?: string;
116
+ description?: string;
117
+ subject?: string;
118
+ startTime?: Date|DateRange;
119
+ endTime?: Date|DateRange;
120
+ status?: string;
121
+ }
122
+
123
+ export interface Tour {
124
+ id?: string;
125
+ name?: string;
126
+ type?: string;
127
+ description?: string;
128
+ status?: string;
129
+ imageURL?: string;
130
+ startTime?: Date;
131
+ endTime?: Date;
132
+ locations: string[]|Location[];
133
+ customURL?: string;
134
+ }
135
+ export interface TourFilter extends Filter {
136
+ id?: string;
137
+ name?: string;
138
+ type?: string;
139
+ status?: string[]|string;
140
+ startTime?: Date|DateRange;
141
+ endTime?: Date|DateRange;
142
+ locations?: string[];
143
+ }
package/src/metadata.ts CHANGED
@@ -2,6 +2,7 @@ export type DataType = 'ObjectId' | 'date' | 'datetime' | 'time'
2
2
  | 'boolean' | 'number' | 'integer' | 'string' | 'text'
3
3
  | 'object' | 'array' | 'primitives' | 'binary';
4
4
  export type FormatType = 'currency' | 'percentage' | 'email' | 'url' | 'phone' | 'fax' | 'ipv4' | 'ipv6';
5
+ export type MatchType = 'equal' | 'prefix' | 'contain' | 'max' | 'min'; // contain: default for string, min: default for Date, number
5
6
 
6
7
  export interface Model {
7
8
  name?: string;
@@ -18,9 +19,11 @@ export interface Attribute {
18
19
  type?: DataType;
19
20
  format?: FormatType;
20
21
  required?: boolean;
22
+ match?: MatchType;
21
23
  defaultValue?: any;
22
24
  key?: boolean;
23
25
  unique?: boolean;
26
+ q?: boolean;
24
27
  noinsert?: boolean;
25
28
  noupdate?: boolean;
26
29
  nopatch?: boolean;
package/src/model.ts CHANGED
@@ -72,7 +72,7 @@ export interface NumberRange {
72
72
  upper?: number;
73
73
  }
74
74
 
75
- export interface SearchModel {
75
+ export interface Filter {
76
76
  page?: number;
77
77
  limit?: number;
78
78
  firstLimit?: number;
@@ -114,14 +114,14 @@ export interface DiffModel<T, ID> {
114
114
  value: T;
115
115
  }
116
116
 
117
- export interface UserSM extends SearchModel {
117
+ export interface UserFilter extends Filter {
118
118
  userId?: string;
119
119
  username?: string;
120
120
  email?: string;
121
121
  displayName?: string;
122
122
  status?: string[]|string;
123
123
  }
124
- export interface RoleSM extends SearchModel {
124
+ export interface RoleFilter extends Filter {
125
125
  roleId?: string;
126
126
  roleName?: string;
127
127
  status?: string[]|string;
package/src/mq.ts ADDED
@@ -0,0 +1,61 @@
1
+ interface StringMap {
2
+ [key: string]: string;
3
+ }
4
+ export interface Message<T, ID, R> {
5
+ id?: ID;
6
+ data?: T;
7
+ attributes?: StringMap;
8
+ timestamp?: Date;
9
+ raw?: R;
10
+ }
11
+ export interface Producer<T, R, ID> {
12
+ produce(data: T, attributes?: StringMap, id?: ID): Promise<R>;
13
+ }
14
+ export interface Publisher<T, R, ID> {
15
+ publish(data: T, attributes?: StringMap, id?: ID): Promise<R>;
16
+ }
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>;
22
+ }
23
+
24
+ export interface SimpleProducer<T, R, ID> {
25
+ produce(to: string, data: T, attributes?: StringMap, id?: ID): Promise<R>;
26
+ }
27
+ export interface SimplePublisher<T, R, ID> {
28
+ publish(to: string, data: T, attributes?: StringMap, id?: ID): Promise<R>;
29
+ }
30
+ export interface SimpleSender<T, R, ID> {
31
+ send(to: string, data: T, attributes?: StringMap, id?: ID): Promise<R>;
32
+ }
33
+ export interface SimpleWriter<T, R, ID> {
34
+ write(to: string, data: T, attributes?: StringMap, id?: ID): Promise<R>;
35
+ }
36
+
37
+ export interface SimpleConsumer<T> {
38
+ consume(handle: (data: T, attributes?: StringMap) => Promise<number>): void;
39
+ }
40
+ export interface SimpleSubscriber<T, R> {
41
+ subscribe(handle: (data: T, attributes?: StringMap) => Promise<number>): void;
42
+ }
43
+ export interface SimpleReceiver<T> {
44
+ receive(handle: (data: T, attributes?: StringMap) => Promise<number>): void;
45
+ }
46
+ export interface SimpleReader<T> {
47
+ read(handle: (data: T, attributes?: StringMap) => Promise<number>): void;
48
+ }
49
+
50
+ export interface Consumer<T, ID, R> {
51
+ consume(data: Message<T, ID, R>): void;
52
+ }
53
+ export interface Subscriber<T, ID, R> {
54
+ subscribe(handle: (data: Message<T, ID, R>) => Promise<number>): void;
55
+ }
56
+ export interface Receiver<T, ID, R> {
57
+ receive(handle: (data: Message<T, ID, R>) => Promise<number>): void;
58
+ }
59
+ export interface Reader<T, ID, R> {
60
+ read(handle: (data: Message<T, ID, R>) => Promise<number>): void;
61
+ }
@@ -1,7 +1,7 @@
1
- import {SearchModel} from '../model';
1
+ import {Filter} from '../model';
2
2
  import {GenericRepository} from './GenericRepository';
3
3
  import {SearchRepository} from './SearchRepository';
4
4
 
5
- export interface GenericSearchRepository<T, ID, R, S extends SearchModel>
5
+ export interface GenericSearchRepository<T, ID, R, S extends Filter>
6
6
  extends GenericRepository<T, ID, R>, SearchRepository<T, S> {
7
7
  }
@@ -1,6 +1,6 @@
1
- import {SearchModel} from '../model';
1
+ import {Filter} from '../model';
2
2
  import {SearchResult} from '../model';
3
3
 
4
- export interface SearchRepository<T, S extends SearchModel> {
4
+ export interface SearchRepository<T, S extends Filter> {
5
5
  search(s: S, limit?: number, offset?: number|string, fields?: string[], ctx?: any): Promise<SearchResult<T>>;
6
6
  }
@@ -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;
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,7 +1,7 @@
1
- import {SearchModel} from '../model';
1
+ import {Filter} from '../model';
2
2
  import {SearchRepository} from './SearchRepository';
3
3
  import {ViewRepository} from './ViewRepository';
4
4
 
5
- export interface ViewSearchRepository<T, ID, S extends SearchModel>
5
+ export interface ViewSearchRepository<T, ID, S extends Filter>
6
6
  extends ViewRepository<T, ID>, SearchRepository<T, S> {
7
7
  }
@@ -1,7 +1,7 @@
1
- import {SearchModel} from '../model';
1
+ 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, S extends SearchModel> extends GenericSearchService<T, ID, R, S>, DiffApprService<T, ID> {
5
+ export interface GenericSearchDiffApprService<T, ID, R, S extends Filter> extends GenericSearchService<T, ID, R, S>, DiffApprService<T, ID> {
6
6
 
7
7
  }
@@ -1,7 +1,7 @@
1
- import {SearchModel} from '../model';
1
+ import {Filter} from '../model';
2
2
  import {GenericService} from './GenericService';
3
3
  import {SearchService} from './SearchService';
4
4
 
5
- export interface GenericSearchService<T, ID, R, S extends SearchModel>
5
+ export interface GenericSearchService<T, ID, R, S extends Filter>
6
6
  extends GenericService<T, ID, R>, SearchService<T, S> {
7
7
  }
@@ -1,7 +1,7 @@
1
- import {SearchModel} from '../model';
1
+ import {Filter} from '../model';
2
2
  import {SearchResult} from '../model';
3
3
 
4
- export interface SearchService<T, S extends SearchModel> {
4
+ export interface SearchService<T, S extends Filter> {
5
5
  keys?(): string[];
6
6
  search(s: S, limit?: number, offset?: number|string, fields?: string[], ctx?: any): Promise<SearchResult<T>>;
7
7
  }
@@ -1,7 +1,7 @@
1
- import {SearchModel} from '../model';
1
+ import {Filter} from '../model';
2
2
  import {SearchService} from './SearchService';
3
3
  import {ViewService} from './ViewService';
4
4
 
5
- export interface ViewSearchService<T, ID, S extends SearchModel>
5
+ export interface ViewSearchService<T, ID, S extends Filter>
6
6
  extends ViewService<T, ID>, SearchService<T, S> {
7
7
  }
@@ -4,6 +4,6 @@ export interface ViewService<T, ID> {
4
4
  metadata?(): Attributes;
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/src/video.ts CHANGED
@@ -1,13 +1,72 @@
1
+ export interface TopLevelCommentSnippet {
2
+ videoId: string;
3
+ topLevelComment: TopLevelComment;
4
+ canReply: boolean;
5
+ totalReplyCount: number;
6
+ isPublic: boolean;
7
+ }
8
+ export interface TopLevelComment {
9
+ kind: string;
10
+ etag: string;
11
+ id: string;
12
+ snippet: TopLevelCommentSubSnippet;
13
+ }
14
+ export interface TopLevelCommentSubSnippet extends CommentInfo, YoutubeAuthor {
15
+ videoId: string;
16
+ }
17
+
18
+ export interface CommentThead extends Author, CommentInfo {
19
+ videoId: string;
20
+ canReply: boolean;
21
+ totalReplyCount: number;
22
+ isPublic: boolean;
23
+ nextPageToken?: string;
24
+ }
25
+
26
+ export interface Comment extends Author, CommentInfo {
27
+ parentId: string;
28
+ }
29
+ export interface AuthorChannelId {
30
+ value: string;
31
+ }
32
+ export interface AuthorInfo {
33
+ authorDisplayName: string;
34
+ authorChannelUrl: string;
35
+ authorProfileImageUrl: string;
36
+ }
37
+ export interface Author extends AuthorInfo {
38
+ authorChannelId: string;
39
+ }
40
+ export interface YoutubeAuthor extends AuthorInfo {
41
+ authorChannelId: AuthorChannelId;
42
+ }
43
+ export interface CommentInfo {
44
+ id: string;
45
+ textDisplay: string;
46
+ textOriginal: string;
47
+ canRate: boolean;
48
+ viewerRating: string;
49
+ likeCount: number;
50
+ publishedAt: Date;
51
+ updatedAt: Date;
52
+ }
53
+ export interface CommentSnippet extends CommentInfo, YoutubeAuthor {
54
+ parentId: string;
55
+ }
56
+
57
+ export interface StringMap {
58
+ [key: string]: string;
59
+ }
1
60
  export interface ListResult<T> {
2
61
  list?: T[];
3
62
  total?: number;
4
63
  limit?: number;
5
64
  nextPageToken?: string;
6
65
  }
66
+ export type ChannelSortType = 'title' | 'count' | 'date';
7
67
  export interface ChannelSM {
8
- keyword?: string;
9
- order?: string; // date, rating, relevance, title, videoCount (for channels), viewCount (for live broadcast)
10
- nextPageToken?: string;
68
+ q?: string;
69
+ sort?: SortType; // date, rating, relevance, title, count (for channels)
11
70
  forMine?: boolean;
12
71
  channelId?: string;
13
72
  channelType?: string; // any, show
@@ -18,10 +77,10 @@ export interface ChannelSM {
18
77
  safeSearch?: string; // moderate, none, strict
19
78
  topicId?: string;
20
79
  }
80
+ export type PlaylistSortType = 'title' | 'count' | 'date';
21
81
  export interface PlaylistSM {
22
- keyword?: string;
23
- order?: string; // date, rating, relevance, title, videoCount (for channels), viewCount (for live broadcast)
24
- nextPageToken?: string;
82
+ q?: string;
83
+ sort?: SortType; // date, rating, relevance, title, count (for channels), viewCount (for live broadcast)
25
84
  forMine?: boolean;
26
85
  channelId?: string;
27
86
  channelType?: string; // any, show
@@ -31,31 +90,42 @@ export interface PlaylistSM {
31
90
  relevanceLanguage?: string;
32
91
  safeSearch?: string; // moderate, none, strict
33
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' | '';
34
105
  export interface ItemSM {
35
- keyword?: string;
36
- type?: string; // video, channel, playlist
37
- videoDuration?: string; // any, long (more than 20 minutes), medium (from 4 minutes to 20 minutes), short (less than 4 minutes)
38
- order?: string; // date, rating, relevance, title, videoCount (for channels), viewCount (for live broadcast)
39
- nextPageToken?: string;
106
+ q?: string;
107
+ type?: ItemType; // video, channel, playlist
108
+ duration?: Duration; // any, long (more than 20 minutes), medium (from 4 minutes to 20 minutes), short (less than 4 minutes)
109
+ sort?: SortType; // date, rating, relevance, title, videoCount (for channels), viewCount (for live broadcast) => title, date => publishedAt, relevance => rank, count => videoCount
40
110
  relatedToVideoId?: string;
41
111
  forMine?: boolean;
42
112
  channelId?: string;
43
- channelType?: string; // any, show
44
- eventType?: string; // completed, live, upcoming
113
+ channelType?: ChannelType; // any, show
114
+ eventType?: EventType; // completed, live, upcoming
45
115
  publishedAfter?: Date;
46
116
  publishedBefore?: Date;
47
117
  regionCode?: string;
48
118
  relevanceLanguage?: string;
49
119
  safeSearch?: string; // moderate, none, strict
50
120
  topicId?: string;
51
- videoCaption?: string; // any, closedCaption, none
52
- videoCategoryId?: string;
53
- videoDefinition?: string; // any, high, standard
54
- videoDimension?: string; // 2d, 3d, any
55
- videoEmbeddable?: string; // any, true
56
- videoLicense?: string; // any, creativeCommon, youtube
57
- videoSyndicated?: string; // any, true
58
- videoType?: string; // any, episode, movie
121
+ categoryId?: string;
122
+ caption?: Caption; // any, closedCaption, none
123
+ definition?: Definition; // any, high, standard
124
+ dimension?: Dimension; // 2d, 3d, any
125
+ embeddable?: EmbeddableType; // any, true
126
+ license?: LicenseType; // any, creativeCommon, youtube
127
+ syndicated?: SyndicatedType; // any, true
128
+ videoType?: SyndicatedType; // any, episode, movie
59
129
  }
60
130
  export interface Item extends Title, Thumbnail, ChannelInfo {
61
131
  kind?: string; // video, channel, playlist
@@ -79,13 +149,14 @@ export interface Channel extends ItemInfo {
79
149
  likes?: string;
80
150
  favorites?: string;
81
151
  uploads?: string;
82
- timestamp?: Date;
152
+ lastUpload?: Date;
83
153
  count?: number;
84
154
  itemCount?: number;
85
155
  playlistCount?: number;
86
156
  playlistItemCount?: number;
87
157
  playlistVideoCount?: number;
88
158
  playlistVideoItemCount?: number;
159
+ channels?: string[]|Channel[];
89
160
  }
90
161
  export interface Playlist extends ItemInfo, BigThumbnail {
91
162
  count?: number;
@@ -98,6 +169,12 @@ export interface PlaylistItemInfo {
98
169
  videoOwnerChannelTitle?: string;
99
170
  }
100
171
  export interface PlaylistVideo extends ItemInfo, BigThumbnail, PlaylistItemInfo {
172
+ duration?: number;
173
+ dimension?: string;
174
+ definition?: number; // 0: 144, 1: 240, 2: 360, 3: 480, 4: 720, 5: 1080, 6: 1440, 7: 2160
175
+ caption?: boolean;
176
+ licensedContent?: boolean;
177
+ projection?: string;
101
178
  }
102
179
  export interface VideoInfo {
103
180
  tags?: string[];
@@ -109,6 +186,8 @@ export interface VideoInfo {
109
186
  export interface Video extends ItemInfo, BigThumbnail, VideoDetail, VideoInfo {
110
187
  videoOwnerChannelId?: string;
111
188
  videoOwnerChannelTitle?: string;
189
+ blockedRegions?: string[];
190
+ allowedRegions?: string[];
112
191
  }
113
192
  export interface VideoDetail {
114
193
  duration: number;
@@ -171,6 +250,10 @@ export interface VideoItemDetail {
171
250
  videoId: string;
172
251
  videoPublishedAt: Date;
173
252
  }
253
+ export interface RegionRestriction {
254
+ allow?: string[];
255
+ blocked?: string[];
256
+ }
174
257
  export interface YoutubeVideoDetail {
175
258
  duration: string;
176
259
  dimension: string;
@@ -178,6 +261,7 @@ export interface YoutubeVideoDetail {
178
261
  caption: string;
179
262
  licensedContent: boolean;
180
263
  projection: string;
264
+ regionRestriction?: RegionRestriction;
181
265
  }
182
266
  export interface BaseSnippet extends Title, ChannelInfo {
183
267
  thumbnails: Thumbnails;
@@ -229,73 +313,35 @@ export interface CategorySnippet {
229
313
  assignable: boolean;
230
314
  channelId: string;
231
315
  }
232
-
233
- export interface TopLevelCommentSnippet {
234
- videoId: string;
235
- topLevelComment: TopLevelComment;
236
- canReply: boolean;
237
- totalReplyCount: number;
238
- isPublic: boolean;
239
- }
240
- export interface TopLevelComment {
241
- kind: string;
242
- etag: string;
316
+ export interface ChannelSubscriptions {
243
317
  id: string;
244
- snippet: TopLevelCommentSubSnippet;
245
- }
246
- export interface TopLevelCommentSubSnippet extends CommentInfo, YoutubeAuthor {
247
- videoId: string;
248
- }
249
-
250
- export interface CommentThead extends Author, CommentInfo {
251
- videoId: string;
252
- canReply: boolean;
253
- totalReplyCount: number;
254
- isPublic: boolean;
255
- nextPageToken?: string;
256
- }
257
-
258
- export interface Comment extends Author, CommentInfo {
259
- parentId: string;
260
- }
261
- export interface AuthorChannelId {
262
- value: string;
318
+ data: Channel[]|string[];
263
319
  }
264
- export interface AuthorInfo {
265
- authorDisplayName: string;
266
- authorChannelUrl: string;
267
- authorProfileImageUrl: string;
268
- }
269
- export interface Author extends AuthorInfo {
270
- authorChannelId: string;
271
- }
272
- export interface YoutubeAuthor extends AuthorInfo {
273
- authorChannelId: AuthorChannelId;
274
- }
275
- export interface CommentInfo {
276
- id: string;
277
- textDisplay: string;
278
- textOriginal: string;
279
- canRate: boolean;
280
- viewerRating: string;
281
- likeCount: number;
282
- publishedAt: Date;
283
- updatedAt: Date;
320
+ export interface SubscriptionSnippet extends Title {
321
+ title: string;
322
+ resourceId: SubscriptionResource;
323
+ thumbnails: Thumbnails;
284
324
  }
285
- export interface CommentSnippet extends CommentInfo, YoutubeAuthor {
286
- parentId: string;
325
+ export interface SubscriptionResource {
326
+ kind: string;
327
+ channelId: string;
287
328
  }
288
329
 
289
330
  export interface ChannelSync {
290
331
  id: string;
291
332
  uploads?: string;
292
- timestamp?: Date;
333
+ syncTime?: Date;
293
334
  level?: number;
294
335
  }
295
336
  export interface PlaylistCollection {
296
337
  id: string;
297
338
  videos: string[];
298
339
  }
340
+ export interface CategoryCollection {
341
+ id: string;
342
+ data: VideoCategory[];
343
+ }
344
+
299
345
  export interface SyncRepository {
300
346
  getChannelSync(channelId: string): Promise<ChannelSync>;
301
347
  saveChannel(channel: Channel): Promise<number>;
@@ -311,7 +357,8 @@ export interface SyncClient {
311
357
  getPlaylist(id: string): Promise<Playlist>;
312
358
  getChannelPlaylists(channelId: string, max?: number, nextPageToken?: string): Promise<ListResult<Playlist>>;
313
359
  getPlaylistVideos(playlistId: string, max?: number, nextPageToken?: string): Promise<ListResult<PlaylistVideo>>;
314
- getVideos(ids: string[], noSnippet?: boolean): Promise<Video[]>;
360
+ getVideos(ids: string[]): Promise<Video[]>;
361
+ getSubscriptions(channelId: string): Promise<Channel[]>;
315
362
  }
316
363
  export interface SyncService {
317
364
  syncChannel(channelId: string): Promise<number>;
@@ -320,32 +367,37 @@ export interface SyncService {
320
367
  syncPlaylists(playlistIds: string[], level?: number): Promise<number>;
321
368
  }
322
369
 
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' | '';
323
375
  export interface VideoService {
324
376
  getCagetories(regionCode?: string): Promise<VideoCategory[]>;
325
- getChannels(ids: string[]): Promise<Channel[]>;
326
- getChannel(id: string): Promise<Channel>;
327
- getChannelPlaylists(channelId: string, max?: number, nextPageToken?: string): Promise<ListResult<Playlist>>;
328
- getPlaylists(ids: string[]): Promise<Playlist[]>;
329
- getPlaylist(id: string): Promise<Playlist>;
330
- getChannelVideos(channelId: string, max?: number, nextPageToken?: string): Promise<ListResult<PlaylistVideo>>;
331
- getPlaylistVideos(playlistId: string, max?: number, nextPageToken?: string): Promise<ListResult<PlaylistVideo>>;
332
- getPopularVideos(regionCode?: string, videoCategoryId?: string, max?: number, nextPageToken?: string): Promise<ListResult<Video>>;
333
- getPopularVideosByRegion(regionCode?: string, max?: number, nextPageToken?: string): Promise<ListResult<Video>>;
334
- getPopularVideosByCategory(videoCategoryId?: string, max?: number, nextPageToken?: string): Promise<ListResult<Video>>;
335
- getVideos(ids: string[], noSnippet?: boolean): Promise<Video[]>;
336
- getVideo(id: string, noSnippet?: boolean): Promise<Video>;
337
- search(sm: ItemSM, max?: number, nextPageToken?: string|number): Promise<ListResult<Item>>;
338
- getRelatedVideos?(videoId: string, max?: number, nextPageToken?: string): Promise<ListResult<Item>>;
339
- searchVideos?(sm: ItemSM, max?: number, nextPageToken?: string|number): Promise<ListResult<Item>>;
340
- searchPlaylists?(sm: PlaylistSM, max?: number, nextPageToken?: string|number): Promise<ListResult<Playlist>>;
341
- searchChannels?(sm: ChannelSM, max?: number, nextPageToken?: string|number): Promise<ListResult<Channel>>;
377
+ getChannels(ids: string[], fields?: string[]): Promise<Channel[]>;
378
+ getChannel(id: string, fields?: string[]): Promise<Channel>;
379
+ getChannelPlaylists(channelId: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<Playlist>>;
380
+ getPlaylists(ids: string[], fields?: string[]): Promise<Playlist[]>;
381
+ getPlaylist(id: string, fields?: string[]): Promise<Playlist>;
382
+ getChannelVideos(channelId: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<PlaylistVideo>>;
383
+ getPlaylistVideos(playlistId: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<PlaylistVideo>>;
384
+ getPopularVideos(regionCode?: string, videoCategoryId?: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<Video>>;
385
+ 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>>;
342
392
  /**
343
393
  * @param videoId
344
394
  * @param order relevance, time (default)
345
395
  * @param nextPageToken
346
396
  */
347
- getCommentThreads?(videoId: string, order?: string, max?: number, nextPageToken?: string): Promise<ListResult<CommentThead>>;
397
+ getCommentThreads?(videoId: string, order?: CommentOrder, max?: number, nextPageToken?: string): Promise<ListResult<CommentThead>>;
348
398
  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>>;
349
401
  }
350
402
  export interface CacheItem<T> {
351
403
  item: T;
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,