@freshpointcz/fresh-core 0.0.14 → 0.0.16
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 +96 -5
- package/dist/index.d.ts +96 -5
- package/dist/index.js +97 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import dayjs, { Dayjs } from 'dayjs';
|
|
2
2
|
import { Logger } from 'winston';
|
|
3
|
-
import { BaseEntity, ColumnOptions, Repository, DataSourceOptions } from 'typeorm';
|
|
3
|
+
import { BaseEntity, ColumnOptions, Repository, EntityTarget, EntityManager, DataSourceOptions } from 'typeorm';
|
|
4
4
|
import { Job } from 'node-schedule';
|
|
5
|
-
import * as
|
|
5
|
+
import * as _eslint_core from '@eslint/core';
|
|
6
6
|
import * as typescript_eslint_dist_compatibility_types from 'typescript-eslint/dist/compatibility-types';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -291,7 +291,8 @@ declare enum LanguageCode {
|
|
|
291
291
|
declare enum PaymentMethod {
|
|
292
292
|
CODE = 0,
|
|
293
293
|
CARD = 1,
|
|
294
|
-
NONE = 2
|
|
294
|
+
NONE = 2,
|
|
295
|
+
CREDIT = 3
|
|
295
296
|
}
|
|
296
297
|
|
|
297
298
|
declare enum TransactionType {
|
|
@@ -343,6 +344,8 @@ declare function TimestampColumn(options?: ColumnOptions): PropertyDecorator;
|
|
|
343
344
|
|
|
344
345
|
declare abstract class FreshDao<T extends BaseEntity> {
|
|
345
346
|
protected abstract repo: Repository<T>;
|
|
347
|
+
protected abstract entity: EntityTarget<T>;
|
|
348
|
+
protected getRepo(manager?: EntityManager, entity?: EntityTarget<T>): Repository<T>;
|
|
346
349
|
}
|
|
347
350
|
|
|
348
351
|
declare class Category extends FreshEntity {
|
|
@@ -360,7 +363,93 @@ declare class Product extends FreshEntity {
|
|
|
360
363
|
declare class Subcategory extends FreshEntity {
|
|
361
364
|
}
|
|
362
365
|
|
|
366
|
+
/**
|
|
367
|
+
* Runtime validation for enum values.
|
|
368
|
+
* If a runtime enum object is provided, the value must match one of its values
|
|
369
|
+
* If no enum object is provided, this falls back to accepting `string | number`
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* isEnumValue(TransactionType, 0) // true
|
|
373
|
+
* isEnumValue(TransactionType, 99) // false
|
|
374
|
+
* isEnumValue(undefined, 99) // true
|
|
375
|
+
* isEnumValue(undefined, "99") // true
|
|
376
|
+
*/
|
|
377
|
+
declare function isEnumValue<E extends Record<string, string | number>>(enumObj: E | undefined, v: unknown): v is E[keyof E];
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Non-null object typeguard
|
|
381
|
+
* @usage Use for narrowing `unknown` type and to check that a value is a non-null object
|
|
382
|
+
* @description
|
|
383
|
+
* WARNING: Arrays and functions are technically objects in JS,
|
|
384
|
+
* but this guard intentionally allows them only as plain objects
|
|
385
|
+
* via structural usage.
|
|
386
|
+
*/
|
|
387
|
+
declare function isObject(v: unknown): v is Record<string, unknown>;
|
|
388
|
+
/**
|
|
389
|
+
* Wrapper around `Object.prototype.hasOwnProperty`.
|
|
390
|
+
* @usage Use this instead of `key in obj`
|
|
391
|
+
*/
|
|
392
|
+
declare function hasOwn(obj: Record<string, unknown>, key: string): boolean;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Checks that a value is a finite number
|
|
396
|
+
*
|
|
397
|
+
* Rejects numbers like:
|
|
398
|
+
* - NaN
|
|
399
|
+
* - Infinity / -Infinity
|
|
400
|
+
*
|
|
401
|
+
* @usage numeric fields validation
|
|
402
|
+
*/
|
|
403
|
+
declare function isNumber(v: unknown): v is number;
|
|
404
|
+
/**
|
|
405
|
+
* Checks that a value is a string
|
|
406
|
+
*/
|
|
407
|
+
declare function isString(v: unknown): v is string;
|
|
408
|
+
/**
|
|
409
|
+
* Validates a numeric boolean flag represented as 0 or 1
|
|
410
|
+
*/
|
|
411
|
+
declare function isFlag01(v: unknown): v is 0 | 1;
|
|
412
|
+
/**
|
|
413
|
+
* Checks that a value is a finite number within a given range
|
|
414
|
+
* By default, the range is inclusive on both ends
|
|
415
|
+
*
|
|
416
|
+
* @param v - Value to validate
|
|
417
|
+
* @param min - Minimum allowed value
|
|
418
|
+
* @param max - Maximum allowed value
|
|
419
|
+
* @param options - Range behavior configuration
|
|
420
|
+
* @param options.includeMin - Whether `min` is allowed (default: true)
|
|
421
|
+
* @param options.includeMax - Whether `max` is allowed (default: true)
|
|
422
|
+
*
|
|
423
|
+
* @returns `true` if the value is a finite number within the range
|
|
424
|
+
* @example
|
|
425
|
+
* isNumberInRange(5, 1, 10); // true
|
|
426
|
+
* isNumberInRange(1, 1, 10); // true
|
|
427
|
+
* isNumberInRange(1, 1, 10, { includeMin: false }); // false
|
|
428
|
+
* isNumberInRange(10, 1, 10, { includeMax: false }); // false
|
|
429
|
+
* isNumberInRange("5", 1, 10); // false
|
|
430
|
+
* isNumberInRange(NaN, 1, 10); // false
|
|
431
|
+
*/
|
|
432
|
+
declare function isNumberInRange(v: unknown, min: number, max: number, options?: {
|
|
433
|
+
includeMin?: boolean;
|
|
434
|
+
includeMax?: boolean;
|
|
435
|
+
}): v is number;
|
|
436
|
+
|
|
363
437
|
type Maybe<T> = T | null;
|
|
438
|
+
/**
|
|
439
|
+
* Validates a value that may be `null` or given type
|
|
440
|
+
*
|
|
441
|
+
* WARNING:
|
|
442
|
+
* `undefined` is NOT accepted by this function.
|
|
443
|
+
* If you need `undefined` support, it must be handled
|
|
444
|
+
* before calling this guard or explicitly allowed elsewhere.
|
|
445
|
+
*
|
|
446
|
+
* @typeParam T - The underlying non-nullable type
|
|
447
|
+
* @param v - Value to validate
|
|
448
|
+
* @param inner - Typeguard function for the underlying type `T`
|
|
449
|
+
*
|
|
450
|
+
* @returns `true` if the value is `null` or satisfies the inner typeguard
|
|
451
|
+
*/
|
|
452
|
+
declare function isMaybe<T>(v: unknown, inner: (x: unknown) => x is T): v is Maybe<T>;
|
|
364
453
|
|
|
365
454
|
declare abstract class DataHelper<T> {
|
|
366
455
|
private _data?;
|
|
@@ -465,6 +554,8 @@ declare abstract class FreshJob<T = void> extends Singleton {
|
|
|
465
554
|
abstract invoke(): T | Promise<T>;
|
|
466
555
|
}
|
|
467
556
|
|
|
557
|
+
type CardNumber = `${number}${number}${number}${number}`;
|
|
558
|
+
|
|
468
559
|
declare class ApiError extends Error {
|
|
469
560
|
private _statusCode;
|
|
470
561
|
get statusCode(): number;
|
|
@@ -483,7 +574,7 @@ declare const FRESH_ESLINT_CONFIG: {
|
|
|
483
574
|
};
|
|
484
575
|
plugins: {
|
|
485
576
|
"@typescript-eslint": typescript_eslint_dist_compatibility_types.CompatiblePlugin;
|
|
486
|
-
prettier:
|
|
577
|
+
prettier: _eslint_core.Plugin;
|
|
487
578
|
};
|
|
488
579
|
rules: {
|
|
489
580
|
"prefer-const": string;
|
|
@@ -550,4 +641,4 @@ interface HealthCheckResult {
|
|
|
550
641
|
};
|
|
551
642
|
}
|
|
552
643
|
|
|
553
|
-
export { AMOUNT_UNIT, ActionCommandCode, ApiError, Category, DataHelper, DateUtils, type Deferred, DepotPoolStatus, Device, FreshDao, FreshEntity, FreshHyperEntity, FreshJob, FreshTranslationBase, type HealthCheckResult, HttpStatus, LanguageCode, Manufacturer, type Maybe, PaymentMethod, PG_DATA_SOURCE_OPTIONS as PgDataSourceOptions, Product, SinglePromiseWaiter, Singleton, type Status, StatusDto, Subcategory, TimestampColumn, TransactionType, createDeferred, FRESH_ESLINT_CONFIG as freshEslintConfig, isValidCron, logger };
|
|
644
|
+
export { AMOUNT_UNIT, ActionCommandCode, ApiError, type CardNumber, Category, DataHelper, DateUtils, type Deferred, DepotPoolStatus, Device, FreshDao, FreshEntity, FreshHyperEntity, FreshJob, FreshTranslationBase, type HealthCheckResult, HttpStatus, LanguageCode, Manufacturer, type Maybe, PaymentMethod, PG_DATA_SOURCE_OPTIONS as PgDataSourceOptions, Product, SinglePromiseWaiter, Singleton, type Status, StatusDto, Subcategory, TimestampColumn, TransactionType, createDeferred, FRESH_ESLINT_CONFIG as freshEslintConfig, hasOwn, isEnumValue, isFlag01, isMaybe, isNumber, isNumberInRange, isObject, isString, isValidCron, logger };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import dayjs, { Dayjs } from 'dayjs';
|
|
2
2
|
import { Logger } from 'winston';
|
|
3
|
-
import { BaseEntity, ColumnOptions, Repository, DataSourceOptions } from 'typeorm';
|
|
3
|
+
import { BaseEntity, ColumnOptions, Repository, EntityTarget, EntityManager, DataSourceOptions } from 'typeorm';
|
|
4
4
|
import { Job } from 'node-schedule';
|
|
5
|
-
import * as
|
|
5
|
+
import * as _eslint_core from '@eslint/core';
|
|
6
6
|
import * as typescript_eslint_dist_compatibility_types from 'typescript-eslint/dist/compatibility-types';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -291,7 +291,8 @@ declare enum LanguageCode {
|
|
|
291
291
|
declare enum PaymentMethod {
|
|
292
292
|
CODE = 0,
|
|
293
293
|
CARD = 1,
|
|
294
|
-
NONE = 2
|
|
294
|
+
NONE = 2,
|
|
295
|
+
CREDIT = 3
|
|
295
296
|
}
|
|
296
297
|
|
|
297
298
|
declare enum TransactionType {
|
|
@@ -343,6 +344,8 @@ declare function TimestampColumn(options?: ColumnOptions): PropertyDecorator;
|
|
|
343
344
|
|
|
344
345
|
declare abstract class FreshDao<T extends BaseEntity> {
|
|
345
346
|
protected abstract repo: Repository<T>;
|
|
347
|
+
protected abstract entity: EntityTarget<T>;
|
|
348
|
+
protected getRepo(manager?: EntityManager, entity?: EntityTarget<T>): Repository<T>;
|
|
346
349
|
}
|
|
347
350
|
|
|
348
351
|
declare class Category extends FreshEntity {
|
|
@@ -360,7 +363,93 @@ declare class Product extends FreshEntity {
|
|
|
360
363
|
declare class Subcategory extends FreshEntity {
|
|
361
364
|
}
|
|
362
365
|
|
|
366
|
+
/**
|
|
367
|
+
* Runtime validation for enum values.
|
|
368
|
+
* If a runtime enum object is provided, the value must match one of its values
|
|
369
|
+
* If no enum object is provided, this falls back to accepting `string | number`
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* isEnumValue(TransactionType, 0) // true
|
|
373
|
+
* isEnumValue(TransactionType, 99) // false
|
|
374
|
+
* isEnumValue(undefined, 99) // true
|
|
375
|
+
* isEnumValue(undefined, "99") // true
|
|
376
|
+
*/
|
|
377
|
+
declare function isEnumValue<E extends Record<string, string | number>>(enumObj: E | undefined, v: unknown): v is E[keyof E];
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Non-null object typeguard
|
|
381
|
+
* @usage Use for narrowing `unknown` type and to check that a value is a non-null object
|
|
382
|
+
* @description
|
|
383
|
+
* WARNING: Arrays and functions are technically objects in JS,
|
|
384
|
+
* but this guard intentionally allows them only as plain objects
|
|
385
|
+
* via structural usage.
|
|
386
|
+
*/
|
|
387
|
+
declare function isObject(v: unknown): v is Record<string, unknown>;
|
|
388
|
+
/**
|
|
389
|
+
* Wrapper around `Object.prototype.hasOwnProperty`.
|
|
390
|
+
* @usage Use this instead of `key in obj`
|
|
391
|
+
*/
|
|
392
|
+
declare function hasOwn(obj: Record<string, unknown>, key: string): boolean;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Checks that a value is a finite number
|
|
396
|
+
*
|
|
397
|
+
* Rejects numbers like:
|
|
398
|
+
* - NaN
|
|
399
|
+
* - Infinity / -Infinity
|
|
400
|
+
*
|
|
401
|
+
* @usage numeric fields validation
|
|
402
|
+
*/
|
|
403
|
+
declare function isNumber(v: unknown): v is number;
|
|
404
|
+
/**
|
|
405
|
+
* Checks that a value is a string
|
|
406
|
+
*/
|
|
407
|
+
declare function isString(v: unknown): v is string;
|
|
408
|
+
/**
|
|
409
|
+
* Validates a numeric boolean flag represented as 0 or 1
|
|
410
|
+
*/
|
|
411
|
+
declare function isFlag01(v: unknown): v is 0 | 1;
|
|
412
|
+
/**
|
|
413
|
+
* Checks that a value is a finite number within a given range
|
|
414
|
+
* By default, the range is inclusive on both ends
|
|
415
|
+
*
|
|
416
|
+
* @param v - Value to validate
|
|
417
|
+
* @param min - Minimum allowed value
|
|
418
|
+
* @param max - Maximum allowed value
|
|
419
|
+
* @param options - Range behavior configuration
|
|
420
|
+
* @param options.includeMin - Whether `min` is allowed (default: true)
|
|
421
|
+
* @param options.includeMax - Whether `max` is allowed (default: true)
|
|
422
|
+
*
|
|
423
|
+
* @returns `true` if the value is a finite number within the range
|
|
424
|
+
* @example
|
|
425
|
+
* isNumberInRange(5, 1, 10); // true
|
|
426
|
+
* isNumberInRange(1, 1, 10); // true
|
|
427
|
+
* isNumberInRange(1, 1, 10, { includeMin: false }); // false
|
|
428
|
+
* isNumberInRange(10, 1, 10, { includeMax: false }); // false
|
|
429
|
+
* isNumberInRange("5", 1, 10); // false
|
|
430
|
+
* isNumberInRange(NaN, 1, 10); // false
|
|
431
|
+
*/
|
|
432
|
+
declare function isNumberInRange(v: unknown, min: number, max: number, options?: {
|
|
433
|
+
includeMin?: boolean;
|
|
434
|
+
includeMax?: boolean;
|
|
435
|
+
}): v is number;
|
|
436
|
+
|
|
363
437
|
type Maybe<T> = T | null;
|
|
438
|
+
/**
|
|
439
|
+
* Validates a value that may be `null` or given type
|
|
440
|
+
*
|
|
441
|
+
* WARNING:
|
|
442
|
+
* `undefined` is NOT accepted by this function.
|
|
443
|
+
* If you need `undefined` support, it must be handled
|
|
444
|
+
* before calling this guard or explicitly allowed elsewhere.
|
|
445
|
+
*
|
|
446
|
+
* @typeParam T - The underlying non-nullable type
|
|
447
|
+
* @param v - Value to validate
|
|
448
|
+
* @param inner - Typeguard function for the underlying type `T`
|
|
449
|
+
*
|
|
450
|
+
* @returns `true` if the value is `null` or satisfies the inner typeguard
|
|
451
|
+
*/
|
|
452
|
+
declare function isMaybe<T>(v: unknown, inner: (x: unknown) => x is T): v is Maybe<T>;
|
|
364
453
|
|
|
365
454
|
declare abstract class DataHelper<T> {
|
|
366
455
|
private _data?;
|
|
@@ -465,6 +554,8 @@ declare abstract class FreshJob<T = void> extends Singleton {
|
|
|
465
554
|
abstract invoke(): T | Promise<T>;
|
|
466
555
|
}
|
|
467
556
|
|
|
557
|
+
type CardNumber = `${number}${number}${number}${number}`;
|
|
558
|
+
|
|
468
559
|
declare class ApiError extends Error {
|
|
469
560
|
private _statusCode;
|
|
470
561
|
get statusCode(): number;
|
|
@@ -483,7 +574,7 @@ declare const FRESH_ESLINT_CONFIG: {
|
|
|
483
574
|
};
|
|
484
575
|
plugins: {
|
|
485
576
|
"@typescript-eslint": typescript_eslint_dist_compatibility_types.CompatiblePlugin;
|
|
486
|
-
prettier:
|
|
577
|
+
prettier: _eslint_core.Plugin;
|
|
487
578
|
};
|
|
488
579
|
rules: {
|
|
489
580
|
"prefer-const": string;
|
|
@@ -550,4 +641,4 @@ interface HealthCheckResult {
|
|
|
550
641
|
};
|
|
551
642
|
}
|
|
552
643
|
|
|
553
|
-
export { AMOUNT_UNIT, ActionCommandCode, ApiError, Category, DataHelper, DateUtils, type Deferred, DepotPoolStatus, Device, FreshDao, FreshEntity, FreshHyperEntity, FreshJob, FreshTranslationBase, type HealthCheckResult, HttpStatus, LanguageCode, Manufacturer, type Maybe, PaymentMethod, PG_DATA_SOURCE_OPTIONS as PgDataSourceOptions, Product, SinglePromiseWaiter, Singleton, type Status, StatusDto, Subcategory, TimestampColumn, TransactionType, createDeferred, FRESH_ESLINT_CONFIG as freshEslintConfig, isValidCron, logger };
|
|
644
|
+
export { AMOUNT_UNIT, ActionCommandCode, ApiError, type CardNumber, Category, DataHelper, DateUtils, type Deferred, DepotPoolStatus, Device, FreshDao, FreshEntity, FreshHyperEntity, FreshJob, FreshTranslationBase, type HealthCheckResult, HttpStatus, LanguageCode, Manufacturer, type Maybe, PaymentMethod, PG_DATA_SOURCE_OPTIONS as PgDataSourceOptions, Product, SinglePromiseWaiter, Singleton, type Status, StatusDto, Subcategory, TimestampColumn, TransactionType, createDeferred, FRESH_ESLINT_CONFIG as freshEslintConfig, hasOwn, isEnumValue, isFlag01, isMaybe, isNumber, isNumberInRange, isObject, isString, isValidCron, logger };
|
package/dist/index.js
CHANGED
|
@@ -108,7 +108,7 @@ var require_main = __commonJS({
|
|
|
108
108
|
var fs = require("fs");
|
|
109
109
|
var path2 = require("path");
|
|
110
110
|
var os = require("os");
|
|
111
|
-
var
|
|
111
|
+
var crypto3 = require("crypto");
|
|
112
112
|
var packageJson = require_package();
|
|
113
113
|
var version = packageJson.version;
|
|
114
114
|
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
@@ -355,7 +355,7 @@ var require_main = __commonJS({
|
|
|
355
355
|
const authTag = ciphertext.subarray(-16);
|
|
356
356
|
ciphertext = ciphertext.subarray(12, -16);
|
|
357
357
|
try {
|
|
358
|
-
const aesgcm =
|
|
358
|
+
const aesgcm = crypto3.createDecipheriv("aes-256-gcm", key, nonce);
|
|
359
359
|
aesgcm.setAuthTag(authTag);
|
|
360
360
|
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
361
361
|
} catch (error) {
|
|
@@ -452,6 +452,14 @@ __export(index_exports, {
|
|
|
452
452
|
TransactionType: () => TransactionType,
|
|
453
453
|
createDeferred: () => createDeferred,
|
|
454
454
|
freshEslintConfig: () => eslint_config_default,
|
|
455
|
+
hasOwn: () => hasOwn,
|
|
456
|
+
isEnumValue: () => isEnumValue,
|
|
457
|
+
isFlag01: () => isFlag01,
|
|
458
|
+
isMaybe: () => isMaybe,
|
|
459
|
+
isNumber: () => isNumber,
|
|
460
|
+
isNumberInRange: () => isNumberInRange,
|
|
461
|
+
isObject: () => isObject,
|
|
462
|
+
isString: () => isString,
|
|
455
463
|
isValidCron: () => isValidCron,
|
|
456
464
|
logger: () => logger
|
|
457
465
|
});
|
|
@@ -857,53 +865,46 @@ var import_typeorm5 = require("typeorm");
|
|
|
857
865
|
// src/database/entities/fresh-entity.ts
|
|
858
866
|
var import_typeorm = require("typeorm");
|
|
859
867
|
|
|
860
|
-
// ../../node_modules/uuid/dist/esm/
|
|
861
|
-
var
|
|
862
|
-
for (let i = 0; i < 256; ++i) {
|
|
863
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
864
|
-
}
|
|
865
|
-
function unsafeStringify(arr, offset = 0) {
|
|
866
|
-
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();
|
|
867
|
-
}
|
|
868
|
-
__name(unsafeStringify, "unsafeStringify");
|
|
869
|
-
|
|
870
|
-
// ../../node_modules/uuid/dist/esm/rng.js
|
|
871
|
-
var import_crypto = require("crypto");
|
|
868
|
+
// ../../node_modules/uuid/dist/esm-node/rng.js
|
|
869
|
+
var import_crypto = __toESM(require("crypto"));
|
|
872
870
|
var rnds8Pool = new Uint8Array(256);
|
|
873
871
|
var poolPtr = rnds8Pool.length;
|
|
874
872
|
function rng() {
|
|
875
873
|
if (poolPtr > rnds8Pool.length - 16) {
|
|
876
|
-
|
|
874
|
+
import_crypto.default.randomFillSync(rnds8Pool);
|
|
877
875
|
poolPtr = 0;
|
|
878
876
|
}
|
|
879
877
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
880
878
|
}
|
|
881
879
|
__name(rng, "rng");
|
|
882
880
|
|
|
883
|
-
// ../../node_modules/uuid/dist/esm/
|
|
884
|
-
var
|
|
881
|
+
// ../../node_modules/uuid/dist/esm-node/stringify.js
|
|
882
|
+
var byteToHex = [];
|
|
883
|
+
for (let i = 0; i < 256; ++i) {
|
|
884
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
885
|
+
}
|
|
886
|
+
function unsafeStringify(arr, offset = 0) {
|
|
887
|
+
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]];
|
|
888
|
+
}
|
|
889
|
+
__name(unsafeStringify, "unsafeStringify");
|
|
890
|
+
|
|
891
|
+
// ../../node_modules/uuid/dist/esm-node/native.js
|
|
892
|
+
var import_crypto2 = __toESM(require("crypto"));
|
|
885
893
|
var native_default = {
|
|
886
|
-
randomUUID: import_crypto2.randomUUID
|
|
894
|
+
randomUUID: import_crypto2.default.randomUUID
|
|
887
895
|
};
|
|
888
896
|
|
|
889
|
-
// ../../node_modules/uuid/dist/esm/v4.js
|
|
897
|
+
// ../../node_modules/uuid/dist/esm-node/v4.js
|
|
890
898
|
function v4(options, buf, offset) {
|
|
891
|
-
var _a, _b, _c;
|
|
892
899
|
if (native_default.randomUUID && !buf && !options) {
|
|
893
900
|
return native_default.randomUUID();
|
|
894
901
|
}
|
|
895
902
|
options = options || {};
|
|
896
|
-
const rnds =
|
|
897
|
-
if (rnds.length < 16) {
|
|
898
|
-
throw new Error("Random bytes length must be >= 16");
|
|
899
|
-
}
|
|
903
|
+
const rnds = options.random || (options.rng || rng)();
|
|
900
904
|
rnds[6] = rnds[6] & 15 | 64;
|
|
901
905
|
rnds[8] = rnds[8] & 63 | 128;
|
|
902
906
|
if (buf) {
|
|
903
907
|
offset = offset || 0;
|
|
904
|
-
if (offset < 0 || offset + 16 > buf.length) {
|
|
905
|
-
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
906
|
-
}
|
|
907
908
|
for (let i = 0; i < 16; ++i) {
|
|
908
909
|
buf[offset + i] = rnds[i];
|
|
909
910
|
}
|
|
@@ -956,7 +957,7 @@ _ts_decorate([
|
|
|
956
957
|
}),
|
|
957
958
|
(0, import_typeorm.Column)({
|
|
958
959
|
type: "uuid",
|
|
959
|
-
default: /* @__PURE__ */ __name(() => "
|
|
960
|
+
default: /* @__PURE__ */ __name(() => "gen_random_uuid()", "default")
|
|
960
961
|
}),
|
|
961
962
|
_ts_metadata("design:type", String)
|
|
962
963
|
], FreshEntity.prototype, "uuid", void 0);
|
|
@@ -1140,6 +1141,7 @@ var PaymentMethod = /* @__PURE__ */ (function(PaymentMethod2) {
|
|
|
1140
1141
|
PaymentMethod2[PaymentMethod2["CODE"] = 0] = "CODE";
|
|
1141
1142
|
PaymentMethod2[PaymentMethod2["CARD"] = 1] = "CARD";
|
|
1142
1143
|
PaymentMethod2[PaymentMethod2["NONE"] = 2] = "NONE";
|
|
1144
|
+
PaymentMethod2[PaymentMethod2["CREDIT"] = 3] = "CREDIT";
|
|
1143
1145
|
return PaymentMethod2;
|
|
1144
1146
|
})({});
|
|
1145
1147
|
|
|
@@ -1198,6 +1200,9 @@ _ts_decorate3([
|
|
|
1198
1200
|
|
|
1199
1201
|
// src/database/dao/fresh-dao.ts
|
|
1200
1202
|
var _FreshDao = class _FreshDao {
|
|
1203
|
+
getRepo(manager, entity = this.entity) {
|
|
1204
|
+
return manager ? manager.getRepository(entity) : this.repo;
|
|
1205
|
+
}
|
|
1201
1206
|
};
|
|
1202
1207
|
__name(_FreshDao, "FreshDao");
|
|
1203
1208
|
var FreshDao = _FreshDao;
|
|
@@ -1286,6 +1291,56 @@ Subcategory = _ts_decorate8([
|
|
|
1286
1291
|
(0, import_typeorm9.Entity)()
|
|
1287
1292
|
], Subcategory);
|
|
1288
1293
|
|
|
1294
|
+
// src/common/typeguards/enums.ts
|
|
1295
|
+
function isEnumValue(enumObj, v) {
|
|
1296
|
+
if (!enumObj) {
|
|
1297
|
+
return typeof v === "string" || typeof v === "number";
|
|
1298
|
+
}
|
|
1299
|
+
const values = new Set(Object.values(enumObj));
|
|
1300
|
+
return (typeof v === "string" || typeof v === "number") && values.has(v);
|
|
1301
|
+
}
|
|
1302
|
+
__name(isEnumValue, "isEnumValue");
|
|
1303
|
+
|
|
1304
|
+
// src/common/typeguards/objects.ts
|
|
1305
|
+
function isObject(v) {
|
|
1306
|
+
return typeof v === "object" && v !== null;
|
|
1307
|
+
}
|
|
1308
|
+
__name(isObject, "isObject");
|
|
1309
|
+
function hasOwn(obj, key) {
|
|
1310
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
1311
|
+
}
|
|
1312
|
+
__name(hasOwn, "hasOwn");
|
|
1313
|
+
|
|
1314
|
+
// src/common/typeguards/primitives.ts
|
|
1315
|
+
function isNumber(v) {
|
|
1316
|
+
return typeof v === "number" && Number.isFinite(v);
|
|
1317
|
+
}
|
|
1318
|
+
__name(isNumber, "isNumber");
|
|
1319
|
+
function isString(v) {
|
|
1320
|
+
return typeof v === "string";
|
|
1321
|
+
}
|
|
1322
|
+
__name(isString, "isString");
|
|
1323
|
+
function isFlag01(v) {
|
|
1324
|
+
return v === 0 || v === 1;
|
|
1325
|
+
}
|
|
1326
|
+
__name(isFlag01, "isFlag01");
|
|
1327
|
+
function isNumberInRange(v, min, max, options) {
|
|
1328
|
+
var _a, _b;
|
|
1329
|
+
if (!isNumber(v)) {
|
|
1330
|
+
return false;
|
|
1331
|
+
}
|
|
1332
|
+
const includeMin = (_a = options == null ? void 0 : options.includeMin) != null ? _a : true;
|
|
1333
|
+
const includeMax = (_b = options == null ? void 0 : options.includeMax) != null ? _b : true;
|
|
1334
|
+
if (includeMin ? v < min : v <= min) {
|
|
1335
|
+
return false;
|
|
1336
|
+
}
|
|
1337
|
+
if (includeMax ? v > max : v >= max) {
|
|
1338
|
+
return false;
|
|
1339
|
+
}
|
|
1340
|
+
return true;
|
|
1341
|
+
}
|
|
1342
|
+
__name(isNumberInRange, "isNumberInRange");
|
|
1343
|
+
|
|
1289
1344
|
// src/core/data-helper.ts
|
|
1290
1345
|
var _DataHelper = class _DataHelper {
|
|
1291
1346
|
constructor(startDataRetrieve = true, deviceIds) {
|
|
@@ -1459,6 +1514,12 @@ var _ApiError = class _ApiError extends Error {
|
|
|
1459
1514
|
__name(_ApiError, "ApiError");
|
|
1460
1515
|
var ApiError = _ApiError;
|
|
1461
1516
|
|
|
1517
|
+
// src/types/maybe-type.ts
|
|
1518
|
+
function isMaybe(v, inner) {
|
|
1519
|
+
return v === null || inner(v);
|
|
1520
|
+
}
|
|
1521
|
+
__name(isMaybe, "isMaybe");
|
|
1522
|
+
|
|
1462
1523
|
// src/config/eslint-config.ts
|
|
1463
1524
|
var import_typescript_eslint = __toESM(require("typescript-eslint"));
|
|
1464
1525
|
var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"));
|
|
@@ -1670,6 +1731,14 @@ var datasource_default = PG_DATA_SOURCE_OPTIONS;
|
|
|
1670
1731
|
TransactionType,
|
|
1671
1732
|
createDeferred,
|
|
1672
1733
|
freshEslintConfig,
|
|
1734
|
+
hasOwn,
|
|
1735
|
+
isEnumValue,
|
|
1736
|
+
isFlag01,
|
|
1737
|
+
isMaybe,
|
|
1738
|
+
isNumber,
|
|
1739
|
+
isNumberInRange,
|
|
1740
|
+
isObject,
|
|
1741
|
+
isString,
|
|
1673
1742
|
isValidCron,
|
|
1674
1743
|
logger
|
|
1675
1744
|
});
|