Initial Commit

This commit is contained in:
병준 박 2019-09-18 15:02:21 +09:00
parent 680fedb8c9
commit 9464e3b6bd
1414 changed files with 12519 additions and 0 deletions

13
.editorconfig Normal file
View File

@ -0,0 +1,13 @@
# 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
[*.md]
max_line_length = off
trim_trailing_whitespace = false

47
.gitignore vendored Normal file
View File

@ -0,0 +1,47 @@
# 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
speed-measure-plugin*.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
/.awcache
# System Files
.DS_Store
Thumbs.db

7
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}

14
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,14 @@
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.autoClosingBrackets": "languageDefined",
"editor.trimAutoWhitespace": true,
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"go.testFlags": ["-v"],
"go.testTimeout": "100s",
"prettier.singleQuote": true,
"debug.node.autoAttach": "on"
}

15
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,15 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "build:main:dev",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

1212
angular.json Normal file

File diff suppressed because it is too large Load Diff

19
config/enviroment.ts Normal file
View File

@ -0,0 +1,19 @@
import * as fs from 'fs';
import * as Path from 'path';
const projectRoot = Path.dirname(__dirname);
const channel = process.env.NODE_ENV;
const s = JSON.stringify;
export function getEnviroments() {
return {
__DARWIN__: process.platform === 'darwin',
__WIN32__: process.platform === 'win32',
__LINUX__: process.platform === 'linux',
__DEV__: channel === 'development',
'process.platform': s(process.platform),
'process.env.NODE_ENV': s(process.env.NODE_ENV || 'development'),
'process.env.TEST_ENV': s(process.env.TEST_ENV)
};
}

View File

@ -0,0 +1,94 @@
import * as path from 'path';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import * as webpack from 'webpack';
import * as nodeExternals from 'webpack-node-externals';
import { getEnviroments } from './enviroment';
const enviroments = getEnviroments();
export const externals = [nodeExternals()];
// if (enviroments.__DEV__) {
// externals.push('devtron');
// }
const outputDir = 'dist/main';
const mainConfig: webpack.Configuration = {
entry: { main: path.resolve(__dirname, '..', 'main/src/index') },
target: 'electron-main',
mode: enviroments.__DEV__ ? 'development' : 'production',
devtool: 'source-map',
optimization: {
noEmitOnErrors: true
},
externals,
output: {
filename: '[name].js',
path: path.resolve(__dirname, '..', outputDir)
},
module: {
rules: [
{
test: /\.tsx?$/,
include: [
path.resolve(__dirname, '..', 'main/src'),
path.resolve(__dirname, '..', 'projects')
],
use: [
{
loader: 'awesome-typescript-loader',
options: {
useCache: true,
configFileName: path.resolve(
__dirname,
'..',
'main/tsconfig.main.json'
)
}
}
],
exclude: /node_modules/
},
{
test: /\.node$/,
loader: 'awesome-node-loader',
options: {
name: '[name].[ext]'
}
}
]
},
plugins: [
new CleanWebpackPlugin({ verbose: false }),
// This saves us a bunch of bytes by pruning locales (which we don't use)
// from moment.
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.DefinePlugin(
Object.assign({}, enviroments, {
__PROCESS_KIND__: JSON.stringify('main')
})
)
],
resolve: {
extensions: ['.js', '.ts'],
alias: {
'@ucap-webmessenger/native': path.resolve(
__dirname,
'..',
'projects/ucap-webmessenger-native/src/public-api'
),
'@ucap-webmessenger/native-electron': path.resolve(
__dirname,
'..',
'projects/ucap-webmessenger-native-electron/src/public-api'
)
},
modules: [path.resolve(__dirname, '..', 'node_modules/')]
},
node: {
__dirname: false,
__filename: false
}
};
export default [mainConfig];

View File

@ -0,0 +1,7 @@
module.exports = (config, options) => {
const PRODUCTION = process.env.NODE_ENV === 'production';
config.target = 'electron-renderer';
return config;
};

View File

@ -0,0 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "commonjs"
}
}

40
electron-builder.json Normal file
View File

