mosquito-transport-js 0.4.2 → 0.4.3
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/package.json
CHANGED
|
@@ -96,7 +96,7 @@ export const insertRecord = async (builder, config, accessIdWithoutLimit, value,
|
|
|
96
96
|
export const getRecord = async (builder, accessIdWithoutLimit, episode = 0) => {
|
|
97
97
|
await awaitStore();
|
|
98
98
|
const { projectUrl, dbUrl, dbName, path, command } = builder;
|
|
99
|
-
const { limit, sort, direction, random } = command;
|
|
99
|
+
const { limit, sort, direction, random, findOne } = command;
|
|
100
100
|
const isEpisode = episode === 1;
|
|
101
101
|
|
|
102
102
|
const transformData = (data) => {
|
|
@@ -49,7 +49,8 @@ export const mfetch = async (input = '', init, config) => {
|
|
|
49
49
|
const isLink = Validator.LINK(input);
|
|
50
50
|
const isBaseUrl = isLink || rawApproach;
|
|
51
51
|
const disableAuth = method?.disableAuth || isBaseUrl;
|
|
52
|
-
const
|
|
52
|
+
const hasBody = body !== undefined;
|
|
53
|
+
const shouldCache = (retrieval !== RETRIEVAL.DEFAULT || (config.disableCache === undefined ? !hasBody : !disableCache)) &&
|
|
53
54
|
![RETRIEVAL.NO_CACHE_NO_AWAIT, RETRIEVAL.NO_CACHE_AWAIT].includes(retrieval);
|
|
54
55
|
const uglified = !!(!isBaseUrl && uglify);
|
|
55
56
|
|
|
@@ -137,17 +138,17 @@ export const mfetch = async (input = '', init, config) => {
|
|
|
137
138
|
|
|
138
139
|
const mtoken = Scoped.AuthJWTToken[projectUrl];
|
|
139
140
|
const initType = rawHeader['content-type'];
|
|
141
|
+
const encodeBody = initType === undefined && hasBody && !isBaseUrl;
|
|
140
142
|
|
|
141
143
|
const [reqBuilder, [privateKey]] = uglified ? await serializeE2E(rawBody, mtoken, serverE2E_PublicKey) : [null, []];
|
|
142
144
|
|
|
143
145
|
const f = await fetch(isLink ? input : `${projectUrl}/${normalizeRoute(input)}`, {
|
|
144
|
-
...(!isBaseUrl ||
|
|
146
|
+
...(!isBaseUrl || hasBody) ? { method: 'POST' } : {},
|
|
145
147
|
...init,
|
|
146
|
-
...uglified ? { body: reqBuilder } : {},
|
|
148
|
+
...uglified ? { body: reqBuilder } : encodeBody ? { body: serialize(body) } : {},
|
|
147
149
|
// cache: 'no-cache',
|
|
148
150
|
headers: {
|
|
149
151
|
...extraHeaders,
|
|
150
|
-
...isBaseUrl ? {} : { 'content-type': 'application/json' },
|
|
151
152
|
...rawHeader,
|
|
152
153
|
...uglified ? {
|
|
153
154
|
uglified,
|