grafio-mongo 1.1.0 → 1.2.0
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/CODE_OF_CONDUCT.md +127 -0
- package/CONTRIBUTING.md +125 -0
- package/dist/MongoStorageProvider.d.ts +2 -0
- package/dist/MongoStorageProvider.js +10 -0
- package/package.json +6 -5
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
|
8
|
+
level of experience, education, socio-economic status, nationality, personal
|
|
9
|
+
appearance, race, religion, or sexual identity and orientation.
|
|
10
|
+
|
|
11
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
12
|
+
diverse, inclusive, and healthy community.
|
|
13
|
+
|
|
14
|
+
## Our Standards
|
|
15
|
+
|
|
16
|
+
Examples of behavior that contributes to a positive environment for our
|
|
17
|
+
community include:
|
|
18
|
+
|
|
19
|
+
* Demonstrating empathy and kindness toward other people
|
|
20
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
21
|
+
* Giving and gracefully accepting constructive feedback
|
|
22
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
23
|
+
and learning from the experience
|
|
24
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
25
|
+
overall community
|
|
26
|
+
|
|
27
|
+
Examples of unacceptable behavior include:
|
|
28
|
+
|
|
29
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
30
|
+
advances of any kind
|
|
31
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
32
|
+
* Public or private harassment
|
|
33
|
+
* Publishing others' private information, such as a physical or email
|
|
34
|
+
address, without their explicit permission
|
|
35
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
36
|
+
professional setting
|
|
37
|
+
|
|
38
|
+
## Enforcement Responsibilities
|
|
39
|
+
|
|
40
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
41
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
42
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
43
|
+
or harmful.
|
|
44
|
+
|
|
45
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
46
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
47
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
48
|
+
decisions when appropriate.
|
|
49
|
+
|
|
50
|
+
## Scope
|
|
51
|
+
|
|
52
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
53
|
+
an individual is officially representing the community in public spaces.
|
|
54
|
+
Examples of representing our community include using an official e-mail
|
|
55
|
+
address, posting via an official social media account, or acting as an appointed
|
|
56
|
+
representative at an online or offline event.
|
|
57
|
+
|
|
58
|
+
## Enforcement
|
|
59
|
+
|
|
60
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
61
|
+
reported to the community leaders responsible for enforcement at
|
|
62
|
+
[INSERT CONTACT METHOD].
|
|
63
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
64
|
+
|
|
65
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
66
|
+
reporter of any incident.
|
|
67
|
+
|
|
68
|
+
## Enforcement Guidelines
|
|
69
|
+
|
|
70
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
71
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
72
|
+
|
|
73
|
+
### 1. Correction
|
|
74
|
+
|
|
75
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
76
|
+
unprofessional or unwelcome in the community.
|
|
77
|
+
|
|
78
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
79
|
+
clarity around the nature of the violation and an explanation of why the
|
|
80
|
+
behavior was inappropriate. A public apology may be requested.
|
|
81
|
+
|
|
82
|
+
### 2. Warning
|
|
83
|
+
|
|
84
|
+
**Community Impact**: A violation through a single incident or series
|
|
85
|
+
of actions.
|
|
86
|
+
|
|
87
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
88
|
+
interaction with the people involved, including unsolicited interaction with
|
|
89
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
90
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
91
|
+
like social media. Violating these terms may lead to a temporary or
|
|
92
|
+
permanent ban.
|
|
93
|
+
|
|
94
|
+
### 3. Temporary Ban
|
|
95
|
+
|
|
96
|
+
**Community Impact**: A serious violation of community standards, including
|
|
97
|
+
sustained inappropriate behavior.
|
|
98
|
+
|
|
99
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
100
|
+
communication with the community for a specified period of time. No public or
|
|
101
|
+
private interaction with the people involved, including unsolicited interaction
|
|
102
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
103
|
+
Violating these terms may lead to a permanent ban.
|
|
104
|
+
|
|
105
|
+
### 4. Permanent Ban
|
|
106
|
+
|
|
107
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
108
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
109
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
110
|
+
|
|
111
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
112
|
+
the community.
|
|
113
|
+
|
|
114
|
+
## Attribution
|
|
115
|
+
|
|
116
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
117
|
+
version 2.0, available at
|
|
118
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
119
|
+
|
|
120
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
121
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
|
122
|
+
|
|
123
|
+
[homepage]: https://www.contributor-covenant.org
|
|
124
|
+
|
|
125
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
126
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
|
127
|
+
https://www.contributor-covenant.org/translations.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Contributing to grafio-mongo
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to grafio-mongo! This document provides guidelines and instructions for contributing to the MongoDB storage backend for [grafio](https://github.com/witspry/grafio).
|
|
4
|
+
|
|
5
|
+
## Contributor License Agreement (CLA)
|
|
6
|
+
|
|
7
|
+
By submitting contributions to grafio, you grant **Satya Jugran** (the project owner) a perpetual, irrevocable, worldwide, non-exclusive, royalty-free license to use, reproduce, modify, distribute, and display your contributions for any purpose, including commercial use, under the terms of the GNU General Public License v3.0 (GPL-3.0).
|
|
8
|
+
|
|
9
|
+
As the copyright owner and project maintainer, I retain full commercial rights to all code in this repository. Contributors acknowledge that their contributions will be licensed under GPL-3.0 and agree that such licensing benefits the project while preserving my rights as the copyright holder.
|
|
10
|
+
|
|
11
|
+
This CLA ensures that contributions are submitted under GPL-3.0 licensing terms and grants me explicit rights to use contributed code in commercial projects without requiring additional approval from contributors.
|
|
12
|
+
|
|
13
|
+
## Getting Started
|
|
14
|
+
|
|
15
|
+
1. **Fork the repository** on GitHub
|
|
16
|
+
2. **Clone your fork** locally:
|
|
17
|
+
```bash
|
|
18
|
+
git clone https://github.com/satya-jugran/grafio-mongo.git
|
|
19
|
+
cd grafio-mongo
|
|
20
|
+
```
|
|
21
|
+
3. **Install dependencies**:
|
|
22
|
+
```bash
|
|
23
|
+
npm install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Development Workflow
|
|
27
|
+
|
|
28
|
+
### Prerequisites
|
|
29
|
+
|
|
30
|
+
- Node.js >= 18
|
|
31
|
+
- npm >= 9
|
|
32
|
+
|
|
33
|
+
### Building
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm run build
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Running Tests
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Run all tests
|
|
43
|
+
npm test
|
|
44
|
+
|
|
45
|
+
# Run tests in watch mode
|
|
46
|
+
npm run test:watch
|
|
47
|
+
|
|
48
|
+
# Run tests with coverage
|
|
49
|
+
npm run test:coverage
|
|
50
|
+
|
|
51
|
+
# Run performance benchmarks
|
|
52
|
+
npm run perf
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Code Style
|
|
56
|
+
|
|
57
|
+
- Use TypeScript for all new code
|
|
58
|
+
- Follow the existing code style (2-space indentation)
|
|
59
|
+
- Run `npm run build` before committing to ensure TypeScript compiles without errors
|
|
60
|
+
|
|
61
|
+
## Project Structure
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
grafio-mongo/
|
|
65
|
+
├── src/ # Source code
|
|
66
|
+
│ ├── index.ts # Main exports
|
|
67
|
+
│ ├── MongoGraphFactory.ts # Factory for creating Graph instances with MongoDB backend
|
|
68
|
+
│ └── MongoStorageProvider.ts # MongoDB storage provider implementing IStorageProvider
|
|
69
|
+
├── tests/ # Test files
|
|
70
|
+
│ ├── graph/ # Graph operation tests with MongoDB backend
|
|
71
|
+
│ ├── storage/ # Storage provider tests
|
|
72
|
+
│ ├── perf/ # Performance benchmarks
|
|
73
|
+
│ └── *.test.ts # Integration tests
|
|
74
|
+
├── CHANGELOG.md # Version history
|
|
75
|
+
└── CODE_OF_CONDUCT.md # Community guidelines
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Making Changes
|
|
79
|
+
|
|
80
|
+
1. **Create a branch** for your changes:
|
|
81
|
+
```bash
|
|
82
|
+
git checkout -b feature/your-feature-name
|
|
83
|
+
# or
|
|
84
|
+
git checkout -b fix/your-bug-fix
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
2. **Make your changes** following the code style guidelines
|
|
88
|
+
|
|
89
|
+
3. **Add tests** for new functionality (see [`tests/`](tests/))
|
|
90
|
+
|
|
91
|
+
4. **Ensure all tests pass**:
|
|
92
|
+
```bash
|
|
93
|
+
npm test
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
5. **Commit your changes** with a clear message:
|
|
97
|
+
```bash
|
|
98
|
+
git commit -m "feat: add new feature description"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Commit Message Format
|
|
102
|
+
|
|
103
|
+
Use conventional commit format:
|
|
104
|
+
- `feat:` for new features
|
|
105
|
+
- `fix:` for bug fixes
|
|
106
|
+
- `docs:` for documentation changes
|
|
107
|
+
- `test:` for test additions/changes
|
|
108
|
+
- `refactor:` for code refactoring
|
|
109
|
+
- `perf:` for performance improvements
|
|
110
|
+
|
|
111
|
+
## Pull Request Process
|
|
112
|
+
|
|
113
|
+
1. Update documentation if needed
|
|
114
|
+
2. Add tests for any new functionality
|
|
115
|
+
3. Ensure all tests pass
|
|
116
|
+
4. Update the [CHANGELOG.md](CHANGELOG.md) if applicable
|
|
117
|
+
5. Submit a pull request with a clear description of the changes
|
|
118
|
+
|
|
119
|
+
## Code of Conduct
|
|
120
|
+
|
|
121
|
+
Please read our [Code of Conduct](./CODE_OF_CONDUCT.md) before contributing to help keep our community welcoming and inclusive.
|
|
122
|
+
|
|
123
|
+
## Questions?
|
|
124
|
+
|
|
125
|
+
Feel free to open an issue on GitHub for questions about contributing.
|
|
@@ -22,7 +22,9 @@ export declare class MongoStorageProvider implements IStorageProvider {
|
|
|
22
22
|
getAllNodes(limit?: number, orderBy?: IOrderBy, transaction?: ITransactionHandle): Promise<NodeData[]>;
|
|
23
23
|
getNodesByType(type: string, transaction?: ITransactionHandle): Promise<NodeData[]>;
|
|
24
24
|
getNodesByProperty(key: string, value: unknown, nodeType?: string, transaction?: ITransactionHandle): Promise<NodeData[]>;
|
|
25
|
+
getTotalNodeCount(transaction?: ITransactionHandle): Promise<number>;
|
|
25
26
|
getEdgesByProperty(key: string, value: unknown, edgeType?: string, transaction?: ITransactionHandle): Promise<EdgeData[]>;
|
|
27
|
+
getTotalEdgeCount(transaction?: ITransactionHandle): Promise<number>;
|
|
26
28
|
insertEdge(edge: EdgeData, transaction?: ITransactionHandle): Promise<void>;
|
|
27
29
|
deleteEdge(id: string, transaction?: ITransactionHandle): Promise<void>;
|
|
28
30
|
hasEdge(id: string, transaction?: ITransactionHandle): Promise<boolean>;
|
|
@@ -29,6 +29,8 @@ class MongoStorageProvider {
|
|
|
29
29
|
await this._nodes.createIndex({ graphId: 1, type: 1 }, { name: 'node_graph_type' });
|
|
30
30
|
await this._edges.createIndex({ graphId: 1, id: 1 }, { unique: true, name: 'edge_graph_id_unique' });
|
|
31
31
|
await this._edges.createIndex({ graphId: 1, type: 1 }, { name: 'edge_graph_type' });
|
|
32
|
+
await this._edges.createIndex({ graphId: 1, sourceId: 1 }, { name: 'edge_graph_source' });
|
|
33
|
+
await this._edges.createIndex({ graphId: 1, targetId: 1 }, { name: 'edge_graph_target' });
|
|
32
34
|
await this._edges.createIndex({ graphId: 1, sourceId: 1, type: 1 }, { name: 'edge_graph_source_type' });
|
|
33
35
|
await this._edges.createIndex({ graphId: 1, targetId: 1, type: 1 }, { name: 'edge_graph_target_type' });
|
|
34
36
|
}
|
|
@@ -107,6 +109,10 @@ class MongoStorageProvider {
|
|
|
107
109
|
const docs = await this._nodes.find(filter, { session }).toArray();
|
|
108
110
|
return docs.map(d => this._docToNode(d));
|
|
109
111
|
}
|
|
112
|
+
async getTotalNodeCount(transaction) {
|
|
113
|
+
const session = transaction?.context;
|
|
114
|
+
return this._nodes.countDocuments({ graphId: this._graphId }, { session });
|
|
115
|
+
}
|
|
110
116
|
async getEdgesByProperty(key, value, edgeType, transaction) {
|
|
111
117
|
const session = transaction?.context;
|
|
112
118
|
const filter = {
|
|
@@ -119,6 +125,10 @@ class MongoStorageProvider {
|
|
|
119
125
|
const docs = await this._edges.find(filter, { session }).toArray();
|
|
120
126
|
return docs.map(d => this._docToEdge(d));
|
|
121
127
|
}
|
|
128
|
+
async getTotalEdgeCount(transaction) {
|
|
129
|
+
const session = transaction?.context;
|
|
130
|
+
return this._edges.countDocuments({ graphId: this._graphId }, { session });
|
|
131
|
+
}
|
|
122
132
|
async insertEdge(edge, transaction) {
|
|
123
133
|
const now = Date.now();
|
|
124
134
|
if (edge.createdOn === undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grafio-mongo",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "MongoDB storage backend for grafio",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"grafio": ">=6.
|
|
18
|
+
"grafio": ">=6.2.0",
|
|
19
19
|
"mongodb": ">=5.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/jest": "^29.5.0",
|
|
23
23
|
"@types/node": "^25.6.0",
|
|
24
|
-
"grafio": "^6.
|
|
24
|
+
"grafio": "^6.2.0",
|
|
25
25
|
"cross-env": "^10.1.0",
|
|
26
26
|
"jest": "^29.5.0",
|
|
27
27
|
"rimraf": "^5.0.0",
|
|
@@ -39,9 +39,10 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"author": "Satya Jugran",
|
|
42
|
-
"license": "
|
|
42
|
+
"license": "GPL-3.0",
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|
|
45
45
|
"url": "https://github.com/satya-jugran/grafio-mongo"
|
|
46
|
-
}
|
|
46
|
+
},
|
|
47
|
+
"funding": "https://ko-fi.com/satyajugran"
|
|
47
48
|
}
|