@junobuild/functions 0.0.6 → 0.0.7-next-2025-03-16

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.
Files changed (38) hide show
  1. package/README.md +288 -127
  2. package/chunk-OVO3T2DM.js +2 -0
  3. package/chunk-OVO3T2DM.js.map +7 -0
  4. package/global.d.js +1 -0
  5. package/global.d.js.map +7 -0
  6. package/global.d.ts +17 -0
  7. package/{dist/types/configs → hooks/db}/assertions.d.ts +13 -13
  8. package/{dist/types/configs → hooks/db}/hooks.d.ts +13 -13
  9. package/{dist/types/configs/collections.config.d.ts → hooks/schemas/collections.d.ts} +3 -3
  10. package/hooks/schemas/context.d.ts +80 -0
  11. package/{dist/types/hooks → hooks/schemas/db}/context.d.ts +8 -76
  12. package/{dist/types/hooks/datastore.d.ts → hooks/schemas/db/payload.d.ts} +0 -145
  13. package/ic-cdk/id.d.ts +11 -0
  14. package/ic-cdk.d.ts +1 -0
  15. package/ic-cdk.js +7 -0
  16. package/ic-cdk.js.map +7 -0
  17. package/index.d.ts +10 -0
  18. package/index.js +2 -0
  19. package/index.js.map +7 -0
  20. package/package.json +25 -16
  21. package/schemas/candid.d.ts +11 -0
  22. package/{dist/types/hooks → schemas}/core.d.ts +16 -10
  23. package/schemas/db.d.ts +57 -0
  24. package/sdk/db.sdk.d.ts +13 -0
  25. package/sdk/schemas/db.d.ts +109 -0
  26. package/sdk/serializer.sdk.d.ts +17 -0
  27. package/sdk.d.ts +3 -0
  28. package/sdk.js +2 -0
  29. package/sdk.js.map +7 -0
  30. package/src/global.d.ts +17 -0
  31. package/dist/browser/index.js +0 -2
  32. package/dist/browser/index.js.map +0 -7
  33. package/dist/index.js +0 -1
  34. package/dist/types/global.d.ts +0 -8
  35. package/dist/types/index.d.ts +0 -9
  36. package/dist/types/sdk/datastore.sdk.d.ts +0 -3
  37. /package/{dist/types/configs → hooks/schemas}/satellite.env.d.ts +0 -0
  38. /package/{dist/types/polyfills → polyfills}/console.polyfill.d.ts +0 -0
package/README.md CHANGED
@@ -14,6 +14,9 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
14
14
 
15
15
  ### :toolbox: Functions
16
16
 
