Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .ask/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build
secrets.json
secrets.*.json
!secrets.sample.json
90 changes: 90 additions & 0 deletions .ask/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
ASK_VERSION := "0.0.5"

DOCKER_SWARM_STACK_NAME := $(shell cat .ask/NAME)

MAKEFILE_PATH := ".ask/Makefile"

# TODO: https://ask-ell.atlassian.net/browse/ASK-3
# packageManager := docker run -it --user=node --rm -v $(PWD):/home/node/workspace --workdir /home/node/workspace node:20 npm
packageManager := npm

.PHONY: help
# Show help
help:
@cat $(MAKEFILE_LIST) | docker run --rm -i xanders/make-help

.PHONY: reload-makefile
# Reload Makefile from latest Ask version
reload-makefile:
curl -o $(MAKEFILE_PATH) https://raw.githubusercontent.com/ask-ell/ask/refs/heads/release/types/node/Makefile

.PHONY: requirements-get
# Get requirements
requirements-get:
@echo "Requirements"
@echo "Make : https://www.gnu.org/software/make/manual/make.html"
@echo "Node : https://nodejs.org/"
@echo "NPM : https://www.npmjs.com/"
@echo "Docker : https://docker.com/"

.ask/secrets.json:
cp -r .ask/secrets.sample.json .ask/secrets.json

.PHONY: install
# Install dependencies
install:
$(packageManager) install
date > node_modules/last_install

node_modules/last_install:
@make -f $(MAKEFILE_PATH) install

.PHONY: build
# Build project
build: node_modules/last_install
$(packageManager) run build
mkdir -p .ask/build
date > .ask/build/last_build

.ask/build/last_build:
@make -f $(MAKEFILE_PATH) build

.PHONY: serve
# Run services in development mode
serve: .ask/secrets.json node_modules/last_install
killall webpack || true
$(packageManager) run start:dev

.PHONY: format
# Format project
format:
$(packageManager) run format

.PHONY: lint
# Format project
lint:
$(packageManager) run lint

.PHONY: test
# Run tests
test: node_modules/last_install
$(packageManager) run test

.PHONY: test-watch
# Run tests in watch mode
test-watch: node_modules/last_install
$(packageManager) run test:watch

.PHONY: clean
# Stop and clean services
clean:
killall webpack || true
$(packageManager) run nx reset

.PHONY: deploy
deploy:
docker stack deploy -c .ask/swarm.yml $(DOCKER_SWARM_STACK_NAME)

.PHONY: undeploy
undeploy:
docker stack rm $(DOCKER_SWARM_STACK_NAME)
1 change: 1 addition & 0 deletions .ask/NAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ask-ell_governance_core
1 change: 1 addition & 0 deletions .ask/secrets.sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Empty file removed .env.sample
Empty file.
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ module.exports = {
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: "./tsconfig.json"
project: './tsconfig.json'
},
rules: {
"@typescript-eslint/space-before-function-paren": "off"
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/no-extraneous-class': 'off'
}
}
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
build
dist
docs
node_modules
.env
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

make format && make lint && git add .
ask format && ask lint && git add .
58 changes: 0 additions & 58 deletions Makefile

This file was deleted.

24 changes: 1 addition & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,2 @@
# Core
Core library for Ask'ell projects.

## Development

### Requirements

