@jsreport/jsreport-core 3.0.1 → 3.1.2-test.2
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/LICENSE +166 -166
- package/README.md +298 -284
- package/index.js +29 -27
- package/lib/main/blobStorage/blobStorage.js +52 -47
- package/lib/main/blobStorage/inMemoryProvider.js +27 -27
- package/lib/main/blobStorage/mainActions.js +24 -24
- package/lib/main/createDefaultLoggerFormat.js +17 -17
- package/lib/main/defaults.js +14 -14
- package/lib/main/extensions/discover.js +20 -20
- package/lib/main/extensions/extensionsManager.js +264 -265
- package/lib/main/extensions/fileUtils.js +56 -55
- package/lib/main/extensions/findVersion.js +49 -53
- package/lib/main/extensions/locationCache.js +103 -97
- package/lib/main/extensions/sorter.js +10 -10
- package/lib/main/extensions/validateMinimalVersion.js +50 -50
- package/lib/main/folders/cascadeFolderRemove.js +25 -25
- package/lib/main/folders/getEntitiesInFolder.js +53 -53
- package/lib/main/folders/index.js +42 -42
- package/lib/main/folders/moveBetweenFolders.js +354 -354
- package/lib/main/folders/validateDuplicatedName.js +107 -107
- package/lib/main/folders/validateReservedName.js +53 -53
- package/lib/main/logger.js +244 -244
- package/lib/main/migration/resourcesToAssets.js +230 -210
- package/lib/main/migration/xlsxTemplatesToAssets.js +128 -118
- package/lib/main/monitoring.js +91 -91
- package/lib/main/optionsLoad.js +237 -237
- package/lib/main/optionsSchema.js +237 -237
- package/lib/main/reporter.js +579 -578
- package/lib/main/schemaValidator.js +252 -252
- package/lib/main/settings.js +154 -154
- package/lib/main/store/checkDuplicatedId.js +27 -27
- package/lib/main/store/collection.js +329 -329
- package/lib/main/store/documentStore.js +469 -469
- package/lib/main/store/mainActions.js +28 -28
- package/lib/main/store/memoryStoreProvider.js +99 -99
- package/lib/main/store/queue.js +48 -48
- package/lib/main/store/referenceUtils.js +251 -251
- package/lib/main/store/setupValidateId.js +43 -43
- package/lib/main/store/setupValidateShortid.js +71 -71
- package/lib/main/store/transaction.js +69 -69
- package/lib/main/store/typeUtils.js +180 -180
- package/lib/main/templates.js +34 -34
- package/lib/main/validateEntityName.js +62 -62
- package/lib/shared/createError.js +36 -36
- package/lib/shared/encryption.js +114 -114
- package/lib/shared/folders/index.js +11 -11
- package/lib/shared/folders/normalizeEntityPath.js +15 -15
- package/lib/shared/folders/resolveEntityFromPath.js +88 -88
- package/lib/shared/folders/resolveEntityPath.js +46 -46
- package/lib/shared/folders/resolveFolderFromPath.js +38 -38
- package/lib/shared/generateRequestId.js +4 -4
- package/lib/shared/listenerCollection.js +169 -0
- package/lib/shared/normalizeMetaFromLogs.js +30 -30
- package/lib/shared/reporter.js +123 -123
- package/lib/shared/request.js +64 -64
- package/lib/shared/tempFilesHandler.js +81 -81
- package/lib/shared/templates.js +82 -82
- package/lib/static/helpers.js +33 -33
- package/lib/worker/blobStorage.js +34 -34
- package/lib/worker/defaultProxyExtend.js +46 -46
- package/lib/worker/documentStore.js +49 -49
- package/lib/worker/extensionsManager.js +17 -17
- package/lib/worker/logger.js +48 -48
- package/lib/worker/render/diff.js +138 -138
- package/lib/worker/render/executeEngine.js +207 -200
- package/lib/worker/render/htmlRecipe.js +10 -10
- package/lib/worker/render/moduleHelper.js +43 -43
- package/lib/worker/render/noneEngine.js +12 -12
- package/lib/worker/render/profiler.js +158 -158
- package/lib/worker/render/render.js +205 -209
- package/lib/worker/render/resolveReferences.js +60 -60
- package/lib/worker/reporter.js +191 -187
- package/lib/worker/sandbox/runInSandbox.js +13 -4
- package/lib/worker/sandbox/safeSandbox.js +828 -822
- package/lib/worker/templates.js +78 -78
- package/lib/worker/workerHandler.js +54 -54
- package/package.json +92 -92
- package/test/blobStorage/common.js +21 -21
- package/test/store/common.js +1449 -1449
|
@@ -1,237 +1,237 @@
|
|
|
1
|
-
const { getDefaultTempDirectory, getDefaultLoadConfig } = require('./defaults')
|
|
2
|
-
// we use deepmerge instead of node.extend here because it supports
|
|
3
|
-
// concatenating arrays instead of replacing them, something necessary
|
|
4
|
-
// to support extending some values in schemas like the "enum"
|
|
5
|
-
const deepMerge = require('deepmerge')
|
|
6
|
-
|
|
7
|
-
module.exports.getRootSchemaOptions = () => ({
|
|
8
|
-
type: 'object',
|
|
9
|
-
properties: {
|
|
10
|
-
rootDirectory: {
|
|
11
|
-
type: 'string',
|
|
12
|
-
description: 'specifies where is the application root and where jsreport searches for extensions'
|
|
13
|
-
},
|
|
14
|
-
appDirectory: {
|
|
15
|
-
type: 'string',
|
|
16
|
-
description: 'specifies directory of the script that was used to start node.js, this value is mostly metadata that is useful for your own code inside jsreport scripts'
|
|
17
|
-
},
|
|
18
|
-
tempDirectory: {
|
|
19
|
-
type: 'string',
|
|
20
|
-
default: getDefaultTempDirectory(),
|
|
21
|
-
description: 'specifies where jsreport stores temporary files used by the conversion pipeline'
|
|
22
|
-
},
|
|
23
|
-
loadConfig: {
|
|
24
|
-
type: 'boolean',
|
|
25
|
-
default: getDefaultLoadConfig(),
|
|
26
|
-
description: 'specifies if jsreport should load configuration values from external sources (cli args, env vars, configuration files) or not'
|
|
27
|
-
},
|
|
28
|
-
autoTempCleanup: {
|
|
29
|
-
type: 'boolean',
|
|
30
|
-
default: true,
|
|
31
|
-
description: 'specifies if after some interval jsreport should automatically clean up temporary files generated while rendering reports'
|
|
32
|
-
},
|
|
33
|
-
discover: {
|
|
34
|
-
type: 'boolean',
|
|
35
|
-
defaultNotInitialized: true,
|
|
36
|
-
description: 'specifies if jsreport should discover/search installed extensions in project and use them automatically'
|
|
37
|
-
},
|
|
38
|
-
useExtensionsLocationCache: {
|
|
39
|
-
type: 'boolean',
|
|
40
|
-
default: true,
|
|
41
|
-
description: '
|
|
42
|
-
},
|
|
43
|
-
logger: {
|
|
44
|
-
type: 'object',
|
|
45
|
-
properties: {
|
|
46
|
-
silent: { type: 'boolean' }
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
reportTimeout: {
|
|
50
|
-
type: ['string', 'number'],
|
|
51
|
-
'$jsreport-acceptsDuration': true,
|
|
52
|
-
description: 'global single timeout that controls how much a report generation should wait before it times out',
|
|
53
|
-
default: 60000
|
|
54
|
-
},
|
|
55
|
-
reportTimeoutMargin: {
|
|
56
|
-
type: ['string', 'number'],
|
|
57
|
-
description: 'the time to wait before the worker thread is forcibly killed after timeout',
|
|
58
|
-
'$jsreport-acceptsDuration': true,
|
|
59
|
-
default: '2s'
|
|
60
|
-
},
|
|
61
|
-
enableRequestReportTimeout: { type: 'boolean', default: false, description: 'option that enables passing a custom report timeout per request using req.options.timeout. this enables that the caller of the report generation control the report timeout so enable it only when you trust the caller' },
|
|
62
|
-
allowLocalFilesAccess: { type: 'boolean', default: false },
|
|
63
|
-
encryption: {
|
|
64
|
-
type: 'object',
|
|
65
|
-
default: {},
|
|
66
|
-
properties: {
|
|
67
|
-
secretKey: {
|
|
68
|
-
type: 'string',
|
|
69
|
-
minLength: 16,
|
|
70
|
-
maxLength: 16
|
|
71
|
-
},
|
|
72
|
-
enabled: {
|
|
73
|
-
type: 'boolean',
|
|
74
|
-
default: true
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
sandbox: {
|
|
79
|
-
type: 'object',
|
|
80
|
-
properties: {
|
|
81
|
-
allowedModules: {
|
|
82
|
-
anyOf: [{
|
|
83
|
-
type: 'string',
|
|
84
|
-
'$jsreport-constantOrArray': ['*']
|
|
85
|
-
}, {
|
|
86
|
-
type: 'array',
|
|
87
|
-
items: { type: 'string' }
|
|
88
|
-
}]
|
|
89
|
-
},
|
|
90
|
-
cache: {
|
|
91
|
-
type: 'object',
|
|
92
|
-
properties: {
|
|
93
|
-
max: { type: 'number' },
|
|
94
|
-
enabled: { type: 'boolean' }
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
workers: {
|
|
100
|
-
type: 'object',
|
|
101
|
-
default: {},
|
|
102
|
-
properties: {
|
|
103
|
-
numberOfWorkers: {
|
|
104
|
-
type: 'number',
|
|
105
|
-
default: 2,
|
|
106
|
-
description: 'Number of workers allocated. Every worker can process a single request in parallel. This means increasing numberOfWorkers will increase the parallelization.'
|
|
107
|
-
},
|
|
108
|
-
initTimeout: {
|
|
109
|
-
type: ['string', 'number'],
|
|
110
|
-
'$jsreport-acceptsDuration': true,
|
|
111
|
-
description: 'Timeout for initializing a worker thread. This should be increased only when running at very slow HW environment.',
|
|
112
|
-
default: '30s'
|
|
113
|
-
},
|
|
114
|
-
resourceLimits: {
|
|
115
|
-
type: 'object',
|
|
116
|
-
description: 'Limits for the individual workers. See https://nodejs.org/api/worker_threads.html#worker_threads_worker_resourcelimits',
|
|
117
|
-
properties: {
|
|
118
|
-
maxOldGenerationSizeMb: { type: 'number' },
|
|
119
|
-
maxYoungGenerationSizeMb: { type: 'number' },
|
|
120
|
-
codeRangeSizeMb: { type: 'number' },
|
|
121
|
-
stackSizeMb: { type: 'number' }
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
store: {
|
|
127
|
-
type: 'object',
|
|
128
|
-
properties: {
|
|
129
|
-
provider: { type: 'string', enum: ['memory'] }
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
blobStorage: {
|
|
133
|
-
type: 'object',
|
|
134
|
-
properties: {
|
|
135
|
-
provider: { type: 'string', enum: ['memory'] }
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
extensions: {
|
|
139
|
-
type: 'object',
|
|
140
|
-
properties: {}
|
|
141
|
-
},
|
|
142
|
-
extensionsList: {
|
|
143
|
-
anyOf: [
|
|
144
|
-
{
|
|
145
|
-
type: 'string',
|
|
146
|
-
'$jsreport-constantOrArray': []
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
type: 'array',
|
|
150
|
-
items: { type: 'string' }
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
},
|
|
154
|
-
migrateXlsxTemplatesToAssets: {
|
|
155
|
-
type: 'boolean',
|
|
156
|
-
default: true
|
|
157
|
-
},
|
|
158
|
-
migrateResourcesToAssets: {
|
|
159
|
-
type: 'boolean',
|
|
160
|
-
default: true
|
|
161
|
-
},
|
|
162
|
-
profiler: {
|
|
163
|
-
type: 'object',
|
|
164
|
-
default: {},
|
|
165
|
-
properties: {
|
|
166
|
-
maxProfilesHistory: {
|
|
167
|
-
type: 'number',
|
|
168
|
-
default: 1000
|
|
169
|
-
},
|
|
170
|
-
cleanupInterval: {
|
|
171
|
-
type: ['string', 'number'],
|
|
172
|
-
'$jsreport-acceptsDuration': true,
|
|
173
|
-
default: '1m'
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
module.exports.extendRootSchemaOptions = (rootSchema, schema) => {
|
|
181
|
-
const schemasToApply = Array.isArray(schema) ? schema : [schema]
|
|
182
|
-
|
|
183
|
-
rootSchema.properties = rootSchema.properties || {}
|
|
184
|
-
|
|
185
|
-
rootSchema.properties.extensions = rootSchema.properties.extensions || {
|
|
186
|
-
type: 'object',
|
|
187
|
-
properties: {}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
schemasToApply.forEach((sch) => {
|
|
191
|
-
if (sch == null) {
|
|
192
|
-
return
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (sch.schema == null && sch.name != null) {
|
|
196
|
-
rootSchema.properties.extensions.properties[sch.name] = {
|
|
197
|
-
type: 'object',
|
|
198
|
-
properties: {
|
|
199
|
-
enabled: { type: 'boolean' }
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return
|
|
203
|
-
} else if (sch.schema == null) {
|
|
204
|
-
return
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
Object.keys(sch.schema).forEach((key) => {
|
|
208
|
-
const current = sch.schema[key]
|
|
209
|
-
|
|
210
|
-
if (key === 'extensions') {
|
|
211
|
-
if (current == null) {
|
|
212
|
-
return
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
Object.keys(current).forEach(s => {
|
|
216
|
-
rootSchema.properties.extensions.properties[s] = deepMerge(rootSchema.properties.extensions.properties[s] || {}, current[s])
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
rootSchema.properties.extensions.properties[s].properties &&
|
|
220
|
-
rootSchema.properties.extensions.properties[s].properties.enabled == null
|
|
221
|
-
) {
|
|
222
|
-
rootSchema.properties.extensions.properties[s].properties.enabled = { type: 'boolean' }
|
|
223
|
-
}
|
|
224
|
-
})
|
|
225
|
-
} else if (current != null) {
|
|
226
|
-
rootSchema.properties[key] = deepMerge(rootSchema.properties[key] || {}, current)
|
|
227
|
-
}
|
|
228
|
-
})
|
|
229
|
-
})
|
|
230
|
-
|
|
231
|
-
return rootSchema
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
module.exports.ignoreInitialSchemaProperties = [
|
|
235
|
-
'properties.store.properties.provider',
|
|
236
|
-
'properties.blobStorage.properties.provider'
|
|
237
|
-
]
|
|
1
|
+
const { getDefaultTempDirectory, getDefaultLoadConfig } = require('./defaults')
|
|
2
|
+
// we use deepmerge instead of node.extend here because it supports
|
|
3
|
+
// concatenating arrays instead of replacing them, something necessary
|
|
4
|
+
// to support extending some values in schemas like the "enum"
|
|
5
|
+
const deepMerge = require('deepmerge')
|
|
6
|
+
|
|
7
|
+
module.exports.getRootSchemaOptions = () => ({
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
rootDirectory: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'specifies where is the application root and where jsreport searches for extensions'
|
|
13
|
+
},
|
|
14
|
+
appDirectory: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'specifies directory of the script that was used to start node.js, this value is mostly metadata that is useful for your own code inside jsreport scripts'
|
|
17
|
+
},
|
|
18
|
+
tempDirectory: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
default: getDefaultTempDirectory(),
|
|
21
|
+
description: 'specifies where jsreport stores temporary files used by the conversion pipeline'
|
|
22
|
+
},
|
|
23
|
+
loadConfig: {
|
|
24
|
+
type: 'boolean',
|
|
25
|
+
default: getDefaultLoadConfig(),
|
|
26
|
+
description: 'specifies if jsreport should load configuration values from external sources (cli args, env vars, configuration files) or not'
|
|
27
|
+
},
|
|
28
|
+
autoTempCleanup: {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
default: true,
|
|
31
|
+
description: 'specifies if after some interval jsreport should automatically clean up temporary files generated while rendering reports'
|
|
32
|
+
},
|
|
33
|
+
discover: {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
defaultNotInitialized: true,
|
|
36
|
+
description: 'specifies if jsreport should discover/search installed extensions in project and use them automatically'
|
|
37
|
+
},
|
|
38
|
+
useExtensionsLocationCache: {
|
|
39
|
+
type: 'boolean',
|
|
40
|
+
default: true,
|
|
41
|
+
description: 'whether if jsreport should read list of extensions from a previous generated cache or if it should crawl and try to search extensions again, set it to false when you want to always force crawling node_modules when searching for extensions while starting jsreport'
|
|
42
|
+
},
|
|
43
|
+
logger: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
silent: { type: 'boolean' }
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
reportTimeout: {
|
|
50
|
+
type: ['string', 'number'],
|
|
51
|
+
'$jsreport-acceptsDuration': true,
|
|
52
|
+
description: 'global single timeout that controls how much a report generation should wait before it times out',
|
|
53
|
+
default: 60000
|
|
54
|
+
},
|
|
55
|
+
reportTimeoutMargin: {
|
|
56
|
+
type: ['string', 'number'],
|
|
57
|
+
description: 'the time to wait before the worker thread is forcibly killed after timeout',
|
|
58
|
+
'$jsreport-acceptsDuration': true,
|
|
59
|
+
default: '2s'
|
|
60
|
+
},
|
|
61
|
+
enableRequestReportTimeout: { type: 'boolean', default: false, description: 'option that enables passing a custom report timeout per request using req.options.timeout. this enables that the caller of the report generation control the report timeout so enable it only when you trust the caller' },
|
|
62
|
+
allowLocalFilesAccess: { type: 'boolean', default: false },
|
|
63
|
+
encryption: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
default: {},
|
|
66
|
+
properties: {
|
|
67
|
+
secretKey: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
minLength: 16,
|
|
70
|
+
maxLength: 16
|
|
71
|
+
},
|
|
72
|
+
enabled: {
|
|
73
|
+
type: 'boolean',
|
|
74
|
+
default: true
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
sandbox: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: {
|
|
81
|
+
allowedModules: {
|
|
82
|
+
anyOf: [{
|
|
83
|
+
type: 'string',
|
|
84
|
+
'$jsreport-constantOrArray': ['*']
|
|
85
|
+
}, {
|
|
86
|
+
type: 'array',
|
|
87
|
+
items: { type: 'string' }
|
|
88
|
+
}]
|
|
89
|
+
},
|
|
90
|
+
cache: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
max: { type: 'number' },
|
|
94
|
+
enabled: { type: 'boolean' }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
workers: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
default: {},
|
|
102
|
+
properties: {
|
|
103
|
+
numberOfWorkers: {
|
|
104
|
+
type: 'number',
|
|
105
|
+
default: 2,
|
|
106
|
+
description: 'Number of workers allocated. Every worker can process a single request in parallel. This means increasing numberOfWorkers will increase the parallelization.'
|
|
107
|
+
},
|
|
108
|
+
initTimeout: {
|
|
109
|
+
type: ['string', 'number'],
|
|
110
|
+
'$jsreport-acceptsDuration': true,
|
|
111
|
+
description: 'Timeout for initializing a worker thread. This should be increased only when running at very slow HW environment.',
|
|
112
|
+
default: '30s'
|
|
113
|
+
},
|
|
114
|
+
resourceLimits: {
|
|
115
|
+
type: 'object',
|
|
116
|
+
description: 'Limits for the individual workers. See https://nodejs.org/api/worker_threads.html#worker_threads_worker_resourcelimits',
|
|
117
|
+
properties: {
|
|
118
|
+
maxOldGenerationSizeMb: { type: 'number' },
|
|
119
|
+
maxYoungGenerationSizeMb: { type: 'number' },
|
|
120
|
+
codeRangeSizeMb: { type: 'number' },
|
|
121
|
+
stackSizeMb: { type: 'number' }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
store: {
|
|
127
|
+
type: 'object',
|
|
128
|
+
properties: {
|
|
129
|
+
provider: { type: 'string', enum: ['memory'] }
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
blobStorage: {
|
|
133
|
+
type: 'object',
|
|
134
|
+
properties: {
|
|
135
|
+
provider: { type: 'string', enum: ['memory'] }
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
extensions: {
|
|
139
|
+
type: 'object',
|
|
140
|
+
properties: {}
|
|
141
|
+
},
|
|
142
|
+
extensionsList: {
|
|
143
|
+
anyOf: [
|
|
144
|
+
{
|
|
145
|
+
type: 'string',
|
|
146
|
+
'$jsreport-constantOrArray': []
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: 'array',
|
|
150
|
+
items: { type: 'string' }
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
},
|
|
154
|
+
migrateXlsxTemplatesToAssets: {
|
|
155
|
+
type: 'boolean',
|
|
156
|
+
default: true
|
|
157
|
+
},
|
|
158
|
+
migrateResourcesToAssets: {
|
|
159
|
+
type: 'boolean',
|
|
160
|
+
default: true
|
|
161
|
+
},
|
|
162
|
+
profiler: {
|
|
163
|
+
type: 'object',
|
|
164
|
+
default: {},
|
|
165
|
+
properties: {
|
|
166
|
+
maxProfilesHistory: {
|
|
167
|
+
type: 'number',
|
|
168
|
+
default: 1000
|
|
169
|
+
},
|
|
170
|
+
cleanupInterval: {
|
|
171
|
+
type: ['string', 'number'],
|
|
172
|
+
'$jsreport-acceptsDuration': true,
|
|
173
|
+
default: '1m'
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
module.exports.extendRootSchemaOptions = (rootSchema, schema) => {
|
|
181
|
+
const schemasToApply = Array.isArray(schema) ? schema : [schema]
|
|
182
|
+
|
|
183
|
+
rootSchema.properties = rootSchema.properties || {}
|
|
184
|
+
|
|
185
|
+
rootSchema.properties.extensions = rootSchema.properties.extensions || {
|
|
186
|
+
type: 'object',
|
|
187
|
+
properties: {}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
schemasToApply.forEach((sch) => {
|
|
191
|
+
if (sch == null) {
|
|
192
|
+
return
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (sch.schema == null && sch.name != null) {
|
|
196
|
+
rootSchema.properties.extensions.properties[sch.name] = {
|
|
197
|
+
type: 'object',
|
|
198
|
+
properties: {
|
|
199
|
+
enabled: { type: 'boolean' }
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return
|
|
203
|
+
} else if (sch.schema == null) {
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
Object.keys(sch.schema).forEach((key) => {
|
|
208
|
+
const current = sch.schema[key]
|
|
209
|
+
|
|
210
|
+
if (key === 'extensions') {
|
|
211
|
+
if (current == null) {
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
Object.keys(current).forEach(s => {
|
|
216
|
+
rootSchema.properties.extensions.properties[s] = deepMerge(rootSchema.properties.extensions.properties[s] || {}, current[s])
|
|
217
|
+
|
|
218
|
+
if (
|
|
219
|
+
rootSchema.properties.extensions.properties[s].properties &&
|
|
220
|
+
rootSchema.properties.extensions.properties[s].properties.enabled == null
|
|
221
|
+
) {
|
|
222
|
+
rootSchema.properties.extensions.properties[s].properties.enabled = { type: 'boolean' }
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
} else if (current != null) {
|
|
226
|
+
rootSchema.properties[key] = deepMerge(rootSchema.properties[key] || {}, current)
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
return rootSchema
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
module.exports.ignoreInitialSchemaProperties = [
|
|
235
|
+
'properties.store.properties.provider',
|
|
236
|
+
'properties.blobStorage.properties.provider'
|
|
237
|
+
]
|