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