@ -0,0 +1,40 @@
{
"productName": "WooriTalk",
"appId": "lgcns.ucap.messenger",
"asar": true,
"protocols": {
"name": "WooriTalk",
"schemes": ["WooriTalk"]
},
"publish": {
"provider": "generic",
"url": "http://localhost:8099/client-updates/"
},
"mac": {
"target": ["default"],
"icon": "./resources/installer/woori.icns"
},
"dmg": {
"title": "WooriTalk",
"icon": "./resources/installer/woori.icns"
},
"win": {
"target": ["zip", "nsis"],
"icon": "./resources/installer/woori_256x256.ico"
},
"linux": {
"target": ["AppImage", "deb", "rpm", "zip", "tar.gz"],
"icon": "./resources/linuxicon"
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"perMachine": true,
"differentialPackage": true
},
"directories": {
"buildResources": "resources/installer/",
"output": "dist-electron/",
"app": "."
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 897 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

209
main/src/app/AppWindow.ts Normal file
View File

@ -0,0 +1,209 @@
import * as path from 'path';
import * as url from 'url';
import { app, BrowserWindow, screen, ipcMain, IpcMainEvent } from 'electron';
import windowStateKeeper from 'electron-window-state';
import { EventEmitter } from 'events';
import { now } from '../util/now';
export class AppWindow {
private window: BrowserWindow | null = null;
private eventEmitter = new EventEmitter();
private _loadTime: number | null = null;
private _rendererReadyTime: number | null = null;
private minWidth = 960;
private minHeight = 660;
public constructor() {
const savedWindowState = windowStateKeeper({
defaultWidth: this.minWidth,
defaultHeight: this.minHeight
});
const windowOptions: Electron.BrowserWindowConstructorOptions = {
x: savedWindowState.x,
y: savedWindowState.y,
width: savedWindowState.width,
height: savedWindowState.height,
minWidth: this.minWidth,
minHeight: this.minHeight,
// This fixes subpixel aliasing on Windows
// See https://github.com/atom/atom/commit/683bef5b9d133cb194b476938c77cc07fd05b972
backgroundColor: '#fff',
webPreferences: {
// Disable auxclick event
// See https://developers.google.com/web/updates/2016/10/auxclick
disableBlinkFeatures: 'Auxclick',
// Enable, among other things, the ResizeObserver
experimentalFeatures: true,
nodeIntegration: true
},
acceptFirstMouse: true
};
if (__DARWIN__) {
windowOptions.titleBarStyle = 'hidden';
} else if (__WIN32__) {
// windowOptions.frame = false;
} else if (__LINUX__) {
windowOptions.icon = path.join(__dirname, 'static', 'icon-logo.png');
}
this.window = new BrowserWindow(windowOptions);
savedWindowState.manage(this.window);
let quitting = false;
app.on('before-quit', () => {
quitting = true;
});
ipcMain.on('will-quit', (event: IpcMainEvent) => {
quitting = true;
event.returnValue = true;
});
// on macOS, when the user closes the window we really just hide it. This
// lets us activate quickly and keep all our interesting logic in the
// renderer.
if (__DARWIN__) {
this.window.on('close', e => {
if (!quitting) {
e.preventDefault();
}
});
}
if (__WIN32__) {
// workaround for known issue with fullscreen-ing the app and restoring
// is that some Chromium API reports the incorrect bounds, so that it
// will leave a small space at the top of the screen on every other
// maximize
//
// adapted from https://github.com/electron/electron/issues/12971#issuecomment-403956396
//
// can be tidied up once https://github.com/electron/electron/issues/12971
// has been confirmed as resolved
this.window.once('ready-to-show', () => {
this.window.on('unmaximize', () => {
setTimeout(() => {
const bounds = this.window.getBounds();
bounds.width += 1;
this.window.setBounds(bounds);
bounds.width -= 1;
this.window.setBounds(bounds);
}, 5);
});
});
}
}
public load(): void {
let startLoad = 0;
if (__DEV__) {
this.window.loadURL('http://localhost:4200');
} else {
this.window.loadURL(
url.format({
pathname: path.join(
__dirname,
'..',
'ucap-webmessenger-app/index.html'
),
protocol: 'file:',
slashes: true
})
);
}
this.window.webContents.once('did-start-loading', () => {
this._rendererReadyTime = null;
this._loadTime = null;
startLoad = now();
});
this.window.webContents.once('did-finish-load', () => {
if (process.env.NODE_ENV === 'development') {
this.window.webContents.openDevTools();
}
this._loadTime = now() - startLoad;
});
this.window.webContents.on('did-finish-load', () => {
this.window.webContents.setVisualZoomLevelLimits(1, 1);
});
this.window.webContents.on('did-fail-load', () => {
this.window.webContents.openDevTools();
this.window.show();
});
}
/** Is the page loaded and has the renderer signalled it's ready? */
private get rendererLoaded(): boolean {
return !!this.loadTime && !!this.rendererReadyTime;
}
public onClose(fn: () => void) {
this.window.on('closed', fn);
}
/**
* Register a function to call when the window is done loading. At that point
* the page has loaded and the renderer has signalled that it is ready.
*/
public onDidLoad(fn: () => void): EventEmitter {
return this.eventEmitter.on('did-load', fn);
}
public isMinimized() {
return this.window.isMinimized();
}
/** Is the window currently visible? */
public isVisible() {
return this.window.isVisible();
}
public restore() {
this.window.restore();
}
public focus() {
this.window.focus();
}
/** Show the window. */
public show() {
this.window.show();
}
/**
* Get the time (in milliseconds) spent loading the page.
*
* This will be `null` until `onDidLoad` is called.
*/
public get loadTime(): number | null {
return this._loadTime;
}
/**
* Get the time (in milliseconds) elapsed from the renderer being loaded to it
* signaling it was ready.
*
* This will be `null` until `onDidLoad` is called.
*/
public get rendererReadyTime(): number | null {
return this._rendererReadyTime;
}
public destroy() {
this.window.destroy();
}
}

View File

View File

@ -0,0 +1 @@
export function showUncaughtException(isLaunchError: boolean, error: Error) {}

18
main/src/global.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
/* eslint-disable @typescript-eslint/interface-name-prefix */
/** Is the app running in dev mode? */
declare const __DEV__: boolean;
/** Is the app being built to run on Darwin? */
declare const __DARWIN__: boolean;
/** Is the app being built to run on Win32? */
declare const __WIN32__: boolean;
/** Is the app being built to run on Linux? */
declare const __LINUX__: boolean;
/**
* The currently executing process kind, this is specific to desktop
* and identifies the processes that we have.
*/
declare const __PROCESS_KIND__: 'main' | 'ui';

148
main/src/index.ts Normal file
View File

@ -0,0 +1,148 @@
import { app, ipcMain, IpcMainEvent } from 'electron';
import * as path from 'path';
import * as url from 'url';
import { AppWindow } from './app/AppWindow';
import { now } from './util/now';
import { showUncaughtException } from './crash/show-uncaught-exception';
import { Channel } from '@ucap-webmessenger/native-electron';
let appWindow: AppWindow | null = null;
const launchTime = now();
let readyTime: number | null = null;
type OnDidLoadFn = (window: AppWindow) => void;
let onDidLoadFns: Array<OnDidLoadFn> | null = [];
let preventQuit = false;
function handleUncaughtException(error: Error) {
preventQuit = true;
// If we haven't got a window we'll assume it's because
// we've just launched and haven't created it yet.
// It could also be because we're encountering an unhandled
// exception on shutdown but that's less likely and since
// this only affects the presentation of the crash dialog
// it's a safe assumption to make.
const isLaunchError = appWindow === null;
if (appWindow) {
appWindow.destroy();
appWindow = null;
}
showUncaughtException(isLaunchError, error);
}
function getUptimeInSeconds() {
return (now() - launchTime) / 1000;
}
process.on('uncaughtException', (error: Error) => {
// error = withSourceMappedStack(error);
// reportError(error, getExtraErrorContext());
handleUncaughtException(error);
});
let isDuplicateInstance = false;
const gotSingleInstanceLock = app.requestSingleInstanceLock();
isDuplicateInstance = !gotSingleInstanceLock;
app.on('second-instance', (event, args, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (appWindow) {
if (appWindow.isMinimized()) {
appWindow.restore();
}
if (!appWindow.isVisible()) {
appWindow.show();
}
appWindow.focus();
}
});
if (isDuplicateInstance) {
app.quit();
}
function createWindow() {
const window = new AppWindow();
window.onClose(() => {
appWindow = null;
if (!__DARWIN__ && !preventQuit) {
app.quit();
}
});
window.onDidLoad(() => {
window.show();
const fns = onDidLoadFns;
onDidLoadFns = null;
for (const fn of fns) {
fn(window);
}
});
window.load();
appWindow = window;
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', () => {
if (isDuplicateInstance) {
return;
}
readyTime = now() - launchTime;
createWindow();
ipcMain.on('uncaught-exception', (event: IpcMainEvent, error: Error) => {
handleUncaughtException(error);
});
ipcMain.on(
'send-error-report',
(
event: IpcMainEvent,
{ error, extra }: { error: Error; extra: { [key: string]: string } }
) => {}
);
});
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
onDidLoad(window => {
window.show();
});
});
function onDidLoad(fn: OnDidLoadFn) {
if (onDidLoadFns) {
onDidLoadFns.push(fn);
} else {
if (appWindow) {
fn(appWindow);
}
}
}
ipcMain.on(Channel.checkForUpdates, (event: IpcMainEvent, ...args: any[]) => {
event.returnValue = false;
});

