Skip to content

Commit

Permalink
feat: extracted AppStateService and UserService to angular-integratio…
Browse files Browse the repository at this point in the history
…n-interface lib
  • Loading branch information
markuczy committed Mar 11, 2024
1 parent 8cea5be commit 73da64f
Show file tree
Hide file tree
Showing 42 changed files with 279 additions and 36 deletions.
2 changes: 1 addition & 1 deletion libs/angular-accelerator/mocks/app-state-service-mock.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'
import { PageInfo, Portal } from '@onecx/integration-interface'
// eslint-disable-next-line
import { AppStateService } from '@onecx/angular-accelerator'
import { AppStateService } from '@onecx/angular-integration-interface'
import { FakeTopic } from './fake-topic'

/**
Expand Down
1 change: 1 addition & 0 deletions libs/angular-accelerator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@angular/router": "^15.2.7",
"@ngx-translate/core": "^14.0.0",
"@onecx/integration-interface": "~4",
"@onecx/angular-integration-interface": "~4",
"chart.js": "^4.4.0",
"d3-scale-chromatic": "^3.0.0",
"rxjs": "~7.8.0",
Expand Down
2 changes: 0 additions & 2 deletions libs/angular-accelerator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export * from './lib/components/search-config/search-config.component'
export * from './lib/components/search-header/search-header.component'

// services
export * from './lib/services/app-state.service'
export * from './lib/services/breadcrumb.service'
export * from './lib/services/user.service'

// pipes
export * from './lib/pipes/dynamic.pipe'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { DynamicPipe } from './pipes/dynamic.pipe'
import { RelativeDatePipe } from './pipes/relative-date.pipe'

import { IfPermissionDirective } from './directives/if-permission.directive'
import { UserService } from './services/user.service'
import { UserService } from '@onecx/angular-integration-interface'

export class AngularAcceleratorMissingTranslationHandler implements MissingTranslationHandler {
handle(params: MissingTranslationHandlerParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { DataAction } from '../../model/data-action'
import { DataSortDirection } from '../../model/data-sort-direction'
import { DataTableColumn } from '../../model/data-table-column.model'
import { MfeInfo } from '@onecx/integration-interface'
import { AppStateService } from '../../services/app-state.service'
import { UserService } from '../../services/user.service'
import { AppStateService } from '@onecx/angular-integration-interface'
import { UserService } from '@onecx/angular-integration-interface'
import { ObjectUtils } from '../../utils/objectutils'
import { DataSortBase } from '../data-sort-base/data-sort-base'
import { Filter, Row } from '../data-table/data-table.component'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { TranslateTestingModule } from 'ngx-translate-testing'
import { NoopAnimationsModule } from '@angular/platform-browser/animations'
import { DateUtils } from '../../utils/dateutils'
import { HttpClientModule } from '@angular/common/http'
import { UserService } from '../../services/user.service'
import { UserService } from '@onecx/angular-integration-interface'
import { MockUserService } from '../../../../mocks/mock-user-service'

describe('InteractiveDataViewComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { MenuItem, PrimeIcons } from 'primeng/api'
import { concat, map, Observable, of } from 'rxjs'
import { BreadcrumbService } from '../../services/breadcrumb.service'
import { TranslateService } from '@ngx-translate/core'
import { AppStateService } from '../../services/app-state.service'
import { UserService } from '../../services/user.service'
import { AppStateService } from '@onecx/angular-integration-interface'
import { UserService } from '@onecx/angular-integration-interface'
import { PrimeIcon } from '../../utils/primeicon.utils'

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Directive, ElementRef, Input, OnInit, Optional, Renderer2, TemplateRef, ViewContainerRef } from '@angular/core'
import { UserService } from '../services/user.service'
import { UserService } from '@onecx/angular-integration-interface'

@Directive({ selector: '[ocxIfPermission], [ocxIfNotPermission]' })
export class IfPermissionDirective implements OnInit {
Expand Down
46 changes: 46 additions & 0 deletions libs/angular-integration-interface/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "ocx",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "ocx",
"style": "kebab-case"
}
],
"no-restricted-syntax": [
"off",
{
"selector": "CallExpression[callee.object.name=\"console\"][callee.property.name=/^(debug|info|time|timeEnd|trace)$/]"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
}
]
}
7 changes: 7 additions & 0 deletions libs/angular-integration-interface/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# angular-integration-interface

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test angular-integration-interface` to execute the unit tests.
22 changes: 22 additions & 0 deletions libs/angular-integration-interface/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable */
export default {
displayName: 'angular-integration-interface',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../coverage/libs/angular-integration-interface',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
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',
],
}
9 changes: 9 additions & 0 deletions libs/angular-integration-interface/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/libs/angular-integration-interface",
"lib": {
"entryFile": "src/index.ts"
},
"assets": ["./assets/**"]
}

