@junobuild/core-standalone 0.1.0
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/LICENSE +21 -0
- package/README.md +17 -0
- package/dist/browser/canisterStatus-MTFHSECX.js +2 -0
- package/dist/browser/canisterStatus-MTFHSECX.js.map +7 -0
- package/dist/browser/chunk-F6RH4LLT.js +69 -0
- package/dist/browser/chunk-F6RH4LLT.js.map +7 -0
- package/dist/browser/index.js +26 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/declarations/deprecated/mission_control-0-0-4.did.d.ts +80 -0
- package/dist/declarations/deprecated/mission_control-0-0-4.factory.did.js +99 -0
- package/dist/declarations/deprecated/satellite-0-0-8.did.d.ts +183 -0
- package/dist/declarations/deprecated/satellite-0-0-8.factory.did.js +194 -0
- package/dist/declarations/deprecated/satellite-0-0-9.did.d.ts +199 -0
- package/dist/declarations/deprecated/satellite-0-0-9.factory.did.js +213 -0
- package/dist/declarations/satellite/satellite.did.d.ts +288 -0
- package/dist/declarations/satellite/satellite.factory.did.js +316 -0
- package/dist/declarations/satellite/satellite.factory.did.mjs +316 -0
- package/dist/index.js +1 -0
- package/dist/node/index.mjs +104 -0
- package/dist/node/index.mjs.map +7 -0
- package/dist/types/api/actor.api.d.ts +9 -0
- package/dist/types/api/doc.api.d.ts +52 -0
- package/dist/types/api/storage.api.d.ts +42 -0
- package/dist/types/constants/auth.constants.d.ts +12 -0
- package/dist/types/constants/container.constants.d.ts +2 -0
- package/dist/types/index.d.ts +38 -0
- package/dist/types/providers/auth.providers.d.ts +79 -0
- package/dist/types/services/auth-timout.services.d.ts +3 -0
- package/dist/types/services/auth.services.d.ts +23 -0
- package/dist/types/services/doc.services.d.ts +127 -0
- package/dist/types/services/factory.services.d.ts +8 -0
- package/dist/types/services/identity.services.d.ts +2 -0
- package/dist/types/services/storage.services.d.ts +130 -0
- package/dist/types/services/user.services.d.ts +2 -0
- package/dist/types/stores/actor.store.d.ts +21 -0
- package/dist/types/stores/agent.store.d.ts +13 -0
- package/dist/types/stores/auth.store.d.ts +13 -0
- package/dist/types/stores/env.store.d.ts +11 -0
- package/dist/types/stores/store.d.ts +5 -0
- package/dist/types/types/auth.types.d.ts +90 -0
- package/dist/types/types/build.types.d.ts +5 -0
- package/dist/types/types/doc.types.d.ts +42 -0
- package/dist/types/types/env.types.d.ts +43 -0
- package/dist/types/types/list.types.d.ts +170 -0
- package/dist/types/types/post-message.d.ts +11 -0
- package/dist/types/types/satellite.types.d.ts +32 -0
- package/dist/types/types/storage.types.d.ts +21 -0
- package/dist/types/types/subscription.types.d.ts +6 -0
- package/dist/types/utils/auth.utils.d.ts +2 -0
- package/dist/types/utils/crypto.utils.d.ts +1 -0
- package/dist/types/utils/data.utils.d.ts +2 -0
- package/dist/types/utils/doc.utils.d.ts +8 -0
- package/dist/types/utils/env.utils.d.ts +4 -0
- package/dist/types/utils/events.utils.d.ts +4 -0
- package/dist/types/utils/list.utils.d.ts +3 -0
- package/dist/types/utils/window.env.utils.d.ts +2 -0
- package/dist/types/utils/window.utils.d.ts +4 -0
- package/dist/types/workers/auth.worker.d.ts +5 -0
- package/dist/workers/auth.worker.js +58 -0
- package/dist/workers/auth.worker.js.map +7 -0
- package/package.json +64 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ActorSubclass } from '@dfinity/agent';
|
|
2
|
+
import type { ActorMethod } from '@dfinity/agent/lib/esm/actor';
|
|
3
|
+
import type { IDL } from '@dfinity/candid';
|
|
4
|
+
import type { _SERVICE as SatelliteActor } from '../../declarations/satellite/satellite.did';
|
|
5
|
+
import type { Satellite } from '../types/satellite.types';
|
|
6
|
+
export declare const getSatelliteActor: (satellite: Satellite) => Promise<SatelliteActor>;
|
|
7
|
+
export declare const getSatelliteExtendedActor: <T = Record<string, ActorMethod<unknown[], unknown>>>({ idlFactory, ...rest }: Satellite & {
|
|
8
|
+
idlFactory: IDL.InterfaceFactory;
|
|
9
|
+
}) => Promise<ActorSubclass<T>>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Doc } from '../types/doc.types';
|
|
2
|
+
import type { ListParams, ListResults } from '../types/list.types';
|
|
3
|
+
import type { Satellite } from '../types/satellite.types';
|
|
4
|
+
export declare const getDoc: <D>({ collection, key, satellite }: {
|
|
5
|
+
collection: string;
|
|
6
|
+
satellite: Satellite;
|
|
7
|
+
} & Pick<Doc<D>, "key">) => Promise<Doc<D> | undefined>;
|
|
8
|
+
export declare const getManyDocs: ({ docs, satellite }: {
|
|
9
|
+
docs: ({
|
|
10
|
+
collection: string;
|
|
11
|
+
} & Pick<Doc<any>, "key">)[];
|
|
12
|
+
satellite: Satellite;
|
|
13
|
+
}) => Promise<(Doc<any> | undefined)[]>;
|
|
14
|
+
export declare const setDoc: <D>({ collection, doc, satellite }: {
|
|
15
|
+
collection: string;
|
|
16
|
+
doc: Doc<D>;
|
|
17
|
+
satellite: Satellite;
|
|
18
|
+
}) => Promise<Doc<D>>;
|
|
19
|
+
export declare const setManyDocs: ({ docs, satellite }: {
|
|
20
|
+
docs: {
|
|
21
|
+
collection: string;
|
|
22
|
+
doc: Doc<any>;
|
|
23
|
+
}[];
|
|
24
|
+
satellite: Satellite;
|
|
25
|
+
}) => Promise<Doc<any>[]>;
|
|
26
|
+
export declare const deleteDoc: <D>({ collection, doc, satellite }: {
|
|
27
|
+
collection: string;
|
|
28
|
+
doc: Doc<D>;
|
|
29
|
+
satellite: Satellite;
|
|
30
|
+
}) => Promise<void>;
|
|
31
|
+
export declare const deleteManyDocs: ({ docs, satellite }: {
|
|
32
|
+
docs: {
|
|
33
|
+
collection: string;
|
|
34
|
+
doc: Doc<any>;
|
|
35
|
+
}[];
|
|
36
|
+
satellite: Satellite;
|
|
37
|
+
}) => Promise<void>;
|
|
38
|
+
export declare const deleteFilteredDocs: ({ collection, filter, satellite }: {
|
|
39
|
+
collection: string;
|
|
40
|
+
filter: ListParams;
|
|
41
|
+
satellite: Satellite;
|
|
42
|
+
}) => Promise<void>;
|
|
43
|
+
export declare const listDocs: <D>({ collection, filter, satellite }: {
|
|
44
|
+
collection: string;
|
|
45
|
+
filter: ListParams;
|
|
46
|
+
satellite: Satellite;
|
|
47
|
+
}) => Promise<ListResults<Doc<D>>>;
|
|
48
|
+
export declare const countDocs: ({ collection, filter, satellite }: {
|
|
49
|
+
collection: string;
|
|
50
|
+
filter: ListParams;
|
|
51
|
+
satellite: Satellite;
|
|
52
|
+
}) => Promise<bigint>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type AssetKey, type UploadAsset } from '@junobuild/storage';
|
|
2
|
+
import type { AssetNoContent } from '../../declarations/satellite/satellite.did';
|
|
3
|
+
import type { ListParams, ListResults } from '../types/list.types';
|
|
4
|
+
import type { Satellite } from '../types/satellite.types';
|
|
5
|
+
export declare const uploadAsset: ({ satellite, ...asset }: UploadAsset & {
|
|
6
|
+
satellite: Satellite;
|
|
7
|
+
}) => Promise<void>;
|
|
8
|
+
export declare const listAssets: ({ collection, satellite, filter }: {
|
|
9
|
+
collection: string;
|
|
10
|
+
satellite: Satellite;
|
|
11
|
+
filter: ListParams;
|
|
12
|
+
}) => Promise<ListResults<AssetNoContent>>;
|
|
13
|
+
export declare const countAssets: ({ collection, satellite, filter }: {
|
|
14
|
+
collection: string;
|
|
15
|
+
satellite: Satellite;
|
|
16
|
+
filter: ListParams;
|
|
17
|
+
}) => Promise<bigint>;
|
|
18
|
+
export declare const deleteAsset: ({ collection, fullPath, satellite }: {
|
|
19
|
+
collection: string;
|
|
20
|
+
satellite: Satellite;
|
|
21
|
+
} & Pick<AssetKey, "fullPath">) => Promise<void>;
|
|
22
|
+
export declare const deleteManyAssets: ({ assets, satellite }: {
|
|
23
|
+
assets: ({
|
|
24
|
+
collection: string;
|
|
25
|
+
} & Pick<AssetKey, "fullPath">)[];
|
|
26
|
+
satellite: Satellite;
|
|
27
|
+
}) => Promise<void>;
|
|
28
|
+
export declare const deleteFilteredAssets: ({ collection, satellite, filter }: {
|
|
29
|
+
collection: string;
|
|
30
|
+
satellite: Satellite;
|
|
31
|
+
filter: ListParams;
|
|
32
|
+
}) => Promise<void>;
|
|
33
|
+
export declare const getAsset: ({ collection, fullPath, satellite }: {
|
|
34
|
+
collection: string;
|
|
35
|
+
satellite: Satellite;
|
|
36
|
+
} & Pick<AssetKey, "fullPath">) => Promise<AssetNoContent | undefined>;
|
|
37
|
+
export declare const getManyAssets: ({ assets, satellite }: {
|
|
38
|
+
assets: ({
|
|
39
|
+
collection: string;
|
|
40
|
+
} & Pick<AssetKey, "fullPath">)[];
|
|
41
|
+
satellite: Satellite;
|
|
42
|
+
}) => Promise<(AssetNoContent | undefined)[]>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const DELEGATION_IDENTITY_EXPIRATION: bigint;
|
|
2
|
+
export declare const ALLOW_PIN_AUTHENTICATION = false;
|
|
3
|
+
export declare const II_POPUP: {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const NFID_POPUP: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const INTERNET_COMPUTER_ORG = "internetcomputer.org";
|
|
12
|
+
export declare const AUTH_TIMER_INTERVAL = 1000;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Asset, AssetEncoding, AssetKey, ENCODING_TYPE, Storage } from '@junobuild/storage';
|
|
2
|
+
import type { User } from './types/auth.types';
|
|
3
|
+
import type { UserEnvironment } from './types/env.types';
|
|
4
|
+
import type { Unsubscribe } from './types/subscription.types';
|
|
5
|
+
export * from './providers/auth.providers';
|
|
6
|
+
export { signIn, signOut, unsafeIdentity } from './services/auth.services';
|
|
7
|
+
export * from './services/doc.services';
|
|
8
|
+
export * from './services/factory.services';
|
|
9
|
+
export * from './services/storage.services';
|
|
10
|
+
export type * from './types/auth.types';
|
|
11
|
+
export type * from './types/doc.types';
|
|
12
|
+
export type * from './types/env.types';
|
|
13
|
+
export { ListOrder, ListPaginate, ListParams, ListResults } from './types/list.types';
|
|
14
|
+
export type * from './types/satellite.types';
|
|
15
|
+
export type * from './types/storage.types';
|
|
16
|
+
export type * from './types/subscription.types';
|
|
17
|
+
export type { Asset, AssetEncoding, AssetKey, ENCODING_TYPE, Storage };
|
|
18
|
+
/**
|
|
19
|
+
* Initializes Juno with the provided optional environment parameters.
|
|
20
|
+
* If no environment is provided, the variables injected by the Vite or NextJS plugins will be used.
|
|
21
|
+
* @deprecated Use {@link initSatellite} instead.
|
|
22
|
+
* @param {UserEnvironment} [userEnv] - The optional user environment configuration.
|
|
23
|
+
* @returns {Promise<Unsubscribe[]>} A promise that resolves to an array of unsubscribe functions.
|
|
24
|
+
*/
|
|
25
|
+
export declare const initJuno: (userEnv?: UserEnvironment) => Promise<Unsubscribe[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Initializes a Juno satellite with the provided optional environment parameters.
|
|
28
|
+
* If no environment is provided, the variables injected by the Vite or NextJS plugins will be used.
|
|
29
|
+
* @param {UserEnvironment} [userEnv] - The optional user environment configuration.
|
|
30
|
+
* @returns {Promise<Unsubscribe[]>} A promise that resolves to an array of unsubscribe functions.
|
|
31
|
+
*/
|
|
32
|
+
export declare const initSatellite: (userEnv?: UserEnvironment) => Promise<Unsubscribe[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Subscribes to authentication state changes. i.e. each time a user signs in or signs out, the callback will be triggered.
|
|
35
|
+
* @param {function(User | null): void} callback - The callback function to execute when the authentication state changes.
|
|
36
|
+
* @returns {Unsubscribe} A function to unsubscribe from the authentication state changes.
|
|
37
|
+
*/
|
|
38
|
+
export declare const authSubscribe: (callback: (authUser: User | null) => void) => Unsubscribe;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { InternetIdentityConfig, NFIDConfig, Provider, SignInOptions } from '../types/auth.types';
|
|
2
|
+
/**
|
|
3
|
+
* Options for signing in with an authentication provider.
|
|
4
|
+
* @interface AuthProviderSignInOptions
|
|
5
|
+
*/
|
|
6
|
+
export interface AuthProviderSignInOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The URL of the identity provider - commonly Internet Identity.
|
|
9
|
+
*/
|
|
10
|
+
identityProvider: string;
|
|
11
|
+
/**
|
|
12
|
+
* Optional features for the window opener.
|
|
13
|
+
*/
|
|
14
|
+
windowOpenerFeatures?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Common traits for all authentication providers
|
|
18
|
+
* @interface AuthProvider
|
|
19
|
+
*/
|
|
20
|
+
export interface AuthProvider {
|
|
21
|
+
/**
|
|
22
|
+
* The unique identifier of the provider.
|
|
23
|
+
*/
|
|
24
|
+
readonly id: Provider;
|
|
25
|
+
/**
|
|
26
|
+
* Method to get the sign-in options for the provider.
|
|
27
|
+
* @param options - The sign-in options.
|
|
28
|
+
* @returns The sign-in options for the provider that can be use to effectively perform a sign-in.
|
|
29
|
+
*/
|
|
30
|
+
signInOptions: (options: Pick<SignInOptions, 'windowed'>) => AuthProviderSignInOptions;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Internet Identity authentication provider.
|
|
34
|
+
* @class InternetIdentityProvider
|
|
35
|
+
* @implements {AuthProvider}
|
|
36
|
+
*/
|
|
37
|
+
export declare class InternetIdentityProvider implements AuthProvider {
|
|
38
|
+
#private;
|
|
39
|
+
/**
|
|
40
|
+
* Creates an instance of InternetIdentityProvider.
|
|
41
|
+
* @param {InternetIdentityConfig} config - The configuration for Internet Identity.
|
|
42
|
+
*/
|
|
43
|
+
constructor({ domain }: InternetIdentityConfig);
|
|
44
|
+
/**
|
|
45
|
+
* Gets the identifier of the provider.
|
|
46
|
+
* @returns {Provider} The identifier of the provider - `internet_identity`.
|
|
47
|
+
*/
|
|
48
|
+
get id(): Provider;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the sign-in options for Internet Identity.
|
|
51
|
+
* @param {Pick<SignInOptions, 'windowed'>} options - The sign-in options.
|
|
52
|
+
* @returns {AuthProviderSignInOptions} The sign-in options for Internet Identity.
|
|
53
|
+
*/
|
|
54
|
+
signInOptions({ windowed }: Pick<SignInOptions, 'windowed'>): AuthProviderSignInOptions;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* NFID authentication provider.
|
|
58
|
+
* @class NFIDProvider
|
|
59
|
+
* @implements {AuthProvider}
|
|
60
|
+
*/
|
|
61
|
+
export declare class NFIDProvider implements AuthProvider {
|
|
62
|
+
#private;
|
|
63
|
+
/**
|
|
64
|
+
* Creates an instance of NFIDProvider.
|
|
65
|
+
* @param {NFIDConfig} config - The configuration for NFID.
|
|
66
|
+
*/
|
|
67
|
+
constructor({ appName, logoUrl }: NFIDConfig);
|
|
68
|
+
/**
|
|
69
|
+
* Gets the identifier of the provider.
|
|
70
|
+
* @returns {Provider} The identifier of the provider- nfid.
|
|
71
|
+
*/
|
|
72
|
+
get id(): Provider;
|
|
73
|
+
/**
|
|
74
|
+
* Gets the sign-in options for NFID.
|
|
75
|
+
* @param {Pick<SignInOptions, 'windowed'>} options - The sign-in options.
|
|
76
|
+
* @returns {AuthProviderSignInOptions} The sign-in options to effectively sign-in with NFID.
|
|
77
|
+
*/
|
|
78
|
+
signInOptions({ windowed }: Pick<SignInOptions, 'windowed'>): AuthProviderSignInOptions;
|
|
79
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Identity } from '@dfinity/agent';
|
|
2
|
+
import type { Provider, SignInOptions } from '../types/auth.types';
|
|
3
|
+
export declare const initAuth: (provider?: Provider) => Promise<void>;
|
|
4
|
+
/**
|
|
5
|
+
* Signs in a user with the specified options.
|
|
6
|
+
* @param {SignInOptions} [options] - The options for signing in.
|
|
7
|
+
* @returns {Promise<void>} A promise that resolves when the sign-in process is complete and the authenticated user is initialized.
|
|
8
|
+
* @throws Will throw an error if the sign-in process fails.
|
|
9
|
+
*/
|
|
10
|
+
export declare const signIn: (options?: SignInOptions) => Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Signs out the current user.
|
|
13
|
+
* @returns {Promise<void>} A promise that resolves when the sign-out process is complete.
|
|
14
|
+
*/
|
|
15
|
+
export declare const signOut: () => Promise<void>;
|
|
16
|
+
export declare const getIdentity: () => Identity | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the identity of a signed-in user or an anonymous identity.
|
|
19
|
+
* This function is useful for loading an identity in web workers.
|
|
20
|
+
* Used to imperatively get the identity. Please be certain before using it.
|
|
21
|
+
* @returns {Promise<Identity>} A promise that resolves to the identity of the user or an anonymous identity.
|
|
22
|
+
*/
|
|
23
|
+
export declare const unsafeIdentity: () => Promise<Identity>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Doc } from '../types/doc.types';
|
|
2
|
+
import type { ListParams, ListResults } from '../types/list.types';
|
|
3
|
+
import type { SatelliteOptions } from '../types/satellite.types';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves a single document from a collection.
|
|
6
|
+
* @template D
|
|
7
|
+
* @param {Object} params - The parameters for retrieving the document.
|
|
8
|
+
* @param {string} params.collection - The name of the collection.
|
|
9
|
+
* @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
|
|
10
|
+
* @param {string} params.key - The key of the document to retrieve.
|
|
11
|
+
* @returns {Promise<Doc<D> | undefined>} A promise that resolves to the document or undefined if not found.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getDoc: <D>({ satellite, ...rest }: {
|
|
14
|
+
collection: string;
|
|
15
|
+
satellite?: SatelliteOptions;
|
|
16
|
+
} & Pick<Doc<D>, "key">) => Promise<Doc<D> | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves multiple documents from a single or different collections in a single call.
|
|
19
|
+
* @param {Object} params - The parameters for retrieving the documents.
|
|
20
|
+
* @param {Array} params.docs - The list of documents with their collections and keys.
|
|
21
|
+
* @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
|
|
22
|
+
* @returns {Promise<Array<Doc<any> | undefined>>} A promise that resolves to an array of documents or undefined if not found.
|
|
23
|
+
*/
|
|
24
|
+
export declare const getManyDocs: ({ satellite, ...rest }: {
|
|
25
|
+
docs: ({
|
|
26
|
+
collection: string;
|
|
27
|
+
} & Pick<Doc<any>, "key">)[];
|
|
28
|
+
satellite?: SatelliteOptions;
|
|
29
|
+
}) => Promise<(Doc<any> | undefined)[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Adds or updates a single document in a collection.
|
|
32
|
+
* @template D
|
|
33
|
+
* @param {Object} params - The parameters for adding or updating the document.
|
|
34
|
+
* @param {string} params.collection - The name of the collection.
|
|
35
|
+
* @param {Doc<D>} params.doc - The document to add or update.
|
|
36
|
+
* @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
|
|
37
|
+
* @returns {Promise<Doc<D>>} A promise that resolves to the added or updated document.
|
|
38
|
+
*/
|
|
39
|
+
export declare const setDoc: <D>({ satellite, ...rest }: {
|
|
40
|
+
collection: string;
|
|
41
|
+
doc: Doc<D>;
|
|
42
|
+
satellite?: SatelliteOptions;
|
|
43
|
+
}) => Promise<Doc<D>>;
|
|
44
|
+
/**
|
|
45
|
+
* Adds or updates multiple documents in a or different collections.
|
|
46
|
+
* @param {Object} params - The parameters for adding or updating the documents.
|
|
47
|
+
* @param {Array} params.docs - The list of documents with their collections and data.
|
|
48
|
+
* @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
|
|
49
|
+
* @returns {Promise<Array<Doc<any>>>} A promise that resolves to an array of added or updated documents.
|
|
50
|
+
*/
|
|
51
|
+
export declare const setManyDocs: ({ satellite, ...rest }: {
|
|
52
|
+
docs: {
|
|
53
|
+
collection: string;
|
|
54
|
+
doc: Doc<any>;
|
|
55
|
+
}[];
|
|
56
|
+
satellite?: SatelliteOptions;
|
|
57
|
+
}) => Promise<Doc<any>[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Deletes a single document from a collection.
|
|
60
|
+
* @template D
|
|
61
|
+
* @param {Object} params - The parameters for deleting the document.
|
|
62
|
+
* @param {string} params.collection - The name of the collection.
|
|
63
|
+
* @param {Doc<D>} params.doc - The document to delete.
|
|
64
|
+
* @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
|
|
65
|
+
* @returns {Promise<void>} A promise that resolves when the document is deleted.
|
|
66
|
+
*/
|
|
67
|
+
export declare const deleteDoc: <D>({ satellite, ...rest }: {
|
|
68
|
+
collection: string;
|
|
69
|
+
doc: Doc<D>;
|
|
70
|
+
satellite?: SatelliteOptions;
|
|
71
|
+
}) => Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Deletes multiple documents from a or different collections.
|
|
74
|
+
* @param {Object} params - The parameters for deleting the documents.
|
|
75
|
+
* @param {Array} params.docs - The list of documents with their collections and data.
|
|
76
|
+
* @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
|
|
77
|
+
* @returns {Promise<void>} A promise that resolves when the documents are deleted.
|
|
78
|
+
*/
|
|
79
|
+
export declare const deleteManyDocs: ({ satellite, ...rest }: {
|
|
80
|
+
docs: {
|
|
81
|
+
collection: string;
|
|
82
|
+
doc: Doc<any>;
|
|
83
|
+
}[];
|
|
84
|
+
satellite?: SatelliteOptions;
|
|
85
|
+
}) => Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Deletes documents from a collection with optional filtering.
|
|
88
|
+
*
|
|
89
|
+
* @param {Object} params - The parameters for deleting documents.
|
|
90
|
+
* @param {string} params.collection - The name of the collection.
|
|
91
|
+
* @param {ListParams} [params.filter] - The filter criteria to match documents for deletion.
|
|
92
|
+
* @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
|
|
93
|
+
*
|
|
94
|
+
* @returns {Promise<void>} A promise that resolves when the documents are deleted.
|
|
95
|
+
*/
|
|
96
|
+
export declare const deleteFilteredDocs: ({ satellite, filter, ...rest }: {
|
|
97
|
+
collection: string;
|
|
98
|
+
filter?: ListParams;
|
|
99
|
+
satellite?: SatelliteOptions;
|
|
100
|
+
}) => Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Lists documents in a collection with optional filtering.
|
|
103
|
+
* @template D
|
|
104
|
+
* @param {Object} params - The parameters for listing the documents.
|
|
105
|
+
* @param {string} params.collection - The name of the collection.
|
|
106
|
+
* @param {ListParams} [params.filter] - Optional filter parameters.
|
|
107
|
+
* @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
|
|
108
|
+
* @returns {Promise<ListResults<Doc<D>>>} A promise that resolves to the list of documents.
|
|
109
|
+
*/
|
|
110
|
+
export declare const listDocs: <D>({ satellite, filter, ...rest }: {
|
|
111
|
+
collection: string;
|
|
112
|
+
filter?: ListParams;
|
|
113
|
+
satellite?: SatelliteOptions;
|
|
114
|
+
}) => Promise<ListResults<Doc<D>>>;
|
|
115
|
+
/**
|
|
116
|
+
* Counts documents in a collection with optional filtering.
|
|
117
|
+
* @param {Object} params - The parameters for counting the documents.
|
|
118
|
+
* @param {string} params.collection - The name of the collection.
|
|
119
|
+
* @param {ListParams} [params.filter] - Optional filter parameters.
|
|
120
|
+
* @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
|
|
121
|
+
* @returns {Promise<bigint>} A promise that resolves to the count of documents as a bigint.
|
|
122
|
+
*/
|
|
123
|
+
export declare const countDocs: ({ satellite, filter, ...rest }: {
|
|
124
|
+
collection: string;
|
|
125
|
+
filter?: ListParams;
|
|
126
|
+
satellite?: SatelliteOptions;
|
|
127
|
+
}) => Promise<bigint>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ActorSubclass } from '@dfinity/agent';
|
|
2
|
+
import type { ActorMethod } from '@dfinity/agent/lib/esm/actor';
|
|
3
|
+
import type { IDL } from '@dfinity/candid';
|
|
4
|
+
import type { SatelliteOptions } from '../types/satellite.types';
|
|
5
|
+
export declare const getSatelliteExtendedActor: <T = Record<string, ActorMethod<unknown[], unknown>>>({ idlFactory, satellite }: {
|
|
6
|
+
idlFactory: IDL.InterfaceFactory;
|
|
7
|
+
satellite?: SatelliteOptions;
|
|
8
|
+
}) => Promise<ActorSubclass<T>>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { Asset, AssetKey, Storage } from '@junobuild/storage';
|
|
2
|
+
import type { AssetNoContent } from '../../declarations/satellite/satellite.did';
|
|
3
|
+
import type { ListParams } from '../types/list.types';
|
|
4
|
+
import type { SatelliteOptions } from '../types/satellite.types';
|
|
5
|
+
import type { Assets } from '../types/storage.types';
|
|
6
|
+
/**
|
|
7
|
+
* Uploads a blob to the storage.
|
|
8
|
+
* @param {Storage & {satellite?: SatelliteOptions}} params - The storage parameters. Satellite options are required only in NodeJS environment.
|
|
9
|
+
* @returns {Promise<AssetKey>} A promise that resolves to the asset key.
|
|
10
|
+
*/
|
|
11
|
+
export declare const uploadBlob: (params: Storage & {
|
|
12
|
+
satellite?: SatelliteOptions;
|
|
13
|
+
}) => Promise<AssetKey>;
|
|
14
|
+
/**
|
|
15
|
+
* Uploads a file to the storage.
|
|
16
|
+
* @param {Partial<Pick<Storage, 'filename'>> & Omit<Storage, 'filename' | 'data'> & {data: File} & {satellite?: SatelliteOptions}} params - The storage parameters. Satellite options are required only in NodeJS environment.
|
|
17
|
+
* @returns {Promise<AssetKey>} A promise that resolves to the asset key.
|
|
18
|
+
*/
|
|
19
|
+
export declare const uploadFile: (params: Partial<Pick<Storage, "filename">> & Omit<Storage, "filename" | "data"> & {
|
|
20
|
+
data: File;
|
|
21
|
+
} & {
|
|
22
|
+
satellite?: SatelliteOptions;
|
|
23
|
+
}) => Promise<AssetKey>;
|
|
24
|
+
/**
|
|
25
|
+
* Lists assets in a collection with optional filtering.
|
|
26
|
+
* @param {Object} params - The parameters for listing the assets.
|
|
27
|
+
* @param {string} params.collection - The name of the collection.
|
|
28
|
+
* @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
|
|
29
|
+
* @param {ListParams} [params.filter] - The filter parameters.
|
|
30
|
+
* @returns {Promise<Assets>} A promise that resolves to the list of assets.
|
|
31
|
+
*/
|
|
32
|
+
export declare const listAssets: ({ collection, satellite: satelliteOptions, filter }: {
|
|
33
|
+
collection: string;
|
|
34
|
+
satellite?: SatelliteOptions;
|
|
35
|
+
filter?: ListParams;
|
|
36
|
+
}) => Promise<Assets>;
|
|
37
|
+
/**
|
|
38
|
+
* Counts assets in a collection with optional filtering.
|
|
39
|
+
* @param {Object} params - The parameters for counting the assets.
|
|
40
|
+
* @param {string} params.collection - The name of the collection.
|
|
41
|
+
* @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
|
|
42
|
+
* @param {ListParams} [params.filter] - The filter parameters for narrowing down the count.
|
|
43
|
+
* @returns {Promise<bigint>} A promise that resolves to the count of assets as a bigint.
|
|
44
|
+
*/
|
|
45
|
+
export declare const countAssets: ({ collection, satellite: satelliteOptions, filter }: {
|
|
46
|
+
collection: string;
|
|
47
|
+
satellite?: SatelliteOptions;
|
|
48
|
+
filter?: ListParams;
|
|
49
|
+
}) => Promise<bigint>;
|
|
50
|
+
/**
|
|
51
|
+
* Deletes an asset from the storage.
|
|
52
|
+
* @param {Object} params - The parameters for deleting the asset.
|
|
53
|
+
* @param {string} params.collection - The name of the collection.
|
|
54
|
+
* @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
|
|
55
|
+
* @param {string} params.fullPath - The full path of the asset.
|
|
56
|
+
* @returns {Promise<void>} A promise that resolves when the asset is deleted.
|
|
57
|
+
*/
|
|
58
|
+
export declare const deleteAsset: ({ collection, fullPath, satellite }: {
|
|
59
|
+
collection: string;
|
|
60
|
+
satellite?: SatelliteOptions;
|
|
61
|
+
} & Pick<AssetKey, "fullPath">) => Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Deletes multiple assets from the storage.
|
|
64
|
+
* @param {Object} params - The parameters for deleting the assets.
|
|
65
|
+
* @param {Array} params.assets - The list of assets with their collections and full paths.
|
|
66
|
+
* @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
|
|
67
|
+
* @returns {Promise<void>} A promise that resolves when the assets are deleted.
|
|
68
|
+
*/
|
|
69
|
+
export declare const deleteManyAssets: ({ assets, satellite }: {
|
|
70
|
+
assets: ({
|
|
71
|
+
collection: string;
|
|
72
|
+
} & Pick<AssetKey, "fullPath">)[];
|
|
73
|
+
satellite?: SatelliteOptions;
|
|
74
|
+
} & Pick<AssetKey, "fullPath">) => Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Deletes multiple assets from a collection based on filtering criteria.
|
|
77
|
+
*
|
|
78
|
+
* @param {Object} params - The parameters for deleting the assets.
|
|
79
|
+
* @param {string} params.collection - The name of the collection from which to delete assets.
|
|
80
|
+
* @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
|
|
81
|
+
* @param {ListParams} [params.filter] - The filter criteria to match assets for deletion.
|
|
82
|
+
*
|
|
83
|
+
* @returns {Promise<void>} A promise that resolves when the assets matching the filter criteria are deleted.
|
|
84
|
+
*/
|
|
85
|
+
export declare const deleteFilteredAssets: ({ collection, satellite: satelliteOptions, filter }: {
|
|
86
|
+
collection: string;
|
|
87
|
+
satellite?: SatelliteOptions;
|
|
88
|
+
filter?: ListParams;
|
|
89
|
+
}) => Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Retrieves an asset from the storage.
|
|
92
|
+
* @param {Object} params - The parameters for retrieving the asset.
|
|
93
|
+
* @param {string} params.collection - The name of the collection.
|
|
94
|
+
* @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
|
|
95
|
+
* @param {string} params.fullPath - The full path of the asset.
|
|
96
|
+
* @returns {Promise<AssetNoContent | undefined>} A promise that resolves to the asset or undefined if not found.
|
|
97
|
+
*/
|
|
98
|
+
export declare const getAsset: ({ satellite, ...rest }: {
|
|
99
|
+
collection: string;
|
|
100
|
+
satellite?: SatelliteOptions;
|
|
101
|
+
} & Pick<AssetKey, "fullPath">) => Promise<AssetNoContent | undefined>;
|
|
102
|
+
/**
|
|
103
|
+
* Retrieves multiple assets from the storage.
|
|
104
|
+
* @param {Object} params - The parameters for retrieving the assets.
|
|
105
|
+
* @param {Array} params.assets - The list of assets with their collections and full paths.
|
|
106
|
+
* @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
|
|
107
|
+
* @returns {Promise<Array<AssetNoContent | undefined>>} A promise that resolves to an array of assets or undefined if not found.
|
|
108
|
+
*/
|
|
109
|
+
export declare const getManyAssets: ({ satellite, ...rest }: {
|
|
110
|
+
assets: ({
|
|
111
|
+
collection: string;
|
|
112
|
+
} & Pick<AssetKey, "fullPath">)[];
|
|
113
|
+
satellite?: SatelliteOptions;
|
|
114
|
+
}) => Promise<(AssetNoContent | undefined)[]>;
|
|
115
|
+
/**
|
|
116
|
+
* Generates a download URL for a given asset.
|
|
117
|
+
*
|
|
118
|
+
* @param {Object} params - The parameters for generating the download URL.
|
|
119
|
+
* @param {Object} params.assetKey - The key details of the asset.
|
|
120
|
+
* @param {string} params.assetKey.fullPath - The full path of the asset.
|
|
121
|
+
* @param {string} params.assetKey.token - The access token for the asset.
|
|
122
|
+
* @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
|
|
123
|
+
*
|
|
124
|
+
* @returns {string} The generated download URL.
|
|
125
|
+
*/
|
|
126
|
+
export declare const downloadUrl: ({ assetKey: { fullPath, token }, satellite: satelliteOptions }: {
|
|
127
|
+
assetKey: Pick<Asset, "fullPath" | "token">;
|
|
128
|
+
} & {
|
|
129
|
+
satellite?: SatelliteOptions;
|
|
130
|
+
}) => string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ActorSubclass } from '@dfinity/agent';
|
|
2
|
+
import type { ActorMethod } from '@dfinity/agent/lib/esm/actor';
|
|
3
|
+
import type { IDL } from '@dfinity/candid';
|
|
4
|
+
import type { BuildType } from '../types/build.types';
|
|
5
|
+
import type { Satellite } from '../types/satellite.types';
|
|
6
|
+
type ActorParams = {
|
|
7
|
+
idlFactory: IDL.InterfaceFactory;
|
|
8
|
+
} & Required<Pick<Satellite, 'satelliteId' | 'identity'>> & Pick<Satellite, 'fetch' | 'container'>;
|
|
9
|
+
type ActorRecord = Record<string, ActorMethod>;
|
|
10
|
+
export declare class ActorStore {
|
|
11
|
+
#private;
|
|
12
|
+
private static instance;
|
|
13
|
+
private constructor();
|
|
14
|
+
static getInstance(): ActorStore;
|
|
15
|
+
getActor<T = ActorRecord>({ satelliteId, identity, buildType, ...rest }: ActorParams & {
|
|
16
|
+
buildType: BuildType;
|
|
17
|
+
}): Promise<ActorSubclass<T>>;
|
|
18
|
+
reset(): void;
|
|
19
|
+
private createActor;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Agent } from '@dfinity/agent';
|
|
2
|
+
import type { Satellite } from '../types/satellite.types';
|
|
3
|
+
type AgentParams = Required<Pick<Satellite, 'identity'>> & Pick<Satellite, 'fetch' | 'container'>;
|
|
4
|
+
export declare class AgentStore {
|
|
5
|
+
#private;
|
|
6
|
+
private static instance;
|
|
7
|
+
private constructor();
|
|
8
|
+
static getInstance(): AgentStore;
|
|
9
|
+
getAgent({ identity, ...rest }: AgentParams): Promise<Agent>;
|
|
10
|
+
reset(): void;
|
|
11
|
+
private createAgent;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { User } from '../types/auth.types';
|
|
2
|
+
import type { Unsubscribe } from '../types/subscription.types';
|
|
3
|
+
import { Store } from './store';
|
|
4
|
+
export declare class AuthStore extends Store<User | null> {
|
|
5
|
+
private static instance;
|
|
6
|
+
private authUser;
|
|
7
|
+
private constructor();
|
|
8
|
+
static getInstance(): AuthStore;
|
|
9
|
+
set(authUser: User | null): void;
|
|
10
|
+
get(): User | null;
|
|
11
|
+
subscribe(callback: (data: User | null) => void): Unsubscribe;
|
|
12
|
+
reset(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Environment } from '../types/env.types';
|
|
2
|
+
import { Store } from './store';
|
|
3
|
+
export declare class EnvStore extends Store<Environment | undefined> {
|
|
4
|
+
private static instance;
|
|
5
|
+
private env;
|
|
6
|
+
private constructor();
|
|
7
|
+
static getInstance(): EnvStore;
|
|
8
|
+
set(env: Environment | undefined): void;
|
|
9
|
+
get(): Environment | undefined;
|
|
10
|
+
subscribe(callback: (data: Environment | null | undefined) => void): () => void;
|
|
11
|
+
}
|