onecore 0.5.12 → 0.5.14

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/lib/index.js CHANGED
@@ -113,47 +113,3 @@ exports.GenericUseCase = GenericUseCase;
113
113
  exports.CRUDUseCase = GenericUseCase;
114
114
  exports.GenericManager = GenericUseCase;
115
115
  exports.CRUDManager = GenericUseCase;
116
- var SavedService = (function () {
117
- function SavedService(savedRepository, max) {
118
- this.savedRepository = savedRepository;
119
- this.max = max;
120
- this.isSaved = this.isSaved.bind(this);
121
- this.save = this.save.bind(this);
122
- this.remove = this.remove.bind(this);
123
- }
124
- SavedService.prototype.isSaved = function (userId, id) {
125
- return this.savedRepository.isSaved(userId, id);
126
- };
127
- SavedService.prototype.save = function (userId, id) {
128
- var _this = this;
129
- return this.savedRepository.count(userId).then(function (count) {
130
- if (count >= _this.max) {
131
- return -1;
132
- }
133
- else {
134
- return _this.savedRepository.save(userId, id);
135
- }
136
- });
137
- };
138
- SavedService.prototype.remove = function (userId, id) {
139
- return this.savedRepository.remove(userId, id);
140
- };
141
- return SavedService;
142
- }());
143
- exports.SavedService = SavedService;
144
- exports.SavedUseCase = SavedService;
145
- var FollowService = (function () {
146
- function FollowService(followRepository) {
147
- this.followRepository = followRepository;
148
- this.follow = this.follow.bind(this);
149
- this.unfollow = this.unfollow.bind(this);
150
- }
151
- FollowService.prototype.follow = function (id, target) {
152
- return this.followRepository.follow(id, target);
153
- };
154
- FollowService.prototype.unfollow = function (id, target) {
155
- return this.followRepository.unfollow(id, target);
156
- };
157
- return FollowService;
158
- }());
159
- exports.FollowService = FollowService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onecore",
3
- "version": "0.5.12",
3
+ "version": "0.5.14",
4
4
  "description": "onecore",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -221,52 +221,3 @@ export class GenericUseCase<T, ID> extends Writer<T> implements GenericService<T
221
221
  export const CRUDUseCase = GenericUseCase
222
222
  export const GenericManager = GenericUseCase
223
223
  export const CRUDManager = GenericUseCase
224
-
225
- export interface SavedRepository<UID, ID> {
226
- isSaved(userId: UID, id: ID): Promise<boolean>
227
- save(userId: UID, id: ID): Promise<number>
228
- remove(userId: UID, id: ID): Promise<number>
229
- count(userId: UID): Promise<number>
230
- }
231
-
232
- // tslint:disable-next-line:max-classes-per-file
233
- export class SavedService<UID, ID> {
234
- constructor(protected savedRepository: SavedRepository<UID, ID>, protected max: number) {
235
- this.isSaved = this.isSaved.bind(this);
236
- this.save = this.save.bind(this);
237
- this.remove = this.remove.bind(this);
238
- }
239
- isSaved(userId: UID, id: ID): Promise<boolean> {
240
- return this.savedRepository.isSaved(userId, id)
241
- }
242
- save(userId: UID, id: ID): Promise<number> {
243
- return this.savedRepository.count(userId).then((count) => {
244
- if (count >= this.max) {
245
- return -1
246
- } else {
247
- return this.savedRepository.save(userId, id)
248
- }
249
- })
250
- }
251
- remove(userId: UID, id: ID): Promise<number> {
252
- return this.savedRepository.remove(userId, id)
253
- }
254
- }
255
- export const SavedUseCase = SavedService
256
-
257
- export interface FollowRepository<ID> {
258
- follow(id: ID, target: ID): Promise<number>
259
- unfollow(id: ID, target: ID): Promise<number>
260
- }
261
- export class FollowService<ID> {
262
- constructor(protected followRepository: FollowRepository<ID>) {
263
- this.follow = this.follow.bind(this)
264
- this.unfollow = this.unfollow.bind(this)
265
- }
266
- follow(id: ID, target: ID): Promise<number> {
267
- return this.followRepository.follow(id, target)
268
- }
269
- unfollow(id: ID, target: ID): Promise<number> {
270
- return this.followRepository.unfollow(id, target)
271
- }
272
- }