Initial Commit ...

This commit is contained in:
2026-04-17 16:22:31 +03:30
commit 2f271b21a2
65 changed files with 10616 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md]
max_line_length = off
trim_trailing_whitespace = false
+49
View File
@@ -0,0 +1,49 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events*.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
#
documentation
package-lock.json
+11
View File
@@ -0,0 +1,11 @@
# XSaherElmApiSDK
this is a library which provides all access to Api.
## Maintainer
Hadi Khazaee asl
[https://www.saherelm.ir](https://www.saherelm.ir)
[hadi_khazaee_asl@yahoo.com](mailto:hadi_khazaee_asl@yahoo.com)
+45
View File
@@ -0,0 +1,45 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"cli": {
"analytics": false
},
"version": 1,
"newProjectRoot": "projects",
"projects": {
"x-saherelm-api-sdk": {
"projectType": "library",
"root": "projects/x-saherelm-api-sdk",
"sourceRoot": "projects/x-saherelm-api-sdk/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"project": "projects/x-saherelm-api-sdk/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/x-saherelm-api-sdk/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "projects/x-saherelm-api-sdk/tsconfig.lib.json"
},
"ivy": {
"tsConfig": "projects/x-saherelm-api-sdk/tsconfig.lib.ivy.json"
}
},
"defaultConfiguration": "production"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/x-saherelm-api-sdk/src/test.ts",
"tsConfig": "projects/x-saherelm-api-sdk/tsconfig.spec.json",
"karmaConfig": "projects/x-saherelm-api-sdk/karma.conf.js"
}
}
}
}
},
"defaultProject": "x-saherelm-api-sdk"
}
+77
View File
@@ -0,0 +1,77 @@
{
"name": "x-saherelm-api-sdkholder",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"refreshModule": "npm run cleanModule && npm i",
"watch": "ng build --watch --configuration development",
"build:ivy": "ng build x-saherelm-api-sdk --configuration=ivy",
"publishModule": "npm run buildModule && npm run packModule",
"buildModule": "npm run preBuildModule && ng build x-saherelm-api-sdk",
"serveDocs": "compodoc -p projects/x-saherelm-api-sdk/tsconfig.lib.json --theme material -s",
"packModule": "cd dist/x-saherelm-api-sdk && npm pack && shx mv *.tgz ../../../../Documents/pack",
"unpublishModuleFromRegistry": "npm unpublish --force x-saherelm-api-sdk --registry https://npm.saherelmhub.ir",
"publishModuleToRegistry": "npm publish ../../Documents/pack/x-saherelm-api-sdk-0.0.1.tgz --registry https://npm.saherelmhub.ir",
"rePublishModuleToRegistry": "npm run publishModule && npm run unpublishModuleFromRegistry && npm run publishModuleToRegistry",
"preBuildModule": "shx --silent rm -rf dist && shx --silent rm ../../Documents/pack/x-saherelm-api-sdk*.tgz || shx true && npm run prepareDependenciesFromRegistry",
"cleanModule": "shx true --silent rm -rf dist && shx true --silent rm ./package-lock.json && shx true --silent rm -rf node_modules && npm i --save-dev shx@0.3.2",
"prepareDependenciesFromRegistry": "npm i --force -D --registry https://npm.saherelmhub.ir x-framework-core x-framework-services x-framework-identity-sdk x-framework-push-service",
"generateDocs": "compodoc -p projects/x-saherelm-api-sdk/tsconfig.lib.json --theme material --hideGenerator --disableSourceCode --disableDomTree --disableTemplateTab --disableStyleTab --disablePrivate --disableLifeCycleHooks --disableRoutesGraph --disableCoverage --customFavicon ../../Documents/resources/favicon.png --customLogo ../../Documents/resources/favicon.png"
},
"private": true,
"dependencies": {
"@angular/animations": "~12.0.4",
"@angular/common": "~12.0.4",
"@angular/compiler": "~12.0.4",
"@angular/core": "~12.0.4",
"@angular/forms": "~12.0.4",
"@angular/platform-browser": "~12.0.4",
"@angular/platform-browser-dynamic": "~12.0.4",
"@angular/router": "~12.0.4",
"rxjs": "~6.6.0",
"tslib": "^2.1.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~12.0.5",
"@angular/cdk": "^12.1.2",
"@angular/cli": "~12.0.4",
"@angular/compiler-cli": "~12.0.4",
"@angular/material": "^12.1.2",
"@angular/material-moment-adapter": "^12.1.2",
"@compodoc/compodoc": "^1.1.14",
"@ionic/angular": "^5.6.11",
"@microsoft/signalr": "^6.0.5",
"@microsoft/signalr-protocol-msgpack": "^7.0.2",
"@types/crypto-js": "^4.0.2",
"@types/howler": "^2.2.3",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"@types/uuid": "^8.3.1",
"bignumber.js": "^9.0.2",
"crypto-js": "^4.0.0",
"howler": "^2.2.3",
"ionicons": "^5.5.2",
"jalali-moment": "^3.3.10",
"jasmine-core": "~3.7.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"libphonenumber-js": "^1.9.22",
"md5-typescript": "^1.0.5",
"moment": "^2.29.1",
"ng-packagr": "^12.0.0",
"ngx-device-detector": "^2.1.1",
"shx": "^0.3.3",
"typescript": "~4.2.3",
"uuid": "^8.3.2",
"x-framework-core": "0.0.1",
"x-framework-identity-sdk": "0.0.1",
"x-framework-push-service": "0.0.1",
"x-framework-services": "0.0.1"
}
}
+11
View File
@@ -0,0 +1,11 @@
# XSaherElmApiSDK
this is a library which provides all access to Api.
## Maintainer
Hadi Khazaee asl
[https://www.saherelm.ir](https://www.saherelm.ir)
[hadi_khazaee_asl@yahoo.com](mailto:hadi_khazaee_asl@yahoo.com)
+44
View File
@@ -0,0 +1,44 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, '../../coverage/x-mabsut-api-sdk'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
@@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/x-saherelm-api-sdk",
"lib": {
"entryFile": "src/public-api.ts"
}
}
+22
View File
@@ -0,0 +1,22 @@
{
"name": "x-saherelm-api-sdk",
"version": "0.0.1",
"description": "provide API SDK of xSaherElm API",
"keywords": [
"x-saherelm",
"x-saherelm-api-sdk"
],
"homepage": "https://saherelm.ir",
"author": {
"name": "Hadi Khazaee Asl",
"email": "hadi_khazaee_asl@yahoo.com",
"url": "https://saherelm.ir"
},
"peerDependencies": {
"@angular/common": "^12.0.4",
"@angular/core": "^12.0.4"
},
"dependencies": {
"tslib": "^2.1.0"
}
}
@@ -0,0 +1,472 @@
import { Observable } from 'rxjs';
import { XBaseRangeRequestDto } from 'x-framework-core';
import { HttpEvent, HttpResponse } from '@angular/common/http';
import { XQueryDto, XQueryResultDto } from 'x-framework-identity-sdk';
export interface IXEntityActions<TModel, TKey> {
//
//#region Repository Implementation ...
//
//#region Retrieve ...
//
//#region Get ...
/**
* Retrieve Specified Item based on Id
*
* @param id the Object ID ...
* @param containsDetail specify retrieve full details
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callGet(
id: TKey,
containsDetail?: boolean,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel>;
callGet(
id: TKey,
containsDetail?: boolean,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel>>;
callGet(
id: TKey,
containsDetail?: boolean,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel>>;
callGet(
id: TKey,
containsDetail?: boolean,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//
//#region GetAll ...
/**
* Retrieve all Items
*
* @param containsDetail specify retrieve full details
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callGetAll(
containsDetail?: boolean,
observe?: 'body',
reportProgress?: boolean
): Observable<Array<TModel>>;
callGetAll(
containsDetail?: boolean,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<Array<TModel>>>;
callGetAll(
containsDetail?: boolean,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<Array<TModel>>>;
callGetAll(
containsDetail?: boolean,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//
//#region FindOne ...
/**
* Fine first Item which matched to the query string
*
* @param query search pattern
* @param containsDetail specify retrieve full details
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callFindOne(
query: string,
containsDetail?: boolean,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel>;
callFindOne(
query: string,
containsDetail?: boolean,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel>>;
callFindOne(
query: string,
containsDetail?: boolean,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel>>;
callFindOne(
query: string,
containsDetail?: boolean,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//
//#region FindMany ...
/**
* Find a Collection of items which matched to Specified Query string
*
* @param query search pattern
* @param containsDetail specify retrieve full details
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callFindMany(
query: string,
containsDetail?: boolean,
observe?: 'body',
reportProgress?: boolean
): Observable<Array<TModel>>;
callFindMany(
query: string,
containsDetail?: boolean,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<Array<TModel>>>;
callFindMany(
query: string,
containsDetail?: boolean,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<Array<TModel>>>;
callFindMany(
query: string,
containsDetail?: boolean,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//
//#region Query ...
/**
* Retrieve Items based on XQuery model
*
* @param query specify data projection attributes
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callQuery(
query: XQueryDto,
observe?: 'body',
reportProgress?: boolean
): Observable<XQueryResultDto<TModel>>;
callQuery(
query: XQueryDto,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<XQueryResultDto<TModel>>>;
callQuery(
query: XQueryDto,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<XQueryResultDto<TModel>>>;
callQuery(
query: XQueryDto,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//#endregion
//
//#region Add ...
//
//#region Add ...
/**
* Add New Item
*
* @param body the new Content which requires to add
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callAdd(
body: TModel,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel>;
callAdd(
body: TModel,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel>>;
callAdd(
body: TModel,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel>>;
callAdd(
body: TModel,
connectionId?: string,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//
//#region AddOrUpdate ...
/**
* Add New Item or Update Exists Item
*
* @param body hte instance of Entity
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callAddOrUpdate(
body: TModel,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel>;
callAddOrUpdate(
body: TModel,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel>>;
callAddOrUpdate(
body: TModel,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel>>;
callAddOrUpdate(
body: TModel,
connectionId?: string,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//
//#region AddMany ...
/**
* Add a Collection of items
*
* @param body an instance of XBaseRangeRequest which contains a collection of items
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callAddMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<void>;
callAddMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<void>>;
callAddMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<void>>;
callAddMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//#endregion
//
//#region Update ...
//
//#region Update ...
/**
* Update Specified Item
*
* @param body the instance with all changes
* @param id the Id of Object which are going to replace or update with this
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callUpdate(
id: TKey,
body: TModel,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel>;
callUpdate(
id: TKey,
body: TModel,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel>>;
callUpdate(
id: TKey,
body: TModel,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel>>;
callUpdate(
id: TKey,
body: TModel,
connectionId?: string,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//
//#region UpdateMany ...
/**
* Update a Collection of Items
*
* @param body an instance of XBaseRangeRequestDto
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callUpdateMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<boolean>;
callUpdateMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<boolean>>;
callUpdateMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<boolean>>;
callUpdateMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//#endregion
//
//#region Exists ...
/**
* Check an items is Exists or not
*
* @param id the id of item
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callIsExists(
id: TKey,
observe?: 'body',
reportProgress?: boolean
): Observable<boolean>;
callIsExists(
id: TKey,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<boolean>>;
callIsExists(
id: TKey,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<boolean>>;
callIsExists(
id: TKey,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//
//#region Remove ...
//
//#region Remove ...
/**
* Remove Specified item by its ID
*
* @param id pointer to specific instance
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callRemove(
id: TKey,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel>;
callRemove(
id: TKey,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel>>;
callRemove(
id: TKey,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel>>;
callRemove(
id: TKey,
connectionId?: string,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//
//#region RemoveMany ...
/**
* Remove a Collection of Items base on RangeRequest
*
* @param body an instance of XBaseRangeRequestDto
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
callRemoveMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<void>;
callRemoveMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<void>>;
callRemoveMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<void>>;
callRemoveMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: any,
reportProgress?: boolean
): Observable<any>;
//#endregion
//#endregion
//#endregion
}
@@ -0,0 +1,796 @@
import {
XQueryDto,
XQueryResultDto,
XBaseApiService,
} from 'x-framework-identity-sdk';
import { Observable } from 'rxjs';
import {
XBaseEndPointAction,
XBaseEndPointParam,
} from '../typings/x-endpoint.typings';
import { IXEntityActions } from './i-x-entity-actions.interface';
import { HttpResponse, HttpEvent, HttpParams } from '@angular/common/http';
import { applyConnectionIdToHeader } from '../typings/x-push-provider.typings';
import { toXString, XBaseRangeRequestDto, XValidators } from 'x-framework-core';
export abstract class XBaseEntityService<TModel, TKey>
extends XBaseApiService
implements IXEntityActions<TModel, TKey>
{
//
//#region Repository Implementation ...
//
//#region Retrieve ...
//
//#region Get ...
public callGet(
id: TKey,
containsDetail?: boolean,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel>;
public callGet(
id: TKey,
containsDetail?: boolean,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel>>;
public callGet(
id: TKey,
containsDetail?: boolean,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel>>;
public callGet(
id: TKey,
containsDetail?: boolean,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(id);
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.Get);
//
// Preparing HttpParams ...
let params: HttpParams = null;
if (!!containsDetail) {
params = this.addContainsDetailQueryParam(params, containsDetail);
}
//
// Prepare Result ...
return this.httpClient.get<TModel>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region GetAll ...
public callGetAll(
containsDetail?: boolean,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel[]>;
public callGetAll(
containsDetail?: boolean,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel[]>>;
public callGetAll(
containsDetail?: boolean,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel[]>>;
public callGetAll(
containsDetail?: boolean,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.GetAll);
//
// Preparing HttpParams ...
let params: HttpParams = null;
if (!!containsDetail) {
params = this.addContainsDetailQueryParam(params, containsDetail);
}
//
// Prepare Result ...
return this.httpClient.get<Array<TModel>>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region FindOne ...
public callFindOne(
query: string,
containsDetail?: boolean,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel>;
public callFindOne(
query: string,
containsDetail?: boolean,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel>>;
public callFindOne(
query: string,
containsDetail?: boolean,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel>>;
public callFindOne(
query: string,
containsDetail?: boolean,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(query);
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.FindOne, {
key: XBaseEndPointParam.XQuery,
value: query,
});
//
// Preparing HttpParams ...
let params: HttpParams = null;
if (!!containsDetail) {
params = this.addContainsDetailQueryParam(params, containsDetail);
}
//
// Prepare Result ...
return this.httpClient.get<TModel>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region FindMany ...
public callFindMany(
query: string,
containsDetail?: boolean,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel[]>;
public callFindMany(
query: string,
containsDetail?: boolean,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel[]>>;
public callFindMany(
query: string,
containsDetail?: boolean,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel[]>>;
public callFindMany(
query: string,
containsDetail?: boolean,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.FindMany, {
key: XBaseEndPointParam.XQuery,
value: query,
});
//
// Preparing HttpParams ...
let params: HttpParams = null;
if (!!containsDetail) {
params = this.addContainsDetailQueryParam(params, containsDetail);
}
//
// Prepare Result ...
return this.httpClient.get<Array<TModel>>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region Query ...
public callQuery(
query: XQueryDto,
observe?: 'body',
reportProgress?: boolean
): Observable<XQueryResultDto<TModel>>;
public callQuery(
query: XQueryDto,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<XQueryResultDto<TModel>>>;
public callQuery(
query: XQueryDto,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<XQueryResultDto<TModel>>>;
public callQuery(
query: XQueryDto,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(query);
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.Query);
//
// Preparing HttpParams ...
const params: HttpParams = this.generateXQueryHttpParams(query);
//
// Prepare Result ...
return this.httpClient.get<XQueryResultDto<TModel>>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//#endregion
//
//#region Add ...
//
//#region Add ...
public callAdd(
body: TModel,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel>;
public callAdd(
body: TModel,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel>>;
public callAdd(
body: TModel,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel>>;
public callAdd(
body: TModel,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(body);
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.Add);
//
// Prepare Result ...
return this.httpClient.post<TModel>(endPointPath, body, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
reportProgress,
});
}
//#endregion
//
//#region AddOrUpdate ...
public callAddOrUpdate(
body: TModel,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel>;
public callAddOrUpdate(
body: TModel,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel>>;
public callAddOrUpdate(
body: TModel,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel>>;
public callAddOrUpdate(
body: TModel,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(body);
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.AddOrUpdate);
//
// Prepare Result ...
return this.httpClient.post<TModel>(endPointPath, body, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
reportProgress,
});
}
//#endregion
//
//#region AddMany ...
public callAddMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<void>;
public callAddMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<void>>;
public callAddMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<void>>;
public callAddMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(body);
XValidators.validateHasChilds(body.items);
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.AddMany);
//
// Prepare Result ...
return this.httpClient.post<void>(endPointPath, body, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
reportProgress,
});
}
//#endregion
//#endregion
//
//#region Update ...
//
//#region Update ...
public callUpdate(
id: TKey,
body: TModel,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel>;
public callUpdate(
id: TKey,
body: TModel,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel>>;
public callUpdate(
id: TKey,
body: TModel,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel>>;
public callUpdate(
id: TKey,
body: TModel,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(id);
XValidators.validateNotNull(body);
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.Update, {
key: XBaseEndPointParam.XId,
value: toXString(id),
});
//
// Prepare Result ...
return this.httpClient.put<TModel>(endPointPath, body, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
reportProgress,
});
}
//#endregion
//
//#region UpdateMany ...
public callUpdateMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<boolean>;
public callUpdateMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<boolean>>;
public callUpdateMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<boolean>>;
public callUpdateMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(body);
XValidators.validateHasChilds(body.items);
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.UpdateMany);
//
// Prepare Result ...
return this.httpClient.post<boolean>(endPointPath, body, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
reportProgress,
});
}
//#endregion
//#endregion
//
//#region Exists ...
public callIsExists(
id: TKey,
observe?: 'body',
reportProgress?: boolean
): Observable<boolean>;
public callIsExists(
id: TKey,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<boolean>>;
public callIsExists(
id: TKey,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<boolean>>;
public callIsExists(
id: TKey,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(id);
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.IsExists, {
key: XBaseEndPointParam.XId,
value: toXString(id),
});
//
// Prepare Result ...
return this.httpClient.get<boolean>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
reportProgress,
});
}
//#endregion
//
//#region Remove ...
//
//#region Remove ...
public callRemove(
id: TKey,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<TModel>;
public callRemove(
id: TKey,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<TModel>>;
public callRemove(
id: TKey,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<TModel>>;
public callRemove(
id: TKey,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(id);
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.Remove, {
key: XBaseEndPointParam.XId,
value: toXString(id),
});
//
// Prepare Result ...
return this.httpClient.delete<TModel>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
reportProgress,
});
}
//#endregion
//
//#region RemoveMany ...
public callRemoveMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<void>;
public callRemoveMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<void>>;
public callRemoveMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<void>>;
public callRemoveMany(
body: XBaseRangeRequestDto<TModel>,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(body);
XValidators.validateHasChilds(body.items);
//
// Instantiiate Headers from Default Headers ...
let headers = this.defaultHeaders;
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute<
XBaseEndPointAction,
XBaseEndPointParam
>(XBaseEndPointAction.RemoveMany);
//
// Prepare Result ...
return this.httpClient.post<void>(endPointPath, body, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
reportProgress,
});
}
//#endregion
//#endregion
//#endregion
}
@@ -0,0 +1,111 @@
import {
Route,
CanLoad,
UrlTree,
UrlSegment,
CanActivate,
CanActivateChild,
RouterStateSnapshot,
ActivatedRouteSnapshot,
} from '@angular/router';
import { Observable } from 'rxjs';
import {
XAccountService,
XFrameworkIdentitySDKConfig,
X_FRAMEWORK_IDENTITY_SDK_CONFIG,
} from 'x-framework-identity-sdk';
import { filter, map, tap } from 'rxjs/operators';
import { Inject, Injectable } from '@angular/core';
import { XManagerService } from 'x-framework-services';
import { XAvailableRoles } from '../typings/x-role.typings';
import { checkIsInRoleByInfo, toRoleInfo } from '../tools/x-role.tools';
import { isNullOrUndefined, XExceptionIDs, XLoggable, XOneOrManyType } from 'x-framework-core';
@Injectable({
providedIn: 'root',
})
export abstract class XBaseGuard
extends XLoggable
implements CanActivate, CanActivateChild, CanLoad
{
//
abstract roles: XOneOrManyType<XAvailableRoles>;
//
constructor(
private authService: XAccountService,
private managerService: XManagerService,
@Inject(X_FRAMEWORK_IDENTITY_SDK_CONFIG)
public config: XFrameworkIdentitySDKConfig
) {
super(config);
}
//
//#region Actions ...
//
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot
):
| Observable<boolean | UrlTree>
| Promise<boolean | UrlTree>
| boolean
| UrlTree {
return this.handleGuard();
}
//
canActivateChild(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot
):
| Observable<boolean | UrlTree>
| Promise<boolean | UrlTree>
| boolean
| UrlTree {
return this.handleGuard();
}
//
canLoad(
route: Route,
segments: UrlSegment[]
): Observable<boolean> | Promise<boolean> | boolean {
return this.handleGuard();
}
//#endregion
//
//#region Private Action ...
private handleGuard(): Observable<boolean> {
return this.authService.state$.pipe(
filter(
(state) =>
!isNullOrUndefined(state) && !!state.isLoggedIn && !!state.profile
),
map((state) => state.profile),
map((user) => toRoleInfo(user)),
map((roleInfo) => checkIsInRoleByInfo(this.roles, roleInfo)),
tap((isPassed) => {
//
if (!isPassed) {
this.handleGuardReject();
}
})
);
}
//
private handleGuardReject(): void {
//
this.managerService.notificationService.presentErrorNotification({
exception: XExceptionIDs.NotAllowed,
dissmissable: true,
});
//
this.managerService.navigateByPage(this.config.Pages.Login);
}
//#endregion
}
@@ -0,0 +1,19 @@
import { XFrameworkCoreConfig } from 'x-framework-core';
import { XFrameworkServicesConfig } from 'x-framework-services';
import { XFrameworkIdentitySDKConfig } from 'x-framework-identity-sdk';
export type XSharedConfig = XFrameworkCoreConfig &
XFrameworkServicesConfig &
XFrameworkIdentitySDKConfig & { [key: string]: any };
// tslint:disable-next-line:no-empty-interface
export interface XSaherElmApiSDKConfig extends XSharedConfig {
//
// Push Service Configuration ...
pushMessageAction: string;
pushServiceRoute: string;
pushManagerReconnectDelay: number;
//
corsBypasserProxy: string;
}
@@ -0,0 +1,30 @@
import { HttpClient } from '@angular/common/http';
import { Injectable, Inject } from '@angular/core';
import { XApiEndPoint } from '../typings/x-endpoint.typings';
import { X_SAHERELM_API_SDK_CONFIG } from '../tokens/x-injectable-tokens';
import { XSaherElmApiSDKConfig } from '../config/x-saherelm-api-sdk.config';
import { XApiConfiguration, XBaseApiService, X_API_CONFIG } from 'x-framework-identity-sdk';
@Injectable({
providedIn: 'root',
})
export class XConfigurationsService extends XBaseApiService {
//
//#region Constructor ...
constructor(
protected httpClient: HttpClient,
@Inject(X_SAHERELM_API_SDK_CONFIG) config: XSaherElmApiSDKConfig,
@Inject(X_API_CONFIG) apiConfig: XApiConfiguration
) {
//
super(
XApiEndPoint.Configurations,
true,
true,
httpClient,
config,
apiConfig
);
}
//#endregion
}
@@ -0,0 +1,203 @@
import {
XBaseDto,
hasChild,
XFileType,
typeGuard,
isSameObject,
isNullOrUndefined,
isNullOrEmptyString,
} from 'x-framework-core';
import {
XReferenceDto,
parseXReferences,
references2String,
} from '../../models/x-reference.dto';
import { XPersonDto } from '../../models/x-person.dto';
/**
* a Model for Describing a File ...
*/
export interface XFileEntity extends XBaseDto {
id: string;
type: XFileType;
name: string;
thumb?: string;
path: string;
thumbPath?: string;
uploadedOn: Date;
fileName?: string;
ownerId: string;
references: string;
}
/**
* a Model for Describing a File ...
*/
export interface XFileDto extends XBaseDto {
id: string;
type: XFileType;
name: string;
thumb?: string;
path: string;
thumbPath?: string;
uploadedOn: Date;
fileName?: string;
ownerId: string;
owner?: XPersonDto;
references: Array<XReferenceDto<string>>;
}
/**
* Default model ...
*/
export const defaultFileDto: XFileDto = {
id: '',
name: '',
path: '',
ownerId: '',
references: [],
type: undefined,
thumb: undefined,
owner: undefined,
fileName: undefined,
thumbPath: undefined,
uploadedOn: undefined,
};
/**
* Preparing Dto Field ...
*
* @param model
*/
export function prepareFileDtoFields(model?: XFileDto) {
//
if (isNullOrUndefined(model)) {
//
model = {
...defaultFileDto,
};
}
//
model = {
id: !isNullOrEmptyString(model.id) ? model.id : defaultFileDto.id,
name: !isNullOrEmptyString(model.name) ? model.name : defaultFileDto.name,
path: !isNullOrEmptyString(model.path) ? model.path : defaultFileDto.path,
ownerId: !isNullOrEmptyString(model.ownerId)
? model.ownerId
: defaultFileDto.ownerId,
references:
!isNullOrUndefined(model.references) && !hasChild(model.references)
? [...model.references]
: defaultFileDto.references,
type: !isNullOrUndefined(model.type) ? model.type : defaultFileDto.type,
thumb: !isNullOrEmptyString(model.thumb)
? model.thumb
: defaultFileDto.thumb,
owner: !isNullOrUndefined(model.owner)
? { ...model.owner }
: defaultFileDto.owner,
fileName: !isNullOrEmptyString(model.fileName)
? model.fileName
: defaultFileDto.fileName,
thumbPath: !isNullOrEmptyString(model.thumbPath)
? model.thumbPath
: defaultFileDto.thumbPath,
uploadedOn: !isNullOrUndefined(model.uploadedOn)
? model.uploadedOn
: defaultFileDto.uploadedOn,
};
//
return model;
}
/**
* Check Model is Default or not ...
*
* @param model
*/
export function isDefaultFileDto(model?: XFileDto) {
return isSameObject(prepareFileDtoFields(model), defaultFileDto);
}
/**
* Model Type Guard ...
*/
export const isXFileDto = typeGuard<XFileDto>([
'id',
'name',
'ownerId',
'type',
'uploadedOn',
'path',
]);
/**
* Converts a FileDto to Entity ...
*
* @param value
* @returns
*/
export function fileDtoToEntity(value: XFileDto) {
//
let result: XFileEntity = undefined;
//
if (!isNullOrUndefined(value) && isXFileDto(value)) {
//
const references = references2String(value.references);
result = {
id: value.id,
type: value.type,
name: value.name,
thumb: value.thumb,
path: value.path,
thumbPath: value.thumbPath,
uploadedOn: value.uploadedOn,
fileName: value.fileName,
ownerId: value.ownerId,
references,
};
}
//
return result;
}
/**
* Converts a FileEntity to Dto ...
*
* @param value
* @param owner
* @returns
*/
export function fileEntityToDto(
value: XFileEntity,
owner: XPersonDto = undefined
) {
//
let result: XFileDto = undefined;
//
if (!isNullOrUndefined(value) && isXFileDto(value)) {
//
const references = parseXReferences<string>(value.references);
result = {
id: value.id,
type: value.type,
name: value.name,
thumb: value.thumb,
path: value.path,
thumbPath: value.thumbPath,
uploadedOn: value.uploadedOn,
fileName: value.fileName,
ownerId: value.ownerId,
owner,
references,
};
}
//
return result;
}
@@ -0,0 +1,24 @@
import { Injectable } from "@angular/core";
import { XFileEntity } from "../models/x-file.dto";
import { XBaseEntityPushService } from "x-framework-push-service";
import { HttpTransportType, ITransport } from "@microsoft/signalr";
@Injectable({
providedIn: 'root'
})
export class XFileEntityPushService extends XBaseEntityPushService<XFileEntity> {
//
//#region Abstracts ...
hubName(): string {
return 'fileEntityHub';
}
requiredAccessToken(): boolean {
return true;
}
transportType(): HttpTransportType | ITransport {
return HttpTransportType.LongPolling;
}
//#endregion
}
@@ -0,0 +1,39 @@
import { Router } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { Inject, Injectable } from '@angular/core';
import { XFileEntity } from '../models/x-file.dto';
import { XApiEndPoint } from '../../typings/x-endpoint.typings';
import { XBaseEntityService } from '../../base/x-base-entity.service';
import { X_API_CONFIG, XApiConfiguration } from 'x-framework-identity-sdk';
import { X_SAHERELM_API_SDK_CONFIG } from '../../tokens/x-injectable-tokens';
import { XSaherElmApiSDKConfig } from '../../config/x-saherelm-api-sdk.config';
/**
* Provides all Entity Actions as a Service ...
*/
@Injectable({
providedIn: 'root',
})
export class XFileEntityService extends XBaseEntityService<
XFileEntity,
string
> {
//
//#region Constructor ...
constructor(
protected router: Router,
protected httpClient: HttpClient,
@Inject(X_SAHERELM_API_SDK_CONFIG) config: XSaherElmApiSDKConfig,
@Inject(X_API_CONFIG) apiConfig: XApiConfiguration
) {
super(
XApiEndPoint.FilesEntity,
true,
true,
httpClient,
config,
apiConfig
);
}
//#endregion
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,21 @@
import { Injectable } from '@angular/core';
import { XFileEntityService } from './services/x-file.entity.service';
import { XFileProviderService } from './services/x-file.provider.service';
import { XFileEntityPushService } from './services/x-file.entity.push.service';
/**
* Export All Provided File related Services ...
*/
@Injectable({
providedIn: 'root',
})
export class XFileServices {
//
//#region Constructor ...
public constructor(
public fileEntityService: XFileEntityService,
public fileProviderService: XFileProviderService,
public fileEntityPushService: XFileEntityPushService
) {}
//#endregion
}
@@ -0,0 +1,29 @@
/**
* All Available EndPoint Routes ...
*/
export enum XFileServiceRoute {
All = 'All',
Upload = '',
Remove = '',
Get = '{id}',
Query = 'Query',
GetTags = '{id}/Tags',
QueryOwned = 'Query/Owned',
StreamById = '{id}/Stream/ById',
AttachTags = '{id}/Tags/AttachMany',
DetachTags = '{id}/Tags/DetachMany',
DownloadById = '{id}/Download/ById',
StreamByName = '{name}/Stream/ByName',
DownloadByName = '{id}/Download/ByName',
}
/**
* All Params Which Used in Related Services ...
*/
export enum XFileParam {
Id = 'id',
Ids = 'ids',
Tags = 'tags',
Name = 'name',
Files = 'files',
}
@@ -0,0 +1,13 @@
import { Injectable } from '@angular/core';
import { XBaseGuard } from '../base/x-base.guard';
import { XAvailableRoles } from '../typings/x-role.typings';
@Injectable({
providedIn: 'root',
})
export class AdminOrAgentGuard extends XBaseGuard {
roles = [
XAvailableRoles.Admin,
XAvailableRoles.Agent
];
}
@@ -0,0 +1,10 @@
import { Injectable } from '@angular/core';
import { XBaseGuard } from '../base/x-base.guard';
import { XAvailableRoles } from '../typings/x-role.typings';
@Injectable({
providedIn: 'root',
})
export class AdminGuard extends XBaseGuard {
roles = XAvailableRoles.Admin;
}
@@ -0,0 +1,10 @@
import { Injectable } from '@angular/core';
import { XBaseGuard } from '../base/x-base.guard';
import { XAvailableRoles } from '../typings/x-role.typings';
@Injectable({
providedIn: 'root',
})
export class AgentGuard extends XBaseGuard {
roles = XAvailableRoles.Agent;
}
@@ -0,0 +1,10 @@
import { Injectable } from '@angular/core';
import { XBaseGuard } from '../base/x-base.guard';
import { XAvailableRoles } from '../typings/x-role.typings';
@Injectable({
providedIn: 'root',
})
export class UserGuard extends XBaseGuard {
roles = XAvailableRoles.User;
}
@@ -0,0 +1,80 @@
import {
XBaseDto,
typeGuard,
isSameObject,
isNullOrUndefined,
isNullOrEmptyString,
} from 'x-framework-core';
/**
* Simply Represent a User ...
*/
export interface XPersonDto extends XBaseDto {
username: string;
firstname: string;
lastname: string;
avatar: string;
}
/**
* Default Model ...
*/
export const defaultPersonDto: XPersonDto = {
username: '',
firstname: '',
lastname: '',
avatar: '',
};
/**
* Prepare Model Fields ...
*
* @param model
* @returns
*/
export function preparePersonDtoFields(model?: XPersonDto) {
//
if (isNullOrUndefined(model)) {
model = {
...defaultPersonDto,
};
}
//
model = {
avatar: isNullOrEmptyString(model.avatar)
? defaultPersonDto.avatar
: model.avatar,
username: isNullOrEmptyString(model.username)
? defaultPersonDto.username
: model.username,
lastname: isNullOrEmptyString(model.lastname)
? defaultPersonDto.lastname
: model.lastname,
firstname: isNullOrEmptyString(model.firstname)
? defaultPersonDto.firstname
: model.firstname,
};
//
return model;
}
/**
* Check Model is Default or not ...
*
* @param model
* @returns
*/
export function isDefaultPersonDto(model?: XPersonDto) {
return isSameObject(preparePersonDtoFields(model), defaultPersonDto);
}
/**
* Model Type Guard ...
*/
export const isXPersonDto = typeGuard<XPersonDto>([
'username',
'firstname',
'lastname',
]);
@@ -0,0 +1,213 @@
import {
nameof,
toNumber,
XBaseDto,
hasChild,
toXString,
typeGuard,
isSameObject,
toListString,
parseListString,
isNullOrUndefined,
isNullOrEmptyString,
} from 'x-framework-core';
export interface XReferenceDto<T> extends XBaseDto {
index: number;
providedFor: string;
referencedTo: T;
}
/**
* Model Type Guard ...
*/
export const isXReferenceDto = typeGuard<XReferenceDto<any>>([
'index',
'providedFor',
'referencedTo',
]);
export const defaultReferenceDto: XReferenceDto<any> = {
index: 0,
providedFor: '',
referencedTo: undefined,
};
export function prepareReferenceDtoFields(model?: XReferenceDto<any>) {
//
if (isNullOrUndefined(model)) {
//
model = {
...defaultReferenceDto,
};
}
//
model = {
index: !isNullOrUndefined(model.index)
? model.index
: defaultReferenceDto.index,
referencedTo: !isNullOrUndefined(model.referencedTo)
? model.referencedTo
: defaultReferenceDto.referencedTo,
providedFor: !isNullOrEmptyString(model.providedFor)
? model.providedFor
: defaultReferenceDto.providedFor,
};
//
return model;
}
export function isDefaultReferenceDto(model?: XReferenceDto<any>) {
return isSameObject(prepareReferenceDtoFields(model), defaultReferenceDto);
}
/**
* Converts any object to XReferenceDto<T> ...
*
* @param value
* @returns
*/
export function parseXReferenceDto<T>(value: any) {
//
let result: XReferenceDto<T> = undefined;
//
let isPassed = false;
isPassed =
!isNullOrUndefined(value) &&
Object.keys(value).includes(nameof<XReferenceDto<T>>('index')) &&
Object.keys(value).includes(nameof<XReferenceDto<T>>('referencedTo')) &&
Object.keys(value).includes(nameof<XReferenceDto<T>>('providedFor'));
if (isPassed) {
//
result = {
index: toNumber(value.index),
providedFor: toXString(value.providedFor),
referencedTo: value.referencedTo as unknown as T,
};
}
//
return result;
}
/**
* Parse an String to XReferenceDto<T> ...
*
* @param value
* @returns
*/
export function parseXReference<T = any>(value: string) {
//
var result: XReferenceDto<T> = undefined;
//
if (!isNullOrEmptyString(value)) {
//
let parts = parseListString(value, '_');
let isValid =
!isNullOrUndefined(parts) && hasChild(parts) && parts.length >= 3;
//
if (isValid) {
//
result = {
index: toNumber(parts[2]),
referencedTo: parts[1] as unknown as T,
providedFor: toXString(parts[0]),
};
}
}
//
return result;
}
/**
* Parse References List From String ...
*
* @param value
* @returns
*/
export function parseXReferences<T = any>(value: string) {
//
let result: Array<XReferenceDto<T>> = [];
//
if (!isNullOrEmptyString(value)) {
//
let parts = parseListString(value);
let isValid = !isNullOrUndefined(parts) && hasChild(parts);
if (isValid) {
//
parts.forEach((part) => {
//
var reference = parseXReference<T>(part);
isValid = !isNullOrUndefined(reference);
if (isValid) {
result.push(reference);
}
});
}
}
//
return result;
}
/**
* Converts an XReferenceDto<T> to String Reperesentation ...
*
* @param value
* @param separator
* @returns
*/
export function reference2String<T = any>(
value: XReferenceDto<T>,
separator: string = '_'
) {
//
let result: string = undefined;
//
if (!isNullOrUndefined(value)) {
result = `${value.providedFor}${separator}${value.referencedTo}${separator}${value.index}`;
}
//
return result;
}
/**
* Converts references Array to String Representation ...
*
* @param value
* @param separator
* @returns
*/
export function references2String<T = any>(
value: Array<XReferenceDto<T>>,
separator: string = ','
) {
//
let result: string = undefined;
//
let arr: Array<string> = [];
if (!isNullOrUndefined(value) && hasChild(value)) {
//
value.forEach((v) => {
//
let refStr = reference2String(v);
arr.push(refStr);
});
}
//
result = toListString(arr, separator);
//
return result;
}
@@ -0,0 +1,55 @@
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Inject, Injectable } from '@angular/core';
import { XAccountService } from 'x-framework-identity-sdk';
import { isNullOrUndefined, XBaseService } from 'x-framework-core';
import { IXPushServiceTokenFetcher } from 'x-framework-push-service';
import { X_SAHERELM_API_SDK_CONFIG } from '../tokens/x-injectable-tokens';
import { XSaherElmApiSDKConfig } from '../config/x-saherelm-api-sdk.config';
@Injectable({
providedIn: 'root',
})
export class XPushTokenFetcherService
extends XBaseService
implements IXPushServiceTokenFetcher
{
//
//#region Props ...
token: string;
token$: Observable<string> = this.accountsService.state$.pipe(
map((state) => (isNullOrUndefined(state) ? null : state.accessToken))
);
//#endregion
//
//#region Constructor ...
constructor(
//
@Inject(X_SAHERELM_API_SDK_CONFIG)
public config: XSaherElmApiSDKConfig,
//
public accountsService: XAccountService
) {
super(config);
//
accountsService.state$.subscribe((state) => {
//
if (isNullOrUndefined(state)) {
this.token = null;
} else {
this.token = state.accessToken;
}
});
}
//#endregion
/**
* retrieve current user's access token ...
* @returns token
*/
public getToken(): string {
return this.token;
}
}
@@ -0,0 +1,192 @@
import {
XBaseDto,
hasChild,
typeGuard,
isSameObject,
XBaseNumberIDDto,
isNullOrUndefined,
isNullOrEmptyString,
} from 'x-framework-core';
/**
* Represent a Locale Resource ...
*/
export interface XStringDto extends XBaseNumberIDDto {
language: string;
resourceTitle: string;
translatedValue: string;
}
/**
* Default Model ...
*/
export const defaultStringDto: XStringDto = {
id: undefined,
language: '',
resourceTitle: '',
translatedValue: '',
};
/**
* Prepare Model Fields ...
*
* @param model
* @returns
*/
export function prepareStringDtoFields(model?: XStringDto) {
//
if (isNullOrUndefined(model)) {
model = {
...defaultStringDto,
};
}
//
model = {
id: isNullOrUndefined(model.id) ? defaultStringDto.id : model.id,
language: isNullOrEmptyString(model.language)
? defaultStringDto.language
: model.language,
resourceTitle: isNullOrEmptyString(model.resourceTitle)
? defaultStringDto.resourceTitle
: model.resourceTitle,
translatedValue: isNullOrEmptyString(model.translatedValue)
? defaultStringDto.translatedValue
: model.translatedValue,
};
//
return model;
}
/**
* Check Model is Default or not ...
*
* @param model
* @returns
*/
export function isDefaultStringDto(model?: XStringDto) {
return isSameObject(prepareStringDtoFields(model), defaultStringDto);
}
/**
* Simply Represent a Locale ...
*/
export interface XLocaleResourceDto extends XBaseDto {
language: string;
value: string;
}
/**
* Default Model ...
*/
export const defaultLocaleResourceDto: XLocaleResourceDto = {
value: '',
language: '',
};
/**
* Prepare Model Fields ...
*
* @param model
* @returns
*/
export function prepareLocaleResourceDtoFields(model?: XLocaleResourceDto) {
//
if (isNullOrUndefined(model)) {
model = {
...defaultLocaleResourceDto,
};
}
//
model = {
value: isNullOrEmptyString(model.value)
? defaultLocaleResourceDto.value
: model.value,
language: isNullOrEmptyString(model.language)
? defaultLocaleResourceDto.language
: model.language,
};
//
return model;
}
/**
* Check Model is Default or not ...
*
* @param model
* @returns
*/
export function isDefaultLocaleResourceDto(model?: XLocaleResourceDto) {
return isSameObject(
prepareLocaleResourceDtoFields(model),
defaultLocaleResourceDto
);
}
/**
* Represent a Locale by it's Resources ...
*/
export interface XResourceDto extends XBaseDto {
resource: string;
locales: Array<XLocaleResourceDto>;
}
/**
* Default Model ...
*/
export const defaultResourceDto: XResourceDto = {
resource: '',
locales: [],
};
/**
* Prepare Model Fields ...
*
* @param model
* @returns
*/
export function prepareResourceDtoFields(model?: XResourceDto) {
//
if (isNullOrUndefined(model)) {
model = {
...defaultResourceDto,
};
}
//
model = {
resource: isNullOrEmptyString(model.resource)
? defaultResourceDto.resource
: model.resource,
locales:
isNullOrUndefined(model.locales) || !hasChild(model.locales)
? defaultResourceDto.locales
: model.locales.map((l) => prepareLocaleResourceDtoFields(l)),
};
//
return model;
}
/**
* Check Model is Default or not ...
*
* @param model
* @returns
*/
export function isDefaultResourceDto(model?: XResourceDto) {
return isSameObject(prepareResourceDtoFields(model), defaultResourceDto);
}
/**
* Model Type Guard ...
*/
export const isXStringDto = typeGuard<XStringDto>([
'id',
'language',
'resourceTitle',
'translatedValue',
]);
@@ -0,0 +1,24 @@
import { Injectable } from '@angular/core';
import { XStringDto } from '../models/x-string.dto';
import { XBaseEntityPushService } from 'x-framework-push-service';
import { HttpTransportType, ITransport } from '@microsoft/signalr';
@Injectable({
providedIn: 'root',
})
export class XStringEntityPushService extends XBaseEntityPushService<XStringDto> {
//
//#region Abstracts ...
hubName(): string {
return 'stringEntityHub';
}
requiredAccessToken(): boolean {
return true;
}
transportType(): HttpTransportType | ITransport {
return HttpTransportType.LongPolling;
}
//#endregion
}
@@ -0,0 +1,39 @@
import { Router } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { Inject, Injectable } from '@angular/core';
import { XStringDto } from '../models/x-string.dto';
import { XApiEndPoint } from '../../typings/x-endpoint.typings';
import { XBaseEntityService } from '../../base/x-base-entity.service';
import { X_API_CONFIG, XApiConfiguration } from 'x-framework-identity-sdk';
import { X_SAHERELM_API_SDK_CONFIG } from '../../tokens/x-injectable-tokens';
import { XSaherElmApiSDKConfig } from '../../config/x-saherelm-api-sdk.config';
/**
* Provides all Entity Actions as a Service ...
*/
@Injectable({
providedIn: 'root',
})
export class XStringEntityService extends XBaseEntityService<
XStringDto,
number
> {
//
//#region Constructor ...
constructor(
protected router: Router,
protected httpClient: HttpClient,
@Inject(X_SAHERELM_API_SDK_CONFIG) config: XSaherElmApiSDKConfig,
@Inject(X_API_CONFIG) apiConfig: XApiConfiguration
) {
super(
XApiEndPoint.StringsEntity,
true,
true,
httpClient,
config,
apiConfig
);
}
//#endregion
}
@@ -0,0 +1,21 @@
import { Injectable } from '@angular/core';
import { XStringEntityService } from './services/x-string.entity.service';
import { XStringProviderService } from './services/x-string.provider.service';
import { XStringEntityPushService } from './services/x-string.entity.push.service';
/**
* Export All Provided String related Services ...
*/
@Injectable({
providedIn: 'root',
})
export class XStringServices {
//
//#region Constructor ...
public constructor(
public stringEntityService: XStringEntityService,
public stringProviderService: XStringProviderService,
public stringEntityPushService: XStringEntityPushService
) {}
//#endregion
}
@@ -0,0 +1,51 @@
/**
* All Available EndPoint Routes ...
*/
export enum XStringsServiceRoute {
//
// Retrievers ...
Get = '',
Resources = 'Resources',
Languages = 'Languages',
AsResource = 'AsResource',
ResourceValue = 'ResourceValue',
IsResourceExists = 'IsResourceExists',
//
// Query ...
QueryResourceIds = 'QueryResourceIds',
QueryLocaleResources = 'QueryLocaleResources',
QueryLanguageResourcs = 'QueryLanguageResourcs',
//
// Add ...
Add = 'Add',
AddModel = 'AddModel',
AddLocale = 'AddLocale',
AddResource = 'AddResource',
AddOrUpdate = 'AddOrUpdate',
AddOrUpdateModel = 'AddOrUpdateModel',
AddOrUpdateLocale = 'AddOrUpdateLocale',
//
// Update ...
Update = 'Update',
UpdateModel = 'UpdateModel',
UpdateLocale = 'UpdateLocale',
//
// Remove ...
Remove = 'Remove',
RemoveLocales = 'RemoveLocales',
RemoveResource = 'RemoveResource',
RemoveLanguage = 'RemoveLanguage',
}
/**
* All Params Which Used in Related Services ...
*/
export enum XStringParam {
Value = 'value',
Resource = 'resource',
Language = 'language',
}
@@ -0,0 +1,138 @@
import {
hasChild,
XBaseDto,
typeGuard,
isSameObject,
isNullOrUndefined,
isNullOrEmptyString,
} from 'x-framework-core';
import {
XReferenceDto,
parseXReferences,
references2String,
} from '../../models/x-reference.dto';
/**
* Represent Specified Tag ...
*/
export interface XTagEntity extends XBaseDto {
id: number;
tag: string;
references: string;
}
/**
* Represent Specified Tag ...
*/
export interface XTagDto extends XBaseDto {
id: number;
tag: string;
references: Array<XReferenceDto<string>>;
}
/**
* Default Model ...
*/
export const defaultTagDto: XTagDto = {
id: 0,
tag: undefined,
references: [],
};
/**
* Prepare Model Fields ...
*
* @param model
* @returns
*/
export function prepareTagDtoFields(model?: XTagDto) {
//
if (isNullOrUndefined(model)) {
//
model = {
...defaultTagDto,
};
}
//
model = {
//
id:
!isNullOrUndefined(model.id) && model.id > 0
? model.id
: defaultTagDto.id,
tag: !isNullOrEmptyString(model.tag) ? model.tag : defaultTagDto.tag,
references:
!isNullOrUndefined(model.references) && hasChild(model.references)
? [...model.references]
: defaultTagDto.references,
};
//
return model;
}
/**
* Check Model is Default or not ...
*
* @param model
* @returns
*/
export function isDefaultTagDto(model?: XTagDto) {
return isSameObject(prepareTagDtoFields(model), defaultTagDto);
}
/**
* Model Type Guard ...
*/
export const isXTagDto = typeGuard<XTagDto>(['id', 'tag']);
/**
* Tag Dto to Tag Entity ...
*
* @param value
* @returns
*/
export function tagDto2Entity(value: XTagDto) {
//
let result: XTagEntity = undefined;
//
if (!isNullOrUndefined(value) && isXTagDto(value)) {
//
const references = references2String(value.references);
result = {
id: value.id,
tag: value.tag,
references,
};
}
//
return result;
}
/**
* Tag Entity to Tag Dto ...
*
* @param value
* @returns
*/
export function tagEntity2Dto(value: XTagEntity) {
//
let result: XTagDto = undefined;
//
if (!isNullOrUndefined(value) && isXTagDto(value)) {
//
const references = parseXReferences<string>(value.references);
result = {
id: value.id,
tag: value.tag,
references,
};
}
//
return result;
}
@@ -0,0 +1,32 @@
import { Injectable } from '@angular/core';
import { XTagEntity } from '../models/x-tag.dto';
import { XBaseEntityPushService } from 'x-framework-push-service';
import { HttpTransportType, ITransport } from '@microsoft/signalr';
@Injectable({
providedIn: 'root',
})
export class XTagEntityPushService extends XBaseEntityPushService<XTagEntity> {
//
//#region Props ...
//#endregion
//
//#region Abstracts ...
hubName(): string {
return 'tagEntityHub';
}
requiredAccessToken(): boolean {
return true;
}
transportType(): HttpTransportType | ITransport {
return HttpTransportType.LongPolling;
}
registerSubjects(): void {
super.registerSubjects();
}
//#endregion
}
@@ -0,0 +1,39 @@
import { Router } from '@angular/router';
import { XTagEntity } from '../models/x-tag.dto';
import { HttpClient } from '@angular/common/http';
import { Inject, Injectable } from '@angular/core';
import { XApiEndPoint } from '../../typings/x-endpoint.typings';
import { XBaseEntityService } from '../../base/x-base-entity.service';
import { X_API_CONFIG, XApiConfiguration } from 'x-framework-identity-sdk';
import { X_SAHERELM_API_SDK_CONFIG } from '../../tokens/x-injectable-tokens';
import { XSaherElmApiSDKConfig } from '../../config/x-saherelm-api-sdk.config';
/**
* Provides all Entity Actions as a Service ...
*/
@Injectable({
providedIn: 'root',
})
export class XTagEntityService extends XBaseEntityService<
XTagEntity,
string
> {
//
//#region Constructor ...
constructor(
protected router: Router,
protected httpClient: HttpClient,
@Inject(X_SAHERELM_API_SDK_CONFIG) config: XSaherElmApiSDKConfig,
@Inject(X_API_CONFIG) apiConfig: XApiConfiguration
) {
super(
XApiEndPoint.TagsEntity,
true,
true,
httpClient,
config,
apiConfig
);
}
//#endregion
}
@@ -0,0 +1,654 @@
import {
toArray,
hasChild,
XValidators,
XOneOrManyType,
isNullOrEmptyString,
} from 'x-framework-core';
import {
HttpEvent,
HttpParams,
HttpClient,
HttpHeaders,
HttpResponse,
} from '@angular/common/http';
import {
XQueryDto,
X_API_CONFIG,
XBaseApiService,
XQueryResultDto,
XApiConfiguration,
} from 'x-framework-identity-sdk';
import { Observable } from 'rxjs';
import { Router } from '@angular/router';
import { XTagDto } from '../models/x-tag.dto';
import { Inject, Injectable } from '@angular/core';
import { fillRouteParams } from '../../tools/x-route.tools';
import { XTagParam, XTagServiceRoute } from '../x-tag.typings';
import { XApiEndPoint } from '../../typings/x-endpoint.typings';
import { X_SAHERELM_API_SDK_CONFIG } from '../../tokens/x-injectable-tokens';
import { XSaherElmApiSDKConfig } from '../../config/x-saherelm-api-sdk.config';
import { applyConnectionIdToHeader } from '../../typings/x-push-provider.typings';
/**
* Provides all Provider Actions as a Service ...
*/
@Injectable({
providedIn: 'root',
})
export class XTagProviderService extends XBaseApiService {
//
//#region Constructor ...
constructor(
protected router: Router,
protected httpClient: HttpClient,
@Inject(X_SAHERELM_API_SDK_CONFIG) config: XSaherElmApiSDKConfig,
@Inject(X_API_CONFIG) apiConfig: XApiConfiguration
) {
super(XApiEndPoint.TagsService, true, true, httpClient, config, apiConfig);
}
//#endregion
//
//#region Actions ...
//
//#region Add ...
/**
* Add Model ...
*
* @param model
* @param connectionId
* @param observe
* @param reportProgress
*/
public add(
model: XTagDto,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<XTagDto>;
public add(
model: XTagDto,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<XTagDto>>;
public add(
model: XTagDto,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<XTagDto>>;
public add(
model: XTagDto,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(model);
XValidators.validateNotEmpty(model.tag);
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute(XTagServiceRoute.Add);
//
// Prepare Result ...
return this.httpClient.post<XTagDto>(endPointPath, model, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region Update ...
/**
* Update Model ...
*
* @param id
* @param model
* @param connectionId
* @param observe
* @param reportProgress
*/
public update(
id: number,
model: XTagDto,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<XTagDto>;
public update(
id: number,
model: XTagDto,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<XTagDto>>;
public update(
id: number,
model: XTagDto,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<XTagDto>>;
public update(
id: number,
model: XTagDto,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(model);
XValidators.validateNotEmpty(model.tag);
//
if (model.id !== id) {
model.id = id;
}
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint
const endPointPath = fillRouteParams(
//
// Base Route on Endpoint ...
this.getActionRoute(XTagServiceRoute.Update),
//
// Params ...
[
{
key: XTagParam.Id,
value: id.toString(),
},
]
);
//
// Prepare Result ...
return this.httpClient.put<XTagDto>(endPointPath, model, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region Remove ...
/**
* Remove Model ...
*
* @param id
* @param connectionId
* @param observe
* @param reportProgress
*/
public remove(
id: number,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<XTagDto>;
public remove(
id: number,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<XTagDto>>;
public remove(
id: number,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<XTagDto>>;
public remove(
id: number,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint ...
const endPointPath = fillRouteParams(
this.getActionRoute(XTagServiceRoute.Remove),
[
{
key: XTagParam.Id,
value: id.toString(),
},
]
);
//
// Prepare Result ...
return this.httpClient.delete<XTagDto>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region Get ...
/**
* Get Specified Model ...
*/
public get(
id: number,
observe?: 'body',
reportProgress?: boolean
): Observable<XTagDto>;
public get(
id: number,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<XTagDto>>;
public get(
id: number,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<XTagDto>>;
public get(
id: number,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint ...
const endPointPath = fillRouteParams(
//
// Base Route on Endpoint ...
this.getActionRoute(XTagServiceRoute.Get),
//
// Params ...
[
{
key: XTagParam.Id,
value: id.toString(),
},
]
);
//
// Prepare Result ...
return this.httpClient.get<XTagDto>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region GetTag ...
/**
* Get Specified Model by Providing Label ...
*/
public getTag(
tag: string,
observe?: 'body',
reportProgress?: boolean
): Observable<XTagDto>;
public getTag(
tag: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<XTagDto>>;
public getTag(
tag: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<XTagDto>>;
public getTag(
tag: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotEmpty(tag);
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Attach Tag to Params ...
params = this.addCustomParam(params, {
key: XTagParam.Tag,
value: tag
});
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint ...
const endPointPath = this.getActionRoute(XTagServiceRoute.GetTag);
//
// Prepare Result ...
return this.httpClient.get<XTagDto>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region All ...
/**
* Retrieve all Exists Models ...
*
* @param observe
* @param reportProgress
*/
public all(
observe?: 'body',
reportProgress?: boolean
): Observable<Array<XTagDto>>;
public all(
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<Array<XTagDto>>>;
public all(
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<Array<XTagDto>>>;
public all(
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Preparing HttpParams ...
//
// Prepare Endpoint
const endPointPath = this.getActionRoute(XTagServiceRoute.All);
//
// Prepare Result ...
return this.httpClient.get<Array<XTagDto>>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region FindOne ...
/**
* Detect Specified Model by Providing Label Query ...
*/
public findOne(
query: string,
observe?: 'body',
reportProgress?: boolean
): Observable<XTagDto>;
public findOne(
query: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<XTagDto>>;
public findOne(
query: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<XTagDto>>;
public findOne(
query: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotEmpty(query);
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Attach Tag to Params ...
params = this.addCustomParam(params, {
key: XTagParam.Query,
value: query
});
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint ...
const endPointPath = this.getActionRoute(XTagServiceRoute.FindOne);
//
// Prepare Result ...
return this.httpClient.get<XTagDto>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region FindMany ...
/**
* Detect Specified Models by Providing Label Query ...
*/
public findMany(
query: string,
observe?: 'body',
reportProgress?: boolean
): Observable<Array<XTagDto>>;
public findMany(
query: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<Array<XTagDto>>>;
public findMany(
query: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<Array<XTagDto>>>;
public findMany(
query: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotEmpty(query);
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Attach Tag to Params ...
params = this.addCustomParam(params, {
key: XTagParam.Query,
value: query
});
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint ...
const endPointPath = this.getActionRoute(XTagServiceRoute.FindMany);
//
// Prepare Result ...
return this.httpClient.get<Array<XTagDto>>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region Query ...
/**
* Query Model ...
*
* @param query
* @param observe
* @param reportProgress
*/
public query(
query: XQueryDto,
observe?: 'body',
reportProgress?: boolean
): Observable<XQueryResultDto<XTagDto>>;
public query(
query: XQueryDto,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<XQueryResultDto<XTagDto>>>;
public query(
query: XQueryDto,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<XQueryResultDto<XTagDto>>>;
public query(
query: XQueryDto,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotNull(query);
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Preparing HttpParams ...
params = this.generateXQueryHttpParams(query);
//
// Prepare Endpoint
const endPointPath = this.getActionRoute(XTagServiceRoute.Query);
//
// Prepare Result ...
return this.httpClient.get<XQueryResultDto<XTagDto>>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//#endregion
}
@@ -0,0 +1,21 @@
import { Injectable } from '@angular/core';
import { XTagEntityService } from './services/x-tag.entity.service';
import { XTagProviderService } from './services/x-tag.provider.service';
import { XTagEntityPushService } from './services/x-tag.entity.push.service';
/**
* Export All Provided Tag related Services ...
*/
@Injectable({
providedIn: 'root',
})
export class XTagServices {
//
//#region Constructor ...
public constructor(
public tagEntityService: XTagEntityService,
public tagProviderService: XTagProviderService,
public tagEntityPushService: XTagEntityPushService
) {}
//#endregion
}
@@ -0,0 +1,23 @@
/**
* All Available EndPoint Routes ...
*/
export enum XTagServiceRoute {
Add = '',
All = 'All',
Get = '{id}',
Update = '{id}',
Remove = '{id}',
Query = 'Query',
GetTag = 'GetTag',
FindOne = 'FindOne',
FindMany = 'FindMany',
}
/**
* All Params Which Used in Related Services ...
*/
export enum XTagParam {
Id = 'id',
Tag = 'tag',
Query = 'query'
}
@@ -0,0 +1,507 @@
import {
HttpEvent,
HttpClient,
HttpParams,
HttpHeaders,
HttpResponse,
} from '@angular/common/http';
import {
X_API_CONFIG,
XBaseApiService,
XApiConfiguration,
} from 'x-framework-identity-sdk';
import { Observable } from 'rxjs';
import { Router } from '@angular/router';
import { Inject, Injectable } from '@angular/core';
import { XLocale, XValidators } from 'x-framework-core';
import { fillRouteParams } from '../../tools/x-route.tools';
import { XApiEndPoint } from '../../typings/x-endpoint.typings';
import { XTermsParam, XTermsServiceRoute } from '../x-terms.typings.dto';
import { X_SAHERELM_API_SDK_CONFIG } from '../../tokens/x-injectable-tokens';
import { XSaherElmApiSDKConfig } from '../../config/x-saherelm-api-sdk.config';
import { applyConnectionIdToHeader } from '../../typings/x-push-provider.typings';
/**
* Provides all Provider Actions as a Service ...
*/
@Injectable({
providedIn: 'root',
})
export class XTermsProviderService extends XBaseApiService {
//
//#region Constructor ...
constructor(
protected router: Router,
protected httpClient: HttpClient,
@Inject(X_SAHERELM_API_SDK_CONFIG) config: XSaherElmApiSDKConfig,
@Inject(X_API_CONFIG) apiConfig: XApiConfiguration
) {
super(
XApiEndPoint.TermsAndConditions,
true,
true,
httpClient,
config,
apiConfig
);
}
//#endregion
//
//#region Actions ...
//
//#region Get ...
/**
* Get Specified Languages Terms and Conditions ...
*
* @param language
* @param observe
* @param reportProgress
*/
public get(
language: XLocale | string,
observe?: 'body',
reportProgress?: boolean
): Observable<string>;
public get(
language: XLocale | string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<string>>;
public get(
language: XLocale | string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<string>>;
public get(
language: XLocale | string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotEmpty(language);
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint ...
const endPointPath = fillRouteParams(
//
// Base Route on Endpoint ...
this.getActionRoute(XTermsServiceRoute.Get),
//
// Params ...
[
{
key: XTermsParam.Language,
value: language,
},
]
);
//
// Prepare Result ...
return this.httpClient.get<string>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region Languages ...
/**
* Get Languages Lists which Contains Terms and Conditions ...
*
* @param observe
* @param reportProgress
*/
public getLanguages(
observe?: 'body',
reportProgress?: boolean
): Observable<Array<string>>;
public getLanguages(
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<Array<string>>>;
public getLanguages(
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<Array<string>>>;
public getLanguages(
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint ...
const endPointPath = this.getActionRoute(XTermsServiceRoute.Languages);
//
// Prepare Result ...
return this.httpClient.get<Array<string>>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region Has ...
/**
* Check Specified Languages Terms and Conditions Exists or not ...
*
* @param language
* @param observe
* @param reportProgress
*/
public has(
language: XLocale | string,
observe?: 'body',
reportProgress?: boolean
): Observable<Boolean>;
public has(
language: XLocale | string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<Boolean>>;
public has(
language: XLocale | string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<Boolean>>;
public has(
language: XLocale | string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotEmpty(language);
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
//
// Prepare Endpoint ...
const endPointPath = fillRouteParams(
//
// Base Route on Endpoint ...
this.getActionRoute(XTermsServiceRoute.Has),
//
// Params ...
[
{
key: XTermsParam.Language,
value: language,
},
]
);
//
// Prepare Result ...
return this.httpClient.get<boolean>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region Add ...
/**
* Add Terms and Conditions For Spevified Language ...
*
* @param language
* @param terms
* @param connectionId
* @param observe
* @param reportProgress
*/
public add(
language: XLocale | string,
terms: string,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<string>;
public add(
language: XLocale | string,
terms: string,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<string>>;
public add(
language: XLocale | string,
terms: string,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<string>>;
public add(
language: XLocale | string,
terms: string,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotEmpty(terms);
XValidators.validateNotEmpty(language);
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint ...
const endPointPath = fillRouteParams(
//
// Base Route on Endpoint ...
this.getActionRoute(XTermsServiceRoute.Add),
//
// Params ...
[
{
key: XTermsParam.Language,
value: language,
},
]
);
//
// Add terms Query String ...
params = this.addCustomParam(params, {
key: XTermsParam.Terms,
value: terms,
});
//
// Prepare Result ...
return this.httpClient.post<string>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region Update ...
/**
* Update Terms and Conditions For Spevified Language ...
*
* @param language
* @param terms
* @param connectionId
* @param observe
* @param reportProgress
*/
public update(
language: XLocale | string,
terms: string,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<boolean>;
public update(
language: XLocale | string,
terms: string,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<boolean>>;
public update(
language: XLocale | string,
terms: string,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<boolean>>;
public update(
language: XLocale | string,
terms: string,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotEmpty(terms);
XValidators.validateNotEmpty(language);
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint ...
const endPointPath = fillRouteParams(
//
// Base Route on Endpoint ...
this.getActionRoute(XTermsServiceRoute.Update),
//
// Params ...
[
{
key: XTermsParam.Language,
value: language,
},
]
);
//
// Add terms Query String ...
params = this.addCustomParam(params, {
key: XTermsParam.Terms,
value: terms,
});
//
// Prepare Result ...
return this.httpClient.put<boolean>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//
//#region Remove ...
/**
* Remove Terms and Conditions For Spevified Language ...
*
* @param language
* @param connectionId
* @param observe
* @param reportProgress
*/
public remove(
language: XLocale | string,
connectionId?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<boolean>;
public remove(
language: XLocale | string,
connectionId?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<boolean>>;
public remove(
language: XLocale | string,
connectionId?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<boolean>>;
public remove(
language: XLocale | string,
connectionId?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
//
// Validate Args ...
XValidators.validateNotEmpty(language);
//
// Base Requirements ...
let params: HttpParams = null;
let headers: HttpHeaders = this.defaultHeaders;
//
// Authentication ...
headers = this.addAuthentication(headers);
headers = this.addAcceptJson(headers);
headers = this.addContentType(headers);
headers = applyConnectionIdToHeader(connectionId, headers);
//
// Prepare Endpoint ...
const endPointPath = fillRouteParams(
//
// Base Route on Endpoint ...
this.getActionRoute(XTermsServiceRoute.Remove),
//
// Params ...
[
{
key: XTermsParam.Language,
value: language,
},
]
);
//
// Prepare Result ...
return this.httpClient.delete<boolean>(endPointPath, {
withCredentials: this.apiConfig.withCredentials,
headers,
observe,
params,
reportProgress,
});
}
//#endregion
//#endregion
}
@@ -0,0 +1,169 @@
import { Subject } from 'rxjs';
import {
XBasePushService,
XBaseEntityPushAction,
IXPushServiceTokenFetcher,
XFrameworkPushServiceConfig,
X_FRAMEWORK_PUSH_SERVICE_CONFIG,
X_FRAMEWORK_PUSH_SERVICE_TOKEN_FETCHER,
} from 'x-framework-push-service';
import { parseJson } from 'x-framework-core';
import { Inject, Injectable, Optional } from '@angular/core';
import { XStringDto } from '../../strings/models/x-string.dto';
import { HttpTransportType, ITransport } from '@microsoft/signalr';
@Injectable({
providedIn: 'root',
})
export class XTermsPushService extends XBasePushService {
//
//#region Props ...
onTermsAdded$ = new Subject<{
model: XStringDto;
actorId: string;
}>();
onTermsDeleted$ = new Subject<{
model: XStringDto;
actorId: string;
}>();
onTermsUpdated$ = new Subject<{
model: XStringDto;
actorId: string;
}>();
//#endregion
//
//#region Constructor ...
constructor(
@Inject(X_FRAMEWORK_PUSH_SERVICE_CONFIG)
public config: XFrameworkPushServiceConfig,
@Optional()
@Inject(X_FRAMEWORK_PUSH_SERVICE_TOKEN_FETCHER)
public tokenFetcher?: IXPushServiceTokenFetcher
) {
super(config, tokenFetcher);
}
//#endregion
//
//#region Abstraction ...
hubName(): string {
return 'termsHub';
}
requiredAccessToken(): boolean {
return true;
}
transportType(): HttpTransportType | ITransport {
return HttpTransportType.LongPolling;
}
registerSubjects(): void {
super.registerSubjects();
//
this.onTermsAdded((model: XStringDto, actorId: string) => {
this.onTermsAdded$.next({ model, actorId });
});
//
this.onTermsDeleted((model: XStringDto, actorId: string) => {
this.onTermsDeleted$.next({ model, actorId });
});
//
this.onTermsUpdated((model: XStringDto, actorId: string) => {
this.onTermsUpdated$.next({ model, actorId });
});
}
//#endregion
//
//#region Event Listeners ...
//
//#region Onners ...
/**
* Register Terms Added Event Listener ...
*
* @param callback
*/
public onTermsAdded(callback: (model: XStringDto, actorId: string) => any) {
//
this.on(XBaseEntityPushAction.Add, (modelJson: string, actorId: string) => {
//
const model = parseJson<XStringDto>(modelJson);
callback(model, actorId);
});
}
/**
* Register Terms Deleted Event Listener ...
*
* @param callback
*/
public onTermsDeleted(callback: (model: XStringDto, actorId: string) => any) {
//
this.on(
XBaseEntityPushAction.Delete,
(modelJson: string, actorId: string) => {
//
const model = parseJson<XStringDto>(modelJson);
callback(model, actorId);
}
);
}
/**
* Register Terms Updated Event Listener ...
*
* @param callback
*/
public onTermsUpdated(callback: (model: XStringDto, actorId: string) => any) {
//
this.on(
XBaseEntityPushAction.Update,
(modelJson: string, actorId: string) => {
//
const model = parseJson<XStringDto>(modelJson);
callback(model, actorId);
}
);
}
//#endregion
//
//#region Offers ...
/**
* UnRegister Added Event Listener ...
*
* @param callback
*/
public offTermsAdded(callback?: (model: XStringDto, actorId: string) => any) {
this.off(XBaseEntityPushAction.Add, callback);
}
/**
* UnRegister Deleted Event Listener ...
*
* @param callback
*/
public offTermsDeleted(
callback?: (model: XStringDto, actorId: string) => any
) {
this.off(XBaseEntityPushAction.Delete, callback);
}
/**
* UnRegister Updated Event Listener ...
*
* @param callback
*/
public offTermsUpdated(
callback?: (model: XStringDto, actorId: string) => any
) {
this.off(XBaseEntityPushAction.Update, callback);
}
//#endregion
//#endregion
}
@@ -0,0 +1,19 @@
import { Injectable } from '@angular/core';
import { XTermsPushService } from './services/x-terms.push.service';
import { XTermsProviderService } from './services/x-terms.provider.service';
/**
* Export All Provided Terms related Services ...
*/
@Injectable({
providedIn: 'root',
})
export class XTermsServices {
//
//#region Constructor ...
public constructor(
public termsPushService: XTermsPushService,
public termsProviderService: XTermsProviderService
) {}
//#endregion
}
@@ -0,0 +1,19 @@
/**
* All Available EndPoint Routes ...
*/
export enum XTermsServiceRoute {
Add = 'Terms/{language}',
Get = 'Terms/{language}',
Update = 'Terms/{language}',
Remove = 'Terms/{language}',
Has = 'Terms/{language}/Has',
Languages = 'Terms/Languages',
}
/**
* All Params Which Used in Related Services ...
*/
export enum XTermsParam {
Terms = 'terms',
Language = 'language',
}
@@ -0,0 +1,6 @@
import { InjectionToken } from '@angular/core';
import { XSaherElmApiSDKConfig } from '../config/x-saherelm-api-sdk.config';
export const X_SAHERELM_API_SDK_CONFIG = new InjectionToken<XSaherElmApiSDKConfig>(
'x_config'
);
@@ -0,0 +1,22 @@
import { isArray, isObject } from 'x-framework-core';
/**
* since for better handling soft deleted in database from api side the deleted
* property added to all XEntities, for better comparing objects we have to delete it.
* this method do this for us ...
*
* @param model the input object
* @returns clear object
*/
export function prepareModel<T>(model: T) {
//
if (!isObject(model) || isArray(model)) {
return model;
}
//
delete (model as any)['deleted'];
//
return model;
}
@@ -0,0 +1,286 @@
import {
toArray,
hasChild,
XExceptionIDs,
throwException,
XOneOrManyType,
} from 'x-framework-core';
import { XUserProfileDto } from 'x-framework-identity-sdk';
import { XUserRoleInfo, XAvailableRoles } from '../typings/x-role.typings';
export function toRoleInfo(user: XUserProfileDto): XUserRoleInfo {
//
if (!user) {
return null;
}
//
const result: XUserRoleInfo = {
isAdmin: hasChild(user.roles) && user.roles.includes(XAvailableRoles.Admin),
isResponsibleManager:
hasChild(user.roles) &&
user.roles.includes(XAvailableRoles.ResponsibleManager),
isJournalist:
hasChild(user.roles) && user.roles.includes(XAvailableRoles.Journalist),
isChiefClerk:
hasChild(user.roles) && user.roles.includes(XAvailableRoles.ChiefClerk),
isChiefClerkAssistant:
hasChild(user.roles) &&
user.roles.includes(XAvailableRoles.ChiefClerkAssistant),
isActuary:
hasChild(user.roles) && user.roles.includes(XAvailableRoles.Actuary),
isActuaryAssistant:
hasChild(user.roles) &&
user.roles.includes(XAvailableRoles.ActuaryAssistant),
isReporter:
hasChild(user.roles) && user.roles.includes(XAvailableRoles.Reporter),
isReporterAssistant:
hasChild(user.roles) &&
user.roles.includes(XAvailableRoles.ReporterAssistant),
isAgent: hasChild(user.roles) && user.roles.includes(XAvailableRoles.Agent),
isUser: hasChild(user.roles) && user.roles.includes(XAvailableRoles.User),
};
//
return result;
}
export function toRoleInfoByRoles(roles: string[]): XUserRoleInfo {
//
if (!hasChild(roles)) {
return null;
}
//
const result: XUserRoleInfo = {
isAdmin: hasChild(roles) && roles.includes(XAvailableRoles.Admin),
isResponsibleManager:
hasChild(roles) && roles.includes(XAvailableRoles.ResponsibleManager),
isJournalist: hasChild(roles) && roles.includes(XAvailableRoles.Journalist),
isChiefClerk: hasChild(roles) && roles.includes(XAvailableRoles.ChiefClerk),
isChiefClerkAssistant:
hasChild(roles) && roles.includes(XAvailableRoles.ChiefClerkAssistant),
isActuary: hasChild(roles) && roles.includes(XAvailableRoles.Actuary),
isActuaryAssistant:
hasChild(roles) && roles.includes(XAvailableRoles.ActuaryAssistant),
isReporter: hasChild(roles) && roles.includes(XAvailableRoles.Reporter),
isReporterAssistant:
hasChild(roles) && roles.includes(XAvailableRoles.ReporterAssistant),
isAgent: hasChild(roles) && roles.includes(XAvailableRoles.Agent),
isUser: hasChild(roles) && roles.includes(XAvailableRoles.User),
};
//
return result;
}
export function getTopRoleByRoleInfo(roleInfo: XUserRoleInfo) {
//
if (!roleInfo) {
throwException(XExceptionIDs.InvalidArgs);
}
//
if (roleInfo.isAdmin) {
return XAvailableRoles.Admin;
} else if (roleInfo.isResponsibleManager) {
return XAvailableRoles.ResponsibleManager;
} else if (roleInfo.isJournalist) {
return XAvailableRoles.Journalist;
} else if (roleInfo.isChiefClerk) {
return XAvailableRoles.ChiefClerk;
} else if (roleInfo.isChiefClerkAssistant) {
return XAvailableRoles.ChiefClerkAssistant;
} else if (roleInfo.isActuary) {
return XAvailableRoles.Actuary;
} else if (roleInfo.isActuaryAssistant) {
return XAvailableRoles.ActuaryAssistant;
} else if (roleInfo.isReporter) {
return XAvailableRoles.Reporter;
} else if (roleInfo.isReporterAssistant) {
return XAvailableRoles.ReporterAssistant;
} else if (roleInfo.isAgent) {
return XAvailableRoles.Agent;
} else if (roleInfo.isUser) {
return XAvailableRoles.User;
} else {
return null;
}
}
export function getTopRoleByRoles(roles: string[]) {
//
const roleInfo = toRoleInfoByRoles(roles);
if (!roleInfo) {
return null;
}
//
return getTopRoleByRoleInfo(roleInfo);
}
export function getTopRoleByProfile(user: XUserProfileDto) {
//
const roleInfo = toRoleInfo(user);
if (!roleInfo) {
return null;
}
//
return getTopRoleByRoleInfo(roleInfo);
}
export function checkIsInRoleByInfo(
roles: XOneOrManyType<XAvailableRoles>,
roleInfo: XUserRoleInfo
): boolean {
//
let result = false;
//
// Normalize Roles ...
const normalRoles = toArray(roles);
//
for (const role of normalRoles) {
switch (role) {
//
case XAvailableRoles.Admin:
result = result || roleInfo.isAdmin;
break;
//
case XAvailableRoles.ResponsibleManager:
result = result || roleInfo.isResponsibleManager;
break;
//
case XAvailableRoles.Journalist:
result = result || roleInfo.isJournalist;
break;
//
case XAvailableRoles.ChiefClerk:
result = result || roleInfo.isChiefClerk;
break;
//
case XAvailableRoles.ChiefClerkAssistant:
result = result || roleInfo.isChiefClerkAssistant;
break;
//
case XAvailableRoles.Actuary:
result = result || roleInfo.isActuary;
break;
//
case XAvailableRoles.ActuaryAssistant:
result = result || roleInfo.isActuaryAssistant;
break;
//
case XAvailableRoles.Reporter:
result = result || roleInfo.isReporter;
break;
//
case XAvailableRoles.ReporterAssistant:
result = result || roleInfo.isReporterAssistant;
break;
//
case XAvailableRoles.Agent:
result = result || roleInfo.isAgent;
break;
//
case XAvailableRoles.User:
result = result || roleInfo.isUser;
break;
//
default:
result = result || false;
break;
}
}
//
return result;
}
export function checkIsInRoleByUser(
role: XAvailableRoles,
user: XUserProfileDto
): boolean {
//
// Validate Args ...
if (!role || !user) {
return false;
}
//
const roleInfo = toRoleInfo(user);
if (!roleInfo) {
return false;
}
//
switch (role) {
//
case XAvailableRoles.Admin:
return roleInfo.isAdmin;
//
case XAvailableRoles.ResponsibleManager:
return roleInfo.isResponsibleManager;
//
case XAvailableRoles.Journalist:
return roleInfo.isJournalist;
//
case XAvailableRoles.ChiefClerk:
return roleInfo.isChiefClerk;
//
case XAvailableRoles.ChiefClerkAssistant:
return roleInfo.isChiefClerkAssistant;
//
case XAvailableRoles.Actuary:
return roleInfo.isActuary;
//
case XAvailableRoles.ActuaryAssistant:
return roleInfo.isActuaryAssistant;
//
case XAvailableRoles.Reporter:
return roleInfo.isReporter;
//
case XAvailableRoles.ReporterAssistant:
return roleInfo.isReporterAssistant;
//
case XAvailableRoles.Agent:
return roleInfo.isAgent;
//
case XAvailableRoles.User:
return roleInfo.isUser;
//
default:
return false;
}
}
export function extractAvaialableRoles() {
//
const AllRoles = Object.assign({}, XAvailableRoles);
let result = Object.values(AllRoles);
return result;
}
@@ -0,0 +1,38 @@
import {
hasChild,
XKeyValue,
isNullOrUndefined,
isNullOrEmptyString,
} from 'x-framework-core';
/**
* Prepare a route by replacing it's params by providing values ...
*/
export function fillRouteParams(
route: string,
params?: Array<XKeyValue<string, string>>
) {
//
let result = '';
//
// Validate ...
if (isNullOrEmptyString(route)) {
return result;
}
//
// Check Params Has Child ...
if (!isNullOrUndefined(params) && hasChild(params)) {
//
result = route;
for (let param of params) {
//
const key = `{${param.key}}`;
result = result.replace(key, param.value);
}
}
//
return result;
}
@@ -0,0 +1,91 @@
//
//#region Custom Header and Params ...
export enum XCHeader {
Role = 'role',
ForceRole = 'forceRole',
}
//#endregion
//
//#region Params ...
/**
* Params Usually Used in Query Strings ...
*/
export enum XBaseParams {
XId = 'id',
XIds = 'ids',
XSoftDelete = 'softDelete',
XIgnoreSoftDeleteds = 'ignoreSoftDeleteds',
}
/**
* prepare all Route Params which used in Account Services Endpoints ...
*/
export enum XBaseEndPointParam {
XId = '{xId}',
XIds = '{xIds}',
XHash = '{xHash}',
XDate = '{xDate}',
XQuery = '{xQuery}',
XTitle = '{xTitle}',
XIdentifier = '{xIdentifier}',
XConnectionID = '{xConnectionId}',
XConnectionIDs = '{xConnectionIds}',
XUserSelectByParam = '{xUserSelectByParam}',
XIgnoreSoftDeleteds = '{xIgnoreSoftDeleteds}',
XUserSelectByParams = '{xUserSelectByParams}',
}
export type XBaseEndPointParams = keyof typeof XBaseEndPointParam;
/**
* All Commonly Used EndPoints Actions ...
*/
export enum XBaseEndPointAction {
//
// TODO: Complete this ...
Get = '{xId}',
GetAll = '',
FindOne = 'FindOne/{xQuery}',
FindMany = 'FindMany/{xQuery}',
Query = 'Query',
RequestPage = 'RequestPage',
Add = '',
AddOrUpdate = 'AddOrUpdate',
AddMany = 'AddMany',
Update = '{xId}',
UpdateMany = 'UpdateMany',
IsExists = '{xId}/IsExists',
Remove = '{xId}',
RemoveMany = 'RemoveMany',
}
export type XBaseEndPointActions = keyof typeof XBaseEndPointAction;
//#endregion
//
//#region Api EndPoints ...
/**
* Represent all API End Points ...
*/
export enum XApiEndPoint {
TagsEntity = 'Entities/Tags',
TagsService = 'Services/Tags',
FilesEntity = 'Entities/Files',
FilesService = 'Services/Files',
Configurations = 'Configurations',
StringsEntity = 'Entities/Strings',
StringsService = 'Services/Strings',
WebinarsEntity = 'Entities/Webinars',
WebinarsService = 'Services/Webinars',
TermsAndConditions = 'Configurations',
}
export declare type XApiEndPoints = keyof typeof XApiEndPoint | string;
//#endregion
//
//#region Configuration ...
export enum XConfigurationEndPoint {
}
export type XConfigurationEndPoints = keyof typeof XConfigurationEndPoint;
//#endregion
@@ -0,0 +1,33 @@
import { HttpHeaders } from '@angular/common/http';
import { isNullOrEmptyString, isNullOrUndefined } from 'x-framework-core';
export enum XPushHeaderKeys {
ConnectionId = 'requestID',
}
/**
* add Connection Id to Headers ...
*
* @param connectionId user connection id ...
* @param headers an instance of HttpHeaders ...
*
* @returns HttpHeaders instance
*/
export function applyConnectionIdToHeader(
connectionId?: string,
headers?: HttpHeaders
) {
//
// New Instance of Headers if Not provided ...
if (isNullOrUndefined(headers)) {
headers = new HttpHeaders();
}
//
if (!isNullOrEmptyString(connectionId)) {
headers = headers.set(XPushHeaderKeys.ConnectionId, connectionId);
}
//
return headers;
}
@@ -0,0 +1,27 @@
export enum XAvailableRoles {
Admin = 'admin',
ResponsibleManager = 'responsible_manager',
Journalist = 'journalist',
ChiefClerk = 'chief_clerk',
ChiefClerkAssistant = 'chief_clerk_assistant',
Actuary = 'actuary',
ActuaryAssistant = 'actuary_assistant',
Reporter = 'reporter',
ReporterAssistant = 'reporter_assistant',
Agent = 'agent',
User = 'user',
}
export interface XUserRoleInfo {
isAdmin: boolean;
isResponsibleManager: boolean;
isJournalist: boolean;
isChiefClerk: boolean;
isChiefClerkAssistant: boolean;
isActuary: boolean;
isActuaryAssistant: boolean;
isReporter: boolean;
isReporterAssistant: boolean;
isAgent: boolean;
isUser: boolean;
}
@@ -0,0 +1,199 @@
import {
XBaseDto,
typeGuard,
isSameObject,
XBaseNumberIDDto,
isNullOrUndefined,
isNullOrEmptyString,
} from 'x-framework-core';
import {
XResourceDto,
prepareResourceDtoFields,
} from '../../strings/models/x-string.dto';
import { preparePersonDtoFields, XPersonDto } from '../../models/x-person.dto';
/**
* Describe Webinar Types ...
*/
export enum XWebinarType {
Public = 0,
Private = 1,
}
export function ToWebinarType(index: number) {
//
if (index == 0) {
return XWebinarType.Public;
} else if (index == 1) {
return XWebinarType.Private;
}
//
return undefined;
}
/**
* Represent a Webinar Model ...
*/
export interface XWebinarDto extends XBaseDto {
id: string;
ownerId: string;
createdOn: Date;
enabled: boolean;
type: XWebinarType;
owner?: XPersonDto;
title: XResourceDto;
description: XResourceDto;
}
/**
* Default Model ...
*/
export const defaultWebinarDto: XWebinarDto = {
id: '',
ownerId: '',
enabled: false,
type: undefined,
owner: undefined,
title: undefined,
createdOn: undefined,
description: undefined,
};
/**
* Prepare Model Fields ...
*
* @param model
* @returns
*/
export function prepareWebinarDtoFields(model?: XWebinarDto) {
//
if (isNullOrUndefined(model)) {
model = {
...defaultWebinarDto,
};
}
//
model = {
id: isNullOrEmptyString(model.id) ? defaultWebinarDto.id : model.id,
type: isNullOrUndefined(model.type) ? defaultWebinarDto.type : model.type,
enabled: isNullOrUndefined(model.enabled)
? defaultWebinarDto.enabled
: model.enabled,
ownerId: isNullOrEmptyString(model.ownerId)
? defaultWebinarDto.ownerId
: model.ownerId,
createdOn: isNullOrUndefined(model.createdOn)
? defaultWebinarDto.createdOn
: model.createdOn,
owner: isNullOrUndefined(model.owner)
? defaultWebinarDto.owner
: preparePersonDtoFields(model.owner),
title: isNullOrUndefined(model.title)
? defaultWebinarDto.title
: prepareResourceDtoFields(model.title),
description: isNullOrUndefined(model.description)
? defaultWebinarDto.description
: prepareResourceDtoFields(model.description),
};
//
return model;
}
/**
* Check Model is Default or not ...
*
* @param model
* @returns
*/
export function isDefaultWebinarModel(model?: XWebinarDto) {
return isSameObject(prepareWebinarDtoFields(model), defaultWebinarDto);
}
/**
* Webinar Subscriber Model ...
*/
export interface XWebinarSubscriberDto extends XBaseNumberIDDto {
webinarId: string;
subscribedOn: Date;
subscriberId: string;
subscriber: XPersonDto;
}
/**
* Default Model ...
*/
export const defaultWebinarSubscriberDto: XWebinarSubscriberDto = {
id: undefined,
webinarId: '',
subscriberId: '',
subscriber: undefined,
subscribedOn: undefined,
};
/**
* Prepare Model Fields ...
*
* @param model
* @returns
*/
export function prepareWebinarSubscriberDtoFields(
model?: XWebinarSubscriberDto
) {
//
if (isNullOrUndefined(model)) {
model = {
...defaultWebinarSubscriberDto,
};
}
//
model = {
id:
isNullOrUndefined(model.id) || model.id <= 0
? defaultWebinarSubscriberDto.id
: model.id,
webinarId: isNullOrEmptyString(model.webinarId)
? defaultWebinarSubscriberDto.webinarId
: model.webinarId,
subscriberId: isNullOrEmptyString(model.subscriberId)
? defaultWebinarSubscriberDto.subscriberId
: model.subscriberId,
subscribedOn: isNullOrUndefined(model.subscribedOn)
? defaultWebinarSubscriberDto.subscribedOn
: model.subscribedOn,
subscriber: isNullOrUndefined(model.subscriber)
? defaultWebinarSubscriberDto.subscriber
: preparePersonDtoFields(model.subscriber),
};
//
return model;
}
/**
* Check Model is Default or not ...
*
* @param model
* @returns
*/
export function isDefaultWebinarSubscriberDto(model?: XWebinarSubscriberDto) {
return isSameObject(
prepareWebinarSubscriberDtoFields(model),
defaultWebinarSubscriberDto
);
}
/**
* Model Type Guard ...
*/
export const isXWebinarDto = typeGuard<XWebinarDto>([
'id',
'ownerId',
'type',
'createdOn',
'description',
'title',
]);
@@ -0,0 +1,167 @@
import { Subject } from 'rxjs';
import { Injectable } from '@angular/core';
import { isNullOrUndefined, parseJson } from 'x-framework-core';
import { XWebinarEntityPushAction } from '../x-webinar.typings';
import { XBaseEntityPushService } from 'x-framework-push-service';
import { HttpTransportType, ITransport } from '@microsoft/signalr';
import { XWebinarDto, XWebinarSubscriberDto } from '../models/x-webinar.dto';
@Injectable({
providedIn: 'root',
})
export class XWebinarEntityPushService extends XBaseEntityPushService<XWebinarDto> {
//
//#region Props ...
onSubscribed$ = new Subject<{
model: XWebinarSubscriberDto;
actorId: string;
}>();
onUnsubscribed$ = new Subject<{
model: XWebinarSubscriberDto;
actorId: string;
}>();
//#endregion
//
//#region Abstracts ...
hubName(): string {
return 'webinarEntityHub';
}
requiredAccessToken(): boolean {
return true;
}
transportType(): HttpTransportType | ITransport {
return HttpTransportType.LongPolling;
}
registerSubjects(): void {
super.registerSubjects();
//
this.onSubscribed((model: XWebinarSubscriberDto, actorId: string) => {
this.onSubscribed$.next({ model, actorId });
});
//
this.onUnsubscribed((model: XWebinarSubscriberDto, actorId: string) => {
this.onUnsubscribed$.next({ model, actorId });
});
}
//#endregion
//
//#region Actions ...
/**
* Fire New Subscriber Action ...
*
* @param model
* @returns
*/
public async subscribe(model: XWebinarSubscriberDto) {
//
// Validate ...
let isValid = !isNullOrUndefined(model);
if (!isValid) {
return;
}
//
await this.invoke(
XWebinarEntityPushAction.Subscribe,
JSON.stringify(model)
);
}
/**
* Fire Unsubscribe Action ...
*
* @param model
* @returns
*/
public async unsubscribe(model: XWebinarSubscriberDto) {
//
// Validate ...
let isValid = !isNullOrUndefined(model);
if (!isValid) {
return;
}
//
await this.invoke(
XWebinarEntityPushAction.Unsubscribe,
JSON.stringify(model)
);
}
//#endregion
//
//#region Event Listeners ...
//
//#region Onners ...
/**
* Register Subscribe Event Listener ...
*
* @param callback
*/
public onSubscribed(
callback: (model: XWebinarSubscriberDto, actorId: string) => any
) {
//
this.on(
XWebinarEntityPushAction.Subscribe,
(modelJson: string, actorId: string) => {
//
const model = parseJson<XWebinarSubscriberDto>(modelJson);
callback(model, actorId);
}
);
}
/**
* Register Unsubscribe Event Listener ...
*
* @param callback
*/
public onUnsubscribed(
callback: (model: XWebinarSubscriberDto, actorId: string) => any
) {
//
this.on(
XWebinarEntityPushAction.Unsubscribe,
(modelJson: string, actorId: string) => {
//
const model = parseJson<XWebinarSubscriberDto>(modelJson);
callback(model, actorId);
}
);
}
//#endregion
//
//#region Offers ...
/**
* UnRegister Subscribe Event Listener ...
*
* @param callback
*/
public offSubscribed(
callback?: (model: XWebinarSubscriberDto, actorId: string) => any
) {
this.off(XWebinarEntityPushAction.Subscribe, callback);
}
/**
* UnRegister Unsubscribe Event Listener ...
*
* @param callback
*/
public offUnsubscribed(
callback?: (model: XWebinarSubscriberDto, actorId: string) => any
) {
this.off(XWebinarEntityPushAction.Unsubscribe, callback);
}
//#endregion
//#endregion
}
@@ -0,0 +1,39 @@
import { Router } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { Inject, Injectable } from '@angular/core';
import { XWebinarDto } from '../models/x-webinar.dto';
import { XApiEndPoint } from '../../typings/x-endpoint.typings';
import { XBaseEntityService } from '../../base/x-base-entity.service';
import { X_API_CONFIG, XApiConfiguration } from 'x-framework-identity-sdk';
import { X_SAHERELM_API_SDK_CONFIG } from '../../tokens/x-injectable-tokens';
import { XSaherElmApiSDKConfig } from '../../config/x-saherelm-api-sdk.config';
/**
* Provides all Entity Actions as a Service ...
*/
@Injectable({
providedIn: 'root',
})
export class XWebinarEntityService extends XBaseEntityService<
XWebinarDto,
string
> {
//
//#region Constructor ...
constructor(
protected router: Router,
protected httpClient: HttpClient,
@Inject(X_SAHERELM_API_SDK_CONFIG) config: XSaherElmApiSDKConfig,
@Inject(X_API_CONFIG) apiConfig: XApiConfiguration
) {
super(
XApiEndPoint.WebinarsEntity,
true,
true,
httpClient,
config,
apiConfig
);
}
//#endregion
}
@@ -0,0 +1,260 @@
import { Subject } from 'rxjs';
import {
XRTCPeerService,
XHubConnectionDto,
XBaseWebRTCService,
IXPushServiceTokenFetcher,
XFrameworkPushServiceConfig,
X_FRAMEWORK_PUSH_SERVICE_CONFIG,
X_FRAMEWORK_PUSH_SERVICE_TOKEN_FETCHER,
} from 'x-framework-push-service';
import { isNullOrEmptyString } from 'x-framework-core';
import { XWebinarPushAction } from '../x-webinar.typings';
import { Inject, Injectable, Optional } from '@angular/core';
import { HttpTransportType, ITransport } from '@microsoft/signalr';
@Injectable({
providedIn: 'root',
})
export class XWebinarPushService extends XBaseWebRTCService {
//
//#region Props ...
onViewerJoined$ = new Subject<{
viewerId: string;
webinarId: string;
userId: string;
username?: string;
}>();
onViewerLeaved$ = new Subject<{
viewerId: string;
webinarId: string;
userId: string;
username?: string;
}>();
onWebinarOpened$ = new Subject<string>();
onWebinarClosed$ = new Subject<string>();
//#endregion
//
//#region Constructor ...
constructor(
public rtcPeerService: XRTCPeerService,
@Inject(X_FRAMEWORK_PUSH_SERVICE_CONFIG)
public config: XFrameworkPushServiceConfig,
@Optional()
@Inject(X_FRAMEWORK_PUSH_SERVICE_TOKEN_FETCHER)
public tokenFetcher?: IXPushServiceTokenFetcher
) {
super(config, tokenFetcher);
}
//#endregion
//
//#region Abstracts ...
hubName(): string {
return 'webinarHub';
}
requiredAccessToken(): boolean {
return true;
}
transportType(): HttpTransportType | ITransport {
return HttpTransportType.ServerSentEvents;
}
skipNegotiation: false
registerSubjects(): void {
super.registerSubjects();
//
this.onWebinarClosed((webinarId: string) => {
this.onWebinarClosed$.next(webinarId);
});
//
this.onWebinarClosed((webinarId: string) => {
this.onWebinarClosed$.next(webinarId);
});
//
this.onViewerJoined(
(
viewerId: string,
webinarId: string,
userId: string,
username?: string
) => {
//
this.onViewerJoined$.next({
userId,
viewerId,
username,
webinarId,
});
}
);
//
this.onViewerLeaved(
(
viewerId: string,
webinarId: string,
userId: string,
username?: string
) => {
//
this.onViewerLeaved$.next({
userId,
viewerId,
username,
webinarId,
});
}
);
}
//#endregion
//
//#region Actions ...
public async openWebinar(webinarId: string) {
//
// Validate ...
if (isNullOrEmptyString(webinarId)) {
return;
}
//
await this.invoke(XWebinarPushAction.WebinarOpened, webinarId);
}
public async closeWebinar(webinarId: string) {
//
// Validate ...
if (isNullOrEmptyString(webinarId)) {
return;
}
//
await this.invoke(XWebinarPushAction.WebinarClosed, webinarId);
}
public async joinWebinar(webinarId: string) {
//
// Validate ...
if (isNullOrEmptyString(webinarId)) {
return;
}
//
await this.invoke(XWebinarPushAction.ViewerJoined, webinarId);
}
public async leaveWebinar(webinarId: string) {
//
// Validate ...
if (isNullOrEmptyString(webinarId)) {
return;
}
//
await this.invoke(XWebinarPushAction.ViewerLeaved, webinarId);
}
public async webinarVisitors(webinarId: string) {
//
let result: Array<XHubConnectionDto> = [];
//
// Validate ...
if (isNullOrEmptyString(webinarId)) {
return result;
}
//
result = await this.invoke<Array<XHubConnectionDto>>(XWebinarPushAction.WebinarVisitors, webinarId);
return result;
}
public async sendMessage(webinarId: string, message: string) {
//
// Validate ...
if (isNullOrEmptyString(webinarId)) {
return;
}
//
await this.invoke(XWebinarPushAction.Message, webinarId, message);
}
//#endregion
//
//#region Event Handlers ...
//
//#region Onners ...
public onWebinarOpened(callback: (webinarId: string) => any) {
this.on(XWebinarPushAction.WebinarOpened, callback);
}
public onWebinarClosed(callback: (webinarId?: string) => any) {
this.on(XWebinarPushAction.WebinarClosed, callback);
}
public onViewerJoined(
callback: (
connectionId: string,
webinarId: string,
userId: string,
username?: string
) => any
) {
this.on(XWebinarPushAction.ViewerJoined, callback);
}
public onViewerLeaved(
callback: (
connectionId: string,
webinarId: string,
userId: string,
username?: string
) => any
) {
this.on(XWebinarPushAction.ViewerLeaved, callback);
}
//#endregion
//
//#region Offers ...
public offWebinarOpened(callback?: (webinarId: string) => any) {
this.off(XWebinarPushAction.WebinarOpened, callback);
}
public offWebinarClosed(callback?: (webinarId?: string) => any) {
this.off(XWebinarPushAction.WebinarClosed, callback);
}
public offViewerJoined(
callback?: (
connectionId: string,
webinarId: string,
userId: string,
username?: string
) => any
) {
this.off(XWebinarPushAction.ViewerJoined, callback);
}
public offViewerLeaved(
callback?: (
connectionId: string,
webinarId: string,
userId: string,
username?: string
) => any
) {
this.off(XWebinarPushAction.ViewerLeaved, callback);
}
//#endregion
//#endregion
}
@@ -0,0 +1,39 @@
import { Router } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { Inject, Injectable } from '@angular/core';
import { XWebinarSubscriberDto } from '../models/x-webinar.dto';
import { XApiEndPoint } from '../../typings/x-endpoint.typings';
import { XBaseEntityService } from '../../base/x-base-entity.service';
import { X_API_CONFIG, XApiConfiguration } from 'x-framework-identity-sdk';
import { X_SAHERELM_API_SDK_CONFIG } from '../../tokens/x-injectable-tokens';
import { XSaherElmApiSDKConfig } from '../../config/x-saherelm-api-sdk.config';
/**
* Provides all Entity Actions as a Service ...
*/
@Injectable({
providedIn: 'root',
})
export class XWebinarSubscriberEntityService extends XBaseEntityService<
XWebinarSubscriberDto,
number
> {
//
//#region Constructor ...
constructor(
protected router: Router,
protected httpClient: HttpClient,
@Inject(X_SAHERELM_API_SDK_CONFIG) config: XSaherElmApiSDKConfig,
@Inject(X_API_CONFIG) apiConfig: XApiConfiguration
) {
super(
XApiEndPoint.WebinarsEntity,
true,
true,
httpClient,
config,
apiConfig
);
}
//#endregion
}
@@ -0,0 +1,25 @@
import { Injectable } from '@angular/core';
import { XWebinarPushService } from './services/x-webinar.push.service';
import { XWebinarEntityService } from './services/x-webinar.entity.service';
import { XWebinarProviderService } from './services/x-webinar.provider.service';
import { XWebinarEntityPushService } from './services/x-webinar.entity.push.service';
import { XWebinarSubscriberEntityService } from './services/x-webinarsubscriber.entity.service';
/**
* Export All Provided Webinar related Services ...
*/
@Injectable({
providedIn: 'root',
})
export class XWebinarServices {
//
//#region Constructor ...
public constructor(
public webinarPushService: XWebinarPushService,
public webinarEntityService: XWebinarEntityService,
public webinarProviderService: XWebinarProviderService,
public webinarEntityPushService: XWebinarEntityPushService,
public webinarSubscriberEntityService: XWebinarSubscriberEntityService
) {}
//#endregion
}
@@ -0,0 +1,82 @@
/**
* All Available EndPoint Routes ...
*/
export enum XWebinarServiceRoute {
CreateWebinar = '',
GetWebinar = '{id}',
GetWebinars = 'All',
UpdateWebinar = '{id}',
RemoveWebinar = '{id}',
QueryWebinars = 'Query',
GetFiles = '{id}/Files',
GetTags = '{id}/Tags',
AttachTags = '{id}/Tags',
DetachTags = '{id}/Tags',
RemoveFiles = '{id}/Files',
UploadFiles = '{id}/Files',
QueryOwnedWebinars = 'Query/Owned',
GetSubscribers = '{id}/Subscribers',
QueryJoinableWebinars = 'Query/Joinable',
StreamFile = '{id}/Files/{fileId}/Stream',
Subscribe = '{id}/Subscribe/{subscriberId}',
QuerySubscribers = '{id}/Subscribers/Query',
DownloadFile = '{id}/Files/{fileId}/Download',
Unsubscribe = '{id}/Unsubscribe/{subscriberId}',
GetSubscriber = '{id}/Subscriber/{subscriberId}',
IsSubscribed = '{id}/IsSubscribed/{subscriberId}',
}
/**
* All Params Which Used in Related Services ...
*/
export enum XWebinarParam {
Id = 'id',
Ids = 'ids',
Tags = 'tags',
Files = 'files',
FileId = 'fileId',
SubscriberId = 'subscriberId',
}
/**
* Webinar Hub Actions ...
*/
export enum XWebinarPushAction {
/// <summary>
/// When a Webinar is Available to Join ...
/// </summary>
WebinarOpened = 'WebinarOpened',
/// <summary>
/// When a Webinar Closed ...
/// </summary>
WebinarClosed = 'WebinarClosed',
/// <summary>
/// When a Viewer is Joined to Webinar ...
/// </summary>
ViewerJoined = 'ViewerJoined',
/// <summary>
/// When a Webinar Subscriber Leaved a Webinar ...
/// </summary>
ViewerLeaved = 'ViewerLeaved',
/// <summary>
/// Retrieve Specified Webinar Visitors ...
/// </summary>
WebinarVisitors = 'WebinarVisitors',
/// <summary>
/// Send a Message to Webinar ...
/// </summary>
Message = 'Message',
}
/**
* Webinar Entity Hub Actions ...
*/
export enum XWebinarEntityPushAction {
Subscribe = 'Subscribe',
Unsubscribe = 'Unsubscribe',
}
@@ -0,0 +1,26 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { XFrameworkCoreModule } from 'x-framework-core';
import { XFrameworkServicesModule } from 'x-framework-services';
import { XFrameworkIdentitySdkModule } from 'x-framework-identity-sdk';
@NgModule({
declarations: [],
imports: [
CommonModule,
HttpClientModule,
XFrameworkCoreModule,
XFrameworkServicesModule,
XFrameworkIdentitySdkModule,
],
exports: [
CommonModule,
HttpClientModule,
XFrameworkCoreModule,
XFrameworkServicesModule,
XFrameworkIdentitySdkModule,
],
providers: [],
})
export class XSaherElmApiSdkModule {}
@@ -0,0 +1,30 @@
import { XLoggable } from 'x-framework-core';
import { Inject, Injectable } from '@angular/core';
import { XTagServices } from './tags/x-tag.services';
import { XFileServices } from './files/x-file.services';
import { XTermsServices } from './terms/x-terms.service';
import { XStringServices } from './strings/x-string.services';
import { XWebinarServices } from './webinars/x-webinar.services';
import { X_SAHERELM_API_SDK_CONFIG } from './tokens/x-injectable-tokens';
import { XSaherElmApiSDKConfig } from './config/x-saherelm-api-sdk.config';
import { XConfigurationsService } from './configurations/x-configurations.service';
@Injectable({
providedIn: 'root',
})
export class XSaherElmAPIService extends XLoggable {
//
//#region Constructor ...
constructor(
public tags: XTagServices,
public files: XFileServices,
public terms: XTermsServices,
public strings: XStringServices,
public webinars: XWebinarServices,
@Inject(X_SAHERELM_API_SDK_CONFIG)
public config: XSaherElmApiSDKConfig,
public configurationService: XConfigurationsService
) {
super(config);
}
}
@@ -0,0 +1,99 @@
/*
* Public API Surface of x-framework-api-sdk
*/
//
// Base ...
export * from './lib/base/x-base.guard';
export * from './lib/base/x-base-entity.service';
export * from './lib/base/i-x-entity-actions.interface';
//
// Config ...
export * from './lib/config/x-saherelm-api-sdk.config';
//
// Models ...
export * from './lib/models/x-person.dto';
export * from './lib/models/x-reference.dto';
//
// Tokens ...
export * from './lib/tokens/x-injectable-tokens';
//
// Tools ...
export * from './lib/tools/x-role.tools';
export * from './lib/tools/x-model.tools';
export * from './lib/tools/x-route.tools';
//
// Services ...
export * from './lib/services/x-push-token-fetcher.service';
//
// Typings ...
export * from './lib/typings/x-role.typings';
export * from './lib/strings/x-string.typings';
export * from './lib/typings/x-endpoint.typings';
export * from './lib/typings/x-push-provider.typings';
//
// Guards ...
export * from './lib/guards/user.guard';
export * from './lib/guards/admin.guard';
export * from './lib/guards/agent.guard';
export * from './lib/guards/admin-or-agent.guard';
//
// Strings ...
export * from './lib/strings/x-string.typings';
export * from './lib/strings/x-string.services';
export * from './lib/strings/models/x-string.dto';
export * from './lib/configurations/x-configurations.service';
export * from './lib/strings/services/x-string.entity.service';
export * from './lib/strings/services/x-string.provider.service';
export * from './lib/strings/services/x-string.entity.push.service';
//
// Terms ...
export * from './lib/terms/x-terms.service';
export * from './lib/terms/x-terms.typings.dto';
export * from './lib/terms/services/x-terms.push.service';
export * from './lib/terms/services/x-terms.provider.service';
//
// Tags ...
export * from './lib/tags/x-tag.typings';
export * from './lib/tags/x-tag.services';
export * from './lib/tags/models/x-tag.dto';
export * from './lib/tags/services/x-tag.entity.service';
export * from './lib/tags/services/x-tag.provider.service';
export * from './lib/tags/services/x-tag.entity.push.service';
//
// Files ...
export * from './lib/files/x-file.typings';
export * from './lib/files/x-file.services';
export * from './lib/files/models/x-file.dto';
export * from './lib/files/services/x-file.entity.service';
export * from './lib/files/services/x-file.provider.service';
export * from './lib/files/services/x-file.entity.push.service';
//
// Webinars ...
export * from './lib/webinars/x-webinar.typings';
export * from './lib/webinars/x-webinar.services';
export * from './lib/webinars/models/x-webinar.dto';
export * from './lib/webinars/services/x-webinar.push.service';
export * from './lib/webinars/services/x-webinar.entity.service';
export * from './lib/webinars/services/x-webinar.provider.service';
export * from './lib/webinars/services/x-webinar.entity.push.service';
export * from './lib/webinars/services/x-webinarsubscriber.entity.service';
//
// Module Service ...
export * from './lib/x-saherelm-api.service';
//
// Module ...
export * from './lib/x-saherelm-api-sdk.module';
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.lib.json",
"angularCompilerOptions": {
"enableIvy": true
}
}
@@ -0,0 +1,20 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [],
"lib": [
"dom",
"es2018"
]
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
@@ -0,0 +1,10 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {
"compilationMode": "partial"
}
}
+39
View File
@@ -0,0 +1,39 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"strict": true,
"baseUrl": "./",
"sourceMap": true,
"target": "es2017",
"module": "es2020",
"declaration": false,
"skipLibCheck": true,
"noImplicitAny": true,
"importHelpers": true,
"strictNullChecks": false,
"noImplicitReturns": true,
"moduleResolution": "node",
"downlevelIteration": true,
"outDir": "./dist/out-tsc",
"experimentalDecorators": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
"lib": [
"es2018",
"dom"
],
"paths": {
"x-saherelm-api-sdk": [
"dist/x-saherelm-api-sdk/x-saherelm-api-sdk",
"dist/x-saherelm-api-sdk"
]
}
},
"angularCompilerOptions": {
"strictTemplates": true,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"enableI18nLegacyMessageIdFormat": false
}
}