@mbc-cqrs-serverless/master 1.0.26 → 1.1.0-beta.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.
- package/README.md +2 -2
- package/dist/enums/setting.enum.d.ts +1 -1
- package/dist/enums/setting.enum.js +1 -1
- package/dist/services/master-data.service.js +1 -1
- package/dist/services/master-data.service.spec.js +1 -1
- package/dist/services/master-setting.service.spec.js +35 -35
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -118,7 +118,7 @@ Settings are resolved in order of specificity (most specific wins):
|
|
|
118
118
|
↓ if not found
|
|
119
119
|
3. Tenant Setting (SETTING#code)
|
|
120
120
|
↓ if not found
|
|
121
|
-
4. Common Setting (pk: SETTING#
|
|
121
|
+
4. Common Setting (pk: SETTING#common)
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
### Example: Theme Setting
|
|
@@ -256,7 +256,7 @@ sk: DATA#[settingCode]#[code]
|
|
|
256
256
|
### Master Setting Key Pattern
|
|
257
257
|
|
|
258
258
|
```
|
|
259
|
-
pk: SETTING#[tenantCode] or SETTING#
|
|
259
|
+
pk: SETTING#[tenantCode] or SETTING#common
|
|
260
260
|
sk: SETTING#[code] (tenant/common)
|
|
261
261
|
SETTING#TENANT_GROUP#[groupId]#[code] (group)
|
|
262
262
|
SETTING#TENANT_USER#[userId]#[code] (user)
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SettingTypeEnum = void 0;
|
|
4
4
|
var SettingTypeEnum;
|
|
5
5
|
(function (SettingTypeEnum) {
|
|
6
|
-
SettingTypeEnum["TENANT_COMMON"] = "
|
|
6
|
+
SettingTypeEnum["TENANT_COMMON"] = "common";
|
|
7
7
|
SettingTypeEnum["TENANT"] = "TENANT";
|
|
8
8
|
SettingTypeEnum["TENANT_GROUP"] = "GROUP";
|
|
9
9
|
SettingTypeEnum["TENANT_USER"] = "USER";
|
|
@@ -103,7 +103,7 @@ let MasterDataService = MasterDataService_1 = class MasterDataService {
|
|
|
103
103
|
pk = (0, helpers_1.generateMasterPk)(tenantCode);
|
|
104
104
|
}
|
|
105
105
|
else {
|
|
106
|
-
pk = (0, helpers_1.generateMasterPk)('
|
|
106
|
+
pk = (0, helpers_1.generateMasterPk)('common');
|
|
107
107
|
}
|
|
108
108
|
const query = { sk: undefined };
|
|
109
109
|
query.sk = {
|
|
@@ -178,7 +178,7 @@ describe('MasterDataService', () => {
|
|
|
178
178
|
};
|
|
179
179
|
dataService.listItemsByPk.mockResolvedValue(mockResponse);
|
|
180
180
|
await service.list(searchDto);
|
|
181
|
-
expect(dataService.listItemsByPk).toHaveBeenCalledWith('MASTER#
|
|
181
|
+
expect(dataService.listItemsByPk).toHaveBeenCalledWith('MASTER#common', expect.any(Object));
|
|
182
182
|
});
|
|
183
183
|
});
|
|
184
184
|
describe('get', () => {
|
|
@@ -120,12 +120,12 @@ describe('SettingService', () => {
|
|
|
120
120
|
});
|
|
121
121
|
it('should return common-level setting if found', async () => {
|
|
122
122
|
jest.spyOn(service, 'getSetting').mockResolvedValueOnce({
|
|
123
|
-
id: 'SETTING#
|
|
123
|
+
id: 'SETTING#common#CommonListSetting',
|
|
124
124
|
settingValue: {},
|
|
125
125
|
});
|
|
126
126
|
const response = await service.getSetting({ code: 'CommonListSetting' }, optionsMock);
|
|
127
127
|
expect(response).toEqual(new entities_1.MasterSettingEntity({
|
|
128
|
-
id: 'SETTING#
|
|
128
|
+
id: 'SETTING#common#CommonListSetting',
|
|
129
129
|
settingValue: {},
|
|
130
130
|
}));
|
|
131
131
|
});
|
|
@@ -140,13 +140,13 @@ describe('SettingService', () => {
|
|
|
140
140
|
const pk = `${constants_1.SETTING_TENANT_PREFIX}${core_1.KEY_SEPARATOR}${enums_1.SettingTypeEnum.TENANT_COMMON}`;
|
|
141
141
|
const sk = settingCode;
|
|
142
142
|
const mockResponse = {
|
|
143
|
-
pk: 'SETTING#
|
|
143
|
+
pk: 'SETTING#common',
|
|
144
144
|
sk: 'UserListSetting',
|
|
145
|
-
id: 'SETTING#
|
|
145
|
+
id: 'SETTING#common#UserListSetting',
|
|
146
146
|
attributes: {},
|
|
147
147
|
code: 'UserListSetting',
|
|
148
148
|
version: 1,
|
|
149
|
-
tenantCode: '
|
|
149
|
+
tenantCode: 'common',
|
|
150
150
|
name: 'UserListSetting',
|
|
151
151
|
type: 'MASTER',
|
|
152
152
|
};
|
|
@@ -162,13 +162,13 @@ describe('SettingService', () => {
|
|
|
162
162
|
attributes: settingValue,
|
|
163
163
|
};
|
|
164
164
|
jest.spyOn(commandService, 'publishAsync').mockResolvedValue({
|
|
165
|
-
pk: 'SETTING#
|
|
165
|
+
pk: 'SETTING#common',
|
|
166
166
|
sk: 'UserListSetting',
|
|
167
|
-
id: 'SETTING#
|
|
167
|
+
id: 'SETTING#common#UserListSetting',
|
|
168
168
|
attributes: {},
|
|
169
169
|
code: 'UserListSetting',
|
|
170
170
|
version: 1,
|
|
171
|
-
tenantCode: '
|
|
171
|
+
tenantCode: 'common',
|
|
172
172
|
name: 'UserListSetting',
|
|
173
173
|
type: 'MASTER',
|
|
174
174
|
});
|
|
@@ -177,13 +177,13 @@ describe('SettingService', () => {
|
|
|
177
177
|
});
|
|
178
178
|
it('should create a new common setting', async () => {
|
|
179
179
|
const mockResponse = {
|
|
180
|
-
pk: 'SETTING#
|
|
180
|
+
pk: 'SETTING#common',
|
|
181
181
|
sk: 'UserListSetting',
|
|
182
|
-
id: 'SETTING#
|
|
182
|
+
id: 'SETTING#common#UserListSetting',
|
|
183
183
|
attributes: {},
|
|
184
184
|
code: 'UserListSetting',
|
|
185
185
|
version: 1,
|
|
186
|
-
tenantCode: '
|
|
186
|
+
tenantCode: 'common',
|
|
187
187
|
name: 'UserListSetting',
|
|
188
188
|
type: 'MASTER',
|
|
189
189
|
};
|
|
@@ -193,13 +193,13 @@ describe('SettingService', () => {
|
|
|
193
193
|
settingValue: {},
|
|
194
194
|
};
|
|
195
195
|
jest.spyOn(commandService, 'publishAsync').mockResolvedValue({
|
|
196
|
-
pk: 'SETTING#
|
|
196
|
+
pk: 'SETTING#common',
|
|
197
197
|
sk: 'UserListSetting',
|
|
198
|
-
id: 'SETTING#
|
|
198
|
+
id: 'SETTING#common#UserListSetting',
|
|
199
199
|
attributes: {},
|
|
200
200
|
code: 'UserListSetting',
|
|
201
201
|
version: 1,
|
|
202
|
-
tenantCode: '
|
|
202
|
+
tenantCode: 'common',
|
|
203
203
|
name: 'UserListSetting',
|
|
204
204
|
type: 'MASTER',
|
|
205
205
|
});
|
|
@@ -208,13 +208,13 @@ describe('SettingService', () => {
|
|
|
208
208
|
});
|
|
209
209
|
it('should create a new common setting with the same code after delete', async () => {
|
|
210
210
|
const mockResponse = {
|
|
211
|
-
pk: 'SETTING#
|
|
211
|
+
pk: 'SETTING#common',
|
|
212
212
|
sk: 'UserListSetting',
|
|
213
|
-
id: 'SETTING#
|
|
213
|
+
id: 'SETTING#common#UserListSetting',
|
|
214
214
|
attributes: {},
|
|
215
215
|
code: 'UserListSetting',
|
|
216
216
|
version: 3,
|
|
217
|
-
tenantCode: '
|
|
217
|
+
tenantCode: 'common',
|
|
218
218
|
name: 'UserListSetting',
|
|
219
219
|
type: 'MASTER',
|
|
220
220
|
};
|
|
@@ -224,25 +224,25 @@ describe('SettingService', () => {
|
|
|
224
224
|
settingValue: {},
|
|
225
225
|
};
|
|
226
226
|
jest.spyOn(dataService, 'getItem').mockResolvedValue({
|
|
227
|
-
pk: 'SETTING#
|
|
227
|
+
pk: 'SETTING#common',
|
|
228
228
|
sk: 'UserListSetting',
|
|
229
|
-
id: 'SETTING#
|
|
229
|
+
id: 'SETTING#common#UserListSetting',
|
|
230
230
|
attributes: {},
|
|
231
231
|
code: 'UserListSetting',
|
|
232
232
|
version: 2,
|
|
233
|
-
tenantCode: '
|
|
233
|
+
tenantCode: 'common',
|
|
234
234
|
name: 'UserListSetting',
|
|
235
235
|
type: 'MASTER',
|
|
236
236
|
isDeleted: true,
|
|
237
237
|
});
|
|
238
238
|
jest.spyOn(commandService, 'publishAsync').mockResolvedValue({
|
|
239
|
-
pk: 'SETTING#
|
|
239
|
+
pk: 'SETTING#common',
|
|
240
240
|
sk: 'UserListSetting',
|
|
241
|
-
id: 'SETTING#
|
|
241
|
+
id: 'SETTING#common#UserListSetting',
|
|
242
242
|
attributes: {},
|
|
243
243
|
code: 'UserListSetting',
|
|
244
244
|
version: 3,
|
|
245
|
-
tenantCode: '
|
|
245
|
+
tenantCode: 'common',
|
|
246
246
|
name: 'UserListSetting',
|
|
247
247
|
type: 'MASTER',
|
|
248
248
|
});
|
|
@@ -844,13 +844,13 @@ describe('SettingService', () => {
|
|
|
844
844
|
const specialCode = 'SETTING_特殊文字@#$%';
|
|
845
845
|
const mockCommonSetting = {
|
|
846
846
|
id: 'test-id',
|
|
847
|
-
pk: 'SETTING#
|
|
847
|
+
pk: 'SETTING#common',
|
|
848
848
|
sk: `SETTING#${specialCode}`,
|
|
849
849
|
code: specialCode,
|
|
850
850
|
name: 'Special Setting',
|
|
851
851
|
version: 1,
|
|
852
852
|
type: 'MASTER',
|
|
853
|
-
tenantCode: '
|
|
853
|
+
tenantCode: 'common',
|
|
854
854
|
isDeleted: false,
|
|
855
855
|
attributes: { special: true },
|
|
856
856
|
createdAt: new Date(),
|
|
@@ -945,13 +945,13 @@ describe('SettingService', () => {
|
|
|
945
945
|
};
|
|
946
946
|
const existingDeletedSetting = {
|
|
947
947
|
id: 'existing-id',
|
|
948
|
-
pk: 'SETTING#
|
|
948
|
+
pk: 'SETTING#common',
|
|
949
949
|
sk: 'SETTING#RECREATED_SETTING',
|
|
950
950
|
code: 'RECREATED_SETTING',
|
|
951
951
|
name: 'RECREATED_SETTING',
|
|
952
952
|
version: 3,
|
|
953
953
|
type: 'MASTER',
|
|
954
|
-
tenantCode: '
|
|
954
|
+
tenantCode: 'common',
|
|
955
955
|
isDeleted: true,
|
|
956
956
|
attributes: { original: true, version: 1 },
|
|
957
957
|
createdAt: new Date('2023-01-01'),
|
|
@@ -960,11 +960,11 @@ describe('SettingService', () => {
|
|
|
960
960
|
dataService.getItem.mockResolvedValue(existingDeletedSetting);
|
|
961
961
|
const mockResponse = {
|
|
962
962
|
id: 'existing-id',
|
|
963
|
-
pk: 'SETTING#
|
|
963
|
+
pk: 'SETTING#common',
|
|
964
964
|
sk: 'SETTING#RECREATED_SETTING',
|
|
965
965
|
version: 3,
|
|
966
966
|
type: 'MASTER',
|
|
967
|
-
tenantCode: '
|
|
967
|
+
tenantCode: 'common',
|
|
968
968
|
name: 'RECREATED_SETTING',
|
|
969
969
|
code: 'RECREATED_SETTING',
|
|
970
970
|
isDeleted: false,
|
|
@@ -992,13 +992,13 @@ describe('SettingService', () => {
|
|
|
992
992
|
};
|
|
993
993
|
const existingDeletedSetting = {
|
|
994
994
|
id: 'existing-id',
|
|
995
|
-
pk: 'SETTING#
|
|
995
|
+
pk: 'SETTING#common',
|
|
996
996
|
sk: 'SETTING#CYCLED_SETTING',
|
|
997
997
|
code: 'CYCLED_SETTING',
|
|
998
998
|
name: 'CYCLED_SETTING',
|
|
999
999
|
version: 7,
|
|
1000
1000
|
type: 'MASTER',
|
|
1001
|
-
tenantCode: '
|
|
1001
|
+
tenantCode: 'common',
|
|
1002
1002
|
isDeleted: true,
|
|
1003
1003
|
attributes: { cycle: 3, previous: true },
|
|
1004
1004
|
createdAt: new Date('2023-01-01'),
|
|
@@ -1007,11 +1007,11 @@ describe('SettingService', () => {
|
|
|
1007
1007
|
dataService.getItem.mockResolvedValue(existingDeletedSetting);
|
|
1008
1008
|
const mockResponse = {
|
|
1009
1009
|
id: 'existing-id',
|
|
1010
|
-
pk: 'SETTING#
|
|
1010
|
+
pk: 'SETTING#common',
|
|
1011
1011
|
sk: 'SETTING#CYCLED_SETTING',
|
|
1012
1012
|
version: 7,
|
|
1013
1013
|
type: 'MASTER',
|
|
1014
|
-
tenantCode: '
|
|
1014
|
+
tenantCode: 'common',
|
|
1015
1015
|
name: 'CYCLED_SETTING',
|
|
1016
1016
|
code: 'CYCLED_SETTING',
|
|
1017
1017
|
isDeleted: false,
|
|
@@ -1284,13 +1284,13 @@ describe('SettingService', () => {
|
|
|
1284
1284
|
const code = 'CONCURRENT_SETTING';
|
|
1285
1285
|
const mockCommonSetting = {
|
|
1286
1286
|
id: 'test-id',
|
|
1287
|
-
pk: 'SETTING#
|
|
1287
|
+
pk: 'SETTING#common',
|
|
1288
1288
|
sk: 'SETTING#CONCURRENT_SETTING',
|
|
1289
1289
|
code: 'CONCURRENT_SETTING',
|
|
1290
1290
|
name: 'Concurrent Setting',
|
|
1291
1291
|
version: 1,
|
|
1292
1292
|
type: 'MASTER',
|
|
1293
|
-
tenantCode: '
|
|
1293
|
+
tenantCode: 'common',
|
|
1294
1294
|
isDeleted: false,
|
|
1295
1295
|
attributes: { concurrent: true },
|
|
1296
1296
|
createdAt: new Date(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbc-cqrs-serverless/master",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-beta.0",
|
|
4
4
|
"description": " Master data management such as setting, sequence, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mbc",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@mbc-cqrs-serverless/core": "1.0.
|
|
47
|
-
"@mbc-cqrs-serverless/sequence": "1.0.
|
|
48
|
-
"@mbc-cqrs-serverless/task": "1.0.
|
|
46
|
+
"@mbc-cqrs-serverless/core": "1.1.0-beta.0",
|
|
47
|
+
"@mbc-cqrs-serverless/sequence": "1.1.0-beta.0",
|
|
48
|
+
"@mbc-cqrs-serverless/task": "1.1.0-beta.0",
|
|
49
49
|
"ulid": "^2.3.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b16d8982c02933fd41a455d3e41f9750bbcf668c"
|
|
52
52
|
}
|