node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

8
server/node_modules/@strapi/utils/dist/async.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
type AnyFunc<TA extends any[] = any[], TR = any> = (...args: TA) => TR;
type MakeProm<T> = Promise<T extends PromiseLike<infer I> ? I : T>;
type PipeReturn<F extends AnyFunc[]> = MakeProm<ReturnType<F[0]>>;
export declare function pipe<T extends AnyFunc[]>(...fns: PipeReturn<T> extends never ? never : T): (...args: Parameters<T[0]>) => PipeReturn<T>;
export declare const map: (...args: any[]) => any;
export declare const reduce: (mixedArray: any[]) => <T>(iteratee: AnyFunc, initialValue?: T) => Promise<T | undefined>;
export {};
//# sourceMappingURL=async.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../src/async.ts"],"names":[],"mappings":"AAGA,KAAK,OAAO,CAAC,EAAE,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,EAAE,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC;AAEvE,KAAK,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAKnE,KAAK,UAAU,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAElE,wBAAgB,IAAI,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,GAAG,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,GAAG,CAAC,gDAYxF;AAED,eAAO,MAAM,GAAG,yBAAc,CAAC;AAE/B,eAAO,MAAM,MAAM,eACJ,GAAG,EAAE,mBACE,OAAO,iBAAiB,CAAC,2BAM5C,CAAC"}

28
server/node_modules/@strapi/utils/dist/async.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
'use strict';
var pMap = require('p-map');
var fp = require('lodash/fp');
function pipe(...fns) {
const [firstFn, ...fnRest] = fns;
return async (...args)=>{
let res = await firstFn.apply(firstFn, args);
for(let i = 0; i < fnRest.length; i += 1){
res = await fnRest[i](res);
}
return res;
};
}
const map = fp.curry(pMap);
const reduce = (mixedArray)=>async (iteratee, initialValue)=>{
let acc = initialValue;
for(let i = 0; i < mixedArray.length; i += 1){
acc = await iteratee(acc, await mixedArray[i], i);
}
return acc;
};
exports.map = map;
exports.pipe = pipe;
exports.reduce = reduce;
//# sourceMappingURL=async.js.map

1
server/node_modules/@strapi/utils/dist/async.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"async.js","sources":["../src/async.ts"],"sourcesContent":["import pMap from 'p-map';\nimport { curry } from 'lodash/fp';\n\ntype AnyFunc<TA extends any[] = any[], TR = any> = (...args: TA) => TR;\n\ntype MakeProm<T> = Promise<T extends PromiseLike<infer I> ? I : T>;\n\ntype PipedFunc<T extends AnyFunc[]> =\n PipeReturn<T> extends never ? never : (...args: Parameters<T[0]>) => PipeReturn<T>;\n\ntype PipeReturn<F extends AnyFunc[]> = MakeProm<ReturnType<F[0]>>;\n\nexport function pipe<T extends AnyFunc[]>(...fns: PipeReturn<T> extends never ? never : T) {\n const [firstFn, ...fnRest] = fns;\n\n return (async (...args: any[]) => {\n let res = await firstFn.apply(firstFn, args);\n\n for (let i = 0; i < fnRest.length; i += 1) {\n res = await fnRest[i](res);\n }\n\n return res;\n }) as PipedFunc<T>;\n}\n\nexport const map = curry(pMap);\n\nexport const reduce =\n (mixedArray: any[]) =>\n async <T>(iteratee: AnyFunc, initialValue?: T) => {\n let acc = initialValue;\n for (let i = 0; i < mixedArray.length; i += 1) {\n acc = await iteratee(acc, await mixedArray[i], i);\n }\n return acc;\n };\n"],"names":["pipe","fns","firstFn","fnRest","args","res","apply","i","length","map","curry","pMap","reduce","mixedArray","iteratee","initialValue","acc"],"mappings":";;;;;AAYO,SAASA,IAA0B,CAAA,GAAGC,GAA4C,EAAA;AACvF,IAAA,MAAM,CAACC,OAAAA,EAAS,GAAGC,MAAAA,CAAO,GAAGF,GAAAA;AAE7B,IAAA,OAAQ,OAAO,GAAGG,IAAAA,GAAAA;AAChB,QAAA,IAAIC,GAAM,GAAA,MAAMH,OAAQI,CAAAA,KAAK,CAACJ,OAASE,EAAAA,IAAAA,CAAAA;QAEvC,IAAK,IAAIG,IAAI,CAAGA,EAAAA,CAAAA,GAAIJ,OAAOK,MAAM,EAAED,KAAK,CAAG,CAAA;AACzCF,YAAAA,GAAAA,GAAM,MAAMF,MAAM,CAACI,CAAAA,CAAE,CAACF,GAAAA,CAAAA;AACxB;QAEA,OAAOA,GAAAA;AACT,KAAA;AACF;AAEO,MAAMI,GAAMC,GAAAA,QAAAA,CAAMC,IAAM;AAElBC,MAAAA,MAAAA,GACX,CAACC,UAAAA,GACD,OAAUC,QAAmBC,EAAAA,YAAAA,GAAAA;AAC3B,QAAA,IAAIC,GAAMD,GAAAA,YAAAA;QACV,IAAK,IAAIR,IAAI,CAAGA,EAAAA,CAAAA,GAAIM,WAAWL,MAAM,EAAED,KAAK,CAAG,CAAA;AAC7CS,YAAAA,GAAAA,GAAM,MAAMF,QAASE,CAAAA,GAAAA,EAAK,MAAMH,UAAU,CAACN,EAAE,EAAEA,CAAAA,CAAAA;AACjD;QACA,OAAOS,GAAAA;;;;;;;"}

24
server/node_modules/@strapi/utils/dist/async.mjs generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import pMap from 'p-map';
import { curry } from 'lodash/fp';
function pipe(...fns) {
const [firstFn, ...fnRest] = fns;
return async (...args)=>{
let res = await firstFn.apply(firstFn, args);
for(let i = 0; i < fnRest.length; i += 1){
res = await fnRest[i](res);
}
return res;
};
}
const map = curry(pMap);
const reduce = (mixedArray)=>async (iteratee, initialValue)=>{
let acc = initialValue;
for(let i = 0; i < mixedArray.length; i += 1){
acc = await iteratee(acc, await mixedArray[i], i);
}
return acc;
};
export { map, pipe, reduce };
//# sourceMappingURL=async.mjs.map

1
server/node_modules/@strapi/utils/dist/async.mjs.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"async.mjs","sources":["../src/async.ts"],"sourcesContent":["import pMap from 'p-map';\nimport { curry } from 'lodash/fp';\n\ntype AnyFunc<TA extends any[] = any[], TR = any> = (...args: TA) => TR;\n\ntype MakeProm<T> = Promise<T extends PromiseLike<infer I> ? I : T>;\n\ntype PipedFunc<T extends AnyFunc[]> =\n PipeReturn<T> extends never ? never : (...args: Parameters<T[0]>) => PipeReturn<T>;\n\ntype PipeReturn<F extends AnyFunc[]> = MakeProm<ReturnType<F[0]>>;\n\nexport function pipe<T extends AnyFunc[]>(...fns: PipeReturn<T> extends never ? never : T) {\n const [firstFn, ...fnRest] = fns;\n\n return (async (...args: any[]) => {\n let res = await firstFn.apply(firstFn, args);\n\n for (let i = 0; i < fnRest.length; i += 1) {\n res = await fnRest[i](res);\n }\n\n return res;\n }) as PipedFunc<T>;\n}\n\nexport const map = curry(pMap);\n\nexport const reduce =\n (mixedArray: any[]) =>\n async <T>(iteratee: AnyFunc, initialValue?: T) => {\n let acc = initialValue;\n for (let i = 0; i < mixedArray.length; i += 1) {\n acc = await iteratee(acc, await mixedArray[i], i);\n }\n return acc;\n };\n"],"names":["pipe","fns","firstFn","fnRest","args","res","apply","i","length","map","curry","pMap","reduce","mixedArray","iteratee","initialValue","acc"],"mappings":";;;AAYO,SAASA,IAA0B,CAAA,GAAGC,GAA4C,EAAA;AACvF,IAAA,MAAM,CAACC,OAAAA,EAAS,GAAGC,MAAAA,CAAO,GAAGF,GAAAA;AAE7B,IAAA,OAAQ,OAAO,GAAGG,IAAAA,GAAAA;AAChB,QAAA,IAAIC,GAAM,GAAA,MAAMH,OAAQI,CAAAA,KAAK,CAACJ,OAASE,EAAAA,IAAAA,CAAAA;QAEvC,IAAK,IAAIG,IAAI,CAAGA,EAAAA,CAAAA,GAAIJ,OAAOK,MAAM,EAAED,KAAK,CAAG,CAAA;AACzCF,YAAAA,GAAAA,GAAM,MAAMF,MAAM,CAACI,CAAAA,CAAE,CAACF,GAAAA,CAAAA;AACxB;QAEA,OAAOA,GAAAA;AACT,KAAA;AACF;AAEO,MAAMI,GAAMC,GAAAA,KAAAA,CAAMC,IAAM;AAElBC,MAAAA,MAAAA,GACX,CAACC,UAAAA,GACD,OAAUC,QAAmBC,EAAAA,YAAAA,GAAAA;AAC3B,QAAA,IAAIC,GAAMD,GAAAA,YAAAA;QACV,IAAK,IAAIR,IAAI,CAAGA,EAAAA,CAAAA,GAAIM,WAAWL,MAAM,EAAED,KAAK,CAAG,CAAA;AAC7CS,YAAAA,GAAAA,GAAM,MAAMF,QAASE,CAAAA,GAAAA,EAAK,MAAMH,UAAU,CAACN,EAAE,EAAEA,CAAAA,CAAAA;AACjD;QACA,OAAOS,GAAAA;;;;;"}

View File

@@ -0,0 +1,71 @@
import type { Model, Kind, Attribute, RelationalAttribute, ComponentAttribute, DynamicZoneAttribute, WithRequired } from './types';
declare const constants: {
ID_ATTRIBUTE: string;
DOC_ID_ATTRIBUTE: string;
PUBLISHED_AT_ATTRIBUTE: string;
CREATED_BY_ATTRIBUTE: string;
UPDATED_BY_ATTRIBUTE: string;
CREATED_AT_ATTRIBUTE: string;
UPDATED_AT_ATTRIBUTE: string;
SINGLE_TYPE: string;
COLLECTION_TYPE: string;
};
declare const getTimestamps: (model: Model) => string[];
declare const getCreatorFields: (model: Model) => string[];
declare const getNonWritableAttributes: (model: Model) => string[];
declare const getWritableAttributes: (model: Model) => string[];
declare const isWritableAttribute: (model: Model, attributeName: string) => boolean;
declare const getNonVisibleAttributes: (model: Model) => string[];
declare const getVisibleAttributes: (model: Model) => string[];
declare const isVisibleAttribute: (model: Model, attributeName: string) => boolean;
declare const getOptions: (model: Model) => {
draftAndPublish: boolean;
} | ({
draftAndPublish: boolean;
} & {
populateCreatorFields?: boolean | undefined;
draftAndPublish?: boolean | undefined;
});
declare const hasDraftAndPublish: (model: Model) => boolean;
declare const isDraft: <T extends object>(data: T, model: Model) => boolean;
declare const isSchema: (data: unknown) => data is Model;
declare const isComponentSchema: (data: unknown) => data is Model & {
modelType: 'component';
};
declare const isContentTypeSchema: (data: unknown) => data is Model & {
modelType: 'contentType';
};
declare const isSingleType: ({ kind }: {
kind?: string | undefined;
}) => boolean;
declare const isCollectionType: ({ kind }: {
kind?: string | undefined;
}) => boolean;
declare const isKind: (kind: Kind) => (model: Model) => boolean;
declare const getPrivateAttributes: (model: Model) => string[];
declare const isPrivateAttribute: (model: Model, attributeName: string) => boolean;
declare const isScalarAttribute: (attribute?: Attribute) => boolean | undefined;
declare const getDoesAttributeRequireValidation: (attribute: Attribute) => any;
declare const isMediaAttribute: (attribute?: Attribute) => boolean;
declare const isRelationalAttribute: (attribute?: Attribute) => attribute is RelationalAttribute;
declare const hasRelationReordering: (attribute?: Attribute) => boolean;
declare const isComponentAttribute: (attribute: Attribute) => attribute is ComponentAttribute | DynamicZoneAttribute;
declare const isDynamicZoneAttribute: (attribute?: Attribute) => attribute is DynamicZoneAttribute;
declare const isMorphToRelationalAttribute: (attribute?: Attribute) => boolean;
declare const getComponentAttributes: (schema: Model) => string[];
declare const getScalarAttributes: (schema: Model) => string[];
declare const getRelationalAttributes: (schema: Model) => string[];
/**
* Checks if an attribute is of type `type`
* @param {object} attribute
* @param {string} type
*/
declare const isTypedAttribute: (attribute: Attribute, type: string) => boolean;
/**
* Returns a route prefix for a contentType
* @param {object} contentType
* @returns {string}
*/
declare const getContentTypeRoutePrefix: (contentType: WithRequired<Model, 'info'>) => string;
export { isSchema, isContentTypeSchema, isComponentSchema, isScalarAttribute, isMediaAttribute, isRelationalAttribute, hasRelationReordering, isComponentAttribute, isDynamicZoneAttribute, isMorphToRelationalAttribute, isTypedAttribute, getPrivateAttributes, isPrivateAttribute, constants, getNonWritableAttributes, getComponentAttributes, getScalarAttributes, getRelationalAttributes, getWritableAttributes, isWritableAttribute, getNonVisibleAttributes, getVisibleAttributes, getTimestamps, getCreatorFields, isVisibleAttribute, getOptions, isDraft, hasDraftAndPublish, isSingleType, isCollectionType, isKind, getContentTypeRoutePrefix, getDoesAttributeRequireValidation, };
//# sourceMappingURL=content-types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../src/content-types.ts"],"names":[],"mappings":"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"}

201
server/node_modules/@strapi/utils/dist/content-types.js generated vendored Normal file
View File