99
main/src/lib/storage.ts Normal file
View File

@ -0,0 +1,99 @@
import Store from 'electron-store';
const STORE_KEY_AUTORUN = 'options.autoRun';
const STORE_KEY_AUTOLOGIN = 'options.autoLogin';
const STORE_KEY_STARTUPHIDEWINDOW = 'options.startupHideWindow';
const STORE_KEY_LOGINCOMPANY = 'login.loginCompany';
const STORE_KEY_LOGINID = 'login.loginId';
const STORE_KEY_LOGINPW = 'login.loginPw';
export class Storage extends Store<any> {
constructor() {
super({
schema: {
options: {
type: 'object',
properties: {
autoRun: {
type: 'boolean'
},
autoLogin: {
type: 'boolean'
},
startupHideWindow: {
type: 'boolean'
}
},
default: {
autoRun: false,
autoLogin: false,
startupHideWindow: false
}
},
login: {
type: 'object',
properties: {
loginCompany: {
type: 'string'
},
loginId: {
type: 'string'
},
loginPw: {
type: 'string'
}
},
default: {
loginCompany: '',
loginId: '',
loginPw: ''
}
}
},
encryptionKey: 'ucap',
fileExtension: 'dat'
});
}
get autoRun(): boolean {
return this.get(STORE_KEY_AUTORUN, false);
}
set autoRun(autoRun: boolean) {
this.set(STORE_KEY_AUTORUN, autoRun);
}
get autoLogin(): boolean {
return this.get(STORE_KEY_AUTOLOGIN, false);
}
set autoLogin(autoLogin: boolean) {
this.set(STORE_KEY_AUTOLOGIN, autoLogin);
}
get startupHideWindow(): boolean {
return this.get(STORE_KEY_STARTUPHIDEWINDOW, false);
}
set startupHideWindow(startupHideWindow: boolean) {
this.set(STORE_KEY_STARTUPHIDEWINDOW, startupHideWindow);
}
get loginCompany(): string {
return this.get(STORE_KEY_LOGINCOMPANY, false);
}
set loginCompany(loginCompany: string) {
this.set(STORE_KEY_LOGINCOMPANY, loginCompany);
}
get loginId(): string {
return this.get(STORE_KEY_LOGINID, false);
}
set loginId(loginId: string) {
this.set(STORE_KEY_LOGINID, loginId);
}
get loginPw(): string {
return this.get(STORE_KEY_LOGINPW, false);
}
set loginPw(loginPw: string) {
this.set(STORE_KEY_LOGINPW, loginPw);
}
}

4
main/src/util/now.ts Normal file
View File

@ -0,0 +1,4 @@
export function now(): number {
const time = process.hrtime();
return time[0] * 1000 + time[1] / 1000000;
}

26
main/tsconfig.main.json Normal file
View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"baseUrl": "./",
"outDir": "../dist/main",
"sourceMap": true,
"declaration": false,
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"target": "es5",
"types": ["node"],
"lib": ["es2017", "es2016", "es2015", "dom"],
"paths": {
"@ucap-webmessenger/native": [
"../projects/ucap-webmessenger-native/src/public-api"
],
"@ucap-webmessenger/native-electron": [
"../projects/ucap-webmessenger-native-electron/src/public-api"
]
}
},
"exclude": ["../node_modules", "**/*.spec.ts"]
}

104
package.json Normal file
View File

