@sap/cds-dk 10.0.5 → 10.0.6
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/CHANGELOG.md +15 -0
- package/bin/export.js +1 -1
- package/bin/version.js +7 -3
- package/lib/build/plugins/hana/index.js +19 -2
- package/lib/init/projectReader.js +4 -2
- package/lib/init/template/ams/files/package.json.hbs +1 -1
- package/lib/init/template/test/files/test/test.xs.hbs +3 -2
- package/lib/init/template/xsuaa/index.js +11 -7
- package/node_modules/@sap/cds/CHANGELOG.md +9 -0
- package/node_modules/@sap/cds/lib/env/defaults.js +1 -0
- package/node_modules/@sap/cds/lib/plugins.js +4 -2
- package/node_modules/@sap/cds/lib/srv/srv-handlers.js +1 -1
- package/node_modules/@sap/cds/libx/_runtime/common/Service.js +1 -1
- package/node_modules/@sap/cds/libx/_runtime/remote/Service.js +1 -1
- package/node_modules/@sap/cds/package.json +1 -1
- package/node_modules/@sap/cds-compiler/CHANGELOG.md +12 -0
- package/node_modules/@sap/cds-compiler/lib/compiler/populate.js +1 -0
- package/node_modules/@sap/cds-compiler/lib/compiler/resolve.js +1 -1
- package/node_modules/@sap/cds-compiler/lib/model/csnUtils.js +13 -8
- package/node_modules/@sap/cds-compiler/package.json +1 -1
- package/node_modules/media-typer/README.md +15 -14
- package/node_modules/media-typer/index.js +0 -8
- package/node_modules/media-typer/package.json +16 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,10 +6,25 @@ This project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
8
8
|
|
|
9
|
+
## Version 10.0.6 - 2026-07-24
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `cds add xsuaa` now generates namespace-suffixed XSUAA `role-collections` for Kyma.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- `cds add http` no longer throws `MULTIPLE_DOCS` when `application.yaml` uses `---` separators (Spring Boot multi-profile format).
|
|
18
|
+
- `cds export --data` now reads seed data via in-memory SQLite instead of the configured db driver, so it no longer fails in projects with `requires.db: hana` (e.g. CAP Java).
|
|
19
|
+
- `cds init --java --add mta` now writes `path: srv` for the Java `srv` module in `mta.yaml` instead of `gen/srv`, so `mbt build` no longer fails with `the "gen/srv" path of the "<app>-srv" module does not exist`.
|
|
20
|
+
- `cds version` no longer reports dependency problems if no dependencies are installed at all. It prints an info message instead.
|
|
21
|
+
- `cds add test` creates tests that are green by default. Sample data is provided as commented code.
|
|
22
|
+
|
|
9
23
|
## Version 10.0.5 - 2026-07-16
|
|
10
24
|
|
|
11
25
|
### Fixed
|
|
12
26
|
|
|
27
|
+
- `cds build --for hana` now declares the plugin for native HANA artifacts placed in the build output (e.g. a `.hdbprojectionview` from `db/src`) in the generated `.hdiconfig`.
|
|
13
28
|
- `cds add typer` now generates a `jsconfig.json` file that works with VS Code.
|
|
14
29
|
- `cds debug <app> --force` on Kyma now preserves existing `NODE_OPTIONS` flags (e.g. `--max-old-space-size`) instead of overwriting them when enabling the inspector.
|
|
15
30
|
- `cds add sample` now selects `stock` in the Books list and object pages, so the overstock discount shows up in the UI.
|
package/bin/export.js
CHANGED
|
@@ -200,7 +200,7 @@ class Export extends Minify {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
async export_data (model) {
|
|
203
|
-
const db = cds.db = await cds.deploy ('*',{silent:true})
|
|
203
|
+
const db = cds.db = await cds.deploy ('*',{silent:true}).to ('sqlite::memory:')
|
|
204
204
|
const out = path.resolve (this.options.to, 'data')
|
|
205
205
|
await fs.promises.rm (out, { recursive: true, force: true })
|
|
206
206
|
await mkdirp (this.options.to, 'data')
|
package/bin/version.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const cds = require('../lib')
|
|
1
2
|
|
|
2
3
|
module.exports = exports = async function cds_version (pattern, options) {
|
|
3
4
|
console.log()
|
|
@@ -9,7 +10,12 @@ module.exports = exports = async function cds_version (pattern, options) {
|
|
|
9
10
|
print_versions (all.flat(),o)
|
|
10
11
|
if (!o.json) {
|
|
11
12
|
if (o.info) console.log ('\n','> Project:', project_info (o))
|
|
12
|
-
if (o._elsp)
|
|
13
|
+
if (o._elsp) {
|
|
14
|
+
if (!cds.utils.fs.existsSync(join(o.root, 'node_modules')))
|
|
15
|
+
console.log (`\nNo dependencies installed. Run ${BOLD}npm install${RESET}, then rerun ${BOLD}cds version${RESET}.`)
|
|
16
|
+
else
|
|
17
|
+
console.log (`\n${RED}ELSPROBLEMS${RESET} reported by ${BOLD}npm ls${RESET}. Run ${BOLD}npm install${RESET} to fix dependency problems, then rerun ${BOLD}cds version${RESET}.`)
|
|
18
|
+
}
|
|
13
19
|
}
|
|
14
20
|
console.log()
|
|
15
21
|
}
|
|
@@ -49,8 +55,6 @@ exports.help = `
|
|
|
49
55
|
repository URL at the end as a markdown link.
|
|
50
56
|
`
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
const cds = require('../lib')
|
|
54
58
|
const $ = cds.utils.sh || sh_polyfill
|
|
55
59
|
const child_process = require('node:child_process')
|
|
56
60
|
const home = require('os').homedir()
|
|
@@ -68,7 +68,6 @@ module.exports = class HanaBuildPlugin extends require('../internal') {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
// create additional stuff in dest
|
|
71
|
-
await this._writeHdiConfig(hdiPlugins)
|
|
72
71
|
await this._writeHdiNamespace()
|
|
73
72
|
await this._writeUndeployJson()
|
|
74
73
|
|
|
@@ -100,6 +99,8 @@ module.exports = class HanaBuildPlugin extends require('../internal') {
|
|
|
100
99
|
)
|
|
101
100
|
}
|
|
102
101
|
|
|
102
|
+
await this._writeHdiConfig(hdiPlugins)
|
|
103
|
+
|
|
103
104
|
// relocate .hdbsynonymconfig files containing *.configure properties to cfg/ folder
|
|
104
105
|
// HDI's template mechanism for configuration files only works from the cfg/ folder
|
|
105
106
|
// For inplace builds (Java), restrict the scan to compileDest only to avoid moving user's
|
|
@@ -433,7 +434,8 @@ module.exports = class HanaBuildPlugin extends require('../internal') {
|
|
|
433
434
|
async _writeHdiConfig(compileHdiPlugins) {
|
|
434
435
|
const DEFAULT_HDI_PLUGINS = [FILE_EXT_CSV, FILE_EXT_HDBTABLEDATA, FILE_EXT_HDBTABLE, ".hdbview", ".hdbindex", ".hdbconstraint", ".hdbcalculationview"]
|
|
435
436
|
const undeployHdiPlugins = await this._readTypesFromUndeployJson() // see CAP issue #6222
|
|
436
|
-
const
|
|
437
|
+
const destHdiPlugins = await this._readTypesFromCompileDest()
|
|
438
|
+
const hdiPlugins = new Set([...DEFAULT_HDI_PLUGINS, ...undeployHdiPlugins, ...compileHdiPlugins, ...destHdiPlugins])
|
|
437
439
|
let hdiConfigPath
|
|
438
440
|
|
|
439
441
|
// do not create the .hdiconfig file in 'gen/db' root folder for now
|
|
@@ -543,6 +545,21 @@ module.exports = class HanaBuildPlugin extends require('../internal') {
|
|
|
543
545
|
return hdiPlugins
|
|
544
546
|
}
|
|
545
547
|
|
|
548
|
+
async _readTypesFromCompileDest() {
|
|
549
|
+
const hdiPlugins = new Set()
|
|
550
|
+
const dir = path.join(this.task.dest, 'src')
|
|
551
|
+
if (!exists(dir)) return hdiPlugins
|
|
552
|
+
|
|
553
|
+
const template = await _readTemplateAsJson('.hdiconfig-all')
|
|
554
|
+
const knownSuffixes = new Set(Object.keys(template['file_suffixes']).map(key => '.' + key))
|
|
555
|
+
const files = await find(dir, { filter: (entry) => !isdir(entry) })
|
|
556
|
+
files.forEach(file => {
|
|
557
|
+
const suffix = path.extname(file)
|
|
558
|
+
if (knownSuffixes.has(suffix)) hdiPlugins.add(suffix)
|
|
559
|
+
})
|
|
560
|
+
return hdiPlugins
|
|
561
|
+
}
|
|
562
|
+
|
|
546
563
|
async _validateMigrationTableFiles() {
|
|
547
564
|
const dbSrcDir = path.join(this.task.src, "src")
|
|
548
565
|
const migrationTableFiles = await find(dbSrcDir, { filter: (res) => {
|
|
@@ -3,6 +3,7 @@ const { join, resolve, basename } = require('node:path')
|
|
|
3
3
|
const { execSync } = require('node:child_process')
|
|
4
4
|
const { fs, exists, isfile, isdir, path } = cds.utils
|
|
5
5
|
const { parseXml } = require('./xml')
|
|
6
|
+
const YAML = require('yaml')
|
|
6
7
|
const { REGEX_JAVA_VERSION, JAVA_LTS_VERSIONS } = require('./constants')
|
|
7
8
|
const TRACE = cds.debug('trace')
|
|
8
9
|
|
|
@@ -69,6 +70,7 @@ module.exports = new class ProjectReader {
|
|
|
69
70
|
readProject() {
|
|
70
71
|
if (!this.appName) this.#setPackageInfo()
|
|
71
72
|
const env = this.env4('production')
|
|
73
|
+
if (this.isJava) env.build.target = '.'
|
|
72
74
|
const { appVersion, appName, appId, appDescription, jdkVersion } = this
|
|
73
75
|
TRACE?.({ env })
|
|
74
76
|
|
|
@@ -249,8 +251,8 @@ module.exports._readSpringBootConfig = async function (roots = [cds.env.folders.
|
|
|
249
251
|
for (let r of rootDirs) {
|
|
250
252
|
const file = isfile(join(r, './src/main/resources/application.yaml'))
|
|
251
253
|
if (file) {
|
|
252
|
-
const
|
|
253
|
-
for (let yamlDoc of
|
|
254
|
+
const docs = YAML.parseAllDocuments(fs.readFileSync(file, 'utf-8'))
|
|
255
|
+
for (let yamlDoc of docs.map(d => d.toJS())) {
|
|
254
256
|
let cds = yamlDoc?.cds;
|
|
255
257
|
if (!cds) continue
|
|
256
258
|
cds = _normalizeSpringBootCfg(cds)
|
|
@@ -19,7 +19,7 @@ describe('{{serviceName}} OData APIs', () => {
|
|
|
19
19
|
it('serves <%name%>', async () => {
|
|
20
20
|
const { data } = await GET `<%&urlPath%> ${{ params: { $select: '<%&selectString%>' } }}`
|
|
21
21
|
expect(data.value).to.containSubset([
|
|
22
|
-
<%&elementsString%>,
|
|
22
|
+
// <%&elementsString%>,
|
|
23
23
|
])
|
|
24
24
|
})
|
|
25
25
|
<%={{ }}=%>{{/entities}}
|
|
@@ -27,7 +27,8 @@ describe('{{serviceName}} OData APIs', () => {
|
|
|
27
27
|
{{#actions}}{{=<% %>=}}
|
|
28
28
|
it('executes <%name%>', async () => {
|
|
29
29
|
const { data } = await POST `<%&urlPath%> ${
|
|
30
|
-
|
|
30
|
+
{}
|
|
31
|
+
// <%¶msString%>
|
|
31
32
|
}`
|
|
32
33
|
// TODO finish this test
|
|
33
34
|
// expect(data.value).to...
|
|
@@ -86,13 +86,17 @@ module.exports = class XsuaaTemplate extends require('../../plugin') {
|
|
|
86
86
|
if (addKyma || addMultitenancy && hasKyma) {
|
|
87
87
|
const overwrites = addMultitenancy ? [{ item: 'xsuaa.parameters.tenant-mode', withValue: 'shared' }] : []
|
|
88
88
|
await merge(__dirname, 'files/values.yaml.hbs').into('chart/values.yaml', { with: project, overwrites })
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
const parameters = {
|
|
90
|
+
xsappname: `${project.appName}-{{ .Release.Namespace }}`
|
|
91
|
+
}
|
|
92
|
+
if (!project.hasCustomRoleCollections && xsSecurity['role-templates'].length) {
|
|
93
|
+
parameters['role-collections'] = xsSecurity['role-templates'].map(role => ({
|
|
94
|
+
name: `${role.name} (${project.appName} {{ .Release.Namespace }})`,
|
|
95
|
+
description: 'generated',
|
|
96
|
+
'role-template-references': [`$XSAPPNAME.${role.name}`],
|
|
97
|
+
}))
|
|
98
|
+
}
|
|
99
|
+
await merge({ xsuaa: { parameters } }).into('chart/values.yaml')
|
|
96
100
|
await KymaTemplate.mergeDependency('service-instance', 'xsuaa')
|
|
97
101
|
|
|
98
102
|
}
|
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
- The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
5
5
|
- This project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## Version 10.0.4 - 2026-07-21
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Default language fallbacks for incomplete `i18n` bundles in Java projects
|
|
12
|
+
- `srv.on/before('READ',...)` handlers registered with a cds-typer singular entity proxy were erroneously rewritten to event `each`
|
|
13
|
+
- Asynchronous plugins (exporting a Promise) were not awaited in ESM projects
|
|
14
|
+
- Fixed context propagation for local app and remote service calls
|
|
15
|
+
|
|
7
16
|
## Version 10.0.3 - 2026-07-02
|
|
8
17
|
|
|
9
18
|
### Fixed
|
|
@@ -36,9 +36,11 @@ exports.activate = async function (plugins = cds.env?.plugins || exports.fetch()
|
|
|
36
36
|
}
|
|
37
37
|
await Promise.all (all.map (([n,c]) => n in prioritized && _load(n,c)))
|
|
38
38
|
await Promise.all (all.map (([n,c]) => n in prioritized || _load(n,c)))
|
|
39
|
-
function _load (plugin, conf) {
|
|
39
|
+
async function _load (plugin, conf) {
|
|
40
40
|
DEBUG?.log(`[cds.plugins] - loading ${plugin}:`, { impl: local(conf.impl) })
|
|
41
|
-
|
|
41
|
+
const module = await cds.utils._import (conf.impl)
|
|
42
|
+
if (module?.default) await module.default
|
|
43
|
+
return module
|
|
42
44
|
}
|
|
43
45
|
DEBUG?.timeEnd ('[cds.plugins] - loaded plugins in')
|
|
44
46
|
return plugins
|
|
@@ -48,7 +48,7 @@ class EventHandlers {
|
|
|
48
48
|
return srv
|
|
49
49
|
}
|
|
50
50
|
else if (typeof path === 'object') {
|
|
51
|
-
if (path.is_singular && event === 'READ') event = 'each' //> srv.after ('READ', Book, ...) w/ Book is a singular def from cds-typer
|
|
51
|
+
if (phase === 'after' && path.is_singular && event === 'READ') event = 'each' //> srv.after ('READ', Book, ...) w/ Book is a singular def from cds-typer
|
|
52
52
|
path = path.name || cds.error.expected `${{path}} to be a string or an entity's CSN definition`
|
|
53
53
|
}
|
|
54
54
|
else if (typeof path === 'string') {
|
|
@@ -66,7 +66,7 @@ class ApplicationService extends cds.Service {
|
|
|
66
66
|
// we need to provide target explicitly because it's cached within ensure_target
|
|
67
67
|
const target = cds.infer.target(query, this)
|
|
68
68
|
const _req = new cds.Request({ query, target, _resolved: true })
|
|
69
|
-
return this.
|
|
69
|
+
return this.dispatch(_req).then(result => postProcess(_req, result, this))
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// async
|
|
@@ -317,7 +317,7 @@ class RemoteService extends cds.Service {
|
|
|
317
317
|
// we need to provide target explicitly because it's cached within ensure_target
|
|
318
318
|
const target = cds.infer.target(query, this)
|
|
319
319
|
const _req = new cds.Request({ query, target, _resolved: true, headers: req.headers, method: req.method })
|
|
320
|
-
return this.
|
|
320
|
+
return this.dispatch(_req).then(result => postProcess(_req, result, this, true))
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
// we need to post process if alias was explicitly set in query
|
|
@@ -15,6 +15,18 @@ might use a deprecated flag only for a limited period of time.
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
## Version 7.0.3 - 2026-07-21
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
- **compiler:** When a backlink target is at least distantly related to the entity
|
|
23
|
+
embedding an association with a backlink comparison, the compiler issues a
|
|
24
|
+
warning ref-deprecated-backlink instead of reporting an error ref-invalid-backlink;
|
|
25
|
+
this is now also the case if the target entity is auto-exposed.
|
|
26
|
+
- **sql:** Avoid dump in to.sql.migration with complex models.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
18
30
|
## Version 7.0.2 - 2026-07-14
|
|
19
31
|
|
|
20
32
|
### Bug Fixes
|
|
@@ -1094,6 +1094,7 @@ function populate( model ) {
|
|
|
1094
1094
|
elem._main?._ancestors?.includes( target )) {
|
|
1095
1095
|
// source and target of the model association are the same entity, and
|
|
1096
1096
|
// the current main artifact is a suitable auto-redirection target → return it
|
|
1097
|
+
// TODO: check with auto-exposed entities (which do not have _ancestors)
|
|
1097
1098
|
return elem._main;
|
|
1098
1099
|
}
|
|
1099
1100
|
const elemScope = preferredElemScope( target, service, elem, assoc._main || assoc );
|
|
@@ -1240,7 +1240,7 @@ function resolve( model ) {
|
|
|
1240
1240
|
if (chain) // standard correct case
|
|
1241
1241
|
return;
|
|
1242
1242
|
|
|
1243
|
-
if (target._ancestors
|
|
1243
|
+
if (target._ancestors || target.$inferred === 'autoexposed') {
|
|
1244
1244
|
// with non-cyclic projection ancestors, not only for managed assoc, but also
|
|
1245
1245
|
// unmanaged, see test3/Associations/Backlinks/CrossEyedBacklink.sql-err.cds
|
|
1246
1246
|
// Current entity is no valid redirection target for the backlink association
|
|
@@ -920,12 +920,10 @@ const _dependents = Symbol('_dependents');
|
|
|
920
920
|
* _dependencies: All artifacts this artifact depends on (because it has a ref to it)
|
|
921
921
|
*
|
|
922
922
|
* @param {CSN.Model} csn A CSN to enrich in-place
|
|
923
|
-
* @param {object} refs csnRefs, only used for artifactRef
|
|
924
923
|
* @returns {object} CSN with _dependents/_dependencies set, "cleanup" function, _dependents/_dependencies Symbol used
|
|
925
924
|
*/
|
|
926
|
-
function setDependencies( csn
|
|
925
|
+
function setDependencies( csn ) {
|
|
927
926
|
const cleanup = [];
|
|
928
|
-
const { artifactRef } = refs;
|
|
929
927
|
|
|
930
928
|
forEachDefinition(csn, (artifact, artifactName) => {
|
|
931
929
|
const queries = getNormalizedQuery(artifact).query;
|
|
@@ -933,11 +931,18 @@ function setDependencies( csn, refs = csnRefs(csn) ) {
|
|
|
933
931
|
initDependencies(artifact);
|
|
934
932
|
forAllQueries(queries, (query) => {
|
|
935
933
|
if (query.SELECT?.from) {
|
|
936
|
-
if (query.SELECT.from.args)
|
|
934
|
+
if (query.SELECT.from.args) {
|
|
937
935
|
handleArgs(artifact, artifactName, query.SELECT.from.args);
|
|
938
|
-
|
|
939
|
-
else if (typeof query.SELECT.from === 'string'
|
|
940
|
-
handleDependency(
|
|
936
|
+
}
|
|
937
|
+
else if (typeof query.SELECT.from === 'string') {
|
|
938
|
+
handleDependency(csn.definitions[query.SELECT.from], artifact, artifactName);
|
|
939
|
+
}
|
|
940
|
+
else if (query.SELECT.from.ref) {
|
|
941
|
+
if (query.SELECT.from.ref[0].id)
|
|
942
|
+
handleDependency(csn.definitions[query.SELECT.from.ref[0].id], artifact, artifactName);
|
|
943
|
+
else
|
|
944
|
+
handleDependency(csn.definitions[query.SELECT.from.ref[0]], artifact, artifactName);
|
|
945
|
+
}
|
|
941
946
|
}
|
|
942
947
|
}, [ 'definitions', artifactName, (artifact.projection ? 'projection' : 'query') ]);
|
|
943
948
|
}
|
|
@@ -952,7 +957,7 @@ function setDependencies( csn, refs = csnRefs(csn) ) {
|
|
|
952
957
|
if (arg.args)
|
|
953
958
|
handleArgs(artifact, artifactName, arg.args);
|
|
954
959
|
else if (arg.ref)
|
|
955
|
-
handleDependency(
|
|
960
|
+
handleDependency(csn.definitions[arg.ref[0].id ? arg.ref[0].id : arg.ref[0]], artifact, artifactName);
|
|
956
961
|
}
|
|
957
962
|
}
|
|
958
963
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# media-typer
|
|
2
2
|
|
|
3
|
-
[![NPM Version][npm-
|
|
4
|
-
[![NPM Downloads][
|
|
3
|
+
[![NPM Version][npm-image]][npm-url]
|
|
4
|
+
[![NPM Downloads][downloads-image]][downloads-url]
|
|
5
5
|
[![Node.js Version][node-version-image]][node-version-url]
|
|
6
|
-
[![Build Status][
|
|
6
|
+
[![Build Status][ci-image]][ci-url]
|
|
7
7
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
8
8
|
|
|
9
9
|
Simple RFC 6838 media type parser.
|
|
10
10
|
|
|
11
|
-
This module will parse a given media type into
|
|
11
|
+
This module will parse a given media type into its component parts, like type,
|
|
12
12
|
subtype, and suffix. A formatter is also provided to put them back together and
|
|
13
13
|
the two can be combined to normalize media types into a canonical form.
|
|
14
14
|
|
|
15
|
-
If you are looking to parse the string that represents a media type and
|
|
15
|
+
If you are looking to parse the string that represents a media type and its
|
|
16
16
|
parameters in HTTP (for example, the `Content-Type` header), use the
|
|
17
17
|
[content-type module](https://www.npmjs.com/package/content-type).
|
|
18
18
|
|
|
@@ -75,19 +75,20 @@ If any of the given object values are invalid, then a `TypeError` is thrown.
|
|
|
75
75
|
var valid = typer.test('image/svg+xml')
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Validate a media type string. This will return `true`
|
|
78
|
+
Validate a media type string. This will return `true` if the string is a well-
|
|
79
79
|
formatted media type, or `false` otherwise.
|
|
80
80
|
|
|
81
81
|
## License
|
|
82
82
|
|
|
83
83
|
[MIT](LICENSE)
|
|
84
84
|
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[node-version-url]: https://nodejs.org/en/download
|
|
89
|
-
[npm-downloads-image]: https://badgen.net/npm/dm/media-typer
|
|
85
|
+
[ci-image]: https://img.shields.io/github/workflow/status/jshttp/media-typer/ci/master?label=ci
|
|
86
|
+
[ci-url]: https://github.com/jshttp/media-typer/actions/workflows/ci.yml
|
|
87
|
+
[npm-image]: https://img.shields.io/npm/v/media-typer.svg
|
|
90
88
|
[npm-url]: https://npmjs.org/package/media-typer
|
|
91
|
-
[
|
|
92
|
-
[
|
|
93
|
-
[
|
|
89
|
+
[node-version-image]: https://img.shields.io/node/v/media-typer.svg
|
|
90
|
+
[node-version-url]: https://nodejs.org/en/
|
|
91
|
+
[coveralls-image]: https://img.shields.io/coveralls/jshttp/media-typer/master.svg
|
|
92
|
+
[coveralls-url]: https://coveralls.io/r/jshttp/media-typer?branch=master
|
|
93
|
+
[downloads-image]: https://img.shields.io/npm/dm/media-typer.svg
|
|
94
|
+
[downloads-url]: https://npmjs.org/package/media-typer
|
|
@@ -83,10 +83,6 @@ function format (obj) {
|
|
|
83
83
|
*/
|
|
84
84
|
|
|
85
85
|
function test (string) {
|
|
86
|
-
if (!string) {
|
|
87
|
-
throw new TypeError('argument string is required')
|
|
88
|
-
}
|
|
89
|
-
|
|
90
86
|
if (typeof string !== 'string') {
|
|
91
87
|
throw new TypeError('argument string is required to be a string')
|
|
92
88
|
}
|
|
@@ -103,10 +99,6 @@ function test (string) {
|
|
|
103
99
|
*/
|
|
104
100
|
|
|
105
101
|
function parse (string) {
|
|
106
|
-
if (!string) {
|
|
107
|
-
throw new TypeError('argument string is required')
|
|
108
|
-
}
|
|
109
|
-
|
|
110
102
|
if (typeof string !== 'string') {
|
|
111
103
|
throw new TypeError('argument string is required to be a string')
|
|
112
104
|
}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "media-typer",
|
|
3
3
|
"description": "Simple RFC 6838 media type parser and formatter",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "jshttp/media-typer",
|
|
8
|
+
"funding": {
|
|
9
|
+
"type": "opencollective",
|
|
10
|
+
"url": "https://opencollective.com/express"
|
|
11
|
+
},
|
|
8
12
|
"devDependencies": {
|
|
9
|
-
"eslint": "
|
|
10
|
-
"eslint-config-standard": "
|
|
11
|
-
"eslint-plugin-import": "2.
|
|
12
|
-
"eslint-plugin-markdown": "1.0.
|
|
13
|
-
"eslint-plugin-node": "
|
|
14
|
-
"eslint-plugin-promise": "4.
|
|
15
|
-
"eslint-plugin-standard": "4.
|
|
16
|
-
"mocha": "
|
|
17
|
-
"nyc": "
|
|
13
|
+
"eslint": "7.23.0",
|
|
14
|
+
"eslint-config-standard": "14.1.1",
|
|
15
|
+
"eslint-plugin-import": "2.22.1",
|
|
16
|
+
"eslint-plugin-markdown": "1.0.2",
|
|
17
|
+
"eslint-plugin-node": "11.1.0",
|
|
18
|
+
"eslint-plugin-promise": "4.3.1",
|
|
19
|
+
"eslint-plugin-standard": "4.1.0",
|
|
20
|
+
"mocha": "9.2.0",
|
|
21
|
+
"nyc": "15.1.0"
|
|
18
22
|
},
|
|
19
23
|
"files": [
|
|
20
24
|
"LICENSE",
|
|
@@ -27,7 +31,7 @@
|
|
|
27
31
|
"scripts": {
|
|
28
32
|
"lint": "eslint --plugin markdown --ext js,md .",
|
|
29
33
|
"test": "mocha --reporter spec --check-leaks --bail test/",
|
|
30
|
-
"test-
|
|
31
|
-
"test-
|
|
34
|
+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
|
35
|
+
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
|
32
36
|
}
|
|
33
37
|
}
|
package/package.json
CHANGED