@litbase/react 4.0.11 → 4.0.13
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/package.json +4 -4
- package/binary-id/src/base64.d.ts +0 -18
- package/binary-id/src/binary-id-generator.d.ts +0 -20
- package/binary-id/src/binary-id.d.ts +0 -28
- package/binary-id/src/binary-string.d.ts +0 -2
- package/binary-id/src/index.d.ts +0 -4
- package/client/src/config.d.ts +0 -12
- package/client/src/index.d.ts +0 -3
- package/client/src/litbase-client.d.ts +0 -62
- package/client/src/remote-collection.d.ts +0 -16
- package/client/src/upload-file-to-url.d.ts +0 -26
- package/core/src/auth/index.d.ts +0 -2
- package/core/src/auth/session-interface.d.ts +0 -33
- package/core/src/auth/user-interface.d.ts +0 -27
- package/core/src/errors/auth-error.d.ts +0 -3
- package/core/src/errors/index.d.ts +0 -1
- package/core/src/index.d.ts +0 -22
- package/core/src/litql/bulk-write-operation.d.ts +0 -31
- package/core/src/litql/database-interface.d.ts +0 -38
- package/core/src/litql/in-memory-database-collection.d.ts +0 -19
- package/core/src/litql/index.d.ts +0 -8
- package/core/src/litql/litql-query.d.ts +0 -4
- package/core/src/litql/litql-types.d.ts +0 -108
- package/core/src/litql/litql.d.ts +0 -163
- package/core/src/litql/query-compiler/compiler-helpers.d.ts +0 -5
- package/core/src/litql/query-compiler/update-compiler.d.ts +0 -2
- package/core/src/logger/console-transport.d.ts +0 -2
- package/core/src/logger/index.d.ts +0 -2
- package/core/src/logger/logger.d.ts +0 -33
- package/core/src/rpc-client-definitions/index.d.ts +0 -1
- package/core/src/rpc-client-definitions/session-definitions.d.ts +0 -3
- package/core/src/rpc-definitions/auth-definitions.d.ts +0 -54
- package/core/src/rpc-definitions/files-definitions.d.ts +0 -14
- package/core/src/rpc-definitions/index.d.ts +0 -4
- package/core/src/rpc-definitions/litql-definitions.d.ts +0 -3
- package/core/src/rpc-definitions/session-definitions.d.ts +0 -2
- package/core/src/rpc-message-logger.d.ts +0 -15
- package/core/src/utils/create-change-observable.d.ts +0 -2
- package/core/src/utils/deep-assign.d.ts +0 -1
- package/core/src/utils/deep-transform.d.ts +0 -1
- package/core/src/utils/exhaust-map-with-trailing.d.ts +0 -1
- package/core/src/utils/get-in.d.ts +0 -1
- package/core/src/utils/get-value-of.d.ts +0 -2
- package/core/src/utils/is-email.d.ts +0 -7
- package/core/src/utils/is-plain-object.d.ts +0 -1
- package/core/src/utils/iterable-utils.d.ts +0 -4
- package/core/src/utils/set.d.ts +0 -1
- package/core/src/utils/simple-object-iterator.d.ts +0 -5
- package/event-emitter/src/index.d.ts +0 -45
- package/rxpc/src/encode-data.d.ts +0 -3
- package/rxpc/src/index.d.ts +0 -5
- package/rxpc/src/loopback-rpc-client.d.ts +0 -7
- package/rxpc/src/rpc-client-interface.d.ts +0 -45
- package/rxpc/src/rpc-message.d.ts +0 -70
- package/rxpc/src/rxpc.d.ts +0 -49
- package/rxpc/src/web-socket-rpc-client.d.ts +0 -14
- package/utils/src/deferred.d.ts +0 -6
- package/utils/src/delay.d.ts +0 -2
- package/utils/src/index.d.ts +0 -3
- package/utils/src/is-promise.d.ts +0 -1
- /package/{client-react/src/hooks → hooks}/use-current-user.d.ts +0 -0
- /package/{client-react/src/hooks → hooks}/use-query.d.ts +0 -0
- /package/{client-react/src/index.d.ts → index.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litbase/react",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.13",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"directory": "dist"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@litbase/client": "^4.0.
|
|
33
|
-
"@litbase/core": "^4.0.
|
|
32
|
+
"@litbase/client": "^4.0.13",
|
|
33
|
+
"@litbase/core": "^4.0.13",
|
|
34
34
|
"rxjs": "^7.8.0",
|
|
35
35
|
"tsup": "^6.6.3",
|
|
36
36
|
"typescript": "^4.9.5"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "9b8dec53bc4cc36241ce91c0a1156dac6f1290bd"
|
|
39
39
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* use this to make a Base64 encoded string URL friendly,
|
|
3
|
-
* i.e. '+' and '/' are replaced with '-' and '_' also any trailing '='
|
|
4
|
-
* characters are removed
|
|
5
|
-
*
|
|
6
|
-
* @param {String} str the encoded string
|
|
7
|
-
* @returns {String} the URL friendly encoded String
|
|
8
|
-
*/
|
|
9
|
-
export declare function toUrlSafeBase64(str: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* Use this to recreate a Base64 encoded string that was made URL friendly
|
|
12
|
-
* using Base64EncodeurlFriendly.
|
|
13
|
-
* '-' and '_' are replaced with '+' and '/' and also it is padded with '+'
|
|
14
|
-
*
|
|
15
|
-
* @param {String} str the encoded string
|
|
16
|
-
* @returns {String} the URL friendly encoded String
|
|
17
|
-
*/
|
|
18
|
-
export declare function fromUrlSafeBase64(str: string): string;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { BinaryId } from "./binary-id.js";
|
|
2
|
-
export declare class BinaryIdGenerator {
|
|
3
|
-
counter: number;
|
|
4
|
-
constructor(counter?: number);
|
|
5
|
-
create(): BinaryId;
|
|
6
|
-
createNested(id: BinaryId): BinaryId;
|
|
7
|
-
protected getCurrentTime(): number;
|
|
8
|
-
protected fillRandomValues(buffer: Uint8Array): void;
|
|
9
|
-
}
|
|
10
|
-
export declare class TestBinaryIdGenerator extends BinaryIdGenerator {
|
|
11
|
-
constructor();
|
|
12
|
-
peekNext(): BinaryId;
|
|
13
|
-
createWithCounter(value: number): BinaryId;
|
|
14
|
-
protected getCurrentTime(): number;
|
|
15
|
-
protected fillRandomValues(buffer: Uint8Array): void;
|
|
16
|
-
}
|
|
17
|
-
export declare let defaultBinaryIdGenerator: BinaryIdGenerator;
|
|
18
|
-
export declare function replaceDefaultBinaryIdGenerator(newValue: BinaryIdGenerator): void;
|
|
19
|
-
export declare function createBinaryId(): BinaryId;
|
|
20
|
-
export declare function createNestedBinaryId(nested: BinaryId): BinaryId;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export declare const binaryIdByteLength = 12;
|
|
2
|
-
export declare const nestedBinaryIdByteLength: number;
|
|
3
|
-
export declare const binaryIdStringLength: number;
|
|
4
|
-
export declare const nestedBinaryIdStringLength: number;
|
|
5
|
-
export declare class BinaryId {
|
|
6
|
-
get length(): number;
|
|
7
|
-
get isNested(): boolean;
|
|
8
|
-
get isEmpty(): boolean;
|
|
9
|
-
get isInvalid(): boolean;
|
|
10
|
-
readonly value: string;
|
|
11
|
-
static equals(a: BinaryId | null | undefined, b: BinaryId | null | undefined): boolean;
|
|
12
|
-
static fromBase64String(value: string): BinaryId;
|
|
13
|
-
static fromUrlSafeString(value: string): BinaryId;
|
|
14
|
-
constructor(value: string | ArrayBufferView | BinaryId);
|
|
15
|
-
equals(other: BinaryId): boolean;
|
|
16
|
-
compare(other: BinaryId): number;
|
|
17
|
-
getNested(): BinaryId;
|
|
18
|
-
getDate(): Date;
|
|
19
|
-
toBinary(): Uint8Array;
|
|
20
|
-
toUrlSafeString(): string;
|
|
21
|
-
toBase64String(): string;
|
|
22
|
-
toString(): string;
|
|
23
|
-
toJSON(): string;
|
|
24
|
-
valueOf(): string;
|
|
25
|
-
}
|
|
26
|
-
export declare const EMPTY_ID: BinaryId;
|
|
27
|
-
export declare const EMPTY_NESTED_ID: BinaryId;
|
|
28
|
-
export declare const INVALID_ID: BinaryId;
|
package/binary-id/src/index.d.ts
DELETED
package/client/src/config.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ProjectionObject, RpcMessageLoggerOptions } from "@litbase/core";
|
|
2
|
-
import { UploadFileOptions } from "./litbase-client.js";
|
|
3
|
-
export declare const config: ClientConfigInterface;
|
|
4
|
-
export interface ClientConfigInterface {
|
|
5
|
-
url: string;
|
|
6
|
-
pingEnabled: boolean;
|
|
7
|
-
currentUserFields: ProjectionObject;
|
|
8
|
-
debug: boolean | RpcMessageLoggerOptions;
|
|
9
|
-
usePreSignedUploads: boolean;
|
|
10
|
-
continueWithSessionTimeoutMs: number;
|
|
11
|
-
defaultUploadOptions: UploadFileOptions;
|
|
12
|
-
}
|
package/client/src/index.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { AddUserWithEmailOptions, ChangePasswordOptions, GetUploadUrlOptions, LitQL, LoginResult, LoginWithOAuthOptions, OAuthProvider, UserInterface, WaitForEmailConfirmationOptions } from "@litbase/core";
|
|
2
|
-
import { BehaviorSubject, Observable } from "rxjs";
|
|
3
|
-
import { UploadStatus } from "./upload-file-to-url.js";
|
|
4
|
-
import { ClientConfigInterface } from "./config.js";
|
|
5
|
-
import { WebSocketRpcClient, RpcDefinition } from "@litbase/rxpc";
|
|
6
|
-
export interface UploadFileStatus extends UploadStatus {
|
|
7
|
-
contentUrl?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface UploadFileOptions extends Omit<GetUploadUrlOptions, "filename" | "size" | "contentType"> {
|
|
10
|
-
}
|
|
11
|
-
export declare class LitbaseClient {
|
|
12
|
-
readonly litql: LitQL;
|
|
13
|
-
private readonly config;
|
|
14
|
-
client: WebSocketRpcClient | null;
|
|
15
|
-
currentUser: UserInterface;
|
|
16
|
-
readonly currentUser$: BehaviorSubject<UserInterface>;
|
|
17
|
-
private readonly client$;
|
|
18
|
-
constructor(litql?: LitQL, config?: ClientConfigInterface);
|
|
19
|
-
connect(): Promise<void>;
|
|
20
|
-
private tryConnect;
|
|
21
|
-
callObservable<TArgs extends any[], TResult>(definition: RpcDefinition<TArgs, TResult>, ...args: TArgs): Observable<TResult>;
|
|
22
|
-
call<TArgs extends any[], TResult>(definition: RpcDefinition<TArgs, TResult>, ...args: TArgs): Promise<TResult>;
|
|
23
|
-
callHttp<TArgs extends any[], TResult>(definition: RpcDefinition<TArgs, TResult>, ...args: TArgs): Promise<unknown>;
|
|
24
|
-
changeUserName(username: string): Promise<import("@litbase/core").DocumentInterface | null>;
|
|
25
|
-
confirmEmailLogin(options: {
|
|
26
|
-
emailToken: string;
|
|
27
|
-
loginHere: boolean;
|
|
28
|
-
}): Promise<LoginResult | undefined>;
|
|
29
|
-
loginWithEmail(options: {
|
|
30
|
-
email: string;
|
|
31
|
-
captchaResponse?: string;
|
|
32
|
-
}): Promise<void>;
|
|
33
|
-
loginWithEmailAndPassword(options: {
|
|
34
|
-
email: string;
|
|
35
|
-
password: string;
|
|
36
|
-
}): Promise<LoginResult>;
|
|
37
|
-
registerWithEmailAndPassword(options: {
|
|
38
|
-
email: string;
|
|
39
|
-
password: string;
|
|
40
|
-
name: string;
|
|
41
|
-
}): Promise<LoginResult>;
|
|
42
|
-
addUserWithEmail(options: AddUserWithEmailOptions): Promise<UserInterface>;
|
|
43
|
-
addUserWithEmailAndPassword(options: {
|
|
44
|
-
email: string;
|
|
45
|
-
password: string;
|
|
46
|
-
name: string;
|
|
47
|
-
}): Promise<UserInterface>;
|
|
48
|
-
getCurrentUser(): Promise<UserInterface>;
|
|
49
|
-
isSameBrowser(): Promise<boolean>;
|
|
50
|
-
waitForEmailConfirmation(options: WaitForEmailConfirmationOptions): Promise<LoginResult>;
|
|
51
|
-
loginWithOAuth(provider: OAuthProvider, options: LoginWithOAuthOptions): Promise<LoginResult>;
|
|
52
|
-
logout(): Promise<void>;
|
|
53
|
-
changePassword(options: ChangePasswordOptions): Promise<void>;
|
|
54
|
-
uploadFile(file: File, options?: UploadFileOptions): Observable<UploadFileStatus>;
|
|
55
|
-
getSessionVariable<T, TDefault = undefined>(key: string, defaultValue?: TDefault): Promise<T | TDefault>;
|
|
56
|
-
private waitForConnection;
|
|
57
|
-
private ensureSession;
|
|
58
|
-
private processLoginResult;
|
|
59
|
-
private getAbsoluteUrl;
|
|
60
|
-
private getUrl;
|
|
61
|
-
}
|
|
62
|
-
export declare const client: any;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BulkWriteOperation, DatabaseCollectionInterface, FindOptions, Projection } from "@litbase/core";
|
|
2
|
-
import { Observable } from "rxjs";
|
|
3
|
-
import { LitbaseClient } from "./litbase-client.js";
|
|
4
|
-
export declare class RemoteCollection implements DatabaseCollectionInterface {
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly client: LitbaseClient;
|
|
7
|
-
constructor(name: string, client: LitbaseClient);
|
|
8
|
-
bulkWrite(operations: BulkWriteOperation<object>[], ordered?: boolean): Promise<void>;
|
|
9
|
-
find(query?: object, projection?: Projection, options?: FindOptions): Observable<object[]>;
|
|
10
|
-
findSnapshot(query?: object, projection?: Projection, options?: FindOptions): Promise<object[]>;
|
|
11
|
-
insert(docs: object[]): Promise<void>;
|
|
12
|
-
remove(query: object, multi?: boolean): Promise<void>;
|
|
13
|
-
update(query: object, update: object, multi?: boolean): Promise<void>;
|
|
14
|
-
upsert(query: object, update: object, multi?: boolean): Promise<void>;
|
|
15
|
-
private queryRemote;
|
|
16
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { AjaxResponse } from "rxjs/ajax";
|
|
2
|
-
import { Observable } from "rxjs";
|
|
3
|
-
export declare enum UploadStatusStatus {
|
|
4
|
-
Done = "done",
|
|
5
|
-
Working = "working",
|
|
6
|
-
Errored = "errored"
|
|
7
|
-
}
|
|
8
|
-
export interface UploadStatus {
|
|
9
|
-
status: UploadStatusStatus;
|
|
10
|
-
file: File;
|
|
11
|
-
progress: number;
|
|
12
|
-
error?: Error;
|
|
13
|
-
response?: AjaxResponse<UploadResponseBody>;
|
|
14
|
-
}
|
|
15
|
-
interface UploadResponseBody {
|
|
16
|
-
status: string;
|
|
17
|
-
url: string;
|
|
18
|
-
}
|
|
19
|
-
export interface UploadFileToUrlOptions {
|
|
20
|
-
extraFields?: Record<string, string>;
|
|
21
|
-
extraHeaders?: Record<string, string>;
|
|
22
|
-
useFormData?: boolean;
|
|
23
|
-
method?: string;
|
|
24
|
-
}
|
|
25
|
-
export declare function uploadFileToUrl(file: File, url: string, { extraHeaders, extraFields, useFormData, method }?: UploadFileToUrlOptions): Observable<UploadStatus>;
|
|
26
|
-
export {};
|
package/core/src/auth/index.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { BinaryId } from "@litbase/binary-id";
|
|
2
|
-
import { DocumentInterface } from "../litql/index.js";
|
|
3
|
-
export type SessionId = string;
|
|
4
|
-
export interface SessionInterface extends DocumentInterface {
|
|
5
|
-
sessionId: SessionId;
|
|
6
|
-
createdAt: Date;
|
|
7
|
-
rotateAt: Date;
|
|
8
|
-
expiresAt: Date;
|
|
9
|
-
lastSeen: Date;
|
|
10
|
-
values: SessionValues;
|
|
11
|
-
}
|
|
12
|
-
export declare const userIdSessionKey: "userId";
|
|
13
|
-
export declare const sameBrowserTokenSessionKey: "sameBrowserToken";
|
|
14
|
-
export type SessionValues = {
|
|
15
|
-
[userIdSessionKey]?: {
|
|
16
|
-
value: BinaryId;
|
|
17
|
-
visibility: ClientVisibility.read;
|
|
18
|
-
};
|
|
19
|
-
[sameBrowserTokenSessionKey]?: {
|
|
20
|
-
value: BinaryId;
|
|
21
|
-
visibility: ClientVisibility.read;
|
|
22
|
-
};
|
|
23
|
-
[key: string]: SessionValue | undefined;
|
|
24
|
-
};
|
|
25
|
-
export interface SessionValue {
|
|
26
|
-
value: any;
|
|
27
|
-
visibility: ClientVisibility;
|
|
28
|
-
}
|
|
29
|
-
export declare enum ClientVisibility {
|
|
30
|
-
readWrite = "readWrite",
|
|
31
|
-
read = "read",
|
|
32
|
-
hidden = "hidden"
|
|
33
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { DocumentInterface } from "../litql/index.js";
|
|
2
|
-
import { OAuthProvider } from "../rpc-definitions/auth-definitions.js";
|
|
3
|
-
export interface UserInterface extends DocumentInterface {
|
|
4
|
-
name: string;
|
|
5
|
-
providers: {
|
|
6
|
-
[key in OAuthProvider]?: {
|
|
7
|
-
id: string;
|
|
8
|
-
};
|
|
9
|
-
} & {
|
|
10
|
-
email?: {
|
|
11
|
-
id: string;
|
|
12
|
-
hashedPassword?: string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Use {@link UserInterface} instead
|
|
18
|
-
*/
|
|
19
|
-
export type BaseUserInterface = UserInterface;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use {@link UserInterface} instead
|
|
22
|
-
*/
|
|
23
|
-
export type RegisteredUser = UserInterface;
|
|
24
|
-
export declare const emptyUser: UserInterface;
|
|
25
|
-
export declare const guestUser: UserInterface;
|
|
26
|
-
export declare function isEmptyUser(user: UserInterface): boolean;
|
|
27
|
-
export declare function isUserGuest(user: UserInterface): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AuthError } from "./auth-error.js";
|
package/core/src/index.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export * from "./errors/index.js";
|
|
2
|
-
export * from "@litbase/binary-id";
|
|
3
|
-
export * from "@litbase/rxpc";
|
|
4
|
-
export * from "./auth/index.js";
|
|
5
|
-
export * from "./litql/index.js";
|
|
6
|
-
export * from "@litbase/event-emitter";
|
|
7
|
-
export * from "./utils/exhaust-map-with-trailing.js";
|
|
8
|
-
export * from "@litbase/utils";
|
|
9
|
-
export * from "./utils/get-value-of.js";
|
|
10
|
-
export * from "./utils/iterable-utils.js";
|
|
11
|
-
export * from "./utils/create-change-observable.js";
|
|
12
|
-
export * from "./utils/simple-object-iterator.js";
|
|
13
|
-
export * from "./utils/deep-assign.js";
|
|
14
|
-
export * from "./utils/deep-transform.js";
|
|
15
|
-
export * from "./utils/get-in.js";
|
|
16
|
-
export * from "./utils/set.js";
|
|
17
|
-
export * from "./utils/is-plain-object.js";
|
|
18
|
-
export * from "./utils/is-email.js";
|
|
19
|
-
export * from "./logger/index.js";
|
|
20
|
-
export * from "./rpc-definitions/index.js";
|
|
21
|
-
export * from "./rpc-client-definitions/index.js";
|
|
22
|
-
export * from "./rpc-message-logger.js";
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { DocumentInterface } from "./database-interface.js";
|
|
2
|
-
interface InsertOneOperation<TDoc> {
|
|
3
|
-
insertOne: {
|
|
4
|
-
document: TDoc;
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
interface UpdateOneOperation {
|
|
8
|
-
updateOne: {
|
|
9
|
-
filter: object;
|
|
10
|
-
update: object;
|
|
11
|
-
upsert?: boolean;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
interface UpdateManyOperation {
|
|
15
|
-
updateMany: {
|
|
16
|
-
filter: object;
|
|
17
|
-
update: object;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
interface DeleteOneOperation {
|
|
21
|
-
deleteOne: {
|
|
22
|
-
filter: object;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
interface DeleteManyOperation {
|
|
26
|
-
deleteMany: {
|
|
27
|
-
filter: object;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export type BulkWriteOperation<TDoc = DocumentInterface> = InsertOneOperation<TDoc> | UpdateOneOperation | UpdateManyOperation | DeleteOneOperation | DeleteManyOperation;
|
|
31
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Observable } from "rxjs";
|
|
2
|
-
import { BulkWriteOperation } from "./bulk-write-operation.js";
|
|
3
|
-
import { BinaryId } from "@litbase/binary-id";
|
|
4
|
-
export type SortOptions = {
|
|
5
|
-
[key: string]: 1 | -1;
|
|
6
|
-
};
|
|
7
|
-
type IncludeProjection<T> = {
|
|
8
|
-
[Prop in keyof T]?: 1 | IncludeProjection<T[Prop]>;
|
|
9
|
-
};
|
|
10
|
-
type ExcludeProjection<T> = {
|
|
11
|
-
[Prop in keyof T]?: 0 | ExcludeProjection<T[Prop]>;
|
|
12
|
-
};
|
|
13
|
-
export type Projection<T = {}> = IncludeProjection<T> | ExcludeProjection<T>;
|
|
14
|
-
export interface FindOptions {
|
|
15
|
-
sort?: SortOptions | null;
|
|
16
|
-
limit?: number | null;
|
|
17
|
-
skip?: number | null;
|
|
18
|
-
allFields?: boolean;
|
|
19
|
-
}
|
|
20
|
-
export interface DatabaseInterface {
|
|
21
|
-
ready: Promise<void>;
|
|
22
|
-
getCollection(name: string): DatabaseCollectionInterface;
|
|
23
|
-
close(): Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
export interface DatabaseCollectionInterface {
|
|
26
|
-
name: string;
|
|
27
|
-
find(query?: object, projection?: Projection, options?: FindOptions): Observable<object[]>;
|
|
28
|
-
findSnapshot(query?: object, projection?: Projection, options?: FindOptions): Promise<object[]>;
|
|
29
|
-
update(query: object, update: object, multi?: boolean): Promise<void>;
|
|
30
|
-
upsert(query: object, update: object, multi?: boolean): Promise<void>;
|
|
31
|
-
remove(query: object, multi?: boolean): Promise<void>;
|
|
32
|
-
insert(docs: object[]): Promise<void>;
|
|
33
|
-
bulkWrite(operations: BulkWriteOperation<object>[], ordered?: boolean): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
export interface DocumentInterface {
|
|
36
|
-
_id: BinaryId;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BulkWriteOperation } from "./bulk-write-operation.js";
|
|
2
|
-
import { Observable } from "rxjs";
|
|
3
|
-
import { DatabaseCollectionInterface, DocumentInterface, FindOptions, Projection } from "../index.js";
|
|
4
|
-
export declare class InMemoryDatabaseCollection<T extends DocumentInterface = DocumentInterface> implements DatabaseCollectionInterface {
|
|
5
|
-
readonly name: string;
|
|
6
|
-
items: T[];
|
|
7
|
-
private readonly change;
|
|
8
|
-
constructor(name: string);
|
|
9
|
-
find(query?: object, projection?: Projection, options?: FindOptions): Observable<T[]>;
|
|
10
|
-
findSnapshot(query?: object, projection?: Projection, options?: FindOptions): Promise<T[]>;
|
|
11
|
-
insert(docs: T[]): Promise<void>;
|
|
12
|
-
remove(query: object, multi?: boolean): Promise<void>;
|
|
13
|
-
update(query: object, update: object, multi?: boolean): Promise<void>;
|
|
14
|
-
upsert(query: object, { $setOnInsert, ...update }: {
|
|
15
|
-
$setOnInsert: object;
|
|
16
|
-
}, multi?: boolean): Promise<void>;
|
|
17
|
-
bulkWrite(operations: BulkWriteOperation[], ordered?: boolean): Promise<void>;
|
|
18
|
-
private updateItems;
|
|
19
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from "./litql.js";
|
|
2
|
-
export * from "./litql-query.js";
|
|
3
|
-
export * from "./litql-types.js";
|
|
4
|
-
export * from "../utils/iterable-utils.js";
|
|
5
|
-
export * from "../utils/get-value-of.js";
|
|
6
|
-
export * from "./database-interface.js";
|
|
7
|
-
export * from "./bulk-write-operation.js";
|
|
8
|
-
export * from "./in-memory-database-collection.js";
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { DatabaseCollectionInterface, SortOptions } from "./database-interface.js";
|
|
2
|
-
import { LitQL } from "./litql.js";
|
|
3
|
-
/**
|
|
4
|
-
* The type of the body of a query
|
|
5
|
-
*/
|
|
6
|
-
export type QueryBody = Record<string, QueryTypeBody>;
|
|
7
|
-
/**
|
|
8
|
-
* The type of the value of a single type in a {@link QueryBody}
|
|
9
|
-
*/
|
|
10
|
-
export type QueryTypeBody = Record<string, QueryFieldBody | QueryOperatorBody>;
|
|
11
|
-
/**
|
|
12
|
-
* The type of the value of a single field in a {@link QueryTypeBody}
|
|
13
|
-
*/
|
|
14
|
-
export type QueryFieldBody = Record<string, unknown> | 1;
|
|
15
|
-
/**
|
|
16
|
-
* The type of the value of a single operator in a {@link QueryTypeBody}
|
|
17
|
-
*/
|
|
18
|
-
export type QueryOperatorBody = unknown;
|
|
19
|
-
/**
|
|
20
|
-
* Additional options that can be passed to a LitQL query
|
|
21
|
-
*/
|
|
22
|
-
export interface QueryOptions {
|
|
23
|
-
/**
|
|
24
|
-
* If true, will only return a one-time snapshot of the query results and will NOT create a live query returning later
|
|
25
|
-
* updates.
|
|
26
|
-
*/
|
|
27
|
-
once?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Additional, custom values passed with the query. Most often used to pass values to hooks or fulfill functions
|
|
30
|
-
* (e.g. the current user).
|
|
31
|
-
*/
|
|
32
|
-
context?: Record<string, unknown>;
|
|
33
|
-
}
|
|
34
|
-
export type JoinCardinality = "one" | "many";
|
|
35
|
-
/**
|
|
36
|
-
* Describes a join side when specifying a database join using {@link registerJoin}
|
|
37
|
-
*/
|
|
38
|
-
export interface JoinPoint {
|
|
39
|
-
/**
|
|
40
|
-
* The name of the type on this joining side
|
|
41
|
-
*/
|
|
42
|
-
type: string;
|
|
43
|
-
/**
|
|
44
|
-
* The name of the new field, that will contain the joined documents from the other side
|
|
45
|
-
*/
|
|
46
|
-
field: string;
|
|
47
|
-
/**
|
|
48
|
-
* The field in this side of the join that must contain a matching value to the other side's joinField.
|
|
49
|
-
*/
|
|
50
|
-
joinField: string;
|
|
51
|
-
/**
|
|
52
|
-
* Specifies the cardinality of this side, eg. one-to-many, one-to-one, many-to-many, etc.
|
|
53
|
-
*/
|
|
54
|
-
joinType: JoinCardinality;
|
|
55
|
-
}
|
|
56
|
-
export interface JoinPointResolution {
|
|
57
|
-
joinPoint: RegisteredJoinPoint;
|
|
58
|
-
query: QueryResolution;
|
|
59
|
-
}
|
|
60
|
-
export interface RegisteredJoinPoint extends JoinPoint {
|
|
61
|
-
oppositeSide: JoinPoint;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* A registered, queryable type
|
|
65
|
-
*/
|
|
66
|
-
export interface RegisteredCollection extends RegisterCollectionOptions {
|
|
67
|
-
joinPoints: Map<string, RegisteredJoinPoint>;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* A resolved type with details
|
|
71
|
-
*/
|
|
72
|
-
export interface QueryResolution {
|
|
73
|
-
/**
|
|
74
|
-
* The type belonging to the resolution.
|
|
75
|
-
*/
|
|
76
|
-
collection: RegisteredCollection;
|
|
77
|
-
/**
|
|
78
|
-
* A map of operators found in {@link body}. Keys are the operator names, values are the operator values
|
|
79
|
-
*/
|
|
80
|
-
operators: Map<string, unknown>;
|
|
81
|
-
/**
|
|
82
|
-
* A set of projected fields found in {@link body}. Does not contain dynamic fields.
|
|
83
|
-
*/
|
|
84
|
-
projection: Map<string, unknown>;
|
|
85
|
-
joinPoints: Map<string, JoinPointResolution>;
|
|
86
|
-
criteria: Record<string, unknown>;
|
|
87
|
-
isMulti: boolean;
|
|
88
|
-
isLive: boolean;
|
|
89
|
-
sort: SortOptions | null;
|
|
90
|
-
limit: number | null;
|
|
91
|
-
skip: number | null;
|
|
92
|
-
context: Record<string, unknown>;
|
|
93
|
-
litql: LitQL;
|
|
94
|
-
isFullProjection: boolean;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Options given to {@link registerCollection}
|
|
98
|
-
*/
|
|
99
|
-
export interface RegisterCollectionOptions {
|
|
100
|
-
/**
|
|
101
|
-
* @see {@link RegisterTypeOptions#name}
|
|
102
|
-
*/
|
|
103
|
-
name: string;
|
|
104
|
-
/**
|
|
105
|
-
* The backing collection where the data presides
|
|
106
|
-
*/
|
|
107
|
-
collection: DatabaseCollectionInterface;
|
|
108
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { JoinPoint, QueryResolution, QueryTypeBody, RegisterCollectionOptions, RegisteredCollection } from "./litql-types.js";
|
|
2
|
-
import { Observable } from "rxjs";
|
|
3
|
-
import { DocumentInterface, FindOptions } from "./database-interface.js";
|
|
4
|
-
import { EventEmitter } from "@litbase/event-emitter";
|
|
5
|
-
export interface UnknownCollectionEventArgs {
|
|
6
|
-
name: string;
|
|
7
|
-
body?: BaseQueryObject;
|
|
8
|
-
resolution: RegisterCollectionOptions | null;
|
|
9
|
-
}
|
|
10
|
-
export interface FindHookEventArgs {
|
|
11
|
-
resolution: QueryResolution;
|
|
12
|
-
projection: Map<string, unknown>;
|
|
13
|
-
findOptions: FindOptions;
|
|
14
|
-
results: DocumentInterface[] | null;
|
|
15
|
-
}
|
|
16
|
-
export interface BeforeFindHookEventArgs extends FindHookEventArgs {
|
|
17
|
-
cancel: boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface MutationHookEventArgs {
|
|
20
|
-
resolution: QueryResolution;
|
|
21
|
-
action: "update" | "upsert" | "remove" | "insert";
|
|
22
|
-
}
|
|
23
|
-
export interface BeforeMutationHookEventArgs extends MutationHookEventArgs {
|
|
24
|
-
cancel: boolean;
|
|
25
|
-
}
|
|
26
|
-
export interface UpdateHookEventArgs extends MutationHookEventArgs {
|
|
27
|
-
body: object;
|
|
28
|
-
}
|
|
29
|
-
export interface BeforeUpdateHookEventArgs extends UpdateHookEventArgs {
|
|
30
|
-
cancel: boolean;
|
|
31
|
-
}
|
|
32
|
-
export interface InsertHookEventArgs extends MutationHookEventArgs {
|
|
33
|
-
items: DocumentInterface[];
|
|
34
|
-
}
|
|
35
|
-
export interface BeforeInsertHookEventArgs extends InsertHookEventArgs {
|
|
36
|
-
cancel: boolean;
|
|
37
|
-
}
|
|
38
|
-
export interface QueryHookEventArgs {
|
|
39
|
-
resolution: QueryResolution;
|
|
40
|
-
}
|
|
41
|
-
interface LitQLEvents {
|
|
42
|
-
unknownCollection(event: UnknownCollectionEventArgs): void;
|
|
43
|
-
beforeQuery(event: QueryHookEventArgs): void;
|
|
44
|
-
beforeFind(event: BeforeFindHookEventArgs): void;
|
|
45
|
-
afterFind(event: FindHookEventArgs): void;
|
|
46
|
-
beforeUpdate(event: BeforeUpdateHookEventArgs): void;
|
|
47
|
-
afterUpdate(event: UpdateHookEventArgs): void;
|
|
48
|
-
beforeUpsert(event: BeforeUpdateHookEventArgs): void;
|
|
49
|
-
afterUpsert(event: UpdateHookEventArgs): void;
|
|
50
|
-
beforeRemove(event: BeforeMutationHookEventArgs): void;
|
|
51
|
-
afterRemove(event: MutationHookEventArgs): void;
|
|
52
|
-
beforeInsert(event: BeforeInsertHookEventArgs): void;
|
|
53
|
-
afterInsert(event: InsertHookEventArgs): void;
|
|
54
|
-
}
|
|
55
|
-
type Abc = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
56
|
-
export interface ProjectionObject {
|
|
57
|
-
[key: `${Abc | "_"}${string}`]: 1 | QueryObject;
|
|
58
|
-
}
|
|
59
|
-
export interface BaseQueryObject extends ProjectionObject {
|
|
60
|
-
$pull?: 1;
|
|
61
|
-
$push?: object;
|
|
62
|
-
$upsert?: object;
|
|
63
|
-
$update?: object;
|
|
64
|
-
$set?: object;
|
|
65
|
-
$context?: object;
|
|
66
|
-
$sort?: Record<string, 1 | -1>;
|
|
67
|
-
$limit?: number;
|
|
68
|
-
$skip?: number;
|
|
69
|
-
$allFields?: 1 | 0 | true | false;
|
|
70
|
-
}
|
|
71
|
-
export interface QueryObject extends BaseQueryObject {
|
|
72
|
-
$match?: Record<string, unknown>;
|
|
73
|
-
$matchAll?: Record<string, unknown>;
|
|
74
|
-
$live?: boolean;
|
|
75
|
-
}
|
|
76
|
-
export interface SinglePromiseQueryObject extends BaseQueryObject {
|
|
77
|
-
$match?: object;
|
|
78
|
-
$live?: false;
|
|
79
|
-
}
|
|
80
|
-
export interface MultiPromiseQueryObject extends BaseQueryObject {
|
|
81
|
-
$matchAll: object;
|
|
82
|
-
$live?: false;
|
|
83
|
-
}
|
|
84
|
-
export interface SingleObservableQueryObject extends BaseQueryObject {
|
|
85
|
-
$match?: object;
|
|
86
|
-
$live: true;
|
|
87
|
-
}
|
|
88
|
-
export interface MultiObservableQueryObject extends BaseQueryObject {
|
|
89
|
-
$matchAll: object;
|
|
90
|
-
$live: true;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Responsible for parsing LitQL queries and resolving their type, field, projection, etc. info.
|
|
94
|
-
*/
|
|
95
|
-
export declare class LitQL extends EventEmitter<LitQLEvents> {
|
|
96
|
-
/**
|
|
97
|
-
* A map of registered types that this parser can identify
|
|
98
|
-
* @private
|
|
99
|
-
*/
|
|
100
|
-
private readonly collections;
|
|
101
|
-
/**
|
|
102
|
-
* Executes the specified LitQL query, on the specified type.
|
|
103
|
-
* @param name The type to query
|
|
104
|
-
* @param query Query body of the type
|
|
105
|
-
*/
|
|
106
|
-
query<T extends DocumentInterface>(name: string, query: SinglePromiseQueryObject): Promise<T | null>;
|
|
107
|
-
query<T extends DocumentInterface>(name: string, query: MultiPromiseQueryObject): Promise<T[]>;
|
|
108
|
-
query<T extends DocumentInterface>(name: string, query: SingleObservableQueryObject): Observable<T | null>;
|
|
109
|
-
query<T extends DocumentInterface>(name: string, query: MultiObservableQueryObject): Observable<T[]>;
|
|
110
|
-
/**
|
|
111
|
-
* Executes the specified LitQL query, on the specified type.
|
|
112
|
-
* @param name The type to query
|
|
113
|
-
* @param body Query body of the type
|
|
114
|
-
*/
|
|
115
|
-
queryType<TResult extends DocumentInterface>(name: string, body: QueryTypeBody): Observable<TResult[]>;
|
|
116
|
-
/**
|
|
117
|
-
* Executes the specified LitQL query, on the specified type, returning only a snapshot of the results, ignoring
|
|
118
|
-
* later updates.
|
|
119
|
-
* @param typeName The type to query
|
|
120
|
-
* @param body Query body of the type
|
|
121
|
-
*/
|
|
122
|
-
queryTypeOnce<TResult extends DocumentInterface>(typeName: string, body: QueryTypeBody): Promise<TResult[]>;
|
|
123
|
-
/**
|
|
124
|
-
* Executes the specified LitQL query, on the specified type, returning a single result, or null if none found.
|
|
125
|
-
* @param typeName The type to query
|
|
126
|
-
* @param body Query body of the type
|
|
127
|
-
*/
|
|
128
|
-
queryTypeOne<TResult extends DocumentInterface>(typeName: string, body: QueryTypeBody): Observable<TResult | null>;
|
|
129
|
-
/**
|
|
130
|
-
* Executes the specified LitQL query, on the specified type, returning a single result, or null if none found.
|
|
131
|
-
* Will return only a snapshot of the results, ignoring later updates.
|
|
132
|
-
* @param typeName The type to query
|
|
133
|
-
* @param body Query body of the type
|
|
134
|
-
*/
|
|
135
|
-
queryTypeOneOnce<TResult extends DocumentInterface>(typeName: string, body: QueryTypeBody): Promise<TResult | null>;
|
|
136
|
-
/**
|
|
137
|
-
* Register a new, queryable type
|
|
138
|
-
* @param options The type's options
|
|
139
|
-
*/
|
|
140
|
-
registerCollection(options: RegisterCollectionOptions): RegisteredCollection;
|
|
141
|
-
/**
|
|
142
|
-
* Creates a joining connection between two types through the specified fields.
|
|
143
|
-
* @param left Specifies the details of the left side of the connection
|
|
144
|
-
* @param right Specifies the details of the right side of the connection
|
|
145
|
-
*/
|
|
146
|
-
registerJoin(left: JoinPoint, right: JoinPoint): void;
|
|
147
|
-
/**
|
|
148
|
-
* Returns a type by name. If there's no registered type under the name, returns null
|
|
149
|
-
* @param name The case insensitive name of the registered type
|
|
150
|
-
* @param body
|
|
151
|
-
*/
|
|
152
|
-
getCollectionInfo(name: string, body?: QueryObject): RegisteredCollection | null;
|
|
153
|
-
getCollection(name: string): import("./database-interface.js").DatabaseCollectionInterface;
|
|
154
|
-
resolveCollectionBody(name: string, body: QueryObject): QueryResolution | null;
|
|
155
|
-
private resolveJoinPoint;
|
|
156
|
-
private setPrimaryIdIfNeeded;
|
|
157
|
-
private supplyIdIfNeeded;
|
|
158
|
-
private mergeSetIntoUpdate;
|
|
159
|
-
private extractCriteria;
|
|
160
|
-
}
|
|
161
|
-
export declare const litql: LitQL;
|
|
162
|
-
export declare function registerLitql(): void;
|
|
163
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare function parsePath(path: PropertyKey): PropertyKey[];
|
|
2
|
-
export declare function explodeAssignObject<TValue = unknown>(obj: object): [PropertyKey[], TValue][];
|
|
3
|
-
export declare function getSortableValue(value: any): any;
|
|
4
|
-
export declare function compareValues(a: any, b: any): number;
|
|
5
|
-
export declare function sortDocuments<T>(documents: T[], sortOptions: object): T[];
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export declare enum LogLevel {
|
|
2
|
-
Debug = 20,
|
|
3
|
-
Info = 30,
|
|
4
|
-
Warn = 40,
|
|
5
|
-
Error = 50,
|
|
6
|
-
Silent = 999
|
|
7
|
-
}
|
|
8
|
-
export declare const logLevelNames: {
|
|
9
|
-
readonly 20: "debug";
|
|
10
|
-
readonly 30: "info";
|
|
11
|
-
readonly 40: "warn";
|
|
12
|
-
readonly 50: "error";
|
|
13
|
-
};
|
|
14
|
-
export interface LoggerTransport {
|
|
15
|
-
(level: LogLevel, message: string, context?: unknown): void;
|
|
16
|
-
}
|
|
17
|
-
export type LogContext = Record<string, unknown> | Error;
|
|
18
|
-
export declare class Logger {
|
|
19
|
-
private transports;
|
|
20
|
-
level: LogLevel;
|
|
21
|
-
context: LogContext;
|
|
22
|
-
module?: string;
|
|
23
|
-
parent: Logger | null;
|
|
24
|
-
error(message: string, context?: LogContext): void;
|
|
25
|
-
warn(message: string, context?: LogContext): void;
|
|
26
|
-
info(message: string, context?: LogContext): void;
|
|
27
|
-
log(message: string, context?: LogContext): void;
|
|
28
|
-
debug(message: string, context?: LogContext): void;
|
|
29
|
-
child(extraContext?: LogContext, module?: string): Logger;
|
|
30
|
-
addTransport(transport: LoggerTransport): void;
|
|
31
|
-
private onLog;
|
|
32
|
-
}
|
|
33
|
-
export declare const logger: Logger;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./session-definitions.js";
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { UserInterface } from "../auth/index.js";
|
|
2
|
-
import { BinaryId } from "@litbase/binary-id";
|
|
3
|
-
import { RpcDefinition } from "@litbase/rxpc";
|
|
4
|
-
export interface LoginWithOAuthOptions {
|
|
5
|
-
code: string;
|
|
6
|
-
redirectUri: string;
|
|
7
|
-
}
|
|
8
|
-
export interface LoginResult {
|
|
9
|
-
user: UserInterface;
|
|
10
|
-
}
|
|
11
|
-
export interface LoginWithEmailResult {
|
|
12
|
-
OTP: BinaryId;
|
|
13
|
-
expiration: Date;
|
|
14
|
-
}
|
|
15
|
-
export interface ChangePasswordOptions {
|
|
16
|
-
userId: BinaryId;
|
|
17
|
-
newPassword: string;
|
|
18
|
-
currentPassword?: string;
|
|
19
|
-
}
|
|
20
|
-
export interface RegisterWithEmailAndPasswordOptions {
|
|
21
|
-
email: string;
|
|
22
|
-
password: string;
|
|
23
|
-
name: string;
|
|
24
|
-
}
|
|
25
|
-
export interface LoginWithEmailOptions {
|
|
26
|
-
email: string;
|
|
27
|
-
captchaResponse?: string;
|
|
28
|
-
}
|
|
29
|
-
export interface ConfirmEmailLoginOptions {
|
|
30
|
-
emailToken: string;
|
|
31
|
-
loginHere: boolean;
|
|
32
|
-
}
|
|
33
|
-
export interface WaitForEmailConfirmationOptions {
|
|
34
|
-
clientToken: BinaryId;
|
|
35
|
-
}
|
|
36
|
-
export interface AddUserWithEmailOptions {
|
|
37
|
-
email: string;
|
|
38
|
-
password?: string;
|
|
39
|
-
extraUserFields?: Record<string, unknown>;
|
|
40
|
-
}
|
|
41
|
-
export type OAuthProvider = "slack" | "facebook" | "google" | "github";
|
|
42
|
-
export declare const loginWithOAuthFunction: RpcDefinition<[OAuthProvider, LoginWithOAuthOptions], LoginResult>;
|
|
43
|
-
export declare const loginWithEmailAndPasswordFunction: RpcDefinition<[{
|
|
44
|
-
email: string;
|
|
45
|
-
password: string;
|
|
46
|
-
}], LoginResult>;
|
|
47
|
-
export declare const addUserWithEmailFunction: RpcDefinition<[AddUserWithEmailOptions], UserInterface>;
|
|
48
|
-
export declare const addUserWithEmailAndPasswordFunction: RpcDefinition<[RegisterWithEmailAndPasswordOptions], UserInterface>;
|
|
49
|
-
export declare const registerWithEmailAndPasswordFunction: RpcDefinition<[RegisterWithEmailAndPasswordOptions], LoginResult>;
|
|
50
|
-
export declare const loginWithEmailFunction: RpcDefinition<[LoginWithEmailOptions], void>;
|
|
51
|
-
export declare const confirmEmailLoginFunction: RpcDefinition<[ConfirmEmailLoginOptions], LoginResult | undefined>;
|
|
52
|
-
export declare const waitForEmailConfirmationFunction: RpcDefinition<[WaitForEmailConfirmationOptions], LoginResult>;
|
|
53
|
-
export declare const logoutFunction: RpcDefinition<[], void>;
|
|
54
|
-
export declare const changePasswordFunction: RpcDefinition<[ChangePasswordOptions], void>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { RpcDefinition } from "@litbase/rxpc";
|
|
2
|
-
export interface GetUploadUrlOptions {
|
|
3
|
-
filename: string;
|
|
4
|
-
size: number;
|
|
5
|
-
contentType: string;
|
|
6
|
-
skipContentDisposition?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface GetUploadUrlResult {
|
|
9
|
-
uploadUrl: string;
|
|
10
|
-
uploadFields: Record<string, string>;
|
|
11
|
-
uploadHeaders: Record<string, string>;
|
|
12
|
-
downloadUrl: string;
|
|
13
|
-
}
|
|
14
|
-
export declare const getUploadUrlFunction: RpcDefinition<[GetUploadUrlOptions], GetUploadUrlResult>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { WebSocketRpcClient } from "@litbase/rxpc";
|
|
2
|
-
export interface RpcMessageLoggerOptions {
|
|
3
|
-
logReceipts?: boolean;
|
|
4
|
-
logPings?: boolean;
|
|
5
|
-
messageCacheCapacity?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare class RpcMessageLogger {
|
|
8
|
-
logReceipts: boolean;
|
|
9
|
-
logPings: boolean;
|
|
10
|
-
private messageCounter;
|
|
11
|
-
private readonly messageCache;
|
|
12
|
-
constructor({ logReceipts, logPings, messageCacheCapacity, }?: RpcMessageLoggerOptions);
|
|
13
|
-
attach(client: WebSocketRpcClient): void;
|
|
14
|
-
private logRpcMessage;
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function deepAssign<T>(target: Record<string, unknown> | undefined, ...rest: unknown[]): T;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function deepTransform<T>(obj: unknown, transformer: (value: unknown, path: string[]) => unknown | undefined): T;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { exhaustMapWithTrailing } from "rxjs-exhaustmap-with-trailing";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getIn<T = any>(obj: unknown, path: PropertyKey[] | string, defaultValue?: T): T;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isPlainObject(val: unknown): val is Record<string, unknown>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function iterMap<T, R>(iterable: Iterable<T>, transform: (item: T, index: number) => R): Generator<R, void, unknown>;
|
|
2
|
-
export declare function iterFilter<T>(iterable: Iterable<T>, predicate: (item: T, index: number) => boolean): Generator<T, void, unknown>;
|
|
3
|
-
export declare function iterReduce<T, R>(iterable: Iterable<T>, reducer: (previousValue: R | undefined, currentValue: T, currentIndex: number) => R): R | undefined;
|
|
4
|
-
export declare function iterReduce<T, R>(iterable: Iterable<T>, reducer: (previousValue: R, currentValue: T, currentIndex: number) => R, initialValue: R): R;
|
package/core/src/utils/set.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function set(obj: unknown, path: PropertyKey[] | string, value: unknown): void;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Observable } from "rxjs";
|
|
2
|
-
interface DefaultEvents {
|
|
3
|
-
error(arg: {
|
|
4
|
-
error: Error;
|
|
5
|
-
}): void;
|
|
6
|
-
newListener(arg: {
|
|
7
|
-
eventName: string;
|
|
8
|
-
listener: Function;
|
|
9
|
-
}): void;
|
|
10
|
-
removeListener(arg: {
|
|
11
|
-
eventName: string;
|
|
12
|
-
listener: Function;
|
|
13
|
-
}): void;
|
|
14
|
-
}
|
|
15
|
-
export interface EventArgInterface<T> {
|
|
16
|
-
type: EventKey<T>;
|
|
17
|
-
target: EventEmitter<T>;
|
|
18
|
-
}
|
|
19
|
-
type In<T> = T extends (arg: infer U) => any ? U : never;
|
|
20
|
-
export type EventIn<T, K extends EventKey<T>> = (K extends keyof DefaultEvents ? In<DefaultEvents[K]> : K extends keyof T ? In<T[K]> : never) & EventArgInterface<T>;
|
|
21
|
-
type EventKey<T> = keyof T | keyof DefaultEvents;
|
|
22
|
-
/** Extract the listener type for a specific event */
|
|
23
|
-
export type Listener<T, K extends EventKey<T> = EventKey<T>> = (arg: EventIn<T, K>) => void | Promise<any>;
|
|
24
|
-
export type Emit<T> = Omit<T, "type" | "target">;
|
|
25
|
-
export interface EventListenerOptions {
|
|
26
|
-
priority?: number;
|
|
27
|
-
once?: boolean;
|
|
28
|
-
}
|
|
29
|
-
type Arguments<T> = [T] extends [(...args: infer U) => any] ? U : [T] extends [void] ? [] : [T];
|
|
30
|
-
export declare class EventEmitter<T> {
|
|
31
|
-
private listeners;
|
|
32
|
-
addListener<K extends EventKey<T>>(eventName: K, listener: Listener<T, K>, options?: EventListenerOptions): this;
|
|
33
|
-
on<K extends EventKey<T>>(eventName: K, listener: Listener<T, K>, options?: EventListenerOptions): this;
|
|
34
|
-
onObservable<K extends keyof T>(eventName: K, options?: EventListenerOptions): Observable<EventIn<T, K>>;
|
|
35
|
-
removeListener<K extends EventKey<T>>(eventName: K, listener: Listener<T, K>): this;
|
|
36
|
-
off<K extends EventKey<T>>(eventName: K, listener: Listener<T, K>): this;
|
|
37
|
-
removeAllListeners<K extends EventKey<T>>(eventName?: K): this;
|
|
38
|
-
listenerCount(eventName: string): number;
|
|
39
|
-
emit<K extends keyof T>(eventName: K, arg: Arguments<T[K]>[0], options?: {
|
|
40
|
-
rejectOnError?: boolean;
|
|
41
|
-
}): Promise<EventIn<T, K>>;
|
|
42
|
-
emitSync<K extends EventKey<T>>(eventName: K, arg: Emit<EventIn<T, K>>): EventIn<T, K>;
|
|
43
|
-
private catchEmitError;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
package/rxpc/src/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "@litbase/event-emitter";
|
|
2
|
-
import { RpcClientInterface, RpcConnectionEvents } from "./rpc-client-interface.js";
|
|
3
|
-
import { RpcMessageIdOptional } from "./rpc-message.js";
|
|
4
|
-
export declare class LoopbackRpcClient extends EventEmitter<RpcConnectionEvents> implements RpcClientInterface {
|
|
5
|
-
constructor();
|
|
6
|
-
send({ id, ...message }: RpcMessageIdOptional): void;
|
|
7
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { RpcMessage, RpcMessageIdOptional } from "./rpc-message.js";
|
|
2
|
-
import { EventEmitter } from "@litbase/event-emitter";
|
|
3
|
-
export declare enum DisconnectReason {
|
|
4
|
-
None = 0,
|
|
5
|
-
ConnectionDenied = 1,
|
|
6
|
-
Unknown = 2
|
|
7
|
-
}
|
|
8
|
-
export interface DisconnectDetails {
|
|
9
|
-
reason: DisconnectReason;
|
|
10
|
-
details: {
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export interface RpcClientOptions {
|
|
15
|
-
socket: WebSocketInterface;
|
|
16
|
-
}
|
|
17
|
-
export declare enum RpcClientStatus {
|
|
18
|
-
Connected = 0,
|
|
19
|
-
Disconnected = 1
|
|
20
|
-
}
|
|
21
|
-
export interface RpcMessageEvent {
|
|
22
|
-
message: RpcMessage;
|
|
23
|
-
}
|
|
24
|
-
export interface RpcConnectionEvents {
|
|
25
|
-
incomingMessage(event: RpcMessageEvent): void;
|
|
26
|
-
outgoingMessage(event: RpcMessageEvent): void;
|
|
27
|
-
close(event: {}): void;
|
|
28
|
-
error(event: {
|
|
29
|
-
error: Error;
|
|
30
|
-
}): void;
|
|
31
|
-
}
|
|
32
|
-
export interface WebSocketInterface {
|
|
33
|
-
readonly readyState: number;
|
|
34
|
-
addEventListener(type: "message", listener: (ev: {
|
|
35
|
-
data: ArrayBuffer | Uint8Array;
|
|
36
|
-
}) => void): void;
|
|
37
|
-
addEventListener(type: "close", listener: (ev: CloseEvent) => void): void;
|
|
38
|
-
addEventListener(type: "error", listener: (ev: {}) => void): void;
|
|
39
|
-
removeEventListener(type: "message" | "close" | "error", listener: Function): void;
|
|
40
|
-
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
|
|
41
|
-
close(code?: number, reason?: string): void;
|
|
42
|
-
}
|
|
43
|
-
export interface RpcClientInterface extends EventEmitter<RpcConnectionEvents> {
|
|
44
|
-
send(message: RpcMessageIdOptional): void;
|
|
45
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { BinaryId } from "@litbase/binary-id";
|
|
2
|
-
import { Overwrite } from "utility-types";
|
|
3
|
-
export declare enum RpcMessageType {
|
|
4
|
-
Ping = "ping",
|
|
5
|
-
Receipt = "receipt",
|
|
6
|
-
Call = "call",
|
|
7
|
-
Next = "next",
|
|
8
|
-
Complete = "complete",
|
|
9
|
-
Error = "error",
|
|
10
|
-
Unsubscribe = "unsubscribe"
|
|
11
|
-
}
|
|
12
|
-
export type RpcMessageId = BinaryId;
|
|
13
|
-
export interface BaseRpcMessage {
|
|
14
|
-
id: RpcMessageId;
|
|
15
|
-
type: RpcMessageType;
|
|
16
|
-
originalId?: RpcMessageId;
|
|
17
|
-
}
|
|
18
|
-
export interface PingRpcMessage {
|
|
19
|
-
id: RpcMessageId;
|
|
20
|
-
type: RpcMessageType.Ping;
|
|
21
|
-
}
|
|
22
|
-
export interface ReceiptRpcMessage {
|
|
23
|
-
id: RpcMessageId;
|
|
24
|
-
type: RpcMessageType.Receipt;
|
|
25
|
-
originalId: RpcMessageId;
|
|
26
|
-
}
|
|
27
|
-
export interface CallRpcMessage {
|
|
28
|
-
id: RpcMessageId;
|
|
29
|
-
type: RpcMessageType.Call;
|
|
30
|
-
name: string;
|
|
31
|
-
args: unknown[];
|
|
32
|
-
}
|
|
33
|
-
export interface NextRpcMessage<TValue = any> {
|
|
34
|
-
id: RpcMessageId;
|
|
35
|
-
type: RpcMessageType.Next;
|
|
36
|
-
originalId: RpcMessageId;
|
|
37
|
-
value: TValue;
|
|
38
|
-
}
|
|
39
|
-
export interface CompleteRpcMessage {
|
|
40
|
-
id: RpcMessageId;
|
|
41
|
-
type: RpcMessageType.Complete;
|
|
42
|
-
originalId: RpcMessageId;
|
|
43
|
-
}
|
|
44
|
-
export interface ErrorRpcMessage {
|
|
45
|
-
id: RpcMessageId;
|
|
46
|
-
type: RpcMessageType.Error;
|
|
47
|
-
originalId?: RpcMessageId;
|
|
48
|
-
error: Error;
|
|
49
|
-
}
|
|
50
|
-
export interface UnsubscribeRpcMessage {
|
|
51
|
-
id: RpcMessageId;
|
|
52
|
-
type: RpcMessageType.Unsubscribe;
|
|
53
|
-
originalId: RpcMessageId;
|
|
54
|
-
}
|
|
55
|
-
export type RpcMessage = PingRpcMessage | ReceiptRpcMessage | CallRpcMessage | NextRpcMessage | CompleteRpcMessage | ErrorRpcMessage | UnsubscribeRpcMessage;
|
|
56
|
-
export type RpcMessageIdOptional = Overwrite<PingRpcMessage, {
|
|
57
|
-
id?: BinaryId;
|
|
58
|
-
}> | Overwrite<ReceiptRpcMessage, {
|
|
59
|
-
id?: BinaryId;
|
|
60
|
-
}> | Overwrite<CallRpcMessage, {
|
|
61
|
-
id?: BinaryId;
|
|
62
|
-
}> | Overwrite<NextRpcMessage, {
|
|
63
|
-
id?: BinaryId;
|
|
64
|
-
}> | Overwrite<CompleteRpcMessage, {
|
|
65
|
-
id?: BinaryId;
|
|
66
|
-
}> | Overwrite<ErrorRpcMessage, {
|
|
67
|
-
id?: BinaryId;
|
|
68
|
-
}> | Overwrite<UnsubscribeRpcMessage, {
|
|
69
|
-
id?: BinaryId;
|
|
70
|
-
}>;
|
package/rxpc/src/rxpc.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Observable } from "rxjs";
|
|
2
|
-
import { CallRpcMessage, RpcMessage } from "./rpc-message.js";
|
|
3
|
-
import { RpcClientInterface } from "./rpc-client-interface.js";
|
|
4
|
-
import { BinaryId } from "@litbase/binary-id";
|
|
5
|
-
import { EventEmitter } from "@litbase/event-emitter";
|
|
6
|
-
import { LoopbackRpcClient } from "./loopback-rpc-client.js";
|
|
7
|
-
export type RpcFunctionArgs = unknown[];
|
|
8
|
-
export type RpcReceiverFunctionReturn<T> = Observable<T> | Promise<T> | T | void;
|
|
9
|
-
export type RpcReceiverFunction<TArgs extends any[] = any, TReturn = any, TClient extends RpcClientInterface = RpcClientInterface> = (request: RpcRequest<TClient>, ...args: TArgs) => RpcReceiverFunctionReturn<TReturn>;
|
|
10
|
-
export interface RpcRequest<TClient extends RpcClientInterface = RpcClientInterface> {
|
|
11
|
-
client: TClient;
|
|
12
|
-
definition: RpcDefinition;
|
|
13
|
-
args: RpcFunctionArgs;
|
|
14
|
-
messageId: BinaryId;
|
|
15
|
-
}
|
|
16
|
-
export interface HookEventArgs<T> {
|
|
17
|
-
request: RpcRequest;
|
|
18
|
-
response: null | Observable<T>;
|
|
19
|
-
}
|
|
20
|
-
export interface RpcRegistryEvents<T> {
|
|
21
|
-
preCall(arg: HookEventArgs<T>): void;
|
|
22
|
-
preResolve(arg: HookEventArgs<T>): void;
|
|
23
|
-
postResolve(arg: HookEventArgs<T>): void;
|
|
24
|
-
postCall(arg: HookEventArgs<T>): void;
|
|
25
|
-
}
|
|
26
|
-
export declare class Rxpc extends EventEmitter<RpcRegistryEvents<any>> {
|
|
27
|
-
readonly loopback: LoopbackRpcClient;
|
|
28
|
-
private readonly definitions;
|
|
29
|
-
constructor();
|
|
30
|
-
register<TArgs extends any[], TReturn, TClient extends RpcClientInterface = RpcClientInterface>(definition: RpcDefinition<TArgs, TReturn>, handler: RpcReceiverFunction<TArgs, TReturn, TClient>, thisArg?: unknown): void;
|
|
31
|
-
registerWithoutRequest<TArgs extends any[], TReturn>(definition: RpcDefinition<TArgs, TReturn>, func: (...args: TArgs) => RpcReceiverFunctionReturn<TReturn>, thisArg?: unknown): void;
|
|
32
|
-
callObservable<T = any>(client: RpcClientInterface, definition: RpcDefinition, ...args: unknown[]): Observable<T>;
|
|
33
|
-
call<T = any>(client: RpcClientInterface, definition: RpcDefinition, ...args: unknown[]): Promise<T>;
|
|
34
|
-
handleClient(client: RpcClientInterface): void;
|
|
35
|
-
handleMessage(client: RpcClientInterface, message: RpcMessage): void;
|
|
36
|
-
createRequestFromMessage(client: RpcClientInterface, message: CallRpcMessage): RpcRequest;
|
|
37
|
-
getDefinition(name: string): RpcDefinition;
|
|
38
|
-
private sendRemoteCall;
|
|
39
|
-
private handleFunctionCall;
|
|
40
|
-
private doFunctionCall;
|
|
41
|
-
private setupCallListeners;
|
|
42
|
-
}
|
|
43
|
-
export declare const rxpc: Rxpc;
|
|
44
|
-
/** @deprecated */
|
|
45
|
-
export declare const registry: Rxpc;
|
|
46
|
-
export declare class RpcDefinition<TArgs = any, TReturn = any> {
|
|
47
|
-
readonly name: string;
|
|
48
|
-
constructor(name: string);
|
|
49
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "@litbase/event-emitter";
|
|
2
|
-
import { RpcMessageIdOptional } from "./rpc-message.js";
|
|
3
|
-
import { DisconnectDetails, RpcClientOptions, RpcClientStatus, RpcConnectionEvents, WebSocketInterface } from "./rpc-client-interface.js";
|
|
4
|
-
export declare class WebSocketRpcClient extends EventEmitter<RpcConnectionEvents> {
|
|
5
|
-
disconnectReason: DisconnectDetails;
|
|
6
|
-
status: RpcClientStatus;
|
|
7
|
-
protected readonly socket: WebSocketInterface;
|
|
8
|
-
constructor(options: RpcClientOptions);
|
|
9
|
-
close(code?: number, reason?: string): Promise<void>;
|
|
10
|
-
send(message: RpcMessageIdOptional): false | undefined;
|
|
11
|
-
private onMessage;
|
|
12
|
-
private onDisconnect;
|
|
13
|
-
private onError;
|
|
14
|
-
}
|
package/utils/src/deferred.d.ts
DELETED
package/utils/src/delay.d.ts
DELETED
package/utils/src/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isPromise<T>(value: unknown): value is Promise<T>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|