@blurpaper/shared 2.0.4 → 2.0.8
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/dist/classes/key-alphabet.class.d.ts +1 -1
- package/dist/classes/key-alphabet.class.js +3 -4
- package/dist/helpers/object.helper.js +1 -1
- package/package.json +1 -1
- package/dist/classes/paper-configuration.class.d.ts +0 -11
- package/dist/classes/paper-configuration.class.js +0 -45
- package/dist/classes/url-formatter.class.d.ts +0 -4
- package/dist/classes/url-formatter.class.js +0 -10
- package/dist/interfaces/env.interface.d.ts +0 -16
- package/dist/interfaces/env.interface.js +0 -2
|
@@ -8,7 +8,7 @@ export declare class KeyAlphabet {
|
|
|
8
8
|
getKeyAlphabetMap(session?: string): Record<string, string>;
|
|
9
9
|
getAlphabetKeyMap(session?: string): Record<string, string>;
|
|
10
10
|
addToAlphabet(key: string, session?: string, settings?: IAlphabetSettingsInput): string;
|
|
11
|
-
getNextAlphabet(key: string, session?: string, settings?: IAlphabetSettingsInput): string;
|
|
11
|
+
getNextAlphabet(key: string, session?: string, settings?: IAlphabetSettingsInput, next?: string): string;
|
|
12
12
|
nextAlphabet(key?: string): string;
|
|
13
13
|
formatGeneratedAlphabet(alphabet: string, settings?: IAlphabetSettingsInput): string;
|
|
14
14
|
}
|
|
@@ -34,15 +34,14 @@ class KeyAlphabet {
|
|
|
34
34
|
if ((!settings || settings.noLowerKeys) && (this.lastGeneratedAlphabetMap[session].length >= key.length)) {
|
|
35
35
|
return key;
|
|
36
36
|
}
|
|
37
|
-
this.
|
|
38
|
-
const generatedAlphabet = this.getNextAlphabet(key, session, settings);
|
|
37
|
+
const generatedAlphabet = this.getNextAlphabet(key, session, settings, this.nextAlphabet(this.lastGeneratedAlphabetMap[session]));
|
|
39
38
|
this.alphabetKeyMap[session][generatedAlphabet] = key;
|
|
40
39
|
if (!settings || settings.addKeyAlphabet) {
|
|
41
40
|
this.keyAlphabetMap[session][key] = generatedAlphabet;
|
|
42
41
|
}
|
|
43
42
|
return generatedAlphabet;
|
|
44
43
|
}
|
|
45
|
-
getNextAlphabet(key, session = constants_1.ALPHABET_DEFAULT_SESSION, settings) {
|
|
44
|
+
getNextAlphabet(key, session = constants_1.ALPHABET_DEFAULT_SESSION, settings, next) {
|
|
46
45
|
if (!this.keyAlphabetMap[session]) {
|
|
47
46
|
this.keyAlphabetMap[session] = {};
|
|
48
47
|
}
|
|
@@ -58,7 +57,7 @@ class KeyAlphabet {
|
|
|
58
57
|
if ((!settings || settings.noLowerKeys) && (this.lastGeneratedAlphabetMap[session].length >= key.length)) {
|
|
59
58
|
return key;
|
|
60
59
|
}
|
|
61
|
-
this.lastGeneratedAlphabetMap[session] = this.nextAlphabet(this.lastGeneratedAlphabetMap[session]);
|
|
60
|
+
this.lastGeneratedAlphabetMap[session] = (next || this.nextAlphabet(this.lastGeneratedAlphabetMap[session]));
|
|
62
61
|
return this.formatGeneratedAlphabet(this.lastGeneratedAlphabetMap[session], settings);
|
|
63
62
|
}
|
|
64
63
|
nextAlphabet(key = constants_1.FIRST_ALPHABET) {
|
|
@@ -20,7 +20,7 @@ const recursivelyReassignKeysAndValues = (alphabetKeyMap, originalObject = {}, m
|
|
|
20
20
|
largeRepetitableIndex = (currentLargeRepetitableIndex >= 0) ? currentLargeRepetitableIndex : largeRepetitables.push(stringifiedLarge) - 1;
|
|
21
21
|
}
|
|
22
22
|
const alphabetKey = alphabetKeyMap.addToAlphabet(key, undefined, { noLowerKeys: true, addKeyAlphabet: true });
|
|
23
|
-
minifiedObject[alphabetKey] = isLargeRepetitable ? largeRepetitableIndex : (0, exports.isPrimitive)(nestedObject) ? (((key === 'value') && ((typeof nestedObject === 'string'))) || (typeof nestedObject === 'number') || !isNaN(Number(nestedObject)) || (typeof nestedObject === 'boolean') || constants_1.GUID_REGEX.test(nestedObject) || constants_1.NUMBER_REGEX.test(nestedObject) || (nestedObject === undefined) || (nestedObject === null) ? nestedObject : alphabetKeyMap.addToAlphabet(nestedObject, undefined, { noLowerKeys: true, addKeyAlphabet: true })) : {};
|
|
23
|
+
minifiedObject[alphabetKey] = isLargeRepetitable ? largeRepetitableIndex : (0, exports.isPrimitive)(nestedObject) ? (((key === 'value') && ((typeof nestedObject === 'string'))) || (typeof nestedObject === 'number') || !isNaN(Number(nestedObject)) || (typeof nestedObject === 'boolean') || constants_1.GUID_REGEX.test(nestedObject) || constants_1.NUMBER_REGEX.test(nestedObject) || (nestedObject === undefined) || (nestedObject === null) ? nestedObject : alphabetKeyMap.addToAlphabet(nestedObject, undefined, { noLowerKeys: true, addKeyAlphabet: true })) : (Array.isArray(nestedObject) ? [] : {});
|
|
24
24
|
if (!(0, exports.isPrimitive)(nestedObject) && !isLargeRepetitable && (!nestedObject[constants_1.VISITED_SESSION_GENERATION_KEY] || (nestedObject[constants_1.VISITED_SESSION_GENERATION_KEY] !== visitingSesion))) {
|
|
25
25
|
(0, exports.recursivelyReassignKeysAndValues)(alphabetKeyMap, nestedObject, minifiedObject[alphabetKey], largeRepetitables, visitingSesion);
|
|
26
26
|
nestedObject[constants_1.VISITED_SESSION_GENERATION_KEY] = visitingSesion;
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { IEnv } from "../interfaces/env.interface";
|
|
2
|
-
export declare class PaperConfiguration {
|
|
3
|
-
env: IEnv;
|
|
4
|
-
isProduction: boolean;
|
|
5
|
-
app: any;
|
|
6
|
-
https: any;
|
|
7
|
-
fs: any;
|
|
8
|
-
constructor(env: IEnv, app: any, https: any, fs: any);
|
|
9
|
-
startNodeServer(): void;
|
|
10
|
-
getCorsOrigin(): Record<string, string | RegExp>;
|
|
11
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PaperConfiguration = void 0;
|
|
4
|
-
class PaperConfiguration {
|
|
5
|
-
env;
|
|
6
|
-
isProduction;
|
|
7
|
-
app;
|
|
8
|
-
https;
|
|
9
|
-
fs;
|
|
10
|
-
constructor(env, app, https, fs) {
|
|
11
|
-
this.env = env;
|
|
12
|
-
this.isProduction = env.NODE_ENV === 'production';
|
|
13
|
-
this.app = app;
|
|
14
|
-
this.https = https;
|
|
15
|
-
this.fs = fs;
|
|
16
|
-
}
|
|
17
|
-
startNodeServer() {
|
|
18
|
-
let server = this.app;
|
|
19
|
-
if (this.isProduction && this.env.PRIVATE_KEY && this.env.FULL_CHAIN) {
|
|
20
|
-
try {
|
|
21
|
-
server = this.https.createServer({
|
|
22
|
-
key: this.fs.readFileSync(this.env.PRIVATE_KEY),
|
|
23
|
-
cert: this.fs.readFileSync(this.env.FULL_CHAIN),
|
|
24
|
-
rejectUnauthorized: false,
|
|
25
|
-
}, this.app);
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
console.log('ERROR:');
|
|
29
|
-
console.log('Could not start with SSL connection');
|
|
30
|
-
console.log(error);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
server.listen(this.env.PORT, () => {
|
|
34
|
-
console.log(`${this.env.APP_NAME} is listening on port ${this.env.PORT}!!!!`);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
getCorsOrigin() {
|
|
38
|
-
return {
|
|
39
|
-
origin: this.isProduction ?
|
|
40
|
-
/^(https:\/\/)([a-zA-Z0-9\-]+)?(?!\/)(?!\?).?(blurpaper.com):?([0-9]+)?/ :
|
|
41
|
-
'*'
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.PaperConfiguration = PaperConfiguration;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.URLFormatter = void 0;
|
|
4
|
-
class URLFormatter {
|
|
5
|
-
url;
|
|
6
|
-
constructor(protocol, linkTo, port) {
|
|
7
|
-
this.url = `${protocol}://${linkTo}:${port}`;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.URLFormatter = URLFormatter;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface IEnv {
|
|
2
|
-
LINK_TO_PAPER_CRUD?: string;
|
|
3
|
-
LINK_TO_PAPER_LOOP?: string;
|
|
4
|
-
LINK_TO_PAPER_EMAIL_BE?: string;
|
|
5
|
-
LINK_TO_PAPER_EBOOK_REPO?: string;
|
|
6
|
-
PAPER_EBOOK_REPO_PORT?: number;
|
|
7
|
-
PAPER_CRUD_PORT?: string;
|
|
8
|
-
PAPER_LOOP_PORT?: string;
|
|
9
|
-
PAPER_EMAIL_BE_PORT?: number;
|
|
10
|
-
PROTOCOL?: string;
|
|
11
|
-
NODE_ENV?: string;
|
|
12
|
-
PRIVATE_KEY?: string;
|
|
13
|
-
FULL_CHAIN?: string;
|
|
14
|
-
APP_NAME?: string;
|
|
15
|
-
PORT?: string;
|
|
16
|
-
}
|