@labdigital/commercetools-mock 0.9.0 → 0.10.0

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.
Files changed (95) hide show
  1. package/README.md +8 -0
  2. package/dist/index.d.ts +18 -17
  3. package/dist/index.global.js +1751 -1664
  4. package/dist/index.global.js.map +1 -1
  5. package/dist/index.js +1773 -1684
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +1966 -1877
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +28 -20
  10. package/src/constants.ts +4 -2
  11. package/src/ctMock.ts +19 -84
  12. package/src/helpers.ts +9 -10
  13. package/src/index.test.ts +1 -1
  14. package/src/lib/haversine.ts +2 -2
  15. package/src/lib/masking.ts +3 -1
  16. package/src/lib/predicateParser.test.ts +16 -0
  17. package/src/lib/predicateParser.ts +94 -86
  18. package/src/lib/projectionSearchFilter.test.ts +28 -36
  19. package/src/lib/projectionSearchFilter.ts +86 -102
  20. package/src/oauth/store.ts +3 -3
  21. package/src/priceSelector.test.ts +18 -35
  22. package/src/priceSelector.ts +6 -9
  23. package/src/product-projection-search.ts +51 -57
  24. package/src/repositories/abstract.ts +85 -41
  25. package/src/repositories/cart-discount.ts +1 -1
  26. package/src/repositories/cart.ts +36 -31
  27. package/src/repositories/category.ts +17 -19
  28. package/src/repositories/channel.ts +1 -1
  29. package/src/repositories/custom-object.ts +35 -22
  30. package/src/repositories/customer-group.ts +1 -1
  31. package/src/repositories/customer.ts +39 -1
  32. package/src/repositories/discount-code.ts +1 -1
  33. package/src/repositories/errors.ts +9 -11
  34. package/src/repositories/extension.ts +13 -11
  35. package/src/repositories/helpers.ts +8 -13
  36. package/src/repositories/index.ts +59 -0
  37. package/src/repositories/inventory-entry.ts +1 -1
  38. package/src/repositories/order.ts +6 -6
  39. package/src/repositories/payment.ts +3 -3
  40. package/src/repositories/product-discount.ts +1 -1
  41. package/src/repositories/product-projection.ts +1 -0
  42. package/src/repositories/product-type.ts +29 -34
  43. package/src/repositories/product.ts +124 -80
  44. package/src/repositories/project.ts +10 -27
  45. package/src/repositories/shipping-method.ts +15 -17
  46. package/src/repositories/shopping-list.ts +2 -2
  47. package/src/repositories/state.ts +9 -9
  48. package/src/repositories/store.ts +2 -2
  49. package/src/repositories/subscription.ts +1 -1
  50. package/src/repositories/tax-category.ts +4 -4
  51. package/src/repositories/type.ts +12 -14
  52. package/src/repositories/zone.ts +5 -6
  53. package/src/server.ts +5 -0
  54. package/src/services/abstract.ts +44 -11
  55. package/src/services/cart-discount.ts +2 -3
  56. package/src/services/cart.test.ts +8 -10
  57. package/src/services/cart.ts +8 -11
  58. package/src/services/category.test.ts +1 -2
  59. package/src/services/category.ts +2 -3
  60. package/src/services/channel.ts +2 -3
  61. package/src/services/custom-object.test.ts +5 -5
  62. package/src/services/custom-object.ts +2 -3
  63. package/src/services/customer-group.ts +2 -3
  64. package/src/services/customer.test.ts +136 -0
  65. package/src/services/customer.ts +2 -3
  66. package/src/services/discount-code.ts +2 -3
  67. package/src/services/extension.ts +2 -3
  68. package/src/services/index.ts +74 -0
  69. package/src/services/inventory-entry.test.ts +8 -12
  70. package/src/services/inventory-entry.ts +2 -3
  71. package/src/services/my-cart.ts +3 -4
  72. package/src/services/my-customer.ts +2 -3
  73. package/src/services/my-order.ts +3 -4
  74. package/src/services/my-payment.ts +2 -3
  75. package/src/services/order.test.ts +4 -6
  76. package/src/services/order.ts +2 -3
  77. package/src/services/payment.ts +2 -3
  78. package/src/services/product-discount.ts +2 -3
  79. package/src/services/product-projection.test.ts +76 -8
  80. package/src/services/product-projection.ts +2 -3
  81. package/src/services/product-type.ts +2 -3
  82. package/src/services/product.test.ts +199 -89
  83. package/src/services/product.ts +2 -3
  84. package/src/services/project.ts +3 -3
  85. package/src/services/shipping-method.ts +2 -3
  86. package/src/services/shopping-list.ts +2 -3
  87. package/src/services/state.ts +2 -3
  88. package/src/services/store.test.ts +11 -2
  89. package/src/services/store.ts +2 -3
  90. package/src/services/subscription.ts +2 -3
  91. package/src/services/tax-category.ts +2 -3
  92. package/src/services/type.ts +2 -3
  93. package/src/services/zone.ts +2 -3
  94. package/src/storage.ts +23 -30
  95. package/src/types.ts +46 -6