@@ -0,0 +1,201 @@
'use strict';
var _ = require('lodash');
var fp = require('lodash/fp');
const SINGLE_TYPE = 'singleType';
const COLLECTION_TYPE = 'collectionType';
const ID_ATTRIBUTE = 'id';
const DOC_ID_ATTRIBUTE = 'documentId';
const PUBLISHED_AT_ATTRIBUTE = 'publishedAt';
const CREATED_BY_ATTRIBUTE = 'createdBy';
const UPDATED_BY_ATTRIBUTE = 'updatedBy';
const CREATED_AT_ATTRIBUTE = 'createdAt';
const UPDATED_AT_ATTRIBUTE = 'updatedAt';
const constants = {
ID_ATTRIBUTE,
DOC_ID_ATTRIBUTE,
PUBLISHED_AT_ATTRIBUTE,
CREATED_BY_ATTRIBUTE,
UPDATED_BY_ATTRIBUTE,
CREATED_AT_ATTRIBUTE,
UPDATED_AT_ATTRIBUTE,
SINGLE_TYPE,
COLLECTION_TYPE
};
const getTimestamps = (model)=>{
const attributes = [];
if (fp.has(CREATED_AT_ATTRIBUTE, model.attributes)) {
attributes.push(CREATED_AT_ATTRIBUTE);
}
if (fp.has(UPDATED_AT_ATTRIBUTE, model.attributes)) {
attributes.push(UPDATED_AT_ATTRIBUTE);
}
return attributes;
};
const getCreatorFields = (model)=>{
const attributes = [];
if (fp.has(CREATED_BY_ATTRIBUTE, model.attributes)) {
attributes.push(CREATED_BY_ATTRIBUTE);
}
if (fp.has(UPDATED_BY_ATTRIBUTE, model.attributes)) {
attributes.push(UPDATED_BY_ATTRIBUTE);
}
return attributes;
};
const getNonWritableAttributes = (model)=>{
if (!model) return [];
const nonWritableAttributes = _.reduce(model.attributes, (acc, attr, attrName)=>attr.writable === false ? acc.concat(attrName) : acc, []);
return _.uniq([
ID_ATTRIBUTE,
DOC_ID_ATTRIBUTE,
...getTimestamps(model),
...nonWritableAttributes
]);
};
const getWritableAttributes = (model)=>{
if (!model) return [];
return _.difference(Object.keys(model.attributes), getNonWritableAttributes(model));
};
const isWritableAttribute = (model, attributeName)=>{
return getWritableAttributes(model).includes(attributeName);
};
const getNonVisibleAttributes = (model)=>{
const nonVisibleAttributes = _.reduce(model.attributes, (acc, attr, attrName)=>attr.visible === false ? acc.concat(attrName) : acc, []);
return _.uniq([
ID_ATTRIBUTE,
DOC_ID_ATTRIBUTE,
...getTimestamps(model),
...nonVisibleAttributes
]);
};
const getVisibleAttributes = (model)=>{
return _.difference(_.keys(model.attributes), getNonVisibleAttributes(model));
};
const isVisibleAttribute = (model, attributeName)=>{
return getVisibleAttributes(model).includes(attributeName);
};
const getOptions = (model)=>_.assign({
draftAndPublish: false
}, _.get(model, 'options', {}));
const hasDraftAndPublish = (model)=>_.get(model, 'options.draftAndPublish', false) === true;
const isDraft = (data, model)=>hasDraftAndPublish(model) && _.get(data, PUBLISHED_AT_ATTRIBUTE) === null;
const isSchema = (data)=>{
return typeof data === 'object' && data !== null && 'modelType' in data && typeof data.modelType === 'string' && [
'component',
'contentType'
].includes(data.modelType);
};
const isComponentSchema = (data)=>{
return isSchema(data) && data.modelType === 'component';
};
const isContentTypeSchema = (data)=>{
return isSchema(data) && data.modelType === 'contentType';
};
const isSingleType = ({ kind = COLLECTION_TYPE })=>kind === SINGLE_TYPE;
const isCollectionType = ({ kind = COLLECTION_TYPE })=>kind === COLLECTION_TYPE;
const isKind = (kind)=>(model)=>model.kind === kind;
const getStoredPrivateAttributes = (model)=>fp.union(strapi?.config?.get('api.responses.privateAttributes', []) ?? [], fp.getOr([], 'options.privateAttributes', model));
const getPrivateAttributes = (model)=>{
return _.union(getStoredPrivateAttributes(model), _.keys(_.pickBy(model.attributes, (attr)=>!!attr.private)));
};
const isPrivateAttribute = (model, attributeName)=>{
if (model?.attributes?.[attributeName]?.private === true) {
return true;
}
return getStoredPrivateAttributes(model).includes(attributeName);
};
const isScalarAttribute = (attribute)=>{
return attribute && ![
'media',
'component',
'relation',
'dynamiczone'
].includes(attribute.type);
};
const getDoesAttributeRequireValidation = (attribute)=>{
return attribute.required || attribute.unique || Object.prototype.hasOwnProperty.call(attribute, 'max') || Object.prototype.hasOwnProperty.call(attribute, 'min') || Object.prototype.hasOwnProperty.call(attribute, 'maxLength') || Object.prototype.hasOwnProperty.call(attribute, 'minLength');
};
const isMediaAttribute = (attribute)=>attribute?.type === 'media';
const isRelationalAttribute = (attribute)=>attribute?.type === 'relation';
const HAS_RELATION_REORDERING = [
'manyToMany',
'manyToOne',
'oneToMany'
];
const hasRelationReordering = (attribute)=>isRelationalAttribute(attribute) && HAS_RELATION_REORDERING.includes(attribute.relation);
const isComponentAttribute = (attribute)=>[
'component',
'dynamiczone'
].includes(attribute?.type);
const isDynamicZoneAttribute = (attribute)=>!!attribute && attribute.type === 'dynamiczone';
const isMorphToRelationalAttribute = (attribute)=>{
return !!attribute && isRelationalAttribute(attribute) && attribute.relation?.startsWith?.('morphTo');
};
const getComponentAttributes = (schema)=>{
return _.reduce(schema.attributes, (acc, attr, attrName)=>{
if (isComponentAttribute(attr)) acc.push(attrName);
return acc;
}, []);
};
const getScalarAttributes = (schema)=>{
return _.reduce(schema.attributes, (acc, attr, attrName)=>{
if (isScalarAttribute(attr)) acc.push(attrName);
return acc;
}, []);
};
const getRelationalAttributes = (schema)=>{
return _.reduce(schema.attributes, (acc, attr, attrName)=>{
if (isRelationalAttribute(attr)) acc.push(attrName);
return acc;
}, []);
};
/**
* Checks if an attribute is of type `type`
* @param {object} attribute
* @param {string} type
*/ const isTypedAttribute = (attribute, type)=>{
return _.has(attribute, 'type') && attribute.type === type;
};
/**
* Returns a route prefix for a contentType
* @param {object} contentType
* @returns {string}
*/ const getContentTypeRoutePrefix = (contentType)=>{
return isSingleType(contentType) ? _.kebabCase(contentType.info.singularName) : _.kebabCase(contentType.info.pluralName);
};
exports.constants = constants;
exports.getComponentAttributes = getComponentAttributes;
exports.getContentTypeRoutePrefix = getContentTypeRoutePrefix;
exports.getCreatorFields = getCreatorFields;
exports.getDoesAttributeRequireValidation = getDoesAttributeRequireValidation;
exports.getNonVisibleAttributes = getNonVisibleAttributes;
exports.getNonWritableAttributes = getNonWritableAttributes;
exports.getOptions = getOptions;
exports.getPrivateAttributes = getPrivateAttributes;
exports.getRelationalAttributes = getRelationalAttributes;
exports.getScalarAttributes = getScalarAttributes;
exports.getTimestamps = getTimestamps;
exports.getVisibleAttributes = getVisibleAttributes;
exports.getWritableAttributes = getWritableAttributes;
exports.hasDraftAndPublish = hasDraftAndPublish;
exports.hasRelationReordering = hasRelationReordering;
exports.isCollectionType = isCollectionType;
exports.isComponentAttribute = isComponentAttribute;
exports.isComponentSchema = isComponentSchema;
exports.isContentTypeSchema = isContentTypeSchema;
exports.isDraft = isDraft;
exports.isDynamicZoneAttribute = isDynamicZoneAttribute;
exports.isKind = isKind;
exports.isMediaAttribute = isMediaAttribute;
exports.isMorphToRelationalAttribute = isMorphToRelationalAttribute;
exports.isPrivateAttribute = isPrivateAttribute;
exports.isRelationalAttribute = isRelationalAttribute;
exports.isScalarAttribute = isScalarAttribute;
exports.isSchema = isSchema;
exports.isSingleType = isSingleType;
exports.isTypedAttribute = isTypedAttribute;
exports.isVisibleAttribute = isVisibleAttribute;
exports.isWritableAttribute = isWritableAttribute;
//# sourceMappingURL=content-types.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,167 @@
import ___default from 'lodash';
import { has, union, getOr } from 'lodash/fp';
const SINGLE_TYPE = 'singleType';
const COLLECTION_TYPE = 'collectionType';
const ID_ATTRIBUTE = 'id';
const DOC_ID_ATTRIBUTE = 'documentId';
const PUBLISHED_AT_ATTRIBUTE = 'publishedAt';
const CREATED_BY_ATTRIBUTE = 'createdBy';
const UPDATED_BY_ATTRIBUTE = 'updatedBy';
const CREATED_AT_ATTRIBUTE = 'createdAt';
const UPDATED_AT_ATTRIBUTE = 'updatedAt';
const constants = {
ID_ATTRIBUTE,
DOC_ID_ATTRIBUTE,
PUBLISHED_AT_ATTRIBUTE,
CREATED_BY_ATTRIBUTE,
UPDATED_BY_ATTRIBUTE,
CREATED_AT_ATTRIBUTE,
UPDATED_AT_ATTRIBUTE,
SINGLE_TYPE,
COLLECTION_TYPE
};
const getTimestamps = (model)=>{
const attributes = [];
if (has(CREATED_AT_ATTRIBUTE, model.attributes)) {
attributes.push(CREATED_AT_ATTRIBUTE);
}
if (has(UPDATED_AT_ATTRIBUTE, model.attributes)) {
attributes.push(UPDATED_AT_ATTRIBUTE);
}
return attributes;
};
const getCreatorFields = (model)=>{
const attributes = [];
if (has(CREATED_BY_ATTRIBUTE, model.attributes)) {
attributes.push(CREATED_BY_ATTRIBUTE);
}
if (has(UPDATED_BY_ATTRIBUTE, model.attributes)) {
attributes.push(UPDATED_BY_ATTRIBUTE);
}
return attributes;
};
const getNonWritableAttributes = (model)=>{
if (!model) return [];
const nonWritableAttributes = ___default.reduce(model.attributes, (acc, attr, attrName)=>attr.writable === false ? acc.concat(attrName) : acc, []);
return ___default.uniq([
ID_ATTRIBUTE,
DOC_ID_ATTRIBUTE,
...getTimestamps(model),
...nonWritableAttributes
]);
};
const getWritableAttributes = (model)=>{
if (!model) return [];
return ___default.difference(Object.keys(model.attributes), getNonWritableAttributes(model));
};
const isWritableAttribute = (model, attributeName)=>{
return getWritableAttributes(model).includes(attributeName);
};
const getNonVisibleAttributes = (model)=>{
const nonVisibleAttributes = ___default.reduce(model.attributes, (acc, attr, attrName)=>attr.visible === false ? acc.concat(attrName) : acc, []);
return ___default.uniq([
ID_ATTRIBUTE,
DOC_ID_ATTRIBUTE,
...getTimestamps(model),
...nonVisibleAttributes
]);
};
const getVisibleAttributes = (model)=>{
return ___default.difference(___default.keys(model.attributes), getNonVisibleAttributes(model));
};
const isVisibleAttribute = (model, attributeName)=>{
return getVisibleAttributes(model).includes(attributeName);
};
const getOptions = (model)=>___default.assign({
draftAndPublish: false
}, ___default.get(model, 'options', {}));
const hasDraftAndPublish = (model)=>___default.get(model, 'options.draftAndPublish', false) === true;
const isDraft = (data, model)=>hasDraftAndPublish(model) && ___default.get(data, PUBLISHED_AT_ATTRIBUTE) === null;
const isSchema = (data)=>{
return typeof data === 'object' && data !== null && 'modelType' in data && typeof data.modelType === 'string' && [
'component',
'contentType'
].includes(data.modelType);
};
const isComponentSchema = (data)=>{
return isSchema(data) && data.modelType === 'component';
};
const isContentTypeSchema = (data)=>{
return isSchema(data) && data.modelType === 'contentType';
};
const isSingleType = ({ kind = COLLECTION_TYPE })=>kind === SINGLE_TYPE;
const isCollectionType = ({ kind = COLLECTION_TYPE })=>kind === COLLECTION_TYPE;
const isKind = (kind)=>(model)=>model.kind === kind;
const getStoredPrivateAttributes = (model)=>union(strapi?.config?.get('api.responses.privateAttributes', []) ?? [], getOr([], 'options.privateAttributes', model));
const getPrivateAttributes = (model)=>{
return ___default.union(getStoredPrivateAttributes(model), ___default.keys(___default.pickBy(model.attributes, (attr)=>!!attr.private)));
};
const isPrivateAttribute = (model, attributeName)=>{
if (model?.attributes?.[attributeName]?.private === true) {
return true;
}
return getStoredPrivateAttributes(model).includes(attributeName);
};
const isScalarAttribute = (attribute)=>{
return attribute && ![
'media',
'component',
'relation',
'dynamiczone'
].includes(attribute.type);
};
const getDoesAttributeRequireValidation = (attribute)=>{
return attribute.required || attribute.unique || Object.prototype.hasOwnProperty.call(attribute, 'max') || Object.prototype.hasOwnProperty.call(attribute, 'min') || Object.prototype.hasOwnProperty.call(attribute, 'maxLength') || Object.prototype.hasOwnProperty.call(attribute, 'minLength');
};
const isMediaAttribute = (attribute)=>attribute?.type === 'media';
const isRelationalAttribute = (attribute)=>attribute?.type === 'relation';
const HAS_RELATION_REORDERING = [
'manyToMany',
'manyToOne',
'oneToMany'
];
const hasRelationReordering = (attribute)=>isRelationalAttribute(attribute) && HAS_RELATION_REORDERING.includes(attribute.relation);
const isComponentAttribute = (attribute)=>[
'component',
'dynamiczone'
].includes(attribute?.type);
const isDynamicZoneAttribute = (attribute)=>!!attribute && attribute.type === 'dynamiczone';
const isMorphToRelationalAttribute = (attribute)=>{
return !!attribute && isRelationalAttribute(attribute) && attribute.relation?.startsWith?.('morphTo');
};
const getComponentAttributes = (schema)=>{
return ___default.reduce(schema.attributes, (acc, attr, attrName)=>{
if (isComponentAttribute(attr)) acc.push(attrName);
return acc;
}, []);
};
const getScalarAttributes = (schema)=>{
return ___default.reduce(schema.attributes, (acc, attr, attrName)=>{
if (isScalarAttribute(attr)) acc.push(attrName);
return acc;
}, []);
};
const getRelationalAttributes = (schema)=>{
return ___default.reduce(schema.attributes, (acc, attr, attrName)=>{
if (isRelationalAttribute(attr)) acc.push(attrName);
return acc;
}, []);
};
/**
* Checks if an attribute is of type `type`
* @param {object} attribute
* @param {string} type
*/ const isTypedAttribute = (attribute, type)=>{
return ___default.has(attribute, 'type') && attribute.type === type;
};
/**
* Returns a route prefix for a contentType
* @param {object} contentType
* @returns {string}
*/ const getContentTypeRoutePrefix = (contentType)=>{
return isSingleType(contentType) ? ___default.kebabCase(contentType.info.singularName) : ___default.kebabCase(contentType.info.pluralName);
};
export { constants, getComponentAttributes, getContentTypeRoutePrefix, getCreatorFields, getDoesAttributeRequireValidation, getNonVisibleAttributes, getNonWritableAttributes, getOptions, getPrivateAttributes, getRelationalAttributes, getScalarAttributes, getTimestamps, getVisibleAttributes, getWritableAttributes, hasDraftAndPublish, hasRelationReordering, isCollectionType, isComponentAttribute, isComponentSchema, isContentTypeSchema, isDraft, isDynamicZoneAttribute, isKind, isMediaAttribute, isMorphToRelationalAttribute, isPrivateAttribute, isRelationalAttribute, isScalarAttribute, isSchema, isSingleType, isTypedAttribute, isVisibleAttribute, isWritableAttribute };
//# sourceMappingURL=content-types.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,82 @@
import { Model } from './types';
type SortOrder = 'asc' | 'desc';
export interface SortMap {
[key: string]: SortOrder | SortMap;
}
export interface SortParamsObject {
[key: string]: SortOrder | SortParamsObject;
}
type SortParams = string | string[] | SortParamsObject | SortParamsObject[];
type FieldsParams = string | string[];
type FiltersParams = unknown;
export interface PopulateAttributesParams {
[key: string]: boolean | PopulateObjectParams;
}
export interface PopulateObjectParams {
sort?: SortParams;
fields?: FieldsParams;
filters?: FiltersParams;
populate?: string | string[] | PopulateAttributesParams;
on?: PopulateAttributesParams;
count?: boolean;
ordering?: unknown;
_q?: string;
limit?: number | string;
start?: number | string;
page?: number | string;
pageSize?: number | string;
}
type PopulateParams = string | string[] | PopulateAttributesParams;
export interface Params {
sort?: SortParams;
fields?: FieldsParams;
filters?: FiltersParams;
populate?: PopulateParams;
count?: boolean;
ordering?: unknown;
_q?: string;
limit?: number | string;
start?: number | string;
page?: number | string;
pageSize?: number | string;
status?: 'draft' | 'published';
}
type FiltersQuery = (options: {
meta: Model;
}) => WhereQuery | undefined;
type OrderByQuery = SortMap | SortMap[];
type SelectQuery = string | string[];
export interface WhereQuery {
[key: string]: any;
}
type PopulateQuery = boolean | string[] | {
[key: string]: PopulateQuery;
};
export interface Query {
orderBy?: OrderByQuery;
select?: SelectQuery;
where?: WhereQuery;
filters?: FiltersQuery;
populate?: PopulateQuery;
count?: boolean;
ordering?: unknown;
_q?: string;
limit?: number;
offset?: number;
page?: number;
pageSize?: number;
}
interface TransformerOptions {
getModel: (uid: string) => Model | undefined;
}
declare const createTransformer: ({ getModel }: TransformerOptions) => {
private_convertSortQueryParams: (sortQuery: SortParams) => OrderByQuery;
private_convertStartQueryParams: (startQuery: unknown) => number;
private_convertLimitQueryParams: (limitQuery: unknown) => number | undefined;
private_convertPopulateQueryParams: (populate: PopulateParams, schema?: Model, depth?: number) => PopulateQuery;
private_convertFiltersQueryParams: (filters: FiltersParams, schema?: Model) => WhereQuery;
private_convertFieldsQueryParams: (fields: FieldsParams, schema?: Model, depth?: number) => SelectQuery | undefined;
transformQueryParams: (uid: string, params: Params) => Query;
};
export { createTransformer };
//# sourceMappingURL=convert-query-params.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"convert-query-params.d.ts","sourceRoot":"","sources":["../src/convert-query-params.ts"],"names":[],"mappings":"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"}

View File

