@junobuild/functions 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["src/hooks/assertions.ts", "src/utils/zod.utils.ts", "src/hooks/schemas/collections.ts", "src/hooks/schemas/context.ts", "src/hooks/schemas/db/context.ts", "src/hooks/schemas/db/payload.ts", "src/hooks/schemas/satellite.env.ts", "src/hooks/schemas/storage/context.ts", "src/hooks/schemas/storage/payload.ts", "src/hooks/hooks.ts", "src/polyfills/console.polyfill.ts", "src/polyfills/random.polyfill.ts"],
4
- "sourcesContent": ["import * as z from 'zod/v4';\nimport {createFunctionSchema} from '../utils/zod.utils';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type AssertFunction, AssertFunctionSchema} from './schemas/context';\nimport {\n type AssertDeleteDocContext,\n AssertDeleteDocContextSchema,\n type AssertSetDocContext,\n AssertSetDocContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n type AssertDeleteAssetContext,\n AssertDeleteAssetContextSchema,\n type AssertUploadAssetContext,\n AssertUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnAssert\n */\nconst OnAssertSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the assertion is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {void} Resolves when the assertion completes.\n */\n assert: AssertFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining assertions related to collections.\n *\n * @template T - The type of context passed to the assertions when triggered.\n */\nexport type OnAssert<T> = Collections & {\n assert: AssertFunction<T>;\n};\n\n/**\n * @see AssertSetDoc\n */\nexport const AssertSetDocSchema = OnAssertSchema(AssertSetDocContextSchema);\n\n/**\n * An assertion that runs when a document is created or updated.\n */\nexport type AssertSetDoc = OnAssert<AssertSetDocContext>;\n\n/**\n * @see AssertDeleteDoc\n */\nexport const AssertDeleteDocSchema = OnAssertSchema(AssertDeleteDocContextSchema);\n\n/**\n * An assertion that runs when a document is deleted.\n */\nexport type AssertDeleteDoc = OnAssert<AssertDeleteDocContext>;\n\n/**\n * @see AssertUploadAsset\n */\nexport const AssertUploadAssetSchema = OnAssertSchema(AssertUploadAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is uploaded.\n */\nexport type AssertUploadAsset = OnAssert<AssertUploadAssetContext>;\n\n/**\n * @see AssertDeleteAsset\n */\nexport const AssertDeleteAssetSchema = OnAssertSchema(AssertDeleteAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is deleted.\n */\nexport type AssertDeleteAsset = OnAssert<AssertDeleteAssetContext>;\n\n/**\n * @see Assert\n */\nexport const AssertSchema = z.union([\n AssertSetDocSchema,\n AssertDeleteDocSchema,\n AssertUploadAssetSchema,\n AssertDeleteAssetSchema\n]);\n\n/**\n * All assertions definitions.\n */\nexport type Assert = AssertSetDoc | AssertDeleteDoc | AssertUploadAsset | AssertDeleteAsset;\n\nexport const AssertFnSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.function({\n input: z.tuple([SatelliteEnvSchema]),\n output: assertSchema\n });\nexport type AssertFn<T extends Assert> = (assert: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const AssertFnOrObjectSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.union([assertSchema, createFunctionSchema(AssertFnSchema(assertSchema))]);\nexport type AssertFnOrObject<T extends Assert> = T | AssertFn<T>;\n\nexport function defineAssert<T extends Assert>(assert: T): T;\nexport function defineAssert<T extends Assert>(assert: AssertFn<T>): AssertFn<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T> {\n return assert;\n}\n", "import * as z from 'zod/v4';\n\n// TODO: Workaround source: https://github.com/colinhacks/zod/issues/4143#issuecomment-2845134912\nexport const createFunctionSchema = <T extends z.core.$ZodFunction>(schema: T) =>\n z.custom<Parameters<T['implement']>[0]>((fn) =>\n schema.implement(fn as Parameters<T['implement']>[0])\n );\n", "import * as z from 'zod/v4';\nimport type {Collection} from '../../schemas/satellite';\n\n/**\n * @see Collections\n */\nexport const CollectionsSchema = z\n .object({\n collections: z.array(z.string()).readonly()\n })\n .strict();\n\n/**\n * Defines the collections where a hook or assertion should run.\n */\nexport interface Collections {\n /**\n * An array of collection names where the hook or assertion will run.\n * If empty, no hooks or assertions are triggered.\n */\n collections: readonly Collection[];\n}\n", "import * as z from 'zod/v4';\nimport {type RawUserId, RawUserIdSchema} from '../../schemas/satellite';\nimport {createFunctionSchema} from '../../utils/zod.utils';\n\n/**\n * @see HookContext\n */\nexport const HookContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n caller: RawUserIdSchema,\n data: dataSchema\n };\n\n return z.strictObject(schemaShape);\n};\n\n/**\n * Represents the context provided to hooks, containing information about the caller and related data.\n *\n * @template T - The type of data associated with the hook.\n */\nexport interface HookContext<T> {\n /**\n * The user who originally triggered the function that in turn triggered the hook.\n */\n caller: RawUserId;\n\n /**\n * The data associated with the hook execution.\n */\n data: T;\n}\n\n/**\n * @see AssertFunction\n */\nexport const AssertFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n createFunctionSchema(z.function({input: z.tuple([contextSchema]), output: z.void()}));\n\n/**\n * Defines the `assert` function schema for assertions.\n *\n * The function takes a context argument and returns `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type AssertFunction<T> = (context: T) => void;\n\n/**\n * @see RunFunction\n */\nexport const RunFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n createFunctionSchema(\n z.function({input: z.tuple([contextSchema]), output: z.promise(z.void()).or(z.void())})\n );\n\n/**\n * Defines the `run` function schema for hooks.\n *\n * The function takes a context argument and returns either a `Promise<void>` or `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type RunFunction<T> = (context: T) => void | Promise<void>;\n", "import * as z from 'zod/v4';\nimport {DocSchema, type OptionDoc} from '../../../schemas/db';\nimport {type Collection, CollectionSchema, type Key, KeySchema} from '../../../schemas/satellite';\nimport {type HookContext, HookContextSchema} from '../context';\nimport {\n type DocAssertDelete,\n DocAssertDeleteSchema,\n type DocAssertSet,\n DocAssertSetSchema,\n type DocUpsert,\n DocUpsertSchema\n} from './payload';\n\n/**\n * @see DocContext\n */\nexport const DocContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n collection: CollectionSchema,\n key: KeySchema,\n data: dataSchema\n };\n\n return z.strictObject(schemaShape);\n};\n\n/**\n * Represents the context of a document operation within a collection.\n *\n * @template T - The type of data associated with the document.\n */\nexport interface DocContext<T> {\n /**\n * The name of the collection where the document is stored.\n */\n collection: Collection;\n\n /**\n * The key identifying the document within the collection.\n */\n key: Key;\n\n /**\n * The data associated with the document operation.\n */\n data: T;\n}\n\n/**\n * @see OnSetDocContext\n */\nexport const OnSetDocContextSchema = HookContextSchema(DocContextSchema(DocUpsertSchema));\n\n/**\n * The context provided to the `onSetDoc` hook.\n *\n * This context contains information about the document being created or updated,\n * along with details about the user who triggered the operation.\n */\nexport type OnSetDocContext = HookContext<DocContext<DocUpsert>>;\n\n/**\n * @see OnSetManyDocsContext\n */\nexport const OnSetManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocUpsertSchema))\n);\n\n/**\n * The context provided to the `onSetManyDocs` hook.\n *\n * This context contains information about multiple documents being created or updated\n * in a single operation, along with details about the user who triggered it.\n */\nexport type OnSetManyDocsContext = HookContext<DocContext<DocUpsert>[]>;\n\n/**\n * @see OnDeleteDocContext\n */\nexport const OnDeleteDocContextSchema = HookContextSchema(DocContextSchema(DocSchema.optional()));\n\n/**\n * The context provided to the `onDeleteDoc` hook.\n *\n * This context contains information about a single document being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteDocContext = HookContext<DocContext<OptionDoc>>;\n\n/**\n * @see OnDeleteManyDocsContext\n */\nexport const OnDeleteManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteManyDocs` hook.\n *\n * This context contains information about multiple documents being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see OnDeleteFilteredDocsContext\n */\nexport const OnDeleteFilteredDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteFilteredDocs` hook.\n *\n * This context contains information about documents deleted as a result of a filter,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see AssertSetDocContext\n */\nexport const AssertSetDocContextSchema = HookContextSchema(DocContextSchema(DocAssertSetSchema));\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is created or updated. If validation fails, the developer should throw an error.\n */\nexport type AssertSetDocContext = HookContext<DocContext<DocAssertSet>>;\n\n/**\n * @see AssertDeleteDocContext\n */\nexport const AssertDeleteDocContextSchema = HookContextSchema(\n DocContextSchema(DocAssertDeleteSchema)\n);\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteDocContext = HookContext<DocContext<DocAssertDelete>>;\n", "import * as z from 'zod/v4';\nimport {\n type DelDoc,\n DelDocSchema,\n type Doc,\n DocSchema,\n type SetDoc,\n SetDocSchema\n} from '../../../schemas/db';\n\n/**\n * @see DocUpsert\n */\nexport const DocUpsertSchema = z\n .object({\n before: DocSchema.optional(),\n after: DocSchema\n })\n .strict();\n\n/**\n * Represents a document update operation.\n *\n * This is used in hooks where a document is either being created or updated.\n */\nexport interface DocUpsert {\n /**\n * The previous version of the document before the update.\n * Undefined if this is a new document.\n */\n before?: Doc;\n\n /**\n * The new version of the document after the update.\n */\n after: Doc;\n}\n/**\n * @see DocAssertSet\n */\nexport const DocAssertSetSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: SetDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before setting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertSet {\n /**\n * The current version of the document before the operation.\n * Undefined if this is a new document.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: SetDoc;\n}\n\n/**\n * @see DocAssertDelete\n */\nexport const DocAssertDeleteSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: DelDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before deleting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertDelete {\n /**\n * The current version of the document before the operation.\n * Undefined if the document does not exist.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: DelDoc;\n}\n", "import * as z from 'zod/v4';\n\n/**\n * @see SatelliteEnv\n */\nexport const SatelliteEnvSchema = z.record(z.string(), z.string());\n\n/**\n * Placeholder for future environment-specific configurations.\n *\n * Currently unused, but it may support features such as:\n * - Defining the execution mode (e.g., staging or production).\n * - Providing environment-specific values like `ckBtcLedgerId` for test or production.\n */\nexport type SatelliteEnv = z.infer<typeof SatelliteEnvSchema>;\n", "import * as z from 'zod/v4';\nimport {AssetSchema, type Asset} from '../../../schemas/storage';\nimport {HookContextSchema, type HookContext} from '../context';\nimport {AssetAssertUploadSchema, type AssetAssertUpload} from './payload';\n\n/**\n * @see OnUploadAssetContext\n */\nexport const OnUploadAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `onUploadAsset` hook.\n *\n * This context contains information about the asset that was uploaded.\n */\nexport type OnUploadAssetContext = HookContext<Asset>;\n\n/**\n * @see OnDeleteAssetContext\n */\nexport const OnDeleteAssetContextSchema = HookContextSchema(AssetSchema.optional());\n\n/**\n * Context for the `onDeleteAsset` hook.\n *\n * This context contains information about a single asset being deleted, along with details about the user who triggered the operation.\n *\n * If undefined, the asset did not exist.\n */\nexport type OnDeleteAssetContext = HookContext<Asset | undefined>;\n\n/**\n * @see OnDeleteManyAssetsContext\n */\nexport const OnDeleteManyAssetsContextSchema = HookContextSchema(z.array(AssetSchema.optional()));\n\n/**\n * Context for the `onDeleteManyAssets` hook.\n *\n * This context contains information about multiple assets being potentially deleted, along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see OnDeleteFilteredAssetsContext\n */\nexport const OnDeleteFilteredAssetsContextSchema = HookContextSchema(\n z.array(AssetSchema.optional())\n);\n\n/**\n * Context for the `onDeleteFilteredAssets` hook.\n *\n * This context contains information about documents deleted as a result of a filter, along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see AssertUploadAssetContext\n */\nexport const AssertUploadAssetContextSchema = HookContextSchema(AssetAssertUploadSchema);\n\n/**\n * Context for the `assertUploadAsset` hook.\n *\n * This context contains information about the asset being validated before it is uploaded. If validation fails, the developer should throw an error.\n */\nexport type AssertUploadAssetContext = HookContext<AssetAssertUpload>;\n\n/**\n * @see AssertDeleteAssetContext\n */\nexport const AssertDeleteAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `assertDeleteAsset` hook.\n *\n * This context contains information about the asset being validated before it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteAssetContext = HookContext<Asset>;\n", "import * as z from 'zod/v4';\nimport {\n type Asset,\n AssetSchema,\n type Batch,\n BatchSchema,\n type CommitBatch,\n CommitBatchSchema\n} from '../../../schemas/storage';\n\n/**\n * @see AssetAssertUpload\n */\nexport const AssetAssertUploadSchema = z\n .object({\n current: AssetSchema.optional(),\n batch: BatchSchema,\n commit_batch: CommitBatchSchema\n })\n .strict();\n\n/**\n * Represents a validation context before uploading an asset.\n */\nexport interface AssetAssertUpload {\n /**\n * The current asset already stored (if any).\n */\n current?: Asset;\n\n /**\n * The batch metadata being uploaded.\n */\n batch: Batch;\n\n /**\n * The commit data describing headers and chunk ids.\n */\n commit_batch: CommitBatch;\n}\n", "import * as z from 'zod/v4';\nimport {createFunctionSchema} from '../utils/zod.utils';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type RunFunction, RunFunctionSchema} from './schemas/context';\nimport {\n type OnDeleteDocContext,\n OnDeleteDocContextSchema,\n type OnDeleteFilteredDocsContext,\n OnDeleteFilteredDocsContextSchema,\n type OnDeleteManyDocsContext,\n OnDeleteManyDocsContextSchema,\n type OnSetDocContext,\n OnSetDocContextSchema,\n type OnSetManyDocsContext,\n OnSetManyDocsContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n type OnDeleteAssetContext,\n OnDeleteAssetContextSchema,\n type OnDeleteFilteredAssetsContext,\n OnDeleteFilteredAssetsContextSchema,\n type OnDeleteManyAssetsContext,\n OnDeleteManyAssetsContextSchema,\n type OnUploadAssetContext,\n OnUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnHook\n */\nconst OnHookSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n run: RunFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining hooks related to collections.\n *\n * @template T - The type of context passed to the hook when triggered.\n */\nexport type OnHook<T> = Collections & {\n /**\n * A function that runs when the hook is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {Promise<void>} Resolves when the operation completes.\n */\n run: RunFunction<T>;\n};\n\n/**\n * @see OnSetDoc\n */\nexport const OnSetDocSchema = OnHookSchema(OnSetDocContextSchema);\n\n/**\n * A hook that runs when a document is created or updated.\n */\nexport type OnSetDoc = OnHook<OnSetDocContext>;\n\n/**\n * @see OnSetManyDocs\n */\nexport const OnSetManyDocsSchema = OnHookSchema(OnSetManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are created or updated.\n */\nexport type OnSetManyDocs = OnHook<OnSetManyDocsContext>;\n\n/**\n * @see OnDeleteDoc\n */\nexport const OnDeleteDocSchema = OnHookSchema(OnDeleteDocContextSchema);\n\n/**\n * A hook that runs when a single document is deleted.\n */\nexport type OnDeleteDoc = OnHook<OnDeleteDocContext>;\n\n/**\n * @see OnDeleteManyDocs\n */\nexport const OnDeleteManyDocsSchema = OnHookSchema(OnDeleteManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are deleted.\n */\nexport type OnDeleteManyDocs = OnHook<OnDeleteManyDocsContext>;\n\n/**\n * @see OnDeleteFilteredDocs\n */\nexport const OnDeleteFilteredDocsSchema = OnHookSchema(OnDeleteFilteredDocsContextSchema);\n\n/**\n * A hook that runs when a filtered set of documents is deleted based on query conditions.\n */\nexport type OnDeleteFilteredDocs = OnHook<OnDeleteFilteredDocsContext>;\n\n/**\n * @see OnUploadAsset\n */\nexport const OnUploadAssetSchema = OnHookSchema(OnUploadAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is uploaded.\n */\nexport type OnUploadAsset = OnHook<OnUploadAssetContext>;\n\n/**\n * @see OnDeleteAsset\n */\nexport const OnDeleteAssetSchema = OnHookSchema(OnDeleteAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is potentially deleted.\n */\nexport type OnDeleteAsset = OnHook<OnDeleteAssetContext>;\n\n/**\n * @see OnDeleteManyAssets\n */\nexport const OnDeleteManyAssetsSchema = OnHookSchema(OnDeleteManyAssetsContextSchema);\n\n/**\n * A hook that runs when multiple assets are potentially deleted.\n */\nexport type OnDeleteManyAssets = OnHook<OnDeleteManyAssetsContext>;\n\n/**\n * @see OnDeleteFilteredAssets\n */\nexport const OnDeleteFilteredAssetsSchema = OnHookSchema(OnDeleteFilteredAssetsContextSchema);\n\n/**\n * A hook that runs when a filtered set of assets is deleted based on query conditions.\n */\nexport type OnDeleteFilteredAssets = OnHook<OnDeleteFilteredAssetsContext>;\n\n/**\n * @see Hook\n */\nexport const HookSchema = z.union([\n OnSetDocSchema,\n OnSetManyDocsSchema,\n OnDeleteDocContextSchema,\n OnDeleteManyDocsContextSchema,\n OnDeleteFilteredDocsContextSchema,\n OnUploadAssetSchema,\n OnDeleteAssetSchema,\n OnDeleteManyAssetsSchema,\n OnDeleteFilteredAssetsSchema\n]);\n\n/**\n * All hooks definitions.\n */\nexport type Hook =\n | OnSetDoc\n | OnSetManyDocs\n | OnDeleteDoc\n | OnDeleteManyDocs\n | OnDeleteFilteredDocs\n | OnUploadAsset\n | OnDeleteAsset\n | OnDeleteManyAssets\n | OnDeleteFilteredAssets;\n\nexport const HookFnSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.function({input: z.tuple([SatelliteEnvSchema]), output: hookSchema});\nexport type HookFn<T extends Hook> = (hook: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const HookFnOrObjectSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.union([hookSchema, createFunctionSchema(HookFnSchema(hookSchema))]);\nexport type HookFnOrObject<T extends Hook> = T | HookFn<T>;\n\nexport function defineHook<T extends Hook>(hook: T): T;\nexport function defineHook<T extends Hook>(hook: HookFn<T>): HookFn<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T> {\n return hook;\n}\n", "import {jsonReplacer} from '@dfinity/utils';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst __juno_satellite_console_log = (v: any[]) => {\n const msg = v\n .map((arg) => (typeof arg === 'object' ? JSON.stringify(arg, jsonReplacer) : arg))\n .join(' ');\n\n globalThis.__ic_cdk_print(msg);\n};\n\n// @ts-expect-error We want to override the console\nglobalThis.console = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n info(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n log(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n warn(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error(...v: any[]) {\n __juno_satellite_console_log(v);\n }\n};\n", "/**\n * @see Math.random\n */\nconst random = (): number => {\n // __juno_satellite_random() returns a signed 32-bit int (i32)\n const value = __juno_satellite_random();\n\n // >>> 0 converts it to unsigned\n return (value >>> 0) / 2 ** 32;\n};\n\n/**\n * Overwrites Math.random with a pseudo-random number using the Satellite's internal RNG.\n *\n * \u26A0\uFE0F This function is not suitable for use cases requiring cryptographically secure or perfectly unpredictable randomness,\n * such as lotteries or gambling dApps.\n *\n * @returns {number} A pseudo-random 32-bit integer.\n *\n * @throws {Error} If the RNG has not been initialized.\n */\nglobalThis.Math.random = random;\n"],
5
- "mappings": "yTAAA,UAAYA,MAAO,SCAnB,UAAYC,MAAO,SAGZ,IAAMC,EAAuDC,GAChE,SAAuCC,GACvCD,EAAO,UAAUC,CAAmC,CACtD,ECNF,UAAYC,MAAO,SAMZ,IAAMC,EACV,SAAO,CACN,YAAe,QAAQ,SAAO,CAAC,EAAE,SAAS,CAC5C,CAAC,EACA,OAAO,ECVV,UAAYC,MAAO,SAOZ,IAAMC,EAA6CC,GAM/C,eALW,CAClB,OAAQC,EACR,KAAMD,CACR,CAEiC,EAuBtBE,EAAgDC,GAC3DC,EAAuB,WAAS,CAAC,MAAS,QAAM,CAACD,CAAa,CAAC,EAAG,OAAU,OAAK,CAAC,CAAC,CAAC,EAczEE,EAA6CF,GACxDC,EACI,WAAS,CAAC,MAAS,QAAM,CAACD,CAAa,CAAC,EAAG,OAAU,UAAU,OAAK,CAAC,EAAE,GAAK,OAAK,CAAC,CAA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gBAAAC,OAAmB,iBAG3B,IAAMC,EAAgCC,GAAa,CACjD,IAAMC,EAAMD,EACT,IAAKE,GAAS,OAAOA,GAAQ,SAAW,KAAK,UAAUA,EAAKJ,EAAY,EAAII,CAAI,EAChF,KAAK,GAAG,EAEX,WAAW,eAAeD,CAAG,CAC/B,EAGA,WAAW,QAAU,CAEnB,QAAQD,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,OAAOA,EAAU,CACfD,EAA6BC,CAAC,CAChC,EAEA,QAAQA,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,SAASA,EAAU,CACjBD,EAA6BC,CAAC,CAChC,CACF,EC1BA,IAAMG,GAAS,KAEC,wBAAwB,IAGpB,GAAK,WAazB,WAAW,KAAK,OAASA",
4
+ "sourcesContent": ["import * as z from 'zod';\nimport {createFunctionSchema} from '../utils/zod.utils';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type AssertFunction, AssertFunctionSchema} from './schemas/context';\nimport {\n type AssertDeleteDocContext,\n AssertDeleteDocContextSchema,\n type AssertSetDocContext,\n AssertSetDocContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n type AssertDeleteAssetContext,\n AssertDeleteAssetContextSchema,\n type AssertUploadAssetContext,\n AssertUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnAssert\n */\nconst OnAssertSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the assertion is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {void} Resolves when the assertion completes.\n */\n assert: AssertFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining assertions related to collections.\n *\n * @template T - The type of context passed to the assertions when triggered.\n */\nexport type OnAssert<T> = Collections & {\n assert: AssertFunction<T>;\n};\n\n/**\n * @see AssertSetDoc\n */\nexport const AssertSetDocSchema = OnAssertSchema(AssertSetDocContextSchema);\n\n/**\n * An assertion that runs when a document is created or updated.\n */\nexport type AssertSetDoc = OnAssert<AssertSetDocContext>;\n\n/**\n * @see AssertDeleteDoc\n */\nexport const AssertDeleteDocSchema = OnAssertSchema(AssertDeleteDocContextSchema);\n\n/**\n * An assertion that runs when a document is deleted.\n */\nexport type AssertDeleteDoc = OnAssert<AssertDeleteDocContext>;\n\n/**\n * @see AssertUploadAsset\n */\nexport const AssertUploadAssetSchema = OnAssertSchema(AssertUploadAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is uploaded.\n */\nexport type AssertUploadAsset = OnAssert<AssertUploadAssetContext>;\n\n/**\n * @see AssertDeleteAsset\n */\nexport const AssertDeleteAssetSchema = OnAssertSchema(AssertDeleteAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is deleted.\n */\nexport type AssertDeleteAsset = OnAssert<AssertDeleteAssetContext>;\n\n/**\n * @see Assert\n */\nexport const AssertSchema = z.union([\n AssertSetDocSchema,\n AssertDeleteDocSchema,\n AssertUploadAssetSchema,\n AssertDeleteAssetSchema\n]);\n\n/**\n * All assertions definitions.\n */\nexport type Assert = AssertSetDoc | AssertDeleteDoc | AssertUploadAsset | AssertDeleteAsset;\n\nexport const AssertFnSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.function({\n input: z.tuple([SatelliteEnvSchema]),\n output: assertSchema\n });\nexport type AssertFn<T extends Assert> = (assert: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const AssertFnOrObjectSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.union([assertSchema, createFunctionSchema(AssertFnSchema(assertSchema))]);\nexport type AssertFnOrObject<T extends Assert> = T | AssertFn<T>;\n\nexport function defineAssert<T extends Assert>(assert: T): T;\nexport function defineAssert<T extends Assert>(assert: AssertFn<T>): AssertFn<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T> {\n return assert;\n}\n", "import * as z from 'zod';\n\n// TODO: Workaround source: https://github.com/colinhacks/zod/issues/4143#issuecomment-2845134912\nexport const createFunctionSchema = <T extends z.core.$ZodFunction>(schema: T) =>\n z.custom<Parameters<T['implement']>[0]>((fn) =>\n schema.implement(fn as Parameters<T['implement']>[0])\n );\n", "import * as z from 'zod';\nimport type {Collection} from '../../schemas/satellite';\n\n/**\n * @see Collections\n */\nexport const CollectionsSchema = z\n .object({\n collections: z.array(z.string()).readonly()\n })\n .strict();\n\n/**\n * Defines the collections where a hook or assertion should run.\n */\nexport interface Collections {\n /**\n * An array of collection names where the hook or assertion will run.\n * If empty, no hooks or assertions are triggered.\n */\n collections: readonly Collection[];\n}\n", "import * as z from 'zod';\nimport {type RawUserId, RawUserIdSchema} from '../../schemas/satellite';\nimport {createFunctionSchema} from '../../utils/zod.utils';\n\n/**\n * @see HookContext\n */\nexport const HookContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n caller: RawUserIdSchema,\n data: dataSchema\n };\n\n return z.strictObject(schemaShape);\n};\n\n/**\n * Represents the context provided to hooks, containing information about the caller and related data.\n *\n * @template T - The type of data associated with the hook.\n */\nexport interface HookContext<T> {\n /**\n * The user who originally triggered the function that in turn triggered the hook.\n */\n caller: RawUserId;\n\n /**\n * The data associated with the hook execution.\n */\n data: T;\n}\n\n/**\n * @see AssertFunction\n */\nexport const AssertFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n createFunctionSchema(z.function({input: z.tuple([contextSchema]), output: z.void()}));\n\n/**\n * Defines the `assert` function schema for assertions.\n *\n * The function takes a context argument and returns `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type AssertFunction<T> = (context: T) => void;\n\n/**\n * @see RunFunction\n */\nexport const RunFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n createFunctionSchema(\n z.function({input: z.tuple([contextSchema]), output: z.promise(z.void()).or(z.void())})\n );\n\n/**\n * Defines the `run` function schema for hooks.\n *\n * The function takes a context argument and returns either a `Promise<void>` or `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type RunFunction<T> = (context: T) => void | Promise<void>;\n", "import * as z from 'zod';\nimport {DocSchema, type OptionDoc} from '../../../schemas/db';\nimport {type Collection, CollectionSchema, type Key, KeySchema} from '../../../schemas/satellite';\nimport {type HookContext, HookContextSchema} from '../context';\nimport {\n type DocAssertDelete,\n DocAssertDeleteSchema,\n type DocAssertSet,\n DocAssertSetSchema,\n type DocUpsert,\n DocUpsertSchema\n} from './payload';\n\n/**\n * @see DocContext\n */\nexport const DocContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n collection: CollectionSchema,\n key: KeySchema,\n data: dataSchema\n };\n\n return z.strictObject(schemaShape);\n};\n\n/**\n * Represents the context of a document operation within a collection.\n *\n * @template T - The type of data associated with the document.\n */\nexport interface DocContext<T> {\n /**\n * The name of the collection where the document is stored.\n */\n collection: Collection;\n\n /**\n * The key identifying the document within the collection.\n */\n key: Key;\n\n /**\n * The data associated with the document operation.\n */\n data: T;\n}\n\n/**\n * @see OnSetDocContext\n */\nexport const OnSetDocContextSchema = HookContextSchema(DocContextSchema(DocUpsertSchema));\n\n/**\n * The context provided to the `onSetDoc` hook.\n *\n * This context contains information about the document being created or updated,\n * along with details about the user who triggered the operation.\n */\nexport type OnSetDocContext = HookContext<DocContext<DocUpsert>>;\n\n/**\n * @see OnSetManyDocsContext\n */\nexport const OnSetManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocUpsertSchema))\n);\n\n/**\n * The context provided to the `onSetManyDocs` hook.\n *\n * This context contains information about multiple documents being created or updated\n * in a single operation, along with details about the user who triggered it.\n */\nexport type OnSetManyDocsContext = HookContext<DocContext<DocUpsert>[]>;\n\n/**\n * @see OnDeleteDocContext\n */\nexport const OnDeleteDocContextSchema = HookContextSchema(DocContextSchema(DocSchema.optional()));\n\n/**\n * The context provided to the `onDeleteDoc` hook.\n *\n * This context contains information about a single document being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteDocContext = HookContext<DocContext<OptionDoc>>;\n\n/**\n * @see OnDeleteManyDocsContext\n */\nexport const OnDeleteManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteManyDocs` hook.\n *\n * This context contains information about multiple documents being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see OnDeleteFilteredDocsContext\n */\nexport const OnDeleteFilteredDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteFilteredDocs` hook.\n *\n * This context contains information about documents deleted as a result of a filter,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see AssertSetDocContext\n */\nexport const AssertSetDocContextSchema = HookContextSchema(DocContextSchema(DocAssertSetSchema));\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is created or updated. If validation fails, the developer should throw an error.\n */\nexport type AssertSetDocContext = HookContext<DocContext<DocAssertSet>>;\n\n/**\n * @see AssertDeleteDocContext\n */\nexport const AssertDeleteDocContextSchema = HookContextSchema(\n DocContextSchema(DocAssertDeleteSchema)\n);\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteDocContext = HookContext<DocContext<DocAssertDelete>>;\n", "import * as z from 'zod';\nimport {\n type DelDoc,\n DelDocSchema,\n type Doc,\n DocSchema,\n type SetDoc,\n SetDocSchema\n} from '../../../schemas/db';\n\n/**\n * @see DocUpsert\n */\nexport const DocUpsertSchema = z\n .object({\n before: DocSchema.optional(),\n after: DocSchema\n })\n .strict();\n\n/**\n * Represents a document update operation.\n *\n * This is used in hooks where a document is either being created or updated.\n */\nexport interface DocUpsert {\n /**\n * The previous version of the document before the update.\n * Undefined if this is a new document.\n */\n before?: Doc;\n\n /**\n * The new version of the document after the update.\n */\n after: Doc;\n}\n/**\n * @see DocAssertSet\n */\nexport const DocAssertSetSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: SetDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before setting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertSet {\n /**\n * The current version of the document before the operation.\n * Undefined if this is a new document.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: SetDoc;\n}\n\n/**\n * @see DocAssertDelete\n */\nexport const DocAssertDeleteSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: DelDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before deleting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertDelete {\n /**\n * The current version of the document before the operation.\n * Undefined if the document does not exist.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: DelDoc;\n}\n", "import * as z from 'zod';\n\n/**\n * @see SatelliteEnv\n */\nexport const SatelliteEnvSchema = z.record(z.string(), z.string());\n\n/**\n * Placeholder for future environment-specific configurations.\n *\n * Currently unused, but it may support features such as:\n * - Defining the execution mode (e.g., staging or production).\n * - Providing environment-specific values like `ckBtcLedgerId` for test or production.\n */\nexport type SatelliteEnv = z.infer<typeof SatelliteEnvSchema>;\n", "import * as z from 'zod';\nimport {AssetSchema, type Asset} from '../../../schemas/storage';\nimport {HookContextSchema, type HookContext} from '../context';\nimport {AssetAssertUploadSchema, type AssetAssertUpload} from './payload';\n\n/**\n * @see OnUploadAssetContext\n */\nexport const OnUploadAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `onUploadAsset` hook.\n *\n * This context contains information about the asset that was uploaded.\n */\nexport type OnUploadAssetContext = HookContext<Asset>;\n\n/**\n * @see OnDeleteAssetContext\n */\nexport const OnDeleteAssetContextSchema = HookContextSchema(AssetSchema.optional());\n\n/**\n * Context for the `onDeleteAsset` hook.\n *\n * This context contains information about a single asset being deleted, along with details about the user who triggered the operation.\n *\n * If undefined, the asset did not exist.\n */\nexport type OnDeleteAssetContext = HookContext<Asset | undefined>;\n\n/**\n * @see OnDeleteManyAssetsContext\n */\nexport const OnDeleteManyAssetsContextSchema = HookContextSchema(z.array(AssetSchema.optional()));\n\n/**\n * Context for the `onDeleteManyAssets` hook.\n *\n * This context contains information about multiple assets being potentially deleted, along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see OnDeleteFilteredAssetsContext\n */\nexport const OnDeleteFilteredAssetsContextSchema = HookContextSchema(\n z.array(AssetSchema.optional())\n);\n\n/**\n * Context for the `onDeleteFilteredAssets` hook.\n *\n * This context contains information about documents deleted as a result of a filter, along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see AssertUploadAssetContext\n */\nexport const AssertUploadAssetContextSchema = HookContextSchema(AssetAssertUploadSchema);\n\n/**\n * Context for the `assertUploadAsset` hook.\n *\n * This context contains information about the asset being validated before it is uploaded. If validation fails, the developer should throw an error.\n */\nexport type AssertUploadAssetContext = HookContext<AssetAssertUpload>;\n\n/**\n * @see AssertDeleteAssetContext\n */\nexport const AssertDeleteAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `assertDeleteAsset` hook.\n *\n * This context contains information about the asset being validated before it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteAssetContext = HookContext<Asset>;\n", "import * as z from 'zod';\nimport {\n type Asset,\n AssetSchema,\n type Batch,\n BatchSchema,\n type CommitBatch,\n CommitBatchSchema\n} from '../../../schemas/storage';\n\n/**\n * @see AssetAssertUpload\n */\nexport const AssetAssertUploadSchema = z\n .object({\n current: AssetSchema.optional(),\n batch: BatchSchema,\n commit_batch: CommitBatchSchema\n })\n .strict();\n\n/**\n * Represents a validation context before uploading an asset.\n */\nexport interface AssetAssertUpload {\n /**\n * The current asset already stored (if any).\n */\n current?: Asset;\n\n /**\n * The batch metadata being uploaded.\n */\n batch: Batch;\n\n /**\n * The commit data describing headers and chunk ids.\n */\n commit_batch: CommitBatch;\n}\n", "import * as z from 'zod';\nimport {createFunctionSchema} from '../utils/zod.utils';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type RunFunction, RunFunctionSchema} from './schemas/context';\nimport {\n type OnDeleteDocContext,\n OnDeleteDocContextSchema,\n type OnDeleteFilteredDocsContext,\n OnDeleteFilteredDocsContextSchema,\n type OnDeleteManyDocsContext,\n OnDeleteManyDocsContextSchema,\n type OnSetDocContext,\n OnSetDocContextSchema,\n type OnSetManyDocsContext,\n OnSetManyDocsContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n type OnDeleteAssetContext,\n OnDeleteAssetContextSchema,\n type OnDeleteFilteredAssetsContext,\n OnDeleteFilteredAssetsContextSchema,\n type OnDeleteManyAssetsContext,\n OnDeleteManyAssetsContextSchema,\n type OnUploadAssetContext,\n OnUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnHook\n */\nconst OnHookSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n run: RunFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining hooks related to collections.\n *\n * @template T - The type of context passed to the hook when triggered.\n */\nexport type OnHook<T> = Collections & {\n /**\n * A function that runs when the hook is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {Promise<void>} Resolves when the operation completes.\n */\n run: RunFunction<T>;\n};\n\n/**\n * @see OnSetDoc\n */\nexport const OnSetDocSchema = OnHookSchema(OnSetDocContextSchema);\n\n/**\n * A hook that runs when a document is created or updated.\n */\nexport type OnSetDoc = OnHook<OnSetDocContext>;\n\n/**\n * @see OnSetManyDocs\n */\nexport const OnSetManyDocsSchema = OnHookSchema(OnSetManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are created or updated.\n */\nexport type OnSetManyDocs = OnHook<OnSetManyDocsContext>;\n\n/**\n * @see OnDeleteDoc\n */\nexport const OnDeleteDocSchema = OnHookSchema(OnDeleteDocContextSchema);\n\n/**\n * A hook that runs when a single document is deleted.\n */\nexport type OnDeleteDoc = OnHook<OnDeleteDocContext>;\n\n/**\n * @see OnDeleteManyDocs\n */\nexport const OnDeleteManyDocsSchema = OnHookSchema(OnDeleteManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are deleted.\n */\nexport type OnDeleteManyDocs = OnHook<OnDeleteManyDocsContext>;\n\n/**\n * @see OnDeleteFilteredDocs\n */\nexport const OnDeleteFilteredDocsSchema = OnHookSchema(OnDeleteFilteredDocsContextSchema);\n\n/**\n * A hook that runs when a filtered set of documents is deleted based on query conditions.\n */\nexport type OnDeleteFilteredDocs = OnHook<OnDeleteFilteredDocsContext>;\n\n/**\n * @see OnUploadAsset\n */\nexport const OnUploadAssetSchema = OnHookSchema(OnUploadAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is uploaded.\n */\nexport type OnUploadAsset = OnHook<OnUploadAssetContext>;\n\n/**\n * @see OnDeleteAsset\n */\nexport const OnDeleteAssetSchema = OnHookSchema(OnDeleteAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is potentially deleted.\n */\nexport type OnDeleteAsset = OnHook<OnDeleteAssetContext>;\n\n/**\n * @see OnDeleteManyAssets\n */\nexport const OnDeleteManyAssetsSchema = OnHookSchema(OnDeleteManyAssetsContextSchema);\n\n/**\n * A hook that runs when multiple assets are potentially deleted.\n */\nexport type OnDeleteManyAssets = OnHook<OnDeleteManyAssetsContext>;\n\n/**\n * @see OnDeleteFilteredAssets\n */\nexport const OnDeleteFilteredAssetsSchema = OnHookSchema(OnDeleteFilteredAssetsContextSchema);\n\n/**\n * A hook that runs when a filtered set of assets is deleted based on query conditions.\n */\nexport type OnDeleteFilteredAssets = OnHook<OnDeleteFilteredAssetsContext>;\n\n/**\n * @see Hook\n */\nexport const HookSchema = z.union([\n OnSetDocSchema,\n OnSetManyDocsSchema,\n OnDeleteDocContextSchema,\n OnDeleteManyDocsContextSchema,\n OnDeleteFilteredDocsContextSchema,\n OnUploadAssetSchema,\n OnDeleteAssetSchema,\n OnDeleteManyAssetsSchema,\n OnDeleteFilteredAssetsSchema\n]);\n\n/**\n * All hooks definitions.\n */\nexport type Hook =\n | OnSetDoc\n | OnSetManyDocs\n | OnDeleteDoc\n | OnDeleteManyDocs\n | OnDeleteFilteredDocs\n | OnUploadAsset\n | OnDeleteAsset\n | OnDeleteManyAssets\n | OnDeleteFilteredAssets;\n\nexport const HookFnSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.function({input: z.tuple([SatelliteEnvSchema]), output: hookSchema});\nexport type HookFn<T extends Hook> = (hook: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const HookFnOrObjectSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.union([hookSchema, createFunctionSchema(HookFnSchema(hookSchema))]);\nexport type HookFnOrObject<T extends Hook> = T | HookFn<T>;\n\nexport function defineHook<T extends Hook>(hook: T): T;\nexport function defineHook<T extends Hook>(hook: HookFn<T>): HookFn<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T> {\n return hook;\n}\n", "import {jsonReplacer} from '@dfinity/utils';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst __juno_satellite_console_log = (v: any[]) => {\n const msg = v\n .map((arg) => (typeof arg === 'object' ? JSON.stringify(arg, jsonReplacer) : arg))\n .join(' ');\n\n globalThis.__ic_cdk_print(msg);\n};\n\n// @ts-expect-error We want to override the console\nglobalThis.console = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n info(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n log(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n warn(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error(...v: any[]) {\n __juno_satellite_console_log(v);\n }\n};\n", "/**\n * @see Math.random\n */\nconst random = (): number => {\n // __juno_satellite_random() returns a signed 32-bit int (i32)\n const value = __juno_satellite_random();\n\n // >>> 0 converts it to unsigned\n return (value >>> 0) / 2 ** 32;\n};\n\n/**\n * Overwrites Math.random with a pseudo-random number using the Satellite's internal RNG.\n *\n * \u26A0\uFE0F This function is not suitable for use cases requiring cryptographically secure or perfectly unpredictable randomness,\n * such as lotteries or gambling dApps.\n *\n * @returns {number} A pseudo-random 32-bit integer.\n *\n * @throws {Error} If the RNG has not been initialized.\n */\nglobalThis.Math.random = random;\n"],
5
+ "mappings": "yTAAA,UAAYA,MAAO,MCAnB,UAAYC,MAAO,MAGZ,IAAMC,EAAuDC,GAChE,SAAuCC,GACvCD,EAAO,UAAUC,CAAmC,CACtD,ECNF,UAAYC,MAAO,MAMZ,IAAMC,EACV,SAAO,CACN,YAAe,QAAQ,SAAO,CAAC,EAAE,SAAS,CAC5C,CAAC,EACA,OAAO,ECVV,UAAYC,MAAO,MAOZ,IAAMC,EAA6CC,GAM/C,eALW,CAClB,OAAQC,EACR,KAAMD,CACR,CAEiC,EAuBtBE,EAAgDC,GAC3DC,EAAuB,WAAS,CAAC,MAAS,QAAM,CAACD,CAAa,CAAC,EAAG,OAAU,OAAK,CAAC,CAAC,CAAC,EAczEE,EAA6CF,GACxDC,EACI,WAAS,CAAC,MAAS,QAAM,CAACD,CAAa,CAAC,EAAG,OAAU,UAAU,OAAK,CAAC,EAAE,GAAK,OAAK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LA,OAAQ,gBAAAC,OAAmB,iBAG3B,IAAMC,EAAgCC,GAAa,CACjD,IAAMC,EAAMD,EACT,IAAKE,GAAS,OAAOA,GAAQ,SAAW,KAAK,UAAUA,EAAKJ,EAAY,EAAII,CAAI,EAChF,KAAK,GAAG,EAEX,WAAW,eAAeD,CAAG,CAC/B,EAGA,WAAW,QAAU,CAEnB,QAAQD,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,OAAOA,EAAU,CACfD,EAA6BC,CAAC,CAChC,EAEA,QAAQA,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,SAASA,EAAU,CACjBD,EAA6BC,CAAC,CAChC,CACF,EC1BA,IAAMG,GAAS,KAEC,wBAAwB,IAGpB,GAAK,WAazB,WAAW,KAAK,OAASA",
6
6
  "names": ["z", "z", "createFunctionSchema", "schema", "fn", "z", "CollectionsSchema", "z", "HookContextSchema", "dataSchema", "RawUserIdSchema", "AssertFunctionSchema", "contextSchema", "createFunctionSchema", "RunFunctionSchema", "z", "z", "DocUpsertSchema", "DocSchema", "DocAssertSetSchema", "SetDocSchema", "DocAssertDeleteSchema", "DelDocSchema", "DocContextSchema", "dataSchema", "CollectionSchema", "KeySchema", "OnSetDocContextSchema", "HookContextSchema", "DocUpsertSchema", "OnSetManyDocsContextSchema", "OnDeleteDocContextSchema", "DocSchema", "OnDeleteManyDocsContextSchema", "OnDeleteFilteredDocsContextSchema", "AssertSetDocContextSchema", "DocAssertSetSchema", "AssertDeleteDocContextSchema", "DocAssertDeleteSchema", "z", "SatelliteEnvSchema", "z", "z", "AssetAssertUploadSchema", "AssetSchema", "BatchSchema", "CommitBatchSchema", "OnUploadAssetContextSchema", "HookContextSchema", "AssetSchema", "OnDeleteAssetContextSchema", "OnDeleteManyAssetsContextSchema", "OnDeleteFilteredAssetsContextSchema", "AssertUploadAssetContextSchema", "AssetAssertUploadSchema", "AssertDeleteAssetContextSchema", "OnAssertSchema", "contextSchema", "CollectionsSchema", "AssertFunctionSchema", "AssertSetDocSchema", "AssertSetDocContextSchema", "AssertDeleteDocSchema", "AssertDeleteDocContextSchema", "AssertUploadAssetSchema", "AssertUploadAssetContextSchema", "AssertDeleteAssetSchema", "AssertDeleteAssetContextSchema", "AssertSchema", "AssertFnSchema", "assertSchema", "SatelliteEnvSchema", "AssertFnOrObjectSchema", "createFunctionSchema", "defineAssert", "assert", "z", "OnHookSchema", "contextSchema", "CollectionsSchema", "RunFunctionSchema", "OnSetDocSchema", "OnSetDocContextSchema", "OnSetManyDocsSchema", "OnSetManyDocsContextSchema", "OnDeleteDocSchema", "OnDeleteDocContextSchema", "OnDeleteManyDocsSchema", "OnDeleteManyDocsContextSchema", "OnDeleteFilteredDocsSchema", "OnDeleteFilteredDocsContextSchema", "OnUploadAssetSchema", "OnUploadAssetContextSchema", "OnDeleteAssetSchema", "OnDeleteAssetContextSchema", "OnDeleteManyAssetsSchema", "OnDeleteManyAssetsContextSchema", "OnDeleteFilteredAssetsSchema", "OnDeleteFilteredAssetsContextSchema", "HookSchema", "HookFnSchema", "hookSchema", "SatelliteEnvSchema", "HookFnOrObjectSchema", "createFunctionSchema", "defineHook", "hook", "jsonReplacer", "__juno_satellite_console_log", "v", "msg", "arg", "random"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/functions",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "JavaScript and TypeScript utilities for Juno Serverless Functions",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",
@@ -51,6 +51,6 @@
51
51
  "@dfinity/identity": "^2.3.0",
52
52
  "@dfinity/principal": "^2.3.0",
53
53
  "@dfinity/utils": "^2",
54
- "zod": "^3.25"
54
+ "zod": "^4"
55
55
  }
