@squidcloud/backend 1.0.4 → 1.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/dist/index.js +5 -5
- package/dist/typescript-client/src/collection-reference.d.ts +5 -3
- package/dist/typescript-client/src/collection-reference.factory.d.ts +3 -1
- package/dist/typescript-client/src/document-reference.d.ts +3 -1
- package/dist/typescript-client/src/index.d.ts +5 -2
- package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +35 -0
- package/dist/typescript-client/src/query/query-builder.factory.d.ts +10 -17
- package/dist/typescript-client/src/squid.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DocId, DocIdObj, DocumentData, IdResolutionMap, IntegrationId } from '@squidcloud/common';
|
|
2
2
|
import { DocumentReference } from './document-reference';
|
|
3
3
|
import { DocumentReferenceFactory } from './document-reference.factory';
|
|
4
|
+
import { JoinQueryBuilder, JoinQueryBuilderFactory } from './query/join-query-builder.factory';
|
|
4
5
|
import { QueryBuilder, QueryBuilderFactory } from './query/query-builder.factory';
|
|
5
6
|
import { Alias } from './query/query.types';
|
|
6
7
|
export declare class CollectionReference<T extends DocumentData> {
|
|
@@ -8,10 +9,11 @@ export declare class CollectionReference<T extends DocumentData> {
|
|
|
8
9
|
private integrationId;
|
|
9
10
|
private readonly documentReferenceFactory;
|
|
10
11
|
private readonly queryBuilderFactory;
|
|
12
|
+
private readonly joinQueryBuilderFactory;
|
|
11
13
|
private readonly documents;
|
|
12
|
-
constructor(collectionName: string, integrationId: IntegrationId, documentReferenceFactory: DocumentReferenceFactory, queryBuilderFactory: QueryBuilderFactory);
|
|
14
|
+
constructor(collectionName: string, integrationId: IntegrationId, documentReferenceFactory: DocumentReferenceFactory, queryBuilderFactory: QueryBuilderFactory, joinQueryBuilderFactory: JoinQueryBuilderFactory);
|
|
13
15
|
doc(docId?: DocId | DocIdObj): DocumentReference<T>;
|
|
14
|
-
query():
|
|
15
|
-
joinQuery<A extends Alias>(alias: A):
|
|
16
|
+
query(): QueryBuilder<T>;
|
|
17
|
+
joinQuery<A extends Alias>(alias: A): JoinQueryBuilder<T, A, Record<A, DocumentReference<T>>>;
|
|
16
18
|
migrateDocIds(idResolutionMap: IdResolutionMap): void;
|
|
17
19
|
}
|
|
@@ -2,13 +2,15 @@ import { CollectionName, DocumentData, IntegrationId } from '@squidcloud/common'
|
|
|
2
2
|
import { CollectionReference } from './collection-reference';
|
|
3
3
|
import DocumentIdentityService from './document-identity.service';
|
|
4
4
|
import { DocumentReferenceFactory } from './document-reference.factory';
|
|
5
|
+
import { JoinQueryBuilderFactory } from './query/join-query-builder.factory';
|
|
5
6
|
import { QueryBuilderFactory } from './query/query-builder.factory';
|
|
6
7
|
export declare class CollectionReferenceFactory {
|
|
7
8
|
private readonly documentReferenceFactory;
|
|
8
9
|
private readonly queryBuilderFactory;
|
|
10
|
+
private readonly joinQueryBuilderFactory;
|
|
9
11
|
private readonly documentIdentityService;
|
|
10
12
|
private readonly collections;
|
|
11
|
-
constructor(documentReferenceFactory: DocumentReferenceFactory, queryBuilderFactory: QueryBuilderFactory, documentIdentityService: DocumentIdentityService);
|
|
13
|
+
constructor(documentReferenceFactory: DocumentReferenceFactory, queryBuilderFactory: QueryBuilderFactory, joinQueryBuilderFactory: JoinQueryBuilderFactory, documentIdentityService: DocumentIdentityService);
|
|
12
14
|
get<T extends DocumentData>(collectionName: CollectionName, integrationId: IntegrationId): CollectionReference<T>;
|
|
13
15
|
private migrateDocIds;
|
|
14
16
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DocumentData, IdResolutionMap, Paths, SquidDocId } from '@squidcloud/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
2
3
|
import { DataManager } from './data.manager';
|
|
3
4
|
import { QueryBuilderFactory } from './query/query-builder.factory';
|
|
4
5
|
import { TransactionId } from './types';
|
|
@@ -9,7 +10,8 @@ export declare class DocumentReference<T extends DocumentData = any> {
|
|
|
9
10
|
constructor(_squidDocId: SquidDocId, dataManager: DataManager, queryBuilderFactory: QueryBuilderFactory);
|
|
10
11
|
get squidDocId(): SquidDocId;
|
|
11
12
|
data(): T;
|
|
12
|
-
|
|
13
|
+
snapshot(): Promise<DocumentReference<T> | undefined>;
|
|
14
|
+
snapshots(): Observable<DocumentReference<T> | undefined>;
|
|
13
15
|
isDirty(): boolean;
|
|
14
16
|
private isTracked;
|
|
15
17
|
update(data: Partial<Record<Paths<T>, any>>, transactionId?: TransactionId): Promise<void>;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { CollectionReference } from './collection-reference';
|
|
2
2
|
export { DocumentReference } from './document-reference';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { JoinQueryBuilder } from './query/join-query-builder.factory';
|
|
4
|
+
export { Changes, QueryBuilder } from './query/query-builder.factory';
|
|
5
|
+
export { Alias, JoinCondition } from './query/query.types';
|
|
6
|
+
export { Squid, SquidOptions } from './squid';
|
|
7
|
+
export { TransactionId } from './types';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CollectionName, DocumentData, FieldName, IntegrationId, Operator, PrimitiveFieldType, Query } from '@squidcloud/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { DocumentReference } from '../document-reference';
|
|
4
|
+
import { DocumentReferenceFactory } from '../document-reference.factory';
|
|
5
|
+
import { QueryBuilderFactory } from './query-builder.factory';
|
|
6
|
+
import { QuerySubscriptionManager } from './query-subscription.manager';
|
|
7
|
+
import { Alias } from './query.types';
|
|
8
|
+
export declare class JoinQueryBuilderFactory {
|
|
9
|
+
private readonly querySubscriptionManager;
|
|
10
|
+
private readonly documentReferenceFactory;
|
|
11
|
+
private readonly queryBuilderFactory;
|
|
12
|
+
constructor(querySubscriptionManager: QuerySubscriptionManager, documentReferenceFactory: DocumentReferenceFactory, queryBuilderFactory: QueryBuilderFactory);
|
|
13
|
+
getForJoin<DocumentType extends DocumentData, MyAlias extends Alias, ReturnType extends Record<MyAlias, DocumentReference<DocumentType>>>(collectionName: CollectionName, integrationId: IntegrationId, alias: MyAlias): JoinQueryBuilder<DocumentType, MyAlias, ReturnType>;
|
|
14
|
+
}
|
|
15
|
+
export declare class JoinQueryBuilder<DocumentType extends DocumentData, MyAlias extends Alias, ReturnType extends Record<MyAlias, DocumentReference<DocumentType> | undefined>> {
|
|
16
|
+
private readonly collectionName;
|
|
17
|
+
private readonly integrationId;
|
|
18
|
+
private readonly querySubscriptionManager;
|
|
19
|
+
private readonly documentReferenceFactory;
|
|
20
|
+
private readonly alias;
|
|
21
|
+
private readonly joinQueryBuilderFactory;
|
|
22
|
+
private readonly queryBuilderFactory;
|
|
23
|
+
private readonly simpleQueryBuilder;
|
|
24
|
+
private readonly joins;
|
|
25
|
+
/** Record that maps the right alias to the left condition */
|
|
26
|
+
private readonly joinConditions;
|
|
27
|
+
constructor(collectionName: CollectionName, integrationId: IntegrationId, querySubscriptionManager: QuerySubscriptionManager, documentReferenceFactory: DocumentReferenceFactory, alias: MyAlias, joinQueryBuilderFactory: JoinQueryBuilderFactory, queryBuilderFactory: QueryBuilderFactory);
|
|
28
|
+
where(fieldName: (keyof DocumentType & FieldName) | string, operator: Operator | 'in' | 'not in', value: PrimitiveFieldType | Array<PrimitiveFieldType>): this;
|
|
29
|
+
limit(limit: number): this;
|
|
30
|
+
sortBy(fieldName: keyof DocumentType & FieldName, asc?: boolean): this;
|
|
31
|
+
join<J extends DocumentData, RightAlias extends Alias, RightReturnType extends Record<RightAlias, DocumentReference<J> | undefined>>(queryBuilder: JoinQueryBuilder<J, RightAlias, RightReturnType>, leftFieldName: keyof DocumentType & FieldName, rightFieldName: keyof J & FieldName): JoinQueryBuilder<DocumentType, MyAlias, ReturnType & Partial<RightReturnType>>;
|
|
32
|
+
snapshot(): Promise<Array<ReturnType>>;
|
|
33
|
+
snapshots(subscribe?: boolean): Observable<Array<ReturnType>>;
|
|
34
|
+
build(): Query;
|
|
35
|
+
}
|
|
@@ -4,38 +4,31 @@ import DocumentIdentityService from '../document-identity.service';
|
|
|
4
4
|
import { DocumentReference } from '../document-reference';
|
|
5
5
|
import { DocumentReferenceFactory } from '../document-reference.factory';
|
|
6
6
|
import { QuerySubscriptionManager } from './query-subscription.manager';
|
|
7
|
-
import { Alias } from './query.types';
|
|
8
7
|
export declare class QueryBuilderFactory {
|
|
9
8
|
private readonly querySubscriptionManager;
|
|
10
9
|
private readonly documentReferenceFactory;
|
|
11
10
|
private readonly documentIdentityService;
|
|
12
11
|
constructor(querySubscriptionManager: QuerySubscriptionManager, documentReferenceFactory: DocumentReferenceFactory, documentIdentityService: DocumentIdentityService);
|
|
13
|
-
getForDocument<DocumentType extends DocumentData
|
|
14
|
-
get<DocumentType extends DocumentData
|
|
15
|
-
getForJoin<DocumentType extends DocumentData, MyAlias extends Alias, ReturnType extends Record<MyAlias, DocumentReference<DocumentType>>>(collectionName: CollectionName, integrationId: IntegrationId, alias: MyAlias): QueryBuilder<DocumentType, MyAlias, ReturnType, true>;
|
|
12
|
+
getForDocument<DocumentType extends DocumentData>(squidDocId: SquidDocId): QueryBuilder<DocumentType>;
|
|
13
|
+
get<DocumentType extends DocumentData>(collectionName: CollectionName, integrationId: IntegrationId): QueryBuilder<DocumentType>;
|
|
16
14
|
}
|
|
17
|
-
export declare class QueryBuilder<DocumentType extends DocumentData
|
|
15
|
+
export declare class QueryBuilder<DocumentType extends DocumentData> {
|
|
18
16
|
private readonly collectionName;
|
|
19
17
|
private readonly integrationId;
|
|
20
18
|
private readonly querySubscriptionManager;
|
|
21
19
|
private readonly documentReferenceFactory;
|
|
22
|
-
private readonly alias;
|
|
23
|
-
private readonly supportsJoin;
|
|
24
20
|
private readonly queryBuilderFactory;
|
|
25
21
|
private readonly documentIdentityService;
|
|
26
22
|
private readonly simpleQueryBuilder;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
sortBy(fieldName: keyof DocumentType & FieldName, asc?: boolean): SupportsJoin extends true ? this : Omit<this, 'join'>;
|
|
34
|
-
join<J extends DocumentData, RightAlias extends Alias, RightReturnType extends Record<RightAlias, DocumentReference<J> | undefined>>(queryBuilder: QueryBuilder<J, RightAlias, RightReturnType, true>, leftFieldName: keyof DocumentType & FieldName, rightFieldName: keyof J & FieldName): QueryBuilder<DocumentType, MyAlias, ReturnType & Partial<RightReturnType>, true>;
|
|
35
|
-
snapshot(): SupportsJoin extends true ? Promise<Array<ReturnType>> : Promise<Array<DocumentReference<DocumentType>>>;
|
|
36
|
-
snapshots(subscribe?: boolean): SupportsJoin extends true ? Observable<Array<ReturnType>> : Observable<Array<DocumentReference<DocumentType>>>;
|
|
23
|
+
constructor(collectionName: CollectionName, integrationId: IntegrationId, querySubscriptionManager: QuerySubscriptionManager, documentReferenceFactory: DocumentReferenceFactory, queryBuilderFactory: QueryBuilderFactory, documentIdentityService: DocumentIdentityService);
|
|
24
|
+
where(fieldName: (keyof DocumentType & FieldName) | string, operator: Operator | 'in' | 'not in', value: PrimitiveFieldType | Array<PrimitiveFieldType>): this;
|
|
25
|
+
limit(limit: number): this;
|
|
26
|
+
sortBy(fieldName: keyof DocumentType & FieldName, asc?: boolean): this;
|
|
27
|
+
snapshot(): Promise<Array<DocumentReference<DocumentType>>>;
|
|
28
|
+
snapshots(subscribe?: boolean): Observable<Array<DocumentReference<DocumentType>>>;
|
|
37
29
|
changes(): Observable<Changes<DocumentType>>;
|
|
38
30
|
build(): Query;
|
|
31
|
+
get hash(): string;
|
|
39
32
|
}
|
|
40
33
|
export interface Changes<DocumentType extends DocumentData> {
|
|
41
34
|
inserts: Array<DocumentReference<DocumentType>>;
|
|
@@ -20,6 +20,7 @@ export declare class Squid {
|
|
|
20
20
|
private readonly lockManager;
|
|
21
21
|
private readonly querySubscriptionManager;
|
|
22
22
|
private readonly queryBuilderFactory;
|
|
23
|
+
private readonly joinQueryBuilderFactory;
|
|
23
24
|
private readonly collectionReferenceFactory;
|
|
24
25
|
private readonly backendFunctionManager;
|
|
25
26
|
private readonly namedQueryManager;
|