@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,136 @@
1
+ /**
2
+ * Maps each `$`-prefixed filter operator to the Sequelize `Op` symbol it means.
3
+ *
4
+ * @remarks
5
+ * This mapping is the reason {@link FilterInput} exists at all. Sequelize's
6
+ * operators are ES symbols, and a symbol cannot be serialized — so a filter built
7
+ * with `Op.gt` on a client would arrive at the service as an empty object. The
8
+ * remote caller sends the string `$gt` instead, and `query.toWhereOptions` swaps in
9
+ * the symbol on this side.
10
+ *
11
+ * Only the operators listed here are translated. Any other key is passed through as
12
+ * written, on the assumption that it is a column name — so a mistyped `$gtt` becomes
13
+ * a filter on a column called `$gtt` rather than an error.
14
+ */
15
+ export declare const FILTER_OPS: {
16
+ $and: symbol;
17
+ $or: symbol;
18
+ $gt: symbol;
19
+ $gte: symbol;
20
+ $lt: symbol;
21
+ $lte: symbol;
22
+ $ne: symbol;
23
+ $eq: symbol;
24
+ $not: symbol;
25
+ $between: symbol;
26
+ $notBetween: symbol;
27
+ $in: symbol;
28
+ $notIn: symbol;
29
+ $like: symbol;
30
+ $notLike: symbol;
31
+ $iLike: symbol;
32
+ $notILike: symbol;
33
+ $regexp: symbol;
34
+ $notRegexp: symbol;
35
+ $iRegexp: symbol;
36
+ $notIRegexp: symbol;
37
+ $overlap: symbol;
38
+ $contains: symbol;
39
+ $contained: symbol;
40
+ $any: symbol;
41
+ $adjacent: symbol;
42
+ $strictLeft: symbol;
43
+ $strictRight: symbol;
44
+ $noExtendRight: symbol;
45
+ $noExtendLeft: symbol;
46
+ };
47
+ /**
48
+ * A where clause as plain, serializable JSON.
49
+ *
50
+ * @remarks
51
+ * Gives a remote caller the same expressive power Sequelize offers locally —
52
+ * comparison, set membership, pattern matching, regular expressions and range
53
+ * operators, nested arbitrarily through `$and` and `$or`. Every operator is a
54
+ * `$`-prefixed string rather than a symbol, because symbols do not survive the wire;
55
+ * {@link FILTER_OPS} does the translation on arrival.
56
+ *
57
+ * Two things follow from how `query.toWhereOptions` walks it. Keys are read
58
+ * recursively, so a value that is itself an object is treated as a nested filter and
59
+ * only a non-object value ends the walk. And any key that is NOT a known operator is
60
+ * kept verbatim as a column name — which is what lets you mix columns and operators
61
+ * in one object, and also means a typo becomes a column rather than a complaint.
62
+ *
63
+ * The declared property types are the common cases rather than hard limits; the
64
+ * runtime walk does not enforce them.
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * // type is 'fast' or 'std', and the reservation was created this year
69
+ * const filter = {
70
+ * $or: [{ type: 'fast' }, { type: 'std' }],
71
+ * createdAt: { $gte: '2026-01-01' },
72
+ * } as FilterInput;
73
+ * ```
74
+ */
75
+ export declare class FilterInput {
76
+ /** Every nested condition must hold (SQL `AND`). */
77
+ $and?: FilterInput | Array<FilterInput | number | string | boolean | null>;
78
+ /** At least one nested condition must hold (SQL `OR`). */
79
+ $or?: FilterInput | Array<FilterInput | number | string | boolean | null>;
80
+ /** Greater than. */
81
+ $gt?: number;
82
+ /** Greater than or equal to. */
83
+ $gte?: number;
84
+ /** Less than. */
85
+ $lt?: number;
86
+ /** Less than or equal to. */
87
+ $lte?: number;
88
+ /** Not equal to. */
89
+ $ne?: number | string;
90
+ /** Equal to. With `null`, becomes `IS NULL`. */
91
+ $eq?: number | string | boolean | null;
92
+ /** Negates the nested condition (SQL `NOT`). */
93
+ $not?: boolean;
94
+ /** Within the inclusive `[low, high]` pair (SQL `BETWEEN`). */
95
+ $between?: Array<number | string>;
96
+ /** Outside the inclusive `[low, high]` pair. */
97
+ $notBetween?: Array<number | string>;
98
+ /** One of the listed values (SQL `IN`). An empty list matches nothing. */
99
+ $in?: Array<number | string | boolean | null>;
100
+ /** None of the listed values (SQL `NOT IN`). */
101
+ $notIn?: Array<number | string | boolean | null>;
102
+ /** Case-sensitive pattern match, `%` and `_` as wildcards (SQL `LIKE`). */
103
+ $like?: string;
104
+ /** Fails a case-sensitive pattern match. */
105
+ $notLike?: string;
106
+ /** Case-insensitive pattern match (Postgres `ILIKE`). */
107
+ $iLike?: string;
108
+ /** Fails a case-insensitive pattern match. */
109
+ $notILike?: string;
110
+ /** Matches a POSIX regular expression (Postgres `~`). */
111
+ $regexp?: string;
112
+ /** Fails a POSIX regular expression (Postgres `!~`). */
113
+ $notRegexp?: string;
114
+ /** Matches a regular expression, case-insensitively (Postgres `~*`). */
115
+ $iRegexp?: string;
116
+ /** Fails a case-insensitive regular expression (Postgres `!~*`). */
117
+ $notIRegexp?: string;
118
+ /** Ranges share at least one value (Postgres `&&`). */
119
+ $overlap?: [number, number];
120
+ /** The column's range contains this value or range (Postgres `@>`). */
121
+ $contains?: number | [number, number];
122
+ /** The column's range is contained by this one (Postgres `<@`). */
123
+ $contained?: [number, number];
124
+ /** Equals any element of the array (Postgres `= ANY`). */
125
+ $any?: number[] | string[];
126
+ /** Ranges touch without overlapping (Postgres `-|-`). */
127
+ $adjacent?: [number, number];
128
+ /** Range lies entirely to the left of this one (Postgres `<<`). */
129
+ $strictLeft?: [number, number];
130
+ /** Range lies entirely to the right of this one (Postgres `>>`). */
131
+ $strictRight?: [number, number];
132
+ /** Range does not extend past this one's right bound (Postgres `&<`). */
133
+ $noExtendRight?: [number, number];
134
+ /** Range does not extend past this one's left bound (Postgres `&>`). */
135
+ $noExtendLeft?: [number, number];
136
+ }
@@ -0,0 +1,291 @@
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 { Op } from 'sequelize';
35
+ /**
36
+ * Maps each `$`-prefixed filter operator to the Sequelize `Op` symbol it means.
37
+ *
38
+ * @remarks
39
+ * This mapping is the reason {@link FilterInput} exists at all. Sequelize's
40
+ * operators are ES symbols, and a symbol cannot be serialized — so a filter built
41
+ * with `Op.gt` on a client would arrive at the service as an empty object. The
42
+ * remote caller sends the string `$gt` instead, and `query.toWhereOptions` swaps in
43
+ * the symbol on this side.
44
+ *
45
+ * Only the operators listed here are translated. Any other key is passed through as
46
+ * written, on the assumption that it is a column name — so a mistyped `$gtt` becomes
47
+ * a filter on a column called `$gtt` rather than an error.
48
+ */
49
+ export const FILTER_OPS = {
50
+ $and: Op.and,
51
+ $or: Op.or,
52
+ $gt: Op.gt,
53
+ $gte: Op.gte,
54
+ $lt: Op.lt,
55
+ $lte: Op.lte,
56
+ $ne: Op.ne,
57
+ $eq: Op.eq,
58
+ $not: Op.not,
59
+ $between: Op.between,
60
+ $notBetween: Op.notBetween,
61
+ $in: Op.in,
62
+ $notIn: Op.notIn,
63
+ $like: Op.like,
64
+ $notLike: Op.notLike,
65
+ $iLike: Op.iLike,
66
+ $notILike: Op.notILike,
67
+ $regexp: Op.regexp,
68
+ $notRegexp: Op.notRegexp,
69
+ $iRegexp: Op.iRegexp,
70
+ $notIRegexp: Op.notIRegexp,
71
+ $overlap: Op.overlap,
72
+ $contains: Op.contains,
73
+ $contained: Op.contained,
74
+ $any: Op.any,
75
+ $adjacent: Op.adjacent,
76
+ $strictLeft: Op.strictLeft,
77
+ $strictRight: Op.strictRight,
78
+ $noExtendRight: Op.noExtendRight,
79
+ $noExtendLeft: Op.noExtendLeft,
80
+ };
81
+ /**
82
+ * A where clause as plain, serializable JSON.
83
+ *
84
+ * @remarks
85
+ * Gives a remote caller the same expressive power Sequelize offers locally —
86
+ * comparison, set membership, pattern matching, regular expressions and range
87
+ * operators, nested arbitrarily through `$and` and `$or`. Every operator is a
88
+ * `$`-prefixed string rather than a symbol, because symbols do not survive the wire;
89
+ * {@link FILTER_OPS} does the translation on arrival.
90
+ *
91
+ * Two things follow from how `query.toWhereOptions` walks it. Keys are read
92
+ * recursively, so a value that is itself an object is treated as a nested filter and
93
+ * only a non-object value ends the walk. And any key that is NOT a known operator is
94
+ * kept verbatim as a column name — which is what lets you mix columns and operators
95
+ * in one object, and also means a typo becomes a column rather than a complaint.
96
+ *
97
+ * The declared property types are the common cases rather than hard limits; the
98
+ * runtime walk does not enforce them.
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * // type is 'fast' or 'std', and the reservation was created this year
103
+ * const filter = {
104
+ * $or: [{ type: 'fast' }, { type: 'std' }],
105
+ * createdAt: { $gte: '2026-01-01' },
106
+ * } as FilterInput;
107
+ * ```
108
+ */
109
+ export class FilterInput {
110
+ /** Every nested condition must hold (SQL `AND`). */
111
+ $and;
112
+ /** At least one nested condition must hold (SQL `OR`). */
113
+ $or;
114
+ /** Greater than. */
115
+ $gt;
116
+ /** Greater than or equal to. */
117
+ $gte;
118
+ /** Less than. */
119
+ $lt;
120
+ /** Less than or equal to. */
121
+ $lte;
122
+ /** Not equal to. */
123
+ $ne;
124
+ /** Equal to. With `null`, becomes `IS NULL`. */
125
+ $eq;
126
+ /** Negates the nested condition (SQL `NOT`). */
127
+ $not;
128
+ /** Within the inclusive `[low, high]` pair (SQL `BETWEEN`). */
129
+ $between;
130
+ /** Outside the inclusive `[low, high]` pair. */
131
+ $notBetween;
132
+ /** One of the listed values (SQL `IN`). An empty list matches nothing. */
133
+ $in;
134
+ /** None of the listed values (SQL `NOT IN`). */
135
+ $notIn;
136
+ /** Case-sensitive pattern match, `%` and `_` as wildcards (SQL `LIKE`). */
137
+ $like;
138
+ /** Fails a case-sensitive pattern match. */
139
+ $notLike;
140
+ /** Case-insensitive pattern match (Postgres `ILIKE`). */
141
+ $iLike;
142
+ /** Fails a case-insensitive pattern match. */
143
+ $notILike;
144
+ /** Matches a POSIX regular expression (Postgres `~`). */
145
+ $regexp;
146
+ /** Fails a POSIX regular expression (Postgres `!~`). */
147
+ $notRegexp;
148
+ /** Matches a regular expression, case-insensitively (Postgres `~*`). */
149
+ $iRegexp;
150
+ /** Fails a case-insensitive regular expression (Postgres `!~*`). */
151
+ $notIRegexp;
152
+ /** Ranges share at least one value (Postgres `&&`). */
153
+ $overlap;
154
+ /** The column's range contains this value or range (Postgres `@>`). */
155
+ $contains;
156
+ /** The column's range is contained by this one (Postgres `<@`). */
157
+ $contained;
158
+ /** Equals any element of the array (Postgres `= ANY`). */
159
+ $any;
160
+ /** Ranges touch without overlapping (Postgres `-|-`). */
161
+ $adjacent;
162
+ /** Range lies entirely to the left of this one (Postgres `<<`). */
163
+ $strictLeft;
164
+ /** Range lies entirely to the right of this one (Postgres `>>`). */
165
+ $strictRight;
166
+ /** Range does not extend past this one's right bound (Postgres `&<`). */
167
+ $noExtendRight;
168
+ /** Range does not extend past this one's left bound (Postgres `&>`). */
169
+ $noExtendLeft;
170
+ }
171
+ __decorate([
172
+ property('FilterInput | Array<FilterInput|number|string|boolean|null>', true),
173
+ __metadata("design:type", Object)
174
+ ], FilterInput.prototype, "$and", void 0);
175
+ __decorate([
176
+ property('FilterInput | Array<FilterInput|number|string|boolean|null>', true),
177
+ __metadata("design:type", Object)
178
+ ], FilterInput.prototype, "$or", void 0);
179
+ __decorate([
180
+ property('number', true),
181
+ __metadata("design:type", Number)
182
+ ], FilterInput.prototype, "$gt", void 0);
183
+ __decorate([
184
+ property('number', true),
185
+ __metadata("design:type", Number)
186
+ ], FilterInput.prototype, "$gte", void 0);
187
+ __decorate([
188
+ property('number', true),
189
+ __metadata("design:type", Number)
190
+ ], FilterInput.prototype, "$lt", void 0);
191
+ __decorate([
192
+ property('number', true),
193
+ __metadata("design:type", Number)
194
+ ], FilterInput.prototype, "$lte", void 0);
195
+ __decorate([
196
+ property('number | string', true),
197
+ __metadata("design:type", Object)
198
+ ], FilterInput.prototype, "$ne", void 0);
199
+ __decorate([
200
+ property('number | string | boolean | null', true),
201
+ __metadata("design:type", Object)
202
+ ], FilterInput.prototype, "$eq", void 0);
203
+ __decorate([
204
+ property('boolean', true),
205
+ __metadata("design:type", Boolean)
206
+ ], FilterInput.prototype, "$not", void 0);
207
+ __decorate([
208
+ property('Array<number | string>', true),
209
+ __metadata("design:type", Array)
210
+ ], FilterInput.prototype, "$between", void 0);
211
+ __decorate([
212
+ property('Array<number | string>', true),
213
+ __metadata("design:type", Array)
214
+ ], FilterInput.prototype, "$notBetween", void 0);
215
+ __decorate([
216
+ property('Array<number | string | boolean | null>', true),
217
+ __metadata("design:type", Array)
218
+ ], FilterInput.prototype, "$in", void 0);
219
+ __decorate([
220
+ property('Array<number | string | boolean | null>', true),
221
+ __metadata("design:type", Array)
222
+ ], FilterInput.prototype, "$notIn", void 0);
223
+ __decorate([
224
+ property('string', true),
225
+ __metadata("design:type", String)
226
+ ], FilterInput.prototype, "$like", void 0);
227
+ __decorate([
228
+ property('string', true),
229
+ __metadata("design:type", String)
230
+ ], FilterInput.prototype, "$notLike", void 0);
231
+ __decorate([
232
+ property('string', true),
233
+ __metadata("design:type", String)
234
+ ], FilterInput.prototype, "$iLike", void 0);
235
+ __decorate([
236
+ property('string', true),
237
+ __metadata("design:type", String)
238
+ ], FilterInput.prototype, "$notILike", void 0);
239
+ __decorate([
240
+ property('string', true),
241
+ __metadata("design:type", String)
242
+ ], FilterInput.prototype, "$regexp", void 0);
243
+ __decorate([
244
+ property('string', true),
245
+ __metadata("design:type", String)
246
+ ], FilterInput.prototype, "$notRegexp", void 0);
247
+ __decorate([
248
+ property('string', true),
249
+ __metadata("design:type", String)
250
+ ], FilterInput.prototype, "$iRegexp", void 0);
251
+ __decorate([
252
+ property('string', true),
253
+ __metadata("design:type", String)
254
+ ], FilterInput.prototype, "$notIRegexp", void 0);
255
+ __decorate([
256
+ property('[number, number]', true),
257
+ __metadata("design:type", Array)
258
+ ], FilterInput.prototype, "$overlap", void 0);
259
+ __decorate([
260
+ property('number | [number, number]', true),
261
+ __metadata("design:type", Object)
262
+ ], FilterInput.prototype, "$contains", void 0);
263
+ __decorate([
264
+ property('[number, number]', true),
265
+ __metadata("design:type", Array)
266
+ ], FilterInput.prototype, "$contained", void 0);
267
+ __decorate([
268
+ property('number[] | string[]', true),
269
+ __metadata("design:type", Array)
270
+ ], FilterInput.prototype, "$any", void 0);
271
+ __decorate([
272
+ property('[number, number]', true),
273
+ __metadata("design:type", Array)
274
+ ], FilterInput.prototype, "$adjacent", void 0);
275
+ __decorate([
276
+ property('[number, number]', true),
277
+ __metadata("design:type", Array)
278
+ ], FilterInput.prototype, "$strictLeft", void 0);
279
+ __decorate([
280
+ property('[number, number]', true),
281
+ __metadata("design:type", Array)
282
+ ], FilterInput.prototype, "$strictRight", void 0);
283
+ __decorate([
284
+ property('[number, number]', true),
285
+ __metadata("design:type", Array)
286
+ ], FilterInput.prototype, "$noExtendRight", void 0);
287
+ __decorate([
288
+ property('[number, number]', true),
289
+ __metadata("design:type", Array)
290
+ ], FilterInput.prototype, "$noExtendLeft", void 0);
291
+ //# sourceMappingURL=FilterInput.js.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A free-form object, describable to `@imqueue/rpc`.
3
+ *
4
+ * @remarks
5
+ * For the places where the shape genuinely is not known ahead of time — a `jsonb`
6
+ * column, a settings blob, a passthrough payload. `@indexed` gives it an RPC
7
+ * description, which a bare `Record<string, any>` cannot have: the RPC layer builds
8
+ * its service description from decorated classes, so an anonymous type would arrive
9
+ * at the client as nothing at all.
10
+ *
11
+ * Reach for it only when that is true. Every property typed this way is one the
12
+ * generated client cannot check.
13
+ */
14
+ export declare class JsonObject {
15
+ [property: string]: any;
16
+ }
@@ -0,0 +1,50 @@
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
+ /*!
8
+ * @imqueue/pg-sequelize - Sequelize ORM refines for @imqueue
9
+ *
10
+ * I'm Queue Software Project
11
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
25
+ *
26
+ * If you want to use this code in a closed source (commercial) project, you can
27
+ * purchase a proprietary commercial license. Please contact us at
28
+ * <support@imqueue.com> to get commercial licensing options.
29
+ */
30
+ import { indexed } from '@imqueue/rpc';
31
+ /**
32
+ * A free-form object, describable to `@imqueue/rpc`.
33
+ *
34
+ * @remarks
35
+ * For the places where the shape genuinely is not known ahead of time — a `jsonb`
36
+ * column, a settings blob, a passthrough payload. `@indexed` gives it an RPC
37
+ * description, which a bare `Record<string, any>` cannot have: the RPC layer builds
38
+ * its service description from decorated classes, so an anonymous type would arrive
39
+ * at the client as nothing at all.
40
+ *
41
+ * Reach for it only when that is true. Every property typed this way is one the
42
+ * generated client cannot check.
43
+ */
44
+ let JsonObject = class JsonObject {
45
+ };
46
+ JsonObject = __decorate([
47
+ indexed(() => `[property: string]: any`)
48
+ ], JsonObject);
49
+ export { JsonObject };
50
+ //# sourceMappingURL=JsonObject.js.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The two directions a column can be ordered in.
3
+ *
4
+ * @remarks
5
+ * The values are the SQL keywords, so they can be handed to Sequelize as they are.
6
+ */
7
+ export declare enum OrderDirection {
8
+ /** Ascending — also what any unrecognised direction becomes. */
9
+ asc = "ASC",
10
+ /** Descending. */
11
+ desc = "DESC"
12
+ }
13
+ /**
14
+ * The `OrderDirection` values as an `@imqueue/rpc` type description.
15
+ *
16
+ * @remarks
17
+ * `'ASC' | 'DESC'`, built from the enum so the description cannot drift from it.
18
+ * Used in the `@indexed` description of {@link OrderByInput}, and available for your
19
+ * own `@property` declarations that accept a direction.
20
+ */
21
+ export declare const ENUM_ORDER_DIRECTION = "'ASC' | 'DESC'";
22
+ /**
23
+ * Which columns to order by, and in which direction.
24
+ *
25
+ * @remarks
26
+ * Keyed by column name; `query.toOrderOptions` turns it into Sequelize's `order`
27
+ * array, preserving the key order of the object, so the first key is the primary
28
+ * sort.
29
+ *
30
+ * Direction values are coerced rather than validated: anything that does not read
31
+ * as `desc`, case-insensitively, becomes ascending. That is deliberate — the value
32
+ * arrives from a remote caller and ends up in SQL, so an unrecognised direction has
33
+ * to become a safe default rather than being passed through. It does mean a typo
34
+ * silently sorts the other way.
35
+ *
36
+ * Column names are NOT coerced, and they reach the query as given.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const orderBy: OrderByInput = { type: OrderDirection.asc, createdAt: OrderDirection.desc };
41
+ * ```
42
+ */
43
+ export declare class OrderByInput {
44
+ [fieldName: string]: OrderDirection;
45
+ }
@@ -0,0 +1,80 @@
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
+ /*!
8
+ * @imqueue/pg-sequelize - Sequelize ORM refines for @imqueue
9
+ *
10
+ * I'm Queue Software Project
11
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
12
+ *
13
+ * This program is free software: you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation, either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
25
+ *
26
+ * If you want to use this code in a closed source (commercial) project, you can
27
+ * purchase a proprietary commercial license. Please contact us at
28
+ * <support@imqueue.com> to get commercial licensing options.
29
+ */
30
+ import { indexed } from '@imqueue/rpc';
31
+ /**
32
+ * The two directions a column can be ordered in.
33
+ *
34
+ * @remarks
35
+ * The values are the SQL keywords, so they can be handed to Sequelize as they are.
36
+ */
37
+ export var OrderDirection;
38
+ (function (OrderDirection) {
39
+ /** Ascending — also what any unrecognised direction becomes. */
40
+ OrderDirection["asc"] = "ASC";
41
+ /** Descending. */
42
+ OrderDirection["desc"] = "DESC";
43
+ })(OrderDirection || (OrderDirection = {}));
44
+ /**
45
+ * The `OrderDirection` values as an `@imqueue/rpc` type description.
46
+ *
47
+ * @remarks
48
+ * `'ASC' | 'DESC'`, built from the enum so the description cannot drift from it.
49
+ * Used in the `@indexed` description of {@link OrderByInput}, and available for your
50
+ * own `@property` declarations that accept a direction.
51
+ */
52
+ export const ENUM_ORDER_DIRECTION = `'${OrderDirection.asc}' | '${OrderDirection.desc}'`;
53
+ /**
54
+ * Which columns to order by, and in which direction.
55
+ *
56
+ * @remarks
57
+ * Keyed by column name; `query.toOrderOptions` turns it into Sequelize's `order`
58
+ * array, preserving the key order of the object, so the first key is the primary
59
+ * sort.
60
+ *
61
+ * Direction values are coerced rather than validated: anything that does not read
62
+ * as `desc`, case-insensitively, becomes ascending. That is deliberate — the value
63
+ * arrives from a remote caller and ends up in SQL, so an unrecognised direction has
64
+ * to become a safe default rather than being passed through. It does mean a typo
65
+ * silently sorts the other way.
66
+ *
67
+ * Column names are NOT coerced, and they reach the query as given.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const orderBy: OrderByInput = { type: OrderDirection.asc, createdAt: OrderDirection.desc };
72
+ * ```
73
+ */
74
+ let OrderByInput = class OrderByInput {
75
+ };
76
+ OrderByInput = __decorate([
77
+ indexed(() => `[fieldName: string]: ${ENUM_ORDER_DIRECTION}`)
78
+ ], OrderByInput);
79
+ export { OrderByInput };
80
+ //# sourceMappingURL=OrderByInput.js.map
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Where a page starts and how big it is.
3
+ *
4
+ * @remarks
5
+ * Turned into Sequelize's `offset`/`limit` by `query.toLimitOptions`, which treats
6
+ * this input as advisory rather than authoritative — see the notes on each property.
7
+ * A negative `limit` is the interesting case: it means "the last N rows", and it is
8
+ * the only reason `count` exists.
9
+ */
10
+ export declare class PaginationInput {
11
+ /**
12
+ * Rows to skip before the page starts.
13
+ *
14
+ * @remarks
15
+ * Ignored when `limit` is absent or zero, since there is then no page to
16
+ * position. With a negative `limit` and an `offset` of zero it is computed
17
+ * instead — see `limit`.
18
+ */
19
+ offset: number;
20
+ /**
21
+ * Rows in the page. Negative counts back from the end of the set.
22
+ *
23
+ * @remarks
24
+ * Zero, absent or non-numeric means no pagination at all: `toLimitOptions`
25
+ * returns an empty options object and the query is left unbounded. That is a
26
+ * quiet default worth knowing about — a caller who sends `limit: 0` expecting
27
+ * "no rows" gets every row.
28
+ *
29
+ * A negative value takes the absolute value as the page size and, when `offset`
30
+ * is zero, positions the window at the end of the set: `count - limit`, clamped
31
+ * at zero. So `{ limit: -10, count: 1340 }` is the last ten rows. Without a
32
+ * `count` the offset computes to a negative number and clamps to zero, giving
33
+ * the FIRST ten rows rather than the last — the two properties go together.
34
+ */
35
+ limit: number;
36
+ /**
37
+ * Total rows in the set, used only to place a negative `limit`.
38
+ *
39
+ * @remarks
40
+ * Nothing validates it against the real total, and it is ignored entirely for a
41
+ * positive `limit`.
42
+ */
43
+ count?: number;
44
+ }