@junobuild/functions 0.0.7 → 0.0.8-next-2025-03-17

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 CHANGED
@@ -15,6 +15,8 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
15
15
  ### :toolbox: Functions
16
16
 
17
17
  - [HookContextSchema](#gear-hookcontextschema)
18
+ - [AssertFunctionSchema](#gear-assertfunctionschema)
19
+ - [RunFunctionSchema](#gear-runfunctionschema)
18
20
  - [DocContextSchema](#gear-doccontextschema)
19
21
  - [AssertFnSchema](#gear-assertfnschema)
20
22
  - [AssertFnOrObjectSchema](#gear-assertfnorobjectschema)
@@ -31,6 +33,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
31
33
  - [setDocStore](#gear-setdocstore)
32
34
  - [decodeDocData](#gear-decodedocdata)
33
35
  - [encodeDocData](#gear-encodedocdata)
36
+ - [call](#gear-call)
34
37
  - [id](#gear-id)
35
38
 
36
39
  #### :gear: HookContextSchema
@@ -41,6 +44,22 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
41
44
 
42
45
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L7)
43
46
 
47
+ #### :gear: AssertFunctionSchema
48
+
49
+ | Function | Type |
50
+ | ---------------------- | ----------------------------------------------------------------------------------------------- |
51
+ | `AssertFunctionSchema` | `<T extends z.ZodTypeAny>(contextSchema: T) => ZodFunction<ZodTuple<[T], ZodUnknown>, ZodVoid>` |
52
+
53
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L32)
54
+
55
+ #### :gear: RunFunctionSchema
56
+
57
+ | Function | Type |
58
+ | ------------------- | ----------------------------------------------------------------------------------------------------------- |
59
+ | `RunFunctionSchema` | `<T extends z.ZodTypeAny>(contextSchema: T) => ZodFunction<ZodTuple<[T], ZodUnknown>, ZodPromise<ZodVoid>>` |
60
+
61
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L47)
62
+
44
63
  #### :gear: DocContextSchema
45
64
 
46
65
  | Function | Type |
@@ -55,7 +74,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
55
74
  | ---------------- | ----------------------------------------------------------------------------------------------------------------------- |
56
75
  | `AssertFnSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>` |
57
76
 
58
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L43)
77
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L44)
59
78
 
60
79
  #### :gear: AssertFnOrObjectSchema
61
80
 
@@ -63,7 +82,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
63
82
  | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
64
83
  | `AssertFnOrObjectSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodUnion<[T, ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>]>` |
65
84
 
66
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L47)
85
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L48)
67
86
 
68
87
  #### :gear: defineAssert
69
88
 
@@ -71,7 +90,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
71
90
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
72
91
  | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
73
92
 
74
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L51)
93
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L52)
75
94
 
76
95
  #### :gear: defineAssert
77
96
 
@@ -79,7 +98,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
79
98
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
80
99
  | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
81
100
 
82
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L52)
101
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L53)
83
102
 
84
103
  #### :gear: defineAssert
85
104
 
@@ -87,7 +106,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
87
106
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
88
107
  | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
89
108
 
90
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L53)
109
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L54)
91
110
 
92
111
  #### :gear: defineAssert
93
112
 
@@ -95,7 +114,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
95
114
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
96
115
  | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
97
116
 
98
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L54)
117
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L55)
99
118
 
100
119
  #### :gear: HookFnSchema
101
120
 
@@ -103,7 +122,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
103
122
  | -------------- | --------------------------------------------------------------------------------------------------------------------- |
104
123
  | `HookFnSchema` | `<T extends z.ZodTypeAny>(hookSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>` |
105
124
 
106
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L43)
125
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L44)
107
126
 
108
127
  #### :gear: HookFnOrObjectSchema
109
128
 
@@ -111,7 +130,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
111
130
  | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
112
131
  | `HookFnOrObjectSchema` | `<T extends z.ZodTypeAny>(hookSchema: T) => ZodUnion<[T, ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>]>` |
113
132
 
114
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L47)
133
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L48)
115
134
 
116
135
  #### :gear: defineHook
117
136
 
@@ -119,7 +138,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
119
138
  | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
120
139
  | `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |
121
140
 
122
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L51)
141
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L52)
123
142
 
124
143
  #### :gear: defineHook
125
144
 
@@ -127,7 +146,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
127
146
  | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
128
147
  | `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |
129
148
 
130
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L52)
149
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L53)
131
150
 
132
151
  #### :gear: defineHook
133
152
 
@@ -135,7 +154,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
135
154
  | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
136
155
  | `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |
137
156
 
138
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L53)
157
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L54)
139
158
 
140
159
  #### :gear: defineHook
141
160
 
@@ -143,7 +162,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
143
162
  | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
144
163
  | `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |
145
164
 
146
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L54)
165
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L55)
147
166
 
148
167
  #### :gear: setDocStore
149
168
 
@@ -151,16 +170,16 @@ Stores or updates a document in the datastore.
151
170
 
152
171
  The data must have been encoded - using encodeDocData - before calling this function.
153
172
 
154
- | Function | Type |
155
- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
156
- | `setDocStore` | `(params: { caller: Uint8Array<ArrayBufferLike>; collection: string; doc: { data: Uint8Array<ArrayBufferLike>; key: string; description?: string or undefined; version?: bigint or undefined; }; }) => void` |
173
+ | Function | Type |
174
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
175
+ | `setDocStore` | `(params: { caller: Uint8Array<ArrayBufferLike> or Principal; collection: string; doc: { data: Uint8Array<ArrayBufferLike>; key: string; description?: string or undefined; version?: bigint or undefined; }; }) => void` |
157
176
 
158
177
  Parameters:
159
178
 
160
179
  - `params`: - The parameters required to store the document,
161
180
  including the caller, collection, key, and document data.
162
181
 
163
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L14)
182
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L15)
164
183
 
165
184
  #### :gear: decodeDocData
166
185
 
@@ -190,6 +209,14 @@ Parameters:
190
209
 
191
210
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/serializer.sdk.ts#L21)
192
211
 
212
+ #### :gear: call
213
+
214
+ | Function | Type |
215
+ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
216
+ | `call` | `<T>(params: { canisterId: Uint8Array<ArrayBufferLike> or Principal; method: string; args: { values: unknown[]; types: Type<unknown>[]; }; results: { types: Type<unknown>[]; }; }) => Promise<...>` |
217
+
218
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/call.ic-cdk.ts#L5)
219
+
193
220
  #### :gear: id
194
221
 
195
222
  Retrieves the Satellite's Principal ID.
@@ -207,11 +234,13 @@ the Principal of the executing canister.
207
234
  ### :wrench: Constants
208
235
 
