@junobuild/core-peer 0.1.16 → 1.0.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.
Files changed (49) hide show
  1. package/dist/browser/index.js +1 -1
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/node/index.mjs +1 -1
  4. package/dist/node/index.mjs.map +4 -4
  5. package/dist/types/api/_actor.factory.d.ts +5 -0
  6. package/dist/types/api/actor.api.d.ts +9 -6
  7. package/dist/types/api/doc.api.d.ts +21 -30
  8. package/dist/types/api/storage.api.d.ts +18 -25
  9. package/dist/types/constants/call-options.constants.d.ts +9 -0
  10. package/dist/types/index.d.ts +13 -13
  11. package/dist/types/providers/auth.providers.d.ts +1 -1
  12. package/dist/types/services/_identity.services.d.ts +2 -0
  13. package/dist/types/services/{user.services.d.ts → _user.services.d.ts} +1 -1
  14. package/dist/types/services/auth-timout.services.d.ts +2 -2
  15. package/dist/types/services/auth.services.d.ts +18 -1
  16. package/dist/types/services/doc.services.d.ts +33 -17
  17. package/dist/types/services/functions.services.d.ts +26 -0
  18. package/dist/types/services/storage.services.d.ts +58 -26
  19. package/dist/types/stores/_agent.factory.d.ts +4 -0
  20. package/dist/types/stores/actor.store.d.ts +5 -5
  21. package/dist/types/stores/agent.store.d.ts +3 -6
  22. package/dist/types/stores/auth.store.d.ts +3 -3
  23. package/dist/types/stores/env.store.d.ts +4 -3
  24. package/dist/types/types/actor.d.ts +51 -0
  25. package/dist/types/types/{auth.types.d.ts → auth.d.ts} +1 -1
  26. package/dist/types/types/call-options.d.ts +43 -0
  27. package/dist/types/types/{doc.types.d.ts → doc.d.ts} +1 -1
  28. package/dist/types/types/{env.types.d.ts → env.d.ts} +3 -3
  29. package/dist/types/types/satellite.d.ts +40 -0
  30. package/dist/types/types/storage.types.d.ts +1 -1
  31. package/dist/types/utils/doc.utils.d.ts +1 -1
  32. package/dist/types/utils/env.utils.d.ts +4 -4
  33. package/dist/types/utils/list.utils.d.ts +1 -1
  34. package/dist/types/workers/_auth.worker.handler.d.ts +11 -0
  35. package/dist/types/workers/auth.worker.d.ts +1 -5
  36. package/dist/workers/_auth.worker.handler.js +43 -0
  37. package/dist/workers/_auth.worker.handler.js.map +7 -0
  38. package/dist/workers/auth.worker.js +7 -7
  39. package/dist/workers/auth.worker.js.map +4 -4
  40. package/package.json +2 -2
  41. package/dist/types/services/factory.services.d.ts +0 -8
  42. package/dist/types/services/identity.services.d.ts +0 -2
  43. package/dist/types/types/build.types.d.ts +0 -5
  44. package/dist/types/types/satellite.types.d.ts +0 -27
  45. /package/dist/types/stores/{store.d.ts → _store.d.ts} +0 -0
  46. /package/dist/types/types/{errors.types.d.ts → errors.d.ts} +0 -0
  47. /package/dist/types/types/{list.types.d.ts → list.d.ts} +0 -0
  48. /package/dist/types/types/{subscription.types.d.ts → subscription.d.ts} +0 -0
  49. /package/dist/types/types/{utility.types.d.ts → utility.d.ts} +0 -0
