@strapi/utils 4.14.3 → 4.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/async.d.ts +1 -0
- package/dist/async.d.ts.map +1 -0
- package/dist/code-generator.d.ts +1 -0
- package/dist/code-generator.d.ts.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/content-types.d.ts +1 -0
- package/dist/content-types.d.ts.map +1 -0
- package/dist/convert-query-params.d.ts +1 -0
- package/dist/convert-query-params.d.ts.map +1 -0
- package/dist/env-helper.d.ts +1 -0
- package/dist/env-helper.d.ts.map +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/file.d.ts +1 -0
- package/dist/file.d.ts.map +1 -0
- package/dist/format-yup-error.d.ts +1 -0
- package/dist/format-yup-error.d.ts.map +1 -0
- package/dist/hooks.d.ts +1 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/import-default.d.ts +1 -0
- package/dist/import-default.d.ts.map +1 -0
- package/dist/index.d.ts +20 -143
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3046 -104
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3029 -0
- package/dist/index.mjs.map +1 -0
- package/dist/object-formatting.d.ts +1 -0
- package/dist/object-formatting.d.ts.map +1 -0
- package/dist/operators.d.ts +1 -0
- package/dist/operators.d.ts.map +1 -0
- package/dist/pagination.d.ts +1 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/parse-multipart.d.ts +2 -2
- package/dist/parse-multipart.d.ts.map +1 -0
- package/dist/parse-type.d.ts +1 -0
- package/dist/parse-type.d.ts.map +1 -0
- package/dist/policy.d.ts +1 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/print-value.d.ts +2 -1
- package/dist/print-value.d.ts.map +1 -0
- package/dist/provider-factory.d.ts +1 -0
- package/dist/provider-factory.d.ts.map +1 -0
- package/dist/relations.d.ts +1 -0
- package/dist/relations.d.ts.map +1 -0
- package/dist/sanitize/index.d.ts +1 -0
- package/dist/sanitize/index.d.ts.map +1 -0
- package/dist/sanitize/sanitizers.d.ts +1 -0
- package/dist/sanitize/sanitizers.d.ts.map +1 -0
- package/dist/sanitize/visitors/index.d.ts +1 -0
- package/dist/sanitize/visitors/index.d.ts.map +1 -0
- package/dist/sanitize/visitors/remove-disallowed-fields.d.ts +1 -0
- package/dist/sanitize/visitors/remove-disallowed-fields.d.ts.map +1 -0
- package/dist/sanitize/visitors/remove-dynamic-zones.d.ts +1 -0
- package/dist/sanitize/visitors/remove-dynamic-zones.d.ts.map +1 -0
- package/dist/sanitize/visitors/remove-morph-to-relations.d.ts +1 -0
- package/dist/sanitize/visitors/remove-morph-to-relations.d.ts.map +1 -0
- package/dist/sanitize/visitors/remove-password.d.ts +1 -0
- package/dist/sanitize/visitors/remove-password.d.ts.map +1 -0
- package/dist/sanitize/visitors/remove-private.d.ts +1 -0
- package/dist/sanitize/visitors/remove-private.d.ts.map +1 -0
- package/dist/sanitize/visitors/remove-restricted-fields.d.ts +1 -0
- package/dist/sanitize/visitors/remove-restricted-fields.d.ts.map +1 -0
- package/dist/sanitize/visitors/remove-restricted-relations.d.ts +1 -0
- package/dist/sanitize/visitors/remove-restricted-relations.d.ts.map +1 -0
- package/dist/set-creator-fields.d.ts +1 -0
- package/dist/set-creator-fields.d.ts.map +1 -0
- package/dist/string-formatting.d.ts +1 -0
- package/dist/string-formatting.d.ts.map +1 -0
- package/dist/template-configuration.d.ts +2 -1
- package/dist/template-configuration.d.ts.map +1 -0
- package/dist/template.d.ts +1 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/traverse/factory.d.ts +1 -0
- package/dist/traverse/factory.d.ts.map +1 -0
- package/dist/traverse/index.d.ts +1 -0
- package/dist/traverse/index.d.ts.map +1 -0
- package/dist/traverse/query-fields.d.ts +1 -0
- package/dist/traverse/query-fields.d.ts.map +1 -0
- package/dist/traverse/query-filters.d.ts +1 -0
- package/dist/traverse/query-filters.d.ts.map +1 -0
- package/dist/traverse/query-populate.d.ts +1 -0
- package/dist/traverse/query-populate.d.ts.map +1 -0
- package/dist/traverse/query-sort.d.ts +1 -0
- package/dist/traverse/query-sort.d.ts.map +1 -0
- package/dist/traverse-entity.d.ts +1 -0
- package/dist/traverse-entity.d.ts.map +1 -0
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -0
- package/dist/validate/index.d.ts +1 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/utils.d.ts +1 -0
- package/dist/validate/utils.d.ts.map +1 -0
- package/dist/validate/validators.d.ts +1 -0
- package/dist/validate/validators.d.ts.map +1 -0
- package/dist/validate/visitors/index.d.ts +1 -0
- package/dist/validate/visitors/index.d.ts.map +1 -0
- package/dist/validate/visitors/throw-disallowed-fields.d.ts +1 -0
- package/dist/validate/visitors/throw-disallowed-fields.d.ts.map +1 -0
- package/dist/validate/visitors/throw-dynamic-zones.d.ts +1 -0
- package/dist/validate/visitors/throw-dynamic-zones.d.ts.map +1 -0
- package/dist/validate/visitors/throw-morph-to-relations.d.ts +1 -0
- package/dist/validate/visitors/throw-morph-to-relations.d.ts.map +1 -0
- package/dist/validate/visitors/throw-password.d.ts +1 -0
- package/dist/validate/visitors/throw-password.d.ts.map +1 -0
- package/dist/validate/visitors/throw-private.d.ts +1 -0
- package/dist/validate/visitors/throw-private.d.ts.map +1 -0
- package/dist/validate/visitors/throw-restricted-fields.d.ts +1 -0
- package/dist/validate/visitors/throw-restricted-fields.d.ts.map +1 -0
- package/dist/validate/visitors/throw-restricted-relations.d.ts +1 -0
- package/dist/validate/visitors/throw-restricted-relations.d.ts.map +1 -0
- package/dist/validators.d.ts +1 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/webhook.d.ts +1 -0
- package/dist/webhook.d.ts.map +1 -0
- package/dist/yup.d.ts +1 -0
- package/dist/yup.d.ts.map +1 -0
- package/package.json +12 -12
- package/dist/async.js +0 -33
- package/dist/async.js.map +0 -1
- package/dist/code-generator.js +0 -11
- package/dist/code-generator.js.map +0 -1
- package/dist/config.js +0 -79
- package/dist/config.js.map +0 -1
- package/dist/content-types.js +0 -162
- package/dist/content-types.js.map +0 -1
- package/dist/convert-query-params.js +0 -477
- package/dist/convert-query-params.js.map +0 -1
- package/dist/env-helper.js +0 -84
- package/dist/env-helper.js.map +0 -1
- package/dist/errors.js +0 -101
- package/dist/errors.js.map +0 -1
- package/dist/file.js +0 -54
- package/dist/file.js.map +0 -1
- package/dist/format-yup-error.js +0 -17
- package/dist/format-yup-error.js.map +0 -1
- package/dist/hooks.js +0 -89
- package/dist/hooks.js.map +0 -1
- package/dist/import-default.js +0 -9
- package/dist/import-default.js.map +0 -1
- package/dist/object-formatting.js +0 -14
- package/dist/object-formatting.js.map +0 -1
- package/dist/operators.js +0 -72
- package/dist/operators.js.map +0 -1
- package/dist/pagination.js +0 -80
- package/dist/pagination.js.map +0 -1
- package/dist/parse-multipart.js +0 -36
- package/dist/parse-multipart.js.map +0 -1
- package/dist/parse-type.js +0 -108
- package/dist/parse-type.js.map +0 -1
- package/dist/policy.js +0 -109
- package/dist/policy.js.map +0 -1
- package/dist/print-value.js +0 -50
- package/dist/print-value.js.map +0 -1
- package/dist/provider-factory.js +0 -80
- package/dist/provider-factory.js.map +0 -1
- package/dist/relations.js +0 -23
- package/dist/relations.js.map +0 -1
- package/dist/sanitize/index.js +0 -156
- package/dist/sanitize/index.js.map +0 -1
- package/dist/sanitize/sanitizers.js +0 -147
- package/dist/sanitize/sanitizers.js.map +0 -1
- package/dist/sanitize/visitors/index.js +0 -21
- package/dist/sanitize/visitors/index.js.map +0 -1
- package/dist/sanitize/visitors/remove-disallowed-fields.js +0 -83
- package/dist/sanitize/visitors/remove-disallowed-fields.js.map +0 -1
- package/dist/sanitize/visitors/remove-dynamic-zones.js +0 -10
- package/dist/sanitize/visitors/remove-dynamic-zones.js.map +0 -1
- package/dist/sanitize/visitors/remove-morph-to-relations.js +0 -10
- package/dist/sanitize/visitors/remove-morph-to-relations.js.map +0 -1
- package/dist/sanitize/visitors/remove-password.js +0 -9
- package/dist/sanitize/visitors/remove-password.js.map +0 -1
- package/dist/sanitize/visitors/remove-private.js +0 -14
- package/dist/sanitize/visitors/remove-private.js.map +0 -1
- package/dist/sanitize/visitors/remove-restricted-fields.js +0 -25
- package/dist/sanitize/visitors/remove-restricted-fields.js.map +0 -1
- package/dist/sanitize/visitors/remove-restricted-relations.js +0 -88
- package/dist/sanitize/visitors/remove-restricted-relations.js.map +0 -1
- package/dist/set-creator-fields.js +0 -39
- package/dist/set-creator-fields.js.map +0 -1
- package/dist/string-formatting.js +0 -85
- package/dist/string-formatting.js.map +0 -1
- package/dist/template-configuration.js +0 -30
- package/dist/template-configuration.js.map +0 -1
- package/dist/template.js +0 -20
- package/dist/template.js.map +0 -1
- package/dist/traverse/factory.js +0 -127
- package/dist/traverse/factory.js.map +0 -1
- package/dist/traverse/index.js +0 -17
- package/dist/traverse/index.js.map +0 -1
- package/dist/traverse/query-fields.js +0 -35
- package/dist/traverse/query-fields.js.map +0 -1
- package/dist/traverse/query-filters.js +0 -75
- package/dist/traverse/query-filters.js.map +0 -1
- package/dist/traverse/query-populate.js +0 -171
- package/dist/traverse/query-populate.js.map +0 -1
- package/dist/traverse/query-sort.js +0 -117
- package/dist/traverse/query-sort.js.map +0 -1
- package/dist/traverse-entity.js +0 -134
- package/dist/traverse-entity.js.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/validate/index.js +0 -121
- package/dist/validate/index.js.map +0 -1
- package/dist/validate/utils.js +0 -9
- package/dist/validate/utils.js.map +0 -1
- package/dist/validate/validators.js +0 -111
- package/dist/validate/validators.js.map +0 -1
- package/dist/validate/visitors/index.js +0 -21
- package/dist/validate/visitors/index.js.map +0 -1
- package/dist/validate/visitors/throw-disallowed-fields.js +0 -84
- package/dist/validate/visitors/throw-disallowed-fields.js.map +0 -1
- package/dist/validate/visitors/throw-dynamic-zones.js +0 -11
- package/dist/validate/visitors/throw-dynamic-zones.js.map +0 -1
- package/dist/validate/visitors/throw-morph-to-relations.js +0 -11
- package/dist/validate/visitors/throw-morph-to-relations.js.map +0 -1
- package/dist/validate/visitors/throw-password.js +0 -10
- package/dist/validate/visitors/throw-password.js.map +0 -1
- package/dist/validate/visitors/throw-private.js +0 -15
- package/dist/validate/visitors/throw-private.js.map +0 -1
- package/dist/validate/visitors/throw-restricted-fields.js +0 -24
- package/dist/validate/visitors/throw-restricted-fields.js.map +0 -1
- package/dist/validate/visitors/throw-restricted-relations.js +0 -81
- package/dist/validate/visitors/throw-restricted-relations.js.map +0 -1
- package/dist/validators.js +0 -64
- package/dist/validators.js.map +0 -1
- package/dist/webhook.js +0 -27
- package/dist/webhook.js.map +0 -1
- package/dist/yup.js +0 -108
- package/dist/yup.js.map +0 -1
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.defaultSanitizePopulate = exports.defaultSanitizeFields = exports.defaultSanitizeSort = exports.defaultSanitizeFilters = exports.defaultSanitizeOutput = exports.sanitizePasswords = void 0;
|
|
7
|
-
const fp_1 = require("lodash/fp");
|
|
8
|
-
const async_1 = require("../async");
|
|
9
|
-
const traverse_entity_1 = __importDefault(require("../traverse-entity"));
|
|
10
|
-
const content_types_1 = require("../content-types");
|
|
11
|
-
const traverse_1 = require("../traverse");
|
|
12
|
-
const visitors_1 = require("./visitors");
|
|
13
|
-
const operators_1 = require("../operators");
|
|
14
|
-
const sanitizePasswords = (schema) => async (entity) => {
|
|
15
|
-
if (!schema) {
|
|
16
|
-
throw new Error('Missing schema in sanitizePasswords');
|
|
17
|
-
}
|
|
18
|
-
return (0, traverse_entity_1.default)(visitors_1.removePassword, { schema }, entity);
|
|
19
|
-
};
|
|
20
|
-
exports.sanitizePasswords = sanitizePasswords;
|
|
21
|
-
const defaultSanitizeOutput = async (schema, entity) => {
|
|
22
|
-
if (!schema) {
|
|
23
|
-
throw new Error('Missing schema in defaultSanitizeOutput');
|
|
24
|
-
}
|
|
25
|
-
return (0, traverse_entity_1.default)((...args) => {
|
|
26
|
-
(0, visitors_1.removePassword)(...args);
|
|
27
|
-
(0, visitors_1.removePrivate)(...args);
|
|
28
|
-
}, { schema }, entity);
|
|
29
|
-
};
|
|
30
|
-
exports.defaultSanitizeOutput = defaultSanitizeOutput;
|
|
31
|
-
const defaultSanitizeFilters = (0, fp_1.curry)((schema, filters) => {
|
|
32
|
-
if (!schema) {
|
|
33
|
-
throw new Error('Missing schema in defaultSanitizeFilters');
|
|
34
|
-
}
|
|
35
|
-
return (0, async_1.pipeAsync)(
|
|
36
|
-
// Remove keys that are not attributes or valid operators
|
|
37
|
-
(0, traverse_1.traverseQueryFilters)(({ key, attribute }, { remove }) => {
|
|
38
|
-
const isAttribute = !!attribute;
|
|
39
|
-
// ID is not an attribute per se, so we need to make
|
|
40
|
-
// an extra check to ensure we're not checking it
|
|
41
|
-
if (key === 'id') {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (!isAttribute && !(0, operators_1.isOperator)(key)) {
|
|
45
|
-
remove(key);
|
|
46
|
-
}
|
|
47
|
-
}, { schema }),
|
|
48
|
-
// Remove dynamic zones from filters
|
|
49
|
-
(0, traverse_1.traverseQueryFilters)(visitors_1.removeDynamicZones, { schema }),
|
|
50
|
-
// Remove morpTo relations from filters
|
|
51
|
-
(0, traverse_1.traverseQueryFilters)(visitors_1.removeMorphToRelations, { schema }),
|
|
52
|
-
// Remove passwords from filters
|
|
53
|
-
(0, traverse_1.traverseQueryFilters)(visitors_1.removePassword, { schema }),
|
|
54
|
-
// Remove private from filters
|
|
55
|
-
(0, traverse_1.traverseQueryFilters)(visitors_1.removePrivate, { schema }),
|
|
56
|
-
// Remove empty objects
|
|
57
|
-
(0, traverse_1.traverseQueryFilters)(({ key, value }, { remove }) => {
|
|
58
|
-
if ((0, fp_1.isObject)(value) && (0, fp_1.isEmpty)(value)) {
|
|
59
|
-
remove(key);
|
|
60
|
-
}
|
|
61
|
-
}, { schema }))(filters);
|
|
62
|
-
});
|
|
63
|
-
exports.defaultSanitizeFilters = defaultSanitizeFilters;
|
|
64
|
-
const defaultSanitizeSort = (0, fp_1.curry)((schema, sort) => {
|
|
65
|
-
if (!schema) {
|
|
66
|
-
throw new Error('Missing schema in defaultSanitizeSort');
|
|
67
|
-
}
|
|
68
|
-
return (0, async_1.pipeAsync)(
|
|
69
|
-
// Remove non attribute keys
|
|
70
|
-
(0, traverse_1.traverseQuerySort)(({ key, attribute }, { remove }) => {
|
|
71
|
-
// ID is not an attribute per se, so we need to make
|
|
72
|
-
// an extra check to ensure we're not checking it
|
|
73
|
-
if (key === 'id') {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (!attribute) {
|
|
77
|
-
remove(key);
|
|
78
|
-
}
|
|
79
|
-
}, { schema }),
|
|
80
|
-
// Remove dynamic zones from sort
|
|
81
|
-
(0, traverse_1.traverseQuerySort)(visitors_1.removeDynamicZones, { schema }),
|
|
82
|
-
// Remove morpTo relations from sort
|
|
83
|
-
(0, traverse_1.traverseQuerySort)(visitors_1.removeMorphToRelations, { schema }),
|
|
84
|
-
// Remove private from sort
|
|
85
|
-
(0, traverse_1.traverseQuerySort)(visitors_1.removePrivate, { schema }),
|
|
86
|
-
// Remove passwords from filters
|
|
87
|
-
(0, traverse_1.traverseQuerySort)(visitors_1.removePassword, { schema }),
|
|
88
|
-
// Remove keys for empty non-scalar values
|
|
89
|
-
(0, traverse_1.traverseQuerySort)(({ key, attribute, value }, { remove }) => {
|
|
90
|
-
// ID is not an attribute per se, so we need to make
|
|
91
|
-
// an extra check to ensure we're not removing it
|
|
92
|
-
if (key === 'id') {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (!(0, content_types_1.isScalarAttribute)(attribute) && (0, fp_1.isEmpty)(value)) {
|
|
96
|
-
remove(key);
|
|
97
|
-
}
|
|
98
|
-
}, { schema }))(sort);
|
|
99
|
-
});
|
|
100
|
-
exports.defaultSanitizeSort = defaultSanitizeSort;
|
|
101
|
-
const defaultSanitizeFields = (0, fp_1.curry)((schema, fields) => {
|
|
102
|
-
if (!schema) {
|
|
103
|
-
throw new Error('Missing schema in defaultSanitizeFields');
|
|
104
|
-
}
|
|
105
|
-
return (0, async_1.pipeAsync)(
|
|
106
|
-
// Only keep scalar attributes
|
|
107
|
-
(0, traverse_1.traverseQueryFields)(({ key, attribute }, { remove }) => {
|
|
108
|
-
// ID is not an attribute per se, so we need to make
|
|
109
|
-
// an extra check to ensure we're not checking it
|
|
110
|
-
if (key === 'id') {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if ((0, fp_1.isNil)(attribute) || !(0, content_types_1.isScalarAttribute)(attribute)) {
|
|
114
|
-
remove(key);
|
|
115
|
-
}
|
|
116
|
-
}, { schema }),
|
|
117
|
-
// Remove private fields
|
|
118
|
-
(0, traverse_1.traverseQueryFields)(visitors_1.removePrivate, { schema }),
|
|
119
|
-
// Remove password fields
|
|
120
|
-
(0, traverse_1.traverseQueryFields)(visitors_1.removePassword, { schema }),
|
|
121
|
-
// Remove nil values from fields array
|
|
122
|
-
(value) => ((0, fp_1.isArray)(value) ? value.filter((field) => !(0, fp_1.isNil)(field)) : value))(fields);
|
|
123
|
-
});
|
|
124
|
-
exports.defaultSanitizeFields = defaultSanitizeFields;
|
|
125
|
-
const defaultSanitizePopulate = (0, fp_1.curry)((schema, populate) => {
|
|
126
|
-
if (!schema) {
|
|
127
|
-
throw new Error('Missing schema in defaultSanitizePopulate');
|
|
128
|
-
}
|
|
129
|
-
return (0, async_1.pipeAsync)((0, traverse_1.traverseQueryPopulate)(async ({ key, value, schema, attribute }, { set }) => {
|
|
130
|
-
if (attribute) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (key === 'sort') {
|
|
134
|
-
set(key, await defaultSanitizeSort(schema, value));
|
|
135
|
-
}
|
|
136
|
-
if (key === 'filters') {
|
|
137
|
-
set(key, await defaultSanitizeFilters(schema, value));
|
|
138
|
-
}
|
|
139
|
-
if (key === 'fields') {
|
|
140
|
-
set(key, await defaultSanitizeFields(schema, value));
|
|
141
|
-
}
|
|
142
|
-
}, { schema }),
|
|
143
|
-
// Remove private fields
|
|
144
|
-
(0, traverse_1.traverseQueryPopulate)(visitors_1.removePrivate, { schema }))(populate);
|
|
145
|
-
});
|
|
146
|
-
exports.defaultSanitizePopulate = defaultSanitizePopulate;
|
|
147
|
-
//# sourceMappingURL=sanitizers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizers.js","sourceRoot":"","sources":["../../src/sanitize/sanitizers.ts"],"names":[],"mappings":";;;;;;AAAA,kCAAqE;AAErE,oCAAqC;AACrC,yEAAgD;AAChD,oDAAqD;AAErD,0CAKqB;AAErB,yCAKoB;AACpB,4CAA0C;AAI1C,MAAM,iBAAiB,GAAG,CAAC,MAAa,EAAE,EAAE,CAAC,KAAK,EAAE,MAAY,EAAE,EAAE;IAClE,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IACD,OAAO,IAAA,yBAAc,EAAC,yBAAc,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC,CAAC;AAoKA,8CAAiB;AAlKnB,MAAM,qBAAqB,GAAG,KAAK,EAAE,MAAa,EAAE,MAAY,EAAE,EAAE;IAClE,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;KAC5D;IACD,OAAO,IAAA,yBAAc,EACnB,CAAC,GAAG,IAAI,EAAE,EAAE;QACV,IAAA,yBAAc,EAAC,GAAG,IAAI,CAAC,CAAC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IAAA,UAAK,EAAC,CAAC,MAAa,EAAE,QAAiB,EAAE,EAAE;IACzE,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IACD,OAAO,IAAA,iBAAS,EACd,IAAA,gCAAqB,EACnB,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QACnD,IAAI,SAAS,EAAE;YACb,OAAO;SACR;QAED,IAAI,GAAG,KAAK,MAAM,EAAE;YAClB,GAAG,CAAC,GAAG,EAAE,MAAM,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;SACpD;QAED,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,GAAG,CAAC,GAAG,EAAE,MAAM,sBAAsB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;SACvD;QAED,IAAI,GAAG,KAAK,QAAQ,EAAE;YACpB,GAAG,CAAC,GAAG,EAAE,MAAM,qBAAqB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;SACtD;IACH,CAAC,EACD,EAAE,MAAM,EAAE,CACX;IACD,wBAAwB;IACxB,IAAA,gCAAqB,EAAC,wBAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CACjD,CAAC,QAAQ,CAAC,CAAC;AACd,CAAC,CAAC,CAAC;AAQD,0DAAuB"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.removeRestrictedFields = exports.removeDisallowedFields = exports.removeDynamicZones = exports.removeMorphToRelations = exports.removeRestrictedRelations = exports.removePrivate = exports.removePassword = void 0;
|
|
7
|
-
var remove_password_1 = require("./remove-password");
|
|
8
|
-
Object.defineProperty(exports, "removePassword", { enumerable: true, get: function () { return __importDefault(remove_password_1).default; } });
|
|
9
|
-
var remove_private_1 = require("./remove-private");
|
|
10
|
-
Object.defineProperty(exports, "removePrivate", { enumerable: true, get: function () { return __importDefault(remove_private_1).default; } });
|
|
11
|
-
var remove_restricted_relations_1 = require("./remove-restricted-relations");
|
|
12
|
-
Object.defineProperty(exports, "removeRestrictedRelations", { enumerable: true, get: function () { return __importDefault(remove_restricted_relations_1).default; } });
|
|
13
|
-
var remove_morph_to_relations_1 = require("./remove-morph-to-relations");
|
|
14
|
-
Object.defineProperty(exports, "removeMorphToRelations", { enumerable: true, get: function () { return __importDefault(remove_morph_to_relations_1).default; } });
|
|
15
|
-
var remove_dynamic_zones_1 = require("./remove-dynamic-zones");
|
|
16
|
-
Object.defineProperty(exports, "removeDynamicZones", { enumerable: true, get: function () { return __importDefault(remove_dynamic_zones_1).default; } });
|
|
17
|
-
var remove_disallowed_fields_1 = require("./remove-disallowed-fields");
|
|
18
|
-
Object.defineProperty(exports, "removeDisallowedFields", { enumerable: true, get: function () { return __importDefault(remove_disallowed_fields_1).default; } });
|
|
19
|
-
var remove_restricted_fields_1 = require("./remove-restricted-fields");
|
|
20
|
-
Object.defineProperty(exports, "removeRestrictedFields", { enumerable: true, get: function () { return __importDefault(remove_restricted_fields_1).default; } });
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/index.ts"],"names":[],"mappings":";;;;;;AAAA,qDAA8D;AAArD,kIAAA,OAAO,OAAkB;AAClC,mDAA4D;AAAnD,gIAAA,OAAO,OAAiB;AACjC,6EAAqF;AAA5E,yJAAA,OAAO,OAA6B;AAC7C,yEAAgF;AAAvE,oJAAA,OAAO,OAA0B;AAC1C,+DAAuE;AAA9D,2IAAA,OAAO,OAAsB;AACtC,uEAA+E;AAAtE,mJAAA,OAAO,OAA0B;AAC1C,uEAA+E;AAAtE,mJAAA,OAAO,OAA0B"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fp_1 = require("lodash/fp");
|
|
4
|
-
exports.default = (allowedFields = null) => ({ key, path: { attribute: path } }, { remove }) => {
|
|
5
|
-
// All fields are allowed
|
|
6
|
-
if (allowedFields === null) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
// Throw on invalid formats
|
|
10
|
-
if (!((0, fp_1.isArray)(allowedFields) && allowedFields.every(fp_1.isString))) {
|
|
11
|
-
throw new TypeError(`Expected array of strings for allowedFields but got "${typeof allowedFields}"`);
|
|
12
|
-
}
|
|
13
|
-
if ((0, fp_1.isNil)(path)) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const containedPaths = getContainedPaths(path);
|
|
17
|
-
/**
|
|
18
|
-
* Tells if the current path should be kept or not based
|
|
19
|
-
* on the success of the check functions for any of the allowed paths.
|
|
20
|
-
*
|
|
21
|
-
* The check functions are defined as follow:
|
|
22
|
-
*
|
|
23
|
-
* `containedPaths.includes(p)`
|
|
24
|
-
* @example
|
|
25
|
-
* ```js
|
|
26
|
-
* const path = 'foo.bar.field';
|
|
27
|
-
* const p = 'foo.bar';
|
|
28
|
-
* // it should match
|
|
29
|
-
*
|
|
30
|
-
* const path = 'foo.bar.field';
|
|
31
|
-
* const p = 'bar.foo';
|
|
32
|
-
* // it shouldn't match
|
|
33
|
-
*
|
|
34
|
-
* const path = 'foo.bar';
|
|
35
|
-
* const p = 'foo.bar.field';
|
|
36
|
-
* // it should match but isn't handled by this check
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* `p.startsWith(`${path}.`)`
|
|
40
|
-
* @example
|
|
41
|
-
* ```js
|
|
42
|
-
* const path = 'foo.bar';
|
|
43
|
-
* const p = 'foo.bar.field';
|
|
44
|
-
* // it should match
|
|
45
|
-
*
|
|
46
|
-
* const path = 'foo.bar.field';
|
|
47
|
-
* const p = 'bar.foo';
|
|
48
|
-
* // it shouldn't match
|
|
49
|
-
*
|
|
50
|
-
* const path = 'foo.bar.field';
|
|
51
|
-
* const p = 'foo.bar';
|
|
52
|
-
* // it should match but isn't handled by this check
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
const isPathAllowed = allowedFields.some((p) => containedPaths.includes(p) || p.startsWith(`${path}.`));
|
|
56
|
-
if (isPathAllowed) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
// Remove otherwise
|
|
60
|
-
remove(key);
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Retrieve the list of allowed paths based on the given path
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```js
|
|
67
|
-
* const containedPaths = getContainedPaths('foo');
|
|
68
|
-
* // ['foo']
|
|
69
|
-
*
|
|
70
|
-
* * const containedPaths = getContainedPaths('foo.bar');
|
|
71
|
-
* // ['foo', 'foo.bar']
|
|
72
|
-
*
|
|
73
|
-
* * const containedPaths = getContainedPaths('foo.bar.field');
|
|
74
|
-
* // ['foo', 'foo.bar', 'foo.bar.field']
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
const getContainedPaths = (path) => {
|
|
78
|
-
const parts = (0, fp_1.toPath)(path);
|
|
79
|
-
return parts.reduce((acc, value, index, list) => {
|
|
80
|
-
return [...acc, list.slice(0, index + 1).join('.')];
|
|
81
|
-
}, []);
|
|
82
|
-
};
|
|
83
|
-
//# sourceMappingURL=remove-disallowed-fields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-disallowed-fields.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/remove-disallowed-fields.ts"],"names":[],"mappings":";;AAAA,kCAA6D;AAG7D,kBAAe,CAAC,gBAAiC,IAAI,EAAW,EAAE,CAChE,CAAC,EAAE,GAAG,EA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ACrB,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const content_types_1 = require("../../content-types");
|
|
4
|
-
const visitor = ({ key, attribute }, { remove }) => {
|
|
5
|
-
if ((0, content_types_1.isDynamicZoneAttribute)(attribute)) {
|
|
6
|
-
remove(key);
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
exports.default = visitor;
|
|
10
|
-
//# sourceMappingURL=remove-dynamic-zones.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-dynamic-zones.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/remove-dynamic-zones.ts"],"names":[],"mappings":";;AAAA,uDAA6D;AAG7D,MAAM,OAAO,GAAY,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IAC1D,IAAI,IAAA,sCAAsB,EAAC,SAAS,CAAC,EAAE;QACrC,MAAM,CAAC,GAAG,CAAC,CAAC;KACb;AACH,CAAC,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const content_types_1 = require("../../content-types");
|
|
4
|
-
const visitor = ({ key, attribute }, { remove }) => {
|
|
5
|
-
if ((0, content_types_1.isMorphToRelationalAttribute)(attribute)) {
|
|
6
|
-
remove(key);
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
exports.default = visitor;
|
|
10
|
-
//# sourceMappingURL=remove-morph-to-relations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-morph-to-relations.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/remove-morph-to-relations.ts"],"names":[],"mappings":";;AAAA,uDAAmE;AAGnE,MAAM,OAAO,GAAY,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IAC1D,IAAI,IAAA,4CAA4B,EAAC,SAAS,CAAC,EAAE;QAC3C,MAAM,CAAC,GAAG,CAAC,CAAC;KACb;AACH,CAAC,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const visitor = ({ key, attribute }, { remove }) => {
|
|
4
|
-
if (attribute?.type === 'password') {
|
|
5
|
-
remove(key);
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
exports.default = visitor;
|
|
9
|
-
//# sourceMappingURL=remove-password.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-password.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/remove-password.ts"],"names":[],"mappings":";;AAEA,MAAM,OAAO,GAAY,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IAC1D,IAAI,SAAS,EAAE,IAAI,KAAK,UAAU,EAAE;QAClC,MAAM,CAAC,GAAG,CAAC,CAAC;KACb;AACH,CAAC,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const content_types_1 = require("../../content-types");
|
|
4
|
-
const visitor = ({ schema, key, attribute }, { remove }) => {
|
|
5
|
-
if (!attribute) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
const isPrivate = attribute.private === true || (0, content_types_1.isPrivateAttribute)(schema, key);
|
|
9
|
-
if (isPrivate) {
|
|
10
|
-
remove(key);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
exports.default = visitor;
|
|
14
|
-
//# sourceMappingURL=remove-private.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-private.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/remove-private.ts"],"names":[],"mappings":";;AAAA,uDAAyD;AAGzD,MAAM,OAAO,GAAY,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IAClE,IAAI,CAAC,SAAS,EAAE;QACd,OAAO;KACR;IAED,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,KAAK,IAAI,IAAI,IAAA,kCAAkB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEhF,IAAI,SAAS,EAAE;QACb,MAAM,CAAC,GAAG,CAAC,CAAC;KACb;AACH,CAAC,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fp_1 = require("lodash/fp");
|
|
4
|
-
exports.default = (restrictedFields = null) => ({ key, path: { attribute: path } }, { remove }) => {
|
|
5
|
-
// Remove all fields
|
|
6
|
-
if (restrictedFields === null) {
|
|
7
|
-
remove(key);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
// Throw on invalid formats
|
|
11
|
-
if (!((0, fp_1.isArray)(restrictedFields) && restrictedFields.every(fp_1.isString))) {
|
|
12
|
-
throw new TypeError(`Expected array of strings for restrictedFields but got "${typeof restrictedFields}"`);
|
|
13
|
-
}
|
|
14
|
-
// Remove if an exact match was found
|
|
15
|
-
if (restrictedFields.includes(path)) {
|
|
16
|
-
remove(key);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
// Remove nested matches
|
|
20
|
-
const isRestrictedNested = restrictedFields.some((allowedPath) => path?.toString().startsWith(`${allowedPath}.`));
|
|
21
|
-
if (isRestrictedNested) {
|
|
22
|
-
remove(key);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=remove-restricted-fields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-restricted-fields.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/remove-restricted-fields.ts"],"names":[],"mappings":";;AAAA,kCAA8C;AAG9C,kBAAe,CAAC,mBAAoC,IAAI,EAAW,EAAE,CACnE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACjD,oBAAoB;IACpB,IAAI,gBAAgB,KAAK,IAAI,EAAE;QAC7B,MAAM,CAAC,GAAG,CAAC,CAAC;QACZ,OAAO;KACR;IAED,2BAA2B;IAC3B,IAAI,CAAC,CAAC,IAAA,YAAO,EAAC,gBAAgB,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,aAAQ,CAAC,CAAC,EAAE;QACpE,MAAM,IAAI,SAAS,CACjB,2DAA2D,OAAO,gBAAgB,GAAG,CACtF,CAAC;KACH;IAED,qCAAqC;IACrC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,IAAc,CAAC,EAAE;QAC7C,MAAM,CAAC,GAAG,CAAC,CAAC;QACZ,OAAO;KACR;IAED,wBAAwB;IACxB,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAC/D,IAAI,EAAE,QAAQ,EAAE,CAAC,UAAU,CAAC,GAAG,WAAW,GAAG,CAAC,CAC/C,CAAC;IACF,IAAI,kBAAkB,EAAE;QACtB,MAAM,CAAC,GAAG,CAAC,CAAC;KACb;AACH,CAAC,CAAC"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const contentTypeUtils = __importStar(require("../../content-types"));
|
|
27
|
-
const ACTIONS_TO_VERIFY = ['find'];
|
|
28
|
-
const { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = contentTypeUtils.constants;
|
|
29
|
-
exports.default = (auth) => async ({ data, key, attribute, schema }, { remove, set }) => {
|
|
30
|
-
if (!attribute) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const isRelation = attribute.type === 'relation';
|
|
34
|
-
if (!isRelation) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const handleMorphRelation = async () => {
|
|
38
|
-
const newMorphValue = [];
|
|
39
|
-
for (const element of data[key]) {
|
|
40
|
-
const scopes = ACTIONS_TO_VERIFY.map((action) => `${element.__type}.${action}`);
|
|
41
|
-
const isAllowed = await hasAccessToSomeScopes(scopes, auth);
|
|
42
|
-
if (isAllowed) {
|
|
43
|
-
newMorphValue.push(element);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
// If the new value is empty, remove the relation completely
|
|
47
|
-
if (newMorphValue.length === 0) {
|
|
48
|
-
remove(key);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
set(key, newMorphValue);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const handleRegularRelation = async () => {
|
|
55
|
-
const scopes = ACTIONS_TO_VERIFY.map((action) => `${attribute.target}.${action}`);
|
|
56
|
-
const isAllowed = await hasAccessToSomeScopes(scopes, auth);
|
|
57
|
-
// If the authenticated user don't have access to any of the scopes, then remove the field
|
|
58
|
-
if (!isAllowed) {
|
|
59
|
-
remove(key);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const isCreatorRelation = [CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE].includes(key);
|
|
63
|
-
// Polymorphic relations
|
|
64
|
-
if (contentTypeUtils.isMorphToRelationalAttribute(attribute)) {
|
|
65
|
-
await handleMorphRelation();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
// Creator relations
|
|
69
|
-
if (isCreatorRelation && schema.options?.populateCreatorFields) {
|
|
70
|
-
// do nothing
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
// Regular relations
|
|
74
|
-
await handleRegularRelation();
|
|
75
|
-
};
|
|
76
|
-
const hasAccessToSomeScopes = async (scopes, auth) => {
|
|
77
|
-
for (const scope of scopes) {
|
|
78
|
-
try {
|
|
79
|
-
await strapi.auth.verify(auth, { scope });
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return false;
|
|
87
|
-
};
|
|
88
|
-
//# sourceMappingURL=remove-restricted-relations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-restricted-relations.js","sourceRoot":"","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B,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,IAAI,MAAM,EAAE,CAAC,CAAC;QAElF,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAE5D,0FAA0F;QAC1F,IAAI,CAAC,SAAS,EAAE;YACd,MAAM,CAAC,GAAG,CAAC,CAAC;SACb;IACH,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,CAAC,oBAAoB,EAAE,oBAAoB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAErF,wBAAwB;IACxB,IAAI,gBAAgB,CAAC,4BAA4B,CAAC,SAAS,CAAC,EAAE;QAC5D,MAAM,mBAAmB,EAAE,CAAC;QAC5B,OAAO;KACR;IAED,oBAAoB;IACpB,IAAI,iBAAiB,IAAI,MAAM,CAAC,OAAO,EAAE,qBAAqB,EAAE;QAC9D,aAAa;QACb,OAAO;KACR;IAED,oBAAoB;IACpB,MAAM,qBAAqB,EAAE,CAAC;AAChC,CAAC,CAAC;AAEJ,MAAM,qBAAqB,GAAG,KAAK,EAAE,MAAgB,EAAE,IAAa,EAAE,EAAE;IACtE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC1B,IAAI;YACF,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC;SACb;QAAC,MAAM;YACN,SAAS;SACV;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const fp_1 = require("lodash/fp");
|
|
27
|
-
const contentTypes = __importStar(require("./content-types"));
|
|
28
|
-
const { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = contentTypes.constants;
|
|
29
|
-
const setCreatorFields = ({ user, isEdition = false }) => (data) => {
|
|
30
|
-
if (isEdition) {
|
|
31
|
-
return (0, fp_1.assoc)(UPDATED_BY_ATTRIBUTE, user.id, data);
|
|
32
|
-
}
|
|
33
|
-
return (0, fp_1.assign)(data, {
|
|
34
|
-
[CREATED_BY_ATTRIBUTE]: user.id,
|
|
35
|
-
[UPDATED_BY_ATTRIBUTE]: user.id,
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
exports.default = setCreatorFields;
|
|
39
|
-
//# sourceMappingURL=set-creator-fields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"set-creator-fields.js","sourceRoot":"","sources":["../src/set-creator-fields.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kCAA0C;AAC1C,8DAAgD;AAEhD,MAAM,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,GAAG,YAAY,CAAC,SAAS,CAAC;AAW9E,MAAM,gBAAgB,GACpB,CAAuB,EAAE,IAAI,EAAE,SAAS,GAAG,KAAK,EAAW,EAAE,EAAE,CAC/D,CAAoC,IAAgB,EAAE,EAAE;IACtD,IAAI,SAAS,EAAE;QACb,OAAO,IAAA,UAAK,EAAC,oBAAoB,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;KACnD;IAED,OAAO,IAAA,WAAM,EAAC,IAAI,EAAE;QAClB,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,EAAE;QAC/B,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,EAAE;KAChC,CAAC,CAAC;AACL,CAAC,CAAC;AAEJ,kBAAe,gBAAgB,CAAC"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.joinBy = exports.startsWithANumber = exports.toRegressedEnumValue = exports.toKebabCase = exports.isKebabCase = exports.isCamelCase = exports.stringEquals = exports.stringIncludes = exports.escapeQuery = exports.getCommonPath = exports.getCommonBeginning = exports.nameToCollectionName = exports.nameToSlug = void 0;
|
|
30
|
-
const lodash_1 = __importStar(require("lodash"));
|
|
31
|
-
const fp_1 = require("lodash/fp");
|
|
32
|
-
const slugify_1 = __importDefault(require("@sindresorhus/slugify"));
|
|
33
|
-
const nameToSlug = (name, options = { separator: '-' }) => (0, slugify_1.default)(name, options);
|
|
34
|
-
exports.nameToSlug = nameToSlug;
|
|
35
|
-
const nameToCollectionName = (name) => (0, slugify_1.default)(name, { separator: '_' });
|
|
36
|
-
exports.nameToCollectionName = nameToCollectionName;
|
|
37
|
-
const toRegressedEnumValue = (value) => (0, slugify_1.default)(value, {
|
|
38
|
-
decamelize: false,
|
|
39
|
-
lowercase: false,
|
|
40
|
-
separator: '_',
|
|
41
|
-
});
|
|
42
|
-
exports.toRegressedEnumValue = toRegressedEnumValue;
|
|
43
|
-
const getCommonBeginning = (...strings) => lodash_1.default.takeWhile(strings[0], (char, index) => strings.every((string) => string[index] === char)).join('');
|
|
44
|
-
exports.getCommonBeginning = getCommonBeginning;
|
|
45
|
-
const getCommonPath = (...paths) => {
|
|
46
|
-
const [segments, ...otherSegments] = paths.map((it) => lodash_1.default.split(it, '/'));
|
|
47
|
-
return lodash_1.default.join(lodash_1.default.takeWhile(segments, (str, index) => otherSegments.every((it) => it[index] === str)), '/');
|
|
48
|
-
};
|
|
49
|
-
exports.getCommonPath = getCommonPath;
|
|
50
|
-
const escapeQuery = (query, charsToEscape, escapeChar = '\\') => {
|
|
51
|
-
return query
|
|
52
|
-
.split('')
|
|
53
|
-
.reduce((escapedQuery, char) => charsToEscape.includes(char)
|
|
54
|
-
? `${escapedQuery}${escapeChar}${char}`
|
|
55
|
-
: `${escapedQuery}${char}`, '');
|
|
56
|
-
};
|
|
57
|
-
exports.escapeQuery = escapeQuery;
|
|
58
|
-
const stringIncludes = (arr, val) => arr.map(String).includes(String(val));
|
|
59
|
-
exports.stringIncludes = stringIncludes;
|
|
60
|
-
const stringEquals = (a, b) => String(a) === String(b);
|
|
61
|
-
exports.stringEquals = stringEquals;
|
|
62
|
-
const isCamelCase = (value) => /^[a-z][a-zA-Z0-9]+$/.test(value);
|
|
63
|
-
exports.isCamelCase = isCamelCase;
|
|
64
|
-
const isKebabCase = (value) => /^([a-z][a-z0-9]*)(-[a-z0-9]+)*$/.test(value);
|
|
65
|
-
exports.isKebabCase = isKebabCase;
|
|
66
|
-
const startsWithANumber = (value) => /^[0-9]/.test(value);
|
|
67
|
-
exports.startsWithANumber = startsWithANumber;
|
|
68
|
-
const joinBy = (joint, ...args) => {
|
|
69
|
-
const trim = (0, fp_1.trimChars)(joint);
|
|
70
|
-
const trimEnd = (0, fp_1.trimCharsEnd)(joint);
|
|
71
|
-
const trimStart = (0, fp_1.trimCharsStart)(joint);
|
|
72
|
-
return args.reduce((url, path, index) => {
|
|
73
|
-
if (args.length === 1)
|
|
74
|
-
return path;
|
|
75
|
-
if (index === 0)
|
|
76
|
-
return trimEnd(path);
|
|
77
|
-
if (index === args.length - 1)
|
|
78
|
-
return url + joint + trimStart(path);
|
|
79
|
-
return url + joint + trim(path);
|
|
80
|
-
}, '');
|
|
81
|
-
};
|
|
82
|
-
exports.joinBy = joinBy;
|
|
83
|
-
const toKebabCase = (value) => (0, lodash_1.kebabCase)(value);
|
|
84
|
-
exports.toKebabCase = toKebabCase;
|
|
85
|
-
//# sourceMappingURL=string-formatting.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string-formatting.js","sourceRoot":"","sources":["../src/string-formatting.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAsC;AACtC,kCAAoE;AACpE,oEAA4C;AAE5C,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,UAA2B,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,EAAE,CACjF,IAAA,iBAAO,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AA0DvB,gCAAU;AAxDZ,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,iBAAO,EAAC,IAAI,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;AAyD/E,oDAAoB;AAvDtB,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAAE,EAAE,CAC7C,IAAA,iBAAO,EAAC,KAAK,EAAE;IACb,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,GAAG;CACf,CAAC,CAAC;AA2DH,oDAAoB;AAzDtB,MAAM,kBAAkB,GAAG,CAAC,GAAG,OAAiB,EAAE,EAAE,CAClD,gBAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAC9F,EAAE,CACH,CAAC;AA8CF,gDAAkB;AA5CpB,MAAM,aAAa,GAAG,CAAC,GAAG,KAAe,EAAE,EAAE;IAC3C,MAAM,CAAC,QAAQ,EAAE,GAA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|
|
5
|
-
const isObj = (value) => (0, lodash_1.isPlainObject)(value);
|
|
6
|
-
/**
|
|
7
|
-
* Allow dynamic config values through the native ES6 template string function.
|
|
8
|
-
*/
|
|
9
|
-
const templateConfiguration = (obj, configPath = '') => {
|
|
10
|
-
// Allow values which looks like such as an ES6 literal string without parenthesis inside (aka function call).
|
|
11
|
-
// Exclude config with conflicting syntax (e.g. npm scripts).
|
|
12
|
-
return Object.keys(obj).reduce((acc, key) => {
|
|
13
|
-
const value = obj[key];
|
|
14
|
-
if (isObj(value) && !(0, lodash_1.isString)(value)) {
|
|
15
|
-
acc[key] = templateConfiguration(value, `${configPath}.${key}`);
|
|
16
|
-
}
|
|
17
|
-
else if ((0, lodash_1.isString)(value) &&
|
|
18
|
-
!excludeConfigPaths.includes(configPath.substr(1)) &&
|
|
19
|
-
value.match(regex) !== null) {
|
|
20
|
-
// eslint-disable-next-line prefer-template, no-eval
|
|
21
|
-
acc[key] = eval('`' + value + '`');
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
acc[key] = value;
|
|
25
|
-
}
|
|
26
|
-
return acc;
|
|
27
|
-
}, {});
|
|
28
|
-
};
|
|
29
|
-
module.exports = templateConfiguration;
|
|
30
|
-
//# sourceMappingURL=template-configuration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-configuration.js","sourceRoot":"","sources":["../src/template-configuration.ts"],"names":[],"mappings":";AAAA,mCAAiD;AAEjD,MAAM,KAAK,GAAG,eAAe,CAAC;AAC9B,MAAM,kBAAkB,GAAG,CAAC,cAAc,CAAC,CAAC;AAE5C,MAAM,KAAK,GAAG,CAAC,KAAc,EAAoC,EAAE,CAAC,IAAA,sBAAa,EAAC,KAAK,CAAC,CAAC;AAEzF;;GAEG;AACH,MAAM,qBAAqB,GAAG,CAAC,GAA4B,EAAE,UAAU,GAAG,EAAE,EAAE,EAAE;IAC9E,8GAA8G;IAC9G,6DAA6D;IAC7D,OAAO,MAAM,CAAC,I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