@ -0,0 +1,104 @@
{
"name": "ucap-webmessenger",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "npm-run-all -p start:renderer start:main",
"start:main": "wait-on http-get://localhost:4200/ && npm run build:main:dev && electron --nolazy --inspect-brk=9229 .",
"start:renderer": "ng serve",
"start:production": "npm run build:renderer && npm run build:main:prod && electron --nolazy --inspect-brk=9229 .",
"build:renderer": "cross-env NODE_ENV=production ng build --base-href ./",
"build:main:dev": "cross-env NODE_ENV=development TS_NODE_PROJECT='./config/tsconfig.webpack.json' parallel-webpack --config=config/main.webpack.config.ts",
"build:main:prod": "cross-env NODE_ENV=production TS_NODE_PROJECT='./config/tsconfig.webpack.json' NODE_OPTIONS='--max_old_space_size=4096' parallel-webpack --config=config/main.webpack.config.ts",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"tslib": "^1.10.0"
},
"devDependencies": {
"@angular-builders/custom-webpack": "^8.2.0",
"@angular-devkit/build-angular": "~0.803.2",
"@angular-devkit/build-ng-packagr": "~0.803.2",
"@angular/animations": "~8.2.4",
"@angular/cdk": "^8.1.4",
"@angular/cli": "~8.3.2",
"@angular/common": "~8.2.4",
"@angular/compiler": "~8.2.4",
"@angular/compiler-cli": "~8.2.4",
"@angular/core": "~8.2.4",
"@angular/flex-layout": "^8.0.0-beta.27",
"@angular/forms": "~8.2.4",
"@angular/language-service": "~8.2.4",
"@angular/material": "^8.1.4",
"@angular/material-moment-adapter": "^8.1.4",
"@angular/platform-browser": "~8.2.4",
"@angular/platform-browser-dynamic": "~8.2.4",
"@angular/router": "~8.2.4",
"@ngrx/effects": "^8.3.0",
"@ngrx/router-store": "^8.3.0",
"@ngrx/store": "^8.3.0",
"@ngrx/store-devtools": "^8.3.0",
"@ngx-translate/core": "^11.0.1",
"@types/crypto-js": "^3.1.43",
"@types/detect-browser": "^4.0.0",
"@types/extract-text-webpack-plugin": "^3.0.4",
"@types/filesize": "^4.1.0",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.7.3",
"@types/semver": "^6.0.2",
"@types/webpack": "^4.39.1",
"@types/webpack-merge": "^4.1.5",
"@types/webpack-node-externals": "^1.6.3",
"awesome-node-loader": "^1.1.1",
"awesome-typescript-loader": "^5.2.1",
"clean-webpack-plugin": "^3.0.0",
"codelyzer": "^5.0.0",
"concurrently": "^4.1.2",
"crypto-js": "^3.1.9-1",
"cross-env": "^5.2.1",
"detect-browser": "^4.6.0",
"devtron": "^1.4.0",
"electron": "^6.0.7",
"electron-builder": "^21.2.0",
"electron-debug": "^3.0.1",
"electron-devtools-installer": "^2.2.4",
"electron-log": "^3.0.7",
"electron-reload": "^1.5.0",
"electron-store": "^4.0.0",
"electron-window-state": "^5.0.3",
"filesize": "^4.1.2",
"hammerjs": "^2.0.8",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"moment": "^2.24.0",
"ng-packagr": "^5.4.0",
"ngrx-store-freeze": "^0.2.4",
"ngx-perfect-scrollbar": "^8.0.0",
"npm-run-all": "^4.1.5",
"parallel-webpack": "^2.4.0",
"protractor": "~5.4.0",
"queueing-subject": "^0.3.4",
"rxjs": "^6.5.2",
"semver": "^6.3.0",
"ts-node": "~7.0.0",
"tsickle": "^0.37.0",
"tslib": "^1.10.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3",
"wait-on": "^3.3.0",
"webpack": "4.39.2",
"webpack-cli": "^3.3.7",
"webpack-node-externals": "^1.7.2",
"zone.js": "~0.9.1"
},
"main": "./dist/main/main.js"
}

View File