@@ -0,0 +1,5 @@
1
+ import type { _SERVICE as SatelliteActor } from '../../declarations/satellite/satellite.did';
2
+ import { idlFactory as idlFactorySatellite } from '../../declarations/satellite/satellite.factory.did.js';
3
+ import { idlFactory as idlCertifiedFactorySatellite } from '../../declarations/satellite/satellite.factory.certified.did.js';
4
+ import { idlFactory as idlFactorySputnik } from '../../declarations/sputnik/sputnik.factory.did.js';
5
+ export { idlCertifiedFactorySatellite, idlFactorySatellite, idlFactorySputnik, type SatelliteActor };
@@ -1,9 +1,12 @@
1
- import type { ActorSubclass } from '@dfinity/agent';
2
- import type { ActorMethod } from '@dfinity/agent/lib/esm/actor';
1
+ import type { ActorMethod, ActorSubclass } from '@dfinity/agent';
3
2
  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>>({ idlFactory, ...rest }: Satellite & {
3
+ import type { CallOptions } from '../types/call-options';
4
+ import type { SatelliteContext } from '../types/satellite';
5
+ import { type SatelliteActor } from './_actor.factory';
6
+ export declare const getSatelliteActor: ({ satellite, options: { certified } }: {
7
+ satellite: SatelliteContext;
8
+ options: CallOptions;
9
+ }) => Promise<SatelliteActor>;
10
+ export declare const getSatelliteExtendedActor: <T = Record<string, ActorMethod>>({ idlFactory, ...rest }: SatelliteContext & {
8
11
  idlFactory: IDL.InterfaceFactory;
9
12
  }) => Promise<ActorSubclass<T>>;
@@ -1,52 +1,43 @@
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 }: {
1
+ import type { ActorReadParams, ActorUpdateParams } from '../types/actor';
2
+ import type { Doc } from '../types/doc';
3
+ import type { ListParams, ListResults } from '../types/list';
4
+ export declare const getDoc: <D>({ collection, key, ...rest }: {
5
5
  collection: string;
6
- satellite: Satellite;
7
- } & Pick<Doc<D>, "key">) => Promise<Doc<D> | undefined>;
8
- export declare const getManyDocs: ({ docs, satellite }: {
6
+ } & ActorReadParams & Pick<Doc<D>, "key">) => Promise<Doc<D> | undefined>;
7
+ export declare const getManyDocs: ({ docs, ...rest }: {
9
8
  docs: ({
10
9
  collection: string;
11
10
  } & Pick<Doc<any>, "key">)[];
12
- satellite: Satellite;
13
- }) => Promise<(Doc<any> | undefined)[]>;
14
- export declare const setDoc: <D>({ collection, doc, satellite }: {
11
+ } & ActorReadParams) => Promise<(Doc<any> | undefined)[]>;
12
+ export declare const setDoc: <D>({ collection, doc, ...rest }: {
15
13
  collection: string;
16
14
  doc: Doc<D>;
17
- satellite: Satellite;
18
- }) => Promise<Doc<D>>;
19
- export declare const setManyDocs: ({ docs, satellite }: {
15
+ } & ActorUpdateParams) => Promise<Doc<D>>;
16
+ export declare const setManyDocs: ({ docs, ...rest }: {
20
17
  docs: {
21
18
  collection: string;
22
19
  doc: Doc<any>;
23
20
  }[];
24
- satellite: Satellite;
25
- }) => Promise<Doc<any>[]>;
26
- export declare const deleteDoc: <D>({ collection, doc, satellite }: {
21
+ } & ActorUpdateParams) => Promise<Doc<any>[]>;
22
+ export declare const deleteDoc: <D>({ collection, doc, ...rest }: {
27
23
  collection: string;
28
24
  doc: Doc<D>;
29
- satellite: Satellite;
30
- }) => Promise<void>;
31
- export declare const deleteManyDocs: ({ docs, satellite }: {
25
+ } & ActorUpdateParams) => Promise<void>;
26
+ export declare const deleteManyDocs: ({ docs, ...rest }: {
32
27
  docs: {
33
28
  collection: string;
34
29
  doc: Doc<any>;
35
30
  }[];
36
- satellite: Satellite;
37
- }) => Promise<void>;
38
- export declare const deleteFilteredDocs: ({ collection, filter, satellite }: {
31
+ } & ActorUpdateParams) => Promise<void>;
32
+ export declare const deleteFilteredDocs: ({ collection, filter, ...rest }: {
39
33
  collection: string;
40
34
  filter: ListParams;
41
- satellite: Satellite;
42
- }) => Promise<void>;
43
- export declare const listDocs: <D>({ collection, filter, satellite }: {
35
+ } & ActorUpdateParams) => Promise<void>;
36
+ export declare const listDocs: <D>({ collection, filter, ...rest }: {
44
37
  collection: string;
45
38
  filter: ListParams;
46
- satellite: Satellite;
47
- }) => Promise<ListResults<Doc<D>>>;
48
- export declare const countDocs: ({ collection, filter, satellite }: {
39
+ } & ActorReadParams) => Promise<ListResults<Doc<D>>>;
40
+ export declare const countDocs: ({ collection, filter, ...rest }: {
49
41
  collection: string;
50
42
  filter: ListParams;
51
- satellite: Satellite;
52
- }) => Promise<bigint>;
43
+ } & ActorReadParams) => Promise<bigint>;
@@ -1,42 +1,35 @@
1
1
  import { type AssetKey, type UploadAsset } from '@junobuild/storage';
