@junobuild/functions 0.1.4 → 0.2.1
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 +464 -356
- package/chunk-KY6LCVKU.js +2 -0
- package/chunk-KY6LCVKU.js.map +7 -0
- package/chunk-R6MTJSTE.js +2 -0
- package/chunk-R6MTJSTE.js.map +7 -0
- package/hooks/assertions.d.ts +382 -6958
- package/hooks/hooks.d.ts +649 -10260
- package/hooks/schemas/collections.d.ts +3 -7
- package/hooks/schemas/context.d.ts +6 -13
- package/hooks/schemas/db/context.d.ts +87 -3332
- package/hooks/schemas/db/payload.d.ts +19 -173
- package/hooks/schemas/satellite.env.d.ts +2 -2
- package/hooks/schemas/storage/context.d.ts +111 -1861
- package/hooks/schemas/storage/payload.d.ts +29 -203
- package/ic-cdk/schemas/call.d.ts +9 -19
- package/ic-cdk.js +1 -1
- package/ic-cdk.js.map +2 -2
- package/index.js +1 -1
- package/index.js.map +4 -4
- package/package.json +1 -1
- package/schemas/candid.d.ts +4 -4
- package/schemas/db.d.ts +11 -51
- package/schemas/list.d.ts +51 -303
- package/schemas/satellite.d.ts +3 -3
- package/schemas/storage.d.ts +66 -312
- package/sdk/schemas/collections.d.ts +5 -2
- package/sdk/schemas/controllers.d.ts +39 -85
- package/sdk/schemas/db.d.ts +152 -874
- package/sdk/schemas/params.d.ts +24 -247
- package/sdk/schemas/storage.d.ts +86 -830
- package/sdk.js +1 -1
- package/sdk.js.map +2 -2
- package/utils/zod.utils.d.ts +2 -0
- package/chunk-CCKUQNB5.js +0 -2
- package/chunk-CCKUQNB5.js.map +0 -7
- package/chunk-SFZECPH3.js +0 -2
- package/chunk-SFZECPH3.js.map +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
2
|
import { type Asset, type Batch, type CommitBatch } from '../../../schemas/storage';
|
|
3
3
|
/**
|
|
4
4
|
* @see AssetAssertUpload
|
|
@@ -10,225 +10,51 @@ export declare const AssetAssertUploadSchema: z.ZodObject<{
|
|
|
10
10
|
full_path: z.ZodString;
|
|
11
11
|
token: z.ZodOptional<z.ZodString>;
|
|
12
12
|
collection: z.ZodString;
|
|
13
|
-
owner: z.
|
|
13
|
+
owner: z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>;
|
|
14
14
|
description: z.ZodOptional<z.ZodString>;
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
collection: string;
|
|
25
|
-
name: string;
|
|
26
|
-
full_path: string;
|
|
27
|
-
description?: string | undefined;
|
|
28
|
-
token?: string | undefined;
|
|
29
|
-
}>;
|
|
30
|
-
headers: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>, "many">;
|
|
31
|
-
encodings: z.ZodArray<z.ZodTuple<[z.ZodEnum<["identity", "gzip", "compress", "deflate", "br"]>, z.ZodObject<{
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
headers: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
|
|
17
|
+
encodings: z.ZodArray<z.ZodTuple<[z.ZodEnum<{
|
|
18
|
+
identity: "identity";
|
|
19
|
+
gzip: "gzip";
|
|
20
|
+
compress: "compress";
|
|
21
|
+
deflate: "deflate";
|
|
22
|
+
br: "br";
|
|
23
|
+
}>, z.ZodObject<{
|
|
32
24
|
modified: z.ZodBigInt;
|
|
33
|
-
content_chunks: z.ZodArray<z.
|
|
25
|
+
content_chunks: z.ZodArray<z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>>;
|
|
34
26
|
total_length: z.ZodBigInt;
|
|
35
|
-
sha256: z.
|
|
36
|
-
},
|
|
37
|
-
modified: bigint;
|
|
38
|
-
content_chunks: Uint8Array<ArrayBufferLike>[];
|
|
39
|
-
total_length: bigint;
|
|
40
|
-
sha256: Uint8Array<ArrayBuffer>;
|
|
41
|
-
}, {
|
|
42
|
-
modified: bigint;
|
|
43
|
-
content_chunks: Uint8Array<ArrayBufferLike>[];
|
|
44
|
-
total_length: bigint;
|
|
45
|
-
sha256: Uint8Array<ArrayBuffer>;
|
|
46
|
-
}>], null>, "many">;
|
|
27
|
+
sha256: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
28
|
+
}, z.core.$strip>], null>>;
|
|
47
29
|
created_at: z.ZodBigInt;
|
|
48
30
|
updated_at: z.ZodBigInt;
|
|
49
31
|
version: z.ZodOptional<z.ZodBigInt>;
|
|
50
|
-
},
|
|
51
|
-
created_at: bigint;
|
|
52
|
-
updated_at: bigint;
|
|
53
|
-
key: {
|
|
54
|
-
owner: Uint8Array<ArrayBufferLike>;
|
|
55
|
-
collection: string;
|
|
56
|
-
name: string;
|
|
57
|
-
full_path: string;
|
|
58
|
-
description?: string | undefined;
|
|
59
|
-
token?: string | undefined;
|
|
60
|
-
};
|
|
61
|
-
headers: [string, string][];
|
|
62
|
-
encodings: ["identity" | "gzip" | "compress" | "deflate" | "br", {
|
|
63
|
-
modified: bigint;
|
|
64
|
-
content_chunks: Uint8Array<ArrayBufferLike>[];
|
|
65
|
-
total_length: bigint;
|
|
66
|
-
sha256: Uint8Array<ArrayBuffer>;
|
|
67
|
-
}][];
|
|
68
|
-
version?: bigint | undefined;
|
|
69
|
-
}, {
|
|
70
|
-
created_at: bigint;
|
|
71
|
-
updated_at: bigint;
|
|
72
|
-
key: {
|
|
73
|
-
owner: Uint8Array<ArrayBufferLike>;
|
|
74
|
-
collection: string;
|
|
75
|
-
name: string;
|
|
76
|
-
full_path: string;
|
|
77
|
-
description?: string | undefined;
|
|
78
|
-
token?: string | undefined;
|
|
79
|
-
};
|
|
80
|
-
headers: [string, string][];
|
|
81
|
-
encodings: ["identity" | "gzip" | "compress" | "deflate" | "br", {
|
|
82
|
-
modified: bigint;
|
|
83
|
-
content_chunks: Uint8Array<ArrayBufferLike>[];
|
|
84
|
-
total_length: bigint;
|
|
85
|
-
sha256: Uint8Array<ArrayBuffer>;
|
|
86
|
-
}][];
|
|
87
|
-
version?: bigint | undefined;
|
|
88
|
-
}>>;
|
|
32
|
+
}, z.core.$strict>>;
|
|
89
33
|
batch: z.ZodObject<{
|
|
90
34
|
key: z.ZodObject<{
|
|
91
35
|
name: z.ZodString;
|
|
92
36
|
full_path: z.ZodString;
|
|
93
37
|
token: z.ZodOptional<z.ZodString>;
|
|
94
38
|
collection: z.ZodString;
|
|
95
|
-
owner: z.
|
|
39
|
+
owner: z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>;
|
|
96
40
|
description: z.ZodOptional<z.ZodString>;
|
|
97
|
-
},
|
|
98
|
-
owner: Uint8Array<ArrayBufferLike>;
|
|
99
|
-
collection: string;
|
|
100
|
-
name: string;
|
|
101
|
-
full_path: string;
|
|
102
|
-
description?: string | undefined;
|
|
103
|
-
token?: string | undefined;
|
|
104
|
-
}, {
|
|
105
|
-
owner: Uint8Array<ArrayBufferLike>;
|
|
106
|
-
collection: string;
|
|
107
|
-
name: string;
|
|
108
|
-
full_path: string;
|
|
109
|
-
description?: string | undefined;
|
|
110
|
-
token?: string | undefined;
|
|
111
|
-
}>;
|
|
41
|
+
}, z.core.$strict>;
|
|
112
42
|
reference_id: z.ZodOptional<z.ZodBigInt>;
|
|
113
43
|
expires_at: z.ZodBigInt;
|
|
114
|
-
encoding_type: z.ZodOptional<z.ZodEnum<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
token?: string | undefined;
|
|
123
|
-
};
|
|
124
|
-
expires_at: bigint;
|
|
125
|
-
reference_id?: bigint | undefined;
|
|
126
|
-
encoding_type?: "identity" | "gzip" | "compress" | "deflate" | "br" | undefined;
|
|
127
|
-
}, {
|
|
128
|
-
key: {
|
|
129
|
-
owner: Uint8Array<ArrayBufferLike>;
|
|
130
|
-
collection: string;
|
|
131
|
-
name: string;
|
|
132
|
-
full_path: string;
|
|
133
|
-
description?: string | undefined;
|
|
134
|
-
token?: string | undefined;
|
|
135
|
-
};
|
|
136
|
-
expires_at: bigint;
|
|
137
|
-
reference_id?: bigint | undefined;
|
|
138
|
-
encoding_type?: "identity" | "gzip" | "compress" | "deflate" | "br" | undefined;
|
|
139
|
-
}>;
|
|
44
|
+
encoding_type: z.ZodOptional<z.ZodEnum<{
|
|
45
|
+
identity: "identity";
|
|
46
|
+
gzip: "gzip";
|
|
47
|
+
compress: "compress";
|
|
48
|
+
deflate: "deflate";
|
|
49
|
+
br: "br";
|
|
50
|
+
}>>;
|
|
51
|
+
}, z.core.$strict>;
|
|
140
52
|
commit_batch: z.ZodObject<{
|
|
141
53
|
batch_id: z.ZodBigInt;
|
|
142
|
-
headers: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null
|
|
143
|
-
chunk_ids: z.ZodArray<z.ZodBigInt
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
batch_id: bigint;
|
|
147
|
-
chunk_ids: bigint[];
|
|
148
|
-
}, {
|
|
149
|
-
headers: [string, string][];
|
|
150
|
-
batch_id: bigint;
|
|
151
|
-
chunk_ids: bigint[];
|
|
152
|
-
}>;
|
|
153
|
-
}, "strict", z.ZodTypeAny, {
|
|
154
|
-
batch: {
|
|
155
|
-
key: {
|
|
156
|
-
owner: Uint8Array<ArrayBufferLike>;
|
|
157
|
-
collection: string;
|
|
158
|
-
name: string;
|
|
159
|
-
full_path: string;
|
|
160
|
-
description?: string | undefined;
|
|
161
|
-
token?: string | undefined;
|
|
162
|
-
};
|
|
163
|
-
expires_at: bigint;
|
|
164
|
-
reference_id?: bigint | undefined;
|
|
165
|
-
encoding_type?: "identity" | "gzip" | "compress" | "deflate" | "br" | undefined;
|
|
166
|
-
};
|
|
167
|
-
commit_batch: {
|
|
168
|
-
headers: [string, string][];
|
|
169
|
-
batch_id: bigint;
|
|
170
|
-
chunk_ids: bigint[];
|
|
171
|
-
};
|
|
172
|
-
current?: {
|
|
173
|
-
created_at: bigint;
|
|
174
|
-
updated_at: bigint;
|
|
175
|
-
key: {
|
|
176
|
-
owner: Uint8Array<ArrayBufferLike>;
|
|
177
|
-
collection: string;
|
|
178
|
-
name: string;
|
|
179
|
-
full_path: string;
|
|
180
|
-
description?: string | undefined;
|
|
181
|
-
token?: string | undefined;
|
|
182
|
-
};
|
|
183
|
-
headers: [string, string][];
|
|
184
|
-
encodings: ["identity" | "gzip" | "compress" | "deflate" | "br", {
|
|
185
|
-
modified: bigint;
|
|
186
|
-
content_chunks: Uint8Array<ArrayBufferLike>[];
|
|
187
|
-
total_length: bigint;
|
|
188
|
-
sha256: Uint8Array<ArrayBuffer>;
|
|
189
|
-
}][];
|
|
190
|
-
version?: bigint | undefined;
|
|
191
|
-
} | undefined;
|
|
192
|
-
}, {
|
|
193
|
-
batch: {
|
|
194
|
-
key: {
|
|
195
|
-
owner: Uint8Array<ArrayBufferLike>;
|
|
196
|
-
collection: string;
|
|
197
|
-
name: string;
|
|
198
|
-
full_path: string;
|
|
199
|
-
description?: string | undefined;
|
|
200
|
-
token?: string | undefined;
|
|
201
|
-
};
|
|
202
|
-
expires_at: bigint;
|
|
203
|
-
reference_id?: bigint | undefined;
|
|
204
|
-
encoding_type?: "identity" | "gzip" | "compress" | "deflate" | "br" | undefined;
|
|
205
|
-
};
|
|
206
|
-
commit_batch: {
|
|
207
|
-
headers: [string, string][];
|
|
208
|
-
batch_id: bigint;
|
|
209
|
-
chunk_ids: bigint[];
|
|
210
|
-
};
|
|
211
|
-
current?: {
|
|
212
|
-
created_at: bigint;
|
|
213
|
-
updated_at: bigint;
|
|
214
|
-
key: {
|
|
215
|
-
owner: Uint8Array<ArrayBufferLike>;
|
|
216
|
-
collection: string;
|
|
217
|
-
name: string;
|
|
218
|
-
full_path: string;
|
|
219
|
-
description?: string | undefined;
|
|
220
|
-
token?: string | undefined;
|
|
221
|
-
};
|
|
222
|
-
headers: [string, string][];
|
|
223
|
-
encodings: ["identity" | "gzip" | "compress" | "deflate" | "br", {
|
|
224
|
-
modified: bigint;
|
|
225
|
-
content_chunks: Uint8Array<ArrayBufferLike>[];
|
|
226
|
-
total_length: bigint;
|
|
227
|
-
sha256: Uint8Array<ArrayBuffer>;
|
|
228
|
-
}][];
|
|
229
|
-
version?: bigint | undefined;
|
|
230
|
-
} | undefined;
|
|
231
|
-
}>;
|
|
54
|
+
headers: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
|
|
55
|
+
chunk_ids: z.ZodArray<z.ZodBigInt>;
|
|
56
|
+
}, z.core.$strict>;
|
|
57
|
+
}, z.core.$strict>;
|
|
232
58
|
/**
|
|
233
59
|
* Represents a validation context before uploading an asset.
|
|
234
60
|
*/
|
package/ic-cdk/schemas/call.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { IDL } from '@dfinity/candid';
|
|
2
2
|
import type { Principal } from '@dfinity/principal';
|
|
3
|
-
import * as z from 'zod';
|
|
3
|
+
import * as z from 'zod/v4';
|
|
4
4
|
import { type RawPrincipal } from '../../schemas/candid';
|
|
5
5
|
/**
|
|
6
6
|
* @see IDLType
|
|
7
7
|
*/
|
|
8
|
-
export declare const IDLTypeSchema: z.
|
|
8
|
+
export declare const IDLTypeSchema: z.ZodCustom<IDL.Type<unknown>, IDL.Type<unknown>>;
|
|
9
9
|
/**
|
|
10
10
|
* Custom validation function to verify if a value is an instance of `IDL.Type` from `@dfinity/candid`.
|
|
11
11
|
*/
|
|
@@ -13,7 +13,7 @@ export type IDLType = z.infer<typeof IDLTypeSchema>;
|
|
|
13
13
|
/**
|
|
14
14
|
* @see CallArg
|
|
15
15
|
*/
|
|
16
|
-
export declare const CallArgSchema: z.ZodTuple<[z.
|
|
16
|
+
export declare const CallArgSchema: z.ZodTuple<[z.ZodCustom<IDL.Type<unknown>, IDL.Type<unknown>>, z.ZodUnknown], null>;
|
|
17
17
|
/**
|
|
18
18
|
* A call argument consisting of its IDL type and corresponding value.
|
|
19
19
|
*/
|
|
@@ -23,7 +23,7 @@ export type CallArg = z.infer<typeof CallArgSchema>;
|
|
|
23
23
|
*
|
|
24
24
|
* @see CallArgs
|
|
25
25
|
*/
|
|
26
|
-
export declare const CallArgsSchema: z.ZodArray<z.ZodTuple<[z.
|
|
26
|
+
export declare const CallArgsSchema: z.ZodArray<z.ZodTuple<[z.ZodCustom<IDL.Type<unknown>, IDL.Type<unknown>>, z.ZodUnknown], null>>;
|
|
27
27
|
/**
|
|
28
28
|
* Represents the arguments for a canister call on the IC.
|
|
29
29
|
*
|
|
@@ -37,7 +37,7 @@ export type CallArgs = z.infer<typeof CallArgsSchema>;
|
|
|
37
37
|
/**
|
|
38
38
|
* @see CallResult
|
|
39
39
|
*/
|
|
40
|
-
export declare const CallResultSchema: z.
|
|
40
|
+
export declare const CallResultSchema: z.ZodCustom<IDL.Type<unknown>, IDL.Type<unknown>>;
|
|
41
41
|
/**
|
|
42
42
|
* Defines the type used to decode the result of a canister call.
|
|
43
43
|
*/
|
|
@@ -46,21 +46,11 @@ export type CallResult = z.infer<typeof CallResultSchema>;
|
|
|
46
46
|
* @see CallParams
|
|
47
47
|
*/
|
|
48
48
|
export declare const CallParamsSchema: z.ZodObject<{
|
|
49
|
-
canisterId: z.ZodUnion<[z.
|
|
49
|
+
canisterId: z.ZodUnion<[z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, z.ZodCustom<Principal, Principal>]>;
|
|
50
50
|
method: z.ZodString;
|
|
51
|
-
args: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.
|
|
52
|
-
result: z.ZodOptional<z.
|
|
53
|
-
},
|
|
54
|
-
canisterId: Uint8Array<ArrayBufferLike> | Principal;
|
|
55
|
-
method: string;
|
|
56
|
-
args?: [IDL.Type<unknown>, unknown][] | undefined;
|
|
57
|
-
result?: IDL.Type<unknown> | undefined;
|
|
58
|
-
}, {
|
|
59
|
-
canisterId: Uint8Array<ArrayBufferLike> | Principal;
|
|
60
|
-
method: string;
|
|
61
|
-
args?: [IDL.Type<unknown>, unknown][] | undefined;
|
|
62
|
-
result?: IDL.Type<unknown> | undefined;
|
|
63
|
-
}>;
|
|
51
|
+
args: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodCustom<IDL.Type<unknown>, IDL.Type<unknown>>, z.ZodUnknown], null>>>;
|
|
52
|
+
result: z.ZodOptional<z.ZodCustom<IDL.Type<unknown>, IDL.Type<unknown>>>;
|
|
53
|
+
}, z.core.$strip>;
|
|
64
54
|
/**
|
|
65
55
|
* Type representing the parameters required to make a canister call.
|
|
66
56
|
*/
|
package/ic-cdk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as n,c as i}from"./chunk-
|
|
1
|
+
import{b as n,c as i}from"./chunk-KY6LCVKU.js";import{IDL as l}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/v4";var p=r.custom(e=>e instanceof A.Type,{message:"Invalid IDL.Type"}),_=r.tuple([p,r.unknown()]),w=r.array(_),S=p,s=r.object({canisterId:n.or(i),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=>{s.parse(e);let{canisterId:o,method:c,args:m,result:f}=e,y=o instanceof z?o.toUint8Array():o,[d,u]=(m??[]).reduce(([C,I],[P,T])=>[[...C,P],[...I,T]],[[],[]]),h=new Uint8Array(l.encode([...d],[...u])),x=await __ic_cdk_call_raw(y,c,h),a=l.decode(D(f),x.buffer);if(a.length>1)throw new t;let[g]=a;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,s 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 =\n providedCanisterId instanceof Principal\n ? providedCanisterId.toUint8Array()\n : providedCanisterId;\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.buffer);\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,
|
|
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 =\n providedCanisterId instanceof Principal\n ? providedCanisterId.toUint8Array()\n : providedCanisterId;\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.buffer);\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/v4';\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,SAMZ,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,EACJJ,aAA8BK,EAC1BL,EAAmB,aAAa,EAChCA,EAEA,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,EAAM,MAAM,EAG9D,GAAIC,EAAO,OAAS,EAClB,MAAM,IAAIE,EAGZ,GAAM,CAACC,CAAQ,EAAIH,EACnB,OAAOG,CACT,EGlDA,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
|
|
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-R6MTJSTE.js";import{a as xe,b as me,c as le}from"./chunk-KY6LCVKU.js";import*as a from"zod/v4";import*as v from"zod/v4";var c=e=>v.custom(i=>e.implement(i));import*as m from"zod/v4";var A=m.object({collections:m.array(m.string()).readonly()}).strict();import*as o from"zod/v4";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/v4";import*as y from"zod/v4";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/v4";var S=D.record(D.string(),D.string());import*as k from"zod/v4";import*as K from"zod/v4";var P=K.object({current:r.optional(),batch:M,commit_batch:j}).strict();var J=t(r),N=t(r.optional()),$=t(k.array(r.optional())),q=t(k.array(r.optional())),G=t(P),L=t(r);var O=e=>A.extend({assert:_(e)}).strict(),Q=O(w),V=O(I),W=O(G),X=O(L),nt=a.union([Q,V,W,X]),Y=e=>a.function({input:a.tuple([S]),output:e}),st=e=>a.union([e,c(Y(e))]);function rt(e){return e}import*as x from"zod/v4";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($),re=s(q),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{L as AssertDeleteAssetContextSchema,X as AssertDeleteAssetSchema,I as AssertDeleteDocContextSchema,V as AssertDeleteDocSchema,st as AssertFnOrObjectSchema,Y as AssertFnSchema,_ as AssertFunctionSchema,nt as AssertSchema,w as AssertSetDocContextSchema,Q as AssertSetDocSchema,G as AssertUploadAssetContextSchema,W 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,q as OnDeleteFilteredAssetsContextSchema,re as OnDeleteFilteredAssetsSchema,u as OnDeleteFilteredDocsContextSchema,yt as OnDeleteFilteredDocsSchema,$ 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
|
-
"sources": ["src/hooks/assertions.ts", "src/hooks/schemas/collections.ts", "src/hooks/schemas/context.ts", "src/hooks/schemas/db/context.ts", "src/hooks/schemas/db/payload.ts", "src/hooks/schemas/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';\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().args(SatelliteEnvSchema).returns(assertSchema);\nexport type AssertFn<T extends Assert> = (assert: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const AssertFnOrObjectSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.union([assertSchema, AssertFnSchema(assertSchema)]);\nexport type AssertFnOrObject<T extends Assert> = T | AssertFn<T>;\n\nexport function defineAssert<T extends Assert>(assert: T): T;\nexport function defineAssert<T extends Assert>(assert: AssertFn<T>): AssertFn<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T> {\n return assert;\n}\n", "import * as z from 'zod';\nimport 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 type {baseObjectInputType, baseObjectOutputType, ZodObject, ZodTypeAny} from 'zod';\nimport * as z from 'zod';\nimport {type RawUserId, RawUserIdSchema} from '../../schemas/satellite';\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 // TODO: workaround for https://github.com/colinhacks/zod/issues/3998\n return z.object(schemaShape).strict() as ZodObject<\n typeof schemaShape,\n 'strict',\n ZodTypeAny,\n baseObjectOutputType<typeof schemaShape>,\n baseObjectInputType<typeof schemaShape>\n >;\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 z.function().args(contextSchema).returns(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 z.function().args(contextSchema).returns(z.promise(z.void()).or(z.void()));\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 type {baseObjectInputType, baseObjectOutputType, ZodObject, ZodTypeAny} from 'zod';\nimport * 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 // TODO: workaround for https://github.com/colinhacks/zod/issues/3998\n return z.object(schemaShape).strict() as ZodObject<\n typeof schemaShape,\n 'strict',\n ZodTypeAny,\n baseObjectOutputType<typeof schemaShape>,\n baseObjectInputType<typeof schemaShape>\n >;\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.unknown());\n\n/**\n * Placeholder for future environment-specific configurations.\n *\n * Currently unused, but it may support features such as:\n * - Defining the execution mode (e.g., staging or production).\n * - Providing environment-specific values like `ckBtcLedgerId` for test or production.\n */\nexport type SatelliteEnv = z.infer<typeof SatelliteEnvSchema>;\n", "import * as z from 'zod';\nimport {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 {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().args(SatelliteEnvSchema).returns(hookSchema);\nexport type HookFn<T extends Hook> = (hook: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const HookFnOrObjectSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.union([hookSchema, HookFnSchema(hookSchema)]);\nexport type HookFnOrObject<T extends Hook> = T | HookFn<T>;\n\nexport function defineHook<T extends Hook>(hook: T): T;\nexport function defineHook<T extends Hook>(hook: HookFn<T>): HookFn<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T> {\n return hook;\n}\n", "import {jsonReplacer} 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,
|
|
6
|
-
"names": ["z", "z", "CollectionsSchema", "z", "HookContextSchema", "dataSchema", "RawUserIdSchema", "AssertFunctionSchema", "contextSchema", "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", "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", "defineHook", "hook", "jsonReplacer", "__juno_satellite_console_log", "v", "msg", "arg", "random"]
|
|
3
|
+
"sources": ["src/hooks/assertions.ts", "src/utils/zod.utils.ts", "src/hooks/schemas/collections.ts", "src/hooks/schemas/context.ts", "src/hooks/schemas/db/context.ts", "src/hooks/schemas/db/payload.ts", "src/hooks/schemas/satellite.env.ts", "src/hooks/schemas/storage/context.ts", "src/hooks/schemas/storage/payload.ts", "src/hooks/hooks.ts", "src/polyfills/console.polyfill.ts", "src/polyfills/random.polyfill.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod/v4';\nimport {createFunctionSchema} from '../utils/zod.utils';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type AssertFunction, AssertFunctionSchema} from './schemas/context';\nimport {\n type AssertDeleteDocContext,\n AssertDeleteDocContextSchema,\n type AssertSetDocContext,\n AssertSetDocContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n type AssertDeleteAssetContext,\n AssertDeleteAssetContextSchema,\n type AssertUploadAssetContext,\n AssertUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnAssert\n */\nconst OnAssertSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the assertion is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {void} Resolves when the assertion completes.\n */\n assert: AssertFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining assertions related to collections.\n *\n * @template T - The type of context passed to the assertions when triggered.\n */\nexport type OnAssert<T> = Collections & {\n assert: AssertFunction<T>;\n};\n\n/**\n * @see AssertSetDoc\n */\nexport const AssertSetDocSchema = OnAssertSchema(AssertSetDocContextSchema);\n\n/**\n * An assertion that runs when a document is created or updated.\n */\nexport type AssertSetDoc = OnAssert<AssertSetDocContext>;\n\n/**\n * @see AssertDeleteDoc\n */\nexport const AssertDeleteDocSchema = OnAssertSchema(AssertDeleteDocContextSchema);\n\n/**\n * An assertion that runs when a document is deleted.\n */\nexport type AssertDeleteDoc = OnAssert<AssertDeleteDocContext>;\n\n/**\n * @see AssertUploadAsset\n */\nexport const AssertUploadAssetSchema = OnAssertSchema(AssertUploadAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is uploaded.\n */\nexport type AssertUploadAsset = OnAssert<AssertUploadAssetContext>;\n\n/**\n * @see AssertDeleteAsset\n */\nexport const AssertDeleteAssetSchema = OnAssertSchema(AssertDeleteAssetContextSchema);\n\n/**\n * An assertion that runs before an asset is deleted.\n */\nexport type AssertDeleteAsset = OnAssert<AssertDeleteAssetContext>;\n\n/**\n * @see Assert\n */\nexport const AssertSchema = z.union([\n AssertSetDocSchema,\n AssertDeleteDocSchema,\n AssertUploadAssetSchema,\n AssertDeleteAssetSchema\n]);\n\n/**\n * All assertions definitions.\n */\nexport type Assert = AssertSetDoc | AssertDeleteDoc | AssertUploadAsset | AssertDeleteAsset;\n\nexport const AssertFnSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.function({\n input: z.tuple([SatelliteEnvSchema]),\n output: assertSchema\n });\nexport type AssertFn<T extends Assert> = (assert: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const AssertFnOrObjectSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.union([assertSchema, createFunctionSchema(AssertFnSchema(assertSchema))]);\nexport type AssertFnOrObject<T extends Assert> = T | AssertFn<T>;\n\nexport function defineAssert<T extends Assert>(assert: T): T;\nexport function defineAssert<T extends Assert>(assert: AssertFn<T>): AssertFn<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T> {\n return assert;\n}\n", "import * as z from 'zod/v4';\n\n// TODO: Workaround source: https://github.com/colinhacks/zod/issues/4143#issuecomment-2845134912\nexport const createFunctionSchema = <T extends z.core.$ZodFunction>(schema: T) =>\n z.custom<Parameters<T['implement']>[0]>((fn) =>\n schema.implement(fn as Parameters<T['implement']>[0])\n );\n", "import * as z from 'zod/v4';\nimport type {Collection} from '../../schemas/satellite';\n\n/**\n * @see Collections\n */\nexport const CollectionsSchema = z\n .object({\n collections: z.array(z.string()).readonly()\n })\n .strict();\n\n/**\n * Defines the collections where a hook or assertion should run.\n */\nexport interface Collections {\n /**\n * An array of collection names where the hook or assertion will run.\n * If empty, no hooks or assertions are triggered.\n */\n collections: readonly Collection[];\n}\n", "import * as z from 'zod/v4';\nimport {type RawUserId, RawUserIdSchema} from '../../schemas/satellite';\nimport {createFunctionSchema} from '../../utils/zod.utils';\n\n/**\n * @see HookContext\n */\nexport const HookContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n caller: RawUserIdSchema,\n data: dataSchema\n };\n\n return z.strictObject(schemaShape);\n};\n\n/**\n * Represents the context provided to hooks, containing information about the caller and related data.\n *\n * @template T - The type of data associated with the hook.\n */\nexport interface HookContext<T> {\n /**\n * The user who originally triggered the function that in turn triggered the hook.\n */\n caller: RawUserId;\n\n /**\n * The data associated with the hook execution.\n */\n data: T;\n}\n\n/**\n * @see AssertFunction\n */\nexport const AssertFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n createFunctionSchema(z.function({input: z.tuple([contextSchema]), output: z.void()}));\n\n/**\n * Defines the `assert` function schema for assertions.\n *\n * The function takes a context argument and returns `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type AssertFunction<T> = (context: T) => void;\n\n/**\n * @see RunFunction\n */\nexport const RunFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n createFunctionSchema(\n z.function({input: z.tuple([contextSchema]), output: z.promise(z.void()).or(z.void())})\n );\n\n/**\n * Defines the `run` function schema for hooks.\n *\n * The function takes a context argument and returns either a `Promise<void>` or `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type RunFunction<T> = (context: T) => void | Promise<void>;\n", "import * as z from 'zod/v4';\nimport {DocSchema, type OptionDoc} from '../../../schemas/db';\nimport {type Collection, CollectionSchema, type Key, KeySchema} from '../../../schemas/satellite';\nimport {type HookContext, HookContextSchema} from '../context';\nimport {\n type DocAssertDelete,\n DocAssertDeleteSchema,\n type DocAssertSet,\n DocAssertSetSchema,\n type DocUpsert,\n DocUpsertSchema\n} from './payload';\n\n/**\n * @see DocContext\n */\nexport const DocContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {\n const schemaShape = {\n collection: CollectionSchema,\n key: KeySchema,\n data: dataSchema\n };\n\n return z.strictObject(schemaShape);\n};\n\n/**\n * Represents the context of a document operation within a collection.\n *\n * @template T - The type of data associated with the document.\n */\nexport interface DocContext<T> {\n /**\n * The name of the collection where the document is stored.\n */\n collection: Collection;\n\n /**\n * The key identifying the document within the collection.\n */\n key: Key;\n\n /**\n * The data associated with the document operation.\n */\n data: T;\n}\n\n/**\n * @see OnSetDocContext\n */\nexport const OnSetDocContextSchema = HookContextSchema(DocContextSchema(DocUpsertSchema));\n\n/**\n * The context provided to the `onSetDoc` hook.\n *\n * This context contains information about the document being created or updated,\n * along with details about the user who triggered the operation.\n */\nexport type OnSetDocContext = HookContext<DocContext<DocUpsert>>;\n\n/**\n * @see OnSetManyDocsContext\n */\nexport const OnSetManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocUpsertSchema))\n);\n\n/**\n * The context provided to the `onSetManyDocs` hook.\n *\n * This context contains information about multiple documents being created or updated\n * in a single operation, along with details about the user who triggered it.\n */\nexport type OnSetManyDocsContext = HookContext<DocContext<DocUpsert>[]>;\n\n/**\n * @see OnDeleteDocContext\n */\nexport const OnDeleteDocContextSchema = HookContextSchema(DocContextSchema(DocSchema.optional()));\n\n/**\n * The context provided to the `onDeleteDoc` hook.\n *\n * This context contains information about a single document being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteDocContext = HookContext<DocContext<OptionDoc>>;\n\n/**\n * @see OnDeleteManyDocsContext\n */\nexport const OnDeleteManyDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteManyDocs` hook.\n *\n * This context contains information about multiple documents being deleted,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see OnDeleteFilteredDocsContext\n */\nexport const OnDeleteFilteredDocsContextSchema = HookContextSchema(\n z.array(DocContextSchema(DocSchema.optional()))\n);\n\n/**\n * The context provided to the `onDeleteFilteredDocs` hook.\n *\n * This context contains information about documents deleted as a result of a filter,\n * along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredDocsContext = HookContext<DocContext<OptionDoc>[]>;\n\n/**\n * @see AssertSetDocContext\n */\nexport const AssertSetDocContextSchema = HookContextSchema(DocContextSchema(DocAssertSetSchema));\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is created or updated. If validation fails, the developer should throw an error.\n */\nexport type AssertSetDocContext = HookContext<DocContext<DocAssertSet>>;\n\n/**\n * @see AssertDeleteDocContext\n */\nexport const AssertDeleteDocContextSchema = HookContextSchema(\n DocContextSchema(DocAssertDeleteSchema)\n);\n\n/**\n * The context provided to the `assertDeleteDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteDocContext = HookContext<DocContext<DocAssertDelete>>;\n", "import * as z from 'zod/v4';\nimport {\n type DelDoc,\n DelDocSchema,\n type Doc,\n DocSchema,\n type SetDoc,\n SetDocSchema\n} from '../../../schemas/db';\n\n/**\n * @see DocUpsert\n */\nexport const DocUpsertSchema = z\n .object({\n before: DocSchema.optional(),\n after: DocSchema\n })\n .strict();\n\n/**\n * Represents a document update operation.\n *\n * This is used in hooks where a document is either being created or updated.\n */\nexport interface DocUpsert {\n /**\n * The previous version of the document before the update.\n * Undefined if this is a new document.\n */\n before?: Doc;\n\n /**\n * The new version of the document after the update.\n */\n after: Doc;\n}\n/**\n * @see DocAssertSet\n */\nexport const DocAssertSetSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: SetDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before setting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertSet {\n /**\n * The current version of the document before the operation.\n * Undefined if this is a new document.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: SetDoc;\n}\n\n/**\n * @see DocAssertDelete\n */\nexport const DocAssertDeleteSchema = z\n .object({\n current: DocSchema.optional(),\n proposed: DelDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before deleting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport interface DocAssertDelete {\n /**\n * The current version of the document before the operation.\n * Undefined if the document does not exist.\n */\n current?: Doc;\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: DelDoc;\n}\n", "import * as z from 'zod/v4';\n\n/**\n * @see SatelliteEnv\n */\nexport const SatelliteEnvSchema = z.record(z.string(), z.string());\n\n/**\n * Placeholder for future environment-specific configurations.\n *\n * Currently unused, but it may support features such as:\n * - Defining the execution mode (e.g., staging or production).\n * - Providing environment-specific values like `ckBtcLedgerId` for test or production.\n */\nexport type SatelliteEnv = z.infer<typeof SatelliteEnvSchema>;\n", "import * as z from 'zod/v4';\nimport {AssetSchema, type Asset} from '../../../schemas/storage';\nimport {HookContextSchema, type HookContext} from '../context';\nimport {AssetAssertUploadSchema, type AssetAssertUpload} from './payload';\n\n/**\n * @see OnUploadAssetContext\n */\nexport const OnUploadAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `onUploadAsset` hook.\n *\n * This context contains information about the asset that was uploaded.\n */\nexport type OnUploadAssetContext = HookContext<Asset>;\n\n/**\n * @see OnDeleteAssetContext\n */\nexport const OnDeleteAssetContextSchema = HookContextSchema(AssetSchema.optional());\n\n/**\n * Context for the `onDeleteAsset` hook.\n *\n * This context contains information about a single asset being deleted, along with details about the user who triggered the operation.\n *\n * If undefined, the asset did not exist.\n */\nexport type OnDeleteAssetContext = HookContext<Asset | undefined>;\n\n/**\n * @see OnDeleteManyAssetsContext\n */\nexport const OnDeleteManyAssetsContextSchema = HookContextSchema(z.array(AssetSchema.optional()));\n\n/**\n * Context for the `onDeleteManyAssets` hook.\n *\n * This context contains information about multiple assets being potentially deleted, along with details about the user who triggered the operation.\n */\nexport type OnDeleteManyAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see OnDeleteFilteredAssetsContext\n */\nexport const OnDeleteFilteredAssetsContextSchema = HookContextSchema(\n z.array(AssetSchema.optional())\n);\n\n/**\n * Context for the `onDeleteFilteredAssets` hook.\n *\n * This context contains information about documents deleted as a result of a filter, along with details about the user who triggered the operation.\n */\nexport type OnDeleteFilteredAssetsContext = HookContext<Array<Asset | undefined>>;\n\n/**\n * @see AssertUploadAssetContext\n */\nexport const AssertUploadAssetContextSchema = HookContextSchema(AssetAssertUploadSchema);\n\n/**\n * Context for the `assertUploadAsset` hook.\n *\n * This context contains information about the asset being validated before it is uploaded. If validation fails, the developer should throw an error.\n */\nexport type AssertUploadAssetContext = HookContext<AssetAssertUpload>;\n\n/**\n * @see AssertDeleteAssetContext\n */\nexport const AssertDeleteAssetContextSchema = HookContextSchema(AssetSchema);\n\n/**\n * Context for the `assertDeleteAsset` hook.\n *\n * This context contains information about the asset being validated before it is deleted. If validation fails, the developer should throw an error.\n */\nexport type AssertDeleteAssetContext = HookContext<Asset>;\n", "import * as z from 'zod/v4';\nimport {\n type Asset,\n AssetSchema,\n type Batch,\n BatchSchema,\n type CommitBatch,\n CommitBatchSchema\n} from '../../../schemas/storage';\n\n/**\n * @see AssetAssertUpload\n */\nexport const AssetAssertUploadSchema = z\n .object({\n current: AssetSchema.optional(),\n batch: BatchSchema,\n commit_batch: CommitBatchSchema\n })\n .strict();\n\n/**\n * Represents a validation context before uploading an asset.\n */\nexport interface AssetAssertUpload {\n /**\n * The current asset already stored (if any).\n */\n current?: Asset;\n\n /**\n * The batch metadata being uploaded.\n */\n batch: Batch;\n\n /**\n * The commit data describing headers and chunk ids.\n */\n commit_batch: CommitBatch;\n}\n", "import * as z from 'zod/v4';\nimport {createFunctionSchema} from '../utils/zod.utils';\nimport {type Collections, CollectionsSchema} from './schemas/collections';\nimport {type RunFunction, RunFunctionSchema} from './schemas/context';\nimport {\n type OnDeleteDocContext,\n OnDeleteDocContextSchema,\n type OnDeleteFilteredDocsContext,\n OnDeleteFilteredDocsContextSchema,\n type OnDeleteManyDocsContext,\n OnDeleteManyDocsContextSchema,\n type OnSetDocContext,\n OnSetDocContextSchema,\n type OnSetManyDocsContext,\n OnSetManyDocsContextSchema\n} from './schemas/db/context';\nimport {SatelliteEnvSchema} from './schemas/satellite.env';\nimport {\n type OnDeleteAssetContext,\n OnDeleteAssetContextSchema,\n type OnDeleteFilteredAssetsContext,\n OnDeleteFilteredAssetsContextSchema,\n type OnDeleteManyAssetsContext,\n OnDeleteManyAssetsContextSchema,\n type OnUploadAssetContext,\n OnUploadAssetContextSchema\n} from './schemas/storage/context';\n\n/**\n * @see OnHook\n */\nconst OnHookSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n run: RunFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * A generic schema for defining hooks related to collections.\n *\n * @template T - The type of context passed to the hook when triggered.\n */\nexport type OnHook<T> = Collections & {\n /**\n * A function that runs when the hook is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {Promise<void>} Resolves when the operation completes.\n */\n run: RunFunction<T>;\n};\n\n/**\n * @see OnSetDoc\n */\nexport const OnSetDocSchema = OnHookSchema(OnSetDocContextSchema);\n\n/**\n * A hook that runs when a document is created or updated.\n */\nexport type OnSetDoc = OnHook<OnSetDocContext>;\n\n/**\n * @see OnSetManyDocs\n */\nexport const OnSetManyDocsSchema = OnHookSchema(OnSetManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are created or updated.\n */\nexport type OnSetManyDocs = OnHook<OnSetManyDocsContext>;\n\n/**\n * @see OnDeleteDoc\n */\nexport const OnDeleteDocSchema = OnHookSchema(OnDeleteDocContextSchema);\n\n/**\n * A hook that runs when a single document is deleted.\n */\nexport type OnDeleteDoc = OnHook<OnDeleteDocContext>;\n\n/**\n * @see OnDeleteManyDocs\n */\nexport const OnDeleteManyDocsSchema = OnHookSchema(OnDeleteManyDocsContextSchema);\n\n/**\n * A hook that runs when multiple documents are deleted.\n */\nexport type OnDeleteManyDocs = OnHook<OnDeleteManyDocsContext>;\n\n/**\n * @see OnDeleteFilteredDocs\n */\nexport const OnDeleteFilteredDocsSchema = OnHookSchema(OnDeleteFilteredDocsContextSchema);\n\n/**\n * A hook that runs when a filtered set of documents is deleted based on query conditions.\n */\nexport type OnDeleteFilteredDocs = OnHook<OnDeleteFilteredDocsContext>;\n\n/**\n * @see OnUploadAsset\n */\nexport const OnUploadAssetSchema = OnHookSchema(OnUploadAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is uploaded.\n */\nexport type OnUploadAsset = OnHook<OnUploadAssetContext>;\n\n/**\n * @see OnDeleteAsset\n */\nexport const OnDeleteAssetSchema = OnHookSchema(OnDeleteAssetContextSchema);\n\n/**\n * A hook that runs when a single asset is potentially deleted.\n */\nexport type OnDeleteAsset = OnHook<OnDeleteAssetContext>;\n\n/**\n * @see OnDeleteManyAssets\n */\nexport const OnDeleteManyAssetsSchema = OnHookSchema(OnDeleteManyAssetsContextSchema);\n\n/**\n * A hook that runs when multiple assets are potentially deleted.\n */\nexport type OnDeleteManyAssets = OnHook<OnDeleteManyAssetsContext>;\n\n/**\n * @see OnDeleteFilteredAssets\n */\nexport const OnDeleteFilteredAssetsSchema = OnHookSchema(OnDeleteFilteredAssetsContextSchema);\n\n/**\n * A hook that runs when a filtered set of assets is deleted based on query conditions.\n */\nexport type OnDeleteFilteredAssets = OnHook<OnDeleteFilteredAssetsContext>;\n\n/**\n * @see Hook\n */\nexport const HookSchema = z.union([\n OnSetDocSchema,\n OnSetManyDocsSchema,\n OnDeleteDocContextSchema,\n OnDeleteManyDocsContextSchema,\n OnDeleteFilteredDocsContextSchema,\n OnUploadAssetSchema,\n OnDeleteAssetSchema,\n OnDeleteManyAssetsSchema,\n OnDeleteFilteredAssetsSchema\n]);\n\n/**\n * All hooks definitions.\n */\nexport type Hook =\n | OnSetDoc\n | OnSetManyDocs\n | OnDeleteDoc\n | OnDeleteManyDocs\n | OnDeleteFilteredDocs\n | OnUploadAsset\n | OnDeleteAsset\n | OnDeleteManyAssets\n | OnDeleteFilteredAssets;\n\nexport const HookFnSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.function({input: z.tuple([SatelliteEnvSchema]), output: hookSchema});\nexport type HookFn<T extends Hook> = (hook: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const HookFnOrObjectSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.union([hookSchema, createFunctionSchema(HookFnSchema(hookSchema))]);\nexport type HookFnOrObject<T extends Hook> = T | HookFn<T>;\n\nexport function defineHook<T extends Hook>(hook: T): T;\nexport function defineHook<T extends Hook>(hook: HookFn<T>): HookFn<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T> {\n return hook;\n}\n", "import {jsonReplacer} from '@dfinity/utils';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst __juno_satellite_console_log = (v: any[]) => {\n const msg = v\n .map((arg) => (typeof arg === 'object' ? JSON.stringify(arg, jsonReplacer) : arg))\n .join(' ');\n\n globalThis.__ic_cdk_print(msg);\n};\n\n// @ts-expect-error We want to override the console\nglobalThis.console = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n info(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n log(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n warn(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error(...v: any[]) {\n __juno_satellite_console_log(v);\n }\n};\n", "/**\n * @see Math.random\n */\nconst random = (): number => {\n // __juno_satellite_random() returns a signed 32-bit int (i32)\n const value = __juno_satellite_random();\n\n // >>> 0 converts it to unsigned\n return (value >>> 0) / 2 ** 32;\n};\n\n/**\n * Overwrites Math.random with a pseudo-random number using the Satellite's internal RNG.\n *\n * \u26A0\uFE0F This function is not suitable for use cases requiring cryptographically secure or perfectly unpredictable randomness,\n * such as lotteries or gambling dApps.\n *\n * @returns {number} A pseudo-random 32-bit integer.\n *\n * @throws {Error} If the RNG has not been initialized.\n */\nglobalThis.Math.random = random;\n"],
|
|
5
|
+
"mappings": "yTAAA,UAAYA,MAAO,SCAnB,UAAYC,MAAO,SAGZ,IAAMC,EAAuDC,GAChE,SAAuCC,GACvCD,EAAO,UAAUC,CAAmC,CACtD,ECNF,UAAYC,MAAO,SAMZ,IAAMC,EACV,SAAO,CACN,YAAe,QAAQ,SAAO,CAAC,EAAE,SAAS,CAC5C,CAAC,EACA,OAAO,ECVV,UAAYC,MAAO,SAOZ,IAAMC,EAA6CC,GAM/C,eALW,CAClB,OAAQC,EACR,KAAMD,CACR,CAEiC,EAuBtBE,EAAgDC,GAC3DC,EAAuB,WAAS,CAAC,MAAS,QAAM,CAACD,CAAa,CAAC,EAAG,OAAU,OAAK,CAAC,CAAC,CAAC,EAczEE,EAA6CF,GACxDC,EACI,WAAS,CAAC,MAAS,QAAM,CAACD,CAAa,CAAC,EAAG,OAAU,UAAU,OAAK,CAAC,EAAE,GAAK,OAAK,CAAC,CAAC,CAAC,CACxF,ECtDF,UAAYG,MAAO,SCAnB,UAAYC,MAAO,SAaZ,IAAMC,EACV,SAAO,CACN,OAAQC,EAAU,SAAS,EAC3B,MAAOA,CACT,CAAC,EACA,OAAO,EAsBGC,EACV,SAAO,CACN,QAASD,EAAU,SAAS,EAC5B,SAAUE,CACZ,CAAC,EACA,OAAO,EAyBGC,EACV,SAAO,CACN,QAASH,EAAU,SAAS,EAC5B,SAAUI,CACZ,CAAC,EACA,OAAO,ED3DH,IAAMC,EAA4CC,GAO9C,eANW,CAClB,WAAYC,EACZ,IAAKC,EACL,KAAMF,CACR,CAEiC,EA4BtBG,EAAwBC,EAAkBL,EAAiBM,CAAe,CAAC,EAa3EC,EAA6BF,EACtC,QAAML,EAAiBM,CAAe,CAAC,CAC3C,EAaaE,EAA2BH,EAAkBL,EAAiBS,EAAU,SAAS,CAAC,CAAC,EAanFC,EAAgCL,EACzC,QAAML,EAAiBS,EAAU,SAAS,CAAC,CAAC,CAChD,EAaaE,EAAoCN,EAC7C,QAAML,EAAiBS,EAAU,SAAS,CAAC,CAAC,CAChD,EAaaG,EAA4BP,EAAkBL,EAAiBa,CAAkB,CAAC,EAalFC,EAA+BT,EAC1CL,EAAiBe,CAAqB,CACxC,EEzIA,UAAYC,MAAO,SAKZ,IAAMC,EAAuB,SAAS,SAAO,EAAK,SAAO,CAAC,ECLjE,UAAYC,MAAO,SCAnB,UAAYC,MAAO,SAaZ,IAAMC,EACV,SAAO,CACN,QAASC,EAAY,SAAS,EAC9B,MAAOC,EACP,aAAcC,CAChB,CAAC,EACA,OAAO,EDXH,IAAMC,EAA6BC,EAAkBC,CAAW,EAY1DC,EAA6BF,EAAkBC,EAAY,SAAS,CAAC,EAcrEE,EAAkCH,EAAoB,QAAMC,EAAY,SAAS,CAAC,CAAC,EAYnFG,EAAsCJ,EAC/C,QAAMC,EAAY,SAAS,CAAC,CAChC,EAYaI,EAAiCL,EAAkBM,CAAuB,EAY1EC,EAAiCP,EAAkBC,CAAW,EPnD3E,IAAMO,EAA0CC,GAC9CC,EAAkB,OAAO,CAOvB,OAAQC,EAAwBF,CAAa,CAC/C,CAAC,EAAE,OAAO,EAcCG,EAAqBJ,EAAeK,CAAyB,EAU7DC,EAAwBN,EAAeO,CAA4B,EAUnEC,EAA0BR,EAAeS,CAA8B,EAUvEC,EAA0BV,EAAeW,CAA8B,EAUvEC,GAAiB,QAAM,CAClCR,EACAE,EACAE,EACAE,CACF,CAAC,EAOYG,EAA0CC,GACnD,WAAS,CACT,MAAS,QAAM,CAACC,CAAkB,CAAC,EACnC,OAAQD,CACV,CAAC,EAGUE,GAAkDF,GAC3D,QAAM,CAACA,EAAcG,EAAqBJ,EAAeC,CAAY,CAAC,CAAC,CAAC,EAMrE,SAASI,GAA+BC,EAAkD,CAC/F,OAAOA,CACT,CShHA,UAAYC,MAAO,SA+BnB,IAAMC,EAAwCC,GAC5CC,EAAkB,OAAO,CACvB,IAAKC,EAAqBF,CAAa,CACzC,CAAC,EAAE,OAAO,EAoBCG,GAAiBJ,EAAaK,CAAqB,EAUnDC,GAAsBN,EAAaO,CAA0B,EAU7DC,GAAoBR,EAAaS,CAAwB,EAUzDC,GAAyBV,EAAaW,CAA6B,EAUnEC,GAA6BZ,EAAaa,CAAiC,EAU3EC,GAAsBd,EAAae,CAA0B,EAU7DC,GAAsBhB,EAAaiB,CAA0B,EAU7DC,GAA2BlB,EAAamB,CAA+B,EAUvEC,GAA+BpB,EAAaqB,CAAmC,EAU/EC,GAAe,QAAM,CAChClB,GACAE,GACAG,EACAE,EACAE,EACAC,GACAE,GACAE,GACAE,EACF,CAAC,EAgBYG,GAAwCC,GACjD,WAAS,CAAC,MAAS,QAAM,CAACC,CAAkB,CAAC,EAAG,OAAQD,CAAU,CAAC,EAG1DE,GAAgDF,GACzD,QAAM,CAACA,EAAYG,EAAqBJ,GAAaC,CAAU,CAAC,CAAC,CAAC,EAM/D,SAASI,GAA2BC,EAA4C,CACrF,OAAOA,CACT,CCvLA,OAAQ,gBAAAC,OAAmB,iBAG3B,IAAMC,EAAgCC,GAAa,CACjD,IAAMC,EAAMD,EACT,IAAKE,GAAS,OAAOA,GAAQ,SAAW,KAAK,UAAUA,EAAKJ,EAAY,EAAII,CAAI,EAChF,KAAK,GAAG,EAEX,WAAW,eAAeD,CAAG,CAC/B,EAGA,WAAW,QAAU,CAEnB,QAAQD,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,OAAOA,EAAU,CACfD,EAA6BC,CAAC,CAChC,EAEA,QAAQA,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,SAASA,EAAU,CACjBD,EAA6BC,CAAC,CAChC,CACF,EC1BA,IAAMG,GAAS,KAEC,wBAAwB,IAGpB,GAAK,WAazB,WAAW,KAAK,OAASA",
|
|
6
|
+
"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
package/schemas/candid.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Principal as CandidPrincipal } from '@dfinity/principal';
|
|
2
|
-
import * as z from 'zod';
|
|
2
|
+
import * as z from 'zod/v4';
|
|
3
3
|
/**
|
|
4
4
|
* A schema that validates a value is an Uint8Array.
|
|
5
5
|
*/
|
|
6
|
-
export declare const Uint8ArraySchema: z.
|
|
6
|
+
export declare const Uint8ArraySchema: z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>;
|
|
7
7
|
/**
|
|
8
8
|
* @see RawPrincipal
|
|
9
9
|
*/
|
|
10
|
-
export declare const RawPrincipalSchema: z.
|
|
10
|
+
export declare const RawPrincipalSchema: z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>;
|
|
11
11
|
/**
|
|
12
12
|
* Represents a raw principal - a Uint8Array representation of a Principal.
|
|
13
13
|
*/
|
|
@@ -15,7 +15,7 @@ export type RawPrincipal = z.infer<typeof RawPrincipalSchema>;
|
|
|
15
15
|
/**
|
|
16
16
|
* @see Principal
|
|
17
17
|
*/
|
|
18
|
-
export declare const PrincipalSchema: z.
|
|
18
|
+
export declare const PrincipalSchema: z.ZodCustom<CandidPrincipal, CandidPrincipal>;
|
|
19
19
|
/**
|
|
20
20
|
* Represents a principal - i.e. an object instantiated with the class Principal.
|
|
21
21
|
*/
|