@ -0,0 +1,24 @@
# UcapWebmessengerApiCommon
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.2.4.
## Code scaffolding
Run `ng generate component component-name --project ucap-webmessenger-api-common` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ucap-webmessenger-api-common`.
> Note: Don't forget to add `--project ucap-webmessenger-api-common` or else it will be added to the default project in your `angular.json` file.
## Build
Run `ng build ucap-webmessenger-api-common` to build the project. The build artifacts will be stored in the `dist/` directory.
## Publishing
After building your library with `ng build ucap-webmessenger-api-common`, go to the dist folder `cd dist/ucap-webmessenger-api-common` and run `npm publish`.
## Running unit tests
Run `ng test ucap-webmessenger-api-common` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

View File

@ -0,0 +1,32 @@
// 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-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../../coverage/ucap-webmessenger-api-common'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};

View File

@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/ucap-webmessenger-api-common",
"lib": {
"entryFile": "src/public-api.ts"
}
}

View File

@ -0,0 +1,8 @@
{
"name": "@ucap-webmessenger/api-common",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^8.2.4",
"@angular/core": "^8.2.4"
}
}

View File

@ -0,0 +1,16 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface FileProfileSaveRequest extends APIRequest {
userSeq: string;
deviceType: DeviceType;
token: string;
file?: File;
intro?: string;
initProfileImage?: boolean;
}
export interface FileProfileSaveResponse extends APIResponse {
ProfileURL?: string;
ProfileSubDir?: string;
}

View File

@ -0,0 +1,9 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest } from '@ucap-webmessenger/api';
export interface FileTalkDownloadRequest extends APIRequest {
userSeq: string;
deviceType: DeviceType;
token: string;
attachmentsSeq?: string;
}

View File

@ -0,0 +1,31 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface FileTalkSaveRequest extends APIRequest {
userSeq: string;
deviceType: DeviceType;
token: string;
file?: File;
fileName?: string;
thumb?: File;
voice?: boolean;
voiceTime?: string;
roomId?: string;
type?: string;
}
export interface FileTalkSaveResponse extends APIResponse {
RoomID?: string;
FileName?: string;
FileExt?: string;
FileType?: string;
ThumbURL?: string;
AttSEQ?: string;
AttSize?: string;
AttRegDate?: string;
ImageWidth?: string;
ImageHeight?: string;
CompanyCode?: string;
VoiceTime?: string;
SynapKey?: string;
}

View File

@ -0,0 +1,24 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface FileTalkShareRequest extends APIRequest {
userSeq: string;
deviceType: DeviceType;
token: string;
attachmentsSeq?: string;
roomId?: string;
synapKey?: string;
}
export interface FileTalkShareResponse extends APIResponse {
RoomID?: string;
FileName?: string;
FileExt?: string;
FileType?: string;
ThumbURL?: string;
AttSEQ?: string;
AttSize?: string;
AttRegDate?: string;
CompanyCode?: string;
SynapKey?: string;
}

View File

@ -0,0 +1,15 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface MassTalkDownloadRequest extends APIRequest {
userSeq: string;
deviceType: DeviceType;
token: string;
eventMassSeq?: string;
}
export interface MassTalkDownloadResponse extends APIResponse {
Content?: string;
UserName?: string;
RegDate?: string;
}

View File

@ -0,0 +1,17 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface MassTalkSaveRequest extends APIRequest {
userSeq: string;
deviceType: DeviceType;
token: string;
content?: string;
roomId?: string;
}
export interface MassTalkSaveResponse extends APIResponse {
EventMassSEQ?: string;
RoomID?: string;
RegDate?: string;
Content?: string;
}

View File

@ -0,0 +1,17 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface TransMassTalkDownloadRequest extends APIRequest {
userSeq: string;
deviceType: DeviceType;
token: string;
eventTransSeq?: string;
}
export interface TransMassTalkDownloadResponse extends APIResponse {
Original?: string;
Translation?: string;
Locale?: string;
UserName?: string;
RegDate?: string;
}

View File

@ -0,0 +1,21 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface TransMassTalkSaveRequest extends APIRequest {
userSeq: string;
deviceType: DeviceType;
token: string;
original?: string;
translation?: string;
roomId?: string;
locale: string;
}
export interface TransMassTalkSaveResponse extends APIResponse {
EventTransSEQ?: string;
RoomID?: string;
RegDate?: string;
Locale?: string;
Original?: string;
Translation?: string;
}

View File

@ -0,0 +1,18 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface TranslationReqRequest extends APIRequest {
userSeq: string;
deviceType: DeviceType;
token: string;
original: string;
srcLocale: string;
destLocale: string;
}
export interface TranslationReqResponse extends APIResponse {
SrcLocale?: string;
DestLocale?: string;
Original?: string;
Translation?: string;
}

View File

@ -0,0 +1,22 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface TranslationSaveRequest extends APIRequest {
userSeq: string;
deviceType: DeviceType;
token: string;
roomId?: string;
original?: string;
srcLocale: string;
destLocale: string;
}
export interface TranslationSaveResponse extends APIResponse {
EventTransSeq?: string;
RoomID?: string;
RegDate?: string;
SrcLocale?: string;
DestLocale?: string;
Original?: string;
Translation?: string;
}

View File

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { CommonApiService } from './common-api.service';
describe('CommonApiService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: CommonApiService = TestBed.get(CommonApiService);
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,227 @@
import { Injectable, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { _MODULE_CONFIG } from '../types/token';
import { ModuleConfig } from '../types/module-config';
import {
FileProfileSaveRequest,
FileProfileSaveResponse
} from '../models/file-profile-save';
import { FileTalkDownloadRequest } from '../models/file-talk-download';
import {
FileTalkSaveRequest,
FileTalkSaveResponse
} from '../models/file-talk-save';
import {
FileTalkShareRequest,
FileTalkShareResponse
} from '../models/file-talk-share';
import {
MassTalkDownloadRequest,
MassTalkDownloadResponse
} from '../models/mass-talk-download';
import {
MassTalkSaveRequest,
MassTalkSaveResponse
} from '../models/mass-talk-save';
import {
TransMassTalkDownloadRequest,
TransMassTalkDownloadResponse
} from '../models/trans-mass-talk-download';
import {
TransMassTalkSaveRequest,
TransMassTalkSaveResponse
} from '../models/trans-mass-talk-save';
import {
TranslationReqRequest,
TranslationReqResponse
} from '../models/translation-req';
import {
TranslationSaveRequest,
TranslationSaveResponse
} from '../models/translation-save';
@Injectable({
providedIn: 'root'
})
export class CommonApiService {
constructor(
@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig,
private httpClient: HttpClient
) {}
public fileProfileSave(
req: FileProfileSaveRequest
): Observable<FileProfileSaveResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.fileProfileSave,
{},
{
params: {}
}
)
.pipe(
map(res => {
return {} as FileProfileSaveResponse;
})
);
}
public fileTalkDownload(req: FileTalkDownloadRequest): Observable<Blob> {
return this.httpClient.post<Blob>(
this.moduleConfig.urls.fileTalkDownload,
{ responseType: 'blob' },
{
params: {}
}
);
}
public fileTalkSave(
req: FileTalkSaveRequest
): Observable<FileTalkSaveResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.fileTalkSave,
{},
{
params: {}
}
)
.pipe(
map(res => {
return {} as FileTalkSaveResponse;
})
);
}
public fileTalkShare(
req: FileTalkShareRequest
): Observable<FileTalkShareResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.fileTalkShare,
{},
{
params: {}
}
)
.pipe(
map(res => {
return {} as FileTalkShareResponse;
})
);
}
public massTalkDownload(
req: MassTalkDownloadRequest
): Observable<MassTalkDownloadResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.massTalkDownload,
{},
{
params: {}
}
)
.pipe(
map(res => {
return {} as MassTalkDownloadResponse;
})
);
}
public massTalkSave(
req: MassTalkSaveRequest
): Observable<MassTalkSaveResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.massTalkSave,
{},
{
params: {}
}
)
.pipe(
map(res => {
return {} as MassTalkSaveResponse;
})
);
}
public transMassTalkDownload(
req: TransMassTalkDownloadRequest
): Observable<TransMassTalkDownloadResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.transMassTalkDownload,
{},
{
params: {}
}
)
.pipe(
map(res => {
return {} as TransMassTalkDownloadResponse;
})
);
}
public transMassTalkSave(
req: TransMassTalkSaveRequest
): Observable<TransMassTalkSaveResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.transMassTalkSave,
{},
{
params: {}
}
)
.pipe(
map(res => {
return {} as TransMassTalkSaveResponse;
})
);
}
public translationReq(
req: TranslationReqRequest
): Observable<TranslationReqResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.translationReq,
{},
{
params: {}
}
)
.pipe(
map(res => {
return {} as TranslationReqResponse;
})
);
}
public translationSave(
req: TranslationSaveRequest
): Observable<TranslationSaveResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.translationSave,
{},
{
params: {}
}
)
.pipe(
map(res => {
return {} as TranslationSaveResponse;
})
);
}
}

View File

@ -0,0 +1,14 @@
export interface ModuleConfig {
urls: {
fileProfileSave: string;
fileTalkDownload: string;
fileTalkSave: string;
fileTalkShare: string;
massTalkDownload: string;
massTalkSave: string;
transMassTalkDownload: string;
transMassTalkSave: string;
translationReq: string;
translationSave: string;
};
}

View File

@ -0,0 +1,5 @@
import { InjectionToken } from '@angular/core';
export const _MODULE_CONFIG = new InjectionToken(
'@ucap-webmessenger/api-common config of module'
);

View File

@ -0,0 +1,23 @@
import { NgModule, ModuleWithProviders } from '@angular/core';
import { _MODULE_CONFIG } from './types/token';
import { CommonApiService } from './services/common-api.service';
import { ModuleConfig } from './types/module-config';
const SERVICES = [CommonApiService];
@NgModule({
declarations: [],
imports: [],
exports: []
})
export class UCapCommonApiModule {
public static forRoot(
config: ModuleConfig
): ModuleWithProviders<UCapCommonApiModule> {
return {
ngModule: UCapCommonApiModule,
providers: [{ provide: _MODULE_CONFIG, useValue: config }, ...SERVICES]
};
}
}

View File

@ -0,0 +1,20 @@
/*
* Public API Surface of ucap-webmessenger-api-common
*/
export * from './lib/types/module-config';
export * from './lib/models/file-profile-save';
export * from './lib/models/file-talk-download';
export * from './lib/models/file-talk-save';
export * from './lib/models/file-talk-share';
export * from './lib/models/mass-talk-download';
export * from './lib/models/mass-talk-save';
export * from './lib/models/trans-mass-talk-download';
export * from './lib/models/trans-mass-talk-save';
export * from './lib/models/translation-req';
export * from './lib/models/translation-save';
export * from './lib/services/common-api.service';
export * from './lib/ucap-common-api.module';

View File

@ -0,0 +1,21 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone';
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);

View File

@ -0,0 +1,26 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"inlineSources": true,
"types": [],
"lib": [
"dom",
"es2018"
]
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}

View File

@ -0,0 +1,17 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"src/test.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}

View File

@ -0,0 +1,17 @@
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"ucapApiCommon",
"camelCase"
],
"component-selector": [
true,
"element",
"ucap-api-common",
"kebab-case"
]
}
}

View File

@ -0,0 +1,24 @@
# UcapWebmessengerApiExternal
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.2.4.
## Code scaffolding
Run `ng generate component component-name --project ucap-webmessenger-api-external` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ucap-webmessenger-api-external`.
> Note: Don't forget to add `--project ucap-webmessenger-api-external` or else it will be added to the default project in your `angular.json` file.
## Build
Run `ng build ucap-webmessenger-api-external` to build the project. The build artifacts will be stored in the `dist/` directory.
## Publishing
After building your library with `ng build ucap-webmessenger-api-external`, go to the dist folder `cd dist/ucap-webmessenger-api-external` and run `npm publish`.
## Running unit tests
Run `ng test ucap-webmessenger-api-external` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

