@squidcloud/client 1.0.123 → 1.0.124
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/cjs/index.js
CHANGED
|
@@ -27907,6 +27907,7 @@ function isStringMatch(str, pattern, caseSensitive) {
|
|
|
27907
27907
|
str = str.toLowerCase();
|
|
27908
27908
|
pattern = pattern.toLowerCase();
|
|
27909
27909
|
}
|
|
27910
|
+
str = str.replace(/\n/g, ' ');
|
|
27910
27911
|
// Escape special regex characters in the pattern
|
|
27911
27912
|
const escapedPattern = pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
27912
27913
|
// Replace '%' wildcard with regex equivalent
|
|
@@ -28705,10 +28706,16 @@ class Pagination {
|
|
|
28705
28706
|
*/
|
|
28706
28707
|
this.internalStateObserver = new external_rxjs_namespaceObject.BehaviorSubject(null);
|
|
28707
28708
|
this.firstElement = null;
|
|
28708
|
-
this.lastElement = null;
|
|
28709
28709
|
this.isDestroyed = new external_rxjs_namespaceObject.BehaviorSubject(false);
|
|
28710
28710
|
this.snapshotSubject = new external_rxjs_namespaceObject.Subject();
|
|
28711
28711
|
this.onFirstPage = true;
|
|
28712
|
+
/* Used during reverse navigation:
|
|
28713
|
+
- When navigating to the last page, we set navigatingToLastPage to true and run a reverse query starting at the end of the query.
|
|
28714
|
+
- When navigating to a previous page, we set lastElement to the last element that should be on that page.
|
|
28715
|
+
In both situations, the variables are reset during the next call to dataReceived.
|
|
28716
|
+
*/
|
|
28717
|
+
this.navigatingToLastPage = false;
|
|
28718
|
+
this.lastElement = null;
|
|
28712
28719
|
this.snapshotSubject.pipe((0,external_rxjs_namespaceObject.switchAll)()).subscribe((data) => this.dataReceived(data));
|
|
28713
28720
|
this.templateSnapshotEmitter = snapshotEmitter.clone();
|
|
28714
28721
|
this.options = Object.assign({ pageSize: 100, subscribe: true }, options);
|
|
@@ -28751,8 +28758,8 @@ class Pagination {
|
|
|
28751
28758
|
return 0;
|
|
28752
28759
|
}
|
|
28753
28760
|
async dataReceived(data) {
|
|
28754
|
-
// Because documents might be deleted by the time we need them (if we are not subscribed), we save the extracted
|
|
28755
|
-
// This is the only place we're allowed to call extractData.
|
|
28761
|
+
// Because documents might be deleted by the time we need them (if we are not subscribed), we save the extracted
|
|
28762
|
+
// data here. This is the only place we're allowed to call extractData.
|
|
28756
28763
|
const extractedData = data.map((s) => this.templateSnapshotEmitter.extractData(s));
|
|
28757
28764
|
if (data.length === 0) {
|
|
28758
28765
|
if (this.onFirstPage) {
|
|
@@ -28763,12 +28770,19 @@ class Pagination {
|
|
|
28763
28770
|
}
|
|
28764
28771
|
return;
|
|
28765
28772
|
}
|
|
28766
|
-
if (this.firstElement === null
|
|
28767
|
-
|
|
28768
|
-
|
|
28769
|
-
|
|
28770
|
-
|
|
28771
|
-
|
|
28773
|
+
if (this.firstElement === null) {
|
|
28774
|
+
if (this.lastElement !== null) {
|
|
28775
|
+
// We just executed a `prev` and we know what the last element is on the page but not the first.
|
|
28776
|
+
// We need to find the first element on the page instead, because that's our anchor.
|
|
28777
|
+
const numAfter = extractedData.filter((s) => this.compare(s, this.lastElement) === 1).length;
|
|
28778
|
+
this.firstElement = extractedData[data.length - numAfter - this.options.pageSize];
|
|
28779
|
+
this.lastElement = null;
|
|
28780
|
+
}
|
|
28781
|
+
else if (this.navigatingToLastPage) {
|
|
28782
|
+
// We just executed a `last`.
|
|
28783
|
+
this.firstElement = extractedData[data.length - this.options.pageSize];
|
|
28784
|
+
this.navigatingToLastPage = false;
|
|
28785
|
+
}
|
|
28772
28786
|
}
|
|
28773
28787
|
const numBefore = extractedData.filter((s) => this.compare(s, this.firstElement) === -1).length;
|
|
28774
28788
|
const numAfter = Math.max(0, data.length - numBefore - this.options.pageSize);
|
|
@@ -28785,27 +28799,29 @@ class Pagination {
|
|
|
28785
28799
|
const newSnapshotEmitter = this.templateSnapshotEmitter
|
|
28786
28800
|
.clone()
|
|
28787
28801
|
.limit(this.options.pageSize * 3)
|
|
28788
|
-
.flipSortOrder()
|
|
28789
|
-
|
|
28790
|
-
|
|
28791
|
-
|
|
28792
|
-
|
|
28793
|
-
|
|
28794
|
-
|
|
28795
|
-
|
|
28802
|
+
.flipSortOrder();
|
|
28803
|
+
if (startingDoc) {
|
|
28804
|
+
newSnapshotEmitter.addCompositeCondition(this.templateSnapshotEmitter.getSortOrders().map((sortOrder) => {
|
|
28805
|
+
return {
|
|
28806
|
+
fieldName: sortOrder.fieldName,
|
|
28807
|
+
operator: sortOrder.asc ? '<=' : '>=',
|
|
28808
|
+
value: getInPath(startingDoc, sortOrder.fieldName),
|
|
28809
|
+
};
|
|
28810
|
+
}));
|
|
28811
|
+
}
|
|
28796
28812
|
this.snapshotSubject.next(newSnapshotEmitter.snapshots(this.options.subscribe).pipe((0,external_rxjs_namespaceObject.map)((s) => s.reverse())));
|
|
28797
28813
|
}
|
|
28798
28814
|
else {
|
|
28799
|
-
const newSnapshotEmitter = this.templateSnapshotEmitter
|
|
28800
|
-
|
|
28801
|
-
.
|
|
28802
|
-
|
|
28803
|
-
|
|
28804
|
-
|
|
28805
|
-
|
|
28806
|
-
|
|
28807
|
-
};
|
|
28808
|
-
}
|
|
28815
|
+
const newSnapshotEmitter = this.templateSnapshotEmitter.clone().limit(this.options.pageSize * 3);
|
|
28816
|
+
if (startingDoc) {
|
|
28817
|
+
newSnapshotEmitter.addCompositeCondition(this.templateSnapshotEmitter.getSortOrders().map((sortOrder) => {
|
|
28818
|
+
return {
|
|
28819
|
+
fieldName: sortOrder.fieldName,
|
|
28820
|
+
operator: sortOrder.asc ? '>=' : '<=',
|
|
28821
|
+
value: getInPath(startingDoc, sortOrder.fieldName),
|
|
28822
|
+
};
|
|
28823
|
+
}));
|
|
28824
|
+
}
|
|
28809
28825
|
this.snapshotSubject.next(newSnapshotEmitter.snapshots(this.options.subscribe));
|
|
28810
28826
|
}
|
|
28811
28827
|
}
|
|
@@ -28815,9 +28831,9 @@ class Pagination {
|
|
|
28815
28831
|
return internalState;
|
|
28816
28832
|
}
|
|
28817
28833
|
return await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.race)(
|
|
28818
|
-
// It is possible that we get here and unsubscribe() was called. In that case we might not get any new state,
|
|
28819
|
-
// stalling we return an empty page in that situation. (We can't return the last page we saw
|
|
28820
|
-
// been deleted, and also because it's possible that we've never seen any data.)
|
|
28834
|
+
// It is possible that we get here and unsubscribe() was called. In that case we might not get any new state,
|
|
28835
|
+
// so to avoid stalling we return an empty page in that situation. (We can't return the last page we saw
|
|
28836
|
+
// because that has already been deleted, and also because it's possible that we've never seen any data.)
|
|
28821
28837
|
this.isDestroyed.pipe((0,external_rxjs_namespaceObject.filter)(Boolean), (0,external_rxjs_namespaceObject.map)((_) => ({
|
|
28822
28838
|
data: [],
|
|
28823
28839
|
extractedData: [],
|
|
@@ -28835,6 +28851,7 @@ class Pagination {
|
|
|
28835
28851
|
hasPrev: numBefore > 0,
|
|
28836
28852
|
};
|
|
28837
28853
|
}
|
|
28854
|
+
/** Unsubscribes from the pagination. */
|
|
28838
28855
|
unsubscribe() {
|
|
28839
28856
|
this.isDestroyed.next(true);
|
|
28840
28857
|
this.isDestroyed.complete();
|
|
@@ -28848,10 +28865,12 @@ class Pagination {
|
|
|
28848
28865
|
this.internalStateObserver.next(null);
|
|
28849
28866
|
this.doNewQuery(extractedData[extractedData.length - numAfter - 1], true);
|
|
28850
28867
|
}
|
|
28868
|
+
/** Returns a promise that resolves when the previous page of data is available. */
|
|
28851
28869
|
async prev() {
|
|
28852
28870
|
this.prevInternal(await this.waitForInternalState());
|
|
28853
28871
|
return await this.waitForData();
|
|
28854
28872
|
}
|
|
28873
|
+
/** Returns a promise that resolves when the next page of data is available. */
|
|
28855
28874
|
async next() {
|
|
28856
28875
|
const { numBefore, extractedData } = await this.waitForInternalState();
|
|
28857
28876
|
this.firstElement = extractedData[numBefore + this.options.pageSize];
|
|
@@ -28859,14 +28878,51 @@ class Pagination {
|
|
|
28859
28878
|
this.doNewQuery(extractedData[numBefore], false);
|
|
28860
28879
|
return await this.waitForData();
|
|
28861
28880
|
}
|
|
28881
|
+
/** Returns a promise that resolves when the page data is available. */
|
|
28862
28882
|
async waitForData() {
|
|
28863
28883
|
return this.internalStateToState(await this.waitForInternalState());
|
|
28864
28884
|
}
|
|
28885
|
+
/** Returns an observable that emits the current state of the pagination. */
|
|
28865
28886
|
observeState() {
|
|
28866
28887
|
return this.internalStateObserver.pipe((0,external_rxjs_namespaceObject.filter)((state) => state !== null), (0,external_rxjs_namespaceObject.map)((state) => {
|
|
28867
28888
|
return this.internalStateToState(state);
|
|
28868
28889
|
}));
|
|
28869
28890
|
}
|
|
28891
|
+
/** Jumps to the first page of the pagination. */
|
|
28892
|
+
async first() {
|
|
28893
|
+
await this.waitForInternalState();
|
|
28894
|
+
this.internalStateObserver.next(null);
|
|
28895
|
+
this.firstElement = null;
|
|
28896
|
+
this.lastElement = null;
|
|
28897
|
+
this.goToFirstPage();
|
|
28898
|
+
return await this.waitForData();
|
|
28899
|
+
}
|
|
28900
|
+
/** Refreshes the current page of the pagination. */
|
|
28901
|
+
async refreshPage() {
|
|
28902
|
+
const { extractedData } = await this.waitForInternalState();
|
|
28903
|
+
this.internalStateObserver.next(null);
|
|
28904
|
+
this.doNewQuery(extractedData[0], false);
|
|
28905
|
+
return await this.waitForData();
|
|
28906
|
+
}
|
|
28907
|
+
/**
|
|
28908
|
+
* Jumps to the last page of the pagination. This page will always have the last <pageSize> elements of the
|
|
28909
|
+
* underlying query, regardless of whether the total document count is evenly divisible by the page size.
|
|
28910
|
+
*/
|
|
28911
|
+
async last() {
|
|
28912
|
+
await this.waitForInternalState();
|
|
28913
|
+
this.internalStateObserver.next(null);
|
|
28914
|
+
this.firstElement = null;
|
|
28915
|
+
this.lastElement = null;
|
|
28916
|
+
this.navigatingToLastPage = true;
|
|
28917
|
+
const lastPageSnapshot = this.templateSnapshotEmitter
|
|
28918
|
+
.clone()
|
|
28919
|
+
.limit(this.options.pageSize * 3)
|
|
28920
|
+
.flipSortOrder()
|
|
28921
|
+
.snapshots(this.options.subscribe)
|
|
28922
|
+
.pipe((0,external_rxjs_namespaceObject.map)((s) => s.reverse()));
|
|
28923
|
+
this.snapshotSubject.next(lastPageSnapshot);
|
|
28924
|
+
return await this.waitForData();
|
|
28925
|
+
}
|
|
28870
28926
|
}
|
|
28871
28927
|
|
|
28872
28928
|
;// CONCATENATED MODULE: ../common/src/query/index.ts
|
|
@@ -32226,7 +32282,6 @@ class AiAssistantClient {
|
|
|
32226
32282
|
this.rpcManager = rpcManager;
|
|
32227
32283
|
this.socketManager = socketManager;
|
|
32228
32284
|
this.integrationId = integrationId;
|
|
32229
|
-
this.ongoingChatRequests = {};
|
|
32230
32285
|
this.ongoingChatSequences = {};
|
|
32231
32286
|
this.socketManager
|
|
32232
32287
|
.observeNotifications()
|
|
@@ -32260,9 +32315,9 @@ class AiAssistantClient {
|
|
|
32260
32315
|
*/
|
|
32261
32316
|
chat(profileId, prompt) {
|
|
32262
32317
|
const clientRequestId = generateId();
|
|
32263
|
-
|
|
32318
|
+
let accumulatedValue = '';
|
|
32319
|
+
const subject = new external_rxjs_namespaceObject.Subject();
|
|
32264
32320
|
const tokenSequence = new external_rxjs_namespaceObject.Subject();
|
|
32265
|
-
this.ongoingChatRequests[clientRequestId] = subject;
|
|
32266
32321
|
this.ongoingChatSequences[clientRequestId] = tokenSequence;
|
|
32267
32322
|
tokenSequence
|
|
32268
32323
|
.pipe((0,external_rxjs_namespaceObject.concatMap)(({ value, complete }) => {
|
|
@@ -32273,7 +32328,8 @@ class AiAssistantClient {
|
|
|
32273
32328
|
}), (0,external_rxjs_namespaceObject.takeWhile)(({ complete }) => !complete, true))
|
|
32274
32329
|
.subscribe({
|
|
32275
32330
|
next: ({ value }) => {
|
|
32276
|
-
|
|
32331
|
+
accumulatedValue += value;
|
|
32332
|
+
subject.next(accumulatedValue);
|
|
32277
32333
|
},
|
|
32278
32334
|
error: (e) => {
|
|
32279
32335
|
console.error(e);
|
|
@@ -32293,7 +32349,6 @@ class AiAssistantClient {
|
|
|
32293
32349
|
subject.complete();
|
|
32294
32350
|
});
|
|
32295
32351
|
return subject.pipe((0,external_rxjs_namespaceObject.finalize)(() => {
|
|
32296
|
-
delete this.ongoingChatRequests[clientRequestId];
|
|
32297
32352
|
delete this.ongoingChatSequences[clientRequestId];
|
|
32298
32353
|
}), (0,external_rxjs_namespaceObject.share)());
|
|
32299
32354
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
/** The state of a pagination. */
|
|
3
3
|
export interface PaginationState<ReturnType> {
|
|
4
|
+
/** The page data. */
|
|
4
5
|
data: Array<ReturnType>;
|
|
6
|
+
/** Whether there is a next page. */
|
|
5
7
|
hasNext: boolean;
|
|
8
|
+
/** Whether there is a previous page. */
|
|
6
9
|
hasPrev: boolean;
|
|
7
10
|
}
|
|
8
11
|
/** Pagination options */
|
|
@@ -22,23 +25,38 @@ export declare class Pagination<ReturnType> {
|
|
|
22
25
|
private readonly options;
|
|
23
26
|
private internalStateObserver;
|
|
24
27
|
private firstElement;
|
|
25
|
-
private lastElement;
|
|
26
28
|
private readonly isDestroyed;
|
|
27
29
|
private templateSnapshotEmitter;
|
|
28
30
|
private snapshotSubject;
|
|
29
31
|
private onFirstPage;
|
|
32
|
+
private navigatingToLastPage;
|
|
33
|
+
private lastElement;
|
|
30
34
|
private goToFirstPage;
|
|
31
35
|
private static compareValues;
|
|
32
36
|
private compare;
|
|
33
|
-
dataReceived
|
|
37
|
+
private dataReceived;
|
|
34
38
|
private doNewQuery;
|
|
35
39
|
private waitForInternalState;
|
|
36
40
|
private internalStateToState;
|
|
41
|
+
/** Unsubscribes from the pagination. */
|
|
37
42
|
unsubscribe(): void;
|
|
38
43
|
prevInternal(internalState: InternalState<ReturnType>): void;
|
|
44
|
+
/** Returns a promise that resolves when the previous page of data is available. */
|
|
39
45
|
prev(): Promise<PaginationState<ReturnType>>;
|
|
46
|
+
/** Returns a promise that resolves when the next page of data is available. */
|
|
40
47
|
next(): Promise<PaginationState<ReturnType>>;
|
|
48
|
+
/** Returns a promise that resolves when the page data is available. */
|
|
41
49
|
waitForData(): Promise<PaginationState<ReturnType>>;
|
|
50
|
+
/** Returns an observable that emits the current state of the pagination. */
|
|
42
51
|
observeState(): Observable<PaginationState<ReturnType>>;
|
|
52
|
+
/** Jumps to the first page of the pagination. */
|
|
53
|
+
first(): Promise<PaginationState<ReturnType>>;
|
|
54
|
+
/** Refreshes the current page of the pagination. */
|
|
55
|
+
refreshPage(): Promise<PaginationState<ReturnType>>;
|
|
56
|
+
/**
|
|
57
|
+
* Jumps to the last page of the pagination. This page will always have the last <pageSize> elements of the
|
|
58
|
+
* underlying query, regardless of whether the total document count is evenly divisible by the page size.
|
|
59
|
+
*/
|
|
60
|
+
last(): Promise<PaginationState<ReturnType>>;
|
|
43
61
|
}
|
|
44
62
|
export {};
|
|
@@ -108,7 +108,7 @@ export declare class QueryContext<T extends DocumentData = any> {
|
|
|
108
108
|
private parseConditions;
|
|
109
109
|
}
|
|
110
110
|
/** A list of context conditions */
|
|
111
|
-
type ContextConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<ContextCondition<Doc, F>>;
|
|
111
|
+
export type ContextConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<ContextCondition<Doc, F>>;
|
|
112
112
|
/** A Context condition - a condition that replaces multiple '==' or '!=' conditions with 'in' and 'not in'. */
|
|
113
113
|
type ContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
|
|
114
114
|
interface InContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'in'> {
|
|
@@ -6,7 +6,6 @@ export declare class AiAssistantClient {
|
|
|
6
6
|
private readonly rpcManager;
|
|
7
7
|
private readonly socketManager;
|
|
8
8
|
private readonly integrationId;
|
|
9
|
-
private readonly ongoingChatRequests;
|
|
10
9
|
private readonly ongoingChatSequences;
|
|
11
10
|
constructor(rpcManager: RpcManager, socketManager: SocketManager, integrationId: IntegrationId);
|
|
12
11
|
/**
|