17
+ - [HookContextSchema](#gear-hookcontextschema)
18
+ - [AssertFunctionSchema](#gear-assertfunctionschema)
19
+ - [RunFunctionSchema](#gear-runfunctionschema)
17
20
  - [DocContextSchema](#gear-doccontextschema)
18
21
  - [AssertFnSchema](#gear-assertfnschema)
19
22
  - [AssertFnOrObjectSchema](#gear-assertfnorobjectschema)
@@ -27,8 +30,34 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
27
30
  - [defineHook](#gear-definehook)
28
31
  - [defineHook](#gear-definehook)
29
32
  - [defineHook](#gear-definehook)
33
+ - [setDocStore](#gear-setdocstore)
30
34
  - [decodeDocData](#gear-decodedocdata)
31
35
  - [encodeDocData](#gear-encodedocdata)
36
+ - [id](#gear-id)
37
+
38
+ #### :gear: HookContextSchema
39
+
40
+ | Function | Type |
41
+ | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
42
+ | `HookContextSchema` | `<T extends z.ZodTypeAny>(dataSchema: T) => ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; data: T; }, "strict", ZodTypeAny, { [k in keyof addQuestionMarks<...>]: addQuestionMarks<...>[k]; }, { [k in keyof baseObjectInputType<...>]: baseObjectInputType<...>[k]; }>` |
43
+
44
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L7)
45
+
46
+ #### :gear: AssertFunctionSchema
47
+
48
+ | Function | Type |
49
+ | ---------------------- | ----------------------------------------------------------------------------------------------- |
50
+ | `AssertFunctionSchema` | `<T extends z.ZodTypeAny>(contextSchema: T) => ZodFunction<ZodTuple<[T], ZodUnknown>, ZodVoid>` |
51
+
52
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L32)
53
+
54
+ #### :gear: RunFunctionSchema
55
+
56
+ | Function | Type |
57
+ | ------------------- | ----------------------------------------------------------------------------------------------------------- |
58
+ | `RunFunctionSchema` | `<T extends z.ZodTypeAny>(contextSchema: T) => ZodFunction<ZodTuple<[T], ZodUnknown>, ZodPromise<ZodVoid>>` |
59
+
60
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L49)
32
61
 
33
62
  #### :gear: DocContextSchema
34
63
 
@@ -36,7 +65,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
36
65
  | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
37
66
  | `DocContextSchema` | `<T extends z.ZodTypeAny>(dataSchema: T) => ZodObject<{ collection: ZodString; key: ZodString; data: T; }, "strict", ZodTypeAny, { [k in keyof addQuestionMarks<baseObjectOutputType<{ collection: ZodString; key: ZodString; data: T; }>, any>]: addQuestionMarks<...>[k]; }, { [k in keyof baseObjectInputType<...>]: baseOb...` |
38
67
 
39
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#L33)
68
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L9)
40
69
 
41
70
  #### :gear: AssertFnSchema
42
71
 
@@ -44,7 +73,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
44
73
  | ---------------- | ----------------------------------------------------------------------------------------------------------------------- |
45
74
  | `AssertFnSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>` |
46
75
 
47
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L43)
76
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L44)
48
77
 
49
78
  #### :gear: AssertFnOrObjectSchema
50
79
 
@@ -52,7 +81,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
52
81
  | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
53
82
  | `AssertFnOrObjectSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodUnion<[T, ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>]>` |
54
83
 
55
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L47)
84
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L48)
56
85
 
57
86
  #### :gear: defineAssert
58
87
 
@@ -60,7 +89,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
60
89
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
61
90
  | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
62
91
 
63
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L51)
92
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L52)
64
93
 
65
94
  #### :gear: defineAssert
66
95
 
@@ -68,7 +97,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
68
97
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
69
98
  | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
70
99
 
71
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L52)
100
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L53)
72
101
 
73
102
  #### :gear: defineAssert
74
103
 
@@ -76,7 +105,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
76
105
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
77
106
  | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
78
107
 
79
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L53)
108
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L54)
80
109
 
81
110
  #### :gear: defineAssert
82
111
 
@@ -84,7 +113,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
84
113
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
85
114
  | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
86
115
 
87
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L54)
116
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L55)
88
117
 
89
118
  #### :gear: HookFnSchema
90
119
 
@@ -92,7 +121,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
92
121
  | -------------- | --------------------------------------------------------------------------------------------------------------------- |
93
122
  | `HookFnSchema` | `<T extends z.ZodTypeAny>(hookSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>` |
94
123
 
95
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L43)
124
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L44)
96
125
 
97
126
  #### :gear: HookFnOrObjectSchema
98
127
 
@@ -100,7 +129,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
100
129
  | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
101
130
  | `HookFnOrObjectSchema` | `<T extends z.ZodTypeAny>(hookSchema: T) => ZodUnion<[T, ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>]>` |
102
131
 
103
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L47)
132
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L48)
104
133
 
105
134
  #### :gear: defineHook
106
135
 
@@ -108,7 +137,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
108
137
  | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
109
138
  | `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |
110
139
 
111
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L51)
140
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L52)
112
141
 
113
142
  #### :gear: defineHook
114
143
 
@@ -116,7 +145,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
116
145
  | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
117
146
  | `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |
118
147
 
119
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L52)
148
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L53)
120
149
 
121
150
  #### :gear: defineHook
122
151
 
@@ -124,7 +153,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
124
153
  | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
125
154
  | `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |
126
155
 
127
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L53)
156
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L54)
128
157
 
129
158
  #### :gear: defineHook
130
159
 
@@ -132,45 +161,107 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
132
161
  | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
133
162
  | `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |
134
163
 