View File

@ -0,0 +1,32 @@
// 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-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../../coverage/ucap-webmessenger-api-external'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};

View File

@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/ucap-webmessenger-api-external",
"lib": {
"entryFile": "src/public-api.ts"
}
}

View File

@ -0,0 +1,8 @@
{
"name": "@ucap-webmessenger/api-external",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^8.2.4",
"@angular/core": "^8.2.4"
}
}

View File

@ -0,0 +1,11 @@
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface CheckUserInfoExRequest extends APIRequest {
userId: string;
companyCode: string;
userSession: string;
}
export interface CheckUserInfoExResponse extends APIResponse {
userId?: string;
}

View File

@ -0,0 +1,23 @@
import { AppType, DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface CompanyListRequest extends APIRequest {
userSeq?: string;
appType?: AppType;
deviceType?: DeviceType;
token?: string;
companyGroupCode: string;
}
export interface Company {
companyCode?: string;
companyName?: string;
companyDomain?: string;
companyConfAuthYn?: string;
ucapUseYn?: string;
companyTimerChatAuthYn?: string;
}
export interface CompanyListResponse extends APIResponse {
companyList?: Company[];
}

View File

@ -0,0 +1,13 @@
import { DeviceType, PushType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface TokenUpdateRequest extends APIRequest {
userSeq: string;
deviceType: DeviceType;
token: string;
mobilePid?: string;
pushType?: PushType;
}
// tslint:disable-next-line: no-empty-interface
export interface TokenUpdateResponse extends APIResponse {}

View File

@ -0,0 +1,21 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface UrlInfoRequest extends APIRequest {
deviceType: DeviceType;
}
export interface UrlInfoResponse extends APIResponse {
portCheckUrl?: string;
messageUrl?: string;
messageUrl2?: string;
passwordUrl?: string;
planUrl?: string;
planUrl2?: string;
vocUrl?: string;
confUrl?: string;
uprApiUrl?: string;
uprSvcUrl?: string;
uprDownloadUrl?: string;
synapViewUrl?: string;
}

View File

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { ExternalApiService } from './external-api.service';
describe('ExternalApiService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: ExternalApiService = TestBed.get(ExternalApiService);
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,154 @@
import { Injectable, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { _MODULE_CONFIG } from '../types/token';
import { ModuleConfig } from '../types/module-config';
import {
CheckUserInfoExRequest,
CheckUserInfoExResponse
} from '../models/check-user-info-ex';
import {
CompanyListRequest,
CompanyListResponse,
Company
} from '../models/company-list';
import {
TokenUpdateRequest,
TokenUpdateResponse
} from '../models/token-update';
import { UrlInfoResponse, UrlInfoRequest } from '../models/url-info';
@Injectable({
providedIn: 'root'
})
export class ExternalApiService {
constructor(
@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig,
private httpClient: HttpClient
) {}
public checkUserInfoEx(
req: CheckUserInfoExRequest
): Observable<CheckUserInfoExResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.checkUserInfoEx,
{},
{
params: {
p_user_id: req.userId,
p_comp_code: req.companyCode,
p_user_session: req.userSession
}
}
)
.pipe(
map(res => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
userId: res.UserID
} as CheckUserInfoExResponse;
})
);
}
public companyList(req: CompanyListRequest): Observable<CompanyListResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.companyList,
{},
{
params: {
p_user_seq: req.userSeq,
p_app_type: req.appType,
p_device_type: req.deviceType,
p_token: req.token,
p_comp_group_code: req.companyGroupCode
}
}
)
.pipe(
map(res => {
let companyList: Company[] | undefined;
if (!!res.CompanyList) {
companyList = [];
for (const company of res.CompanyList) {
companyList.push({
companyCode: company.COMPANY_CODE,
companyName: company.COMPANY_NAME,
companyDomain: company.COMPANY_DOMAIN,
companyConfAuthYn: company.COMPANY_CONF_AUTH,
ucapUseYn: company.UCAP_USE_YN,
companyTimerChatAuthYn: company.COMPANY_TIMER_CHAT_AUTH
});
}
}
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
companyList
} as CompanyListResponse;
})
);
}
public tokenUpdate(req: TokenUpdateRequest): Observable<TokenUpdateResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.tokenUpdate,
{},
{
params: {
p_user_seq: req.userSeq,
p_device_type: req.deviceType,
p_token: req.token,
p_mobile_pid: req.mobilePid,
p_push_type: req.pushType
}
}
)
.pipe(
map(res => {
return {} as TokenUpdateResponse;
})
);
}
public urlInfo(req: UrlInfoRequest): Observable<UrlInfoResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.urlInfo,
{},
{
params: {
p_device_type: req.deviceType
}
}
)
.pipe(
map(res => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
portCheckUrl: res.PortCheckURL,
messageUrl: res.MsgURL,
messageUrl2: res.MsgURL2,
passwordUrl: res.PasswordURL,
planUrl: res.PlanURL,
planUrl2: res.PlanURL2,
vocUrl: res.VocURL,
confUrl: res.ConfURL,
uprApiUrl: res.UprApiURL,
uprSvcUrl: res.UprSvcURL,
uprDownloadUrl: res.UprDownloadURL,
synapViewUrl: res.SynapViewURL
} as UrlInfoResponse;
})
);
}
}

