onecore 0.0.28 → 0.0.31
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 +5 -13
- package/src/location.ts +9 -0
- package/src/model.ts +3 -3
- package/src/repository/GenericRepository.ts +4 -6
- package/src/repository/ViewRepository.ts +0 -2
- package/src/service/GenericService.ts +2 -3
- package/src/service/ViewService.ts +0 -2
- package/src/video.ts +35 -96
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -40,6 +40,10 @@ export * from './video';
|
|
|
40
40
|
export * from './health';
|
|
41
41
|
export * from './logger';
|
|
42
42
|
|
|
43
|
+
export type DeleteFile = (name: string, directory?: string) => Promise<boolean>;
|
|
44
|
+
export type Delete = (delFile: DeleteFile, url: string) => Promise<boolean>;
|
|
45
|
+
export type UrlBuild = (name: string, directory?: string) => string;
|
|
46
|
+
|
|
43
47
|
export type Log = (msg: string) => void;
|
|
44
48
|
export type LogFunc = Log;
|
|
45
49
|
|
|
@@ -59,9 +63,7 @@ export class ViewManager<T, ID> implements ViewService<T, ID> {
|
|
|
59
63
|
constructor(private r: ViewRepository<T, ID>) {
|
|
60
64
|
this.metadata = this.metadata.bind(this);
|
|
61
65
|
this.keys = this.keys.bind(this);
|
|
62
|
-
this.all = this.all.bind(this);
|
|
63
66
|
this.load = this.load.bind(this);
|
|
64
|
-
this.exist = this.exist.bind(this);
|
|
65
67
|
}
|
|
66
68
|
metadata(): Attributes|undefined {
|
|
67
69
|
return (this.r.metadata ? this.r.metadata() : undefined);
|
|
@@ -69,15 +71,9 @@ export class ViewManager<T, ID> implements ViewService<T, ID> {
|
|
|
69
71
|
keys(): string[] {
|
|
70
72
|
return (this.r.keys ? this.r.keys() : []);
|
|
71
73
|
}
|
|
72
|
-
all(ctx?: any): Promise<T[]> {
|
|
73
|
-
return (this.r.all ? this.r.all() : Promise.resolve([]));
|
|
74
|
-
}
|
|
75
74
|
load(id: ID, ctx?: any): Promise<T | null> {
|
|
76
75
|
return this.r.load(id, ctx);
|
|
77
76
|
}
|
|
78
|
-
exist(id: ID, ctx?: any): Promise<boolean> {
|
|
79
|
-
return (this.r.exist ? this.r.exist(id, ctx) : Promise.resolve(false));
|
|
80
|
-
}
|
|
81
77
|
}
|
|
82
78
|
// tslint:disable-next-line:max-classes-per-file
|
|
83
79
|
export class GenericManager<T, ID> extends ViewManager<T, ID> implements GenericService<T, ID, number> {
|
|
@@ -86,7 +82,6 @@ export class GenericManager<T, ID> extends ViewManager<T, ID> implements Generic
|
|
|
86
82
|
this.insert = this.insert.bind(this);
|
|
87
83
|
this.update = this.update.bind(this);
|
|
88
84
|
this.patch = this.patch.bind(this);
|
|
89
|
-
this.save = this.save.bind(this);
|
|
90
85
|
this.delete = this.delete.bind(this);
|
|
91
86
|
}
|
|
92
87
|
insert(obj: T, ctx?: any): Promise<number> {
|
|
@@ -95,12 +90,9 @@ export class GenericManager<T, ID> extends ViewManager<T, ID> implements Generic
|
|
|
95
90
|
update(obj: T, ctx?: any): Promise<number> {
|
|
96
91
|
return this.repository.update(obj, ctx);
|
|
97
92
|
}
|
|
98
|
-
patch(obj: T
|
|
93
|
+
patch(obj: Partial<T>, ctx?: any): Promise<number> {
|
|
99
94
|
return (this.repository.patch ? this.repository.patch(obj, ctx) : Promise.resolve(-1));
|
|
100
95
|
}
|
|
101
|
-
save(obj: T, ctx?: any): Promise<number> {
|
|
102
|
-
return (this.repository.save ? this.repository.save(obj, ctx) : Promise.resolve(-1));
|
|
103
|
-
}
|
|
104
96
|
delete(id: ID, ctx?: any): Promise<number> {
|
|
105
97
|
return (this.repository.delete ? this.repository.delete(id, ctx) : Promise.resolve(-1));
|
|
106
98
|
}
|
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
|
+
}
|
package/src/model.ts
CHANGED
|
@@ -144,9 +144,9 @@ export interface UserFilter extends Filter {
|
|
|
144
144
|
displayName?: string;
|
|
145
145
|
dateOfBirth?: DateRange;
|
|
146
146
|
status?: string[]|string;
|
|
147
|
-
interests
|
|
148
|
-
skills
|
|
149
|
-
achievements
|
|
147
|
+
interests?: string[];
|
|
148
|
+
skills?: Skill[];
|
|
149
|
+
achievements?: Achievement[];
|
|
150
150
|
}
|
|
151
151
|
export interface RoleFilter extends Filter {
|
|
152
152
|
roleId?: string;
|
|
@@ -3,14 +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
|
|
7
|
-
|
|
8
|
-
delete?(id: ID, ctx?: any): Promise<number>;
|
|
6
|
+
patch(obj: Partial<T>, ctx?: any): Promise<number>;
|
|
7
|
+
delete(id: ID, ctx?: any): Promise<number>;
|
|
9
8
|
}
|
|
10
9
|
export interface Repository<T, ID> extends ViewRepository<T, ID> {
|
|
11
10
|
insert(obj: T, ctx?: any): Promise<number>;
|
|
12
11
|
update(obj: T, ctx?: any): Promise<number>;
|
|
13
|
-
patch
|
|
14
|
-
|
|
15
|
-
delete?(id: ID, ctx?: any): Promise<number>;
|
|
12
|
+
patch(obj: Partial<T>, ctx?: any): Promise<number>;
|
|
13
|
+
delete(id: ID, ctx?: any): Promise<number>;
|
|
16
14
|
}
|
|
@@ -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
|
|
7
|
-
|
|
8
|
-
delete?(id: ID, ctx?: any): Promise<number>;
|
|
6
|
+
patch(obj: Partial<T>, ctx?: any): Promise<R>;
|
|
7
|
+
delete(id: ID, ctx?: any): Promise<number>;
|
|
9
8
|
}
|
package/src/video.ts
CHANGED
|
@@ -58,7 +58,7 @@ export interface StringMap {
|
|
|
58
58
|
[key: string]: string;
|
|
59
59
|
}
|
|
60
60
|
export interface ListResult<T> {
|
|
61
|
-
list
|
|
61
|
+
list: T[];
|
|
62
62
|
total?: number;
|
|
63
63
|
limit?: number;
|
|
64
64
|
nextPageToken?: string;
|
|
@@ -90,18 +90,18 @@ export interface PlaylistFilter {
|
|
|
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'
|
|
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
105
|
export interface ItemFilter {
|
|
106
106
|
q?: string;
|
|
107
107
|
type?: ItemType; // video, channel, playlist
|
|
@@ -129,13 +129,15 @@ export interface ItemFilter {
|
|
|
129
129
|
}
|
|
130
130
|
export interface VideoItem extends Title, Thumbnail, ChannelInfo {
|
|
131
131
|
kind?: string; // video, channel, playlist
|
|
132
|
-
id
|
|
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
|
|
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
|
|
196
|
-
caption
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
309
|
-
contentDetails
|
|
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
|
|
371
|
-
|
|
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>;
|
|
332
|
+
getVideo(id: string, fields?: string[]): Promise<Video|null|undefined>;
|
|
387
333
|
search(sm: ItemFilter, max?: number, nextPageToken?: string | number, fields?: string[]): Promise<ListResult<VideoItem>>;
|
|
388
334
|
getRelatedVideos?(videoId: string, max?: number, nextPageToken?: string, fields?: string[]): Promise<ListResult<VideoItem>>;
|
|
389
|
-
searchVideos
|
|
390
|
-
searchPlaylists
|
|
391
|
-
searchChannels
|
|
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
|
|
400
|
-
getPopularVideosByCategory
|
|
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
|
}
|