Comparing version 0.8.1 to 0.9.0
@@ -13,2 +13,18 @@ ?.?.? Release notes (2020-??-??) | ||
0.9.0 Release notes (2020-09-24) | ||
============================================================= | ||
### Enhancements | ||
* Added support for linking credentials to an existing user. [#3088](https://github.com/realm/realm-js/pull/3088), [#3239](https://github.com/realm/realm-js/pull/3239) and [#3240](https://github.com/realm/realm-js/pull/3240) | ||
* Added a better toJSON() implementation on User objects. [#3221](https://github.com/realm/realm-js/pull/3221) | ||
* Added `watch` support to MongoDB Collections. [#3247](https://github.com/realm/realm-js/pull/3247) | ||
### Fixed | ||
* If the payload for `callFunction` included certain types the request would fail with `"invalid function call request (status 400)"`. All `EJSON` serialization is now done in canonical mode [#3157](https://github.com/realm/realm-js/pull/3157) | ||
* Fixed sending device information when authenticating a user. [#3220](https://github.com/realm/realm-js/pull/3220) | ||
* Fixed an issue where logging an `app` instance could result in a MongoDB Realm function being called. [#3223](https://github.com/realm/realm-js/pull/3223) | ||
### Internal | ||
* None | ||
0.8.1 Release notes (2020-08-17) | ||
@@ -41,3 +57,3 @@ ============================================================= | ||
### Internal | ||
* None | ||
* Refactored the concept of base, authenticated, prefixed transports into a single "fetcher" built on-top-of the "realm-network-package". ([#3086](https://github.com/realm/realm-js/pull/3086)) | ||
@@ -44,0 +60,0 @@ 0.7.0 Release notes (2020-07-13) |
@@ -0,6 +1,10 @@ | ||
/// <reference types="node" /> | ||
/// <reference path="../types/realm/bson.d.ts" /> | ||
/// <reference path="../types/realm/app.d.ts" /> | ||
declare type StorageChangeListner = () => void; | ||
/** | ||
* A function that can be called when the storage changes. | ||
*/ | ||
declare type StorageChangeListener = () => void; | ||
/** | ||
* Implementors of this provide a simple key-value store. | ||
@@ -36,3 +40,3 @@ */ | ||
*/ | ||
addListener(listener: StorageChangeListner): void; | ||
addListener(listener: StorageChangeListener): void; | ||
/** | ||
@@ -43,3 +47,3 @@ * Remove a callback function which was previously added. | ||
*/ | ||
removeListener(listener: StorageChangeListner): void; | ||
removeListener(listener: StorageChangeListener): void; | ||
} | ||
@@ -81,5 +85,5 @@ | ||
/** @inheritdoc */ | ||
addListener(listener: StorageChangeListner): void; | ||
addListener(listener: StorageChangeListener): void; | ||
/** @inheritdoc */ | ||
removeListener(listener: StorageChangeListner): void; | ||
removeListener(listener: StorageChangeListener): void; | ||
} | ||
@@ -91,10 +95,8 @@ | ||
}; | ||
interface Request<RequestBody> { | ||
interface Request<RequestBody> extends FetchRequestInit<RequestBody> { | ||
method: Method; | ||
url: string; | ||
timeoutMs?: number; | ||
headers?: Headers; | ||
body?: RequestBody | string; | ||
} | ||
interface Response { | ||
interface CallbackResponse { | ||
statusCode: number; | ||
@@ -104,3 +106,3 @@ headers: Headers; | ||
} | ||
declare type SuccessCallback = (response: Response) => void; | ||
declare type SuccessCallback = (response: CallbackResponse) => void; | ||
declare type ErrorCallback = (err: Error) => void; | ||
@@ -112,19 +114,101 @@ interface ResponseHandler { | ||
interface NetworkTransport { | ||
fetchAndParse<RequestBody extends any, ResponseBody extends any>(request: Request<RequestBody>): Promise<ResponseBody>; | ||
fetch<RequestBody extends any>(request: Request<RequestBody>): Promise<FetchResponse>; | ||
fetchWithCallbacks<RequestBody extends any>(request: Request<RequestBody>, handler: ResponseHandler): void; | ||
} | ||
/** | ||
* TODO: Determine if the shape of an error response is specific to each service or widely used | ||
*/ | ||
declare class MongoDBRealmError extends Error { | ||
readonly method: Method; | ||
declare type AbortSignal = any; | ||
declare type FetchHeadersInit = FetchHeaders | string[][] | Record<string, string>; | ||
declare type FetchRequestCredentials = "include" | "omit" | "same-origin"; | ||
declare type FetchRequestMode = "cors" | "navigate" | "no-cors" | "same-origin"; | ||
declare type FetchReadableStream = unknown; | ||
interface FetchBody { | ||
readonly body: FetchReadableStream | null; | ||
readonly bodyUsed: boolean; | ||
arrayBuffer(): Promise<ArrayBuffer>; | ||
blob(): Promise<unknown>; | ||
json(): Promise<any>; | ||
text(): Promise<string>; | ||
} | ||
interface FetchHeaders { | ||
append(name: string, value: string): void; | ||
delete(name: string): void; | ||
get(name: string): string | null; | ||
has(name: string): boolean; | ||
set(name: string, value: string): void; | ||
forEach(callback: (value: string, name: string) => void): void; | ||
} | ||
interface FetchResponse extends FetchBody { | ||
readonly headers: FetchHeaders; | ||
readonly ok: boolean; | ||
readonly redirected: boolean; | ||
readonly status: number; | ||
readonly statusText: string; | ||
readonly type: unknown; | ||
readonly url: string; | ||
readonly statusCode: number; | ||
readonly statusText: string; | ||
readonly errorCode: string | undefined; | ||
readonly link: string | undefined; | ||
constructor(method: Method, url: string, statusCode: number, statusText: string, response: any); | ||
clone(): FetchResponse; | ||
} | ||
interface FetchRequestInit<RequestBody = unknown> { | ||
/** | ||
* A BodyInit object or null to set request's body. | ||
*/ | ||
body?: RequestBody; | ||
/** | ||
* A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. | ||
*/ | ||
credentials?: FetchRequestCredentials; | ||
/** | ||
* A Headers object, an object literal, or an array of two-item arrays to set request's headers. | ||
*/ | ||
headers?: FetchHeadersInit; | ||
/** | ||
* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. | ||
*/ | ||
integrity?: string; | ||
/** | ||
* A boolean to set request's keepalive. | ||
*/ | ||
keepalive?: boolean; | ||
/** | ||
* A string to set request's method. | ||
*/ | ||
method?: string; | ||
/** | ||
* A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. | ||
*/ | ||
mode?: FetchRequestMode; | ||
/** | ||
* An AbortSignal to set request's signal. | ||
*/ | ||
signal?: AbortSignal | null; | ||
} | ||
/** @inheritdoc */ | ||
declare class UserProfile implements Realm.UserProfile { | ||
/** @inheritdoc */ | ||
readonly name?: string; | ||
/** @inheritdoc */ | ||
readonly email?: string; | ||
/** @inheritdoc */ | ||
readonly pictureUrl?: string; | ||
/** @inheritdoc */ | ||
readonly firstName?: string; | ||
/** @inheritdoc */ | ||
readonly lastName?: string; | ||
/** @inheritdoc */ | ||
readonly gender?: string; | ||
/** @inheritdoc */ | ||
readonly birthday?: string; | ||
/** @inheritdoc */ | ||
readonly minAge?: string; | ||
/** @inheritdoc */ | ||
readonly maxAge?: string; | ||
/** @inheritdoc */ | ||
readonly type: Realm.UserType; | ||
/** @inheritdoc */ | ||
readonly identities: Realm.UserIdentity[]; | ||
/** | ||
* @param response The response of a call fetching the users profile. | ||
*/ | ||
constructor(response?: any); | ||
} | ||
declare type AnonymousPayload = Realm.Credentials.AnonymousPayload; | ||
@@ -140,2 +224,6 @@ declare type ApiKeyPayload = Realm.Credentials.ApiKeyPayload; | ||
/** | ||
* Types of an authentication provider. | ||
*/ | ||
declare type ProviderType = "anon-user" | "api-key" | "local-userpass" | "custom-function" | "custom-token" | "oauth2-google" | "oauth2-facebook" | "oauth2-apple"; | ||
/** | ||
* Instances of this class can be passed to the `app.logIn` method to authenticate an end-user. | ||
@@ -243,41 +331,166 @@ */ | ||
/** | ||
* A request to be sent via the transport. | ||
* Note: This has a path instead of a url. | ||
* Used to control which user is currently active - this would most likely be the {App} instance. | ||
*/ | ||
interface Request$1<RequestBody> { | ||
declare type UserContext = { | ||
/** | ||
* HTTP method used when fetching. | ||
* The currently active user. | ||
*/ | ||
method: Method; | ||
currentUser: User<object, object> | null; | ||
}; | ||
/** | ||
* Used when getting the location url of the app. | ||
*/ | ||
declare type LocationUrlContext = { | ||
/** The location URL of the app, used instead of the base url. */ | ||
locationUrl: Promise<string>; | ||
}; | ||
declare type TokenType = "access" | "refresh" | "none"; | ||
interface RequestWithUrl<RequestBody> extends Request<RequestBody> { | ||
path?: never; | ||
} | ||
interface RequestWithPath<RequestBody> extends Omit<Request<RequestBody>, "url"> { | ||
/** Construct a URL from the location URL prepended is path */ | ||
path: string; | ||
url?: never; | ||
} | ||
/** | ||
* A request which will send the access or refresh token of the current user. | ||
*/ | ||
declare type AuthenticatedRequest<RequestBody> = { | ||
/** | ||
* Path of the resource to fetch. | ||
* Which token should be used when requesting? | ||
* | ||
* @default "access" | ||
*/ | ||
path?: string; | ||
tokenType?: TokenType; | ||
/** | ||
* Body to send when fetching. | ||
* The user issuing the request. | ||
*/ | ||
body?: RequestBody | string; | ||
user?: User<object, object>; | ||
} & (RequestWithUrl<RequestBody> | RequestWithPath<RequestBody>); | ||
/** | ||
* | ||
*/ | ||
declare type FetcherConfig = { | ||
/** | ||
* Headers to send when fetching. | ||
* The id of the app. | ||
*/ | ||
headers?: { | ||
[name: string]: string; | ||
}; | ||
} | ||
appId: string; | ||
/** | ||
* The underlying network transport. | ||
*/ | ||
transport: NetworkTransport; | ||
/** | ||
* An object which can be used to determine the currently active user. | ||
*/ | ||
userContext: UserContext; | ||
/** | ||
* An optional promise which resolves to the response of the app location request. | ||
*/ | ||
locationUrlContext: LocationUrlContext; | ||
}; | ||
/** | ||
* A transport takes care of fetching resources, more specialized than the `realm-network-transport`. | ||
* Wraps a NetworkTransport from the "realm-network-transport" package. | ||
* Extracts error messages and throws `MongoDBRealmError` objects upon failures. | ||
* Injects access or refresh tokens for a current or specific user. | ||
* Refreshes access tokens if requests fails due to a 401 error. | ||
* Optionally parses response as JSON before returning it. | ||
* Fetches and exposes an app's location url. | ||
*/ | ||
interface Transport { | ||
declare class Fetcher implements LocationUrlContext { | ||
/** | ||
* Fetch a network resource. | ||
* @param user An optional user to generate the header for. | ||
* @param tokenType The type of token (access or refresh). | ||
* @returns An object containing the user's token as "Authorization" header or undefined if no user is given. | ||
*/ | ||
private static buildAuthorizationHeader; | ||
/** | ||
* @param body The body string or object passed from a request. | ||
* @returns An object optionally specifying the "Content-Type" header. | ||
*/ | ||
private static buildBody; | ||
/** | ||
* @param body The body string or object passed from a request. | ||
* @returns An object optionally specifying the "Content-Type" header. | ||
*/ | ||
private static buildJsonHeader; | ||
/** | ||
* The id of the app, which this Fetcher was created for. | ||
*/ | ||
private readonly appId; | ||
private readonly transport; | ||
private readonly userContext; | ||
private readonly locationUrlContext; | ||
/** | ||
* @param config A configuration of the fetcher. | ||
*/ | ||
constructor({ appId, transport, userContext, locationUrlContext, }: FetcherConfig); | ||
clone(config: Partial<FetcherConfig>): Fetcher; | ||
/** | ||
* Fetch a network resource as an authenticated user. | ||
* | ||
* @param request The request to issue towards the server. | ||
* @param request The request which should be sent to the server. | ||
* @param attempts Number of times this request has been attempted. Used when retrying, callers don't need to pass a value. | ||
* @returns The response from the server. | ||
*/ | ||
fetch<RequestBody extends any, ResponseBody extends any>(request: Request$1<RequestBody>): Promise<ResponseBody>; | ||
fetch<RequestBody = unknown>(request: AuthenticatedRequest<RequestBody>, attempts?: number): Promise<FetchResponse>; | ||
/** | ||
* Creates another transport from this instance, adding a prefix to its path. | ||
* Fetch a network resource as an authenticated user and parse the result as extended JSON. | ||
* | ||
* @param pathPrefix Path to prefix. | ||
* @param request The request which should be sent to the server. | ||
* @returns The response from the server, parsed as extended JSON. | ||
*/ | ||
prefix(pathPrefix: string): Transport; | ||
fetchJSON<RequestBody extends object = any, ResponseBody extends object = any>(request: AuthenticatedRequest<RequestBody>): Promise<ResponseBody>; | ||
/** | ||
* Fetch an "event-stream" resource as an authenticated user. | ||
* | ||
* @param request The request which should be sent to the server. | ||
*/ | ||
fetchStream<RequestBody = unknown>(request: AuthenticatedRequest<RequestBody>): Promise<AsyncIterable<Uint8Array>>; | ||
/** | ||
* @returns The path of the app route. | ||
*/ | ||
get appRoute(): { | ||
path: string; | ||
location(): { | ||
path: string; | ||
}; | ||
authProvider(providerName: string): { | ||
path: string; | ||
login(): { | ||
path: string; | ||
}; | ||
}; | ||
emailPasswordAuth(providerName: string): { | ||
register(): { | ||
path: string; | ||
}; | ||
confirm(): { | ||
path: string; | ||
}; | ||
confirmSend(): { | ||
path: string; | ||
}; | ||
reset(): { | ||
path: string; | ||
}; | ||
resetSend(): { | ||
path: string; | ||
}; | ||
resetCall(): { | ||
path: string; | ||
}; | ||
path: string; | ||
login(): { | ||
path: string; | ||
}; | ||
}; | ||
functionsCall(): { | ||
path: string; | ||
}; | ||
}; | ||
/** | ||
* @returns A promise of the location URL of the app. | ||
*/ | ||
get locationUrl(): Promise<string>; | ||
} | ||
@@ -287,13 +500,11 @@ | ||
declare class EmailPasswordAuth implements Realm.Auth.EmailPasswordAuth { | ||
private readonly fetcher; | ||
private readonly providerName; | ||
/** | ||
* The underlying transport. | ||
*/ | ||
private readonly transport; | ||
/** | ||
* Construct an interface to the email / password authentication provider. | ||
* | ||
* @param transport The underlying transport used to request the services. | ||
* @param fetcher The underlying fetcher used to request the services. | ||
* @param providerName Optional custom name of the authentication provider. | ||
*/ | ||
constructor(transport: Transport, providerName?: string); | ||
constructor(fetcher: Fetcher, providerName?: string); | ||
/** @inheritdoc */ | ||
@@ -313,77 +524,15 @@ registerUser(email: string, password: string): Promise<void>; | ||
/** | ||
* Used to control which user is currently active - this would most likely be the {App} instance. | ||
*/ | ||
interface UserContext { | ||
/** | ||
* The currently active user. | ||
*/ | ||
currentUser: User<any, any> | null; | ||
} | ||
declare type TokenType = "access" | "refresh"; | ||
/** | ||
* A request which will send the access or refresh token of the current user. | ||
*/ | ||
interface AuthenticatedRequest<RequestBody> extends Request$1<RequestBody> { | ||
/** | ||
* Which token should be used when requesting? | ||
* | ||
* @default "access" | ||
*/ | ||
tokenType?: TokenType; | ||
} | ||
/** | ||
* Fetches resources as a particular user. | ||
*/ | ||
declare class AuthenticatedTransport implements Transport { | ||
/** | ||
* Underlying transport. | ||
*/ | ||
private readonly transport; | ||
/** | ||
* An object controlling which user is currently active. | ||
*/ | ||
private readonly userContext; | ||
/** | ||
* Constructs a transport that injects authorization headers to requests. | ||
* | ||
* @param transport The underlying transport. | ||
* @param userContext The context controlling what user is authenticated. | ||
*/ | ||
constructor(transport: Transport, userContext: UserContext); | ||
/** | ||
* Fetch a network resource as an authenticated user. | ||
* | ||
* @param request The request to issue towards the server. | ||
* @param user The user used when fetching, defaults to the `app.currentUser`. | ||
* If `null`, the fetch will be unauthenticated. | ||
* @param retries How many times was this request retried? | ||
* @returns A response from requesting with authentication. | ||
*/ | ||
fetch<RequestBody extends any, ResponseBody extends any>(request: AuthenticatedRequest<RequestBody>, user?: User | null, retries?: number): Promise<ResponseBody>; | ||
/** @inheritdoc */ | ||
prefix(pathPrefix: string): AuthenticatedTransport; | ||
/** | ||
* Generate an object with an authorization header to issue requests as a specific user. | ||
* | ||
* @param user An optional user to generate the header for. | ||
* @param tokenType The type of token (access or refresh). | ||
* @returns An object containing with the users access token as authorization header or undefined if no user is given. | ||
*/ | ||
private buildAuthorizationHeader; | ||
} | ||
/** @inheritdoc */ | ||
declare class ApiKeyAuth implements Realm.Auth.ApiKeyAuth { | ||
/** | ||
* The transport used to send requests to services. | ||
* The fetcher used to send requests to services. | ||
*/ | ||
private readonly transport; | ||
private readonly fetcher; | ||
/** | ||
* Construct an interface to the API-key authentication provider. | ||
* | ||
* @param transport The transport used to send requests to services. | ||
* @param fetcher The fetcher used to send requests to services. | ||
* @param providerName Optional custom name of the authentication provider. | ||
*/ | ||
constructor(transport: AuthenticatedTransport, providerName?: string); | ||
constructor(fetcher: Fetcher, providerName?: string); | ||
/** @inheritdoc */ | ||
@@ -409,16 +558,18 @@ create(name: string): Promise<Realm.Auth.ApiKey>; | ||
} | ||
/** The state of a user within the app */ | ||
declare enum UserState { | ||
/** Active, with both access and refresh tokens */ | ||
Active = "active", | ||
/** Logged out, but there might still be data persisted about the user, in the browser. */ | ||
LoggedOut = "logged-out", | ||
/** Logged out and all data about the user has been removed. */ | ||
Removed = "removed" | ||
} | ||
/** The type of a user. */ | ||
declare enum UserType { | ||
/** Created by the user itself. */ | ||
Normal = "normal", | ||
/** Created by an administrator of the app. */ | ||
Server = "server" | ||
} | ||
declare function performLogIn(app: App<any>, credentials: Credentials): Promise<{ | ||
id: string; | ||
accessToken: string; | ||
refreshToken: string; | ||
}>; | ||
/** | ||
@@ -432,2 +583,3 @@ * Representation of an authenticated user of an app. | ||
readonly app: App<FunctionsFactoryType, CustomDataType>; | ||
/** @inheritdoc */ | ||
readonly functions: FunctionsFactoryType & Realm.BaseFunctionsFactory; | ||
@@ -448,9 +600,10 @@ /** @inheritdoc */ | ||
private _profile; | ||
private transport; | ||
private fetcher; | ||
private storage; | ||
/** | ||
* @param parameters Parameters of the user. | ||
*/ | ||
constructor({ app, id, accessToken, refreshToken }: UserParameters); | ||
/** | ||
* The automatically-generated internal id of the user. | ||
* | ||
* @returns The id of the user in the MongoDB Realm database. | ||
* @returns The automatically-generated internal id of the user in the MongoDB Realm database. | ||
*/ | ||
@@ -475,7 +628,2 @@ get id(): string; | ||
/** | ||
* The state of the user is one of: | ||
* - "active" The user is logged in and ready. | ||
* - "logged-out" The user was logged in, but is no longer logged in. | ||
* - "removed" The user was logged in, but removed entirely from the app again. | ||
* | ||
* @returns The current state of the user. | ||
@@ -489,14 +637,22 @@ */ | ||
get profile(): Realm.UserProfile; | ||
get identities(): Realm.UserIdentity[]; | ||
get providerType(): ProviderType; | ||
get deviceId(): string | null; | ||
/** | ||
* Refresh the users profile data. | ||
*/ | ||
refreshProfile(): Promise<void>; | ||
/** | ||
* Log out the user, invalidating the session (and its refresh token). | ||
*/ | ||
logOut(): Promise<void>; | ||
/** @inheritdoc */ | ||
linkCredentials(credentials: Credentials): Promise<void>; | ||
/** | ||
* Authenticate and retrieve the access and refresh tokens. | ||
* | ||
* @param credentials Credentials to use when logging in. | ||
* Request a new access token, using the refresh token. | ||
*/ | ||
logIn(credentials: Realm.Credentials): Promise<void>; | ||
refreshAccessToken(): Promise<void>; | ||
/** @inheritdoc */ | ||
linkCredentials(credentials: Realm.Credentials): Promise<void>; | ||
refreshAccessToken(): Promise<void>; | ||
refreshCustomData(): Promise<CustomDataType>; | ||
/** @inheritdoc */ | ||
callFunction(name: string, ...args: any[]): Promise<any>; | ||
@@ -507,118 +663,225 @@ /** | ||
hydrate(): void; | ||
/** | ||
* @returns A plain ol' JavaScript object representation of the user. | ||
*/ | ||
toJSON(): { | ||
id: string; | ||
accessToken: string | null; | ||
refreshToken: string | null; | ||
profile: UserProfile | undefined; | ||
state: UserState; | ||
customData: CustomDataType; | ||
}; | ||
/** @inheritdoc */ | ||
push(serviceName?: string): Realm.Services.Push; | ||
/** @inheritdoc */ | ||
mongoClient(serviceName: string): Realm.Services.MongoDB; | ||
private decodeAccessToken; | ||
} | ||
declare type AppLocation = { | ||
/** | ||
* Storage specific to the app. | ||
*/ | ||
declare class AppStorage extends PrefixedStorage { | ||
/** | ||
* The hostname to be used when communicating with the app server. | ||
* @param storage The underlying storage to wrap. | ||
* @param appId The id of the app. | ||
*/ | ||
hostname: string; | ||
constructor(storage: Storage, appId: string); | ||
/** | ||
* The physical location of the app server. | ||
* Reads out the list of user ids from storage. | ||
* | ||
* @returns A list of user ids. | ||
*/ | ||
location: string; | ||
getUserIds(): any[]; | ||
/** | ||
* The deployment model of an app. | ||
* Sets the list of ids in storage. | ||
* Optionally merging with existing ids stored in the storage, by prepending these while voiding duplicates. | ||
* | ||
* @param userIds The list of ids to store. | ||
* @param mergeWithExisting Prepend existing ids to avoid data-races with other apps using this storage. | ||
*/ | ||
deploymentModel: "GLOBAL" | "LOCAL"; | ||
}; | ||
declare type AppLocationContext = { | ||
setUserIds(userIds: string[], mergeWithExisting: boolean): void; | ||
/** | ||
* An object with a property representing the location of an app. | ||
* Remove an id from the list of ids. | ||
* | ||
* @param userId The id of a User to be removed. | ||
*/ | ||
location: Promise<AppLocation>; | ||
}; | ||
removeUserId(userId: string): void; | ||
/** | ||
* @returns id of this device (if any exists) | ||
*/ | ||
getDeviceId(): string | null; | ||
/** | ||
* @param deviceId The id of this device, to send on subsequent authentication requests. | ||
*/ | ||
setDeviceId(deviceId: string): void; | ||
} | ||
declare type BaseRequest<RequestBody> = Request$1<RequestBody> & { | ||
/** A class representation of the BSON ObjectId type. */ | ||
declare class ObjectId { | ||
/** | ||
* Should the location (derived base URL) of the app be ignored for this request? | ||
* Create a new ObjectId instance | ||
* @param {(string|number|ObjectId)} id Can be a 24 byte hex string, 12 byte binary string or a Number. | ||
*/ | ||
constructor(id?: string | number | ObjectId); | ||
/** The generation time of this ObjectId instance */ | ||
generationTime: number; | ||
/** If true cache the hex string representation of ObjectId */ | ||
static cacheHexString?: boolean; | ||
/** | ||
* Creates an ObjectId from a hex string representation of an ObjectId. | ||
* @param {string} hexString create a ObjectId from a passed in 24 byte hexstring. | ||
* @return {ObjectId} return the created ObjectId | ||
*/ | ||
static createFromHexString(hexString: string): ObjectId; | ||
/** | ||
* Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. Used for comparisons or sorting the ObjectId. | ||
* @param {number} time an integer number representing a number of seconds. | ||
* @return {ObjectId} return the created ObjectId | ||
*/ | ||
static createFromTime(time: number): ObjectId; | ||
/** | ||
* Checks if a value is a valid bson ObjectId | ||
* | ||
* @default false | ||
* @return {boolean} return true if the value is a valid bson ObjectId, return false otherwise. | ||
*/ | ||
ignoreLocation?: boolean; | ||
static isValid(id: string | number | ObjectId): boolean; | ||
/** | ||
* Compares the equality of this ObjectId with `otherID`. | ||
* @param {ObjectId|string} otherID ObjectId instance to compare against. | ||
* @return {boolean} the result of comparing two ObjectId's | ||
*/ | ||
equals(otherID: ObjectId | string): boolean; | ||
/** | ||
* Generate a 12 byte id string used in ObjectId's | ||
* @param {number} time optional parameter allowing to pass in a second based timestamp. | ||
* @return {string} return the 12 byte id binary string. | ||
*/ | ||
static generate(time?: number): Buffer; | ||
/** | ||
* Returns the generation date (accurate up to the second) that this ID was generated. | ||
* @return {Date} the generation date | ||
*/ | ||
getTimestamp(): Date; | ||
/** | ||
* Return the ObjectId id as a 24 byte hex string representation | ||
* @return {string} return the 24 byte hex string representation. | ||
*/ | ||
toHexString(): string; | ||
} | ||
declare enum DeviceFields { | ||
DEVICE_ID = "deviceId", | ||
APP_ID = "appId", | ||
APP_VERSION = "appVersion", | ||
PLATFORM = "platform", | ||
PLATFORM_VERSION = "platformVersion", | ||
SDK_VERSION = "sdkVersion" | ||
} | ||
declare type DeviceInformationValues = { | ||
[DeviceFields.PLATFORM]: string; | ||
[DeviceFields.PLATFORM_VERSION]: string; | ||
[DeviceFields.SDK_VERSION]: string; | ||
[DeviceFields.APP_ID]?: string; | ||
[DeviceFields.APP_VERSION]?: string; | ||
[DeviceFields.DEVICE_ID]?: ObjectId; | ||
}; | ||
declare type DeviceInformationParams = { | ||
appId?: string; | ||
appVersion?: string; | ||
deviceId?: ObjectId; | ||
}; | ||
/** | ||
* A basic transport, wrapping a NetworkTransport from the "realm-network-transport" package, injecting a baseUrl. | ||
* Information describing the device, app and SDK. | ||
*/ | ||
declare class BaseTransport implements Transport { | ||
declare class DeviceInformation implements DeviceInformationValues { | ||
/** | ||
* This base route will be prefixed requests issued through by the base transport. | ||
* The id of the device. | ||
*/ | ||
private static readonly DEFAULT_BASE_ROUTE; | ||
readonly deviceId: ObjectId | undefined; | ||
/** | ||
* Default headers that will always be sat on requests. | ||
* The id of the Realm App. | ||
*/ | ||
private static readonly DEFAULT_HEADERS; | ||
readonly appId: string | undefined; | ||
/** | ||
* The underlying network transport. | ||
* The version of the Realm App. | ||
*/ | ||
private readonly networkTransport; | ||
readonly appVersion: string | undefined; | ||
/** | ||
* The base URL to prepend to paths. | ||
* The name of the platform / browser. | ||
*/ | ||
private baseUrl; | ||
readonly platform: string; | ||
/** | ||
* The base URL to prepend to paths. | ||
* The version of the platform / browser. | ||
*/ | ||
private readonly baseRoute; | ||
readonly platformVersion: string; | ||
/** | ||
* An object used to derive the location of the app. | ||
* The version of the Realm Web SDK (constant provided by Rollup). | ||
*/ | ||
private readonly locationContext?; | ||
readonly sdkVersion: string; | ||
/** | ||
* Constructs a base transport, which takes paths (prepended by a base URL) instead of absolute urls. | ||
* | ||
* @param networkTransport The underlying network transport. | ||
* @param baseUrl The base URL to prepend to paths. | ||
* @param locationContext Optional object used to determine the actual base URL of the app. | ||
* @param baseRoute Optional base route to prepend to the base URL. | ||
* @param params Construct the device information from these parameters. | ||
*/ | ||
constructor(networkTransport: NetworkTransport | undefined, baseUrl: string, locationContext?: AppLocationContext, baseRoute?: string); | ||
/** @inheritdoc */ | ||
fetch<RequestBody extends any = any, ResponseBody extends any = any>(request: BaseRequest<RequestBody>): Promise<ResponseBody>; | ||
/** @inheritdoc */ | ||
prefix(pathPrefix: string): Transport; | ||
constructor({ appId, appVersion, deviceId, }: DeviceInformationParams); | ||
/** | ||
* Determines the base URL from the configuration or from the location context. | ||
* | ||
* @param ignoreLocation Ignore the location context. | ||
* @returns An base64 URI encoded representation of the device information. | ||
*/ | ||
determineBaseUrl(ignoreLocation: boolean): Promise<string>; | ||
encode(): string; | ||
} | ||
/** | ||
* Storage specific to the app. | ||
* The response from an authentication request. | ||
*/ | ||
declare class AppStorage extends PrefixedStorage { | ||
declare type AuthResponse = { | ||
/** | ||
* Construct a storage for an `App` | ||
* | ||
* @param storage The underlying storage to wrap. | ||
* @param appId The id of the app. | ||
* The id of the user. | ||
*/ | ||
constructor(storage: Storage, appId: string); | ||
userId: string; | ||
/** | ||
* Reads out the list of user ids from storage. | ||
* | ||
* @returns A list of user ids. | ||
* The short-living access token. | ||
*/ | ||
getUserIds(): any[]; | ||
accessToken: string; | ||
/** | ||
* Sets the list of ids in storage. | ||
* Optionally merging with existing ids stored in the storage, by prepending these while voiding duplicates. | ||
* | ||
* @param userIds The list of ids to store. | ||
* @param mergeWithExisting Prepend existing ids to avoid data-races with other apps using this storage. | ||
* The refresh token for the session. | ||
*/ | ||
setUserIds(userIds: string[], mergeWithExisting: boolean): void; | ||
refreshToken: string | null; | ||
/** | ||
* Remove an id from the list of ids. | ||
* | ||
* @param userId The id of a User to be removed. | ||
* The id of the device recognized by the server. | ||
*/ | ||
removeUserId(userId: string): void; | ||
deviceId: string; | ||
}; | ||
declare type DeviceInformationGetter = () => DeviceInformation; | ||
/** | ||
* Handles authentication and linking of users. | ||
*/ | ||
declare class Authenticator { | ||
private readonly fetcher; | ||
private readonly oauth2; | ||
private readonly getDeviceInformation; | ||
/** | ||
* @param fetcher The fetcher used to fetch responses from the server. | ||
* @param storage The storage used when completing OAuth 2.0 flows (should not be scoped to a specific app). | ||
* @param getDeviceInformation Called to get device information to be sent to the server. | ||
*/ | ||
constructor(fetcher: Fetcher, storage: Storage, getDeviceInformation: DeviceInformationGetter); | ||
/** | ||
* @param credentials Credentials to use when logging in. | ||
* @param linkingUser A user requesting to link. | ||
*/ | ||
authenticate(credentials: Realm.Credentials<any>, linkingUser?: User<object, object>): Promise<AuthResponse>; | ||
/** | ||
* @param credentials Credentials to use when logging in. | ||
* @param link Should the request link with the current user? | ||
* @param extraQueryParams Any extra parameters to include in the query string | ||
*/ | ||
private getLogInUrl; | ||
private openWindowAndWaitForAuthResponse; | ||
} | ||
/** | ||
* Default base url to prefix all requests if no baseUrl is specified in the configuration. | ||
*/ | ||
declare const DEFAULT_BASE_URL = "https://stitch.mongodb.com"; | ||
/** | ||
* Configuration to pass as an argument when constructing an app. | ||
@@ -635,8 +898,2 @@ */ | ||
storage?: Storage; | ||
/** | ||
* Should the location of the app be fetched to determine the base URL upon the first request? | ||
* | ||
* @default true | ||
*/ | ||
fetchLocation?: boolean; | ||
} | ||
@@ -646,3 +903,3 @@ /** | ||
*/ | ||
declare class App<FunctionsFactoryType extends object = Realm.DefaultFunctionsFactory, CustomDataType extends object = any> implements Realm.App<FunctionsFactoryType, CustomDataType>, AppLocationContext { | ||
declare class App<FunctionsFactoryType extends object = Realm.DefaultFunctionsFactory, CustomDataType extends object = any> implements Realm.App<FunctionsFactoryType, CustomDataType> { | ||
/** @inheritdoc */ | ||
@@ -659,13 +916,5 @@ readonly functions: FunctionsFactoryType & Realm.BaseFunctionsFactory; | ||
/** | ||
* Default base url to prefix all requests if no baseUrl is specified in the configuration. | ||
* An object which can be used to fetch responses from the server. | ||
*/ | ||
static readonly DEFAULT_BASE_URL = "https://stitch.mongodb.com"; | ||
/** | ||
* A transport adding the base route prefix to all requests. | ||
*/ | ||
readonly baseTransport: BaseTransport; | ||
/** | ||
* A transport adding the base and app route prefix to all requests. | ||
*/ | ||
readonly appTransport: Transport; | ||
readonly fetcher: Fetcher; | ||
/** @inheritdoc */ | ||
@@ -678,2 +927,6 @@ readonly emailPasswordAuth: EmailPasswordAuth; | ||
/** | ||
* Internal authenticator used to complete authentication requests. | ||
*/ | ||
readonly authenticator: Authenticator; | ||
/** | ||
* An array of active and logged-out users. | ||
@@ -684,10 +937,15 @@ * Elements in the beginning of the array is considered more recent than the later elements. | ||
/** | ||
* An promise of the apps location metadata. | ||
* The base URL of the app. | ||
*/ | ||
private _location; | ||
private readonly baseUrl; | ||
/** | ||
* A helper used to complete an OAuth 2.0 authentication flow. | ||
* Local app configuration. | ||
* Useful to determine what name and version an authenticated user is running. | ||
*/ | ||
private oauth2; | ||
private readonly localApp; | ||
/** | ||
* A promise resolving to the App's location url. | ||
*/ | ||
private _locationUrl; | ||
/** | ||
* Construct a Realm App, either from the Realm App id visible from the MongoDB Realm UI or a configuration. | ||
@@ -699,11 +957,11 @@ * | ||
/** | ||
* Switch user | ||
* Switch user. | ||
* | ||
* @param nextUser The user or id of the user to switch to | ||
* @param nextUser The user or id of the user to switch to. | ||
*/ | ||
switchUser(nextUser: User<FunctionsFactoryType, CustomDataType>): void; | ||
/** | ||
* Log in a user | ||
* Log in a user. | ||
* | ||
* @param credentials Credentials to use when logging in | ||
* @param credentials Credentials to use when logging in. | ||
* @param fetchProfile Should the users profile be fetched? (default: true) | ||
@@ -717,3 +975,3 @@ */ | ||
/** | ||
* The currently active user (or null if no active users exists) | ||
* The currently active user (or null if no active users exists). | ||
* | ||
@@ -732,14 +990,9 @@ * @returns the currently active user or null. | ||
/** | ||
* Get the location metadata of an app. | ||
* | ||
* @returns A promise of the app's location metadata. | ||
* @returns A promise of the app URL, with the app location resolved. | ||
*/ | ||
get location(): Promise<AppLocation>; | ||
get locationUrl(): Promise<string>; | ||
/** | ||
* Perform the actual login, based on the credentials. | ||
* Either it decodes the credentials and instantiates a user directly or it calls User.logIn to perform a fetch. | ||
* | ||
* @param credentials Credentials to use when logging in | ||
* @returns Information about the current device, sent to the server when authenticating. | ||
*/ | ||
private performLogIn; | ||
get deviceInformation(): DeviceInformation; | ||
/** | ||
@@ -749,5 +1002,3 @@ * Create (and store) a new user or update an existing user's access and refresh tokens. | ||
* | ||
* @param userId The id of the user. | ||
* @param accessToken The new access token of the user. | ||
* @param refreshToken The new refresh token of the user. | ||
* @param response A response from the Authenticator. | ||
* @returns A new or an existing user. | ||
@@ -762,2 +1013,48 @@ */ | ||
/** | ||
* An error produced while communicating with the MongoDB Realm server. | ||
*/ | ||
declare class MongoDBRealmError extends Error { | ||
/** | ||
* The method used when requesting. | ||
*/ | ||
readonly method: Method; | ||
/** | ||
* The URL of the resource which got fetched. | ||
*/ | ||
readonly url: string; | ||
/** | ||
* The HTTP status code of the response. | ||
*/ | ||
readonly statusCode: number; | ||
/** | ||
* A human readable version of the HTTP status. | ||
*/ | ||
readonly statusText: string; | ||
/** | ||
* Any application-level error message. | ||
*/ | ||
readonly error: string | undefined; | ||
/** | ||
* Any application-level error code. | ||
*/ | ||
readonly errorCode: string | undefined; | ||
/** | ||
* Any application-level (URL) link containing details about the error. | ||
*/ | ||
readonly link: string | undefined; | ||
/** | ||
* Constructs and returns an error from a request and a response. | ||
* Note: The caller must throw this error themselves. | ||
* | ||
* @param request The request sent to the server. | ||
* @param response A raw response, as returned from the server. | ||
*/ | ||
static fromRequestAndResponse(request: Request<unknown>, response: FetchResponse): Promise<MongoDBRealmError>; | ||
constructor(method: Method, url: string, statusCode: number, statusText: string, error?: string, errorCode?: string, link?: string); | ||
} | ||
/** | ||
* Simplified handle to a browser window. | ||
*/ | ||
declare type Window = { | ||
@@ -774,2 +1071,11 @@ /** | ||
/** | ||
* Helps decode buffers into strings of various encodings. | ||
*/ | ||
declare class TextDecoder { | ||
decode(buffer: Uint8Array, options?: { | ||
stream: boolean; | ||
}): string; | ||
} | ||
/** An object with values specific to the runtime environment. */ | ||
declare type Environment = { | ||
@@ -784,2 +1090,14 @@ /** | ||
openWindow: (url: string) => Window | null; | ||
/** | ||
* The name of the executing platform. | ||
*/ | ||
platform: string; | ||
/** | ||
* The version of the executing platform. | ||
*/ | ||
platformVersion: string; | ||
/** | ||
* Helps decode buffers into strings of various encodings. | ||
*/ | ||
TextDecoder: typeof TextDecoder; | ||
}; | ||
@@ -831,5 +1149,5 @@ /** | ||
/** @inheritdoc */ | ||
addListener(listener: StorageChangeListner): void; | ||
addListener(listener: StorageChangeListener): void; | ||
/** @inheritdoc */ | ||
removeListener(listener: StorageChangeListner): void; | ||
removeListener(listener: StorageChangeListener): void; | ||
} | ||
@@ -848,2 +1166,2 @@ | ||
export { AnonymousPayload, ApiKeyPayload, App, AppConfiguration, ApplePayload, Credentials, EmailPasswordPayload, FacebookPayload, FunctionPayload, GooglePayload, JWTPayload, LocalStorage, MongoDBRealmError, OAuth2RedirectPayload, User, UserState, UserType, getApp, getEnvironment, handleAuthRedirect, performLogIn, setEnvironment }; | ||
export { App, AppConfiguration, Credentials, DEFAULT_BASE_URL, LocalStorage, MongoDBRealmError, ProviderType, User, UserState, UserType, getApp, getEnvironment, handleAuthRedirect, setEnvironment }; |
{ | ||
"name": "realm-web", | ||
"version": "0.8.1", | ||
"version": "0.9.0", | ||
"description": "Authenticate and communicate with the MongoDB Realm platform, from your web-browser", | ||
@@ -46,2 +46,3 @@ "main": "./dist/bundle.cjs.js", | ||
"bson": "4.0.0", | ||
"detect-browser": "^5.1.1", | ||
"js-base64": "^2.6.3" | ||
@@ -56,2 +57,3 @@ }, | ||
"@rollup/plugin-node-resolve": "^7.1.3", | ||
"@rollup/plugin-replace": "^2.3.3", | ||
"@rollup/plugin-typescript": "^4.1.1", | ||
@@ -65,6 +67,6 @@ "@types/chai": "^4.2.9", | ||
"chai": "^4.2.0", | ||
"eslint": "file:../../node_modules/eslint", | ||
"eslint": "^6.8.0", | ||
"mocha": "^5.2.0", | ||
"node-fetch": "^2.6.0", | ||
"realm-network-transport": "^0.6.0", | ||
"realm-network-transport": "^0.7.0", | ||
"rollup": "^2.6.1", | ||
@@ -74,4 +76,4 @@ "rollup-plugin-dts": "^1.4.0", | ||
"ts-node": "^8.8.2", | ||
"typescript": "file:../../node_modules/typescript" | ||
"typescript": "^4.0.2" | ||
} | ||
} |
@@ -16,3 +16,3 @@ # Realm Web | ||
```html | ||
<script src="https://unpkg.com/realm-web@0.8.0/dist/bundle.iife.js"></script> | ||
<script src="https://unpkg.com/realm-web@0.9.0/dist/bundle.iife.js"></script> | ||
``` | ||
@@ -26,9 +26,5 @@ | ||
- A limited selection of [services](https://docs.mongodb.com/stitch/services/) are implemented at the moment: | ||
- MongoDB (watching a collection is not yet implemented). | ||
- MongoDB: Read, write and watch MongoDB documents. | ||
- HTTP: Send requests using the MongoDB service as a proxy. | ||
Some parts of the legacy Stitch SDK is still missing, most notably: | ||
- The ability to link a user to another identity. | ||
- No device information is sent to the service when authenticating a user. | ||
## Using Realm Web from Node.js | ||
@@ -35,0 +31,0 @@ |
@@ -276,2 +276,7 @@ //////////////////////////////////////////////////////////////////////////// | ||
/** | ||
* Get an app instance from the cache. | ||
*/ | ||
static getCachedApp(appId: string): App; | ||
/** | ||
* Log in a user using a specific credential | ||
@@ -313,5 +318,27 @@ * | ||
baseUrl?: string; | ||
/** | ||
* This describes the local app, sent to the server when a user authenticates. | ||
* Specifying this will enable the server to respond differently to specific versions of specific apps. | ||
*/ | ||
app?: LocalAppConfiguration; | ||
} | ||
/** | ||
* This describes the local app, sent to the server when a user authenticates. | ||
*/ | ||
interface LocalAppConfiguration { | ||
/** | ||
* The name / id of the local app. | ||
* Note: This should be the name or a bundle id of your app, not the MongoDB Realm app. | ||
*/ | ||
name?: string; | ||
/** | ||
* The version of the local app. | ||
*/ | ||
version?: string; | ||
} | ||
/** | ||
* Representation of an authenticated user of an app. | ||
@@ -329,2 +356,12 @@ */ | ||
/** | ||
* The provider type for the user. | ||
*/ | ||
readonly providerType: string; | ||
/** | ||
* The id of the device. | ||
*/ | ||
readonly deviceId: string | null; | ||
/** | ||
* The state of the user. | ||
@@ -334,4 +371,6 @@ */ | ||
// TODO: Populate the list of identities | ||
// readonly identities: UserIdentity[]; | ||
/** | ||
* The identities of the user at any of the app's authentication providers. | ||
*/ | ||
readonly identities: UserIdentity[]; | ||
@@ -419,2 +458,13 @@ /** | ||
push(serviceName: string): Realm.Services.Push; | ||
/** | ||
* Returns a connection to the MongoDB service. | ||
* | ||
* @example | ||
* let blueWidgets = user.mongoClient('myClusterName') | ||
* .db('myDb') | ||
* .collection('widgets') | ||
* .find({color: 'blue'}); | ||
*/ | ||
mongoClient(serviceName: string): Realm.Services.MongoDB; | ||
} | ||
@@ -534,2 +584,14 @@ | ||
callFunction(name: string, ...args: any[]): Promise<any>; | ||
/** | ||
* Call a remote MongoDB Realm function by its name, in a streaming mode. | ||
* Consider using `functions[name]()` instead of calling this method. | ||
* | ||
* @param name Name of the function. | ||
* @param args Arguments passed to the function. | ||
*/ | ||
callFunctionStreaming( | ||
name: string, | ||
...args: any[] | ||
): Promise<AsyncIterable<Uint8Array>>; | ||
} | ||
@@ -536,0 +598,0 @@ |
@@ -101,3 +101,3 @@ //////////////////////////////////////////////////////////////////////////// | ||
user: User; | ||
partitionValue: string|number|ObjectId; | ||
partitionValue: string|number|ObjectId|null; | ||
customHttpHeaders?: { [header: string]: string }; | ||
@@ -202,4 +202,4 @@ newRealmFileBehavior?: OpenRealmBehaviorConfiguration; | ||
/** | ||
* RealmJsonSerializeReplacer solves circular structures when serializing Realm entities | ||
* @example JSON.stringify(realm.objects("Person"), Realm.RealmJsonSerializeReplacer) | ||
* JsonSerializationReplacer solves circular structures when serializing Realm entities | ||
* @example JSON.stringify(realm.objects("Person"), Realm.JsonSerializationReplacer) | ||
*/ | ||
@@ -347,3 +347,3 @@ const JsonSerializationReplacer: (key: string, val: any) => any; | ||
type ErrorCallback = (session: Sync.Session, error: SyncError) => void; | ||
type ErrorCallback = (session: App.Sync.Session, error: SyncError) => void; | ||
@@ -387,3 +387,3 @@ const enum SessionStopPolicy { | ||
namespace Sync { | ||
namespace App.Sync { | ||
class Session { | ||
@@ -414,3 +414,2 @@ readonly config: SyncConfiguration; | ||
* AuthError | ||
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Sync.AuthError.html } | ||
*/ | ||
@@ -436,9 +435,11 @@ class AuthError { | ||
function setLogLevel(logLevel: LogLevel): void; | ||
function setLogger(callback: (level: NumericLogLevel, message: string) => void): void; | ||
function setUserAgent(userAgent: string): void; | ||
function enableSessionMultiplexing(): void; | ||
function initiateClientReset(path: string): void; | ||
function _hasExistingSessions(): boolean; | ||
function reconnect(): void; | ||
function getAllSyncSessions(user: Realm.User): [Realm.App.Sync.Session]; | ||
function getSyncSession(user: Realm.User, partitionValue: string|number|ObjectId|null) : Realm.App.Sync.Session; | ||
function setLogLevel(app: App, logLevel: LogLevel): void; | ||
function setLogger(app: App, callback: (level: NumericLogLevel, message: string) => void): void; | ||
function setUserAgent(app: App, userAgent: string): void; | ||
function enableSessionMultiplexing(app: App): void; | ||
function initiateClientReset(app: App, path: string): void; | ||
function _hasExistingSessions(app: App): boolean; | ||
function reconnect(app: App): void; | ||
} | ||
@@ -485,3 +486,3 @@ } | ||
readonly syncSession: Realm.Sync.Session | null; | ||
readonly syncSession: Realm.App.Sync.Session | null; | ||
@@ -548,8 +549,6 @@ /** | ||
* @param {T} properties | ||
* @param {boolean} update? | ||
* @param {Realm.UpdateMode} mode? If not provided, `Realm.UpdateMode.Never` is used. | ||
* @returns T & Realm.Object | ||
* | ||
* @deprecated, to be removed in future versions. Use `create(type, properties, UpdateMode)` instead. | ||
*/ | ||
create<T>(type: string, properties: RealmInsertionModel<T>, update?: boolean): T & Realm.Object | ||
create<T>(type: string, properties: RealmInsertionModel<T>, mode?: Realm.UpdateMode): T & Realm.Object | ||
@@ -559,8 +558,6 @@ /** | ||
* @param {T} properties | ||
* @param {boolean} update? | ||
* @param {Realm.UpdateMode} mode? If not provided, `Realm.UpdateMode.Never` is used. | ||
* @returns T | ||
* | ||
* @deprecated, to be removed in future versions. Use `create(type, properties, UpdateMode)` instead. | ||
*/ | ||
create<T extends Realm.Object>(type: {new(...arg: any[]): T; }, properties: RealmInsertionModel<T>, update?: boolean): T | ||
create<T extends Realm.Object>(type: {new(...arg: any[]): T; }, properties: RealmInsertionModel<T>, mode?: Realm.UpdateMode): T | ||
@@ -570,6 +567,8 @@ /** | ||
* @param {T} properties | ||
* @param {Realm.UpdateMode} mode? If not provided, `Realm.UpdateMode.Never` is used. | ||
* @param {boolean} update? | ||
* @returns T & Realm.Object | ||
* | ||
* @deprecated, to be removed in future versions. Use `create(type, properties, UpdateMode)` instead. | ||
*/ | ||
create<T>(type: string, properties: RealmInsertionModel<T>, mode?: Realm.UpdateMode): T & Realm.Object | ||
create<T>(type: string, properties: RealmInsertionModel<T>, update?: boolean): T & Realm.Object | ||
@@ -579,6 +578,8 @@ /** | ||
* @param {T} properties | ||
* @param {Realm.UpdateMode} mode? If not provided, `Realm.UpdateMode.Never` is used. | ||
* @param {boolean} update? | ||
* @returns T | ||
* | ||
* @deprecated, to be removed in future versions. Use `create(type, properties, UpdateMode)` instead. | ||
*/ | ||
create<T extends Realm.Object>(type: {new(...arg: any[]): T; }, properties: RealmInsertionModel<T>, mode?: Realm.UpdateMode): T | ||
create<T extends Realm.Object>(type: {new(...arg: any[]): T; }, properties: RealmInsertionModel<T>, update?: boolean): T | ||
@@ -585,0 +586,0 @@ /** |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1006341
26097
2
6
20
35
+ Addeddetect-browser@^5.1.1
+ Addeddetect-browser@5.3.0(transitive)