View File

@ -0,0 +1,8 @@
export interface ModuleConfig {
urls: {
checkUserInfoEx: string;
companyList: string;
tokenUpdate: string;
urlInfo: string;
};
}

View File

@ -0,0 +1,5 @@
import { InjectionToken } from '@angular/core';
export const _MODULE_CONFIG = new InjectionToken(
'@ucap-webmessenger/api-external config of module'
);

View File

@ -0,0 +1,23 @@
import { NgModule, ModuleWithProviders } from '@angular/core';
import { _MODULE_CONFIG } from './types/token';
import { ExternalApiService } from './services/external-api.service';
import { ModuleConfig } from './types/module-config';
const SERVICES = [ExternalApiService];
@NgModule({
declarations: [],
imports: [],
exports: []
})
export class UCapExternalApiModule {
public static forRoot(
config: ModuleConfig
): ModuleWithProviders<UCapExternalApiModule> {
return {
ngModule: UCapExternalApiModule,
providers: [{ provide: _MODULE_CONFIG, useValue: config }, ...SERVICES]
};
}
}

View File

@ -0,0 +1,14 @@
/*
* Public API Surface of ucap-webmessenger-api-public
*/
export * from './lib/types/module-config';
export * from './lib/models/check-user-info-ex';
export * from './lib/models/company-list';
export * from './lib/models/token-update';
export * from './lib/models/url-info';
export * from './lib/services/external-api.service';
export * from './lib/ucap-external-api.module';

View File

@ -0,0 +1,21 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone';
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);

View File

@ -0,0 +1,26 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"inlineSources": true,
"types": [],
"lib": [
"dom",
"es2018"
]
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}

View File

@ -0,0 +1,17 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"src/test.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}

View File

@ -0,0 +1,17 @@
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"ucapApiExternal",
"camelCase"
],
"component-selector": [
true,
"element",
"ucap-api-external",
"kebab-case"
]
}
}

View File