56
56
  }
@@ -1,5 +1,5 @@
1
1
  import { Principal as CandidPrincipal } from '@dfinity/principal';
2
- import * as z from 'zod/v4';
2
+ import * as z from 'zod';
3
3
  /**
4
4
  * A schema that validates a value is an Uint8Array.
5
5
  */
package/schemas/db.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as z from 'zod/v4';
1
+ import * as z from 'zod';
2
2
  import { Uint8ArraySchema } from './candid';
3
3
  import { type Description, type RawUserId, type Timestamp, type Version } from './satellite';
4
4
  /**
package/schemas/list.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as z from 'zod/v4';
1
+ import * as z from 'zod';
2
2
  import { type Description, type Key, type RawUserId, type Timestamp } from './satellite';
3
3
  /**
4
4
  * @see TimestampMatcher
@@ -1,4 +1,4 @@
1
- import * as z from 'zod/v4';
1
+ import * as z from 'zod';
2
2
  /**
3
3
  * @see Timestamp
4
4
  */
@@ -1,4 +1,4 @@
1
- import * as z from 'zod/v4';
1
+ import * as z from 'zod';
2
2
  import { type Collection, type Description, type RawUserId, type Timestamp, type Version } from './satellite';
3
3
  /**
4
4
  * Represents a single HTTP header as a tuple of name and value.
@@ -1,4 +1,4 @@
1
- import * as z from 'zod/v4';
1
+ import * as z from 'zod';
2
2
  /**
3
3
  * @see Memory
4
4
  */
