@freshpointcz/fresh-core 0.0.11 → 0.0.13
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/index.d.mts +432 -0
- package/dist/index.d.ts +432 -0
- package/dist/index.js +1587 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1551 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +6 -6
package/dist/index.js
ADDED
|
@@ -0,0 +1,1587 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/dotenv/package.json
|
|
37
|
+
var require_package = __commonJS({
|
|
38
|
+
"../../node_modules/dotenv/package.json"(exports2, module2) {
|
|
39
|
+
module2.exports = {
|
|
40
|
+
name: "dotenv",
|
|
41
|
+
version: "16.6.1",
|
|
42
|
+
description: "Loads environment variables from .env file",
|
|
43
|
+
main: "lib/main.js",
|
|
44
|
+
types: "lib/main.d.ts",
|
|
45
|
+
exports: {
|
|
46
|
+
".": {
|
|
47
|
+
types: "./lib/main.d.ts",
|
|
48
|
+
require: "./lib/main.js",
|
|
49
|
+
default: "./lib/main.js"
|
|
50
|
+
},
|
|
51
|
+
"./config": "./config.js",
|
|
52
|
+
"./config.js": "./config.js",
|
|
53
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
54
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
55
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
56
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
57
|
+
"./package.json": "./package.json"
|
|
58
|
+
},
|
|
59
|
+
scripts: {
|
|
60
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
61
|
+
lint: "standard",
|
|
62
|
+
pretest: "npm run lint && npm run dts-check",
|
|
63
|
+
test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
64
|
+
"test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
65
|
+
prerelease: "npm test",
|
|
66
|
+
release: "standard-version"
|
|
67
|
+
},
|
|
68
|
+
repository: {
|
|
69
|
+
type: "git",
|
|
70
|
+
url: "git://github.com/motdotla/dotenv.git"
|
|
71
|
+
},
|
|
72
|
+
homepage: "https://github.com/motdotla/dotenv#readme",
|
|
73
|
+
funding: "https://dotenvx.com",
|
|
74
|
+
keywords: [
|
|
75
|
+
"dotenv",
|
|
76
|
+
"env",
|
|
77
|
+
".env",
|
|
78
|
+
"environment",
|
|
79
|
+
"variables",
|
|
80
|
+
"config",
|
|
81
|
+
"settings"
|
|
82
|
+
],
|
|
83
|
+
readmeFilename: "README.md",
|
|
84
|
+
license: "BSD-2-Clause",
|
|
85
|
+
devDependencies: {
|
|
86
|
+
"@types/node": "^18.11.3",
|
|
87
|
+
decache: "^4.6.2",
|
|
88
|
+
sinon: "^14.0.1",
|
|
89
|
+
standard: "^17.0.0",
|
|
90
|
+
"standard-version": "^9.5.0",
|
|
91
|
+
tap: "^19.2.0",
|
|
92
|
+
typescript: "^4.8.4"
|
|
93
|
+
},
|
|
94
|
+
engines: {
|
|
95
|
+
node: ">=12"
|
|
96
|
+
},
|
|
97
|
+
browser: {
|
|
98
|
+
fs: false
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// ../../node_modules/dotenv/lib/main.js
|
|
105
|
+
var require_main = __commonJS({
|
|
106
|
+
"../../node_modules/dotenv/lib/main.js"(exports2, module2) {
|
|
107
|
+
"use strict";
|
|
108
|
+
var fs = require("fs");
|
|
109
|
+
var path2 = require("path");
|
|
110
|
+
var os = require("os");
|
|
111
|
+
var crypto = require("crypto");
|
|
112
|
+
var packageJson = require_package();
|
|
113
|
+
var version = packageJson.version;
|
|
114
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
115
|
+
function parse(src) {
|
|
116
|
+
const obj = {};
|
|
117
|
+
let lines = src.toString();
|
|
118
|
+
lines = lines.replace(/\r\n?/mg, "\n");
|
|
119
|
+
let match;
|
|
120
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
121
|
+
const key = match[1];
|
|
122
|
+
let value = match[2] || "";
|
|
123
|
+
value = value.trim();
|
|
124
|
+
const maybeQuote = value[0];
|
|
125
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
126
|
+
if (maybeQuote === '"') {
|
|
127
|
+
value = value.replace(/\\n/g, "\n");
|
|
128
|
+
value = value.replace(/\\r/g, "\r");
|
|
129
|
+
}
|
|
130
|
+
obj[key] = value;
|
|
131
|
+
}
|
|
132
|
+
return obj;
|
|
133
|
+
}
|
|
134
|
+
__name(parse, "parse");
|
|
135
|
+
function _parseVault(options) {
|
|
136
|
+
options = options || {};
|
|
137
|
+
const vaultPath = _vaultPath(options);
|
|
138
|
+
options.path = vaultPath;
|
|
139
|
+
const result = DotenvModule.configDotenv(options);
|
|
140
|
+
if (!result.parsed) {
|
|
141
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
142
|
+
err.code = "MISSING_DATA";
|
|
143
|
+
throw err;
|
|
144
|
+
}
|
|
145
|
+
const keys = _dotenvKey(options).split(",");
|
|
146
|
+
const length = keys.length;
|
|
147
|
+
let decrypted;
|
|
148
|
+
for (let i = 0; i < length; i++) {
|
|
149
|
+
try {
|
|
150
|
+
const key = keys[i].trim();
|
|
151
|
+
const attrs = _instructions(result, key);
|
|
152
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
153
|
+
break;
|
|
154
|
+
} catch (error) {
|
|
155
|
+
if (i + 1 >= length) {
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return DotenvModule.parse(decrypted);
|
|
161
|
+
}
|
|
162
|
+
__name(_parseVault, "_parseVault");
|
|
163
|
+
function _warn(message) {
|
|
164
|
+
console.log(`[dotenv@${version}][WARN] ${message}`);
|
|
165
|
+
}
|
|
166
|
+
__name(_warn, "_warn");
|
|
167
|
+
function _debug(message) {
|
|
168
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
169
|
+
}
|
|
170
|
+
__name(_debug, "_debug");
|
|
171
|
+
function _log(message) {
|
|
172
|
+
console.log(`[dotenv@${version}] ${message}`);
|
|
173
|
+
}
|
|
174
|
+
__name(_log, "_log");
|
|
175
|
+
function _dotenvKey(options) {
|
|
176
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
177
|
+
return options.DOTENV_KEY;
|
|
178
|
+
}
|
|
179
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
180
|
+
return process.env.DOTENV_KEY;
|
|
181
|
+
}
|
|
182
|
+
return "";
|
|
183
|
+
}
|
|
184
|
+
__name(_dotenvKey, "_dotenvKey");
|
|
185
|
+
function _instructions(result, dotenvKey) {
|
|
186
|
+
let uri;
|
|
187
|
+
try {
|
|
188
|
+
uri = new URL(dotenvKey);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (error.code === "ERR_INVALID_URL") {
|
|
191
|
+
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
192
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
193
|
+
throw err;
|
|
194
|
+
}
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
const key = uri.password;
|
|
198
|
+
if (!key) {
|
|
199
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
200
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
201
|
+
throw err;
|
|
202
|
+
}
|
|
203
|
+
const environment = uri.searchParams.get("environment");
|
|
204
|
+
if (!environment) {
|
|
205
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
206
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
207
|
+
throw err;
|
|
208
|
+
}
|
|
209
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
210
|
+
const ciphertext = result.parsed[environmentKey];
|
|
211
|
+
if (!ciphertext) {
|
|
212
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
213
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
214
|
+
throw err;
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
ciphertext,
|
|
218
|
+
key
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
__name(_instructions, "_instructions");
|
|
222
|
+
function _vaultPath(options) {
|
|
223
|
+
let possibleVaultPath = null;
|
|
224
|
+
if (options && options.path && options.path.length > 0) {
|
|
225
|
+
if (Array.isArray(options.path)) {
|
|
226
|
+
for (const filepath of options.path) {
|
|
227
|
+
if (fs.existsSync(filepath)) {
|
|
228
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
possibleVaultPath = path2.resolve(process.cwd(), ".env.vault");
|
|
236
|
+
}
|
|
237
|
+
if (fs.existsSync(possibleVaultPath)) {
|
|
238
|
+
return possibleVaultPath;
|
|
239
|
+
}
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
__name(_vaultPath, "_vaultPath");
|
|
243
|
+
function _resolveHome(envPath) {
|
|
244
|
+
return envPath[0] === "~" ? path2.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
245
|
+
}
|
|
246
|
+
__name(_resolveHome, "_resolveHome");
|
|
247
|
+
function _configVault(options) {
|
|
248
|
+
const debug = Boolean(options && options.debug);
|
|
249
|
+
const quiet = options && "quiet" in options ? options.quiet : true;
|
|
250
|
+
if (debug || !quiet) {
|
|
251
|
+
_log("Loading env from encrypted .env.vault");
|
|
252
|
+
}
|
|
253
|
+
const parsed = DotenvModule._parseVault(options);
|
|
254
|
+
let processEnv = process.env;
|
|
255
|
+
if (options && options.processEnv != null) {
|
|
256
|
+
processEnv = options.processEnv;
|
|
257
|
+
}
|
|
258
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
259
|
+
return {
|
|
260
|
+
parsed
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
__name(_configVault, "_configVault");
|
|
264
|
+
function configDotenv(options) {
|
|
265
|
+
const dotenvPath = path2.resolve(process.cwd(), ".env");
|
|
266
|
+
let encoding = "utf8";
|
|
267
|
+
const debug = Boolean(options && options.debug);
|
|
268
|
+
const quiet = options && "quiet" in options ? options.quiet : true;
|
|
269
|
+
if (options && options.encoding) {
|
|
270
|
+
encoding = options.encoding;
|
|
271
|
+
} else {
|
|
272
|
+
if (debug) {
|
|
273
|
+
_debug("No encoding is specified. UTF-8 is used by default");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
let optionPaths = [
|
|
277
|
+
dotenvPath
|
|
278
|
+
];
|
|
279
|
+
if (options && options.path) {
|
|
280
|
+
if (!Array.isArray(options.path)) {
|
|
281
|
+
optionPaths = [
|
|
282
|
+
_resolveHome(options.path)
|
|
283
|
+
];
|
|
284
|
+
} else {
|
|
285
|
+
optionPaths = [];
|
|
286
|
+
for (const filepath of options.path) {
|
|
287
|
+
optionPaths.push(_resolveHome(filepath));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
let lastError;
|
|
292
|
+
const parsedAll = {};
|
|
293
|
+
for (const path3 of optionPaths) {
|
|
294
|
+
try {
|
|
295
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path3, {
|
|
296
|
+
encoding
|
|
297
|
+
}));
|
|
298
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
299
|
+
} catch (e) {
|
|
300
|
+
if (debug) {
|
|
301
|
+
_debug(`Failed to load ${path3} ${e.message}`);
|
|
302
|
+
}
|
|
303
|
+
lastError = e;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
let processEnv = process.env;
|
|
307
|
+
if (options && options.processEnv != null) {
|
|
308
|
+
processEnv = options.processEnv;
|
|
309
|
+
}
|
|
310
|
+
DotenvModule.populate(processEnv, parsedAll, options);
|
|
311
|
+
if (debug || !quiet) {
|
|
312
|
+
const keysCount = Object.keys(parsedAll).length;
|
|
313
|
+
const shortPaths = [];
|
|
314
|
+
for (const filePath of optionPaths) {
|
|
315
|
+
try {
|
|
316
|
+
const relative = path2.relative(process.cwd(), filePath);
|
|
317
|
+
shortPaths.push(relative);
|
|
318
|
+
} catch (e) {
|
|
319
|
+
if (debug) {
|
|
320
|
+
_debug(`Failed to load ${filePath} ${e.message}`);
|
|
321
|
+
}
|
|
322
|
+
lastError = e;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")}`);
|
|
326
|
+
}
|
|
327
|
+
if (lastError) {
|
|
328
|
+
return {
|
|
329
|
+
parsed: parsedAll,
|
|
330
|
+
error: lastError
|
|
331
|
+
};
|
|
332
|
+
} else {
|
|
333
|
+
return {
|
|
334
|
+
parsed: parsedAll
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
__name(configDotenv, "configDotenv");
|
|
339
|
+
function config2(options) {
|
|
340
|
+
if (_dotenvKey(options).length === 0) {
|
|
341
|
+
return DotenvModule.configDotenv(options);
|
|
342
|
+
}
|
|
343
|
+
const vaultPath = _vaultPath(options);
|
|
344
|
+
if (!vaultPath) {
|
|
345
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
346
|
+
return DotenvModule.configDotenv(options);
|
|
347
|
+
}
|
|
348
|
+
return DotenvModule._configVault(options);
|
|
349
|
+
}
|
|
350
|
+
__name(config2, "config");
|
|
351
|
+
function decrypt(encrypted, keyStr) {
|
|
352
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
353
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
354
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
355
|
+
const authTag = ciphertext.subarray(-16);
|
|
356
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
357
|
+
try {
|
|
358
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
359
|
+
aesgcm.setAuthTag(authTag);
|
|
360
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
361
|
+
} catch (error) {
|
|
362
|
+
const isRange = error instanceof RangeError;
|
|
363
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
|
364
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
365
|
+
if (isRange || invalidKeyLength) {
|
|
366
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
367
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
368
|
+
throw err;
|
|
369
|
+
} else if (decryptionFailed) {
|
|
370
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
371
|
+
err.code = "DECRYPTION_FAILED";
|
|
372
|
+
throw err;
|
|
373
|
+
} else {
|
|
374
|
+
throw error;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
__name(decrypt, "decrypt");
|
|
379
|
+
function populate(processEnv, parsed, options = {}) {
|
|
380
|
+
const debug = Boolean(options && options.debug);
|
|
381
|
+
const override = Boolean(options && options.override);
|
|
382
|
+
if (typeof parsed !== "object") {
|
|
383
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
384
|
+
err.code = "OBJECT_REQUIRED";
|
|
385
|
+
throw err;
|
|
386
|
+
}
|
|
387
|
+
for (const key of Object.keys(parsed)) {
|
|
388
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
389
|
+
if (override === true) {
|
|
390
|
+
processEnv[key] = parsed[key];
|
|
391
|
+
}
|
|
392
|
+
if (debug) {
|
|
393
|
+
if (override === true) {
|
|
394
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
395
|
+
} else {
|
|
396
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
} else {
|
|
400
|
+
processEnv[key] = parsed[key];
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
__name(populate, "populate");
|
|
405
|
+
var DotenvModule = {
|
|
406
|
+
configDotenv,
|
|
407
|
+
_configVault,
|
|
408
|
+
_parseVault,
|
|
409
|
+
config: config2,
|
|
410
|
+
decrypt,
|
|
411
|
+
parse,
|
|
412
|
+
populate
|
|
413
|
+
};
|
|
414
|
+
module2.exports.configDotenv = DotenvModule.configDotenv;
|
|
415
|
+
module2.exports._configVault = DotenvModule._configVault;
|
|
416
|
+
module2.exports._parseVault = DotenvModule._parseVault;
|
|
417
|
+
module2.exports.config = DotenvModule.config;
|
|
418
|
+
module2.exports.decrypt = DotenvModule.decrypt;
|
|
419
|
+
module2.exports.parse = DotenvModule.parse;
|
|
420
|
+
module2.exports.populate = DotenvModule.populate;
|
|
421
|
+
module2.exports = DotenvModule;
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// src/index.ts
|
|
426
|
+
var index_exports = {};
|
|
427
|
+
__export(index_exports, {
|
|
428
|
+
AMOUNT_UNIT: () => AMOUNT_UNIT,
|
|
429
|
+
ActionCommandCode: () => ActionCommandCode,
|
|
430
|
+
ApiError: () => ApiError,
|
|
431
|
+
Category: () => Category,
|
|
432
|
+
DataHelper: () => DataHelper,
|
|
433
|
+
DateUtils: () => DateUtils,
|
|
434
|
+
DepotPoolStatus: () => DepotPoolStatus,
|
|
435
|
+
Device: () => Device,
|
|
436
|
+
FreshDao: () => FreshDao,
|
|
437
|
+
FreshEntity: () => FreshEntity,
|
|
438
|
+
FreshHyperEntity: () => FreshHyperEntity,
|
|
439
|
+
FreshJob: () => FreshJob,
|
|
440
|
+
FreshTranslationBase: () => FreshTranslationBase,
|
|
441
|
+
HttpStatus: () => HttpStatus,
|
|
442
|
+
LanguageCode: () => LanguageCode,
|
|
443
|
+
Manufacturer: () => Manufacturer,
|
|
444
|
+
PaymentMethod: () => PaymentMethod,
|
|
445
|
+
PgDataSourceOptions: () => datasource_default,
|
|
446
|
+
Product: () => Product,
|
|
447
|
+
SinglePromiseWaiter: () => SinglePromiseWaiter,
|
|
448
|
+
Singleton: () => Singleton,
|
|
449
|
+
StatusDto: () => StatusDto,
|
|
450
|
+
Subcategory: () => Subcategory,
|
|
451
|
+
TimestampColumn: () => TimestampColumn,
|
|
452
|
+
TransactionType: () => TransactionType,
|
|
453
|
+
createDeferred: () => createDeferred,
|
|
454
|
+
freshEslintConfig: () => eslint_config_default,
|
|
455
|
+
isValidCron: () => isValidCron,
|
|
456
|
+
logger: () => logger
|
|
457
|
+
});
|
|
458
|
+
module.exports = __toCommonJS(index_exports);
|
|
459
|
+
|
|
460
|
+
// src/common/date-utils.ts
|
|
461
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
462
|
+
var import_utc = __toESM(require("dayjs/plugin/utc"));
|
|
463
|
+
var import_timezone = __toESM(require("dayjs/plugin/timezone"));
|
|
464
|
+
var import_isBetween = __toESM(require("dayjs/plugin/isBetween"));
|
|
465
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
466
|
+
import_dayjs.default.extend(import_utc.default);
|
|
467
|
+
import_dayjs.default.extend(import_timezone.default);
|
|
468
|
+
import_dayjs.default.extend(import_isBetween.default);
|
|
469
|
+
import_dayjs.default.extend(import_customParseFormat.default);
|
|
470
|
+
var _DateUtils = class _DateUtils {
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region SQL timestamps
|
|
473
|
+
static fromISOtoSQLtimestamp(ts) {
|
|
474
|
+
return (0, import_dayjs.default)(ts).utc().format("YYYY-MM-DD HH:mm:ss");
|
|
475
|
+
}
|
|
476
|
+
static toSQLtimestamp(ts) {
|
|
477
|
+
return ts.format("YYYY-MM-DD HH:mm:ss");
|
|
478
|
+
}
|
|
479
|
+
static fromSQLtimestamp(mysqlDate) {
|
|
480
|
+
return (0, import_dayjs.default)(mysqlDate, "YYYY-MM-DD HH:mm:ss").utc(true);
|
|
481
|
+
}
|
|
482
|
+
static getSqlTimestampFromNowCzech() {
|
|
483
|
+
return _DateUtils.toSQLtimestamp(_DateUtils.getNowCzech());
|
|
484
|
+
}
|
|
485
|
+
//#endregion
|
|
486
|
+
// ---------- UTC
|
|
487
|
+
static fromISO(isoDate) {
|
|
488
|
+
return (0, import_dayjs.default)(isoDate).utc(false);
|
|
489
|
+
}
|
|
490
|
+
// ----------
|
|
491
|
+
static getDate(ts) {
|
|
492
|
+
return (0, import_dayjs.default)(ts);
|
|
493
|
+
}
|
|
494
|
+
static getNow() {
|
|
495
|
+
return (0, import_dayjs.default)();
|
|
496
|
+
}
|
|
497
|
+
static getNowCzech() {
|
|
498
|
+
return (0, import_dayjs.default)().tz("Europe/Prague").utc(true);
|
|
499
|
+
}
|
|
500
|
+
static clone(ts) {
|
|
501
|
+
return (0, import_dayjs.default)(ts);
|
|
502
|
+
}
|
|
503
|
+
static getLastSunday(weeksOffset = 0) {
|
|
504
|
+
let now = _DateUtils.getNowCzech();
|
|
505
|
+
now = now.date(now.date() - (now.day() + 1) % 7 - 7 * weeksOffset);
|
|
506
|
+
now = now.hour(0);
|
|
507
|
+
now = now.minute(0);
|
|
508
|
+
now = now.second(0);
|
|
509
|
+
now = now.millisecond(0);
|
|
510
|
+
return now;
|
|
511
|
+
}
|
|
512
|
+
static dayInWeek(ts) {
|
|
513
|
+
const input = ts != null ? ts : (0, import_dayjs.default)();
|
|
514
|
+
const day = input.day();
|
|
515
|
+
if (day === 0) {
|
|
516
|
+
return 7;
|
|
517
|
+
}
|
|
518
|
+
return day;
|
|
519
|
+
}
|
|
520
|
+
static isWorkdayDay(ts) {
|
|
521
|
+
const weekDay = ts.get("day");
|
|
522
|
+
if (weekDay === 0) {
|
|
523
|
+
return false;
|
|
524
|
+
}
|
|
525
|
+
if (weekDay === 6) {
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
ts = ts.set("hour", 0).set("minutes", 0).set("seconds", 0).set("milliseconds", 0);
|
|
529
|
+
return !_DateUtils.HOLIDAYS.includes(ts.valueOf());
|
|
530
|
+
}
|
|
531
|
+
static getDiffInMinutesWithNow(inputTime) {
|
|
532
|
+
const now = (0, import_dayjs.default)();
|
|
533
|
+
const diffInMinutes = now.diff(inputTime, "minute");
|
|
534
|
+
return diffInMinutes;
|
|
535
|
+
}
|
|
536
|
+
static isInLastDays(numOfDays, timestampInput) {
|
|
537
|
+
const timestamp = typeof timestampInput === "string" ? (0, import_dayjs.default)(timestampInput) : timestampInput;
|
|
538
|
+
const now = (0, import_dayjs.default)();
|
|
539
|
+
const dateLimit = now.subtract(numOfDays, "day");
|
|
540
|
+
return timestamp.isAfter(dateLimit);
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
__name(_DateUtils, "DateUtils");
|
|
544
|
+
//#region Holidays
|
|
545
|
+
/** Holidays 2025-2030 as YYYY-MM-DD strings */
|
|
546
|
+
__publicField(_DateUtils, "HOLIDAYS_STR", [
|
|
547
|
+
/* 2025 */
|
|
548
|
+
"2025-01-01",
|
|
549
|
+
"2025-04-18",
|
|
550
|
+
"2025-04-21",
|
|
551
|
+
"2025-05-01",
|
|
552
|
+
"2025-05-08",
|
|
553
|
+
"2025-07-05",
|
|
554
|
+
"2025-07-06",
|
|
555
|
+
"2025-09-28",
|
|
556
|
+
"2025-10-28",
|
|
557
|
+
"2025-11-17",
|
|
558
|
+
"2025-12-24",
|
|
559
|
+
"2025-12-25",
|
|
560
|
+
"2025-12-26",
|
|
561
|
+
/* 2026 */
|
|
562
|
+
"2026-01-01",
|
|
563
|
+
"2026-04-03",
|
|
564
|
+
"2026-04-06",
|
|
565
|
+
"2026-05-01",
|
|
566
|
+
"2026-05-08",
|
|
567
|
+
"2026-07-05",
|
|
568
|
+
"2026-07-06",
|
|
569
|
+
"2026-09-28",
|
|
570
|
+
"2026-10-28",
|
|
571
|
+
"2026-11-17",
|
|
572
|
+
"2026-12-24",
|
|
573
|
+
"2026-12-25",
|
|
574
|
+
"2026-12-26",
|
|
575
|
+
/* 2027 */
|
|
576
|
+
"2027-01-01",
|
|
577
|
+
"2027-03-26",
|
|
578
|
+
"2027-03-29",
|
|
579
|
+
"2027-05-01",
|
|
580
|
+
"2027-05-08",
|
|
581
|
+
"2027-07-05",
|
|
582
|
+
"2027-07-06",
|
|
583
|
+
"2027-09-28",
|
|
584
|
+
"2027-10-28",
|
|
585
|
+
"2027-11-17",
|
|
586
|
+
"2027-12-24",
|
|
587
|
+
"2027-12-25",
|
|
588
|
+
"2027-12-26",
|
|
589
|
+
/* 2028 */
|
|
590
|
+
"2028-01-01",
|
|
591
|
+
"2028-04-14",
|
|
592
|
+
"2028-04-17",
|
|
593
|
+
"2028-05-01",
|
|
594
|
+
"2028-05-08",
|
|
595
|
+
"2028-07-05",
|
|
596
|
+
"2028-07-06",
|
|
597
|
+
"2028-09-28",
|
|
598
|
+
"2028-10-28",
|
|
599
|
+
"2028-11-17",
|
|
600
|
+
"2028-12-24",
|
|
601
|
+
"2028-12-25",
|
|
602
|
+
"2028-12-26",
|
|
603
|
+
/* 2029 */
|
|
604
|
+
"2029-01-01",
|
|
605
|
+
"2029-03-30",
|
|
606
|
+
"2029-04-02",
|
|
607
|
+
"2029-05-01",
|
|
608
|
+
"2029-05-08",
|
|
609
|
+
"2029-07-05",
|
|
610
|
+
"2029-07-06",
|
|
611
|
+
"2029-09-28",
|
|
612
|
+
"2029-10-28",
|
|
613
|
+
"2029-11-17",
|
|
614
|
+
"2029-12-24",
|
|
615
|
+
"2029-12-25",
|
|
616
|
+
"2029-12-26",
|
|
617
|
+
/* 2030 */
|
|
618
|
+
"2030-01-01",
|
|
619
|
+
"2030-04-19",
|
|
620
|
+
"2030-04-22",
|
|
621
|
+
"2030-05-01",
|
|
622
|
+
"2030-05-08",
|
|
623
|
+
"2030-07-05",
|
|
624
|
+
"2030-07-06",
|
|
625
|
+
"2030-09-28",
|
|
626
|
+
"2030-10-28",
|
|
627
|
+
"2030-11-17",
|
|
628
|
+
"2030-12-24",
|
|
629
|
+
"2030-12-25",
|
|
630
|
+
"2030-12-26"
|
|
631
|
+
]);
|
|
632
|
+
/** Holidays 2025-2030 as UTC timestamps */
|
|
633
|
+
__publicField(_DateUtils, "HOLIDAYS", _DateUtils.HOLIDAYS_STR.map((h) => {
|
|
634
|
+
const date = new Date(h);
|
|
635
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
636
|
+
return date.getTime();
|
|
637
|
+
}));
|
|
638
|
+
var DateUtils = _DateUtils;
|
|
639
|
+
|
|
640
|
+
// src/common/promise-magic/deferred.ts
|
|
641
|
+
function createDeferred() {
|
|
642
|
+
let resolve;
|
|
643
|
+
let reject;
|
|
644
|
+
const promise = new Promise((res, rej) => {
|
|
645
|
+
resolve = res;
|
|
646
|
+
reject = rej;
|
|
647
|
+
});
|
|
648
|
+
return {
|
|
649
|
+
promise,
|
|
650
|
+
resolve,
|
|
651
|
+
reject
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
__name(createDeferred, "createDeferred");
|
|
655
|
+
|
|
656
|
+
// src/common/promise-magic/single-promise-waiter.ts
|
|
657
|
+
var _SinglePromiseWaiter = class _SinglePromiseWaiter {
|
|
658
|
+
constructor() {
|
|
659
|
+
__publicField(this, "_promise", null);
|
|
660
|
+
}
|
|
661
|
+
static getInstance() {
|
|
662
|
+
if (!_SinglePromiseWaiter._instance) {
|
|
663
|
+
_SinglePromiseWaiter._instance = new _SinglePromiseWaiter();
|
|
664
|
+
}
|
|
665
|
+
return _SinglePromiseWaiter._instance;
|
|
666
|
+
}
|
|
667
|
+
get promise() {
|
|
668
|
+
return this._promise;
|
|
669
|
+
}
|
|
670
|
+
set promise(promise) {
|
|
671
|
+
if (promise !== null) {
|
|
672
|
+
this._promise = promise;
|
|
673
|
+
this._promise.finally(() => {
|
|
674
|
+
this._promise = null;
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
get hasPromise() {
|
|
679
|
+
return this._promise !== null;
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
__name(_SinglePromiseWaiter, "SinglePromiseWaiter");
|
|
683
|
+
__publicField(_SinglePromiseWaiter, "_instance");
|
|
684
|
+
var SinglePromiseWaiter = _SinglePromiseWaiter;
|
|
685
|
+
|
|
686
|
+
// src/common/winston.ts
|
|
687
|
+
var import_winston = __toESM(require("winston"));
|
|
688
|
+
var SERVICE = process.env.SERVICE_NAME || "depot-ordering-service";
|
|
689
|
+
var ENV = process.env.NODE_ENV || "localhost";
|
|
690
|
+
var levelToSeverity = {
|
|
691
|
+
silly: "debug",
|
|
692
|
+
verbose: "debug",
|
|
693
|
+
debug: "debug",
|
|
694
|
+
http: "info",
|
|
695
|
+
info: "info",
|
|
696
|
+
warn: "warn",
|
|
697
|
+
error: "error"
|
|
698
|
+
};
|
|
699
|
+
var baseFormat = import_winston.default.format.combine(import_winston.default.format.timestamp({
|
|
700
|
+
format: /* @__PURE__ */ __name(() => (/* @__PURE__ */ new Date()).toISOString(), "format")
|
|
701
|
+
}), import_winston.default.format.errors({
|
|
702
|
+
stack: true
|
|
703
|
+
}), import_winston.default.format.printf((info) => {
|
|
704
|
+
const payload = {
|
|
705
|
+
ts: info.timestamp,
|
|
706
|
+
level: info.level,
|
|
707
|
+
severity: levelToSeverity[info.level] || info.level,
|
|
708
|
+
message: info.message,
|
|
709
|
+
service: SERVICE,
|
|
710
|
+
env: ENV,
|
|
711
|
+
process_name: process.title || process.argv[1] || "node",
|
|
712
|
+
pid: process.pid,
|
|
713
|
+
device: process.env.DEVICE_ID || void 0,
|
|
714
|
+
traceId: info.traceId,
|
|
715
|
+
spanId: info.spanId,
|
|
716
|
+
extra: info.extra || info.meta || void 0,
|
|
717
|
+
stack: info.stack
|
|
718
|
+
};
|
|
719
|
+
return JSON.stringify(payload);
|
|
720
|
+
}));
|
|
721
|
+
var transports = [
|
|
722
|
+
new import_winston.default.transports.Console({
|
|
723
|
+
level: process.env.LOG_LEVEL || "info"
|
|
724
|
+
})
|
|
725
|
+
];
|
|
726
|
+
var logger = import_winston.default.createLogger({
|
|
727
|
+
level: process.env.LOG_LEVEL || "info",
|
|
728
|
+
format: baseFormat,
|
|
729
|
+
transports,
|
|
730
|
+
exitOnError: false
|
|
731
|
+
});
|
|
732
|
+
logger.stream = {
|
|
733
|
+
write: /* @__PURE__ */ __name((message) => logger.info(message.trim()), "write")
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
// src/common/utils/is-cron-valid.ts
|
|
737
|
+
function isValidCron(expr) {
|
|
738
|
+
const parts = expr.trim().split(/\s+/);
|
|
739
|
+
if (parts.length < 5 || parts.length > 6) {
|
|
740
|
+
return false;
|
|
741
|
+
}
|
|
742
|
+
const cronPart = /^(\*|\d+|\d+\-\d+|\d+\/\d+|\*\/\d+)(,\d+)*$/;
|
|
743
|
+
return parts.every((part) => cronPart.test(part));
|
|
744
|
+
}
|
|
745
|
+
__name(isValidCron, "isValidCron");
|
|
746
|
+
|
|
747
|
+
// src/common/patterns/singleton.ts
|
|
748
|
+
var _Singleton = class _Singleton {
|
|
749
|
+
constructor() {
|
|
750
|
+
const ctor = this.constructor;
|
|
751
|
+
const existing = _Singleton.instances.get(ctor);
|
|
752
|
+
if (existing) {
|
|
753
|
+
return existing;
|
|
754
|
+
}
|
|
755
|
+
_Singleton.instances.set(ctor, this);
|
|
756
|
+
}
|
|
757
|
+
static getInstance(...args) {
|
|
758
|
+
let instance = _Singleton.instances.get(this);
|
|
759
|
+
if (!instance) {
|
|
760
|
+
instance = new this(...args);
|
|
761
|
+
_Singleton.instances.set(this, instance);
|
|
762
|
+
}
|
|
763
|
+
return instance;
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
__name(_Singleton, "Singleton");
|
|
767
|
+
__publicField(_Singleton, "instances", /* @__PURE__ */ new Map());
|
|
768
|
+
var Singleton = _Singleton;
|
|
769
|
+
|
|
770
|
+
// src/common/dto/status-dto.ts
|
|
771
|
+
var _StatusDto = class _StatusDto {
|
|
772
|
+
constructor(status, details, timestamp) {
|
|
773
|
+
/**
|
|
774
|
+
* Call result status
|
|
775
|
+
*/
|
|
776
|
+
__publicField(this, "status");
|
|
777
|
+
/**
|
|
778
|
+
* UTC Timestamp
|
|
779
|
+
* @example "2021-12-01T13:23:39.305Z"
|
|
780
|
+
*/
|
|
781
|
+
__publicField(this, "timestamp");
|
|
782
|
+
/**
|
|
783
|
+
* Details (optional)
|
|
784
|
+
*/
|
|
785
|
+
__publicField(this, "details");
|
|
786
|
+
this.status = status;
|
|
787
|
+
this.details = details;
|
|
788
|
+
this.timestamp = timestamp != null ? timestamp : DateUtils.getNowCzech().toISOString();
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
__name(_StatusDto, "StatusDto");
|
|
792
|
+
var StatusDto = _StatusDto;
|
|
793
|
+
|
|
794
|
+
// src/common/constants/amount-unit.ts
|
|
795
|
+
var AMOUNT_UNIT = {
|
|
796
|
+
1: {
|
|
797
|
+
symbol: "g",
|
|
798
|
+
translations: {
|
|
799
|
+
en: "gram",
|
|
800
|
+
cs: "gram"
|
|
801
|
+
}
|
|
802
|
+
},
|
|
803
|
+
2: {
|
|
804
|
+
symbol: "kg",
|
|
805
|
+
translations: {
|
|
806
|
+
en: "kilogram",
|
|
807
|
+
cs: "kilogram"
|
|
808
|
+
}
|
|
809
|
+
},
|
|
810
|
+
3: {
|
|
811
|
+
symbol: "ml",
|
|
812
|
+
translations: {
|
|
813
|
+
en: "milliliter",
|
|
814
|
+
cs: "mililitr"
|
|
815
|
+
}
|
|
816
|
+
},
|
|
817
|
+
4: {
|
|
818
|
+
symbol: "l",
|
|
819
|
+
translations: {
|
|
820
|
+
en: "liter",
|
|
821
|
+
cs: "litr"
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
// src/common/schema/entities/category.entity.ts
|
|
827
|
+
var import_typeorm5 = require("typeorm");
|
|
828
|
+
|
|
829
|
+
// src/database/entities/fresh-entity.ts
|
|
830
|
+
var import_typeorm = require("typeorm");
|
|
831
|
+
|
|
832
|
+
// ../../node_modules/uuid/dist/esm/stringify.js
|
|
833
|
+
var byteToHex = [];
|
|
834
|
+
for (let i = 0; i < 256; ++i) {
|
|
835
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
836
|
+
}
|
|
837
|
+
function unsafeStringify(arr, offset = 0) {
|
|
838
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
839
|
+
}
|
|
840
|
+
__name(unsafeStringify, "unsafeStringify");
|
|
841
|
+
|
|
842
|
+
// ../../node_modules/uuid/dist/esm/rng.js
|
|
843
|
+
var import_crypto = require("crypto");
|
|
844
|
+
var rnds8Pool = new Uint8Array(256);
|
|
845
|
+
var poolPtr = rnds8Pool.length;
|
|
846
|
+
function rng() {
|
|
847
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
|
848
|
+
(0, import_crypto.randomFillSync)(rnds8Pool);
|
|
849
|
+
poolPtr = 0;
|
|
850
|
+
}
|
|
851
|
+
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
852
|
+
}
|
|
853
|
+
__name(rng, "rng");
|
|
854
|
+
|
|
855
|
+
// ../../node_modules/uuid/dist/esm/native.js
|
|
856
|
+
var import_crypto2 = require("crypto");
|
|
857
|
+
var native_default = {
|
|
858
|
+
randomUUID: import_crypto2.randomUUID
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
// ../../node_modules/uuid/dist/esm/v4.js
|
|
862
|
+
function v4(options, buf, offset) {
|
|
863
|
+
var _a, _b, _c;
|
|
864
|
+
if (native_default.randomUUID && !buf && !options) {
|
|
865
|
+
return native_default.randomUUID();
|
|
866
|
+
}
|
|
867
|
+
options = options || {};
|
|
868
|
+
const rnds = (_c = (_b = options.random) != null ? _b : (_a = options.rng) == null ? void 0 : _a.call(options)) != null ? _c : rng();
|
|
869
|
+
if (rnds.length < 16) {
|
|
870
|
+
throw new Error("Random bytes length must be >= 16");
|
|
871
|
+
}
|
|
872
|
+
rnds[6] = rnds[6] & 15 | 64;
|
|
873
|
+
rnds[8] = rnds[8] & 63 | 128;
|
|
874
|
+
if (buf) {
|
|
875
|
+
offset = offset || 0;
|
|
876
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
877
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
878
|
+
}
|
|
879
|
+
for (let i = 0; i < 16; ++i) {
|
|
880
|
+
buf[offset + i] = rnds[i];
|
|
881
|
+
}
|
|
882
|
+
return buf;
|
|
883
|
+
}
|
|
884
|
+
return unsafeStringify(rnds);
|
|
885
|
+
}
|
|
886
|
+
__name(v4, "v4");
|
|
887
|
+
var v4_default = v4;
|
|
888
|
+
|
|
889
|
+
// src/database/entities/fresh-entity.ts
|
|
890
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
891
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
892
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
893
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
894
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
895
|
+
}
|
|
896
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
897
|
+
function _ts_metadata(k, v) {
|
|
898
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
899
|
+
}
|
|
900
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
901
|
+
var _FreshEntity = class _FreshEntity extends import_typeorm.BaseEntity {
|
|
902
|
+
/** After manual construction `id` is irrelevant. Refer to `uuid` only, because that will be inserted into DB */
|
|
903
|
+
constructor() {
|
|
904
|
+
super();
|
|
905
|
+
__publicField(this, "id");
|
|
906
|
+
__publicField(this, "uuid");
|
|
907
|
+
__publicField(this, "created_at");
|
|
908
|
+
__publicField(this, "updated_at");
|
|
909
|
+
// for soft delete methods by typeorm
|
|
910
|
+
__publicField(this, "deleted_at");
|
|
911
|
+
this.id = 0;
|
|
912
|
+
this.uuid = v4_default();
|
|
913
|
+
const newDate = /* @__PURE__ */ new Date();
|
|
914
|
+
this.created_at = newDate;
|
|
915
|
+
this.updated_at = newDate;
|
|
916
|
+
this.deleted_at = null;
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
__name(_FreshEntity, "FreshEntity");
|
|
920
|
+
var FreshEntity = _FreshEntity;
|
|
921
|
+
_ts_decorate([
|
|
922
|
+
(0, import_typeorm.PrimaryGeneratedColumn)("increment"),
|
|
923
|
+
_ts_metadata("design:type", Number)
|
|
924
|
+
], FreshEntity.prototype, "id", void 0);
|
|
925
|
+
_ts_decorate([
|
|
926
|
+
(0, import_typeorm.Index)({
|
|
927
|
+
unique: true
|
|
928
|
+
}),
|
|
929
|
+
(0, import_typeorm.Column)({
|
|
930
|
+
type: "uuid",
|
|
931
|
+
default: /* @__PURE__ */ __name(() => "timescale.uuid_generate_v4()", "default")
|
|
932
|
+
}),
|
|
933
|
+
_ts_metadata("design:type", String)
|
|
934
|
+
], FreshEntity.prototype, "uuid", void 0);
|
|
935
|
+
_ts_decorate([
|
|
936
|
+
(0, import_typeorm.CreateDateColumn)({
|
|
937
|
+
type: "timestamptz"
|
|
938
|
+
}),
|
|
939
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
940
|
+
], FreshEntity.prototype, "created_at", void 0);
|
|
941
|
+
_ts_decorate([
|
|
942
|
+
(0, import_typeorm.UpdateDateColumn)({
|
|
943
|
+
type: "timestamptz"
|
|
944
|
+
}),
|
|
945
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
946
|
+
], FreshEntity.prototype, "updated_at", void 0);
|
|
947
|
+
_ts_decorate([
|
|
948
|
+
(0, import_typeorm.DeleteDateColumn)({
|
|
949
|
+
type: "timestamptz",
|
|
950
|
+
nullable: true
|
|
951
|
+
}),
|
|
952
|
+
_ts_metadata("design:type", Object)
|
|
953
|
+
], FreshEntity.prototype, "deleted_at", void 0);
|
|
954
|
+
|
|
955
|
+
// src/database/entities/fresh-hyper-entity.ts
|
|
956
|
+
var import_typeorm3 = require("typeorm");
|
|
957
|
+
|
|
958
|
+
// src/database/decorators/timestamp-column.ts
|
|
959
|
+
var import_typeorm2 = require("typeorm");
|
|
960
|
+
function TimestampColumn(options = {}) {
|
|
961
|
+
const defaultOptions = {
|
|
962
|
+
type: "timestamptz",
|
|
963
|
+
nullable: false,
|
|
964
|
+
default: /* @__PURE__ */ __name(() => "CURRENT_TIMESTAMP", "default"),
|
|
965
|
+
...options
|
|
966
|
+
};
|
|
967
|
+
return (0, import_typeorm2.Column)(defaultOptions);
|
|
968
|
+
}
|
|
969
|
+
__name(TimestampColumn, "TimestampColumn");
|
|
970
|
+
|
|
971
|
+
// src/database/entities/fresh-hyper-entity.ts
|
|
972
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
973
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
974
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
975
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
976
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
977
|
+
}
|
|
978
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
979
|
+
function _ts_metadata2(k, v) {
|
|
980
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
981
|
+
}
|
|
982
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
983
|
+
var _FreshHyperEntity = class _FreshHyperEntity extends import_typeorm3.BaseEntity {
|
|
984
|
+
/** After manual construction `id` is irrelevant */
|
|
985
|
+
constructor(timestamp) {
|
|
986
|
+
super();
|
|
987
|
+
// input timestamp as PK
|
|
988
|
+
__publicField(this, "timestamp");
|
|
989
|
+
// just info column about time of insert
|
|
990
|
+
__publicField(this, "created_at");
|
|
991
|
+
this.timestamp = timestamp != null ? timestamp : /* @__PURE__ */ new Date();
|
|
992
|
+
this.created_at = /* @__PURE__ */ new Date();
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
__name(_FreshHyperEntity, "FreshHyperEntity");
|
|
996
|
+
var FreshHyperEntity = _FreshHyperEntity;
|
|
997
|
+
_ts_decorate2([
|
|
998
|
+
(0, import_typeorm3.PrimaryColumn)({
|
|
999
|
+
type: "timestamptz"
|
|
1000
|
+
}),
|
|
1001
|
+
_ts_metadata2("design:type", typeof Date === "undefined" ? Object : Date)
|
|
1002
|
+
], FreshHyperEntity.prototype, "timestamp", void 0);
|
|
1003
|
+
_ts_decorate2([
|
|
1004
|
+
TimestampColumn(),
|
|
1005
|
+
_ts_metadata2("design:type", typeof Date === "undefined" ? Object : Date)
|
|
1006
|
+
], FreshHyperEntity.prototype, "created_at", void 0);
|
|
1007
|
+
|
|
1008
|
+
// src/database/entities/fresh-translation-entity.ts
|
|
1009
|
+
var import_typeorm4 = require("typeorm");
|
|
1010
|
+
|
|
1011
|
+
// src/enums/action-command-code.ts
|
|
1012
|
+
var ActionCommandCode = /* @__PURE__ */ (function(ActionCommandCode2) {
|
|
1013
|
+
ActionCommandCode2[ActionCommandCode2["RESTART_PC"] = 1] = "RESTART_PC";
|
|
1014
|
+
ActionCommandCode2[ActionCommandCode2["RESTART_APPLICATION"] = 2] = "RESTART_APPLICATION";
|
|
1015
|
+
ActionCommandCode2[ActionCommandCode2["RESTART_ROUTER"] = 3] = "RESTART_ROUTER";
|
|
1016
|
+
ActionCommandCode2[ActionCommandCode2["RESTART_REMOTE_CONTROL"] = 4] = "RESTART_REMOTE_CONTROL";
|
|
1017
|
+
ActionCommandCode2[ActionCommandCode2["SYNCHRONIZE"] = 5] = "SYNCHRONIZE";
|
|
1018
|
+
ActionCommandCode2[ActionCommandCode2["DIAGNOSE_LOCKS"] = 6] = "DIAGNOSE_LOCKS";
|
|
1019
|
+
ActionCommandCode2[ActionCommandCode2["SYNCHRONIZE_CONFIG"] = 7] = "SYNCHRONIZE_CONFIG";
|
|
1020
|
+
return ActionCommandCode2;
|
|
1021
|
+
})({});
|
|
1022
|
+
|
|
1023
|
+
// src/enums/depot-pool-status.ts
|
|
1024
|
+
var DepotPoolStatus = /* @__PURE__ */ (function(DepotPoolStatus2) {
|
|
1025
|
+
DepotPoolStatus2[DepotPoolStatus2["NEW"] = 0] = "NEW";
|
|
1026
|
+
DepotPoolStatus2[DepotPoolStatus2["PICKED"] = 1] = "PICKED";
|
|
1027
|
+
DepotPoolStatus2[DepotPoolStatus2["WRITTEN_OFF"] = 2] = "WRITTEN_OFF";
|
|
1028
|
+
DepotPoolStatus2[DepotPoolStatus2["ACTIVE"] = 3] = "ACTIVE";
|
|
1029
|
+
DepotPoolStatus2[DepotPoolStatus2["TERMINATED"] = 4] = "TERMINATED";
|
|
1030
|
+
return DepotPoolStatus2;
|
|
1031
|
+
})({});
|
|
1032
|
+
|
|
1033
|
+
// src/enums/http-status.ts
|
|
1034
|
+
var HttpStatus = /* @__PURE__ */ (function(HttpStatus2) {
|
|
1035
|
+
HttpStatus2[HttpStatus2["CONTINUE"] = 100] = "CONTINUE";
|
|
1036
|
+
HttpStatus2[HttpStatus2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
1037
|
+
HttpStatus2[HttpStatus2["PROCESSING"] = 102] = "PROCESSING";
|
|
1038
|
+
HttpStatus2[HttpStatus2["EARLY_HINTS"] = 103] = "EARLY_HINTS";
|
|
1039
|
+
HttpStatus2[HttpStatus2["OK"] = 200] = "OK";
|
|
1040
|
+
HttpStatus2[HttpStatus2["CREATED"] = 201] = "CREATED";
|
|
1041
|
+
HttpStatus2[HttpStatus2["ACCEPTED"] = 202] = "ACCEPTED";
|
|
1042
|
+
HttpStatus2[HttpStatus2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
1043
|
+
HttpStatus2[HttpStatus2["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
1044
|
+
HttpStatus2[HttpStatus2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
1045
|
+
HttpStatus2[HttpStatus2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
1046
|
+
HttpStatus2[HttpStatus2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
1047
|
+
HttpStatus2[HttpStatus2["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
|
|
1048
|
+
HttpStatus2[HttpStatus2["IM_USED"] = 226] = "IM_USED";
|
|
1049
|
+
HttpStatus2[HttpStatus2["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
|
|
1050
|
+
HttpStatus2[HttpStatus2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
1051
|
+
HttpStatus2[HttpStatus2["FOUND"] = 302] = "FOUND";
|
|
1052
|
+
HttpStatus2[HttpStatus2["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
1053
|
+
HttpStatus2[HttpStatus2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
1054
|
+
HttpStatus2[HttpStatus2["USE_PROXY"] = 305] = "USE_PROXY";
|
|
1055
|
+
HttpStatus2[HttpStatus2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
1056
|
+
HttpStatus2[HttpStatus2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
1057
|
+
HttpStatus2[HttpStatus2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
1058
|
+
HttpStatus2[HttpStatus2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
1059
|
+
HttpStatus2[HttpStatus2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
1060
|
+
HttpStatus2[HttpStatus2["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
1061
|
+
HttpStatus2[HttpStatus2["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
1062
|
+
HttpStatus2[HttpStatus2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
1063
|
+
HttpStatus2[HttpStatus2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
1064
|
+
HttpStatus2[HttpStatus2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
1065
|
+
HttpStatus2[HttpStatus2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
1066
|
+
HttpStatus2[HttpStatus2["CONFLICT"] = 409] = "CONFLICT";
|
|
1067
|
+
HttpStatus2[HttpStatus2["GONE"] = 410] = "GONE";
|
|
1068
|
+
HttpStatus2[HttpStatus2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
1069
|
+
HttpStatus2[HttpStatus2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
1070
|
+
HttpStatus2[HttpStatus2["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
1071
|
+
HttpStatus2[HttpStatus2["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
1072
|
+
HttpStatus2[HttpStatus2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
1073
|
+
HttpStatus2[HttpStatus2["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
|
|
1074
|
+
HttpStatus2[HttpStatus2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
1075
|
+
HttpStatus2[HttpStatus2["IM_A_TEAPOT"] = 418] = "IM_A_TEAPOT";
|
|
1076
|
+
HttpStatus2[HttpStatus2["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
1077
|
+
HttpStatus2[HttpStatus2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
1078
|
+
HttpStatus2[HttpStatus2["LOCKED"] = 423] = "LOCKED";
|
|
1079
|
+
HttpStatus2[HttpStatus2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
1080
|
+
HttpStatus2[HttpStatus2["TOO_EARLY"] = 425] = "TOO_EARLY";
|
|
1081
|
+
HttpStatus2[HttpStatus2["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
|
|
1082
|
+
HttpStatus2[HttpStatus2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
1083
|
+
HttpStatus2[HttpStatus2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
1084
|
+
HttpStatus2[HttpStatus2["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
|
|
1085
|
+
HttpStatus2[HttpStatus2["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
|
|
1086
|
+
HttpStatus2[HttpStatus2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
1087
|
+
HttpStatus2[HttpStatus2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
1088
|
+
HttpStatus2[HttpStatus2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
1089
|
+
HttpStatus2[HttpStatus2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
1090
|
+
HttpStatus2[HttpStatus2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
1091
|
+
HttpStatus2[HttpStatus2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
1092
|
+
HttpStatus2[HttpStatus2["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
|
|
1093
|
+
HttpStatus2[HttpStatus2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
1094
|
+
HttpStatus2[HttpStatus2["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
1095
|
+
HttpStatus2[HttpStatus2["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
|
|
1096
|
+
HttpStatus2[HttpStatus2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
1097
|
+
return HttpStatus2;
|
|
1098
|
+
})({});
|
|
1099
|
+
|
|
1100
|
+
// src/enums/language-code.ts
|
|
1101
|
+
var LanguageCode = /* @__PURE__ */ (function(LanguageCode2) {
|
|
1102
|
+
LanguageCode2["CS"] = "cs";
|
|
1103
|
+
LanguageCode2["EN"] = "en";
|
|
1104
|
+
LanguageCode2["DE"] = "de";
|
|
1105
|
+
LanguageCode2["PL"] = "pl";
|
|
1106
|
+
LanguageCode2["SK"] = "sk";
|
|
1107
|
+
return LanguageCode2;
|
|
1108
|
+
})({});
|
|
1109
|
+
|
|
1110
|
+
// src/enums/payment-method.ts
|
|
1111
|
+
var PaymentMethod = /* @__PURE__ */ (function(PaymentMethod2) {
|
|
1112
|
+
PaymentMethod2[PaymentMethod2["CODE"] = 0] = "CODE";
|
|
1113
|
+
PaymentMethod2[PaymentMethod2["CARD"] = 1] = "CARD";
|
|
1114
|
+
PaymentMethod2[PaymentMethod2["NONE"] = 2] = "NONE";
|
|
1115
|
+
return PaymentMethod2;
|
|
1116
|
+
})({});
|
|
1117
|
+
|
|
1118
|
+
// src/enums/transaction-type.ts
|
|
1119
|
+
var TransactionType = /* @__PURE__ */ (function(TransactionType2) {
|
|
1120
|
+
TransactionType2[TransactionType2["WRITEOFF"] = 0] = "WRITEOFF";
|
|
1121
|
+
TransactionType2[TransactionType2["SALE"] = 1] = "SALE";
|
|
1122
|
+
TransactionType2[TransactionType2["LOST"] = 2] = "LOST";
|
|
1123
|
+
TransactionType2[TransactionType2["ADD"] = 3] = "ADD";
|
|
1124
|
+
TransactionType2[TransactionType2["DELIVERY"] = 4] = "DELIVERY";
|
|
1125
|
+
TransactionType2[TransactionType2["DEPOT_WRITEOFF"] = 5] = "DEPOT_WRITEOFF";
|
|
1126
|
+
TransactionType2[TransactionType2["DEPOT_ADD"] = 6] = "DEPOT_ADD";
|
|
1127
|
+
TransactionType2[TransactionType2["RETURN"] = 7] = "RETURN";
|
|
1128
|
+
TransactionType2[TransactionType2["INVENTORY_SURPLUS"] = 8] = "INVENTORY_SURPLUS";
|
|
1129
|
+
TransactionType2[TransactionType2["INVENTORY_MISSING"] = 9] = "INVENTORY_MISSING";
|
|
1130
|
+
return TransactionType2;
|
|
1131
|
+
})({});
|
|
1132
|
+
|
|
1133
|
+
// src/database/entities/fresh-translation-entity.ts
|
|
1134
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
1135
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1136
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1137
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1138
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1139
|
+
}
|
|
1140
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
1141
|
+
function _ts_metadata3(k, v) {
|
|
1142
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1143
|
+
}
|
|
1144
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
1145
|
+
var languageValues = Object.values(LanguageCode).map((v) => `'${v}'`).join(",");
|
|
1146
|
+
var _FreshTranslationBase = class _FreshTranslationBase extends import_typeorm4.BaseEntity {
|
|
1147
|
+
constructor() {
|
|
1148
|
+
super();
|
|
1149
|
+
__publicField(this, "id");
|
|
1150
|
+
__publicField(this, "languageCode");
|
|
1151
|
+
this.id = 0;
|
|
1152
|
+
this.languageCode = LanguageCode.CS;
|
|
1153
|
+
}
|
|
1154
|
+
};
|
|
1155
|
+
__name(_FreshTranslationBase, "FreshTranslationBase");
|
|
1156
|
+
var FreshTranslationBase = _FreshTranslationBase;
|
|
1157
|
+
_ts_decorate3([
|
|
1158
|
+
(0, import_typeorm4.PrimaryGeneratedColumn)(),
|
|
1159
|
+
_ts_metadata3("design:type", Number)
|
|
1160
|
+
], FreshTranslationBase.prototype, "id", void 0);
|
|
1161
|
+
_ts_decorate3([
|
|
1162
|
+
(0, import_typeorm4.Column)({
|
|
1163
|
+
type: "varchar",
|
|
1164
|
+
length: 3,
|
|
1165
|
+
nullable: false
|
|
1166
|
+
}),
|
|
1167
|
+
(0, import_typeorm4.Check)(`"languageCode" IN (${languageValues})`),
|
|
1168
|
+
_ts_metadata3("design:type", typeof LanguageCode === "undefined" ? Object : LanguageCode)
|
|
1169
|
+
], FreshTranslationBase.prototype, "languageCode", void 0);
|
|
1170
|
+
|
|
1171
|
+
// src/database/dao/fresh-dao.ts
|
|
1172
|
+
var _FreshDao = class _FreshDao {
|
|
1173
|
+
};
|
|
1174
|
+
__name(_FreshDao, "FreshDao");
|
|
1175
|
+
var FreshDao = _FreshDao;
|
|
1176
|
+
|
|
1177
|
+
// src/common/schema/entities/category.entity.ts
|
|
1178
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
1179
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1180
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1181
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1182
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1183
|
+
}
|
|
1184
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
1185
|
+
var _Category = class _Category extends FreshEntity {
|
|
1186
|
+
};
|
|
1187
|
+
__name(_Category, "Category");
|
|
1188
|
+
var Category = _Category;
|
|
1189
|
+
Category = _ts_decorate4([
|
|
1190
|
+
(0, import_typeorm5.Entity)()
|
|
1191
|
+
], Category);
|
|
1192
|
+
|
|
1193
|
+
// src/common/schema/entities/device.entity.ts
|
|
1194
|
+
var import_typeorm6 = require("typeorm");
|
|
1195
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1196
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1197
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1198
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1199
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1200
|
+
}
|
|
1201
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
1202
|
+
var _Device = class _Device extends FreshEntity {
|
|
1203
|
+
};
|
|
1204
|
+
__name(_Device, "Device");
|
|
1205
|
+
var Device = _Device;
|
|
1206
|
+
Device = _ts_decorate5([
|
|
1207
|
+
(0, import_typeorm6.Entity)()
|
|
1208
|
+
], Device);
|
|
1209
|
+
|
|
1210
|
+
// src/common/schema/entities/manufacturer.entity.ts
|
|
1211
|
+
var import_typeorm7 = require("typeorm");
|
|
1212
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1213
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1214
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1215
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1216
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1217
|
+
}
|
|
1218
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
1219
|
+
var _Manufacturer = class _Manufacturer extends FreshEntity {
|
|
1220
|
+
};
|
|
1221
|
+
__name(_Manufacturer, "Manufacturer");
|
|
1222
|
+
var Manufacturer = _Manufacturer;
|
|
1223
|
+
Manufacturer = _ts_decorate6([
|
|
1224
|
+
(0, import_typeorm7.Entity)()
|
|
1225
|
+
], Manufacturer);
|
|
1226
|
+
|
|
1227
|
+
// src/common/schema/entities/product.entity.ts
|
|
1228
|
+
var import_typeorm8 = require("typeorm");
|
|
1229
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1230
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1231
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1232
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1233
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1234
|
+
}
|
|
1235
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
1236
|
+
var _Product = class _Product extends FreshEntity {
|
|
1237
|
+
};
|
|
1238
|
+
__name(_Product, "Product");
|
|
1239
|
+
var Product = _Product;
|
|
1240
|
+
Product = _ts_decorate7([
|
|
1241
|
+
(0, import_typeorm8.Entity)()
|
|
1242
|
+
], Product);
|
|
1243
|
+
|
|
1244
|
+
// src/common/schema/entities/subcategory.entity.ts
|
|
1245
|
+
var import_typeorm9 = require("typeorm");
|
|
1246
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1247
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1248
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1249
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1250
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1251
|
+
}
|
|
1252
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1253
|
+
var _Subcategory = class _Subcategory extends FreshEntity {
|
|
1254
|
+
};
|
|
1255
|
+
__name(_Subcategory, "Subcategory");
|
|
1256
|
+
var Subcategory = _Subcategory;
|
|
1257
|
+
Subcategory = _ts_decorate8([
|
|
1258
|
+
(0, import_typeorm9.Entity)()
|
|
1259
|
+
], Subcategory);
|
|
1260
|
+
|
|
1261
|
+
// src/core/data-helper.ts
|
|
1262
|
+
var _DataHelper = class _DataHelper {
|
|
1263
|
+
constructor(startDataRetrieve = true, deviceIds) {
|
|
1264
|
+
__publicField(this, "_data");
|
|
1265
|
+
__publicField(this, "_dataPromise", null);
|
|
1266
|
+
__publicField(this, "deviceIds");
|
|
1267
|
+
this.deviceIds = deviceIds;
|
|
1268
|
+
if (startDataRetrieve) {
|
|
1269
|
+
this._dataPromise = this.startDataRetrieval();
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
get data() {
|
|
1273
|
+
return this._data;
|
|
1274
|
+
}
|
|
1275
|
+
set data(value) {
|
|
1276
|
+
this._data = value;
|
|
1277
|
+
}
|
|
1278
|
+
get dataPromise() {
|
|
1279
|
+
return this._dataPromise;
|
|
1280
|
+
}
|
|
1281
|
+
set dataPromise(value) {
|
|
1282
|
+
this._dataPromise = value;
|
|
1283
|
+
}
|
|
1284
|
+
async getData() {
|
|
1285
|
+
if (this._dataPromise) {
|
|
1286
|
+
return await this._dataPromise;
|
|
1287
|
+
}
|
|
1288
|
+
if (this._data === void 0) {
|
|
1289
|
+
this._dataPromise = this.startDataRetrieval();
|
|
1290
|
+
return this._dataPromise;
|
|
1291
|
+
}
|
|
1292
|
+
return this._data;
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1295
|
+
__name(_DataHelper, "DataHelper");
|
|
1296
|
+
var DataHelper = _DataHelper;
|
|
1297
|
+
|
|
1298
|
+
// src/core/class/fresh-job.ts
|
|
1299
|
+
var import_node_schedule = require("node-schedule");
|
|
1300
|
+
var _FreshJob = class _FreshJob extends Singleton {
|
|
1301
|
+
/**
|
|
1302
|
+
* @param cronExpression must be cron of just numbers ex.: `0 5 * * 4`
|
|
1303
|
+
* By default timezone is added " Europe/Prague"
|
|
1304
|
+
*/
|
|
1305
|
+
constructor(jobName, cronExpression, jobEnabled) {
|
|
1306
|
+
super();
|
|
1307
|
+
__publicField(this, "_jobName");
|
|
1308
|
+
__publicField(this, "_cronExpression");
|
|
1309
|
+
__publicField(this, "_job", null);
|
|
1310
|
+
this._jobName = jobName;
|
|
1311
|
+
if (!isValidCron(cronExpression)) {
|
|
1312
|
+
throw new Error(`Job ${this.jobName} cannot be constructed with invalid cron: "${cronExpression}"`);
|
|
1313
|
+
}
|
|
1314
|
+
this._cronExpression = cronExpression;
|
|
1315
|
+
if (jobEnabled) {
|
|
1316
|
+
this._job = (0, import_node_schedule.scheduleJob)({
|
|
1317
|
+
rule: this._cronExpression,
|
|
1318
|
+
tz: "Europe/Prague"
|
|
1319
|
+
}, async () => {
|
|
1320
|
+
await this.invoke();
|
|
1321
|
+
});
|
|
1322
|
+
if (!this._job) {
|
|
1323
|
+
throw new Error(`Job ${this._jobName} could not be scheduled`);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
this.onInit();
|
|
1327
|
+
}
|
|
1328
|
+
/** Just logging */
|
|
1329
|
+
onInit(rescheduled) {
|
|
1330
|
+
console.log(`Job ${this.jobName} ${rescheduled ? "rescheduled" : "initialized"} with cron rule: "${this.cronExpression}"`);
|
|
1331
|
+
}
|
|
1332
|
+
get jobName() {
|
|
1333
|
+
return this._jobName;
|
|
1334
|
+
}
|
|
1335
|
+
set jobName(value) {
|
|
1336
|
+
this._jobName = value;
|
|
1337
|
+
}
|
|
1338
|
+
get cronExpression() {
|
|
1339
|
+
return this._cronExpression;
|
|
1340
|
+
}
|
|
1341
|
+
set cronExpression(value) {
|
|
1342
|
+
this._cronExpression = value;
|
|
1343
|
+
}
|
|
1344
|
+
get job() {
|
|
1345
|
+
return this._job;
|
|
1346
|
+
}
|
|
1347
|
+
set job(value) {
|
|
1348
|
+
this._job = value;
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
__name(_FreshJob, "FreshJob");
|
|
1352
|
+
var FreshJob = _FreshJob;
|
|
1353
|
+
|
|
1354
|
+
// src/core/errors/api-error.ts
|
|
1355
|
+
var _ApiError = class _ApiError extends Error {
|
|
1356
|
+
constructor(statusCode, status, detail) {
|
|
1357
|
+
super();
|
|
1358
|
+
__publicField(this, "_statusCode");
|
|
1359
|
+
__publicField(this, "_statusDto");
|
|
1360
|
+
this._statusCode = statusCode;
|
|
1361
|
+
this._statusDto = new StatusDto(status, detail);
|
|
1362
|
+
}
|
|
1363
|
+
get statusCode() {
|
|
1364
|
+
return this._statusCode;
|
|
1365
|
+
}
|
|
1366
|
+
get statusDto() {
|
|
1367
|
+
return this._statusDto;
|
|
1368
|
+
}
|
|
1369
|
+
};
|
|
1370
|
+
__name(_ApiError, "ApiError");
|
|
1371
|
+
var ApiError = _ApiError;
|
|
1372
|
+
|
|
1373
|
+
// src/config/eslint-config.ts
|
|
1374
|
+
var import_typescript_eslint = __toESM(require("typescript-eslint"));
|
|
1375
|
+
var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"));
|
|
1376
|
+
var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"));
|
|
1377
|
+
var FRESH_ESLINT_CONFIG = [
|
|
1378
|
+
{
|
|
1379
|
+
// Prettier integration
|
|
1380
|
+
...import_eslint_config_prettier.default,
|
|
1381
|
+
// Affected files
|
|
1382
|
+
files: [
|
|
1383
|
+
"**/*.ts",
|
|
1384
|
+
"**/*.tsx"
|
|
1385
|
+
],
|
|
1386
|
+
ignores: [
|
|
1387
|
+
"dist/**",
|
|
1388
|
+
"node_modules/**",
|
|
1389
|
+
"build/**",
|
|
1390
|
+
"**/*.js",
|
|
1391
|
+
"**/*.mjs",
|
|
1392
|
+
"**/*-migration.ts",
|
|
1393
|
+
"**/*-migration.js"
|
|
1394
|
+
],
|
|
1395
|
+
languageOptions: {
|
|
1396
|
+
parser: import_typescript_eslint.default.parser,
|
|
1397
|
+
ecmaVersion: "latest",
|
|
1398
|
+
sourceType: "module"
|
|
1399
|
+
},
|
|
1400
|
+
// Extra plugins declared
|
|
1401
|
+
plugins: {
|
|
1402
|
+
"@typescript-eslint": import_typescript_eslint.default.plugin,
|
|
1403
|
+
prettier: import_eslint_plugin_prettier.default
|
|
1404
|
+
},
|
|
1405
|
+
rules: {
|
|
1406
|
+
// Eslint rules
|
|
1407
|
+
// no lets or vars
|
|
1408
|
+
"prefer-const": "error",
|
|
1409
|
+
// blocks ("red" === color) these ifs
|
|
1410
|
+
yoda: [
|
|
1411
|
+
"error",
|
|
1412
|
+
"never"
|
|
1413
|
+
],
|
|
1414
|
+
"no-multiple-empty-lines": [
|
|
1415
|
+
"error",
|
|
1416
|
+
{
|
|
1417
|
+
max: 1
|
|
1418
|
+
}
|
|
1419
|
+
],
|
|
1420
|
+
// semi-colons
|
|
1421
|
+
semi: [
|
|
1422
|
+
"error",
|
|
1423
|
+
"always"
|
|
1424
|
+
],
|
|
1425
|
+
// forces block for all control statements (forbid one-line returns)
|
|
1426
|
+
curly: [
|
|
1427
|
+
"error",
|
|
1428
|
+
"all"
|
|
1429
|
+
],
|
|
1430
|
+
// makes spaces between brackets
|
|
1431
|
+
"object-curly-spacing": [
|
|
1432
|
+
"error",
|
|
1433
|
+
"always"
|
|
1434
|
+
],
|
|
1435
|
+
// checks same if/else conditions
|
|
1436
|
+
"no-dupe-else-if": "error",
|
|
1437
|
+
// keeps imports from one package in same declaration
|
|
1438
|
+
"no-duplicate-imports": "error",
|
|
1439
|
+
// blocks simple '=' in condition blocks
|
|
1440
|
+
"no-cond-assign": [
|
|
1441
|
+
"error",
|
|
1442
|
+
"always"
|
|
1443
|
+
],
|
|
1444
|
+
// forbids promise inside promise
|
|
1445
|
+
"no-async-promise-executor": "error",
|
|
1446
|
+
// watches possible falltrough in switch cases
|
|
1447
|
+
"no-fallthrough": "error",
|
|
1448
|
+
// use === instead of ==
|
|
1449
|
+
eqeqeq: [
|
|
1450
|
+
"error",
|
|
1451
|
+
"always"
|
|
1452
|
+
],
|
|
1453
|
+
// Prettier formatting rules
|
|
1454
|
+
"prettier/prettier": [
|
|
1455
|
+
"error",
|
|
1456
|
+
{
|
|
1457
|
+
// max 100 chars per line
|
|
1458
|
+
printWidth: 100,
|
|
1459
|
+
// keep 4 spaces and no tabs
|
|
1460
|
+
tabWidth: 4,
|
|
1461
|
+
useTabs: false,
|
|
1462
|
+
// enforce semicolons
|
|
1463
|
+
semi: true,
|
|
1464
|
+
// prefers ""
|
|
1465
|
+
singleQuote: false,
|
|
1466
|
+
// last comma in array or object
|
|
1467
|
+
trailingComma: "es5",
|
|
1468
|
+
// enable spacing next to brackets
|
|
1469
|
+
bracketSpacing: true,
|
|
1470
|
+
// enables CRLF eol which is enforced by git
|
|
1471
|
+
endOfLine: "auto"
|
|
1472
|
+
}
|
|
1473
|
+
],
|
|
1474
|
+
// Namin conventions
|
|
1475
|
+
"@typescript-eslint/naming-convention": [
|
|
1476
|
+
"error",
|
|
1477
|
+
{
|
|
1478
|
+
selector: [
|
|
1479
|
+
"variable",
|
|
1480
|
+
"function"
|
|
1481
|
+
],
|
|
1482
|
+
format: [
|
|
1483
|
+
"camelCase"
|
|
1484
|
+
],
|
|
1485
|
+
leadingUnderscore: "allow"
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
selector: "class",
|
|
1489
|
+
format: [
|
|
1490
|
+
"PascalCase"
|
|
1491
|
+
]
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
selector: "variable",
|
|
1495
|
+
modifiers: [
|
|
1496
|
+
"const",
|
|
1497
|
+
"exported"
|
|
1498
|
+
],
|
|
1499
|
+
format: [
|
|
1500
|
+
"UPPER_CASE",
|
|
1501
|
+
"PascalCase"
|
|
1502
|
+
]
|
|
1503
|
+
},
|
|
1504
|
+
{
|
|
1505
|
+
selector: "property",
|
|
1506
|
+
modifiers: [
|
|
1507
|
+
"readonly"
|
|
1508
|
+
],
|
|
1509
|
+
format: [
|
|
1510
|
+
"UPPER_CASE"
|
|
1511
|
+
]
|
|
1512
|
+
}
|
|
1513
|
+
]
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
];
|
|
1517
|
+
var eslint_config_default = FRESH_ESLINT_CONFIG;
|
|
1518
|
+
|
|
1519
|
+
// src/config/datasource.ts
|
|
1520
|
+
var import_path = __toESM(require("path"));
|
|
1521
|
+
var import_typeorm_naming_strategies = require("typeorm-naming-strategies");
|
|
1522
|
+
var import_dotenv = __toESM(require_main());
|
|
1523
|
+
(0, import_dotenv.config)();
|
|
1524
|
+
var basePath = process.cwd();
|
|
1525
|
+
var isTs = process.env.LOCAL === "true";
|
|
1526
|
+
var PG_DATA_SOURCE_OPTIONS = {
|
|
1527
|
+
applicationName: "<service-name>",
|
|
1528
|
+
name: "<service-name>-connection",
|
|
1529
|
+
type: "postgres",
|
|
1530
|
+
host: process.env.POSTGRE_SQL_HOST || "<host>",
|
|
1531
|
+
port: Number(process.env.POSTGRE_SQL_PORT || "3300"),
|
|
1532
|
+
username: process.env.POSTGRE_SQL_USER || "<user>",
|
|
1533
|
+
password: process.env.POSTGRE_SQL_PASSWORD || "<password>",
|
|
1534
|
+
database: process.env.POSTGRE_SQL_DATABASE || "<database>",
|
|
1535
|
+
schema: process.env.POSTGRE_SQL_SCHEMA || "<scheme>",
|
|
1536
|
+
entities: [
|
|
1537
|
+
import_path.default.join(basePath, isTs ? "src/entity/*.{ts,js}" : "build/entity/*.js")
|
|
1538
|
+
],
|
|
1539
|
+
migrations: [
|
|
1540
|
+
import_path.default.join(basePath, isTs ? "src/migration/*.{ts,js}" : "build/migration/*.js")
|
|
1541
|
+
],
|
|
1542
|
+
migrationsRun: process.env.RUN_MIGRATIONS === "true",
|
|
1543
|
+
migrationsTableName: "migrations",
|
|
1544
|
+
migrationsTransactionMode: "each",
|
|
1545
|
+
synchronize: false,
|
|
1546
|
+
logging: false,
|
|
1547
|
+
extra: {
|
|
1548
|
+
connectionLimit: 20
|
|
1549
|
+
},
|
|
1550
|
+
useUTC: true,
|
|
1551
|
+
cache: true,
|
|
1552
|
+
namingStrategy: new import_typeorm_naming_strategies.SnakeNamingStrategy()
|
|
1553
|
+
};
|
|
1554
|
+
var datasource_default = PG_DATA_SOURCE_OPTIONS;
|
|
1555
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1556
|
+
0 && (module.exports = {
|
|
1557
|
+
AMOUNT_UNIT,
|
|
1558
|
+
ActionCommandCode,
|
|
1559
|
+
ApiError,
|
|
1560
|
+
Category,
|
|
1561
|
+
DataHelper,
|
|
1562
|
+
DateUtils,
|
|
1563
|
+
DepotPoolStatus,
|
|
1564
|
+
Device,
|
|
1565
|
+
FreshDao,
|
|
1566
|
+
FreshEntity,
|
|
1567
|
+
FreshHyperEntity,
|
|
1568
|
+
FreshJob,
|
|
1569
|
+
FreshTranslationBase,
|
|
1570
|
+
HttpStatus,
|
|
1571
|
+
LanguageCode,
|
|
1572
|
+
Manufacturer,
|
|
1573
|
+
PaymentMethod,
|
|
1574
|
+
PgDataSourceOptions,
|
|
1575
|
+
Product,
|
|
1576
|
+
SinglePromiseWaiter,
|
|
1577
|
+
Singleton,
|
|
1578
|
+
StatusDto,
|
|
1579
|
+
Subcategory,
|
|
1580
|
+
TimestampColumn,
|
|
1581
|
+
TransactionType,
|
|
1582
|
+
createDeferred,
|
|
1583
|
+
freshEslintConfig,
|
|
1584
|
+
isValidCron,
|
|
1585
|
+
logger
|
|
1586
|
+
});
|
|
1587
|
+
//# sourceMappingURL=index.js.map
|