@junobuild/functions 0.0.4 → 0.0.5

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/configs/assert.config.ts", "../../src/hooks/context.ts", "../../src/hooks/core.ts", "../../src/hooks/datastore.ts", "../../src/configs/collections.config.ts", "../../src/configs/satellite.config.ts", "../../src/configs/hook.config.ts", "../../src/sdk/datastore.sdk.ts", "../../src/polyfills/console.polyfill.ts"],
4
- "sourcesContent": ["import * as z from 'zod';\nimport {AssertSetDocContextSchema} from '../hooks/context';\nimport {CollectionsConfigSchema} from './collections.config';\nimport {SatelliteConfigEnvSchema} from './satellite.config';\n\n/**\n * A generic configuration schema for defining assertions related to collections.\n *\n * @template T - The type of context passed to the assertions when triggered.\n */\nconst OnAssertConfigSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsConfigSchema.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 {Promise<void>} Resolves when the operation completes.\n */\n assert: z.function().args(contextSchema).returns(z.promise(z.void()))\n }).strict();\n\n/**\n * @see AssertSetDocConfig\n */\nexport const AssertSetDocConfigSchema = OnAssertConfigSchema(AssertSetDocContextSchema);\n\n/**\n * Configuration schema for an assertion that runs when a document is created or updated.\n */\nexport type AssertSetDocConfig = z.infer<typeof AssertSetDocConfigSchema>;\n\n// TODO: to be extended\n/**\n * @see AssertConfig\n */\nexport const AssertConfigSchema = AssertSetDocConfigSchema;\n\n/**\n * All possible config for assertions.\n */\nexport type AssertConfig = z.infer<typeof AssertConfigSchema>;\n\nexport const AssertFnSchema = <T extends z.ZodTypeAny>(hookConfigSchema: T) =>\n z.function().args(SatelliteConfigEnvSchema).returns(hookConfigSchema);\nexport type AssertFn<T extends AssertConfig> = (\n config: z.infer<typeof SatelliteConfigEnvSchema>\n) => T;\n\nexport const AssertFnOrObjectSchema = <T extends z.ZodTypeAny>(hookConfigSchema: T) =>\n z.union([hookConfigSchema, AssertFnSchema(hookConfigSchema)]);\nexport type AssertFnOrObject<T extends AssertConfig> = T | AssertFn<T>;\n\nexport function defineAssert<T extends AssertConfig>(config: T): T;\nexport function defineAssert<T extends AssertConfig>(config: AssertFn<T>): AssertFn<T>;\nexport function defineAssert<T extends AssertConfig>(\n config: AssertFnOrObject<T>\n): AssertFnOrObject<T>;\nexport function defineAssert<T extends AssertConfig>(\n config: AssertFnOrObject<T>\n): AssertFnOrObject<T> {\n return config;\n}\n", "import * as z from 'zod';\nimport {RawUserIdSchema} from './core';\nimport {DocAssertSetSchema, DocUpsertSchema} from './datastore';\n\n/**\n * @see HookContext\n */\nconst HookContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z\n .object({\n /**\n * The user who originally triggered the function that in turn triggered the hook.\n */\n caller: RawUserIdSchema,\n\n /**\n * The data associated with the hook execution.\n */\n data: dataSchema\n })\n .strict();\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 type HookContext<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof HookContextSchema<T>>>;\n\n/**\n * @see DocContext\n */\nexport const DocContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z\n .object({\n /**\n * The name of the collection where the document is stored.\n */\n collection: z.string(),\n\n /**\n * The unique key identifying the document within the collection.\n */\n key: z.string(),\n\n /**\n * The data associated with the document operation.\n */\n data: dataSchema\n })\n .strict();\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 type DocContext<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof DocContextSchema<T>>>;\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 = z.infer<typeof OnSetDocContextSchema>;\n\n/**\n * @see AssertSetDocContext\n */\nexport const AssertSetDocContextSchema = HookContextSchema(DocContextSchema(DocAssertSetSchema));\n\n/**\n * The context provided to the `assertSetDoc` 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 = z.infer<typeof AssertSetDocContextSchema>;\n", "import * as z from 'zod';\n\n/**\n * @see Timestamp\n */\nexport const TimestampSchema = z.bigint();\n\n/**\n * Represents a timestamp in nanoseconds since the Unix epoch.\n *\n * Used for tracking when events occur, such as document creation and updates.\n */\nexport type Timestamp = z.infer<typeof TimestampSchema>;\n\n/**\n * @see Version\n */\nexport const VersionSchema = z.bigint();\n\n/**\n * Represents a version number for tracking changes.\n *\n * This is typically incremented with each update to ensure consistency.\n */\nexport type Version = z.infer<typeof VersionSchema>;\n\n/**\n * @see RawData\n */\nexport const RawDataSchema = z.instanceof(Uint8Array);\n\n/**\n * Represents raw binary data.\n *\n * This is used to store unstructured data in a document.\n */\nexport type RawData = z.infer<typeof RawDataSchema>;\n\n/**\n * @see RawPrincipal\n */\nexport const RawPrincipalSchema = z.custom<Uint8Array>((val) => val instanceof Uint8Array, {\n message: 'Expected Uint8Array'\n});\n\n/**\n * Represents a raw principal identifier.\n *\n * Principals are unique identities used in authentication and authorization.\n */\nexport type RawPrincipal = z.infer<typeof RawPrincipalSchema>;\n\n/**\n * @see RawUserId\n */\nexport const RawUserIdSchema = RawPrincipalSchema;\n\n/**\n * Represents a raw user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type RawUserId = z.infer<typeof RawUserIdSchema>;\n", "import * as z from 'zod';\nimport {RawDataSchema, RawUserIdSchema, TimestampSchema, VersionSchema} from './core';\n\n/**\n * @see DocDescription\n */\nexport const DocDescriptionSchema = z.string().max(1024);\n\n/**\n * Represents a document description with a maximum length of 1024 characters.\n */\nexport type DocDescription = z.infer<typeof DocDescriptionSchema>;\n\n/**\n * @see Doc\n */\nexport const DocSchema = z\n .object({\n /**\n * The user who owns this document.\n */\n owner: RawUserIdSchema,\n\n /**\n * The raw data of the document.\n */\n data: RawDataSchema,\n\n /**\n * An optional description of the document.\n */\n description: DocDescriptionSchema.optional(),\n\n /**\n * The timestamp when the document was first created.\n */\n created_at: TimestampSchema,\n\n /**\n * The timestamp when the document was last updated.\n */\n updated_at: TimestampSchema,\n\n /**\n * The version number of the document, used for consistency checks.\n * If not provided, it's assumed to be the first version.\n */\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents a document stored in a collection.\n */\nexport type Doc = z.infer<typeof DocSchema>;\n\n/**\n * @see DocUpsert\n */\nexport const DocUpsertSchema = z\n .object({\n /**\n * The previous version of the document before the update.\n * Undefined if this is a new document.\n */\n before: DocSchema.optional(),\n\n /**\n * The new version of the document after the update.\n */\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 type DocUpsert = z.infer<typeof DocUpsertSchema>;\n\n/**\n * @see ProposedDoc\n */\nexport const ProposedDocSchema = z\n .object({\n /**\n * The raw data of the document.\n */\n data: RawDataSchema,\n\n /**\n * An optional description of the document.\n */\n description: DocDescriptionSchema.optional(),\n\n /**\n * The expected version number to ensure consistency.\n */\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document.\n * This can be validated before allowing the operation.\n */\nexport type ProposedDoc = z.infer<typeof ProposedDocSchema>;\n\n/**\n * @see DocAssertSet\n */\nexport const DocAssertSetSchema = z\n .object({\n /**\n * The current version of the document before the operation.\n * Undefined if this is a new document.\n */\n current: DocSchema.optional(),\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: ProposedDocSchema\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 type DocAssertSet = z.infer<typeof DocAssertSetSchema>;\n\n/**\n * @see SetDoc\n */\nexport const SetDocSchema = z\n .object({\n /**\n * The raw data of the document.\n */\n data: RawDataSchema,\n\n /**\n * An optional description of the document.\n */\n description: DocDescriptionSchema.optional(),\n\n /**\n * The expected version number to ensure consistency.\n * If provided, the operation will fail if the stored version does not match.\n */\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents a request to set or update a document.\n *\n * This is used when submitting new document data.\n */\nexport type SetDoc = z.infer<typeof SetDocSchema>;\n", "import * as z from 'zod';\n\n/**\n * Defines the collections where a hook or assertion should run.\n */\nexport const CollectionsConfigSchema = z\n .object({\n /**\n * An array containing at least one collection name where the hook or assertion will be executed.\n */\n collections: z.array(z.string()).min(1)\n })\n .strict();\n\n/** @typedef {z.infer<typeof CollectionsConfigSchema>} CollectionsConfig */\nexport type CollectionsConfig = z.infer<typeof CollectionsConfigSchema>;\n", "import * as z from 'zod';\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 const SatelliteConfigEnvSchema = z.record(z.unknown());\n\n/** @typedef {z.infer<typeof SatelliteConfigEnvSchema>} SatelliteConfigEnv */\nexport type SatelliteConfigEnv = z.infer<typeof SatelliteConfigEnvSchema>;\n", "import * as z from 'zod';\nimport {OnSetDocContextSchema} from '../hooks/context';\nimport {CollectionsConfigSchema} from './collections.config';\nimport {SatelliteConfigEnvSchema} from './satellite.config';\n\n/**\n * A generic configuration schema for defining hooks related to collections.\n *\n * @template T - The type of context passed to the hook when triggered.\n */\nconst OnHookConfigSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsConfigSchema.extend({\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: z.function().args(contextSchema).returns(z.promise(z.void()))\n }).strict();\n\n/**\n * @see OnSetDocConfig\n */\nexport const OnSetDocConfigSchema = OnHookConfigSchema(OnSetDocContextSchema);\n\n/**\n * Configuration for a hook that runs when a document is created or updated.\n */\nexport type OnSetDocConfig = z.infer<typeof OnSetDocConfigSchema>;\n\n// TODO: to be extended\n/**\n * @see HookConfig\n */\nexport const HookConfigSchema = OnSetDocConfigSchema;\n\n/**\n * All possible config for assertions.\n */\nexport type HookConfig = z.infer<typeof HookConfigSchema>;\n\nexport const HookFnSchema = <T extends z.ZodTypeAny>(hookConfigSchema: T) =>\n z.function().args(SatelliteConfigEnvSchema).returns(hookConfigSchema);\nexport type HookFn<T extends HookConfig> = (config: z.infer<typeof SatelliteConfigEnvSchema>) => T;\n\nexport const HookFnOrObjectSchema = <T extends z.ZodTypeAny>(hookConfigSchema: T) =>\n z.union([hookConfigSchema, HookFnSchema(hookConfigSchema)]);\nexport type HookFnOrObject<T extends HookConfig> = T | HookFn<T>;\n\nexport function defineHook<T extends HookConfig>(config: T): T;\nexport function defineHook<T extends HookConfig>(config: HookFn<T>): HookFn<T>;\nexport function defineHook<T extends HookConfig>(config: HookFnOrObject<T>): HookFnOrObject<T>;\nexport function defineHook<T extends HookConfig>(config: HookFnOrObject<T>): HookFnOrObject<T> {\n return config;\n}\n", "import {jsonReplacer, jsonReviver} from '@dfinity/utils';\nimport type {RawData} from '../hooks/core';\n\nexport const decodeDocData = <T>(data: RawData): T =>\n JSON.parse(__juno_satellite_datastore_raw_data_to_text(data), jsonReviver);\n\nexport const encodeDocData = <T>(data: T): RawData =>\n __juno_satellite_datastore_raw_data_from_text(JSON.stringify(data, jsonReplacer));\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"],
5
- "mappings": "AAAA,UAAYA,MAAO,MCAnB,UAAYC,MAAO,MCAnB,UAAYC,MAAO,MAKZ,IAAMC,EAAoB,SAAO,EAY3BC,EAAkB,SAAO,EAYzBC,EAAkB,aAAW,UAAU,EAYvCC,EAAuB,SAAoBC,GAAQA,aAAe,WAAY,CACzF,QAAS,qBACX,CAAC,EAYYC,EAAkBF,ECvD/B,UAAYG,MAAO,MAMZ,IAAMC,EAAyB,SAAO,EAAE,IAAI,IAAI,EAU1CC,EACV,SAAO,CAIN,MAAOC,EAKP,KAAMC,EAKN,YAAaH,EAAqB,SAAS,EAK3C,WAAYI,EAKZ,WAAYA,EAMZ,QAASC,EAAc,SAAS,CAClC,CAAC,EACA,OAAO,EAUGC,EACV,SAAO,CAKN,OAAQL,EAAU,SAAS,EAK3B,MAAOA,CACT,CAAC,EACA,OAAO,EAYGM,EACV,SAAO,CAIN,KAAMJ,EAKN,YAAaH,EAAqB,SAAS,EAK3C,QAASK,EAAc,SAAS,CAClC,CAAC,EACA,OAAO,EAWGG,EACV,SAAO,CAKN,QAASP,EAAU,SAAS,EAM5B,SAAUM,CACZ,CAAC,EACA,OAAO,EAaGE,EACV,SAAO,CAIN,KAAMN,EAKN,YAAaH,EAAqB,SAAS,EAM3C,QAASK,EAAc,SAAS,CAClC,CAAC,EACA,OAAO,EFtJV,IAAMK,EAA6CC,GAE9C,SAAO,CAIN,OAAQC,EAKR,KAAMD,CACR,CAAC,EACA,OAAO,EAYCE,EAA4CF,GAEpD,SAAO,CAIN,WAAc,SAAO,EAKrB,I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A8C,KAAK,UAAUA,EAAMH,CAAY,CAAC,ECPlF,OAAQ,gBAAAK,MAAmB,iBAG3B,IAAMC,EAAgCC,GAAa,CACjD,IAAMC,EAAMD,EACT,IAAKE,GAAS,OAAOA,GAAQ,SAAW,KAAK,UAAUA,EAAKJ,CAAY,EAAII,CAAI,EAChF,KAAK,GAAG,EAEX,WAAW,eAAeD,CAAG,CAC/B,EAGA,WAAW,QAAU,CAEnB,QAAQD,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,OAAOA,EAAU,CACfD,EAA6BC,CAAC,CAChC,EAEA,QAAQA,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,SAASA,EAAU,CACjBD,EAA6BC,CAAC,CAChC,CACF",
6
- "names": ["z", "z", "z", "TimestampSchema", "VersionSchema", "RawDataSchema", "RawPrincipalSchema", "val", "RawUserIdSchema", "z", "DocDescriptionSchema", "DocSchema", "RawUserIdSchema", "RawDataSchema", "TimestampSchema", "VersionSchema", "DocUpsertSchema", "ProposedDocSchema", "DocAssertSetSchema", "SetDocSchema", "HookContextSchema", "dataSchema", "RawUserIdSchema", "DocContextSchema", "OnSetDocContextSchema", "DocUpsertSchema", "AssertSetDocContextSchema", "DocAssertSetSchema", "z", "CollectionsConfigSchema", "z", "SatelliteConfigEnvSchema", "OnAssertConfigSchema", "contextSchema", "CollectionsConfigSchema", "AssertSetDocConfigSchema", "AssertSetDocContextSchema", "AssertConfigSchema", "AssertFnSchema", "hookConfigSchema", "SatelliteConfigEnvSchema", "AssertFnOrObjectSchema", "defineAssert", "config", "z", "OnHookConfigSchema", "contextSchema", "CollectionsConfigSchema", "OnSetDocConfigSchema", "OnSetDocContextSchema", "HookConfigSchema", "HookFnSchema", "hookConfigSchema", "SatelliteConfigEnvSchema", "HookFnOrObjectSchema", "defineHook", "config", "jsonReplacer", "jsonReviver", "decodeDocData", "data", "encodeDocData", "jsonReplacer", "__juno_satellite_console_log", "v", "msg", "arg"]
3
+ "sources": ["../../src/configs/assertions.ts", "../../src/hooks/context.ts", "../../src/hooks/core.ts", "../../src/hooks/datastore.ts", "../../src/configs/collections.config.ts", "../../src/configs/satellite.env.ts", "../../src/configs/hooks.ts", "../../src/sdk/datastore.sdk.ts", "../../src/polyfills/console.polyfill.ts"],
4
+ "sourcesContent": ["import * as z from 'zod';\nimport {AssertSetDocContextSchema} from '../hooks/context';\nimport {CollectionsConfigSchema} from './collections.config';\nimport {SatelliteEnvSchema} from './satellite.env';\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 */\nconst OnAssertSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsConfigSchema.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 {Promise<void>} Resolves when the operation completes.\n */\n assert: z.function().args(contextSchema).returns(z.promise(z.void()))\n }).strict();\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 = z.infer<typeof AssertSetDocSchema>;\n\n// TODO: to be extended\n/**\n * @see Assert\n */\nexport const AssertSchema = AssertSetDocSchema;\n\n/**\n * All assertions definitions.\n */\nexport type Assert = z.infer<typeof AssertSchema>;\n\nexport const AssertFnSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.function().args(SatelliteEnvSchema).returns(assertSchema);\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, 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 {RawUserIdSchema} from './core';\nimport {DocAssertSetSchema, DocUpsertSchema} from './datastore';\n\n/**\n * @see HookContext\n */\nconst HookContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z\n .object({\n /**\n * The user who originally triggered the function that in turn triggered the hook.\n */\n caller: RawUserIdSchema,\n\n /**\n * The data associated with the hook execution.\n */\n data: dataSchema\n })\n .strict();\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 type HookContext<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof HookContextSchema<T>>>;\n\n/**\n * @see DocContext\n */\nexport const DocContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z\n .object({\n /**\n * The name of the collection where the document is stored.\n */\n collection: z.string(),\n\n /**\n * The unique key identifying the document within the collection.\n */\n key: z.string(),\n\n /**\n * The data associated with the document operation.\n */\n data: dataSchema\n })\n .strict();\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 type DocContext<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof DocContextSchema<T>>>;\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 = z.infer<typeof OnSetDocContextSchema>;\n\n/**\n * @see AssertSetDocContext\n */\nexport const AssertSetDocContextSchema = HookContextSchema(DocContextSchema(DocAssertSetSchema));\n\n/**\n * The context provided to the `assertSetDoc` 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 = z.infer<typeof AssertSetDocContextSchema>;\n", "import * as z from 'zod';\n\n/**\n * @see Timestamp\n */\nexport const TimestampSchema = z.bigint();\n\n/**\n * Represents a timestamp in nanoseconds since the Unix epoch.\n *\n * Used for tracking when events occur, such as document creation and updates.\n */\nexport type Timestamp = z.infer<typeof TimestampSchema>;\n\n/**\n * @see Version\n */\nexport const VersionSchema = z.bigint();\n\n/**\n * Represents a version number for tracking changes.\n *\n * This is typically incremented with each update to ensure consistency.\n */\nexport type Version = z.infer<typeof VersionSchema>;\n\n/**\n * @see RawData\n */\nexport const RawDataSchema = z.custom<Uint8Array>((val) => val instanceof Uint8Array, {\n message: 'Expected Uint8Array'\n});\n\n/**\n * Represents raw binary data.\n *\n * This is used to store unstructured data in a document.\n */\nexport type RawData = z.infer<typeof RawDataSchema>;\n\n/**\n * @see RawPrincipal\n */\nexport const RawPrincipalSchema = z.custom<Uint8Array>((val) => val instanceof Uint8Array, {\n message: 'Expected Uint8Array'\n});\n\n/**\n * Represents a raw principal identifier.\n *\n * Principals are unique identities used in authentication and authorization.\n */\nexport type RawPrincipal = z.infer<typeof RawPrincipalSchema>;\n\n/**\n * @see RawUserId\n */\nexport const RawUserIdSchema = RawPrincipalSchema;\n\n/**\n * Represents a raw user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type RawUserId = z.infer<typeof RawUserIdSchema>;\n", "import * as z from 'zod';\nimport {RawDataSchema, RawUserIdSchema, TimestampSchema, VersionSchema} from './core';\n\n/**\n * @see DocDescription\n */\nexport const DocDescriptionSchema = z.string().max(1024);\n\n/**\n * Represents a document description with a maximum length of 1024 characters.\n */\nexport type DocDescription = z.infer<typeof DocDescriptionSchema>;\n\n/**\n * @see Doc\n */\nexport const DocSchema = z\n .object({\n /**\n * The user who owns this document.\n */\n owner: RawUserIdSchema,\n\n /**\n * The raw data of the document.\n */\n data: RawDataSchema,\n\n /**\n * An optional description of the document.\n */\n description: DocDescriptionSchema.optional(),\n\n /**\n * The timestamp when the document was first created.\n */\n created_at: TimestampSchema,\n\n /**\n * The timestamp when the document was last updated.\n */\n updated_at: TimestampSchema,\n\n /**\n * The version number of the document, used for consistency checks.\n * If not provided, it's assumed to be the first version.\n */\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents a document stored in a collection.\n */\nexport type Doc = z.infer<typeof DocSchema>;\n\n/**\n * @see DocUpsert\n */\nexport const DocUpsertSchema = z\n .object({\n /**\n * The previous version of the document before the update.\n * Undefined if this is a new document.\n */\n before: DocSchema.optional(),\n\n /**\n * The new version of the document after the update.\n */\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 type DocUpsert = z.infer<typeof DocUpsertSchema>;\n\n/**\n * @see ProposedDoc\n */\nexport const ProposedDocSchema = z\n .object({\n /**\n * The raw data of the document.\n */\n data: RawDataSchema,\n\n /**\n * An optional description of the document.\n */\n description: DocDescriptionSchema.optional(),\n\n /**\n * The expected version number to ensure consistency.\n */\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document.\n * This can be validated before allowing the operation.\n */\nexport type ProposedDoc = z.infer<typeof ProposedDocSchema>;\n\n/**\n * @see DocAssertSet\n */\nexport const DocAssertSetSchema = z\n .object({\n /**\n * The current version of the document before the operation.\n * Undefined if this is a new document.\n */\n current: DocSchema.optional(),\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: ProposedDocSchema\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 type DocAssertSet = z.infer<typeof DocAssertSetSchema>;\n\n/**\n * @see SetDoc\n */\nexport const SetDocSchema = z\n .object({\n /**\n * The raw data of the document.\n */\n data: RawDataSchema,\n\n /**\n * An optional description of the document.\n */\n description: DocDescriptionSchema.optional(),\n\n /**\n * The expected version number to ensure consistency.\n * If provided, the operation will fail if the stored version does not match.\n */\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents a request to set or update a document.\n *\n * This is used when submitting new document data.\n */\nexport type SetDoc = z.infer<typeof SetDocSchema>;\n", "import * as z from 'zod';\n\n/**\n * @see CollectionsConfig\n */\nexport const CollectionsConfigSchema = z\n .object({\n /**\n * An array containing at least one collection name where the hook or assertion will be executed.\n */\n collections: z.array(z.string()).min(1)\n })\n .strict();\n\n/**\n * Defines the collections where a hook or assertion should run.\n */\nexport type CollectionsConfig = z.infer<typeof CollectionsConfigSchema>;\n", "import * as z from 'zod';\n\n/**\n * @see SatelliteEnv\n */\nexport const SatelliteEnvSchema = z.record(z.unknown());\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 {OnSetDocContextSchema} from '../hooks/context';\nimport {CollectionsConfigSchema} from './collections.config';\nimport {SatelliteEnvSchema} from './satellite.env';\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 */\nconst OnHookSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsConfigSchema.extend({\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: z.function().args(contextSchema).returns(z.promise(z.void()))\n }).strict();\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 = z.infer<typeof OnSetDocSchema>;\n\n// TODO: to be extended\n/**\n * @see Hook\n */\nexport const HookSchema = OnSetDocSchema;\n\n/**\n * All hooks definitions.\n */\nexport type Hook = z.infer<typeof HookSchema>;\n\nexport const HookFnSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.function().args(SatelliteEnvSchema).returns(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, 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, jsonReviver} from '@dfinity/utils';\nimport type {RawData} from '../hooks/core';\n\nexport const decodeDocData = <T>(data: RawData): T =>\n JSON.parse(__juno_satellite_datastore_raw_data_to_text(data), jsonReviver);\n\nexport const encodeDocData = <T>(data: T): RawData =>\n __juno_satellite_datastore_raw_data_from_text(JSON.stringify(data, jsonReplacer));\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"],
5
+ "mappings": "AAAA,UAAYA,MAAO,MCAnB,UAAYC,MAAO,MCAnB,UAAYC,MAAO,MAKZ,IAAMC,EAAoB,SAAO,EAY3BC,EAAkB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C,EAEA,QAAQA,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,SAASA,EAAU,CACjBD,EAA6BC,CAAC,CAChC,CACF",
6
+ "names": ["z", "z", "z", "TimestampSchema", "VersionSchema", "RawDataSchema", "val", "RawPrincipalSchema", "RawUserIdSchema", "z", "DocDescriptionSchema", "DocSchema", "RawUserIdSchema", "RawDataSchema", "TimestampSchema", "VersionSchema", "DocUpsertSchema", "ProposedDocSchema", "DocAssertSetSchema", "SetDocSchema", "HookContextSchema", "dataSchema", "RawUserIdSchema", "DocContextSchema", "OnSetDocContextSchema", "DocUpsertSchema", "AssertSetDocContextSchema", "DocAssertSetSchema", "z", "CollectionsConfigSchema", "z", "SatelliteEnvSchema", "OnAssertSchema", "contextSchema", "CollectionsConfigSchema", "AssertSetDocSchema", "AssertSetDocContextSchema", "AssertSchema", "AssertFnSchema", "assertSchema", "SatelliteEnvSchema", "AssertFnOrObjectSchema", "defineAssert", "assert", "z", "OnHookSchema", "contextSchema", "CollectionsConfigSchema", "OnSetDocSchema", "OnSetDocContextSchema", "HookSchema", "HookFnSchema", "hookSchema", "SatelliteEnvSchema", "HookFnOrObjectSchema", "defineHook", "hook", "jsonReplacer", "jsonReviver", "decodeDocData", "data", "encodeDocData", "jsonReplacer", "__juno_satellite_console_log", "v", "msg", "arg"]
7
7
  }
