@freshpointcz/fresh-core 0.0.20 → 0.0.21
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 +47 -2
- package/dist/index.d.ts +47 -2
- package/dist/index.js +1059 -1006
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1057 -1007
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -658,70 +658,37 @@ var _StatusDto = class _StatusDto {
|
|
|
658
658
|
__name(_StatusDto, "StatusDto");
|
|
659
659
|
var StatusDto = _StatusDto;
|
|
660
660
|
|
|
661
|
-
// src/common/pagination/
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
skip: (page - 1) * limit
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
__name(parsePaginationFromURL, "parsePaginationFromURL");
|
|
680
|
-
|
|
681
|
-
// src/common/pagination/pagination-meta.ts
|
|
682
|
-
function getPaginationMeta(total, page, limit) {
|
|
683
|
-
return {
|
|
684
|
-
total,
|
|
685
|
-
page,
|
|
686
|
-
limit,
|
|
687
|
-
totalPages: Math.ceil(total / limit)
|
|
688
|
-
};
|
|
661
|
+
// src/common/pagination/find-options/date-range.ts
|
|
662
|
+
import { Between, LessThanOrEqual, MoreThanOrEqual } from "typeorm";
|
|
663
|
+
function buildDateRange(from, to) {
|
|
664
|
+
const f = from ? new Date(from) : void 0;
|
|
665
|
+
const t = to ? new Date(to) : void 0;
|
|
666
|
+
if (f && t) {
|
|
667
|
+
return Between(f, t);
|
|
668
|
+
}
|
|
669
|
+
if (f) {
|
|
670
|
+
return MoreThanOrEqual(f);
|
|
671
|
+
}
|
|
672
|
+
if (t) {
|
|
673
|
+
return LessThanOrEqual(t);
|
|
674
|
+
}
|
|
675
|
+
return void 0;
|
|
689
676
|
}
|
|
690
|
-
__name(
|
|
677
|
+
__name(buildDateRange, "buildDateRange");
|
|
691
678
|
|
|
692
|
-
// src/common/pagination/
|
|
693
|
-
function
|
|
679
|
+
// src/common/pagination/find-options/order.ts
|
|
680
|
+
function buildOrder(sortBy, sortOrder) {
|
|
681
|
+
if (!sortBy) {
|
|
682
|
+
return void 0;
|
|
683
|
+
}
|
|
694
684
|
return {
|
|
695
|
-
|
|
696
|
-
...params
|
|
685
|
+
[sortBy]: sortOrder != null ? sortOrder : "ASC"
|
|
697
686
|
};
|
|
698
687
|
}
|
|
699
|
-
__name(
|
|
700
|
-
var DEFAULT_PAGINATION_PARAMS = {
|
|
701
|
-
page: 1,
|
|
702
|
-
limit: 1e3,
|
|
703
|
-
skip: 0
|
|
704
|
-
};
|
|
688
|
+
__name(buildOrder, "buildOrder");
|
|
705
689
|
|
|
706
|
-
// src/
|
|
707
|
-
|
|
708
|
-
const results = [];
|
|
709
|
-
let page = 1;
|
|
710
|
-
while (true) {
|
|
711
|
-
const { data, meta } = await fetchPage({
|
|
712
|
-
page,
|
|
713
|
-
limit: batchSize,
|
|
714
|
-
skip: (page - 1) * batchSize
|
|
715
|
-
});
|
|
716
|
-
results.push(...data);
|
|
717
|
-
if (page >= meta.totalPages) {
|
|
718
|
-
break;
|
|
719
|
-
}
|
|
720
|
-
page++;
|
|
721
|
-
}
|
|
722
|
-
return results;
|
|
723
|
-
}
|
|
724
|
-
__name(listAll, "listAll");
|
|
690
|
+
// src/core/class/fresh-job.ts
|
|
691
|
+
import { scheduleJob } from "node-schedule";
|
|
725
692
|
|
|
726
693
|
// src/common/patterns/singleton.ts
|
|
727
694
|
var _Singleton = class _Singleton {
|
|
@@ -774,236 +741,173 @@ __name(_Singleton, "Singleton");
|
|
|
774
741
|
__publicField(_Singleton, "instances", /* @__PURE__ */ new Map());
|
|
775
742
|
var Singleton = _Singleton;
|
|
776
743
|
|
|
777
|
-
// src/
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
__publicField(this, "
|
|
744
|
+
// src/core/class/fresh-job.ts
|
|
745
|
+
var _FreshJob = class _FreshJob extends Singleton {
|
|
746
|
+
/**
|
|
747
|
+
* Creates and optionally schedules a singleton cron job.
|
|
748
|
+
*
|
|
749
|
+
* @param jobName - Logical name of the job (used in logs and errors).
|
|
750
|
+
* @param cronExpression - Cron expression consisting of numeric fields only.
|
|
751
|
+
* Example: `0 5 * * 4`
|
|
752
|
+
* The timezone `"Europe/Prague"` is applied automatically.
|
|
753
|
+
*
|
|
754
|
+
* @param jobEnabled - Whether the job should be scheduled immediately.
|
|
755
|
+
* If `false`, the instance exists but no cron trigger is registered.
|
|
756
|
+
*
|
|
757
|
+
* @throws Error If the cron expression is invalid.
|
|
758
|
+
* @throws Error If the job cannot be scheduled.
|
|
759
|
+
*/
|
|
760
|
+
constructor(jobName, cronExpression, jobEnabled) {
|
|
761
|
+
super(false);
|
|
762
|
+
/** Human-readable job identifier (used for logs and errors). */
|
|
763
|
+
__publicField(this, "_jobName");
|
|
764
|
+
/**
|
|
765
|
+
* Cron expression defining when the job runs.
|
|
766
|
+
*
|
|
767
|
+
* Must contain numeric cron fields only.
|
|
768
|
+
* Example: `0 5 * * 4`
|
|
769
|
+
*
|
|
770
|
+
* Timezone is always forced to `"Europe/Prague"`.
|
|
771
|
+
* If you need another timezone, this class is not your friend.
|
|
772
|
+
*/
|
|
773
|
+
__publicField(this, "_cronExpression");
|
|
774
|
+
/** Scheduled job instance, or `null` if the job is disabled. */
|
|
775
|
+
__publicField(this, "_job", null);
|
|
776
|
+
this._jobName = jobName;
|
|
777
|
+
if (!isValidCron(cronExpression)) {
|
|
778
|
+
throw new Error(`Job ${this.jobName} cannot be constructed with invalid cron: "${cronExpression}"`);
|
|
779
|
+
}
|
|
780
|
+
this._cronExpression = cronExpression;
|
|
781
|
+
if (jobEnabled) {
|
|
782
|
+
this._job = scheduleJob({
|
|
783
|
+
rule: this._cronExpression,
|
|
784
|
+
tz: "Europe/Prague"
|
|
785
|
+
}, async () => {
|
|
786
|
+
await this.invoke();
|
|
787
|
+
});
|
|
788
|
+
if (!this._job) {
|
|
789
|
+
throw new Error(`Job ${this._jobName} could not be scheduled`);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
this.onInit();
|
|
797
793
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
794
|
+
/**
|
|
795
|
+
* Initialization hook.
|
|
796
|
+
*
|
|
797
|
+
* Called once during construction and used primarily for logging.
|
|
798
|
+
* Can also be reused by subclasses if manual rescheduling is implemented.
|
|
799
|
+
*
|
|
800
|
+
* @param rescheduled - Indicates whether the job was reconfigured
|
|
801
|
+
* after initial creation.
|
|
802
|
+
*/
|
|
803
|
+
onInit(rescheduled) {
|
|
804
|
+
console.log(`Job ${this.jobName} ${rescheduled ? "rescheduled" : "initialized"} with cron rule: "${this.cronExpression}"`);
|
|
805
|
+
}
|
|
806
|
+
/** @returns The logical name of the job. */
|
|
807
|
+
get jobName() {
|
|
808
|
+
return this._jobName;
|
|
809
|
+
}
|
|
810
|
+
/** Allows subclasses to rename the job if absolutely necessary. */
|
|
811
|
+
set jobName(value) {
|
|
812
|
+
this._jobName = value;
|
|
813
|
+
}
|
|
814
|
+
/** @returns The cron expression used to schedule the job. */
|
|
815
|
+
get cronExpression() {
|
|
816
|
+
return this._cronExpression;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Allows subclasses to update the cron expression internally.
|
|
820
|
+
* Does reschedule of job if exists
|
|
821
|
+
*/
|
|
822
|
+
set cronExpression(value) {
|
|
823
|
+
if (!isValidCron(value)) {
|
|
824
|
+
throw new Error(`Job ${this._jobName} cannot be re-scheduled with invalid cron: "${value}"`);
|
|
801
825
|
}
|
|
802
|
-
|
|
826
|
+
this._cronExpression = value;
|
|
803
827
|
}
|
|
804
|
-
|
|
805
|
-
|
|
828
|
+
/** @returns The underlying scheduled job instance, or `null` if disabled. */
|
|
829
|
+
get job() {
|
|
830
|
+
return this._job;
|
|
806
831
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
832
|
+
/** Allows subclasses to manage the scheduled job instance. */
|
|
833
|
+
set job(value) {
|
|
834
|
+
this._job = value;
|
|
835
|
+
}
|
|
836
|
+
reschedule(newCronExpression) {
|
|
837
|
+
let result = false;
|
|
838
|
+
if (!isValidCron(newCronExpression)) {
|
|
839
|
+
throw new Error(`Job ${this._jobName} cannot be re-scheduled with invalid cron: "${newCronExpression}"`);
|
|
840
|
+
}
|
|
841
|
+
this._cronExpression = newCronExpression;
|
|
842
|
+
if (this._job) {
|
|
843
|
+
const rescheduleSuccess = this._job.reschedule({
|
|
844
|
+
rule: this._cronExpression,
|
|
845
|
+
tz: "Europe/Prague"
|
|
812
846
|
});
|
|
847
|
+
if (!rescheduleSuccess) {
|
|
848
|
+
throw new Error(`Job ${this._jobName} could not be re-scheduled`);
|
|
849
|
+
} else {
|
|
850
|
+
this.onInit(true);
|
|
851
|
+
}
|
|
852
|
+
result = rescheduleSuccess;
|
|
813
853
|
}
|
|
814
|
-
|
|
815
|
-
get hasPromise() {
|
|
816
|
-
return this._promise !== null;
|
|
854
|
+
return result;
|
|
817
855
|
}
|
|
818
856
|
};
|
|
819
|
-
__name(
|
|
820
|
-
|
|
821
|
-
var SinglePromiseWaiter = _SinglePromiseWaiter;
|
|
822
|
-
|
|
823
|
-
// src/common/schema/entities/category.entity.ts
|
|
824
|
-
import { Entity } from "typeorm";
|
|
825
|
-
|
|
826
|
-
// src/database/entities/fresh-entity.ts
|
|
827
|
-
import { BaseEntity, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, Column } from "typeorm";
|
|
828
|
-
|
|
829
|
-
// ../../node_modules/uuid/dist/esm/stringify.js
|
|
830
|
-
var byteToHex = [];
|
|
831
|
-
for (let i = 0; i < 256; ++i) {
|
|
832
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
833
|
-
}
|
|
834
|
-
function unsafeStringify(arr, offset = 0) {
|
|
835
|
-
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();
|
|
836
|
-
}
|
|
837
|
-
__name(unsafeStringify, "unsafeStringify");
|
|
857
|
+
__name(_FreshJob, "FreshJob");
|
|
858
|
+
var FreshJob = _FreshJob;
|
|
838
859
|
|
|
839
|
-
//
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
860
|
+
// src/core/errors/api-error.ts
|
|
861
|
+
var _ApiError = class _ApiError extends Error {
|
|
862
|
+
constructor(statusCode, status, detail) {
|
|
863
|
+
super();
|
|
864
|
+
__publicField(this, "_statusCode");
|
|
865
|
+
__publicField(this, "_statusDto");
|
|
866
|
+
this._statusCode = statusCode;
|
|
867
|
+
this._statusDto = new StatusDto(status, detail);
|
|
868
|
+
}
|
|
869
|
+
get statusCode() {
|
|
870
|
+
return this._statusCode;
|
|
871
|
+
}
|
|
872
|
+
get statusDto() {
|
|
873
|
+
return this._statusDto;
|
|
847
874
|
}
|
|
848
|
-
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
849
|
-
}
|
|
850
|
-
__name(rng, "rng");
|
|
851
|
-
|
|
852
|
-
// ../../node_modules/uuid/dist/esm/native.js
|
|
853
|
-
import { randomUUID } from "crypto";
|
|
854
|
-
var native_default = {
|
|
855
|
-
randomUUID
|
|
856
875
|
};
|
|
876
|
+
__name(_ApiError, "ApiError");
|
|
877
|
+
var ApiError = _ApiError;
|
|
857
878
|
|
|
858
|
-
//
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
const rnds = (_c = (_b = options.random) != null ? _b : (_a = options.rng) == null ? void 0 : _a.call(options)) != null ? _c : rng();
|
|
866
|
-
if (rnds.length < 16) {
|
|
867
|
-
throw new Error("Random bytes length must be >= 16");
|
|
868
|
-
}
|
|
869
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
870
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
871
|
-
if (buf) {
|
|
872
|
-
offset = offset || 0;
|
|
873
|
-
if (offset < 0 || offset + 16 > buf.length) {
|
|
874
|
-
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
875
|
-
}
|
|
876
|
-
for (let i = 0; i < 16; ++i) {
|
|
877
|
-
buf[offset + i] = rnds[i];
|
|
878
|
-
}
|
|
879
|
-
return buf;
|
|
880
|
-
}
|
|
881
|
-
return unsafeStringify(rnds);
|
|
882
|
-
}
|
|
883
|
-
__name(v4, "v4");
|
|
884
|
-
var v4_default = v4;
|
|
885
|
-
|
|
886
|
-
// src/database/entities/fresh-entity.ts
|
|
887
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
888
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
889
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
890
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
891
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
892
|
-
}
|
|
893
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
894
|
-
function _ts_metadata(k, v) {
|
|
895
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
896
|
-
}
|
|
897
|
-
__name(_ts_metadata, "_ts_metadata");
|
|
898
|
-
var _FreshEntity = class _FreshEntity extends BaseEntity {
|
|
899
|
-
/** After manual construction `id` is irrelevant. Refer to `uuid` only, because that will be inserted into DB */
|
|
900
|
-
constructor() {
|
|
901
|
-
super();
|
|
902
|
-
__publicField(this, "id");
|
|
903
|
-
__publicField(this, "uuid");
|
|
904
|
-
__publicField(this, "created_at");
|
|
905
|
-
__publicField(this, "updated_at");
|
|
906
|
-
// for soft delete methods by typeorm
|
|
907
|
-
__publicField(this, "deleted_at");
|
|
908
|
-
this.id = 0;
|
|
909
|
-
this.uuid = v4_default();
|
|
910
|
-
const newDate = /* @__PURE__ */ new Date();
|
|
911
|
-
this.created_at = newDate;
|
|
912
|
-
this.updated_at = newDate;
|
|
913
|
-
this.deleted_at = null;
|
|
879
|
+
// src/core/errors/business-warning.ts
|
|
880
|
+
var _BusinessWarning = class _BusinessWarning extends Error {
|
|
881
|
+
constructor(code, message) {
|
|
882
|
+
super(message);
|
|
883
|
+
__publicField(this, "code");
|
|
884
|
+
this.code = code;
|
|
885
|
+
this.name = "BusinessWarning";
|
|
914
886
|
}
|
|
915
887
|
};
|
|
916
|
-
__name(
|
|
917
|
-
var
|
|
918
|
-
_ts_decorate([
|
|
919
|
-
PrimaryGeneratedColumn("increment"),
|
|
920
|
-
_ts_metadata("design:type", Number)
|
|
921
|
-
], FreshEntity.prototype, "id", void 0);
|
|
922
|
-
_ts_decorate([
|
|
923
|
-
Index({
|
|
924
|
-
unique: true
|
|
925
|
-
}),
|
|
926
|
-
Column({
|
|
927
|
-
type: "uuid",
|
|
928
|
-
default: /* @__PURE__ */ __name(() => "gen_random_uuid()", "default")
|
|
929
|
-
}),
|
|
930
|
-
_ts_metadata("design:type", String)
|
|
931
|
-
], FreshEntity.prototype, "uuid", void 0);
|
|
932
|
-
_ts_decorate([
|
|
933
|
-
CreateDateColumn({
|
|
934
|
-
type: "timestamptz"
|
|
935
|
-
}),
|
|
936
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
937
|
-
], FreshEntity.prototype, "created_at", void 0);
|
|
938
|
-
_ts_decorate([
|
|
939
|
-
UpdateDateColumn({
|
|
940
|
-
type: "timestamptz"
|
|
941
|
-
}),
|
|
942
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
943
|
-
], FreshEntity.prototype, "updated_at", void 0);
|
|
944
|
-
_ts_decorate([
|
|
945
|
-
DeleteDateColumn({
|
|
946
|
-
type: "timestamptz",
|
|
947
|
-
nullable: true
|
|
948
|
-
}),
|
|
949
|
-
_ts_metadata("design:type", Object)
|
|
950
|
-
], FreshEntity.prototype, "deleted_at", void 0);
|
|
951
|
-
|
|
952
|
-
// src/database/entities/fresh-hyper-entity.ts
|
|
953
|
-
import { BaseEntity as BaseEntity2, PrimaryColumn } from "typeorm";
|
|
954
|
-
|
|
955
|
-
// src/database/decorators/timestamp-column.ts
|
|
956
|
-
import { Column as Column2 } from "typeorm";
|
|
957
|
-
function TimestampColumn(options = {}) {
|
|
958
|
-
const defaultOptions = {
|
|
959
|
-
type: "timestamptz",
|
|
960
|
-
nullable: false,
|
|
961
|
-
default: /* @__PURE__ */ __name(() => "CURRENT_TIMESTAMP", "default"),
|
|
962
|
-
...options
|
|
963
|
-
};
|
|
964
|
-
return Column2(defaultOptions);
|
|
965
|
-
}
|
|
966
|
-
__name(TimestampColumn, "TimestampColumn");
|
|
888
|
+
__name(_BusinessWarning, "BusinessWarning");
|
|
889
|
+
var BusinessWarning = _BusinessWarning;
|
|
967
890
|
|
|
968
|
-
// src/
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
// input timestamp as PK
|
|
985
|
-
__publicField(this, "timestamp");
|
|
986
|
-
// just info column about time of insert
|
|
987
|
-
__publicField(this, "created_at");
|
|
988
|
-
this.timestamp = timestamp != null ? timestamp : /* @__PURE__ */ new Date();
|
|
989
|
-
this.created_at = /* @__PURE__ */ new Date();
|
|
891
|
+
// src/core/errors/fresh-error.ts
|
|
892
|
+
var _FreshError = class _FreshError extends Error {
|
|
893
|
+
constructor(statusCode, status, detail, options) {
|
|
894
|
+
super(detail != null ? detail : status);
|
|
895
|
+
/** HTTP status code sent in the response. */
|
|
896
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
897
|
+
__publicField(this, "statusCode");
|
|
898
|
+
/** Structured response body describing the error. */
|
|
899
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
900
|
+
__publicField(this, "statusDto");
|
|
901
|
+
this.name = this.constructor.name;
|
|
902
|
+
if ((options == null ? void 0 : options.cause) !== void 0) {
|
|
903
|
+
this.cause = options.cause;
|
|
904
|
+
}
|
|
905
|
+
this.statusCode = statusCode;
|
|
906
|
+
this.statusDto = new StatusDto(status, detail);
|
|
990
907
|
}
|
|
991
908
|
};
|
|
992
|
-
__name(
|
|
993
|
-
var
|
|
994
|
-
_ts_decorate2([
|
|
995
|
-
PrimaryColumn({
|
|
996
|
-
type: "timestamptz"
|
|
997
|
-
}),
|
|
998
|
-
_ts_metadata2("design:type", typeof Date === "undefined" ? Object : Date)
|
|
999
|
-
], FreshHyperEntity.prototype, "timestamp", void 0);
|
|
1000
|
-
_ts_decorate2([
|
|
1001
|
-
TimestampColumn(),
|
|
1002
|
-
_ts_metadata2("design:type", typeof Date === "undefined" ? Object : Date)
|
|
1003
|
-
], FreshHyperEntity.prototype, "created_at", void 0);
|
|
1004
|
-
|
|
1005
|
-
// src/database/entities/fresh-translation-entity.ts
|
|
1006
|
-
import { PrimaryGeneratedColumn as PrimaryGeneratedColumn2, Column as Column3, BaseEntity as BaseEntity3, Check } from "typeorm";
|
|
909
|
+
__name(_FreshError, "FreshError");
|
|
910
|
+
var FreshError = _FreshError;
|
|
1007
911
|
|
|
1008
912
|
// src/enums/action-command-code.ts
|
|
1009
913
|
var ActionCommandCode = /* @__PURE__ */ (function(ActionCommandCode2) {
|
|
@@ -1128,853 +1032,996 @@ var TransactionType = /* @__PURE__ */ (function(TransactionType2) {
|
|
|
1128
1032
|
return TransactionType2;
|
|
1129
1033
|
})({});
|
|
1130
1034
|
|
|
1131
|
-
// src/
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1136
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1137
|
-
}
|
|
1138
|
-
__name(_ts_decorate3, "_ts_decorate");
|
|
1139
|
-
function _ts_metadata3(k, v) {
|
|
1140
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1141
|
-
}
|
|
1142
|
-
__name(_ts_metadata3, "_ts_metadata");
|
|
1143
|
-
var languageValues = Object.values(LanguageCode).map((v) => `'${v}'`).join(",");
|
|
1144
|
-
var _FreshTranslationBase = class _FreshTranslationBase extends BaseEntity3 {
|
|
1145
|
-
constructor() {
|
|
1146
|
-
super();
|
|
1147
|
-
__publicField(this, "id");
|
|
1148
|
-
__publicField(this, "languageCode");
|
|
1149
|
-
this.id = 0;
|
|
1150
|
-
this.languageCode = LanguageCode.CS;
|
|
1035
|
+
// src/core/errors/errors.ts
|
|
1036
|
+
var _BadRequestError = class _BadRequestError extends FreshError {
|
|
1037
|
+
constructor(detail, options) {
|
|
1038
|
+
super(HttpStatus.BAD_REQUEST, "validation-error", detail, options);
|
|
1151
1039
|
}
|
|
1152
1040
|
};
|
|
1153
|
-
__name(
|
|
1154
|
-
var
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
], FreshTranslationBase.prototype, "id", void 0);
|
|
1159
|
-
_ts_decorate3([
|
|
1160
|
-
Column3({
|
|
1161
|
-
type: "varchar",
|
|
1162
|
-
length: 3,
|
|
1163
|
-
nullable: false
|
|
1164
|
-
}),
|
|
1165
|
-
Check(`"languageCode" IN (${languageValues})`),
|
|
1166
|
-
_ts_metadata3("design:type", typeof LanguageCode === "undefined" ? Object : LanguageCode)
|
|
1167
|
-
], FreshTranslationBase.prototype, "languageCode", void 0);
|
|
1168
|
-
|
|
1169
|
-
// src/database/dao/fresh-dao.ts
|
|
1170
|
-
var _FreshDao = class _FreshDao {
|
|
1171
|
-
getRepo(manager, entity = this.entity) {
|
|
1172
|
-
return manager ? manager.getRepository(entity) : this.repo;
|
|
1041
|
+
__name(_BadRequestError, "BadRequestError");
|
|
1042
|
+
var BadRequestError = _BadRequestError;
|
|
1043
|
+
var _UnauthorizedError = class _UnauthorizedError extends FreshError {
|
|
1044
|
+
constructor(detail, options) {
|
|
1045
|
+
super(HttpStatus.UNAUTHORIZED, "not-authenticated", detail, options);
|
|
1173
1046
|
}
|
|
1174
1047
|
};
|
|
1175
|
-
__name(
|
|
1176
|
-
var
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
// ─── TypeORM lifecycle hooks ────────────────────────────────────────
|
|
1181
|
-
afterInsert(event) {
|
|
1182
|
-
var _a;
|
|
1183
|
-
const id = (_a = event.entity) == null ? void 0 : _a.id;
|
|
1184
|
-
if (!id) {
|
|
1185
|
-
return;
|
|
1186
|
-
}
|
|
1187
|
-
if (event.queryRunner.isTransactionActive) {
|
|
1188
|
-
this.addPending(event, id, "created");
|
|
1189
|
-
} else {
|
|
1190
|
-
console.warn(`${this.SUBSCRIBER_NAME} - Notification sent outside transaction for id=${id}`);
|
|
1191
|
-
this.sendNotification(id, "created", event.queryRunner.manager);
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
afterUpdate(event) {
|
|
1195
|
-
var _a, _b, _c;
|
|
1196
|
-
const id = (_c = (_a = event.entity) == null ? void 0 : _a.id) != null ? _c : (_b = event.databaseEntity) == null ? void 0 : _b.id;
|
|
1197
|
-
if (!id) {
|
|
1198
|
-
return;
|
|
1199
|
-
}
|
|
1200
|
-
if (event.queryRunner.isTransactionActive) {
|
|
1201
|
-
this.addPending(event, id, "updated");
|
|
1202
|
-
} else {
|
|
1203
|
-
console.warn(`${this.SUBSCRIBER_NAME} - Notification sent outside transaction for id=${id}`);
|
|
1204
|
-
this.sendNotification(id, "updated", event.queryRunner.manager);
|
|
1205
|
-
}
|
|
1048
|
+
__name(_UnauthorizedError, "UnauthorizedError");
|
|
1049
|
+
var UnauthorizedError = _UnauthorizedError;
|
|
1050
|
+
var _PaymentRequiredError = class _PaymentRequiredError extends FreshError {
|
|
1051
|
+
constructor(detail, options) {
|
|
1052
|
+
super(HttpStatus.PAYMENT_REQUIRED, "error", detail, options);
|
|
1206
1053
|
}
|
|
1207
|
-
afterSoftRemove(event) {
|
|
1208
|
-
var _a, _b, _c;
|
|
1209
|
-
const id = (_c = (_a = event.entity) == null ? void 0 : _a.id) != null ? _c : (_b = event.databaseEntity) == null ? void 0 : _b.id;
|
|
1210
|
-
if (!id) {
|
|
1211
|
-
return;
|
|
1212
|
-
}
|
|
1213
|
-
if (event.queryRunner.isTransactionActive) {
|
|
1214
|
-
this.addPending(event, id, "deleted");
|
|
1215
|
-
} else {
|
|
1216
|
-
console.warn(`${this.SUBSCRIBER_NAME} - Notification sent outside transaction for id=${id}`);
|
|
1217
|
-
this.sendNotification(id, "deleted", event.queryRunner.manager);
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
async afterTransactionCommit(event) {
|
|
1221
|
-
var _a;
|
|
1222
|
-
const pending = (_a = event.queryRunner.data) == null ? void 0 : _a[this.PENDING_KEY];
|
|
1223
|
-
if (!pending || pending.size === 0) {
|
|
1224
|
-
return;
|
|
1225
|
-
}
|
|
1226
|
-
event.queryRunner.data[this.PENDING_KEY] = /* @__PURE__ */ new Map();
|
|
1227
|
-
for (const [id, changeEvent] of pending) {
|
|
1228
|
-
await this.sendNotification(id, changeEvent, event.connection.manager);
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
// ─── Private helpers ───────────────────────────────────────────────
|
|
1232
|
-
addPending(event, id, changeEvent) {
|
|
1233
|
-
if (!event.queryRunner.data) {
|
|
1234
|
-
event.queryRunner.data = {};
|
|
1235
|
-
}
|
|
1236
|
-
if (!event.queryRunner.data[this.PENDING_KEY]) {
|
|
1237
|
-
event.queryRunner.data[this.PENDING_KEY] = /* @__PURE__ */ new Map();
|
|
1238
|
-
}
|
|
1239
|
-
const existing = event.queryRunner.data[this.PENDING_KEY].get(id);
|
|
1240
|
-
if (!existing || changeEvent === "created" || changeEvent === "deleted") {
|
|
1241
|
-
event.queryRunner.data[this.PENDING_KEY].set(id, changeEvent);
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
async sendNotification(id, changeEvent, manager) {
|
|
1245
|
-
try {
|
|
1246
|
-
await this.handleNotification(id, changeEvent, manager);
|
|
1247
|
-
} catch (error) {
|
|
1248
|
-
console.error(`${this.SUBSCRIBER_NAME} - Failed to send notification: ${error instanceof Error ? error.message : error}`);
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
};
|
|
1252
|
-
__name(_BaseEntityChangeSubscriber, "BaseEntityChangeSubscriber");
|
|
1253
|
-
var BaseEntityChangeSubscriber = _BaseEntityChangeSubscriber;
|
|
1254
|
-
|
|
1255
|
-
// src/common/schema/entities/category.entity.ts
|
|
1256
|
-
function _ts_decorate4(decorators, target, key, desc) {
|
|
1257
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1258
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1259
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1260
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1261
|
-
}
|
|
1262
|
-
__name(_ts_decorate4, "_ts_decorate");
|
|
1263
|
-
var _Category = class _Category extends FreshEntity {
|
|
1264
|
-
};
|
|
1265
|
-
__name(_Category, "Category");
|
|
1266
|
-
var Category = _Category;
|
|
1267
|
-
Category = _ts_decorate4([
|
|
1268
|
-
Entity()
|
|
1269
|
-
], Category);
|
|
1270
|
-
|
|
1271
|
-
// src/common/schema/entities/device.entity.ts
|
|
1272
|
-
import { Entity as Entity2 } from "typeorm";
|
|
1273
|
-
function _ts_decorate5(decorators, target, key, desc) {
|
|
1274
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1275
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1276
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1277
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1278
|
-
}
|
|
1279
|
-
__name(_ts_decorate5, "_ts_decorate");
|
|
1280
|
-
var _Device = class _Device extends FreshEntity {
|
|
1281
|
-
};
|
|
1282
|
-
__name(_Device, "Device");
|
|
1283
|
-
var Device = _Device;
|
|
1284
|
-
Device = _ts_decorate5([
|
|
1285
|
-
Entity2()
|
|
1286
|
-
], Device);
|
|
1287
|
-
|
|
1288
|
-
// src/common/schema/entities/manufacturer.entity.ts
|
|
1289
|
-
import { Entity as Entity3 } from "typeorm";
|
|
1290
|
-
function _ts_decorate6(decorators, target, key, desc) {
|
|
1291
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1292
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1293
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1294
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1295
|
-
}
|
|
1296
|
-
__name(_ts_decorate6, "_ts_decorate");
|
|
1297
|
-
var _Manufacturer = class _Manufacturer extends FreshEntity {
|
|
1298
|
-
};
|
|
1299
|
-
__name(_Manufacturer, "Manufacturer");
|
|
1300
|
-
var Manufacturer = _Manufacturer;
|
|
1301
|
-
Manufacturer = _ts_decorate6([
|
|
1302
|
-
Entity3()
|
|
1303
|
-
], Manufacturer);
|
|
1304
|
-
|
|
1305
|
-
// src/common/schema/entities/product.entity.ts
|
|
1306
|
-
import { Entity as Entity4 } from "typeorm";
|
|
1307
|
-
function _ts_decorate7(decorators, target, key, desc) {
|
|
1308
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1309
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1310
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1311
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1312
|
-
}
|
|
1313
|
-
__name(_ts_decorate7, "_ts_decorate");
|
|
1314
|
-
var _Product = class _Product extends FreshEntity {
|
|
1315
1054
|
};
|
|
1316
|
-
__name(
|
|
1317
|
-
var
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
// src/common/schema/entities/subcategory.entity.ts
|
|
1323
|
-
import { Entity as Entity5 } from "typeorm";
|
|
1324
|
-
function _ts_decorate8(decorators, target, key, desc) {
|
|
1325
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1326
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1327
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1328
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1329
|
-
}
|
|
1330
|
-
__name(_ts_decorate8, "_ts_decorate");
|
|
1331
|
-
var _Subcategory = class _Subcategory extends FreshEntity {
|
|
1055
|
+
__name(_PaymentRequiredError, "PaymentRequiredError");
|
|
1056
|
+
var PaymentRequiredError = _PaymentRequiredError;
|
|
1057
|
+
var _ForbiddenError = class _ForbiddenError extends FreshError {
|
|
1058
|
+
constructor(detail, options) {
|
|
1059
|
+
super(HttpStatus.FORBIDDEN, "not-authorized", detail, options);
|
|
1060
|
+
}
|
|
1332
1061
|
};
|
|
1333
|
-
__name(
|
|
1334
|
-
var
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
// src/common/typeguards/decimal.ts
|
|
1340
|
-
function toDecimal(num, precision = 9, scale = 2) {
|
|
1341
|
-
const limit = Math.pow(10, precision - scale);
|
|
1342
|
-
if (Math.abs(num) >= limit) {
|
|
1343
|
-
throw new Error(`Value ${num} exceeds the allowed precision of ${precision} and scale of ${scale}.`);
|
|
1062
|
+
__name(_ForbiddenError, "ForbiddenError");
|
|
1063
|
+
var ForbiddenError = _ForbiddenError;
|
|
1064
|
+
var _NotFoundError = class _NotFoundError extends FreshError {
|
|
1065
|
+
constructor(detail, options) {
|
|
1066
|
+
super(HttpStatus.NOT_FOUND, "error", detail, options);
|
|
1344
1067
|
}
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
if ((options == null ? void 0 : options.allowedType) !== void 0 && type !== options.allowedType) {
|
|
1352
|
-
return false;
|
|
1068
|
+
};
|
|
1069
|
+
__name(_NotFoundError, "NotFoundError");
|
|
1070
|
+
var NotFoundError = _NotFoundError;
|
|
1071
|
+
var _MethodNotAllowedError = class _MethodNotAllowedError extends FreshError {
|
|
1072
|
+
constructor(detail, options) {
|
|
1073
|
+
super(HttpStatus.METHOD_NOT_ALLOWED, "error", detail, options);
|
|
1353
1074
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1075
|
+
};
|
|
1076
|
+
__name(_MethodNotAllowedError, "MethodNotAllowedError");
|
|
1077
|
+
var MethodNotAllowedError = _MethodNotAllowedError;
|
|
1078
|
+
var _NotAcceptableError = class _NotAcceptableError extends FreshError {
|
|
1079
|
+
constructor(detail, options) {
|
|
1080
|
+
super(HttpStatus.NOT_ACCEPTABLE, "error", detail, options);
|
|
1356
1081
|
}
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
return false;
|
|
1364
|
-
}
|
|
1365
|
-
const str = n.toString();
|
|
1366
|
-
if (str.includes("e") || str.includes("E")) {
|
|
1367
|
-
return false;
|
|
1368
|
-
}
|
|
1369
|
-
const parts = str.replace("-", "").split(".");
|
|
1370
|
-
intPart = parts[0];
|
|
1371
|
-
fracPart = (_b = parts[1]) != null ? _b : "";
|
|
1372
|
-
} else {
|
|
1373
|
-
const s = v;
|
|
1374
|
-
const escapedSep = sep === "." ? "\\." : ",";
|
|
1375
|
-
const pattern = new RegExp(`^-?\\d+(?:${escapedSep}\\d+)?$`);
|
|
1376
|
-
if (!pattern.test(s)) {
|
|
1377
|
-
return false;
|
|
1378
|
-
}
|
|
1379
|
-
const parts = s.replace("-", "").split(sep);
|
|
1380
|
-
intPart = parts[0];
|
|
1381
|
-
fracPart = (_c = parts[1]) != null ? _c : "";
|
|
1082
|
+
};
|
|
1083
|
+
__name(_NotAcceptableError, "NotAcceptableError");
|
|
1084
|
+
var NotAcceptableError = _NotAcceptableError;
|
|
1085
|
+
var _ProxyAuthenticationRequiredError = class _ProxyAuthenticationRequiredError extends FreshError {
|
|
1086
|
+
constructor(detail, options) {
|
|
1087
|
+
super(HttpStatus.PROXY_AUTHENTICATION_REQUIRED, "not-authenticated", detail, options);
|
|
1382
1088
|
}
|
|
1383
|
-
|
|
1384
|
-
|
|
1089
|
+
};
|
|
1090
|
+
__name(_ProxyAuthenticationRequiredError, "ProxyAuthenticationRequiredError");
|
|
1091
|
+
var ProxyAuthenticationRequiredError = _ProxyAuthenticationRequiredError;
|
|
1092
|
+
var _RequestTimeoutError = class _RequestTimeoutError extends FreshError {
|
|
1093
|
+
constructor(detail, options) {
|
|
1094
|
+
super(HttpStatus.REQUEST_TIMEOUT, "error", detail, options);
|
|
1385
1095
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
if (!enumObj) {
|
|
1393
|
-
return typeof v === "string" || typeof v === "number";
|
|
1096
|
+
};
|
|
1097
|
+
__name(_RequestTimeoutError, "RequestTimeoutError");
|
|
1098
|
+
var RequestTimeoutError = _RequestTimeoutError;
|
|
1099
|
+
var _ConflictError = class _ConflictError extends FreshError {
|
|
1100
|
+
constructor(detail, options) {
|
|
1101
|
+
super(HttpStatus.CONFLICT, "error", detail, options);
|
|
1394
1102
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
function isObject(v) {
|
|
1402
|
-
return typeof v === "object" && v !== null;
|
|
1403
|
-
}
|
|
1404
|
-
__name(isObject, "isObject");
|
|
1405
|
-
function hasOwn(obj, key) {
|
|
1406
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
1407
|
-
}
|
|
1408
|
-
__name(hasOwn, "hasOwn");
|
|
1409
|
-
|
|
1410
|
-
// src/common/typeguards/primitives.ts
|
|
1411
|
-
function isNumber(v) {
|
|
1412
|
-
return typeof v === "number" && Number.isFinite(v);
|
|
1413
|
-
}
|
|
1414
|
-
__name(isNumber, "isNumber");
|
|
1415
|
-
function isString(v) {
|
|
1416
|
-
return typeof v === "string";
|
|
1417
|
-
}
|
|
1418
|
-
__name(isString, "isString");
|
|
1419
|
-
function isFlag01(v) {
|
|
1420
|
-
return v === 0 || v === 1;
|
|
1421
|
-
}
|
|
1422
|
-
__name(isFlag01, "isFlag01");
|
|
1423
|
-
function isNumberInRange(v, min, max, options) {
|
|
1424
|
-
var _a, _b;
|
|
1425
|
-
if (!isNumber(v)) {
|
|
1426
|
-
return false;
|
|
1103
|
+
};
|
|
1104
|
+
__name(_ConflictError, "ConflictError");
|
|
1105
|
+
var ConflictError = _ConflictError;
|
|
1106
|
+
var _GoneError = class _GoneError extends FreshError {
|
|
1107
|
+
constructor(detail, options) {
|
|
1108
|
+
super(HttpStatus.GONE, "error", detail, options);
|
|
1427
1109
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1110
|
+
};
|
|
1111
|
+
__name(_GoneError, "GoneError");
|
|
1112
|
+
var GoneError = _GoneError;
|
|
1113
|
+
var _LengthRequiredError = class _LengthRequiredError extends FreshError {
|
|
1114
|
+
constructor(detail, options) {
|
|
1115
|
+
super(HttpStatus.LENGTH_REQUIRED, "error", detail, options);
|
|
1432
1116
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1117
|
+
};
|
|
1118
|
+
__name(_LengthRequiredError, "LengthRequiredError");
|
|
1119
|
+
var LengthRequiredError = _LengthRequiredError;
|
|
1120
|
+
var _PreconditionFailedError = class _PreconditionFailedError extends FreshError {
|
|
1121
|
+
constructor(detail, options) {
|
|
1122
|
+
super(HttpStatus.PRECONDITION_FAILED, "error", detail, options);
|
|
1435
1123
|
}
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
var
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
async function runWithConcurrency(items, concurrency, worker) {
|
|
1443
|
-
const queue = [
|
|
1444
|
-
...items
|
|
1445
|
-
];
|
|
1446
|
-
const runNext = /* @__PURE__ */ __name(async () => {
|
|
1447
|
-
const item = queue.shift();
|
|
1448
|
-
if (!item) {
|
|
1449
|
-
return;
|
|
1450
|
-
}
|
|
1451
|
-
await worker(item);
|
|
1452
|
-
await runNext();
|
|
1453
|
-
}, "runNext");
|
|
1454
|
-
await Promise.all(Array.from({
|
|
1455
|
-
length: Math.min(concurrency, items.length)
|
|
1456
|
-
}, runNext));
|
|
1457
|
-
}
|
|
1458
|
-
__name(runWithConcurrency, "runWithConcurrency");
|
|
1459
|
-
|
|
1460
|
-
// src/common/utils/id-path-param-resolver.utils.ts
|
|
1461
|
-
function resolvePathParameterId(id) {
|
|
1462
|
-
return /^\d+$/.test(id) ? parseInt(id, 10) : id;
|
|
1463
|
-
}
|
|
1464
|
-
__name(resolvePathParameterId, "resolvePathParameterId");
|
|
1465
|
-
|
|
1466
|
-
// src/common/utils/is-cron-valid.ts
|
|
1467
|
-
function isValidCron(expr) {
|
|
1468
|
-
const parts = expr.trim().split(/\s+/);
|
|
1469
|
-
if (parts.length < 5 || parts.length > 6) {
|
|
1470
|
-
return false;
|
|
1124
|
+
};
|
|
1125
|
+
__name(_PreconditionFailedError, "PreconditionFailedError");
|
|
1126
|
+
var PreconditionFailedError = _PreconditionFailedError;
|
|
1127
|
+
var _PayloadTooLargeError = class _PayloadTooLargeError extends FreshError {
|
|
1128
|
+
constructor(detail, options) {
|
|
1129
|
+
super(HttpStatus.PAYLOAD_TOO_LARGE, "error", detail, options);
|
|
1471
1130
|
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
function buildPatch(data, keys, transforms) {
|
|
1479
|
-
const patch = {};
|
|
1480
|
-
for (const k of keys) {
|
|
1481
|
-
const value = data[k];
|
|
1482
|
-
if (value === void 0) {
|
|
1483
|
-
continue;
|
|
1484
|
-
}
|
|
1485
|
-
patch[k] = (transforms == null ? void 0 : transforms[k]) ? transforms[k](value) : value;
|
|
1131
|
+
};
|
|
1132
|
+
__name(_PayloadTooLargeError, "PayloadTooLargeError");
|
|
1133
|
+
var PayloadTooLargeError = _PayloadTooLargeError;
|
|
1134
|
+
var _UriTooLongError = class _UriTooLongError extends FreshError {
|
|
1135
|
+
constructor(detail, options) {
|
|
1136
|
+
super(HttpStatus.URI_TOO_LONG, "error", detail, options);
|
|
1486
1137
|
}
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
var _FreshJob = class _FreshJob extends Singleton {
|
|
1494
|
-
/**
|
|
1495
|
-
* Creates and optionally schedules a singleton cron job.
|
|
1496
|
-
*
|
|
1497
|
-
* @param jobName - Logical name of the job (used in logs and errors).
|
|
1498
|
-
* @param cronExpression - Cron expression consisting of numeric fields only.
|
|
1499
|
-
* Example: `0 5 * * 4`
|
|
1500
|
-
* The timezone `"Europe/Prague"` is applied automatically.
|
|
1501
|
-
*
|
|
1502
|
-
* @param jobEnabled - Whether the job should be scheduled immediately.
|
|
1503
|
-
* If `false`, the instance exists but no cron trigger is registered.
|
|
1504
|
-
*
|
|
1505
|
-
* @throws Error If the cron expression is invalid.
|
|
1506
|
-
* @throws Error If the job cannot be scheduled.
|
|
1507
|
-
*/
|
|
1508
|
-
constructor(jobName, cronExpression, jobEnabled) {
|
|
1509
|
-
super(false);
|
|
1510
|
-
/** Human-readable job identifier (used for logs and errors). */
|
|
1511
|
-
__publicField(this, "_jobName");
|
|
1512
|
-
/**
|
|
1513
|
-
* Cron expression defining when the job runs.
|
|
1514
|
-
*
|
|
1515
|
-
* Must contain numeric cron fields only.
|
|
1516
|
-
* Example: `0 5 * * 4`
|
|
1517
|
-
*
|
|
1518
|
-
* Timezone is always forced to `"Europe/Prague"`.
|
|
1519
|
-
* If you need another timezone, this class is not your friend.
|
|
1520
|
-
*/
|
|
1521
|
-
__publicField(this, "_cronExpression");
|
|
1522
|
-
/** Scheduled job instance, or `null` if the job is disabled. */
|
|
1523
|
-
__publicField(this, "_job", null);
|
|
1524
|
-
this._jobName = jobName;
|
|
1525
|
-
if (!isValidCron(cronExpression)) {
|
|
1526
|
-
throw new Error(`Job ${this.jobName} cannot be constructed with invalid cron: "${cronExpression}"`);
|
|
1527
|
-
}
|
|
1528
|
-
this._cronExpression = cronExpression;
|
|
1529
|
-
if (jobEnabled) {
|
|
1530
|
-
this._job = scheduleJob({
|
|
1531
|
-
rule: this._cronExpression,
|
|
1532
|
-
tz: "Europe/Prague"
|
|
1533
|
-
}, async () => {
|
|
1534
|
-
await this.invoke();
|
|
1535
|
-
});
|
|
1536
|
-
if (!this._job) {
|
|
1537
|
-
throw new Error(`Job ${this._jobName} could not be scheduled`);
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
this.onInit();
|
|
1138
|
+
};
|
|
1139
|
+
__name(_UriTooLongError, "UriTooLongError");
|
|
1140
|
+
var UriTooLongError = _UriTooLongError;
|
|
1141
|
+
var _UnsupportedMediaTypeError = class _UnsupportedMediaTypeError extends FreshError {
|
|
1142
|
+
constructor(detail, options) {
|
|
1143
|
+
super(HttpStatus.UNSUPPORTED_MEDIA_TYPE, "error", detail, options);
|
|
1541
1144
|
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
* @param rescheduled - Indicates whether the job was reconfigured
|
|
1549
|
-
* after initial creation.
|
|
1550
|
-
*/
|
|
1551
|
-
onInit(rescheduled) {
|
|
1552
|
-
console.log(`Job ${this.jobName} ${rescheduled ? "rescheduled" : "initialized"} with cron rule: "${this.cronExpression}"`);
|
|
1145
|
+
};
|
|
1146
|
+
__name(_UnsupportedMediaTypeError, "UnsupportedMediaTypeError");
|
|
1147
|
+
var UnsupportedMediaTypeError = _UnsupportedMediaTypeError;
|
|
1148
|
+
var _RangeNotSatisfiableError = class _RangeNotSatisfiableError extends FreshError {
|
|
1149
|
+
constructor(detail, options) {
|
|
1150
|
+
super(HttpStatus.RANGE_NOT_SATISFIABLE, "error", detail, options);
|
|
1553
1151
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1152
|
+
};
|
|
1153
|
+
__name(_RangeNotSatisfiableError, "RangeNotSatisfiableError");
|
|
1154
|
+
var RangeNotSatisfiableError = _RangeNotSatisfiableError;
|
|
1155
|
+
var _ExpectationFailedError = class _ExpectationFailedError extends FreshError {
|
|
1156
|
+
constructor(detail, options) {
|
|
1157
|
+
super(HttpStatus.EXPECTATION_FAILED, "error", detail, options);
|
|
1557
1158
|
}
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1159
|
+
};
|
|
1160
|
+
__name(_ExpectationFailedError, "ExpectationFailedError");
|
|
1161
|
+
var ExpectationFailedError = _ExpectationFailedError;
|
|
1162
|
+
var _ImATeapotError = class _ImATeapotError extends FreshError {
|
|
1163
|
+
constructor(detail, options) {
|
|
1164
|
+
super(HttpStatus.IM_A_TEAPOT, "error", detail, options);
|
|
1561
1165
|
}
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1166
|
+
};
|
|
1167
|
+
__name(_ImATeapotError, "ImATeapotError");
|
|
1168
|
+
var ImATeapotError = _ImATeapotError;
|
|
1169
|
+
var _MisdirectedRequestError = class _MisdirectedRequestError extends FreshError {
|
|
1170
|
+
constructor(detail, options) {
|
|
1171
|
+
super(HttpStatus.MISDIRECTED_REQUEST, "error", detail, options);
|
|
1565
1172
|
}
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
throw new Error(`Job ${this._jobName} cannot be re-scheduled with invalid cron: "${value}"`);
|
|
1573
|
-
}
|
|
1574
|
-
this._cronExpression = value;
|
|
1173
|
+
};
|
|
1174
|
+
__name(_MisdirectedRequestError, "MisdirectedRequestError");
|
|
1175
|
+
var MisdirectedRequestError = _MisdirectedRequestError;
|
|
1176
|
+
var _UnprocessableEntityError = class _UnprocessableEntityError extends FreshError {
|
|
1177
|
+
constructor(detail, options) {
|
|
1178
|
+
super(HttpStatus.UNPROCESSABLE_ENTITY, "validation-error", detail, options);
|
|
1575
1179
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1180
|
+
};
|
|
1181
|
+
__name(_UnprocessableEntityError, "UnprocessableEntityError");
|
|
1182
|
+
var UnprocessableEntityError = _UnprocessableEntityError;
|
|
1183
|
+
var _LockedError = class _LockedError extends FreshError {
|
|
1184
|
+
constructor(detail, options) {
|
|
1185
|
+
super(HttpStatus.LOCKED, "error", detail, options);
|
|
1579
1186
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1187
|
+
};
|
|
1188
|
+
__name(_LockedError, "LockedError");
|
|
1189
|
+
var LockedError = _LockedError;
|
|
1190
|
+
var _FailedDependencyError = class _FailedDependencyError extends FreshError {
|
|
1191
|
+
constructor(detail, options) {
|
|
1192
|
+
super(HttpStatus.FAILED_DEPENDENCY, "error", detail, options);
|
|
1583
1193
|
}
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
if (this._job) {
|
|
1591
|
-
const rescheduleSuccess = this._job.reschedule({
|
|
1592
|
-
rule: this._cronExpression,
|
|
1593
|
-
tz: "Europe/Prague"
|
|
1594
|
-
});
|
|
1595
|
-
if (!rescheduleSuccess) {
|
|
1596
|
-
throw new Error(`Job ${this._jobName} could not be re-scheduled`);
|
|
1597
|
-
} else {
|
|
1598
|
-
this.onInit(true);
|
|
1599
|
-
}
|
|
1600
|
-
result = rescheduleSuccess;
|
|
1601
|
-
}
|
|
1602
|
-
return result;
|
|
1194
|
+
};
|
|
1195
|
+
__name(_FailedDependencyError, "FailedDependencyError");
|
|
1196
|
+
var FailedDependencyError = _FailedDependencyError;
|
|
1197
|
+
var _TooEarlyError = class _TooEarlyError extends FreshError {
|
|
1198
|
+
constructor(detail, options) {
|
|
1199
|
+
super(HttpStatus.TOO_EARLY, "error", detail, options);
|
|
1603
1200
|
}
|
|
1604
1201
|
};
|
|
1605
|
-
__name(
|
|
1606
|
-
var
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
constructor(statusCode, status, detail) {
|
|
1611
|
-
super();
|
|
1612
|
-
__publicField(this, "_statusCode");
|
|
1613
|
-
__publicField(this, "_statusDto");
|
|
1614
|
-
this._statusCode = statusCode;
|
|
1615
|
-
this._statusDto = new StatusDto(status, detail);
|
|
1202
|
+
__name(_TooEarlyError, "TooEarlyError");
|
|
1203
|
+
var TooEarlyError = _TooEarlyError;
|
|
1204
|
+
var _UpgradeRequiredError = class _UpgradeRequiredError extends FreshError {
|
|
1205
|
+
constructor(detail, options) {
|
|
1206
|
+
super(HttpStatus.UPGRADE_REQUIRED, "error", detail, options);
|
|
1616
1207
|
}
|
|
1617
|
-
|
|
1618
|
-
|
|
1208
|
+
};
|
|
1209
|
+
__name(_UpgradeRequiredError, "UpgradeRequiredError");
|
|
1210
|
+
var UpgradeRequiredError = _UpgradeRequiredError;
|
|
1211
|
+
var _PreconditionRequiredError = class _PreconditionRequiredError extends FreshError {
|
|
1212
|
+
constructor(detail, options) {
|
|
1213
|
+
super(HttpStatus.PRECONDITION_REQUIRED, "error", detail, options);
|
|
1619
1214
|
}
|
|
1620
|
-
|
|
1621
|
-
|
|
1215
|
+
};
|
|
1216
|
+
__name(_PreconditionRequiredError, "PreconditionRequiredError");
|
|
1217
|
+
var PreconditionRequiredError = _PreconditionRequiredError;
|
|
1218
|
+
var _TooManyRequestsError = class _TooManyRequestsError extends FreshError {
|
|
1219
|
+
constructor(detail, options) {
|
|
1220
|
+
super(HttpStatus.TOO_MANY_REQUESTS, "error", detail, options);
|
|
1622
1221
|
}
|
|
1623
1222
|
};
|
|
1624
|
-
__name(
|
|
1625
|
-
var
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
constructor(code, message) {
|
|
1630
|
-
super(message);
|
|
1631
|
-
__publicField(this, "code");
|
|
1632
|
-
this.code = code;
|
|
1633
|
-
this.name = "BusinessWarning";
|
|
1223
|
+
__name(_TooManyRequestsError, "TooManyRequestsError");
|
|
1224
|
+
var TooManyRequestsError = _TooManyRequestsError;
|
|
1225
|
+
var _RequestHeaderFieldsTooLargeError = class _RequestHeaderFieldsTooLargeError extends FreshError {
|
|
1226
|
+
constructor(detail, options) {
|
|
1227
|
+
super(HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE, "error", detail, options);
|
|
1634
1228
|
}
|
|
1635
1229
|
};
|
|
1636
|
-
__name(
|
|
1637
|
-
var
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
constructor(statusCode, status, detail, options) {
|
|
1642
|
-
super(detail != null ? detail : status);
|
|
1643
|
-
/** HTTP status code sent in the response. */
|
|
1644
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1645
|
-
__publicField(this, "statusCode");
|
|
1646
|
-
/** Structured response body describing the error. */
|
|
1647
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1648
|
-
__publicField(this, "statusDto");
|
|
1649
|
-
this.name = this.constructor.name;
|
|
1650
|
-
if ((options == null ? void 0 : options.cause) !== void 0) {
|
|
1651
|
-
this.cause = options.cause;
|
|
1652
|
-
}
|
|
1653
|
-
this.statusCode = statusCode;
|
|
1654
|
-
this.statusDto = new StatusDto(status, detail);
|
|
1230
|
+
__name(_RequestHeaderFieldsTooLargeError, "RequestHeaderFieldsTooLargeError");
|
|
1231
|
+
var RequestHeaderFieldsTooLargeError = _RequestHeaderFieldsTooLargeError;
|
|
1232
|
+
var _UnavailableForLegalReasonsError = class _UnavailableForLegalReasonsError extends FreshError {
|
|
1233
|
+
constructor(detail, options) {
|
|
1234
|
+
super(HttpStatus.UNAVAILABLE_FOR_LEGAL_REASONS, "error", detail, options);
|
|
1655
1235
|
}
|
|
1656
1236
|
};
|
|
1657
|
-
__name(
|
|
1658
|
-
var
|
|
1659
|
-
|
|
1660
|
-
// src/core/errors/errors.ts
|
|
1661
|
-
var _BadRequestError = class _BadRequestError extends FreshError {
|
|
1237
|
+
__name(_UnavailableForLegalReasonsError, "UnavailableForLegalReasonsError");
|
|
1238
|
+
var UnavailableForLegalReasonsError = _UnavailableForLegalReasonsError;
|
|
1239
|
+
var _InternalServerError = class _InternalServerError extends FreshError {
|
|
1662
1240
|
constructor(detail, options) {
|
|
1663
|
-
super(HttpStatus.
|
|
1241
|
+
super(HttpStatus.INTERNAL_SERVER_ERROR, "internal-server-error", detail, options);
|
|
1664
1242
|
}
|
|
1665
1243
|
};
|
|
1666
|
-
__name(
|
|
1667
|
-
var
|
|
1668
|
-
var
|
|
1244
|
+
__name(_InternalServerError, "InternalServerError");
|
|
1245
|
+
var InternalServerError = _InternalServerError;
|
|
1246
|
+
var _NotImplementedError = class _NotImplementedError extends FreshError {
|
|
1669
1247
|
constructor(detail, options) {
|
|
1670
|
-
super(HttpStatus.
|
|
1248
|
+
super(HttpStatus.NOT_IMPLEMENTED, "internal-server-error", detail, options);
|
|
1671
1249
|
}
|
|
1672
1250
|
};
|
|
1673
|
-
__name(
|
|
1674
|
-
var
|
|
1675
|
-
var
|
|
1251
|
+
__name(_NotImplementedError, "NotImplementedError");
|
|
1252
|
+
var NotImplementedError = _NotImplementedError;
|
|
1253
|
+
var _BadGatewayError = class _BadGatewayError extends FreshError {
|
|
1676
1254
|
constructor(detail, options) {
|
|
1677
|
-
super(HttpStatus.
|
|
1255
|
+
super(HttpStatus.BAD_GATEWAY, "internal-server-error", detail, options);
|
|
1678
1256
|
}
|
|
1679
1257
|
};
|
|
1680
|
-
__name(
|
|
1681
|
-
var
|
|
1682
|
-
var
|
|
1258
|
+
__name(_BadGatewayError, "BadGatewayError");
|
|
1259
|
+
var BadGatewayError = _BadGatewayError;
|
|
1260
|
+
var _ServiceUnavailableError = class _ServiceUnavailableError extends FreshError {
|
|
1683
1261
|
constructor(detail, options) {
|
|
1684
|
-
super(HttpStatus.
|
|
1262
|
+
super(HttpStatus.SERVICE_UNAVAILABLE, "internal-server-error", detail, options);
|
|
1685
1263
|
}
|
|
1686
1264
|
};
|
|
1687
|
-
__name(
|
|
1688
|
-
var
|
|
1689
|
-
var
|
|
1265
|
+
__name(_ServiceUnavailableError, "ServiceUnavailableError");
|
|
1266
|
+
var ServiceUnavailableError = _ServiceUnavailableError;
|
|
1267
|
+
var _GatewayTimeoutError = class _GatewayTimeoutError extends FreshError {
|
|
1690
1268
|
constructor(detail, options) {
|
|
1691
|
-
super(HttpStatus.
|
|
1269
|
+
super(HttpStatus.GATEWAY_TIMEOUT, "internal-server-error", detail, options);
|
|
1692
1270
|
}
|
|
1693
1271
|
};
|
|
1694
|
-
__name(
|
|
1695
|
-
var
|
|
1696
|
-
var
|
|
1272
|
+
__name(_GatewayTimeoutError, "GatewayTimeoutError");
|
|
1273
|
+
var GatewayTimeoutError = _GatewayTimeoutError;
|
|
1274
|
+
var _HttpVersionNotSupportedError = class _HttpVersionNotSupportedError extends FreshError {
|
|
1697
1275
|
constructor(detail, options) {
|
|
1698
|
-
super(HttpStatus.
|
|
1276
|
+
super(HttpStatus.HTTP_VERSION_NOT_SUPPORTED, "internal-server-error", detail, options);
|
|
1699
1277
|
}
|
|
1700
1278
|
};
|
|
1701
|
-
__name(
|
|
1702
|
-
var
|
|
1703
|
-
var
|
|
1279
|
+
__name(_HttpVersionNotSupportedError, "HttpVersionNotSupportedError");
|
|
1280
|
+
var HttpVersionNotSupportedError = _HttpVersionNotSupportedError;
|
|
1281
|
+
var _VariantAlsoNegotiatesError = class _VariantAlsoNegotiatesError extends FreshError {
|
|
1704
1282
|
constructor(detail, options) {
|
|
1705
|
-
super(HttpStatus.
|
|
1283
|
+
super(HttpStatus.VARIANT_ALSO_NEGOTIATES, "internal-server-error", detail, options);
|
|
1706
1284
|
}
|
|
1707
1285
|
};
|
|
1708
|
-
__name(
|
|
1709
|
-
var
|
|
1710
|
-
var
|
|
1286
|
+
__name(_VariantAlsoNegotiatesError, "VariantAlsoNegotiatesError");
|
|
1287
|
+
var VariantAlsoNegotiatesError = _VariantAlsoNegotiatesError;
|
|
1288
|
+
var _InsufficientStorageError = class _InsufficientStorageError extends FreshError {
|
|
1711
1289
|
constructor(detail, options) {
|
|
1712
|
-
super(HttpStatus.
|
|
1290
|
+
super(HttpStatus.INSUFFICIENT_STORAGE, "internal-server-error", detail, options);
|
|
1713
1291
|
}
|
|
1714
1292
|
};
|
|
1715
|
-
__name(
|
|
1716
|
-
var
|
|
1717
|
-
var
|
|
1293
|
+
__name(_InsufficientStorageError, "InsufficientStorageError");
|
|
1294
|
+
var InsufficientStorageError = _InsufficientStorageError;
|
|
1295
|
+
var _LoopDetectedError = class _LoopDetectedError extends FreshError {
|
|
1718
1296
|
constructor(detail, options) {
|
|
1719
|
-
super(HttpStatus.
|
|
1297
|
+
super(HttpStatus.LOOP_DETECTED, "internal-server-error", detail, options);
|
|
1720
1298
|
}
|
|
1721
1299
|
};
|
|
1722
|
-
__name(
|
|
1723
|
-
var
|
|
1724
|
-
var
|
|
1300
|
+
__name(_LoopDetectedError, "LoopDetectedError");
|
|
1301
|
+
var LoopDetectedError = _LoopDetectedError;
|
|
1302
|
+
var _NotExtendedError = class _NotExtendedError extends FreshError {
|
|
1725
1303
|
constructor(detail, options) {
|
|
1726
|
-
super(HttpStatus.
|
|
1304
|
+
super(HttpStatus.NOT_EXTENDED, "internal-server-error", detail, options);
|
|
1305
|
+
}
|
|
1306
|
+
};
|
|
1307
|
+
__name(_NotExtendedError, "NotExtendedError");
|
|
1308
|
+
var NotExtendedError = _NotExtendedError;
|
|
1309
|
+
var _NetworkAuthenticationRequiredError = class _NetworkAuthenticationRequiredError extends FreshError {
|
|
1310
|
+
constructor(detail, options) {
|
|
1311
|
+
super(HttpStatus.NETWORK_AUTHENTICATION_REQUIRED, "internal-server-error", detail, options);
|
|
1312
|
+
}
|
|
1313
|
+
};
|
|
1314
|
+
__name(_NetworkAuthenticationRequiredError, "NetworkAuthenticationRequiredError");
|
|
1315
|
+
var NetworkAuthenticationRequiredError = _NetworkAuthenticationRequiredError;
|
|
1316
|
+
|
|
1317
|
+
// src/core/data-helper.ts
|
|
1318
|
+
var _DataHelper = class _DataHelper {
|
|
1319
|
+
constructor(startDataRetrieve = true, deviceIds) {
|
|
1320
|
+
__publicField(this, "_data");
|
|
1321
|
+
__publicField(this, "_dataPromise", null);
|
|
1322
|
+
__publicField(this, "deviceIds");
|
|
1323
|
+
this.deviceIds = deviceIds;
|
|
1324
|
+
if (startDataRetrieve) {
|
|
1325
|
+
this._dataPromise = this.startDataRetrieval();
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
get data() {
|
|
1329
|
+
return this._data;
|
|
1330
|
+
}
|
|
1331
|
+
set data(value) {
|
|
1332
|
+
this._data = value;
|
|
1333
|
+
}
|
|
1334
|
+
get dataPromise() {
|
|
1335
|
+
return this._dataPromise;
|
|
1336
|
+
}
|
|
1337
|
+
set dataPromise(value) {
|
|
1338
|
+
this._dataPromise = value;
|
|
1339
|
+
}
|
|
1340
|
+
async getData() {
|
|
1341
|
+
if (this._dataPromise) {
|
|
1342
|
+
return await this._dataPromise;
|
|
1343
|
+
}
|
|
1344
|
+
if (this._data === void 0) {
|
|
1345
|
+
this._dataPromise = this.startDataRetrieval();
|
|
1346
|
+
return this._dataPromise;
|
|
1347
|
+
}
|
|
1348
|
+
return this._data;
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
__name(_DataHelper, "DataHelper");
|
|
1352
|
+
var DataHelper = _DataHelper;
|
|
1353
|
+
|
|
1354
|
+
// src/common/pagination/find-options/pagination.ts
|
|
1355
|
+
function buildPagination(page, limit) {
|
|
1356
|
+
if (page === void 0 && limit === void 0) {
|
|
1357
|
+
return void 0;
|
|
1727
1358
|
}
|
|
1359
|
+
if (page !== void 0 && page < 1 || limit !== void 0 && limit < 0) {
|
|
1360
|
+
throw new ApiError(HttpStatus.BAD_REQUEST, "validation-error", "Pagination parameters cannot be negative");
|
|
1361
|
+
}
|
|
1362
|
+
const p = page != null ? page : 1;
|
|
1363
|
+
const l = limit != null ? limit : 1e3;
|
|
1364
|
+
return {
|
|
1365
|
+
page: p,
|
|
1366
|
+
limit: l,
|
|
1367
|
+
skip: (p - 1) * l
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
__name(buildPagination, "buildPagination");
|
|
1371
|
+
|
|
1372
|
+
// src/common/pagination/constructors.ts
|
|
1373
|
+
function constructTypeormPagination(params) {
|
|
1374
|
+
return {
|
|
1375
|
+
take: params.limit,
|
|
1376
|
+
skip: params.skip
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
__name(constructTypeormPagination, "constructTypeormPagination");
|
|
1380
|
+
function parsePaginationFromURL(searchParams) {
|
|
1381
|
+
var _a, _b;
|
|
1382
|
+
const page = Math.max(1, parseInt((_a = searchParams.get("page")) != null ? _a : "1", 10));
|
|
1383
|
+
const limit = Math.min(100, Math.max(1, parseInt((_b = searchParams.get("limit")) != null ? _b : "20", 10)));
|
|
1384
|
+
return {
|
|
1385
|
+
page,
|
|
1386
|
+
limit,
|
|
1387
|
+
skip: (page - 1) * limit
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
__name(parsePaginationFromURL, "parsePaginationFromURL");
|
|
1391
|
+
|
|
1392
|
+
// src/common/pagination/pagination-meta.ts
|
|
1393
|
+
function getPaginationMeta(total, page, limit) {
|
|
1394
|
+
return {
|
|
1395
|
+
total,
|
|
1396
|
+
page,
|
|
1397
|
+
limit,
|
|
1398
|
+
totalPages: Math.ceil(total / limit)
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
__name(getPaginationMeta, "getPaginationMeta");
|
|
1402
|
+
|
|
1403
|
+
// src/common/pagination/pagination-params.ts
|
|
1404
|
+
function getPaginationParams(params) {
|
|
1405
|
+
return {
|
|
1406
|
+
...DEFAULT_PAGINATION_PARAMS,
|
|
1407
|
+
...params
|
|
1408
|
+
};
|
|
1409
|
+
}
|
|
1410
|
+
__name(getPaginationParams, "getPaginationParams");
|
|
1411
|
+
var DEFAULT_PAGINATION_PARAMS = {
|
|
1412
|
+
page: 1,
|
|
1413
|
+
limit: 1e3,
|
|
1414
|
+
skip: 0
|
|
1728
1415
|
};
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1416
|
+
|
|
1417
|
+
// src/common/pagination/scrapper.ts
|
|
1418
|
+
async function listAll(fetchPage, batchSize = 1e3) {
|
|
1419
|
+
const results = [];
|
|
1420
|
+
let page = 1;
|
|
1421
|
+
while (true) {
|
|
1422
|
+
const { data, meta } = await fetchPage({
|
|
1423
|
+
page,
|
|
1424
|
+
limit: batchSize,
|
|
1425
|
+
skip: (page - 1) * batchSize
|
|
1426
|
+
});
|
|
1427
|
+
results.push(...data);
|
|
1428
|
+
if (page >= meta.totalPages) {
|
|
1429
|
+
break;
|
|
1430
|
+
}
|
|
1431
|
+
page++;
|
|
1734
1432
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1433
|
+
return results;
|
|
1434
|
+
}
|
|
1435
|
+
__name(listAll, "listAll");
|
|
1436
|
+
|
|
1437
|
+
// src/common/promise-magic/deferred.ts
|
|
1438
|
+
function createDeferred() {
|
|
1439
|
+
let resolve;
|
|
1440
|
+
let reject;
|
|
1441
|
+
const promise = new Promise((res, rej) => {
|
|
1442
|
+
resolve = res;
|
|
1443
|
+
reject = rej;
|
|
1444
|
+
});
|
|
1445
|
+
return {
|
|
1446
|
+
promise,
|
|
1447
|
+
resolve,
|
|
1448
|
+
reject
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
__name(createDeferred, "createDeferred");
|
|
1452
|
+
|
|
1453
|
+
// src/common/promise-magic/single-promise-waiter.ts
|
|
1454
|
+
var _SinglePromiseWaiter = class _SinglePromiseWaiter {
|
|
1455
|
+
constructor() {
|
|
1456
|
+
__publicField(this, "_promise", null);
|
|
1741
1457
|
}
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
super(HttpStatus.PRECONDITION_FAILED, "error", detail, options);
|
|
1458
|
+
static getInstance() {
|
|
1459
|
+
if (!_SinglePromiseWaiter._instance) {
|
|
1460
|
+
_SinglePromiseWaiter._instance = new _SinglePromiseWaiter();
|
|
1461
|
+
}
|
|
1462
|
+
return _SinglePromiseWaiter._instance;
|
|
1748
1463
|
}
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
var PreconditionFailedError = _PreconditionFailedError;
|
|
1752
|
-
var _PayloadTooLargeError = class _PayloadTooLargeError extends FreshError {
|
|
1753
|
-
constructor(detail, options) {
|
|
1754
|
-
super(HttpStatus.PAYLOAD_TOO_LARGE, "error", detail, options);
|
|
1464
|
+
get promise() {
|
|
1465
|
+
return this._promise;
|
|
1755
1466
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1467
|
+
set promise(promise) {
|
|
1468
|
+
if (promise !== null) {
|
|
1469
|
+
this._promise = promise;
|
|
1470
|
+
this._promise.finally(() => {
|
|
1471
|
+
this._promise = null;
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1762
1474
|
}
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
var UriTooLongError = _UriTooLongError;
|
|
1766
|
-
var _UnsupportedMediaTypeError = class _UnsupportedMediaTypeError extends FreshError {
|
|
1767
|
-
constructor(detail, options) {
|
|
1768
|
-
super(HttpStatus.UNSUPPORTED_MEDIA_TYPE, "error", detail, options);
|
|
1475
|
+
get hasPromise() {
|
|
1476
|
+
return this._promise !== null;
|
|
1769
1477
|
}
|
|
1770
1478
|
};
|
|
1771
|
-
__name(
|
|
1772
|
-
|
|
1773
|
-
var
|
|
1774
|
-
|
|
1775
|
-
|
|
1479
|
+
__name(_SinglePromiseWaiter, "SinglePromiseWaiter");
|
|
1480
|
+
__publicField(_SinglePromiseWaiter, "_instance");
|
|
1481
|
+
var SinglePromiseWaiter = _SinglePromiseWaiter;
|
|
1482
|
+
|
|
1483
|
+
// src/common/schema/entities/category.entity.ts
|
|
1484
|
+
import { Entity } from "typeorm";
|
|
1485
|
+
|
|
1486
|
+
// src/database/entities/fresh-entity.ts
|
|
1487
|
+
import { BaseEntity, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, Column } from "typeorm";
|
|
1488
|
+
|
|
1489
|
+
// ../../node_modules/uuid/dist/esm/stringify.js
|
|
1490
|
+
var byteToHex = [];
|
|
1491
|
+
for (let i = 0; i < 256; ++i) {
|
|
1492
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
1493
|
+
}
|
|
1494
|
+
function unsafeStringify(arr, offset = 0) {
|
|
1495
|
+
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();
|
|
1496
|
+
}
|
|
1497
|
+
__name(unsafeStringify, "unsafeStringify");
|
|
1498
|
+
|
|
1499
|
+
// ../../node_modules/uuid/dist/esm/rng.js
|
|
1500
|
+
import { randomFillSync } from "crypto";
|
|
1501
|
+
var rnds8Pool = new Uint8Array(256);
|
|
1502
|
+
var poolPtr = rnds8Pool.length;
|
|
1503
|
+
function rng() {
|
|
1504
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
|
1505
|
+
randomFillSync(rnds8Pool);
|
|
1506
|
+
poolPtr = 0;
|
|
1776
1507
|
}
|
|
1508
|
+
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
1509
|
+
}
|
|
1510
|
+
__name(rng, "rng");
|
|
1511
|
+
|
|
1512
|
+
// ../../node_modules/uuid/dist/esm/native.js
|
|
1513
|
+
import { randomUUID } from "crypto";
|
|
1514
|
+
var native_default = {
|
|
1515
|
+
randomUUID
|
|
1777
1516
|
};
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1517
|
+
|
|
1518
|
+
// ../../node_modules/uuid/dist/esm/v4.js
|
|
1519
|
+
function v4(options, buf, offset) {
|
|
1520
|
+
var _a, _b, _c;
|
|
1521
|
+
if (native_default.randomUUID && !buf && !options) {
|
|
1522
|
+
return native_default.randomUUID();
|
|
1783
1523
|
}
|
|
1784
|
-
};
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
constructor(detail, options) {
|
|
1789
|
-
super(HttpStatus.IM_A_TEAPOT, "error", detail, options);
|
|
1524
|
+
options = options || {};
|
|
1525
|
+
const rnds = (_c = (_b = options.random) != null ? _b : (_a = options.rng) == null ? void 0 : _a.call(options)) != null ? _c : rng();
|
|
1526
|
+
if (rnds.length < 16) {
|
|
1527
|
+
throw new Error("Random bytes length must be >= 16");
|
|
1790
1528
|
}
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1529
|
+
rnds[6] = rnds[6] & 15 | 64;
|
|
1530
|
+
rnds[8] = rnds[8] & 63 | 128;
|
|
1531
|
+
if (buf) {
|
|
1532
|
+
offset = offset || 0;
|
|
1533
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
1534
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
1535
|
+
}
|
|
1536
|
+
for (let i = 0; i < 16; ++i) {
|
|
1537
|
+
buf[offset + i] = rnds[i];
|
|
1538
|
+
}
|
|
1539
|
+
return buf;
|
|
1797
1540
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
var
|
|
1802
|
-
|
|
1803
|
-
|
|
1541
|
+
return unsafeStringify(rnds);
|
|
1542
|
+
}
|
|
1543
|
+
__name(v4, "v4");
|
|
1544
|
+
var v4_default = v4;
|
|
1545
|
+
|
|
1546
|
+
// src/database/entities/fresh-entity.ts
|
|
1547
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
1548
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1549
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1550
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1551
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1552
|
+
}
|
|
1553
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
1554
|
+
function _ts_metadata(k, v) {
|
|
1555
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1556
|
+
}
|
|
1557
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
1558
|
+
var _FreshEntity = class _FreshEntity extends BaseEntity {
|
|
1559
|
+
/** After manual construction `id` is irrelevant. Refer to `uuid` only, because that will be inserted into DB */
|
|
1560
|
+
constructor() {
|
|
1561
|
+
super();
|
|
1562
|
+
__publicField(this, "id");
|
|
1563
|
+
__publicField(this, "uuid");
|
|
1564
|
+
__publicField(this, "created_at");
|
|
1565
|
+
__publicField(this, "updated_at");
|
|
1566
|
+
// for soft delete methods by typeorm
|
|
1567
|
+
__publicField(this, "deleted_at");
|
|
1568
|
+
this.id = 0;
|
|
1569
|
+
this.uuid = v4_default();
|
|
1570
|
+
const newDate = /* @__PURE__ */ new Date();
|
|
1571
|
+
this.created_at = newDate;
|
|
1572
|
+
this.updated_at = newDate;
|
|
1573
|
+
this.deleted_at = null;
|
|
1804
1574
|
}
|
|
1805
1575
|
};
|
|
1806
|
-
__name(
|
|
1807
|
-
var
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1576
|
+
__name(_FreshEntity, "FreshEntity");
|
|
1577
|
+
var FreshEntity = _FreshEntity;
|
|
1578
|
+
_ts_decorate([
|
|
1579
|
+
PrimaryGeneratedColumn("increment"),
|
|
1580
|
+
_ts_metadata("design:type", Number)
|
|
1581
|
+
], FreshEntity.prototype, "id", void 0);
|
|
1582
|
+
_ts_decorate([
|
|
1583
|
+
Index({
|
|
1584
|
+
unique: true
|
|
1585
|
+
}),
|
|
1586
|
+
Column({
|
|
1587
|
+
type: "uuid",
|
|
1588
|
+
default: /* @__PURE__ */ __name(() => "gen_random_uuid()", "default")
|
|
1589
|
+
}),
|
|
1590
|
+
_ts_metadata("design:type", String)
|
|
1591
|
+
], FreshEntity.prototype, "uuid", void 0);
|
|
1592
|
+
_ts_decorate([
|
|
1593
|
+
CreateDateColumn({
|
|
1594
|
+
type: "timestamptz"
|
|
1595
|
+
}),
|
|
1596
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
1597
|
+
], FreshEntity.prototype, "created_at", void 0);
|
|
1598
|
+
_ts_decorate([
|
|
1599
|
+
UpdateDateColumn({
|
|
1600
|
+
type: "timestamptz"
|
|
1601
|
+
}),
|
|
1602
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
1603
|
+
], FreshEntity.prototype, "updated_at", void 0);
|
|
1604
|
+
_ts_decorate([
|
|
1605
|
+
DeleteDateColumn({
|
|
1606
|
+
type: "timestamptz",
|
|
1607
|
+
nullable: true
|
|
1608
|
+
}),
|
|
1609
|
+
_ts_metadata("design:type", Object)
|
|
1610
|
+
], FreshEntity.prototype, "deleted_at", void 0);
|
|
1611
|
+
|
|
1612
|
+
// src/database/entities/fresh-hyper-entity.ts
|
|
1613
|
+
import { BaseEntity as BaseEntity2, PrimaryColumn } from "typeorm";
|
|
1614
|
+
|
|
1615
|
+
// src/database/decorators/timestamp-column.ts
|
|
1616
|
+
import { Column as Column2 } from "typeorm";
|
|
1617
|
+
function TimestampColumn(options = {}) {
|
|
1618
|
+
const defaultOptions = {
|
|
1619
|
+
type: "timestamptz",
|
|
1620
|
+
nullable: false,
|
|
1621
|
+
default: /* @__PURE__ */ __name(() => "CURRENT_TIMESTAMP", "default"),
|
|
1622
|
+
...options
|
|
1623
|
+
};
|
|
1624
|
+
return Column2(defaultOptions);
|
|
1625
|
+
}
|
|
1626
|
+
__name(TimestampColumn, "TimestampColumn");
|
|
1627
|
+
|
|
1628
|
+
// src/database/entities/fresh-hyper-entity.ts
|
|
1629
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
1630
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1631
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1632
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1633
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1634
|
+
}
|
|
1635
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
1636
|
+
function _ts_metadata2(k, v) {
|
|
1637
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1638
|
+
}
|
|
1639
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
1640
|
+
var _FreshHyperEntity = class _FreshHyperEntity extends BaseEntity2 {
|
|
1641
|
+
/** After manual construction `id` is irrelevant */
|
|
1642
|
+
constructor(timestamp) {
|
|
1643
|
+
super();
|
|
1644
|
+
// input timestamp as PK
|
|
1645
|
+
__publicField(this, "timestamp");
|
|
1646
|
+
// just info column about time of insert
|
|
1647
|
+
__publicField(this, "created_at");
|
|
1648
|
+
this.timestamp = timestamp != null ? timestamp : /* @__PURE__ */ new Date();
|
|
1649
|
+
this.created_at = /* @__PURE__ */ new Date();
|
|
1811
1650
|
}
|
|
1812
1651
|
};
|
|
1813
|
-
__name(
|
|
1814
|
-
var
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1652
|
+
__name(_FreshHyperEntity, "FreshHyperEntity");
|
|
1653
|
+
var FreshHyperEntity = _FreshHyperEntity;
|
|
1654
|
+
_ts_decorate2([
|
|
1655
|
+
PrimaryColumn({
|
|
1656
|
+
type: "timestamptz"
|
|
1657
|
+
}),
|
|
1658
|
+
_ts_metadata2("design:type", typeof Date === "undefined" ? Object : Date)
|
|
1659
|
+
], FreshHyperEntity.prototype, "timestamp", void 0);
|
|
1660
|
+
_ts_decorate2([
|
|
1661
|
+
TimestampColumn(),
|
|
1662
|
+
_ts_metadata2("design:type", typeof Date === "undefined" ? Object : Date)
|
|
1663
|
+
], FreshHyperEntity.prototype, "created_at", void 0);
|
|
1664
|
+
|
|
1665
|
+
// src/database/entities/fresh-translation-entity.ts
|
|
1666
|
+
import { PrimaryGeneratedColumn as PrimaryGeneratedColumn2, Column as Column3, BaseEntity as BaseEntity3, Check } from "typeorm";
|
|
1667
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
1668
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1669
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1670
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1671
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1672
|
+
}
|
|
1673
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
1674
|
+
function _ts_metadata3(k, v) {
|
|
1675
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1676
|
+
}
|
|
1677
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
1678
|
+
var languageValues = Object.values(LanguageCode).map((v) => `'${v}'`).join(",");
|
|
1679
|
+
var _FreshTranslationBase = class _FreshTranslationBase extends BaseEntity3 {
|
|
1680
|
+
constructor() {
|
|
1681
|
+
super();
|
|
1682
|
+
__publicField(this, "id");
|
|
1683
|
+
__publicField(this, "languageCode");
|
|
1684
|
+
this.id = 0;
|
|
1685
|
+
this.languageCode = LanguageCode.CS;
|
|
1818
1686
|
}
|
|
1819
1687
|
};
|
|
1820
|
-
__name(
|
|
1821
|
-
var
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1688
|
+
__name(_FreshTranslationBase, "FreshTranslationBase");
|
|
1689
|
+
var FreshTranslationBase = _FreshTranslationBase;
|
|
1690
|
+
_ts_decorate3([
|
|
1691
|
+
PrimaryGeneratedColumn2(),
|
|
1692
|
+
_ts_metadata3("design:type", Number)
|
|
1693
|
+
], FreshTranslationBase.prototype, "id", void 0);
|
|
1694
|
+
_ts_decorate3([
|
|
1695
|
+
Column3({
|
|
1696
|
+
type: "varchar",
|
|
1697
|
+
length: 3,
|
|
1698
|
+
nullable: false
|
|
1699
|
+
}),
|
|
1700
|
+
Check(`"languageCode" IN (${languageValues})`),
|
|
1701
|
+
_ts_metadata3("design:type", typeof LanguageCode === "undefined" ? Object : LanguageCode)
|
|
1702
|
+
], FreshTranslationBase.prototype, "languageCode", void 0);
|
|
1703
|
+
|
|
1704
|
+
// src/database/dao/fresh-dao.ts
|
|
1705
|
+
var _FreshDao = class _FreshDao {
|
|
1706
|
+
getRepo(manager, entity = this.entity) {
|
|
1707
|
+
return manager ? manager.getRepository(entity) : this.repo;
|
|
1825
1708
|
}
|
|
1826
1709
|
};
|
|
1827
|
-
__name(
|
|
1828
|
-
var
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1710
|
+
__name(_FreshDao, "FreshDao");
|
|
1711
|
+
var FreshDao = _FreshDao;
|
|
1712
|
+
|
|
1713
|
+
// src/database/subscribers/base-entity-change.subscriber.ts
|
|
1714
|
+
var _BaseEntityChangeSubscriber = class _BaseEntityChangeSubscriber {
|
|
1715
|
+
// ─── TypeORM lifecycle hooks ────────────────────────────────────────
|
|
1716
|
+
afterInsert(event) {
|
|
1717
|
+
var _a;
|
|
1718
|
+
const id = (_a = event.entity) == null ? void 0 : _a.id;
|
|
1719
|
+
if (!id) {
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
if (event.queryRunner.isTransactionActive) {
|
|
1723
|
+
this.addPending(event, id, "created");
|
|
1724
|
+
} else {
|
|
1725
|
+
console.warn(`${this.SUBSCRIBER_NAME} - Notification sent outside transaction for id=${id}`);
|
|
1726
|
+
this.sendNotification(id, "created", event.queryRunner.manager);
|
|
1727
|
+
}
|
|
1832
1728
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1729
|
+
afterUpdate(event) {
|
|
1730
|
+
var _a, _b, _c;
|
|
1731
|
+
const id = (_c = (_a = event.entity) == null ? void 0 : _a.id) != null ? _c : (_b = event.databaseEntity) == null ? void 0 : _b.id;
|
|
1732
|
+
if (!id) {
|
|
1733
|
+
return;
|
|
1734
|
+
}
|
|
1735
|
+
if (event.queryRunner.isTransactionActive) {
|
|
1736
|
+
this.addPending(event, id, "updated");
|
|
1737
|
+
} else {
|
|
1738
|
+
console.warn(`${this.SUBSCRIBER_NAME} - Notification sent outside transaction for id=${id}`);
|
|
1739
|
+
this.sendNotification(id, "updated", event.queryRunner.manager);
|
|
1740
|
+
}
|
|
1839
1741
|
}
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1742
|
+
afterSoftRemove(event) {
|
|
1743
|
+
var _a, _b, _c;
|
|
1744
|
+
const id = (_c = (_a = event.entity) == null ? void 0 : _a.id) != null ? _c : (_b = event.databaseEntity) == null ? void 0 : _b.id;
|
|
1745
|
+
if (!id) {
|
|
1746
|
+
return;
|
|
1747
|
+
}
|
|
1748
|
+
if (event.queryRunner.isTransactionActive) {
|
|
1749
|
+
this.addPending(event, id, "deleted");
|
|
1750
|
+
} else {
|
|
1751
|
+
console.warn(`${this.SUBSCRIBER_NAME} - Notification sent outside transaction for id=${id}`);
|
|
1752
|
+
this.sendNotification(id, "deleted", event.queryRunner.manager);
|
|
1753
|
+
}
|
|
1846
1754
|
}
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1755
|
+
async afterTransactionCommit(event) {
|
|
1756
|
+
var _a;
|
|
1757
|
+
const pending = (_a = event.queryRunner.data) == null ? void 0 : _a[this.PENDING_KEY];
|
|
1758
|
+
if (!pending || pending.size === 0) {
|
|
1759
|
+
return;
|
|
1760
|
+
}
|
|
1761
|
+
event.queryRunner.data[this.PENDING_KEY] = /* @__PURE__ */ new Map();
|
|
1762
|
+
for (const [id, changeEvent] of pending) {
|
|
1763
|
+
await this.sendNotification(id, changeEvent, event.connection.manager);
|
|
1764
|
+
}
|
|
1853
1765
|
}
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1766
|
+
// ─── Private helpers ───────────────────────────────────────────────
|
|
1767
|
+
addPending(event, id, changeEvent) {
|
|
1768
|
+
if (!event.queryRunner.data) {
|
|
1769
|
+
event.queryRunner.data = {};
|
|
1770
|
+
}
|
|
1771
|
+
if (!event.queryRunner.data[this.PENDING_KEY]) {
|
|
1772
|
+
event.queryRunner.data[this.PENDING_KEY] = /* @__PURE__ */ new Map();
|
|
1773
|
+
}
|
|
1774
|
+
const existing = event.queryRunner.data[this.PENDING_KEY].get(id);
|
|
1775
|
+
if (!existing || changeEvent === "created" || changeEvent === "deleted") {
|
|
1776
|
+
event.queryRunner.data[this.PENDING_KEY].set(id, changeEvent);
|
|
1777
|
+
}
|
|
1860
1778
|
}
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1779
|
+
async sendNotification(id, changeEvent, manager) {
|
|
1780
|
+
try {
|
|
1781
|
+
await this.handleNotification(id, changeEvent, manager);
|
|
1782
|
+
} catch (error) {
|
|
1783
|
+
console.error(`${this.SUBSCRIBER_NAME} - Failed to send notification: ${error instanceof Error ? error.message : error}`);
|
|
1784
|
+
}
|
|
1867
1785
|
}
|
|
1868
1786
|
};
|
|
1869
|
-
__name(
|
|
1870
|
-
var
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1787
|
+
__name(_BaseEntityChangeSubscriber, "BaseEntityChangeSubscriber");
|
|
1788
|
+
var BaseEntityChangeSubscriber = _BaseEntityChangeSubscriber;
|
|
1789
|
+
|
|
1790
|
+
// src/common/schema/entities/category.entity.ts
|
|
1791
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
1792
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1793
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1794
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1795
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1796
|
+
}
|
|
1797
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
1798
|
+
var _Category = class _Category extends FreshEntity {
|
|
1875
1799
|
};
|
|
1876
|
-
__name(
|
|
1877
|
-
var
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1800
|
+
__name(_Category, "Category");
|
|
1801
|
+
var Category = _Category;
|
|
1802
|
+
Category = _ts_decorate4([
|
|
1803
|
+
Entity()
|
|
1804
|
+
], Category);
|
|
1805
|
+
|
|
1806
|
+
// src/common/schema/entities/device.entity.ts
|
|
1807
|
+
import { Entity as Entity2 } from "typeorm";
|
|
1808
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1809
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1810
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1811
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1812
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1813
|
+
}
|
|
1814
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
1815
|
+
var _Device = class _Device extends FreshEntity {
|
|
1882
1816
|
};
|
|
1883
|
-
__name(
|
|
1884
|
-
var
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1817
|
+
__name(_Device, "Device");
|
|
1818
|
+
var Device = _Device;
|
|
1819
|
+
Device = _ts_decorate5([
|
|
1820
|
+
Entity2()
|
|
1821
|
+
], Device);
|
|
1822
|
+
|
|
1823
|
+
// src/common/schema/entities/manufacturer.entity.ts
|
|
1824
|
+
import { Entity as Entity3 } from "typeorm";
|
|
1825
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1826
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1827
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1828
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1829
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1830
|
+
}
|
|
1831
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
1832
|
+
var _Manufacturer = class _Manufacturer extends FreshEntity {
|
|
1889
1833
|
};
|
|
1890
|
-
__name(
|
|
1891
|
-
var
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1834
|
+
__name(_Manufacturer, "Manufacturer");
|
|
1835
|
+
var Manufacturer = _Manufacturer;
|
|
1836
|
+
Manufacturer = _ts_decorate6([
|
|
1837
|
+
Entity3()
|
|
1838
|
+
], Manufacturer);
|
|
1839
|
+
|
|
1840
|
+
// src/common/schema/entities/product.entity.ts
|
|
1841
|
+
import { Entity as Entity4 } from "typeorm";
|
|
1842
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1843
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1844
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1845
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1846
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1847
|
+
}
|
|
1848
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
1849
|
+
var _Product = class _Product extends FreshEntity {
|
|
1896
1850
|
};
|
|
1897
|
-
__name(
|
|
1898
|
-
var
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1851
|
+
__name(_Product, "Product");
|
|
1852
|
+
var Product = _Product;
|
|
1853
|
+
Product = _ts_decorate7([
|
|
1854
|
+
Entity4()
|
|
1855
|
+
], Product);
|
|
1856
|
+
|
|
1857
|
+
// src/common/schema/entities/subcategory.entity.ts
|
|
1858
|
+
import { Entity as Entity5 } from "typeorm";
|
|
1859
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1860
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1861
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1862
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1863
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1864
|
+
}
|
|
1865
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1866
|
+
var _Subcategory = class _Subcategory extends FreshEntity {
|
|
1903
1867
|
};
|
|
1904
|
-
__name(
|
|
1905
|
-
var
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1868
|
+
__name(_Subcategory, "Subcategory");
|
|
1869
|
+
var Subcategory = _Subcategory;
|
|
1870
|
+
Subcategory = _ts_decorate8([
|
|
1871
|
+
Entity5()
|
|
1872
|
+
], Subcategory);
|
|
1873
|
+
|
|
1874
|
+
// src/common/typeguards/decimal.ts
|
|
1875
|
+
function toDecimal(num, precision = 9, scale = 2) {
|
|
1876
|
+
const limit = Math.pow(10, precision - scale);
|
|
1877
|
+
if (Math.abs(num) >= limit) {
|
|
1878
|
+
throw new Error(`Value ${num} exceeds the allowed precision of ${precision} and scale of ${scale}.`);
|
|
1909
1879
|
}
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1880
|
+
return num.toFixed(scale);
|
|
1881
|
+
}
|
|
1882
|
+
__name(toDecimal, "toDecimal");
|
|
1883
|
+
function isDecimal(v, options) {
|
|
1884
|
+
var _a, _b, _c;
|
|
1885
|
+
const type = typeof v;
|
|
1886
|
+
if ((options == null ? void 0 : options.allowedType) !== void 0 && type !== options.allowedType) {
|
|
1887
|
+
return false;
|
|
1916
1888
|
}
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
var InsufficientStorageError = _InsufficientStorageError;
|
|
1920
|
-
var _LoopDetectedError = class _LoopDetectedError extends FreshError {
|
|
1921
|
-
constructor(detail, options) {
|
|
1922
|
-
super(HttpStatus.LOOP_DETECTED, "internal-server-error", detail, options);
|
|
1889
|
+
if (type !== "number" && type !== "string") {
|
|
1890
|
+
return false;
|
|
1923
1891
|
}
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1892
|
+
const sep = (_a = options == null ? void 0 : options.decimalPoint) != null ? _a : ".";
|
|
1893
|
+
let intPart;
|
|
1894
|
+
let fracPart;
|
|
1895
|
+
if (type === "number") {
|
|
1896
|
+
const n = v;
|
|
1897
|
+
if (!Number.isFinite(n)) {
|
|
1898
|
+
return false;
|
|
1899
|
+
}
|
|
1900
|
+
const str = n.toString();
|
|
1901
|
+
if (str.includes("e") || str.includes("E")) {
|
|
1902
|
+
return false;
|
|
1903
|
+
}
|
|
1904
|
+
const parts = str.replace("-", "").split(".");
|
|
1905
|
+
intPart = parts[0];
|
|
1906
|
+
fracPart = (_b = parts[1]) != null ? _b : "";
|
|
1907
|
+
} else {
|
|
1908
|
+
const s = v;
|
|
1909
|
+
const escapedSep = sep === "." ? "\\." : ",";
|
|
1910
|
+
const pattern = new RegExp(`^-?\\d+(?:${escapedSep}\\d+)?$`);
|
|
1911
|
+
if (!pattern.test(s)) {
|
|
1912
|
+
return false;
|
|
1913
|
+
}
|
|
1914
|
+
const parts = s.replace("-", "").split(sep);
|
|
1915
|
+
intPart = parts[0];
|
|
1916
|
+
fracPart = (_c = parts[1]) != null ? _c : "";
|
|
1930
1917
|
}
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
var NotExtendedError = _NotExtendedError;
|
|
1934
|
-
var _NetworkAuthenticationRequiredError = class _NetworkAuthenticationRequiredError extends FreshError {
|
|
1935
|
-
constructor(detail, options) {
|
|
1936
|
-
super(HttpStatus.NETWORK_AUTHENTICATION_REQUIRED, "internal-server-error", detail, options);
|
|
1918
|
+
if ((options == null ? void 0 : options.scale) !== void 0 && fracPart.length > options.scale) {
|
|
1919
|
+
return false;
|
|
1937
1920
|
}
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1921
|
+
return (options == null ? void 0 : options.precision) === void 0 || intPart.length + fracPart.length <= options.precision;
|
|
1922
|
+
}
|
|
1923
|
+
__name(isDecimal, "isDecimal");
|
|
1941
1924
|
|
|
1942
|
-
// src/
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
__publicField(this, "_dataPromise", null);
|
|
1947
|
-
__publicField(this, "deviceIds");
|
|
1948
|
-
this.deviceIds = deviceIds;
|
|
1949
|
-
if (startDataRetrieve) {
|
|
1950
|
-
this._dataPromise = this.startDataRetrieval();
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
get data() {
|
|
1954
|
-
return this._data;
|
|
1925
|
+
// src/common/typeguards/enums.ts
|
|
1926
|
+
function isEnumValue(enumObj, v) {
|
|
1927
|
+
if (!enumObj) {
|
|
1928
|
+
return typeof v === "string" || typeof v === "number";
|
|
1955
1929
|
}
|
|
1956
|
-
|
|
1957
|
-
|
|
1930
|
+
const values = new Set(Object.values(enumObj));
|
|
1931
|
+
return (typeof v === "string" || typeof v === "number") && values.has(v);
|
|
1932
|
+
}
|
|
1933
|
+
__name(isEnumValue, "isEnumValue");
|
|
1934
|
+
|
|
1935
|
+
// src/common/typeguards/objects.ts
|
|
1936
|
+
function isObject(v) {
|
|
1937
|
+
return typeof v === "object" && v !== null;
|
|
1938
|
+
}
|
|
1939
|
+
__name(isObject, "isObject");
|
|
1940
|
+
function hasOwn(obj, key) {
|
|
1941
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
1942
|
+
}
|
|
1943
|
+
__name(hasOwn, "hasOwn");
|
|
1944
|
+
|
|
1945
|
+
// src/common/typeguards/primitives.ts
|
|
1946
|
+
function isNumber(v) {
|
|
1947
|
+
return typeof v === "number" && Number.isFinite(v);
|
|
1948
|
+
}
|
|
1949
|
+
__name(isNumber, "isNumber");
|
|
1950
|
+
function isString(v) {
|
|
1951
|
+
return typeof v === "string";
|
|
1952
|
+
}
|
|
1953
|
+
__name(isString, "isString");
|
|
1954
|
+
function isFlag01(v) {
|
|
1955
|
+
return v === 0 || v === 1;
|
|
1956
|
+
}
|
|
1957
|
+
__name(isFlag01, "isFlag01");
|
|
1958
|
+
function isNumberInRange(v, min, max, options) {
|
|
1959
|
+
var _a, _b;
|
|
1960
|
+
if (!isNumber(v)) {
|
|
1961
|
+
return false;
|
|
1958
1962
|
}
|
|
1959
|
-
|
|
1960
|
-
|
|
1963
|
+
const includeMin = (_a = options == null ? void 0 : options.includeMin) != null ? _a : true;
|
|
1964
|
+
const includeMax = (_b = options == null ? void 0 : options.includeMax) != null ? _b : true;
|
|
1965
|
+
if (includeMin ? v < min : v <= min) {
|
|
1966
|
+
return false;
|
|
1961
1967
|
}
|
|
1962
|
-
|
|
1963
|
-
|
|
1968
|
+
if (includeMax ? v > max : v >= max) {
|
|
1969
|
+
return false;
|
|
1964
1970
|
}
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1971
|
+
return true;
|
|
1972
|
+
}
|
|
1973
|
+
__name(isNumberInRange, "isNumberInRange");
|
|
1974
|
+
var TO_BINARY_FLAG = /* @__PURE__ */ __name((v) => v === 1 || v === true ? 1 : 0, "TO_BINARY_FLAG");
|
|
1975
|
+
|
|
1976
|
+
// src/common/utils/async.utils.ts
|
|
1977
|
+
async function runWithConcurrency(items, concurrency, worker) {
|
|
1978
|
+
const queue = [
|
|
1979
|
+
...items
|
|
1980
|
+
];
|
|
1981
|
+
const runNext = /* @__PURE__ */ __name(async () => {
|
|
1982
|
+
const item = queue.shift();
|
|
1983
|
+
if (!item) {
|
|
1984
|
+
return;
|
|
1968
1985
|
}
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1986
|
+
await worker(item);
|
|
1987
|
+
await runNext();
|
|
1988
|
+
}, "runNext");
|
|
1989
|
+
await Promise.all(Array.from({
|
|
1990
|
+
length: Math.min(concurrency, items.length)
|
|
1991
|
+
}, runNext));
|
|
1992
|
+
}
|
|
1993
|
+
__name(runWithConcurrency, "runWithConcurrency");
|
|
1994
|
+
|
|
1995
|
+
// src/common/utils/id-path-param-resolver.utils.ts
|
|
1996
|
+
function resolvePathParameterId(id) {
|
|
1997
|
+
return /^\d+$/.test(id) ? parseInt(id, 10) : id;
|
|
1998
|
+
}
|
|
1999
|
+
__name(resolvePathParameterId, "resolvePathParameterId");
|
|
2000
|
+
|
|
2001
|
+
// src/common/utils/is-cron-valid.ts
|
|
2002
|
+
function isValidCron(expr) {
|
|
2003
|
+
const parts = expr.trim().split(/\s+/);
|
|
2004
|
+
if (parts.length < 5 || parts.length > 6) {
|
|
2005
|
+
return false;
|
|
2006
|
+
}
|
|
2007
|
+
const cronPart = /^(\*|\d+|\d+\-\d+|\d+\/\d+|\*\/\d+)(,\d+)*$/;
|
|
2008
|
+
return parts.every((part) => cronPart.test(part));
|
|
2009
|
+
}
|
|
2010
|
+
__name(isValidCron, "isValidCron");
|
|
2011
|
+
|
|
2012
|
+
// src/common/utils/patch.utils.ts
|
|
2013
|
+
function buildPatch(data, keys, transforms) {
|
|
2014
|
+
const patch = {};
|
|
2015
|
+
for (const k of keys) {
|
|
2016
|
+
const value = data[k];
|
|
2017
|
+
if (value === void 0) {
|
|
2018
|
+
continue;
|
|
1972
2019
|
}
|
|
1973
|
-
|
|
2020
|
+
patch[k] = (transforms == null ? void 0 : transforms[k]) ? transforms[k](value) : value;
|
|
1974
2021
|
}
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
2022
|
+
return patch;
|
|
2023
|
+
}
|
|
2024
|
+
__name(buildPatch, "buildPatch");
|
|
1978
2025
|
|
|
1979
2026
|
// src/types/maybe-type.ts
|
|
1980
2027
|
function isMaybe(v, inner) {
|
|
@@ -2235,6 +2282,9 @@ export {
|
|
|
2235
2282
|
UpgradeRequiredError,
|
|
2236
2283
|
UriTooLongError,
|
|
2237
2284
|
VariantAlsoNegotiatesError,
|
|
2285
|
+
buildDateRange,
|
|
2286
|
+
buildOrder,
|
|
2287
|
+
buildPagination,
|
|
2238
2288
|
buildPatch,
|
|
2239
2289
|
constructTypeormPagination,
|
|
2240
2290
|
createDeferred,
|