@@ -0,0 +1,512 @@
'use strict';
var _ = require('lodash');
var fp = require('lodash/fp');
var contentTypes = require('./content-types.js');
var errors = require('./errors.js');
var operators = require('./operators.js');
var parseType = require('./parse-type.js');
const { ID_ATTRIBUTE, DOC_ID_ATTRIBUTE, PUBLISHED_AT_ATTRIBUTE } = contentTypes.constants;
class InvalidOrderError extends Error {
constructor(){
super();
this.message = 'Invalid order. order can only be one of asc|desc|ASC|DESC';
}
}
class InvalidSortError extends Error {
constructor(){
super();
this.message = 'Invalid sort parameter. Expected a string, an array of strings, a sort object or an array of sort objects';
}
}
function validateOrder(order) {
if (!fp.isString(order) || ![
'asc',
'desc'
].includes(order.toLocaleLowerCase())) {
throw new InvalidOrderError();
}
}
const convertCountQueryParams = (countQuery)=>{
return parseType({
type: 'boolean',
value: countQuery
});
};
const convertOrderingQueryParams = (ordering)=>{
return ordering;
};
const isPlainObject = (value)=>_.isPlainObject(value);
const isStringArray = (value)=>fp.isArray(value) && value.every(fp.isString);
const createTransformer = ({ getModel })=>{
/**
* Sort query parser
*/ const convertSortQueryParams = (sortQuery)=>{
if (typeof sortQuery === 'string') {
return convertStringSortQueryParam(sortQuery);
}
if (isStringArray(sortQuery)) {
return sortQuery.flatMap((sortValue)=>convertStringSortQueryParam(sortValue));
}
if (Array.isArray(sortQuery)) {
return sortQuery.map((sortValue)=>convertNestedSortQueryParam(sortValue));
}
if (isPlainObject(sortQuery)) {
return convertNestedSortQueryParam(sortQuery);
}
throw new InvalidSortError();
};
const convertStringSortQueryParam = (sortQuery)=>{
return sortQuery.split(',').map((value)=>convertSingleSortQueryParam(value));
};
const convertSingleSortQueryParam = (sortQuery)=>{
if (!sortQuery) {
return {};
}
if (!fp.isString(sortQuery)) {
throw new Error('Invalid sort query');
}
// split field and order param with default order to ascending
const [field, order = 'asc'] = sortQuery.split(':');
if (field.length === 0) {
throw new Error('Field cannot be empty');
}
validateOrder(order);
// TODO: field should be a valid path on an object model
return _.set({}, field, order);
};
const convertNestedSortQueryParam = (sortQuery)=>{
const transformedSort = {};
for (const field of Object.keys(sortQuery)){
const order = sortQuery[field];
// this is a deep sort
if (isPlainObject(order)) {
transformedSort[field] = convertNestedSortQueryParam(order);
} else if (typeof order === 'string') {
validateOrder(order);
transformedSort[field] = order;
} else {
throw Error(`Invalid sort type expected object or string got ${typeof order}`);
}
}
return transformedSort;
};
/**
* Start query parser
*/ const convertStartQueryParams = (startQuery)=>{
const startAsANumber = fp.toNumber(startQuery);
if (!_.isInteger(startAsANumber) || startAsANumber < 0) {
throw new Error(`convertStartQueryParams expected a positive integer got ${startAsANumber}`);
}
return startAsANumber;
};
/**
* Limit query parser
*/ const convertLimitQueryParams = (limitQuery)=>{
const limitAsANumber = fp.toNumber(limitQuery);
if (!_.isInteger(limitAsANumber) || limitAsANumber !== -1 && limitAsANumber < 0) {
throw new Error(`convertLimitQueryParams expected a positive integer got ${limitAsANumber}`);
}
if (limitAsANumber === -1) {
return undefined;
}
return limitAsANumber;
};
const convertPageQueryParams = (page)=>{
const pageVal = fp.toNumber(page);
if (!fp.isInteger(pageVal) || pageVal <= 0) {
throw new errors.PaginationError(`Invalid 'page' parameter. Expected an integer > 0, received: ${page}`);
}
return pageVal;
};
const convertPageSizeQueryParams = (pageSize, page)=>{
const pageSizeVal = fp.toNumber(pageSize);
if (!fp.isInteger(pageSizeVal) || pageSizeVal <= 0) {
throw new errors.PaginationError(`Invalid 'pageSize' parameter. Expected an integer > 0, received: ${page}`);
}
return pageSizeVal;
};
const validatePaginationParams = (page, pageSize, start, limit)=>{
const isPagePagination = !fp.isNil(page) || !fp.isNil(pageSize);
const isOffsetPagination = !fp.isNil(start) || !fp.isNil(limit);
if (isPagePagination && isOffsetPagination) {
throw new errors.PaginationError('Invalid pagination attributes. The page parameters are incorrect and must be in the pagination object');
}
};
class InvalidPopulateError extends Error {
constructor(){
super();
this.message = 'Invalid populate parameter. Expected a string, an array of strings, a populate object';
}
}
// NOTE: we could support foo.* or foo.bar.* etc later on
const convertPopulateQueryParams = (populate, schema, depth = 0)=>{
if (depth === 0 && populate === '*') {
return true;
}
if (typeof populate === 'string') {
return populate.split(',').map((value)=>_.trim(value));
}
if (Array.isArray(populate)) {
// map convert
return _.uniq(populate.flatMap((value)=>{
if (typeof value !== 'string') {
throw new InvalidPopulateError();
}
return value.split(',').map((value)=>_.trim(value));
}));
}
if (_.isPlainObject(populate)) {
return convertPopulateObject(populate, schema);
}
throw new InvalidPopulateError();
};
const hasPopulateFragmentDefined = (populate)=>{
return typeof populate === 'object' && 'on' in populate && !fp.isNil(populate.on);
};
const hasCountDefined = (populate)=>{
return typeof populate === 'object' && 'count' in populate && typeof populate.count === 'boolean';
};
const convertPopulateObject = (populate, schema)=>{
if (!schema) {
return {};
}
const { attributes } = schema;
return Object.entries(populate).reduce((acc, [key, subPopulate])=>{
// Try converting strings to regular booleans if possible
if (_.isString(subPopulate)) {
try {
const subPopulateAsBoolean = parseType({
type: 'boolean',
value: subPopulate
});
// Only true is accepted as a boolean populate value
return subPopulateAsBoolean ? {
...acc,
[key]: true
} : acc;
} catch {
// ignore
}
}
if (_.isBoolean(subPopulate)) {
// Only true is accepted as a boolean populate value
return subPopulate === true ? {
...acc,
[key]: true
} : acc;
}
const attribute = attributes[key];
if (!attribute) {
return acc;
}
// Allow adding an 'on' strategy to populate queries for morphTo relations and dynamic zones
const isMorphLikeRelationalAttribute = contentTypes.isDynamicZoneAttribute(attribute) || contentTypes.isMorphToRelationalAttribute(attribute);
if (isMorphLikeRelationalAttribute) {
const hasInvalidProperties = Object.keys(subPopulate).some((key)=>![
'populate',
'on',
'count'
].includes(key));
if (hasInvalidProperties) {
throw new Error(`Invalid nested populate for ${schema.info?.singularName}.${key} (${schema.uid}). Expected a fragment ("on") or "count" but found ${JSON.stringify(subPopulate)}`);
}
/**
* Validate nested population queries in the context of a polymorphic attribute (dynamic zone, morph relation).
*
* If 'populate' exists in subPopulate, its value should be constrained to a wildcard ('*').
*/ if ('populate' in subPopulate && subPopulate.populate !== '*') {
throw new Error(`Invalid nested population query detected. When using 'populate' within polymorphic structures, ` + `its value must be '*' to indicate all second level links. Specific field targeting is not supported here. ` + `Consider using the fragment API for more granular population control.`);
}
// TODO: Remove the possibility to have multiple properties at the same time (on/count/populate)
const newSubPopulate = {};
// case: { populate: '*' }
if ('populate' in subPopulate) {
Object.assign(newSubPopulate, {
populate: true
});
}
// case: { on: { <clauses> } }
if (hasPopulateFragmentDefined(subPopulate)) {
// If the fragment API is used, it applies the transformation to every
// sub-populate, then assign the result to the new sub-populate
Object.assign(newSubPopulate, {
on: Object.entries(subPopulate.on).reduce((acc, [type, typeSubPopulate])=>({
...acc,
[type]: convertNestedPopulate(typeSubPopulate, getModel(type))
}), {})
});
}
// case: { count: true | false }
if (hasCountDefined(subPopulate)) {
Object.assign(newSubPopulate, {
count: subPopulate.count
});
}
return {
...acc,
[key]: newSubPopulate
};
}
// Edge case when trying to use the fragment ('on') on a non-morph like attribute
if (!isMorphLikeRelationalAttribute && hasPopulateFragmentDefined(subPopulate)) {
throw new Error(`Using fragments is not permitted to populate "${key}" in "${schema.uid}"`);
}
// NOTE: Retrieve the target schema UID.
// Only handles basic relations, medias and component since it's not possible
// to populate with options for a dynamic zone or a polymorphic relation
let targetSchemaUID;
if (attribute.type === 'relation') {
targetSchemaUID = attribute.target;
} else if (attribute.type === 'component') {
targetSchemaUID = attribute.component;
} else if (attribute.type === 'media') {
targetSchemaUID = 'plugin::upload.file';
} else {
return acc;
}
const targetSchema = getModel(targetSchemaUID);
// ignore the sub-populate for the current key if there is no schema associated
if (!targetSchema) {
return acc;
}
const populateObject = convertNestedPopulate(subPopulate, targetSchema);
if (!populateObject) {
return acc;
}
return {
...acc,
[key]: populateObject
};
}, {});
};
const convertNestedPopulate = (subPopulate, schema)=>{
if (_.isString(subPopulate)) {
return parseType({
type: 'boolean',
value: subPopulate,
forceCast: true
});
}
if (_.isBoolean(subPopulate)) {
return subPopulate;
}
if (!isPlainObject(subPopulate)) {
throw new Error(`Invalid nested populate. Expected '*' or an object`);
}
const { sort, filters, fields, populate, count, ordering, page, pageSize, start, limit } = subPopulate;
const query = {};
if (sort) {
query.orderBy = convertSortQueryParams(sort);
}
if (filters) {
query.where = convertFiltersQueryParams(filters, schema);
}
if (fields) {
query.select = convertFieldsQueryParams(fields, schema);
}
if (populate) {
query.populate = convertPopulateQueryParams(populate, schema);
}
if (count) {
query.count = convertCountQueryParams(count);
}
if (ordering) {
query.ordering = convertOrderingQueryParams(ordering);
}
validatePaginationParams(page, pageSize, start, limit);
if (!fp.isNil(page)) {
query.page = convertPageQueryParams(page);
}
if (!fp.isNil(pageSize)) {
query.pageSize = convertPageSizeQueryParams(pageSize, page);
}
if (!fp.isNil(start)) {
query.offset = convertStartQueryParams(start);
}
if (!fp.isNil(limit)) {
query.limit = convertLimitQueryParams(limit);
}
return query;
};
// TODO: ensure field is valid in content types (will probably have to check strapi.contentTypes since it can be a string.path)
const convertFieldsQueryParams = (fields, schema, depth = 0)=>{
if (depth === 0 && fields === '*') {
return undefined;
}
if (typeof fields === 'string') {
const fieldsValues = fields.split(',').map((value)=>_.trim(value));
// NOTE: Only include the doc id if it's a content type
if (schema?.modelType === 'contentType') {
return _.uniq([
ID_ATTRIBUTE,
DOC_ID_ATTRIBUTE,
...fieldsValues
]);
}
return _.uniq([
ID_ATTRIBUTE,
...fieldsValues
]);
}
if (isStringArray(fields)) {
// map convert
const fieldsValues = fields.flatMap((value)=>convertFieldsQueryParams(value, schema, depth + 1)).filter((v)=>!fp.isNil(v));
// NOTE: Only include the doc id if it's a content type
if (schema?.modelType === 'contentType') {
return _.uniq([
ID_ATTRIBUTE,
DOC_ID_ATTRIBUTE,
...fieldsValues
]);
}
return _.uniq([
ID_ATTRIBUTE,
...fieldsValues
]);
}
throw new Error('Invalid fields parameter. Expected a string or an array of strings');
};
const isValidSchemaAttribute = (key, schema)=>{
if ([
DOC_ID_ATTRIBUTE,
ID_ATTRIBUTE
].includes(key)) {
return true;
}
if (!schema) {
return false;
}
return Object.keys(schema.attributes).includes(key);
};
const convertFiltersQueryParams = (filters, schema)=>{
// Filters need to be either an array or an object
// Here we're only checking for 'object' type since typeof [] => object and typeof {} => object
if (!fp.isObject(filters)) {
throw new Error('The filters parameter must be an object or an array');
}
// Don't mutate the original object
const filtersCopy = fp.cloneDeep(filters);
return convertAndSanitizeFilters(filtersCopy, schema);
};
const convertAndSanitizeFilters = (filters, schema)=>{
if (Array.isArray(filters)) {
return filters// Sanitize each filter
.map((filter)=>convertAndSanitizeFilters(filter, schema))// Filter out empty filters
.filter((filter)=>!isPlainObject(filter) || !fp.isEmpty(filter));
}
if (!isPlainObject(filters)) {
return filters;
}
const removeOperator = (operator)=>delete filters[operator];
// Here, `key` can either be an operator or an attribute name
for (const [key, value] of Object.entries(filters)){
const attribute = fp.get(key, schema?.attributes);
const validKey = operators.isOperator(key) || isValidSchemaAttribute(key, schema);
if (!validKey) {
removeOperator(key);
} else if (attribute) {
// Relations
if (attribute.type === 'relation') {
filters[key] = convertAndSanitizeFilters(value, getModel(attribute.target));
} else if (attribute.type === 'component') {
filters[key] = convertAndSanitizeFilters(value, getModel(attribute.component));
} else if (attribute.type === 'media') {
filters[key] = convertAndSanitizeFilters(value, getModel('plugin::upload.file'));
} else if (attribute.type === 'dynamiczone') {
removeOperator(key);
} else if (attribute.type === 'password') {
// Always remove password attributes from filters object
removeOperator(key);
} else {
filters[key] = convertAndSanitizeFilters(value, schema);
}
} else if ([
'$null',
'$notNull'
].includes(key)) {
filters[key] = parseType({
type: 'boolean',
value: filters[key],
forceCast: true
});
} else if (fp.isObject(value)) {
filters[key] = convertAndSanitizeFilters(value, schema);
}
// Remove empty objects & arrays
if (isPlainObject(filters[key]) && fp.isEmpty(filters[key])) {
removeOperator(key);
}
}
return filters;
};
const convertStatusParams = (status, query = {})=>{
// NOTE: this is the query layer filters not the document/entity service filters
query.filters = ({ meta })=>{
const contentType = getModel(meta.uid);
// Ignore if target model has disabled DP, as it doesn't make sense to filter by its status
if (!contentType || !contentTypes.hasDraftAndPublish(contentType)) {
return {};
}
return {
[PUBLISHED_AT_ATTRIBUTE]: {
$null: status === 'draft'
}
};
};
};
const transformQueryParams = (uid, params)=>{
// NOTE: can be a CT, a Compo or nothing in the case of polymorphism (DZ & morph relations)
const schema = getModel(uid);
const query = {};
const { _q, sort, filters, fields, populate, page, pageSize, start, limit, status, ...rest } = params;
if (!fp.isNil(status)) {
convertStatusParams(status, query);
}
if (!fp.isNil(_q)) {
query._q = _q;
}
if (!fp.isNil(sort)) {
query.orderBy = convertSortQueryParams(sort);
}
if (!fp.isNil(filters)) {
query.where = convertFiltersQueryParams(filters, schema);
}
if (!fp.isNil(fields)) {
query.select = convertFieldsQueryParams(fields, schema);
}
if (!fp.isNil(populate)) {
query.populate = convertPopulateQueryParams(populate, schema);
}
validatePaginationParams(page, pageSize, start, limit);
if (!fp.isNil(page)) {
query.page = convertPageQueryParams(page);
}
if (!fp.isNil(pageSize)) {
query.pageSize = convertPageSizeQueryParams(pageSize, page);
}
if (!fp.isNil(start)) {
query.offset = convertStartQueryParams(start);
}
if (!fp.isNil(limit)) {
query.limit = convertLimitQueryParams(limit);
}
return {
...rest,
...query
};
};
return {
private_convertSortQueryParams: convertSortQueryParams,
private_convertStartQueryParams: convertStartQueryParams,
private_convertLimitQueryParams: convertLimitQueryParams,
private_convertPopulateQueryParams: convertPopulateQueryParams,
private_convertFiltersQueryParams: convertFiltersQueryParams,
private_convertFieldsQueryParams: convertFieldsQueryParams,
transformQueryParams
};
};
exports.createTransformer = createTransformer;
//# sourceMappingURL=convert-query-params.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,510 @@
import ___default from 'lodash';
import { isString, toNumber, isNil, isObject, cloneDeep, isEmpty, get, isArray, isInteger } from 'lodash/fp';
import { isDynamicZoneAttribute, isMorphToRelationalAttribute, constants, hasDraftAndPublish } from './content-types.mjs';
import { PaginationError } from './errors.mjs';
import { isOperator } from './operators.mjs';
import parseType from './parse-type.mjs';
const { ID_ATTRIBUTE, DOC_ID_ATTRIBUTE, PUBLISHED_AT_ATTRIBUTE } = constants;
class InvalidOrderError extends Error {
constructor(){
super();
this.message = 'Invalid order. order can only be one of asc|desc|ASC|DESC';
}
}
class InvalidSortError extends Error {
constructor(){
super();
this.message = 'Invalid sort parameter. Expected a string, an array of strings, a sort object or an array of sort objects';
}
}
function validateOrder(order) {
if (!isString(order) || ![
'asc',
'desc'
].includes(order.toLocaleLowerCase())) {
throw new InvalidOrderError();
}
}
const convertCountQueryParams = (countQuery)=>{
return parseType({
type: 'boolean',
value: countQuery
});
};
const convertOrderingQueryParams = (ordering)=>{
return ordering;
};
const isPlainObject = (value)=>___default.isPlainObject(value);
const isStringArray = (value)=>isArray(value) && value.every(isString);
const createTransformer = ({ getModel })=>{
/**
* Sort query parser
*/ const convertSortQueryParams = (sortQuery)=>{
if (typeof sortQuery === 'string') {
return convertStringSortQueryParam(sortQuery);
}
if (isStringArray(sortQuery)) {
return sortQuery.flatMap((sortValue)=>convertStringSortQueryParam(sortValue));
}
if (Array.isArray(sortQuery)) {
return sortQuery.map((sortValue)=>convertNestedSortQueryParam(sortValue));
}
if (isPlainObject(sortQuery)) {
return convertNestedSortQueryParam(sortQuery);
}
throw new InvalidSortError();
};
const convertStringSortQueryParam = (sortQuery)=>{
return sortQuery.split(',').map((value)=>convertSingleSortQueryParam(value));
};
const convertSingleSortQueryParam = (sortQuery)=>{
if (!sortQuery) {
return {};
}
if (!isString(sortQuery)) {
throw new Error('Invalid sort query');
}
// split field and order param with default order to ascending
const [field, order = 'asc'] = sortQuery.split(':');
if (field.length === 0) {
throw new Error('Field cannot be empty');
}
validateOrder(order);
// TODO: field should be a valid path on an object model
return ___default.set({}, field, order);
};
const convertNestedSortQueryParam = (sortQuery)=>{
const transformedSort = {};
for (const field of Object.keys(sortQuery)){
const order = sortQuery[field];
// this is a deep sort
if (isPlainObject(order)) {
transformedSort[field] = convertNestedSortQueryParam(order);
} else if (typeof order === 'string') {
validateOrder(order);
transformedSort[field] = order;
} else {
throw Error(`Invalid sort type expected object or string got ${typeof order}`);
}
}
return transformedSort;
};
/**
* Start query parser
*/ const convertStartQueryParams = (startQuery)=>{
const startAsANumber = toNumber(startQuery);
if (!___default.isInteger(startAsANumber) || startAsANumber < 0) {
throw new Error(`convertStartQueryParams expected a positive integer got ${startAsANumber}`);
}
return startAsANumber;
};
/**
* Limit query parser
*/ const convertLimitQueryParams = (limitQuery)=>{
const limitAsANumber = toNumber(limitQuery);
if (!___default.isInteger(limitAsANumber) || limitAsANumber !== -1 && limitAsANumber < 0) {
throw new Error(`convertLimitQueryParams expected a positive integer got ${limitAsANumber}`);
}
if (limitAsANumber === -1) {
return undefined;
}
return limitAsANumber;
};
const convertPageQueryParams = (page)=>{
const pageVal = toNumber(page);
if (!isInteger(pageVal) || pageVal <= 0) {
throw new PaginationError(`Invalid 'page' parameter. Expected an integer > 0, received: ${page}`);
}
return pageVal;
};
const convertPageSizeQueryParams = (pageSize, page)=>{
const pageSizeVal = toNumber(pageSize);
if (!isInteger(pageSizeVal) || pageSizeVal <= 0) {
throw new PaginationError(`Invalid 'pageSize' parameter. Expected an integer > 0, received: ${page}`);
}
return pageSizeVal;
};
const validatePaginationParams = (page, pageSize, start, limit)=>{
const isPagePagination = !isNil(page) || !isNil(pageSize);
const isOffsetPagination = !isNil(start) || !isNil(limit);
if (isPagePagination && isOffsetPagination) {
throw new PaginationError('Invalid pagination attributes. The page parameters are incorrect and must be in the pagination object');
}
};
class InvalidPopulateError extends Error {
constructor(){
super();
this.message = 'Invalid populate parameter. Expected a string, an array of strings, a populate object';
}
}
// NOTE: we could support foo.* or foo.bar.* etc later on
const convertPopulateQueryParams = (populate, schema, depth = 0)=>{
if (depth === 0 && populate === '*') {
return true;
}
if (typeof populate === 'string') {
return populate.split(',').map((value)=>___default.trim(value));
}
if (Array.isArray(populate)) {
// map convert
return ___default.uniq(populate.flatMap((value)=>{
if (typeof value !== 'string') {
throw new InvalidPopulateError();
}
return value.split(',').map((value)=>___default.trim(value));
}));
}
if (___default.isPlainObject(populate)) {
return convertPopulateObject(populate, schema);
}
throw new InvalidPopulateError();
};
const hasPopulateFragmentDefined = (populate)=>{
return typeof populate === 'object' && 'on' in populate && !isNil(populate.on);
};
const hasCountDefined = (populate)=>{
return typeof populate === 'object' && 'count' in populate && typeof populate.count === 'boolean';
};
const convertPopulateObject = (populate, schema)=>{
if (!schema) {
return {};
}
const { attributes } = schema;
return Object.entries(populate).reduce((acc, [key, subPopulate])=>{
// Try converting strings to regular booleans if possible
if (___default.isString(subPopulate)) {
try {
const subPopulateAsBoolean = parseType({
type: 'boolean',
value: subPopulate
});
// Only true is accepted as a boolean populate value
return subPopulateAsBoolean ? {
...acc,
[key]: true
} : acc;
} catch {
// ignore
}
}
if (___default.isBoolean(subPopulate)) {
// Only true is accepted as a boolean populate value
return subPopulate === true ? {
...acc,
[key]: true
} : acc;
}
const attribute = attributes[key];
if (!attribute) {
return acc;
}
// Allow adding an 'on' strategy to populate queries for morphTo relations and dynamic zones
const isMorphLikeRelationalAttribute = isDynamicZoneAttribute(attribute) || isMorphToRelationalAttribute(attribute);
if (isMorphLikeRelationalAttribute) {
const hasInvalidProperties = Object.keys(subPopulate).some((key)=>![
'populate',
'on',
'count'
].includes(key));
if (hasInvalidProperties) {
throw new Error(`Invalid nested populate for ${schema.info?.singularName}.${key} (${schema.uid}). Expected a fragment ("on") or "count" but found ${JSON.stringify(subPopulate)}`);
}
/**
* Validate nested population queries in the context of a polymorphic attribute (dynamic zone, morph relation).
*
* If 'populate' exists in subPopulate, its value should be constrained to a wildcard ('*').
*/ if ('populate' in subPopulate && subPopulate.populate !== '*') {
throw new Error(`Invalid nested population query detected. When using 'populate' within polymorphic structures, ` + `its value must be '*' to indicate all second level links. Specific field targeting is not supported here. ` + `Consider using the fragment API for more granular population control.`);
}
// TODO: Remove the possibility to have multiple properties at the same time (on/count/populate)
const newSubPopulate = {};
// case: { populate: '*' }
if ('populate' in subPopulate) {
Object.assign(newSubPopulate, {
populate: true
});
}
// case: { on: { <clauses> } }
if (hasPopulateFragmentDefined(subPopulate)) {
// If the fragment API is used, it applies the transformation to every
// sub-populate, then assign the result to the new sub-populate
Object.assign(newSubPopulate, {
on: Object.entries(subPopulate.on).reduce((acc, [type, typeSubPopulate])=>({
...acc,
[type]: convertNestedPopulate(typeSubPopulate, getModel(type))
}), {})
});
}
// case: { count: true | false }
if (hasCountDefined(subPopulate)) {
Object.assign(newSubPopulate, {
count: subPopulate.count
});
}
return {
...acc,
[key]: newSubPopulate
};
}
// Edge case when trying to use the fragment ('on') on a non-morph like attribute
if (!isMorphLikeRelationalAttribute && hasPopulateFragmentDefined(subPopulate)) {
throw new Error(`Using fragments is not permitted to populate "${key}" in "${schema.uid}"`);
}
// NOTE: Retrieve the target schema UID.
// Only handles basic relations, medias and component since it's not possible
// to populate with options for a dynamic zone or a polymorphic relation
let targetSchemaUID;
if (attribute.type === 'relation') {
targetSchemaUID = attribute.target;
} else if (attribute.type === 'component') {
targetSchemaUID = attribute.component;
} else if (attribute.type === 'media') {
targetSchemaUID = 'plugin::upload.file';
} else {
return acc;
}
const targetSchema = getModel(targetSchemaUID);
// ignore the sub-populate for the current key if there is no schema associated
if (!targetSchema) {
return acc;
}
const populateObject = convertNestedPopulate(subPopulate, targetSchema);
if (!populateObject) {
return acc;
}
return {
...acc,
[key]: populateObject
};
}, {});
};
const convertNestedPopulate = (subPopulate, schema)=>{
if (___default.isString(subPopulate)) {
return parseType({
type: 'boolean',
value: subPopulate,
forceCast: true
});
}
if (___default.isBoolean(subPopulate)) {
return subPopulate;
}
if (!isPlainObject(subPopulate)) {
throw new Error(`Invalid nested populate. Expected '*' or an object`);
}
const { sort, filters, fields, populate, count, ordering, page, pageSize, start, limit } = subPopulate;
const query = {};
if (sort) {
query.orderBy = convertSortQueryParams(sort);
}
if (filters) {
query.where = convertFiltersQueryParams(filters, schema);
}
if (fields) {
query.select = convertFieldsQueryParams(fields, schema);
}
if (populate) {
query.populate = convertPopulateQueryParams(populate, schema);
}
if (count) {
query.count = convertCountQueryParams(count);
}
if (ordering) {
query.ordering = convertOrderingQueryParams(ordering);
}
validatePaginationParams(page, pageSize, start, limit);
if (!isNil(page)) {
query.page = convertPageQueryParams(page);
}
if (!isNil(pageSize)) {
query.pageSize = convertPageSizeQueryParams(pageSize, page);
}
if (!isNil(start)) {
query.offset = convertStartQueryParams(start);
}
if (!isNil(limit)) {
query.limit = convertLimitQueryParams(limit);
}
return query;
};
// TODO: ensure field is valid in content types (will probably have to check strapi.contentTypes since it can be a string.path)
const convertFieldsQueryParams = (fields, schema, depth = 0)=>{
if (depth === 0 && fields === '*') {
return undefined;
}
if (typeof fields === 'string') {
const fieldsValues = fields.split(',').map((value)=>___default.trim(value));
// NOTE: Only include the doc id if it's a content type
if (schema?.modelType === 'contentType') {
return ___default.uniq([
ID_ATTRIBUTE,
DOC_ID_ATTRIBUTE,
...fieldsValues
]);
}
return ___default.uniq([
ID_ATTRIBUTE,
...fieldsValues
]);
}
if (isStringArray(fields)) {
// map convert
const fieldsValues = fields.flatMap((value)=>convertFieldsQueryParams(value, schema, depth + 1)).filter((v)=>!isNil(v));
// NOTE: Only include the doc id if it's a content type
if (schema?.modelType === 'contentType') {
return ___default.uniq([
ID_ATTRIBUTE,
DOC_ID_ATTRIBUTE,
...fieldsValues
]);
}
return ___default.uniq([
ID_ATTRIBUTE,
...fieldsValues
]);
}
throw new Error('Invalid fields parameter. Expected a string or an array of strings');
};
const isValidSchemaAttribute = (key, schema)=>{
if ([
DOC_ID_ATTRIBUTE,
ID_ATTRIBUTE
].includes(key)) {
return true;
}
if (!schema) {
return false;
}
return Object.keys(schema.attributes).includes(key);
};
const convertFiltersQueryParams = (filters, schema)=>{
// Filters need to be either an array or an object
// Here we're only checking for 'object' type since typeof [] => object and typeof {} => object
if (!isObject(filters)) {
throw new Error('The filters parameter must be an object or an array');
}
// Don't mutate the original object
const filtersCopy = cloneDeep(filters);
return convertAndSanitizeFilters(filtersCopy, schema);
};
const convertAndSanitizeFilters = (filters, schema)=>{
if (Array.isArray(filters)) {
return filters// Sanitize each filter
.map((filter)=>convertAndSanitizeFilters(filter, schema))// Filter out empty filters
.filter((filter)=>!isPlainObject(filter) || !isEmpty(filter));
}
if (!isPlainObject(filters)) {
return filters;
}
const removeOperator = (operator)=>delete filters[operator];
// Here, `key` can either be an operator or an attribute name
for (const [key, value] of Object.entries(filters)){
const attribute = get(key, schema?.attributes);
const validKey = isOperator(key) || isValidSchemaAttribute(key, schema);
if (!validKey) {
removeOperator(key);
} else if (attribute) {
// Relations
if (attribute.type === 'relation') {
filters[key] = convertAndSanitizeFilters(value, getModel(attribute.target));
} else if (attribute.type === 'component') {
filters[key] = convertAndSanitizeFilters(value, getModel(attribute.component));
} else if (attribute.type === 'media') {
filters[key] = convertAndSanitizeFilters(value, getModel('plugin::upload.file'));
} else if (attribute.type === 'dynamiczone') {
removeOperator(key);
} else if (attribute.type === 'password') {
// Always remove password attributes from filters object
removeOperator(key);
} else {
filters[key] = convertAndSanitizeFilters(value, schema);
}
} else if ([
'$null',
'$notNull'
].includes(key)) {
filters[key] = parseType({
type: 'boolean',
value: filters[key],
forceCast: true
});
} else if (isObject(value)) {
filters[key] = convertAndSanitizeFilters(value, schema);
}
// Remove empty objects & arrays
if (isPlainObject(filters[key]) && isEmpty(filters[key])) {
removeOperator(key);
}
}
return filters;
};
const convertStatusParams = (status, query = {})=>{
// NOTE: this is the query layer filters not the document/entity service filters
query.filters = ({ meta })=>{
const contentType = getModel(meta.uid);
// Ignore if target model has disabled DP, as it doesn't make sense to filter by its status
if (!contentType || !hasDraftAndPublish(contentType)) {
return {};
}
return {
[PUBLISHED_AT_ATTRIBUTE]: {
$null: status === 'draft'
}
};
};
};
const transformQueryParams = (uid, params)=>{
// NOTE: can be a CT, a Compo or nothing in the case of polymorphism (DZ & morph relations)
const schema = getModel(uid);
const query = {};
const { _q, sort, filters, fields, populate, page, pageSize, start, limit, status, ...rest } = params;
if (!isNil(status)) {
convertStatusParams(status, query);
}
if (!isNil(_q)) {
query._q = _q;
}
if (!isNil(sort)) {
query.orderBy = convertSortQueryParams(sort);
}
if (!isNil(filters)) {
query.where = convertFiltersQueryParams(filters, schema);
}
if (!isNil(fields)) {
query.select = convertFieldsQueryParams(fields, schema);
}
if (!isNil(populate)) {
query.populate = convertPopulateQueryParams(populate, schema);
}
validatePaginationParams(page, pageSize, start, limit);
if (!isNil(page)) {
query.page = convertPageQueryParams(page);
}
if (!isNil(pageSize)) {
query.pageSize = convertPageSizeQueryParams(pageSize, page);
}
if (!isNil(start)) {
query.offset = convertStartQueryParams(start);
}
if (!isNil(limit)) {
query.limit = convertLimitQueryParams(limit);
}
return {
...rest,
...query
};
};
return {
private_convertSortQueryParams: convertSortQueryParams,
private_convertStartQueryParams: convertStartQueryParams,
private_convertLimitQueryParams: convertLimitQueryParams,
private_convertPopulateQueryParams: convertPopulateQueryParams,
private_convertFiltersQueryParams: convertFiltersQueryParams,
private_convertFieldsQueryParams: convertFieldsQueryParams,
transformQueryParams
};
};
export { createTransformer };
//# sourceMappingURL=convert-query-params.mjs.map

File diff suppressed because one or more lines are too long

