Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

feature: isolate jsonSchemaCommand in a package #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 .github/workflows/release-to-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ jobs:
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./packages/test-tools/package.json
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./packages/json-schema-command/package.json
8 changes: 6 additions & 2 deletions castore.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@
},
{
"path": "packages/json-schema-event",
"name": "📬 Json Schema"
"name": "📬 Json Schema Event"
},
{
"path": "packages/zod-event",
"name": "📬 Zod"
"name": "📬 Zod Event"
},
{
"path": "packages/json-schema-command",
"name": "👮‍♀️ Json Schema Command"
},
{
"path": "packages/test-tools",
Expand Down
1 change: 1 addition & 0 deletions demo/blueprint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@castore/core": "workspace:",
"@castore/json-schema-command": "workspace:",
"@castore/json-schema-event": "workspace:",
"@types/node": "^17.0.29",
"@zerollup/ts-transform-paths": "^1.7.18",
Expand Down
3 changes: 2 additions & 1 deletion demo/blueprint/src/commands/createUser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { v4 as uuid } from 'uuid';

import { JSONSchemaCommand, tuple } from '@castore/core';
import { tuple } from '@castore/core';
import { JSONSchemaCommand } from '@castore/json-schema-command';

import { userEventStore, UserStatus } from '~/users';

Expand Down
3 changes: 2 additions & 1 deletion demo/blueprint/src/commands/deleteUser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { JSONSchemaCommand, tuple } from '@castore/core';
import { tuple } from '@castore/core';
import { JSONSchemaCommand } from '@castore/json-schema-command';

import { userEventStore, UserStatus } from '~/users';

Expand Down
1 change: 1 addition & 0 deletions demo/visualization/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@ant-design/icons": "^4.7.0",
"@castore/core": "workspace:",
"@castore/demo-blueprint": "workspace:",
"@castore/json-schema-command": "workspace:",
"@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3",
"@material-ui/core": "^4.12.4",
Expand Down
3 changes: 2 additions & 1 deletion demo/visualization/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { CssBaseline, Tab, ThemeProvider } from '@mui/material';
import React, { useState } from 'react';
import { createGlobalState } from 'react-use';

import type { EventStore, JSONSchemaCommand } from '@castore/core';
import type { EventStore } from '@castore/core';
import type { JSONSchemaCommand } from '@castore/json-schema-command';

import { EventStoreSynchronizer } from '~/components/EventStoreSynchronizer';
import { dbByEventStoreId, eventStoresById } from '~/services/data';
Expand Down
2 changes: 1 addition & 1 deletion demo/visualization/src/tabs/Commands/CommandCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@mui/material';
import React from 'react';

import type { JSONSchemaCommand } from '@castore/core';
import type { JSONSchemaCommand } from '@castore/json-schema-command';

import { Form } from '~/components/Form';
import { eventStoresById } from '~/services/data';
Expand Down
2 changes: 1 addition & 1 deletion demo/visualization/src/tabs/Commands/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Stack } from '@mui/material';
import React from 'react';

import type { JSONSchemaCommand } from '@castore/core';
import type { JSONSchemaCommand } from '@castore/json-schema-command';

import { CommandCard } from './CommandCard';

Expand Down
4 changes: 0 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"dependency-cruiser": "^11.7.0",
"eslint": "^8.14.0",
"jest": "^27.5.1",
"json-schema-to-ts": "^2.5.4",
"prettier": "^2.6.2",
"ts-node": "^10.7.0",
"ts-toolbelt": "^9.6.0",
Expand All @@ -73,8 +72,5 @@
]
}
}
},
"peerDependencies": {
"json-schema-to-ts": "^2.0.0"
}
}
120 changes: 0 additions & 120 deletions packages/core/src/command/implementations/jsonSchema.util.test.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ export type {
EventStoreAggregate,
} from './eventStore';
export { Command, tuple } from './command/command';
export { JSONSchemaCommand } from './command/implementations/jsonSchema';
export type { OnEventAlreadyExistsCallback } from './command/implementations/jsonSchema';
1 change: 1 addition & 0 deletions packages/json-schema-command/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
2 changes: 2 additions & 0 deletions packages/json-schema-command/.lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const baseConfig = require('../../.lintstagedrc');
module.exports = baseConfig;
3 changes: 3 additions & 0 deletions packages/json-schema-command/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const commonBabelConfig = require('../../commonConfiguration/babel.config');

