Skip to content

Commit

Permalink
Merge branch '1-0-0' into 'main'
Browse files Browse the repository at this point in the history
1-0-0

See merge request fluxlabs/flux-eco/aggregate-root!2
  • Loading branch information
mstuder committed Apr 9, 2022
2 parents a872691 + 7ab131e commit 656ba13
Show file tree
Hide file tree
Showing 52 changed files with 1,941 additions and 819 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## [1.0.0]
* added functional usage

## [0.0.2]
* added flux-publish-utils

Expand Down
126 changes: 126 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,132 @@ The storage can be replaced by the implementation of a further adapter.
The usage is demonstrated by the following example application:
https://github.com/flux-caps/todo-app

## Usage
.env
```
AGGREGATE_ROOT_SCHEMA_DIRECTORY=schemas/domain
AGGREGATE_ROOT_STORAGE_CONFIG_ENV_PREFIX=EVENTS_
AGGREGATE_ROOT_EVENT_SCHEMA_FILE_PATH=../schemas/AggregateRootEvent.yaml
EVENTS_STORAGE_HOST=localhost
EVENTS_STORAGE_DRIVER=Pdo_Mysql
EVENTS_STORAGE_NAME=events
EVENTS_STORAGE_USER=user
EVENTS_STORAGE_PASSWORD=password
PROJECTION_APP_SCHEMA_DIRECTORY=../vendor/flux-eco/projection/schemas
PROJECTION_ECO_SCHEMA_DIRECTORY=schemas/projections
PROJECTION_STORAGE_CONFIG_ENV_PREFIX=PROJECTION_
PROJECTION_STORAGE_NAME=projection
PROJECTION_STORAGE_HOST=localhost
PROJECTION_STORAGE_DRIVER=Pdo_Mysql
PROJECTION_STORAGE_USER=user
PROJECTION_STORAGE_PASSWORD=password
STREAM_STORAGE_CONFIG_ENV_PREFIX=STREAM_
STREAM_STORAGE_NAME=stream
STREAM_STORAGE_HOST=localhost
STREAM_STORAGE_DRIVER=Pdo_Mysql
STREAM_STORAGE_USER=user
STREAM_STORAGE_PASSWORD=password
STREAM_TABLE_NAME=stream
STREAM_STATE_SCHEMA_FILE=../vendor/flux-eco/global-stream/schemas/State.yaml
```

schemas\domain\account.yaml
```
name: account
type: object
properties:
aggregateId:
type: string
readOnly: true
correlationId:
type: string
readOnly: true
aggregateName:
type: string
const: todo
readOnly: true
sequence:
type: integer
readOnly: true
createdDateTime:
type: string
format: date-time
readOnly: true
createdBy:
type: string
format: email
readOnly: true
changedDateTime:
type: string
format: date-time
readOnly: true
changedBy:
type: string
format: email
readOnly: true
rootObjectSchema:
type: string
const: v1
rootObject:
type: object
properties:
firstname:
type: string
lastname:
type: string
```

schemas\projections\account.yaml
```
title: account
type: object
aggregateRootNames:
- account
properties:
projectionId:
type: string
firstname:
type: string
index: account.rootObject.firstname
lastname:
type: string
index: account.rootObject.lastname
```

example.php
```
<?php
require_once __DIR__ . '/../vendor/autoload.php';
FluxEco\DotEnv\Api::new()->load(__DIR__);
//initialize
fluxAggregateRoot\initialize();
//create
$correlationId = fluxValueObject\getNewUuid();
$actorEmail = 'example@fluxlabs.ch';
$aggregateName = 'account';
$aggregateId = fluxValueObject\getNewUuid();
$payload = json_encode([
"firstname" => "Emmett",
"lastname" => "Brown"
]);
fluxAggregateRoot\create($correlationId, $actorEmail, $aggregateName, $aggregateId, $payload);
//change
$correlationId = fluxValueObject\getNewUuid();
$payload = json_encode([
"firstname" => "Dr. Emmett",
"lastname" => "Brown"
]);
fluxAggregateRoot\change($correlationId, $actorEmail, $aggregateName, $aggregateId, $payload);
//delete
fluxAggregateRoot\delete($correlationId, $actorEmail, $aggregateName, $aggregateId);
```

## Contributing :purple_heart:
Please ...
Expand Down
22 changes: 15 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "flux-eco/aggregate-root",
"description": "Manage aggregate roots described as json schema",
"version": "0.0.2",
"version": "1.0.0",
"type": "flux-app",
"keywords": [
"flux-eco",
Expand All @@ -22,22 +22,30 @@
"email": "support@fluxlabs.ch"
},
"require": {
"flux-eco/global-stream": ">=0.0.1",
"flux-eco/storage": ">=0.0.1",
"flux-eco/value-object": ">=0.0.1",
"flux-eco/global-stream": ">=1.0.0",
"flux-eco/storage": ">=1.0.0",
"flux-eco/value-object": ">=1.0.0",
"flux-eco/json-schema-assertion": ">=0.0.1",
"flux-eco/json-schema-instance": ">=0.0.1",
"flux-eco/json-schema-document": ">=0.0.1",
"flux-eco/json-schema-instance": ">=1.0.0",
"flux-eco/json-schema-document": ">=1.0.0",
"php": ">=8.0",
"ext-curl": "*",
"ext-json": "*",
"ext-yaml": "*"
},

"autoload": {
"files": [
"fn/change.php",
"fn/create.php",
"fn/delete.php",
"fn/initialize.php"
],
"psr-4": {
"FluxEco\\AggregateRoot\\": [
"src/"
],
"fluxAggregateRoot\\": [
"fn/"
]
}
},
Expand Down
Loading

0 comments on commit 656ba13

Please sign in to comment.