21
server/node_modules/@strapi/utils/dist/env-helper.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
export type Env = typeof envFn & typeof utils;
declare function envFn<T>(key: string, defaultValue?: T): string | T | undefined;
declare const utils: {
int(key: string, defaultValue?: number): number | undefined;
float(key: string, defaultValue?: number): number | undefined;
bool(key: string, defaultValue?: boolean): boolean | undefined;
json(key: string, defaultValue?: object): any;
array(key: string, defaultValue?: string[]): string[] | undefined;
date(key: string, defaultValue?: Date): Date | undefined;
/**
* Gets a value from env that matches oneOf provided values
* @param {string} key
* @param {string[]} expectedValues
* @param {string|undefined} defaultValue
* @returns {string|undefined}
*/
oneOf(key: string, expectedValues?: unknown[], defaultValue?: unknown): unknown;
};
declare const env: Env;
export default env;
//# sourceMappingURL=env-helper.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"env-helper.d.ts","sourceRoot":"","sources":["../src/env-helper.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,GAAG,OAAO,KAAK,GAAG,OAAO,KAAK,CAAC;AAE9C,iBAAS,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,SAAS,CAEvE;AAMD,QAAA,MAAM,KAAK;aACA,MAAM,iBAAiB,MAAM,GAAG,MAAM,GAAG,SAAS;eAQhD,MAAM,iBAAiB,MAAM,GAAG,MAAM,GAAG,SAAS;cAQnD,MAAM,iBAAiB,OAAO,GAAG,OAAO,GAAG,SAAS;cAQpD,MAAM,iBAAiB,MAAM;eAgB5B,MAAM,iBAAiB,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS;cAgBvD,MAAM,iBAAiB,IAAI,GAAG,IAAI,GAAG,SAAS;IAQxD;;;;;;OAMG;eACQ,MAAM,mBAAmB,OAAO,EAAE,iBAAiB,OAAO;CAYtE,CAAC;AAEF,QAAA,MAAM,GAAG,EAAE,GAAiC,CAAC;AAE7C,eAAe,GAAG,CAAC"}

81
server/node_modules/@strapi/utils/dist/env-helper.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
'use strict';
var _ = require('lodash');
function envFn(key, defaultValue) {
return _.has(process.env, key) ? process.env[key] : defaultValue;
}
function getKey(key) {
return process.env[key] ?? '';
}
const utils = {
int (key, defaultValue) {
if (!_.has(process.env, key)) {
return defaultValue;
}
return parseInt(getKey(key), 10);
},
float (key, defaultValue) {
if (!_.has(process.env, key)) {
return defaultValue;
}
return parseFloat(getKey(key));
},
bool (key, defaultValue) {
if (!_.has(process.env, key)) {
return defaultValue;
}
return getKey(key) === 'true';
},
json (key, defaultValue) {
if (!_.has(process.env, key)) {
return defaultValue;
}
try {
return JSON.parse(getKey(key));
} catch (error) {
if (error instanceof Error) {
throw new Error(`Invalid json environment variable ${key}: ${error.message}`);
}
throw error;
}
},
array (key, defaultValue) {
if (!_.has(process.env, key)) {
return defaultValue;
}
let value = getKey(key);
if (value.startsWith('[') && value.endsWith(']')) {
value = value.substring(1, value.length - 1);
}
return value.split(',').map((v)=>{
return _.trim(_.trim(v, ' '), '"');
});
},
date (key, defaultValue) {
if (!_.has(process.env, key)) {
return defaultValue;
}
return new Date(getKey(key));
},
/**
* Gets a value from env that matches oneOf provided values
* @param {string} key
* @param {string[]} expectedValues
* @param {string|undefined} defaultValue
* @returns {string|undefined}
*/ oneOf (key, expectedValues, defaultValue) {
if (!expectedValues) {
throw new Error(`env.oneOf requires expectedValues`);
}
if (defaultValue && !expectedValues.includes(defaultValue)) {
throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
}
const rawValue = env(key, defaultValue);
return expectedValues.includes(rawValue) ? rawValue : defaultValue;
}
};
const env = Object.assign(envFn, utils);
module.exports = env;
//# sourceMappingURL=env-helper.js.map

File diff suppressed because one or more lines are too long

79
server/node_modules/@strapi/utils/dist/env-helper.mjs generated vendored Normal file
View File

@@ -0,0 +1,79 @@
import ___default from 'lodash';
function envFn(key, defaultValue) {
return ___default.has(process.env, key) ? process.env[key] : defaultValue;
}
function getKey(key) {
return process.env[key] ?? '';
}
const utils = {
int (key, defaultValue) {
if (!___default.has(process.env, key)) {
return defaultValue;
}
return parseInt(getKey(key), 10);
},
float (key, defaultValue) {
if (!___default.has(process.env, key)) {
return defaultValue;
}
return parseFloat(getKey(key));
},
bool (key, defaultValue) {
if (!___default.has(process.env, key)) {
return defaultValue;
}
return getKey(key) === 'true';
},
json (key, defaultValue) {
if (!___default.has(process.env, key)) {
return defaultValue;
}
try {
return JSON.parse(getKey(key));
} catch (error) {
if (error instanceof Error) {
throw new Error(`Invalid json environment variable ${key}: ${error.message}`);
}
throw error;
}
},
array (key, defaultValue) {
if (!___default.has(process.env, key)) {
return defaultValue;
}
let value = getKey(key);
if (value.startsWith('[') && value.endsWith(']')) {
value = value.substring(1, value.length - 1);
}
return value.split(',').map((v)=>{
return ___default.trim(___default.trim(v, ' '), '"');
});
},
date (key, defaultValue) {
if (!___default.has(process.env, key)) {
return defaultValue;
}
return new Date(getKey(key));
},
/**
* Gets a value from env that matches oneOf provided values
* @param {string} key
* @param {string[]} expectedValues
* @param {string|undefined} defaultValue
* @returns {string|undefined}
*/ oneOf (key, expectedValues, defaultValue) {
if (!expectedValues) {
throw new Error(`env.oneOf requires expectedValues`);
}
if (defaultValue && !expectedValues.includes(defaultValue)) {
throw new Error(`env.oneOf requires defaultValue to be included in expectedValues`);
}
const rawValue = env(key, defaultValue);
return expectedValues.includes(rawValue) ? rawValue : defaultValue;
}
};
const env = Object.assign(envFn, utils);
export { env as default };
//# sourceMappingURL=env-helper.mjs.map

File diff suppressed because one or more lines are too long

48
server/node_modules/@strapi/utils/dist/errors.d.ts generated vendored Normal file
View File

@@ -0,0 +1,48 @@
import yup from 'yup';
import { HttpError } from 'http-errors';
declare class ApplicationError<TName extends string = 'ApplicationError', TMessage extends string = string, TDetails = unknown> extends Error {
name: TName;
details: TDetails;
message: TMessage;
constructor(message?: TMessage, details?: TDetails);
}
declare class ValidationError<TMessage extends string = string, TDetails = unknown> extends ApplicationError<'ValidationError', TMessage, TDetails> {
constructor(message: TMessage, details?: TDetails);
}
interface YupFormattedError {
path: string[];
message: string;
name: string;
value: string;
}
declare class YupValidationError<TMessage extends string = string> extends ValidationError<TMessage, {
errors: YupFormattedError[];
}> {
constructor(yupError: yup.ValidationError, message?: TMessage);
}
declare class PaginationError<TMessage extends string = string, TDetails = unknown> extends ApplicationError<'PaginationError', TMessage, TDetails> {
constructor(message?: TMessage, details?: TDetails);
}
declare class NotFoundError<TMessage extends string = string, TDetails = unknown> extends ApplicationError<'NotFoundError', TMessage, TDetails> {
constructor(message?: TMessage, details?: TDetails);
}
declare class ForbiddenError<TName extends string = 'ForbiddenError', TMessage extends string = string, TDetails = unknown> extends ApplicationError<TName, TMessage, TDetails> {
constructor(message?: TMessage, details?: TDetails);
}
declare class UnauthorizedError<TMessage extends string = string, TDetails = unknown> extends ApplicationError<'UnauthorizedError', TMessage, TDetails> {
constructor(message?: TMessage, details?: TDetails);
}
declare class RateLimitError<TMessage extends string = string, TDetails = unknown> extends ApplicationError<'RateLimitError', TMessage, TDetails> {
constructor(message?: TMessage, details?: TDetails);
}
declare class PayloadTooLargeError<TMessage extends string = string, TDetails = unknown> extends ApplicationError<'PayloadTooLargeError', TMessage, TDetails> {
constructor(message?: TMessage, details?: TDetails);
}
declare class PolicyError<TMessage extends string = string, TDetails = unknown> extends ForbiddenError<'PolicyError', TMessage, TDetails> {
constructor(message?: TMessage, details?: TDetails);
}
declare class NotImplementedError<TMessage extends string = string, TDetails = unknown> extends ApplicationError<'NotImplementedError', TMessage, TDetails> {
constructor(message?: TMessage, details?: TDetails);
}
export { HttpError, ApplicationError, ValidationError, YupValidationError, PaginationError, NotFoundError, ForbiddenError, UnauthorizedError, RateLimitError, PayloadTooLargeError, PolicyError, NotImplementedError, };
//# sourceMappingURL=errors.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"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"}

104
server/node_modules/@strapi/utils/dist/errors.js generated vendored Normal file
View File

@@ -0,0 +1,104 @@
'use strict';
var httpErrors = require('http-errors');
var formatYupError = require('./format-yup-error.js');
/* ApplicationError */ class ApplicationError extends Error {
constructor(message = 'An application error occured', details = {}){
super();
this.name = 'ApplicationError';
this.message = message;
this.details = details;
}
}
class ValidationError extends ApplicationError {
constructor(message, details){
super(message, details);
this.name = 'ValidationError';
}
}
class YupValidationError extends ValidationError {
constructor(yupError, message){
super('Validation');
const { errors, message: yupMessage } = formatYupError.formatYupErrors(yupError);
this.message = message || yupMessage;
this.details = {
errors
};
}
}
class PaginationError extends ApplicationError {
constructor(message = 'Invalid pagination', details){
super(message, details);
this.name = 'PaginationError';
this.message = message;
}
}
class NotFoundError extends ApplicationError {
constructor(message = 'Entity not found', details){
super(message, details);
this.name = 'NotFoundError';
this.message = message;
}
}
class ForbiddenError extends ApplicationError {
constructor(message = 'Forbidden access', details){
super(message, details);
this.name = 'ForbiddenError';
this.message = message;
}
}
class UnauthorizedError extends ApplicationError {
constructor(message = 'Unauthorized', details){
super(message, details);
this.name = 'UnauthorizedError';
this.message = message;
}
}
class RateLimitError extends ApplicationError {
constructor(message = 'Too many requests, please try again later.', details){
super(message, details);
this.name = 'RateLimitError';
this.message = message;
this.details = details || {};
}
}
class PayloadTooLargeError extends ApplicationError {
constructor(message = 'Entity too large', details){
super(message, details);
this.name = 'PayloadTooLargeError';
this.message = message;
}
}
class PolicyError extends ForbiddenError {
constructor(message = 'Policy Failed', details){
super(message, details);
this.name = 'PolicyError';
this.message = message;
this.details = details || {};
}
}
class NotImplementedError extends ApplicationError {
constructor(message = 'This feature is not implemented yet', details){
super(message, details);
this.name = 'NotImplementedError';
this.message = message;
}
}
Object.defineProperty(exports, "HttpError", {
enumerable: true,
get: function () { return httpErrors.HttpError; }
});
exports.ApplicationError = ApplicationError;
exports.ForbiddenError = ForbiddenError;
exports.NotFoundError = NotFoundError;
exports.NotImplementedError = NotImplementedError;
exports.PaginationError = PaginationError;
exports.PayloadTooLargeError = PayloadTooLargeError;
exports.PolicyError = PolicyError;
exports.RateLimitError = RateLimitError;
exports.UnauthorizedError = UnauthorizedError;
exports.ValidationError = ValidationError;
exports.YupValidationError = YupValidationError;
//# sourceMappingURL=errors.js.map

1
server/node_modules/@strapi/utils/dist/errors.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

88
server/node_modules/@strapi/utils/dist/errors.mjs generated vendored Normal file
View File

@@ -0,0 +1,88 @@
export { HttpError } from 'http-errors';
import { formatYupErrors } from './format-yup-error.mjs';
/* ApplicationError */ class ApplicationError extends Error {
constructor(message = 'An application error occured', details = {}){
super();
this.name = 'ApplicationError';
this.message = message;
this.details = details;
}
}
class ValidationError extends ApplicationError {
constructor(message, details){
super(message, details);
this.name = 'ValidationError';
}
}
class YupValidationError extends ValidationError {
constructor(yupError, message){
super('Validation');
const { errors, message: yupMessage } = formatYupErrors(yupError);
this.message = message || yupMessage;
this.details = {
errors
};
}
}
class PaginationError extends ApplicationError {
constructor(message = 'Invalid pagination', details){
super(message, details);
this.name = 'PaginationError';
this.message = message;
}
}
class NotFoundError extends ApplicationError {
constructor(message = 'Entity not found', details){
super(message, details);
this.name = 'NotFoundError';
this.message = message;
}
}
class ForbiddenError extends ApplicationError {
constructor(message = 'Forbidden access', details){
super(message, details);
this.name = 'ForbiddenError';
this.message = message;
}
}
class UnauthorizedError extends ApplicationError {
constructor(message = 'Unauthorized', details){
super(message, details);
this.name = 'UnauthorizedError';
this.message = message;
}
}
class RateLimitError extends ApplicationError {
constructor(message = 'Too many requests, please try again later.', details){
super(message, details);
this.name = 'RateLimitError';
this.message = message;
this.details = details || {};
}
}
class PayloadTooLargeError extends ApplicationError {
constructor(message = 'Entity too large', details){
super(message, details);
this.name = 'PayloadTooLargeError';
this.message = message;
}
}
class PolicyError extends ForbiddenError {
constructor(message = 'Policy Failed', details){
super(message, details);
this.name = 'PolicyError';
this.message = message;
this.details = details || {};
}
}
class NotImplementedError extends ApplicationError {
constructor(message = 'This feature is not implemented yet', details){
super(message, details);
this.name = 'NotImplementedError';
this.message = message;
}
}
export { ApplicationError, ForbiddenError, NotFoundError, NotImplementedError, PaginationError, PayloadTooLargeError, PolicyError, RateLimitError, UnauthorizedError, ValidationError, YupValidationError };
//# sourceMappingURL=errors.mjs.map

File diff suppressed because one or more lines are too long

22
server/node_modules/@strapi/utils/dist/file.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/**
* Utils file containing file treatment utils
*/
import { Writable, WritableOptions } from 'node:stream';
declare const kbytesToBytes: (kbytes: number) => number;
declare const bytesToKbytes: (bytes: number) => number;
declare const bytesToHumanReadable: (bytes: number) => string;
declare const streamToBuffer: (stream: NodeJS.ReadableStream) => Promise<Buffer>;
declare const getStreamSize: (stream: NodeJS.ReadableStream) => Promise<unknown>;
/**
* Create a writeable Node.js stream that discards received data.
* Useful for testing, draining a stream of data, etc.
*/
declare function writableDiscardStream(options?: WritableOptions): Writable;
export { streamToBuffer, bytesToHumanReadable, bytesToKbytes, kbytesToBytes, getStreamSize, writableDiscardStream, };
//# sourceMappingURL=file.d.ts.map

1
server/node_modules/@strapi/utils/dist/file.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":";;;;;;AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAExD,QAAA,MAAM,aAAa,WAAY,MAAM,WAAkB,CAAC;AACxD,QAAA,MAAM,aAAa,UAAW,MAAM,WAA2C,CAAC;AAChF,QAAA,MAAM,oBAAoB,UAAW,MAAM,WAK1C,CAAC;AAEF,QAAA,MAAM,cAAc,WAAY,qBAAqB,KAAG,QAAQ,MAAM,CAUlE,CAAC;AAEL,QAAA,MAAM,aAAa,WAAY,qBAAqB,qBAShD,CAAC;AAEL;;;GAGG;AACH,iBAAS,qBAAqB,CAAC,OAAO,CAAC,EAAE,eAAe,YAOvD;AAED,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,aAAa,EACb,qBAAqB,GACtB,CAAC"}

57
server/node_modules/@strapi/utils/dist/file.js generated vendored Normal file
View File

@@ -0,0 +1,57 @@
'use strict';
var node_stream = require('node:stream');
const kbytesToBytes = (kbytes)=>kbytes * 1000;
const bytesToKbytes = (bytes)=>Math.round(bytes / 1000 * 100) / 100;
const bytesToHumanReadable = (bytes)=>{
const sizes = [
'Bytes',
'KB',
'MB',
'GB',
'TB',
'PB'
];
if (bytes === 0) return '0 Bytes';
const i = parseInt(`${Math.floor(Math.log(bytes) / Math.log(1000))}`, 10);
return `${Math.round(bytes / 1000 ** i)} ${sizes[i]}`;
};
const streamToBuffer = (stream)=>new Promise((resolve, reject)=>{
const chunks = [];
stream.on('data', (chunk)=>{
chunks.push(chunk);
});
stream.on('end', ()=>{
resolve(Buffer.concat(chunks));
});
stream.on('error', reject);
});
const getStreamSize = (stream)=>new Promise((resolve, reject)=>{
let size = 0;
stream.on('data', (chunk)=>{
size += Buffer.byteLength(chunk);
});
stream.on('close', ()=>resolve(size));
stream.on('error', reject);
stream.resume();
});
/**
* Create a writeable Node.js stream that discards received data.
* Useful for testing, draining a stream of data, etc.
*/ function writableDiscardStream(options) {
return new node_stream.Writable({
...options,
write (chunk, encding, callback) {
setImmediate(callback);
}
});
}
exports.bytesToHumanReadable = bytesToHumanReadable;
exports.bytesToKbytes = bytesToKbytes;
exports.getStreamSize = getStreamSize;
exports.kbytesToBytes = kbytesToBytes;
exports.streamToBuffer = streamToBuffer;
exports.writableDiscardStream = writableDiscardStream;
//# sourceMappingURL=file.js.map

1
server/node_modules/@strapi/utils/dist/file.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"file.js","sources":["../src/file.ts"],"sourcesContent":["/**\n * Utils file containing file treatment utils\n */\nimport { Writable, WritableOptions } from 'node:stream';\n\nconst kbytesToBytes = (kbytes: number) => kbytes * 1000;\nconst bytesToKbytes = (bytes: number) => Math.round((bytes / 1000) * 100) / 100;\nconst bytesToHumanReadable = (bytes: number) => {\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];\n if (bytes === 0) return '0 Bytes';\n const i = parseInt(`${Math.floor(Math.log(bytes) / Math.log(1000))}`, 10);\n return `${Math.round(bytes / 1000 ** i)} ${sizes[i]}`;\n};\n\nconst streamToBuffer = (stream: NodeJS.ReadableStream): Promise<Buffer> =>\n new Promise((resolve, reject) => {\n const chunks: Uint8Array[] = [];\n stream.on('data', (chunk) => {\n chunks.push(chunk);\n });\n stream.on('end', () => {\n resolve(Buffer.concat(chunks));\n });\n stream.on('error', reject);\n });\n\nconst getStreamSize = (stream: NodeJS.ReadableStream) =>\n new Promise((resolve, reject) => {\n let size = 0;\n stream.on('data', (chunk) => {\n size += Buffer.byteLength(chunk);\n });\n stream.on('close', () => resolve(size));\n stream.on('error', reject);\n stream.resume();\n });\n\n/**\n * Create a writeable Node.js stream that discards received data.\n * Useful for testing, draining a stream of data, etc.\n */\nfunction writableDiscardStream(options?: WritableOptions) {\n return new Writable({\n ...options,\n write(chunk, encding, callback) {\n setImmediate(callback);\n },\n });\n}\n\nexport {\n streamToBuffer,\n bytesToHumanReadable,\n bytesToKbytes,\n kbytesToBytes,\n getStreamSize,\n writableDiscardStream,\n};\n"],"names":["kbytesToBytes","kbytes","bytesToKbytes","bytes","Math","round","bytesToHumanReadable","sizes","i","parseInt","floor","log","streamToBuffer","stream","Promise","resolve","reject","chunks","on","chunk","push","Buffer","concat","getStreamSize","size","byteLength","resume","writableDiscardStream","options","Writable","write","encding","callback","setImmediate"],"mappings":";;;;AAKMA,MAAAA,aAAAA,GAAgB,CAACC,MAAAA,GAAmBA,MAAS,GAAA;AAC7CC,MAAAA,aAAAA,GAAgB,CAACC,KAAkBC,GAAAA,IAAAA,CAAKC,KAAK,CAAEF,KAAQ,GAAA,IAAA,GAAQ,GAAO,CAAA,GAAA;AAC5E,MAAMG,uBAAuB,CAACH,KAAAA,GAAAA;AAC5B,IAAA,MAAMI,KAAQ,GAAA;AAAC,QAAA,OAAA;AAAS,QAAA,IAAA;AAAM,QAAA,IAAA;AAAM,QAAA,IAAA;AAAM,QAAA,IAAA;AAAM,QAAA;AAAK,KAAA;IACrD,IAAIJ,KAAAA,KAAU,GAAG,OAAO,SAAA;AACxB,IAAA,MAAMK,IAAIC,QAAS,CAAA,CAAC,EAAEL,IAAAA,CAAKM,KAAK,CAACN,IAAAA,CAAKO,GAAG,CAACR,SAASC,IAAKO,CAAAA,GAAG,CAAC,IAAA,CAAA,CAAA,CAAO,CAAC,EAAE,EAAA,CAAA;AACtE,IAAA,OAAO,CAAC,EAAEP,IAAKC,CAAAA,KAAK,CAACF,KAAQ,GAAA,IAAA,IAAQK,CAAG,CAAA,CAAA,CAAC,EAAED,KAAK,CAACC,CAAAA,CAAE,CAAC,CAAC;AACvD;AAEA,MAAMI,iBAAiB,CAACC,MAAAA,GACtB,IAAIC,OAAAA,CAAQ,CAACC,OAASC,EAAAA,MAAAA,GAAAA;AACpB,QAAA,MAAMC,SAAuB,EAAE;QAC/BJ,MAAOK,CAAAA,EAAE,CAAC,MAAA,EAAQ,CAACC,KAAAA,GAAAA;AACjBF,YAAAA,MAAAA,CAAOG,IAAI,CAACD,KAAAA,CAAAA;AACd,SAAA,CAAA;QACAN,MAAOK,CAAAA,EAAE,CAAC,KAAO,EAAA,IAAA;YACfH,OAAQM,CAAAA,MAAAA,CAAOC,MAAM,CAACL,MAAAA,CAAAA,CAAAA;AACxB,SAAA,CAAA;QACAJ,MAAOK,CAAAA,EAAE,CAAC,OAASF,EAAAA,MAAAA,CAAAA;AACrB,KAAA;AAEF,MAAMO,gBAAgB,CAACV,MAAAA,GACrB,IAAIC,OAAAA,CAAQ,CAACC,OAASC,EAAAA,MAAAA,GAAAA;AACpB,QAAA,IAAIQ,IAAO,GAAA,CAAA;QACXX,MAAOK,CAAAA,EAAE,CAAC,MAAA,EAAQ,CAACC,KAAAA,GAAAA;YACjBK,IAAQH,IAAAA,MAAAA,CAAOI,UAAU,CAACN,KAAAA,CAAAA;AAC5B,SAAA,CAAA;AACAN,QAAAA,MAAAA,CAAOK,EAAE,CAAC,OAAS,EAAA,IAAMH,OAAQS,CAAAA,IAAAA,CAAAA,CAAAA;QACjCX,MAAOK,CAAAA,EAAE,CAAC,OAASF,EAAAA,MAAAA,CAAAA;AACnBH,QAAAA,MAAAA,CAAOa,MAAM,EAAA;AACf,KAAA;AAEF;;;IAIA,SAASC,sBAAsBC,OAAyB,EAAA;AACtD,IAAA,OAAO,IAAIC,oBAAS,CAAA;AAClB,QAAA,GAAGD,OAAO;AACVE,QAAAA,KAAAA,CAAAA,CAAMX,KAAK,EAAEY,OAAO,EAAEC,QAAQ,EAAA;YAC5BC,YAAaD,CAAAA,QAAAA,CAAAA;AACf;AACF,KAAA,CAAA;AACF;;;;;;;;;"}

