@foxtware/mineral 0.1.28 → 0.1.30
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/.creds.yml.sample +35 -2
- package/AGENTS.md +7 -0
- package/_build_scripts/createNewFunction.js +26 -3
- package/api/dpd/docs.md +6 -0
- package/api/dpd/dpd.constants.js +9 -0
- package/api/dpd/dpd.utils.js +145 -0
- package/api/dpd/dpdTrackingGet.js +64 -0
- package/api/dropbox/docs.md +7 -0
- package/api/dropbox/dropbox.constants.js +10 -0
- package/api/dropbox/dropbox.utils.js +67 -0
- package/api/dropbox/dropboxAccountGet.js +64 -0
- package/api/dropbox/dropboxFileCopy.js +67 -0
- package/api/dropbox/dropboxFileDelete.js +89 -0
- package/api/dropbox/dropboxFileDownload.js +139 -0
- package/api/dropbox/dropboxFileMetadataGet.js +100 -0
- package/api/dropbox/dropboxFileMove.js +67 -0
- package/api/dropbox/dropboxFileUpload.js +129 -0
- package/api/dropbox/dropboxFolderCreate.js +68 -0
- package/api/dropbox/dropboxFolderList.js +66 -0
- package/api/dropbox/dropboxGet.js +158 -0
- package/api/dropbox/dropboxSearch.js +161 -0
- package/api/dropbox/dropboxSharedLinkCreate.js +68 -0
- package/api/dropbox/dropboxSpaceUsageGet.js +55 -0
- package/api/dropbox/dropboxTemporaryLinkGet.js +75 -0
- package/api/fedex/docs.md +6 -0
- package/api/fedex/fedex.constants.js +11 -0
- package/api/fedex/fedex.utils.js +151 -0
- package/api/fedex/fedexTrackingGet.js +76 -0
- package/api/google/docs.md +1 -0
- package/api/google/google.constants.js +1 -0
- package/api/google/google.utils.js +21 -0
- package/api/google/googleanalyticsMetadataGet.js +62 -0
- package/api/google/googleanalyticsRealtimeReportRun.js +103 -0
- package/api/google/googleanalyticsReportRun.js +114 -0
- package/api/paypal/docs.md +14 -0
- package/api/paypal/paypal.constants.js +13 -0
- package/api/paypal/paypal.utils.js +166 -0
- package/api/paypal/paypalAccessTokenGet.js +81 -0
- package/api/paypal/paypalAuthorizationCapture.js +75 -0
- package/api/paypal/paypalAuthorizationGet.js +57 -0
- package/api/paypal/paypalBalancesGet.js +65 -0
- package/api/paypal/paypalCaptureGet.js +57 -0
- package/api/paypal/paypalCaptureRefund.js +78 -0
- package/api/paypal/paypalOrderAuthorize.js +69 -0
- package/api/paypal/paypalOrderCapture.js +69 -0
- package/api/paypal/paypalOrderCreate.js +81 -0
- package/api/paypal/paypalOrderGet.js +57 -0
- package/api/paypal/paypalRefundGet.js +57 -0
- package/api/paypal/paypalTransactionsGet.js +101 -0
- package/api/paypal/paypalUserInfoGet.js +62 -0
- package/api/royalmail/docs.md +6 -0
- package/api/royalmail/royalmail.constants.js +7 -0
- package/api/royalmail/royalmail.utils.js +55 -0
- package/api/royalmail/royalmailTrackingGet.js +70 -0
- package/api/shopify/shopify.utils.js +65 -4
- package/api/shopify/shopifyMetaobjectCreate.js +13 -6
- package/api/shopify/shopifyMetaobjectDelete.js +90 -0
- package/api/shopify/shopifyMetaobjectGet.js +80 -0
- package/api/shopify/shopifyMetaobjectUpdate.js +108 -0
- package/api/shopify/shopifyStorefrontSearch.js +158 -0
- package/api/spotify/docs.md +8 -0
- package/api/spotify/spotify.constants.js +12 -0
- package/api/spotify/spotify.utils.js +106 -0
- package/api/spotify/spotifyAlbumGet.js +76 -0
- package/api/spotify/spotifyAlbumTracksGet.js +49 -0
- package/api/spotify/spotifyArtistAlbumsGet.js +55 -0
- package/api/spotify/spotifyArtistGet.js +71 -0
- package/api/spotify/spotifyArtistTopTracksGet.js +56 -0
- package/api/spotify/spotifyGet.js +171 -0
- package/api/spotify/spotifyMeGet.js +48 -0
- package/api/spotify/spotifyPlayerCurrentlyPlayingGet.js +62 -0
- package/api/spotify/spotifyPlayerDevicesGet.js +51 -0
- package/api/spotify/spotifyPlayerGet.js +63 -0
- package/api/spotify/spotifyPlayerNext.js +55 -0
- package/api/spotify/spotifyPlayerPause.js +55 -0
- package/api/spotify/spotifyPlayerPlay.js +70 -0
- package/api/spotify/spotifyPlayerPrevious.js +55 -0
- package/api/spotify/spotifyPlaylistCreate.js +63 -0
- package/api/spotify/spotifyPlaylistGet.js +91 -0
- package/api/spotify/spotifyPlaylistItemsAdd.js +61 -0
- package/api/spotify/spotifyPlaylistItemsGet.js +58 -0
- package/api/spotify/spotifyPlaylistItemsRemove.js +67 -0
- package/api/spotify/spotifyPlaylistUpdate.js +64 -0
- package/api/spotify/spotifyPlaylistsGet.js +47 -0
- package/api/spotify/spotifySavedTracksGet.js +46 -0
- package/api/spotify/spotifySavedTracksRemove.js +59 -0
- package/api/spotify/spotifySavedTracksSave.js +59 -0
- package/api/spotify/spotifySearch.js +174 -0
- package/api/spotify/spotifyTrackGet.js +76 -0
- package/api/starshipit/starshipitProductUpdate.js +102 -0
- package/api/starshipit/starshipitProductsGet.js +2 -2
- package/api/stylearcade/stylearcadeGet.js +5 -2
- package/api/utils.js +39 -0
- package/package.json +1 -1
- package/server.js +3 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// https://developer.spotify.com/documentation/web-api/reference/search
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, Getter } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { spotifyClient } = require('../spotify/spotify.utils');
|
|
6
|
+
const { MAX_SEARCH_PER_PAGE } = require('../spotify/spotify.constants');
|
|
7
|
+
|
|
8
|
+
const argsWarden = new ArgsWarden([
|
|
9
|
+
['credsPayload', credsValidator],
|
|
10
|
+
['query'],
|
|
11
|
+
['types'],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const digSearchResults = (data, types) => {
|
|
15
|
+
const typeList = (Array.isArray(types) ? types : String(types).split(','))
|
|
16
|
+
.map((t) => t.trim())
|
|
17
|
+
.filter(Boolean);
|
|
18
|
+
|
|
19
|
+
// Flatten matches across requested types, tagging each with its type key.
|
|
20
|
+
const out = [];
|
|
21
|
+
for (const type of typeList) {
|
|
22
|
+
const key = type.endsWith('s') ? type : `${ type }s`;
|
|
23
|
+
const page = data?.[key];
|
|
24
|
+
const items = page?.items ?? [];
|
|
25
|
+
for (const item of items) {
|
|
26
|
+
out.push({ type: key, ...item });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const spotifySearchPacket = async (
|
|
33
|
+
credsPayload,
|
|
34
|
+
query,
|
|
35
|
+
types,
|
|
36
|
+
{
|
|
37
|
+
params = {},
|
|
38
|
+
perPage = MAX_SEARCH_PER_PAGE,
|
|
39
|
+
fetchClient = spotifyClient,
|
|
40
|
+
} = {},
|
|
41
|
+
) => {
|
|
42
|
+
const typeParam = Array.isArray(types) ? types.join(',') : types;
|
|
43
|
+
|
|
44
|
+
return fetchClient.fetch({
|
|
45
|
+
context: { credsPayload },
|
|
46
|
+
requestPayload: {
|
|
47
|
+
method: 'get',
|
|
48
|
+
url: '/search',
|
|
49
|
+
params: {
|
|
50
|
+
q: query,
|
|
51
|
+
type: typeParam,
|
|
52
|
+
limit: Math.min(perPage, MAX_SEARCH_PER_PAGE),
|
|
53
|
+
offset: 0,
|
|
54
|
+
...params,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const spotifySearchPaginator = async (currentParams, response) => {
|
|
61
|
+
if (!response?.ok) {
|
|
62
|
+
return [true];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const data = response.data ?? {};
|
|
66
|
+
// Any requested type still having a next URL means we continue.
|
|
67
|
+
const hasNext = Object.values(data).some(
|
|
68
|
+
(page) => page && typeof page === 'object' && page.next,
|
|
69
|
+
);
|
|
70
|
+
if (!hasNext) {
|
|
71
|
+
return [true];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const { args, options } = currentParams;
|
|
75
|
+
const { params = {}, perPage = MAX_SEARCH_PER_PAGE } = options;
|
|
76
|
+
const currentOffset = Number(params.offset ?? 0);
|
|
77
|
+
const pageLimit = Number(params.limit ?? perPage);
|
|
78
|
+
|
|
79
|
+
return [false, {
|
|
80
|
+
args,
|
|
81
|
+
options: {
|
|
82
|
+
...options,
|
|
83
|
+
params: {
|
|
84
|
+
...params,
|
|
85
|
+
offset: currentOffset + pageLimit,
|
|
86
|
+
limit: pageLimit,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
}];
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const spotifySearch = async (
|
|
93
|
+
returnGetter,
|
|
94
|
+
|
|
95
|
+
credsPayload,
|
|
96
|
+
query,
|
|
97
|
+
types,
|
|
98
|
+
{
|
|
99
|
+
market,
|
|
100
|
+
includeExternal,
|
|
101
|
+
perPage = MAX_SEARCH_PER_PAGE,
|
|
102
|
+
fetchClient,
|
|
103
|
+
...getterOptions
|
|
104
|
+
} = {},
|
|
105
|
+
) => {
|
|
106
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
107
|
+
credsPayload,
|
|
108
|
+
query,
|
|
109
|
+
types,
|
|
110
|
+
});
|
|
111
|
+
if (rejectResponse) {
|
|
112
|
+
return rejectResponse;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const typeList = Array.isArray(types) ? types : String(types).split(',');
|
|
116
|
+
|
|
117
|
+
const getter = new Getter(
|
|
118
|
+
{
|
|
119
|
+
args: [credsPayload, query, types],
|
|
120
|
+
options: {
|
|
121
|
+
params: {
|
|
122
|
+
...(market !== undefined && { market }),
|
|
123
|
+
...(includeExternal !== undefined && {
|
|
124
|
+
include_external: includeExternal,
|
|
125
|
+
}),
|
|
126
|
+
},
|
|
127
|
+
perPage,
|
|
128
|
+
fetchClient,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
func: spotifySearchPacket,
|
|
133
|
+
digester: (response) => {
|
|
134
|
+
if (!response?.ok) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
return digSearchResults(response.data, typeList);
|
|
138
|
+
},
|
|
139
|
+
paginator: spotifySearchPaginator,
|
|
140
|
+
...getterOptions,
|
|
141
|
+
},
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
if (returnGetter) {
|
|
145
|
+
return getter;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const data = await getter.run({ returnAll: true });
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
ok: true,
|
|
152
|
+
data,
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const funcApiConfig = {
|
|
157
|
+
argsWarden,
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
module.exports = {
|
|
161
|
+
spotifySearch: (...args) => spotifySearch(false, ...args),
|
|
162
|
+
spotifySearchGetter: (...args) => spotifySearch(true, ...args),
|
|
163
|
+
funcApiConfig,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/*
|
|
167
|
+
curl -X POST "http://localhost:8000/spotifySearch" \
|
|
168
|
+
-H "Content-Type: application/json" \
|
|
169
|
+
-d '{
|
|
170
|
+
"credsPayload": { "credsPath": "spotify" },
|
|
171
|
+
"query": "radiohead",
|
|
172
|
+
"types": ["artist", "album"]
|
|
173
|
+
}'
|
|
174
|
+
*/
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// https://developer.spotify.com/documentation/web-api/reference/get-track
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden, actionSingleOrMultiple, logDeep } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { spotifyClient } = require('../spotify/spotify.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['trackId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const spotifyTrackGetSingle = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
trackId,
|
|
15
|
+
{
|
|
16
|
+
market,
|
|
17
|
+
fetchClient = spotifyClient,
|
|
18
|
+
} = {},
|
|
19
|
+
) => {
|
|
20
|
+
const response = await fetchClient.fetch({
|
|
21
|
+
context: { credsPayload },
|
|
22
|
+
requestPayload: {
|
|
23
|
+
method: 'get',
|
|
24
|
+
url: `/tracks/${ trackId }`,
|
|
25
|
+
params: {
|
|
26
|
+
...(market !== undefined && { market }),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const { ok, data, error } = response;
|
|
32
|
+
if (!ok) {
|
|
33
|
+
logDeep({ error });
|
|
34
|
+
return { ok: false, error };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return { ok: true, data };
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const spotifyTrackGet = async (
|
|
41
|
+
credsPayload,
|
|
42
|
+
trackId,
|
|
43
|
+
{
|
|
44
|
+
market,
|
|
45
|
+
queueRunOptions,
|
|
46
|
+
fetchClient,
|
|
47
|
+
} = {},
|
|
48
|
+
) => {
|
|
49
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
50
|
+
credsPayload,
|
|
51
|
+
trackId,
|
|
52
|
+
});
|
|
53
|
+
if (rejectResponse) {
|
|
54
|
+
return rejectResponse;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return actionSingleOrMultiple(
|
|
58
|
+
trackId,
|
|
59
|
+
spotifyTrackGetSingle,
|
|
60
|
+
(trackIdItem) => ({
|
|
61
|
+
args: [credsPayload, trackIdItem, { market, fetchClient }],
|
|
62
|
+
}),
|
|
63
|
+
{
|
|
64
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const funcApiConfig = {
|
|
70
|
+
argsWarden,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
module.exports = {
|
|
74
|
+
spotifyTrackGet,
|
|
75
|
+
funcApiConfig,
|
|
76
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// https://api-docs.starshipit.com/#9101a9d7-91b1-492c-b7ad-5f92f80bbfd7
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { starshipitClient } = require('../starshipit/starshipit.utils');
|
|
6
|
+
const { starshipitProductsGet } = require('../starshipit/starshipitProductsGet');
|
|
7
|
+
|
|
8
|
+
const argsWarden = new ArgsWarden([
|
|
9
|
+
['credsPayload', credsValidator],
|
|
10
|
+
['productId'],
|
|
11
|
+
['sku'],
|
|
12
|
+
['updatePayload'],
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
const starshipitProductUpdate = async (
|
|
16
|
+
credsPayload,
|
|
17
|
+
productId,
|
|
18
|
+
sku,
|
|
19
|
+
updatePayload,
|
|
20
|
+
{
|
|
21
|
+
setData = false,
|
|
22
|
+
} = {},
|
|
23
|
+
) => {
|
|
24
|
+
|
|
25
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
26
|
+
credsPayload,
|
|
27
|
+
productId,
|
|
28
|
+
sku,
|
|
29
|
+
updatePayload,
|
|
30
|
+
});
|
|
31
|
+
if (rejectResponse) {
|
|
32
|
+
return rejectResponse;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!setData) {
|
|
36
|
+
const productsResponse = await starshipitProductsGet(
|
|
37
|
+
credsPayload,
|
|
38
|
+
{
|
|
39
|
+
searchTerm: sku,
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (!productsResponse?.ok) {
|
|
44
|
+
return productsResponse;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const currentProduct = productsResponse.data?.find(product => product?.sku === sku);
|
|
48
|
+
if (!currentProduct) {
|
|
49
|
+
return {
|
|
50
|
+
ok: false,
|
|
51
|
+
error: {
|
|
52
|
+
code: 'PRODUCT_NOT_FOUND',
|
|
53
|
+
message: `No Starshipit product found for SKU ${ sku }`,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
updatePayload = {
|
|
59
|
+
...currentProduct,
|
|
60
|
+
...updatePayload,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return starshipitClient.fetch({
|
|
65
|
+
requestPayload: {
|
|
66
|
+
url: '/products/update',
|
|
67
|
+
method: 'put',
|
|
68
|
+
body: {
|
|
69
|
+
id: productId,
|
|
70
|
+
product: {
|
|
71
|
+
id: productId,
|
|
72
|
+
sku,
|
|
73
|
+
...updatePayload,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
context: {
|
|
78
|
+
credsPayload,
|
|
79
|
+
resultPath: 'result.product',
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const funcApiConfig = {
|
|
85
|
+
argsWarden,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
module.exports = {
|
|
89
|
+
starshipitProductUpdate,
|
|
90
|
+
funcApiConfig,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
curl -X POST "http://localhost:8000/starshipitProductUpdate" \
|
|
95
|
+
-H "Content-Type: application/json" \
|
|
96
|
+
-d '{
|
|
97
|
+
"credsPayload": { "credsPath": "starshipit.wf" },
|
|
98
|
+
"productId": 3015817,
|
|
99
|
+
"sku": "WFAL48-1-S",
|
|
100
|
+
"updatePayload": { "hs_code": "6104630011" }
|
|
101
|
+
}'
|
|
102
|
+
*/
|
|
@@ -45,7 +45,7 @@ module.exports = {
|
|
|
45
45
|
curl -X POST "http://localhost:8000/starshipitProductsGet" \
|
|
46
46
|
-H "Content-Type: application/json" \
|
|
47
47
|
-d '{
|
|
48
|
-
"credsPayload": { "credsPath": "starshipit.
|
|
49
|
-
"options": { "
|
|
48
|
+
"credsPayload": { "credsPath": "starshipit.wf" },
|
|
49
|
+
"options": { "limit": 20 }
|
|
50
50
|
}'
|
|
51
51
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { ArgsWarden, Getter } = require('../utils');
|
|
1
|
+
const { ArgsWarden, Getter, valueProvided } = require('../utils');
|
|
2
2
|
const { credsValidator } = require('../validators');
|
|
3
3
|
const { stylearcadeClient } = require('../stylearcade/stylearcade.utils');
|
|
4
4
|
const { MAX_PER_PAGE } = require('../stylearcade/stylearcade.constants');
|
|
@@ -59,7 +59,10 @@ const stylearcadeGetDigester = (response, nodeName) => {
|
|
|
59
59
|
return [];
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
const items = response?.data?.[nodeName] ?? [];
|
|
63
|
+
// Filter out items that have data property, but it's null
|
|
64
|
+
const meaningfulItems = items.filter(item => Object.hasOwn(item, 'data') && valueProvided(item.data));
|
|
65
|
+
return meaningfulItems;
|
|
63
66
|
};
|
|
64
67
|
|
|
65
68
|
const stylearcadeGet = async (
|
package/api/utils.js
CHANGED
|
@@ -1411,6 +1411,43 @@ const surveyObject = (
|
|
|
1411
1411
|
);
|
|
1412
1412
|
};
|
|
1413
1413
|
|
|
1414
|
+
const diffObjects = (
|
|
1415
|
+
sourceOfTruthObject,
|
|
1416
|
+
comparisonObject,
|
|
1417
|
+
{
|
|
1418
|
+
propMap = {},
|
|
1419
|
+
} = {},
|
|
1420
|
+
) => {
|
|
1421
|
+
const diff = {};
|
|
1422
|
+
for (const [key, value] of Object.entries(sourceOfTruthObject)) {
|
|
1423
|
+
const comparisonKey = propMap[key] || key;
|
|
1424
|
+
// TODO: Consider deep equality
|
|
1425
|
+
if (comparisonObject[comparisonKey] !== value) {
|
|
1426
|
+
diff[key] = value;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
return diff;
|
|
1430
|
+
};
|
|
1431
|
+
|
|
1432
|
+
const objectPropsTranslate = (
|
|
1433
|
+
obj,
|
|
1434
|
+
propMap,
|
|
1435
|
+
{
|
|
1436
|
+
omitUnmappedProps = false,
|
|
1437
|
+
} = {},
|
|
1438
|
+
) => {
|
|
1439
|
+
const translatedObj = {};
|
|
1440
|
+
|
|
1441
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
1442
|
+
if (omitUnmappedProps && !propMap[key]) {
|
|
1443
|
+
continue;
|
|
1444
|
+
}
|
|
1445
|
+
const translatedKey = propMap[key] || key;
|
|
1446
|
+
translatedObj[translatedKey] = value;
|
|
1447
|
+
}
|
|
1448
|
+
return translatedObj;
|
|
1449
|
+
};
|
|
1450
|
+
|
|
1414
1451
|
module.exports = {
|
|
1415
1452
|
wait,
|
|
1416
1453
|
timeMs,
|
|
@@ -1452,4 +1489,6 @@ module.exports = {
|
|
|
1452
1489
|
objectMatchesPartial,
|
|
1453
1490
|
oneFromManyInResponse,
|
|
1454
1491
|
surveyObject,
|
|
1492
|
+
diffObjects,
|
|
1493
|
+
objectPropsTranslate,
|
|
1455
1494
|
};
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -200,11 +200,13 @@ const logStartup = ({
|
|
|
200
200
|
if (api_dirs.length) {
|
|
201
201
|
console.log('Extra API dirs:', api_dirs.join(', '));
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
|
|
204
|
+
/*
|
|
204
205
|
console.log('Registered routes:');
|
|
205
206
|
for (const route of [...routeHandlers.keys()].sort()) {
|
|
206
207
|
console.log(route);
|
|
207
208
|
}
|
|
209
|
+
*/
|
|
208
210
|
};
|
|
209
211
|
|
|
210
212
|
const startServer = (options = {}) => {
|