135
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L54)
164
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L55)
165
+
166
+ #### :gear: setDocStore
167
+
168
+ Stores or updates a document in the datastore.
169
+
170
+ The data must have been encoded - using encodeDocData - before calling this function.
171
+
172
+ | Function | Type |
173
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
174
+ | `setDocStore` | `(params: { caller: Uint8Array<ArrayBufferLike>; collection: string; doc: { data: Uint8Array<ArrayBufferLike>; key: string; description?: string or undefined; version?: bigint or undefined; }; }) => void` |
175
+
176
+ Parameters:
177
+
178
+ - `params`: - The parameters required to store the document,
179
+ including the caller, collection, key, and document data.
180
+
181
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/db.sdk.ts#L14)
136
182
 
137
183
  #### :gear: decodeDocData
138
184
 
185
+ Decodes the raw data of a document into a JavaScript object.
186
+
139
187
  | Function | Type |
140
188
  | --------------- | --------------------------------------------- |
141
189
  | `decodeDocData` | `<T>(data: Uint8Array<ArrayBufferLike>) => T` |
142
190
 
143
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/datastore.sdk.ts#L4)
191
+ Parameters:
192
+
193
+ - `data`: - The raw data to be decoded.
194
+
195
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/serializer.sdk.ts#L11)
144
196
 
145
197
  #### :gear: encodeDocData
146
198
 
199
+ Encodes a JavaScript object into a raw data format to be applied to a document.
200
+
147
201
  | Function | Type |
148
202
  | --------------- | --------------------------------------------- |
149
203
  | `encodeDocData` | `<T>(data: T) => Uint8Array<ArrayBufferLike>` |
150
204
 
