npm package: @junobuild/functions
Description: JavaScript and TypeScript utilities for Juno Serverless Functions
Author: David Dal Busco
Latest version: 0.8.3

[![npm][npm-badge]][npm-badge-url]
[![license][npm-license]][npm-license-url]

[npm-badge]: https://img.shields.io/npm/v/@junobuild/functions
[npm-badge-url]: https://www.npmjs.com/package/@junobuild/functions
[npm-license]: https://img.shields.io/npm/l/@junobuild/functions
[npm-license-url]: https://github.com/junobuild/juno-js/blob/main/LICENSE

# Juno Functions

JavaScript and TypeScript utilities for [Juno] Serverless Functions.

<!-- TSDOC_START -->

### :toolbox: Functions

- [createFunctionSchema](#gear-createfunctionschema)
- [QueryFnSchema](#gear-queryfnschema)
- [QueryFnOrObjectSchema](#gear-queryfnorobjectschema)
- [defineQuery](#gear-definequery)
- [defineQuery](#gear-definequery)
- [defineQuery](#gear-definequery)
- [defineQuery](#gear-definequery)
- [UpdateFnSchema](#gear-updatefnschema)
- [UpdateFnOrObjectSchema](#gear-updatefnorobjectschema)
- [defineUpdate](#gear-defineupdate)
- [defineUpdate](#gear-defineupdate)
- [defineUpdate](#gear-defineupdate)
- [defineUpdate](#gear-defineupdate)
- [HookContextSchema](#gear-hookcontextschema)
- [AssertFunctionSchema](#gear-assertfunctionschema)
- [RunFunctionSchema](#gear-runfunctionschema)
- [DocContextSchema](#gear-doccontextschema)
- [AssertFnSchema](#gear-assertfnschema)
- [AssertFnOrObjectSchema](#gear-assertfnorobjectschema)
- [defineAssert](#gear-defineassert)
- [defineAssert](#gear-defineassert)
- [defineAssert](#gear-defineassert)
- [defineAssert](#gear-defineassert)
- [HookFnSchema](#gear-hookfnschema)
- [HookFnOrObjectSchema](#gear-hookfnorobjectschema)
- [defineHook](#gear-definehook)
- [defineHook](#gear-definehook)
- [defineHook](#gear-definehook)
- [defineHook](#gear-definehook)
- [createListResultsSchema](#gear-createlistresultsschema)
- [decodeDocData](#gear-decodedocdata)
- [encodeDocData](#gear-encodedocdata)
- [normalizeCaller](#gear-normalizecaller)
- [getAdminAccessKeys](#gear-getadminaccesskeys)
- [getAccessKeys](#gear-getaccesskeys)
- [isWriteAccessKey](#gear-iswriteaccesskey)
- [isValidAccessKey](#gear-isvalidaccesskey)
- [isAdminController](#gear-isadmincontroller)
- [setDocStore](#gear-setdocstore)
- [deleteDocStore](#gear-deletedocstore)
- [getDocStore](#gear-getdocstore)
- [listDocsStore](#gear-listdocsstore)
- [countCollectionDocsStore](#gear-countcollectiondocsstore)
- [countDocsStore](#gear-countdocsstore)
- [deleteDocsStore](#gear-deletedocsstore)
- [deleteFilteredDocsStore](#gear-deletefiltereddocsstore)
- [callerIsAdmin](#gear-callerisadmin)
- [callerHasWritePermission](#gear-callerhaswritepermission)
- [callerIsAccessKey](#gear-callerisaccesskey)
- [countCollectionAssetsStore](#gear-countcollectionassetsstore)
- [countAssetsStore](#gear-countassetsstore)
- [setAssetHandler](#gear-setassethandler)
- [deleteAssetStore](#gear-deleteassetstore)
- [deleteAssetsStore](#gear-deleteassetsstore)
- [deleteFilteredAssetsStore](#gear-deletefilteredassetsstore)
- [setAssetTokenStore](#gear-setassettokenstore)
- [getAssetStore](#gear-getassetstore)
- [listAssetsStore](#gear-listassetsstore)
- [getContentChunksStore](#gear-getcontentchunksstore)
- [call](#gear-call)
- [msgCaller](#gear-msgcaller)
- [caller](#gear-caller)
- [httpRequest](#gear-httprequest)
- [canisterSelf](#gear-canisterself)
- [id](#gear-id)
- [satelliteSelf](#gear-satelliteself)
- [time](#gear-time)

#### :gear: createFunctionSchema

Wraps a Zod function schema so that parsing returns the **original function**
instead of Zod's wrapped validator.

## Why?

In Zod v4, `z.function({...})` normally returns a wrapper that validates
both arguments and the return value **every time the function is called**.
If your function's return type is `void | Promise<void>`, Zod tries to
validate it synchronously, which can throw
"Encountered Promise during synchronous parse"
when the implementation is async.

By using `.implement`, we tell Zod: “this is the function that satisfies
the schema.” That way the schema still validates the function shape at
parse time, but the returned value is the **original function** you passed
in — no runtime wrapper, no sync/async mismatch.

Reference:
https://github.com/colinhacks/zod/issues/4143#issuecomment-2845134912

Note: We need the function for this library, see following comment
https://github.com/colinhacks/zod/issues/4143#issuecomment-3335735535

| Function               | Type                                                                                                              |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `createFunctionSchema` | `<T extends z.ZodFunction>(schema: T) => ZodCustom<Parameters<T["implement"]>[0], Parameters<T["implement"]>[0]>` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/utils/zod.utils.ts#L27)

#### :gear: QueryFnSchema

| Function        | Type                                                                                                            |
| --------------- | --------------------------------------------------------------------------------------------------------------- |
| `QueryFnSchema` | `<T extends z.ZodTypeAny>(querySchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodString>], null>, T>` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/query.ts#L66)

#### :gear: QueryFnOrObjectSchema

| Function                | Type                                                                                                                                                                                         |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `QueryFnOrObjectSchema` | `<T extends z.ZodTypeAny>(querySchema: T) => ZodUnion<readonly [T, ZodCustom<$InferInnerFunctionType<ZodTuple<[ZodRecord<ZodString, ZodString>], null>, T>, $InferInnerFunctionType<...>>]>` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/query.ts#L76)

#### :gear: defineQuery

| Function      | Type                                                                                                                                                                                                                                                                                                                               |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineQuery` | `{ <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(query: Query<TArgs, TResult>): QueryDefinition<TArgs, TResult>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(query: QueryFn<...>): (env: Record<...>) => QueryDefinition<...>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(qu...` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/query.ts#L86)

#### :gear: defineQuery

| Function      | Type                                                                                                                                                                                                                                                                                                                               |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineQuery` | `{ <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(query: Query<TArgs, TResult>): QueryDefinition<TArgs, TResult>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(query: QueryFn<...>): (env: Record<...>) => QueryDefinition<...>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(qu...` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/query.ts#L89)

#### :gear: defineQuery

| Function      | Type                                                                                                                                                                                                                                                                                                                               |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineQuery` | `{ <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(query: Query<TArgs, TResult>): QueryDefinition<TArgs, TResult>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(query: QueryFn<...>): (env: Record<...>) => QueryDefinition<...>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(qu...` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/query.ts#L92)

#### :gear: defineQuery

| Function      | Type                                                                                                                                                                                                                                                                                                                               |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineQuery` | `{ <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(query: Query<TArgs, TResult>): QueryDefinition<TArgs, TResult>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(query: QueryFn<...>): (env: Record<...>) => QueryDefinition<...>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(qu...` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/query.ts#L95)

#### :gear: UpdateFnSchema

| Function         | Type                                                                                                             |
| ---------------- | ---------------------------------------------------------------------------------------------------------------- |
| `UpdateFnSchema` | `<T extends z.ZodTypeAny>(updateSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodString>], null>, T>` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/update.ts#L66)

#### :gear: UpdateFnOrObjectSchema

| Function                 | Type                                                                                                                                                                                          |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `UpdateFnOrObjectSchema` | `<T extends z.ZodTypeAny>(updateSchema: T) => ZodUnion<readonly [T, ZodCustom<$InferInnerFunctionType<ZodTuple<[ZodRecord<ZodString, ZodString>], null>, T>, $InferInnerFunctionType<...>>]>` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/update.ts#L76)

#### :gear: defineUpdate

| Function       | Type                                                                                                                                                                                                                                                                                                                               |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineUpdate` | `{ <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(update: Update<TArgs, TResult>): UpdateDefinition<TArgs, TResult>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(update: UpdateFn<...>): (env: Record<...>) => UpdateDefinition<...>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawSha...` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/update.ts#L86)

#### :gear: defineUpdate

| Function       | Type                                                                                                                                                                                                                                                                                                                               |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineUpdate` | `{ <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(update: Update<TArgs, TResult>): UpdateDefinition<TArgs, TResult>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(update: UpdateFn<...>): (env: Record<...>) => UpdateDefinition<...>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawSha...` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/update.ts#L89)

#### :gear: defineUpdate

| Function       | Type                                                                                                                                                                                                                                                                                                                               |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineUpdate` | `{ <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(update: Update<TArgs, TResult>): UpdateDefinition<TArgs, TResult>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(update: UpdateFn<...>): (env: Record<...>) => UpdateDefinition<...>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawSha...` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/update.ts#L92)

#### :gear: defineUpdate

| Function       | Type                                                                                                                                                                                                                                                                                                                               |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineUpdate` | `{ <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(update: Update<TArgs, TResult>): UpdateDefinition<TArgs, TResult>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(update: UpdateFn<...>): (env: Record<...>) => UpdateDefinition<...>; <TArgs extends z.ZodRawShape, TResult extends z.ZodRawSha...` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/update.ts#L95)

#### :gear: HookContextSchema

| Function            | Type                                                                                                                                               |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `HookContextSchema` | `<T extends z.ZodTypeAny>(dataSchema: T) => ZodObject<{ caller: ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>; data: T; }, $strict>` |

References:

- HookContext

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L8)

#### :gear: AssertFunctionSchema

| Function               | Type                                                                                                                                                                    |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AssertFunctionSchema` | `<T extends z.ZodTypeAny>(contextSchema: T) => ZodCustom<$InferInnerFunctionType<ZodTuple<[T], null>, ZodVoid>, $InferInnerFunctionType<ZodTuple<[T], null>, ZodVoid>>` |

References:

- AssertFunction

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L37)

#### :gear: RunFunctionSchema

| Function            | Type                                                                                                                                                                            |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `RunFunctionSchema` | `<T extends z.ZodTypeAny>(contextSchema: T) => ZodCustom<$InferInnerFunctionType<ZodTuple<[T], null>, ZodUnion<[ZodPromise<ZodVoid>, ZodVoid]>>, $InferInnerFunctionType<...>>` |

References:

- RunFunction

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L52)

#### :gear: DocContextSchema

| Function           | Type                                                                                                                 |
| ------------------ | -------------------------------------------------------------------------------------------------------------------- |
| `DocContextSchema` | `<T extends z.ZodTypeAny>(dataSchema: T) => ZodObject<{ collection: ZodString; key: ZodString; data: T; }, $strict>` |

References:

- DocContext

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L17)

#### :gear: AssertFnSchema

| Function         | Type                                                                                                             |
| ---------------- | ---------------------------------------------------------------------------------------------------------------- |
| `AssertFnSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodString>], null>, T>` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/assertions.ts#L97)

#### :gear: AssertFnOrObjectSchema

| Function                 | Type                                                                                                                                                                                          |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AssertFnOrObjectSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodUnion<readonly [T, ZodCustom<$InferInnerFunctionType<ZodTuple<[ZodRecord<ZodString, ZodString>], null>, T>, $InferInnerFunctionType<...>>]>` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/assertions.ts#L104)

#### :gear: defineAssert

| Function       | Type                                                                                                                                                                |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/assertions.ts#L108)

#### :gear: defineAssert

| Function       | Type                                                                                                                                                                |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/assertions.ts#L109)

#### :gear: defineAssert

| Function       | Type                                                                                                                                                                |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/assertions.ts#L110)

#### :gear: defineAssert

| Function       | Type                                                                                                                                                                |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/assertions.ts#L111)

#### :gear: HookFnSchema

| Function       | Type                                                                                                           |
| -------------- | -------------------------------------------------------------------------------------------------------------- |
| `HookFnSchema` | `<T extends z.ZodTypeAny>(hookSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodString>], null>, T>` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/hooks.ts#L171)

#### :gear: HookFnOrObjectSchema

| Function               | Type                                                                                                                                                                                        |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `HookFnOrObjectSchema` | `<T extends z.ZodTypeAny>(hookSchema: T) => ZodUnion<readonly [T, ZodCustom<$InferInnerFunctionType<ZodTuple<[ZodRecord<ZodString, ZodString>], null>, T>, $InferInnerFunctionType<...>>]>` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/hooks.ts#L175)

#### :gear: defineHook

| Function     | Type                                                                                                                                            |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/hooks.ts#L179)

#### :gear: defineHook

| Function     | Type                                                                                                                                            |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/hooks.ts#L180)

#### :gear: defineHook

| Function     | Type                                                                                                                                            |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/hooks.ts#L181)

#### :gear: defineHook

| Function     | Type                                                                                                                                            |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/hooks.ts#L182)

#### :gear: createListResultsSchema

Represents a list result.

| Function                  | Type                                                                                                                                                                                                                                         |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `createListResultsSchema` | `<T extends z.ZodTypeAny>(itemData: T) => ZodObject<{ items: ZodArray<ZodTuple<[ZodString, T], null>>; items_length: ZodBigInt; items_page: ZodOptional<ZodBigInt>; matches_length: ZodBigInt; matches_pages: ZodOptional<...>; }, $strict>` |

References:

- JsListResults

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/list.ts#L128)

#### :gear: decodeDocData

Decodes the raw data of a document into a JavaScript object.

| Function        | Type                      |
| --------------- | ------------------------- |
| `decodeDocData` | `<T>(data: RawData) => T` |

Parameters:

- `data`: - The raw data to be decoded.

Returns:

The parsed JavaScript object.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/serializer.sdk.ts#L11)

#### :gear: encodeDocData

Encodes a JavaScript object into a raw data format to be applied to a document.

| Function        | Type                      |
| --------------- | ------------------------- |
| `encodeDocData` | `<T>(data: T) => RawData` |

Parameters:

- `data`: - The data to be encoded.

Returns:

The serialized raw data.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/serializer.sdk.ts#L21)

#### :gear: normalizeCaller

Normalizes a user ID into a raw `Uint8Array` representation.

| Function          | Type                            |
| ----------------- | ------------------------------- |
| `normalizeCaller` | `(caller: any) => RawPrincipal` |

Parameters:

- `caller`: - The caller identity, either a raw `Uint8Array`
  or a `Principal` instance.

Returns:

The raw user ID as a `Uint8Array`.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/utils/caller.utils.ts#L12)

#### :gear: getAdminAccessKeys

Gets the list of admin access keys from the Satellite.

| Function             | Type               |
| -------------------- | ------------------ |
| `getAdminAccessKeys` | `() => AccessKeys` |

Returns:

The list of admin acces keys.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/access-keys.sdk.ts#L15)

#### :gear: getAccessKeys

Gets the list of access keys from the Satellite.

| Function        | Type               |
| --------------- | ------------------ |
| `getAccessKeys` | `() => AccessKeys` |

Returns:

The list of all access keys.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/access-keys.sdk.ts#L24)

#### :gear: isWriteAccessKey

Checks if the given id exists among the provided access keys.

| Function           | Type                                        |
| ------------------ | ------------------------------------------- |
| `isWriteAccessKey` | `(params: AccessKeyCheckParams) => boolean` |

Parameters:

- `params`: - The parameters including the id
  and the list of access keys to verify against.

Returns:

Whether the id is an access key with write permission.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/access-keys.sdk.ts#L36)

#### :gear: isValidAccessKey

Checks if the given id exists among the provided access keys.

| Function           | Type                                        |
| ------------------ | ------------------------------------------- |
| `isValidAccessKey` | `(params: AccessKeyCheckParams) => boolean` |

Parameters:

- `params`: - The parameters including the id
  and the list of access keys to verify against.

Returns:

Whether the id is an access key.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/access-keys.sdk.ts#L56)

#### :gear: isAdminController

Checks if the given id is an admin among the provided access keys and a controller as known on the Internet Computer.

| Function            | Type                                        |
| ------------------- | ------------------------------------------- |
| `isAdminController` | `(params: AccessKeyCheckParams) => boolean` |

Parameters:

- `params`: - The parameters including the id
  and the list of access keys to verify against.

Returns:

Whether the id is an admin and a controller of the Satellite on the Internet Computer.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/access-keys.sdk.ts#L76)

#### :gear: setDocStore

Stores or updates a document in the datastore.

The data must have been encoded - using encodeDocData - before calling this function.

| Function      | Type                                                   |
| ------------- | ------------------------------------------------------ |
| `setDocStore` | `(params: SetDocStoreParams) => DocContext<DocUpsert>` |

Parameters:

- `params`: - The parameters required to store the document,
  including the caller, collection, key, and document data.

Returns:

The context of the stored or updated document,
including its key, collection, and both the previous and current versions of the document.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L39)

#### :gear: deleteDocStore

Deletes a document from the datastore.

| Function         | Type                                                      |
| ---------------- | --------------------------------------------------------- |
| `deleteDocStore` | `(params: DeleteDocStoreParams) => DocContext<OptionDoc>` |

Parameters:

- `params`: - The parameters required to delete the document,
  including the caller, collection, key, and the expected version of the document.

Returns:

The context of the deleted document,
including its key, collection, and optionally the previous document data if it existed.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L61)

#### :gear: getDocStore

Retrieve a document from the datastore.

| Function      | Type                                       |
| ------------- | ------------------------------------------ |
| `getDocStore` | `(params: GetDocStoreParams) => OptionDoc` |

Parameters:

- `params`: - The parameters required to get the document.

Returns:

The document if found, or undefined if not.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L81)

#### :gear: listDocsStore

Lists documents from the datastore using optional filtering, pagination, and ordering parameters.

| Function        | Type                                            |
| --------------- | ----------------------------------------------- |
| `listDocsStore` | `(params: ListStoreParams) => ListResults<Doc>` |

Parameters:

- `params`: - The parameters required to perform the list operation.

Returns:

A list result containing matching documents and pagination metadata.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L101)

#### :gear: countCollectionDocsStore

Counts the number of documents in a specific collection.

| Function                   | Type                                   |
| -------------------------- | -------------------------------------- |
| `countCollectionDocsStore` | `(params: CollectionParams) => bigint` |

Parameters:

- `params`: - The parameters required to count documents in the collection.

Returns:

The total number of documents in the specified collection.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L121)

#### :gear: countDocsStore

Counts the number of documents in a collection matching specific filters and owned by a specific caller.

| Function         | Type                                  |
| ---------------- | ------------------------------------- |
| `countDocsStore` | `(params: ListStoreParams) => bigint` |

Parameters:

- `params`: - The parameters required to perform the filtered count.

Returns:

The number of documents that match the provided filters.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L139)

#### :gear: deleteDocsStore

Delete documents in a specific collection of the Datastore.

| Function          | Type                                 |
| ----------------- | ------------------------------------ |
| `deleteDocsStore` | `(params: CollectionParams) => void` |

Parameters:

- `params`: - The parameters required to delete documents in the collection.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L157)

#### :gear: deleteFilteredDocsStore

Delete documents in a collection matching specific filters and owned by a specific caller.

| Function                  | Type                                                   |
| ------------------------- | ------------------------------------------------------ |
| `deleteFilteredDocsStore` | `(params: ListStoreParams) => DocContext<OptionDoc>[]` |

Parameters:

- `params`: - The parameters required to perform the filtered deletion.

Returns:

The context resulting of the deletion of documents that match the provided filters.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L175)

#### :gear: callerIsAdmin

Guard that succeeds if the caller is an admin access key of this satellite.

| Function        | Type         |
| --------------- | ------------ |
| `callerIsAdmin` | `() => void` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/guards.sdk.ts#L10)

#### :gear: callerHasWritePermission

Guard that succeeds if the caller is an access key with write permission.

| Function                   | Type               |
| -------------------------- | ------------------ |
| `callerHasWritePermission` | `() => AccessKeys` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/guards.sdk.ts#L21)

#### :gear: callerIsAccessKey

Guard that succeeds if the caller is any recognized access key of this satellite.

| Function            | Type               |
| ------------------- | ------------------ |
| `callerIsAccessKey` | `() => AccessKeys` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/guards.sdk.ts#L31)

#### :gear: countCollectionAssetsStore

Counts the number of assets in a specific collection.

| Function                     | Type                                   |
| ---------------------------- | -------------------------------------- |
| `countCollectionAssetsStore` | `(params: CollectionParams) => bigint` |

Parameters:

- `params`: - The parameters required to count assets in the collection.

Returns:

The total number of assets in the specified collection.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L37)

#### :gear: countAssetsStore

Counts the number of assets in a collection matching specific filters and owned by a specific caller.

| Function           | Type                                  |
| ------------------ | ------------------------------------- |
| `countAssetsStore` | `(params: ListStoreParams) => bigint` |

Parameters:

- `params`: - The parameters required to perform the filtered count.

Returns:

The number of assets that match the provided filters.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L55)

#### :gear: setAssetHandler

Sets or updates an asset in the storage.

| Function          | Type                                      |
| ----------------- | ----------------------------------------- |
| `setAssetHandler` | `(params: SetAssetHandlerParams) => void` |

Parameters:

- `params`: - The parameters required to set or update an asset.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L73)

#### :gear: deleteAssetStore

Deletes an asset from the storage.

| Function           | Type                                           |
| ------------------ | ---------------------------------------------- |
| `deleteAssetStore` | `(params: GetAssetStoreParams) => OptionAsset` |

Parameters:

- `params`: - The parameters required to delete the asset.

Returns:

The potentially deleted asset.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L91)

#### :gear: deleteAssetsStore

Delete assets in a specific collection of the Storage.

| Function            | Type                                 |
| ------------------- | ------------------------------------ |
| `deleteAssetsStore` | `(params: CollectionParams) => void` |

Parameters:

- `params`: - The parameters required to delete assets in the collection.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L109)

#### :gear: deleteFilteredAssetsStore

Delete assets in a collection matching specific filters and owned by a specific caller.

| Function                    | Type                                         |
| --------------------------- | -------------------------------------------- |
| `deleteFilteredAssetsStore` | `(params: ListStoreParams) => OptionAsset[]` |

Parameters:

- `params`: - The parameters required to perform the filtered deletion.

Returns:

The potential asset resulting of the deletion that match the provided filters.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L127)

#### :gear: setAssetTokenStore

Set or update an access token for an asset in a collection's store.

| Function             | Type                                         |
| -------------------- | -------------------------------------------- |
| `setAssetTokenStore` | `(params: SetAssetTokenStoreParams) => void` |

Parameters:

- `params`: - The parameters required to set the token of the asset.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L147)

#### :gear: getAssetStore

Retrieve an asset from the storage.

| Function        | Type                                           |
| --------------- | ---------------------------------------------- |
| `getAssetStore` | `(params: GetAssetStoreParams) => OptionAsset` |

Parameters:

- `params`: - The parameters required to get the asset.

Returns:

The asset if found, or undefined if not.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L167)

#### :gear: listAssetsStore

Lists assets (without content) from the storage using optional filtering, pagination, and ordering parameters.

| Function          | Type                                                       |
| ----------------- | ---------------------------------------------------------- |
| `listAssetsStore` | `(params: ListStoreParams) => ListResults<AssetNoContent>` |

Parameters:

- `params`: - The parameters required to perform the list operation.

Returns:

A list result containing matching assets and pagination metadata.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L187)

#### :gear: getContentChunksStore

Retrieves content chunks of an asset.

This function fetches a content chunk of a given asset encoding using the specified parameters.

| Function                | Type                                                         |
| ----------------------- | ------------------------------------------------------------ |
| `getContentChunksStore` | `(params: GetContentChunksStoreParams) => Blob or undefined` |

Parameters:

- `params`: - The parameters including encoding, chunk index, and memory type.

Returns:

The content chunk if found, or `undefined` if not.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/storage.sdk.ts#L209)

#### :gear: call

Makes an asynchronous call to a canister on the Internet Computer.

This function encodes the provided arguments using Candid, performs the canister call,
and decodes the response based on the expected result types.

| Function | Type                                    |
| -------- | --------------------------------------- |
| `call`   | `<T>(params: CallParams) => Promise<T>` |

Parameters:

- `params`: - The parameters required for the canister call

Returns:

A promise resolving to the decoded result of the call.
Returns `undefined` if the canister response is empty.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/call.ic-cdk.ts#L20)

#### :gear: msgCaller

Retrieves the caller's Principal ID.

This function is a JavaScript binding for the Rust function
[`ic_cdk::api::msg_caller()`](https://docs.rs/ic-cdk/latest/ic_cdk/api/fn.msg_caller.html), which returns
the Principal of the caller of the current call.

| Function    | Type              |
| ----------- | ----------------- |
| `msgCaller` | `() => Principal` |

Returns:

The Principal ID of the caller.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/caller.ic-cdk.ts#L12)

#### :gear: caller

| Function | Type              |
| -------- | ----------------- |
| `caller` | `() => Principal` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/caller.ic-cdk.ts#L21)

#### :gear: httpRequest

Performs an HTTP request from a Juno serverless function.

| Function      | Type                                                    |
| ------------- | ------------------------------------------------------- |
| `httpRequest` | `(args: HttpRequestArgs) => Promise<HttpRequestResult>` |

Parameters:

- `args`: - The HTTP request parameters

Returns:

A promise resolving to the HTTP response.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/http-request.ic-cdk.ts#L17)

#### :gear: canisterSelf

Retrieves the Satellite's Principal ID.

This function is a JavaScript binding for the Rust function
[`ic_cdk::api::canister_self()`](https://docs.rs/ic-cdk/latest/ic_cdk/api/fn.canister_self.html), which returns
the Principal of the executing canister.

| Function       | Type              |
| -------------- | ----------------- |
| `canisterSelf` | `() => Principal` |

Returns:

The Principal ID of the Satellite.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/id.ic-cdk.ts#L12)

#### :gear: id

| Function | Type              |
| -------- | ----------------- |
| `id`     | `() => Principal` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/id.ic-cdk.ts#L24)

#### :gear: satelliteSelf

Retrieves the Satellite's Principal ID.

| Function        | Type              |
| --------------- | ----------------- |
| `satelliteSelf` | `() => Principal` |

Returns:

The Principal ID of the Satellite.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/id.ic-cdk.ts#L31)

#### :gear: time

Gets current timestamp, in nanoseconds since the epoch (1970-01-01)

This function is a JavaScript binding for the Rust function
[`ic_cdk::time()`](https://docs.rs/ic-cdk/latest/ic_cdk/api/fn.time.html), which returns
the system time publicly exposed and verified part of the IC state tree

| Function | Type           |
| -------- | -------------- |
| `time`   | `() => bigint` |

Returns:

The current timestamp.

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/time.ic-cdk.ts#L10)

### :wrench: Constants

- [SatelliteEnvSchema](#gear-satelliteenvschema)
- [JUNO_FUNCTION_TYPE](#gear-juno_function_type)
- [CustomFunctionGuardSchema](#gear-customfunctionguardschema)
- [CustomFunctionWithArgsAndResultSchema](#gear-customfunctionwithargsandresultschema)
- [CustomFunctionWithArgsSchema](#gear-customfunctionwithargsschema)
- [CustomFunctionWithResultSchema](#gear-customfunctionwithresultschema)
- [CustomFunctionWithoutArgsAndResultSchema](#gear-customfunctionwithoutargsandresultschema)
- [CustomFunctionSchema](#gear-customfunctionschema)
- [QuerySchema](#gear-queryschema)
- [UpdateSchema](#gear-updateschema)
- [RawPrincipalSchema](#gear-rawprincipalschema)
- [TimestampSchema](#gear-timestampschema)
- [VersionSchema](#gear-versionschema)
- [RawUserIdSchema](#gear-rawuseridschema)
- [UserIdSchema](#gear-useridschema)
- [CollectionSchema](#gear-collectionschema)
- [KeySchema](#gear-keyschema)
- [DescriptionSchema](#gear-descriptionschema)
- [CollectionsSchema](#gear-collectionsschema)
- [RawDataSchema](#gear-rawdataschema)
- [DocSchema](#gear-docschema)
- [OptionDocSchema](#gear-optiondocschema)
- [SetDocSchema](#gear-setdocschema)
- [DelDocSchema](#gear-deldocschema)
- [DocUpsertSchema](#gear-docupsertschema)
- [DocAssertSetSchema](#gear-docassertsetschema)
- [DocAssertDeleteSchema](#gear-docassertdeleteschema)
- [OnSetDocContextSchema](#gear-onsetdoccontextschema)
- [OnSetManyDocsContextSchema](#gear-onsetmanydocscontextschema)
- [OnDeleteDocContextSchema](#gear-ondeletedoccontextschema)
- [OnDeleteManyDocsContextSchema](#gear-ondeletemanydocscontextschema)
- [OnDeleteFilteredDocsContextSchema](#gear-ondeletefiltereddocscontextschema)
- [AssertSetDocContextSchema](#gear-assertsetdoccontextschema)
- [AssertDeleteDocContextSchema](#gear-assertdeletedoccontextschema)
- [HeaderFieldsSchema](#gear-headerfieldsschema)
- [BlobSchema](#gear-blobschema)
- [AssetKeySchema](#gear-assetkeyschema)
- [AssetEncodingSchema](#gear-assetencodingschema)
- [AssetSchema](#gear-assetschema)
- [AssetNoContentSchema](#gear-assetnocontentschema)
- [BatchSchema](#gear-batchschema)
- [CommitBatchSchema](#gear-commitbatchschema)
- [FullPathSchema](#gear-fullpathschema)
- [AssetAccessTokenSchema](#gear-assetaccesstokenschema)
- [OptionAssetSchema](#gear-optionassetschema)
- [AssetAssertUploadSchema](#gear-assetassertuploadschema)
- [OnUploadAssetContextSchema](#gear-onuploadassetcontextschema)
- [OnDeleteAssetContextSchema](#gear-ondeleteassetcontextschema)
- [OnDeleteManyAssetsContextSchema](#gear-ondeletemanyassetscontextschema)
- [OnDeleteFilteredAssetsContextSchema](#gear-ondeletefilteredassetscontextschema)
- [AssertUploadAssetContextSchema](#gear-assertuploadassetcontextschema)
- [AssertDeleteAssetContextSchema](#gear-assertdeleteassetcontextschema)
- [AssertSetDocSchema](#gear-assertsetdocschema)
- [AssertDeleteDocSchema](#gear-assertdeletedocschema)
- [AssertUploadAssetSchema](#gear-assertuploadassetschema)
- [AssertDeleteAssetSchema](#gear-assertdeleteassetschema)
- [AssertSchema](#gear-assertschema)
- [OnSetDocSchema](#gear-onsetdocschema)
- [OnSetManyDocsSchema](#gear-onsetmanydocsschema)
- [OnDeleteDocSchema](#gear-ondeletedocschema)
- [OnDeleteManyDocsSchema](#gear-ondeletemanydocsschema)
- [OnDeleteFilteredDocsSchema](#gear-ondeletefiltereddocsschema)
- [OnUploadAssetSchema](#gear-onuploadassetschema)
- [OnDeleteAssetSchema](#gear-ondeleteassetschema)
- [OnDeleteManyAssetsSchema](#gear-ondeletemanyassetsschema)
- [OnDeleteFilteredAssetsSchema](#gear-ondeletefilteredassetsschema)
- [HookSchema](#gear-hookschema)
- [TimestampMatcherSchema](#gear-timestampmatcherschema)
- [ListMatcherSchema](#gear-listmatcherschema)
- [ListPaginateSchema](#gear-listpaginateschema)
- [ListOrderFieldSchema](#gear-listorderfieldschema)
- [ListOrderSchema](#gear-listorderschema)
- [ListParamsSchema](#gear-listparamsschema)
- [AccessKeyScopeSchema](#gear-accesskeyscopeschema)
- [AccessKeyKindSchema](#gear-accesskeykindschema)
- [MetadataSchema](#gear-metadataschema)
- [AccessKeySchema](#gear-accesskeyschema)
- [AccessKeyRecordSchema](#gear-accesskeyrecordschema)
- [AccessKeysSchema](#gear-accesskeysschema)
- [AccessKeyCheckParamsSchema](#gear-accesskeycheckparamsschema)
- [CollectionParamsSchema](#gear-collectionparamsschema)
- [ListStoreParamsSchema](#gear-liststoreparamsschema)
- [GetDocStoreParamsSchema](#gear-getdocstoreparamsschema)
- [SetDocStoreParamsSchema](#gear-setdocstoreparamsschema)
- [DeleteDocStoreParamsSchema](#gear-deletedocstoreparamsschema)
- [CountCollectionDocsStoreParamsSchema](#gear-countcollectiondocsstoreparamsschema)
- [CountDocsStoreParamsSchema](#gear-countdocsstoreparamsschema)
- [ListDocsStoreParamsSchema](#gear-listdocsstoreparamsschema)
- [DeleteDocsStoreParamsSchema](#gear-deletedocsstoreparamsschema)
- [DeleteFilteredDocsStoreParamsSchema](#gear-deletefiltereddocsstoreparamsschema)
- [MemorySchema](#gear-memoryschema)
- [GetAssetStoreParamsSchema](#gear-getassetstoreparamsschema)
- [CountCollectionAssetsStoreParamsSchema](#gear-countcollectionassetsstoreparamsschema)
- [CountAssetsStoreParamsSchema](#gear-countassetsstoreparamsschema)
- [SetAssetHandlerParamsSchema](#gear-setassethandlerparamsschema)
- [DeleteAssetsStoreParamsSchema](#gear-deleteassetsstoreparamsschema)
- [DeleteFilteredAssetsStoreParamsSchema](#gear-deletefilteredassetsstoreparamsschema)
- [DeleteAssetStoreParamsSchema](#gear-deleteassetstoreparamsschema)
- [SetAssetTokenStoreParamsSchema](#gear-setassettokenstoreparamsschema)
- [ListAssetsStoreParamsSchema](#gear-listassetsstoreparamsschema)
- [GetContentChunksStoreParamsSchema](#gear-getcontentchunksstoreparamsschema)
- [IDLTypeSchema](#gear-idltypeschema)
- [CallArgSchema](#gear-callargschema)
- [CallArgsSchema](#gear-callargsschema)
- [CallResultSchema](#gear-callresultschema)
- [CallParamsSchema](#gear-callparamsschema)
- [HttpHeaderSchema](#gear-httpheaderschema)
- [HttpMethodSchema](#gear-httpmethodschema)
- [HttpRequestArgsSchema](#gear-httprequestargsschema)
- [HttpRequestResultSchema](#gear-httprequestresultschema)
- [TransformArgsSchema](#gear-transformargsschema)

#### :gear: SatelliteEnvSchema

| Constant             | Type                              |
| -------------------- | --------------------------------- |
| `SatelliteEnvSchema` | `ZodRecord<ZodString, ZodString>` |

References:

- SatelliteEnv

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/satellite.env.ts#L6)

#### :gear: JUNO_FUNCTION_TYPE

Internal constant used by Juno's tooling to discover serverless functions.
Not intended for direct use by developers.

| Constant             | Type                                                                                      |
| -------------------- | ----------------------------------------------------------------------------------------- |
| `JUNO_FUNCTION_TYPE` | `{ readonly QUERY: "__juno_function_query"; readonly UPDATE: "__juno_function_update"; }` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/constants.ts#L5)

#### :gear: CustomFunctionGuardSchema

| Constant                    | Type                                                                                                                |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `CustomFunctionGuardSchema` | `ZodCustom<$InferInnerFunctionType<$ZodFunctionArgs, ZodVoid>, $InferInnerFunctionType<$ZodFunctionArgs, ZodVoid>>` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/schemas/function.ts#L15)

#### :gear: CustomFunctionWithArgsAndResultSchema

| Constant                                | Type                                                                                                                                                 |
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `CustomFunctionWithArgsAndResultSchema` | `ZodObject<{ args: ZodCustom<ZodObject<$ZodLooseShape, $strip>, ZodObject<$ZodLooseShape, $strip>>; ... 4 more ...; type: ZodEnum<...>; }, $strict>` |

References:

- CustomFunctionWithArgsAndResult

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/schemas/function.ts#L32)

#### :gear: CustomFunctionWithArgsSchema

| Constant                       | Type                                                                                                                                                                                                             |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `CustomFunctionWithArgsSchema` | `ZodObject<{ args: ZodCustom<ZodObject<$ZodLooseShape, $strip>, ZodObject<$ZodLooseShape, $strip>>; handler: ZodCustom<...>; guard: ZodOptional<...>; hidden: ZodOptional<...>; type: ZodEnum<...>; }, $strict>` |

References:

- CustomFunctionWithArgs

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/schemas/function.ts#L48)

#### :gear: CustomFunctionWithResultSchema

| Constant                         | Type                                                                                                                                                                                                               |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `CustomFunctionWithResultSchema` | `ZodObject<{ result: ZodCustom<ZodObject<$ZodLooseShape, $strip>, ZodObject<$ZodLooseShape, $strip>>; handler: ZodCustom<...>; guard: ZodOptional<...>; hidden: ZodOptional<...>; type: ZodEnum<...>; }, $strict>` |

References:

- CustomFunctionWithResult

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/schemas/function.ts#L63)

#### :gear: CustomFunctionWithoutArgsAndResultSchema

| Constant                                   | Type                                                                                                                                                                                                                                               |
| ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `CustomFunctionWithoutArgsAndResultSchema` | `ZodObject<{ handler: ZodCustom<$InferInnerFunctionType<ZodTuple<[], null>, ZodUnion<readonly [ZodVoid, ZodPromise<ZodVoid>]>>, $InferInnerFunctionType<...>>; guard: ZodOptional<...>; hidden: ZodOptional<...>; type: ZodEnum<...>; }, $strict>` |

References:

- CustomFunctionWithoutArgsAndResult

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/schemas/function.ts#L78)

#### :gear: CustomFunctionSchema

| Constant               | Type                                                                                                                                                                                                                      |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `CustomFunctionSchema` | `ZodUnion<readonly [ZodObject<{ args: ZodCustom<ZodObject<$ZodLooseShape, $strip>, ZodObject<$ZodLooseShape, $strip>>; ... 4 more ...; type: ZodEnum<...>; }, $strict>, ZodObject<...>, ZodObject<...>, ZodObject<...>]>` |

References:

- CustomFunction

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/schemas/function.ts#L92)

#### :gear: QuerySchema

| Constant      | Type                                                                                                                                                                                                                                                                                                                               |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `QuerySchema` | `ZodUnion<readonly [ZodObject<{ type: ZodLiteral<"__juno_function_query">; args: ZodCustom<ZodObject<$ZodLooseShape, $strip>, ZodObject<$ZodLooseShape, $strip>>; result: ZodCustom<...>; handler: ZodCustom<...>; guard: ZodOptional<...>; hidden: ZodOptional<...>; }, $strict>, ZodObject<...>, ZodObject<...>, ZodObject<....` |

References:

- Query

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/query.ts#L23)

#### :gear: UpdateSchema

| Constant       | Type                                                                                                                                                                                                                                                                                                                               |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `UpdateSchema` | `ZodUnion<readonly [ZodObject<{ type: ZodLiteral<"__juno_function_update">; args: ZodCustom<ZodObject<$ZodLooseShape, $strip>, ZodObject<$ZodLooseShape, $strip>>; result: ZodCustom<...>; handler: ZodCustom<...>; guard: ZodOptional<...>; hidden: ZodOptional<...>; }, $strict>, ZodObject<...>, ZodObject<...>, ZodObject<...` |

References:

- Update

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/functions/update.ts#L23)

#### :gear: RawPrincipalSchema

| Constant             | Type                                                          |
| -------------------- | ------------------------------------------------------------- |
| `RawPrincipalSchema` | `ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>` |

References:

- RawPrincipal

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/principal.ts#L6)

#### :gear: TimestampSchema

| Constant          | Type        |
| ----------------- | ----------- |
| `TimestampSchema` | `ZodBigInt` |

References:

- Timestamp

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/satellite.ts#L8)

#### :gear: VersionSchema

| Constant        | Type        |
| --------------- | ----------- |
| `VersionSchema` | `ZodBigInt` |

References:

- Version

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/satellite.ts#L20)

#### :gear: RawUserIdSchema

| Constant          | Type                                                          |
| ----------------- | ------------------------------------------------------------- |
| `RawUserIdSchema` | `ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>` |

References:

- RawUserId

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/satellite.ts#L32)

#### :gear: UserIdSchema

| Constant       | Type                                                   |
| -------------- | ------------------------------------------------------ |
| `UserIdSchema` | `ZodPipe<ZodCustom<any, any>, ZodTransform<any, any>>` |

References:

- UserId

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/satellite.ts#L44)

#### :gear: CollectionSchema

| Constant           | Type        |
| ------------------ | ----------- |
| `CollectionSchema` | `ZodString` |

References:

- Collection

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/satellite.ts#L56)

#### :gear: KeySchema

| Constant    | Type        |
| ----------- | ----------- |
| `KeySchema` | `ZodString` |

References:

- Key

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/satellite.ts#L66)

#### :gear: DescriptionSchema

| Constant            | Type        |
| ------------------- | ----------- |
| `DescriptionSchema` | `ZodString` |

References:

- Description

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/satellite.ts#L76)

#### :gear: CollectionsSchema

| Constant