@strapi/core 0.0.0-experimental.aa680be2574ebd6a8ca7675ce7ba57512d0df8cf → 0.0.0-experimental.aa8f064c5e2c0138b780746dc4455c060da87829
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/dist/Strapi.d.ts.map +1 -1
- package/dist/Strapi.js +2 -0
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +2 -0
- package/dist/Strapi.mjs.map +1 -1
- package/dist/configuration/index.d.ts +1 -0
- package/dist/configuration/index.d.ts.map +1 -1
- package/dist/configuration/index.js +1 -0
- package/dist/configuration/index.js.map +1 -1
- package/dist/configuration/index.mjs +1 -0
- package/dist/configuration/index.mjs.map +1 -1
- package/dist/ee/index.d.ts +6 -0
- package/dist/ee/index.d.ts.map +1 -1
- package/dist/ee/index.js +29 -3
- package/dist/ee/index.js.map +1 -1
- package/dist/ee/index.mjs +30 -4
- package/dist/ee/index.mjs.map +1 -1
- package/dist/ee/license.d.ts +3 -1
- package/dist/ee/license.d.ts.map +1 -1
- package/dist/ee/license.js +8 -2
- package/dist/ee/license.js.map +1 -1
- package/dist/ee/license.mjs +9 -4
- package/dist/ee/license.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/package.json.js +15 -13
- package/dist/package.json.js.map +1 -1
- package/dist/package.json.mjs +15 -13
- package/dist/package.json.mjs.map +1 -1
- package/dist/services/core-store.d.ts +2 -2
- package/dist/services/core-store.d.ts.map +1 -1
- package/dist/services/core-store.js.map +1 -1
- package/dist/services/core-store.mjs.map +1 -1
- package/dist/services/document-service/entries.d.ts.map +1 -1
- package/dist/services/document-service/entries.js +42 -0
- package/dist/services/document-service/entries.js.map +1 -1
- package/dist/services/document-service/entries.mjs +43 -1
- package/dist/services/document-service/entries.mjs.map +1 -1
- package/dist/services/document-service/internationalization.d.ts +6 -1
- package/dist/services/document-service/internationalization.d.ts.map +1 -1
- package/dist/services/document-service/internationalization.js +32 -0
- package/dist/services/document-service/internationalization.js.map +1 -1
- package/dist/services/document-service/internationalization.mjs +32 -1
- package/dist/services/document-service/internationalization.mjs.map +1 -1
- package/dist/services/document-service/repository.d.ts.map +1 -1
- package/dist/services/document-service/repository.js +5 -4
- package/dist/services/document-service/repository.js.map +1 -1
- package/dist/services/document-service/repository.mjs +6 -5
- package/dist/services/document-service/repository.mjs.map +1 -1
- package/dist/services/entity-validator/index.d.ts.map +1 -1
- package/dist/services/entity-validator/index.js +9 -0
- package/dist/services/entity-validator/index.js.map +1 -1
- package/dist/services/entity-validator/index.mjs +9 -0
- package/dist/services/entity-validator/index.mjs.map +1 -1
- package/dist/services/entity-validator/validators.d.ts +1 -0
- package/dist/services/entity-validator/validators.d.ts.map +1 -1
- package/dist/services/entity-validator/validators.js +3 -0
- package/dist/services/entity-validator/validators.js.map +1 -1
- package/dist/services/entity-validator/validators.mjs +3 -0
- package/dist/services/entity-validator/validators.mjs.map +1 -1
- package/dist/services/metrics/admin-user-hash.d.ts.map +1 -1
- package/dist/services/metrics/admin-user-hash.js.map +1 -1
- package/dist/services/metrics/admin-user-hash.mjs.map +1 -1
- package/dist/services/metrics/sender.d.ts.map +1 -1
- package/dist/services/metrics/sender.js +3 -3
- package/dist/services/metrics/sender.js.map +1 -1
- package/dist/services/metrics/sender.mjs +4 -4
- package/dist/services/metrics/sender.mjs.map +1 -1
- package/dist/services/utils/conditional-fields.d.ts +3 -0
- package/dist/services/utils/conditional-fields.d.ts.map +1 -0
- package/dist/services/utils/conditional-fields.js +22 -0
- package/dist/services/utils/conditional-fields.js.map +1 -0
- package/dist/services/utils/conditional-fields.mjs +20 -0
- package/dist/services/utils/conditional-fields.mjs.map +1 -0
- package/dist/utils/fetch.d.ts +5 -1
- package/dist/utils/fetch.d.ts.map +1 -1
- package/dist/utils/fetch.js +8 -4
- package/dist/utils/fetch.js.map +1 -1
- package/dist/utils/fetch.mjs +8 -4
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/transform-content-types-to-models.d.ts +197 -0
- package/dist/utils/transform-content-types-to-models.d.ts.map +1 -1
- package/package.json +15 -13
@@ -4,7 +4,7 @@ import _ from 'lodash';
|
|
4
4
|
import isDocker from 'is-docker';
|
5
5
|
import ciEnv from 'ci-info';
|
6
6
|
import tsUtils from '@strapi/typescript-utils';
|
7
|
-
import {
|
7
|
+
import { generateInstallId, env } from '@strapi/utils';
|
8
8
|
import { generateAdminUserHash } from './admin-user-hash.mjs';
|
9
9
|
|
10
10
|
const defaultQueryOpts = {
|
@@ -23,8 +23,8 @@ const ANALYTICS_URI = 'https://analytics.strapi.io';
|
|
23
23
|
/**
|
24
24
|
* Create a send function for event with all the necessary metadata
|
25
25
|
*/ var createSender = ((strapi)=>{
|
26
|
-
const { uuid } = strapi.config;
|
27
|
-
const
|
26
|
+
const { uuid, installId: installIdFromPackageJson } = strapi.config;
|
27
|
+
const installId = generateInstallId(uuid, installIdFromPackageJson);
|
28
28
|
const serverRootPath = strapi.dirs.app.root;
|
29
29
|
const adminRootPath = path.join(strapi.dirs.app.root, 'src', 'admin');
|
30
30
|
const anonymousUserProperties = {
|
@@ -52,7 +52,7 @@ const ANALYTICS_URI = 'https://analytics.strapi.io';
|
|
52
52
|
body: JSON.stringify({
|
53
53
|
event,
|
54
54
|
userId,
|
55
|
-
|
55
|
+
installId,
|
56
56
|
eventProperties: payload.eventProperties,
|
57
57
|
userProperties: userId ? {
|
58
58
|
...anonymousUserProperties,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sender.mjs","sources":["../../../src/services/metrics/sender.ts"],"sourcesContent":["import os from 'os';\nimport path from 'path';\nimport _ from 'lodash';\nimport isDocker from 'is-docker';\nimport ciEnv from 'ci-info';\nimport tsUtils from '@strapi/typescript-utils';\nimport { env,
|
1
|
+
{"version":3,"file":"sender.mjs","sources":["../../../src/services/metrics/sender.ts"],"sourcesContent":["import os from 'os';\nimport path from 'path';\nimport _ from 'lodash';\nimport isDocker from 'is-docker';\nimport ciEnv from 'ci-info';\nimport tsUtils from '@strapi/typescript-utils';\nimport { env, generateInstallId } from '@strapi/utils';\nimport type { Core } from '@strapi/types';\nimport { generateAdminUserHash } from './admin-user-hash';\n\nexport interface Payload {\n eventProperties?: Record<string, unknown>;\n userProperties?: Record<string, unknown>;\n groupProperties?: Record<string, unknown>;\n}\n\nexport type Sender = (\n event: string,\n payload?: Payload,\n opts?: Record<string, unknown>\n) => Promise<boolean>;\n\nconst defaultQueryOpts = {\n timeout: 1000,\n headers: { 'Content-Type': 'application/json' },\n};\n\nconst ANALYTICS_URI = 'https://analytics.strapi.io';\n\n/**\n * Add properties from the package.json strapi key in the metadata\n */\nconst addPackageJsonStrapiMetadata = (metadata: Record<string, unknown>, strapi: Core.Strapi) => {\n const { packageJsonStrapi = {} } = strapi.config;\n\n _.defaults(metadata, packageJsonStrapi);\n};\n\n/**\n * Create a send function for event with all the necessary metadata\n */\nexport default (strapi: Core.Strapi): Sender => {\n const { uuid, installId: installIdFromPackageJson } = strapi.config;\n\n const installId = generateInstallId(uuid, installIdFromPackageJson);\n\n const serverRootPath = strapi.dirs.app.root;\n const adminRootPath = path.join(strapi.dirs.app.root, 'src', 'admin');\n\n const anonymousUserProperties = {\n environment: strapi.config.environment,\n os: os.type(),\n osPlatform: os.platform(),\n osArch: os.arch(),\n osRelease: os.release(),\n nodeVersion: process.versions.node,\n };\n\n const anonymousGroupProperties = {\n docker: process.env.DOCKER || isDocker(),\n isCI: ciEnv.isCI,\n version: strapi.config.get('info.strapi'),\n useTypescriptOnServer: tsUtils.isUsingTypeScriptSync(serverRootPath),\n useTypescriptOnAdmin: tsUtils.isUsingTypeScriptSync(adminRootPath),\n projectId: uuid,\n isHostedOnStrapiCloud: env('STRAPI_HOSTING', null) === 'strapi.cloud',\n };\n\n addPackageJsonStrapiMetadata(anonymousGroupProperties, strapi);\n\n return async (event: string, payload: Payload = {}, opts = {}) => {\n const userId = generateAdminUserHash(strapi);\n\n const reqParams = {\n method: 'POST',\n body: JSON.stringify({\n event,\n userId,\n installId,\n eventProperties: payload.eventProperties,\n userProperties: userId ? { ...anonymousUserProperties, ...payload.userProperties } : {},\n groupProperties: {\n ...anonymousGroupProperties,\n projectType: strapi.EE ? 'Enterprise' : 'Community',\n ...payload.groupProperties,\n },\n }),\n ..._.merge({ headers: { 'X-Strapi-Event': event } }, defaultQueryOpts, opts),\n };\n\n try {\n const res = await strapi.fetch(`${ANALYTICS_URI}/api/v2/track`, reqParams);\n return res.ok;\n } catch (err) {\n return false;\n }\n };\n};\n"],"names":["defaultQueryOpts","timeout","headers","ANALYTICS_URI","addPackageJsonStrapiMetadata","metadata","strapi","packageJsonStrapi","config","_","defaults","uuid","installId","installIdFromPackageJson","generateInstallId","serverRootPath","dirs","app","root","adminRootPath","path","join","anonymousUserProperties","environment","os","type","osPlatform","platform","osArch","arch","osRelease","release","nodeVersion","process","versions","node","anonymousGroupProperties","docker","env","DOCKER","isDocker","isCI","ciEnv","version","get","useTypescriptOnServer","tsUtils","isUsingTypeScriptSync","useTypescriptOnAdmin","projectId","isHostedOnStrapiCloud","event","payload","opts","userId","generateAdminUserHash","reqParams","method","body","JSON","stringify","eventProperties","userProperties","groupProperties","projectType","EE","merge","res","fetch","ok","err"],"mappings":";;;;;;;;;AAsBA,MAAMA,gBAAmB,GAAA;IACvBC,OAAS,EAAA,IAAA;IACTC,OAAS,EAAA;QAAE,cAAgB,EAAA;AAAmB;AAChD,CAAA;AAEA,MAAMC,aAAgB,GAAA,6BAAA;AAEtB;;IAGA,MAAMC,4BAA+B,GAAA,CAACC,QAAmCC,EAAAA,MAAAA,GAAAA;AACvE,IAAA,MAAM,EAAEC,iBAAoB,GAAA,EAAE,EAAE,GAAGD,OAAOE,MAAM;IAEhDC,CAAEC,CAAAA,QAAQ,CAACL,QAAUE,EAAAA,iBAAAA,CAAAA;AACvB,CAAA;AAEA;;IAGA,mBAAe,CAAA,CAACD,MAAAA,GAAAA;IACd,MAAM,EAAEK,IAAI,EAAEC,SAAAA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0,0 +1,22 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var fp = require('lodash/fp');
|
4
|
+
|
5
|
+
const getNumberOfConditionalFields = ()=>{
|
6
|
+
const contentTypes = strapi.contentTypes;
|
7
|
+
const components = strapi.components;
|
8
|
+
const countConditionalFieldsInSchema = (schema)=>{
|
9
|
+
return fp.pipe(fp.map('attributes'), fp.flatMap(fp.values), fp.sumBy((attribute)=>{
|
10
|
+
if (attribute.conditions && typeof attribute.conditions === 'object') {
|
11
|
+
return 1;
|
12
|
+
}
|
13
|
+
return 0;
|
14
|
+
}))(schema);
|
15
|
+
};
|
16
|
+
const contentTypeCount = countConditionalFieldsInSchema(contentTypes);
|
17
|
+
const componentCount = countConditionalFieldsInSchema(components);
|
18
|
+
return contentTypeCount + componentCount;
|
19
|
+
};
|
20
|
+
|
21
|
+
module.exports = getNumberOfConditionalFields;
|
22
|
+
//# sourceMappingURL=conditional-fields.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"conditional-fields.js","sources":["../../../src/services/utils/conditional-fields.ts"],"sourcesContent":["import { map, values, sumBy, pipe, flatMap } from 'lodash/fp';\nimport type { Schema, UID } from '@strapi/types';\n\nconst getNumberOfConditionalFields = () => {\n const contentTypes: Record<UID.ContentType, Schema.ContentType> = strapi.contentTypes;\n const components: Record<UID.Component, Schema.Component> = strapi.components;\n\n const countConditionalFieldsInSchema = (\n schema: Record<string, Schema.ContentType | Schema.Component>\n ) => {\n return pipe(\n map('attributes'),\n flatMap(values),\n sumBy((attribute: Schema.Attribute.AnyAttribute) => {\n if (attribute.conditions && typeof attribute.conditions === 'object') {\n return 1;\n }\n return 0;\n })\n )(schema);\n };\n\n const contentTypeCount = countConditionalFieldsInSchema(contentTypes);\n const componentCount = countConditionalFieldsInSchema(components);\n\n return contentTypeCount + componentCount;\n};\n\nexport default getNumberOfConditionalFields;\n"],"names":["getNumberOfConditionalFields","contentTypes","strapi","components","countConditionalFieldsInSchema","schema","pipe","map","flatMap","values","sumBy","attribute","conditions","contentTypeCount","componentCount"],"mappings":";;;;AAGA,MAAMA,4BAA+B,GAAA,IAAA;IACnC,MAAMC,YAAAA,GAA4DC,OAAOD,YAAY;IACrF,MAAME,UAAAA,GAAsDD,OAAOC,UAAU;AAE7E,IAAA,MAAMC,iCAAiC,CACrCC,MAAAA,GAAAA;AAEA,QAAA,OAAOC,QACLC,MAAI,CAAA,YAAA,CAAA,EACJC,UAAQC,CAAAA,SAAAA,CAAAA,EACRC,SAAM,CAACC,SAAAA,GAAAA;AACL,YAAA,IAAIA,UAAUC,UAAU,IAAI,OAAOD,SAAUC,CAAAA,UAAU,KAAK,QAAU,EAAA;gBACpE,OAAO,CAAA;AACT;YACA,OAAO,CAAA;SAETP,CAAAA,CAAAA,CAAAA,MAAAA,CAAAA;AACJ,KAAA;AAEA,IAAA,MAAMQ,mBAAmBT,8BAA+BH,CAAAA,YAAAA,CAAAA;AACxD,IAAA,MAAMa,iBAAiBV,8BAA+BD,CAAAA,UAAAA,CAAAA;AAEtD,IAAA,OAAOU,gBAAmBC,GAAAA,cAAAA;AAC5B;;;;"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { pipe, map, flatMap, values, sumBy } from 'lodash/fp';
|
2
|
+
|
3
|
+
const getNumberOfConditionalFields = ()=>{
|
4
|
+
const contentTypes = strapi.contentTypes;
|
5
|
+
const components = strapi.components;
|
6
|
+
const countConditionalFieldsInSchema = (schema)=>{
|
7
|
+
return pipe(map('attributes'), flatMap(values), sumBy((attribute)=>{
|
8
|
+
if (attribute.conditions && typeof attribute.conditions === 'object') {
|
9
|
+
return 1;
|
10
|
+
}
|
11
|
+
return 0;
|
12
|
+
}))(schema);
|
13
|
+
};
|
14
|
+
const contentTypeCount = countConditionalFieldsInSchema(contentTypes);
|
15
|
+
const componentCount = countConditionalFieldsInSchema(components);
|
16
|
+
return contentTypeCount + componentCount;
|
17
|
+
};
|
18
|
+
|
19
|
+
export { getNumberOfConditionalFields as default };
|
20
|
+
//# sourceMappingURL=conditional-fields.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"conditional-fields.mjs","sources":["../../../src/services/utils/conditional-fields.ts"],"sourcesContent":["import { map, values, sumBy, pipe, flatMap } from 'lodash/fp';\nimport type { Schema, UID } from '@strapi/types';\n\nconst getNumberOfConditionalFields = () => {\n const contentTypes: Record<UID.ContentType, Schema.ContentType> = strapi.contentTypes;\n const components: Record<UID.Component, Schema.Component> = strapi.components;\n\n const countConditionalFieldsInSchema = (\n schema: Record<string, Schema.ContentType | Schema.Component>\n ) => {\n return pipe(\n map('attributes'),\n flatMap(values),\n sumBy((attribute: Schema.Attribute.AnyAttribute) => {\n if (attribute.conditions && typeof attribute.conditions === 'object') {\n return 1;\n }\n return 0;\n })\n )(schema);\n };\n\n const contentTypeCount = countConditionalFieldsInSchema(contentTypes);\n const componentCount = countConditionalFieldsInSchema(components);\n\n return contentTypeCount + componentCount;\n};\n\nexport default getNumberOfConditionalFields;\n"],"names":["getNumberOfConditionalFields","contentTypes","strapi","components","countConditionalFieldsInSchema","schema","pipe","map","flatMap","values","sumBy","attribute","conditions","contentTypeCount","componentCount"],"mappings":";;AAGA,MAAMA,4BAA+B,GAAA,IAAA;IACnC,MAAMC,YAAAA,GAA4DC,OAAOD,YAAY;IACrF,MAAME,UAAAA,GAAsDD,OAAOC,UAAU;AAE7E,IAAA,MAAMC,iCAAiC,CACrCC,MAAAA,GAAAA;AAEA,QAAA,OAAOC,KACLC,GAAI,CAAA,YAAA,CAAA,EACJC,OAAQC,CAAAA,MAAAA,CAAAA,EACRC,MAAM,CAACC,SAAAA,GAAAA;AACL,YAAA,IAAIA,UAAUC,UAAU,IAAI,OAAOD,SAAUC,CAAAA,UAAU,KAAK,QAAU,EAAA;gBACpE,OAAO,CAAA;AACT;YACA,OAAO,CAAA;SAETP,CAAAA,CAAAA,CAAAA,MAAAA,CAAAA;AACJ,KAAA;AAEA,IAAA,MAAMQ,mBAAmBT,8BAA+BH,CAAAA,YAAAA,CAAAA;AACxD,IAAA,MAAMa,iBAAiBV,8BAA+BD,CAAAA,UAAAA,CAAAA;AAEtD,IAAA,OAAOU,gBAAmBC,GAAAA,cAAAA;AAC5B;;;;"}
|
package/dist/utils/fetch.d.ts
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
import type { Core, Modules } from '@strapi/types';
|
2
|
-
|
2
|
+
interface StrapiFetchOptions {
|
3
|
+
logs?: boolean;
|
4
|
+
}
|
5
|
+
export declare const createStrapiFetch: (strapi: Core.Strapi, options?: StrapiFetchOptions) => Modules.Fetch.Fetch;
|
3
6
|
export type Fetch = Modules.Fetch.Fetch;
|
7
|
+
export {};
|
4
8
|
//# sourceMappingURL=fetch.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/utils/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/utils/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAKnD,UAAU,kBAAkB;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,eAAO,MAAM,iBAAiB,WACpB,KAAK,MAAM,YACT,kBAAkB,KAC3B,aAAa,MA4Bf,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC"}
|
package/dist/utils/fetch.js
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
var undici = require('undici');
|
4
4
|
|
5
|
-
// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici
|
6
5
|
// Create a wrapper for Node's Fetch API that applies a global proxy
|
7
|
-
const createStrapiFetch = (strapi)=>{
|
6
|
+
const createStrapiFetch = (strapi, options)=>{
|
7
|
+
const { logs = true } = options ?? {};
|
8
8
|
function strapiFetch(url, options) {
|
9
9
|
const fetchOptions = {
|
10
10
|
...strapiFetch.dispatcher ? {
|
@@ -12,12 +12,16 @@ const createStrapiFetch = (strapi)=>{
|
|
12
12
|
} : {},
|
13
13
|
...options
|
14
14
|
};
|
15
|
-
|
15
|
+
if (logs) {
|
16
|
+
strapi.log.debug(`Making request for ${url}`);
|
17
|
+
}
|
16
18
|
return fetch(url, fetchOptions);
|
17
19
|
}
|
18
20
|
const proxy = strapi.config.get('server.proxy.fetch') || strapi.config.get('server.proxy.global');
|
19
21
|
if (proxy) {
|
20
|
-
|
22
|
+
if (logs) {
|
23
|
+
strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);
|
24
|
+
}
|
21
25
|
strapiFetch.dispatcher = new undici.ProxyAgent(proxy);
|
22
26
|
}
|
23
27
|
return strapiFetch;
|
package/dist/utils/fetch.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetch.js","sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { ProxyAgent } from 'undici';\n\n// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici\n\n// Create a wrapper for Node's Fetch API that applies a global proxy\nexport const createStrapiFetch = (strapi: Core.Strapi): Modules.Fetch.Fetch => {\n function strapiFetch(url: RequestInfo | URL, options?: RequestInit) {\n const fetchOptions = {\n ...(strapiFetch.dispatcher ? { dispatcher: strapiFetch.dispatcher } : {}),\n ...options,\n };\n strapi.log.debug(`Making request for ${url}`);\n return fetch(url, fetchOptions);\n }\n\n const proxy =\n strapi.config.get<ConstructorParameters<typeof ProxyAgent>[0]>('server.proxy.fetch') ||\n strapi.config.get<string>('server.proxy.global');\n\n if (proxy) {\n strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);\n strapiFetch.dispatcher = new ProxyAgent(proxy);\n }\n\n return strapiFetch;\n};\n\nexport type Fetch = Modules.Fetch.Fetch;\n"],"names":["createStrapiFetch","strapi","
|
1
|
+
{"version":3,"file":"fetch.js","sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { ProxyAgent } from 'undici';\n\n// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici\n\ninterface StrapiFetchOptions {\n logs?: boolean;\n}\n\n// Create a wrapper for Node's Fetch API that applies a global proxy\nexport const createStrapiFetch = (\n strapi: Core.Strapi,\n options?: StrapiFetchOptions\n): Modules.Fetch.Fetch => {\n const { logs = true } = options ?? {};\n\n function strapiFetch(url: RequestInfo | URL, options?: RequestInit) {\n const fetchOptions = {\n ...(strapiFetch.dispatcher ? { dispatcher: strapiFetch.dispatcher } : {}),\n ...options,\n };\n\n if (logs) {\n strapi.log.debug(`Making request for ${url}`);\n }\n\n return fetch(url, fetchOptions);\n }\n\n const proxy =\n strapi.config.get<ConstructorParameters<typeof ProxyAgent>[0]>('server.proxy.fetch') ||\n strapi.config.get<string>('server.proxy.global');\n\n if (proxy) {\n if (logs) {\n strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);\n }\n strapiFetch.dispatcher = new ProxyAgent(proxy);\n }\n\n return strapiFetch;\n};\n\nexport type Fetch = Modules.Fetch.Fetch;\n"],"names":["createStrapiFetch","strapi","options","logs","strapiFetch","url","fetchOptions","dispatcher","log","debug","fetch","proxy","config","get","info","ProxyAgent"],"mappings":";;;;AASA;AACO,MAAMA,iBAAoB,GAAA,CAC/BC,MACAC,EAAAA,OAAAA,GAAAA;AAEA,IAAA,MAAM,EAAEC,IAAO,GAAA,IAAI,EAAE,GAAGD,WAAW,EAAC;IAEpC,SAASE,WAAAA,CAAYC,GAAsB,EAAEH,OAAqB,EAAA;AAChE,QAAA,MAAMI,YAAe,GAAA;YACnB,GAAIF,WAAAA,CAAYG,UAAU,GAAG;AAAEA,gBAAAA,UAAAA,EAAYH,YAAYG;AAAW,aAAA,GAAI,EAAE;AACxE,YAAA,GAAGL;AACL,SAAA;AAEA,QAAA,IAAIC,IAAM,EAAA;YACRF,MAAOO,CAAAA,GAAG,CAACC,KAAK,CAAC,CAAC,mBAAmB,EAAEJ,IAAI,CAAC,CAAA;AAC9C;AAEA,QAAA,OAAOK,MAAML,GAAKC,EAAAA,YAAAA,CAAAA;AACpB;IAEA,MAAMK,KAAAA,GACJV,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAA8C,oBAAA,CAAA,IAC/DZ,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAAS,qBAAA,CAAA;AAE5B,IAAA,IAAIF,KAAO,EAAA;AACT,QAAA,IAAIR,IAAM,EAAA;YACRF,MAAOO,CAAAA,GAAG,CAACM,IAAI,CAAC,CAAC,gCAAgC,EAAEH,MAAM,CAAC,CAAA;AAC5D;QACAP,WAAYG,CAAAA,UAAU,GAAG,IAAIQ,iBAAWJ,CAAAA,KAAAA,CAAAA;AAC1C;IAEA,OAAOP,WAAAA;AACT;;;;"}
|
package/dist/utils/fetch.mjs
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { ProxyAgent } from 'undici';
|
2
2
|
|
3
|
-
// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici
|
4
3
|
// Create a wrapper for Node's Fetch API that applies a global proxy
|
5
|
-
const createStrapiFetch = (strapi)=>{
|
4
|
+
const createStrapiFetch = (strapi, options)=>{
|
5
|
+
const { logs = true } = options ?? {};
|
6
6
|
function strapiFetch(url, options) {
|
7
7
|
const fetchOptions = {
|
8
8
|
...strapiFetch.dispatcher ? {
|
@@ -10,12 +10,16 @@ const createStrapiFetch = (strapi)=>{
|
|
10
10
|
} : {},
|
11
11
|
...options
|
12
12
|
};
|
13
|
-
|
13
|
+
if (logs) {
|
14
|
+
strapi.log.debug(`Making request for ${url}`);
|
15
|
+
}
|
14
16
|
return fetch(url, fetchOptions);
|
15
17
|
}
|
16
18
|
const proxy = strapi.config.get('server.proxy.fetch') || strapi.config.get('server.proxy.global');
|
17
19
|
if (proxy) {
|
18
|
-
|
20
|
+
if (logs) {
|
21
|
+
strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);
|
22
|
+
}
|
19
23
|
strapiFetch.dispatcher = new ProxyAgent(proxy);
|
20
24
|
}
|
21
25
|
return strapiFetch;
|
package/dist/utils/fetch.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetch.mjs","sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { ProxyAgent } from 'undici';\n\n// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici\n\n// Create a wrapper for Node's Fetch API that applies a global proxy\nexport const createStrapiFetch = (strapi: Core.Strapi): Modules.Fetch.Fetch => {\n function strapiFetch(url: RequestInfo | URL, options?: RequestInit) {\n const fetchOptions = {\n ...(strapiFetch.dispatcher ? { dispatcher: strapiFetch.dispatcher } : {}),\n ...options,\n };\n strapi.log.debug(`Making request for ${url}`);\n return fetch(url, fetchOptions);\n }\n\n const proxy =\n strapi.config.get<ConstructorParameters<typeof ProxyAgent>[0]>('server.proxy.fetch') ||\n strapi.config.get<string>('server.proxy.global');\n\n if (proxy) {\n strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);\n strapiFetch.dispatcher = new ProxyAgent(proxy);\n }\n\n return strapiFetch;\n};\n\nexport type Fetch = Modules.Fetch.Fetch;\n"],"names":["createStrapiFetch","strapi","
|
1
|
+
{"version":3,"file":"fetch.mjs","sources":["../../src/utils/fetch.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { ProxyAgent } from 'undici';\n\n// TODO: once core Node exposes a stable way to create a ProxyAgent we will use that instead of undici\n\ninterface StrapiFetchOptions {\n logs?: boolean;\n}\n\n// Create a wrapper for Node's Fetch API that applies a global proxy\nexport const createStrapiFetch = (\n strapi: Core.Strapi,\n options?: StrapiFetchOptions\n): Modules.Fetch.Fetch => {\n const { logs = true } = options ?? {};\n\n function strapiFetch(url: RequestInfo | URL, options?: RequestInit) {\n const fetchOptions = {\n ...(strapiFetch.dispatcher ? { dispatcher: strapiFetch.dispatcher } : {}),\n ...options,\n };\n\n if (logs) {\n strapi.log.debug(`Making request for ${url}`);\n }\n\n return fetch(url, fetchOptions);\n }\n\n const proxy =\n strapi.config.get<ConstructorParameters<typeof ProxyAgent>[0]>('server.proxy.fetch') ||\n strapi.config.get<string>('server.proxy.global');\n\n if (proxy) {\n if (logs) {\n strapi.log.info(`Using proxy for Fetch requests: ${proxy}`);\n }\n strapiFetch.dispatcher = new ProxyAgent(proxy);\n }\n\n return strapiFetch;\n};\n\nexport type Fetch = Modules.Fetch.Fetch;\n"],"names":["createStrapiFetch","strapi","options","logs","strapiFetch","url","fetchOptions","dispatcher","log","debug","fetch","proxy","config","get","info","ProxyAgent"],"mappings":";;AASA;AACO,MAAMA,iBAAoB,GAAA,CAC/BC,MACAC,EAAAA,OAAAA,GAAAA;AAEA,IAAA,MAAM,EAAEC,IAAO,GAAA,IAAI,EAAE,GAAGD,WAAW,EAAC;IAEpC,SAASE,WAAAA,CAAYC,GAAsB,EAAEH,OAAqB,EAAA;AAChE,QAAA,MAAMI,YAAe,GAAA;YACnB,GAAIF,WAAAA,CAAYG,UAAU,GAAG;AAAEA,gBAAAA,UAAAA,EAAYH,YAAYG;AAAW,aAAA,GAAI,EAAE;AACxE,YAAA,GAAGL;AACL,SAAA;AAEA,QAAA,IAAIC,IAAM,EAAA;YACRF,MAAOO,CAAAA,GAAG,CAACC,KAAK,CAAC,CAAC,mBAAmB,EAAEJ,IAAI,CAAC,CAAA;AAC9C;AAEA,QAAA,OAAOK,MAAML,GAAKC,EAAAA,YAAAA,CAAAA;AACpB;IAEA,MAAMK,KAAAA,GACJV,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAA8C,oBAAA,CAAA,IAC/DZ,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAAS,qBAAA,CAAA;AAE5B,IAAA,IAAIF,KAAO,EAAA;AACT,QAAA,IAAIR,IAAM,EAAA;YACRF,MAAOO,CAAAA,GAAG,CAACM,IAAI,CAAC,CAAC,gCAAgC,EAAEH,MAAM,CAAC,CAAA;AAC5D;QACAP,WAAYG,CAAAA,UAAU,GAAG,IAAIQ,UAAWJ,CAAAA,KAAAA,CAAAA;AAC1C;IAEA,OAAOP,WAAAA;AACT;;;;"}
|