@metamask/profile-sync-controller 0.8.1 → 0.9.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/CHANGELOG.md +20 -1
- package/dist/controllers/user-storage/UserStorageController.cjs +55 -14
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +12 -3
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +12 -3
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +57 -15
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.cjs +38 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.cjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.cts +26 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.cts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.mts +26 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.mts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.mjs +39 -0
- package/dist/controllers/user-storage/__fixtures__/mockAccounts.mjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs +9 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts +5 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts +5 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs +7 -0
- package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.cjs +15 -3
- package/dist/controllers/user-storage/__fixtures__/mockServices.cjs.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts +2 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts +2 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts.map +1 -1
- package/dist/controllers/user-storage/__fixtures__/mockServices.mjs +14 -3
- package/dist/controllers/user-storage/__fixtures__/mockServices.mjs.map +1 -1
- package/dist/controllers/user-storage/services.cjs +58 -2
- package/dist/controllers/user-storage/services.cjs.map +1 -1
- package/dist/controllers/user-storage/services.d.cts +10 -1
- package/dist/controllers/user-storage/services.d.cts.map +1 -1
- package/dist/controllers/user-storage/services.d.mts +10 -1
- package/dist/controllers/user-storage/services.d.mts.map +1 -1
- package/dist/controllers/user-storage/services.mjs +33 -1
- package/dist/controllers/user-storage/services.mjs.map +1 -1
- package/dist/controllers/user-storage/utils.cjs +27 -1
- package/dist/controllers/user-storage/utils.cjs.map +1 -1
- package/dist/controllers/user-storage/utils.d.cts +11 -0
- package/dist/controllers/user-storage/utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/utils.d.mts +11 -0
- package/dist/controllers/user-storage/utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/utils.mjs +25 -0
- package/dist/controllers/user-storage/utils.mjs.map +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.cjs +4 -2
- package/dist/sdk/__fixtures__/mock-userstorage.cjs.map +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.d.cts +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.d.cts.map +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.d.mts +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.d.mts.map +1 -1
- package/dist/sdk/__fixtures__/mock-userstorage.mjs +4 -2
- package/dist/sdk/__fixtures__/mock-userstorage.mjs.map +1 -1
- package/dist/sdk/user-storage.cjs +39 -1
- package/dist/sdk/user-storage.cjs.map +1 -1
- package/dist/sdk/user-storage.d.cts +2 -1
- package/dist/sdk/user-storage.d.cts.map +1 -1
- package/dist/sdk/user-storage.d.mts +2 -1
- package/dist/sdk/user-storage.d.mts.map +1 -1
- package/dist/sdk/user-storage.mjs +39 -1
- package/dist/sdk/user-storage.mjs.map +1 -1
- package/dist/shared/storage-schema.cjs.map +1 -1
- package/dist/shared/storage-schema.d.cts +5 -2
- package/dist/shared/storage-schema.d.cts.map +1 -1
- package/dist/shared/storage-schema.d.mts +5 -2
- package/dist/shared/storage-schema.d.mts.map +1 -1
- package/dist/shared/storage-schema.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { EthAccountType } from "@metamask/keyring-api";
|
|
2
|
+
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
1
3
|
/**
|
|
2
4
|
* Get a random default account name from the list of localized default account names
|
|
3
5
|
* @returns A random default account name
|
|
@@ -8,48 +10,72 @@ export declare const MOCK_INTERNAL_ACCOUNTS: {
|
|
|
8
10
|
ONE: {
|
|
9
11
|
address: string;
|
|
10
12
|
id: string;
|
|
13
|
+
type: EthAccountType;
|
|
11
14
|
metadata: {
|
|
12
15
|
name: string;
|
|
13
16
|
nameLastUpdatedAt: number;
|
|
17
|
+
keyring: {
|
|
18
|
+
type: KeyringTypes;
|
|
19
|
+
};
|
|
14
20
|
};
|
|
15
21
|
}[];
|
|
16
22
|
ONE_DEFAULT_NAME: {
|
|
17
23
|
address: string;
|
|
18
24
|
id: string;
|
|
25
|
+
type: EthAccountType;
|
|
19
26
|
metadata: {
|
|
20
27
|
name: string;
|
|
21
28
|
nameLastUpdatedAt: number;
|
|
29
|
+
keyring: {
|
|
30
|
+
type: KeyringTypes;
|
|
31
|
+
};
|
|
22
32
|
};
|
|
23
33
|
}[];
|
|
24
34
|
ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED: {
|
|
25
35
|
address: string;
|
|
26
36
|
id: string;
|
|
37
|
+
type: EthAccountType;
|
|
27
38
|
metadata: {
|
|
28
39
|
name: string;
|
|
40
|
+
keyring: {
|
|
41
|
+
type: KeyringTypes;
|
|
42
|
+
};
|
|
29
43
|
};
|
|
30
44
|
}[];
|
|
31
45
|
ONE_CUSTOM_NAME_WITH_LAST_UPDATED: {
|
|
32
46
|
address: string;
|
|
33
47
|
id: string;
|
|
48
|
+
type: EthAccountType;
|
|
34
49
|
metadata: {
|
|
35
50
|
name: string;
|
|
36
51
|
nameLastUpdatedAt: number;
|
|
52
|
+
keyring: {
|
|
53
|
+
type: KeyringTypes;
|
|
54
|
+
};
|
|
37
55
|
};
|
|
38
56
|
}[];
|
|
39
57
|
ONE_CUSTOM_NAME_WITH_LAST_UPDATED_MOST_RECENT: {
|
|
40
58
|
address: string;
|
|
41
59
|
id: string;
|
|
60
|
+
type: EthAccountType;
|
|
42
61
|
metadata: {
|
|
43
62
|
name: string;
|
|
44
63
|
nameLastUpdatedAt: number;
|
|
64
|
+
keyring: {
|
|
65
|
+
type: KeyringTypes;
|
|
66
|
+
};
|
|
45
67
|
};
|
|
46
68
|
}[];
|
|
47
69
|
ALL: {
|
|
48
70
|
address: string;
|
|
49
71
|
id: string;
|
|
72
|
+
type: EthAccountType;
|
|
50
73
|
metadata: {
|
|
51
74
|
name: string;
|
|
52
75
|
nameLastUpdatedAt: number;
|
|
76
|
+
keyring: {
|
|
77
|
+
type: KeyringTypes;
|
|
78
|
+
};
|
|
53
79
|
};
|
|
54
80
|
}[];
|
|
55
81
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockAccounts.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockAccounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mockAccounts.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockAccounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAwB,8BAA8B;AAC7E,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAe5D;;;GAGG;AACH,eAAO,MAAM,+BAA+B,mbAGzC,CAAC;AAEJ,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyHlC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;CA6BtC,CAAC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import $metamaskkeyringapi from "@metamask/keyring-api";
|
|
2
|
+
const { EthAccountType } = $metamaskkeyringapi;
|
|
3
|
+
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
1
4
|
import { LOCALIZED_DEFAULT_ACCOUNT_NAMES } from "../accounts/constants.mjs";
|
|
2
5
|
import { mapInternalAccountToUserStorageAccount } from "../accounts/user-storage.mjs";
|
|
3
6
|
/**
|
|
@@ -18,9 +21,13 @@ export const MOCK_INTERNAL_ACCOUNTS = {
|
|
|
18
21
|
{
|
|
19
22
|
address: '0x123',
|
|
20
23
|
id: '1',
|
|
24
|
+
type: EthAccountType.Eoa,
|
|
21
25
|
metadata: {
|
|
22
26
|
name: 'test',
|
|
23
27
|
nameLastUpdatedAt: 1,
|
|
28
|
+
keyring: {
|
|
29
|
+
type: KeyringTypes.hd,
|
|
30
|
+
},
|
|
24
31
|
},
|
|
25
32
|
},
|
|
26
33
|
],
|
|
@@ -28,9 +35,13 @@ export const MOCK_INTERNAL_ACCOUNTS = {
|
|
|
28
35
|
{
|
|
29
36
|
address: '0x123',
|
|
30
37
|
id: '1',
|
|
38
|
+
type: EthAccountType.Eoa,
|
|
31
39
|
metadata: {
|
|
32
40
|
name: `${getMockRandomDefaultAccountName()} 1`,
|
|
33
41
|
nameLastUpdatedAt: 1,
|
|
42
|
+
keyring: {
|
|
43
|
+
type: KeyringTypes.hd,
|
|
44
|
+
},
|
|
34
45
|
},
|
|
35
46
|
},
|
|
36
47
|
],
|
|
@@ -38,8 +49,12 @@ export const MOCK_INTERNAL_ACCOUNTS = {
|
|
|
38
49
|
{
|
|
39
50
|
address: '0x123',
|
|
40
51
|
id: '1',
|
|
52
|
+
type: EthAccountType.Eoa,
|
|
41
53
|
metadata: {
|
|
42
54
|
name: 'Internal account custom name without nameLastUpdatedAt',
|
|
55
|
+
keyring: {
|
|
56
|
+
type: KeyringTypes.hd,
|
|
57
|
+
},
|
|
43
58
|
},
|
|
44
59
|
},
|
|
45
60
|
],
|
|
@@ -47,9 +62,13 @@ export const MOCK_INTERNAL_ACCOUNTS = {
|
|
|
47
62
|
{
|
|
48
63
|
address: '0x123',
|
|
49
64
|
id: '1',
|
|
65
|
+
type: EthAccountType.Eoa,
|
|
50
66
|
metadata: {
|
|
51
67
|
name: 'Internal account custom name with nameLastUpdatedAt',
|
|
52
68
|
nameLastUpdatedAt: 1,
|
|
69
|
+
keyring: {
|
|
70
|
+
type: KeyringTypes.hd,
|
|
71
|
+
},
|
|
53
72
|
},
|
|
54
73
|
},
|
|
55
74
|
],
|
|
@@ -57,9 +76,13 @@ export const MOCK_INTERNAL_ACCOUNTS = {
|
|
|
57
76
|
{
|
|
58
77
|
address: '0x123',
|
|
59
78
|
id: '1',
|
|
79
|
+
type: EthAccountType.Eoa,
|
|
60
80
|
metadata: {
|
|
61
81
|
name: 'Internal account custom name with nameLastUpdatedAt',
|
|
62
82
|
nameLastUpdatedAt: 9999,
|
|
83
|
+
keyring: {
|
|
84
|
+
type: KeyringTypes.hd,
|
|
85
|
+
},
|
|
63
86
|
},
|
|
64
87
|
},
|
|
65
88
|
],
|
|
@@ -67,33 +90,49 @@ export const MOCK_INTERNAL_ACCOUNTS = {
|
|
|
67
90
|
{
|
|
68
91
|
address: '0x123',
|
|
69
92
|
id: '1',
|
|
93
|
+
type: EthAccountType.Eoa,
|
|
70
94
|
metadata: {
|
|
71
95
|
name: 'test',
|
|
72
96
|
nameLastUpdatedAt: 1,
|
|
97
|
+
keyring: {
|
|
98
|
+
type: KeyringTypes.hd,
|
|
99
|
+
},
|
|
73
100
|
},
|
|
74
101
|
},
|
|
75
102
|
{
|
|
76
103
|
address: '0x456',
|
|
77
104
|
id: '2',
|
|
105
|
+
type: EthAccountType.Eoa,
|
|
78
106
|
metadata: {
|
|
79
107
|
name: 'Account 2',
|
|
80
108
|
nameLastUpdatedAt: 2,
|
|
109
|
+
keyring: {
|
|
110
|
+
type: KeyringTypes.hd,
|
|
111
|
+
},
|
|
81
112
|
},
|
|
82
113
|
},
|
|
83
114
|
{
|
|
84
115
|
address: '0x789',
|
|
85
116
|
id: '3',
|
|
117
|
+
type: EthAccountType.Eoa,
|
|
86
118
|
metadata: {
|
|
87
119
|
name: 'Účet 2',
|
|
88
120
|
nameLastUpdatedAt: 3,
|
|
121
|
+
keyring: {
|
|
122
|
+
type: KeyringTypes.hd,
|
|
123
|
+
},
|
|
89
124
|
},
|
|
90
125
|
},
|
|
91
126
|
{
|
|
92
127
|
address: '0xabc',
|
|
93
128
|
id: '4',
|
|
129
|
+
type: EthAccountType.Eoa,
|
|
94
130
|
metadata: {
|
|
95
131
|
name: 'My Account 4',
|
|
96
132
|
nameLastUpdatedAt: 4,
|
|
133
|
+
keyring: {
|
|
134
|
+
type: KeyringTypes.hd,
|
|
135
|
+
},
|
|
97
136
|
},
|
|
98
137
|
},
|
|
99
138
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockAccounts.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockAccounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mockAccounts.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockAccounts.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAE5D,OAAO,EAAE,+BAA+B,EAAE,kCAA8B;AACxE,OAAO,EAAE,sCAAsC,EAAE,qCAAiC;AAElF;;;;;GAKG;AACH,MAAM,gDAAgD,GAAG,CACvD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,OAAO,EAAE;oBACP,IAAI,EAAE,YAAY,CAAC,EAAE;iBACtB;aACF;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,oBAAoB,EAAE,gDAAgD,CACpE,sBAAsB,CAAC,GAAwB,CAChD;IACD,GAAG,EAAE,gDAAgD,CACnD,sBAAsB,CAAC,GAAwB,CAChD;IACD,gBAAgB,EAAE,gDAAgD,CAChE,sBAAsB,CAAC,gBAAqC,CAC7D;IACD,oCAAoC,EAClC,gDAAgD,CAAC;QAC/C;YACE,GAAG,sBAAsB,CAAC,oCAAoC,CAAC,CAAC,CAAC;YACjE,QAAQ,EAAE;gBACR,IAAI,EAAE,4DAA4D;aACnE;SACF;KACmB,CAAC;IACzB,iCAAiC,EAC/B,gDAAgD,CAAC;QAC/C;YACE,GAAG,sBAAsB,CAAC,oCAAoC,CAAC,CAAC,CAAC;YACjE,QAAQ,EAAE;gBACR,IAAI,EAAE,yDAAyD;gBAC/D,iBAAiB,EAAE,CAAC;aACrB;SACF;KACmB,CAAC;CAC1B,CAAC","sourcesContent":["import { EthAccountType, type InternalAccount } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\n\nimport { LOCALIZED_DEFAULT_ACCOUNT_NAMES } from '../accounts/constants';\nimport { mapInternalAccountToUserStorageAccount } from '../accounts/user-storage';\n\n/**\n * Map an array of internal accounts to an array of user storage accounts\n * Only used for testing purposes\n * @param internalAccounts - An array of internal accounts\n * @returns An array of user storage accounts\n */\nconst mapInternalAccountsListToUserStorageAccountsList = (\n internalAccounts: InternalAccount[],\n) => internalAccounts.map(mapInternalAccountToUserStorageAccount);\n\n/**\n * Get a random default account name from the list of localized default account names\n * @returns A random default account name\n */\nexport const getMockRandomDefaultAccountName = () =>\n LOCALIZED_DEFAULT_ACCOUNT_NAMES[\n Math.floor(Math.random() * LOCALIZED_DEFAULT_ACCOUNT_NAMES.length)\n ];\n\nexport const MOCK_INTERNAL_ACCOUNTS = {\n EMPTY: [],\n ONE: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'test',\n nameLastUpdatedAt: 1,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ONE_DEFAULT_NAME: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: `${getMockRandomDefaultAccountName()} 1`,\n nameLastUpdatedAt: 1,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Internal account custom name without nameLastUpdatedAt',\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ONE_CUSTOM_NAME_WITH_LAST_UPDATED: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Internal account custom name with nameLastUpdatedAt',\n nameLastUpdatedAt: 1,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ONE_CUSTOM_NAME_WITH_LAST_UPDATED_MOST_RECENT: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Internal account custom name with nameLastUpdatedAt',\n nameLastUpdatedAt: 9999,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n ALL: [\n {\n address: '0x123',\n id: '1',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'test',\n nameLastUpdatedAt: 1,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n {\n address: '0x456',\n id: '2',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Account 2',\n nameLastUpdatedAt: 2,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n {\n address: '0x789',\n id: '3',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'Účet 2',\n nameLastUpdatedAt: 3,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n {\n address: '0xabc',\n id: '4',\n type: EthAccountType.Eoa,\n metadata: {\n name: 'My Account 4',\n nameLastUpdatedAt: 4,\n keyring: {\n type: KeyringTypes.hd,\n },\n },\n },\n ],\n};\n\nexport const MOCK_USER_STORAGE_ACCOUNTS = {\n SAME_AS_INTERNAL_ALL: mapInternalAccountsListToUserStorageAccountsList(\n MOCK_INTERNAL_ACCOUNTS.ALL as InternalAccount[],\n ),\n ONE: mapInternalAccountsListToUserStorageAccountsList(\n MOCK_INTERNAL_ACCOUNTS.ONE as InternalAccount[],\n ),\n ONE_DEFAULT_NAME: mapInternalAccountsListToUserStorageAccountsList(\n MOCK_INTERNAL_ACCOUNTS.ONE_DEFAULT_NAME as InternalAccount[],\n ),\n ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED:\n mapInternalAccountsListToUserStorageAccountsList([\n {\n ...MOCK_INTERNAL_ACCOUNTS.ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED[0],\n metadata: {\n name: 'User storage account custom name without nameLastUpdatedAt',\n },\n },\n ] as InternalAccount[]),\n ONE_CUSTOM_NAME_WITH_LAST_UPDATED:\n mapInternalAccountsListToUserStorageAccountsList([\n {\n ...MOCK_INTERNAL_ACCOUNTS.ONE_CUSTOM_NAME_WITHOUT_LAST_UPDATED[0],\n metadata: {\n name: 'User storage account custom name with nameLastUpdatedAt',\n nameLastUpdatedAt: 3,\n },\n },\n ] as InternalAccount[]),\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMockUserStoragePutResponse = exports.getMockUserStorageAllFeatureEntriesResponse = exports.getMockUserStorageGetResponse = exports.createMockAllFeatureEntriesResponse = exports.createMockGetStorageResponse = exports.getMockUserStorageEndpoint = void 0;
|
|
3
|
+
exports.getMockUserStorageBatchPutResponse = exports.getMockUserStoragePutResponse = exports.getMockUserStorageAllFeatureEntriesResponse = exports.getMockUserStorageGetResponse = exports.createMockAllFeatureEntriesResponse = exports.createMockGetStorageResponse = exports.getMockUserStorageEndpoint = void 0;
|
|
4
4
|
const storage_schema_1 = require("../../../shared/storage-schema.cjs");
|
|
5
5
|
const services_1 = require("../services.cjs");
|
|
6
6
|
const mockStorage_1 = require("./mockStorage.cjs");
|
|
@@ -73,4 +73,12 @@ const getMockUserStoragePutResponse = (path = 'notifications.notification_settin
|
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
75
|
exports.getMockUserStoragePutResponse = getMockUserStoragePutResponse;
|
|
76
|
+
const getMockUserStorageBatchPutResponse = (path = 'notifications') => {
|
|
77
|
+
return {
|
|
78
|
+
url: (0, exports.getMockUserStorageEndpoint)(path),
|
|
79
|
+
requestMethod: 'PUT',
|
|
80
|
+
response: null,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
exports.getMockUserStorageBatchPutResponse = getMockUserStorageBatchPutResponse;
|
|
76
84
|
//# sourceMappingURL=mockResponses.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":";;;AAIA,uEAAiE;AAKjE,8CAAoD;AACpD,mDAIuB;AAQhB,MAAM,0BAA0B,GAAG,CACxC,IAAuE,EACvE,EAAE;IACF,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QAChC,OAAO,GAAG,gCAAqB,IAAI,IAAI,EAAE,CAAC;KAC3C;IAED,OAAO,GAAG,gCAAqB,IAAI,IAAA,gCAAe,EAChD,IAAwC,EACxC,8BAAgB,CACjB,EAAE,CAAC;AACN,CAAC,CAAC;AAXW,QAAA,0BAA0B,8BAWrC;AAEF;;;;GAIG;AACI,KAAK,UAAU,4BAA4B,CAChD,IAAa;IAEb,OAAO;QACL,SAAS,EAAE,YAAY;QACvB,IAAI,EAAE,MAAM,IAAA,yCAA2B,EAAC,IAAI,CAAC;KAC9C,CAAC;AACJ,CAAC;AAPD,oEAOC;AAED;;;;GAIG;AACI,KAAK,UAAU,mCAAmC,CACvD,UAAoB,CAAC,+BAAiB,CAAC;IAEvC,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,OAAO,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC;QAC3B,MAAM,aAAa,GAAG,MAAM,IAAA,yCAA2B,EAAC,CAAC,CAAC,CAAC;QAC3D,OAAO;YACL,SAAS,EAAE,YAAY;YACvB,IAAI,EAAE,aAAa;SACpB,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAZD,kFAYC;AAED;;;;GAIG;AACI,KAAK,UAAU,6BAA6B,CACjD,OAAyC,qCAAqC;IAE9E,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,MAAM,4BAA4B,EAAE;KACxB,CAAC;AAC3B,CAAC;AARD,sEAQC;AAED;;;;;GAKG;AACI,KAAK,UAAU,2CAA2C,CAC/D,OAAuC,eAAe,EACtD,OAAkB;IAElB,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,MAAM,mCAAmC,CAAC,OAAO,CAAC;KACtC,CAAC;AAC3B,CAAC;AATD,kGASC;AAEM,MAAM,6BAA6B,GAAG,CAC3C,OAAyC,qCAAqC,EAC9E,EAAE;IACF,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,6BAA6B,iCAQxC","sourcesContent":["import type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../../../shared/storage-schema';\nimport { createEntryPath } from '../../../shared/storage-schema';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\nimport { USER_STORAGE_ENDPOINT } from '../services';\nimport {\n MOCK_ENCRYPTED_STORAGE_DATA,\n MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n} from './mockStorage';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const getMockUserStorageEndpoint = (\n path: UserStoragePathWithFeatureAndKey | UserStoragePathWithFeatureOnly,\n) => {\n if (path.split('.').length === 1) {\n return `${USER_STORAGE_ENDPOINT}/${path}`;\n }\n\n return `${USER_STORAGE_ENDPOINT}/${createEntryPath(\n path as UserStoragePathWithFeatureAndKey,\n MOCK_STORAGE_KEY,\n )}`;\n};\n\n/**\n * Creates a mock GET user-storage response\n * @param data - data to encrypt\n * @returns a realistic GET Response Body\n */\nexport async function createMockGetStorageResponse(\n data?: string,\n): Promise<GetUserStorageResponse> {\n return {\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n };\n}\n\n/**\n * Creates a mock GET ALL user-storage response\n * @param dataArr - array of data to encrypt\n * @returns a realistic GET ALL Response Body\n */\nexport async function createMockAllFeatureEntriesResponse(\n dataArr: string[] = [MOCK_STORAGE_DATA],\n): Promise<GetUserStorageAllFeatureEntriesResponse> {\n return await Promise.all(\n dataArr.map(async function (d) {\n const encryptedData = await MOCK_ENCRYPTED_STORAGE_DATA(d);\n return {\n HashedKey: 'HASHED_KEY',\n Data: encryptedData,\n };\n }),\n );\n}\n\n/**\n * Creates a mock user-storage api GET request\n * @param path - path of the GET Url\n * @returns mock GET API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageGetResponse(\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockGetStorageResponse(),\n } satisfies MockResponse;\n}\n\n/**\n * Creates a mock user-storage api GET ALL request\n * @param path - path of the GET url\n * @param dataArr - data to encrypt\n * @returns mock GET ALL API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageAllFeatureEntriesResponse(\n path: UserStoragePathWithFeatureOnly = 'notifications',\n dataArr?: string[],\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockAllFeatureEntriesResponse(dataArr),\n } satisfies MockResponse;\n}\n\nexport const getMockUserStoragePutResponse = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":";;;AAIA,uEAAiE;AAKjE,8CAAoD;AACpD,mDAIuB;AAQhB,MAAM,0BAA0B,GAAG,CACxC,IAAuE,EACvE,EAAE;IACF,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QAChC,OAAO,GAAG,gCAAqB,IAAI,IAAI,EAAE,CAAC;KAC3C;IAED,OAAO,GAAG,gCAAqB,IAAI,IAAA,gCAAe,EAChD,IAAwC,EACxC,8BAAgB,CACjB,EAAE,CAAC;AACN,CAAC,CAAC;AAXW,QAAA,0BAA0B,8BAWrC;AAEF;;;;GAIG;AACI,KAAK,UAAU,4BAA4B,CAChD,IAAa;IAEb,OAAO;QACL,SAAS,EAAE,YAAY;QACvB,IAAI,EAAE,MAAM,IAAA,yCAA2B,EAAC,IAAI,CAAC;KAC9C,CAAC;AACJ,CAAC;AAPD,oEAOC;AAED;;;;GAIG;AACI,KAAK,UAAU,mCAAmC,CACvD,UAAoB,CAAC,+BAAiB,CAAC;IAEvC,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,OAAO,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC;QAC3B,MAAM,aAAa,GAAG,MAAM,IAAA,yCAA2B,EAAC,CAAC,CAAC,CAAC;QAC3D,OAAO;YACL,SAAS,EAAE,YAAY;YACvB,IAAI,EAAE,aAAa;SACpB,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAZD,kFAYC;AAED;;;;GAIG;AACI,KAAK,UAAU,6BAA6B,CACjD,OAAyC,qCAAqC;IAE9E,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,MAAM,4BAA4B,EAAE;KACxB,CAAC;AAC3B,CAAC;AARD,sEAQC;AAED;;;;;GAKG;AACI,KAAK,UAAU,2CAA2C,CAC/D,OAAuC,eAAe,EACtD,OAAkB;IAElB,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,MAAM,mCAAmC,CAAC,OAAO,CAAC;KACtC,CAAC;AAC3B,CAAC;AATD,kGASC;AAEM,MAAM,6BAA6B,GAAG,CAC3C,OAAyC,qCAAqC,EAC9E,EAAE;IACF,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,6BAA6B,iCAQxC;AAEK,MAAM,kCAAkC,GAAG,CAChD,OAAuC,eAAe,EACtD,EAAE;IACF,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,kCAAkC,sCAQ7C","sourcesContent":["import type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../../../shared/storage-schema';\nimport { createEntryPath } from '../../../shared/storage-schema';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\nimport { USER_STORAGE_ENDPOINT } from '../services';\nimport {\n MOCK_ENCRYPTED_STORAGE_DATA,\n MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n} from './mockStorage';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const getMockUserStorageEndpoint = (\n path: UserStoragePathWithFeatureAndKey | UserStoragePathWithFeatureOnly,\n) => {\n if (path.split('.').length === 1) {\n return `${USER_STORAGE_ENDPOINT}/${path}`;\n }\n\n return `${USER_STORAGE_ENDPOINT}/${createEntryPath(\n path as UserStoragePathWithFeatureAndKey,\n MOCK_STORAGE_KEY,\n )}`;\n};\n\n/**\n * Creates a mock GET user-storage response\n * @param data - data to encrypt\n * @returns a realistic GET Response Body\n */\nexport async function createMockGetStorageResponse(\n data?: string,\n): Promise<GetUserStorageResponse> {\n return {\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n };\n}\n\n/**\n * Creates a mock GET ALL user-storage response\n * @param dataArr - array of data to encrypt\n * @returns a realistic GET ALL Response Body\n */\nexport async function createMockAllFeatureEntriesResponse(\n dataArr: string[] = [MOCK_STORAGE_DATA],\n): Promise<GetUserStorageAllFeatureEntriesResponse> {\n return await Promise.all(\n dataArr.map(async function (d) {\n const encryptedData = await MOCK_ENCRYPTED_STORAGE_DATA(d);\n return {\n HashedKey: 'HASHED_KEY',\n Data: encryptedData,\n };\n }),\n );\n}\n\n/**\n * Creates a mock user-storage api GET request\n * @param path - path of the GET Url\n * @returns mock GET API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageGetResponse(\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockGetStorageResponse(),\n } satisfies MockResponse;\n}\n\n/**\n * Creates a mock user-storage api GET ALL request\n * @param path - path of the GET url\n * @param dataArr - data to encrypt\n * @returns mock GET ALL API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageAllFeatureEntriesResponse(\n path: UserStoragePathWithFeatureOnly = 'notifications',\n dataArr?: string[],\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockAllFeatureEntriesResponse(dataArr),\n } satisfies MockResponse;\n}\n\nexport const getMockUserStoragePutResponse = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageBatchPutResponse = (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n"]}
|
|
@@ -39,4 +39,9 @@ export declare const getMockUserStoragePutResponse: (path?: UserStoragePathWithF
|
|
|
39
39
|
requestMethod: "PUT";
|
|
40
40
|
response: null;
|
|
41
41
|
};
|
|
42
|
+
export declare const getMockUserStorageBatchPutResponse: (path?: UserStoragePathWithFeatureOnly) => {
|
|
43
|
+
url: string;
|
|
44
|
+
requestMethod: "PUT";
|
|
45
|
+
response: null;
|
|
46
|
+
};
|
|
42
47
|
//# sourceMappingURL=mockResponses.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,2CAAuC;AAExC,OAAO,KAAK,EACV,uCAAuC,EACvC,sBAAsB,EACvB,wBAAoB;AAcrB,eAAO,MAAM,0BAA0B,SAC/B,gCAAgC,GAAG,8BAA8B,WAUxE,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAKjC;AAED;;;;GAIG;AACH,wBAAsB,mCAAmC,CACvD,OAAO,GAAE,MAAM,EAAwB,GACtC,OAAO,CAAC,uCAAuC,CAAC,CAUlD;AAED;;;;GAIG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,GAAE,gCAAwE;;;;GAO/E;AAED;;;;;GAKG;AACH,wBAAsB,2CAA2C,CAC/D,IAAI,GAAE,8BAAgD,EACtD,OAAO,CAAC,EAAE,MAAM,EAAE;;;;GAOnB;AAED,eAAO,MAAM,6BAA6B,UAClC,gCAAgC;;;;CAOvC,CAAC"}
|
|
1
|
+
{"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,2CAAuC;AAExC,OAAO,KAAK,EACV,uCAAuC,EACvC,sBAAsB,EACvB,wBAAoB;AAcrB,eAAO,MAAM,0BAA0B,SAC/B,gCAAgC,GAAG,8BAA8B,WAUxE,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAKjC;AAED;;;;GAIG;AACH,wBAAsB,mCAAmC,CACvD,OAAO,GAAE,MAAM,EAAwB,GACtC,OAAO,CAAC,uCAAuC,CAAC,CAUlD;AAED;;;;GAIG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,GAAE,gCAAwE;;;;GAO/E;AAED;;;;;GAKG;AACH,wBAAsB,2CAA2C,CAC/D,IAAI,GAAE,8BAAgD,EACtD,OAAO,CAAC,EAAE,MAAM,EAAE;;;;GAOnB;AAED,eAAO,MAAM,6BAA6B,UAClC,gCAAgC;;;;CAOvC,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACvC,8BAA8B;;;;CAOrC,CAAC"}
|
|
@@ -39,4 +39,9 @@ export declare const getMockUserStoragePutResponse: (path?: UserStoragePathWithF
|
|
|
39
39
|
requestMethod: "PUT";
|
|
40
40
|
response: null;
|
|
41
41
|
};
|
|
42
|
+
export declare const getMockUserStorageBatchPutResponse: (path?: UserStoragePathWithFeatureOnly) => {
|
|
43
|
+
url: string;
|
|
44
|
+
requestMethod: "PUT";
|
|
45
|
+
response: null;
|
|
46
|
+
};
|
|
42
47
|
//# sourceMappingURL=mockResponses.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,2CAAuC;AAExC,OAAO,KAAK,EACV,uCAAuC,EACvC,sBAAsB,EACvB,wBAAoB;AAcrB,eAAO,MAAM,0BAA0B,SAC/B,gCAAgC,GAAG,8BAA8B,WAUxE,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAKjC;AAED;;;;GAIG;AACH,wBAAsB,mCAAmC,CACvD,OAAO,GAAE,MAAM,EAAwB,GACtC,OAAO,CAAC,uCAAuC,CAAC,CAUlD;AAED;;;;GAIG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,GAAE,gCAAwE;;;;GAO/E;AAED;;;;;GAKG;AACH,wBAAsB,2CAA2C,CAC/D,IAAI,GAAE,8BAAgD,EACtD,OAAO,CAAC,EAAE,MAAM,EAAE;;;;GAOnB;AAED,eAAO,MAAM,6BAA6B,UAClC,gCAAgC;;;;CAOvC,CAAC"}
|
|
1
|
+
{"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,2CAAuC;AAExC,OAAO,KAAK,EACV,uCAAuC,EACvC,sBAAsB,EACvB,wBAAoB;AAcrB,eAAO,MAAM,0BAA0B,SAC/B,gCAAgC,GAAG,8BAA8B,WAUxE,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAKjC;AAED;;;;GAIG;AACH,wBAAsB,mCAAmC,CACvD,OAAO,GAAE,MAAM,EAAwB,GACtC,OAAO,CAAC,uCAAuC,CAAC,CAUlD;AAED;;;;GAIG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,GAAE,gCAAwE;;;;GAO/E;AAED;;;;;GAKG;AACH,wBAAsB,2CAA2C,CAC/D,IAAI,GAAE,8BAAgD,EACtD,OAAO,CAAC,EAAE,MAAM,EAAE;;;;GAOnB;AAED,eAAO,MAAM,6BAA6B,UAClC,gCAAgC;;;;CAOvC,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACvC,8BAA8B;;;;CAOrC,CAAC"}
|
|
@@ -64,4 +64,11 @@ export const getMockUserStoragePutResponse = (path = 'notifications.notification
|
|
|
64
64
|
response: null,
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
|
+
export const getMockUserStorageBatchPutResponse = (path = 'notifications') => {
|
|
68
|
+
return {
|
|
69
|
+
url: getMockUserStorageEndpoint(path),
|
|
70
|
+
requestMethod: 'PUT',
|
|
71
|
+
response: null,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
67
74
|
//# sourceMappingURL=mockResponses.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,2CAAuC;AAKjE,OAAO,EAAE,qBAAqB,EAAE,wBAAoB;AACpD,OAAO,EACL,2B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C;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,MAAM,mCAAmC,CAAC,OAAO,CAAC;KACtC,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,OAAyC,qCAAqC,EAC9E,EAAE;IACF,OAAO;QACL,GAAG,EAAE,0BAA0B,CAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../../../shared/storage-schema';\nimport { createEntryPath } from '../../../shared/storage-schema';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\nimport { USER_STORAGE_ENDPOINT } from '../services';\nimport {\n MOCK_ENCRYPTED_STORAGE_DATA,\n MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n} from './mockStorage';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const getMockUserStorageEndpoint = (\n path: UserStoragePathWithFeatureAndKey | UserStoragePathWithFeatureOnly,\n) => {\n if (path.split('.').length === 1) {\n return `${USER_STORAGE_ENDPOINT}/${path}`;\n }\n\n return `${USER_STORAGE_ENDPOINT}/${createEntryPath(\n path as UserStoragePathWithFeatureAndKey,\n MOCK_STORAGE_KEY,\n )}`;\n};\n\n/**\n * Creates a mock GET user-storage response\n * @param data - data to encrypt\n * @returns a realistic GET Response Body\n */\nexport async function createMockGetStorageResponse(\n data?: string,\n): Promise<GetUserStorageResponse> {\n return {\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n };\n}\n\n/**\n * Creates a mock GET ALL user-storage response\n * @param dataArr - array of data to encrypt\n * @returns a realistic GET ALL Response Body\n */\nexport async function createMockAllFeatureEntriesResponse(\n dataArr: string[] = [MOCK_STORAGE_DATA],\n): Promise<GetUserStorageAllFeatureEntriesResponse> {\n return await Promise.all(\n dataArr.map(async function (d) {\n const encryptedData = await MOCK_ENCRYPTED_STORAGE_DATA(d);\n return {\n HashedKey: 'HASHED_KEY',\n Data: encryptedData,\n };\n }),\n );\n}\n\n/**\n * Creates a mock user-storage api GET request\n * @param path - path of the GET Url\n * @returns mock GET API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageGetResponse(\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockGetStorageResponse(),\n } satisfies MockResponse;\n}\n\n/**\n * Creates a mock user-storage api GET ALL request\n * @param path - path of the GET url\n * @param dataArr - data to encrypt\n * @returns mock GET ALL API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageAllFeatureEntriesResponse(\n path: UserStoragePathWithFeatureOnly = 'notifications',\n dataArr?: string[],\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockAllFeatureEntriesResponse(dataArr),\n } satisfies MockResponse;\n}\n\nexport const getMockUserStoragePutResponse = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,2CAAuC;AAKjE,OAAO,EAAE,qBAAqB,EAAE,wBAAoB;AACpD,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,gBAAgB,EACjB,0BAAsB;AAQvB,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,IAAuE,EACvE,EAAE;IACF,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,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,OAAO;QACL,GAAG,EAAE,0BAA0B,CAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAChD,OAAuC,eAAe,EACtD,EAAE;IACF,OAAO;QACL,GAAG,EAAE,0BAA0B,CAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../../../shared/storage-schema';\nimport { createEntryPath } from '../../../shared/storage-schema';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\nimport { USER_STORAGE_ENDPOINT } from '../services';\nimport {\n MOCK_ENCRYPTED_STORAGE_DATA,\n MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n} from './mockStorage';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const getMockUserStorageEndpoint = (\n path: UserStoragePathWithFeatureAndKey | UserStoragePathWithFeatureOnly,\n) => {\n if (path.split('.').length === 1) {\n return `${USER_STORAGE_ENDPOINT}/${path}`;\n }\n\n return `${USER_STORAGE_ENDPOINT}/${createEntryPath(\n path as UserStoragePathWithFeatureAndKey,\n MOCK_STORAGE_KEY,\n )}`;\n};\n\n/**\n * Creates a mock GET user-storage response\n * @param data - data to encrypt\n * @returns a realistic GET Response Body\n */\nexport async function createMockGetStorageResponse(\n data?: string,\n): Promise<GetUserStorageResponse> {\n return {\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n };\n}\n\n/**\n * Creates a mock GET ALL user-storage response\n * @param dataArr - array of data to encrypt\n * @returns a realistic GET ALL Response Body\n */\nexport async function createMockAllFeatureEntriesResponse(\n dataArr: string[] = [MOCK_STORAGE_DATA],\n): Promise<GetUserStorageAllFeatureEntriesResponse> {\n return await Promise.all(\n dataArr.map(async function (d) {\n const encryptedData = await MOCK_ENCRYPTED_STORAGE_DATA(d);\n return {\n HashedKey: 'HASHED_KEY',\n Data: encryptedData,\n };\n }),\n );\n}\n\n/**\n * Creates a mock user-storage api GET request\n * @param path - path of the GET Url\n * @returns mock GET API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageGetResponse(\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockGetStorageResponse(),\n } satisfies MockResponse;\n}\n\n/**\n * Creates a mock user-storage api GET ALL request\n * @param path - path of the GET url\n * @param dataArr - data to encrypt\n * @returns mock GET ALL API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageAllFeatureEntriesResponse(\n path: UserStoragePathWithFeatureOnly = 'notifications',\n dataArr?: string[],\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockAllFeatureEntriesResponse(dataArr),\n } satisfies MockResponse;\n}\n\nexport const getMockUserStoragePutResponse = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageBatchPutResponse = (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n"]}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.mockEndpointUpsertUserStorage = exports.mockEndpointGetUserStorage = exports.mockEndpointGetUserStorageAllFeatureEntries = void 0;
|
|
6
|
+
exports.mockEndpointBatchUpsertUserStorage = exports.mockEndpointUpsertUserStorage = exports.mockEndpointGetUserStorage = exports.mockEndpointGetUserStorageAllFeatureEntries = void 0;
|
|
7
7
|
const nock_1 = __importDefault(require("nock"));
|
|
8
8
|
const mockResponses_1 = require("./mockResponses.cjs");
|
|
9
9
|
const mockEndpointGetUserStorageAllFeatureEntries = async (path = 'notifications', mockReply) => {
|
|
@@ -30,12 +30,24 @@ const mockEndpointGetUserStorage = async (path = 'notifications.notification_set
|
|
|
30
30
|
return mockEndpoint;
|
|
31
31
|
};
|
|
32
32
|
exports.mockEndpointGetUserStorage = mockEndpointGetUserStorage;
|
|
33
|
-
const mockEndpointUpsertUserStorage = (path = 'notifications.notification_settings', mockReply) => {
|
|
33
|
+
const mockEndpointUpsertUserStorage = (path = 'notifications.notification_settings', mockReply, expectCallback) => {
|
|
34
34
|
const mockResponse = (0, mockResponses_1.getMockUserStoragePutResponse)(path);
|
|
35
35
|
const mockEndpoint = (0, nock_1.default)(mockResponse.url)
|
|
36
36
|
.put('')
|
|
37
|
-
.reply(mockReply?.status ?? 204)
|
|
37
|
+
.reply(mockReply?.status ?? 204, async (_, requestBody) => {
|
|
38
|
+
await expectCallback?.(requestBody);
|
|
39
|
+
});
|
|
38
40
|
return mockEndpoint;
|
|
39
41
|
};
|
|
40
42
|
exports.mockEndpointUpsertUserStorage = mockEndpointUpsertUserStorage;
|
|
43
|
+
const mockEndpointBatchUpsertUserStorage = (path = 'notifications', mockReply, callback) => {
|
|
44
|
+
const mockResponse = (0, mockResponses_1.getMockUserStorageBatchPutResponse)(path);
|
|
45
|
+
const mockEndpoint = (0, nock_1.default)(mockResponse.url)
|
|
46
|
+
.put('')
|
|
47
|
+
.reply(mockReply?.status ?? 204, async (uri, requestBody) => {
|
|
48
|
+
return await callback?.(uri, requestBody);
|
|
49
|
+
});
|
|
50
|
+
return mockEndpoint;
|
|
51
|
+
};
|
|
52
|
+
exports.mockEndpointBatchUpsertUserStorage = mockEndpointBatchUpsertUserStorage;
|
|
41
53
|
//# sourceMappingURL=mockServices.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockServices.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAMxB,
|
|
1
|
+
{"version":3,"file":"mockServices.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAMxB,uDAKyB;AAOlB,MAAM,2CAA2C,GAAG,KAAK,EAC9D,OAAuC,eAAe,EACtD,SAAqB,EACrB,EAAE;IACF,MAAM,YAAY,GAAG,MAAM,IAAA,2DAA2C,EAAC,IAAI,CAAC,CAAC;IAC7E,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,YAAY,CAAC,QAAQ;KAC5B,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,YAAY,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAfW,QAAA,2CAA2C,+CAetD;AAEK,MAAM,0BAA0B,GAAG,KAAK,EAC7C,OAAyC,qCAAqC,EAC9E,SAAqB,EACrB,EAAE;IACF,MAAM,YAAY,GAAG,MAAM,IAAA,6CAA6B,EAAC,IAAI,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,YAAY,CAAC,QAAQ;KAC5B,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,YAAY,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAfW,QAAA,0BAA0B,8BAerC;AAEK,MAAM,6BAA6B,GAAG,CAC3C,OAAyC,qCAAqC,EAC9E,SAAqC,EACrC,cAA0D,EAC1D,EAAE;IACF,MAAM,YAAY,GAAG,IAAA,6CAA6B,EAAC,IAAI,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,YAAY,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,SAAS,EAAE,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE;QACxD,MAAM,cAAc,EAAE,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IACL,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAZW,QAAA,6BAA6B,iCAYxC;AAEK,MAAM,kCAAkC,GAAG,CAChD,OAAuC,eAAe,EACtD,SAAqC,EACrC,QAAiE,EACjE,EAAE;IACF,MAAM,YAAY,GAAG,IAAA,kDAAkC,EAAC,IAAI,CAAC,CAAC;IAC9D,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,YAAY,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,SAAS,EAAE,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE;QAC1D,OAAO,MAAM,QAAQ,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IACL,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAZW,QAAA,kCAAkC,sCAY7C","sourcesContent":["import nock from 'nock';\n\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../../../shared/storage-schema';\nimport {\n getMockUserStorageGetResponse,\n getMockUserStoragePutResponse,\n getMockUserStorageAllFeatureEntriesResponse,\n getMockUserStorageBatchPutResponse,\n} from './mockResponses';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\nexport const mockEndpointGetUserStorageAllFeatureEntries = async (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageAllFeatureEntriesResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointGetUserStorage = async (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageGetResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointUpsertUserStorage = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n mockReply?: Pick<MockReply, 'status'>,\n expectCallback?: (requestBody: nock.Body) => Promise<void>,\n) => {\n const mockResponse = getMockUserStoragePutResponse(path);\n const mockEndpoint = nock(mockResponse.url)\n .put('')\n .reply(mockReply?.status ?? 204, async (_, requestBody) => {\n await expectCallback?.(requestBody);\n });\n return mockEndpoint;\n};\n\nexport const mockEndpointBatchUpsertUserStorage = (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n mockReply?: Pick<MockReply, 'status'>,\n callback?: (uri: string, requestBody: nock.Body) => Promise<void>,\n) => {\n const mockResponse = getMockUserStorageBatchPutResponse(path);\n const mockEndpoint = nock(mockResponse.url)\n .put('')\n .reply(mockReply?.status ?? 204, async (uri, requestBody) => {\n return await callback?.(uri, requestBody);\n });\n return mockEndpoint;\n};\n"]}
|
|
@@ -6,6 +6,7 @@ type MockReply = {
|
|
|
6
6
|
};
|
|
7
7
|
export declare const mockEndpointGetUserStorageAllFeatureEntries: (path?: UserStoragePathWithFeatureOnly, mockReply?: MockReply) => Promise<nock.Scope>;
|
|
8
8
|
export declare const mockEndpointGetUserStorage: (path?: UserStoragePathWithFeatureAndKey, mockReply?: MockReply) => Promise<nock.Scope>;
|
|
9
|
-
export declare const mockEndpointUpsertUserStorage: (path?: UserStoragePathWithFeatureAndKey, mockReply?: Pick<MockReply, 'status'>) => nock.Scope;
|
|
9
|
+
export declare const mockEndpointUpsertUserStorage: (path?: UserStoragePathWithFeatureAndKey, mockReply?: Pick<MockReply, 'status'>, expectCallback?: ((requestBody: nock.Body) => Promise<void>) | undefined) => nock.Scope;
|
|
10
|
+
export declare const mockEndpointBatchUpsertUserStorage: (path?: UserStoragePathWithFeatureOnly, mockReply?: Pick<MockReply, 'status'>, callback?: ((uri: string, requestBody: nock.Body) => Promise<void>) | undefined) => nock.Scope;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=mockServices.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockServices.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;AAExB,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,2CAAuC;
|
|
1
|
+
{"version":3,"file":"mockServices.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;AAExB,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,2CAAuC;AAQxC,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,2CAA2C,UAChD,8BAA8B,cACxB,SAAS,wBAatB,CAAC;AAEF,eAAO,MAAM,0BAA0B,UAC/B,gCAAgC,cAC1B,SAAS,wBAatB,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAClC,gCAAgC,cAC1B,KAAK,SAAS,EAAE,QAAQ,CAAC,kCACN,SAAS,KAAK,QAAQ,IAAI,CAAC,4BAS3D,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACvC,8BAA8B,cACxB,KAAK,SAAS,EAAE,QAAQ,CAAC,oBACpB,MAAM,eAAe,SAAS,KAAK,QAAQ,IAAI,CAAC,4BASlE,CAAC"}
|
|
@@ -6,6 +6,7 @@ type MockReply = {
|
|
|
6
6
|
};
|
|
7
7
|
export declare const mockEndpointGetUserStorageAllFeatureEntries: (path?: UserStoragePathWithFeatureOnly, mockReply?: MockReply) => Promise<nock.Scope>;
|
|
8
8
|
export declare const mockEndpointGetUserStorage: (path?: UserStoragePathWithFeatureAndKey, mockReply?: MockReply) => Promise<nock.Scope>;
|
|
9
|
-
export declare const mockEndpointUpsertUserStorage: (path?: UserStoragePathWithFeatureAndKey, mockReply?: Pick<MockReply, 'status'>) => nock.Scope;
|
|
9
|
+
export declare const mockEndpointUpsertUserStorage: (path?: UserStoragePathWithFeatureAndKey, mockReply?: Pick<MockReply, 'status'>, expectCallback?: ((requestBody: nock.Body) => Promise<void>) | undefined) => nock.Scope;
|
|
10
|
+
export declare const mockEndpointBatchUpsertUserStorage: (path?: UserStoragePathWithFeatureOnly, mockReply?: Pick<MockReply, 'status'>, callback?: ((uri: string, requestBody: nock.Body) => Promise<void>) | undefined) => nock.Scope;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=mockServices.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockServices.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;AAExB,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,2CAAuC;
|
|
1
|
+
{"version":3,"file":"mockServices.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;AAExB,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,2CAAuC;AAQxC,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,2CAA2C,UAChD,8BAA8B,cACxB,SAAS,wBAatB,CAAC;AAEF,eAAO,MAAM,0BAA0B,UAC/B,gCAAgC,cAC1B,SAAS,wBAatB,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAClC,gCAAgC,cAC1B,KAAK,SAAS,EAAE,QAAQ,CAAC,kCACN,SAAS,KAAK,QAAQ,IAAI,CAAC,4BAS3D,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACvC,8BAA8B,cACxB,KAAK,SAAS,EAAE,QAAQ,CAAC,oBACpB,MAAM,eAAe,SAAS,KAAK,QAAQ,IAAI,CAAC,4BASlE,CAAC"}
|
|
@@ -6,7 +6,7 @@ function $importDefault(module) {
|
|
|
6
6
|
}
|
|
7
7
|
import $nock from "nock";
|
|
8
8
|
const nock = $importDefault($nock);
|
|
9
|
-
import { getMockUserStorageGetResponse, getMockUserStoragePutResponse, getMockUserStorageAllFeatureEntriesResponse } from "./mockResponses.mjs";
|
|
9
|
+
import { getMockUserStorageGetResponse, getMockUserStoragePutResponse, getMockUserStorageAllFeatureEntriesResponse, getMockUserStorageBatchPutResponse } from "./mockResponses.mjs";
|
|
10
10
|
export const mockEndpointGetUserStorageAllFeatureEntries = async (path = 'notifications', mockReply) => {
|
|
11
11
|
const mockResponse = await getMockUserStorageAllFeatureEntriesResponse(path);
|
|
12
12
|
const reply = mockReply ?? {
|
|
@@ -29,11 +29,22 @@ export const mockEndpointGetUserStorage = async (path = 'notifications.notificat
|
|
|
29
29
|
.reply(reply.status, reply.body);
|
|
30
30
|
return mockEndpoint;
|
|
31
31
|
};
|
|
32
|
-
export const mockEndpointUpsertUserStorage = (path = 'notifications.notification_settings', mockReply) => {
|
|
32
|
+
export const mockEndpointUpsertUserStorage = (path = 'notifications.notification_settings', mockReply, expectCallback) => {
|
|
33
33
|
const mockResponse = getMockUserStoragePutResponse(path);
|
|
34
34
|
const mockEndpoint = nock(mockResponse.url)
|
|
35
35
|
.put('')
|
|
36
|
-
.reply(mockReply?.status ?? 204)
|
|
36
|
+
.reply(mockReply?.status ?? 204, async (_, requestBody) => {
|
|
37
|
+
await expectCallback?.(requestBody);
|
|
38
|
+
});
|
|
39
|
+
return mockEndpoint;
|
|
40
|
+
};
|
|
41
|
+
export const mockEndpointBatchUpsertUserStorage = (path = 'notifications', mockReply, callback) => {
|
|
42
|
+
const mockResponse = getMockUserStorageBatchPutResponse(path);
|
|
43
|
+
const mockEndpoint = nock(mockResponse.url)
|
|
44
|
+
.put('')
|
|
45
|
+
.reply(mockReply?.status ?? 204, async (uri, requestBody) => {
|
|
46
|
+
return await callback?.(uri, requestBody);
|
|
47
|
+
});
|
|
37
48
|
return mockEndpoint;
|
|
38
49
|
};
|
|
39
50
|
//# sourceMappingURL=mockServices.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockServices.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAI,aAAa;;AAMxB,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,2CAA2C,
|
|
1
|
+
{"version":3,"file":"mockServices.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAI,aAAa;;AAMxB,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,2CAA2C,EAC3C,kCAAkC,E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M,IAAI,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE;QACxD,MAAM,cAAc,EAAE,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IACL,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAChD,OAAuC,eAAe,EACtD,SAAqC,EACrC,QAAiE,EACjE,EAAE;IACF,MAAM,YAAY,GAAG,kCAAkC,CAAC,IAAI,CAAC,CAAC;IAC9D,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,SAAS,EAAE,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE;QAC1D,OAAO,MAAM,QAAQ,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IACL,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import nock from 'nock';\n\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../../../shared/storage-schema';\nimport {\n getMockUserStorageGetResponse,\n getMockUserStoragePutResponse,\n getMockUserStorageAllFeatureEntriesResponse,\n getMockUserStorageBatchPutResponse,\n} from './mockResponses';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\nexport const mockEndpointGetUserStorageAllFeatureEntries = async (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageAllFeatureEntriesResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointGetUserStorage = async (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageGetResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointUpsertUserStorage = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n mockReply?: Pick<MockReply, 'status'>,\n expectCallback?: (requestBody: nock.Body) => Promise<void>,\n) => {\n const mockResponse = getMockUserStoragePutResponse(path);\n const mockEndpoint = nock(mockResponse.url)\n .put('')\n .reply(mockReply?.status ?? 204, async (_, requestBody) => {\n await expectCallback?.(requestBody);\n });\n return mockEndpoint;\n};\n\nexport const mockEndpointBatchUpsertUserStorage = (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n mockReply?: Pick<MockReply, 'status'>,\n callback?: (uri: string, requestBody: nock.Body) => Promise<void>,\n) => {\n const mockResponse = getMockUserStorageBatchPutResponse(path);\n const mockEndpoint = nock(mockResponse.url)\n .put('')\n .reply(mockReply?.status ?? 204, async (uri, requestBody) => {\n return await callback?.(uri, requestBody);\n });\n return mockEndpoint;\n};\n"]}
|
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.upsertUserStorage = exports.getUserStorageAllFeatureEntries = exports.getUserStorage = exports.USER_STORAGE_ENDPOINT = exports.USER_STORAGE_API = void 0;
|
|
29
|
+
exports.batchUpsertUserStorage = exports.upsertUserStorage = exports.getUserStorageAllFeatureEntries = exports.getUserStorage = exports.USER_STORAGE_ENDPOINT = exports.USER_STORAGE_API = void 0;
|
|
7
30
|
const loglevel_1 = __importDefault(require("loglevel"));
|
|
8
|
-
const encryption_1 =
|
|
31
|
+
const encryption_1 = __importStar(require("../../shared/encryption/index.cjs"));
|
|
9
32
|
const env_1 = require("../../shared/env.cjs");
|
|
10
33
|
const storage_schema_1 = require("../../shared/storage-schema.cjs");
|
|
11
34
|
const ENV_URLS = (0, env_1.getEnvUrls)(env_1.Env.PRD);
|
|
@@ -116,4 +139,37 @@ async function upsertUserStorage(data, opts) {
|
|
|
116
139
|
}
|
|
117
140
|
}
|
|
118
141
|
exports.upsertUserStorage = upsertUserStorage;
|
|
142
|
+
/**
|
|
143
|
+
* User Storage Service - Set multiple storage entries for one specific feature.
|
|
144
|
+
* You cannot use this method to set multiple features at once.
|
|
145
|
+
*
|
|
146
|
+
* @param data - data to store, in the form of an array of [entryKey, entryValue] pairs
|
|
147
|
+
* @param opts - storage options
|
|
148
|
+
*/
|
|
149
|
+
async function batchUpsertUserStorage(data, opts) {
|
|
150
|
+
if (!data.length) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;
|
|
154
|
+
const encryptedData = await Promise.all(data.map(async (d) => {
|
|
155
|
+
return [
|
|
156
|
+
(0, encryption_1.createSHA256Hash)(d[0] + storageKey),
|
|
157
|
+
await encryption_1.default.encryptString(d[1], opts.storageKey, nativeScryptCrypto),
|
|
158
|
+
];
|
|
159
|
+
}));
|
|
160
|
+
const url = new URL(`${exports.USER_STORAGE_ENDPOINT}/${path}`);
|
|
161
|
+
const formattedData = Object.fromEntries(encryptedData);
|
|
162
|
+
const res = await fetch(url.toString(), {
|
|
163
|
+
method: 'PUT',
|
|
164
|
+
headers: {
|
|
165
|
+
'Content-Type': 'application/json',
|
|
166
|
+
Authorization: `Bearer ${bearerToken}`,
|
|
167
|
+
},
|
|
168
|
+
body: JSON.stringify({ data: formattedData }),
|
|
169
|
+
});
|
|
170
|
+
if (!res.ok) {
|
|
171
|
+
throw new Error('user-storage - unable to batch upsert data');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.batchUpsertUserStorage = batchUpsertUserStorage;
|
|
119
175
|
//# sourceMappingURL=services.cjs.map
|