@imqueue/pg-sequelize 4.2.0

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/CONTRIBUTING.md +58 -0
  3. package/CONTRIBUTION-TERMS.md +79 -0
  4. package/LICENSE +585 -0
  5. package/README.md +94 -0
  6. package/SECURITY.md +41 -0
  7. package/index.d.ts +86 -0
  8. package/index.js +87 -0
  9. package/package.json +75 -0
  10. package/src/BaseModel.d.ts +695 -0
  11. package/src/BaseModel.js +917 -0
  12. package/src/Graph.d.ts +215 -0
  13. package/src/Graph.js +257 -0
  14. package/src/decorators/AssociatedWith.d.ts +94 -0
  15. package/src/decorators/AssociatedWith.js +71 -0
  16. package/src/decorators/ColumnIndex.d.ts +206 -0
  17. package/src/decorators/ColumnIndex.js +98 -0
  18. package/src/decorators/CreatedBy.d.ts +27 -0
  19. package/src/decorators/CreatedBy.js +84 -0
  20. package/src/decorators/DeletedBy.d.ts +30 -0
  21. package/src/decorators/DeletedBy.js +89 -0
  22. package/src/decorators/DynamicView.d.ts +124 -0
  23. package/src/decorators/DynamicView.js +113 -0
  24. package/src/decorators/Emittable.d.ts +39 -0
  25. package/src/decorators/Emittable.js +42 -0
  26. package/src/decorators/NullableIndex.d.ts +77 -0
  27. package/src/decorators/NullableIndex.js +64 -0
  28. package/src/decorators/UpdatedBy.d.ts +27 -0
  29. package/src/decorators/UpdatedBy.js +105 -0
  30. package/src/decorators/View.d.ts +87 -0
  31. package/src/decorators/View.js +93 -0
  32. package/src/decorators/index.d.ts +32 -0
  33. package/src/decorators/index.js +33 -0
  34. package/src/helpers/index.d.ts +24 -0
  35. package/src/helpers/index.js +25 -0
  36. package/src/helpers/js.d.ts +61 -0
  37. package/src/helpers/js.js +88 -0
  38. package/src/helpers/query.d.ts +445 -0
  39. package/src/helpers/query.js +1095 -0
  40. package/src/index.d.ts +162 -0
  41. package/src/index.js +223 -0
  42. package/src/types/DataPage.d.ts +52 -0
  43. package/src/types/DataPage.js +2 -0
  44. package/src/types/FieldsInput.d.ts +41 -0
  45. package/src/types/FieldsInput.js +75 -0
  46. package/src/types/FilterInput.d.ts +136 -0
  47. package/src/types/FilterInput.js +291 -0
  48. package/src/types/JsonObject.d.ts +16 -0
  49. package/src/types/JsonObject.js +50 -0
  50. package/src/types/OrderByInput.d.ts +45 -0
  51. package/src/types/OrderByInput.js +80 -0
  52. package/src/types/PaginationInput.d.ts +44 -0
  53. package/src/types/PaginationInput.js +90 -0
  54. package/src/types/index.d.ts +30 -0
  55. package/src/types/index.js +31 -0
  56. package/src/types/ranges/DateRange.d.ts +27 -0
  57. package/src/types/ranges/DateRange.js +69 -0
  58. package/src/types/ranges/IRange.d.ts +47 -0
  59. package/src/types/ranges/IRange.js +2 -0
  60. package/src/types/ranges/NumericRange.d.ts +19 -0
  61. package/src/types/ranges/NumericRange.js +61 -0
  62. package/src/types/ranges/index.d.ts +26 -0
  63. package/src/types/ranges/index.js +27 -0
