@regulaforensics/idv-interfaces 0.1.248-nightly
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/index.d.ts +59 -0
- package/dist/main.js +102 -0
- package/package.json +24 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export declare class BaseError {
|
|
2
|
+
errorCode: number | string;
|
|
3
|
+
errorCodeKey: string;
|
|
4
|
+
message?: string;
|
|
5
|
+
underlyingError?: string;
|
|
6
|
+
underlyingBaseError?: BaseError;
|
|
7
|
+
domain?: string;
|
|
8
|
+
module: string;
|
|
9
|
+
errorEnumName: string;
|
|
10
|
+
shortDomainCode: string;
|
|
11
|
+
constructor({ errorCode, errorCodeKey, message, underlyingError, underlyingBaseError, domain, module, errorEnumName, shortDomainCode, }: {
|
|
12
|
+
errorCode: number | string;
|
|
13
|
+
errorCodeKey: string;
|
|
14
|
+
module: string;
|
|
15
|
+
message?: string;
|
|
16
|
+
underlyingError?: string;
|
|
17
|
+
underlyingBaseError?: BaseError;
|
|
18
|
+
domain?: string;
|
|
19
|
+
errorEnumName: string;
|
|
20
|
+
shortDomainCode: string;
|
|
21
|
+
});
|
|
22
|
+
static getErrorKey<T extends Record<string, any>>(errorCode: number | string, errorEnum: T): string;
|
|
23
|
+
get lastUnderlyingError(): string | undefined;
|
|
24
|
+
toObject(): Record<string, any>;
|
|
25
|
+
get shortChain(): string;
|
|
26
|
+
get fullChain(): string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare abstract class BaseModule<TModuleProps = unknown, TModulesConfig = unknown> extends HTMLElement {
|
|
30
|
+
abstract props: IdvModuleProps<TModuleProps, TModulesConfig> | null;
|
|
31
|
+
abstract setProps(config: IdvModuleProps<TModuleProps, TModulesConfig>): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export declare function cleanObjectFromUndefined(obj: Record<string, unknown>): Record<string, unknown>;
|
|
35
|
+
|
|
36
|
+
export declare type IdvModuleProps<TModuleProps, TModulesConfig> = {
|
|
37
|
+
isProcessing?: (isProcessing: boolean) => void;
|
|
38
|
+
moduleProps: TModuleProps;
|
|
39
|
+
modulesConfig?: TModulesConfig;
|
|
40
|
+
perform: (data: any) => void;
|
|
41
|
+
idvEventListener: (module: string, data: any) => void;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export declare interface IdvModuleStaticMethods {
|
|
45
|
+
displayName: string;
|
|
46
|
+
isReady(): boolean;
|
|
47
|
+
getSupportedTemplates(): string[];
|
|
48
|
+
initialize(modulesConfig: Record<string, unknown>): void;
|
|
49
|
+
deinitialize(): void;
|
|
50
|
+
getIdentifier(): string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export declare type ModuleClass<TModuleProps = unknown, TModulesConfig = unknown> = IdvModuleStaticMethods & (new (...args: any[]) => BaseModule<TModuleProps, TModulesConfig>);
|
|
54
|
+
|
|
55
|
+
export declare function parseClientJSON<T>(json: T): T;
|
|
56
|
+
|
|
57
|
+
export declare function registerModule<TModuleProps = unknown, TModulesConfig = unknown>(name: string, ModuleClass: ModuleClass<TModuleProps, TModulesConfig>): void;
|
|
58
|
+
|
|
59
|
+
export { }
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var l = Object.defineProperty;
|
|
2
|
+
var m = Object.getOwnPropertySymbols;
|
|
3
|
+
var u = Object.prototype.hasOwnProperty, E = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var y = (r, e, i) => e in r ? l(r, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[e] = i, s = (r, e) => {
|
|
5
|
+
for (var i in e || (e = {}))
|
|
6
|
+
u.call(e, i) && y(r, i, e[i]);
|
|
7
|
+
if (m)
|
|
8
|
+
for (var i of m(e))
|
|
9
|
+
E.call(e, i) && y(r, i, e[i]);
|
|
10
|
+
return r;
|
|
11
|
+
};
|
|
12
|
+
class o {
|
|
13
|
+
constructor({
|
|
14
|
+
errorCode: e,
|
|
15
|
+
errorCodeKey: i,
|
|
16
|
+
message: t,
|
|
17
|
+
underlyingError: n,
|
|
18
|
+
underlyingBaseError: g,
|
|
19
|
+
domain: f,
|
|
20
|
+
module: c,
|
|
21
|
+
errorEnumName: a,
|
|
22
|
+
shortDomainCode: p
|
|
23
|
+
}) {
|
|
24
|
+
this.errorCode = e, this.errorCodeKey = i, this.message = t, this.underlyingError = n, this.underlyingBaseError = g, this.module = c, this.domain = f, this.errorEnumName = a, this.shortDomainCode = p;
|
|
25
|
+
}
|
|
26
|
+
static getErrorKey(e, i) {
|
|
27
|
+
const t = Object.keys(i).find((n) => i[n] === e);
|
|
28
|
+
if (!t)
|
|
29
|
+
throw new Error(`Invalid errorCode: ${e} in enum`);
|
|
30
|
+
return t;
|
|
31
|
+
}
|
|
32
|
+
get lastUnderlyingError() {
|
|
33
|
+
let e = this.underlyingBaseError;
|
|
34
|
+
for (; (e == null ? void 0 : e.underlyingBaseError) instanceof o; )
|
|
35
|
+
e = e.underlyingBaseError;
|
|
36
|
+
return e == null ? void 0 : e.underlyingError;
|
|
37
|
+
}
|
|
38
|
+
toObject() {
|
|
39
|
+
const e = {
|
|
40
|
+
errorCode: this.errorCode,
|
|
41
|
+
errorCodeKey: this.errorCodeKey,
|
|
42
|
+
errorEnumName: this.errorEnumName,
|
|
43
|
+
message: this.message,
|
|
44
|
+
module: this.module,
|
|
45
|
+
underlyingError: this.underlyingError,
|
|
46
|
+
lastUnderlineError: this.lastUnderlyingError
|
|
47
|
+
};
|
|
48
|
+
return this.underlyingBaseError && this.underlyingBaseError instanceof o && (e.underlyingBaseError = this.underlyingBaseError.toObject()), e;
|
|
49
|
+
}
|
|
50
|
+
get shortChain() {
|
|
51
|
+
let e = `${this.shortDomainCode}:${this.errorCode}${this.underlyingError ? "-" + this.underlyingError : ""}`;
|
|
52
|
+
return this.underlyingBaseError instanceof o && (e += `-${this.underlyingBaseError.shortChain}`), e;
|
|
53
|
+
}
|
|
54
|
+
get fullChain() {
|
|
55
|
+
let e = `${this.module}.${this.domain}:${this.errorCodeKey}${this.underlyingError ? "-" + this.underlyingError : ""}`;
|
|
56
|
+
return this.underlyingBaseError instanceof o && (e += `-${this.underlyingBaseError.fullChain}`), e;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
class b extends HTMLElement {
|
|
60
|
+
}
|
|
61
|
+
function w(r, e) {
|
|
62
|
+
if (e.displayName ? console.log(`Register module: ${e.displayName}`) : console.error('Missed "displayName" when register module'), e.getSupportedTemplates && typeof e.getSupportedTemplates == "function") {
|
|
63
|
+
const i = e.getSupportedTemplates();
|
|
64
|
+
console.log(`${e == null ? void 0 : e.displayName} supported templates: ${i.join(", ")}`);
|
|
65
|
+
} else
|
|
66
|
+
console.error('Missed "getSupportedTemplates" method when register module');
|
|
67
|
+
if (e.initialize && typeof e.initialize == "function" || console.error(`${e == null ? void 0 : e.displayName} "initialize" method was not implemented`), e.deinitialize && typeof e.deinitialize == "function" || console.error(`${e == null ? void 0 : e.displayName} "deinitialize" method was not implemented`), e.isReady && typeof e.isReady == "function" || console.error(`${e == null ? void 0 : e.displayName} "isReady" method was not implemented`), e.getIdentifier && typeof e.getIdentifier == "function") {
|
|
68
|
+
const i = e.getIdentifier();
|
|
69
|
+
console.log(`Module id: ${i}`);
|
|
70
|
+
} else
|
|
71
|
+
console.error('Missed "getIdentifier" when register module');
|
|
72
|
+
customElements.get(e.getIdentifier()) ? console.log(`Module ${r} has already registered`) : customElements.define(r, e), console.log("-------");
|
|
73
|
+
}
|
|
74
|
+
const h = (r) => typeof r == "object" && r !== null && !Array.isArray(r);
|
|
75
|
+
function d(r) {
|
|
76
|
+
if (Array.isArray(r))
|
|
77
|
+
return r.map(d);
|
|
78
|
+
if (h(r)) {
|
|
79
|
+
const e = s({}, r);
|
|
80
|
+
if (delete e.ios, delete e.android, delete e.web, "web" in r)
|
|
81
|
+
if (h(r.web)) {
|
|
82
|
+
const t = d(e);
|
|
83
|
+
return s(s({}, t), r.web);
|
|
84
|
+
} else
|
|
85
|
+
return r.web;
|
|
86
|
+
const i = {};
|
|
87
|
+
for (const [t, n] of Object.entries(e))
|
|
88
|
+
i[t] = d(n);
|
|
89
|
+
return i;
|
|
90
|
+
}
|
|
91
|
+
return r;
|
|
92
|
+
}
|
|
93
|
+
function N(r) {
|
|
94
|
+
return Object.fromEntries(Object.entries(r).filter(([, e]) => e !== void 0));
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
o as BaseError,
|
|
98
|
+
b as BaseModule,
|
|
99
|
+
N as cleanObjectFromUndefined,
|
|
100
|
+
d as parseClientJSON,
|
|
101
|
+
w as registerModule
|
|
102
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@regulaforensics/idv-interfaces",
|
|
3
|
+
"version": "0.1.248-nightly",
|
|
4
|
+
"description": "Regula framework agnostic web components to work with document idv",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"main": "./dist/main.js",
|
|
7
|
+
"module": "./dist/main.js",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
"import": "./dist/main.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist/main.js",
|
|
15
|
+
"dist/index.d.ts"
|
|
16
|
+
],
|
|
17
|
+
"author": "Regula Forensics, Inc.",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"homepage": "https://storybook-face.regulaforensics.com/",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "vite build",
|
|
22
|
+
"test": "vitest run"
|
|
23
|
+
}
|
|
24
|
+
}
|