- [Make](https://www.gnu.org/software/make/)
- [Docker](https://www.docker.com/)
- [Docker Compose V2](https://docs.docker.com/compose/)

### Commands

#### Run tests

```bash
make test
```

#### Run tests on "watch" mode

```bash
make test-watch
```
Core library for Ask'ell projects.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IAggregateRoot } from "@_core/ddd";
import type { IAggregateRoot } from '@ask-ell/core/ddd'

import { IArticleState } from "./article.state.interface";
import type { IArticleState } from './article.state.interface'

export interface IArticle extends IAggregateRoot<IArticleState> {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface IArticleState {
title: string;
description: string;
title: string
description: string
}
16 changes: 8 additions & 8 deletions examples/blog/application/domain/aggregates/article/article.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { ok, IResult, fail } from "@_core";
import { AggregateRoot } from "@_core/ddd";
import { ok, type IResult, fail } from '@ask-ell/core'
import { AggregateRoot } from '@ask-ell/core/ddd'

import { WrongArticleTitleSizeError } from "../../../errors";
import { MINIMUM_CHARACTERS_REQUIRED_FOR_ARTICLE_TITLE } from "./constants";
import type { IArticle } from "./article.interface";
import { IArticleState } from "./article.state.interface";
import { WrongArticleTitleSizeError } from '../../../errors'
import { MINIMUM_CHARACTERS_REQUIRED_FOR_ARTICLE_TITLE } from './constants'
import type { IArticle } from './article.interface'
import type { IArticleState } from './article.state.interface'

export class Article extends AggregateRoot<IArticleState> implements IArticle {
checkStateValidity(newState: IArticleState): IResult<void> {
if (newState.title.length < MINIMUM_CHARACTERS_REQUIRED_FOR_ARTICLE_TITLE) {
return fail(new WrongArticleTitleSizeError());
return fail(new WrongArticleTitleSizeError())
}
return ok();
return ok()
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const MINIMUM_CHARACTERS_REQUIRED_FOR_ARTICLE_TITLE: number = 10;
export const MINIMUM_CHARACTERS_REQUIRED_FOR_ARTICLE_TITLE = 10
12 changes: 6 additions & 6 deletions examples/blog/application/domain/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { IArticleState } from "./aggregates/article/article.state.interface";
import type { IArticle } from "./aggregates/article/article.interface";
import type { IArticleState } from './aggregates/article/article.state.interface'
import type { IArticle } from './aggregates/article/article.interface'

import { Article } from "./aggregates/article/article";
import { WrongArticleTitleSizeError } from "../errors/wrong-article-title-size.error";
import { Article } from './aggregates/article/article'
import { WrongArticleTitleSizeError } from '../errors/wrong-article-title-size.error'

export type { IArticle, IArticleState };
export type { IArticle, IArticleState }

export { Article, WrongArticleTitleSizeError };
export { Article, WrongArticleTitleSizeError }
2 changes: 1 addition & 1 deletion examples/blog/application/errors/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./wrong-article-title-size.error";
export * from './wrong-article-title-size.error'
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ApplicationError } from "@_core/hexa";
import { ApplicationError } from '@ask-ell/core/hexa'

import { MINIMUM_CHARACTERS_REQUIRED_FOR_ARTICLE_TITLE } from "../domain/aggregates/article/constants";
import { MINIMUM_CHARACTERS_REQUIRED_FOR_ARTICLE_TITLE } from '../domain/aggregates/article/constants'

export class WrongArticleTitleSizeError extends ApplicationError {
constructor() {
super(
`article title must contain less than ${MINIMUM_CHARACTERS_REQUIRED_FOR_ARTICLE_TITLE}`
);
)
}
}
35 changes: 16 additions & 19 deletions examples/blog/application/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
import type { IArticleProvider } from "./ports/driven/article.provider.interface";
import type { IArticleRepository } from "./ports/driven/article.repository.interface";
import type { ICreateArticleUseCase } from "./ports/driving/create-article.use-case.interface";
import type { IUpdateArticleUseCase } from "./ports/driving/update-article.use-case.interface";
import type { CreateArticleUseCaseInput } from "./ports/driving/types";
import type { CreateArticleUseCaseOutput } from "./ports/driving/types";
import type { UpdateArticleUseCaseOutput } from "./ports/driving/types";
import type { ArticleAggregateRootState } from "./ports/driven/types";
import type { IUnitOfWork } from "./unit-of-work.interface";
import type { SaveArticleInput } from "./ports/driven/types";
import type { IArticleProvider } from './ports/driven/article.provider.interface'
import type { IArticleRepository } from './ports/driven/article.repository.interface'
import type { ICreateArticleUseCase } from './ports/driving/create-article.use-case.interface'
import type { IUpdateArticleUseCase } from './ports/driving/update-article.use-case.interface'
import type { ICreateArticleUseCaseInput, IUpdateArticleUseCaseInput } from './ports/driving/types'
import type { ArticleAggregateRootState } from './ports/driven/types'
import type { IUnitOfWork } from './unit-of-work.interface'
import type { IArticleState } from './domain/aggregates/article/article.state.interface'

import { CreateArticleUseCase } from "./use-cases/create-article.use-case";
import { UpdateArticleUseCase } from "./use-cases/update-article.use-case";
import { CreateArticleUseCase } from './use-cases/create-article.use-case'
import { UpdateArticleUseCase } from './use-cases/update-article.use-case'

export type {
IUnitOfWork,
SaveArticleInput,
IArticleProvider,
IArticleRepository,
ICreateArticleUseCase,
IUpdateArticleUseCase,
CreateArticleUseCaseInput,
CreateArticleUseCaseOutput,
UpdateArticleUseCaseOutput,
ICreateArticleUseCaseInput,
ArticleAggregateRootState,
};
IArticleState,
IUpdateArticleUseCaseInput
}

export { CreateArticleUseCase, UpdateArticleUseCase };
export * from "./errors";
export { CreateArticleUseCase, UpdateArticleUseCase }
export * from './errors'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IAggregateRootProvider } from "@_core/hexa";
import type { IAggregateRootProvider } from '@ask-ell/core/hexa'

import { IArticleState } from "../../domain";
import { ArticleAggregateRootState } from "./types";
import type { IArticleState } from '../../domain'
import type { ArticleAggregateRootState } from './types'

export interface IArticleProvider
extends IAggregateRootProvider<IArticleState, ArticleAggregateRootState> {}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { IAggregateRootRepository } from "@_core/hexa";
import type { IAggregateRootRepository } from '@ask-ell/core/hexa'

import type { SaveArticleInput, ArticleAggregateRootState } from "./types";
import type { ArticleAggregateRootState } from './types'
import type { IArticleState } from '../../domain'

export interface IArticleRepository
extends IAggregateRootRepository<
SaveArticleInput,
ArticleAggregateRootState
> {}
export interface IArticleRepository extends IAggregateRootRepository<IArticleState, ArticleAggregateRootState> { }
7 changes: 3 additions & 4 deletions examples/blog/application/ports/driven/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { AggregateRootState } from "@_core/ddd";
import type { AggregateRootState } from '@ask-ell/core/ddd'

import { IArticleState } from "../../domain";
import type { IArticleState } from '../../domain'

export type SaveArticleInput = IArticleState;
export type ArticleAggregateRootState = AggregateRootState<IArticleState>;
export type ArticleAggregateRootState = AggregateRootState<IArticleState>
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import type { IUseCase } from "@_core/hexa";
import type { IUseCase } from '@ask-ell/core/hexa'

import { CreateArticleUseCaseInput, CreateArticleUseCaseOutput } from "./types";
import type { ICreateArticleUseCaseInput } from './types'
import type { ArticleAggregateRootState } from '../driven/types'

export interface ICreateArticleUseCase
extends IUseCase<
CreateArticleUseCaseInput,
Promise<CreateArticleUseCaseOutput>
> {}
export interface ICreateArticleUseCase extends IUseCase<ICreateArticleUseCaseInput, Promise<ArticleAggregateRootState>> { }
Loading