@@ -0,0 +1,90 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ /*!
11
+ * @imqueue/pg-sequelize - Sequelize ORM refines for @imqueue
12
+ *
13
+ * I'm Queue Software Project
14
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
15
+ *
16
+ * This program is free software: you can redistribute it and/or modify
17
+ * it under the terms of the GNU General Public License as published by
18
+ * the Free Software Foundation, either version 3 of the License, or
19
+ * (at your option) any later version.
20
+ *
21
+ * This program is distributed in the hope that it will be useful,
22
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ * GNU General Public License for more details.
25
+ *
26
+ * You should have received a copy of the GNU General Public License
27
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
28
+ *
29
+ * If you want to use this code in a closed source (commercial) project, you can
30
+ * purchase a proprietary commercial license. Please contact us at
31
+ * <support@imqueue.com> to get commercial licensing options.
32
+ */
33
+ import { property } from '@imqueue/rpc';
34
+ /**
35
+ * Where a page starts and how big it is.
36
+ *
37
+ * @remarks
38
+ * Turned into Sequelize's `offset`/`limit` by `query.toLimitOptions`, which treats
39
+ * this input as advisory rather than authoritative — see the notes on each property.
40
+ * A negative `limit` is the interesting case: it means "the last N rows", and it is
41
+ * the only reason `count` exists.
42
+ */
43
+ export class PaginationInput {
44
+ /**
45
+ * Rows to skip before the page starts.
46
+ *
47
+ * @remarks
48
+ * Ignored when `limit` is absent or zero, since there is then no page to
49
+ * position. With a negative `limit` and an `offset` of zero it is computed
50
+ * instead — see `limit`.
51
+ */
52
+ offset;
53
+ /**
54
+ * Rows in the page. Negative counts back from the end of the set.
55
+ *
56
+ * @remarks
57
+ * Zero, absent or non-numeric means no pagination at all: `toLimitOptions`
58
+ * returns an empty options object and the query is left unbounded. That is a
59
+ * quiet default worth knowing about — a caller who sends `limit: 0` expecting
60
+ * "no rows" gets every row.
61
+ *
62
+ * A negative value takes the absolute value as the page size and, when `offset`
63
+ * is zero, positions the window at the end of the set: `count - limit`, clamped
64
+ * at zero. So `{ limit: -10, count: 1340 }` is the last ten rows. Without a
65
+ * `count` the offset computes to a negative number and clamps to zero, giving
66
+ * the FIRST ten rows rather than the last — the two properties go together.
67
+ */
68
+ limit;
69
+ /**
70
+ * Total rows in the set, used only to place a negative `limit`.
71
+ *
72
+ * @remarks
73
+ * Nothing validates it against the real total, and it is ignored entirely for a
74
+ * positive `limit`.
75
+ */
76
+ count;
77
+ }
78
+ __decorate([
79
+ property('number'),
80
+ __metadata("design:type", Number)
81
+ ], PaginationInput.prototype, "offset", void 0);
82
+ __decorate([
83
+ property('number'),
84
+ __metadata("design:type", Number)
85
+ ], PaginationInput.prototype, "limit", void 0);
86
+ __decorate([
87
+ property('number', true),
88
+ __metadata("design:type", Number)
89
+ ], PaginationInput.prototype, "count", void 0);
90
+ //# sourceMappingURL=PaginationInput.js.map
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * @imqueue/pg-sequelize - Sequelize ORM refines for @imqueue
3
+ *
4
+ * I'm Queue Software Project
5
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ * If you want to use this code in a closed source (commercial) project, you can
21
+ * purchase a proprietary commercial license. Please contact us at
22
+ * <support@imqueue.com> to get commercial licensing options.
23
+ */
24
+ export * from './ranges/index.js';
25
+ export * from './FieldsInput.js';
26
+ export * from './FilterInput.js';
27
+ export * from './PaginationInput.js';
28
+ export * from './OrderByInput.js';
29
+ export * from './JsonObject.js';
30
+ export * from './DataPage.js';
@@ -0,0 +1,31 @@
1
+ /*!
2
+ * @imqueue/pg-sequelize - Sequelize ORM refines for @imqueue
3
+ *
4
+ * I'm Queue Software Project
5
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ * If you want to use this code in a closed source (commercial) project, you can
21
+ * purchase a proprietary commercial license. Please contact us at
22
+ * <support@imqueue.com> to get commercial licensing options.
23
+ */
24
+ export * from './ranges/index.js';
25
+ export * from './FieldsInput.js';
26
+ export * from './FilterInput.js';
27
+ export * from './PaginationInput.js';
28
+ export * from './OrderByInput.js';
29
+ export * from './JsonObject.js';
30
+ export * from './DataPage.js';
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,27 @@
1
+ import { type IRange } from './IRange.js';
2
+ /**
3
+ * A range between two dates, as an `@imqueue/rpc` type.
4
+ *
5
+ * @remarks
6
+ * Accepts a `Date` or an ISO-8601 string on either bound, because a remote caller
7
+ * has only the string — a `Date` does not survive JSON.
8
+ *
9
+ * Used through the `Range`-suffix convention rather than by naming the column
10
+ * directly: filter `<column>Range` and `query.withRangeFilters` moves it onto
11
+ * `<column>`. Passing both forms for one column throws a `TypeError` rather than
12
+ * silently preferring one.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // reservations whose `duration` column falls inside the window
17
+ * const filter = {
18
+ * durationRange: { start: '2026-08-01', end: '2026-08-31' },
19
+ * } as FilterInput;
20
+ * ```
21
+ */
22
+ export declare class DateRange implements IRange {
23
+ /** Start of the range — a `Date`, or an ISO-8601 string from a remote caller. */
24
+ start: string | Date;
25
+ /** End of the range — a `Date`, or an ISO-8601 string from a remote caller. */
26
+ end: string | Date;
27
+ }
@@ -0,0 +1,69 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ /*!
11
+ * @imqueue/pg-sequelize - Sequelize ORM refines for @imqueue
12
+ *
13
+ * I'm Queue Software Project
14
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
15
+ *
16
+ * This program is free software: you can redistribute it and/or modify
17
+ * it under the terms of the GNU General Public License as published by
18
+ * the Free Software Foundation, either version 3 of the License, or
19
+ * (at your option) any later version.
20
+ *
21
+ * This program is distributed in the hope that it will be useful,
22
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ * GNU General Public License for more details.
25
+ *
26
+ * You should have received a copy of the GNU General Public License
27
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
28
+ *
29
+ * If you want to use this code in a closed source (commercial) project, you can
30
+ * purchase a proprietary commercial license. Please contact us at
31
+ * <support@imqueue.com> to get commercial licensing options.
32
+ */
33
+ import { property } from '@imqueue/rpc';
34
+ import {} from './IRange.js';
35
+ /**
36
+ * A range between two dates, as an `@imqueue/rpc` type.
37
+ *
38
+ * @remarks
39
+ * Accepts a `Date` or an ISO-8601 string on either bound, because a remote caller
40
+ * has only the string — a `Date` does not survive JSON.
41
+ *
42
+ * Used through the `Range`-suffix convention rather than by naming the column
43
+ * directly: filter `<column>Range` and `query.withRangeFilters` moves it onto
44
+ * `<column>`. Passing both forms for one column throws a `TypeError` rather than
45
+ * silently preferring one.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * // reservations whose `duration` column falls inside the window
50
+ * const filter = {
51
+ * durationRange: { start: '2026-08-01', end: '2026-08-31' },
52
+ * } as FilterInput;
53
+ * ```
54
+ */
55
+ export class DateRange {
56
+ /** Start of the range — a `Date`, or an ISO-8601 string from a remote caller. */
57
+ start;
58
+ /** End of the range — a `Date`, or an ISO-8601 string from a remote caller. */
59
+ end;
60
+ }
61
+ __decorate([
62
+ property('string | Date'),
63
+ __metadata("design:type", Object)
64
+ ], DateRange.prototype, "start", void 0);
65
+ __decorate([
66
+ property('string | Date'),
67
+ __metadata("design:type", Object)
68
+ ], DateRange.prototype, "end", void 0);
69
+ //# sourceMappingURL=DateRange.js.map
@@ -0,0 +1,47 @@
1
+ /*!
2
+ * @imqueue/pg-sequelize - Sequelize ORM refines for @imqueue
3
+ *
4
+ * I'm Queue Software Project
5
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ * If you want to use this code in a closed source (commercial) project, you can
21
+ * purchase a proprietary commercial license. Please contact us at
22
+ * <support@imqueue.com> to get commercial licensing options.
23
+ */
24
+ /**
25
+ * The shape every range filter shares: a start and an end.
26
+ *
27
+ * @remarks
28
+ * `query.withRangeFilters` recognises a range by exactly these two keys, in either
29
+ * order, on a filter property whose name ends in `Range`. So the property NAMES are
30
+ * the contract — an object with any other key set is left alone and filtered as an
31
+ * ordinary value.
32
+ *
33
+ * The convention it implements: a caller filters `durationRange` and the helper
34
+ * rewrites it onto the real `duration` column. Sending both `duration` and
35
+ * `durationRange` is an error rather than a merge — see
36
+ * {@link DateRange} for the worked example.
37
+ *
38
+ * Deliberately untyped at `any`, so a range of anything Postgres supports can
39
+ * implement it; {@link DateRange} and {@link NumericRange} are the two the package
40
+ * ships.
41
+ */
42
+ export interface IRange {
43
+ /** Lower bound of the range. */
44
+ start: any;
45
+ /** Upper bound of the range. */
46
+ end: any;
47
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IRange.js.map
@@ -0,0 +1,19 @@
1
+ import { type IRange } from './IRange.js';
2
+ /**
3
+ * A range between two numbers, as an `@imqueue/rpc` type.
4
+ *
5
+ * @remarks
6
+ * The numeric counterpart of {@link DateRange}, and used the same way: filter
7
+ * `<column>Range` and `query.withRangeFilters` rewrites it onto `<column>`.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const filter = { priceRange: { start: 10, end: 100 } } as FilterInput;
12
+ * ```
13
+ */
14
+ export declare class NumericRange implements IRange {
15
+ /** Lower bound of the range. */
16
+ start: number;
17
+ /** Upper bound of the range. */
18
+ end: number;
19
+ }
@@ -0,0 +1,61 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ /*!
11
+ * @imqueue/pg-sequelize - Sequelize ORM refines for @imqueue
12
+ *
13
+ * I'm Queue Software Project
14
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
15
+ *
16
+ * This program is free software: you can redistribute it and/or modify
17
+ * it under the terms of the GNU General Public License as published by
18
+ * the Free Software Foundation, either version 3 of the License, or
19
+ * (at your option) any later version.
20
+ *
21
+ * This program is distributed in the hope that it will be useful,
22
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ * GNU General Public License for more details.
25
+ *
26
+ * You should have received a copy of the GNU General Public License
27
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
28
+ *
29
+ * If you want to use this code in a closed source (commercial) project, you can
30
+ * purchase a proprietary commercial license. Please contact us at
31
+ * <support@imqueue.com> to get commercial licensing options.
32
+ */
33
+ import { property } from '@imqueue/rpc';
34
+ import {} from './IRange.js';
35
+ /**
36
+ * A range between two numbers, as an `@imqueue/rpc` type.
37
+ *
38
+ * @remarks
39
+ * The numeric counterpart of {@link DateRange}, and used the same way: filter
40
+ * `<column>Range` and `query.withRangeFilters` rewrites it onto `<column>`.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const filter = { priceRange: { start: 10, end: 100 } } as FilterInput;
45
+ * ```
46
+ */
47
+ export class NumericRange {
48
+ /** Lower bound of the range. */
49
+ start;
50
+ /** Upper bound of the range. */
51
+ end;
52
+ }
53
+ __decorate([
54
+ property('number'),
55
+ __metadata("design:type", Number)
56
+ ], NumericRange.prototype, "start", void 0);
57
+ __decorate([
58
+ property('number'),
59
+ __metadata("design:type", Number)
60
+ ], NumericRange.prototype, "end", void 0);
61
+ //# sourceMappingURL=NumericRange.js.map
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * @imqueue/pg-sequelize - Sequelize ORM refines for @imqueue
3
+ *
4
+ * I'm Queue Software Project
5
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ * If you want to use this code in a closed source (commercial) project, you can
21
+ * purchase a proprietary commercial license. Please contact us at
22
+ * <support@imqueue.com> to get commercial licensing options.
23
+ */
24
+ export * from './IRange.js';
25
+ export * from './DateRange.js';
26
+ export * from './NumericRange.js';
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * @imqueue/pg-sequelize - Sequelize ORM refines for @imqueue
3
+ *
4
+ * I'm Queue Software Project
5
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ * If you want to use this code in a closed source (commercial) project, you can
21
+ * purchase a proprietary commercial license. Please contact us at
22
+ * <support@imqueue.com> to get commercial licensing options.
23
+ */
24
+ export * from './IRange.js';
25
+ export * from './DateRange.js';
26
+ export * from './NumericRange.js';
27
+ //# sourceMappingURL=index.js.map