@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.js ADDED
@@ -0,0 +1,1328 @@
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 __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
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"(exports2, module2) {
44
+ module2.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"(exports2, module2) {
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
+ module2.exports.configDotenv = DotenvModule.configDotenv;
390
+ module2.exports._configVault = DotenvModule._configVault;
391
+ module2.exports._parseVault = DotenvModule._parseVault;
392
+ module2.exports.config = DotenvModule.config;
393
+ module2.exports.decrypt = DotenvModule.decrypt;
394
+ module2.exports.parse = DotenvModule.parse;
395
+ module2.exports.populate = DotenvModule.populate;
396
+ module2.exports = DotenvModule;
397
+ }
398
+ });
399
+
400
+ // src/index.ts
401
+ var index_exports = {};
402
+ __export(index_exports, {
403
+ AMOUNT_UNIT: () => AMOUNT_UNIT,
404
+ ActionCommandCode: () => ActionCommandCode,
405
+ ApiError: () => ApiError,
406
+ Category: () => Category,
407
+ DataHelper: () => DataHelper,
408
+ DateUtils: () => DateUtils,
409
+ DepotPoolStatus: () => DepotPoolStatus,
410
+ Device: () => Device,
411
+ FreshDao: () => FreshDao,
412
+ FreshEntity: () => FreshEntity,
413
+ FreshHyperEntity: () => FreshHyperEntity,
414
+ FreshJob: () => FreshJob,
415
+ FreshTranslationBase: () => FreshTranslationBase,
416
+ HttpStatus: () => HttpStatus,
417
+ LanguageCode: () => LanguageCode,
418
+ Manufacturer: () => Manufacturer,
419
+ PaymentMethod: () => PaymentMethod,
420
+ PgDataSourceOptions: () => datasource_default,
421
+ Product: () => Product,
422
+ SinglePromiseWaiter: () => SinglePromiseWaiter,
423
+ Singleton: () => Singleton,
424
+ StatusDto: () => StatusDto,
425
+ Subcategory: () => Subcategory,
426
+ TimestampColumn: () => TimestampColumn,
427
+ TransactionType: () => TransactionType,
428
+ createDeferred: () => createDeferred,
429
+ freshEslintConfig: () => eslint_config_default,
430
+ isValidCron: () => isValidCron,
431
+ logger: () => logger
432
+ });
433
+ module.exports = __toCommonJS(index_exports);
434
+
435
+ // src/common/date-utils.ts
436
+ var import_dayjs = __toESM(require("dayjs"));
437
+ var import_utc = __toESM(require("dayjs/plugin/utc"));
438
+ var import_timezone = __toESM(require("dayjs/plugin/timezone"));
439
+ var import_isBetween = __toESM(require("dayjs/plugin/isBetween"));
440
+ var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
441
+ import_dayjs.default.extend(import_utc.default);
442
+ import_dayjs.default.extend(import_timezone.default);
443
+ import_dayjs.default.extend(import_isBetween.default);
444
+ import_dayjs.default.extend(import_customParseFormat.default);
445
+ var _DateUtils = class _DateUtils {
446
+ //#endregion
447
+ //#region SQL timestamps
448
+ static fromISOtoSQLtimestamp(ts) {
449
+ return (0, import_dayjs.default)(ts).utc().format("YYYY-MM-DD HH:mm:ss");
450
+ }
451
+ static toSQLtimestamp(ts) {
452
+ return ts.format("YYYY-MM-DD HH:mm:ss");
453
+ }
454
+ static fromSQLtimestamp(mysqlDate) {
455
+ return (0, import_dayjs.default)(mysqlDate, "YYYY-MM-DD HH:mm:ss").utc(true);
456
+ }
457
+ static getSqlTimestampFromNowCzech() {
458
+ return _DateUtils.toSQLtimestamp(_DateUtils.getNowCzech());
459
+ }
460
+ //#endregion
461
+ // ---------- UTC
462
+ static fromISO(isoDate) {
463
+ return (0, import_dayjs.default)(isoDate).utc(false);
464
+ }
465
+ // ----------
466
+ static getDate(ts) {
467
+ return (0, import_dayjs.default)(ts);
468
+ }
469
+ static getNow() {
470
+ return (0, import_dayjs.default)();
471
+ }
472
+ static getNowCzech() {
473
+ return (0, import_dayjs.default)().tz("Europe/Prague").utc(true);
474
+ }
475
+ static clone(ts) {
476
+ return (0, import_dayjs.default)(ts);
477
+ }
478
+ static getLastSunday(weeksOffset = 0) {
479
+ let now = _DateUtils.getNowCzech();
480
+ now = now.date(now.date() - (now.day() + 1) % 7 - 7 * weeksOffset);
481
+ now = now.hour(0);
482
+ now = now.minute(0);
483
+ now = now.second(0);
484
+ now = now.millisecond(0);
485
+ return now;
486
+ }
487
+ static dayInWeek(ts) {
488
+ const input = ts != null ? ts : (0, import_dayjs.default)();
489
+ const day = input.day();
490
+ if (day === 0) {
491
+ return 7;
492
+ }
493
+ return day;
494
+ }
495
+ static isWorkdayDay(ts) {
496
+ const weekDay = ts.get("day");
497
+ if (weekDay === 0) {
498
+ return false;
499
+ }
500
+ if (weekDay === 6) {
501
+ return false;
502
+ }
503
+ ts = ts.set("hour", 0).set("minutes", 0).set("seconds", 0).set("milliseconds", 0);
504
+ return !_DateUtils.HOLIDAYS.includes(ts.valueOf());
505
+ }
506
+ static getDiffInMinutesWithNow(inputTime) {
507
+ const now = (0, import_dayjs.default)();
508
+ const diffInMinutes = now.diff(inputTime, "minute");
509
+ return diffInMinutes;
510
+ }
511
+ static isInLastDays(numOfDays, timestampInput) {
512
+ const timestamp = typeof timestampInput === "string" ? (0, import_dayjs.default)(timestampInput) : timestampInput;
513
+ const now = (0, import_dayjs.default)();
514
+ const dateLimit = now.subtract(numOfDays, "day");
515
+ return timestamp.isAfter(dateLimit);
516
+ }
517
+ };
518
+ //#region Holidays
519
+ /** Holidays 2025-2030 as YYYY-MM-DD strings */
520
+ _DateUtils.HOLIDAYS_STR = [
521
+ /* 2025 */
522
+ "2025-01-01",
523
+ "2025-04-18",
524
+ "2025-04-21",
525
+ "2025-05-01",
526
+ "2025-05-08",
527
+ "2025-07-05",
528
+ "2025-07-06",
529
+ "2025-09-28",
530
+ "2025-10-28",
531
+ "2025-11-17",
532
+ "2025-12-24",
533
+ "2025-12-25",
534
+ "2025-12-26",
535
+ /* 2026 */
536
+ "2026-01-01",
537
+ "2026-04-03",
538
+ "2026-04-06",
539
+ "2026-05-01",
540
+ "2026-05-08",
541
+ "2026-07-05",
542
+ "2026-07-06",
543
+ "2026-09-28",
544
+ "2026-10-28",
545
+ "2026-11-17",
546
+ "2026-12-24",
547
+ "2026-12-25",
548
+ "2026-12-26",
549
+ /* 2027 */
550
+ "2027-01-01",
551
+ "2027-03-26",
552
+ "2027-03-29",
553
+ "2027-05-01",
554
+ "2027-05-08",
555
+ "2027-07-05",
556
+ "2027-07-06",
557
+ "2027-09-28",
558
+ "2027-10-28",
559
+ "2027-11-17",
560
+ "2027-12-24",
561
+ "2027-12-25",
562
+ "2027-12-26",
563
+ /* 2028 */
564
+ "2028-01-01",
565
+ "2028-04-14",
566
+ "2028-04-17",
567
+ "2028-05-01",
568
+ "2028-05-08",
569
+ "2028-07-05",
570
+ "2028-07-06",
571
+ "2028-09-28",
572
+ "2028-10-28",
573
+ "2028-11-17",
574
+ "2028-12-24",
575
+ "2028-12-25",
576
+ "2028-12-26",
577
+ /* 2029 */
578
+ "2029-01-01",
579
+ "2029-03-30",
580
+ "2029-04-02",
581
+ "2029-05-01",
582
+ "2029-05-08",
583
+ "2029-07-05",
584
+ "2029-07-06",
585
+ "2029-09-28",
586
+ "2029-10-28",
587
+ "2029-11-17",
588
+ "2029-12-24",
589
+ "2029-12-25",
590
+ "2029-12-26",
591
+ /* 2030 */
592
+ "2030-01-01",
593
+ "2030-04-19",
594
+ "2030-04-22",
595
+ "2030-05-01",
596
+ "2030-05-08",
597
+ "2030-07-05",
598
+ "2030-07-06",
599
+ "2030-09-28",
600
+ "2030-10-28",
601
+ "2030-11-17",
602
+ "2030-12-24",
603
+ "2030-12-25",
604
+ "2030-12-26"
605
+ ];
606
+ /** Holidays 2025-2030 as UTC timestamps */
607
+ _DateUtils.HOLIDAYS = _DateUtils.HOLIDAYS_STR.map((h) => {
608
+ const date = new Date(h);
609
+ date.setUTCHours(0, 0, 0, 0);
610
+ return date.getTime();
611
+ });
612
+ var DateUtils = _DateUtils;
613
+
614
+ // src/common/promise-magic/deferred.ts
615
+ function createDeferred() {
616
+ let resolve;
617
+ let reject;
618
+ const promise = new Promise((res, rej) => {
619
+ resolve = res;
620
+ reject = rej;
621
+ });
622
+ return { promise, resolve, reject };
623
+ }
624
+
625
+ // src/common/promise-magic/single-promise-waiter.ts
626
+ var SinglePromiseWaiter = class _SinglePromiseWaiter {
627
+ constructor() {
628
+ this._promise = null;
629
+ }
630
+ static getInstance() {
631
+ if (!_SinglePromiseWaiter._instance) {
632
+ _SinglePromiseWaiter._instance = new _SinglePromiseWaiter();
633
+ }
634
+ return _SinglePromiseWaiter._instance;
635
+ }
636
+ get promise() {
637
+ return this._promise;
638
+ }
639
+ set promise(promise) {
640
+ if (promise !== null) {
641
+ this._promise = promise;
642
+ this._promise.finally(() => {
643
+ this._promise = null;
644
+ });
645
+ }
646
+ }
647
+ get hasPromise() {
648
+ return this._promise !== null;
649
+ }
650
+ };
651
+
652
+ // src/common/winston.ts
653
+ var import_winston = __toESM(require("winston"));
654
+ var SERVICE = process.env.SERVICE_NAME || "depot-ordering-service";
655
+ var ENV = process.env.NODE_ENV || "localhost";
656
+ var levelToSeverity = {
657
+ silly: "debug",
658
+ verbose: "debug",
659
+ debug: "debug",
660
+ http: "info",
661
+ info: "info",
662
+ warn: "warn",
663
+ error: "error"
664
+ };
665
+ var baseFormat = import_winston.default.format.combine(
666
+ import_winston.default.format.timestamp({ format: () => (/* @__PURE__ */ new Date()).toISOString() }),
667
+ import_winston.default.format.errors({ stack: true }),
668
+ import_winston.default.format.printf((info) => {
669
+ const payload = {
670
+ ts: info.timestamp,
671
+ level: info.level,
672
+ severity: levelToSeverity[info.level] || info.level,
673
+ message: info.message,
674
+ service: SERVICE,
675
+ env: ENV,
676
+ process_name: process.title || process.argv[1] || "node",
677
+ pid: process.pid,
678
+ device: process.env.DEVICE_ID || void 0,
679
+ traceId: info.traceId,
680
+ spanId: info.spanId,
681
+ extra: info.extra || info.meta || void 0,
682
+ stack: info.stack
683
+ };
684
+ return JSON.stringify(payload);
685
+ })
686
+ );
687
+ var transports = [
688
+ new import_winston.default.transports.Console({
689
+ level: process.env.LOG_LEVEL || "info"
690
+ })
691
+ ];
692
+ var logger = import_winston.default.createLogger({
693
+ level: process.env.LOG_LEVEL || "info",
694
+ format: baseFormat,
695
+ transports,
696
+ exitOnError: false
697
+ });
698
+ logger.stream = {
699
+ write: (message) => logger.info(message.trim())
700
+ };
701
+
702
+ // src/common/utils/is-cron-valid.ts
703
+ function isValidCron(expr) {
704
+ const parts = expr.trim().split(/\s+/);
705
+ if (parts.length < 5 || parts.length > 6) {
706
+ return false;
707
+ }
708
+ const cronPart = /^(\*|\d+|\d+\-\d+|\d+\/\d+|\*\/\d+)(,\d+)*$/;
709
+ return parts.every((part) => cronPart.test(part));
710
+ }
711
+
712
+ // src/common/patterns/singleton.ts
713
+ var _Singleton = class _Singleton {
714
+ constructor() {
715
+ const ctor = this.constructor;
716
+ const existing = _Singleton.instances.get(ctor);
717
+ if (existing) {
718
+ return existing;
719
+ }
720
+ _Singleton.instances.set(ctor, this);
721
+ }
722
+ };
723
+ _Singleton.instances = /* @__PURE__ */ new Map();
724
+ var Singleton = _Singleton;
725
+
726
+ // src/common/dto/status-dto.ts
727
+ var StatusDto = class {
728
+ constructor(status, details, timestamp) {
729
+ this.status = status;
730
+ this.details = details;
731
+ this.timestamp = timestamp != null ? timestamp : DateUtils.getNowCzech().toISOString();
732
+ }
733
+ };
734
+
735
+ // src/common/constants/amount-unit.ts
736
+ var AMOUNT_UNIT = {
737
+ 1: { symbol: "g", translations: { en: "gram", cs: "gram" } },
738
+ 2: { symbol: "kg", translations: { en: "kilogram", cs: "kilogram" } },
739
+ 3: { symbol: "ml", translations: { en: "milliliter", cs: "mililitr" } },
740
+ 4: { symbol: "l", translations: { en: "liter", cs: "litr" } }
741
+ };
742
+
743
+ // src/common/schema/entities/category.entity.ts
744
+ var import_typeorm5 = require("typeorm");
745
+
746
+ // src/database/entities/fresh-entity.ts
747
+ var import_typeorm = require("typeorm");
748
+
749
+ // ../../node_modules/uuid/dist/esm/stringify.js
750
+ var byteToHex = [];
751
+ for (let i = 0; i < 256; ++i) {
752
+ byteToHex.push((i + 256).toString(16).slice(1));
753
+ }
754
+ function unsafeStringify(arr, offset = 0) {
755
+ 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();
756
+ }
757
+
758
+ // ../../node_modules/uuid/dist/esm/rng.js
759
+ var import_crypto = require("crypto");
760
+ var rnds8Pool = new Uint8Array(256);
761
+ var poolPtr = rnds8Pool.length;
762
+ function rng() {
763
+ if (poolPtr > rnds8Pool.length - 16) {
764
+ (0, import_crypto.randomFillSync)(rnds8Pool);
765
+ poolPtr = 0;
766
+ }
767
+ return rnds8Pool.slice(poolPtr, poolPtr += 16);
768
+ }
769
+
770
+ // ../../node_modules/uuid/dist/esm/native.js
771
+ var import_crypto2 = require("crypto");
772
+ var native_default = { randomUUID: import_crypto2.randomUUID };
773
+
774
+ // ../../node_modules/uuid/dist/esm/v4.js
775
+ function v4(options, buf, offset) {
776
+ var _a, _b, _c;
777
+ if (native_default.randomUUID && !buf && !options) {
778
+ return native_default.randomUUID();
779
+ }
780
+ options = options || {};
781
+ const rnds = (_c = (_b = options.random) != null ? _b : (_a = options.rng) == null ? void 0 : _a.call(options)) != null ? _c : rng();
782
+ if (rnds.length < 16) {
783
+ throw new Error("Random bytes length must be >= 16");
784
+ }
785
+ rnds[6] = rnds[6] & 15 | 64;
786
+ rnds[8] = rnds[8] & 63 | 128;
787
+ if (buf) {
788
+ offset = offset || 0;
789
+ if (offset < 0 || offset + 16 > buf.length) {
790
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
791
+ }
792
+ for (let i = 0; i < 16; ++i) {
793
+ buf[offset + i] = rnds[i];
794
+ }
795
+ return buf;
796
+ }
797
+ return unsafeStringify(rnds);
798
+ }
799
+ var v4_default = v4;
800
+
801
+ // src/database/entities/fresh-entity.ts
802
+ var FreshEntity = class extends import_typeorm.BaseEntity {
803
+ /** After manual construction `id` is irrelevant. Refer to `uuid` only, because that will be inserted into DB */
804
+ constructor() {
805
+ super();
806
+ this.id = 0;
807
+ this.uuid = v4_default();
808
+ const newDate = /* @__PURE__ */ new Date();
809
+ this.created_at = newDate;
810
+ this.updated_at = newDate;
811
+ this.deleted_at = null;
812
+ }
813
+ };
814
+ __decorateClass([
815
+ (0, import_typeorm.PrimaryGeneratedColumn)("increment")
816
+ ], FreshEntity.prototype, "id", 2);
817
+ __decorateClass([
818
+ (0, import_typeorm.Index)({ unique: true }),
819
+ (0, import_typeorm.Column)({ type: "uuid", default: () => "timescale.uuid_generate_v4()" })
820
+ ], FreshEntity.prototype, "uuid", 2);
821
+ __decorateClass([
822
+ (0, import_typeorm.CreateDateColumn)({ type: "timestamptz" })
823
+ ], FreshEntity.prototype, "created_at", 2);
824
+ __decorateClass([
825
+ (0, import_typeorm.UpdateDateColumn)({ type: "timestamptz" })
826
+ ], FreshEntity.prototype, "updated_at", 2);
827
+ __decorateClass([
828
+ (0, import_typeorm.DeleteDateColumn)({ type: "timestamptz", nullable: true })
829
+ ], FreshEntity.prototype, "deleted_at", 2);
830
+
831
+ // src/database/entities/fresh-hyper-entity.ts
832
+ var import_typeorm3 = require("typeorm");
833
+
834
+ // src/database/decorators/timestamp-column.ts
835
+ var import_typeorm2 = require("typeorm");
836
+ function TimestampColumn(options = {}) {
837
+ const defaultOptions = {
838
+ type: "timestamptz",
839
+ nullable: false,
840
+ default: () => "CURRENT_TIMESTAMP",
841
+ ...options
842
+ };
843
+ return (0, import_typeorm2.Column)(defaultOptions);
844
+ }
845
+
846
+ // src/database/entities/fresh-hyper-entity.ts
847
+ var FreshHyperEntity = class extends import_typeorm3.BaseEntity {
848
+ /** After manual construction `id` is irrelevant */
849
+ constructor(timestamp) {
850
+ super();
851
+ this.timestamp = timestamp != null ? timestamp : /* @__PURE__ */ new Date();
852
+ this.created_at = /* @__PURE__ */ new Date();
853
+ }
854
+ };
855
+ __decorateClass([
856
+ (0, import_typeorm3.PrimaryColumn)({ type: "timestamptz" })
857
+ ], FreshHyperEntity.prototype, "timestamp", 2);
858
+ __decorateClass([
859
+ TimestampColumn()
860
+ ], FreshHyperEntity.prototype, "created_at", 2);
861
+
862
+ // src/database/entities/fresh-translation-entity.ts
863
+ var import_typeorm4 = require("typeorm");
864
+
865
+ // src/enums/action-command-code.ts
866
+ var ActionCommandCode = /* @__PURE__ */ ((ActionCommandCode2) => {
867
+ ActionCommandCode2[ActionCommandCode2["RESTART_PC"] = 1] = "RESTART_PC";
868
+ ActionCommandCode2[ActionCommandCode2["RESTART_APPLICATION"] = 2] = "RESTART_APPLICATION";
869
+ ActionCommandCode2[ActionCommandCode2["RESTART_ROUTER"] = 3] = "RESTART_ROUTER";
870
+ ActionCommandCode2[ActionCommandCode2["RESTART_REMOTE_CONTROL"] = 4] = "RESTART_REMOTE_CONTROL";
871
+ ActionCommandCode2[ActionCommandCode2["SYNCHRONIZE"] = 5] = "SYNCHRONIZE";
872
+ ActionCommandCode2[ActionCommandCode2["DIAGNOSE_LOCKS"] = 6] = "DIAGNOSE_LOCKS";
873
+ ActionCommandCode2[ActionCommandCode2["SYNCHRONIZE_CONFIG"] = 7] = "SYNCHRONIZE_CONFIG";
874
+ return ActionCommandCode2;
875
+ })(ActionCommandCode || {});
876
+
877
+ // src/enums/depot-pool-status.ts
878
+ var DepotPoolStatus = /* @__PURE__ */ ((DepotPoolStatus2) => {
879
+ DepotPoolStatus2[DepotPoolStatus2["NEW"] = 0] = "NEW";
880
+ DepotPoolStatus2[DepotPoolStatus2["PICKED"] = 1] = "PICKED";
881
+ DepotPoolStatus2[DepotPoolStatus2["WRITTEN_OFF"] = 2] = "WRITTEN_OFF";
882
+ DepotPoolStatus2[DepotPoolStatus2["ACTIVE"] = 3] = "ACTIVE";
883
+ DepotPoolStatus2[DepotPoolStatus2["TERMINATED"] = 4] = "TERMINATED";
884
+ return DepotPoolStatus2;
885
+ })(DepotPoolStatus || {});
886
+
887
+ // src/enums/http-status.ts
888
+ var HttpStatus = /* @__PURE__ */ ((HttpStatus2) => {
889
+ HttpStatus2[HttpStatus2["CONTINUE"] = 100] = "CONTINUE";
890
+ HttpStatus2[HttpStatus2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
891
+ HttpStatus2[HttpStatus2["PROCESSING"] = 102] = "PROCESSING";
892
+ HttpStatus2[HttpStatus2["EARLY_HINTS"] = 103] = "EARLY_HINTS";
893
+ HttpStatus2[HttpStatus2["OK"] = 200] = "OK";
894
+ HttpStatus2[HttpStatus2["CREATED"] = 201] = "CREATED";
895
+ HttpStatus2[HttpStatus2["ACCEPTED"] = 202] = "ACCEPTED";
896
+ HttpStatus2[HttpStatus2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
897
+ HttpStatus2[HttpStatus2["NO_CONTENT"] = 204] = "NO_CONTENT";
898
+ HttpStatus2[HttpStatus2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
899
+ HttpStatus2[HttpStatus2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
900
+ HttpStatus2[HttpStatus2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
901
+ HttpStatus2[HttpStatus2["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
902
+ HttpStatus2[HttpStatus2["IM_USED"] = 226] = "IM_USED";
903
+ HttpStatus2[HttpStatus2["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
904
+ HttpStatus2[HttpStatus2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
905
+ HttpStatus2[HttpStatus2["FOUND"] = 302] = "FOUND";
906
+ HttpStatus2[HttpStatus2["SEE_OTHER"] = 303] = "SEE_OTHER";
907
+ HttpStatus2[HttpStatus2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
908
+ HttpStatus2[HttpStatus2["USE_PROXY"] = 305] = "USE_PROXY";
909
+ HttpStatus2[HttpStatus2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
910
+ HttpStatus2[HttpStatus2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
911
+ HttpStatus2[HttpStatus2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
912
+ HttpStatus2[HttpStatus2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
913
+ HttpStatus2[HttpStatus2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
914
+ HttpStatus2[HttpStatus2["FORBIDDEN"] = 403] = "FORBIDDEN";
915
+ HttpStatus2[HttpStatus2["NOT_FOUND"] = 404] = "NOT_FOUND";
916
+ HttpStatus2[HttpStatus2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
917
+ HttpStatus2[HttpStatus2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
918
+ HttpStatus2[HttpStatus2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
919
+ HttpStatus2[HttpStatus2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
920
+ HttpStatus2[HttpStatus2["CONFLICT"] = 409] = "CONFLICT";
921
+ HttpStatus2[HttpStatus2["GONE"] = 410] = "GONE";
922
+ HttpStatus2[HttpStatus2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
923
+ HttpStatus2[HttpStatus2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
924
+ HttpStatus2[HttpStatus2["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
925
+ HttpStatus2[HttpStatus2["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
926
+ HttpStatus2[HttpStatus2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
927
+ HttpStatus2[HttpStatus2["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
928
+ HttpStatus2[HttpStatus2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
929
+ HttpStatus2[HttpStatus2["IM_A_TEAPOT"] = 418] = "IM_A_TEAPOT";
930
+ HttpStatus2[HttpStatus2["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
931
+ HttpStatus2[HttpStatus2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
932
+ HttpStatus2[HttpStatus2["LOCKED"] = 423] = "LOCKED";
933
+ HttpStatus2[HttpStatus2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
934
+ HttpStatus2[HttpStatus2["TOO_EARLY"] = 425] = "TOO_EARLY";
935
+ HttpStatus2[HttpStatus2["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
936
+ HttpStatus2[HttpStatus2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
937
+ HttpStatus2[HttpStatus2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
938
+ HttpStatus2[HttpStatus2["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
939
+ HttpStatus2[HttpStatus2["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
940
+ HttpStatus2[HttpStatus2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
941
+ HttpStatus2[HttpStatus2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
942
+ HttpStatus2[HttpStatus2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
943
+ HttpStatus2[HttpStatus2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
944
+ HttpStatus2[HttpStatus2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
945
+ HttpStatus2[HttpStatus2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
946
+ HttpStatus2[HttpStatus2["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
947
+ HttpStatus2[HttpStatus2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
948
+ HttpStatus2[HttpStatus2["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
949
+ HttpStatus2[HttpStatus2["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
950
+ HttpStatus2[HttpStatus2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
951
+ return HttpStatus2;
952
+ })(HttpStatus || {});
953
+
954
+ // src/enums/language-code.ts
955
+ var LanguageCode = /* @__PURE__ */ ((LanguageCode2) => {
956
+ LanguageCode2["CS"] = "cs";
957
+ LanguageCode2["EN"] = "en";
958
+ LanguageCode2["DE"] = "de";
959
+ LanguageCode2["PL"] = "pl";
960
+ LanguageCode2["SK"] = "sk";
961
+ return LanguageCode2;
962
+ })(LanguageCode || {});
963
+
964
+ // src/enums/payment-method.ts
965
+ var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
966
+ PaymentMethod2[PaymentMethod2["CODE"] = 0] = "CODE";
967
+ PaymentMethod2[PaymentMethod2["CARD"] = 1] = "CARD";
968
+ PaymentMethod2[PaymentMethod2["NONE"] = 2] = "NONE";
969
+ return PaymentMethod2;
970
+ })(PaymentMethod || {});
971
+
972
+ // src/enums/transaction-type.ts
973
+ var TransactionType = /* @__PURE__ */ ((TransactionType2) => {
974
+ TransactionType2[TransactionType2["WRITEOFF"] = 0] = "WRITEOFF";
975
+ TransactionType2[TransactionType2["SALE"] = 1] = "SALE";
976
+ TransactionType2[TransactionType2["LOST"] = 2] = "LOST";
977
+ TransactionType2[TransactionType2["ADD"] = 3] = "ADD";
978
+ TransactionType2[TransactionType2["DELIVERY"] = 4] = "DELIVERY";
979
+ TransactionType2[TransactionType2["DEPOT_WRITEOFF"] = 5] = "DEPOT_WRITEOFF";
980
+ TransactionType2[TransactionType2["DEPOT_ADD"] = 6] = "DEPOT_ADD";
981
+ TransactionType2[TransactionType2["RETURN"] = 7] = "RETURN";
982
+ TransactionType2[TransactionType2["INVENTORY_SURPLUS"] = 8] = "INVENTORY_SURPLUS";
983
+ TransactionType2[TransactionType2["INVENTORY_MISSING"] = 9] = "INVENTORY_MISSING";
984
+ return TransactionType2;
985
+ })(TransactionType || {});
986
+
987
+ // src/database/entities/fresh-translation-entity.ts
988
+ var languageValues = Object.values(LanguageCode).map((v) => `'${v}'`).join(",");
989
+ var FreshTranslationBase = class extends import_typeorm4.BaseEntity {
990
+ constructor() {
991
+ super();
992
+ this.id = 0;
993
+ this.languageCode = "cs" /* CS */;
994
+ }
995
+ };
996
+ __decorateClass([
997
+ (0, import_typeorm4.PrimaryGeneratedColumn)()
998
+ ], FreshTranslationBase.prototype, "id", 2);
999
+ __decorateClass([
1000
+ (0, import_typeorm4.Column)({
1001
+ type: "varchar",
1002
+ length: 3,
1003
+ nullable: false
1004
+ }),
1005
+ (0, import_typeorm4.Check)(`"languageCode" IN (${languageValues})`)
1006
+ ], FreshTranslationBase.prototype, "languageCode", 2);
1007
+
1008
+ // src/database/dao/fresh-dao.ts
1009
+ var FreshDao = class {
1010
+ };
1011
+
1012
+ // src/common/schema/entities/category.entity.ts
1013
+ var Category = class extends FreshEntity {
1014
+ // ...
1015
+ };
1016
+ Category = __decorateClass([
1017
+ (0, import_typeorm5.Entity)()
1018
+ ], Category);
1019
+
1020
+ // src/common/schema/entities/device.entity.ts
1021
+ var import_typeorm6 = require("typeorm");
1022
+ var Device = class extends FreshEntity {
1023
+ // ...
1024
+ };
1025
+ Device = __decorateClass([
1026
+ (0, import_typeorm6.Entity)()
1027
+ ], Device);
1028
+
1029
+ // src/common/schema/entities/manufacturer.entity.ts
1030
+ var import_typeorm7 = require("typeorm");
1031
+ var Manufacturer = class extends FreshEntity {
1032
+ // ...
1033
+ };
1034
+ Manufacturer = __decorateClass([
1035
+ (0, import_typeorm7.Entity)()
1036
+ ], Manufacturer);
1037
+
1038
+ // src/common/schema/entities/product.entity.ts
1039
+ var import_typeorm8 = require("typeorm");
1040
+ var Product = class extends FreshEntity {
1041
+ // ...
1042
+ };
1043
+ Product = __decorateClass([
1044
+ (0, import_typeorm8.Entity)()
1045
+ ], Product);
1046
+
1047
+ // src/common/schema/entities/subcategory.entity.ts
1048
+ var import_typeorm9 = require("typeorm");
1049
+ var Subcategory = class extends FreshEntity {
1050
+ // ...
1051
+ };
1052
+ Subcategory = __decorateClass([
1053
+ (0, import_typeorm9.Entity)()
1054
+ ], Subcategory);
1055
+
1056
+ // src/core/data-helper.ts
1057
+ var DataHelper = class {
1058
+ constructor(startDataRetrieve = true, deviceIds) {
1059
+ this._dataPromise = null;
1060
+ this.deviceIds = deviceIds;
1061
+ if (startDataRetrieve) {
1062
+ this._dataPromise = this.startDataRetrieval();
1063
+ }
1064
+ }
1065
+ get data() {
1066
+ return this._data;
1067
+ }
1068
+ set data(value) {
1069
+ this._data = value;
1070
+ }
1071
+ get dataPromise() {
1072
+ return this._dataPromise;
1073
+ }
1074
+ set dataPromise(value) {
1075
+ this._dataPromise = value;
1076
+ }
1077
+ async getData() {
1078
+ if (this._dataPromise) {
1079
+ return await this._dataPromise;
1080
+ }
1081
+ if (this._data === void 0) {
1082
+ this._dataPromise = this.startDataRetrieval();
1083
+ return this._dataPromise;
1084
+ }
1085
+ return this._data;
1086
+ }
1087
+ };
1088
+
1089
+ // src/core/class/fresh-job.ts
1090
+ var import_node_schedule = require("node-schedule");
1091
+ var FreshJob = class extends Singleton {
1092
+ /**
1093
+ * @param cronExpression must be cron of just numbers ex.: `0 5 * * 4`
1094
+ * By default timezone is added " Europe/Prague"
1095
+ */
1096
+ constructor(jobName, cronExpression, jobEnabled) {
1097
+ super();
1098
+ this._job = null;
1099
+ this._jobName = jobName;
1100
+ if (!isValidCron(cronExpression)) {
1101
+ throw new Error(
1102
+ `Job ${this.jobName} cannot be constructed with invalid cron: "${cronExpression}"`
1103
+ );
1104
+ }
1105
+ this._cronExpression = cronExpression;
1106
+ if (jobEnabled) {
1107
+ this._job = (0, import_node_schedule.scheduleJob)(
1108
+ { rule: this._cronExpression, tz: "Europe/Prague" },
1109
+ async () => {
1110
+ await this.invoke();
1111
+ }
1112
+ );
1113
+ if (!this._job) {
1114
+ throw new Error(`Job ${this._jobName} could not be scheduled`);
1115
+ }
1116
+ }
1117
+ this.onInit();
1118
+ }
1119
+ /** Just logging */
1120
+ onInit(rescheduled) {
1121
+ console.log(
1122
+ `Job ${this.jobName} ${rescheduled ? "rescheduled" : "initialized"} with cron rule: "${this.cronExpression}"`
1123
+ );
1124
+ }
1125
+ get jobName() {
1126
+ return this._jobName;
1127
+ }
1128
+ set jobName(value) {
1129
+ this._jobName = value;
1130
+ }
1131
+ get cronExpression() {
1132
+ return this._cronExpression;
1133
+ }
1134
+ set cronExpression(value) {
1135
+ this._cronExpression = value;
1136
+ }
1137
+ get job() {
1138
+ return this._job;
1139
+ }
1140
+ set job(value) {
1141
+ this._job = value;
1142
+ }
1143
+ };
1144
+
1145
+ // src/core/errors/api-error.ts
1146
+ var ApiError = class extends Error {
1147
+ get statusCode() {
1148
+ return this._statusCode;
1149
+ }
1150
+ get statusDto() {
1151
+ return this._statusDto;
1152
+ }
1153
+ constructor(statusCode, status, detail) {
1154
+ super();
1155
+ this._statusCode = statusCode;
1156
+ this._statusDto = new StatusDto(status, detail);
1157
+ }
1158
+ };
1159
+
1160
+ // src/config/eslint-config.ts
1161
+ var import_typescript_eslint = __toESM(require("typescript-eslint"));
1162
+ var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"));
1163
+ var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"));
1164
+ var FRESH_ESLINT_CONFIG = [
1165
+ {
1166
+ // Prettier integration
1167
+ ...import_eslint_config_prettier.default,
1168
+ // Affected files
1169
+ files: ["**/*.ts", "**/*.tsx"],
1170
+ ignores: [
1171
+ "dist/**",
1172
+ "node_modules/**",
1173
+ "build/**",
1174
+ "**/*.js",
1175
+ "**/*.mjs",
1176
+ "**/*-migration.ts",
1177
+ "**/*-migration.js"
1178
+ ],
1179
+ languageOptions: {
1180
+ parser: import_typescript_eslint.default.parser,
1181
+ ecmaVersion: "latest",
1182
+ sourceType: "module"
1183
+ },
1184
+ // Extra plugins declared
1185
+ plugins: {
1186
+ "@typescript-eslint": import_typescript_eslint.default.plugin,
1187
+ prettier: import_eslint_plugin_prettier.default
1188
+ },
1189
+ rules: {
1190
+ // Eslint rules
1191
+ // no lets or vars
1192
+ "prefer-const": "error",
1193
+ // blocks ("red" === color) these ifs
1194
+ yoda: ["error", "never"],
1195
+ "no-multiple-empty-lines": ["error", { max: 1 }],
1196
+ // semi-colons
1197
+ semi: ["error", "always"],
1198
+ // forces block for all control statements (forbid one-line returns)
1199
+ curly: ["error", "all"],
1200
+ // makes spaces between brackets
1201
+ "object-curly-spacing": ["error", "always"],
1202
+ // checks same if/else conditions
1203
+ "no-dupe-else-if": "error",
1204
+ // keeps imports from one package in same declaration
1205
+ "no-duplicate-imports": "error",
1206
+ // blocks simple '=' in condition blocks
1207
+ "no-cond-assign": ["error", "always"],
1208
+ // forbids promise inside promise
1209
+ "no-async-promise-executor": "error",
1210
+ // watches possible falltrough in switch cases
1211
+ "no-fallthrough": "error",
1212
+ // use === instead of ==
1213
+ eqeqeq: ["error", "always"],
1214
+ // Prettier formatting rules
1215
+ "prettier/prettier": [
1216
+ "error",
1217
+ {
1218
+ // max 100 chars per line
1219
+ printWidth: 100,
1220
+ // keep 4 spaces and no tabs
1221
+ tabWidth: 4,
1222
+ useTabs: false,
1223
+ // enforce semicolons
1224
+ semi: true,
1225
+ // prefers ""
1226
+ singleQuote: false,
1227
+ // last comma in array or object
1228
+ trailingComma: "es5",
1229
+ // enable spacing next to brackets
1230
+ bracketSpacing: true,
1231
+ // enables CRLF eol which is enforced by git
1232
+ endOfLine: "auto"
1233
+ }
1234
+ ],
1235
+ // Namin conventions
1236
+ "@typescript-eslint/naming-convention": [
1237
+ "error",
1238
+ {
1239
+ selector: ["variable", "function"],
1240
+ format: ["camelCase"],
1241
+ leadingUnderscore: "allow"
1242
+ },
1243
+ {
1244
+ selector: "class",
1245
+ format: ["PascalCase"]
1246
+ },
1247
+ {
1248
+ selector: "variable",
1249
+ modifiers: ["const", "exported"],
1250
+ format: ["UPPER_CASE"]
1251
+ },
1252
+ {
1253
+ selector: "property",
1254
+ modifiers: ["readonly"],
1255
+ format: ["UPPER_CASE"]
1256
+ }
1257
+ ]
1258
+ }
1259
+ }
1260
+ ];
1261
+ var eslint_config_default = FRESH_ESLINT_CONFIG;
1262
+
1263
+ // src/config/datasource.ts
1264
+ var import_path = __toESM(require("path"));
1265
+ var import_typeorm_naming_strategies = require("typeorm-naming-strategies");
1266
+ var import_dotenv = __toESM(require_main());
1267
+ (0, import_dotenv.config)();
1268
+ var basePath = process.cwd();
1269
+ var isTs = process.env.LOCAL === "true";
1270
+ var PG_DATA_SOURCE_OPTIONS = {
1271
+ applicationName: "<service-name>",
1272
+ name: "<service-name>-connection",
1273
+ type: "postgres",
1274
+ host: process.env.POSTGRE_SQL_HOST || "<host>",
1275
+ port: Number(process.env.POSTGRE_SQL_PORT || "3300"),
1276
+ username: process.env.POSTGRE_SQL_USER || "<user>",
1277
+ password: process.env.POSTGRE_SQL_PASSWORD || "<password>",
1278
+ database: process.env.POSTGRE_SQL_DATABASE || "<database>",
1279
+ schema: process.env.POSTGRE_SQL_SCHEMA || "<scheme>",
1280
+ entities: [import_path.default.join(basePath, isTs ? "src/entity/*.{ts,js}" : "build/entity/*.js")],
1281
+ migrations: [import_path.default.join(basePath, isTs ? "src/migration/*.{ts,js}" : "build/migration/*.js")],
1282
+ migrationsRun: process.env.RUN_MIGRATIONS === "true",
1283
+ migrationsTableName: "migrations",
1284
+ migrationsTransactionMode: "each",
1285
+ synchronize: false,
1286
+ logging: false,
1287
+ extra: {
1288
+ connectionLimit: 20
1289
+ },
1290
+ useUTC: true,
1291
+ cache: true,
1292
+ namingStrategy: new import_typeorm_naming_strategies.SnakeNamingStrategy()
1293
+ // replication: undefined,
1294
+ };
1295
+ var datasource_default = PG_DATA_SOURCE_OPTIONS;
1296
+ // Annotate the CommonJS export names for ESM import in node:
1297
+ 0 && (module.exports = {
1298
+ AMOUNT_UNIT,
1299
+ ActionCommandCode,
1300
+ ApiError,
1301
+ Category,
1302
+ DataHelper,
1303
+ DateUtils,
1304
+ DepotPoolStatus,
1305
+ Device,
1306
+ FreshDao,
1307
+ FreshEntity,
1308
+ FreshHyperEntity,
1309
+ FreshJob,
1310
+ FreshTranslationBase,
1311
+ HttpStatus,
1312
+ LanguageCode,
1313
+ Manufacturer,
1314
+ PaymentMethod,
1315
+ PgDataSourceOptions,
1316
+ Product,
1317
+ SinglePromiseWaiter,
1318
+ Singleton,
1319
+ StatusDto,
1320
+ Subcategory,
1321
+ TimestampColumn,
1322
+ TransactionType,
1323
+ createDeferred,
1324
+ freshEslintConfig,
1325
+ isValidCron,
1326
+ logger
1327
+ });
1328
+ //# sourceMappingURL=index.js.map