Meta-model based data structures for those who need it
Installations
npm install moddle
Developer Guide
Typescript
No
Module System
ESM
Node Version
20.18.1
NPM Version
10.8.2
Score
92.4
Supply Chain
99.6
Quality
92.6
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
JavaScript (100%)
Developer
bpmn-io
Download Statistics
Total Downloads
12,253,394
Last Day
13,881
Last Week
85,336
Last Month
400,409
Last Year
4,188,830
GitHub Statistics
92 Stars
206 Commits
33 Forks
17 Watching
7 Branches
15 Contributors
Package Meta Information
Latest Version
7.2.0
Package Id
moddle@7.2.0
Unpacked Size
279.27 kB
Size
48.95 kB
File Count
13
NPM Version
10.8.2
Node Version
20.18.1
Publised On
20 Dec 2024
Total Downloads
Cumulative downloads
Total Downloads
12,253,394
Last day
-19%
13,881
Compared to previous day
Last week
-6%
85,336
Compared to previous week
Last month
2.7%
400,409
Compared to previous month
Last year
44.9%
4,188,830
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
moddle
A utility library for working with meta-model based data structures.
What is it good for?
moddle offers you a concise way to define meta models in JavaScript. You can use these models to consume documents, create model elements, and perform model validation.
Define a schema
You start by creating a moddle schema. It is a JSON file which describes types, their properties, and relationships:
1{ 2 "$schema": "https://unpkg.com/moddle/resources/schema/moddle.json", 3 "name": "Cars", 4 "uri": "http://cars", 5 "prefix": "c", 6 "types": [ 7 { 8 "name": "Base", 9 "properties": [ 10 { "name": "id", "type": "String", "isAttr": true } 11 ] 12 }, 13 { 14 "name": "Root", 15 "superClass": [ "Base" ], 16 "properties": [ 17 { "name": "cars", "type": "Car", "isMany": true } 18 ] 19 }, 20 { 21 "name": "Car", 22 "superClass": [ "Base" ], 23 "properties": [ 24 { "name": "name", "type": "String", "isAttr": true, "default": "No Name" }, 25 { "name": "power", "type": "Integer", "isAttr": true }, 26 { "name": "similar", "type": "Car", "isMany": true, "isReference": true }, 27 { "name": "trunk", "type": "Element", "isMany": true } 28 ] 29 } 30 ] 31}
You may attach the provided JSON schema to get your moddle descriptor validated by code editor.
Instantiate moddle
You can instantiate a moddle instance with a set of defined schemas:
1import { Moddle } from 'moddle'; 2 3var cars = new Moddle([ carsJSON ]);
Create objects
Use a moddle instance to create objects of your defined types:
1var taiga = cars.create('c:Car', { name: 'Taiga' }); 2 3console.log(taiga); 4// { $type: 'c:Car', name: 'Taiga' }; 5 6 7var cheapCar = cars.create('c:Car'); 8 9console.log(cheapCar.name); 10// "No Name" 11 12 13// really? 14cheapCar.get('similar').push(taiga);
Introspect things
Then again, given the knowledge moddle has, you can perform deep introspection:
1var carDescriptor = cheapCar.$descriptor; 2 3console.log(carDescriptor.properties); 4// [ { name: 'id', type: 'String', ... }, { name: 'name', type: 'String', ...} ... ]
Access extensions
moddle is friendly towards extensions and keeps unknown any properties around:
1taiga.set('specialProperty', 'not known to moddle'); 2 3console.log(taiga.get('specialProperty')); 4// 'not known to moddle'
It also allows you to create any elements for namespaces that you did not explicitly define:
1var screwdriver = cars.createAny('tools:Screwdriver', 'http://tools', { 2 make: 'ScrewIt!' 3}); 4 5car.trunk.push(screwdriver);
There is more
Have a look at our test coverage to learn about everything that is currently supported.
Resources
Related
- moddle-xml: read xml documents based on moddle descriptors
License
MIT
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/bpmn-io/.github/SECURITY.md:1
- Info: Found linked content: github.com/bpmn-io/.github/SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/bpmn-io/.github/SECURITY.md:1
- Info: Found text in security policy: github.com/bpmn-io/.github/SECURITY.md:1
Reason
SAST tool detected but not run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Warn: 0 commits out of 25 are checked with a SAST tool
Reason
Found 7/13 approved changesets -- score normalized to 5
Reason
6 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 5
Reason
8 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-7q7g-4xm8-89cq
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
Reason
dependency not pinned by hash detected -- score normalized to 1
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CI.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/bpmn-io/moddle/CI.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CI.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/bpmn-io/moddle/CI.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CODE_SCANNING.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/bpmn-io/moddle/CODE_SCANNING.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CODE_SCANNING.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/bpmn-io/moddle/CODE_SCANNING.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CODE_SCANNING.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/bpmn-io/moddle/CODE_SCANNING.yml/main?enable=pin
- Info: 0 out of 5 GitHub-owned GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/CI.yml:1
- Warn: no topLevel permission defined: .github/workflows/CODE_SCANNING.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Score
4.8
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More