2
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 }: {
3
+ import type { ActorReadParams, ActorUpdateParams } from '../types/actor';
4
+ import type { ListParams, ListResults } from '../types/list';
5
+ export declare const uploadAsset: ({ asset, ...rest }: {
6
+ asset: UploadAsset;
7
+ } & ActorUpdateParams) => Promise<void>;
8
+ export declare const listAssets: ({ collection, filter, ...rest }: {
9
9
  collection: string;
10
- satellite: Satellite;
11
10
  filter: ListParams;
12
- }) => Promise<ListResults<AssetNoContent>>;
13
- export declare const countAssets: ({ collection, satellite, filter }: {
11
+ } & ActorReadParams) => Promise<ListResults<AssetNoContent>>;
12
+ export declare const countAssets: ({ collection, filter, ...rest }: {
14
13
  collection: string;
15
- satellite: Satellite;
16
14
  filter: ListParams;
17
- }) => Promise<bigint>;
18
- export declare const deleteAsset: ({ collection, fullPath, satellite }: {
15
+ } & ActorReadParams) => Promise<bigint>;
16
+ export declare const deleteAsset: ({ collection, fullPath, ...rest }: {
19
17
  collection: string;
20
- satellite: Satellite;
21
- } & Pick<AssetKey, "fullPath">) => Promise<void>;
18
+ } & ActorUpdateParams & Pick<AssetKey, "fullPath">) => Promise<void>;
22
19
  export declare const deleteManyAssets: ({ assets, satellite }: {
23
20
  assets: ({
24
21
  collection: string;
25
22
  } & Pick<AssetKey, "fullPath">)[];
26
- satellite: Satellite;
27
- }) => Promise<void>;
28
- export declare const deleteFilteredAssets: ({ collection, satellite, filter }: {
23
+ } & ActorUpdateParams) => Promise<void>;
24
+ export declare const deleteFilteredAssets: ({ collection, filter, ...rest }: {
29
25
  collection: string;
30
- satellite: Satellite;
31
26
  filter: ListParams;
32
- }) => Promise<void>;
33
- export declare const getAsset: ({ collection, fullPath, satellite }: {
27
+ } & ActorUpdateParams) => Promise<void>;
28
+ export declare const getAsset: ({ collection, fullPath, ...rest }: {
34
29
  collection: string;
35
- satellite: Satellite;
36
- } & Pick<AssetKey, "fullPath">) => Promise<AssetNoContent | undefined>;
37
- export declare const getManyAssets: ({ assets, satellite }: {
30
+ } & ActorReadParams & Pick<AssetKey, "fullPath">) => Promise<AssetNoContent | undefined>;
31
+ export declare const getManyAssets: ({ assets, ...rest }: {
38
32
  assets: ({
39
33
  collection: string;
40
34
  } & Pick<AssetKey, "fullPath">)[];
41
- satellite: Satellite;
42
- }) => Promise<(AssetNoContent | undefined)[]>;
35
+ } & ActorReadParams) => Promise<(AssetNoContent | undefined)[]>;
@@ -0,0 +1,9 @@
1
+ import type { ReadOptions } from '../types/call-options';
2
+ /**
3
+ * Default options for read operations.
4
+ *
5
+ * For backwards compatibility and because most developers probably prioritize speed over
6
+ * additional security when fetching read-only data from the Internet Computer,
7
+ * read operations are performed in an uncertified way by default.
8
+ */
9
+ export declare const DEFAULT_READ_OPTIONS: ReadOptions;
@@ -1,21 +1,21 @@
1
1
  import type { Asset, AssetEncoding, AssetKey, EncodingType, 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';
2
+ import type { User } from './types/auth';
3
+ import type { UserEnvironment } from './types/env';
4
+ import type { Unsubscribe } from './types/subscription';
5
5
  export * from './providers/auth.providers';
6
- export { signIn, signOut, unsafeIdentity } from './services/auth.services';
6
+ export { getIdentityOnce, signIn, signOut, unsafeIdentity } from './services/auth.services';
7
7
  export * from './services/doc.services';
8
- export * from './services/factory.services';
8
+ export * from './services/functions.services';
9
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 * from './types/errors.types';
14
- export { ListOrder, ListPaginate, ListParams, ListResults } from './types/list.types';
15
- export type * from './types/satellite.types';
10
+ export type * from './types/auth';
11
+ export type * from './types/doc';
12
+ export type * from './types/env';
13
+ export * from './types/errors';
14
+ export { ListOrder, ListPaginate, ListParams, ListResults } from './types/list';
15
+ export type * from './types/satellite';
16
16
  export type * from './types/storage.types';
17
- export type * from './types/subscription.types';
18
- export type * from './types/utility.types';
17
+ export type * from './types/subscription';
18
+ export type * from './types/utility';
19
19
  export type { Asset, AssetEncoding, AssetKey, EncodingType, Storage };
20
20
  /**
21
21
  * Initializes Juno with the provided optional environment parameters.
@@ -1,4 +1,4 @@
1
- import type { InternetIdentityConfig, NFIDConfig, Provider, SignInOptions } from '../types/auth.types';
1
+ import type { InternetIdentityConfig, NFIDConfig, Provider, SignInOptions } from '../types/auth';
2
2
  /**
3
3
  * Options for signing in with an authentication provider.
4
4
  * @interface AuthProviderSignInOptions
@@ -0,0 +1,2 @@
1
+ import { type Identity } from '@dfinity/agent';
2
+ export declare const getAnyIdentity: (identity?: Identity) => Identity;
@@ -1,2 +1,2 @@
1
- import type { Provider, User } from '../types/auth.types';
1
+ import type { Provider, User } from '../types/auth';
2
2
  export declare const initUser: (provider?: Provider) => Promise<User>;
@@ -1,3 +1,3 @@
1
- import type { EnvironmentWorker } from '../types/env.types';
2
- import type { Unsubscribe } from '../types/subscription.types';
1
+ import type { EnvironmentWorker } from '../types/env';
2
+ import type { Unsubscribe } from '../types/subscription';
3
3
  export declare const initAuthTimeoutWorker: (auth: EnvironmentWorker) => Unsubscribe;
@@ -1,5 +1,5 @@
1
1
  import type { Identity } from '@dfinity/agent';
2
- import type { Provider, SignInOptions } from '../types/auth.types';
2
+ import type { Provider, SignInOptions } from '../types/auth';
3
3
  export declare const initAuth: (provider?: Provider) => Promise<void>;
4
4
  /**
5
5
  * Signs in a user with the specified options.
@@ -14,6 +14,10 @@ export declare const signIn: (options?: SignInOptions) => Promise<void>;
14
14
  * @returns {Promise<void>} A promise that resolves when the sign-out process is complete.
15
15
  */
16
16
  export declare const signOut: () => Promise<void>;
17
+ /**
18
+ * ℹ️ Exposed for testing purpose only. Should not be leaked to consumer or used by the library.
19
+ */
20
+ export declare const resetAuth: () => Promise<void>;
17
21
  export declare const getIdentity: () => Identity | undefined;
18
22
  /**
19
23
  * Returns the identity of a signed-in user or an anonymous identity.
@@ -22,3 +26,16 @@ export declare const getIdentity: () => Identity | undefined;
22
26
  * @returns {Promise<Identity>} A promise that resolves to the identity of the user or an anonymous identity.
23
27
  */
24
28
  export declare const unsafeIdentity: () => Promise<Identity>;
29
+ /**
30
+ * Returns the current identity if the user is authenticated.
31
+ *
32
+ * ⚠️ Use this function imperatively only. Do **not** persist the identity in global state.
33
+ * It is intended for short-lived or one-time operations.
34
+ *
35
+ * Typical use case is to enable developers to implement custom features for the Internet Computer:
36
+ * - Passing the identity to temporarily create an actor or agent to call a canister
37
+ * - Signing a message or making a one-time authenticated call
38
+ *
39
+ * @returns The authenticated identity, or null if unavailable.
40
+ */
41
+ export declare const getIdentityOnce: () => Promise<Identity | null>;
@@ -1,39 +1,47 @@
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';
1
+ import type { ReadOptions } from '../types/call-options';
2
+ import type { Doc } from '../types/doc';
3
+ import type { ListParams, ListResults } from '../types/list';
4
+ import type { SatelliteOptions } from '../types/satellite';
4
5
  /**
5
6
  * Retrieves a single document from a collection.
7
+ *
6
8
  * @template D
7
9
  * @param {Object} params - The parameters for retrieving the document.
8
10
  * @param {string} params.collection - The name of the collection.
9
- * @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
10
11
  * @param {string} params.key - The key of the document to retrieve.
12
+ * @param {ReadOptions} [params.options] - Call options controlling certification. Defaults to uncertified reads for performance unless specified.
13
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
11
14
  * @returns {Promise<Doc<D> | undefined>} A promise that resolves to the document or undefined if not found.
12
15
  */
13
- export declare const getDoc: <D>({ satellite, ...rest }: {
16
+ export declare const getDoc: <D>({ satellite, options, ...rest }: {
14
17
  collection: string;
15
18
  satellite?: SatelliteOptions;
19
+ options?: ReadOptions;
16
20
  } & Pick<Doc<D>, "key">) => Promise<Doc<D> | undefined>;
17
21
  /**
18
22
  * Retrieves multiple documents from a single or different collections in a single call.
23
+ *
19
24
  * @param {Object} params - The parameters for retrieving the documents.
20
25
  * @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).
26
+ * @param {ReadOptions} [params.options] - Call options controlling certification. Defaults to uncertified reads for performance unless specified.
27
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
22
28
  * @returns {Promise<Array<Doc<any> | undefined>>} A promise that resolves to an array of documents or undefined if not found.
23
29
  */
24
- export declare const getManyDocs: ({ satellite, ...rest }: {
30
+ export declare const getManyDocs: ({ satellite, options, ...rest }: {
25
31
  docs: ({
26
32
  collection: string;
27
33
  } & Pick<Doc<any>, "key">)[];
28
34
  satellite?: SatelliteOptions;
35
+ options?: ReadOptions;
29
36
  }) => Promise<(Doc<any> | undefined)[]>;
30
37
  /**
31
38
  * Adds or updates a single document in a collection.
39
+ *
32
40
  * @template D
33
41
  * @param {Object} params - The parameters for adding or updating the document.
34
42
  * @param {string} params.collection - The name of the collection.
35
43
  * @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).
44
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
37
45
  * @returns {Promise<Doc<D>>} A promise that resolves to the added or updated document.
38
46
  */
39
47
  export declare const setDoc: <D>({ satellite, ...rest }: {
@@ -43,9 +51,10 @@ export declare const setDoc: <D>({ satellite, ...rest }: {
43
51
  }) => Promise<Doc<D>>;
44
52
  /**
45
53
  * Adds or updates multiple documents in a or different collections.
54
+ *
46
55
  * @param {Object} params - The parameters for adding or updating the documents.
47
56
  * @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).
57
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
49
58
  * @returns {Promise<Array<Doc<any>>>} A promise that resolves to an array of added or updated documents.
50
59
  */
51
60
  export declare const setManyDocs: ({ satellite, ...rest }: {
@@ -57,11 +66,12 @@ export declare const setManyDocs: ({ satellite, ...rest }: {
57
66
  }) => Promise<Doc<any>[]>;
58
67
  /**
59
68
  * Deletes a single document from a collection.
69
+ *
60
70
  * @template D
61
71
  * @param {Object} params - The parameters for deleting the document.
62
72
  * @param {string} params.collection - The name of the collection.
63
73
  * @param {Doc<D>} params.doc - The document to delete.
64
- * @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
74
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
65
75
  * @returns {Promise<void>} A promise that resolves when the document is deleted.
66
76
  */
67
77
  export declare const deleteDoc: <D>({ satellite, ...rest }: {
@@ -71,9 +81,10 @@ export declare const deleteDoc: <D>({ satellite, ...rest }: {
71
81
  }) => Promise<void>;
72
82
  /**
73
83
  * Deletes multiple documents from a or different collections.
84
+ *
74
85
  * @param {Object} params - The parameters for deleting the documents.
75
86
  * @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).
87
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
77
88
  * @returns {Promise<void>} A promise that resolves when the documents are deleted.
78
89
  */
79
90
  export declare const deleteManyDocs: ({ satellite, ...rest }: {
@@ -89,8 +100,7 @@ export declare const deleteManyDocs: ({ satellite, ...rest }: {
89
100
  * @param {Object} params - The parameters for deleting documents.
90
101
  * @param {string} params.collection - The name of the collection.
91
102
  * @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
- *
103
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
94
104
  * @returns {Promise<void>} A promise that resolves when the documents are deleted.
95
105
  */
96
106
  export declare const deleteFilteredDocs: ({ satellite, filter, ...rest }: {
@@ -100,28 +110,34 @@ export declare const deleteFilteredDocs: ({ satellite, filter, ...rest }: {
100
110
  }) => Promise<void>;
101
111
  /**
102
112
  * Lists documents in a collection with optional filtering.
113
+ *
103
114
  * @template D
104
115
  * @param {Object} params - The parameters for listing the documents.
105
116
  * @param {string} params.collection - The name of the collection.
106
117
  * @param {ListParams} [params.filter] - Optional filter parameters.
107
- * @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
118
+ * @param {ReadOptions} [params.options] - Call options controlling certification. Defaults to uncertified reads for performance unless specified.
119
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
108
120
  * @returns {Promise<ListResults<Doc<D>>>} A promise that resolves to the list of documents.
109
121
  */
110
- export declare const listDocs: <D>({ satellite, filter, ...rest }: {
122
+ export declare const listDocs: <D>({ satellite, options, filter, ...rest }: {
111
123
  collection: string;
112
124
  filter?: ListParams;
113
125
  satellite?: SatelliteOptions;
126
+ options?: ReadOptions;
114
127
  }) => Promise<ListResults<Doc<D>>>;
115
128
  /**
116
129
  * Counts documents in a collection with optional filtering.
130
+ *
117
131
  * @param {Object} params - The parameters for counting the documents.
118
132
  * @param {string} params.collection - The name of the collection.
119
133
  * @param {ListParams} [params.filter] - Optional filter parameters.
120
- * @param {SatelliteOptions} [params.satellite] - Options for the satellite (useful for NodeJS usage only).
134
+ * @param {ReadOptions} [params.options] - Call options controlling certification. Defaults to uncertified reads for performance unless specified.
135
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
121
136
  * @returns {Promise<bigint>} A promise that resolves to the count of documents as a bigint.
122
137
  */
123
- export declare const countDocs: ({ satellite, filter, ...rest }: {
138
+ export declare const countDocs: ({ satellite, options, filter, ...rest }: {
124
139
  collection: string;
125
140
  filter?: ListParams;
126
141
  satellite?: SatelliteOptions;
142
+ options?: ReadOptions;
127
143
  }) => Promise<bigint>;
@@ -0,0 +1,26 @@
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';
5
+ /**
6
+ * Returns an extended satellite actor instance using the provided IDL factory and satellite options.
7
+ *
8
+ * This function is intended for advanced use cases where developers have implemented
9
+ * custom endpoints in their serverless functions using the extended build type.
10
+ *
11
+ * In most cases, developers should not need to call this directly.
12
+ * Extended actors are typically mapped and handled automatically.
13
+ *
14
+ * @template T - The actor interface type.
15
+ *
16
+ * @param {Object} params - The parameters for creating the actor.
17
+ * @param {IDL.InterfaceFactory} params.idlFactory - The IDL factory defining the custom actor interface.
18
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only.
19
+ * In browser environments, configuration is automatically inherited from `initSatellite()`.
20
+ *
21
+ * @returns {Promise<ActorSubclass<T>>} A promise that resolves to the extended actor instance.
22
+ */
23
+ export declare const getSatelliteExtendedActor: <T = Record<string, ActorMethod>>({ idlFactory, satellite }: {
24
+ idlFactory: IDL.InterfaceFactory;
25
+ satellite?: SatelliteOptions;
26
+ }) => Promise<ActorSubclass<T>>;
@@ -1,11 +1,13 @@
1
1
  import type { Asset, AssetKey, Storage } from '@junobuild/storage';
2
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';
3
+ import type { ReadOptions } from '../types/call-options';
4
+ import type { ListParams } from '../types/list';
5
+ import type { SatelliteOptions } from '../types/satellite';
5
6
  import type { Assets } from '../types/storage.types';
6
7
  /**
7
8
  * Uploads a blob to the storage.
8
- * @param {Storage & {satellite?: SatelliteOptions}} params - The storage parameters. Satellite options are required only in NodeJS environment.
9
+ *
10
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
9
11
  * @returns {Promise<AssetKey>} A promise that resolves to the asset key.
10
12
  */
11
13
  export declare const uploadBlob: (params: Storage & {
@@ -13,7 +15,8 @@ export declare const uploadBlob: (params: Storage & {
13
15
  }) => Promise<AssetKey>;
14
16
  /**
15
17
  * 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.
18
+ *
19
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
17
20
  * @returns {Promise<AssetKey>} A promise that resolves to the asset key.
18
21
  */
19
22
  export declare const uploadFile: (params: Partial<Pick<Storage, "filename">> & Omit<Storage, "filename" | "data"> & {
@@ -23,36 +26,43 @@ export declare const uploadFile: (params: Partial<Pick<Storage, "filename">> & O
23
26
  }) => Promise<AssetKey>;
24
27
  /**
25
28
  * Lists assets in a collection with optional filtering.
29
+ *
26
30
  * @param {Object} params - The parameters for listing the assets.
27
31
  * @param {string} params.collection - The name of the collection.
28
- * @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
29
32
  * @param {ListParams} [params.filter] - The filter parameters.
33
+ * @param {ReadOptions} [params.options] - Call options controlling certification. Defaults to uncertified reads for performance unless specified.
34
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
30
35
  * @returns {Promise<Assets>} A promise that resolves to the list of assets.
31
36
  */
32
- export declare const listAssets: ({ collection, satellite: satelliteOptions, filter }: {
37
+ export declare const listAssets: ({ collection, filter, satellite: satelliteOptions, options }: {
33
38
  collection: string;
34
- satellite?: SatelliteOptions;
35
39
  filter?: ListParams;
40
+ satellite?: SatelliteOptions;
41
+ options?: ReadOptions;
36
42
  }) => Promise<Assets>;
37
43
  /**
38
44
  * Counts assets in a collection with optional filtering.
45
+ *
39
46
  * @param {Object} params - The parameters for counting the assets.
40
47
  * @param {string} params.collection - The name of the collection.
41
- * @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
42
48
  * @param {ListParams} [params.filter] - The filter parameters for narrowing down the count.
49
+ * @param {ReadOptions} [params.options] - Call options controlling certification. Defaults to uncertified reads for performance unless specified.
50
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
43
51
  * @returns {Promise<bigint>} A promise that resolves to the count of assets as a bigint.
44
52
  */
45
- export declare const countAssets: ({ collection, satellite: satelliteOptions, filter }: {
53
+ export declare const countAssets: ({ collection, filter, satellite: satelliteOptions, options }: {
46
54
  collection: string;
47
- satellite?: SatelliteOptions;
48
55
  filter?: ListParams;
56
+ satellite?: SatelliteOptions;
57
+ options?: ReadOptions;
49
58
  }) => Promise<bigint>;
50
59
  /**
51
60
  * Deletes an asset from the storage.
61
+ *
52
62
  * @param {Object} params - The parameters for deleting the asset.
53
63
  * @param {string} params.collection - The name of the collection.
54
- * @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
55
64
  * @param {string} params.fullPath - The full path of the asset.
65
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
56
66
  * @returns {Promise<void>} A promise that resolves when the asset is deleted.
57
67
  */
58
68
  export declare const deleteAsset: ({ collection, fullPath, satellite }: {
@@ -61,9 +71,10 @@ export declare const deleteAsset: ({ collection, fullPath, satellite }: {
61
71
  } & Pick<AssetKey, "fullPath">) => Promise<void>;
62
72
  /**
63
73
  * Deletes multiple assets from the storage.
74
+ *
64
75
  * @param {Object} params - The parameters for deleting the assets.
65
76
  * @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).
77
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
67
78
  * @returns {Promise<void>} A promise that resolves when the assets are deleted.
68
79
  */
69
80
  export declare const deleteManyAssets: ({ assets, satellite }: {
@@ -71,15 +82,14 @@ export declare const deleteManyAssets: ({ assets, satellite }: {
71
82
  collection: string;
72
83
  } & Pick<AssetKey, "fullPath">)[];
73
84
  satellite?: SatelliteOptions;
74
- } & Pick<AssetKey, "fullPath">) => Promise<void>;
85
+ }) => Promise<void>;
75
86
  /**
76
87
  * Deletes multiple assets from a collection based on filtering criteria.
77
88
  *
78
89
  * @param {Object} params - The parameters for deleting the assets.
79
90
  * @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
91
  * @param {ListParams} [params.filter] - The filter criteria to match assets for deletion.
82
- *
92
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
83
93
  * @returns {Promise<void>} A promise that resolves when the assets matching the filter criteria are deleted.
84
94
  */
85
95
  export declare const deleteFilteredAssets: ({ collection, satellite: satelliteOptions, filter }: {
@@ -89,39 +99,61 @@ export declare const deleteFilteredAssets: ({ collection, satellite: satelliteOp
89
99
  }) => Promise<void>;
90
100
  /**
91
101
  * Retrieves an asset from the storage.
102
+ *
92
103
  * @param {Object} params - The parameters for retrieving the asset.
93
104
  * @param {string} params.collection - The name of the collection.
94
- * @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
95
105
  * @param {string} params.fullPath - The full path of the asset.
106
+ * @param {ReadOptions} [params.options] - Call options controlling certification. Defaults to uncertified reads for performance unless specified.
107
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
96
108
  * @returns {Promise<AssetNoContent | undefined>} A promise that resolves to the asset or undefined if not found.
97
109
  */
98
- export declare const getAsset: ({ satellite, ...rest }: {
110
+ export declare const getAsset: ({ satellite, options, ...rest }: {
99
111
  collection: string;
100
112
  satellite?: SatelliteOptions;
113
+ options?: ReadOptions;
101
114
  } & Pick<AssetKey, "fullPath">) => Promise<AssetNoContent | undefined>;
102
115
  /**
103
116
  * Retrieves multiple assets from the storage.
117
+ *
104
118
  * @param {Object} params - The parameters for retrieving the assets.
105
119
  * @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).
120
+ * @param {ReadOptions} [params.options] - Call options controlling certification. Defaults to uncertified reads for performance unless specified.
121
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
107
122
  * @returns {Promise<Array<AssetNoContent | undefined>>} A promise that resolves to an array of assets or undefined if not found.
108
123
  */
109
- export declare const getManyAssets: ({ satellite, ...rest }: {
124
+ export declare const getManyAssets: ({ satellite, options, ...rest }: {
110
125
  assets: ({
111
126
  collection: string;
112
127
  } & Pick<AssetKey, "fullPath">)[];
113
128
  satellite?: SatelliteOptions;
129
+ options?: ReadOptions;
114
130
  }) => Promise<(AssetNoContent | undefined)[]>;
115
131
  /**
116
- * Generates a download URL for a given asset.
132
+ * Returns a public URL for accessing a specific asset stored on a Satellite.
133
+ *
134
+ * This URL can be used to:
135
+ * - Open the file directly in a browser
136
+ * - Embed the asset in HTML elements like `<img src="...">`, `<video src="...">`, or `<a href="...">`
137
+ * - Programmatically download or display the asset in your application
138
+ *
139
+ * ### Example
140
+ * ```ts
141
+ * const url = downloadUrl({
142
+ * assetKey: {
143
+ * fullPath: '/images/logo.png',
144
+ * }
145
+ * });
117
146
  *
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).
147
+ * // Usage in an <img> tag
148
+ * <img src={url} alt="Logo" />
149
+ * ```
123
150
  *
124
- * @returns {string} The generated download URL.
151
+ * @param {Object} params - Parameters for generating the URL.
152
+ * @param {Object} params.assetKey - Identifies the asset to generate the URL for.
153
+ * @param {string} params.assetKey.fullPath - The full path of the asset (e.g., `/folder/file.jpg`).
154
+ * @param {string} [params.assetKey.token] - Optional access token for accessing protected assets.
155
+ * @param {SatelliteOptions} [params.satellite] - Options to specify a satellite in a NodeJS environment only. In browser environments, the satellite configuration is inherited from the initialization through `initSatellite()`.
156
+ * @returns {string} A full URL pointing to the asset.
125
157
  */
126
158
  export declare const downloadUrl: ({ assetKey: { fullPath, token }, satellite: satelliteOptions }: {
127
159
  assetKey: Pick<Asset, "fullPath" | "token">;
@@ -0,0 +1,4 @@
1
+ import { HttpAgent } from '@dfinity/agent';
2
+ import type { SatelliteContext } from '../types/satellite';
3
+ export type CreateAgentParams = Required<Pick<SatelliteContext, 'identity'>> & Pick<SatelliteContext, 'container'>;
4
+ export declare const createAgent: ({ identity, container }: CreateAgentParams) => Promise<HttpAgent>;