50
server/node_modules/@strapi/utils/dist/file.mjs generated vendored Normal file
View File

@@ -0,0 +1,50 @@
import { Writable } from 'node:stream';
const kbytesToBytes = (kbytes)=>kbytes * 1000;
const bytesToKbytes = (bytes)=>Math.round(bytes / 1000 * 100) / 100;
const bytesToHumanReadable = (bytes)=>{
const sizes = [
'Bytes',
'KB',
'MB',
'GB',
'TB',
'PB'
];
if (bytes === 0) return '0 Bytes';
const i = parseInt(`${Math.floor(Math.log(bytes) / Math.log(1000))}`, 10);
return `${Math.round(bytes / 1000 ** i)} ${sizes[i]}`;
};
const streamToBuffer = (stream)=>new Promise((resolve, reject)=>{
const chunks = [];
stream.on('data', (chunk)=>{
chunks.push(chunk);
});
stream.on('end', ()=>{
resolve(Buffer.concat(chunks));
});
stream.on('error', reject);
});
const getStreamSize = (stream)=>new Promise((resolve, reject)=>{
let size = 0;
stream.on('data', (chunk)=>{
size += Buffer.byteLength(chunk);
});
stream.on('close', ()=>resolve(size));
stream.on('error', reject);
stream.resume();
});
/**
* Create a writeable Node.js stream that discards received data.
* Useful for testing, draining a stream of data, etc.
*/ function writableDiscardStream(options) {
return new Writable({
...options,
write (chunk, encding, callback) {
setImmediate(callback);
}
});
}
export { bytesToHumanReadable, bytesToKbytes, getStreamSize, kbytesToBytes, streamToBuffer, writableDiscardStream };
//# sourceMappingURL=file.mjs.map

1
server/node_modules/@strapi/utils/dist/file.mjs.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"file.mjs","sources":["../src/file.ts"],"sourcesContent":["/**\n * Utils file containing file treatment utils\n */\nimport { Writable, WritableOptions } from 'node:stream';\n\nconst kbytesToBytes = (kbytes: number) => kbytes * 1000;\nconst bytesToKbytes = (bytes: number) => Math.round((bytes / 1000) * 100) / 100;\nconst bytesToHumanReadable = (bytes: number) => {\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];\n if (bytes === 0) return '0 Bytes';\n const i = parseInt(`${Math.floor(Math.log(bytes) / Math.log(1000))}`, 10);\n return `${Math.round(bytes / 1000 ** i)} ${sizes[i]}`;\n};\n\nconst streamToBuffer = (stream: NodeJS.ReadableStream): Promise<Buffer> =>\n new Promise((resolve, reject) => {\n const chunks: Uint8Array[] = [];\n stream.on('data', (chunk) => {\n chunks.push(chunk);\n });\n stream.on('end', () => {\n resolve(Buffer.concat(chunks));\n });\n stream.on('error', reject);\n });\n\nconst getStreamSize = (stream: NodeJS.ReadableStream) =>\n new Promise((resolve, reject) => {\n let size = 0;\n stream.on('data', (chunk) => {\n size += Buffer.byteLength(chunk);\n });\n stream.on('close', () => resolve(size));\n stream.on('error', reject);\n stream.resume();\n });\n\n/**\n * Create a writeable Node.js stream that discards received data.\n * Useful for testing, draining a stream of data, etc.\n */\nfunction writableDiscardStream(options?: WritableOptions) {\n return new Writable({\n ...options,\n write(chunk, encding, callback) {\n setImmediate(callback);\n },\n });\n}\n\nexport {\n streamToBuffer,\n bytesToHumanReadable,\n bytesToKbytes,\n kbytesToBytes,\n getStreamSize,\n writableDiscardStream,\n};\n"],"names":["kbytesToBytes","kbytes","bytesToKbytes","bytes","Math","round","bytesToHumanReadable","sizes","i","parseInt","floor","log","streamToBuffer","stream","Promise","resolve","reject","chunks","on","chunk","push","Buffer","concat","getStreamSize","size","byteLength","resume","writableDiscardStream","options","Writable","write","encding","callback","setImmediate"],"mappings":";;AAKMA,MAAAA,aAAAA,GAAgB,CAACC,MAAAA,GAAmBA,MAAS,GAAA;AAC7CC,MAAAA,aAAAA,GAAgB,CAACC,KAAkBC,GAAAA,IAAAA,CAAKC,KAAK,CAAEF,KAAQ,GAAA,IAAA,GAAQ,GAAO,CAAA,GAAA;AAC5E,MAAMG,uBAAuB,CAACH,KAAAA,GAAAA;AAC5B,IAAA,MAAMI,KAAQ,GAAA;AAAC,QAAA,OAAA;AAAS,QAAA,IAAA;AAAM,QAAA,IAAA;AAAM,QAAA,IAAA;AAAM,QAAA,IAAA;AAAM,QAAA;AAAK,KAAA;IACrD,IAAIJ,KAAAA,KAAU,GAAG,OAAO,SAAA;AACxB,IAAA,MAAMK,IAAIC,QAAS,CAAA,CAAC,EAAEL,IAAAA,CAAKM,KAAK,CAACN,IAAAA,CAAKO,GAAG,CAACR,SAASC,IAAKO,CAAAA,GAAG,CAAC,IAAA,CAAA,CAAA,CAAO,CAAC,EAAE,EAAA,CAAA;AACtE,IAAA,OAAO,CAAC,EAAEP,IAAKC,CAAAA,KAAK,CAACF,KAAQ,GAAA,IAAA,IAAQK,CAAG,CAAA,CAAA,CAAC,EAAED,KAAK,CAACC,CAAAA,CAAE,CAAC,CAAC;AACvD;AAEA,MAAMI,iBAAiB,CAACC,MAAAA,GACtB,IAAIC,OAAAA,CAAQ,CAACC,OAASC,EAAAA,MAAAA,GAAAA;AACpB,QAAA,MAAMC,SAAuB,EAAE;QAC/BJ,MAAOK,CAAAA,EAAE,CAAC,MAAA,EAAQ,CAACC,KAAAA,GAAAA;AACjBF,YAAAA,MAAAA,CAAOG,IAAI,CAACD,KAAAA,CAAAA;AACd,SAAA,CAAA;QACAN,MAAOK,CAAAA,EAAE,CAAC,KAAO,EAAA,IAAA;YACfH,OAAQM,CAAAA,MAAAA,CAAOC,MAAM,CAACL,MAAAA,CAAAA,CAAAA;AACxB,SAAA,CAAA;QACAJ,MAAOK,CAAAA,EAAE,CAAC,OAASF,EAAAA,MAAAA,CAAAA;AACrB,KAAA;AAEF,MAAMO,gBAAgB,CAACV,MAAAA,GACrB,IAAIC,OAAAA,CAAQ,CAACC,OAASC,EAAAA,MAAAA,GAAAA;AACpB,QAAA,IAAIQ,IAAO,GAAA,CAAA;QACXX,MAAOK,CAAAA,EAAE,CAAC,MAAA,EAAQ,CAACC,KAAAA,GAAAA;YACjBK,IAAQH,IAAAA,MAAAA,CAAOI,UAAU,CAACN,KAAAA,CAAAA;AAC5B,SAAA,CAAA;AACAN,QAAAA,MAAAA,CAAOK,EAAE,CAAC,OAAS,EAAA,IAAMH,OAAQS,CAAAA,IAAAA,CAAAA,CAAAA;QACjCX,MAAOK,CAAAA,EAAE,CAAC,OAASF,EAAAA,MAAAA,CAAAA;AACnBH,QAAAA,MAAAA,CAAOa,MAAM,EAAA;AACf,KAAA;AAEF;;;IAIA,SAASC,sBAAsBC,OAAyB,EAAA;AACtD,IAAA,OAAO,IAAIC,QAAS,CAAA;AAClB,QAAA,GAAGD,OAAO;AACVE,QAAAA,KAAAA,CAAAA,CAAMX,KAAK,EAAEY,OAAO,EAAEC,QAAQ,EAAA;YAC5BC,YAAaD,CAAAA,QAAAA,CAAAA;AACf;AACF,KAAA,CAAA;AACF;;;;"}

View File

@@ -0,0 +1,12 @@
import { ValidationError } from 'yup';
declare const formatYupErrors: (yupError: ValidationError) => {
errors: {
path: string[];
message: string;
name: string;
value: any;
}[];
message: string;
};
export { formatYupErrors };
//# sourceMappingURL=format-yup-error.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"format-yup-error.d.ts","sourceRoot":"","sources":["../src/format-yup-error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAStC,QAAA,MAAM,eAAe,aAAc,eAAe;;;;;;;;CAKhD,CAAC;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC"}

View File

@@ -0,0 +1,19 @@
'use strict';
var fp = require('lodash/fp');
const formatYupInnerError = (yupError)=>({
path: fp.toPath(yupError.path),
message: yupError.message,
name: yupError.name,
value: yupError.value
});
const formatYupErrors = (yupError)=>({
errors: fp.isEmpty(yupError.inner) ? [
formatYupInnerError(yupError)
] : yupError.inner.map(formatYupInnerError),
message: yupError.message
});
exports.formatYupErrors = formatYupErrors;
//# sourceMappingURL=format-yup-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"format-yup-error.js","sources":["../src/format-yup-error.ts"],"sourcesContent":["import { isEmpty, toPath } from 'lodash/fp';\nimport { ValidationError } from 'yup';\n\nconst formatYupInnerError = (yupError: ValidationError) => ({\n path: toPath(yupError.path),\n message: yupError.message,\n name: yupError.name,\n value: yupError.value,\n});\n\nconst formatYupErrors = (yupError: ValidationError) => ({\n errors: isEmpty(yupError.inner)\n ? [formatYupInnerError(yupError)]\n : yupError.inner.map(formatYupInnerError),\n message: yupError.message,\n});\n\nexport { formatYupErrors };\n"],"names":["formatYupInnerError","yupError","path","toPath","message","name","value","formatYupErrors","errors","isEmpty","inner","map"],"mappings":";;;;AAGA,MAAMA,mBAAAA,GAAsB,CAACC,QAAAA,IAA+B;QAC1DC,IAAMC,EAAAA,SAAAA,CAAOF,SAASC,IAAI,CAAA;AAC1BE,QAAAA,OAAAA,EAASH,SAASG,OAAO;AACzBC,QAAAA,IAAAA,EAAMJ,SAASI,IAAI;AACnBC,QAAAA,KAAAA,EAAOL,SAASK;KAClB,CAAA;AAEMC,MAAAA,eAAAA,GAAkB,CAACN,QAAAA,IAA+B;QACtDO,MAAQC,EAAAA,UAAAA,CAAQR,QAASS,CAAAA,KAAK,CAC1B,GAAA;YAACV,mBAAoBC,CAAAA,QAAAA;AAAU,SAAA,GAC/BA,QAASS,CAAAA,KAAK,CAACC,GAAG,CAACX,mBAAAA,CAAAA;AACvBI,QAAAA,OAAAA,EAASH,SAASG;KACpB;;;;"}

View File

@@ -0,0 +1,17 @@
import { isEmpty, toPath } from 'lodash/fp';
const formatYupInnerError = (yupError)=>({
path: toPath(yupError.path),
message: yupError.message,
name: yupError.name,
value: yupError.value
});
const formatYupErrors = (yupError)=>({
errors: isEmpty(yupError.inner) ? [
formatYupInnerError(yupError)
] : yupError.inner.map(formatYupInnerError),
message: yupError.message
});
export { formatYupErrors };
//# sourceMappingURL=format-yup-error.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"format-yup-error.mjs","sources":["../src/format-yup-error.ts"],"sourcesContent":["import { isEmpty, toPath } from 'lodash/fp';\nimport { ValidationError } from 'yup';\n\nconst formatYupInnerError = (yupError: ValidationError) => ({\n path: toPath(yupError.path),\n message: yupError.message,\n name: yupError.name,\n value: yupError.value,\n});\n\nconst formatYupErrors = (yupError: ValidationError) => ({\n errors: isEmpty(yupError.inner)\n ? [formatYupInnerError(yupError)]\n : yupError.inner.map(formatYupInnerError),\n message: yupError.message,\n});\n\nexport { formatYupErrors };\n"],"names":["formatYupInnerError","yupError","path","toPath","message","name","value","formatYupErrors","errors","isEmpty","inner","map"],"mappings":";;AAGA,MAAMA,mBAAAA,GAAsB,CAACC,QAAAA,IAA+B;QAC1DC,IAAMC,EAAAA,MAAAA,CAAOF,SAASC,IAAI,CAAA;AAC1BE,QAAAA,OAAAA,EAASH,SAASG,OAAO;AACzBC,QAAAA,IAAAA,EAAMJ,SAASI,IAAI;AACnBC,QAAAA,KAAAA,EAAOL,SAASK;KAClB,CAAA;AAEMC,MAAAA,eAAAA,GAAkB,CAACN,QAAAA,IAA+B;QACtDO,MAAQC,EAAAA,OAAAA,CAAQR,QAASS,CAAAA,KAAK,CAC1B,GAAA;YAACV,mBAAoBC,CAAAA,QAAAA;AAAU,SAAA,GAC/BA,QAASS,CAAAA,KAAK,CAACC,GAAG,CAACX,mBAAAA,CAAAA;AACvBI,QAAAA,OAAAA,EAASH,SAASG;KACpB;;;;"}

64
server/node_modules/@strapi/utils/dist/hooks.d.ts generated vendored Normal file
View File

@@ -0,0 +1,64 @@
export type Handler = (...args: any[]) => any;
export interface Hook<T extends Handler = Handler> {
getHandlers(): Handler[];
register(handler: T): Hook<T>;
delete(handler: T): Hook<T>;
call(...args: any[]): void;
}
export interface AsyncSeriesHook extends Hook {
call(...args: any[]): Promise<void>;
}
export interface AsyncSeriesWaterfallHook extends Hook {
call(...args: any[]): Promise<any>;
}
export interface AsyncParallelHook extends Hook {
call(...args: any[]): Promise<any[]>;
}
export interface AsyncBailHook extends Hook {
call(...args: any[]): Promise<any>;
}
/**
* Create an async series hook.
* Upon execution, it will execute every handler in order with the same context
*/
declare const createAsyncSeriesHook: <T extends Handler = Handler>() => {
call(context: unknown): Promise<void>;
getHandlers(): Handler[];
register(handler: T): Hook<T>;
delete(handler: T): Hook<T>;
};
/**
* Create an async series waterfall hook.
* Upon execution, it will execute every handler in order and pass the return value of the last handler to the next one
*/
declare const createAsyncSeriesWaterfallHook: <T extends Handler = Handler>() => {
call(param: unknown): Promise<unknown>;
getHandlers(): Handler[];
register(handler: T): Hook<T>;
delete(handler: T): Hook<T>;
};
/**
* Create an async parallel hook.
* Upon execution, it will execute every registered handler in band.
*/
declare const createAsyncParallelHook: <T extends Handler = Handler>() => {
call(context: unknown): Promise<any[]>;
getHandlers(): Handler[];
register(handler: T): Hook<T>;
delete(handler: T): Hook<T>;
};
/**
* Create an async parallel hook.
* Upon execution, it will execute every registered handler in serie and return the first result found.
*/
declare const createAsyncBailHook: <T extends Handler = Handler>() => {
call(context: unknown): Promise<any>;
getHandlers(): Handler[];
register(handler: T): Hook<T>;
delete(handler: T): Hook<T>;
};
export declare const internals: {
createHook: <T extends Handler = Handler>() => Hook<T>;
};
export { createAsyncSeriesHook, createAsyncSeriesWaterfallHook, createAsyncParallelHook, createAsyncBailHook, };
//# sourceMappingURL=hooks.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAE9C,MAAM,WAAW,IAAI,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO;IAC/C,WAAW,IAAI,OAAO,EAAE,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,eAAgB,SAAQ,IAAI;IAC3C,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AACD,MAAM,WAAW,wBAAyB,SAAQ,IAAI;IACpD,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,iBAAkB,SAAQ,IAAI;IAC7C,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI;IACzC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACpC;AAqCD;;;GAGG;AACH,QAAA,MAAM,qBAAqB;kBAGL,OAAO;mBA/DZ,OAAO,EAAE;;;CAoExB,CAAC;AAEH;;;GAGG;AACH,QAAA,MAAM,8BAA8B;gBAGhB,OAAO;mBA7EV,OAAO,EAAE;;;CAsFxB,CAAC;AAEH;;;GAGG;AACH,QAAA,MAAM,uBAAuB;kBAGP,OAAO;mBA/FZ,OAAO,EAAE;;;CAoGxB,CAAC;AAEH;;;GAGG;AACH,QAAA,MAAM,mBAAmB;kBAGH,OAAO;mBA7GZ,OAAO,EAAE;;;CAsHxB,CAAC;AAEH,eAAO,MAAM,SAAS;mDAhG8B,KAAK,CAAC,CAAC;CAmG1D,CAAC;AAEF,OAAO,EACL,qBAAqB,EACrB,8BAA8B,EAC9B,uBAAuB,EACvB,mBAAmB,GACpB,CAAC"}

86
server/node_modules/@strapi/utils/dist/hooks.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
'use strict';
var fp = require('lodash/fp');
/**
* Create a default Strapi hook
*/ const createHook = ()=>{
const state = {
handlers: []
};
return {
getHandlers () {
return state.handlers;
},
register (handler) {
state.handlers.push(handler);
return this;
},
delete (handler) {
state.handlers = fp.remove(fp.eq(handler), state.handlers);
return this;
},
call () {
throw new Error('Method not implemented');
}
};
};
/**
* Create an async series hook.
* Upon execution, it will execute every handler in order with the same context
*/ const createAsyncSeriesHook = ()=>({
...createHook(),
async call (context) {
for (const handler of this.getHandlers()){
await handler(context);
}
}
});
/**
* Create an async series waterfall hook.
* Upon execution, it will execute every handler in order and pass the return value of the last handler to the next one
*/ const createAsyncSeriesWaterfallHook = ()=>({
...createHook(),
async call (param) {
let res = param;
for (const handler of this.getHandlers()){
res = await handler(res);
}
return res;
}
});
/**
* Create an async parallel hook.
* Upon execution, it will execute every registered handler in band.
*/ const createAsyncParallelHook = ()=>({
...createHook(),
async call (context) {
const promises = this.getHandlers().map((handler)=>handler(fp.cloneDeep(context)));
return Promise.all(promises);
}
});
/**
* Create an async parallel hook.
* Upon execution, it will execute every registered handler in serie and return the first result found.
*/ const createAsyncBailHook = ()=>({
...createHook(),
async call (context) {
for (const handler of this.getHandlers()){
const result = await handler(context);
if (result !== undefined) {
return result;
}
}
}
});
const internals = {
// Internal utils
createHook
};
exports.createAsyncBailHook = createAsyncBailHook;
exports.createAsyncParallelHook = createAsyncParallelHook;
exports.createAsyncSeriesHook = createAsyncSeriesHook;
exports.createAsyncSeriesWaterfallHook = createAsyncSeriesWaterfallHook;
exports.internals = internals;
//# sourceMappingURL=hooks.js.map

1
server/node_modules/@strapi/utils/dist/hooks.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

80
server/node_modules/@strapi/utils/dist/hooks.mjs generated vendored Normal file
View File

@@ -0,0 +1,80 @@
import { cloneDeep, remove, eq } from 'lodash/fp';
/**
* Create a default Strapi hook
*/ const createHook = ()=>{
const state = {
handlers: []
};
return {
getHandlers () {
return state.handlers;
},
register (handler) {
state.handlers.push(handler);
return this;
},
delete (handler) {
state.handlers = remove(eq(handler), state.handlers);
return this;
},
call () {
throw new Error('Method not implemented');
}
};
};
/**
* Create an async series hook.
* Upon execution, it will execute every handler in order with the same context
*/ const createAsyncSeriesHook = ()=>({
...createHook(),
async call (context) {
for (const handler of this.getHandlers()){
await handler(context);
}
}
});
/**
* Create an async series waterfall hook.
* Upon execution, it will execute every handler in order and pass the return value of the last handler to the next one
*/ const createAsyncSeriesWaterfallHook = ()=>({
...createHook(),
async call (param) {
let res = param;
for (const handler of this.getHandlers()){
res = await handler(res);
}
return res;
}
});
/**
* Create an async parallel hook.
* Upon execution, it will execute every registered handler in band.
*/ const createAsyncParallelHook = ()=>({
...createHook(),
async call (context) {
const promises = this.getHandlers().map((handler)=>handler(cloneDeep(context)));
return Promise.all(promises);
}
});
/**
* Create an async parallel hook.
* Upon execution, it will execute every registered handler in serie and return the first result found.
*/ const createAsyncBailHook = ()=>({
...createHook(),
async call (context) {
for (const handler of this.getHandlers()){
const result = await handler(context);
if (result !== undefined) {
return result;
}
}
}
});
const internals = {
// Internal utils
createHook
};
export { createAsyncBailHook, createAsyncParallelHook, createAsyncSeriesHook, createAsyncSeriesWaterfallHook, internals };
//# sourceMappingURL=hooks.mjs.map

