Skip to content

Commit

Permalink
Merge pull request #152 from castore-dev/finish-docs
Browse files Browse the repository at this point in the history
patch: Finish docs
  • Loading branch information
ThomasAribart committed Sep 22, 2023
2 parents aa393cc + ce73afb commit 54ba736
Show file tree
Hide file tree
Showing 26 changed files with 896 additions and 269 deletions.
1 change: 1 addition & 0 deletions docs/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 2
sidebar_position: 1
---

# Installation
Expand Down
58 changes: 0 additions & 58 deletions docs/docs/1-introduction.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const pokemonAppearedEventType = new EventType<

:::info

Note that we only provided TS types for `payload` and `metadata` properties. That is because, as stated in the [core design](../1-introduction.md#-core-design), **Castore is meant to be as flexible as possible**, and that includes the validation library you want to use (if any): The `EventType` class can be used directly if no validation is required, or implemented by [other classes](../5-packages.md#-event-types) which will add run-time validation methods to it 👍
Note that we only provided TS types for `payload` and `metadata` properties. That is because, as stated in the [core design](../../../), **Castore is meant to be as flexible as possible**, and that includes the validation library you want to use (if any): The `EventType` class can be used directly if no validation is required, or implemented by [other classes](../4-packages.md#-event-types) which will add run-time validation methods to it 👍

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ const { aggregate } = await pokemonsEventStore.getAggregate('pikachu1');

:::info

You can choose to build an event storage adapter that suits your usage. However, we highly recommend using an [off-the-shelf adapter](../5-packages.md#-event-storage-adapters) (if the storage solution that you use does not have an adapter yet, feel free to create/upvote an issue, or contribute 🤗).
You can choose to build an event storage adapter that suits your usage. However, we highly recommend using an [off-the-shelf adapter](../4-packages.md#-event-storage-adapters) (if the storage solution that you use does not have an adapter yet, feel free to create/upvote an issue, or contribute 🤗).

:::
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ const catchPokemonCommand = new Command({

:::info

Note that we only provided TS types for `Input` and `Output` properties. That is because, as stated in the [core design](../1-introduction.md#-core-design), **Castore is meant to be as flexible as possible**, and that includes the validation library you want to use (if any): The `Command` class can be used directly if no validation is required, or implemented by [other classes](../5-packages.md#-commands) which will add run-time validation methods to it 👍
Note that we only provided TS types for `Input` and `Output` properties. That is because, as stated in the [core design](../../../), **Castore is meant to be as flexible as possible**, and that includes the validation library you want to use (if any): The `Command` class can be used directly if no validation is required, or implemented by [other classes](../4-packages.md#-commands) which will add run-time validation methods to it 👍

:::

`Commands` handlers should NOT use [read models](../4-reacting-to-events/6-read-models.md) when validating that a modification is acceptable. Read models are like cache: They are not the source of truth, and may not represent the freshest state.
`Commands` handlers should NOT use [read models](../3-reacting-to-events/6-read-models.md) when validating that a modification is acceptable. Read models are like cache: They are not the source of truth, and may not represent the freshest state.

Fetching and pushing events non-simultaneously exposes your application to [race conditions](https://en.wikipedia.org/wiki/Race_condition). To counter that, commands are designed to be retried when an `EventAlreadyExistsError` is triggered (which is part of the `EventStorageAdapter` interface).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"label": "Event Sourcing concepts",
"position": 3
"position": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ await messageQueue.publishMessage(...);

:::info

You can code your own `MessageQueueAdapter` (simply implement the `MessageChannelAdapter` interface), but we highly recommend using an [off-the-shelf adapter](../5-packages.md#-message-queue-adapters) (if the messaging solution that you use does not have an adapter yet, feel free to create/upvote an issue, or contribute 🤗).
You can code your own `MessageQueueAdapter` (simply implement the `MessageChannelAdapter` interface), but we highly recommend using an [off-the-shelf adapter](../4-packages.md#-message-queue-adapters) (if the messaging solution that you use does not have an adapter yet, feel free to create/upvote an issue, or contribute 🤗).

:::

Expand Down Expand Up @@ -129,7 +129,7 @@ The following methods interact with the messaging solution of your application t

**Type Helpers:**

- <code>MessageChannelMessage</code>: Given a <code>MessageQueue</code>, returns the TS type of its messages
- `MessageChannelMessage`: Given a `MessageQueue`, returns the TS type of its messages

```ts
import type { MessageChannelMessage } from '@castore/core';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ await messageBus.publishMessage(...);

:::info

You can code your own `MessageBusAdapter` (simply implement the `MessageChannelAdapter` interface), but we highly recommend using an [off-the-shelf adapter](../5-packages.md#-message-buses-adapters) (if the messaging solution that you use is missing, feel free to create/upvote an issue, or contribute 🤗).
You can code your own `MessageBusAdapter` (simply implement the `MessageChannelAdapter` interface), but we highly recommend using an [off-the-shelf adapter](../4-packages.md#-message-buses-adapters) (if the messaging solution that you use is missing, feel free to create/upvote an issue, or contribute 🤗).

:::

Expand Down Expand Up @@ -125,7 +125,7 @@ The following methods interact with the messaging solution of your application t

**Type Helpers:**

- <code>MessageChannelMessage</code>: Given a <code>MessageBus</code>, returns the TS type of its messages
- `MessageChannelMessage`: Given a `MessageBus`, returns the TS type of its messages

```ts
import type { MessageChannelMessage } from '@castore/core';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"label": "Reacting to events",
"position": 4
"position": 3
}
2 changes: 1 addition & 1 deletion docs/docs/5-packages.md → docs/docs/4-packages.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 5
sidebar_position: 4
---

# Packages
Expand Down
148 changes: 10 additions & 138 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

const lightCodeTheme = require('prism-react-renderer/themes/vsLight');
const darkCodeTheme = require('prism-react-renderer/themes/vsDark');

// @ts-expect-error bad typing
lightCodeTheme.plain.backgroundColor = '#f8f8f8';
// @ts-expect-error bad typing
darkCodeTheme.plain.backgroundColor = '#242424';

/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Castore',
Expand Down Expand Up @@ -50,7 +58,6 @@ const config = {
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
// Replace with your project's social card
image: 'img/castore-social-card.jpg',
navbar: {
hideOnScroll: true,
Expand All @@ -76,143 +83,8 @@ const config = {
],
},
prism: {
theme: {
plain: {
color: '#393A34',
backgroundColor: '#f6f8fa',
},
styles: [
{
types: ['comment', 'prolog', 'doctype', 'cdata'],
style: {
color: '#999988',
fontStyle: 'italic',
},
},
{
types: ['namespace'],
style: {
opacity: 0.7,
},
},
{
types: ['string', 'attr-value'],
style: {
color: '#e3116c',
},
},
{
types: ['punctuation', 'operator'],
style: {
color: '#393A34',
},
},
{
types: [
'entity',
'url',
'symbol',
'number',
'boolean',
'variable',
'constant',
'property',
'regex',
'inserted',
],
style: {
color: '#36acaa',
},
},
{
types: ['atrule', 'keyword', 'attr-name', 'selector'],
style: {
color: '#00a4db',
},
},
{
types: ['function', 'deleted', 'tag'],
style: {
color: '#d73a49',
},
},
{
types: ['function-variable'],
style: {
color: '#6f42c1',
},
},
{
types: ['tag', 'selector', 'keyword'],
style: {
color: '#00009f',
},
},
],
},
darkTheme: {
plain: {
color: '#F8F8F2',
backgroundColor: '#282A36',
},
styles: [
{
types: ['prolog', 'constant', 'builtin'],
style: {
color: 'rgb(189, 147, 249)',
},
},
{
types: ['inserted', 'function'],
style: {
color: 'rgb(80, 250, 123)',
},
},
{
types: ['deleted'],
style: {
color: 'rgb(255, 85, 85)',
},
},
{
types: ['changed'],
style: {
color: 'rgb(255, 184, 108)',
},
},
{
types: ['punctuation', 'symbol'],
style: {
color: 'rgb(248, 248, 242)',
},
},
{
types: ['string', 'char', 'tag', 'selector'],
style: {
color: 'rgb(255, 121, 198)',
},
},
{
types: ['keyword', 'variable'],
style: {
color: 'rgb(189, 147, 249)',
fontStyle: 'italic',
},
},
{
types: ['comment'],
style: {
color: 'rgb(98, 114, 164)',
},
},
{
types: ['attr-name'],
style: {
color: 'rgb(241, 250, 140)',
},
},
],
},
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
},
algolia: {
// The application ID provided by Algolia
Expand Down
3 changes: 2 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
"@docusaurus/preset-classic": "2.4.1",
"@mdx-js/react": "^1.6.22",
"@mui/material": "^5.6.3",
"clsx": "^1.2.1",
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.11.0",
"uuid": "^9.0.0",
"web-vitals": "^2.1.4"
},
Expand Down
Loading

0 comments on commit 54ba736

Please sign in to comment.