@junobuild/functions 0.5.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +753 -323
- package/canisters/_canister.d.ts +1 -1
- package/canisters/cmc/index.js +1 -1
- package/canisters/index.js +1 -1
- package/canisters/ledger/icp/index.js +1 -1
- package/canisters/ledger/icrc/index.js +1 -1
- package/canisters/ledger/icrc/schemas.d.ts +1 -1
- package/canisters/schemas.d.ts +1 -1
- package/{chunk-5NZMOUKF.js → chunk-2LVPADWI.js} +2 -2
- package/chunk-7JYM2CKB.js +2 -0
- package/chunk-7JYM2CKB.js.map +7 -0
- package/chunk-HVIYPRXX.js +2 -0
- package/chunk-HVIYPRXX.js.map +7 -0
- package/{chunk-EMQQE34V.js → chunk-W42LR3ZN.js} +2 -2
- package/chunk-XRHVLXYG.js +2 -0
- package/functions/constants.d.ts +8 -0
- package/functions/query.d.ts +49 -0
- package/functions/schemas/function.d.ts +170 -0
- package/functions/update.d.ts +49 -0
- package/functions/wrappers.d.ts +1 -0
- package/global.d.ts +1 -0
- package/hooks/assertions.d.ts +57 -57
- package/hooks/hooks.d.ts +116 -116
- package/hooks/schemas/context.d.ts +1 -1
- package/hooks/schemas/db/context.d.ts +26 -26
- package/hooks/schemas/db/payload.d.ts +9 -9
- package/hooks/schemas/storage/context.d.ts +19 -19
- package/hooks/schemas/storage/payload.d.ts +3 -3
- package/ic-cdk/caller.ic-cdk.d.ts +15 -0
- package/ic-cdk/id.ic-cdk.d.ts +11 -1
- package/ic-cdk/schemas/call.d.ts +1 -1
- package/ic-cdk.d.ts +1 -0
- package/ic-cdk.js +1 -1
- package/ic-cdk.js.map +4 -4
- package/index.d.ts +5 -1
- package/index.js +1 -1
- package/index.js.map +4 -4
- package/package.json +3 -2
- package/schemas/candid.d.ts +5 -6
- package/schemas/db.d.ts +7 -8
- package/schemas/list.d.ts +1 -1
- package/schemas/satellite.d.ts +4 -3
- package/schemas/storage.d.ts +9 -9
- package/sdk/schemas/controllers.d.ts +4 -4
- package/sdk/schemas/db.d.ts +10 -10
- package/sdk/schemas/params.d.ts +2 -2
- package/sdk/schemas/storage.d.ts +12 -12
- package/sdk.js +1 -1
- package/sdk.js.map +4 -4
- package/src/global.d.ts +1 -0
- package/utils/zod.utils.d.ts +4 -1
- package/chunk-7B6WU32N.js +0 -2
- package/chunk-7B6WU32N.js.map +0 -7
- package/chunk-KVADXJMF.js +0 -2
- package/chunk-KVADXJMF.js.map +0 -7
- package/chunk-TZVF5LQY.js +0 -2
- /package/{chunk-5NZMOUKF.js.map → chunk-2LVPADWI.js.map} +0 -0
- /package/{chunk-EMQQE34V.js.map → chunk-W42LR3ZN.js.map} +0 -0
- /package/{chunk-TZVF5LQY.js.map → chunk-XRHVLXYG.js.map} +0 -0
- /package/{hooks/schemas → schemas}/satellite.env.d.ts +0 -0
package/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["src/
|
|
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/**\n * Wraps a Zod function schema so that parsing returns the **original function**\n * instead of Zod's wrapped validator.\n *\n * Why?\n * ----\n * In Zod v4, `z.function({...})` normally returns a wrapper that validates\n * both arguments and the return value **every time the function is called**.\n * If your function's return type is `void | Promise<void>`, Zod tries to\n * validate it synchronously, which can throw\n * \"Encountered Promise during synchronous parse\"\n * when the implementation is async.\n *\n * By using `.implement`, we tell Zod: \u201Cthis is the function that satisfies\n * the schema.\u201D That way the schema still validates the function shape at\n * parse time, but the returned value is the **original function** you passed\n * in \u2014 no runtime wrapper, no sync/async mismatch.\n *\n * Reference:\n * https://github.com/colinhacks/zod/issues/4143#issuecomment-2845134912*\n */\nexport const createFunctionSchema = <T extends z.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": "
|
|
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", "
|
|
3
|
+
"sources": ["src/functions/query.ts", "src/schemas/satellite.env.ts", "src/utils/zod.utils.ts", "src/functions/constants.ts", "src/functions/schemas/function.ts", "src/functions/update.ts", "src/hooks/assertions.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/storage/context.ts", "src/hooks/schemas/storage/payload.ts", "src/hooks/hooks.ts", "src/functions/wrappers.ts", "src/polyfills/console.polyfill.ts", "src/polyfills/random.polyfill.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\nimport {type SatelliteEnv, SatelliteEnvSchema} from '../schemas/satellite.env';\nimport {createFunctionSchema} from '../utils/zod.utils';\nimport {JUNO_FUNCTION_TYPE} from './constants';\nimport {\n type CustomFunctionWithArgs,\n type CustomFunctionWithArgsAndResult,\n type CustomFunctionWithoutArgsAndResult,\n type CustomFunctionWithResult,\n CustomFunctionWithArgsAndResultSchema,\n CustomFunctionWithArgsSchema,\n CustomFunctionWithoutArgsAndResultSchema,\n CustomFunctionWithResultSchema\n} from './schemas/function';\n\nconst QueryBaseSchema = z.strictObject({\n type: z.literal(JUNO_FUNCTION_TYPE.QUERY)\n});\n\n/**\n * @see Query\n */\nexport const QuerySchema = z.union([\n z.strictObject({\n ...CustomFunctionWithArgsAndResultSchema.shape,\n ...QueryBaseSchema.shape\n }),\n z.strictObject({\n ...CustomFunctionWithArgsSchema.shape,\n ...QueryBaseSchema.shape\n }),\n z.strictObject({\n ...CustomFunctionWithResultSchema.shape,\n ...QueryBaseSchema.shape\n }),\n z.strictObject({\n ...CustomFunctionWithoutArgsAndResultSchema.shape,\n ...QueryBaseSchema.shape\n })\n]);\n\n/**\n * The input shape for defining a query serverless function.\n * Does not include `type`, which is injected by `defineQuery`.\n */\nexport type Query<\n TArgs extends z.ZodRawShape = z.ZodRawShape,\n TResult extends z.ZodRawShape = z.ZodRawShape\n> =\n | Omit<CustomFunctionWithArgsAndResult<TArgs, TResult>, 'type'>\n | Omit<CustomFunctionWithArgs<TArgs>, 'type'>\n | Omit<CustomFunctionWithResult<TResult>, 'type'>\n | Omit<CustomFunctionWithoutArgsAndResult, 'type'>;\n\n/**\n * A query function definition with `type` injected by `defineQuery`.\n * Queries are read-only functions that do not modify state.\n */\nexport type QueryDefinition<\n TArgs extends z.ZodRawShape = z.ZodRawShape,\n TResult extends z.ZodRawShape = z.ZodRawShape\n> = Query<TArgs, TResult> & {\n type: typeof JUNO_FUNCTION_TYPE.QUERY;\n};\n\nexport const QueryFnSchema = <T extends z.ZodTypeAny>(querySchema: T) =>\n z.function({input: z.tuple([SatelliteEnvSchema]), output: querySchema});\n\n/**\n * A factory function that receives the satellite environment and returns a query definition.\n */\nexport type QueryFn<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape> = (\n env: SatelliteEnv\n) => Query<TArgs, TResult>;\n\nexport const QueryFnOrObjectSchema = <T extends z.ZodTypeAny>(querySchema: T) =>\n z.union([querySchema, createFunctionSchema(QueryFnSchema(querySchema))]);\n\n/**\n * A query definition or a factory function that returns one.\n */\nexport type QueryFnOrObject<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape> =\n | Query<TArgs, TResult>\n | QueryFn<TArgs, TResult>;\n\nexport function defineQuery<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(\n query: Query<TArgs, TResult>\n): QueryDefinition<TArgs, TResult>;\nexport function defineQuery<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(\n query: QueryFn<TArgs, TResult>\n): (env: SatelliteEnv) => QueryDefinition<TArgs, TResult>;\nexport function defineQuery<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(\n query: QueryFnOrObject<TArgs, TResult>\n): QueryDefinition<TArgs, TResult> | ((env: SatelliteEnv) => QueryDefinition<TArgs, TResult>);\nexport function defineQuery<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(\n query: Query<TArgs, TResult> | QueryFn<TArgs, TResult>\n): QueryDefinition<TArgs, TResult> | ((env: SatelliteEnv) => QueryDefinition<TArgs, TResult>) {\n if (typeof query === 'function') {\n return (env: SatelliteEnv) => {\n const result = {...query(env), type: JUNO_FUNCTION_TYPE.QUERY};\n QuerySchema.parse(result);\n return result;\n };\n }\n\n const result = {...query, type: JUNO_FUNCTION_TYPE.QUERY};\n QuerySchema.parse(result);\n return result;\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';\n\n/**\n * Wraps a Zod function schema so that parsing returns the **original function**\n * instead of Zod's wrapped validator.\n *\n * Why?\n * ----\n * In Zod v4, `z.function({...})` normally returns a wrapper that validates\n * both arguments and the return value **every time the function is called**.\n * If your function's return type is `void | Promise<void>`, Zod tries to\n * validate it synchronously, which can throw\n * \"Encountered Promise during synchronous parse\"\n * when the implementation is async.\n *\n * By using `.implement`, we tell Zod: \u201Cthis is the function that satisfies\n * the schema.\u201D That way the schema still validates the function shape at\n * parse time, but the returned value is the **original function** you passed\n * in \u2014 no runtime wrapper, no sync/async mismatch.\n *\n * Reference:\n * https://github.com/colinhacks/zod/issues/4143#issuecomment-2845134912\n *\n * Note: We need the function for this library, see following comment\n * https://github.com/colinhacks/zod/issues/4143#issuecomment-3335735535\n */\nexport const createFunctionSchema = <T extends z.ZodFunction>(schema: T) =>\n z.custom<Parameters<T['implement']>[0]>(\n (fn) => typeof fn === 'function' && schema.implement(fn as Parameters<T['implement']>[0])\n );\n", "/**\n * Internal constant used by Juno's tooling to discover serverless functions.\n * Not intended for direct use by developers.\n */\nexport const JUNO_FUNCTION_TYPE = {\n QUERY: '__juno_function_query',\n UPDATE: '__juno_function_update'\n} as const;\n", "import * as z from 'zod';\nimport {createFunctionSchema} from '../../utils/zod.utils';\nimport {JUNO_FUNCTION_TYPE} from '../constants';\n\n/**\n * The type of a serverless function. Not exposed to the developer. It allows the CLI\n * to discover the functions when parsing the code.\n */\nexport type CustomFunctionType = (typeof JUNO_FUNCTION_TYPE)[keyof typeof JUNO_FUNCTION_TYPE];\n\nconst CustomFunctionBaseSchema = z.strictObject({\n type: z.enum([JUNO_FUNCTION_TYPE.QUERY, JUNO_FUNCTION_TYPE.UPDATE])\n});\n\n/**\n * @see CustomFunctionWithArgsAndResult\n */\nexport const CustomFunctionWithArgsAndResultSchema = z.strictObject({\n ...CustomFunctionBaseSchema.shape,\n args: z.instanceof(z.ZodObject),\n result: z.instanceof(z.ZodObject),\n handler: createFunctionSchema(\n z.function({\n input: z.tuple([z.unknown()]),\n output: z.union([z.unknown(), z.promise(z.unknown())])\n })\n )\n});\n\n/**\n * @see CustomFunctionWithArgs\n */\nexport const CustomFunctionWithArgsSchema = z.strictObject({\n ...CustomFunctionBaseSchema.shape,\n args: z.instanceof(z.ZodObject),\n handler: createFunctionSchema(\n z.function({\n input: z.tuple([z.unknown()]),\n output: z.union([z.void(), z.promise(z.void())])\n })\n )\n});\n\n/**\n * @see CustomFunctionWithResult\n */\nexport const CustomFunctionWithResultSchema = z.strictObject({\n ...CustomFunctionBaseSchema.shape,\n result: z.instanceof(z.ZodObject),\n handler: createFunctionSchema(\n z.function({\n input: z.tuple([]),\n output: z.union([z.unknown(), z.promise(z.unknown())])\n })\n )\n});\n\n/**\n * @see CustomFunctionWithoutArgsAndResult\n */\nexport const CustomFunctionWithoutArgsAndResultSchema = z.strictObject({\n ...CustomFunctionBaseSchema.shape,\n handler: createFunctionSchema(\n z.function({\n input: z.tuple([]),\n output: z.union([z.void(), z.promise(z.void())])\n })\n )\n});\n\n/**\n * @see CustomFunction\n */\nexport const CustomFunctionSchema = z.union([\n CustomFunctionWithArgsAndResultSchema,\n CustomFunctionWithArgsSchema,\n CustomFunctionWithResultSchema,\n CustomFunctionWithoutArgsAndResultSchema\n]);\n\n/**\n * Base interface for all serverless function variants.\n */\ninterface CustomFunctionBase {\n /**\n * The type of the function, either a query or an update.\n */\n type: CustomFunctionType;\n}\n\n/**\n * A serverless function with both input arguments and an output result.\n *\n * @template TArgs - The type of the input arguments.\n * @template TResult - The type of the output result.\n */\nexport interface CustomFunctionWithArgsAndResult<\n TArgs extends z.ZodRawShape,\n TResult extends z.ZodRawShape\n> extends CustomFunctionBase {\n /**\n * A Zod schema describing the input arguments.\n */\n args: z.ZodObject<TArgs>;\n\n /**\n * A Zod schema describing the output result.\n */\n result: z.ZodObject<TResult>;\n\n /**\n * The function handler. Can be synchronous or asynchronous.\n *\n * @param {TArgs} args - The input arguments.\n * @returns {TResult | Promise<TResult>}\n */\n handler: (\n args: z.infer<z.ZodObject<TArgs>>\n ) => z.infer<z.ZodObject<TResult>> | Promise<z.infer<z.ZodObject<TResult>>>;\n}\n\n/**\n * A serverless function with input arguments but no output result.\n *\n * @template TArgs - The type of the input arguments.\n */\nexport interface CustomFunctionWithArgs<TArgs extends z.ZodRawShape> extends CustomFunctionBase {\n /**\n * A Zod schema describing the input arguments.\n */\n args: z.ZodObject<TArgs>;\n\n /**\n * The function handler. Can be synchronous or asynchronous.\n *\n * @param {TArgs} args - The input arguments.\n * @returns {void | Promise<void>}\n */\n handler: (args: z.infer<z.ZodObject<TArgs>>) => void | Promise<void>;\n}\n\n/**\n * A serverless function with an output result but no input arguments.\n *\n * @template TResult - The type of the output result.\n */\nexport interface CustomFunctionWithResult<\n TResult extends z.ZodRawShape\n> extends CustomFunctionBase {\n /**\n * A Zod schema describing the output result.\n */\n result: z.ZodObject<TResult>;\n\n /**\n * The function handler. Can be synchronous or asynchronous.\n *\n * @returns {TResult | Promise<TResult>}\n */\n handler: () => z.infer<z.ZodObject<TResult>> | Promise<z.infer<z.ZodObject<TResult>>>;\n}\n\n/**\n * A serverless function with no input arguments and no output result.\n */\nexport interface CustomFunctionWithoutArgsAndResult extends CustomFunctionBase {\n /**\n * The function handler. Can be synchronous or asynchronous.\n *\n * @returns {void | Promise<void>}\n */\n handler: () => void | Promise<void>;\n}\n\n/**\n * A serverless function definition. The four variants cover all combinations\n * of optional input arguments and output result.\n *\n * @template TArgs - The type of the input arguments.\n * @template TResult - The type of the output result.\n */\nexport type CustomFunction<\n TArgs extends z.ZodRawShape = z.ZodRawShape,\n TResult extends z.ZodRawShape = z.ZodRawShape\n> =\n | CustomFunctionWithArgsAndResult<TArgs, TResult>\n | CustomFunctionWithArgs<TArgs>\n | CustomFunctionWithResult<TResult>\n | CustomFunctionWithoutArgsAndResult;\n", "import * as z from 'zod';\nimport {type SatelliteEnv, SatelliteEnvSchema} from '../schemas/satellite.env';\nimport {createFunctionSchema} from '../utils/zod.utils';\nimport {JUNO_FUNCTION_TYPE} from './constants';\nimport {\n type CustomFunctionWithArgs,\n type CustomFunctionWithArgsAndResult,\n type CustomFunctionWithoutArgsAndResult,\n type CustomFunctionWithResult,\n CustomFunctionWithArgsAndResultSchema,\n CustomFunctionWithArgsSchema,\n CustomFunctionWithoutArgsAndResultSchema,\n CustomFunctionWithResultSchema\n} from './schemas/function';\n\nconst UpdateBaseSchema = z.strictObject({\n type: z.literal(JUNO_FUNCTION_TYPE.UPDATE)\n});\n\n/**\n * @see Update\n */\nexport const UpdateSchema = z.union([\n z.strictObject({\n ...CustomFunctionWithArgsAndResultSchema.shape,\n ...UpdateBaseSchema.shape\n }),\n z.strictObject({\n ...CustomFunctionWithArgsSchema.shape,\n ...UpdateBaseSchema.shape\n }),\n z.strictObject({\n ...CustomFunctionWithResultSchema.shape,\n ...UpdateBaseSchema.shape\n }),\n z.strictObject({\n ...CustomFunctionWithoutArgsAndResultSchema.shape,\n ...UpdateBaseSchema.shape\n })\n]);\n\n/**\n * The input shape for defining an update serverless function.\n * Does not include `type`, which is injected by `defineUpdate`.\n */\nexport type Update<\n TArgs extends z.ZodRawShape = z.ZodRawShape,\n TResult extends z.ZodRawShape = z.ZodRawShape\n> =\n | Omit<CustomFunctionWithArgsAndResult<TArgs, TResult>, 'type'>\n | Omit<CustomFunctionWithArgs<TArgs>, 'type'>\n | Omit<CustomFunctionWithResult<TResult>, 'type'>\n | Omit<CustomFunctionWithoutArgsAndResult, 'type'>;\n\n/**\n * A update function definition with `type` injected by `defineUpdate`.\n * Queries are read-only functions that do not modify state.\n */\nexport type UpdateDefinition<\n TArgs extends z.ZodRawShape = z.ZodRawShape,\n TResult extends z.ZodRawShape = z.ZodRawShape\n> = Update<TArgs, TResult> & {\n type: typeof JUNO_FUNCTION_TYPE.UPDATE;\n};\n\nexport const UpdateFnSchema = <T extends z.ZodTypeAny>(updateSchema: T) =>\n z.function({input: z.tuple([SatelliteEnvSchema]), output: updateSchema});\n\n/**\n * A factory function that receives the satellite environment and returns an update definition.\n */\nexport type UpdateFn<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape> = (\n env: SatelliteEnv\n) => Update<TArgs, TResult>;\n\nexport const UpdateFnOrObjectSchema = <T extends z.ZodTypeAny>(updateSchema: T) =>\n z.union([updateSchema, createFunctionSchema(UpdateFnSchema(updateSchema))]);\n\n/**\n * A update definition or a factory function that returns one.\n */\nexport type UpdateFnOrObject<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape> =\n | Update<TArgs, TResult>\n | UpdateFn<TArgs, TResult>;\n\nexport function defineUpdate<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(\n update: Update<TArgs, TResult>\n): UpdateDefinition<TArgs, TResult>;\nexport function defineUpdate<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(\n update: UpdateFn<TArgs, TResult>\n): (env: SatelliteEnv) => UpdateDefinition<TArgs, TResult>;\nexport function defineUpdate<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(\n update: UpdateFnOrObject<TArgs, TResult>\n): UpdateDefinition<TArgs, TResult> | ((env: SatelliteEnv) => UpdateDefinition<TArgs, TResult>);\nexport function defineUpdate<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(\n update: Update<TArgs, TResult> | UpdateFn<TArgs, TResult>\n): UpdateDefinition<TArgs, TResult> | ((env: SatelliteEnv) => UpdateDefinition<TArgs, TResult>) {\n if (typeof update === 'function') {\n return (env: SatelliteEnv) => {\n const result = {...update(env), type: JUNO_FUNCTION_TYPE.UPDATE};\n UpdateSchema.parse(result);\n return result;\n };\n }\n\n const result = {...update, type: JUNO_FUNCTION_TYPE.UPDATE};\n UpdateSchema.parse(result);\n return result;\n}\n", "import * as z from 'zod';\nimport {SatelliteEnvSchema} from '../schemas/satellite.env';\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 {\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';\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';\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 {SatelliteEnvSchema} from '../schemas/satellite.env';\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 {\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 {nonNullish} from '@dfinity/utils';\nimport * as z from 'zod';\nimport {decodeDocData, encodeDocData} from '../sdk/serializer.sdk';\nimport {QuerySchema} from './query';\nimport {UpdateSchema} from './update';\n\nconst ConfigSchema = z.union([QuerySchema, UpdateSchema]);\ntype Config = z.infer<typeof ConfigSchema>;\n\n// eslint-disable-next-line local-rules/prefer-object-params\nglobalThis.__juno_satellite_fn_invoke_sync = (config: Config, raw?: Uint8Array<ArrayBuffer>) => {\n ConfigSchema.parse(config);\n\n const args =\n 'args' in config && config.args instanceof z.ZodType\n ? config.args?.parse(nonNullish(raw) ? decodeDocData(raw) : undefined)\n : undefined;\n\n const execute = () => {\n if (nonNullish(args)) {\n return (config.handler as (args: unknown) => unknown)(args);\n }\n\n return (config.handler as () => unknown)();\n };\n\n const result = execute();\n\n const parsed =\n 'result' in config && config.result instanceof z.ZodType\n ? config.result?.parse(result)\n : undefined;\n\n globalThis.jsResult = nonNullish(parsed) ? encodeDocData(parsed) : parsed;\n};\n\n// eslint-disable-next-line local-rules/prefer-object-params\nglobalThis.__juno_satellite_fn_invoke_async = async (\n config: Config,\n raw?: Uint8Array<ArrayBuffer>\n) => {\n ConfigSchema.parse(config);\n\n const args =\n 'args' in config && config.args instanceof z.ZodType\n ? config.args?.parse(nonNullish(raw) ? decodeDocData(raw) : undefined)\n : undefined;\n\n const execute = async () => {\n if (nonNullish(args)) {\n return await (config.handler as (args: unknown) => unknown)(args);\n }\n\n return await (config.handler as () => unknown)();\n };\n\n const result = await execute();\n\n const parsed =\n 'result' in config && config.result instanceof z.ZodType\n ? config.result?.parse(result)\n : undefined;\n\n globalThis.jsResult = nonNullish(parsed) ? encodeDocData(parsed) : parsed;\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": "2WAAA,UAAYA,MAAO,MCAnB,UAAYC,MAAO,MAKZ,IAAMC,EAAuB,SAAS,SAAO,EAAK,SAAO,CAAC,ECLjE,UAAYC,MAAO,MA0BZ,IAAMC,EAAiDC,GAC1D,SACCC,GAAO,OAAOA,GAAO,YAAcD,EAAO,UAAUC,CAAmC,CAC1F,ECzBK,IAAMC,EAAqB,CAChC,MAAO,wBACP,OAAQ,wBACV,ECPA,UAAYC,MAAO,MAUnB,IAAMC,EAA6B,eAAa,CAC9C,KAAQ,OAAK,CAACC,EAAmB,MAAOA,EAAmB,MAAM,CAAC,CACpE,CAAC,EAKYC,EAA0C,eAAa,CAClE,GAAGF,EAAyB,MAC5B,KAAQ,aAAa,WAAS,EAC9B,OAAU,aAAa,WAAS,EAChC,QAASG,EACL,WAAS,CACT,MAAS,QAAM,CAAG,UAAQ,CAAC,CAAC,EAC5B,OAAU,QAAM,CAAG,UAAQ,EAAK,UAAU,UAAQ,CAAC,CAAC,CAAC,CACvD,CAAC,CACH,CACF,CAAC,EAKYC,EAAiC,eAAa,CACzD,GAAGJ,EAAyB,MAC5B,KAAQ,aAAa,WAAS,EAC9B,QAASG,EACL,WAAS,CACT,MAAS,QAAM,CAAG,UAAQ,CAAC,CAAC,EAC5B,OAAU,QAAM,CAAG,OAAK,EAAK,UAAU,OAAK,CAAC,CAAC,CAAC,CACjD,CAAC,CACH,C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AAW,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
|
+
"names": ["z", "z", "SatelliteEnvSchema", "z", "createFunctionSchema", "schema", "fn", "JUNO_FUNCTION_TYPE", "z", "CustomFunctionBaseSchema", "JUNO_FUNCTION_TYPE", "CustomFunctionWithArgsAndResultSchema", "createFunctionSchema", "CustomFunctionWithArgsSchema", "CustomFunctionWithResultSchema", "CustomFunctionWithoutArgsAndResultSchema", "CustomFunctionSchema", "QueryBaseSchema", "JUNO_FUNCTION_TYPE", "QuerySchema", "CustomFunctionWithArgsAndResultSchema", "CustomFunctionWithArgsSchema", "CustomFunctionWithResultSchema", "CustomFunctionWithoutArgsAndResultSchema", "QueryFnSchema", "querySchema", "SatelliteEnvSchema", "QueryFnOrObjectSchema", "createFunctionSchema", "defineQuery", "query", "env", "result", "z", "UpdateBaseSchema", "JUNO_FUNCTION_TYPE", "UpdateSchema", "CustomFunctionWithArgsAndResultSchema", "CustomFunctionWithArgsSchema", "CustomFunctionWithResultSchema", "CustomFunctionWithoutArgsAndResultSchema", "UpdateFnSchema", "updateSchema", "SatelliteEnvSchema", "UpdateFnOrObjectSchema", "createFunctionSchema", "defineUpdate", "update", "env", "result", "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", "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", "nonNullish", "z", "ConfigSchema", "QuerySchema", "UpdateSchema", "config", "raw", "args", "nonNullish", "decodeDocData", "result", "parsed", "encodeDocData", "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.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "JavaScript and TypeScript utilities for Juno Serverless Functions",
|
|
5
5
|
"author": "David Dal Busco (https://daviddalbusco.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"@dfinity/utils": "^4.1",
|
|
98
98
|
"@icp-sdk/core": "^5",
|
|
99
|
-
"zod": "^
|
|
99
|
+
"@junobuild/zod": "^1",
|
|
100
|
+
"zod": "^4.3"
|
|
100
101
|
}
|
|
101
102
|
}
|
package/schemas/candid.d.ts
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as z from 'zod';
|
|
1
|
+
import type * as z from 'zod';
|
|
3
2
|
/**
|
|
4
3
|
* A schema that validates a value is an Uint8Array.
|
|
5
4
|
*/
|
|
6
|
-
export declare const Uint8ArraySchema: z.ZodCustom<Uint8Array<
|
|
5
|
+
export declare const Uint8ArraySchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
7
6
|
/**
|
|
8
7
|
* @see RawPrincipal
|
|
9
8
|
*/
|
|
10
|
-
export declare const RawPrincipalSchema: z.ZodCustom<Uint8Array<
|
|
9
|
+
export declare const RawPrincipalSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
11
10
|
/**
|
|
12
11
|
* Represents a raw principal - a Uint8Array representation of a Principal.
|
|
13
12
|
*/
|
|
14
|
-
export type RawPrincipal =
|
|
13
|
+
export type RawPrincipal = Uint8Array;
|
|
15
14
|
/**
|
|
16
15
|
* @see Principal
|
|
17
16
|
*/
|
|
18
|
-
export declare const PrincipalSchema: z.ZodCustom<
|
|
17
|
+
export declare const PrincipalSchema: z.ZodPipe<z.ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, z.ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>;
|
|
19
18
|
/**
|
|
20
19
|
* Represents a principal - i.e. an object instantiated with the class Principal.
|
|
21
20
|
*/
|
package/schemas/db.d.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
-
import { Uint8ArraySchema } from './candid';
|
|
3
2
|
import { type Description, type RawUserId, type Timestamp, type Version } from './satellite';
|
|
4
3
|
/**
|
|
5
4
|
* @see RawData
|
|
6
5
|
*/
|
|
7
|
-
export declare const RawDataSchema: z.ZodCustom<Uint8Array<
|
|
6
|
+
export declare const RawDataSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
8
7
|
/**
|
|
9
8
|
* Represents raw binary data.
|
|
10
9
|
*
|
|
11
10
|
* This is used to store structured data in a document.
|
|
12
11
|
*/
|
|
13
|
-
export type RawData =
|
|
12
|
+
export type RawData = Uint8Array;
|
|
14
13
|
/**
|
|
15
14
|
* @see Doc
|
|
16
15
|
*/
|
|
17
16
|
export declare const DocSchema: z.ZodObject<{
|
|
18
|
-
owner: z.ZodCustom<Uint8Array<
|
|
19
|
-
data: z.ZodCustom<Uint8Array<
|
|
17
|
+
owner: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
18
|
+
data: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
20
19
|
description: z.ZodOptional<z.ZodString>;
|
|
21
20
|
created_at: z.ZodBigInt;
|
|
22
21
|
updated_at: z.ZodBigInt;
|
|
@@ -56,8 +55,8 @@ export interface Doc {
|
|
|
56
55
|
* @see OptionDoc
|
|
57
56
|
*/
|
|
58
57
|
export declare const OptionDocSchema: z.ZodOptional<z.ZodObject<{
|
|
59
|
-
owner: z.ZodCustom<Uint8Array<
|
|
60
|
-
data: z.ZodCustom<Uint8Array<
|
|
58
|
+
owner: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
59
|
+
data: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
61
60
|
description: z.ZodOptional<z.ZodString>;
|
|
62
61
|
created_at: z.ZodBigInt;
|
|
63
62
|
updated_at: z.ZodBigInt;
|
|
@@ -71,7 +70,7 @@ export type OptionDoc = Doc | undefined;
|
|
|
71
70
|
* @see SetDoc
|
|
72
71
|
*/
|
|
73
72
|
export declare const SetDocSchema: z.ZodObject<{
|
|
74
|
-
data: z.ZodCustom<Uint8Array<
|
|
73
|
+
data: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
75
74
|
description: z.ZodOptional<z.ZodString>;
|
|
76
75
|
version: z.ZodOptional<z.ZodBigInt>;
|
|
77
76
|
}, z.core.$strict>;
|
package/schemas/list.d.ts
CHANGED
|
@@ -140,7 +140,7 @@ export declare const ListParamsSchema: z.ZodObject<{
|
|
|
140
140
|
keys: "keys";
|
|
141
141
|
}>;
|
|
142
142
|
}, z.core.$strict>>;
|
|
143
|
-
owner: z.ZodOptional<z.ZodCustom<Uint8Array<
|
|
143
|
+
owner: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
144
144
|
}, z.core.$strict>;
|
|
145
145
|
/**
|
|
146
146
|
* Full set of listing parameters.
|
package/schemas/satellite.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
+
import { type RawPrincipal } from './candid';
|
|
2
3
|
/**
|
|
3
4
|
* @see Timestamp
|
|
4
5
|
*/
|
|
@@ -22,17 +23,17 @@ export type Version = z.infer<typeof VersionSchema>;
|
|
|
22
23
|
/**
|
|
23
24
|
* @see RawUserId
|
|
24
25
|
*/
|
|
25
|
-
export declare const RawUserIdSchema: z.ZodCustom<Uint8Array<
|
|
26
|
+
export declare const RawUserIdSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
26
27
|
/**
|
|
27
28
|
* Represents a raw user identifier.
|
|
28
29
|
*
|
|
29
30
|
* This is a principal associated with a user.
|
|
30
31
|
*/
|
|
31
|
-
export type RawUserId =
|
|
32
|
+
export type RawUserId = RawPrincipal;
|
|
32
33
|
/**
|
|
33
34
|
* @see UserId
|
|
34
35
|
*/
|
|
35
|
-
export declare const UserIdSchema: z.ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal
|
|
36
|
+
export declare const UserIdSchema: z.ZodPipe<z.ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, z.ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>;
|
|
36
37
|
/**
|
|
37
38
|
* Represents a user identifier.
|
|
38
39
|
*
|
package/schemas/storage.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type HeaderFields = HeaderField[];
|
|
|
15
15
|
/**
|
|
16
16
|
* @see Blob
|
|
17
17
|
*/
|
|
18
|
-
export declare const BlobSchema: z.ZodCustom<Uint8Array<
|
|
18
|
+
export declare const BlobSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
19
19
|
/**
|
|
20
20
|
* Binary content used in asset encoding.
|
|
21
21
|
*/
|
|
@@ -36,7 +36,7 @@ export declare const AssetKeySchema: z.ZodObject<{
|
|
|
36
36
|
full_path: z.ZodString;
|
|
37
37
|
token: z.ZodOptional<z.ZodString>;
|
|
38
38
|
collection: z.ZodString;
|
|
39
|
-
owner: z.ZodCustom<Uint8Array<
|
|
39
|
+
owner: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
40
40
|
description: z.ZodOptional<z.ZodString>;
|
|
41
41
|
}, z.core.$strict>;
|
|
42
42
|
/**
|
|
@@ -74,7 +74,7 @@ export interface AssetKey {
|
|
|
74
74
|
*/
|
|
75
75
|
export declare const AssetEncodingSchema: z.ZodObject<{
|
|
76
76
|
modified: z.ZodBigInt;
|
|
77
|
-
content_chunks: z.ZodArray<z.ZodCustom<Uint8Array<
|
|
77
|
+
content_chunks: z.ZodArray<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
78
78
|
total_length: z.ZodBigInt;
|
|
79
79
|
sha256: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
80
80
|
}, z.core.$strip>;
|
|
@@ -116,7 +116,7 @@ export declare const AssetSchema: z.ZodObject<{
|
|
|
116
116
|
full_path: z.ZodString;
|
|
117
117
|
token: z.ZodOptional<z.ZodString>;
|
|
118
118
|
collection: z.ZodString;
|
|
119
|
-
owner: z.ZodCustom<Uint8Array<
|
|
119
|
+
owner: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
120
120
|
description: z.ZodOptional<z.ZodString>;
|
|
121
121
|
}, z.core.$strict>;
|
|
122
122
|
headers: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
|
|
@@ -128,7 +128,7 @@ export declare const AssetSchema: z.ZodObject<{
|
|
|
128
128
|
br: "br";
|
|
129
129
|
}>, z.ZodObject<{
|
|
130
130
|
modified: z.ZodBigInt;
|
|
131
|
-
content_chunks: z.ZodArray<z.ZodCustom<Uint8Array<
|
|
131
|
+
content_chunks: z.ZodArray<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
132
132
|
total_length: z.ZodBigInt;
|
|
133
133
|
sha256: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
134
134
|
}, z.core.$strip>], null>>;
|
|
@@ -177,7 +177,7 @@ export declare const AssetNoContentSchema: z.ZodObject<{
|
|
|
177
177
|
full_path: z.ZodString;
|
|
178
178
|
token: z.ZodOptional<z.ZodString>;
|
|
179
179
|
collection: z.ZodString;
|
|
180
|
-
owner: z.ZodCustom<Uint8Array<
|
|
180
|
+
owner: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
181
181
|
description: z.ZodOptional<z.ZodString>;
|
|
182
182
|
}, z.core.$strict>;
|
|
183
183
|
headers: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
|
|
@@ -212,7 +212,7 @@ export declare const BatchSchema: z.ZodObject<{
|
|
|
212
212
|
full_path: z.ZodString;
|
|
213
213
|
token: z.ZodOptional<z.ZodString>;
|
|
214
214
|
collection: z.ZodString;
|
|
215
|
-
owner: z.ZodCustom<Uint8Array<
|
|
215
|
+
owner: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
216
216
|
description: z.ZodOptional<z.ZodString>;
|
|
217
217
|
}, z.core.$strict>;
|
|
218
218
|
reference_id: z.ZodOptional<z.ZodBigInt>;
|
|
@@ -310,7 +310,7 @@ export declare const OptionAssetSchema: z.ZodOptional<z.ZodObject<{
|
|
|
310
310
|
full_path: z.ZodString;
|
|
311
311
|
token: z.ZodOptional<z.ZodString>;
|
|
312
312
|
collection: z.ZodString;
|
|
313
|
-
owner: z.ZodCustom<Uint8Array<
|
|
313
|
+
owner: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
314
314
|
description: z.ZodOptional<z.ZodString>;
|
|
315
315
|
}, z.core.$strict>;
|
|
316
316
|
headers: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
|
|
@@ -322,7 +322,7 @@ export declare const OptionAssetSchema: z.ZodOptional<z.ZodObject<{
|
|
|
322
322
|
br: "br";
|
|
323
323
|
}>, z.ZodObject<{
|
|
324
324
|
modified: z.ZodBigInt;
|
|
325
|
-
content_chunks: z.ZodArray<z.ZodCustom<Uint8Array<
|
|
325
|
+
content_chunks: z.ZodArray<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
326
326
|
total_length: z.ZodBigInt;
|
|
327
327
|
sha256: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
328
328
|
}, z.core.$strip>], null>>;
|
|
@@ -81,7 +81,7 @@ export interface Controller {
|
|
|
81
81
|
/**
|
|
82
82
|
* @see ControllerRecordSchema
|
|
83
83
|
*/
|
|
84
|
-
export declare const ControllerRecordSchema: z.ZodTuple<[z.ZodCustom<Uint8Array<
|
|
84
|
+
export declare const ControllerRecordSchema: z.ZodTuple<[z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodObject<{
|
|
85
85
|
metadata: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
|
|
86
86
|
created_at: z.ZodBigInt;
|
|
87
87
|
updated_at: z.ZodBigInt;
|
|
@@ -103,7 +103,7 @@ export type ControllerRecord = z.infer<typeof ControllerRecordSchema>;
|
|
|
103
103
|
/**
|
|
104
104
|
* @see ControllersSchema
|
|
105
105
|
*/
|
|
106
|
-
export declare const ControllersSchema: z.ZodArray<z.ZodTuple<[z.ZodCustom<Uint8Array<
|
|
106
|
+
export declare const ControllersSchema: z.ZodArray<z.ZodTuple<[z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodObject<{
|
|
107
107
|
metadata: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
|
|
108
108
|
created_at: z.ZodBigInt;
|
|
109
109
|
updated_at: z.ZodBigInt;
|
|
@@ -126,8 +126,8 @@ export type Controllers = z.infer<typeof ControllersSchema>;
|
|
|
126
126
|
* @see ControllerCheckParamsSchema
|
|
127
127
|
*/
|
|
128
128
|
export declare const ControllerCheckParamsSchema: z.ZodObject<{
|
|
129
|
-
caller: z.ZodUnion<[z.ZodCustom<Uint8Array<
|
|
130
|
-
controllers: z.ZodArray<z.ZodTuple<[z.ZodCustom<Uint8Array<
|
|
129
|
+
caller: z.ZodUnion<[z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodPipe<z.ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, z.ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>]>;
|
|
130
|
+
controllers: z.ZodArray<z.ZodTuple<[z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodObject<{
|
|
131
131
|
metadata: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
|
|
132
132
|
created_at: z.ZodBigInt;
|
|
133
133
|
updated_at: z.ZodBigInt;
|
package/sdk/schemas/db.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type CollectionParams, type ListStoreParams } from './params';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const GetDocStoreParamsSchema: import("zod").ZodObject<{
|
|
8
8
|
collection: import("zod").ZodString;
|
|
9
|
-
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<
|
|
9
|
+
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, import("zod").ZodPipe<import("zod").ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, import("zod").ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>]>;
|
|
10
10
|
key: import("zod").ZodString;
|
|
11
11
|
}, import("zod/v4/core").$strict>;
|
|
12
12
|
/**
|
|
@@ -27,10 +27,10 @@ export type GetDocStoreParams = CollectionParams & {
|
|
|
27
27
|
*/
|
|
28
28
|
export declare const SetDocStoreParamsSchema: import("zod").ZodObject<{
|
|
29
29
|
collection: import("zod").ZodString;
|
|
30
|
-
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<
|
|
30
|
+
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, import("zod").ZodPipe<import("zod").ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, import("zod").ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>]>;
|
|
31
31
|
key: import("zod").ZodString;
|
|
32
32
|
doc: import("zod").ZodObject<{
|
|
33
|
-
data: import("zod").ZodCustom<Uint8Array<
|
|
33
|
+
data: import("zod").ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
34
34
|
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
35
35
|
version: import("zod").ZodOptional<import("zod").ZodBigInt>;
|
|
36
36
|
}, import("zod/v4/core").$strict>;
|
|
@@ -52,7 +52,7 @@ export type SetDocStoreParams = GetDocStoreParams & {
|
|
|
52
52
|
*/
|
|
53
53
|
export declare const DeleteDocStoreParamsSchema: import("zod").ZodObject<{
|
|
54
54
|
collection: import("zod").ZodString;
|
|
55
|
-
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<
|
|
55
|
+
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, import("zod").ZodPipe<import("zod").ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, import("zod").ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>]>;
|
|
56
56
|
key: import("zod").ZodString;
|
|
57
57
|
doc: import("zod").ZodObject<{
|
|
58
58
|
version: import("zod").ZodOptional<import("zod").ZodBigInt>;
|
|
@@ -85,7 +85,7 @@ export type CountCollectionDocsStoreParams = CollectionParams;
|
|
|
85
85
|
*/
|
|
86
86
|
export declare const CountDocsStoreParamsSchema: import("zod").ZodObject<{
|
|
87
87
|
collection: import("zod").ZodString;
|
|
88
|
-
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<
|
|
88
|
+
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, import("zod").ZodPipe<import("zod").ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, import("zod").ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>]>;
|
|
89
89
|
params: import("zod").ZodObject<{
|
|
90
90
|
matcher: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
91
91
|
key: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -121,7 +121,7 @@ export declare const CountDocsStoreParamsSchema: import("zod").ZodObject<{
|
|
|
121
121
|
keys: "keys";
|
|
122
122
|
}>;
|
|
123
123
|
}, import("zod/v4/core").$strict>>;
|
|
124
|
-
owner: import("zod").ZodOptional<import("zod").ZodCustom<Uint8Array<
|
|
124
|
+
owner: import("zod").ZodOptional<import("zod").ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
125
125
|
}, import("zod/v4/core").$strict>;
|
|
126
126
|
}, import("zod/v4/core").$strict>;
|
|
127
127
|
/**
|
|
@@ -133,7 +133,7 @@ export type CountDocsStoreParams = ListStoreParams;
|
|
|
133
133
|
*/
|
|
134
134
|
export declare const ListDocsStoreParamsSchema: import("zod").ZodObject<{
|
|
135
135
|
collection: import("zod").ZodString;
|
|
136
|
-
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<
|
|
136
|
+
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, import("zod").ZodPipe<import("zod").ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, import("zod").ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>]>;
|
|
137
137
|
params: import("zod").ZodObject<{
|
|
138
138
|
matcher: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
139
139
|
key: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -169,7 +169,7 @@ export declare const ListDocsStoreParamsSchema: import("zod").ZodObject<{
|
|
|
169
169
|
keys: "keys";
|
|
170
170
|
}>;
|
|
171
171
|
}, import("zod/v4/core").$strict>>;
|
|
172
|
-
owner: import("zod").ZodOptional<import("zod").ZodCustom<Uint8Array<
|
|
172
|
+
owner: import("zod").ZodOptional<import("zod").ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
173
173
|
}, import("zod/v4/core").$strict>;
|
|
174
174
|
}, import("zod/v4/core").$strict>;
|
|
175
175
|
/**
|
|
@@ -191,7 +191,7 @@ export type DeleteDocsStoreParams = CollectionParams;
|
|
|
191
191
|
*/
|
|
192
192
|
export declare const DeleteFilteredDocsStoreParamsSchema: import("zod").ZodObject<{
|
|
193
193
|
collection: import("zod").ZodString;
|
|
194
|
-
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<
|
|
194
|
+
caller: import("zod").ZodUnion<[import("zod").ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, import("zod").ZodPipe<import("zod").ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, import("zod").ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>]>;
|
|
195
195
|
params: import("zod").ZodObject<{
|
|
196
196
|
matcher: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
197
197
|
key: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -227,7 +227,7 @@ export declare const DeleteFilteredDocsStoreParamsSchema: import("zod").ZodObjec
|
|
|
227
227
|
keys: "keys";
|
|
228
228
|
}>;
|
|
229
229
|
}, import("zod/v4/core").$strict>>;
|
|
230
|
-
owner: import("zod").ZodOptional<import("zod").ZodCustom<Uint8Array<
|
|
230
|
+
owner: import("zod").ZodOptional<import("zod").ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
231
231
|
}, import("zod/v4/core").$strict>;
|
|
232
232
|
}, import("zod/v4/core").$strict>;
|
|
233
233
|
/**
|
package/sdk/schemas/params.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface CollectionParams {
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const ListStoreParamsSchema: z.ZodObject<{
|
|
23
23
|
collection: z.ZodString;
|
|
24
|
-
caller: z.ZodUnion<[z.ZodCustom<Uint8Array<
|
|
24
|
+
caller: z.ZodUnion<[z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodPipe<z.ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, z.ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>]>;
|
|
25
25
|
params: z.ZodObject<{
|
|
26
26
|
matcher: z.ZodOptional<z.ZodObject<{
|
|
27
27
|
key: z.ZodOptional<z.ZodString>;
|
|
@@ -57,7 +57,7 @@ export declare const ListStoreParamsSchema: z.ZodObject<{
|
|
|
57
57
|
keys: "keys";
|
|
58
58
|
}>;
|
|
59
59
|
}, z.core.$strict>>;
|
|
60
|
-
owner: z.ZodOptional<z.ZodCustom<Uint8Array<
|
|
60
|
+
owner: z.ZodOptional<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>;
|
|
61
61
|
}, z.core.$strict>;
|
|
62
62
|
}, z.core.$strict>;
|
|
63
63
|
/**
|