@@ -1,9 +1,9 @@
1
1
  import * as z from 'zod';
2
- import { SatelliteConfigEnvSchema } from './satellite.config';
2
+ import { SatelliteEnvSchema } from './satellite.env';
3
3
  /**
4
- * @see AssertSetDocConfig
4
+ * @see AssertSetDoc
5
5
  */
6
- export declare const AssertSetDocConfigSchema: z.ZodObject<z.objectUtil.extendShape<{
6
+ export declare const AssertSetDocSchema: z.ZodObject<z.objectUtil.extendShape<{
7
7
  collections: z.ZodArray<z.ZodString, "many">;
8
8
  }, {
9
9
  /**
@@ -20,48 +20,48 @@ export declare const AssertSetDocConfigSchema: z.ZodObject<z.objectUtil.extendSh
20
20
  data: z.ZodObject<{
21
21
  current: z.ZodOptional<z.ZodObject<{
22
22
  owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
23
- data: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
23
+ data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
24
24
  description: z.ZodOptional<z.ZodString>;
25
25
  created_at: z.ZodBigInt;
26
26
  updated_at: z.ZodBigInt;
27
27
  version: z.ZodOptional<z.ZodBigInt>;
28
28
  }, "strict", z.ZodTypeAny, {
29
29
  owner: Uint8Array<ArrayBufferLike>;
30
- data: Uint8Array<ArrayBuffer>;
30
+ data: Uint8Array<ArrayBufferLike>;
31
31
  created_at: bigint;
32
32
  updated_at: bigint;
33
33
  description?: string | undefined;
34
34
  version?: bigint | undefined;
35
35
  }, {
36
36
  owner: Uint8Array<ArrayBufferLike>;
37
- data: Uint8Array<ArrayBuffer>;
37
+ data: Uint8Array<ArrayBufferLike>;
38
38
  created_at: bigint;
39
39
  updated_at: bigint;
40
40
  description?: string | undefined;
41
41
  version?: bigint | undefined;
42
42
  }>>;
43
43
  proposed: z.ZodObject<{
44
- data: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
44
+ data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
45
45
  description: z.ZodOptional<z.ZodString>;
46
46
  version: z.ZodOptional<z.ZodBigInt>;
47
47
  }, "strict", z.ZodTypeAny, {
48
- data: Uint8Array<ArrayBuffer>;
48
+ data: Uint8Array<ArrayBufferLike>;
49
49
  description?: string | undefined;
50
50
  version?: bigint | undefined;
51
51
  }, {
52
- data: Uint8Array<ArrayBuffer>;
52
+ data: Uint8Array<ArrayBufferLike>;
53
53
  description?: string | undefined;
54
54
  version?: bigint | undefined;
55
55
  }>;
56
56
  }, "strict", z.ZodTypeAny, {
57
57
  proposed: {
58
- data: Uint8Array<ArrayBuffer>;
58
+ data: Uint8Array<ArrayBufferLike>;
59
59
  description?: string | undefined;
60
60
  version?: bigint | undefined;
61
61
  };
62
62
  current?: {
63
63
  owner: Uint8Array<ArrayBufferLike>;
64
- data: Uint8Array<ArrayBuffer>;
64
+ data: Uint8Array<ArrayBufferLike>;
65
65
  created_at: bigint;
66
66
  updated_at: bigint;
67
67
  description?: string | undefined;
@@ -69,13 +69,13 @@ export declare const AssertSetDocConfigSchema: z.ZodObject<z.objectUtil.extendSh
69
69
  } | undefined;
70
70
  }, {
71
71
  proposed: {
72
- data: Uint8Array<ArrayBuffer>;
72
+ data: Uint8Array<ArrayBufferLike>;
73
73
  description?: string | undefined;
74
74
  version?: bigint | undefined;
75
75
  };
76
76
  current?: {
77
77
  owner: Uint8Array<ArrayBufferLike>;
78
- data: Uint8Array<ArrayBuffer>;
78
+ data: Uint8Array<ArrayBufferLike>;
79
79
  created_at: bigint;
80
80
  updated_at: bigint;
81
81
  description?: string | undefined;
@@ -85,13 +85,13 @@ export declare const AssertSetDocConfigSchema: z.ZodObject<z.objectUtil.extendSh
85
85
  }, "strict", z.ZodTypeAny, {
86
86
  data: {
87
87
  proposed: {
88
- data: Uint8Array<ArrayBuffer>;
88
+ data: Uint8Array<ArrayBufferLike>;
89
89
  description?: string | undefined;
90
90
  version?: bigint | undefined;
91
91
  };
92
92
  current?: {
93
93
  owner: Uint8Array<ArrayBufferLike>;
94
- data: Uint8Array<ArrayBuffer>;
94
+ data: Uint8Array<ArrayBufferLike>;
95
95
  created_at: bigint;
96
96
  updated_at: bigint;
97
97
  description?: string | undefined;
@@ -103,13 +103,13 @@ export declare const AssertSetDocConfigSchema: z.ZodObject<z.objectUtil.extendSh
103
103
  }, {
104
104
  data: {
105
105
  proposed: {
106
- data: Uint8Array<ArrayBuffer>;
106
+ data: Uint8Array<ArrayBufferLike>;
107
107
  description?: string | undefined;
108
108
  version?: bigint | undefined;
109
109
  };
110
110
  current?: {
111
111
  owner: Uint8Array<ArrayBufferLike>;
112
- data: Uint8Array<ArrayBuffer>;
112
+ data: Uint8Array<ArrayBufferLike>;
113
113
  created_at: bigint;
114
114
  updated_at: bigint;
115
115
  description?: string | undefined;
@@ -123,13 +123,13 @@ export declare const AssertSetDocConfigSchema: z.ZodObject<z.objectUtil.extendSh
123
123
  data: {
124
124
  data: {
125
125
  proposed: {
126
- data: Uint8Array<ArrayBuffer>;
126
+ data: Uint8Array<ArrayBufferLike>;
127
127
  description?: string | undefined;
128
128
  version?: bigint | undefined;
129
129
  };
130
130
  current?: {
131
131
  owner: Uint8Array<ArrayBufferLike>;
132
- data: Uint8Array<ArrayBuffer>;
132
+ data: Uint8Array<ArrayBufferLike>;
133
133
  created_at: bigint;
134
134
  updated_at: bigint;
135
135
  description?: string | undefined;
@@ -144,13 +144,13 @@ export declare const AssertSetDocConfigSchema: z.ZodObject<z.objectUtil.extendSh
144
144
  data: {
145
145
  data: {
146
146
  proposed: {
147
- data: Uint8Array<ArrayBuffer>;
147
+ data: Uint8Array<ArrayBufferLike>;
148
148
  description?: string | undefined;
149
149
  version?: bigint | undefined;
150
150
  };
151
151
  current?: {
152
152
  owner: Uint8Array<ArrayBufferLike>;
153
- data: Uint8Array<ArrayBuffer>;
153
+ data: Uint8Array<ArrayBufferLike>;
154
154
  created_at: bigint;
155
155
  updated_at: bigint;
156
156
  description?: string | undefined;
@@ -168,13 +168,13 @@ export declare const AssertSetDocConfigSchema: z.ZodObject<z.objectUtil.extendSh
168
168
  data: {
169
169
  data: {
170
170
  proposed: {
171
- data: Uint8Array<ArrayBuffer>;
171
+ data: Uint8Array<ArrayBufferLike>;
172
172
  description?: string | undefined;
173
173
  version?: bigint | undefined;
174
174
  };
175
175
  current?: {
176
176
  owner: Uint8Array<ArrayBufferLike>;
177
- data: Uint8Array<ArrayBuffer>;
177
+ data: Uint8Array<ArrayBufferLike>;
178
178
  created_at: bigint;
179
179
  updated_at: bigint;
180
180
  description?: string | undefined;
@@ -192,13 +192,13 @@ export declare const AssertSetDocConfigSchema: z.ZodObject<z.objectUtil.extendSh
192
192
  data: {
193
193
  data: {
194
194
  proposed: {
195
- data: Uint8Array<ArrayBuffer>;
195
+ data: Uint8Array<ArrayBufferLike>;
196
196
  description?: string | undefined;
197
197
  version?: bigint | undefined;
198
198
  };
199
199
  current?: {
200
200
  owner: Uint8Array<ArrayBufferLike>;
201
- data: Uint8Array<ArrayBuffer>;
201
+ data: Uint8Array<ArrayBufferLike>;
202
202
  created_at: bigint;
203
203
  updated_at: bigint;
204
204
  description?: string | undefined;
@@ -212,13 +212,13 @@ export declare const AssertSetDocConfigSchema: z.ZodObject<z.objectUtil.extendSh
212
212
  }, ...args: unknown[]) => Promise<void>;
213
213
  }>;
214
214
  /**
215
- * Configuration schema for an assertion that runs when a document is created or updated.
215
+ * An assertion that runs when a document is created or updated.
216
216
  */
217
- export type AssertSetDocConfig = z.infer<typeof AssertSetDocConfigSchema>;
217
+ export type AssertSetDoc = z.infer<typeof AssertSetDocSchema>;
218
218
  /**
219
- * @see AssertConfig
219
+ * @see Assert
220
220
  */
221
- export declare const AssertConfigSchema: z.ZodObject<z.objectUtil.extendShape<{
221
+ export declare const AssertSchema: z.ZodObject<z.objectUtil.extendShape<{
222
222
  collections: z.ZodArray<z.ZodString, "many">;
223
223
  }, {
224
224
  /**
@@ -235,48 +235,48 @@ export declare const AssertConfigSchema: z.ZodObject<z.objectUtil.extendShape<{
235
235
  data: z.ZodObject<{
236
236
  current: z.ZodOptional<z.ZodObject<{
237
237
  owner: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
238
- data: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
238
+ data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
239
239
  description: z.ZodOptional<z.ZodString>;
240
240
  created_at: z.ZodBigInt;
241
241
  updated_at: z.ZodBigInt;
242
242
  version: z.ZodOptional<z.ZodBigInt>;
243
243
  }, "strict", z.ZodTypeAny, {
244
244
  owner: Uint8Array<ArrayBufferLike>;
245
- data: Uint8Array<ArrayBuffer>;
245
+ data: Uint8Array<ArrayBufferLike>;
246
246
  created_at: bigint;
247
247
  updated_at: bigint;
248
248
  description?: string | undefined;
249
249
  version?: bigint | undefined;
250
250
  }, {
251
251
  owner: Uint8Array<ArrayBufferLike>;
252
- data: Uint8Array<ArrayBuffer>;
252
+ data: Uint8Array<ArrayBufferLike>;
253
253
  created_at: bigint;
254
254
  updated_at: bigint;
255
255
  description?: string | undefined;
256
256
  version?: bigint | undefined;
257
257
  }>>;
258
258
  proposed: z.ZodObject<{
259
- data: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
259
+ data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
260
260
  description: z.ZodOptional<z.ZodString>;
261
261
  version: z.ZodOptional<z.ZodBigInt>;
262
262
  }, "strict", z.ZodTypeAny, {
263
- data: Uint8Array<ArrayBuffer>;
263
+ data: Uint8Array<ArrayBufferLike>;
264
264
  description?: string | undefined;
265
265
  version?: bigint | undefined;
266
266
  }, {
267
- data: Uint8Array<ArrayBuffer>;
267
+ data: Uint8Array<ArrayBufferLike>;
268
268
  description?: string | undefined;
269
269
  version?: bigint | undefined;
270
270
  }>;
271
271
  }, "strict", z.ZodTypeAny, {
272
272
  proposed: {
273
- data: Uint8Array<ArrayBuffer>;
273
+ data: Uint8Array<ArrayBufferLike>;
274
274
  description?: string | undefined;
275
275
  version?: bigint | undefined;
276
276
  };
277
277
  current?: {
278
278
  owner: Uint8Array<ArrayBufferLike>;
279
- data: Uint8Array<ArrayBuffer>;
279
+ data: Uint8Array<ArrayBufferLike>;
280
280
  created_at: bigint;
281
281
  updated_at: bigint;
282
282
  description?: string | undefined;
@@ -284,13 +284,13 @@ export declare const AssertConfigSchema: z.ZodObject<z.objectUtil.extendShape<{
284
284
  } | undefined;
285
285
  }, {
286
286
  proposed: {
287
- data: Uint8Array<ArrayBuffer>;
287
+ data: Uint8Array<ArrayBufferLike>;
288
288
  description?: string | undefined;
289
289
  version?: bigint | undefined;
290
290
  };
291
291
  current?: {
292
292
  owner: Uint8Array<ArrayBufferLike>;
293
- data: Uint8Array<ArrayBuffer>;
293
+ data: Uint8Array<ArrayBufferLike>;
294
294
  created_at: bigint;
295
295
  updated_at: bigint;
296
296
  description?: string | undefined;
@@ -300,13 +300,13 @@ export declare const AssertConfigSchema: z.ZodObject<z.objectUtil.extendShape<{
300
300
  }, "strict", z.ZodTypeAny, {
301
301
  data: {
302
302
  proposed: {
303
- data: Uint8Array<ArrayBuffer>;
303
+ data: Uint8Array<ArrayBufferLike>;
304
304
  description?: string | undefined;
305
305
  version?: bigint | undefined;
306
306
  };
307
307
  current?: {
308
308
  owner: Uint8Array<ArrayBufferLike>;
309
- data: Uint8Array<ArrayBuffer>;
309
+ data: Uint8Array<ArrayBufferLike>;
310
310
  created_at: bigint;
311
311
  updated_at: bigint;
312
312
  description?: string | undefined;
@@ -318,13 +318,13 @@ export declare const AssertConfigSchema: z.ZodObject<z.objectUtil.extendShape<{
318
318
  }, {
319
319
  data: {
320
320
  proposed: {
321
- data: Uint8Array<ArrayBuffer>;
321
+ data: Uint8Array<ArrayBufferLike>;
322
322
  description?: string | undefined;
323
323
  version?: bigint | undefined;
324
324
  };
325
325
  current?: {
326
326
  owner: Uint8Array<ArrayBufferLike>;
327
- data: Uint8Array<ArrayBuffer>;
327
+ data: Uint8Array<ArrayBufferLike>;
328
328
  created_at: bigint;
329
329
  updated_at: bigint;
330
330
  description?: string | undefined;
@@ -338,13 +338,13 @@ export declare const AssertConfigSchema: z.ZodObject<z.objectUtil.extendShape<{
338
338
  data: {
339
339
  data: {
340
340
  proposed: {
341
- data: Uint8Array<ArrayBuffer>;
341
+ data: Uint8Array<ArrayBufferLike>;
342
342
  description?: string | undefined;
343
343
  version?: bigint | undefined;
344
344
  };
345
345
  current?: {
346
346
  owner: Uint8Array<ArrayBufferLike>;
347
- data: Uint8Array<ArrayBuffer>;
347
+ data: Uint8Array<ArrayBufferLike>;
348
348
  created_at: bigint;
349
349
  updated_at: bigint;
350
350
  description?: string | undefined;
@@ -359,13 +359,13 @@ export declare const AssertConfigSchema: z.ZodObject<z.objectUtil.extendShape<{
359
359
  data: {
360
360
  data: {
361
361
  proposed: {
362
- data: Uint8Array<ArrayBuffer>;
362
+ data: Uint8Array<ArrayBufferLike>;
363
363
  description?: string | undefined;
364
364
  version?: bigint | undefined;
365
365
  };
366
366
  current?: {
367
367
  owner: Uint8Array<ArrayBufferLike>;
368
- data: Uint8Array<ArrayBuffer>;
368
+ data: Uint8Array<ArrayBufferLike>;
369
369
  created_at: bigint;
370
370
  updated_at: bigint;
371
371
  description?: string | undefined;
@@ -383,13 +383,13 @@ export declare const AssertConfigSchema: z.ZodObject<z.objectUtil.extendShape<{
383
383
  data: {
384
384
  data: {
385
385
  proposed: {
386
- data: Uint8Array<ArrayBuffer>;
386
+ data: Uint8Array<ArrayBufferLike>;
387
387
  description?: string | undefined;
388
388
  version?: bigint | undefined;
389
389
  };
390
390
  current?: {
391
391
  owner: Uint8Array<ArrayBufferLike>;
392
- data: Uint8Array<ArrayBuffer>;
392
+ data: Uint8Array<ArrayBufferLike>;
393
393
  created_at: bigint;
394
394
  updated_at: bigint;
395
395
  description?: string | undefined;
@@ -407,13 +407,13 @@ export declare const AssertConfigSchema: z.ZodObject<z.objectUtil.extendShape<{
407
407
  data: {
408
408
  data: {
409
409
  proposed: {
410
- data: Uint8Array<ArrayBuffer>;
410
+ data: Uint8Array<ArrayBufferLike>;
411
411
  description?: string | undefined;
412
412
  version?: bigint | undefined;
413
413
  };
414
414
  current?: {
415
415
  owner: Uint8Array<ArrayBufferLike>;
416
- data: Uint8Array<ArrayBuffer>;
416
+ data: Uint8Array<ArrayBufferLike>;
417
417
  created_at: bigint;
418
418
  updated_at: bigint;
419
419
  description?: string | undefined;
@@ -427,13 +427,13 @@ export declare const AssertConfigSchema: z.ZodObject<z.objectUtil.extendShape<{
427
427
  }, ...args: unknown[]) => Promise<void>;
428
428
  }>;
429
429
  /**
430
- * All possible config for assertions.
430
+ * All assertions definitions.
431
431
  */
432
- export type AssertConfig = z.infer<typeof AssertConfigSchema>;
433
- export declare const AssertFnSchema: <T extends z.ZodTypeAny>(hookConfigSchema: T) => z.ZodFunction<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodUnknown>], z.ZodUnknown>, T>;
434
- export type AssertFn<T extends AssertConfig> = (config: z.infer<typeof SatelliteConfigEnvSchema>) => T;
435
- export declare const AssertFnOrObjectSchema: <T extends z.ZodTypeAny>(hookConfigSchema: T) => z.ZodUnion<[T, z.ZodFunction<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodUnknown>], z.ZodUnknown>, T>]>;
436
- export type AssertFnOrObject<T extends AssertConfig> = T | AssertFn<T>;
437
- export declare function defineAssert<T extends AssertConfig>(config: T): T;
438
- export declare function defineAssert<T extends AssertConfig>(config: AssertFn<T>): AssertFn<T>;
439
- export declare function defineAssert<T extends AssertConfig>(config: AssertFnOrObject<T>): AssertFnOrObject<T>;
432
+ export type Assert = z.infer<typeof AssertSchema>;
433
+ export declare const AssertFnSchema: <T extends z.ZodTypeAny>(assertSchema: T) => z.ZodFunction<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodUnknown>], z.ZodUnknown>, T>;
434
+ export type AssertFn<T extends Assert> = (assert: z.infer<typeof SatelliteEnvSchema>) => T;
435
+ export declare const AssertFnOrObjectSchema: <T extends z.ZodTypeAny>(assertSchema: T) => z.ZodUnion<[T, z.ZodFunction<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodUnknown>], z.ZodUnknown>, T>]>;
436
+ export type AssertFnOrObject<T extends Assert> = T | AssertFn<T>;
437
+ export declare function defineAssert<T extends Assert>(assert: T): T;
438
+ export declare function defineAssert<T extends Assert>(assert: AssertFn<T>): AssertFn<T>;
439
+ export declare function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>;
@@ -1,6 +1,6 @@
1
1
  import * as z from 'zod';
2
2
  /**
3
- * Defines the collections where a hook or assertion should run.
3
+ * @see CollectionsConfig
4
4
  */
5
5
  export declare const CollectionsConfigSchema: z.ZodObject<{
6
6
  /**
@@ -12,5 +12,7 @@ export declare const CollectionsConfigSchema: z.ZodObject<{
12
12
  }, {
13
13
  collections: string[];
14
14
  }>;
15
- /** @typedef {z.infer<typeof CollectionsConfigSchema>} CollectionsConfig */
15
+ /**
16
+ * Defines the collections where a hook or assertion should run.
17
+ */
16
18
  export type CollectionsConfig = z.infer<typeof CollectionsConfigSchema>;