module.exports = commonBabelConfig();
3 changes: 3 additions & 0 deletions packages/json-schema-command/dependency-cruiser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/** @type {import('dependency-cruiser').IConfiguration} */
const baseConfig = require('../../dependency-cruiser');
module.exports = baseConfig;
8 changes: 8 additions & 0 deletions packages/json-schema-command/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const commonConfig = require('../../commonConfiguration/jest.config');

const config = {
...commonConfig,
moduleDirectories: ['node_modules', '<rootDir>'],
};

module.exports = config;
82 changes: 82 additions & 0 deletions packages/json-schema-command/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"name": "@castore/json-schema-command",
"version": "1.0.3",
"license": "MIT",
"homepage": "https://github.com/theodo/castore#readme",
"bugs": "https://github.com/theodo/castore/issues",
"repository": "theodo/castore.git",
"keywords": [
"event",
"source",
"store",
"typescript"
],
"publishConfig": {
"access": "public"
},
"sideEffects": false,
"files": [
"dist"
],
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"scripts": {
"lint-fix": "yarn linter-base-config --fix",
"lint-fix-all": "yarn lint-fix .",
"linter-base-config": "eslint --ext=js,ts .",
"package": "rm -rf dist && yarn package-cjs && yarn package-esm && yarn package-types",
"package-cjs": "NODE_ENV=cjs yarn transpile --out-dir dist/cjs --source-maps",
"package-esm": "NODE_ENV=esm yarn transpile --out-dir dist/esm --source-maps",
"package-types": "ttsc -p tsconfig.build.json",
"test": "yarn test-linter && yarn test-type && yarn test-circular && yarn test-unit",
"test-circular": "yarn depcruise --validate dependency-cruiser.js .",
"test-linter": "yarn linter-base-config .",
"test-type": "tsc --noEmit --emitDeclarationOnly false",
"test-unit": "yarn jest",
"transpile": "babel src --extensions .ts --quiet",
"watch": "rm -rf dist && concurrently 'yarn:package-* --watch'"
},
"dependencies": {
"ts-toolbelt": "^9.6.0"
},
"devDependencies": {
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.9",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@castore/core": "workspace:",
"@types/node": "^17.0.29",
"@zerollup/ts-transform-paths": "^1.7.18",
"babel-plugin-module-resolver": "^4.1.0",
"concurrently": "^7.1.0",
"dependency-cruiser": "^11.7.0",
"eslint": "^8.14.0",
"jest": "^27.5.1",
"json-schema-to-ts": "^2.5.4",
"prettier": "^2.6.2",
"ts-node": "^10.7.0",
"ttypescript": "^1.5.13",
"typescript": "^4.6.3"
},
"maintainers": [
"Thomas Aribart",
"Charles Géry",
"Juliette Fournier",
"Valentin Beggi"
],
"nx": {
"targets": {
"package": {
"outputs": [
"packages/json-schema-command/dist"
]
}
}
},
"peerDependencies": {
"@castore/core": "*",
"json-schema-to-ts": "^2.0.0"
}
}
6 changes: 6 additions & 0 deletions packages/json-schema-command/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"root": "packages/json-schema-command",
"projectType": "library",
"tags": [],
"implicitDependencies": ["core"]
}
2 changes: 2 additions & 0 deletions packages/json-schema-command/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { JSONSchemaCommand } from './jsonSchema';
export type { OnEventAlreadyExistsCallback } from './jsonSchema';
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts';

import { EventAlreadyExistsError } from '~/errors/eventAlreadyExists';
import { EventStore } from '~/eventStore';

import { Command } from '../command';
import { Command, EventAlreadyExistsError, EventStore } from '@castore/core';

export type OnEventAlreadyExistsCallback = (
error: EventAlreadyExistsError,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { FromSchema } from 'json-schema-to-ts';
import { A } from 'ts-toolbelt';

import { counterEventStore, userEventStore } from '~/eventStore.util.test';
import { Command } from '@castore/core';

import { Command } from '../command';
import { JSONSchemaCommand } from './jsonSchema';
import {
counterEventStore,
incrementCounter,
incrementCounterA,
incrementCounterANoOutput,
incrementCounterNoOutput,
inputSchema,
outputSchema,
userEventStore,
} from './jsonSchema.util.test';

type Input = FromSchema<typeof inputSchema>;
Expand Down
Loading