@labdigital/commercetools-mock 1.5.0 → 1.6.1
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/README.md +5 -4
- package/dist/index.cjs +117 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -7
- package/dist/index.d.ts +30 -7
- package/dist/index.js +117 -17
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/constants.ts +2 -2
- package/src/ctMock.ts +176 -176
- package/src/exceptions.ts +10 -10
- package/src/helpers.ts +26 -26
- package/src/index.test.ts +173 -173
- package/src/index.ts +3 -3
- package/src/lib/expandParser.ts +19 -19
- package/src/lib/haversine.test.ts +13 -13
- package/src/lib/haversine.ts +14 -14
- package/src/lib/masking.ts +15 -15
- package/src/lib/parser.ts +2 -2
- package/src/lib/predicateParser.test.ts +204 -204
- package/src/lib/predicateParser.ts +398 -398
- package/src/lib/projectionSearchFilter.test.ts +168 -168
- package/src/lib/projectionSearchFilter.ts +272 -269
- package/src/lib/proxy.ts +8 -8
- package/src/oauth/errors.ts +4 -4
- package/src/oauth/helpers.ts +6 -6
- package/src/oauth/server.ts +103 -101
- package/src/oauth/store.ts +27 -27
- package/src/priceSelector.test.ts +68 -68
- package/src/priceSelector.ts +70 -70
- package/src/product-projection-search.ts +296 -296
- package/src/projectAPI.test.ts +3 -3
- package/src/projectAPI.ts +46 -46
- package/src/repositories/abstract.ts +190 -190
- package/src/repositories/associate-role.ts +10 -7
- package/src/repositories/attribute-group.ts +63 -8
- package/src/repositories/business-unit.ts +10 -7
- package/src/repositories/cart-discount.ts +134 -134
- package/src/repositories/cart.ts +517 -514
- package/src/repositories/category.ts +170 -167
- package/src/repositories/channel.ts +114 -111
- package/src/repositories/custom-object.ts +66 -63
- package/src/repositories/customer-group.ts +72 -69
- package/src/repositories/customer.ts +90 -90
- package/src/repositories/discount-code.ts +171 -168
- package/src/repositories/errors.ts +15 -15
- package/src/repositories/extension.ts +79 -76
- package/src/repositories/helpers.ts +180 -180
- package/src/repositories/index.ts +39 -39
- package/src/repositories/inventory-entry.ts +98 -95
- package/src/repositories/my-order.ts +11 -11
- package/src/repositories/order-edit.ts +29 -29
- package/src/repositories/order.test.ts +191 -191
- package/src/repositories/order.ts +393 -393
- package/src/repositories/payment.ts +155 -155
- package/src/repositories/product-discount.ts +149 -149
- package/src/repositories/product-projection.ts +135 -50
- package/src/repositories/product-selection.ts +31 -31
- package/src/repositories/product-type.ts +156 -156
- package/src/repositories/product.ts +600 -597
- package/src/repositories/project.ts +136 -135
- package/src/repositories/quote-request.ts +19 -19
- package/src/repositories/quote.ts +19 -19
- package/src/repositories/review.ts +24 -24
- package/src/repositories/shipping-method.ts +217 -217
- package/src/repositories/shopping-list.ts +49 -49
- package/src/repositories/staged-quote.ts +20 -20
- package/src/repositories/standalone-price.ts +72 -61
- package/src/repositories/state.ts +84 -84
- package/src/repositories/store.ts +114 -114
- package/src/repositories/subscription.ts +40 -40
- package/src/repositories/tax-category.ts +98 -98
- package/src/repositories/type.ts +157 -157
- package/src/repositories/zone.ts +71 -71
- package/src/server.ts +2 -2
- package/src/services/abstract.ts +173 -173
- package/src/services/attribute-group.ts +16 -0
- package/src/services/cart-discount.ts +8 -8
- package/src/services/cart.test.ts +409 -409
- package/src/services/cart.ts +50 -50
- package/src/services/category.test.ts +25 -25
- package/src/services/category.ts +8 -8
- package/src/services/channel.ts +8 -8
- package/src/services/custom-object.test.ts +184 -184
- package/src/services/custom-object.ts +48 -48
- package/src/services/customer-group.ts +8 -8
- package/src/services/customer.test.ts +151 -151
- package/src/services/customer.ts +27 -27
- package/src/services/discount-code.ts +8 -8
- package/src/services/extension.ts +8 -8
- package/src/services/index.ts +52 -44
- package/src/services/inventory-entry.test.ts +162 -162
- package/src/services/inventory-entry.ts +8 -8
- package/src/services/my-cart.test.ts +78 -78
- package/src/services/my-cart.ts +28 -28
- package/src/services/my-customer.test.ts +44 -44
- package/src/services/my-customer.ts +53 -53
- package/src/services/my-order.ts +20 -20
- package/src/services/my-payment.test.ts +65 -65
- package/src/services/my-payment.ts +8 -8
- package/src/services/order.test.ts +527 -527
- package/src/services/order.ts +31 -31
- package/src/services/payment.test.ts +65 -65
- package/src/services/payment.ts +8 -8
- package/src/services/product-discount.ts +8 -8
- package/src/services/product-projection.test.ts +502 -428
- package/src/services/product-projection.ts +32 -18
- package/src/services/product-type.test.ts +56 -56
- package/src/services/product-type.ts +8 -8
- package/src/services/product.test.ts +510 -510
- package/src/services/product.ts +8 -8
- package/src/services/project.ts +34 -34
- package/src/services/shipping-method.test.ts +81 -81
- package/src/services/shipping-method.ts +12 -12
- package/src/services/shopping-list.ts +8 -8
- package/src/services/standalone-price.test.ts +256 -256
- package/src/services/standalone-price.ts +8 -8
- package/src/services/state.test.ts +42 -42
- package/src/services/state.ts +8 -8
- package/src/services/store.test.ts +57 -57
- package/src/services/store.ts +8 -8
- package/src/services/subscription.ts +8 -8
- package/src/services/tax-category.test.ts +61 -61
- package/src/services/tax-category.ts +8 -8
- package/src/services/type.ts +8 -8
- package/src/services/zone.ts +8 -8
- package/src/storage/abstract.ts +58 -58
- package/src/storage/in-memory.ts +419 -419
- package/src/types.ts +82 -82
|
@@ -1,178 +1,181 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
Category,
|
|
3
|
+
CategoryChangeAssetNameAction,
|
|
4
|
+
CategoryChangeSlugAction,
|
|
5
|
+
CategoryDraft,
|
|
6
|
+
CategorySetAssetDescriptionAction,
|
|
7
|
+
CategorySetAssetSourcesAction,
|
|
8
|
+
CategorySetCustomFieldAction,
|
|
9
|
+
CategorySetCustomTypeAction,
|
|
10
|
+
CategorySetDescriptionAction,
|
|
11
|
+
CategorySetKeyAction,
|
|
12
|
+
CategorySetMetaDescriptionAction,
|
|
13
|
+
CategorySetMetaKeywordsAction,
|
|
14
|
+
CategorySetMetaTitleAction,
|
|
15
15
|
} from '@commercetools/platform-sdk'
|
|
16
16
|
import { v4 as uuidv4 } from 'uuid'
|
|
17
17
|
import { getBaseResourceProperties } from '../helpers.js'
|
|
18
18
|
import type { Writable } from '../types.js'
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
AbstractResourceRepository,
|
|
21
|
+
type RepositoryContext,
|
|
22
|
+
} from './abstract.js'
|
|
20
23
|
import { createCustomFields } from './helpers.js'
|
|
21
24
|
|
|
22
25
|
export class CategoryRepository extends AbstractResourceRepository<'category'> {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
getTypeId() {
|
|
27
|
+
return 'category' as const
|
|
28
|
+
}
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
30
|
+
create(context: RepositoryContext, draft: CategoryDraft): Category {
|
|
31
|
+
const resource: Category = {
|
|
32
|
+
...getBaseResourceProperties(),
|
|
33
|
+
key: draft.key,
|
|
34
|
+
name: draft.name,
|
|
35
|
+
slug: draft.slug,
|
|
36
|
+
orderHint: draft.orderHint || '',
|
|
37
|
+
externalId: draft.externalId || '',
|
|
38
|
+
parent: draft.parent
|
|
39
|
+
? { typeId: 'category', id: draft.parent.id! }
|
|
40
|
+
: undefined,
|
|
41
|
+
ancestors: [], // TODO
|
|
42
|
+
assets:
|
|
43
|
+
draft.assets?.map((d) => ({
|
|
44
|
+
id: uuidv4(),
|
|
45
|
+
name: d.name,
|
|
46
|
+
description: d.description,
|
|
47
|
+
sources: d.sources,
|
|
48
|
+
tags: d.tags,
|
|
49
|
+
key: d.key,
|
|
50
|
+
custom: createCustomFields(
|
|
51
|
+
draft.custom,
|
|
52
|
+
context.projectKey,
|
|
53
|
+
this._storage
|
|
54
|
+
),
|
|
55
|
+
})) || [],
|
|
56
|
+
custom: createCustomFields(
|
|
57
|
+
draft.custom,
|
|
58
|
+
context.projectKey,
|
|
59
|
+
this._storage
|
|
60
|
+
),
|
|
61
|
+
}
|
|
62
|
+
this.saveNew(context, resource)
|
|
63
|
+
return resource
|
|
64
|
+
}
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
66
|
+
actions = {
|
|
67
|
+
changeAssetName: (
|
|
68
|
+
context: RepositoryContext,
|
|
69
|
+
resource: Writable<Category>,
|
|
70
|
+
{ assetId, assetKey, name }: CategoryChangeAssetNameAction
|
|
71
|
+
) => {
|
|
72
|
+
resource.assets?.forEach((asset) => {
|
|
73
|
+
if (assetId && assetId === asset.id) {
|
|
74
|
+
asset.name = name
|
|
75
|
+
}
|
|
76
|
+
if (assetKey && assetKey === asset.key) {
|
|
77
|
+
asset.name = name
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
},
|
|
81
|
+
changeSlug: (
|
|
82
|
+
context: RepositoryContext,
|
|
83
|
+
resource: Writable<Category>,
|
|
84
|
+
{ slug }: CategoryChangeSlugAction
|
|
85
|
+
) => {
|
|
86
|
+
resource.slug = slug
|
|
87
|
+
},
|
|
88
|
+
setKey: (
|
|
89
|
+
context: RepositoryContext,
|
|
90
|
+
resource: Writable<Category>,
|
|
91
|
+
{ key }: CategorySetKeyAction
|
|
92
|
+
) => {
|
|
93
|
+
resource.key = key
|
|
94
|
+
},
|
|
95
|
+
setAssetDescription: (
|
|
96
|
+
context: RepositoryContext,
|
|
97
|
+
resource: Writable<Category>,
|
|
98
|
+
{ assetId, assetKey, description }: CategorySetAssetDescriptionAction
|
|
99
|
+
) => {
|
|
100
|
+
resource.assets?.forEach((asset) => {
|
|
101
|
+
if (assetId && assetId === asset.id) {
|
|
102
|
+
asset.description = description
|
|
103
|
+
}
|
|
104
|
+
if (assetKey && assetKey === asset.key) {
|
|
105
|
+
asset.description = description
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
},
|
|
109
|
+
setAssetSources: (
|
|
110
|
+
context: RepositoryContext,
|
|
111
|
+
resource: Writable<Category>,
|
|
112
|
+
{ assetId, assetKey, sources }: CategorySetAssetSourcesAction
|
|
113
|
+
) => {
|
|
114
|
+
resource.assets?.forEach((asset) => {
|
|
115
|
+
if (assetId && assetId === asset.id) {
|
|
116
|
+
asset.sources = sources
|
|
117
|
+
}
|
|
118
|
+
if (assetKey && assetKey === asset.key) {
|
|
119
|
+
asset.sources = sources
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
},
|
|
123
|
+
setDescription: (
|
|
124
|
+
context: RepositoryContext,
|
|
125
|
+
resource: Writable<Category>,
|
|
126
|
+
{ description }: CategorySetDescriptionAction
|
|
127
|
+
) => {
|
|
128
|
+
resource.description = description
|
|
129
|
+
},
|
|
130
|
+
setMetaDescription: (
|
|
131
|
+
context: RepositoryContext,
|
|
132
|
+
resource: Writable<Category>,
|
|
133
|
+
{ metaDescription }: CategorySetMetaDescriptionAction
|
|
134
|
+
) => {
|
|
135
|
+
resource.metaDescription = metaDescription
|
|
136
|
+
},
|
|
137
|
+
setMetaKeywords: (
|
|
138
|
+
context: RepositoryContext,
|
|
139
|
+
resource: Writable<Category>,
|
|
140
|
+
{ metaKeywords }: CategorySetMetaKeywordsAction
|
|
141
|
+
) => {
|
|
142
|
+
resource.metaKeywords = metaKeywords
|
|
143
|
+
},
|
|
144
|
+
setMetaTitle: (
|
|
145
|
+
context: RepositoryContext,
|
|
146
|
+
resource: Writable<Category>,
|
|
147
|
+
{ metaTitle }: CategorySetMetaTitleAction
|
|
148
|
+
) => {
|
|
149
|
+
resource.metaTitle = metaTitle
|
|
150
|
+
},
|
|
151
|
+
setCustomType: (
|
|
152
|
+
context: RepositoryContext,
|
|
153
|
+
resource: Writable<Category>,
|
|
154
|
+
{ type, fields }: CategorySetCustomTypeAction
|
|
155
|
+
) => {
|
|
156
|
+
if (type) {
|
|
157
|
+
resource.custom = createCustomFields(
|
|
158
|
+
{ type, fields },
|
|
159
|
+
context.projectKey,
|
|
160
|
+
this._storage
|
|
161
|
+
)
|
|
162
|
+
} else {
|
|
163
|
+
resource.custom = undefined
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
setCustomField: (
|
|
167
|
+
context: RepositoryContext,
|
|
168
|
+
resource: Writable<Category>,
|
|
169
|
+
{ name, value }: CategorySetCustomFieldAction
|
|
170
|
+
) => {
|
|
171
|
+
if (!resource.custom) {
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
if (value === null) {
|
|
175
|
+
delete resource.custom.fields[name]
|
|
176
|
+
} else {
|
|
177
|
+
resource.custom.fields[name] = value
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
}
|
|
178
181
|
}
|
|
@@ -1,126 +1,129 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
Channel,
|
|
3
|
+
ChannelChangeDescriptionAction,
|
|
4
|
+
ChannelChangeKeyAction,
|
|
5
|
+
ChannelChangeNameAction,
|
|
6
|
+
ChannelDraft,
|
|
7
|
+
ChannelSetAddressAction,
|
|
8
|
+
ChannelSetCustomFieldAction,
|
|
9
|
+
ChannelSetCustomTypeAction,
|
|
10
|
+
ChannelSetGeoLocationAction,
|
|
11
|
+
ChannelUpdateAction,
|
|
12
12
|
} from '@commercetools/platform-sdk'
|
|
13
13
|
import { getBaseResourceProperties } from '../helpers.js'
|
|
14
14
|
import type { Writable } from '../types.js'
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
AbstractResourceRepository,
|
|
17
|
+
type RepositoryContext,
|
|
18
|
+
} from './abstract.js'
|
|
16
19
|
import { createAddress, createCustomFields } from './helpers.js'
|
|
17
20
|
|
|
18
21
|
export class ChannelRepository extends AbstractResourceRepository<'channel'> {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
getTypeId() {
|
|
23
|
+
return 'channel' as const
|
|
24
|
+
}
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
create(context: RepositoryContext, draft: ChannelDraft): Channel {
|
|
27
|
+
const resource: Channel = {
|
|
28
|
+
...getBaseResourceProperties(),
|
|
29
|
+
key: draft.key,
|
|
30
|
+
name: draft.name,
|
|
31
|
+
description: draft.description,
|
|
32
|
+
roles: draft.roles || [],
|
|
33
|
+
geoLocation: draft.geoLocation,
|
|
34
|
+
address: createAddress(draft.address, context.projectKey, this._storage),
|
|
35
|
+
custom: createCustomFields(
|
|
36
|
+
draft.custom,
|
|
37
|
+
context.projectKey,
|
|
38
|
+
this._storage
|
|
39
|
+
),
|
|
40
|
+
}
|
|
41
|
+
this.saveNew(context, resource)
|
|
42
|
+
return resource
|
|
43
|
+
}
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
actions: Partial<
|
|
46
|
+
Record<
|
|
47
|
+
ChannelUpdateAction['action'],
|
|
48
|
+
(
|
|
49
|
+
context: RepositoryContext,
|
|
50
|
+
resource: Writable<Channel>,
|
|
51
|
+
action: any
|
|
52
|
+
) => void
|
|
53
|
+
>
|
|
54
|
+
> = {
|
|
55
|
+
changeKey: (
|
|
56
|
+
context: RepositoryContext,
|
|
57
|
+
resource: Writable<Channel>,
|
|
58
|
+
{ key }: ChannelChangeKeyAction
|
|
59
|
+
) => {
|
|
60
|
+
resource.key = key
|
|
61
|
+
},
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
changeName: (
|
|
64
|
+
context: RepositoryContext,
|
|
65
|
+
resource: Writable<Channel>,
|
|
66
|
+
{ name }: ChannelChangeNameAction
|
|
67
|
+
) => {
|
|
68
|
+
resource.name = name
|
|
69
|
+
},
|
|
67
70
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
changeDescription: (
|
|
72
|
+
context: RepositoryContext,
|
|
73
|
+
resource: Writable<Channel>,
|
|
74
|
+
{ description }: ChannelChangeDescriptionAction
|
|
75
|
+
) => {
|
|
76
|
+
resource.description = description
|
|
77
|
+
},
|
|
75
78
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
setAddress: (
|
|
80
|
+
context: RepositoryContext,
|
|
81
|
+
resource: Writable<Channel>,
|
|
82
|
+
{ address }: ChannelSetAddressAction
|
|
83
|
+
) => {
|
|
84
|
+
resource.address = createAddress(
|
|
85
|
+
address,
|
|
86
|
+
context.projectKey,
|
|
87
|
+
this._storage
|
|
88
|
+
)
|
|
89
|
+
},
|
|
87
90
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
setGeoLocation: (
|
|
92
|
+
context: RepositoryContext,
|
|
93
|
+
resource: Writable<Channel>,
|
|
94
|
+
{ geoLocation }: ChannelSetGeoLocationAction
|
|
95
|
+
) => {
|
|
96
|
+
resource.geoLocation = geoLocation
|
|
97
|
+
},
|
|
95
98
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
99
|
+
setCustomType: (
|
|
100
|
+
context: RepositoryContext,
|
|
101
|
+
resource: Writable<Channel>,
|
|
102
|
+
{ type, fields }: ChannelSetCustomTypeAction
|
|
103
|
+
) => {
|
|
104
|
+
if (type) {
|
|
105
|
+
resource.custom = createCustomFields(
|
|
106
|
+
{ type, fields },
|
|
107
|
+
context.projectKey,
|
|
108
|
+
this._storage
|
|
109
|
+
)
|
|
110
|
+
} else {
|
|
111
|
+
resource.custom = undefined
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
setCustomField: (
|
|
115
|
+
context: RepositoryContext,
|
|
116
|
+
resource: Writable<Channel>,
|
|
117
|
+
{ name, value }: ChannelSetCustomFieldAction
|
|
118
|
+
) => {
|
|
119
|
+
if (!resource.custom) {
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
if (value === null) {
|
|
123
|
+
delete resource.custom.fields[name]
|
|
124
|
+
} else {
|
|
125
|
+
resource.custom.fields[name] = value
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
}
|
|
126
129
|
}
|