@@ -1,4 +1,4 @@
1
- import * as z from 'zod/v4';
1
+ import * as z from 'zod';
2
2
  import { type RawUserId, type Timestamp, type UserId } from '../../schemas/satellite';
3
3
  /**
4
4
  * @see ControllerScopeSchema
@@ -4,11 +4,11 @@ import { type CollectionParams, type ListStoreParams } from './params';
4
4
  /**
5
5
  * @see GetDocStoreParams
6
6
  */
7
- export declare const GetDocStoreParamsSchema: import("zod/v4").ZodObject<{
8
- collection: import("zod/v4").ZodString;
9
- caller: import("zod/v4").ZodUnion<[import("zod/v4").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod/v4").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
10
- key: import("zod/v4").ZodString;
11
- }, import("zod/v4/core").$strict>;
7
+ export declare const GetDocStoreParamsSchema: import("zod").ZodObject<{
8
+ collection: import("zod").ZodString;
9
+ caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
10
+ key: import("zod").ZodString;
11
+ }, import("zod/v4/core/schemas.cjs").$strict>;
12
12
  /**
13
13
  * Represents the base parameters required to access the datastore and modify a document.
14
14
  */
@@ -25,16 +25,16 @@ export type GetDocStoreParams = CollectionParams & {
25
25
  /**
26
26
  * @see SetDocStoreParams
27
27
  */
28
- export declare const SetDocStoreParamsSchema: import("zod/v4").ZodObject<{
29
- collection: import("zod/v4").ZodString;
30
- caller: import("zod/v4").ZodUnion<[import("zod/v4").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod/v4").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
31
- key: import("zod/v4").ZodString;
32
- doc: import("zod/v4").ZodObject<{
33
- data: import("zod/v4").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>;
34
- description: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
35
- version: import("zod/v4").ZodOptional<import("zod/v4").ZodBigInt>;
36
- }, import("zod/v4/core").$strict>;
37
- }, import("zod/v4/core").$strict>;
28
+ export declare const SetDocStoreParamsSchema: import("zod").ZodObject<{
29
+ collection: import("zod").ZodString;
30
+ caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
31
+ key: import("zod").ZodString;
32
+ doc: import("zod").ZodObject<{
33
+ data: import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>;
34
+ description: import("zod").ZodOptional<import("zod").ZodString>;
35
+ version: import("zod").ZodOptional<import("zod").ZodBigInt>;
36
+ }, import("zod/v4/core/schemas.cjs").$strict>;
37
+ }, import("zod/v4/core/schemas.cjs").$strict>;
38
38
  /**
39
39
  * Represents the parameters required to store or update a document.
40
40
  *
@@ -50,14 +50,14 @@ export type SetDocStoreParams = GetDocStoreParams & {
50
50
  /**
51
51
  * @see DeleteDocStoreParams
52
52
  */
53
- export declare const DeleteDocStoreParamsSchema: import("zod/v4").ZodObject<{
54
- collection: import("zod/v4").ZodString;
55
- caller: import("zod/v4").ZodUnion<[import("zod/v4").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod/v4").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
56
- key: import("zod/v4").ZodString;
57
- doc: import("zod/v4").ZodObject<{
58
- version: import("zod/v4").ZodOptional<import("zod/v4").ZodBigInt>;
59
- }, import("zod/v4/core").$strict>;
60
- }, import("zod/v4/core").$strict>;
53
+ export declare const DeleteDocStoreParamsSchema: import("zod").ZodObject<{
54
+ collection: import("zod").ZodString;
55
+ caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
56
+ key: import("zod").ZodString;
57
+ doc: import("zod").ZodObject<{
58
+ version: import("zod").ZodOptional<import("zod").ZodBigInt>;
59
+ }, import("zod/v4/core/schemas.cjs").$strict>;
60
+ }, import("zod/v4/core/schemas.cjs").$strict>;
61
61
  /**
62
62
  * Represents the parameters required to delete a document.
63
63
  *
@@ -73,9 +73,9 @@ export type DeleteDocStoreParams = GetDocStoreParams & {
73
73
  /**
74
74
  * @see CountCollectionDocsStoreParams
75
75
  */
76
- export declare const CountCollectionDocsStoreParamsSchema: import("zod/v4").ZodObject<{
77
- collection: import("zod/v4").ZodString;
78
- }, import("zod/v4/core").$strict>;
76
+ export declare const CountCollectionDocsStoreParamsSchema: import("zod").ZodObject<{
77
+ collection: import("zod").ZodString;
78
+ }, import("zod/v4/core/schemas.cjs").$strict>;
79
79
  /**
80
80
  * The parameters required to count documents from the datastore.
81
81
  */
@@ -83,47 +83,47 @@ export type CountCollectionDocsStoreParams = CollectionParams;
83
83
  /**
84
84
  * @see CountDocsStoreParams
85
85
  */
86
- export declare const CountDocsStoreParamsSchema: import("zod/v4").ZodObject<{
87
- collection: import("zod/v4").ZodString;
88
- caller: import("zod/v4").ZodUnion<[import("zod/v4").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod/v4").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
89
- params: import("zod/v4").ZodObject<{
90
- matcher: import("zod/v4").ZodOptional<import("zod/v4").ZodObject<{
91
- key: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
92
- description: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
93
- created_at: import("zod/v4").ZodOptional<import("zod/v4").ZodUnion<readonly [import("zod/v4").ZodObject<{
94
- equal: import("zod/v4").ZodBigInt;
95
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
96
- greater_than: import("zod/v4").ZodBigInt;
97
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
98
- less_than: import("zod/v4").ZodBigInt;
99
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
100
- between: import("zod/v4").ZodTuple<[import("zod/v4").ZodBigInt, import("zod/v4").ZodBigInt], null>;
101
- }, import("zod/v4/core").$strip>]>>;
102
- updated_at: import("zod/v4").ZodOptional<import("zod/v4").ZodUnion<readonly [import("zod/v4").ZodObject<{
103
- equal: import("zod/v4").ZodBigInt;
104
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
105
- greater_than: import("zod/v4").ZodBigInt;
106
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
107
- less_than: import("zod/v4").ZodBigInt;
108
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
109
- between: import("zod/v4").ZodTuple<[import("zod/v4").ZodBigInt, import("zod/v4").ZodBigInt], null>;
110
- }, import("zod/v4/core").$strip>]>>;
111
- }, import("zod/v4/core").$strict>>;
112
- paginate: import("zod/v4").ZodOptional<import("zod/v4").ZodObject<{
113
- start_after: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
114
- limit: import("zod/v4").ZodOptional<import("zod/v4").ZodBigInt>;
115
- }, import("zod/v4/core").$strict>>;
116
- order: import("zod/v4").ZodOptional<import("zod/v4").ZodObject<{
117
- desc: import("zod/v4").ZodBoolean;
118
- field: import("zod/v4").ZodEnum<{
86
+ export declare const CountDocsStoreParamsSchema: import("zod").ZodObject<{
87
+ collection: import("zod").ZodString;
88
+ caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
89
+ params: import("zod").ZodObject<{
90
+ matcher: import("zod").ZodOptional<import("zod").ZodObject<{
91
+ key: import("zod").ZodOptional<import("zod").ZodString>;
92
+ description: import("zod").ZodOptional<import("zod").ZodString>;
93
+ created_at: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
94
+ equal: import("zod").ZodBigInt;
95
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
96
+ greater_than: import("zod").ZodBigInt;
97
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
98
+ less_than: import("zod").ZodBigInt;
99
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
100
+ between: import("zod").ZodTuple<[import("zod").ZodBigInt, import("zod").ZodBigInt], null>;
101
+ }, import("zod/v4/core/schemas.cjs").$strip>]>>;
102
+ updated_at: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
103
+ equal: import("zod").ZodBigInt;
104
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
105
+ greater_than: import("zod").ZodBigInt;
106
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
107
+ less_than: import("zod").ZodBigInt;
108
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
109
+ between: import("zod").ZodTuple<[import("zod").ZodBigInt, import("zod").ZodBigInt], null>;
110
+ }, import("zod/v4/core/schemas.cjs").$strip>]>>;
111
+ }, import("zod/v4/core/schemas.cjs").$strict>>;
112
+ paginate: import("zod").ZodOptional<import("zod").ZodObject<{
113
+ start_after: import("zod").ZodOptional<import("zod").ZodString>;
114
+ limit: import("zod").ZodOptional<import("zod").ZodBigInt>;
115
+ }, import("zod/v4/core/schemas.cjs").$strict>>;
116
+ order: import("zod").ZodOptional<import("zod").ZodObject<{
117
+ desc: import("zod").ZodBoolean;
118
+ field: import("zod").ZodEnum<{
119
119
  created_at: "created_at";
120
120
  updated_at: "updated_at";
121
121
  keys: "keys";
122
122
  }>;
123
- }, import("zod/v4/core").$strict>>;
124
- owner: import("zod/v4").ZodOptional<import("zod/v4").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>>;
125
- }, import("zod/v4/core").$strict>;
126
- }, import("zod/v4/core").$strict>;
123
+ }, import("zod/v4/core/schemas.cjs").$strict>>;
124
+ owner: import("zod").ZodOptional<import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>>;
125
+ }, import("zod/v4/core/schemas.cjs").$strict>;
126
+ }, import("zod/v4/core/schemas.cjs").$strict>;
127
127
  /**
128
128
  * The parameters required to count documents from the datastore.
129
129
  */
@@ -131,47 +131,47 @@ export type CountDocsStoreParams = ListStoreParams;
131
131
  /**
132
132
  * @see ListDocsStoreParams
133
133
  */
134
- export declare const ListDocsStoreParamsSchema: import("zod/v4").ZodObject<{
135
- collection: import("zod/v4").ZodString;
136
- caller: import("zod/v4").ZodUnion<[import("zod/v4").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod/v4").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
137
- params: import("zod/v4").ZodObject<{
138
- matcher: import("zod/v4").ZodOptional<import("zod/v4").ZodObject<{
139
- key: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
140
- description: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
141
- created_at: import("zod/v4").ZodOptional<import("zod/v4").ZodUnion<readonly [import("zod/v4").ZodObject<{
142
- equal: import("zod/v4").ZodBigInt;
143
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
144
- greater_than: import("zod/v4").ZodBigInt;
145
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
146
- less_than: import("zod/v4").ZodBigInt;
147
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
148
- between: import("zod/v4").ZodTuple<[import("zod/v4").ZodBigInt, import("zod/v4").ZodBigInt], null>;
149
- }, import("zod/v4/core").$strip>]>>;
150
- updated_at: import("zod/v4").ZodOptional<import("zod/v4").ZodUnion<readonly [import("zod/v4").ZodObject<{
151
- equal: import("zod/v4").ZodBigInt;
152
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
153
- greater_than: import("zod/v4").ZodBigInt;
154
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
155
- less_than: import("zod/v4").ZodBigInt;
156
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
157
- between: import("zod/v4").ZodTuple<[import("zod/v4").ZodBigInt, import("zod/v4").ZodBigInt], null>;
158
- }, import("zod/v4/core").$strip>]>>;
159
- }, import("zod/v4/core").$strict>>;
160
- paginate: import("zod/v4").ZodOptional<import("zod/v4").ZodObject<{
161
- start_after: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
162
- limit: import("zod/v4").ZodOptional<import("zod/v4").ZodBigInt>;
163
- }, import("zod/v4/core").$strict>>;
164
- order: import("zod/v4").ZodOptional<import("zod/v4").ZodObject<{
165
- desc: import("zod/v4").ZodBoolean;
166
- field: import("zod/v4").ZodEnum<{
134
+ export declare const ListDocsStoreParamsSchema: import("zod").ZodObject<{
135
+ collection: import("zod").ZodString;
136
+ caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
137
+ params: import("zod").ZodObject<{
138
+ matcher: import("zod").ZodOptional<import("zod").ZodObject<{
139
+ key: import("zod").ZodOptional<import("zod").ZodString>;
140
+ description: import("zod").ZodOptional<import("zod").ZodString>;
141
+ created_at: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
142
+ equal: import("zod").ZodBigInt;
143
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
144
+ greater_than: import("zod").ZodBigInt;
145
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
146
+ less_than: import("zod").ZodBigInt;
147
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
148
+ between: import("zod").ZodTuple<[import("zod").ZodBigInt, import("zod").ZodBigInt], null>;
149
+ }, import("zod/v4/core/schemas.cjs").$strip>]>>;
150
+ updated_at: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
151
+ equal: import("zod").ZodBigInt;
152
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
153
+ greater_than: import("zod").ZodBigInt;
154
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
155
+ less_than: import("zod").ZodBigInt;
156
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
157
+ between: import("zod").ZodTuple<[import("zod").ZodBigInt, import("zod").ZodBigInt], null>;
158
+ }, import("zod/v4/core/schemas.cjs").$strip>]>>;
159
+ }, import("zod/v4/core/schemas.cjs").$strict>>;
160
+ paginate: import("zod").ZodOptional<import("zod").ZodObject<{
161
+ start_after: import("zod").ZodOptional<import("zod").ZodString>;
162
+ limit: import("zod").ZodOptional<import("zod").ZodBigInt>;
163
+ }, import("zod/v4/core/schemas.cjs").$strict>>;
164
+ order: import("zod").ZodOptional<import("zod").ZodObject<{
165
+ desc: import("zod").ZodBoolean;
166
+ field: import("zod").ZodEnum<{
167
167
  created_at: "created_at";
168
168
  updated_at: "updated_at";
169
169
  keys: "keys";
170
170
  }>;
171
- }, import("zod/v4/core").$strict>>;
172
- owner: import("zod/v4").ZodOptional<import("zod/v4").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>>;
173
- }, import("zod/v4/core").$strict>;
174
- }, import("zod/v4/core").$strict>;
171
+ }, import("zod/v4/core/schemas.cjs").$strict>>;
172
+ owner: import("zod").ZodOptional<import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>>;
173
+ }, import("zod/v4/core/schemas.cjs").$strict>;
174
+ }, import("zod/v4/core/schemas.cjs").$strict>;
175
175
  /**
176
176
  * The parameters required to list documents from the datastore.
177
177
  */