1
server/node_modules/@strapi/utils/dist/hooks.mjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export default function importDefault(modName: string): any;
//# sourceMappingURL=import-default.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"import-default.d.ts","sourceRoot":"","sources":["../src/import-default.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAO,EAAE,MAAM,OAGpD"}

View File

@@ -0,0 +1,9 @@
'use strict';
/* eslint-disable @typescript-eslint/no-var-requires */ function importDefault(modName) {
const mod = require(modName);
return mod && mod.__esModule ? mod.default : mod;
}
module.exports = importDefault;
//# sourceMappingURL=import-default.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"import-default.js","sources":["../src/import-default.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\n\nexport default function importDefault(modName: string) {\n const mod = require(modName);\n return mod && mod.__esModule ? mod.default : mod;\n}\n"],"names":["importDefault","modName","mod","require","__esModule","default"],"mappings":";;AAAA,wDAEe,SAASA,aAAAA,CAAcC,OAAe,EAAA;AACnD,IAAA,MAAMC,MAAMC,OAAQF,CAAAA,OAAAA,CAAAA;AACpB,IAAA,OAAOC,OAAOA,GAAIE,CAAAA,UAAU,GAAGF,GAAAA,CAAIG,OAAO,GAAGH,GAAAA;AAC/C;;;;"}

View File

@@ -0,0 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */ function importDefault(modName) {
const mod = require(modName);
return mod && mod.__esModule ? mod.default : mod;
}
export { importDefault as default };
//# sourceMappingURL=import-default.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"import-default.mjs","sources":["../src/import-default.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\n\nexport default function importDefault(modName: string) {\n const mod = require(modName);\n return mod && mod.__esModule ? mod.default : mod;\n}\n"],"names":["importDefault","modName","mod","require","__esModule","default"],"mappings":"AAAA,wDAEe,SAASA,aAAAA,CAAcC,OAAe,EAAA;AACnD,IAAA,MAAMC,MAAMC,OAAQF,CAAAA,OAAAA,CAAAA;AACpB,IAAA,OAAOC,OAAOA,GAAIE,CAAAA,UAAU,GAAGF,GAAAA,CAAIG,OAAO,GAAGH,GAAAA;AAC/C;;;;"}

27
server/node_modules/@strapi/utils/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,27 @@
export { default as parseType } from './parse-type';
export { default as env } from './env-helper';
export { default as setCreatorFields } from './set-creator-fields';
export { default as providerFactory } from './provider-factory';
export { default as traverseEntity } from './traverse-entity';
export { default as importDefault } from './import-default';
export { generateInstallId } from './install-id';
export { validateYupSchema, validateYupSchemaSync } from './validators';
export { isOperator, isOperatorOfType } from './operators';
export * as queryParams from './convert-query-params';
export * as sanitize from './sanitize';
export * as validate from './validate';
export * as pagination from './pagination';
export * as packageManager from './package-manager';
export * as traverse from './traverse';
export * as template from './template';
export * as file from './file';
export * as async from './async';
export * as policy from './policy';
export * as yup from './yup';
export * as errors from './errors';
export * as contentTypes from './content-types';
export * as relations from './relations';
export * as hooks from './hooks';
export * from './zod';
export * from './primitives';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,cAAc,OAAO,CAAC;AAEtB,cAAc,cAAc,CAAC"}

66
server/node_modules/@strapi/utils/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
'use strict';
var parseType = require('./parse-type.js');
var envHelper = require('./env-helper.js');
var setCreatorFields = require('./set-creator-fields.js');
var providerFactory = require('./provider-factory.js');
var traverseEntity = require('./traverse-entity.js');
var importDefault = require('./import-default.js');
var installId = require('./install-id.js');
var validators = require('./validators.js');
var operators = require('./operators.js');
var convertQueryParams = require('./convert-query-params.js');
var index = require('./sanitize/index.js');
var index$1 = require('./validate/index.js');
var pagination = require('./pagination.js');
var packageManager = require('./package-manager.js');
var index$2 = require('./traverse/index.js');
var template = require('./template.js');
var file = require('./file.js');
var async = require('./async.js');
var policy = require('./policy.js');
var yup = require('./yup.js');
var errors = require('./errors.js');
var contentTypes = require('./content-types.js');
var relations = require('./relations.js');
var hooks = require('./hooks.js');
var zod = require('./zod.js');
var strings = require('./primitives/strings.js');
var arrays = require('./primitives/arrays.js');
var objects = require('./primitives/objects.js');
var dates = require('./primitives/dates.js');
exports.parseType = parseType;
exports.env = envHelper;
exports.setCreatorFields = setCreatorFields;
exports.providerFactory = providerFactory;
exports.traverseEntity = traverseEntity;
exports.importDefault = importDefault;
exports.generateInstallId = installId.generateInstallId;
exports.validateYupSchema = validators.validateYupSchema;
exports.validateYupSchemaSync = validators.validateYupSchemaSync;
exports.isOperator = operators.isOperator;
exports.isOperatorOfType = operators.isOperatorOfType;
exports.queryParams = convertQueryParams;
exports.sanitize = index;
exports.validate = index$1;
exports.pagination = pagination;
exports.packageManager = packageManager;
exports.traverse = index$2;
exports.template = template;
exports.file = file;
exports.async = async;
exports.policy = policy;
exports.yup = yup;
exports.errors = errors;
exports.contentTypes = contentTypes;
exports.relations = relations;
exports.hooks = hooks;
exports.validateZod = zod.validateZod;
exports.strings = strings;
exports.arrays = arrays;
exports.objects = objects;
exports.dates = dates;
//# sourceMappingURL=index.js.map

1
server/node_modules/@strapi/utils/dist/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

49
server/node_modules/@strapi/utils/dist/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,49 @@
export { default as parseType } from './parse-type.mjs';
export { default as env } from './env-helper.mjs';
export { default as setCreatorFields } from './set-creator-fields.mjs';
export { default as providerFactory } from './provider-factory.mjs';
export { default as traverseEntity } from './traverse-entity.mjs';
export { default as importDefault } from './import-default.mjs';
export { generateInstallId } from './install-id.mjs';
export { validateYupSchema, validateYupSchemaSync } from './validators.mjs';
export { isOperator, isOperatorOfType } from './operators.mjs';
import * as convertQueryParams from './convert-query-params.mjs';
export { convertQueryParams as queryParams };
import * as index from './sanitize/index.mjs';
export { index as sanitize };
import * as index$1 from './validate/index.mjs';
export { index$1 as validate };
import * as pagination from './pagination.mjs';
export { pagination };
import * as packageManager from './package-manager.mjs';
export { packageManager };
import * as index$2 from './traverse/index.mjs';
export { index$2 as traverse };
import * as template from './template.mjs';
export { template };
import * as file from './file.mjs';
export { file };
import * as async from './async.mjs';
export { async };
import * as policy from './policy.mjs';
export { policy };
import * as yup from './yup.mjs';
export { yup };
import * as errors from './errors.mjs';
export { errors };
import * as contentTypes from './content-types.mjs';
export { contentTypes };
import * as relations from './relations.mjs';
export { relations };
import * as hooks from './hooks.mjs';
export { hooks };
export { validateZod } from './zod.mjs';
import * as strings from './primitives/strings.mjs';
export { strings };
import * as arrays from './primitives/arrays.mjs';
export { arrays };
import * as objects from './primitives/objects.mjs';
export { objects };
import * as dates from './primitives/dates.mjs';
export { dates };
//# sourceMappingURL=index.mjs.map

1
server/node_modules/@strapi/utils/dist/index.mjs.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,2 @@
export declare const generateInstallId: (projectId: string, installId: string) => string;
//# sourceMappingURL=install-id.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"install-id.d.ts","sourceRoot":"","sources":["../src/install-id.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,cAAe,MAAM,aAAa,MAAM,WAUrE,CAAC"}

17
server/node_modules/@strapi/utils/dist/install-id.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
'use strict';
var crypto = require('crypto');
var nodeMachineId = require('node-machine-id');
const generateInstallId = (projectId, installId)=>{
if (installId) return installId;
try {
const machineId = nodeMachineId.machineIdSync();
return projectId ? crypto.createHash('sha256').update(`${machineId}-${projectId}`).digest('hex') : crypto.randomUUID();
} catch (error) {
return crypto.randomUUID();
}
};
exports.generateInstallId = generateInstallId;
//# sourceMappingURL=install-id.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"install-id.js","sources":["../src/install-id.ts"],"sourcesContent":["import crypto from 'crypto';\nimport { machineIdSync } from 'node-machine-id';\n\nexport const generateInstallId = (projectId: string, installId: string) => {\n if (installId) return installId;\n try {\n const machineId = machineIdSync();\n return projectId\n ? crypto.createHash('sha256').update(`${machineId}-${projectId}`).digest('hex')\n : crypto.randomUUID();\n } catch (error) {\n return crypto.randomUUID();\n }\n};\n"],"names":["generateInstallId","projectId","installId","machineId","machineIdSync","crypto","createHash","update","digest","randomUUID","error"],"mappings":";;;;;AAGO,MAAMA,iBAAoB,GAAA,CAACC,SAAmBC,EAAAA,SAAAA,GAAAA;AACnD,IAAA,IAAIA,WAAW,OAAOA,SAAAA;IACtB,IAAI;AACF,QAAA,MAAMC,SAAYC,GAAAA,2BAAAA,EAAAA;AAClB,QAAA,OAAOH,YACHI,MAAOC,CAAAA,UAAU,CAAC,QAAUC,CAAAA,CAAAA,MAAM,CAAC,CAAC,EAAEJ,UAAU,CAAC,EAAEF,UAAU,CAAC,CAAA,CAAEO,MAAM,CAAC,KAAA,CAAA,GACvEH,OAAOI,UAAU,EAAA;AACvB,KAAA,CAAE,OAAOC,KAAO,EAAA;AACd,QAAA,OAAOL,OAAOI,UAAU,EAAA;AAC1B;AACF;;;;"}

15
server/node_modules/@strapi/utils/dist/install-id.mjs generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import crypto from 'crypto';
import { machineIdSync } from 'node-machine-id';
const generateInstallId = (projectId, installId)=>{
if (installId) return installId;
try {
const machineId = machineIdSync();
return projectId ? crypto.createHash('sha256').update(`${machineId}-${projectId}`).digest('hex') : crypto.randomUUID();
} catch (error) {
return crypto.randomUUID();
}
};
export { generateInstallId };
//# sourceMappingURL=install-id.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"install-id.mjs","sources":["../src/install-id.ts"],"sourcesContent":["import crypto from 'crypto';\nimport { machineIdSync } from 'node-machine-id';\n\nexport const generateInstallId = (projectId: string, installId: string) => {\n if (installId) return installId;\n try {\n const machineId = machineIdSync();\n return projectId\n ? crypto.createHash('sha256').update(`${machineId}-${projectId}`).digest('hex')\n : crypto.randomUUID();\n } catch (error) {\n return crypto.randomUUID();\n }\n};\n"],"names":["generateInstallId","projectId","installId","machineId","machineIdSync","crypto","createHash","update","digest","randomUUID","error"],"mappings":";;;AAGO,MAAMA,iBAAoB,GAAA,CAACC,SAAmBC,EAAAA,SAAAA,GAAAA;AACnD,IAAA,IAAIA,WAAW,OAAOA,SAAAA;IACtB,IAAI;AACF,QAAA,MAAMC,SAAYC,GAAAA,aAAAA,EAAAA;AAClB,QAAA,OAAOH,YACHI,MAAOC,CAAAA,UAAU,CAAC,QAAUC,CAAAA,CAAAA,MAAM,CAAC,CAAC,EAAEJ,UAAU,CAAC,EAAEF,UAAU,CAAC,CAAA,CAAEO,MAAM,CAAC,KAAA,CAAA,GACvEH,OAAOI,UAAU,EAAA;AACvB,KAAA,CAAE,OAAOC,KAAO,EAAA;AACd,QAAA,OAAOL,OAAOI,UAAU,EAAA;AAC1B;AACF;;;;"}

View File

@@ -0,0 +1,3 @@
export declare const isOperatorOfType: (type: string, key: string, ignoreCase?: boolean) => boolean;
export declare const isOperator: (key: string, ignoreCase?: boolean) => boolean;
//# sourceMappingURL=operators.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../src/operators.ts"],"names":[],"mappings":"AA+DA,eAAO,MAAM,gBAAgB,SAAU,MAAM,OAAO,MAAM,kCAUzD,CAAC;AAEF,eAAO,MAAM,UAAU,QAAS,MAAM,kCAErC,CAAC"}

79
server/node_modules/@strapi/utils/dist/operators.js generated vendored Normal file
View File

@@ -0,0 +1,79 @@
'use strict';
const GROUP_OPERATORS = [
'$and',
'$or'
];
const WHERE_OPERATORS = [
'$not',
'$in',
'$notIn',
'$eq',
'$eqi',
'$ne',
'$nei',
'$gt',
'$gte',
'$lt',
'$lte',
'$null',
'$notNull',
'$between',
'$startsWith',
'$endsWith',
'$startsWithi',
'$endsWithi',
'$contains',
'$notContains',
'$containsi',
'$notContainsi',
// Experimental, only for internal use
'$jsonSupersetOf'
];
const CAST_OPERATORS = [
'$not',
'$in',
'$notIn',
'$eq',
'$ne',
'$gt',
'$gte',
'$lt',
'$lte',
'$between'
];
const ARRAY_OPERATORS = [
'$in',
'$notIn',
'$between'
];
const OPERATORS = {
where: WHERE_OPERATORS,
cast: CAST_OPERATORS,
group: GROUP_OPERATORS,
array: ARRAY_OPERATORS
};
// for performance, cache all operators in lowercase
const OPERATORS_LOWERCASE = Object.fromEntries(Object.entries(OPERATORS).map(([key, values])=>[
key,
values.map((value)=>value.toLowerCase())
]));
const isObjKey = (key, obj)=>{
return key in obj;
};
const isOperatorOfType = (type, key, ignoreCase = false)=>{
if (ignoreCase) {
return OPERATORS_LOWERCASE[type]?.includes(key.toLowerCase()) ?? false;
}
if (isObjKey(type, OPERATORS)) {
return OPERATORS[type]?.includes(key) ?? false;
}
return false;
};
const isOperator = (key, ignoreCase = false)=>{
return Object.keys(OPERATORS).some((type)=>isOperatorOfType(type, key, ignoreCase));
};
exports.isOperator = isOperator;
exports.isOperatorOfType = isOperatorOfType;
//# sourceMappingURL=operators.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"operators.js","sources":["../src/operators.ts"],"sourcesContent":["const GROUP_OPERATORS = ['$and', '$or'];\n\nconst WHERE_OPERATORS = [\n '$not',\n '$in',\n '$notIn',\n '$eq',\n '$eqi',\n '$ne',\n '$nei',\n '$gt',\n '$gte',\n '$lt',\n '$lte',\n '$null',\n '$notNull',\n '$between',\n '$startsWith',\n '$endsWith',\n '$startsWithi',\n '$endsWithi',\n '$contains',\n '$notContains',\n '$containsi',\n '$notContainsi',\n // Experimental, only for internal use\n '$jsonSupersetOf',\n];\n\nconst CAST_OPERATORS = [\n '$not',\n '$in',\n '$notIn',\n '$eq',\n '$ne',\n '$gt',\n '$gte',\n '$lt',\n '$lte',\n '$between',\n];\n\nconst ARRAY_OPERATORS = ['$in', '$notIn', '$between'];\n\nconst OPERATORS = {\n where: WHERE_OPERATORS,\n cast: CAST_OPERATORS,\n group: GROUP_OPERATORS,\n array: ARRAY_OPERATORS,\n};\n\n// for performance, cache all operators in lowercase\nconst OPERATORS_LOWERCASE = Object.fromEntries(\n Object.entries(OPERATORS).map(([key, values]) => [\n key,\n values.map((value) => value.toLowerCase()),\n ])\n);\n\nconst isObjKey = <T extends object>(key: string | symbol | number, obj: T): key is keyof T => {\n return key in obj;\n};\n\nexport const isOperatorOfType = (type: string, key: string, ignoreCase = false) => {\n if (ignoreCase) {\n return OPERATORS_LOWERCASE[type]?.includes(key.toLowerCase()) ?? false;\n }\n\n if (isObjKey(type, OPERATORS)) {\n return OPERATORS[type]?.includes(key) ?? false;\n }\n\n return false;\n};\n\nexport const isOperator = (key: string, ignoreCase = false) => {\n return Object.keys(OPERATORS).some((type) => isOperatorOfType(type, key, ignoreCase));\n};\n"],"names":["GROUP_OPERATORS","WHERE_OPERATORS","CAST_OPERATORS","ARRAY_OPERATORS","OPERATORS","where","cast","group","array","OPERATORS_LOWERCASE","Object","fromEntries","entries","map","key","values","value","toLowerCase","isObjKey","obj","isOperatorOfType","type","ignoreCase","includes","isOperator","keys","some"],"mappings":";;AAAA,MAAMA,eAAkB,GAAA;AAAC,IAAA,MAAA;AAAQ,IAAA;AAAM,CAAA;AAEvC,MAAMC,eAAkB,GAAA;AACtB,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,QAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA,OAAA;AACA,IAAA,UAAA;AACA,IAAA,UAAA;AACA,IAAA,aAAA;AACA,IAAA,WAAA;AACA,IAAA,cAAA;AACA,IAAA,YAAA;AACA,IAAA,WAAA;AACA,IAAA,cAAA;AACA,IAAA,YAAA;AACA,IAAA,eAAA;;AAEA,IAAA;AACD,CAAA;AAED,MAAMC,cAAiB,GAAA;AACrB,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,QAAA;AACA,IAAA,KAAA;AACA,IAAA,KAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,eAAkB,GAAA;AAAC,IAAA,KAAA;AAAO,IAAA,QAAA;AAAU,IAAA;AAAW,CAAA;AAErD,MAAMC,SAAY,GAAA;IAChBC,KAAOJ,EAAAA,eAAAA;IACPK,IAAMJ,EAAAA,cAAAA;IACNK,KAAOP,EAAAA,eAAAA;IACPQ,KAAOL,EAAAA;AACT,CAAA;AAEA;AACA,MAAMM,mBAAsBC,GAAAA,MAAAA,CAAOC,WAAW,CAC5CD,OAAOE,OAAO,CAACR,SAAWS,CAAAA,CAAAA,GAAG,CAAC,CAAC,CAACC,GAAAA,EAAKC,OAAO,GAAK;AAC/CD,QAAAA,GAAAA;AACAC,QAAAA,MAAAA,CAAOF,GAAG,CAAC,CAACG,KAAAA,GAAUA,MAAMC,WAAW,EAAA;AACxC,KAAA,CAAA,CAAA;AAGH,MAAMC,QAAAA,GAAW,CAAmBJ,GAA+BK,EAAAA,GAAAA,GAAAA;AACjE,IAAA,OAAOL,GAAOK,IAAAA,GAAAA;AAChB,CAAA;MAEaC,gBAAmB,GAAA,CAACC,IAAcP,EAAAA,GAAAA,EAAaQ,aAAa,KAAK,GAAA;AAC5E,IAAA,IAAIA,UAAY,EAAA;AACd,QAAA,OAAOb,mBAAmB,CAACY,IAAAA,CAAK,EAAEE,QAAST,CAAAA,GAAAA,CAAIG,WAAW,EAAO,CAAA,IAAA,KAAA;AACnE;IAEA,IAAIC,QAAAA,CAASG,MAAMjB,SAAY,CAAA,EAAA;AAC7B,QAAA,OAAOA,SAAS,CAACiB,IAAK,CAAA,EAAEE,SAAST,GAAQ,CAAA,IAAA,KAAA;AAC3C;IAEA,OAAO,KAAA;AACT;AAEaU,MAAAA,UAAAA,GAAa,CAACV,GAAAA,EAAaQ,aAAa,KAAK,GAAA;IACxD,OAAOZ,MAAAA,CAAOe,IAAI,CAACrB,SAAWsB,CAAAA,CAAAA,IAAI,CAAC,CAACL,IAAAA,GAASD,gBAAiBC,CAAAA,IAAAA,EAAMP,GAAKQ,EAAAA,UAAAA,CAAAA,CAAAA;AAC3E;;;;;"}

76
server/node_modules/@strapi/utils/dist/operators.mjs generated vendored Normal file
View File

