Comparing version 3.0.9-pre to 3.0.9
{ | ||
"name": "cqrs", | ||
"version": "3.0.9-pre", | ||
"description": "cqrs for javascript", | ||
"main": "dist/lib/index.js", | ||
"types": "dist/lib/index.d.ts", | ||
"scripts": { | ||
"test": "tsc && mocha --require source-map-support/register dist/test && node example/main.js ", | ||
"test2": "tsc && mocha --require source-map-support/register dist/test/test.clusterSystem", | ||
"build": "tsc" | ||
"version": "3.0.9", | ||
"peerDependencies": { | ||
"@angular/common": "^15.0.0", | ||
"@angular/core": "^15.0.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/liangzeng/cqrs" | ||
}, | ||
"keywords": [ | ||
"ddd", | ||
"cqrs", | ||
"domain", | ||
"distributed" | ||
], | ||
"author": "Liang Zeng", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/liangzeng/cqrs/issues" | ||
}, | ||
"homepage": "https://github.com/liangzeng/cqrs", | ||
"dependencies": { | ||
"@types/socket.io": "^1.4.29", | ||
"@types/socket.io-client": "^1.4.29", | ||
"debug": "^2.6.8", | ||
"nedb-promise": "^2.0.1", | ||
"protobufjs": "^6.7.3", | ||
"socket.io": "^2.0.3", | ||
"socket.io-client": "^2.0.3", | ||
"uuid": "^3.0.1" | ||
"pouchdb": "^8.0.1", | ||
"pouchdb-find": "^8.0.1", | ||
"tslib": "^2.3.0", | ||
"uuid": "^9.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^2.2.41", | ||
"browserify": "^14.4.0", | ||
"mocha": "^2.5.3", | ||
"should": "^4.3.0", | ||
"source-map-support": "^0.4.15", | ||
"typescript": "^2.3.4" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
"@types/node": "^18.14.0", | ||
"@types/pouchdb": "^6.4.0", | ||
"@types/pouchdb-find": "^7.3.0", | ||
"@types/uuid": "^9.0.0", | ||
"typescript": "^4.9.5" | ||
} | ||
} |
198
README.md
@@ -1,196 +0,24 @@ | ||
CQRS | ||
==== | ||
DDD-CQRS-Actor framework. | ||
### Document [ [chinese](https://github.com/liangzeng/cqrs/wiki) ] | ||
# Cqrs | ||
Version | ||
======= | ||
cqrs@2.0.6-pre | ||
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 15.0.0. | ||
Install | ||
======= | ||
## Code scaffolding | ||
npm install cqrs@2.0.6-pre --save | ||
Run `ng generate component component-name --project cqrs` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project cqrs`. | ||
> Note: Don't forget to add `--project cqrs` or else it will be added to the default project in your `angular.json` file. | ||
Consumers | ||
========= | ||
+ [Node.js Forum](https://github.com/liangzeng/forum) | ||
## Build | ||
EventStore | ||
========== | ||
+ [mongodb eventstore](https://github.com/liangzeng/cqrs-mongo-eventstore) | ||
```js | ||
const {Domain} = require("cqrs"); | ||
const MongoStore = require("cqrs-mongo-eventstore").default; | ||
const eventstore = new MongoStore("localhost/test"); | ||
const domain = new Domain({eventstore}); | ||
``` | ||
Run `ng build cqrs` to build the project. The build artifacts will be stored in the `dist/` directory. | ||
Roadmap | ||
======= | ||
+ preview core | ||
+ use typescript rewrite core | ||
+ saga rollback | ||
+ join the distributed system | ||
+ Actor version support | ||
+ ~~use protobuf message~~ | ||
+ ~~actor GC~~ | ||
+ ~~system time travel~~ | ||
+ ~~DCI support~~ | ||
## Publishing | ||
After building your library with `ng build cqrs`, go to the dist folder `cd dist/cqrs` and run `npm publish`. | ||
Step | ||
==== | ||
## Running unit tests | ||
#### create Actor class | ||
Run `ng test cqrs` to execute the unit tests via [Karma](https://karma-runner.github.io). | ||
```js | ||
const { Actor } = require("cqrs"); | ||
class User extends Actor { /* see example */ } | ||
class Transfer extends Actor { /* see example */ } | ||
``` | ||
#### register Actor class to domain | ||
## Further help | ||
```js | ||
const { domain } = require("cqrs"); // get default domain. | ||
domain.register(User).register(Transfer); | ||
``` | ||
#### create/get an Actor instance | ||
```js | ||
// only javascript object | ||
const user = await domain.create("User", {name:"Leo"}); | ||
user.json; // get actor instance data. | ||
user.deduct(120.00); // call instance method. | ||
const userInstance = await domain.get("User",userId); // get a User instance. | ||
``` | ||
Preview Example | ||
=============== | ||
see ES6 [Example](https://github.com/liangzeng/cqrs/tree/master/example) | ||
#### User.js | ||
```js | ||
const { Actor } = require("cqrs"); | ||
module.exports = class User extends Actor { | ||
constructor(data) { | ||
super({ money: data.money || 0, name: data.name }); | ||
} | ||
changename(name) { | ||
this.$(name); | ||
} | ||
deduct(money) { | ||
this.$("deduct", money); | ||
} | ||
add(money) { | ||
this.service.apply("add", money); | ||
} | ||
when(event) { | ||
const data = this.json; | ||
switch (event.type) { | ||
case "changename": | ||
return { name: event.name } | ||
case "deduct": | ||
return { money: data.money - event.data } | ||
case "add": | ||
return { money: data.money + event.data } | ||
} | ||
} | ||
} | ||
``` | ||
#### Transfer.js | ||
```js | ||
const { Actor } = require("cqrs"); | ||
module.exports = class Transfer extends Actor { | ||
constructor(data) { | ||
super({ finish: false }); | ||
} | ||
log(event) { | ||
console.log(event); | ||
} | ||
async transfe(fromUserId, toUserId, money) { | ||
const $ = this.$; | ||
$.lock(); | ||
$.once({ actorType: "User", type: "add" }, "log"); | ||
const fromUser = await $.get("User", fromUserId); | ||
const toUser = await $.get("User", toUserId); | ||
fromUser.deduct(money); | ||
toUser.add(money); | ||
$.unlock(); | ||
$("finish", null); | ||
} | ||
when(event) { | ||
switch (event.type) { | ||
case "finish": | ||
return { finish: true } | ||
} | ||
} | ||
} | ||
``` | ||
#### main.js | ||
```js | ||
const { domain, Actor } = require("cqrs"); | ||
const User = require("./User"); | ||
const Transfer = require("./Transfer"); | ||
domain.register(User).register(Transfer); | ||
async function main() { | ||
let fromUser = await domain.create("User", { name: "fromUser" }); | ||
fromUser.add(100); | ||
let toUser = await domain.create("User", { name: "toUser" }); | ||
const transfer = await domain.create("Transfer", {}); | ||
await transfer.transfe(fromUser.id, toUser.id, 15); | ||
fromUser = await domain.get("User", fromUser.id); | ||
toUser = await domain.get("User", toUser.id); | ||
console.log("fromUser's money is " , fromUser.json.money); | ||
console.log("toUser's money is " , toUser.json.money); | ||
} | ||
main(); | ||
``` | ||
#### out | ||
``` | ||
fromUser's money is 85 | ||
toUser's money is 15 | ||
Event { | ||
data: 100, | ||
type: 'add', | ||
method: 'add', | ||
sagaId: undefined, | ||
index: 0, | ||
id: '6459e760-558e-11e7-87a3-9b10ea692d1e', | ||
actorId: '645887d0-558e-11e7-87a3-9b10ea692d1e', | ||
actorType: 'User', | ||
actorVersion: '1.0', | ||
date: 2017-06-20T07:59:31.542Z } | ||
``` | ||
LICENSE | ||
======= | ||
GPL2.0 | ||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
6
5
1
100
1
37792
57
1082
2
25
1
1
+ Addedpouchdb@^8.0.1
+ Addedpouchdb-find@^8.0.1
+ Addedtslib@^2.3.0
+ Added@angular/common@15.2.10(transitive)
+ Added@angular/core@15.2.10(transitive)
+ Addedabort-controller@3.0.0(transitive)
+ Addedabstract-leveldown@6.2.3(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedclone-buffer@1.0.0(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddeferred-leveldown@5.3.0(transitive)
+ Addeddouble-ended-queue@2.1.0-0(transitive)
+ Addedencoding-down@6.3.0(transitive)
+ Addedend-stream@0.1.0(transitive)
+ Addederrno@0.1.8(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedfetch-cookie@0.11.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedimmediate@3.3.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedlevel@6.0.1(transitive)
+ Addedlevel-codec@9.0.2(transitive)
+ Addedlevel-concat-iterator@2.0.1(transitive)
+ Addedlevel-errors@2.0.1(transitive)
+ Addedlevel-iterator-stream@4.0.2(transitive)
+ Addedlevel-js@5.0.2(transitive)
+ Addedlevel-packager@5.1.1(transitive)
+ Addedlevel-supports@1.0.1(transitive)
+ Addedlevel-write-stream@1.0.0(transitive)
+ Addedleveldown@5.6.0(transitive)
+ Addedlevelup@4.4.0(transitive)
+ Addedltgt@2.2.1(transitive)
+ Addednapi-macros@2.0.0(transitive)
+ Addednode-fetch@2.6.7(transitive)
+ Addednode-gyp-build@4.1.1(transitive)
+ Addedpouchdb@8.0.1(transitive)
+ Addedpouchdb-abstract-mapreduce@8.0.1(transitive)
+ Addedpouchdb-binary-utils@8.0.1(transitive)
+ Addedpouchdb-collate@8.0.1(transitive)
+ Addedpouchdb-collections@8.0.1(transitive)
+ Addedpouchdb-errors@8.0.1(transitive)
+ Addedpouchdb-fetch@8.0.1(transitive)
+ Addedpouchdb-find@8.0.1(transitive)
+ Addedpouchdb-mapreduce-utils@8.0.1(transitive)
+ Addedpouchdb-md5@8.0.1(transitive)
+ Addedpouchdb-selector-core@8.0.1(transitive)
+ Addedpouchdb-utils@8.0.1(transitive)
+ Addedprr@1.0.1(transitive)
+ Addedpsl@1.9.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedquerystringify@2.2.0(transitive)
+ Addedreadable-stream@0.0.41.1.143.6.2(transitive)
+ Addedrequires-port@1.0.0(transitive)
+ Addedrxjs@7.8.1(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedspark-md5@3.0.2(transitive)
+ Addedstring_decoder@0.10.311.3.0(transitive)
+ Addedthrough2@3.0.2(transitive)
+ Addedtough-cookie@4.1.4(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedtslib@2.7.0(transitive)
+ Addeduniversalify@0.2.0(transitive)
+ Addedurl-parse@1.5.10(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addeduuid@8.3.29.0.1(transitive)
+ Addedvuvuzela@1.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
+ Addedwrite-stream@0.4.3(transitive)
+ Addedxtend@4.0.2(transitive)
+ Addedzone.js@0.13.3(transitive)
- Removed@types/socket.io@^1.4.29
- Removed@types/socket.io-client@^1.4.29
- Removeddebug@^2.6.8
- Removednedb-promise@^2.0.1
- Removedprotobufjs@^6.7.3
- Removedsocket.io@^2.0.3
- Removedsocket.io-client@^2.0.3
- Removed@protobufjs/aspromise@1.1.2(transitive)
- Removed@protobufjs/base64@1.1.2(transitive)
- Removed@protobufjs/codegen@2.0.4(transitive)
- Removed@protobufjs/eventemitter@1.1.0(transitive)
- Removed@protobufjs/fetch@1.1.0(transitive)
- Removed@protobufjs/float@1.0.2(transitive)
- Removed@protobufjs/inquire@1.1.0(transitive)
- Removed@protobufjs/path@1.1.2(transitive)
- Removed@protobufjs/pool@1.1.0(transitive)
- Removed@protobufjs/utf8@1.1.0(transitive)
- Removed@types/long@4.0.2(transitive)
- Removed@types/node@22.7.4(transitive)
- Removed@types/socket.io@1.4.42(transitive)
- Removed@types/socket.io-client@1.4.36(transitive)
- Removedaccepts@1.3.8(transitive)
- Removedafter@0.8.2(transitive)
- Removedany-promise@1.3.0(transitive)
- Removedarraybuffer.slice@0.0.7(transitive)
- Removedasync@0.2.10(transitive)
- Removedbacko2@1.0.2(transitive)
- Removedbase64-arraybuffer@0.1.4(transitive)
- Removedbase64id@2.0.0(transitive)
- Removedbinary-search-tree@0.2.5(transitive)
- Removedblob@0.0.5(transitive)
- Removedcomponent-bind@1.0.0(transitive)
- Removedcomponent-emitter@1.2.11.3.1(transitive)
- Removedcomponent-inherit@0.0.3(transitive)
- Removedcookie@0.4.2(transitive)
- Removeddebug@2.6.93.1.04.1.1(transitive)
- Removedengine.io@3.6.2(transitive)
- Removedengine.io-client@3.5.4(transitive)
- Removedengine.io-parser@2.2.1(transitive)
- Removedhas-binary2@1.0.3(transitive)
- Removedhas-cors@1.1.0(transitive)
- Removedimmediate@3.0.6(transitive)
- Removedindexof@0.0.1(transitive)
- Removedisarray@2.0.1(transitive)
- Removedlie@3.1.1(transitive)
- Removedlocalforage@1.10.0(transitive)
- Removedlong@4.0.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedms@2.0.02.1.3(transitive)
- Removednedb@1.8.0(transitive)
- Removednedb-promise@2.0.1(transitive)
- Removednegotiator@0.6.3(transitive)
- Removedparseqs@0.0.6(transitive)
- Removedparseuri@0.0.6(transitive)
- Removedprotobufjs@6.11.4(transitive)
- Removedsocket.io@2.5.1(transitive)
- Removedsocket.io-adapter@1.1.2(transitive)
- Removedsocket.io-client@2.5.0(transitive)
- Removedsocket.io-parser@3.3.43.4.3(transitive)
- Removedthenify@3.3.1(transitive)
- Removedto-array@0.1.4(transitive)
- Removedunderscore@1.4.4(transitive)
- Removedundici-types@6.19.8(transitive)
- Removeduuid@3.4.0(transitive)
- Removedws@7.5.10(transitive)
- Removedxmlhttprequest-ssl@1.6.3(transitive)
- Removedyeast@0.1.2(transitive)
Updateduuid@^9.0.0