@ -0,0 +1,24 @@
# UcapWebmessengerApiPublic
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.2.4.
## Code scaffolding
Run `ng generate component component-name --project ucap-webmessenger-api-public` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ucap-webmessenger-api-public`.
> Note: Don't forget to add `--project ucap-webmessenger-api-public` or else it will be added to the default project in your `angular.json` file.
## Build
Run `ng build ucap-webmessenger-api-public` to build the project. The build artifacts will be stored in the `dist/` directory.
## Publishing
After building your library with `ng build ucap-webmessenger-api-public`, go to the dist folder `cd dist/ucap-webmessenger-api-public` and run `npm publish`.
## Running unit tests
Run `ng test ucap-webmessenger-api-public` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

View File

@ -0,0 +1,32 @@
// 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-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../../coverage/ucap-webmessenger-api-public'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};

View File

@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/ucap-webmessenger-api-public",
"lib": {
"entryFile": "src/public-api.ts"
}
}

View File

@ -0,0 +1,8 @@
{
"name": "@ucap-webmessenger/api-public",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^8.2.4",
"@angular/core": "^8.2.4"
}
}

View File

@ -0,0 +1,13 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface UpdateInfoRequest extends APIRequest {
deviceType: DeviceType;
}
export interface UpdateInfoResponse extends APIResponse {
appVersion?: string;
installUrl?: string;
launcherAppVersion?: string;
launcherInstallUrl?: string;
}

View File

@ -0,0 +1,29 @@
import { DeviceType } from '@ucap-webmessenger/core';
import { APIRequest, APIResponse } from '@ucap-webmessenger/api';
export interface VersionInfoRequest extends APIRequest {
userSeq?: string;
deviceType: DeviceType;
token?: string;
companyGroupType: string;
companyCode: string;
loginId: string;
}
export interface VersionInfoResponse extends APIResponse {
protocolCode?: string;
syncMode?: string;
appVersion?: string;
installUrl?: string;
serverIp?: string;
serverPort?: string;
uploadUrl?: string;
downloadUrl?: string;
profileUploadUrl?: string;
profileRoot?: string;
fileTerm?: string;
fileAllowSize?: string;
authIp?: string;
launcherAppVersion?: string;
launcherInstallUrl?: string;
}

View File

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { PublicApiService } from './public-api.service';
describe('PublicApiService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: PublicApiService = TestBed.get(PublicApiService);
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,89 @@
import { Injectable, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { _MODULE_CONFIG } from '../types/token';
import {
VersionInfoRequest,
VersionInfoResponse
} from '../models/version-info';
import { UpdateInfoRequest, UpdateInfoResponse } from '../models/update-info';
import { ModuleConfig } from '../types/module-config';
@Injectable({
providedIn: 'root'
})
export class PublicApiService {
constructor(
@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig,
private httpClient: HttpClient
) {}
public versionInfo(req: VersionInfoRequest): Observable<VersionInfoResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.versionInfo,
{},
{
params: {
p_user_seq: req.userSeq,
p_device_type: req.deviceType,
p_token: req.token,
p_comp_group_type: req.companyGroupType,
p_comp_code: req.companyCode,
p_login_id: req.loginId
}
}
)
.pipe(
map(res => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
protocolCode: res.ProtocolCD,
syncMode: res.SyncMode,
appVersion: res.AppVer,
installUrl: res.InstallURL,
serverIp: res.ServerIP,
serverPort: res.ServerPort,
uploadUrl: res.UploadURL,
downloadUrl: res.DownloadURL,
profileUploadUrl: res.ProfileUploadURL,
profileRoot: res.ProfileRoot,
fileTerm: res.FileTerm,
fileAllowSize: res.FileAllowSize,
authIp: res.AuthIP,
launcherAppVersion: res.LauncherAppVer,
launcherInstallUrl: res.LauncherInstallURL
} as VersionInfoResponse;
})
);
}
public updateInfo(req: UpdateInfoRequest): Observable<UpdateInfoResponse> {
return this.httpClient
.post<any>(
this.moduleConfig.urls.updateInfo,
{},
{
params: {
p_device_type: req.deviceType
}
}
)
.pipe(
map(res => {
return {
statusCode: res.StatusCode,
errorMessage: res.ErrorMessage,
appVersion: res.AppVer,
installUrl: res.InstallURL,
launcherAppVersion: res.LauncherAppVer,
launcherInstallUrl: res.LauncherInstallURL
} as UpdateInfoResponse;
})
);
}
}

View File

@ -0,0 +1,6 @@
export interface ModuleConfig {
urls: {
versionInfo: string;
updateInfo: string;
};
}

View File

@ -0,0 +1,5 @@
import { InjectionToken } from '@angular/core';
export const _MODULE_CONFIG = new InjectionToken(
'@ucap-webmessenger/api-public config of module'
);

View File

@ -0,0 +1,23 @@
import { NgModule, ModuleWithProviders } from '@angular/core';
import { _MODULE_CONFIG } from './types/token';
import { PublicApiService } from './services/public-api.service';
import { ModuleConfig } from './types/module-config';
const SERVICES = [PublicApiService];
@NgModule({
declarations: [],
imports: [],
exports: []
})
export class UCapPublicApiModule {
public static forRoot(
config: ModuleConfig
): ModuleWithProviders<UCapPublicApiModule> {
return {
ngModule: UCapPublicApiModule,
providers: [{ provide: _MODULE_CONFIG, useValue: config }, ...SERVICES]
};
}
}

View File

@ -0,0 +1,12 @@
/*
* Public API Surface of ucap-webmessenger-api-public
*/
export * from './lib/types/module-config';
export * from './lib/models/update-info';
export * from './lib/models/version-info';
export * from './lib/services/public-api.service';
export * from './lib/ucap-public-api.module';

View File

@ -0,0 +1,21 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone';
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);

View File

@ -0,0 +1,26 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"inlineSources": true,
"types": [],
"lib": [
"dom",
"es2018"
]
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}

View File

@ -0,0 +1,17 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"src/test.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}

View File

@ -0,0 +1,17 @@
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"ucapApiPublic",
"camelCase"
],
"component-selector": [
true,
"element",
"ucap-api-public",
"kebab-case"
]
}
}

View File

@ -0,0 +1,24 @@
# UcapWebmessengerApi
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.2.4.
## Code scaffolding
Run `ng generate component component-name --project ucap-webmessenger-api` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ucap-webmessenger-api`.
> Note: Don't forget to add `--project ucap-webmessenger-api` or else it will be added to the default project in your `angular.json` file.
## Build
Run `ng build ucap-webmessenger-api` to build the project. The build artifacts will be stored in the `dist/` directory.
## Publishing
After building your library with `ng build ucap-webmessenger-api`, go to the dist folder `cd dist/ucap-webmessenger-api` and run `npm publish`.
## Running unit tests
Run `ng test ucap-webmessenger-api` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

View File

@ -0,0 +1,32 @@
// 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-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../../coverage/ucap-webmessenger-api'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};

View File

@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/ucap-webmessenger-api",
"lib": {
"entryFile": "src/public-api.ts"
}
}

View File

@ -0,0 +1,8 @@
{
"name": "@ucap-webmessenger/api",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^8.2.4",
"@angular/core": "^8.2.4"
}
}

View File

@ -0,0 +1,9 @@
export interface APIRequest {
_id?: string;
}
export interface APIResponse {
_id?: string;
statusCode: string;
errorMessage: string;
}

View File

@ -0,0 +1,3 @@
export enum StatusCode {
Success = '200'
}

Some files were not shown because too many files have changed in this diff Show More