@@ -0,0 +1,76 @@
const GROUP_OPERATORS = [
'$and',
'$or'
];
const WHERE_OPERATORS = [
'$not',
'$in',
'$notIn',
'$eq',
'$eqi',
'$ne',
'$nei',
'$gt',
'$gte',
'$lt',
'$lte',
'$null',
'$notNull',
'$between',
'$startsWith',
'$endsWith',
'$startsWithi',
'$endsWithi',
'$contains',
'$notContains',
'$containsi',
'$notContainsi',
// Experimental, only for internal use
'$jsonSupersetOf'
];
const CAST_OPERATORS = [
'$not',
'$in',
'$notIn',
'$eq',
'$ne',
'$gt',
'$gte',
'$lt',
'$lte',
'$between'
];
const ARRAY_OPERATORS = [
'$in',
'$notIn',
'$between'
];
const OPERATORS = {
where: WHERE_OPERATORS,
cast: CAST_OPERATORS,
group: GROUP_OPERATORS,
array: ARRAY_OPERATORS
};
// for performance, cache all operators in lowercase
const OPERATORS_LOWERCASE = Object.fromEntries(Object.entries(OPERATORS).map(([key, values])=>[
key,
values.map((value)=>value.toLowerCase())
]));
const isObjKey = (key, obj)=>{
return key in obj;
};
const isOperatorOfType = (type, key, ignoreCase = false)=>{
if (ignoreCase) {
return OPERATORS_LOWERCASE[type]?.includes(key.toLowerCase()) ?? false;
}
if (isObjKey(type, OPERATORS)) {
return OPERATORS[type]?.includes(key) ?? false;
}
return false;
};
const isOperator = (key, ignoreCase = false)=>{
return Object.keys(OPERATORS).some((type)=>isOperatorOfType(type, key, ignoreCase));
};
export { isOperator, isOperatorOfType };
//# sourceMappingURL=operators.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"operators.mjs","sources":["../src/operators.ts"],"sourcesContent":["const GROUP_OPERATORS = ['$and', '$or'];\n\nconst WHERE_OPERATORS = [\n '$not',\n '$in',\n '$notIn',\n '$eq',\n '$eqi',\n '$ne',\n '$nei',\n '$gt',\n '$gte',\n '$lt',\n '$lte',\n '$null',\n '$notNull',\n '$between',\n '$startsWith',\n '$endsWith',\n '$startsWithi',\n '$endsWithi',\n '$contains',\n '$notContains',\n '$containsi',\n '$notContainsi',\n // Experimental, only for internal use\n '$jsonSupersetOf',\n];\n\nconst CAST_OPERATORS = [\n '$not',\n '$in',\n '$notIn',\n '$eq',\n '$ne',\n '$gt',\n '$gte',\n '$lt',\n '$lte',\n '$between',\n];\n\nconst ARRAY_OPERATORS = ['$in', '$notIn', '$between'];\n\nconst OPERATORS = {\n where: WHERE_OPERATORS,\n cast: CAST_OPERATORS,\n group: GROUP_OPERATORS,\n array: ARRAY_OPERATORS,\n};\n\n// for performance, cache all operators in lowercase\nconst OPERATORS_LOWERCASE = Object.fromEntries(\n Object.entries(OPERATORS).map(([key, values]) => [\n key,\n values.map((value) => value.toLowerCase()),\n ])\n);\n\nconst isObjKey = <T extends object>(key: string | symbol | number, obj: T): key is keyof T => {\n return key in obj;\n};\n\nexport const isOperatorOfType = (type: string, key: string, ignoreCase = false) => {\n if (ignoreCase) {\n return OPERATORS_LOWERCASE[type]?.includes(key.toLowerCase()) ?? false;\n }\n\n if (isObjKey(type, OPERATORS)) {\n return OPERATORS[type]?.includes(key) ?? false;\n }\n\n return false;\n};\n\nexport const isOperator = (key: string, ignoreCase = false) => {\n return Object.keys(OPERATORS).some((type) => isOperatorOfType(type, key, ignoreCase));\n};\n"],"names":["GROUP_OPERATORS","WHERE_OPERATORS","CAST_OPERATORS","ARRAY_OPERATORS","OPERATORS","where","cast","group","array","OPERATORS_LOWERCASE","Object","fromEntries","entries","map","key","values","value","toLowerCase","isObjKey","obj","isOperatorOfType","type","ignoreCase","includes","isOperator","keys","some"],"mappings":"AAAA,MAAMA,eAAkB,GAAA;AAAC,IAAA,MAAA;AAAQ,IAAA;AAAM,CAAA;AAEvC,MAAMC,eAAkB,GAAA;AACtB,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,QAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA,OAAA;AACA,IAAA,UAAA;AACA,IAAA,UAAA;AACA,IAAA,aAAA;AACA,IAAA,WAAA;AACA,IAAA,cAAA;AACA,IAAA,YAAA;AACA,IAAA,WAAA;AACA,IAAA,cAAA;AACA,IAAA,YAAA;AACA,IAAA,eAAA;;AAEA,IAAA;AACD,CAAA;AAED,MAAMC,cAAiB,GAAA;AACrB,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,QAAA;AACA,IAAA,KAAA;AACA,IAAA,KAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,eAAkB,GAAA;AAAC,IAAA,KAAA;AAAO,IAAA,QAAA;AAAU,IAAA;AAAW,CAAA;AAErD,MAAMC,SAAY,GAAA;IAChBC,KAAOJ,EAAAA,eAAAA;IACPK,IAAMJ,EAAAA,cAAAA;IACNK,KAAOP,EAAAA,eAAAA;IACPQ,KAAOL,EAAAA;AACT,CAAA;AAEA;AACA,MAAMM,mBAAsBC,GAAAA,MAAAA,CAAOC,WAAW,CAC5CD,OAAOE,OAAO,CAACR,SAAWS,CAAAA,CAAAA,GAAG,CAAC,CAAC,CAACC,GAAAA,EAAKC,OAAO,GAAK;AAC/CD,QAAAA,GAAAA;AACAC,QAAAA,MAAAA,CAAOF,GAAG,CAAC,CAACG,KAAAA,GAAUA,MAAMC,WAAW,EAAA;AACxC,KAAA,CAAA,CAAA;AAGH,MAAMC,QAAAA,GAAW,CAAmBJ,GAA+BK,EAAAA,GAAAA,GAAAA;AACjE,IAAA,OAAOL,GAAOK,IAAAA,GAAAA;AAChB,CAAA;MAEaC,gBAAmB,GAAA,CAACC,IAAcP,EAAAA,GAAAA,EAAaQ,aAAa,KAAK,GAAA;AAC5E,IAAA,IAAIA,UAAY,EAAA;AACd,QAAA,OAAOb,mBAAmB,CAACY,IAAAA,CAAK,EAAEE,QAAST,CAAAA,GAAAA,CAAIG,WAAW,EAAO,CAAA,IAAA,KAAA;AACnE;IAEA,IAAIC,QAAAA,CAASG,MAAMjB,SAAY,CAAA,EAAA;AAC7B,QAAA,OAAOA,SAAS,CAACiB,IAAK,CAAA,EAAEE,SAAST,GAAQ,CAAA,IAAA,KAAA;AAC3C;IAEA,OAAO,KAAA;AACT;AAEaU,MAAAA,UAAAA,GAAa,CAACV,GAAAA,EAAaQ,aAAa,KAAK,GAAA;IACxD,OAAOZ,MAAAA,CAAOe,IAAI,CAACrB,SAAWsB,CAAAA,CAAAA,IAAI,CAAC,CAACL,IAAAA,GAASD,gBAAiBC,CAAAA,IAAAA,EAAMP,GAAKQ,EAAAA,UAAAA,CAAAA,CAAAA;AAC3E;;;;"}

View File

@@ -0,0 +1,7 @@
import execa from 'execa';
import type { Options as ProcessOptions } from 'execa';
type SupportedPackageManagerName = 'npm' | 'yarn';
export declare const getPreferred: (pkgPath: string) => Promise<SupportedPackageManagerName>;
export declare const installDependencies: (path: string, packageManager: SupportedPackageManagerName, options?: ProcessOptions<string>) => execa.ExecaChildProcess<string>;
export {};
//# sourceMappingURL=package-manager.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../src/package-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,OAAO,CAAC;AAKvD,KAAK,2BAA2B,GAAG,KAAK,GAAG,MAAM,CAAC;AAElD,eAAO,MAAM,YAAY,YAAmB,MAAM,KAAG,QAAQ,2BAA2B,CAkBvF,CAAC;AAEF,eAAO,MAAM,mBAAmB,SACxB,MAAM,kBACI,2BAA2B,YAClC,eAAe,MAAM,CAAC,oCAGhC,CAAC"}

View File

@@ -0,0 +1,36 @@
'use strict';
var execa = require('execa');
var preferredPM = require('preferred-pm');
const SUPPORTED_PACKAGE_MANAGERS = [
'npm',
'yarn'
];
const DEFAULT_PACKAGE_MANAGER = 'npm';
const getPreferred = async (pkgPath)=>{
const pm = await preferredPM(pkgPath);
const hasPackageManager = pm !== undefined;
if (!hasPackageManager) {
throw new Error(`Couldn't find a package manager in your project.`);
}
const isPackageManagerSupported = SUPPORTED_PACKAGE_MANAGERS.includes(pm.name);
if (!isPackageManagerSupported) {
process.emitWarning(`We detected your package manager (${pm.name} v${pm.version}), but it's not officially supported by Strapi yet. Defaulting to npm instead.`);
return DEFAULT_PACKAGE_MANAGER;
}
return pm.name;
};
const installDependencies = (path, packageManager, options = {})=>{
return execa(packageManager, [
'install'
], {
...options,
cwd: path,
stdin: 'ignore'
});
};
exports.getPreferred = getPreferred;
exports.installDependencies = installDependencies;
//# sourceMappingURL=package-manager.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"package-manager.js","sources":["../src/package-manager.ts"],"sourcesContent":["import execa from 'execa';\nimport preferredPM from 'preferred-pm';\n\nimport type { Options as ProcessOptions } from 'execa';\n\nconst SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn'];\nconst DEFAULT_PACKAGE_MANAGER = 'npm' as const;\n\ntype SupportedPackageManagerName = 'npm' | 'yarn';\n\nexport const getPreferred = async (pkgPath: string): Promise<SupportedPackageManagerName> => {\n const pm = await preferredPM(pkgPath);\n\n const hasPackageManager = pm !== undefined;\n if (!hasPackageManager) {\n throw new Error(`Couldn't find a package manager in your project.`);\n }\n\n const isPackageManagerSupported = SUPPORTED_PACKAGE_MANAGERS.includes(pm.name);\n if (!isPackageManagerSupported) {\n process.emitWarning(\n `We detected your package manager (${pm.name} v${pm.version}), but it's not officially supported by Strapi yet. Defaulting to npm instead.`\n );\n\n return DEFAULT_PACKAGE_MANAGER;\n }\n\n return pm.name as SupportedPackageManagerName;\n};\n\nexport const installDependencies = (\n path: string,\n packageManager: SupportedPackageManagerName,\n options: ProcessOptions<string> = {}\n) => {\n return execa(packageManager, ['install'], { ...options, cwd: path, stdin: 'ignore' });\n};\n"],"names":["SUPPORTED_PACKAGE_MANAGERS","DEFAULT_PACKAGE_MANAGER","getPreferred","pkgPath","pm","preferredPM","hasPackageManager","undefined","Error","isPackageManagerSupported","includes","name","process","emitWarning","version","installDependencies","path","packageManager","options","execa","cwd","stdin"],"mappings":";;;;;AAKA,MAAMA,0BAA6B,GAAA;AAAC,IAAA,KAAA;AAAO,IAAA;AAAO,CAAA;AAClD,MAAMC,uBAA0B,GAAA,KAAA;AAIzB,MAAMC,eAAe,OAAOC,OAAAA,GAAAA;IACjC,MAAMC,EAAAA,GAAK,MAAMC,WAAYF,CAAAA,OAAAA,CAAAA;AAE7B,IAAA,MAAMG,oBAAoBF,EAAOG,KAAAA,SAAAA;AACjC,IAAA,IAAI,CAACD,iBAAmB,EAAA;AACtB,QAAA,MAAM,IAAIE,KAAAA,CAAM,CAAC,gDAAgD,CAAC,CAAA;AACpE;AAEA,IAAA,MAAMC,yBAA4BT,GAAAA,0BAAAA,CAA2BU,QAAQ,CAACN,GAAGO,IAAI,CAAA;AAC7E,IAAA,IAAI,CAACF,yBAA2B,EAAA;AAC9BG,QAAAA,OAAAA,CAAQC,WAAW,CACjB,CAAC,kCAAkC,EAAET,EAAGO,CAAAA,IAAI,CAAC,EAAE,EAAEP,EAAAA,CAAGU,OAAO,CAAC,8EAA8E,CAAC,CAAA;QAG7I,OAAOb,uBAAAA;AACT;AAEA,IAAA,OAAOG,GAAGO,IAAI;AAChB;MAEaI,mBAAsB,GAAA,CACjCC,MACAC,cACAC,EAAAA,OAAAA,GAAkC,EAAE,GAAA;AAEpC,IAAA,OAAOC,MAAMF,cAAgB,EAAA;AAAC,QAAA;KAAU,EAAE;AAAE,QAAA,GAAGC,OAAO;QAAEE,GAAKJ,EAAAA,IAAAA;QAAMK,KAAO,EAAA;AAAS,KAAA,CAAA;AACrF;;;;;"}

View File

@@ -0,0 +1,33 @@
import execa from 'execa';
import preferredPM from 'preferred-pm';
const SUPPORTED_PACKAGE_MANAGERS = [
'npm',
'yarn'
];
const DEFAULT_PACKAGE_MANAGER = 'npm';
const getPreferred = async (pkgPath)=>{
const pm = await preferredPM(pkgPath);
const hasPackageManager = pm !== undefined;
if (!hasPackageManager) {
throw new Error(`Couldn't find a package manager in your project.`);
}
const isPackageManagerSupported = SUPPORTED_PACKAGE_MANAGERS.includes(pm.name);
if (!isPackageManagerSupported) {
process.emitWarning(`We detected your package manager (${pm.name} v${pm.version}), but it's not officially supported by Strapi yet. Defaulting to npm instead.`);
return DEFAULT_PACKAGE_MANAGER;
}
return pm.name;
};
const installDependencies = (path, packageManager, options = {})=>{
return execa(packageManager, [
'install'
], {
...options,
cwd: path,
stdin: 'ignore'
});
};
export { getPreferred, installDependencies };
//# sourceMappingURL=package-manager.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"package-manager.mjs","sources":["../src/package-manager.ts"],"sourcesContent":["import execa from 'execa';\nimport preferredPM from 'preferred-pm';\n\nimport type { Options as ProcessOptions } from 'execa';\n\nconst SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn'];\nconst DEFAULT_PACKAGE_MANAGER = 'npm' as const;\n\ntype SupportedPackageManagerName = 'npm' | 'yarn';\n\nexport const getPreferred = async (pkgPath: string): Promise<SupportedPackageManagerName> => {\n const pm = await preferredPM(pkgPath);\n\n const hasPackageManager = pm !== undefined;\n if (!hasPackageManager) {\n throw new Error(`Couldn't find a package manager in your project.`);\n }\n\n const isPackageManagerSupported = SUPPORTED_PACKAGE_MANAGERS.includes(pm.name);\n if (!isPackageManagerSupported) {\n process.emitWarning(\n `We detected your package manager (${pm.name} v${pm.version}), but it's not officially supported by Strapi yet. Defaulting to npm instead.`\n );\n\n return DEFAULT_PACKAGE_MANAGER;\n }\n\n return pm.name as SupportedPackageManagerName;\n};\n\nexport const installDependencies = (\n path: string,\n packageManager: SupportedPackageManagerName,\n options: ProcessOptions<string> = {}\n) => {\n return execa(packageManager, ['install'], { ...options, cwd: path, stdin: 'ignore' });\n};\n"],"names":["SUPPORTED_PACKAGE_MANAGERS","DEFAULT_PACKAGE_MANAGER","getPreferred","pkgPath","pm","preferredPM","hasPackageManager","undefined","Error","isPackageManagerSupported","includes","name","process","emitWarning","version","installDependencies","path","packageManager","options","execa","cwd","stdin"],"mappings":";;;AAKA,MAAMA,0BAA6B,GAAA;AAAC,IAAA,KAAA;AAAO,IAAA;AAAO,CAAA;AAClD,MAAMC,uBAA0B,GAAA,KAAA;AAIzB,MAAMC,eAAe,OAAOC,OAAAA,GAAAA;IACjC,MAAMC,EAAAA,GAAK,MAAMC,WAAYF,CAAAA,OAAAA,CAAAA;AAE7B,IAAA,MAAMG,oBAAoBF,EAAOG,KAAAA,SAAAA;AACjC,IAAA,IAAI,CAACD,iBAAmB,EAAA;AACtB,QAAA,MAAM,IAAIE,KAAAA,CAAM,CAAC,gDAAgD,CAAC,CAAA;AACpE;AAEA,IAAA,MAAMC,yBAA4BT,GAAAA,0BAAAA,CAA2BU,QAAQ,CAACN,GAAGO,IAAI,CAAA;AAC7E,IAAA,IAAI,CAACF,yBAA2B,EAAA;AAC9BG,QAAAA,OAAAA,CAAQC,WAAW,CACjB,CAAC,kCAAkC,EAAET,EAAGO,CAAAA,IAAI,CAAC,EAAE,EAAEP,EAAAA,CAAGU,OAAO,CAAC,8EAA8E,CAAC,CAAA;QAG7I,OAAOb,uBAAAA;AACT;AAEA,IAAA,OAAOG,GAAGO,IAAI;AAChB;MAEaI,mBAAsB,GAAA,CACjCC,MACAC,cACAC,EAAAA,OAAAA,GAAkC,EAAE,GAAA;AAEpC,IAAA,OAAOC,MAAMF,cAAgB,EAAA;AAAC,QAAA;KAAU,EAAE;AAAE,QAAA,GAAGC,OAAO;QAAEE,GAAKJ,EAAAA,IAAAA;QAAMK,KAAO,EAAA;AAAS,KAAA,CAAA;AACrF;;;;"}

49
server/node_modules/@strapi/utils/dist/pagination.d.ts generated vendored Normal file
View File

@@ -0,0 +1,49 @@
interface PaginationArgs {
page: number;
pageSize: number;
start: number;
limit: number;
}
export interface Pagination {
start: number;
limit: number;
}
export interface PagePatinationInformation {
page: number;
pageSize: number;
pageCount: number;
total: number;
}
export interface OffsetPaginationInformation {
start: number;
limit: number;
total: number;
}
declare const withDefaultPagination: <T extends Partial<PaginationArgs>>(args: T, { defaults, maxLimit }?: {
defaults?: {} | undefined;
maxLimit?: number | undefined;
}) => {
start: number;
limit: number;
} & Partial<T>;
/**
* Transform pagination information into a paginated response:
* {
* page: number,
* pageSize: number,
* pageCount: number,
* total: number
* }
*/
declare const transformPagedPaginationInfo: (paginationInfo: Partial<PaginationArgs>, total: number) => PagePatinationInformation;
/**
* Transform pagination information into a offset response:
* {
* start: number,
* limit: number,
* total: number
* }
*/
declare const transformOffsetPaginationInfo: (paginationInfo: Partial<PaginationArgs>, total: number) => OffsetPaginationInformation;
export { withDefaultPagination, transformPagedPaginationInfo, transformOffsetPaginationInfo };
//# sourceMappingURL=pagination.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAGA,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AA0CD,QAAA,MAAM,qBAAqB,4CACnB,CAAC;;;;;;cAwDR,CAAC;AAEF;;;;;;;;GAQG;AACH,QAAA,MAAM,4BAA4B,mBAChB,QAAQ,cAAc,CAAC,SAChC,MAAM,KACZ,yBAkCF,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,6BAA6B,mBACjB,QAAQ,cAAc,CAAC,SAChC,MAAM,KACZ,2BAuBF,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,CAAC"}

163
server/node_modules/@strapi/utils/dist/pagination.js generated vendored Normal file
View File

@@ -0,0 +1,163 @@
'use strict';
var fp = require('lodash/fp');
var errors = require('./errors.js');
const STRAPI_DEFAULTS = {
offset: {
start: 0,
limit: 10
},
page: {
page: 1,
pageSize: 10
}
};
const paginationAttributes = [
'start',
'limit',
'page',
'pageSize'
];
const withMaxLimit = (limit, maxLimit = -1)=>{
if (maxLimit === -1 || limit < maxLimit) {
return limit;
}
return maxLimit;
};
// Ensure minimum page & pageSize values (page >= 1, pageSize >= 0, start >= 0, limit >= 0)
const ensureMinValues = ({ start, limit })=>({
start: Math.max(start, 0),
limit: limit === -1 ? limit : Math.max(limit, 1)
});
const ensureMaxValues = (maxLimit = -1)=>({ start, limit })=>({
start,
limit: withMaxLimit(limit, maxLimit)
});
// Apply maxLimit as the limit when limit is -1
const withNoLimit = (pagination, maxLimit = -1)=>({
...pagination,
limit: pagination.limit === -1 ? maxLimit : pagination.limit
});
const withDefaultPagination = (args, { defaults = {}, maxLimit = -1 } = {})=>{
const defaultValues = fp.merge(STRAPI_DEFAULTS, defaults);
const usePagePagination = !fp.isNil(args.page) || !fp.isNil(args.pageSize);
const useOffsetPagination = !fp.isNil(args.start) || !fp.isNil(args.limit);
const ensureValidValues = fp.pipe(ensureMinValues, ensureMaxValues(maxLimit));
// If there is no pagination attribute, don't modify the payload
if (!usePagePagination && !useOffsetPagination) {
return fp.merge(args, ensureValidValues(defaultValues.offset));
}
// If there is page & offset pagination attributes, throw an error
if (usePagePagination && useOffsetPagination) {
throw new errors.PaginationError('Cannot use both page & offset pagination in the same query');
}
const pagination = {
start: 0,
limit: 0
};
// Start / Limit
if (useOffsetPagination) {
const { start, limit } = fp.merge(defaultValues.offset, args);
Object.assign(pagination, {
start,
limit
});
}
// Page / PageSize
if (usePagePagination) {
const { page, pageSize } = fp.merge(defaultValues.page, {
...args,
pageSize: Math.max(1, args.pageSize ?? 0)
});
Object.assign(pagination, {
start: (page - 1) * pageSize,
limit: pageSize
});
}
// Handle -1 limit
Object.assign(pagination, withNoLimit(pagination, maxLimit));
const replacePaginationAttributes = fp.pipe(// Remove pagination attributes
fp.omit(paginationAttributes), // Merge the object with the new pagination + ensure minimum & maximum values
fp.merge(ensureValidValues(pagination)));
return replacePaginationAttributes(args);
};
/**
* Transform pagination information into a paginated response:
* {
* page: number,
* pageSize: number,
* pageCount: number,
* total: number
* }
*/ const transformPagedPaginationInfo = (paginationInfo, total)=>{
if (!fp.isNil(paginationInfo.page)) {
const page = paginationInfo.page;
const pageSize = paginationInfo.pageSize ?? total;
return {
page,
pageSize,
pageCount: pageSize > 0 ? Math.ceil(total / pageSize) : 0,
total
};
}
if (!fp.isNil(paginationInfo.start)) {
const start = paginationInfo.start;
const limit = paginationInfo.limit ?? total;
// Start limit to page page size
return {
page: Math.floor(start / limit) + 1,
pageSize: limit,
pageCount: limit > 0 ? Math.ceil(total / limit) : 0,
total
};
}
// Default pagination
return {
...paginationInfo,
page: 1,
pageSize: 10,
pageCount: 1,
total
};
};
/**
* Transform pagination information into a offset response:
* {
* start: number,
* limit: number,
* total: number
* }
*/ const transformOffsetPaginationInfo = (paginationInfo, total)=>{
if (!fp.isNil(paginationInfo.page)) {
const limit = paginationInfo.pageSize ?? total;
const start = (paginationInfo.page - 1) * limit;
return {
start,
limit,
total
};
}
if (!fp.isNil(paginationInfo.start)) {
const start = paginationInfo.start;
const limit = paginationInfo.limit ?? total;
// Start limit to page page size
return {
start,
limit,
total
};
}
// Default pagination
return {
...paginationInfo,
start: 0,
limit: 10,
total
};
};
exports.transformOffsetPaginationInfo = transformOffsetPaginationInfo;
exports.transformPagedPaginationInfo = transformPagedPaginationInfo;
exports.withDefaultPagination = withDefaultPagination;
//# sourceMappingURL=pagination.js.map