@@ -179,9 +179,9 @@ export type ListDocsStoreParams = ListStoreParams;
179
179
  /**
180
180
  * @see DeleteDocsStoreParams
181
181
  */
182
- export declare const DeleteDocsStoreParamsSchema: import("zod/v4").ZodObject<{
183
- collection: import("zod/v4").ZodString;
184
- }, import("zod/v4/core").$strict>;
182
+ export declare const DeleteDocsStoreParamsSchema: import("zod").ZodObject<{
183
+ collection: import("zod").ZodString;
184
+ }, import("zod/v4/core/schemas.cjs").$strict>;
185
185
  /**
186
186
  * The parameters required to delete the documents from a collection of the datastore.
187
187
  */
@@ -189,47 +189,47 @@ export type DeleteDocsStoreParams = CollectionParams;
189
189
  /**
190
190
  * @see DeleteFilteredDocsParams
191
191
  */
192
- export declare const DeleteFilteredDocsStoreParamsSchema: import("zod/v4").ZodObject<{
193
- collection: import("zod/v4").ZodString;
194
- caller: import("zod/v4").ZodUnion<[import("zod/v4").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod/v4").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
195
- params: import("zod/v4").ZodObject<{
196
- matcher: import("zod/v4").ZodOptional<import("zod/v4").ZodObject<{
197
- key: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
198
- description: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
199
- created_at: import("zod/v4").ZodOptional<import("zod/v4").ZodUnion<readonly [import("zod/v4").ZodObject<{
200
- equal: import("zod/v4").ZodBigInt;
201
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
202
- greater_than: import("zod/v4").ZodBigInt;
203
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
204
- less_than: import("zod/v4").ZodBigInt;
205
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
206
- between: import("zod/v4").ZodTuple<[import("zod/v4").ZodBigInt, import("zod/v4").ZodBigInt], null>;
207
- }, import("zod/v4/core").$strip>]>>;
208
- updated_at: import("zod/v4").ZodOptional<import("zod/v4").ZodUnion<readonly [import("zod/v4").ZodObject<{
209
- equal: import("zod/v4").ZodBigInt;
210
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
211
- greater_than: import("zod/v4").ZodBigInt;
212
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
213
- less_than: import("zod/v4").ZodBigInt;
214
- }, import("zod/v4/core").$strip>, import("zod/v4").ZodObject<{
215
- between: import("zod/v4").ZodTuple<[import("zod/v4").ZodBigInt, import("zod/v4").ZodBigInt], null>;
216
- }, import("zod/v4/core").$strip>]>>;
217
- }, import("zod/v4/core").$strict>>;
218
- paginate: import("zod/v4").ZodOptional<import("zod/v4").ZodObject<{
219
- start_after: import("zod/v4").ZodOptional<import("zod/v4").ZodString>;
220
- limit: import("zod/v4").ZodOptional<import("zod/v4").ZodBigInt>;
221
- }, import("zod/v4/core").$strict>>;
222
- order: import("zod/v4").ZodOptional<import("zod/v4").ZodObject<{
223
- desc: import("zod/v4").ZodBoolean;
224
- field: import("zod/v4").ZodEnum<{
192
+ export declare const DeleteFilteredDocsStoreParamsSchema: import("zod").ZodObject<{
193
+ collection: import("zod").ZodString;
194
+ caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<import("@dfinity/principal").Principal, import("@dfinity/principal").Principal>]>;
195
+ params: import("zod").ZodObject<{
196
+ matcher: import("zod").ZodOptional<import("zod").ZodObject<{
197
+ key: import("zod").ZodOptional<import("zod").ZodString>;
198
+ description: import("zod").ZodOptional<import("zod").ZodString>;
199
+ created_at: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
200
+ equal: import("zod").ZodBigInt;
201
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
202
+ greater_than: import("zod").ZodBigInt;
203
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
204
+ less_than: import("zod").ZodBigInt;
205
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
206
+ between: import("zod").ZodTuple<[import("zod").ZodBigInt, import("zod").ZodBigInt], null>;
207
+ }, import("zod/v4/core/schemas.cjs").$strip>]>>;
208
+ updated_at: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
209
+ equal: import("zod").ZodBigInt;
210
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
211
+ greater_than: import("zod").ZodBigInt;
212
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
213
+ less_than: import("zod").ZodBigInt;
214
+ }, import("zod/v4/core/schemas.cjs").$strip>, import("zod").ZodObject<{
215
+ between: import("zod").ZodTuple<[import("zod").ZodBigInt, import("zod").ZodBigInt], null>;
216
+ }, import("zod/v4/core/schemas.cjs").$strip>]>>;
217
+ }, import("zod/v4/core/schemas.cjs").$strict>>;
218
+ paginate: import("zod").ZodOptional<import("zod").ZodObject<{
219
+ start_after: import("zod").ZodOptional<import("zod").ZodString>;
220
+ limit: import("zod").ZodOptional<import("zod").ZodBigInt>;
221
+ }, import("zod/v4/core/schemas.cjs").$strict>>;
222
+ order: import("zod").ZodOptional<import("zod").ZodObject<{
223
+ desc: import("zod").ZodBoolean;
224
+ field: import("zod").ZodEnum<{
225
225
  created_at: "created_at";
226
226
  updated_at: "updated_at";
227
227
  keys: "keys";
228
228
  }>;
229
- }, import("zod/v4/core").$strict>>;
230
- owner: import("zod/v4").ZodOptional<import("zod/v4").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>>;
231
- }, import("zod/v4/core").$strict>;
232
- }, import("zod/v4/core").$strict>;
229
+ }, import("zod/v4/core/schemas.cjs").$strict>>;
230
+ owner: import("zod").ZodOptional<import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>>;
231
+ }, import("zod/v4/core/schemas.cjs").$strict>;
232
+ }, import("zod/v4/core/schemas.cjs").$strict>;
233
233
  /**
234
234
  * The parameters required to delete documents from the datastore.
235
235
  */
@@ -1,4 +1,4 @@
1
- import * as z from 'zod/v4';
1
+ import * as z from 'zod';
2
2
  import { type ListParams } from '../../schemas/list';
3
3
  import { type Collection, type RawUserId, type UserId } from '../../schemas/satellite';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import * as z from 'zod/v4';
1
+ import * as z from 'zod';
2
2
  import { type RawUserId, type UserId } from '../../schemas/satellite';
3
3
  import { type AssetEncoding, type AssetKey, type Blob, type FullPath, type HeaderFields } from '../../schemas/storage';
4
4
  import { type Memory } from './collections';