209
236
  - [CollectionsSchema](#gear-collectionsschema)
237
+ - [RawPrincipalSchema](#gear-rawprincipalschema)
238
+ - [PrincipalSchema](#gear-principalschema)
210
239
  - [TimestampSchema](#gear-timestampschema)
211
240
  - [VersionSchema](#gear-versionschema)
212
241
  - [RawDataSchema](#gear-rawdataschema)
213
- - [RawPrincipalSchema](#gear-rawprincipalschema)
214
242
  - [RawUserIdSchema](#gear-rawuseridschema)
243
+ - [UserIdSchema](#gear-useridschema)
215
244
  - [CollectionSchema](#gear-collectionschema)
216
245
  - [KeySchema](#gear-keyschema)
217
246
  - [DocDescriptionSchema](#gear-docdescriptionschema)
@@ -228,6 +257,8 @@ the Principal of the executing canister.
228
257
  - [HookSchema](#gear-hookschema)
229
258
  - [SetDocSchema](#gear-setdocschema)
230
259
  - [SetDocStoreParamsSchema](#gear-setdocstoreparamsschema)
260
+ - [CallArgsSchema](#gear-callargsschema)
261
+ - [CallParamsSchema](#gear-callparamsschema)
231
262
 
232
263
  #### :gear: CollectionsSchema
233
264
 
@@ -237,13 +268,29 @@ the Principal of the executing canister.
237
268
 
238
269
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/collections.ts#L6)
239
270
 
271
+ #### :gear: RawPrincipalSchema
272
+
273
+ | Constant | Type |
274
+ | -------------------- | ------------------------------------------------------------------------------- |
275
+ | `RawPrincipalSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
276
+
277
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/candid.ts#L7)
278
+
279
+ #### :gear: PrincipalSchema
280
+
281
+ | Constant | Type |
282
+ | ----------------- | ------------------------------------------- |
283
+ | `PrincipalSchema` | `ZodType<Principal, ZodTypeDef, Principal>` |
284
+
285
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/candid.ts#L19)
286
+
240
287
  #### :gear: TimestampSchema
241
288
 
242
289
  | Constant | Type |
243
290
  | ----------------- | ----------- |
244
291
  | `TimestampSchema` | `ZodBigInt` |
245
292
 
246
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L6)
293
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L7)
247
294
 
248
295
  #### :gear: VersionSchema
249
296
 
@@ -251,7 +298,7 @@ the Principal of the executing canister.
251
298
  | --------------- | ----------- |
252
299
  | `VersionSchema` | `ZodBigInt` |
253
300
 
254
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L18)
301
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L19)
255
302
 
256
303
  #### :gear: RawDataSchema
257
304
 
@@ -259,15 +306,7 @@ the Principal of the executing canister.
259
306
  | --------------- | ------------------------------------------------------------------------------- |
260
307
  | `RawDataSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
261
308
 
262
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L30)
263
-
264
- #### :gear: RawPrincipalSchema
265
-
266
- | Constant | Type |
267
- | -------------------- | ------------------------------------------------------------------------------- |
268
- | `RawPrincipalSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
269
-
270
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L44)
309
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L31)
271
310
 
272
311
  #### :gear: RawUserIdSchema
273
312
 
@@ -275,7 +314,15 @@ the Principal of the executing canister.
275
314
  | ----------------- | ------------------------------------------------------------------------------- |
276
315
  | `RawUserIdSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
277
316
 
278
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L58)
317
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L45)
318
+
319
+ #### :gear: UserIdSchema
320
+
321
+ | Constant | Type |
322
+ | -------------- | ------------------------------------------- |
323
+ | `UserIdSchema` | `ZodType<Principal, ZodTypeDef, Principal>` |
324
+
325
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L57)
279
326
 
280
327
  #### :gear: CollectionSchema
281
328
 
@@ -283,7 +330,7 @@ the Principal of the executing canister.
283
330
  | ------------------ | ----------- |
284
331
  | `CollectionSchema` | `ZodString` |
285
332
 
286
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L70)
333
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L69)
287
334
 
288
335
  #### :gear: KeySchema
289
336
 
@@ -291,7 +338,7 @@ the Principal of the executing canister.
291
338
  | ----------- | ----------- |
292
339
  | `KeySchema` | `ZodString` |
293
340
 
294
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L80)
341
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L79)
295
342
 
296
343
  #### :gear: DocDescriptionSchema
297
344
 
@@ -363,7 +410,7 @@ the Principal of the executing canister.
363
410
  | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
364
411
  | `AssertSetDocSchema` | `ZodObject<extendShape<{ collections: ZodArray<ZodString, "many">; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodVoid>; }>, "strict", ZodTypeAny, { ...; }, {...` |
365
412
 
366
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L25)
413
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L26)
367
414
 
368
415
  #### :gear: AssertSchema
369
416
 
@@ -371,7 +418,7 @@ the Principal of the executing canister.
371
418
  | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
372
419
  | `AssertSchema` | `ZodObject<extendShape<{ collections: ZodArray<ZodString, "many">; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodVoid>; }>, "strict", ZodTypeAny, { ...; }, {...` |
373
420
 
374
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L36)
421
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L37)
375
422
 
376
423
  #### :gear: OnSetDocSchema
377
424
 
@@ -379,7 +426,7 @@ the Principal of the executing canister.
379
426
  | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
380
427
  | `OnSetDocSchema` | `ZodObject<extendShape<{ collections: ZodArray<ZodString, "many">; }, { run: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodPromise<...>>; }>, "strict", ZodTypeAny, { ...;...` |
381
428
 
382
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L25)
429
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L26)
383
430
 
384
431
  #### :gear: HookSchema
385
432
 
@@ -387,7 +434,7 @@ the Principal of the executing canister.
387
434
  | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
388
435
  | `HookSchema` | `ZodObject<extendShape<{ collections: ZodArray<ZodString, "many">; }, { run: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodPromise<...>>; }>, "strict", ZodTypeAny, { ...;...` |
389
436
 
390
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L36)
437
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L37)
391
438
 
392
439
  #### :gear: SetDocSchema
393
440
 
@@ -395,27 +442,53 @@ the Principal of the executing canister.
395
442
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
396
443
  | `SetDocSchema` | `ZodObject<{ key: ZodString; description: ZodOptional<ZodString>; data: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
397
444
 
398
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/db.ts#L14)
445
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/db.ts#L15)
399
446
 
400
447
  #### :gear: SetDocStoreParamsSchema
401
448
 
402
- | Constant | Type |
403
- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
404
- | `SetDocStoreParamsSchema` | `ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; collection: ZodString; doc: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
449
+ | Constant | Type |
450
+ | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
451
+ | `SetDocStoreParamsSchema` | `ZodObject<{ caller: ZodUnion<[ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>, ZodType<...>]>; collection: ZodString; doc: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
452
+
453
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/db.ts#L50)
454
+
455
+ #### :gear: CallArgsSchema
456
+
457
+ Schema for encoding function call arguments on the Internet Computer.
458
+
459
+ Requests and responses on the IC are encoded using Candid.
460
+ This schema ensures that arguments are provided with both their value and type
461
+ to allow proper encoding.
405
462
 
406
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/db.ts#L49)
463
+ | Constant | Type |
464
+ | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
465
+ | `CallArgsSchema` | `ZodObject<{ types: ZodArray<ZodType<Type<unknown>, ZodTypeDef, Type<unknown>>, "many">; values: ZodArray<ZodUnknown, "many">; }, "strip", ZodTypeAny, { ...; }, { ...; }>` |
466
+
467
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/call.ts#L24)
468
+
469
+ #### :gear: CallParamsSchema
470
+
471
+ | Constant | Type |
472
+ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
473
+ | `CallParamsSchema` | `ZodObject<{ canisterId: ZodUnion<[ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>, ZodType<...>]>; method: ZodString; args: ZodObject<...>; results: ZodObject<...>; }, "strip", ZodTypeAny, { ...; }, { ...; }>` |
474
+
475
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/call.ts#L44)
407
476
 
408
477
  ### :cocktail: Types
409
478
 
410
479
  - [Collections](#gear-collections)
480
+ - [RawPrincipal](#gear-rawprincipal)
481
+ - [Principal](#gear-principal)
411
482
  - [Timestamp](#gear-timestamp)
412
483
  - [Version](#gear-version)
413
484
  - [RawData](#gear-rawdata)
414
- - [RawPrincipal](#gear-rawprincipal)
415
485
  - [RawUserId](#gear-rawuserid)
486
+ - [UserId](#gear-userid)
416
487
  - [Collection](#gear-collection)
417
488
  - [Key](#gear-key)
418
489
  - [HookContext](#gear-hookcontext)
490
+ - [AssertFunction](#gear-assertfunction)
491
+ - [RunFunction](#gear-runfunction)
419
492
  - [DocDescription](#gear-docdescription)
420
493
  - [Doc](#gear-doc)
421
494
  - [DocUpsert](#gear-docupsert)
@@ -435,6 +508,8 @@ the Principal of the executing canister.
435
508
  - [HookFnOrObject](#gear-hookfnorobject)
436
509
  - [SetDoc](#gear-setdoc)
437
510
  - [SetDocStoreParams](#gear-setdocstoreparams)
511
+ - [CallArgs](#gear-callargs)
512
+ - [CallParams](#gear-callparams)
438
513
 
439
514
  #### :gear: Collections
440
515
 
@@ -446,6 +521,26 @@ Defines the collections where a hook or assertion should run.
446
521
 
447
522
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/collections.ts#L18)
448
523
 
524
+ #### :gear: RawPrincipal
525
+
526
+ Represents a raw principal - a Uint8Array representation of a Principal.
527
+
528
+ | Type | Type |
529
+ | -------------- | ------------------------------------ |
530
+ | `RawPrincipal` | `z.infer<typeof RawPrincipalSchema>` |
531
+
532
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/candid.ts#L14)
533
+
534
+ #### :gear: Principal
535
+
536
+ Represents a principal - i.e. an object instantiated with the class Principal.
537
+
538
+ | Type | Type |
539
+ | ----------- | --------------------------------- |
540
+ | `Principal` | `z.infer<typeof PrincipalSchema>` |
541
+
542
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/candid.ts#L26)
543
+
449
544
  #### :gear: Timestamp
450
545
 
451
546
  Represents a timestamp in nanoseconds since the Unix epoch.
@@ -456,7 +551,7 @@ Used for tracking when events occur, such as document creation and updates.
456
551
  | ----------- | --------------------------------- |
457
552
  | `Timestamp` | `z.infer<typeof TimestampSchema>` |
458
553
 
459
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L13)
554
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L14)
460
555
 
461
556
  #### :gear: Version
462
557
 
@@ -468,7 +563,7 @@ This is typically incremented with each update to ensure consistency.
468
563
  | --------- | ------------------------------- |
469
564
  | `Version` | `z.infer<typeof VersionSchema>` |
470
565
 
471
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L25)
566
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L26)
472
567
 
473
568
  #### :gear: RawData
474
569
 
@@ -480,19 +575,7 @@ This is used to store unstructured data in a document.
480
575
  | --------- | ------------------------------- |
481
576
  | `RawData` | `z.infer<typeof RawDataSchema>` |
482
577
 
483
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L39)
484
-
485
- #### :gear: RawPrincipal
486
-
487
- Represents a raw principal identifier.
488
-
489
- Principals are unique identities used in authentication and authorization.
490
-
491
- | Type | Type |
492
- | -------------- | ------------------------------------ |
493
- | `RawPrincipal` | `z.infer<typeof RawPrincipalSchema>` |
494
-
495
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L53)
578
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L40)
496
579
 
497
580
  #### :gear: RawUserId
498
581
 
@@ -504,7 +587,19 @@ This is a principal associated with a user.
504
587
  | ----------- | --------------------------------- |
505
588
  | `RawUserId` | `z.infer<typeof RawUserIdSchema>` |
506
589
 
507
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L65)
590
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L52)
591
+
592
+ #### :gear: UserId
593
+
594
+ Represents a user identifier.
595
+
596
+ This is a principal associated with a user.
597
+
598
+ | Type | Type |
599
+ | -------- | ------------------------------ |
600
+ | `UserId` | `z.infer<typeof UserIdSchema>` |
601
+
602
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L64)
508
603
 
509
604
  #### :gear: Collection
510
605
 
@@ -514,7 +609,7 @@ A collection name where data are stored.
514
609
  | ------------ | ---------------------------------- |
515
610
  | `Collection` | `z.infer<typeof CollectionSchema>` |
516
611
 
517
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L75)
612
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L74)
518
613
 
519
614
  #### :gear: Key
520
615
 
@@ -524,7 +619,7 @@ A unique key identifier within a collection.
524
619
  | ----- | --------------------------- |
525
620
  | `Key` | `z.infer<typeof KeySchema>` |
526
621
 
527
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L85)
622
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L84)
528
623
 
529
624
  #### :gear: HookContext
530
625
 
@@ -536,6 +631,30 @@ Represents the context provided to hooks, containing information about the calle
536
631
 
537
632
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L27)
538
633
 
634
+ #### :gear: AssertFunction
635
+
636
+ Defines the `assert` function schema for assertions.
637
+
638
+ The function takes a context argument and returns `void`.
639
+
640
+ | Type | Type |
641
+ | ---------------- | ---------------------------------------------------------------- |
642
+ | `AssertFunction` | `z.infer<ReturnType<typeof AssertFunctionSchema<z.ZodType<T>>>>` |
643
+
644
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L42)
645
+
646
+ #### :gear: RunFunction
647
+
648
+ Defines the `run` function schema for hooks.
649
+
650
+ The function takes a context argument and returns a `Promise<void>`.
651
+
652
+ | Type | Type |
653
+ | ------------- | ------------------------------------------------------------- |
654
+ | `RunFunction` | `z.infer<ReturnType<typeof RunFunctionSchema<z.ZodType<T>>>>` |
655
+
656
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L57)
657
+
539
658
  #### :gear: DocDescription
540
659
 
541
660
  Represents a document description with a maximum length of 1024 characters.
@@ -651,7 +770,7 @@ An assertion that runs when a document is created or updated.
651
770
  | -------------- | ------------------------------------ |
652
771
  | `AssertSetDoc` | `z.infer<typeof AssertSetDocSchema>` |
653
772
 
654
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L30)
773
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L31)
655
774
 
656
775
  #### :gear: Assert
657
776
 
@@ -661,7 +780,7 @@ All assertions definitions.
661
780
  | -------- | ------------------------------ |
662
781
  | `Assert` | `z.infer<typeof AssertSchema>` |
663
782
 
664
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L41)
783
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L42)
665
784
 
666
785
  #### :gear: AssertFn
667
786
 
@@ -669,7 +788,7 @@ All assertions definitions.
669
788
  | ---------- | --------------------------------------------------- |
670
789
  | `AssertFn` | `(assert: z.infer<typeof SatelliteEnvSchema>) => T` |
671
790
 
672
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L45)
791
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L46)
673
792
 
674
793
  #### :gear: AssertFnOrObject
675
794
 
@@ -677,7 +796,7 @@ All assertions definitions.
677
796
  | ------------------ | ------------------ |
678
797
  | `AssertFnOrObject` | `T or AssertFn<T>` |
679
798
 
680
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L49)
799
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L50)
681
800
 
682
801
  #### :gear: OnSetDoc
683
802
 
@@ -687,7 +806,7 @@ A hook that runs when a document is created or updated.
687
806
  | ---------- | -------------------------------- |
688
807
  | `OnSetDoc` | `z.infer<typeof OnSetDocSchema>` |
689
808
 
690
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L30)
809
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L31)
691
810
 
692
811
  #### :gear: Hook
693
812
 
@@ -697,7 +816,7 @@ All hooks definitions.
697
816
  | ------ | ---------------------------- |
698
817
  | `Hook` | `z.infer<typeof HookSchema>` |
699
818
 
700
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L41)
819
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L42)
701
820
 
702
821
  #### :gear: HookFn
703
822
 
@@ -705,7 +824,7 @@ All hooks definitions.
705
824
  | -------- | ------------------------------------------------- |
706
825
  | `HookFn` | `(hook: z.infer<typeof SatelliteEnvSchema>) => T` |
707
826
 
708
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L45)
827
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L46)
709
828
 
710
829
  #### :gear: HookFnOrObject
711
830
 
@@ -713,7 +832,7 @@ All hooks definitions.
713
832
  | ---------------- | ---------------- |
714
833
  | `HookFnOrObject` | `T or HookFn<T>` |
715
834
 
716
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L49)
835
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L50)
717
836
 
718
837
  #### :gear: SetDoc
719
838
 
@@ -725,7 +844,7 @@ This is used when submitting new document data.
725
844
  | -------- | ------------------------------ |
726
845
  | `SetDoc` | `z.infer<typeof SetDocSchema>` |
727
846
 
728
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/db.ts#L44)
847
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/db.ts#L45)
729
848
 
730
849
  #### :gear: SetDocStoreParams
731
850
 
@@ -738,7 +857,27 @@ collection, and key.
738
857
  | ------------------- | ----------------------------------------- |
739
858
  | `SetDocStoreParams` | `z.infer<typeof SetDocStoreParamsSchema>` |
740
859
 
741
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/db.ts#L74)
860
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/db.ts#L75)
861
+
862
+ #### :gear: CallArgs
863
+
864
+ Type representing function call arguments on the IC.
865
+
866
+ | Type | Type |
867
+ | ---------- | -------------------------------- |
868
+ | `CallArgs` | `z.infer<typeof CallArgsSchema>` |
869
+
870
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/call.ts#L39)
871
+
872
+ #### :gear: CallParams
873
+
874
+ Type representing the parameters required to make a canister call.
875
+
876
+ | Type | Type |
877
+ | ------------ | ---------------------------------- |
878
+ | `CallParams` | `z.infer<typeof CallParamsSchema>` |
879
+
880
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/call.ts#L69)
742
881
 
743
882
  <!-- TSDOC_END -->
744
883
 
@@ -0,0 +1,2 @@
1
+ import{a as r,b as a}from"./chunk-O3XBHEOU.js";import*as e from"zod";var o=e.bigint(),c=e.bigint(),p=e.custom(n=>n instanceof Uint8Array,{message:"Expected Uint8Array"}),i=r,h=a,y=e.string(),S=e.string();import*as t from"zod";var m=t.string().max(1024),z=t.object({owner:i,data:p,description:m.optional(),created_at:o,updated_at:o,version:c.optional()}).strict();export{o as a,c as b,p as c,i as d,h as e,y as f,S as g,m as h,z as i};
2
+ //# sourceMappingURL=chunk-3VORCQH4.js.map