@@ -1,88 +1,110 @@
1
- import { Product, ProductDraft } from '@commercetools/platform-sdk'
1
+ import { Product, ProductData, ProductDraft } from '@commercetools/platform-sdk'
2
2
  import supertest from 'supertest'
3
3
  import { CommercetoolsMock } from '../index'
4
4
  import assert from 'assert'
5
5
 
6
6
  const ctMock = new CommercetoolsMock()
7
7
 
8
- describe('Product', () => {
9
- test('Create product', async () => {
10
- const draft: ProductDraft = {
11
- name: {
12
- 'nl-NL': 'test product',
13
- },
14
- productType: {
15
- typeId: 'product-type',
16
- id: 'some-uuid',
8
+ const publishedProductDraft: ProductDraft = {
9
+ name: {
10
+ 'nl-NL': 'test published product',
11
+ },
12
+ productType: {
13
+ typeId: 'product-type',
14
+ id: 'some-uuid',
15
+ },
16
+ masterVariant: {
17
+ sku: '1337',
18
+ attributes: [
19
+ {
20
+ name: 'test',
21
+ value: 'test',
17
22
  },
18
- slug: {
19
- 'nl-NL': 'test-product',
23
+ ],
24
+ },
25
+ variants: [
26
+ {
27
+ sku: '1338',
28
+ attributes: [
29
+ {
30
+ name: 'test2',
31
+ value: 'test2',
32
+ },
33
+ ],
34
+ },
35
+ ],
36
+ slug: {
37
+ 'nl-NL': 'test-published-product',
38
+ },
39
+ publish: true,
40
+ }
41
+
42
+ const unpublishedProductDraft: ProductDraft = {
43
+ name: {
44
+ 'nl-NL': 'test unpublished product',
45
+ },
46
+ productType: {
47
+ typeId: 'product-type',
48
+ id: 'some-uuid',
49
+ },
50
+ masterVariant: {
51
+ sku: '2337',
52
+ attributes: [
53
+ {
54
+ name: 'test',
55
+ value: 'test',
20
56
  },
21
- masterVariant: {},
22
- }
57
+ ],
58
+ },
59
+ variants: [
60
+ {
61
+ sku: '2338',
62
+ attributes: [
63
+ {
64
+ name: 'test2',
65
+ value: 'test2',
66
+ },
67
+ ],
68
+ },
69
+ ],
70
+ slug: {
71
+ 'nl-NL': 'test-unpublished-product',
72
+ },
73
+ publish: false,
74
+ }
23
75
 
76
+ describe('Product', () => {
77
+ test('Create product', async () => {
24
78
  const response = await supertest(ctMock.app)
25
79
  .post('/dummy/products')
26
- .send(draft)
80
+ .send(unpublishedProductDraft)
27
81
 
28
- expect(response.body).toEqual({
29
- createdAt: expect.anything(),
30
- id: expect.anything(),
31
- lastModifiedAt: expect.anything(),
32
- masterData: {
33
- staged: {
34
- name: {
35
- 'nl-NL': 'test product',
36
- },
37
- slug: {
38
- 'nl-NL': 'test-product',
39
- },
40
- categories: [],
41
- masterVariant: {
42
- assets: [],
43
- attributes: [],
44
- id: 1,
45
- images: [],
46
- },
47
- variants: [],
48
- },
49
- hasStagedChanges: true,
50
- published: false,
51
- },
52
- productType: {
53
- typeId: 'product-type',
54
- id: 'some-uuid',
55
- },
56
- version: 1,
57
- })
58
- })
59
- })
60
-
61
- describe('Product update actions', () => {
62
- const ctMock = new CommercetoolsMock()
63
- let product: Product | undefined
64
-
65
- beforeEach(async () => {
66
- const draft: ProductDraft = {
82
+ const productData: ProductData = {
67
83
  name: {
68
- 'nl-NL': 'test product',
84
+ 'nl-NL': 'test unpublished product',
69
85
  },
70
- productType: {
71
- typeId: 'product-type',
72
- id: 'some-uuid',
86
+ slug: {
87
+ 'nl-NL': 'test-unpublished-product',
73
88
  },
89
+ categories: [],
74
90
  masterVariant: {
75
- sku: '1337',
91
+ sku: '2337',
92
+ assets: [],
76
93
  attributes: [
77
94
  {
78
95
  name: 'test',
79
96
  value: 'test',
80
97
  },
81
98
  ],
99
+ id: 1,
100
+ images: [],
82
101
  },
83
102
  variants: [
84
103
  {
85
- sku: '1338',
104
+ sku: '2338',
105
+ assets: [],
106
+ id: 2,
107
+ images: [],
86
108
  attributes: [
87
109
  {
88
110
  name: 'test2',
@@ -91,44 +113,132 @@ describe('Product update actions', () => {
91
113
  ],
92
114
  },
93
115
  ],
94
- slug: {
95
- 'nl-NL': 'test-product',
96
- },
97
- publish: true,
116
+ searchKeywords: {},
98
117
  }
99
- let response = await supertest(ctMock.app)
118
+
119
+ expect(response.body).toEqual({
120
+ createdAt: expect.anything(),
121
+ id: expect.anything(),
122
+ lastModifiedAt: expect.anything(),
123
+ masterData: {
124
+ staged: productData,
125
+ current: productData,
126
+ hasStagedChanges: false,
127
+ published: false,
128
+ },
129
+ productType: {
130
+ typeId: 'product-type',
131
+ id: 'some-uuid',
132
+ },
133
+ version: 1,
134
+ } as Product)
135
+ })
136
+ })
137
+
138
+ describe('Product update actions', () => {
139
+ const ctMock = new CommercetoolsMock()
140
+ let productPublished: Product | undefined
141
+ let productUnpublished: Product | undefined
142
+
143
+ beforeEach(async () => {
144
+ let response
145
+ response = await supertest(ctMock.app)
146
+ .post('/dummy/products')
147
+ .send(publishedProductDraft)
148
+
149
+ expect(response.status).toBe(201)
150
+ productPublished = response.body
151
+
152
+ response = await supertest(ctMock.app)
100
153
  .post('/dummy/products')
101
- .send(draft)
154
+ .send(unpublishedProductDraft)
102
155
 
103
156
  expect(response.status).toBe(201)
104
- product = response.body
157
+ productUnpublished = response.body
105
158
  })
106
159
 
107
- test('setAttribute masterVariant', async () => {
108
- assert(product, 'product not created')
160
+ test('setAttribute masterVariant (staged)', async () => {
161
+ assert(productPublished, 'product not created')
162
+
163
+ {
164
+ const response = await supertest(ctMock.app)
165
+ .post(`/dummy/products/${productPublished.id}`)
166
+ .send({
167
+ version: 1,
168
+ actions: [
169
+ { action: 'setAttribute', sku: '1337', name: 'foo', value: 'bar' },
170
+ ],
171
+ })
172
+
173
+ expect(response.status).toBe(200)
174
+ const product: Product = response.body
175
+ expect(product.version).toBe(2)
176
+ expect(product.masterData.hasStagedChanges).toBeTruthy()
177
+ expect(product.masterData.current.masterVariant.attributes).toHaveLength(
178
+ 1
179
+ )
180
+ expect(product.masterData.staged.masterVariant.attributes).toHaveLength(2)
181
+
182
+ const attr = response.body.masterData.staged.masterVariant.attributes[1]
183
+ expect(attr).toEqual({ name: 'foo', value: 'bar' })
184
+ }
185
+
186
+ // Publish
187
+ {
188
+ const response = await supertest(ctMock.app)
189
+ .post(`/dummy/products/${productPublished.id}`)
190
+ .send({
191
+ version: 2,
192
+ actions: [{ action: 'publish', scope: 'All' }],
193
+ })
194
+
195
+ expect(response.status).toBe(200)
196
+ const product: Product = response.body
197
+ expect(product.version).toBe(3)
198
+ expect(product.masterData.hasStagedChanges).toBeFalsy()
199
+ expect(product.masterData.current.masterVariant.attributes).toHaveLength(
200
+ 2
201
+ )
202
+ }
203
+ })
204
+
205
+ test('setAttribute masterVariant (published)', async () => {
206
+ assert(productPublished, 'product not created')
109
207
 
110
208
  const response = await supertest(ctMock.app)
111
- .post(`/dummy/products/${product.id}`)
209
+ .post(`/dummy/products/${productPublished.id}`)
112
210
  .send({
113
211
  version: 1,
114
212
  actions: [
115
- { action: 'setAttribute', sku: '1337', name: 'foo', value: 'bar' },
213
+ {
214
+ action: 'setAttribute',
215
+ sku: '1337',
216
+ name: 'foo',
217
+ value: 'bar',
218
+ staged: false,
219
+ },
116
220
  ],
117
221
  })
222
+
118
223
  expect(response.status).toBe(200)
119
- expect(response.body.version).toBe(2)
120
- expect(
121
- response.body.masterData.current.masterVariant.attributes
122
- ).toHaveLength(2)
123
- const attr = response.body.masterData.current.masterVariant.attributes[1]
224
+ const product: Product = response.body
225
+
226
+ // TODO: Since we auto publish it actually does two version updates. So the
227
+ // version should be 3
228
+ expect(product.version).toBe(2)
229
+ expect(product.masterData.hasStagedChanges).toBeFalsy()
230
+ expect(product.masterData.current.masterVariant.attributes).toHaveLength(2)
231
+ expect(product.masterData.staged.masterVariant.attributes).toHaveLength(2)
232
+
233
+ const attr = response.body.masterData.staged.masterVariant.attributes[1]
124
234
  expect(attr).toEqual({ name: 'foo', value: 'bar' })
125
235
  })
126
236
 
127
237
  test('setAttribute variant', async () => {
128
- assert(product, 'product not created')
238
+ assert(productPublished, 'product not created')
129
239
 
130
240
  const response = await supertest(ctMock.app)
131
- .post(`/dummy/products/${product.id}`)
241
+ .post(`/dummy/products/${productPublished.id}`)
132
242
  .send({
133
243
  version: 1,
134
244
  actions: [
@@ -137,18 +247,18 @@ describe('Product update actions', () => {
137
247
  })
138
248
  expect(response.status).toBe(200)
139
249
  expect(response.body.version).toBe(2)
140
- expect(
141
- response.body.masterData.current.variants[0].attributes
142
- ).toHaveLength(2)
143
- const attr = response.body.masterData.current.variants[0].attributes[1]
250
+ expect(response.body.masterData.staged.variants[0].attributes).toHaveLength(
251
+ 2
252
+ )
253
+ const attr = response.body.masterData.staged.variants[0].attributes[1]
144
254
  expect(attr).toEqual({ name: 'foo', value: 'bar' })
145
255
  })
146
256
 
147
257
  test('setAttribute variant and publish', async () => {
148
- assert(product, 'product not created')
258
+ assert(productPublished, 'product not created')
149
259
 
150
260
  const response = await supertest(ctMock.app)
151
- .post(`/dummy/products/${product.id}`)
261
+ .post(`/dummy/products/${productPublished.id}`)
152
262
  .send({
153
263
  version: 1,
154
264
  actions: [
@@ -157,7 +267,7 @@ describe('Product update actions', () => {
157
267
  ],
158
268
  })
159
269
  expect(response.status).toBe(200)
160
- expect(response.body.version).toBe(2)
270
+ expect(response.body.version).toBe(3)
161
271
  expect(
162
272
  response.body.masterData.current.variants[0].attributes
163
273
  ).toHaveLength(2)
@@ -166,10 +276,10 @@ describe('Product update actions', () => {
166
276
  })
167
277
 
168
278
  test('setAttribute overwrite', async () => {
169
- assert(product, 'product not created')
279
+ assert(productPublished, 'product not created')
170
280
 
171
281
  const response = await supertest(ctMock.app)
172
- .post(`/dummy/products/${product.id}`)
282
+ .post(`/dummy/products/${productPublished.id}`)
173
283
  .send({
174
284
  version: 1,
175
285
  actions: [
@@ -179,9 +289,9 @@ describe('Product update actions', () => {
179
289
  expect(response.status).toBe(200)
180
290
  expect(response.body.version).toBe(2)
181
291
  expect(
182
- response.body.masterData.current.masterVariant.attributes
292
+ response.body.masterData.staged.masterVariant.attributes
183
293
  ).toHaveLength(1)
184
- const attr = response.body.masterData.current.masterVariant.attributes[0]
294
+ const attr = response.body.masterData.staged.masterVariant.attributes[0]
185
295
  expect(attr).toEqual({ name: 'test', value: 'foo' })
186
296
  })
187
297
  })
@@ -1,14 +1,13 @@
1
1
  import AbstractService from './abstract'
2
2
  import { Router } from 'express'
3
- import { AbstractStorage } from '../storage'
4
3
  import { ProductRepository } from '../repositories/product'
5
4
 
6
5
  export class ProductService extends AbstractService {
7
6
  public repository: ProductRepository
8
7
 
9
- constructor(parent: Router, storage: AbstractStorage) {
8
+ constructor(parent: Router, repository: ProductRepository) {
10
9
  super(parent)
11
- this.repository = new ProductRepository(storage)
10
+ this.repository = repository
12
11
  }
13
12
 
14
13
  getBasePath() {
@@ -1,6 +1,5 @@
1
1
  import { Router } from 'express'
2
2
  import { Request, Response } from 'express'
3
- import { AbstractStorage } from '../storage'
4
3
  import { ProjectRepository } from '../repositories/project'
5
4
  import { Update } from '@commercetools/platform-sdk'
6
5
  import { getRepositoryContext } from '../repositories/helpers'
@@ -8,8 +7,8 @@ import { getRepositoryContext } from '../repositories/helpers'
8
7
  export class ProjectService {
9
8
  public repository: ProjectRepository
10
9
 
11
- constructor(parent: Router, storage: AbstractStorage) {
12
- this.repository = new ProjectRepository(storage)
10
+ constructor(parent: Router, repository: ProjectRepository) {
11
+ this.repository = repository
13
12
  this.registerRoutes(parent)
14
13
  }
15
14
 
@@ -34,6 +33,7 @@ export class ProjectService {
34
33
  this.repository.processUpdateActions(
35
34
  getRepositoryContext(request),
36
35
  project,
36
+ updateRequest.version,
37
37
  updateRequest.actions
38
38
  )
39
39
 
@@ -1,14 +1,13 @@
1
1
  import { ShippingMethodRepository } from '../repositories/shipping-method'
2
2
  import AbstractService from './abstract'
3
- import { AbstractStorage } from '../storage'
4
3
  import { Router } from 'express'
5
4
 
6
5
  export class ShippingMethodService extends AbstractService {
7
6
  public repository: ShippingMethodRepository
8
7
 
9
- constructor(parent: Router, storage: AbstractStorage) {
8
+ constructor(parent: Router, repository: ShippingMethodRepository) {
10
9
  super(parent)
11
- this.repository = new ShippingMethodRepository(storage)
10
+ this.repository = repository
12
11
  this.registerRoutes(parent)
13
12
  }
14
13
 
@@ -1,14 +1,13 @@
1
1
  import { ShoppingListRepository } from './../repositories/shopping-list'
2
2
  import AbstractService from './abstract'
3
3
  import { Router } from 'express'
4
- import { AbstractStorage } from '../storage'
5
4
 
6
5
  export class ShoppingListService extends AbstractService {
7
6
  public repository: ShoppingListRepository
8
7
 
9
- constructor(parent: Router, storage: AbstractStorage) {
8
+ constructor(parent: Router, repository: ShoppingListRepository) {
10
9
  super(parent)
11
- this.repository = new ShoppingListRepository(storage)
10
+ this.repository = repository
12
11
  }
13
12
 
14
13
  getBasePath() {
@@ -1,14 +1,13 @@
1
1
  import { StateRepository } from '../repositories/state'
2
2
  import AbstractService from './abstract'
3
3
  import { Router } from 'express'
4
- import { AbstractStorage } from '../storage'
5
4
 
6
5
  export class StateService extends AbstractService {
7
6
  public repository: StateRepository
8
7
 
9
- constructor(parent: Router, storage: AbstractStorage) {
8
+ constructor(parent: Router, repository: StateRepository) {
10
9
  super(parent)
11
- this.repository = new StateRepository(storage)
10
+ this.repository = repository
12
11
  }
13
12
 
14
13
  getBasePath() {
@@ -23,7 +23,10 @@ describe('Store', () => {
23
23
  createdAt: '',
24
24
  lastModifiedAt: '',
25
25
  key: 'STOREKEY',
26
+ languages: [],
26
27
  distributionChannels: [],
28
+ supplyChannels: [],
29
+ productSelections: [],
27
30
  })
28
31
 
29
32
  const response = await supertest(ctMock.app).get(
@@ -32,12 +35,15 @@ describe('Store', () => {
32
35
 
33
36
  expect(response.status).toBe(200)
34
37
  expect(response.body).toEqual({
38
+ version: 1,
35
39
  createdAt: '',
36
- distributionChannels: [],
37
40
  id: 'fake-store',
38
41
  key: 'STOREKEY',
39
42
  lastModifiedAt: '',
40
- version: 1,
43
+ languages: [],
44
+ distributionChannels: [],
45
+ supplyChannels: [],
46
+ productSelections: [],
41
47
  })
42
48
  })
43
49
 
@@ -48,7 +54,10 @@ describe('Store', () => {
48
54
  createdAt: '',
49
55
  lastModifiedAt: '',
50
56
  key: 'STOREKEY',
57
+ languages: [],
51
58
  distributionChannels: [],
59
+ supplyChannels: [],
60
+ productSelections: [],
52
61
  })
53
62
 
54
63
  const response = await supertest(ctMock.app).get(
@@ -1,15 +1,14 @@
1
1
  import AbstractService from './abstract'
2
2
  import { Router, Request, Response } from 'express'
3
3
  import { StoreRepository } from '../repositories/store'
4
- import { AbstractStorage } from '../storage'
5
4
  import { getRepositoryContext } from '../repositories/helpers'
6
5
 
7
6
  export class StoreService extends AbstractService {
8
7
  public repository: StoreRepository
9
8
 
10
- constructor(parent: Router, storage: AbstractStorage) {
9
+ constructor(parent: Router, repository: StoreRepository) {
11
10
  super(parent)
12
- this.repository = new StoreRepository(storage)
11
+ this.repository = repository
13
12
  }
14
13
 
15
14
  getBasePath() {
@@ -1,14 +1,13 @@
1
1
  import AbstractService from './abstract'
2
2
  import { Router } from 'express'
3
- import { AbstractStorage } from '../storage'
4
3
  import { SubscriptionRepository } from '../repositories/subscription'
5
4
 
6
5
  export class SubscriptionService extends AbstractService {
7
6
  public repository: SubscriptionRepository
8
7
 
9
- constructor(parent: Router, storage: AbstractStorage) {
8
+ constructor(parent: Router, repository: SubscriptionRepository) {
10
9
  super(parent)
11
- this.repository = new SubscriptionRepository(storage)
10
+ this.repository = repository
12
11
  }
13
12
 
14
13
  getBasePath() {
@@ -1,15 +1,14 @@
1
1
  import { TaxCategoryRepository } from '../repositories/tax-category'
2
2
  import AbstractService from './abstract'
3
- import { AbstractStorage } from '../storage'
4
3
  import { Request, Response, Router } from 'express'
5
4
  import { getRepositoryContext } from '../repositories/helpers'
6
5
 
7
6
  export class TaxCategoryService extends AbstractService {
8
7
  public repository: TaxCategoryRepository
9
8
 
10
- constructor(parent: Router, storage: AbstractStorage) {
9
+ constructor(parent: Router, repository: TaxCategoryRepository) {
11
10
  super(parent)
12
- this.repository = new TaxCategoryRepository(storage)
11
+ this.repository = repository
13
12
  }
14
13
 
15
14
  getBasePath() {
@@ -1,14 +1,13 @@
1
1
  import AbstractService from './abstract'
2
2
  import { Router } from 'express'
3
3
  import { TypeRepository } from '../repositories/type'
4
- import { AbstractStorage } from '../storage'
5
4
 
6
5
  export class TypeService extends AbstractService {
7
6
  public repository: TypeRepository
8
7
 
9
- constructor(parent: Router, storage: AbstractStorage) {
8
+ constructor(parent: Router, repository: TypeRepository) {
10
9
  super(parent)
11
- this.repository = new TypeRepository(storage)
10
+ this.repository = repository
12
11
  }
13
12
 
14
13
  getBasePath() {
@@ -1,14 +1,13 @@
1
1
  import { Router } from 'express'
2
2
  import AbstractService from './abstract'
3
- import { AbstractStorage } from '../storage'
4
3
  import { ZoneRepository } from '../repositories/zone'
5
4
 
6
5
  export class ZoneService extends AbstractService {
7
6
  public repository: ZoneRepository
8
7
 
9
- constructor(parent: Router, storage: AbstractStorage) {
8
+ constructor(parent: Router, repository: ZoneRepository) {
10
9
  super(parent)
11
- this.repository = new ZoneRepository(storage)
10
+ this.repository = repository
12
11
  }
13
12
 
14
13
  getBasePath() {