13 changes: 13 additions & 0 deletions libs/angular-integration-interface/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@onecx/angular-integration-interface",
"version": "4.9.0",
"peerDependencies": {
"@angular/core": "^15.2.7",
"@onecx/integration-interface": "~4",
"rxjs": "~7.8.0"
},
"dependencies": {},
"publishConfig": {
"access": "public"
}
}
58 changes: 58 additions & 0 deletions libs/angular-integration-interface/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "angular-integration-interface",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/angular-integration-interface/src",
"prefix": "onecx",
"tags": [],
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/angular:package",
"outputs": [
"{workspaceRoot}/dist/{projectRoot}"
],
"options": {
"project": "libs/angular-integration-interface/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "libs/angular-integration-interface/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "libs/angular-integration-interface/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/angular-integration-interface/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"libs/angular-integration-interface/**/*.ts",
"libs/angular-integration-interface/**/*.html"
]
}
},
"release": {
"executor": "nx-release:build-update-publish",
"options": {
"libName": "angular-integration-interface"
}
}
}
}
3 changes: 3 additions & 0 deletions libs/angular-integration-interface/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// services
export * from './lib/services/app-state.service'
export * from './lib/services/user.service'
15 changes: 15 additions & 0 deletions libs/angular-integration-interface/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'jest-preset-angular/setup-jest'

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
})
31 changes: 31 additions & 0 deletions libs/angular-integration-interface/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "es2022",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.lib.prod.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../tsconfig.base.json",
"angularCompilerOptions": {
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
14 changes: 14 additions & 0 deletions libs/angular-integration-interface/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [],
"target": "es2022",
"useDefineForClassFields": false
},
"exclude": ["**/*.spec.ts", "src/test-setup.ts", "jest.config.ts", "**/*.test.ts", "**/*.stories.ts", "jest.config.ts"],
"include": ["**/*.ts"]
}
13 changes: 13 additions & 0 deletions libs/angular-integration-interface/tsconfig.lib.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false,
"target": "es2022",
"useDefineForClassFields": false
},
"angularCompilerOptions": {
"compilationMode": "partial"
},
"exclude": ["jest.config.ts"]
}

11 changes: 11 additions & 0 deletions libs/angular-integration-interface/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"target": "es2016",
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"]
}
1 change: 1 addition & 0 deletions libs/portal-integration-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@onecx/accelerator": "~4",
"@onecx/integration-interface": "~4",
"@onecx/angular-accelerator": "~4",
"@onecx/angular-integration-interface": "~4",
"fast-deep-equal": "^3.1.3",
"msw": "^1.3.2",
"rxjs": "~7.8.0",
Expand Down
4 changes: 2 additions & 2 deletions libs/portal-integration-angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ export * from './lib/core/utils/caching-translate-loader.utils'

export {
BreadcrumbService,
UserService,
SearchConfig,
Action,
DataAction,
DataTableColumn,
ColumnType,
AppStateService,
ObjectDetailItem,
} from '@onecx/angular-accelerator'

export { AppStateService, UserService } from '@onecx/angular-integration-interface'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component } from '@angular/core'
import { catchError, map, Observable, of, switchMap, tap, throwError, EMPTY, mergeMap } from 'rxjs'
import { AnnouncementItem, AnnouncementPriorityType } from '../../../model/announcement-item'
import { AnnouncementsApiService } from '../../../services/announcements-api.service'
import { AppStateService } from '@onecx/angular-accelerator'
import { AppStateService } from '@onecx/angular-integration-interface'
import { ConfigurationService } from '../../../services/configuration.service'

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AUTH_SERVICE } from '../../../api/injection-tokens'
import { MenuService } from '../../../services/app.menu.service'
import { MenuItem } from 'primeng/api'
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'
import { UserService } from '@onecx/angular-accelerator'
import { UserService } from '@onecx/angular-integration-interface'
import { map, Observable } from 'rxjs'
import { UserProfile } from '../../../model/user-profile.model'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from '@angular/core'
import { map, Observable } from 'rxjs'
import { MfeInfo } from '../../../model/mfe-info.model'
import { AppStateService } from '@onecx/angular-accelerator'
import { AppStateService } from '@onecx/angular-integration-interface'

@Component({
selector: 'ocx-mfe-debug',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ConfigurationService } from '../../../services/configuration.service'
import { Router } from '@angular/router'
import { MenuItem } from 'primeng/api'
import { MenuService } from '../../../services/app.menu.service'
import { AppStateService } from '@onecx/angular-accelerator'
import { AppStateService } from '@onecx/angular-integration-interface'
import { combineLatest, concat, map, Observable, of, withLatestFrom } from 'rxjs'
import { ThemeService } from '../../../services/theme.service'
import { API_PREFIX } from '../../../api/constants'
Expand Down
Loading

0 comments on commit 73da64f

Please sign in to comment.