File diff suppressed because one or more lines are too long

159
server/node_modules/@strapi/utils/dist/pagination.mjs generated vendored Normal file
View File

@@ -0,0 +1,159 @@
import { merge, isNil, pipe, omit } from 'lodash/fp';
import { PaginationError } from './errors.mjs';
const STRAPI_DEFAULTS = {
offset: {
start: 0,
limit: 10
},
page: {
page: 1,
pageSize: 10
}
};
const paginationAttributes = [
'start',
'limit',
'page',
'pageSize'
];
const withMaxLimit = (limit, maxLimit = -1)=>{
if (maxLimit === -1 || limit < maxLimit) {
return limit;
}
return maxLimit;
};
// Ensure minimum page & pageSize values (page >= 1, pageSize >= 0, start >= 0, limit >= 0)
const ensureMinValues = ({ start, limit })=>({
start: Math.max(start, 0),
limit: limit === -1 ? limit : Math.max(limit, 1)
});
const ensureMaxValues = (maxLimit = -1)=>({ start, limit })=>({
start,
limit: withMaxLimit(limit, maxLimit)
});
// Apply maxLimit as the limit when limit is -1
const withNoLimit = (pagination, maxLimit = -1)=>({
...pagination,
limit: pagination.limit === -1 ? maxLimit : pagination.limit
});
const withDefaultPagination = (args, { defaults = {}, maxLimit = -1 } = {})=>{
const defaultValues = merge(STRAPI_DEFAULTS, defaults);
const usePagePagination = !isNil(args.page) || !isNil(args.pageSize);
const useOffsetPagination = !isNil(args.start) || !isNil(args.limit);
const ensureValidValues = pipe(ensureMinValues, ensureMaxValues(maxLimit));
// If there is no pagination attribute, don't modify the payload
if (!usePagePagination && !useOffsetPagination) {
return merge(args, ensureValidValues(defaultValues.offset));
}
// If there is page & offset pagination attributes, throw an error
if (usePagePagination && useOffsetPagination) {
throw new PaginationError('Cannot use both page & offset pagination in the same query');
}
const pagination = {
start: 0,
limit: 0
};
// Start / Limit
if (useOffsetPagination) {
const { start, limit } = merge(defaultValues.offset, args);
Object.assign(pagination, {
start,
limit
});
}
// Page / PageSize
if (usePagePagination) {
const { page, pageSize } = merge(defaultValues.page, {
...args,
pageSize: Math.max(1, args.pageSize ?? 0)
});
Object.assign(pagination, {
start: (page - 1) * pageSize,
limit: pageSize
});
}
// Handle -1 limit
Object.assign(pagination, withNoLimit(pagination, maxLimit));
const replacePaginationAttributes = pipe(// Remove pagination attributes
omit(paginationAttributes), // Merge the object with the new pagination + ensure minimum & maximum values
merge(ensureValidValues(pagination)));
return replacePaginationAttributes(args);
};
/**
* Transform pagination information into a paginated response:
* {
* page: number,
* pageSize: number,
* pageCount: number,
* total: number
* }
*/ const transformPagedPaginationInfo = (paginationInfo, total)=>{
if (!isNil(paginationInfo.page)) {
const page = paginationInfo.page;
const pageSize = paginationInfo.pageSize ?? total;
return {
page,
pageSize,
pageCount: pageSize > 0 ? Math.ceil(total / pageSize) : 0,
total
};
}
if (!isNil(paginationInfo.start)) {
const start = paginationInfo.start;
const limit = paginationInfo.limit ?? total;
// Start limit to page page size
return {
page: Math.floor(start / limit) + 1,
pageSize: limit,
pageCount: limit > 0 ? Math.ceil(total / limit) : 0,
total
};
}
// Default pagination
return {
...paginationInfo,
page: 1,
pageSize: 10,
pageCount: 1,
total
};
};
/**
* Transform pagination information into a offset response:
* {
* start: number,
* limit: number,
* total: number
* }
*/ const transformOffsetPaginationInfo = (paginationInfo, total)=>{
if (!isNil(paginationInfo.page)) {
const limit = paginationInfo.pageSize ?? total;
const start = (paginationInfo.page - 1) * limit;
return {
start,
limit,
total
};
}
if (!isNil(paginationInfo.start)) {
const start = paginationInfo.start;
const limit = paginationInfo.limit ?? total;
// Start limit to page page size
return {
start,
limit,
total
};
}
// Default pagination
return {
...paginationInfo,
start: 0,
limit: 10,
total
};
};
export { transformOffsetPaginationInfo, transformPagedPaginationInfo, withDefaultPagination };
//# sourceMappingURL=pagination.mjs.map

File diff suppressed because one or more lines are too long

22
server/node_modules/@strapi/utils/dist/parse-type.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
type TypeMap = {
boolean: boolean;
integer: number;
biginteger: number;
float: number;
decimal: number;
time: string;
date: string;
timestamp: Date;
datetime: Date;
};
export interface ParseTypeOptions<T extends keyof TypeMap> {
type: T;
value: unknown;
forceCast?: boolean;
}
/**
* Cast basic values based on attribute type
*/
declare const parseType: <Type extends keyof TypeMap>(options: ParseTypeOptions<Type>) => TypeMap[Type];
export default parseType;
//# sourceMappingURL=parse-type.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parse-type.d.ts","sourceRoot":"","sources":["../src/parse-type.ts"],"names":[],"mappings":"AAuEA,KAAK,OAAO,GAAG;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,MAAM,OAAO;IACvD,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AA0BD;;GAEG;AACH,QAAA,MAAM,SAAS,wCAAyC,iBAAiB,IAAI,CAAC,KAAG,OAAO,CAAC,IAAI,CAyB5F,CAAC;AAEF,eAAe,SAAS,CAAC"}

140
server/node_modules/@strapi/utils/dist/parse-type.js generated vendored Normal file
View File

@@ -0,0 +1,140 @@
'use strict';
var _ = require('lodash');
var dates = require('date-fns');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var ___namespace = /*#__PURE__*/_interopNamespaceDefault(_);
var dates__namespace = /*#__PURE__*/_interopNamespaceDefault(dates);
const timeRegex = /^(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]{1,3})?$/;
const isDate = (v)=>{
return dates__namespace.isDate(v);
};
const parseTime = (value)=>{
if (isDate(value)) {
return dates__namespace.format(value, 'HH:mm:ss.SSS');
}
if (typeof value !== 'string') {
throw new Error(`Expected a string, got a ${typeof value}`);
}
const result = value.match(timeRegex);
if (result === null) {
throw new Error('Invalid time format, expected HH:mm:ss.SSS');
}
const [, hours, minutes, seconds, fraction = '.000'] = result;
const fractionPart = ___namespace.padEnd(fraction.slice(1), 3, '0');
return `${hours}:${minutes}:${seconds}.${fractionPart}`;
};
const parseDate = (value)=>{
if (isDate(value)) {
return dates__namespace.format(value, 'yyyy-MM-dd');
}
if (typeof value !== 'string') {
throw new Error(`Expected a string, got a ${typeof value}`);
}
try {
const date = dates__namespace.parseISO(value);
if (dates__namespace.isValid(date)) return dates__namespace.format(date, 'yyyy-MM-dd');
throw new Error(`Invalid format, expected an ISO compatible date`);
} catch (error) {
throw new Error(`Invalid format, expected an ISO compatible date`);
}
};
const parseDateTimeOrTimestamp = (value)=>{
if (isDate(value)) {
return value;
}
if (typeof value !== 'string') {
throw new Error(`Expected a string, got a ${typeof value}`);
}
try {
const date = dates__namespace.parseISO(value);
if (dates__namespace.isValid(date)) return date;
const milliUnixDate = dates__namespace.parse(value, 'T', new Date());
if (dates__namespace.isValid(milliUnixDate)) return milliUnixDate;
throw new Error(`Invalid format, expected a timestamp or an ISO date`);
} catch (error) {
throw new Error(`Invalid format, expected a timestamp or an ISO date`);
}
};
const parseBoolean = (value, options)=>{
const { forceCast = false } = options;
if (typeof value === 'boolean') {
return value;
}
if (typeof value === 'string' || typeof value === 'number') {
if ([
'true',
't',
'1',
1
].includes(value)) {
return true;
}
if ([
'false',
'f',
'0',
0
].includes(value)) {
return false;
}
}
if (forceCast) {
return Boolean(value);
}
throw new Error('Invalid boolean input. Expected "t","1","true","false","0","f"');
};
/**
* Cast basic values based on attribute type
*/ const parseType = (options)=>{
const { type, value, forceCast } = options;
switch(type){
case 'boolean':
return parseBoolean(value, {
forceCast
});
case 'integer':
case 'biginteger':
case 'float':
case 'decimal':
{
return ___namespace.toNumber(value);
}
case 'time':
{
return parseTime(value);
}
case 'date':
{
return parseDate(value);
}
case 'timestamp':
case 'datetime':
{
return parseDateTimeOrTimestamp(value);
}
default:
return value;
}
};
module.exports = parseType;
//# sourceMappingURL=parse-type.js.map

File diff suppressed because one or more lines are too long

118
server/node_modules/@strapi/utils/dist/parse-type.mjs generated vendored Normal file
View File

@@ -0,0 +1,118 @@
import * as _ from 'lodash';
import * as dates from 'date-fns';
const timeRegex = /^(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]{1,3})?$/;
const isDate = (v)=>{
return dates.isDate(v);
};
const parseTime = (value)=>{
if (isDate(value)) {
return dates.format(value, 'HH:mm:ss.SSS');
}
if (typeof value !== 'string') {
throw new Error(`Expected a string, got a ${typeof value}`);
}
const result = value.match(timeRegex);
if (result === null) {
throw new Error('Invalid time format, expected HH:mm:ss.SSS');
}
const [, hours, minutes, seconds, fraction = '.000'] = result;
const fractionPart = _.padEnd(fraction.slice(1), 3, '0');
return `${hours}:${minutes}:${seconds}.${fractionPart}`;
};
const parseDate = (value)=>{
if (isDate(value)) {
return dates.format(value, 'yyyy-MM-dd');
}
if (typeof value !== 'string') {
throw new Error(`Expected a string, got a ${typeof value}`);
}
try {
const date = dates.parseISO(value);
if (dates.isValid(date)) return dates.format(date, 'yyyy-MM-dd');
throw new Error(`Invalid format, expected an ISO compatible date`);
} catch (error) {
throw new Error(`Invalid format, expected an ISO compatible date`);
}
};
const parseDateTimeOrTimestamp = (value)=>{
if (isDate(value)) {
return value;
}
if (typeof value !== 'string') {
throw new Error(`Expected a string, got a ${typeof value}`);
}
try {
const date = dates.parseISO(value);
if (dates.isValid(date)) return date;
const milliUnixDate = dates.parse(value, 'T', new Date());
if (dates.isValid(milliUnixDate)) return milliUnixDate;
throw new Error(`Invalid format, expected a timestamp or an ISO date`);
} catch (error) {
throw new Error(`Invalid format, expected a timestamp or an ISO date`);
}
};
const parseBoolean = (value, options)=>{
const { forceCast = false } = options;
if (typeof value === 'boolean') {
return value;
}
if (typeof value === 'string' || typeof value === 'number') {
if ([
'true',
't',
'1',
1
].includes(value)) {
return true;
}
if ([
'false',
'f',
'0',
0
].includes(value)) {
return false;
}
}
if (forceCast) {
return Boolean(value);
}
throw new Error('Invalid boolean input. Expected "t","1","true","false","0","f"');
};
/**
* Cast basic values based on attribute type
*/ const parseType = (options)=>{
const { type, value, forceCast } = options;
switch(type){
case 'boolean':
return parseBoolean(value, {
forceCast
});
case 'integer':
case 'biginteger':
case 'float':
case 'decimal':
{
return _.toNumber(value);
}
case 'time':
{
return parseTime(value);
}
case 'date':
{
return parseDate(value);
}
case 'timestamp':
case 'datetime':
{
return parseDateTimeOrTimestamp(value);
}
default:
return value;
}
};
export { parseType as default };
//# sourceMappingURL=parse-type.mjs.map

File diff suppressed because one or more lines are too long

16
server/node_modules/@strapi/utils/dist/policy.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
interface Options {
name: string;
validator?(config: unknown): void;
handler(...args: any[]): any;
}
declare const createPolicy: (options: Options) => {
name: string;
validator: (config: unknown) => void;
handler: (...args: any[]) => any;
};
declare const createPolicyContext: (type: string, ctx: object) => {
is: import("lodash/fp").LodashEq1x1;
readonly type: string;
} & object;
export { createPolicy, createPolicyContext };
//# sourceMappingURL=policy.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAEA,UAAU,OAAO;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAClC,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;CAC9B;AAED,QAAA,MAAM,YAAY,YAAa,OAAO;;wBAGF,OAAO;uBANxB,GAAG,EAAE,KAAG,GAAG;CAqB7B,CAAC;AAEF,QAAA,MAAM,mBAAmB,SAAU,MAAM,OAAO,MAAM;;;UAUrD,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC"}

33
server/node_modules/@strapi/utils/dist/policy.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
'use strict';
var fp = require('lodash/fp');
const createPolicy = (options)=>{
const { name = 'unnamed', validator, handler } = options;
const wrappedValidator = (config)=>{
if (validator) {
try {
validator(config);
} catch (e) {
throw new Error(`Invalid config passed to "${name}" policy.`);
}
}
};
return {
name,
validator: wrappedValidator,
handler
};
};
const createPolicyContext = (type, ctx)=>{
return Object.assign({
is: fp.eq(type),
get type () {
return type;
}
}, ctx);
};
exports.createPolicy = createPolicy;
exports.createPolicyContext = createPolicyContext;
//# sourceMappingURL=policy.js.map

1
server/node_modules/@strapi/utils/dist/policy.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"policy.js","sources":["../src/policy.ts"],"sourcesContent":["import { eq } from 'lodash/fp';\n\ninterface Options {\n name: string;\n validator?(config: unknown): void;\n handler(...args: any[]): any;\n}\n\nconst createPolicy = (options: Options) => {\n const { name = 'unnamed', validator, handler } = options;\n\n const wrappedValidator = (config: unknown) => {\n if (validator) {\n try {\n validator(config);\n } catch (e) {\n throw new Error(`Invalid config passed to \"${name}\" policy.`);\n }\n }\n };\n\n return {\n name,\n validator: wrappedValidator,\n handler,\n };\n};\n\nconst createPolicyContext = (type: string, ctx: object) => {\n return Object.assign(\n {\n is: eq(type),\n get type() {\n return type;\n },\n },\n ctx\n );\n};\n\nexport { createPolicy, createPolicyContext };\n"],"names":["createPolicy","options","name","validator","handler","wrappedValidator","config","e","Error","createPolicyContext","type","ctx","Object","assign","is","eq"],"mappings":";;;;AAQA,MAAMA,eAAe,CAACC,OAAAA,GAAAA;IACpB,MAAM,EAAEC,OAAO,SAAS,EAAEC,SAAS,EAAEC,OAAO,EAAE,GAAGH,OAAAA;AAEjD,IAAA,MAAMI,mBAAmB,CAACC,MAAAA,GAAAA;AACxB,QAAA,IAAIH,SAAW,EAAA;YACb,IAAI;gBACFA,SAAUG,CAAAA,MAAAA,CAAAA;AACZ,aAAA,CAAE,OAAOC,CAAG,EAAA;AACV,gBAAA,MAAM,IAAIC,KAAM,CAAA,CAAC,0BAA0B,EAAEN,IAAAA,CAAK,SAAS,CAAC,CAAA;AAC9D;AACF;AACF,KAAA;IAEA,OAAO;AACLA,QAAAA,IAAAA;QACAC,SAAWE,EAAAA,gBAAAA;AACXD,QAAAA;AACF,KAAA;AACF;AAEMK,MAAAA,mBAAAA,GAAsB,CAACC,IAAcC,EAAAA,GAAAA,GAAAA;IACzC,OAAOC,MAAAA,CAAOC,MAAM,CAClB;AACEC,QAAAA,EAAAA,EAAIC,KAAGL,CAAAA,IAAAA,CAAAA;AACP,QAAA,IAAIA,IAAO,CAAA,GAAA;YACT,OAAOA,IAAAA;AACT;KAEFC,EAAAA,GAAAA,CAAAA;AAEJ;;;;;"}

30
server/node_modules/@strapi/utils/dist/policy.mjs generated vendored Normal file
View File

@@ -0,0 +1,30 @@
import { eq } from 'lodash/fp';
const createPolicy = (options)=>{
const { name = 'unnamed', validator, handler } = options;
const wrappedValidator = (config)=>{
if (validator) {
try {
validator(config);
} catch (e) {
throw new Error(`Invalid config passed to "${name}" policy.`);
}
}
};
return {
name,
validator: wrappedValidator,
handler
};
};
const createPolicyContext = (type, ctx)=>{
return Object.assign({
is: eq(type),
get type () {
return type;
}
}, ctx);
};
export { createPolicy, createPolicyContext };
//# sourceMappingURL=policy.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"policy.mjs","sources":["../src/policy.ts"],"sourcesContent":["import { eq } from 'lodash/fp';\n\ninterface Options {\n name: string;\n validator?(config: unknown): void;\n handler(...args: any[]): any;\n}\n\nconst createPolicy = (options: Options) => {\n const { name = 'unnamed', validator, handler } = options;\n\n const wrappedValidator = (config: unknown) => {\n if (validator) {\n try {\n validator(config);\n } catch (e) {\n throw new Error(`Invalid config passed to \"${name}\" policy.`);\n }\n }\n };\n\n return {\n name,\n validator: wrappedValidator,\n handler,\n };\n};\n\nconst createPolicyContext = (type: string, ctx: object) => {\n return Object.assign(\n {\n is: eq(type),\n get type() {\n return type;\n },\n },\n ctx\n );\n};\n\nexport { createPolicy, createPolicyContext };\n"],"names":["createPolicy","options","name","validator","handler","wrappedValidator","config","e","Error","createPolicyContext","type","ctx","Object","assign","is","eq"],"mappings":";;AAQA,MAAMA,eAAe,CAACC,OAAAA,GAAAA;IACpB,MAAM,EAAEC,OAAO,SAAS,EAAEC,SAAS,EAAEC,OAAO,EAAE,GAAGH,OAAAA;AAEjD,IAAA,MAAMI,mBAAmB,CAACC,MAAAA,GAAAA;AACxB,QAAA,IAAIH,SAAW,EAAA;YACb,IAAI;gBACFA,SAAUG,CAAAA,MAAAA,CAAAA;AACZ,aAAA,CAAE,OAAOC,CAAG,EAAA;AACV,gBAAA,MAAM,IAAIC,KAAM,CAAA,CAAC,0BAA0B,EAAEN,IAAAA,CAAK,SAAS,CAAC,CAAA;AAC9D;AACF;AACF,KAAA;IAEA,OAAO;AACLA,QAAAA,IAAAA;QACAC,SAAWE,EAAAA,gBAAAA;AACXD,QAAAA;AACF,KAAA;AACF;AAEMK,MAAAA,mBAAAA,GAAsB,CAACC,IAAcC,EAAAA,GAAAA,GAAAA;IACzC,OAAOC,MAAAA,CAAOC,MAAM,CAClB;AACEC,QAAAA,EAAAA,EAAIC,EAAGL,CAAAA,IAAAA,CAAAA;AACP,QAAA,IAAIA,IAAO,CAAA,GAAA;YACT,OAAOA,IAAAA;AACT;KAEFC,EAAAA,GAAAA,CAAAA;AAEJ;;;;"}

View File

@@ -0,0 +1,3 @@
declare const includesString: (arr: unknown[], val: unknown) => boolean;
export { includesString };
//# sourceMappingURL=arrays.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../../src/primitives/arrays.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,cAAc,QAAS,OAAO,EAAE,OAAO,OAAO,YAAmC,CAAC;AAExF,OAAO,EAAE,cAAc,EAAE,CAAC"}

View File

@@ -0,0 +1,7 @@
'use strict';
const castIncludes = (arr, val, cast)=>arr.map((val)=>cast(val)).includes(cast(val));
const includesString = (arr, val)=>castIncludes(arr, val, String);
exports.includesString = includesString;
//# sourceMappingURL=arrays.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"arrays.js","sources":["../../src/primitives/arrays.ts"],"sourcesContent":["const castIncludes = (arr: unknown[], val: unknown, cast: (val: unknown) => unknown): boolean =>\n arr.map((val) => cast(val)).includes(cast(val));\n\nconst includesString = (arr: unknown[], val: unknown) => castIncludes(arr, val, String);\n\nexport { includesString };\n"],"names":["castIncludes","arr","val","cast","map","includes","includesString","String"],"mappings":";;AAAA,MAAMA,YAAe,GAAA,CAACC,GAAgBC,EAAAA,GAAAA,EAAcC,OAClDF,GAAIG,CAAAA,GAAG,CAAC,CAACF,GAAQC,GAAAA,IAAAA,CAAKD,GAAMG,CAAAA,CAAAA,CAAAA,QAAQ,CAACF,IAAKD,CAAAA,GAAAA,CAAAA,CAAAA;AAE5C,MAAMI,iBAAiB,CAACL,GAAAA,EAAgBC,GAAiBF,GAAAA,YAAAA,CAAaC,KAAKC,GAAKK,EAAAA,MAAAA;;;;"}

Some files were not shown because too many files have changed in this diff Show More