@junobuild/functions 0.3.2 → 0.3.3
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 +33 -13
- package/chunk-CCKUQNB5.js +2 -0
- package/chunk-CCKUQNB5.js.map +7 -0
- package/chunk-SFZECPH3.js +2 -0
- package/chunk-SFZECPH3.js.map +7 -0
- package/hooks/assertions.d.ts +2 -2
- package/hooks/hooks.d.ts +2 -2
- package/hooks/schemas/collections.d.ts +1 -1
- package/hooks/schemas/context.d.ts +1 -1
- package/hooks/schemas/db/context.d.ts +1 -1
- package/hooks/schemas/db/payload.d.ts +1 -1
- package/hooks/schemas/satellite.env.d.ts +1 -1
- package/hooks/schemas/storage/context.d.ts +1 -1
- package/hooks/schemas/storage/payload.d.ts +1 -1
- package/ic-cdk/schemas/call.d.ts +1 -1
- package/ic-cdk.js +1 -1
- package/ic-cdk.js.map +2 -2
- package/index.js +1 -1
- package/index.js.map +2 -2
- package/package.json +2 -2
- package/schemas/candid.d.ts +1 -1
- package/schemas/db.d.ts +1 -1
- package/schemas/list.d.ts +1 -1
- package/schemas/satellite.d.ts +1 -1
- package/schemas/storage.d.ts +2 -2
- package/sdk/schemas/collections.d.ts +1 -1
- package/sdk/schemas/controllers.d.ts +1 -1
- package/sdk/schemas/db.d.ts +112 -112
- package/sdk/schemas/params.d.ts +1 -1
- package/sdk/schemas/storage.d.ts +1 -1
- package/sdk.js +1 -1
- package/sdk.js.map +2 -2
- package/utils/zod.utils.d.ts +23 -2
- package/chunk-KY6LCVKU.js +0 -2
- package/chunk-KY6LCVKU.js.map +0 -7
- package/chunk-R6MTJSTE.js +0 -2
- package/chunk-R6MTJSTE.js.map +0 -7
package/README.md
CHANGED
|
@@ -62,11 +62,31 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
|
|
|
62
62
|
|
|
63
63
|
#### :gear: createFunctionSchema
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
| `createFunctionSchema` | `<T extends z.core.$ZodFunction>(schema: T) => ZodCustom<Parameters<T["implement"]>[0], Parameters<T["implement"]>[0]>` |
|
|
65
|
+
Wraps a Zod function schema so that parsing returns the **original function**
|
|
66
|
+
instead of Zod's wrapped validator.
|
|
68
67
|
|
|
69
|
-
|
|
68
|
+
## Why?
|
|
69
|
+
|
|
70
|
+
In Zod v4, `z.function({...})` normally returns a wrapper that validates
|
|
71
|
+
both arguments and the return value **every time the function is called**.
|
|
72
|
+
If your function's return type is `void | Promise<void>`, Zod tries to
|
|
73
|
+
validate it synchronously, which can throw
|
|
74
|
+
"Encountered Promise during synchronous parse"
|
|
75
|
+
when the implementation is async.
|
|
76
|
+
|
|
77
|
+
By using `.implement`, we tell Zod: “this is the function that satisfies
|
|
78
|
+
the schema.” That way the schema still validates the function shape at
|
|
79
|
+
parse time, but the returned value is the **original function** you passed
|
|
80
|
+
in — no runtime wrapper, no sync/async mismatch.
|
|
81
|
+
|
|
82
|
+
Reference:
|
|
83
|
+
https://github.com/colinhacks/zod/issues/4143#issuecomment-2845134912*
|
|
84
|
+
|
|
85
|
+
| Function | Type |
|
|
86
|
+
| ---------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
87
|
+
| `createFunctionSchema` | `<T extends z.ZodFunction>(schema: T) => ZodCustom<Parameters<T["implement"]>[0], Parameters<T["implement"]>[0]>` |
|
|
88
|
+
|
|
89
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/utils/zod.utils.ts#L24)
|
|
70
90
|
|
|
71
91
|
#### :gear: HookContextSchema
|
|
72
92
|
|
|
@@ -118,9 +138,9 @@ References:
|
|
|
118
138
|
|
|
119
139
|
#### :gear: AssertFnSchema
|
|
120
140
|
|
|
121
|
-
| Function | Type
|
|
122
|
-
| ---------------- |
|
|
123
|
-
| `AssertFnSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) =>
|
|
141
|
+
| Function | Type |
|
|
142
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
143
|
+
| `AssertFnSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodString>], null>, T>` |
|
|
124
144
|
|
|
125
145
|
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/assertions.ts#L97)
|
|
126
146
|
|
|
@@ -166,9 +186,9 @@ References:
|
|
|
166
186
|
|
|
167
187
|
#### :gear: HookFnSchema
|
|
168
188
|
|
|
169
|
-
| Function | Type
|
|
170
|
-
| -------------- |
|
|
171
|
-
| `HookFnSchema` | `<T extends z.ZodTypeAny>(hookSchema: T) =>
|
|
189
|
+
| Function | Type |
|
|
190
|
+
| -------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
191
|
+
| `HookFnSchema` | `<T extends z.ZodTypeAny>(hookSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodString>], null>, T>` |
|
|
172
192
|
|
|
173
193
|
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/hooks.ts#L171)
|
|
174
194
|
|
|
@@ -1190,9 +1210,9 @@ References:
|
|
|
1190
1210
|
|
|
1191
1211
|
#### :gear: AssetNoContentSchema
|
|
1192
1212
|
|
|
1193
|
-
| Constant | Type
|
|
1194
|
-
| ---------------------- |
|
|
1195
|
-
| `AssetNoContentSchema` | `ZodObject<{
|
|
1213
|
+
| Constant | Type |
|
|
1214
|
+
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1215
|
+
| `AssetNoContentSchema` | `ZodObject<{ key: ZodObject<{ name: ZodString; full_path: ZodString; token: ZodOptional<ZodString>; collection: ZodString; owner: ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<...>>; description: ZodOptional<...>; }, $strict>; ... 4 more ...; encodings: ZodArray<...>; }, $strict>` |
|
|
1196
1216
|
|
|
1197
1217
|
References:
|
|
1198
1218
|
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Principal as r}from"@dfinity/principal";import*as i from"zod";var n=i.custom(a=>a instanceof Uint8Array,{message:"Expected Uint8Array"}),c=n,t=i.custom(a=>a instanceof r,{message:"Expected an instance of a Principal"});export{n as a,c as b,t as c};
|
|
2
|
+
//# sourceMappingURL=chunk-CCKUQNB5.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/schemas/candid.ts"],
|
|
4
|
+
"sourcesContent": ["import {Principal as CandidPrincipal} from '@dfinity/principal';\nimport * as z from 'zod';\n\n/**\n * A schema that validates a value is an Uint8Array.\n */\nexport const Uint8ArraySchema = z.custom<Uint8Array>((val) => val instanceof Uint8Array, {\n message: 'Expected Uint8Array'\n});\n\n/**\n * @see RawPrincipal\n */\nexport const RawPrincipalSchema = Uint8ArraySchema;\n\n/**\n * Represents a raw principal - a Uint8Array representation of a Principal.\n */\nexport type RawPrincipal = z.infer<typeof RawPrincipalSchema>;\n\n/**\n * @see Principal\n */\nexport const PrincipalSchema = z.custom<CandidPrincipal>((val) => val instanceof CandidPrincipal, {\n message: 'Expected an instance of a Principal'\n});\n\n/**\n * Represents a principal - i.e. an object instantiated with the class Principal.\n */\nexport type Principal = z.infer<typeof PrincipalSchema>;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAQ,aAAaA,MAAsB,qBAC3C,UAAYC,MAAO,MAKZ,IAAMC,EAAqB,SAAoBC,GAAQA,aAAe,WAAY,CACvF,QAAS,qBACX,CAAC,EAKYC,EAAqBF,EAUrBG,EAAoB,SAAyBF,GAAQA,aAAeH,EAAiB,CAChG,QAAS,qCACX,CAAC",
|
|
6
|
+
"names": ["CandidPrincipal", "z", "Uint8ArraySchema", "val", "RawPrincipalSchema", "PrincipalSchema"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as s,b as h,c as l}from"./chunk-CCKUQNB5.js";import*as i from"zod";var o=i.bigint(),r=i.bigint(),n=h,O=l,y=i.string(),c=i.string(),a=i.string().max(1024);import*as p from"zod";var g=s,_=p.object({owner:n,data:g,description:a.optional(),created_at:o,updated_at:o,version:r.optional()}).strict(),H=_.optional(),V=p.object({data:g,description:a.optional(),version:r.optional()}).strict(),P=p.object({version:r.optional()}).strict();import*as e from"zod";var u=e.tuple([e.string(),e.string()]),x=e.array(u),T=s,A=T,D=e.instanceof(Uint8Array).refine(m=>m.length===32,{message:"Hash must be a Uint8Array of length 32"}),z=e.object({name:e.string(),full_path:e.string(),token:e.string().optional(),collection:y,owner:n,description:a.optional()}).strict(),S=e.object({modified:o,content_chunks:e.array(A),total_length:e.bigint(),sha256:D}),w=S.omit({content_chunks:!0}).strict(),d=e.enum(["identity","gzip","compress","deflate","br"]),f=e.object({key:z,headers:x,encodings:e.array(e.tuple([d,S])),created_at:o,updated_at:o,version:r.optional()}).strict(),q=f.omit({encodings:!0}).extend({encodings:e.array(e.tuple([d,w]))}).strict(),I=e.bigint(),Z=e.object({key:z,reference_id:I.optional(),expires_at:o,encoding_type:d.optional()}).strict(),U=e.bigint(),R=e.bigint(),G=e.object({batch_id:R,headers:x,chunk_ids:e.array(U)}).strict(),J=e.string(),Q=f.optional();import*as t from"zod";var b=t.union([t.object({equal:o}),t.object({greater_than:o}),t.object({less_than:o}),t.object({between:t.tuple([o,o])})]),k=t.object({key:c.optional(),description:a.optional(),created_at:b.optional(),updated_at:b.optional()}).strict(),j=t.object({start_after:c.optional(),limit:t.bigint().optional()}).strict(),C=t.enum(["keys","created_at","updated_at"]),L=t.object({desc:t.boolean(),field:C}).strict(),Y=t.object({matcher:k.optional(),paginate:j.optional(),order:L.optional(),owner:n.optional()}).strict(),$=m=>t.object({items:t.array(t.tuple([c,m])),items_length:t.bigint(),items_page:t.bigint().optional(),matches_length:t.bigint(),matches_pages:t.bigint().optional()}).strict();export{o as a,r as b,n as c,O as d,y as e,c as f,a as g,g as h,_ as i,H as j,V as k,P as l,x as m,T as n,z as o,S as p,f as q,q as r,Z as s,G as t,J as u,Q as v,b as w,k as x,j as y,C as z,L as A,Y as B,$ as C};
|
|
2
|
+
//# sourceMappingURL=chunk-SFZECPH3.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/schemas/satellite.ts", "src/schemas/db.ts", "src/schemas/storage.ts", "src/schemas/list.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\nimport {PrincipalSchema, RawPrincipalSchema} from './candid';\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 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\n/**\n * @see UserId\n */\nexport const UserIdSchema = PrincipalSchema;\n\n/**\n * Represents a user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type UserId = z.infer<typeof UserIdSchema>;\n\n/**\n * @see Collection\n */\nexport const CollectionSchema = z.string();\n\n/**\n * A collection name where data are stored.\n */\nexport type Collection = z.infer<typeof CollectionSchema>;\n\n/**\n * @see Key\n */\nexport const KeySchema = z.string();\n\n/**\n * A key identifier within a collection.\n */\nexport type Key = z.infer<typeof KeySchema>;\n\n/**\n * @see Description\n */\nexport const DescriptionSchema = z.string().max(1024);\n\n/**\n * Represents a description with a maximum length of 1024 characters.\n * Used for document and asset fields which can be useful for search purpose.\n */\nexport type Description = z.infer<typeof DescriptionSchema>;\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {\n type Description,\n DescriptionSchema,\n type RawUserId,\n RawUserIdSchema,\n type Timestamp,\n TimestampSchema,\n type Version,\n VersionSchema\n} from './satellite';\n\n/**\n * @see RawData\n */\nexport const RawDataSchema = Uint8ArraySchema;\n\n/**\n * Represents raw binary data.\n *\n * This is used to store structured data in a document.\n */\nexport type RawData = z.infer<typeof Uint8ArraySchema>;\n\n/**\n * @see Doc\n */\nexport const DocSchema = z\n .object({\n owner: RawUserIdSchema,\n data: RawDataSchema,\n description: DescriptionSchema.optional(),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents a document stored in a collection.\n */\nexport interface Doc {\n /**\n * The user who owns this document.\n */\n owner: RawUserId;\n\n /**\n * The raw data of the document.\n */\n data: RawData;\n\n /**\n * An optional description of the document.\n */\n description?: Description;\n\n /**\n * The timestamp when the document was first created.\n */\n created_at: Timestamp;\n\n /**\n * The timestamp when the document was last updated.\n */\n updated_at: Timestamp;\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?: Version;\n}\n\n/**\n * @see OptionDoc\n */\nexport const OptionDocSchema = DocSchema.optional();\n\n/**\n * A shorthand for a document that might or not be defined.\n */\nexport type OptionDoc = Doc | undefined;\n\n/**\n * @see SetDoc\n */\nexport const SetDocSchema = z\n .object({\n data: RawDataSchema,\n description: DescriptionSchema.optional(),\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document to be created or updated.\n * This can be validated before allowing the operation.\n */\nexport interface SetDoc {\n /**\n * The raw data of the document.\n */\n data: RawData;\n\n /**\n * An optional description of the document.\n */\n description?: Description;\n\n /**\n * The expected version number to ensure consistency.\n */\n version?: Version;\n}\n\n/**\n * @see DelDoc\n */\nexport const DelDocSchema = z\n .object({\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document to be deleted.\n * This can be validated before allowing the operation.\n */\nexport interface DelDoc {\n /**\n * The expected version number to ensure consistency.\n */\n version?: Version;\n}\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {\n type Collection,\n CollectionSchema,\n type Description,\n DescriptionSchema,\n type RawUserId,\n RawUserIdSchema,\n type Timestamp,\n TimestampSchema,\n type Version,\n VersionSchema\n} from './satellite';\n\n/**\n * @see HeaderField\n */\nconst HeaderFieldSchema = z.tuple([z.string(), z.string()]);\n\n/**\n * Represents a single HTTP header as a tuple of name and value.\n */\nexport type HeaderField = [string, string];\n\n/**\n * @see HeaderFields\n */\nexport const HeaderFieldsSchema = z.array(HeaderFieldSchema);\n\n/**\n * Represents a list of HTTP headers.\n */\nexport type HeaderFields = HeaderField[];\n\n/**\n * @see Blob\n */\nexport const BlobSchema = Uint8ArraySchema;\n\n/**\n * Binary content used in asset encoding.\n */\nexport type Blob = Uint8Array;\n\n/**\n * @see BlobOrKey\n */\nconst BlobOrKeySchema = BlobSchema;\n\n/**\n * When stable memory is used, chunks are saved within a StableBTreeMap and their keys - StableEncodingChunkKey - are saved for reference as serialized values\n */\nexport type BlobOrKey = Uint8Array;\n\n/**\n * @see Hash\n */\nconst HashSchema = z.instanceof(Uint8Array).refine((val) => val.length === 32, {\n message: 'Hash must be a Uint8Array of length 32'\n});\n\n/**\n * Represents a SHA-256 hash as a 32-byte binary value.\n */\nexport type Hash = Uint8Array;\n\n/**\n * @see AssetKey\n */\nexport const AssetKeySchema = z\n .object({\n name: z.string(),\n full_path: z.string(),\n token: z.string().optional(),\n collection: CollectionSchema,\n owner: RawUserIdSchema,\n description: DescriptionSchema.optional()\n })\n .strict();\n\n/**\n * Metadata identifying an asset within a collection and the storage system.\n */\nexport interface AssetKey {\n /**\n * The name of the asset (e.g., \"logo.png\").\n */\n name: string;\n\n /**\n * The full relative path of the asset (e.g., \"/images/logo.png\").\n */\n full_path: string;\n\n /**\n * Optional access token for the asset.\n * If set, can be used using a query parameter e.g. /full_path/?token=1223-3345-5564-3333\n */\n token?: string;\n\n /**\n * The collection to which this asset belongs.\n */\n collection: Collection;\n\n /**\n * The owner of the asset.\n */\n owner: RawUserId;\n\n /**\n * Optional description of the asset for indexing/search.\n */\n description?: Description;\n}\n\n/**\n * @see AssetEncoding\n */\nexport const AssetEncodingSchema = z.object({\n modified: TimestampSchema,\n content_chunks: z.array(BlobOrKeySchema),\n total_length: z.bigint(),\n sha256: HashSchema\n});\n\n/**\n * Represents a specific encoding of an asset, such as \"gzip\" or \"identity\" (no compression).\n */\nexport interface AssetEncoding {\n /**\n * Timestamp when the encoding was last modified.\n */\n modified: Timestamp;\n\n /**\n * Chunks of binary content or references to them.\n */\n content_chunks: BlobOrKey[];\n\n /**\n * Total byte size of the encoded content.\n */\n total_length: bigint;\n\n /**\n * SHA-256 hash of the encoded content.\n */\n sha256: Hash;\n}\n\n/**\n * @see AssetEncodingNoContent\n */\nconst AssetEncodingNoContentSchema = AssetEncodingSchema.omit({content_chunks: true}).strict();\n\n/**\n * Represents a specific encoding of an asset, such as \"gzip\" or \"identity\" (no compression), without the chunks.\n */\nexport type AssetEncodingNoContent = Omit<AssetEncoding, 'content_chunks'>;\n\n/**\n * @see EncodingType\n */\nconst EncodingTypeSchema = z.enum(['identity', 'gzip', 'compress', 'deflate', 'br']);\n\n/**\n * A string identifier representing a specific encoding format (e.g., \"gzip\", \"identity\").\n */\nexport type EncodingType = 'identity' | 'gzip' | 'compress' | 'deflate' | 'br';\n\n/**\n * @see Asset\n */\nexport const AssetSchema = z\n .object({\n key: AssetKeySchema,\n headers: HeaderFieldsSchema,\n encodings: z.array(z.tuple([EncodingTypeSchema, AssetEncodingSchema])),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * A stored asset including its metadata, encodings, and timestamps.\n */\nexport interface Asset {\n /**\n * Metadata about the asset's identity and ownership.\n */\n key: AssetKey;\n\n /**\n * Optional HTTP headers associated with the asset.\n */\n headers: HeaderField[];\n\n /**\n * A mapping from encoding types (e.g., \"identity\", \"gzip\") to the corresponding encoded version.\n */\n encodings: [EncodingType, AssetEncoding][];\n\n /**\n * Timestamp when the asset was created.\n */\n created_at: Timestamp;\n\n /**\n * Timestamp when the asset was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * Optional version number of the asset.\n */\n version?: Version;\n}\n\n/**\n * @see AssetNoContent\n */\nexport const AssetNoContentSchema = AssetSchema.omit({encodings: true})\n .extend({\n encodings: z.array(z.tuple([EncodingTypeSchema, AssetEncodingNoContentSchema]))\n })\n .strict();\n\n/**\n * A stored asset including its metadata, encodings without chunks, and timestamps.\n */\nexport type AssetNoContent = Omit<Asset, 'encodings'> & {\n encodings: [EncodingType, AssetEncodingNoContent][];\n};\n\n/**\n * @see ReferenceId\n */\nconst ReferenceIdSchema = z.bigint();\n\n/**\n * A unique reference identifier for batches.\n */\nexport type ReferenceId = bigint;\n\n/**\n * @see Batch\n */\nexport const BatchSchema = z\n .object({\n key: AssetKeySchema,\n reference_id: ReferenceIdSchema.optional(),\n expires_at: TimestampSchema,\n encoding_type: EncodingTypeSchema.optional()\n })\n .strict();\n\n/**\n * Represents a batch of chunks to be uploaded and committed to an asset.\n */\nexport interface Batch {\n /**\n * The metadata key for the asset being uploaded.\n */\n key: AssetKey;\n\n /**\n * Optional reference ID for tracking or validation.\n */\n reference_id?: ReferenceId;\n\n /**\n * Timestamp when this batch expires.\n */\n expires_at: Timestamp;\n\n /**\n * Optional encoding format (e.g., \"gzip\").\n */\n encoding_type?: EncodingType;\n}\n\n/**\n * @see ChunkId\n */\nconst ChunkIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a single chunk of data.\n */\nexport type ChunkId = bigint;\n\n/**\n * @see BatchId\n */\nconst BatchIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a batch of upload.\n */\nexport type BatchId = bigint;\n\n/**\n * @see CommitBatch\n */\nexport const CommitBatchSchema = z\n .object({\n batch_id: BatchIdSchema,\n headers: HeaderFieldsSchema,\n chunk_ids: z.array(ChunkIdSchema)\n })\n .strict();\n\n/**\n * Represents the final step in uploading an asset, committing the batch to storage.\n */\nexport interface CommitBatch {\n /**\n * The ID of the batch being committed.\n */\n batch_id: BatchId;\n\n /**\n * HTTP headers associated with this asset.\n */\n headers: HeaderField[];\n\n /**\n * List of chunk IDs that make up the asset content.\n */\n chunk_ids: ChunkId[];\n}\n\n/**\n * @see FullPath\n */\nexport const FullPathSchema = z.string();\n\n/**\n * Represents the relative path of an asset in storage.\n * For assets that are not part of the frontend app, the collection must be included at the root of the path.\n *\n * Example: `/images/a-sun-above-the-mountains.png`\n */\nexport type FullPath = string;\n\n/**\n * @see OptionAsset\n */\nexport const OptionAssetSchema = AssetSchema.optional();\n\n/**\n * A shorthand for an asset that might or not be defined.\n */\nexport type OptionAsset = Asset | undefined;\n", "import * as z from 'zod';\nimport {\n type Description,\n type Key,\n type RawUserId,\n type Timestamp,\n DescriptionSchema,\n KeySchema,\n RawUserIdSchema,\n TimestampSchema\n} from './satellite';\n\n/**\n * @see TimestampMatcher\n */\nexport const TimestampMatcherSchema = z.union([\n z.object({equal: TimestampSchema}),\n z.object({greater_than: TimestampSchema}),\n z.object({less_than: TimestampSchema}),\n z.object({between: z.tuple([TimestampSchema, TimestampSchema])})\n]);\n\n/**\n * TimestampMatcher matches a timestamp field using a specific strategy.\n */\nexport type TimestampMatcher =\n | {equal: Timestamp}\n | {greater_than: Timestamp}\n | {less_than: Timestamp}\n | {between: [Timestamp, Timestamp]};\n\n/**\n * @see ListMatcher\n */\nexport const ListMatcherSchema = z\n .object({\n key: KeySchema.optional(),\n description: DescriptionSchema.optional(),\n created_at: TimestampMatcherSchema.optional(),\n updated_at: TimestampMatcherSchema.optional()\n })\n .strict();\n\n/**\n * Matcher used to filter list results.\n */\nexport interface ListMatcher {\n key?: Key;\n description?: Description;\n created_at?: TimestampMatcher;\n updated_at?: TimestampMatcher;\n}\n\n/**\n * @see ListPaginate\n */\nexport const ListPaginateSchema = z\n .object({\n start_after: KeySchema.optional(),\n limit: z.bigint().optional()\n })\n .strict();\n\n/**\n * Optional pagination controls for listing.\n */\nexport interface ListPaginate {\n start_after?: Key;\n limit?: bigint;\n}\n\n/**\n * @see ListOrderField\n */\nexport const ListOrderFieldSchema = z.enum(['keys', 'created_at', 'updated_at']);\n\n/**\n * Enum representing possible fields to order by.\n */\nexport type ListOrderField = 'keys' | 'updated_at' | 'created_at';\n\n/**\n * @see ListOrder\n */\nexport const ListOrderSchema = z\n .object({\n desc: z.boolean(),\n field: ListOrderFieldSchema\n })\n .strict();\n\n/**\n * Ordering strategy for listing documents.\n */\nexport interface ListOrder {\n desc: boolean;\n field: ListOrderField;\n}\n\n/**\n * @see ListParams\n */\nexport const ListParamsSchema = z\n .object({\n matcher: ListMatcherSchema.optional(),\n paginate: ListPaginateSchema.optional(),\n order: ListOrderSchema.optional(),\n owner: RawUserIdSchema.optional()\n })\n .strict();\n\n/**\n * Full set of listing parameters.\n */\nexport interface ListParams {\n matcher?: ListMatcher;\n paginate?: ListPaginate;\n order?: ListOrder;\n owner?: RawUserId;\n}\n\n/**\n * Represents a list result.\n *\n * @template T - The type of the data returned per item.\n * @see JsListResults\n */\nexport const createListResultsSchema = <T extends z.ZodTypeAny>(itemData: T) =>\n z\n .object({\n items: z.array(z.tuple([KeySchema, itemData])),\n items_length: z.bigint(),\n items_page: z.bigint().optional(),\n matches_length: z.bigint(),\n matches_pages: z.bigint().optional()\n })\n .strict();\n\n/**\n * List results, parameterized by type of returned item.\n */\nexport interface ListResults<T> {\n items: [Key, T][];\n items_length: bigint;\n items_page?: bigint;\n matches_length: bigint;\n matches_pages?: bigint;\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["z", "TimestampSchema", "VersionSchema", "RawUserIdSchema", "RawPrincipalSchema", "UserIdSchema", "PrincipalSchema", "CollectionSchema", "KeySchema", "DescriptionSchema", "z", "RawDataSchema", "Uint8ArraySchema", "DocSchema", "RawUserIdSchema", "DescriptionSchema", "TimestampSchema", "VersionSchema", "OptionDocSchema", "SetDocSchema", "DelDocSchema", "z", "HeaderFieldSchema", "HeaderFieldsSchema", "BlobSchema", "Uint8ArraySchema", "BlobOrKeySchema", "HashSchema", "val", "AssetKeySchema", "CollectionSchema", "RawUserIdSchema", "DescriptionSchema", "AssetEncodingSchema", "TimestampSchema", "AssetEncodingNoContentSchema", "EncodingTypeSchema", "AssetSchema", "VersionSchema", "AssetNoContentSchema", "ReferenceIdSchema", "BatchSchema", "ChunkIdSchema", "BatchIdSchema", "CommitBatchSchema", "FullPathSchema", "OptionAssetSchema", "z", "TimestampMatcherSchema", "TimestampSchema", "ListMatcherSchema", "KeySchema", "DescriptionSchema", "ListPaginateSchema", "ListOrderFieldSchema", "ListOrderSchema", "ListParamsSchema", "RawUserIdSchema", "createListResultsSchema", "itemData"]
|
|
7
|
+
}
|
package/hooks/assertions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as z from 'zod
|
|
1
|
+
import * as z from 'zod';
|
|
2
2
|
import { type Collections } from './schemas/collections';
|
|
3
3
|
import { type AssertFunction } from './schemas/context';
|
|
4
4
|
import { type AssertDeleteDocContext, type AssertSetDocContext } from './schemas/db/context';
|
|
@@ -564,7 +564,7 @@ export declare const AssertSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
564
564
|
* All assertions definitions.
|
|
565
565
|
*/
|
|
566
566
|
export type Assert = AssertSetDoc | AssertDeleteDoc | AssertUploadAsset | AssertDeleteAsset;
|
|
567
|
-
export declare const AssertFnSchema: <T extends z.ZodTypeAny>(assertSchema: T) => z.
|
|
567
|
+
export declare const AssertFnSchema: <T extends z.ZodTypeAny>(assertSchema: T) => z.ZodFunction<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodString>], null>, T>;
|
|
568
568
|
export type AssertFn<T extends Assert> = (assert: z.infer<typeof SatelliteEnvSchema>) => T;
|
|
569
569
|
export declare const AssertFnOrObjectSchema: <T extends z.ZodTypeAny>(assertSchema: T) => z.ZodUnion<readonly [T, z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodString>], null>, T>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodString>], null>, T>>]>;
|
|
570
570
|
export type AssertFnOrObject<T extends Assert> = T | AssertFn<T>;
|
package/hooks/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as z from 'zod
|
|
1
|
+
import * as z from 'zod';
|
|
2
2
|
import { type Collections } from './schemas/collections';
|
|
3
3
|
import { type RunFunction } from './schemas/context';
|
|
4
4
|
import { type OnDeleteDocContext, type OnDeleteFilteredDocsContext, type OnDeleteManyDocsContext, type OnSetDocContext, type OnSetManyDocsContext } from './schemas/db/context';
|
|
@@ -909,7 +909,7 @@ export declare const HookSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
909
909
|
* All hooks definitions.
|
|
910
910
|
*/
|
|
911
911
|
export type Hook = OnSetDoc | OnSetManyDocs | OnDeleteDoc | OnDeleteManyDocs | OnDeleteFilteredDocs | OnUploadAsset | OnDeleteAsset | OnDeleteManyAssets | OnDeleteFilteredAssets;
|
|
912
|
-
export declare const HookFnSchema: <T extends z.ZodTypeAny>(hookSchema: T) => z.
|
|
912
|
+
export declare const HookFnSchema: <T extends z.ZodTypeAny>(hookSchema: T) => z.ZodFunction<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodString>], null>, T>;
|
|
913
913
|
export type HookFn<T extends Hook> = (hook: z.infer<typeof SatelliteEnvSchema>) => T;
|
|
914
914
|
export declare const HookFnOrObjectSchema: <T extends z.ZodTypeAny>(hookSchema: T) => z.ZodUnion<readonly [T, z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodString>], null>, T>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodString>], null>, T>>]>;
|
|
915
915
|
export type HookFnOrObject<T extends Hook> = T | HookFn<T>;
|
package/ic-cdk/schemas/call.d.ts
CHANGED
package/ic-cdk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as a,c as n}from"./chunk-
|
|
1
|
+
import{b as a,c as n}from"./chunk-CCKUQNB5.js";import{IDL as s}from"@dfinity/candid";import{Principal as z}from"@dfinity/principal";import{toNullable as D}from"@dfinity/utils";import{IDL as A}from"@dfinity/candid";import*as r from"zod";var p=r.custom(e=>e instanceof A.Type,{message:"Invalid IDL.Type"}),_=r.tuple([p,r.unknown()]),w=r.array(_),S=p,i=r.object({canisterId:a.or(n),method:r.string().min(1),args:w.optional(),result:S.optional()});var t=class extends Error{constructor(){super(),this.message="More than one object returned by the response. This is unexpected."}};var N=async e=>{i.parse(e);let{canisterId:l,method:c,args:m,result:y}=e,f=z.from(l).toUint8Array(),[d,u]=(m??[]).reduce(([C,I],[P,T])=>[[...C,P],[...I,T]],[[],[]]),h=new Uint8Array(s.encode([...d],[...u])),x=await __ic_cdk_call_raw(f,c,h),o=s.decode(D(y),x);if(o.length>1)throw new t;let[g]=o;return g};import{Principal as L}from"@dfinity/principal";var F=()=>L.fromUint8Array(__ic_cdk_id());var H=()=>__ic_cdk_time();export{_ as CallArgSchema,w as CallArgsSchema,i as CallParamsSchema,t as CallResponseLengthError,S as CallResultSchema,p as IDLTypeSchema,N as call,F as id,H as time};
|
|
2
2
|
//# sourceMappingURL=ic-cdk.js.map
|
package/ic-cdk.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/ic-cdk/call.ic-cdk.ts", "src/ic-cdk/schemas/call.ts", "src/ic-cdk/types/errors.ts", "src/ic-cdk/id.ic-cdk.ts", "src/ic-cdk/time.ic-cdk.ts"],
|
|
4
|
-
"sourcesContent": ["import {IDL} from '@dfinity/candid';\nimport {Principal} from '@dfinity/principal';\nimport {toNullable} from '@dfinity/utils';\nimport {type CallParams, type IDLType, CallParamsSchema} from './schemas/call';\nimport {CallResponseLengthError} from './types/errors';\n\n/**\n * Makes an asynchronous call to a canister on the Internet Computer.\n *\n * This function encodes the provided arguments using Candid, performs the canister call,\n * and decodes the response based on the expected result types.\n *\n * @template T - The expected return type of the canister call.\n * @param {CallParams} params - The parameters required for the canister call\n * @returns {Promise<T | undefined>} A promise resolving to the decoded result of the call.\n * Returns `undefined` if the canister response is empty.\n * @throws {ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the canister call fails.\n */\nexport const call = async <T>(params: CallParams): Promise<T> => {\n CallParamsSchema.parse(params);\n\n const {canisterId: providedCanisterId, method, args: providedArgs, result: resultType} = params;\n\n const canisterId = Principal.from(providedCanisterId).toUint8Array();\n\n const [argsTypes, argsValues] = (providedArgs ?? []).reduce<[IDLType[], unknown[]]>(\n ([argsTypes, argsValues], [type, value]) => [\n [...argsTypes, type],\n [...argsValues, value]\n ],\n [[], []]\n );\n\n const args = new Uint8Array(IDL.encode([...argsTypes], [...argsValues]));\n\n const bytes: Uint8Array<ArrayBuffer> = await __ic_cdk_call_raw(canisterId, method, args);\n\n const result = IDL.decode(toNullable(resultType), bytes);\n\n // We have no test covering this use case because decode seems to never return more than one element, as we never specify more than one return type.\n if (result.length > 1) {\n throw new CallResponseLengthError();\n }\n\n const [response] = result as unknown as [T];\n return response;\n};\n", "import {IDL} from '@dfinity/candid';\nimport type {Principal} from '@dfinity/principal';\nimport * as z from 'zod
|
|
5
|
-
"mappings": "+CAAA,OAAQ,OAAAA,MAAU,kBAClB,OAAQ,aAAAC,MAAgB,qBACxB,OAAQ,cAAAC,MAAiB,iBCFzB,OAAQ,OAAAC,MAAU,kBAElB,UAAYC,MAAO,
|
|
4
|
+
"sourcesContent": ["import {IDL} from '@dfinity/candid';\nimport {Principal} from '@dfinity/principal';\nimport {toNullable} from '@dfinity/utils';\nimport {type CallParams, type IDLType, CallParamsSchema} from './schemas/call';\nimport {CallResponseLengthError} from './types/errors';\n\n/**\n * Makes an asynchronous call to a canister on the Internet Computer.\n *\n * This function encodes the provided arguments using Candid, performs the canister call,\n * and decodes the response based on the expected result types.\n *\n * @template T - The expected return type of the canister call.\n * @param {CallParams} params - The parameters required for the canister call\n * @returns {Promise<T | undefined>} A promise resolving to the decoded result of the call.\n * Returns `undefined` if the canister response is empty.\n * @throws {ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the canister call fails.\n */\nexport const call = async <T>(params: CallParams): Promise<T> => {\n CallParamsSchema.parse(params);\n\n const {canisterId: providedCanisterId, method, args: providedArgs, result: resultType} = params;\n\n const canisterId = Principal.from(providedCanisterId).toUint8Array();\n\n const [argsTypes, argsValues] = (providedArgs ?? []).reduce<[IDLType[], unknown[]]>(\n ([argsTypes, argsValues], [type, value]) => [\n [...argsTypes, type],\n [...argsValues, value]\n ],\n [[], []]\n );\n\n const args = new Uint8Array(IDL.encode([...argsTypes], [...argsValues]));\n\n const bytes: Uint8Array<ArrayBuffer> = await __ic_cdk_call_raw(canisterId, method, args);\n\n const result = IDL.decode(toNullable(resultType), bytes);\n\n // We have no test covering this use case because decode seems to never return more than one element, as we never specify more than one return type.\n if (result.length > 1) {\n throw new CallResponseLengthError();\n }\n\n const [response] = result as unknown as [T];\n return response;\n};\n", "import {IDL} from '@dfinity/candid';\nimport type {Principal} from '@dfinity/principal';\nimport * as z from 'zod';\nimport {PrincipalSchema, type RawPrincipal, RawPrincipalSchema} from '../../schemas/candid';\n\n/**\n * @see IDLType\n */\nexport const IDLTypeSchema = z.custom<IDL.Type<unknown>>((val) => val instanceof IDL.Type, {\n message: 'Invalid IDL.Type'\n});\n\n/**\n * Custom validation function to verify if a value is an instance of `IDL.Type` from `@dfinity/candid`.\n */\nexport type IDLType = z.infer<typeof IDLTypeSchema>;\n\n/**\n * @see CallArg\n */\nexport const CallArgSchema = z.tuple([IDLTypeSchema, z.unknown()]);\n\n/**\n * A call argument consisting of its IDL type and corresponding value.\n */\nexport type CallArg = z.infer<typeof CallArgSchema>;\n\n/**\n * Schema for encoding the call arguments.\n *\n * @see CallArgs\n */\nexport const CallArgsSchema = z.array(CallArgSchema);\n\n/**\n * Represents the arguments for a canister call on the IC.\n *\n * Requests and responses on the IC are encoded using Candid.\n * This schema ensures that each argument is provided with both its type and value\n * for proper encoding.\n *\n * The order of arguments is preserved for the function call.\n */\nexport type CallArgs = z.infer<typeof CallArgsSchema>;\n\n/**\n * @see CallResult\n */\nexport const CallResultSchema = IDLTypeSchema;\n\n/**\n * Defines the type used to decode the result of a canister call.\n */\nexport type CallResult = z.infer<typeof CallResultSchema>;\n\n/**\n * @see CallParams\n */\nexport const CallParamsSchema = z.object({\n canisterId: RawPrincipalSchema.or(PrincipalSchema),\n method: z.string().min(1),\n args: CallArgsSchema.optional(),\n result: CallResultSchema.optional()\n});\n\n/**\n * Type representing the parameters required to make a canister call.\n */\nexport interface CallParams {\n /**\n * The target canister's ID.\n */\n canisterId: RawPrincipal | Principal;\n\n /**\n * The name of the method to call. Minimum one character.\n */\n method: string;\n\n /**\n * The arguments, including types and values, for the canister call.\n */\n args?: CallArgs;\n\n /**\n * The expected result type used for decoding the response.\n */\n result?: CallResult;\n}\n", "export class CallResponseLengthError extends Error {\n constructor() {\n super();\n\n this.message = 'More than one object returned by the response. This is unexpected.';\n }\n}\n", "import {Principal} from '@dfinity/principal';\n\n/**\n * Retrieves the Satellite's Principal ID.\n *\n * This function is a JavaScript binding for the Rust function\n * [`ic_cdk::id()`](https://docs.rs/ic-cdk/latest/ic_cdk/fn.id.html), which returns\n * the Principal of the executing canister.\n *\n * @returns {Principal} The Principal ID of the Satellite.\n */\nexport const id = (): Principal => {\n const principal = Principal.fromUint8Array(__ic_cdk_id());\n\n // We assume the Principal is always built using the global function and is therefore always valid.\n // In other words, we do not validate it to conserve resources and optimize performance.\n\n return principal;\n};\n", "/**\n * Gets current timestamp, in nanoseconds since the epoch (1970-01-01)\n *\n * This function is a JavaScript binding for the Rust function\n * [`ic_cdk::time()`](https://docs.rs/ic-cdk/latest/ic_cdk/api/fn.time.html), which returns\n * the system time publicly exposed and verified part of the IC state tree\n *\n * @returns {bigint} The current timestamp.\n */\nexport const time = (): bigint => __ic_cdk_time();\n"],
|
|
5
|
+
"mappings": "+CAAA,OAAQ,OAAAA,MAAU,kBAClB,OAAQ,aAAAC,MAAgB,qBACxB,OAAQ,cAAAC,MAAiB,iBCFzB,OAAQ,OAAAC,MAAU,kBAElB,UAAYC,MAAO,MAMZ,IAAMC,EAAkB,SAA2BC,GAAQA,aAAeC,EAAI,KAAM,CACzF,QAAS,kBACX,CAAC,EAUYC,EAAkB,QAAM,CAACH,EAAiB,UAAQ,CAAC,CAAC,EAYpDI,EAAmB,QAAMD,CAAa,EAgBtCE,EAAmBL,EAUnBM,EAAqB,SAAO,CACvC,WAAYC,EAAmB,GAAGC,CAAe,EACjD,OAAU,SAAO,EAAE,IAAI,CAAC,EACxB,KAAMJ,EAAe,SAAS,EAC9B,OAAQC,EAAiB,SAAS,CACpC,CAAC,EC/DM,IAAMI,EAAN,cAAsC,KAAM,CACjD,aAAc,CACZ,MAAM,EAEN,KAAK,QAAU,oEACjB,CACF,EFaO,IAAMC,EAAO,MAAUC,GAAmC,CAC/DC,EAAiB,MAAMD,CAAM,EAE7B,GAAM,CAAC,WAAYE,EAAoB,OAAAC,EAAQ,KAAMC,EAAc,OAAQC,CAAU,EAAIL,EAEnFM,EAAaC,EAAU,KAAKL,CAAkB,EAAE,aAAa,EAE7D,CAACM,EAAWC,CAAU,GAAKL,GAAgB,CAAC,GAAG,OACnD,CAAC,CAACI,EAAWC,CAAU,EAAG,CAACC,EAAMC,CAAK,IAAM,CAC1C,CAAC,GAAGH,EAAWE,CAAI,EACnB,CAAC,GAAGD,EAAYE,CAAK,CACvB,EACA,CAAC,CAAC,EAAG,CAAC,CAAC,CACT,EAEMC,EAAO,IAAI,WAAWC,EAAI,OAAO,CAAC,GAAGL,CAAS,EAAG,CAAC,GAAGC,CAAU,CAAC,CAAC,EAEjEK,EAAiC,MAAM,kBAAkBR,EAAYH,EAAQS,CAAI,EAEjFG,EAASF,EAAI,OAAOG,EAAWX,CAAU,EAAGS,CAAK,EAGvD,GAAIC,EAAO,OAAS,EAClB,MAAM,IAAIE,EAGZ,GAAM,CAACC,CAAQ,EAAIH,EACnB,OAAOG,CACT,EG/CA,OAAQ,aAAAC,MAAgB,qBAWjB,IAAMC,EAAK,IACED,EAAU,eAAe,YAAY,CAAC,ECHnD,IAAME,EAAO,IAAc,cAAc",
|
|
6
6
|
"names": ["IDL", "Principal", "toNullable", "IDL", "z", "IDLTypeSchema", "val", "IDL", "CallArgSchema", "CallArgsSchema", "CallResultSchema", "CallParamsSchema", "RawPrincipalSchema", "PrincipalSchema", "CallResponseLengthError", "call", "params", "CallParamsSchema", "providedCanisterId", "method", "providedArgs", "resultType", "canisterId", "Principal", "argsTypes", "argsValues", "type", "value", "args", "IDL", "bytes", "result", "toNullable", "CallResponseLengthError", "response", "Principal", "id", "time"]
|
|
7
7
|
}
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as Ue,B as Me,C as je,a as ie,b as De,c as z,d as Ae,e as F,f as H,g as ye,h as Se,i as n,j as Oe,k as b,l as U,m as de,n as he,o as Ce,p as fe,q as r,r as Te,s as M,t as j,u as ue,v as ke,w as ze,x as Fe,y as He,z as be}from"./chunk-
|
|
1
|
+
import{A as Ue,B as Me,C as je,a as ie,b as De,c as z,d as Ae,e as F,f as H,g as ye,h as Se,i as n,j as Oe,k as b,l as U,m as de,n as he,o as Ce,p as fe,q as r,r as Te,s as M,t as j,u as ue,v as ke,w as ze,x as Fe,y as He,z as be}from"./chunk-SFZECPH3.js";import{a as xe,b as me,c as le}from"./chunk-CCKUQNB5.js";import*as a from"zod";import*as v from"zod";var c=e=>v.custom(i=>e.implement(i));import*as m from"zod";var A=m.object({collections:m.array(m.string()).readonly()}).strict();import*as o from"zod";var t=e=>o.strictObject({caller:z,data:e}),_=e=>c(o.function({input:o.tuple([e]),output:o.void()})),Z=e=>c(o.function({input:o.tuple([e]),output:o.promise(o.void()).or(o.void())}));import*as l from"zod";import*as y from"zod";var C=y.object({before:n.optional(),after:n}).strict(),R=y.object({current:n.optional(),proposed:b}).strict(),g=y.object({current:n.optional(),proposed:U}).strict();var p=e=>l.strictObject({collection:F,key:H,data:e}),E=t(p(C)),B=t(l.array(p(C))),f=t(p(n.optional())),T=t(l.array(p(n.optional()))),u=t(l.array(p(n.optional()))),w=t(p(R)),I=t(p(g));import*as D from"zod";var S=D.record(D.string(),D.string());import*as k from"zod";import*as K from"zod";var P=K.object({current:r.optional(),batch:M,commit_batch:j}).strict();var J=t(r),N=t(r.optional()),q=t(k.array(r.optional())),G=t(k.array(r.optional())),L=t(P),Q=t(r);var O=e=>A.extend({assert:_(e)}).strict(),V=O(w),W=O(I),X=O(L),Y=O(Q),nt=a.union([V,W,X,Y]),$=e=>a.function({input:a.tuple([S]),output:e}),st=e=>a.union([e,c($(e))]);function rt(e){return e}import*as x from"zod";var s=e=>A.extend({run:Z(e)}).strict(),ee=s(E),te=s(B),Dt=s(f),At=s(T),yt=s(u),oe=s(J),ne=s(N),se=s(q),re=s(G),St=x.union([ee,te,f,T,u,oe,ne,se,re]),ce=e=>x.function({input:x.tuple([S]),output:e}),Ot=e=>x.union([e,c(ce(e))]);function dt(e){return e}import{jsonReplacer as pe}from"@dfinity/utils";var d=e=>{let i=e.map(h=>typeof h=="object"?JSON.stringify(h,pe):h).join(" ");globalThis.__ic_cdk_print(i)};globalThis.console={info(...e){d(e)},log(...e){d(e)},warn(...e){d(e)},error(...e){d(e)}};var ae=()=>(__juno_satellite_random()>>>0)/4294967296;globalThis.Math.random=ae;export{Q as AssertDeleteAssetContextSchema,Y as AssertDeleteAssetSchema,I as AssertDeleteDocContextSchema,W as AssertDeleteDocSchema,st as AssertFnOrObjectSchema,$ as AssertFnSchema,_ as AssertFunctionSchema,nt as AssertSchema,w as AssertSetDocContextSchema,V as AssertSetDocSchema,L as AssertUploadAssetContextSchema,X as AssertUploadAssetSchema,P as AssetAssertUploadSchema,fe as AssetEncodingSchema,Ce as AssetKeySchema,Te as AssetNoContentSchema,r as AssetSchema,M as BatchSchema,he as BlobSchema,F as CollectionSchema,A as CollectionsSchema,j as CommitBatchSchema,U as DelDocSchema,ye as DescriptionSchema,g as DocAssertDeleteSchema,R as DocAssertSetSchema,p as DocContextSchema,n as DocSchema,C as DocUpsertSchema,ue as FullPathSchema,de as HeaderFieldsSchema,t as HookContextSchema,Ot as HookFnOrObjectSchema,ce as HookFnSchema,St as HookSchema,H as KeySchema,Fe as ListMatcherSchema,be as ListOrderFieldSchema,Ue as ListOrderSchema,He as ListPaginateSchema,Me as ListParamsSchema,N as OnDeleteAssetContextSchema,ne as OnDeleteAssetSchema,f as OnDeleteDocContextSchema,Dt as OnDeleteDocSchema,G as OnDeleteFilteredAssetsContextSchema,re as OnDeleteFilteredAssetsSchema,u as OnDeleteFilteredDocsContextSchema,yt as OnDeleteFilteredDocsSchema,q as OnDeleteManyAssetsContextSchema,se as OnDeleteManyAssetsSchema,T as OnDeleteManyDocsContextSchema,At as OnDeleteManyDocsSchema,E as OnSetDocContextSchema,ee as OnSetDocSchema,B as OnSetManyDocsContextSchema,te as OnSetManyDocsSchema,J as OnUploadAssetContextSchema,oe as OnUploadAssetSchema,ke as OptionAssetSchema,Oe as OptionDocSchema,le as PrincipalSchema,Se as RawDataSchema,me as RawPrincipalSchema,z as RawUserIdSchema,Z as RunFunctionSchema,S as SatelliteEnvSchema,b as SetDocSchema,ze as TimestampMatcherSchema,ie as TimestampSchema,xe as Uint8ArraySchema,Ae as UserIdSchema,De as VersionSchema,je as createListResultsSchema,rt as defineAssert,dt as defineHook};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/hooks/assertions.ts", "src/utils/zod.utils.ts", "src/hooks/schemas/collections.ts", "src/hooks/schemas/context.ts", "src/hooks/schemas/db/context.ts", "src/hooks/schemas/db/payload.ts", "src/hooks/schemas/satellite.env.ts", "src/hooks/schemas/storage/context.ts", "src/hooks/schemas/storage/payload.ts", "src/hooks/hooks.ts", "src/polyfills/console.polyfill.ts", "src/polyfills/random.polyfill.ts"],
|
|
4
|
-
"sourcesContent": ["import * as z from 'zod/v4';\nimport {createFunctionSchema} from '../utils/zod.utils';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type AssertFunction, AssertFunctionSchema} from './schemas/context';\nimport {\n type AssertDeleteDocContext,\n AssertDeleteDocContextSchema,\n type AssertSetDocContext,\n AssertSetDocContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n type AssertDeleteAssetContext,\n AssertDeleteAssetContextSchema,\n type AssertUploadAssetContext,\n AssertUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnAssert\n */\nconst OnAssertSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the assertion is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {void} Resolves when the assertion completes.\n */\n assert: AssertFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining assertions related to collections.\n *\n * @template T - The type of context passed to the assertions when triggered.\n */\nexport type OnAssert<T> = Collections & {\n assert: AssertFunction<T>;\n};\n\n/**\n * @see AssertSetDoc\n */\nexport const AssertSetDocSchema = OnAssertSchema(AssertSetDocContextSchema);\n\n/**\n * An assertion that runs when a document is created or updated.\n */\nexport type AssertSetDoc = OnAssert<AssertSetDocContext>;\n\n/**\n * @see AssertDeleteDoc\n */\nexport const AssertDeleteDocSchema = OnAssertSchema(AssertDeleteDocContextSchema);\n\n/**\n * An assertion that runs when a document is deleted.\n */\nexport type AssertDeleteDoc = OnAssert<AssertDeleteDocContext>;\n\n/**\n * @see AssertUploadAsset\n */\nexport const AssertUploadAssetSchema = OnAssertSchema(AssertUploadAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is uploaded.\n */\nexport type AssertUploadAsset = OnAssert<AssertUploadAssetContext>;\n\n/**\n * @see AssertDeleteAsset\n */\nexport const AssertDeleteAssetSchema = OnAssertSchema(AssertDeleteAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is deleted.\n */\nexport type AssertDeleteAsset = OnAssert<AssertDeleteAssetContext>;\n\n/**\n * @see Assert\n */\nexport const AssertSchema = z.union([\n AssertSetDocSchema,\n AssertDeleteDocSchema,\n AssertUploadAssetSchema,\n AssertDeleteAssetSchema\n]);\n\n/**\n * All assertions definitions.\n */\nexport type Assert = AssertSetDoc | AssertDeleteDoc | AssertUploadAsset | AssertDeleteAsset;\n\nexport const AssertFnSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.function({\n input: z.tuple([SatelliteEnvSchema]),\n output: assertSchema\n });\nexport type AssertFn<T extends Assert> = (assert: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const AssertFnOrObjectSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.union([assertSchema, createFunctionSchema(AssertFnSchema(assertSchema))]);\nexport type AssertFnOrObject<T extends Assert> = T | AssertFn<T>;\n\nexport function defineAssert<T extends Assert>(assert: T): T;\nexport function defineAssert<T extends Assert>(assert: AssertFn<T>): AssertFn<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T> {\n return assert;\n}\n", "import * as z from 'zod/v4';\n\n// TODO: Workaround source: https://github.com/colinhacks/zod/issues/4143#issuecomment-2845134912\nexport const createFunctionSchema = <T extends z.core.$ZodFunction>(schema: T) =>\n z.custom<Parameters<T['implement']>[0]>((fn) =>\n schema.implement(fn as Parameters<T['implement']>[0])\n );\n", "import * as z from 'zod/v4';\nimport type {Collection} from '../../schemas/satellite';\n\n/**\n * @see Collections\n */\nexport const CollectionsSchema = z\n .object({\n collections: z.array(z.string()).readonly()\n })\n .strict();\n\n/**\n * Defines the collections where a hook or assertion should run.\n */\nexport interface Collections {\n /**\n * An array of collection names where the hook or assertion will run.\n * If empty, no hooks or assertions are triggered.\n */\n collections: readonly Collection[];\n}\n", "import * as z from 'zod/v4';\nimport {type RawUserId, RawUserIdSchema} from '../../schemas/satellite';\nimport {createFunctionSchema} from '../../utils/zod.utils';\n\n/**\n * @see HookContext\n */\nexport const HookContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n caller: RawUserIdSchema,\n data: dataSchema\n };\n\n return z.strictObject(schemaShape);\n};\n\n/**\n * Represents the context provided to hooks, containing information about the caller and related data.\n *\n * @template T - The type of data associated with the hook.\n */\nexport interface HookContext<T> {\n /**\n * The user who originally triggered the function that in turn triggered the hook.\n */\n caller: RawUserId;\n\n /**\n * The data associated with the hook execution.\n */\n data: T;\n}\n\n/**\n * @see AssertFunction\n */\nexport const AssertFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n createFunctionSchema(z.function({input: z.tuple([contextSchema]), output: z.void()}));\n\n/**\n * Defines the `assert` function schema for assertions.\n *\n * The function takes a context argument and returns `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type AssertFunction<T> = (context: T) => void;\n\n/**\n * @see RunFunction\n */\nexport const RunFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n createFunctionSchema(\n z.function({input: z.tuple([contextSchema]), output: z.promise(z.void()).or(z.void())})\n );\n\n/**\n * Defines the `run` function schema for hooks.\n *\n * The function takes a context argument and returns either a `Promise<void>` or `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type RunFunction<T> = (context: T) => void | Promise<void>;\n", "import * as z from 'zod/v4';\nimport {DocSchema, type OptionDoc} from '../../../schemas/db';\nimport {type Collection, CollectionSchema, type Key, KeySchema} from '../../../schemas/satellite';\nimport {type HookContext, HookContextSchema} from '../context';\nimport {\n type DocAssertDelete,\n DocAssertDeleteSchema,\n type DocAssertSet,\n DocAssertSetSchema,\n type DocUpsert,\n DocUpsertSchema\n} from './payload';\n\n/**\n * @see DocContext\n */\nexport const DocContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n collection: CollectionSchema,\n key: KeySchema,\n data: dataSchema\n };\n\n return z.strictObject(schemaShape);\n};\n\n/**\n * Represents the context of a document operation within a collection.\n *\n * @template T - The type of data associated with the document.\n */\nexport interface DocContext<T> {\n /**\n * The name of the collection where the document is stored.\n */\n collection: Collection;\n\n /**\n * The key identifying the document within the collection.\n */\n key: Key;\n\n /**\n * The data associated with the document operation.\n */\n data: T;\n}\n\n/**\n * @see OnSetDocContext\n */\nexport const OnSetDocContextSchema = HookContextSchema(DocContextSchema(DocUpsertSchema));\n\n/**\n * The context provided to the `onSetDoc` hook.\n *\n * This context contains information about the document being created or updated,\n * along with details about the user who triggered the operation.\n */\nexport type OnSetDocContext = HookContext<DocContext<DocUpsert>>;\n\n/**\n * @see OnSetManyDocsContext\n */\nexport const OnSetManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocUpsertSchema))\n);\n\n/**\n * The context provided to the `onSetManyDocs` hook.\n *\n * This context contains information about multiple documents being created or updated\n * in a single operation, along with details about the user who triggered it.\n */\nexport type OnSetManyDocsContext = HookContext<DocContext<DocUpsert>[]>;\n\n/**\n * @see OnDeleteDocContext\n */\nexport const OnDeleteDocContextSchema = HookContextSchema(DocContextSchema(DocSchema.optional()));\n\n/**\n * The context provided to the `onDeleteDoc` hook.\n *\n * This context contains information about a single document being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteDocContext = HookContext<DocContext<OptionDoc>>;\n\n/**\n * @see OnDeleteManyDocsContext\n */\nexport const OnDeleteManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteManyDocs` hook.\n *\n * This context contains information about multiple documents being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see OnDeleteFilteredDocsContext\n */\nexport const OnDeleteFilteredDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteFilteredDocs` hook.\n *\n * This context contains information about documents deleted as a result of a filter,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see AssertSetDocContext\n */\nexport const AssertSetDocContextSchema = HookContextSchema(DocContextSchema(DocAssertSetSchema));\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is created or updated. If validation fails, the developer should throw an error.\n */\nexport type AssertSetDocContext = HookContext<DocContext<DocAssertSet>>;\n\n/**\n * @see AssertDeleteDocContext\n */\nexport const AssertDeleteDocContextSchema = HookContextSchema(\n DocContextSchema(DocAssertDeleteSchema)\n);\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteDocContext = HookContext<DocContext<DocAssertDelete>>;\n", "import * as z from 'zod/v4';\nimport {\n type DelDoc,\n DelDocSchema,\n type Doc,\n DocSchema,\n type SetDoc,\n SetDocSchema\n} from '../../../schemas/db';\n\n/**\n * @see DocUpsert\n */\nexport const DocUpsertSchema = z\n .object({\n before: DocSchema.optional(),\n after: DocSchema\n })\n .strict();\n\n/**\n * Represents a document update operation.\n *\n * This is used in hooks where a document is either being created or updated.\n */\nexport interface DocUpsert {\n /**\n * The previous version of the document before the update.\n * Undefined if this is a new document.\n */\n before?: Doc;\n\n /**\n * The new version of the document after the update.\n */\n after: Doc;\n}\n/**\n * @see DocAssertSet\n */\nexport const DocAssertSetSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: SetDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before setting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertSet {\n /**\n * The current version of the document before the operation.\n * Undefined if this is a new document.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: SetDoc;\n}\n\n/**\n * @see DocAssertDelete\n */\nexport const DocAssertDeleteSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: DelDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before deleting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertDelete {\n /**\n * The current version of the document before the operation.\n * Undefined if the document does not exist.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: DelDoc;\n}\n", "import * as z from 'zod/v4';\n\n/**\n * @see SatelliteEnv\n */\nexport const SatelliteEnvSchema = z.record(z.string(), z.string());\n\n/**\n * Placeholder for future environment-specific configurations.\n *\n * Currently unused, but it may support features such as:\n * - Defining the execution mode (e.g., staging or production).\n * - Providing environment-specific values like `ckBtcLedgerId` for test or production.\n */\nexport type SatelliteEnv = z.infer<typeof SatelliteEnvSchema>;\n", "import * as z from 'zod/v4';\nimport {AssetSchema, type Asset} from '../../../schemas/storage';\nimport {HookContextSchema, type HookContext} from '../context';\nimport {AssetAssertUploadSchema, type AssetAssertUpload} from './payload';\n\n/**\n * @see OnUploadAssetContext\n */\nexport const OnUploadAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `onUploadAsset` hook.\n *\n * This context contains information about the asset that was uploaded.\n */\nexport type OnUploadAssetContext = HookContext<Asset>;\n\n/**\n * @see OnDeleteAssetContext\n */\nexport const OnDeleteAssetContextSchema = HookContextSchema(AssetSchema.optional());\n\n/**\n * Context for the `onDeleteAsset` hook.\n *\n * This context contains information about a single asset being deleted, along with details about the user who triggered the operation.\n *\n * If undefined, the asset did not exist.\n */\nexport type OnDeleteAssetContext = HookContext<Asset | undefined>;\n\n/**\n * @see OnDeleteManyAssetsContext\n */\nexport const OnDeleteManyAssetsContextSchema = HookContextSchema(z.array(AssetSchema.optional()));\n\n/**\n * Context for the `onDeleteManyAssets` hook.\n *\n * This context contains information about multiple assets being potentially deleted, along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see OnDeleteFilteredAssetsContext\n */\nexport const OnDeleteFilteredAssetsContextSchema = HookContextSchema(\n z.array(AssetSchema.optional())\n);\n\n/**\n * Context for the `onDeleteFilteredAssets` hook.\n *\n * This context contains information about documents deleted as a result of a filter, along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see AssertUploadAssetContext\n */\nexport const AssertUploadAssetContextSchema = HookContextSchema(AssetAssertUploadSchema);\n\n/**\n * Context for the `assertUploadAsset` hook.\n *\n * This context contains information about the asset being validated before it is uploaded. If validation fails, the developer should throw an error.\n */\nexport type AssertUploadAssetContext = HookContext<AssetAssertUpload>;\n\n/**\n * @see AssertDeleteAssetContext\n */\nexport const AssertDeleteAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `assertDeleteAsset` hook.\n *\n * This context contains information about the asset being validated before it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteAssetContext = HookContext<Asset>;\n", "import * as z from 'zod/v4';\nimport {\n type Asset,\n AssetSchema,\n type Batch,\n BatchSchema,\n type CommitBatch,\n CommitBatchSchema\n} from '../../../schemas/storage';\n\n/**\n * @see AssetAssertUpload\n */\nexport const AssetAssertUploadSchema = z\n .object({\n current: AssetSchema.optional(),\n batch: BatchSchema,\n commit_batch: CommitBatchSchema\n })\n .strict();\n\n/**\n * Represents a validation context before uploading an asset.\n */\nexport interface AssetAssertUpload {\n /**\n * The current asset already stored (if any).\n */\n current?: Asset;\n\n /**\n * The batch metadata being uploaded.\n */\n batch: Batch;\n\n /**\n * The commit data describing headers and chunk ids.\n */\n commit_batch: CommitBatch;\n}\n", "import * as z from 'zod/v4';\nimport {createFunctionSchema} from '../utils/zod.utils';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type RunFunction, RunFunctionSchema} from './schemas/context';\nimport {\n type OnDeleteDocContext,\n OnDeleteDocContextSchema,\n type OnDeleteFilteredDocsContext,\n OnDeleteFilteredDocsContextSchema,\n type OnDeleteManyDocsContext,\n OnDeleteManyDocsContextSchema,\n type OnSetDocContext,\n OnSetDocContextSchema,\n type OnSetManyDocsContext,\n OnSetManyDocsContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n type OnDeleteAssetContext,\n OnDeleteAssetContextSchema,\n type OnDeleteFilteredAssetsContext,\n OnDeleteFilteredAssetsContextSchema,\n type OnDeleteManyAssetsContext,\n OnDeleteManyAssetsContextSchema,\n type OnUploadAssetContext,\n OnUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnHook\n */\nconst OnHookSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n run: RunFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining hooks related to collections.\n *\n * @template T - The type of context passed to the hook when triggered.\n */\nexport type OnHook<T> = Collections & {\n /**\n * A function that runs when the hook is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {Promise<void>} Resolves when the operation completes.\n */\n run: RunFunction<T>;\n};\n\n/**\n * @see OnSetDoc\n */\nexport const OnSetDocSchema = OnHookSchema(OnSetDocContextSchema);\n\n/**\n * A hook that runs when a document is created or updated.\n */\nexport type OnSetDoc = OnHook<OnSetDocContext>;\n\n/**\n * @see OnSetManyDocs\n */\nexport const OnSetManyDocsSchema = OnHookSchema(OnSetManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are created or updated.\n */\nexport type OnSetManyDocs = OnHook<OnSetManyDocsContext>;\n\n/**\n * @see OnDeleteDoc\n */\nexport const OnDeleteDocSchema = OnHookSchema(OnDeleteDocContextSchema);\n\n/**\n * A hook that runs when a single document is deleted.\n */\nexport type OnDeleteDoc = OnHook<OnDeleteDocContext>;\n\n/**\n * @see OnDeleteManyDocs\n */\nexport const OnDeleteManyDocsSchema = OnHookSchema(OnDeleteManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are deleted.\n */\nexport type OnDeleteManyDocs = OnHook<OnDeleteManyDocsContext>;\n\n/**\n * @see OnDeleteFilteredDocs\n */\nexport const OnDeleteFilteredDocsSchema = OnHookSchema(OnDeleteFilteredDocsContextSchema);\n\n/**\n * A hook that runs when a filtered set of documents is deleted based on query conditions.\n */\nexport type OnDeleteFilteredDocs = OnHook<OnDeleteFilteredDocsContext>;\n\n/**\n * @see OnUploadAsset\n */\nexport const OnUploadAssetSchema = OnHookSchema(OnUploadAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is uploaded.\n */\nexport type OnUploadAsset = OnHook<OnUploadAssetContext>;\n\n/**\n * @see OnDeleteAsset\n */\nexport const OnDeleteAssetSchema = OnHookSchema(OnDeleteAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is potentially deleted.\n */\nexport type OnDeleteAsset = OnHook<OnDeleteAssetContext>;\n\n/**\n * @see OnDeleteManyAssets\n */\nexport const OnDeleteManyAssetsSchema = OnHookSchema(OnDeleteManyAssetsContextSchema);\n\n/**\n * A hook that runs when multiple assets are potentially deleted.\n */\nexport type OnDeleteManyAssets = OnHook<OnDeleteManyAssetsContext>;\n\n/**\n * @see OnDeleteFilteredAssets\n */\nexport const OnDeleteFilteredAssetsSchema = OnHookSchema(OnDeleteFilteredAssetsContextSchema);\n\n/**\n * A hook that runs when a filtered set of assets is deleted based on query conditions.\n */\nexport type OnDeleteFilteredAssets = OnHook<OnDeleteFilteredAssetsContext>;\n\n/**\n * @see Hook\n */\nexport const HookSchema = z.union([\n OnSetDocSchema,\n OnSetManyDocsSchema,\n OnDeleteDocContextSchema,\n OnDeleteManyDocsContextSchema,\n OnDeleteFilteredDocsContextSchema,\n OnUploadAssetSchema,\n OnDeleteAssetSchema,\n OnDeleteManyAssetsSchema,\n OnDeleteFilteredAssetsSchema\n]);\n\n/**\n * All hooks definitions.\n */\nexport type Hook =\n | OnSetDoc\n | OnSetManyDocs\n | OnDeleteDoc\n | OnDeleteManyDocs\n | OnDeleteFilteredDocs\n | OnUploadAsset\n | OnDeleteAsset\n | OnDeleteManyAssets\n | OnDeleteFilteredAssets;\n\nexport const HookFnSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.function({input: z.tuple([SatelliteEnvSchema]), output: hookSchema});\nexport type HookFn<T extends Hook> = (hook: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const HookFnOrObjectSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.union([hookSchema, createFunctionSchema(HookFnSchema(hookSchema))]);\nexport type HookFnOrObject<T extends Hook> = T | HookFn<T>;\n\nexport function defineHook<T extends Hook>(hook: T): T;\nexport function defineHook<T extends Hook>(hook: HookFn<T>): HookFn<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T> {\n return hook;\n}\n", "import {jsonReplacer} from '@dfinity/utils';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst __juno_satellite_console_log = (v: any[]) => {\n const msg = v\n .map((arg) => (typeof arg === 'object' ? JSON.stringify(arg, jsonReplacer) : arg))\n .join(' ');\n\n globalThis.__ic_cdk_print(msg);\n};\n\n// @ts-expect-error We want to override the console\nglobalThis.console = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n info(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n log(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n warn(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error(...v: any[]) {\n __juno_satellite_console_log(v);\n }\n};\n", "/**\n * @see Math.random\n */\nconst random = (): number => {\n // __juno_satellite_random() returns a signed 32-bit int (i32)\n const value = __juno_satellite_random();\n\n // >>> 0 converts it to unsigned\n return (value >>> 0) / 2 ** 32;\n};\n\n/**\n * Overwrites Math.random with a pseudo-random number using the Satellite's internal RNG.\n *\n * \u26A0\uFE0F This function is not suitable for use cases requiring cryptographically secure or perfectly unpredictable randomness,\n * such as lotteries or gambling dApps.\n *\n * @returns {number} A pseudo-random 32-bit integer.\n *\n * @throws {Error} If the RNG has not been initialized.\n */\nglobalThis.Math.random = random;\n"],
|
|
5
|
-
"mappings": "yTAAA,UAAYA,MAAO,
|
|
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": "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",
|
|
6
6
|
"names": ["z", "z", "createFunctionSchema", "schema", "fn", "z", "CollectionsSchema", "z", "HookContextSchema", "dataSchema", "RawUserIdSchema", "AssertFunctionSchema", "contextSchema", "createFunctionSchema", "RunFunctionSchema", "z", "z", "DocUpsertSchema", "DocSchema", "DocAssertSetSchema", "SetDocSchema", "DocAssertDeleteSchema", "DelDocSchema", "DocContextSchema", "dataSchema", "CollectionSchema", "KeySchema", "OnSetDocContextSchema", "HookContextSchema", "DocUpsertSchema", "OnSetManyDocsContextSchema", "OnDeleteDocContextSchema", "DocSchema", "OnDeleteManyDocsContextSchema", "OnDeleteFilteredDocsContextSchema", "AssertSetDocContextSchema", "DocAssertSetSchema", "AssertDeleteDocContextSchema", "DocAssertDeleteSchema", "z", "SatelliteEnvSchema", "z", "z", "AssetAssertUploadSchema", "AssetSchema", "BatchSchema", "CommitBatchSchema", "OnUploadAssetContextSchema", "HookContextSchema", "AssetSchema", "OnDeleteAssetContextSchema", "OnDeleteManyAssetsContextSchema", "OnDeleteFilteredAssetsContextSchema", "AssertUploadAssetContextSchema", "AssetAssertUploadSchema", "AssertDeleteAssetContextSchema", "OnAssertSchema", "contextSchema", "CollectionsSchema", "AssertFunctionSchema", "AssertSetDocSchema", "AssertSetDocContextSchema", "AssertDeleteDocSchema", "AssertDeleteDocContextSchema", "AssertUploadAssetSchema", "AssertUploadAssetContextSchema", "AssertDeleteAssetSchema", "AssertDeleteAssetContextSchema", "AssertSchema", "AssertFnSchema", "assertSchema", "SatelliteEnvSchema", "AssertFnOrObjectSchema", "createFunctionSchema", "defineAssert", "assert", "z", "OnHookSchema", "contextSchema", "CollectionsSchema", "RunFunctionSchema", "OnSetDocSchema", "OnSetDocContextSchema", "OnSetManyDocsSchema", "OnSetManyDocsContextSchema", "OnDeleteDocSchema", "OnDeleteDocContextSchema", "OnDeleteManyDocsSchema", "OnDeleteManyDocsContextSchema", "OnDeleteFilteredDocsSchema", "OnDeleteFilteredDocsContextSchema", "OnUploadAssetSchema", "OnUploadAssetContextSchema", "OnDeleteAssetSchema", "OnDeleteAssetContextSchema", "OnDeleteManyAssetsSchema", "OnDeleteManyAssetsContextSchema", "OnDeleteFilteredAssetsSchema", "OnDeleteFilteredAssetsContextSchema", "HookSchema", "HookFnSchema", "hookSchema", "SatelliteEnvSchema", "HookFnOrObjectSchema", "createFunctionSchema", "defineHook", "hook", "jsonReplacer", "__juno_satellite_console_log", "v", "msg", "arg", "random"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junobuild/functions",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "JavaScript and TypeScript utilities for Juno Serverless Functions",
|
|
5
5
|
"author": "David Dal Busco (https://daviddalbusco.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,6 +51,6 @@
|
|
|
51
51
|
"@dfinity/identity": "^3.2.6",
|
|
52
52
|
"@dfinity/principal": "^3.2.6",
|
|
53
53
|
"@dfinity/utils": "^3.1",
|
|
54
|
-
"zod": "^
|
|
54
|
+
"zod": "^4"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/schemas/candid.d.ts
CHANGED
package/schemas/db.d.ts
CHANGED
package/schemas/list.d.ts
CHANGED
package/schemas/satellite.d.ts
CHANGED
package/schemas/storage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as z from 'zod
|
|
1
|
+
import * as z from 'zod';
|
|
2
2
|
import { type Collection, type Description, type RawUserId, type Timestamp, type Version } from './satellite';
|
|
3
3
|
/**
|
|
4
4
|
* Represents a single HTTP header as a tuple of name and value.
|
|
@@ -169,9 +169,9 @@ export interface Asset {
|
|
|
169
169
|
* @see AssetNoContent
|
|
170
170
|
*/
|
|
171
171
|
export declare const AssetNoContentSchema: z.ZodObject<{
|
|
172
|
-
version: z.ZodOptional<z.ZodBigInt>;
|
|
173
172
|
created_at: z.ZodBigInt;
|
|
174
173
|
updated_at: z.ZodBigInt;
|
|
174
|
+
version: z.ZodOptional<z.ZodBigInt>;
|
|
175
175
|
key: z.ZodObject<{
|
|
176
176
|
name: z.ZodString;
|
|
177
177
|
full_path: z.ZodString;
|