@junobuild/functions 0.0.6 → 0.0.7

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