151
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/datastore.sdk.ts#L7)
205
+ Parameters:
206
+
207
+ - `data`: - The data to be encoded.
208
+
209
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/serializer.sdk.ts#L21)
210
+
211
+ #### :gear: id
212
+
213
+ Retrieves the Satellite's Principal ID.
214
+
215
+ This function is a JavaScript binding for the Rust function
216
+ [`ic_cdk::id()`](https://docs.rs/ic-cdk/latest/ic_cdk/fn.id.html), which returns
217
+ the Principal of the executing canister.
218
+
219
+ | Function | Type |
220
+ | -------- | ----------------- |
221
+ | `id` | `() => Principal` |
222
+
223
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/id.ts#L12)
152
224
 
153
225
  ### :wrench: Constants
154
226
 
227
+ - [CollectionsSchema](#gear-collectionsschema)
228
+ - [RawPrincipalSchema](#gear-rawprincipalschema)
155
229
  - [TimestampSchema](#gear-timestampschema)
156
230
  - [VersionSchema](#gear-versionschema)
157
231
  - [RawDataSchema](#gear-rawdataschema)
158
- - [RawPrincipalSchema](#gear-rawprincipalschema)
159
232
  - [RawUserIdSchema](#gear-rawuseridschema)
233
+ - [CollectionSchema](#gear-collectionschema)
234
+ - [KeySchema](#gear-keyschema)
160
235
  - [DocDescriptionSchema](#gear-docdescriptionschema)
161
236
  - [DocSchema](#gear-docschema)
162
237
  - [DocUpsertSchema](#gear-docupsertschema)
163
238
  - [ProposedDocSchema](#gear-proposeddocschema)
164
239
  - [DocAssertSetSchema](#gear-docassertsetschema)
165
- - [SetDocSchema](#gear-setdocschema)
166
240
  - [OnSetDocContextSchema](#gear-onsetdoccontextschema)
167
241
  - [AssertSetDocContextSchema](#gear-assertsetdoccontextschema)
168
- - [CollectionsConfigSchema](#gear-collectionsconfigschema)
169
242
  - [SatelliteEnvSchema](#gear-satelliteenvschema)
170
243
  - [AssertSetDocSchema](#gear-assertsetdocschema)
171
244
  - [AssertSchema](#gear-assertschema)
172
245
  - [OnSetDocSchema](#gear-onsetdocschema)
173
246
  - [HookSchema](#gear-hookschema)
247
+ - [SetDocSchema](#gear-setdocschema)
248
+ - [SetDocStoreParamsSchema](#gear-setdocstoreparamsschema)
249
+
250
+ #### :gear: CollectionsSchema
251
+
252
+ | Constant | Type |
253
+ | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
254
+ | `CollectionsSchema` | `ZodObject<{ collections: ZodArray<ZodString, "many">; }, "strict", ZodTypeAny, { collections: string[]; }, { collections: string[]; }>` |
255
+
256
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/collections.ts#L6)
257
+
258
+ #### :gear: RawPrincipalSchema
259
+
260
+ | Constant | Type |
261
+ | -------------------- | ------------------------------------------------------------------------------- |
262
+ | `RawPrincipalSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
263
+
264
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/candid.ts#L6)
174
265
 
175
266
  #### :gear: TimestampSchema
176
267
 
@@ -178,7 +269,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
178
269
  | ----------------- | ----------- |
179
270
  | `TimestampSchema` | `ZodBigInt` |
180
271
 
181
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L6)
272
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L7)
182
273
 
183
274
  #### :gear: VersionSchema
184
275
 
@@ -186,7 +277,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
186
277
  | --------------- | ----------- |
187
278
  | `VersionSchema` | `ZodBigInt` |
188
279
 
189
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L18)
280
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L19)
190
281
 
191
282
  #### :gear: RawDataSchema
192
283
 
@@ -194,15 +285,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
194
285
  | --------------- | ------------------------------------------------------------------------------- |
195
286
  | `RawDataSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
196
287
 
197
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L30)
198
-
199
- #### :gear: RawPrincipalSchema
200
-
201
- | Constant | Type |
202
- | -------------------- | ------------------------------------------------------------------------------- |
203
- | `RawPrincipalSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
204
-
205
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L44)
288
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L31)
206
289
 
207
290
  #### :gear: RawUserIdSchema
208
291
 
@@ -210,7 +293,23 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
210
293
  | ----------------- | ------------------------------------------------------------------------------- |
211
294
  | `RawUserIdSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
212
295
 
213
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L58)
296
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L45)
297
+
298
+ #### :gear: CollectionSchema
299
+
300
+ | Constant | Type |
301
+ | ------------------ | ----------- |
302
+ | `CollectionSchema` | `ZodString` |
303
+
304
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L57)
305
+
306
+ #### :gear: KeySchema
307
+
308
+ | Constant | Type |
309
+ | ----------- | ----------- |
310
+ | `KeySchema` | `ZodString` |
311
+
312
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L67)
214
313
 
215
314
  #### :gear: DocDescriptionSchema
216
315
 
@@ -218,7 +317,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
218
317
  | ---------------------- | ----------- |
219
318
  | `DocDescriptionSchema` | `ZodString` |
220
319
 
221
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L7)
320
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/db.ts#L7)
222
321
 
223
322
  #### :gear: DocSchema
224
323
 
@@ -226,7 +325,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
226
325
  | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
227
326
  | `DocSchema` | `ZodObject<{ owner: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; ... 4 more ...; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
228
327
 
229
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L17)
328
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/db.ts#L17)
230
329
 
231
330
  #### :gear: DocUpsertSchema
232
331
 
@@ -234,7 +333,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
234
333
  | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
235
334
  | `DocUpsertSchema` | `ZodObject<{ before: ZodOptional<ZodObject<{ owner: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; ... 4 more ...; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>>; after: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
236
335
 
237
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L60)
336
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L8)
238
337
 
239
338
  #### :gear: ProposedDocSchema
240
339
 
@@ -242,7 +341,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
242
341
  | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
243
342
  | `ProposedDocSchema` | `ZodObject<{ data: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; description: ZodOptional<...>; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
244
343
 
245
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L85)
344
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L33)
246
345
 
247
346
  #### :gear: DocAssertSetSchema
248
347
 
@@ -250,15 +349,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
250
349
  | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
251
350
  | `DocAssertSetSchema` | `ZodObject<{ current: ZodOptional<ZodObject<{ owner: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; ... 4 more ...; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>>; proposed: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
252
351
 
253
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L113)
254
-
255
- #### :gear: SetDocSchema
256
-
257
- | Constant | Type |
258
- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
259
- | `SetDocSchema` | `ZodObject<{ data: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; description: ZodOptional<...>; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
260
-
261
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L140)
352
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L61)
262
353
 
263
354
  #### :gear: OnSetDocContextSchema
264
355
 
@@ -266,7 +357,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
266
357
  | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
267
358
  | `OnSetDocContextSchema` | `ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
268
359
 
269
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#L63)
360
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L39)
270
361
 
271
362
  #### :gear: AssertSetDocContextSchema
272
363
 
@@ -274,15 +365,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
274
365
  | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
275
366
  | `AssertSetDocContextSchema` | `ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
276
367
 
277
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#L76)
278
-
279
- #### :gear: CollectionsConfigSchema
280
-
281
- | Constant | Type |
282
- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
283
- | `CollectionsConfigSchema` | `ZodObject<{ collections: ZodArray<ZodString, "many">; }, "strict", ZodTypeAny, { collections: string[]; }, { collections: string[]; }>` |
284
-
285
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/collections.config.ts#L6)
368
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L52)
286
369
 
287
370
  #### :gear: SatelliteEnvSchema
288
371
 
@@ -290,7 +373,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
290
373
  | -------------------- | ---------------------------------- |
291
374
  | `SatelliteEnvSchema` | `ZodRecord<ZodString, ZodUnknown>` |
292
375
 
293
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.env.ts#L6)
376
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/satellite.env.ts#L6)
294
377
 
295
378
  #### :gear: AssertSetDocSchema
296
379
 
@@ -298,7 +381,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
298
381
  | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
299
382
  | `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, { ...; }, {...` |
300
383
 
301
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L25)
384
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L26)
302
385
 
303
386
  #### :gear: AssertSchema
304
387
 
@@ -306,7 +389,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
306
389
  | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
307
390
  | `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, { ...; }, {...` |
308
391
 
309
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L36)
392
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L37)
310
393
 
311
394
  #### :gear: OnSetDocSchema
312
395
 
@@ -314,7 +397,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
314
397
  | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
315
398
  | `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, { ...;...` |
316
399
 
317
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L25)
400
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L26)
318
401
 
319
402
  #### :gear: HookSchema
320
403
 
@@ -322,26 +405,45 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
322
405
  | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
323
406
  | `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, { ...;...` |
324
407
 
325
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L36)
408
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L37)
409
+
410
+ #### :gear: SetDocSchema
411
+
412
+ | Constant | Type |
413
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
414
+ | `SetDocSchema` | `ZodObject<{ key: ZodString; description: ZodOptional<ZodString>; data: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
415
+
416
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/db.ts#L14)
417
+
418
+ #### :gear: SetDocStoreParamsSchema
419
+
420
+ | Constant | Type |
421
+ | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
422
+ | `SetDocStoreParamsSchema` | `ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; collection: ZodString; doc: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
423
+
424
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/db.ts#L49)
326
425
 
327
426
  ### :cocktail: Types
328
427
 
428
+ - [Collections](#gear-collections)
429
+ - [RawPrincipal](#gear-rawprincipal)
329
430
  - [Timestamp](#gear-timestamp)
330
431
  - [Version](#gear-version)
331
432
  - [RawData](#gear-rawdata)
332
- - [RawPrincipal](#gear-rawprincipal)
333
433
  - [RawUserId](#gear-rawuserid)
434
+ - [Collection](#gear-collection)
435
+ - [Key](#gear-key)
436
+ - [HookContext](#gear-hookcontext)
437
+ - [AssertFunction](#gear-assertfunction)
438
+ - [RunFunction](#gear-runfunction)
334
439
  - [DocDescription](#gear-docdescription)
335
440
  - [Doc](#gear-doc)
336
441
  - [DocUpsert](#gear-docupsert)
337
442
  - [ProposedDoc](#gear-proposeddoc)
338
443
  - [DocAssertSet](#gear-docassertset)
339
- - [SetDoc](#gear-setdoc)
340
- - [HookContext](#gear-hookcontext)
341
444
  - [DocContext](#gear-doccontext)
342
445
  - [OnSetDocContext](#gear-onsetdoccontext)
343
446
  - [AssertSetDocContext](#gear-assertsetdoccontext)
344
- - [CollectionsConfig](#gear-collectionsconfig)
345
447
  - [SatelliteEnv](#gear-satelliteenv)
346
448
  - [AssertSetDoc](#gear-assertsetdoc)
347
449
  - [Assert](#gear-assert)
@@ -351,6 +453,30 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
351
453
  - [Hook](#gear-hook)
352
454
  - [HookFn](#gear-hookfn)
353
455
  - [HookFnOrObject](#gear-hookfnorobject)
456
+ - [SetDoc](#gear-setdoc)
457
+ - [SetDocStoreParams](#gear-setdocstoreparams)
458
+
459
+ #### :gear: Collections
460
+
461
+ Defines the collections where a hook or assertion should run.
462
+
463
+ | Type | Type |
464
+ | ------------- | ----------------------------------- |
465
+ | `Collections` | `z.infer<typeof CollectionsSchema>` |
466
+
467
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/collections.ts#L18)
468
+
469
+ #### :gear: RawPrincipal
470
+
471
+ Represents a raw principal identifier.
472
+
473
+ Principals are unique identities used in authentication and authorization.
474
+
475
+ | Type | Type |
476
+ | -------------- | ------------------------------------ |
477
+ | `RawPrincipal` | `z.infer<typeof RawPrincipalSchema>` |
478
+
479
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/candid.ts#L15)
354
480
 
355
481
  #### :gear: Timestamp
356
482
 
@@ -362,7 +488,7 @@ Used for tracking when events occur, such as document creation and updates.
362
488
  | ----------- | --------------------------------- |
363
489
  | `Timestamp` | `z.infer<typeof TimestampSchema>` |
364
490
 
365
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L13)
491
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L14)
366
492
 
367
493
  #### :gear: Version
368
494
 
@@ -374,7 +500,7 @@ This is typically incremented with each update to ensure consistency.
374
500
  | --------- | ------------------------------- |
375
501
  | `Version` | `z.infer<typeof VersionSchema>` |
376
502
 
377
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L25)
503
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L26)
378
504
 
379
505
  #### :gear: RawData
380
506
 
@@ -386,19 +512,7 @@ This is used to store unstructured data in a document.
386
512
  | --------- | ------------------------------- |
387
513
  | `RawData` | `z.infer<typeof RawDataSchema>` |
388
514
 
389
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L39)
390
-
391
- #### :gear: RawPrincipal
392
-
393
- Represents a raw principal identifier.
394
-
395
- Principals are unique identities used in authentication and authorization.
396
-
397
- | Type | Type |
398
- | -------------- | ------------------------------------ |
399
- | `RawPrincipal` | `z.infer<typeof RawPrincipalSchema>` |
400
-
401
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L53)
515
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L40)
402
516
 
403
517
  #### :gear: RawUserId
404
518
 
@@ -410,7 +524,61 @@ This is a principal associated with a user.
410
524
  | ----------- | --------------------------------- |
411
525
  | `RawUserId` | `z.infer<typeof RawUserIdSchema>` |
412
526
 
413
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L65)
527
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L52)
528
+
529
+ #### :gear: Collection
530
+
531
+ A collection name where data are stored.
532
+
533
+ | Type | Type |
534
+ | ------------ | ---------------------------------- |
535
+ | `Collection` | `z.infer<typeof CollectionSchema>` |
536
+
537
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L62)
538
+
539
+ #### :gear: Key
540
+
541
+ A unique key identifier within a collection.
542
+
543
+ | Type | Type |
544
+ | ----- | --------------------------- |
545
+ | `Key` | `z.infer<typeof KeySchema>` |
546
+
547
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/core.ts#L72)
548
+
549
+ #### :gear: HookContext
550
+
551
+ Represents the context provided to hooks, containing information about the caller and related data.
552
+
553
+ | Type | Type |
554
+ | ------------- | -------------------------------------------------- |
555
+ | `HookContext` | `z.infer<ReturnType<typeof HookContextSchema<T>>>` |
556
+
557
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L27)
558
+
559
+ #### :gear: AssertFunction
560
+
561
+ Defines the `assert` function schema for assertions.
562
+
563
+ The function takes a context argument and returns `void`.
564
+
565
+ | Type | Type |
566
+ | ---------------- | ------------------------------------------------------- |
567
+ | `AssertFunction` | `z.infer< ReturnType<typeof AssertFunctionSchema<T>> >` |
568
+
569
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L42)
570
+
571
+ #### :gear: RunFunction
572
+
573
+ Defines the `run` function schema for hooks.
574
+
575
+ The function takes a context argument and returns a `Promise<void>`.
576
+
577
+ | Type | Type |
578
+ | ------------- | -------------------------------------------------- |
579
+ | `RunFunction` | `z.infer<ReturnType<typeof RunFunctionSchema<T>>>` |
580
+
581
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L59)
414
582
 
415
583
  #### :gear: DocDescription
416
584
 
@@ -420,7 +588,7 @@ Represents a document description with a maximum length of 1024 characters.
420
588
  | ---------------- | -------------------------------------- |
421
589
  | `DocDescription` | `z.infer<typeof DocDescriptionSchema>` |
422
590
 
423
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L12)
591
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/db.ts#L12)
424
592
 
425
593
  #### :gear: Doc
426
594
 
@@ -430,7 +598,7 @@ Represents a document stored in a collection.
430
598
  | ----- | --------------------------- |
431
599
  | `Doc` | `z.infer<typeof DocSchema>` |
432
600
 
433
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L55)
601
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/schemas/db.ts#L55)
434
602
 
435
603
  #### :gear: DocUpsert
436
604
 
@@ -442,7 +610,7 @@ This is used in hooks where a document is either being created or updated.
442
610
  | ----------- | --------------------------------- |
443
611
  | `DocUpsert` | `z.infer<typeof DocUpsertSchema>` |
444
612
 
445
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L80)
613
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L28)
446
614
 
447
615
  #### :gear: ProposedDoc
448
616
 
@@ -453,7 +621,7 @@ This can be validated before allowing the operation.
453
621
  | ------------- | ----------------------------------- |
454
622
  | `ProposedDoc` | `z.infer<typeof ProposedDocSchema>` |
455
623
 
456
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L108)
624
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L56)
457
625
 
458
626
  #### :gear: DocAssertSet
459
627
 
@@ -466,29 +634,7 @@ throw an error if their validation fails.
466
634
  | -------------- | ------------------------------------ |
467
635
  | `DocAssertSet` | `z.infer<typeof DocAssertSetSchema>` |
468
636
 
469
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L135)
470
-
471
- #### :gear: SetDoc
472
-
473
- Represents a request to set or update a document.
474
-
475
- This is used when submitting new document data.
476
-
477
- | Type | Type |
478
- | -------- | ------------------------------ |
479
- | `SetDoc` | `z.infer<typeof SetDocSchema>` |
480
-
481
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L165)
482
-
483
- #### :gear: HookContext
484
-
485
- Represents the context provided to hooks, containing information about the caller and related data.
486
-
487
- | Type | Type |
488
- | ------------- | -------------------------------------------------- |
489
- | `HookContext` | `z.infer<ReturnType<typeof HookContextSchema<T>>>` |
490
-
491
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#L28)
637
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L83)
492
638
 
493
639
  #### :gear: DocContext
494
640
 
@@ -498,7 +644,7 @@ Represents the context of a document operation within a collection.
498
644
  | ------------ | ------------------------------------------------- |
499
645
  | `DocContext` | `z.infer<ReturnType<typeof DocContextSchema<T>>>` |
500
646
 
501
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#L58)
647
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L34)
502
648
 
503
649
  #### :gear: OnSetDocContext
504
650
 
@@ -511,7 +657,7 @@ along with details about the user who triggered the operation.
511
657
  | ----------------- | --------------------------------------- |
512
658
  | `OnSetDocContext` | `z.infer<typeof OnSetDocContextSchema>` |
513
659
 
514
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#L71)
660
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L47)
515
661
 
516
662
  #### :gear: AssertSetDocContext
517
663
 
@@ -524,17 +670,7 @@ it is created or updated. If validation fails, the developer should throw an err
524
670
  | --------------------- | ------------------------------------------- |
525
671
  | `AssertSetDocContext` | `z.infer<typeof AssertSetDocContextSchema>` |
526
672
 
527
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#L84)
528
-
529
- #### :gear: CollectionsConfig
530
-
531
- Defines the collections where a hook or assertion should run.
532
-
533
- | Type | Type |
534
- | ------------------- | ----------------------------------------- |
535
- | `CollectionsConfig` | `z.infer<typeof CollectionsConfigSchema>` |
536
-
537
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/collections.config.ts#L18)
673
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L60)
538
674
 
539
675
  #### :gear: SatelliteEnv
540
676
 
@@ -549,7 +685,7 @@ Currently unused, but it may support features such as:
549
685
  | -------------- | ------------------------------------ |
550
686
  | `SatelliteEnv` | `z.infer<typeof SatelliteEnvSchema>` |
551
687
 
552
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.env.ts#L15)
688
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/satellite.env.ts#L15)
553
689
 
554
690
  #### :gear: AssertSetDoc
555
691
 
@@ -559,7 +695,7 @@ An assertion that runs when a document is created or updated.
559
695
  | -------------- | ------------------------------------ |
560
696
  | `AssertSetDoc` | `z.infer<typeof AssertSetDocSchema>` |
561
697
 
562
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L30)
698
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L31)
563
699
 
564
700
  #### :gear: Assert
565
701
 
@@ -569,7 +705,7 @@ All assertions definitions.
569
705
  | -------- | ------------------------------ |
570
706
  | `Assert` | `z.infer<typeof AssertSchema>` |
571
707
 
572
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L41)
708
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L42)
573
709
 
574
710
  #### :gear: AssertFn
575
711
 
@@ -577,7 +713,7 @@ All assertions definitions.
577
713
  | ---------- | --------------------------------------------------- |
578
714
  | `AssertFn` | `(assert: z.infer<typeof SatelliteEnvSchema>) => T` |
579
715
 
580
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L45)
716
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L46)
581
717
 
582
718
  #### :gear: AssertFnOrObject
583
719
 
@@ -585,7 +721,7 @@ All assertions definitions.
585
721
  | ------------------ | ------------------ |
586
722
  | `AssertFnOrObject` | `T or AssertFn<T>` |
587
723
 
588
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L49)
724
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L50)
589
725
 
590
726
  #### :gear: OnSetDoc
591
727
 
@@ -595,7 +731,7 @@ A hook that runs when a document is created or updated.
595
731
  | ---------- | -------------------------------- |
596
732
  | `OnSetDoc` | `z.infer<typeof OnSetDocSchema>` |
597
733
 
598
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L30)
734
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L31)
599
735
 
600
736
  #### :gear: Hook
601
737
 
@@ -605,7 +741,7 @@ All hooks definitions.
605
741
  | ------ | ---------------------------- |
606
742
  | `Hook` | `z.infer<typeof HookSchema>` |
607
743
 
608
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L41)
744
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L42)
609
745
 
610
746
  #### :gear: HookFn
611
747
 
@@ -613,7 +749,7 @@ All hooks definitions.
613
749
  | -------- | ------------------------------------------------- |
614
750
  | `HookFn` | `(hook: z.infer<typeof SatelliteEnvSchema>) => T` |
615
751
 
616
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L45)
752
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L46)
617
753
 
618
754
  #### :gear: HookFnOrObject
619
755
 
@@ -621,7 +757,32 @@ All hooks definitions.
621
757
  | ---------------- | ---------------- |
622
758
  | `HookFnOrObject` | `T or HookFn<T>` |
623
759
 
624
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L49)
760
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L50)
761
+
762
+ #### :gear: SetDoc
763
+
764
+ Represents a request to set or update a document.
765
+
766
+ This is used when submitting new document data.
767
+
768
+ | Type | Type |
769
+ | -------- | ------------------------------ |
770
+ | `SetDoc` | `z.infer<typeof SetDocSchema>` |
771
+
772
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/db.ts#L44)
773
+
774
+ #### :gear: SetDocStoreParams
775
+
776
+ Represents the parameters required to store or update a document.
777
+
778
+ This includes the document data along with metadata such as the caller,
779
+ collection, and key.
780
+
781
+ | Type | Type |
782
+ | ------------------- | ----------------------------------------- |
783
+ | `SetDocStoreParams` | `z.infer<typeof SetDocStoreParamsSchema>` |
784
+
785
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/db.ts#L74)
625
786
 
626
787
  <!-- TSDOC_END -->
627
788