Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: distributed state in AppStateService #12

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
29 changes: 7 additions & 22 deletions libs/accelerator/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,15 @@
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "onecx",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "onecx",
"style": "kebab-case"
}
]
}
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
Expand Down
6 changes: 5 additions & 1 deletion libs/accelerator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This library contains all framework independent accelerators.

## Building

Run `nx build accelerator` to build the library.

## Running unit tests

Run `nx test accelerator` to execute the unit tests.
Run `nx test accelerator` to execute the unit tests via [Jest](https://jestjs.io).
19 changes: 4 additions & 15 deletions libs/accelerator/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,10 @@
export default {
displayName: 'accelerator',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../coverage/libs/accelerator',
testEnvironment: 'node',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/libs/accelerator',
}
8 changes: 0 additions & 8 deletions libs/accelerator/ng-package.json

This file was deleted.

22 changes: 10 additions & 12 deletions libs/accelerator/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"name": "@onecx/accelerator",
"version": "3.1.1",
"peerDependencies": {
"@angular/common": "^15.2.7",
"@angular/core": "^15.2.7",
"rxjs": "^7.8.0"
},
"publishConfig": {
"access": "public"
}
}

"name": "@onecx/accelerator",
"version": "3.1.1",
"peerDependencies": {
"tslib": "^2.3.0",
"rxjs": "7.8.1"
},
"type": "commonjs",
"main": "./src/index.js",
"typings": "./src/index.d.ts"
}
59 changes: 18 additions & 41 deletions libs/accelerator/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,28 @@
"name": "accelerator",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/accelerator/src",
"prefix": "onecx",
"tags": [],
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/angular:package",
"outputs": [
"{workspaceRoot}/dist/{projectRoot}"
],
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"project": "libs/accelerator/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "libs/accelerator/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "libs/accelerator/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
"outputPath": "dist/libs/accelerator",
"main": "libs/accelerator/src/index.ts",
"tsConfig": "libs/accelerator/tsconfig.lib.json",
"assets": ["libs/accelerator/*.md"]
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/accelerator/**/*.ts", "libs/accelerator/package.json"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": [
"{workspaceRoot}/coverage/{projectRoot}"
],
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/accelerator/jest.config.ts",
"passWithNoTests": true
Expand All @@ -39,25 +34,7 @@
"codeCoverage": true
}
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": [
"{options.outputFile}"
],
"options": {
"lintFilePatterns": [
"libs/accelerator/**/*.ts",
"libs/accelerator/**/*.html",
"libs/accelerator/package.json"
]
}
},
"release": {
"executor": "nx-release:build-update-publish",
"options": {
"libName": "accelerator"
}
}
}
}
},
"tags": []
}
1 change: 0 additions & 1 deletion libs/accelerator/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './lib/accelerator.module'
export * from './lib/topic/topic'
7 changes: 0 additions & 7 deletions libs/accelerator/src/lib/accelerator.module.ts

This file was deleted.

14 changes: 11 additions & 3 deletions libs/accelerator/src/lib/topic/topic.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* The test environment that will be used for testing.
* The default environment in Jest is a Node.js environment.
* If you are building a web app, you can use a browser-like environment through jsdom instead.
*
* @jest-environment jsdom
*/

import { map } from 'rxjs'
import { Topic } from './topic'

Expand Down Expand Up @@ -79,7 +87,7 @@ describe('Topic', () => {
expect(values2).toEqual(['value1', 'value2'])
})

it('should has no value if message name is different', () => {
it('should have no value if message name is different', () => {
testTopic1.publish('value1')

expect(values1).toEqual(['value1'])
Expand All @@ -92,7 +100,7 @@ describe('Topic', () => {
expect(values3).toEqual([])
})

it('should has no value if message version is different', () => {
it('should have no value if message version is different', () => {
testTopic1.publish('value1')

expect(values1).toEqual(['value1'])
Expand All @@ -105,7 +113,7 @@ describe('Topic', () => {
expect(values3).toEqual([])
})

it('should has no value if message is undefined', () => {
it('should have no value if message is undefined', () => {
testTopic1.publish('value1')

expect(values1).toEqual(['value1'])
Expand Down
4 changes: 2 additions & 2 deletions libs/accelerator/src/lib/topic/topic.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { filter, map } from 'rxjs/operators'
import { BehaviorSubject, Observable, Observer, OperatorFunction, Subscription, UnaryFunction } from 'rxjs'
import { BehaviorSubject, Observable, Observer, OperatorFunction, Subscribable, Subscription, UnaryFunction } from 'rxjs'
import { TopicDataMessage } from './topic-data-message'
import { TopicMessage } from './topic-message'
import { TopicMessageType } from './topic-message-type'

export class Topic<T> {
export class Topic<T> implements Subscribable<T>{
public isInitialized: Promise<void>
private data = new BehaviorSubject<TopicDataMessage<T> | undefined>(undefined)

Expand Down
8 changes: 0 additions & 8 deletions libs/accelerator/src/test-setup.ts

This file was deleted.

14 changes: 4 additions & 10 deletions libs/accelerator/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "es2022",
"useDefineForClassFields": false,
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
Expand All @@ -18,11 +18,5 @@
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../tsconfig.base.json",
"angularCompilerOptions": {
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
]
}
9 changes: 3 additions & 6 deletions libs/accelerator/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [],
"target": "es2022",
"types": ["node"]
},
"exclude": ["src/**/*.spec.ts", "src/test-setup.ts", "jest.config.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
11 changes: 0 additions & 11 deletions libs/accelerator/tsconfig.lib.prod.json

This file was deleted.

2 changes: 0 additions & 2 deletions libs/accelerator/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"target": "es2016",
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
}
25 changes: 25 additions & 0 deletions libs/integration-interface/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
}
]
}
11 changes: 11 additions & 0 deletions libs/integration-interface/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# integration-interface

This library contains everything that is needed to communicate with the shell and that is framework independent

## Building

Run `nx build integration-interface` to build the library.

## Running unit tests

Run `nx test integration-interface` to execute the unit tests via [Jest](https://jestjs.io).
11 changes: 11 additions & 0 deletions libs/integration-interface/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'integration-interface',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/libs/integration-interface',
}
12 changes: 12 additions & 0 deletions libs/integration-interface/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@onecx/integration-interface",
"version": "3.1.1",
"peerDependencies": {
"tslib": "^2.3.0",
"rxjs": "7.8.1",
"@onecx/accelerator": "^3"
},
"type": "commonjs",
"main": "./src/index.js",
"typings": "./src/index.d.ts"
}
Loading
Loading