ng-qubee 2.0.3 → 2.0.5
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/README.md +8 -0
- package/fesm2022/ng-qubee.mjs +257 -66
- package/fesm2022/ng-qubee.mjs.map +1 -1
- package/lib/errors/invalid-limit.error.d.ts +3 -0
- package/lib/errors/invalid-model-name.error.d.ts +3 -0
- package/lib/errors/invalid-page-number.error.d.ts +3 -0
- package/lib/services/nest.service.d.ts +113 -12
- package/package.json +27 -5
- package/public-api.d.ts +5 -0
- package/esm2022/lib/enums/sort.enum.mjs +0 -6
- package/esm2022/lib/errors/key-not-found.error.mjs +0 -6
- package/esm2022/lib/errors/unselectable-model.error.mjs +0 -6
- package/esm2022/lib/interfaces/config.interface.mjs +0 -2
- package/esm2022/lib/interfaces/fields.interface.mjs +0 -2
- package/esm2022/lib/interfaces/filters.interface.mjs +0 -2
- package/esm2022/lib/interfaces/normalized.interface.mjs +0 -2
- package/esm2022/lib/interfaces/paginated-object.interface.mjs +0 -2
- package/esm2022/lib/interfaces/pagination-config.interface.mjs +0 -2
- package/esm2022/lib/interfaces/query-builder-config.interface.mjs +0 -2
- package/esm2022/lib/interfaces/query-builder-state.interface.mjs +0 -2
- package/esm2022/lib/interfaces/sort.interface.mjs +0 -2
- package/esm2022/lib/models/paginated-collection.mjs +0 -47
- package/esm2022/lib/models/query-builder-options.mjs +0 -12
- package/esm2022/lib/models/response-options.mjs +0 -17
- package/esm2022/lib/ng-qubee.module.mjs +0 -42
- package/esm2022/lib/provide-ngqubee.mjs +0 -39
- package/esm2022/lib/services/nest.service.mjs +0 -173
- package/esm2022/lib/services/ng-qubee.service.mjs +0 -319
- package/esm2022/lib/services/pagination.service.mjs +0 -23
- package/esm2022/ng-qubee.mjs +0 -5
- package/esm2022/public-api.mjs +0 -9
package/README.md
CHANGED
|
@@ -17,6 +17,14 @@ NgQubee uses some open source projects to work properly:
|
|
|
17
17
|
|
|
18
18
|
And of course NgQubee itself is open source with a [public repository][ng-qubee] on GitHub.
|
|
19
19
|
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
NgQubee requires:
|
|
23
|
+
- **Angular**: >=16.0.0 <22.0.0 (supports Angular 16 through 21)
|
|
24
|
+
- **RxJS**: ^6.5.0 || ^7.0.0
|
|
25
|
+
|
|
26
|
+
> **Note**: Angular 16+ is required because NgQubee uses Angular Signals for state management.
|
|
27
|
+
|
|
20
28
|
## Installation
|
|
21
29
|
Install NgQubee via NPM
|
|
22
30
|
|
package/fesm2022/ng-qubee.mjs
CHANGED
|
@@ -10,6 +10,17 @@ class KeyNotFoundError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
class PaginatedCollection {
|
|
13
|
+
data;
|
|
14
|
+
page;
|
|
15
|
+
from;
|
|
16
|
+
to;
|
|
17
|
+
total;
|
|
18
|
+
perPage;
|
|
19
|
+
prevPageUrl;
|
|
20
|
+
nextPageUrl;
|
|
21
|
+
lastPage;
|
|
22
|
+
firstPageUrl;
|
|
23
|
+
lastPageUrl;
|
|
13
24
|
constructor(data, page, from, to, total, perPage, prevPageUrl, nextPageUrl, lastPage, firstPageUrl, lastPageUrl) {
|
|
14
25
|
this.data = data;
|
|
15
26
|
this.page = page;
|
|
@@ -68,6 +79,13 @@ class UnselectableModelError extends Error {
|
|
|
68
79
|
}
|
|
69
80
|
|
|
70
81
|
class QueryBuilderOptions {
|
|
82
|
+
appends;
|
|
83
|
+
fields;
|
|
84
|
+
filters;
|
|
85
|
+
includes;
|
|
86
|
+
limit;
|
|
87
|
+
page;
|
|
88
|
+
sort;
|
|
71
89
|
constructor(options) {
|
|
72
90
|
this.appends = options.appends || 'append';
|
|
73
91
|
this.fields = options.fields || 'fields';
|
|
@@ -79,6 +97,27 @@ class QueryBuilderOptions {
|
|
|
79
97
|
}
|
|
80
98
|
}
|
|
81
99
|
|
|
100
|
+
class InvalidModelNameError extends Error {
|
|
101
|
+
constructor(model) {
|
|
102
|
+
super(`Invalid model name: Model name must be a non-empty string. Received: ${JSON.stringify(model)}`);
|
|
103
|
+
this.name = 'InvalidModelNameError';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
class InvalidPageNumberError extends Error {
|
|
108
|
+
constructor(page) {
|
|
109
|
+
super(`Invalid page number: Page must be a positive integer greater than 0. Received: ${page}`);
|
|
110
|
+
this.name = 'InvalidPageNumberError';
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
class InvalidLimitError extends Error {
|
|
115
|
+
constructor(limit) {
|
|
116
|
+
super(`Invalid limit value: Limit must be a positive integer greater than 0. Received: ${limit}`);
|
|
117
|
+
this.name = 'InvalidLimitError';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
82
121
|
const INITIAL_STATE = {
|
|
83
122
|
baseUrl: '',
|
|
84
123
|
fields: {},
|
|
@@ -90,40 +129,77 @@ const INITIAL_STATE = {
|
|
|
90
129
|
sorts: []
|
|
91
130
|
};
|
|
92
131
|
class NestService {
|
|
132
|
+
/**
|
|
133
|
+
* Private writable signal that holds the Query Builder state
|
|
134
|
+
*
|
|
135
|
+
* @type {IQueryBuilderState}
|
|
136
|
+
*/
|
|
137
|
+
_nest = signal(this._clone(INITIAL_STATE));
|
|
138
|
+
/**
|
|
139
|
+
* A computed signal that makes readonly the writable signal _nest
|
|
140
|
+
*
|
|
141
|
+
* @type {Signal<IQueryBuilderState>}
|
|
142
|
+
*/
|
|
143
|
+
nest = computed(() => this._clone(this._nest()));
|
|
93
144
|
constructor() {
|
|
94
|
-
/**
|
|
95
|
-
* Private writable signal that holds the Query Builder state
|
|
96
|
-
*
|
|
97
|
-
* @type {IQueryBuilderState}
|
|
98
|
-
*/
|
|
99
|
-
this._nest = signal(this._clone(INITIAL_STATE));
|
|
100
|
-
/**
|
|
101
|
-
* A computed signal that makes readonly the writable signal _nest
|
|
102
|
-
*
|
|
103
|
-
* @type {Signal<IQueryBuilderState>}
|
|
104
|
-
*/
|
|
105
|
-
this.nest = computed(() => this._clone(this._nest()));
|
|
106
145
|
// Nothing to see here 👮🏻♀️
|
|
107
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Set the base URL for the API
|
|
149
|
+
*
|
|
150
|
+
* @param {string} baseUrl - The base URL to prepend to generated URIs
|
|
151
|
+
* @example
|
|
152
|
+
* service.baseUrl = 'https://api.example.com';
|
|
153
|
+
*/
|
|
108
154
|
set baseUrl(baseUrl) {
|
|
109
155
|
this._nest.update(nest => ({
|
|
110
156
|
...nest,
|
|
111
157
|
baseUrl
|
|
112
158
|
}));
|
|
113
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Set the limit for paginated results
|
|
162
|
+
* Must be a positive integer greater than 0
|
|
163
|
+
*
|
|
164
|
+
* @param {number} limit - The number of items per page
|
|
165
|
+
* @throws {InvalidLimitError} If limit is not a positive integer
|
|
166
|
+
* @example
|
|
167
|
+
* service.limit = 25;
|
|
168
|
+
*/
|
|
114
169
|
set limit(limit) {
|
|
170
|
+
this._validateLimit(limit);
|
|
115
171
|
this._nest.update(nest => ({
|
|
116
172
|
...nest,
|
|
117
173
|
limit
|
|
118
174
|
}));
|
|
119
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Set the model name for the query
|
|
178
|
+
* Must be a non-empty string
|
|
179
|
+
*
|
|
180
|
+
* @param {string} model - The model/resource name (e.g., 'users', 'posts')
|
|
181
|
+
* @throws {InvalidModelNameError} If model is not a non-empty string
|
|
182
|
+
* @example
|
|
183
|
+
* service.model = 'users';
|
|
184
|
+
*/
|
|
120
185
|
set model(model) {
|
|
186
|
+
this._validateModelName(model);
|
|
121
187
|
this._nest.update(nest => ({
|
|
122
188
|
...nest,
|
|
123
189
|
model
|
|
124
190
|
}));
|
|
125
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Set the page number for pagination
|
|
194
|
+
* Must be a positive integer greater than 0
|
|
195
|
+
*
|
|
196
|
+
* @param {number} page - The page number to fetch
|
|
197
|
+
* @throws {InvalidPageNumberError} If page is not a positive integer
|
|
198
|
+
* @example
|
|
199
|
+
* service.page = 2;
|
|
200
|
+
*/
|
|
126
201
|
set page(page) {
|
|
202
|
+
this._validatePageNumber(page);
|
|
127
203
|
this._nest.update(nest => ({
|
|
128
204
|
...nest,
|
|
129
205
|
page
|
|
@@ -132,49 +208,123 @@ class NestService {
|
|
|
132
208
|
_clone(obj) {
|
|
133
209
|
return JSON.parse(JSON.stringify(obj));
|
|
134
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Validates that the model name is a non-empty string
|
|
213
|
+
*
|
|
214
|
+
* @param {string} model - The model name to validate
|
|
215
|
+
* @throws {InvalidModelNameError} If model is not a non-empty string
|
|
216
|
+
* @private
|
|
217
|
+
*/
|
|
218
|
+
_validateModelName(model) {
|
|
219
|
+
if (!model || typeof model !== 'string' || model.trim().length === 0) {
|
|
220
|
+
throw new InvalidModelNameError(model);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Validates that the page number is a positive integer
|
|
225
|
+
*
|
|
226
|
+
* @param {number} page - The page number to validate
|
|
227
|
+
* @throws {InvalidPageNumberError} If page is not a positive integer
|
|
228
|
+
* @private
|
|
229
|
+
*/
|
|
230
|
+
_validatePageNumber(page) {
|
|
231
|
+
if (!Number.isInteger(page) || page < 1) {
|
|
232
|
+
throw new InvalidPageNumberError(page);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Validates that the limit is a positive integer
|
|
237
|
+
*
|
|
238
|
+
* @param {number} limit - The limit value to validate
|
|
239
|
+
* @throws {InvalidLimitError} If limit is not a positive integer
|
|
240
|
+
* @private
|
|
241
|
+
*/
|
|
242
|
+
_validateLimit(limit) {
|
|
243
|
+
if (!Number.isInteger(limit) || limit < 1) {
|
|
244
|
+
throw new InvalidLimitError(limit);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
135
247
|
/**
|
|
136
248
|
* Add selectable fields for the given model to the request
|
|
249
|
+
* Automatically prevents duplicate fields for each model
|
|
137
250
|
*
|
|
138
|
-
* @param {IFields} fields
|
|
251
|
+
* @param {IFields} fields - Object mapping model names to arrays of field names
|
|
139
252
|
* @return {void}
|
|
140
|
-
* @
|
|
253
|
+
* @example
|
|
254
|
+
* service.addFields({ users: ['id', 'email', 'username'] });
|
|
255
|
+
* service.addFields({ posts: ['title', 'content'] });
|
|
141
256
|
*/
|
|
142
257
|
addFields(fields) {
|
|
143
|
-
this._nest.update(nest =>
|
|
144
|
-
...nest
|
|
145
|
-
fields
|
|
146
|
-
|
|
258
|
+
this._nest.update(nest => {
|
|
259
|
+
const mergedFields = { ...nest.fields };
|
|
260
|
+
Object.keys(fields).forEach(model => {
|
|
261
|
+
const existingFields = mergedFields[model] || [];
|
|
262
|
+
const newFields = fields[model];
|
|
263
|
+
// Use Set to prevent duplicates
|
|
264
|
+
const uniqueFields = Array.from(new Set([...existingFields, ...newFields]));
|
|
265
|
+
mergedFields[model] = uniqueFields;
|
|
266
|
+
});
|
|
267
|
+
return {
|
|
268
|
+
...nest,
|
|
269
|
+
fields: mergedFields
|
|
270
|
+
};
|
|
271
|
+
});
|
|
147
272
|
}
|
|
148
273
|
/**
|
|
149
274
|
* Add filters to the request
|
|
275
|
+
* Automatically prevents duplicate filter values for each filter key
|
|
150
276
|
*
|
|
151
|
-
* @param {IFilters} filters
|
|
152
|
-
* @
|
|
277
|
+
* @param {IFilters} filters - Object mapping filter keys to arrays of values
|
|
278
|
+
* @return {void}
|
|
279
|
+
* @example
|
|
280
|
+
* service.addFilters({ id: [1, 2, 3] });
|
|
281
|
+
* service.addFilters({ status: ['active', 'pending'] });
|
|
153
282
|
*/
|
|
154
283
|
addFilters(filters) {
|
|
155
|
-
this._nest.update(nest =>
|
|
156
|
-
...nest
|
|
157
|
-
filters
|
|
158
|
-
|
|
284
|
+
this._nest.update(nest => {
|
|
285
|
+
const mergedFilters = { ...nest.filters };
|
|
286
|
+
Object.keys(filters).forEach(key => {
|
|
287
|
+
const existingValues = mergedFilters[key] || [];
|
|
288
|
+
const newValues = filters[key];
|
|
289
|
+
// Use Set to prevent duplicates
|
|
290
|
+
const uniqueValues = Array.from(new Set([...existingValues, ...newValues]));
|
|
291
|
+
mergedFilters[key] = uniqueValues;
|
|
292
|
+
});
|
|
293
|
+
return {
|
|
294
|
+
...nest,
|
|
295
|
+
filters: mergedFilters
|
|
296
|
+
};
|
|
297
|
+
});
|
|
159
298
|
}
|
|
160
299
|
/**
|
|
161
300
|
* Add resources to include with the request
|
|
301
|
+
* Automatically prevents duplicate includes
|
|
162
302
|
*
|
|
163
|
-
* @param {string[]} includes
|
|
303
|
+
* @param {string[]} includes - Array of model names to include in the response
|
|
164
304
|
* @return {void}
|
|
165
|
-
* @
|
|
305
|
+
* @example
|
|
306
|
+
* service.addIncludes(['profile', 'posts']);
|
|
307
|
+
* service.addIncludes(['comments']);
|
|
166
308
|
*/
|
|
167
309
|
addIncludes(includes) {
|
|
168
|
-
this._nest.update(nest =>
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
310
|
+
this._nest.update(nest => {
|
|
311
|
+
// Use Set to prevent duplicates
|
|
312
|
+
const uniqueIncludes = Array.from(new Set([...nest.includes, ...includes]));
|
|
313
|
+
return {
|
|
314
|
+
...nest,
|
|
315
|
+
includes: uniqueIncludes
|
|
316
|
+
};
|
|
317
|
+
});
|
|
172
318
|
}
|
|
173
319
|
/**
|
|
174
320
|
* Add a field that should be used for sorting data
|
|
175
321
|
*
|
|
176
|
-
* @param {ISort} sort
|
|
322
|
+
* @param {ISort} sort - Sort configuration with field name and order (ASC/DESC)
|
|
177
323
|
* @return {void}
|
|
324
|
+
* @example
|
|
325
|
+
* import { SortEnum } from 'ng-qubee';
|
|
326
|
+
* service.addSort({ field: 'created_at', order: SortEnum.DESC });
|
|
327
|
+
* service.addSort({ field: 'name', order: SortEnum.ASC });
|
|
178
328
|
*/
|
|
179
329
|
addSort(sort) {
|
|
180
330
|
this._nest.update(nest => ({
|
|
@@ -184,16 +334,22 @@ class NestService {
|
|
|
184
334
|
}
|
|
185
335
|
/**
|
|
186
336
|
* Remove fields for the given model
|
|
337
|
+
* Uses deep cloning to prevent mutations to the original state
|
|
187
338
|
*
|
|
188
|
-
* @param {IFields} fields
|
|
339
|
+
* @param {IFields} fields - Object mapping model names to arrays of field names to remove
|
|
340
|
+
* @return {void}
|
|
341
|
+
* @example
|
|
342
|
+
* service.deleteFields({ users: ['email'] });
|
|
343
|
+
* service.deleteFields({ posts: ['content', 'body'] });
|
|
189
344
|
*/
|
|
190
345
|
deleteFields(fields) {
|
|
191
|
-
|
|
346
|
+
// Deep clone the fields object to prevent mutations
|
|
347
|
+
const f = this._clone(this._nest().fields);
|
|
192
348
|
Object.keys(fields).forEach(k => {
|
|
193
349
|
if (!(k in f)) {
|
|
194
350
|
return;
|
|
195
351
|
}
|
|
196
|
-
f[k] =
|
|
352
|
+
f[k] = f[k].filter(v => !fields[k].includes(v));
|
|
197
353
|
});
|
|
198
354
|
this._nest.update(nest => ({
|
|
199
355
|
...nest,
|
|
@@ -201,12 +357,18 @@ class NestService {
|
|
|
201
357
|
}));
|
|
202
358
|
}
|
|
203
359
|
/**
|
|
360
|
+
* Remove filters from the request
|
|
361
|
+
* Uses deep cloning to prevent mutations to the original state
|
|
204
362
|
*
|
|
205
|
-
* @param filters
|
|
206
|
-
* @
|
|
363
|
+
* @param {...string[]} filters - Filter keys to remove
|
|
364
|
+
* @return {void}
|
|
365
|
+
* @example
|
|
366
|
+
* service.deleteFilters('id');
|
|
367
|
+
* service.deleteFilters('status', 'type');
|
|
207
368
|
*/
|
|
208
369
|
deleteFilters(...filters) {
|
|
209
|
-
|
|
370
|
+
// Deep clone the filters object to prevent mutations
|
|
371
|
+
const f = this._clone(this._nest().filters);
|
|
210
372
|
filters.forEach(k => delete f[k]);
|
|
211
373
|
this._nest.update(nest => ({
|
|
212
374
|
...nest,
|
|
@@ -214,8 +376,13 @@ class NestService {
|
|
|
214
376
|
}));
|
|
215
377
|
}
|
|
216
378
|
/**
|
|
379
|
+
* Remove includes from the request
|
|
217
380
|
*
|
|
218
|
-
* @param includes
|
|
381
|
+
* @param {...string[]} includes - Include names to remove
|
|
382
|
+
* @return {void}
|
|
383
|
+
* @example
|
|
384
|
+
* service.deleteIncludes('profile');
|
|
385
|
+
* service.deleteIncludes('posts', 'comments');
|
|
219
386
|
*/
|
|
220
387
|
deleteIncludes(...includes) {
|
|
221
388
|
this._nest.update(nest => ({
|
|
@@ -224,8 +391,13 @@ class NestService {
|
|
|
224
391
|
}));
|
|
225
392
|
}
|
|
226
393
|
/**
|
|
394
|
+
* Remove sorts from the request by field name
|
|
227
395
|
*
|
|
228
|
-
* @param sorts
|
|
396
|
+
* @param {...string[]} sorts - Field names of sorts to remove
|
|
397
|
+
* @return {void}
|
|
398
|
+
* @example
|
|
399
|
+
* service.deleteSorts('created_at');
|
|
400
|
+
* service.deleteSorts('name', 'created_at');
|
|
229
401
|
*/
|
|
230
402
|
deleteSorts(...sorts) {
|
|
231
403
|
const s = [...this._nest().sorts];
|
|
@@ -240,25 +412,36 @@ class NestService {
|
|
|
240
412
|
sorts: s
|
|
241
413
|
}));
|
|
242
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* Reset the query builder state to initial values
|
|
417
|
+
* Clears all fields, filters, includes, sorts, and resets pagination
|
|
418
|
+
*
|
|
419
|
+
* @return {void}
|
|
420
|
+
* @example
|
|
421
|
+
* service.reset();
|
|
422
|
+
* // State is now: { baseUrl: '', fields: {}, filters: {}, includes: [], limit: 15, model: '', page: 1, sorts: [] }
|
|
423
|
+
*/
|
|
243
424
|
reset() {
|
|
244
425
|
this._nest.update(_ => this._clone(INITIAL_STATE));
|
|
245
426
|
}
|
|
246
|
-
static
|
|
247
|
-
static
|
|
427
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NestService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
428
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NestService });
|
|
248
429
|
}
|
|
249
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
430
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NestService, decorators: [{
|
|
250
431
|
type: Injectable
|
|
251
432
|
}], ctorParameters: () => [] });
|
|
252
433
|
|
|
253
434
|
class NgQubeeService {
|
|
435
|
+
_nestService;
|
|
436
|
+
_options;
|
|
437
|
+
/**
|
|
438
|
+
* This property serves as an accumulator for holding the composed string with each query param
|
|
439
|
+
*/
|
|
440
|
+
_uri = '';
|
|
441
|
+
_uri$ = new BehaviorSubject('');
|
|
442
|
+
uri$ = this._uri$.asObservable().pipe(filter(uri => !!uri));
|
|
254
443
|
constructor(_nestService, options = {}) {
|
|
255
444
|
this._nestService = _nestService;
|
|
256
|
-
/**
|
|
257
|
-
* This property serves as an accumulator for holding the composed string with each query param
|
|
258
|
-
*/
|
|
259
|
-
this._uri = '';
|
|
260
|
-
this._uri$ = new BehaviorSubject('');
|
|
261
|
-
this.uri$ = this._uri$.asObservable().pipe(filter(uri => !!uri));
|
|
262
445
|
this._options = new QueryBuilderOptions(options);
|
|
263
446
|
}
|
|
264
447
|
_parseFields(s) {
|
|
@@ -350,12 +533,6 @@ class NgQubeeService {
|
|
|
350
533
|
_prepend(model) {
|
|
351
534
|
return this._uri ? '&' : `/${model}?`;
|
|
352
535
|
}
|
|
353
|
-
// private _removeArgIfEmpty(arg: string): string {
|
|
354
|
-
// const params = new URL(this._uri).searchParams;
|
|
355
|
-
// if (!params.get(arg)) {
|
|
356
|
-
// params.delete(arg);
|
|
357
|
-
// }
|
|
358
|
-
// }
|
|
359
536
|
/**
|
|
360
537
|
* Add fields to the select statement for the given model
|
|
361
538
|
*
|
|
@@ -546,10 +723,10 @@ class NgQubeeService {
|
|
|
546
723
|
this._nestService.page = page;
|
|
547
724
|
return this;
|
|
548
725
|
}
|
|
549
|
-
static
|
|
550
|
-
static
|
|
726
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NgQubeeService, deps: [{ token: NestService }, { token: 'QUERY_PARAMS_CONFIG', optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
727
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NgQubeeService });
|
|
551
728
|
}
|
|
552
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
729
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NgQubeeService, decorators: [{
|
|
553
730
|
type: Injectable
|
|
554
731
|
}], ctorParameters: () => [{ type: NestService }, { type: undefined, decorators: [{
|
|
555
732
|
type: Inject,
|
|
@@ -559,6 +736,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImpor
|
|
|
559
736
|
}] }] });
|
|
560
737
|
|
|
561
738
|
class ResponseOptions {
|
|
739
|
+
currentPage;
|
|
740
|
+
data;
|
|
741
|
+
firstPageUrl;
|
|
742
|
+
from;
|
|
743
|
+
lastPage;
|
|
744
|
+
lastPageUrl;
|
|
745
|
+
nextPageUrl;
|
|
746
|
+
path;
|
|
747
|
+
perPage;
|
|
748
|
+
prevPageUrl;
|
|
749
|
+
to;
|
|
750
|
+
total;
|
|
562
751
|
constructor(options) {
|
|
563
752
|
this.currentPage = options.currentPage || 'current_page';
|
|
564
753
|
this.data = options.data || 'data';
|
|
@@ -576,16 +765,18 @@ class ResponseOptions {
|
|
|
576
765
|
}
|
|
577
766
|
|
|
578
767
|
class PaginationService {
|
|
768
|
+
_options;
|
|
579
769
|
constructor(options = {}) {
|
|
580
770
|
this._options = new ResponseOptions(options);
|
|
581
771
|
}
|
|
772
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
582
773
|
paginate(response) {
|
|
583
774
|
return new PaginatedCollection(response[this._options.data], response[this._options.currentPage], response[this._options.from], response[this._options.to], response[this._options.total], response[this._options.perPage], response[this._options.prevPageUrl], response[this._options.nextPageUrl], response[this._options.lastPage], response[this._options.firstPageUrl], response[this._options.lastPageUrl]);
|
|
584
775
|
}
|
|
585
|
-
static
|
|
586
|
-
static
|
|
776
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: PaginationService, deps: [{ token: 'RESPONSE_OPTIONS', optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
777
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: PaginationService });
|
|
587
778
|
}
|
|
588
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
779
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: PaginationService, decorators: [{
|
|
589
780
|
type: Injectable
|
|
590
781
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
591
782
|
type: Inject,
|
|
@@ -612,15 +803,15 @@ class NgQubeeModule {
|
|
|
612
803
|
]
|
|
613
804
|
};
|
|
614
805
|
}
|
|
615
|
-
static
|
|
616
|
-
static
|
|
617
|
-
static
|
|
806
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NgQubeeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
807
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.5", ngImport: i0, type: NgQubeeModule });
|
|
808
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NgQubeeModule, providers: [{
|
|
618
809
|
deps: [NestService],
|
|
619
810
|
provide: NgQubeeService,
|
|
620
811
|
useFactory: (nestService) => new NgQubeeService(nestService, {})
|
|
621
|
-
}] });
|
|
812
|
+
}] });
|
|
622
813
|
}
|
|
623
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
814
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: NgQubeeModule, decorators: [{
|
|
624
815
|
type: NgModule,
|
|
625
816
|
args: [{
|
|
626
817
|
providers: [{
|
|
@@ -674,5 +865,5 @@ function provideNgQubee(config = {}) {
|
|
|
674
865
|
* Generated bundle index. Do not edit.
|
|
675
866
|
*/
|
|
676
867
|
|
|
677
|
-
export { NgQubeeModule, NgQubeeService, PaginatedCollection, PaginationService, provideNgQubee };
|
|
868
|
+
export { InvalidLimitError, InvalidModelNameError, InvalidPageNumberError, KeyNotFoundError, NgQubeeModule, NgQubeeService, PaginatedCollection, PaginationService, UnselectableModelError, provideNgQubee };
|
|
678
869
|
//# sourceMappingURL=ng-qubee.mjs.map
|