@squidcloud/local-backend 1.0.49 → 1.0.51
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/common/src/ai-assistant.context.d.ts +13 -13
- package/dist/common/src/ai-assistant.context.js +19 -19
- package/dist/common/src/ai-assistant.schemas.d.ts +243 -243
- package/dist/common/src/ai-assistant.schemas.js +210 -210
- package/dist/common/src/ai-assistant.types.d.ts +90 -90
- package/dist/common/src/ai-assistant.types.js +11 -11
- package/dist/common/src/api-call.context.d.ts +13 -13
- package/dist/common/src/api-call.context.js +16 -16
- package/dist/common/src/api.types.d.ts +23 -23
- package/dist/common/src/api.types.js +2 -2
- package/dist/common/src/application.schemas.d.ts +1168 -1168
- package/dist/common/src/application.schemas.js +741 -741
- package/dist/common/src/application.types.d.ts +228 -228
- package/dist/common/src/application.types.js +89 -89
- package/dist/common/src/backend-function.schemas.d.ts +3 -3
- package/dist/common/src/backend-function.schemas.js +12 -12
- package/dist/common/src/backend-function.types.d.ts +6 -6
- package/dist/common/src/backend-function.types.js +2 -2
- package/dist/common/src/backend-run.types.d.ts +54 -54
- package/dist/common/src/backend-run.types.js +96 -73
- package/dist/common/src/backend-run.types.js.map +1 -1
- package/dist/common/src/bundle-api.types.d.ts +63 -62
- package/dist/common/src/bundle-api.types.js +2 -2
- package/dist/common/src/bundle-data.types.d.ts +59 -59
- package/dist/common/src/bundle-data.types.js +2 -2
- package/dist/common/src/communication.types.d.ts +18 -18
- package/dist/common/src/communication.types.js +40 -40
- package/dist/common/src/context.types.d.ts +24 -24
- package/dist/common/src/context.types.js +2 -2
- package/dist/common/src/distributed-lock.context.d.ts +5 -5
- package/dist/common/src/distributed-lock.context.js +10 -10
- package/dist/common/src/document.types.d.ts +32 -32
- package/dist/common/src/document.types.js +50 -50
- package/dist/common/src/graphql.context.d.ts +14 -14
- package/dist/common/src/graphql.context.js +12 -12
- package/dist/common/src/graphql.types.d.ts +11 -11
- package/dist/common/src/graphql.types.js +34 -34
- package/dist/common/src/heartbeat.types.d.ts +4 -4
- package/dist/common/src/heartbeat.types.js +16 -16
- package/dist/common/src/http-status.enum.d.ts +50 -50
- package/dist/common/src/http-status.enum.js +54 -54
- package/dist/common/src/index.d.ts +53 -53
- package/dist/common/src/index.js +69 -69
- package/dist/common/src/integrations/ai_assistant.types.d.ts +30 -30
- package/dist/common/src/integrations/ai_assistant.types.js +2 -2
- package/dist/common/src/integrations/api.types.d.ts +80 -80
- package/dist/common/src/integrations/api.types.js +2 -2
- package/dist/common/src/integrations/auth.types.d.ts +39 -39
- package/dist/common/src/integrations/auth.types.js +2 -2
- package/dist/common/src/integrations/database.types.d.ts +236 -236
- package/dist/common/src/integrations/database.types.js +2 -2
- package/dist/common/src/integrations/index.d.ts +101 -101
- package/dist/common/src/integrations/index.js +105 -105
- package/dist/common/src/integrations/observability.types.d.ts +23 -23
- package/dist/common/src/integrations/observability.types.js +23 -23
- package/dist/common/src/integrations/observability.types.js.map +1 -1
- package/dist/common/src/logger.types.d.ts +21 -21
- package/dist/common/src/logger.types.js +11 -11
- package/dist/common/src/metrics.types.d.ts +73 -73
- package/dist/common/src/metrics.types.js +11 -11
- package/dist/common/src/mutation.context.d.ts +13 -13
- package/dist/common/src/mutation.context.js +26 -26
- package/dist/common/src/mutation.schemas.d.ts +5 -5
- package/dist/common/src/mutation.schemas.js +114 -114
- package/dist/common/src/mutation.types.d.ts +63 -63
- package/dist/common/src/mutation.types.js +142 -142
- package/dist/common/src/named-query.context.d.ts +4 -4
- package/dist/common/src/named-query.context.js +9 -9
- package/dist/common/src/named-query.schemas.d.ts +3 -3
- package/dist/common/src/named-query.schemas.js +13 -13
- package/dist/common/src/named-query.types.d.ts +8 -8
- package/dist/common/src/named-query.types.js +2 -2
- package/dist/common/src/query/base-query-builder.d.ts +65 -65
- package/dist/common/src/query/base-query-builder.js +294 -294
- package/dist/common/src/query/index.d.ts +3 -3
- package/dist/common/src/query/index.js +19 -19
- package/dist/common/src/query/query-context.d.ts +47 -47
- package/dist/common/src/query/query-context.js +159 -159
- package/dist/common/src/query/serialized-query.types.d.ts +24 -24
- package/dist/common/src/query/serialized-query.types.js +2 -2
- package/dist/common/src/query.types.d.ts +81 -81
- package/dist/common/src/query.types.js +153 -153
- package/dist/common/src/regions.d.ts +21 -21
- package/dist/common/src/regions.js +46 -46
- package/dist/common/src/schema/schema.types.d.ts +30 -30
- package/dist/common/src/schema/schema.types.js +172 -172
- package/dist/common/src/secret.schemas.d.ts +6 -6
- package/dist/common/src/secret.schemas.js +32 -32
- package/dist/common/src/secret.types.d.ts +49 -49
- package/dist/common/src/secret.types.js +5 -5
- package/dist/common/src/security.types.d.ts +3 -3
- package/dist/common/src/security.types.js +2 -2
- package/dist/common/src/socket.schemas.d.ts +3 -3
- package/dist/common/src/socket.schemas.js +58 -58
- package/dist/common/src/socket.types.d.ts +108 -108
- package/dist/common/src/socket.types.js +2 -2
- package/dist/common/src/time-units.d.ts +5 -5
- package/dist/common/src/time-units.js +8 -8
- package/dist/common/src/trigger.types.d.ts +15 -15
- package/dist/common/src/trigger.types.js +2 -2
- package/dist/common/src/types.d.ts +21 -21
- package/dist/common/src/types.js +2 -2
- package/dist/common/src/utils/array.d.ts +8 -8
- package/dist/common/src/utils/array.js +51 -51
- package/dist/common/src/utils/assert.d.ts +8 -8
- package/dist/common/src/utils/assert.js +49 -49
- package/dist/common/src/utils/error.d.ts +4 -4
- package/dist/common/src/utils/error.js +10 -10
- package/dist/common/src/utils/http.d.ts +2 -2
- package/dist/common/src/utils/http.js +40 -38
- package/dist/common/src/utils/http.js.map +1 -1
- package/dist/common/src/utils/id.d.ts +2 -2
- package/dist/common/src/utils/id.js +21 -21
- package/dist/common/src/utils/lock.manager.d.ts +9 -9
- package/dist/common/src/utils/lock.manager.js +39 -39
- package/dist/common/src/utils/nullish.d.ts +2 -2
- package/dist/common/src/utils/nullish.js +11 -11
- package/dist/common/src/utils/object.d.ts +5 -6
- package/dist/common/src/utils/object.js +75 -89
- package/dist/common/src/utils/object.js.map +1 -1
- package/dist/common/src/utils/serialization.d.ts +6 -6
- package/dist/common/src/utils/serialization.js +77 -77
- package/dist/common/src/utils/transforms.d.ts +18 -18
- package/dist/common/src/utils/transforms.js +92 -92
- package/dist/common/src/utils/url.d.ts +1 -1
- package/dist/common/src/utils/url.js +15 -15
- package/dist/common/src/utils/validation.d.ts +17 -17
- package/dist/common/src/utils/validation.js +209 -209
- package/dist/common/src/utils/validation.js.map +1 -1
- package/dist/common/src/webhook-response.d.ts +6 -7
- package/dist/common/src/webhook-response.js +2 -7
- package/dist/common/src/webhook-response.js.map +1 -1
- package/dist/internal-common/src/async-queue.d.ts +4 -4
- package/dist/internal-common/src/async-queue.js +17 -17
- package/dist/internal-common/src/code-executor.types.d.ts +13 -13
- package/dist/internal-common/src/code-executor.types.js +2 -2
- package/dist/internal-common/src/environment/environment.types.d.ts +74 -74
- package/dist/internal-common/src/environment/environment.types.js +2 -2
- package/dist/internal-common/src/environment/index.d.ts +6 -6
- package/dist/internal-common/src/environment/index.js +27 -27
- package/dist/internal-common/src/environment/local.environment.d.ts +2 -2
- package/dist/internal-common/src/environment/local.environment.js +62 -62
- package/dist/internal-common/src/filters/custom-exception.filter.d.ts +6 -6
- package/dist/internal-common/src/filters/custom-exception.filter.js +44 -44
- package/dist/internal-common/src/index.d.ts +14 -14
- package/dist/internal-common/src/index.js +32 -32
- package/dist/internal-common/src/interceptors/body.interceptor.d.ts +5 -5
- package/dist/internal-common/src/interceptors/body.interceptor.js +24 -24
- package/dist/internal-common/src/kafka/kafka.manager.d.ts +22 -22
- package/dist/internal-common/src/kafka/kafka.manager.js +129 -129
- package/dist/internal-common/src/kafka/kafka.types.d.ts +17 -17
- package/dist/internal-common/src/kafka/kafka.types.js +2 -2
- package/dist/internal-common/src/kafka-observability-publisher.d.ts +11 -11
- package/dist/internal-common/src/kafka-observability-publisher.js +20 -20
- package/dist/internal-common/src/local-dev.types.d.ts +31 -31
- package/dist/internal-common/src/local-dev.types.js +2 -2
- package/dist/internal-common/src/observability-publisher.d.ts +9 -9
- package/dist/internal-common/src/observability-publisher.js +58 -58
- package/dist/internal-common/src/observability.types.d.ts +17 -17
- package/dist/internal-common/src/observability.types.js +2 -2
- package/dist/internal-common/src/shutdown.manager.d.ts +20 -20
- package/dist/internal-common/src/shutdown.manager.js +75 -75
- package/dist/internal-common/src/utils.d.ts +5 -5
- package/dist/internal-common/src/utils.js +29 -29
- package/dist/local-backend/src/index.d.ts +4 -4
- package/dist/local-backend/src/index.js +20 -20
- package/dist/local-backend/src/local-backend-socket.service.d.ts +18 -18
- package/dist/local-backend/src/local-backend-socket.service.js +107 -108
- package/dist/local-backend/src/local-backend-socket.service.js.map +1 -1
- package/dist/local-backend/src/local-backend.app.d.ts +2 -2
- package/dist/local-backend/src/local-backend.app.js +19 -19
- package/dist/local-backend/src/local-backend.controller.d.ts +8 -8
- package/dist/local-backend/src/local-backend.controller.js +49 -49
- package/dist/local-backend/src/local-backend.module.d.ts +8 -8
- package/dist/local-backend/src/local-backend.module.js +53 -53
- package/dist/local-backend/src/local-backend.service.d.ts +15 -15
- package/dist/local-backend/src/local-backend.service.js +165 -165
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -1
|
@@ -1,295 +1,295 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Pagination = exports.BaseQueryBuilder = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const assert_1 = require("../utils/assert");
|
|
6
|
-
const object_1 = require("../utils/object");
|
|
7
|
-
class BaseQueryBuilder {
|
|
8
|
-
eq(fieldName, value) {
|
|
9
|
-
return this.where(fieldName, '==', value);
|
|
10
|
-
}
|
|
11
|
-
neq(fieldName, value) {
|
|
12
|
-
return this.where(fieldName, '!=', value);
|
|
13
|
-
}
|
|
14
|
-
in(fieldName, value) {
|
|
15
|
-
return this.where(fieldName, 'in', value);
|
|
16
|
-
}
|
|
17
|
-
nin(fieldName, value) {
|
|
18
|
-
return this.where(fieldName, 'not in', value);
|
|
19
|
-
}
|
|
20
|
-
gt(fieldName, value) {
|
|
21
|
-
return this.where(fieldName, '>', value);
|
|
22
|
-
}
|
|
23
|
-
gte(fieldName, value) {
|
|
24
|
-
return this.where(fieldName, '>=', value);
|
|
25
|
-
}
|
|
26
|
-
lt(fieldName, value) {
|
|
27
|
-
return this.where(fieldName, '<', value);
|
|
28
|
-
}
|
|
29
|
-
lte(fieldName, value) {
|
|
30
|
-
return this.where(fieldName, '<=', value);
|
|
31
|
-
}
|
|
32
|
-
like(fieldName, pattern, caseSensitive) {
|
|
33
|
-
return this.where(fieldName, caseSensitive ? 'like_cs' : 'like', pattern);
|
|
34
|
-
}
|
|
35
|
-
notLike(fieldName, pattern, caseSensitive) {
|
|
36
|
-
return this.where(fieldName, caseSensitive ? 'not like_cs' : 'not like', pattern);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.BaseQueryBuilder = BaseQueryBuilder;
|
|
40
|
-
class SnapshotEmitterWrapper {
|
|
41
|
-
constructor(snapshotEmitter, options, forward) {
|
|
42
|
-
this.options = options;
|
|
43
|
-
this.forward = forward;
|
|
44
|
-
this.destroySubject = new rxjs_1.Subject();
|
|
45
|
-
this.data = new rxjs_1.BehaviorSubject(undefined);
|
|
46
|
-
snapshotEmitter
|
|
47
|
-
.snapshots(this.options.subscribe)
|
|
48
|
-
.pipe((0, rxjs_1.takeUntil)(this.destroySubject))
|
|
49
|
-
.subscribe((data) => this.data.next(forward ? data : this.reverse(data)));
|
|
50
|
-
this.destroySubject.subscribe(() => this.data.complete());
|
|
51
|
-
}
|
|
52
|
-
reverse(data) {
|
|
53
|
-
const slice = data.slice(0, this.options.pageSize).reverse();
|
|
54
|
-
return [...slice, ...data.slice(this.options.pageSize)];
|
|
55
|
-
}
|
|
56
|
-
destroy() {
|
|
57
|
-
this.destroySubject.next();
|
|
58
|
-
this.destroySubject.complete();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
class Pagination {
|
|
62
|
-
constructor(snapshotEmitter, options = {}) {
|
|
63
|
-
this.isDestroyed = new rxjs_1.BehaviorSubject(false);
|
|
64
|
-
this.destroyedObs = this.isDestroyed.pipe((0, rxjs_1.filter)(Boolean), (0, rxjs_1.take)(1));
|
|
65
|
-
this._observeState = new rxjs_1.BehaviorSubject({
|
|
66
|
-
data: [],
|
|
67
|
-
hasNext: false,
|
|
68
|
-
hasPrev: false,
|
|
69
|
-
isLoading: true,
|
|
70
|
-
});
|
|
71
|
-
this.currentPageSnapshotEmitterWrapperSubject = new rxjs_1.BehaviorSubject(undefined);
|
|
72
|
-
this.options = Object.assign({ pageSize: 100, subscribe: true }, options);
|
|
73
|
-
this.templateSnapshotEmitter = snapshotEmitter.clone();
|
|
74
|
-
if (this.options.subscribe) {
|
|
75
|
-
this.firstPageSnapshotEmitterWrapper = new SnapshotEmitterWrapper(this.templateSnapshotEmitter.clone().limit(Math.min(this.options.pageSize * 3, 2000)), this.options, true);
|
|
76
|
-
this.firstPageDataAvailable = (0, rxjs_1.firstValueFrom)(this.firstPageSnapshotEmitterWrapper.data.pipe((0, rxjs_1.filter)(Boolean), (0, rxjs_1.raceWith)(this.isDestroyed)));
|
|
77
|
-
this.firstPageSnapshotEmitterWrapper.data.pipe((0, rxjs_1.filter)(Boolean)).subscribe((data) => {
|
|
78
|
-
if (!data.length) {
|
|
79
|
-
this.resetToFirstPageData();
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (!this.currentPageSnapshotEmitterWrapperSubject.value) {
|
|
83
|
-
this._observeState.next({
|
|
84
|
-
data: data.slice(0, this.options.pageSize),
|
|
85
|
-
hasNext: data.length > this.options.pageSize,
|
|
86
|
-
hasPrev: false,
|
|
87
|
-
isLoading: false,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
else if (!this._observeState.value.hasPrev &&
|
|
91
|
-
this.templateSnapshotEmitter.extractData(data[0]) !==
|
|
92
|
-
this.templateSnapshotEmitter.extractData(this._observeState.value.data[0])) {
|
|
93
|
-
this._observeState.next(Object.assign(Object.assign({}, this._observeState.value), { hasPrev: true }));
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
const firstPageEmitter = this.templateSnapshotEmitter.clone().limit(this.options.pageSize + 1);
|
|
99
|
-
this.currentPageSnapshotEmitterWrapperSubject.next(new SnapshotEmitterWrapper(firstPageEmitter, this.options, true));
|
|
100
|
-
}
|
|
101
|
-
this.currentPageSnapshotEmitterWrapperSubject
|
|
102
|
-
.pipe((0, rxjs_1.takeUntil)(this.destroyedObs), (0, rxjs_1.startWith)(undefined), (0, rxjs_1.pairwise)())
|
|
103
|
-
.subscribe(([before, after]) => {
|
|
104
|
-
if (before)
|
|
105
|
-
before.destroy();
|
|
106
|
-
if (!after)
|
|
107
|
-
return;
|
|
108
|
-
after.data.pipe((0, rxjs_1.filter)(Boolean)).subscribe((data) => {
|
|
109
|
-
var _a, _b, _c;
|
|
110
|
-
if (after.forward) {
|
|
111
|
-
let hasPrev = true;
|
|
112
|
-
if (this.options.subscribe) {
|
|
113
|
-
const firstPageData = (0, assert_1.truthy)((_a = this.firstPageSnapshotEmitterWrapper) === null || _a === void 0 ? void 0 : _a.data.value, 'NO_FIRST_PAGE_DATA');
|
|
114
|
-
if (!firstPageData.length || !data.length) {
|
|
115
|
-
this.resetToFirstPageData();
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (this.templateSnapshotEmitter.extractData(firstPageData[0]) ===
|
|
119
|
-
this.templateSnapshotEmitter.extractData(data[0])) {
|
|
120
|
-
this.resetToFirstPageData();
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
hasPrev = this._observeState.value.hasNext;
|
|
126
|
-
if (hasPrev && !data.length) {
|
|
127
|
-
this.resetToFirstPageData();
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
this._observeState.next({
|
|
132
|
-
data: data.slice(0, this.options.pageSize),
|
|
133
|
-
hasNext: data.length > this.options.pageSize,
|
|
134
|
-
hasPrev,
|
|
135
|
-
isLoading: false,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
let hasNext = true;
|
|
140
|
-
if (this.options.subscribe) {
|
|
141
|
-
if (data.length < this.options.pageSize) {
|
|
142
|
-
this.resetToFirstPageData();
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const firstPageData = (0, assert_1.truthy)((_b = this.firstPageSnapshotEmitterWrapper) === null || _b === void 0 ? void 0 : _b.data.value, 'NO_FIRST_PAGE_DATA');
|
|
146
|
-
if (!firstPageData ||
|
|
147
|
-
!data.length ||
|
|
148
|
-
this.templateSnapshotEmitter.extractData(firstPageData[0]) ===
|
|
149
|
-
this.templateSnapshotEmitter.extractData(data[0])) {
|
|
150
|
-
this.resetToFirstPageData();
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const lastPageData = (0, assert_1.truthy)((_c = this.lastPageSnapshotEmitterWrapper) === null || _c === void 0 ? void 0 : _c.data.value, 'NO_LAST_PAGE_DATA');
|
|
154
|
-
if (this.templateSnapshotEmitter.extractData(lastPageData[lastPageData.length - 1]) ===
|
|
155
|
-
this.templateSnapshotEmitter.extractData(data[Math.min(data.length, this.options.pageSize) - 1])) {
|
|
156
|
-
hasNext = false;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
const hasPrev = this.options.subscribe || data.length > this.options.pageSize;
|
|
160
|
-
if (!data.length && this._observeState.value.hasPrev) {
|
|
161
|
-
this.resetToFirstPageData();
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
this._observeState.next({
|
|
165
|
-
data: data.slice(0, this.options.pageSize),
|
|
166
|
-
hasNext: hasNext,
|
|
167
|
-
hasPrev: hasPrev,
|
|
168
|
-
isLoading: false,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
async next() {
|
|
175
|
-
if (this.isDestroyed.value)
|
|
176
|
-
return this._observeState.value;
|
|
177
|
-
await this.firstPageDataAvailable;
|
|
178
|
-
if (this.isDestroyed.value)
|
|
179
|
-
return this._observeState.value;
|
|
180
|
-
const currentState = this._observeState.value;
|
|
181
|
-
if (currentState.isLoading || !currentState.hasNext)
|
|
182
|
-
return this._observeState.value;
|
|
183
|
-
const currentData = currentState.data;
|
|
184
|
-
const lastDoc = this.templateSnapshotEmitter.extractData((0, assert_1.truthy)(currentData[this.options.pageSize - 1], 'NO_LAST_ITEM'));
|
|
185
|
-
const nextPageSnapshotEmitter = this.templateSnapshotEmitter
|
|
186
|
-
.clone()
|
|
187
|
-
.limit(Math.min(this.options.pageSize * 3, 2000))
|
|
188
|
-
.addCompositeCondition(this.templateSnapshotEmitter.getSortOrders().map((sortOrder) => {
|
|
189
|
-
return {
|
|
190
|
-
fieldName: sortOrder.fieldName,
|
|
191
|
-
operator: sortOrder.asc ? '>' : '<',
|
|
192
|
-
value: (0, object_1.getInPath)(lastDoc, sortOrder.fieldName),
|
|
193
|
-
};
|
|
194
|
-
}));
|
|
195
|
-
this._observeState.next(Object.assign(Object.assign({}, currentState), { isLoading: true }));
|
|
196
|
-
this.currentPageSnapshotEmitterWrapperSubject.next(new SnapshotEmitterWrapper(nextPageSnapshotEmitter, this.options, true));
|
|
197
|
-
return await this.waitForData();
|
|
198
|
-
}
|
|
199
|
-
async prev() {
|
|
200
|
-
if (this.isDestroyed.value)
|
|
201
|
-
return this._observeState.value;
|
|
202
|
-
await this.firstPageDataAvailable;
|
|
203
|
-
if (this.options.subscribe) {
|
|
204
|
-
this.createLastPageSnapshotEmitterWrapper();
|
|
205
|
-
await this.lastPageDataAvailable;
|
|
206
|
-
}
|
|
207
|
-
if (this.isDestroyed.value)
|
|
208
|
-
return this._observeState.value;
|
|
209
|
-
const currentState = this._observeState.value;
|
|
210
|
-
if (currentState.isLoading || !currentState.hasPrev)
|
|
211
|
-
return this._observeState.value;
|
|
212
|
-
const currentData = currentState.data;
|
|
213
|
-
const firstDoc = this.templateSnapshotEmitter.extractData((0, assert_1.truthy)(currentData[0], 'NO_FIRST_ITEM'));
|
|
214
|
-
const prevPageSnapshotEmitter = this.templateSnapshotEmitter
|
|
215
|
-
.clone()
|
|
216
|
-
.flipSortOrder()
|
|
217
|
-
.limit(Math.min(this.options.pageSize * 3, 2000));
|
|
218
|
-
prevPageSnapshotEmitter.addCompositeCondition(prevPageSnapshotEmitter.getSortOrders().map((sortOrder) => {
|
|
219
|
-
return {
|
|
220
|
-
fieldName: sortOrder.fieldName,
|
|
221
|
-
operator: sortOrder.asc ? '>' : '<',
|
|
222
|
-
value: (0, object_1.getInPath)(firstDoc, sortOrder.fieldName),
|
|
223
|
-
};
|
|
224
|
-
}));
|
|
225
|
-
this._observeState.next(Object.assign(Object.assign({}, currentState), { isLoading: true }));
|
|
226
|
-
this.currentPageSnapshotEmitterWrapperSubject.next(new SnapshotEmitterWrapper(prevPageSnapshotEmitter, this.options, false));
|
|
227
|
-
return await this.waitForData();
|
|
228
|
-
}
|
|
229
|
-
unsubscribe() {
|
|
230
|
-
this.isDestroyed.next(true);
|
|
231
|
-
this.isDestroyed.complete();
|
|
232
|
-
if (this.firstPageSnapshotEmitterWrapper) {
|
|
233
|
-
this.firstPageSnapshotEmitterWrapper.destroy();
|
|
234
|
-
}
|
|
235
|
-
if (this.currentPageSnapshotEmitterWrapperSubject.value) {
|
|
236
|
-
this.currentPageSnapshotEmitterWrapperSubject.value.destroy();
|
|
237
|
-
}
|
|
238
|
-
if (this.lastPageSnapshotEmitterWrapper) {
|
|
239
|
-
this.lastPageSnapshotEmitterWrapper.destroy();
|
|
240
|
-
}
|
|
241
|
-
this.currentPageSnapshotEmitterWrapperSubject.complete();
|
|
242
|
-
this._observeState.complete();
|
|
243
|
-
}
|
|
244
|
-
observeState() {
|
|
245
|
-
return this._observeState.asObservable();
|
|
246
|
-
}
|
|
247
|
-
async waitForData() {
|
|
248
|
-
if (!this._observeState.value.isLoading)
|
|
249
|
-
return this._observeState.value;
|
|
250
|
-
await (0, rxjs_1.firstValueFrom)(this._observeState.pipe((0, rxjs_1.filter)((state) => !state.isLoading), (0, rxjs_1.take)(1), (0, rxjs_1.raceWith)(this.destroyedObs)));
|
|
251
|
-
return this._observeState.value;
|
|
252
|
-
}
|
|
253
|
-
createLastPageSnapshotEmitterWrapper() {
|
|
254
|
-
if (this.lastPageSnapshotEmitterWrapper)
|
|
255
|
-
return;
|
|
256
|
-
const lastPageEmitter = this.templateSnapshotEmitter
|
|
257
|
-
.clone()
|
|
258
|
-
.flipSortOrder()
|
|
259
|
-
.limit(Math.min(this.options.pageSize * 3, 2000));
|
|
260
|
-
this.lastPageSnapshotEmitterWrapper = new SnapshotEmitterWrapper(lastPageEmitter, this.options, false);
|
|
261
|
-
this.lastPageDataAvailable = (0, rxjs_1.firstValueFrom)(this.lastPageSnapshotEmitterWrapper.data.pipe((0, rxjs_1.filter)(Boolean), (0, rxjs_1.raceWith)(this.destroyedObs)));
|
|
262
|
-
this.lastPageSnapshotEmitterWrapper.data.pipe((0, rxjs_1.filter)(Boolean)).subscribe((data) => {
|
|
263
|
-
if (!this.currentPageSnapshotEmitterWrapperSubject) {
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
if (!data.length) {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
if (!this._observeState.value.hasNext &&
|
|
270
|
-
this.templateSnapshotEmitter.extractData(data[data.length - 1]) !==
|
|
271
|
-
this.templateSnapshotEmitter.extractData(this._observeState.value.data[this._observeState.value.data.length - 1])) {
|
|
272
|
-
this._observeState.next(Object.assign(Object.assign({}, this._observeState.value), { hasNext: true }));
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
resetToFirstPageData() {
|
|
277
|
-
var _a, _b, _c, _d;
|
|
278
|
-
this.currentPageSnapshotEmitterWrapperSubject.next(undefined);
|
|
279
|
-
if (!this.options.subscribe) {
|
|
280
|
-
const currentState = this._observeState.value;
|
|
281
|
-
this._observeState.next(Object.assign(Object.assign({}, currentState), { hasNext: false, hasPrev: false, isLoading: true }));
|
|
282
|
-
const firstPageEmitter = this.templateSnapshotEmitter.clone().limit(this.options.pageSize + 1);
|
|
283
|
-
this.currentPageSnapshotEmitterWrapperSubject.next(new SnapshotEmitterWrapper(firstPageEmitter, this.options, true));
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
this._observeState.next({
|
|
287
|
-
data: (_c = (_b = (_a = this.firstPageSnapshotEmitterWrapper) === null || _a === void 0 ? void 0 : _a.data.value) === null || _b === void 0 ? void 0 : _b.slice(0, this.options.pageSize)) !== null && _c !== void 0 ? _c : [],
|
|
288
|
-
hasNext: (0, assert_1.truthy)((_d = this.firstPageSnapshotEmitterWrapper) === null || _d === void 0 ? void 0 : _d.data.value, 'NO_FIRST_PAGE_DATA').length > this.options.pageSize,
|
|
289
|
-
hasPrev: false,
|
|
290
|
-
isLoading: false,
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
exports.Pagination = Pagination;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pagination = exports.BaseQueryBuilder = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const assert_1 = require("../utils/assert");
|
|
6
|
+
const object_1 = require("../utils/object");
|
|
7
|
+
class BaseQueryBuilder {
|
|
8
|
+
eq(fieldName, value) {
|
|
9
|
+
return this.where(fieldName, '==', value);
|
|
10
|
+
}
|
|
11
|
+
neq(fieldName, value) {
|
|
12
|
+
return this.where(fieldName, '!=', value);
|
|
13
|
+
}
|
|
14
|
+
in(fieldName, value) {
|
|
15
|
+
return this.where(fieldName, 'in', value);
|
|
16
|
+
}
|
|
17
|
+
nin(fieldName, value) {
|
|
18
|
+
return this.where(fieldName, 'not in', value);
|
|
19
|
+
}
|
|
20
|
+
gt(fieldName, value) {
|
|
21
|
+
return this.where(fieldName, '>', value);
|
|
22
|
+
}
|
|
23
|
+
gte(fieldName, value) {
|
|
24
|
+
return this.where(fieldName, '>=', value);
|
|
25
|
+
}
|
|
26
|
+
lt(fieldName, value) {
|
|
27
|
+
return this.where(fieldName, '<', value);
|
|
28
|
+
}
|
|
29
|
+
lte(fieldName, value) {
|
|
30
|
+
return this.where(fieldName, '<=', value);
|
|
31
|
+
}
|
|
32
|
+
like(fieldName, pattern, caseSensitive) {
|
|
33
|
+
return this.where(fieldName, caseSensitive ? 'like_cs' : 'like', pattern);
|
|
34
|
+
}
|
|
35
|
+
notLike(fieldName, pattern, caseSensitive) {
|
|
36
|
+
return this.where(fieldName, caseSensitive ? 'not like_cs' : 'not like', pattern);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.BaseQueryBuilder = BaseQueryBuilder;
|
|
40
|
+
class SnapshotEmitterWrapper {
|
|
41
|
+
constructor(snapshotEmitter, options, forward) {
|
|
42
|
+
this.options = options;
|
|
43
|
+
this.forward = forward;
|
|
44
|
+
this.destroySubject = new rxjs_1.Subject();
|
|
45
|
+
this.data = new rxjs_1.BehaviorSubject(undefined);
|
|
46
|
+
snapshotEmitter
|
|
47
|
+
.snapshots(this.options.subscribe)
|
|
48
|
+
.pipe((0, rxjs_1.takeUntil)(this.destroySubject))
|
|
49
|
+
.subscribe((data) => this.data.next(forward ? data : this.reverse(data)));
|
|
50
|
+
this.destroySubject.subscribe(() => this.data.complete());
|
|
51
|
+
}
|
|
52
|
+
reverse(data) {
|
|
53
|
+
const slice = data.slice(0, this.options.pageSize).reverse();
|
|
54
|
+
return [...slice, ...data.slice(this.options.pageSize)];
|
|
55
|
+
}
|
|
56
|
+
destroy() {
|
|
57
|
+
this.destroySubject.next();
|
|
58
|
+
this.destroySubject.complete();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
class Pagination {
|
|
62
|
+
constructor(snapshotEmitter, options = {}) {
|
|
63
|
+
this.isDestroyed = new rxjs_1.BehaviorSubject(false);
|
|
64
|
+
this.destroyedObs = this.isDestroyed.pipe((0, rxjs_1.filter)(Boolean), (0, rxjs_1.take)(1));
|
|
65
|
+
this._observeState = new rxjs_1.BehaviorSubject({
|
|
66
|
+
data: [],
|
|
67
|
+
hasNext: false,
|
|
68
|
+
hasPrev: false,
|
|
69
|
+
isLoading: true,
|
|
70
|
+
});
|
|
71
|
+
this.currentPageSnapshotEmitterWrapperSubject = new rxjs_1.BehaviorSubject(undefined);
|
|
72
|
+
this.options = Object.assign({ pageSize: 100, subscribe: true }, options);
|
|
73
|
+
this.templateSnapshotEmitter = snapshotEmitter.clone();
|
|
74
|
+
if (this.options.subscribe) {
|
|
75
|
+
this.firstPageSnapshotEmitterWrapper = new SnapshotEmitterWrapper(this.templateSnapshotEmitter.clone().limit(Math.min(this.options.pageSize * 3, 2000)), this.options, true);
|
|
76
|
+
this.firstPageDataAvailable = (0, rxjs_1.firstValueFrom)(this.firstPageSnapshotEmitterWrapper.data.pipe((0, rxjs_1.filter)(Boolean), (0, rxjs_1.raceWith)(this.isDestroyed)));
|
|
77
|
+
this.firstPageSnapshotEmitterWrapper.data.pipe((0, rxjs_1.filter)(Boolean)).subscribe((data) => {
|
|
78
|
+
if (!data.length) {
|
|
79
|
+
this.resetToFirstPageData();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (!this.currentPageSnapshotEmitterWrapperSubject.value) {
|
|
83
|
+
this._observeState.next({
|
|
84
|
+
data: data.slice(0, this.options.pageSize),
|
|
85
|
+
hasNext: data.length > this.options.pageSize,
|
|
86
|
+
hasPrev: false,
|
|
87
|
+
isLoading: false,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else if (!this._observeState.value.hasPrev &&
|
|
91
|
+
this.templateSnapshotEmitter.extractData(data[0]) !==
|
|
92
|
+
this.templateSnapshotEmitter.extractData(this._observeState.value.data[0])) {
|
|
93
|
+
this._observeState.next(Object.assign(Object.assign({}, this._observeState.value), { hasPrev: true }));
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const firstPageEmitter = this.templateSnapshotEmitter.clone().limit(this.options.pageSize + 1);
|
|
99
|
+
this.currentPageSnapshotEmitterWrapperSubject.next(new SnapshotEmitterWrapper(firstPageEmitter, this.options, true));
|
|
100
|
+
}
|
|
101
|
+
this.currentPageSnapshotEmitterWrapperSubject
|
|
102
|
+
.pipe((0, rxjs_1.takeUntil)(this.destroyedObs), (0, rxjs_1.startWith)(undefined), (0, rxjs_1.pairwise)())
|
|
103
|
+
.subscribe(([before, after]) => {
|
|
104
|
+
if (before)
|
|
105
|
+
before.destroy();
|
|
106
|
+
if (!after)
|
|
107
|
+
return;
|
|
108
|
+
after.data.pipe((0, rxjs_1.filter)(Boolean)).subscribe((data) => {
|
|
109
|
+
var _a, _b, _c;
|
|
110
|
+
if (after.forward) {
|
|
111
|
+
let hasPrev = true;
|
|
112
|
+
if (this.options.subscribe) {
|
|
113
|
+
const firstPageData = (0, assert_1.truthy)((_a = this.firstPageSnapshotEmitterWrapper) === null || _a === void 0 ? void 0 : _a.data.value, 'NO_FIRST_PAGE_DATA');
|
|
114
|
+
if (!firstPageData.length || !data.length) {
|
|
115
|
+
this.resetToFirstPageData();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (this.templateSnapshotEmitter.extractData(firstPageData[0]) ===
|
|
119
|
+
this.templateSnapshotEmitter.extractData(data[0])) {
|
|
120
|
+
this.resetToFirstPageData();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
hasPrev = this._observeState.value.hasNext;
|
|
126
|
+
if (hasPrev && !data.length) {
|
|
127
|
+
this.resetToFirstPageData();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
this._observeState.next({
|
|
132
|
+
data: data.slice(0, this.options.pageSize),
|
|
133
|
+
hasNext: data.length > this.options.pageSize,
|
|
134
|
+
hasPrev,
|
|
135
|
+
isLoading: false,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
let hasNext = true;
|
|
140
|
+
if (this.options.subscribe) {
|
|
141
|
+
if (data.length < this.options.pageSize) {
|
|
142
|
+
this.resetToFirstPageData();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const firstPageData = (0, assert_1.truthy)((_b = this.firstPageSnapshotEmitterWrapper) === null || _b === void 0 ? void 0 : _b.data.value, 'NO_FIRST_PAGE_DATA');
|
|
146
|
+
if (!firstPageData ||
|
|
147
|
+
!data.length ||
|
|
148
|
+
this.templateSnapshotEmitter.extractData(firstPageData[0]) ===
|
|
149
|
+
this.templateSnapshotEmitter.extractData(data[0])) {
|
|
150
|
+
this.resetToFirstPageData();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const lastPageData = (0, assert_1.truthy)((_c = this.lastPageSnapshotEmitterWrapper) === null || _c === void 0 ? void 0 : _c.data.value, 'NO_LAST_PAGE_DATA');
|
|
154
|
+
if (this.templateSnapshotEmitter.extractData(lastPageData[lastPageData.length - 1]) ===
|
|
155
|
+
this.templateSnapshotEmitter.extractData(data[Math.min(data.length, this.options.pageSize) - 1])) {
|
|
156
|
+
hasNext = false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const hasPrev = this.options.subscribe || data.length > this.options.pageSize;
|
|
160
|
+
if (!data.length && this._observeState.value.hasPrev) {
|
|
161
|
+
this.resetToFirstPageData();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this._observeState.next({
|
|
165
|
+
data: data.slice(0, this.options.pageSize),
|
|
166
|
+
hasNext: hasNext,
|
|
167
|
+
hasPrev: hasPrev,
|
|
168
|
+
isLoading: false,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async next() {
|
|
175
|
+
if (this.isDestroyed.value)
|
|
176
|
+
return this._observeState.value;
|
|
177
|
+
await this.firstPageDataAvailable;
|
|
178
|
+
if (this.isDestroyed.value)
|
|
179
|
+
return this._observeState.value;
|
|
180
|
+
const currentState = this._observeState.value;
|
|
181
|
+
if (currentState.isLoading || !currentState.hasNext)
|
|
182
|
+
return this._observeState.value;
|
|
183
|
+
const currentData = currentState.data;
|
|
184
|
+
const lastDoc = this.templateSnapshotEmitter.extractData((0, assert_1.truthy)(currentData[this.options.pageSize - 1], 'NO_LAST_ITEM'));
|
|
185
|
+
const nextPageSnapshotEmitter = this.templateSnapshotEmitter
|
|
186
|
+
.clone()
|
|
187
|
+
.limit(Math.min(this.options.pageSize * 3, 2000))
|
|
188
|
+
.addCompositeCondition(this.templateSnapshotEmitter.getSortOrders().map((sortOrder) => {
|
|
189
|
+
return {
|
|
190
|
+
fieldName: sortOrder.fieldName,
|
|
191
|
+
operator: sortOrder.asc ? '>' : '<',
|
|
192
|
+
value: (0, object_1.getInPath)(lastDoc, sortOrder.fieldName),
|
|
193
|
+
};
|
|
194
|
+
}));
|
|
195
|
+
this._observeState.next(Object.assign(Object.assign({}, currentState), { isLoading: true }));
|
|
196
|
+
this.currentPageSnapshotEmitterWrapperSubject.next(new SnapshotEmitterWrapper(nextPageSnapshotEmitter, this.options, true));
|
|
197
|
+
return await this.waitForData();
|
|
198
|
+
}
|
|
199
|
+
async prev() {
|
|
200
|
+
if (this.isDestroyed.value)
|
|
201
|
+
return this._observeState.value;
|
|
202
|
+
await this.firstPageDataAvailable;
|
|
203
|
+
if (this.options.subscribe) {
|
|
204
|
+
this.createLastPageSnapshotEmitterWrapper();
|
|
205
|
+
await this.lastPageDataAvailable;
|
|
206
|
+
}
|
|
207
|
+
if (this.isDestroyed.value)
|
|
208
|
+
return this._observeState.value;
|
|
209
|
+
const currentState = this._observeState.value;
|
|
210
|
+
if (currentState.isLoading || !currentState.hasPrev)
|
|
211
|
+
return this._observeState.value;
|
|
212
|
+
const currentData = currentState.data;
|
|
213
|
+
const firstDoc = this.templateSnapshotEmitter.extractData((0, assert_1.truthy)(currentData[0], 'NO_FIRST_ITEM'));
|
|
214
|
+
const prevPageSnapshotEmitter = this.templateSnapshotEmitter
|
|
215
|
+
.clone()
|
|
216
|
+
.flipSortOrder()
|
|
217
|
+
.limit(Math.min(this.options.pageSize * 3, 2000));
|
|
218
|
+
prevPageSnapshotEmitter.addCompositeCondition(prevPageSnapshotEmitter.getSortOrders().map((sortOrder) => {
|
|
219
|
+
return {
|
|
220
|
+
fieldName: sortOrder.fieldName,
|
|
221
|
+
operator: sortOrder.asc ? '>' : '<',
|
|
222
|
+
value: (0, object_1.getInPath)(firstDoc, sortOrder.fieldName),
|
|
223
|
+
};
|
|
224
|
+
}));
|
|
225
|
+
this._observeState.next(Object.assign(Object.assign({}, currentState), { isLoading: true }));
|
|
226
|
+
this.currentPageSnapshotEmitterWrapperSubject.next(new SnapshotEmitterWrapper(prevPageSnapshotEmitter, this.options, false));
|
|
227
|
+
return await this.waitForData();
|
|
228
|
+
}
|
|
229
|
+
unsubscribe() {
|
|
230
|
+
this.isDestroyed.next(true);
|
|
231
|
+
this.isDestroyed.complete();
|
|
232
|
+
if (this.firstPageSnapshotEmitterWrapper) {
|
|
233
|
+
this.firstPageSnapshotEmitterWrapper.destroy();
|
|
234
|
+
}
|
|
235
|
+
if (this.currentPageSnapshotEmitterWrapperSubject.value) {
|
|
236
|
+
this.currentPageSnapshotEmitterWrapperSubject.value.destroy();
|
|
237
|
+
}
|
|
238
|
+
if (this.lastPageSnapshotEmitterWrapper) {
|
|
239
|
+
this.lastPageSnapshotEmitterWrapper.destroy();
|
|
240
|
+
}
|
|
241
|
+
this.currentPageSnapshotEmitterWrapperSubject.complete();
|
|
242
|
+
this._observeState.complete();
|
|
243
|
+
}
|
|
244
|
+
observeState() {
|
|
245
|
+
return this._observeState.asObservable();
|
|
246
|
+
}
|
|
247
|
+
async waitForData() {
|
|
248
|
+
if (!this._observeState.value.isLoading)
|
|
249
|
+
return this._observeState.value;
|
|
250
|
+
await (0, rxjs_1.firstValueFrom)(this._observeState.pipe((0, rxjs_1.filter)((state) => !state.isLoading), (0, rxjs_1.take)(1), (0, rxjs_1.raceWith)(this.destroyedObs)));
|
|
251
|
+
return this._observeState.value;
|
|
252
|
+
}
|
|
253
|
+
createLastPageSnapshotEmitterWrapper() {
|
|
254
|
+
if (this.lastPageSnapshotEmitterWrapper)
|
|
255
|
+
return;
|
|
256
|
+
const lastPageEmitter = this.templateSnapshotEmitter
|
|
257
|
+
.clone()
|
|
258
|
+
.flipSortOrder()
|
|
259
|
+
.limit(Math.min(this.options.pageSize * 3, 2000));
|
|
260
|
+
this.lastPageSnapshotEmitterWrapper = new SnapshotEmitterWrapper(lastPageEmitter, this.options, false);
|
|
261
|
+
this.lastPageDataAvailable = (0, rxjs_1.firstValueFrom)(this.lastPageSnapshotEmitterWrapper.data.pipe((0, rxjs_1.filter)(Boolean), (0, rxjs_1.raceWith)(this.destroyedObs)));
|
|
262
|
+
this.lastPageSnapshotEmitterWrapper.data.pipe((0, rxjs_1.filter)(Boolean)).subscribe((data) => {
|
|
263
|
+
if (!this.currentPageSnapshotEmitterWrapperSubject) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (!data.length) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (!this._observeState.value.hasNext &&
|
|
270
|
+
this.templateSnapshotEmitter.extractData(data[data.length - 1]) !==
|
|
271
|
+
this.templateSnapshotEmitter.extractData(this._observeState.value.data[this._observeState.value.data.length - 1])) {
|
|
272
|
+
this._observeState.next(Object.assign(Object.assign({}, this._observeState.value), { hasNext: true }));
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
resetToFirstPageData() {
|
|
277
|
+
var _a, _b, _c, _d;
|
|
278
|
+
this.currentPageSnapshotEmitterWrapperSubject.next(undefined);
|
|
279
|
+
if (!this.options.subscribe) {
|
|
280
|
+
const currentState = this._observeState.value;
|
|
281
|
+
this._observeState.next(Object.assign(Object.assign({}, currentState), { hasNext: false, hasPrev: false, isLoading: true }));
|
|
282
|
+
const firstPageEmitter = this.templateSnapshotEmitter.clone().limit(this.options.pageSize + 1);
|
|
283
|
+
this.currentPageSnapshotEmitterWrapperSubject.next(new SnapshotEmitterWrapper(firstPageEmitter, this.options, true));
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
this._observeState.next({
|
|
287
|
+
data: (_c = (_b = (_a = this.firstPageSnapshotEmitterWrapper) === null || _a === void 0 ? void 0 : _a.data.value) === null || _b === void 0 ? void 0 : _b.slice(0, this.options.pageSize)) !== null && _c !== void 0 ? _c : [],
|
|
288
|
+
hasNext: (0, assert_1.truthy)((_d = this.firstPageSnapshotEmitterWrapper) === null || _d === void 0 ? void 0 : _d.data.value, 'NO_FIRST_PAGE_DATA').length > this.options.pageSize,
|
|
289
|
+
hasPrev: false,
|
|
290
|
+
isLoading: false,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
exports.Pagination = Pagination;
|
|
295
295
|
//# sourceMappingURL=base-query-builder.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './query-context';
|
|
2
|
-
export * from './base-query-builder';
|
|
3
|
-
export * from './serialized-query.types';
|
|
1
|
+
export * from './query-context';
|
|
2
|
+
export * from './base-query-builder';
|
|
3
|
+
export * from './serialized-query.types';
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./query-context"), exports);
|
|
18
|
-
__exportStar(require("./base-query-builder"), exports);
|
|
19
|
-
__exportStar(require("./serialized-query.types"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./query-context"), exports);
|
|
18
|
+
__exportStar(require("./base-query-builder"), exports);
|
|
19
|
+
__exportStar(require("./serialized-query.types"), exports);
|
|
20
20
|
//# sourceMappingURL=index.js.map
|