@junobuild/functions 0.0.4 → 0.0.6-next-2025-03-15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -40,115 +40,127 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
40
40
 
41
41
  #### :gear: AssertFnSchema
42
42
 
43
- | Function | Type |
44
- | ---------------- | --------------------------------------------------------------------------------------------------------------------------- |
45
- | `AssertFnSchema` | `<T extends z.ZodTypeAny>(hookConfigSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>` |
43
+ | Function | Type |
44
+ | ---------------- | ----------------------------------------------------------------------------------------------------------------------- |
45
+ | `AssertFnSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>` |
46
46
 
47
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assert.config.ts#L43)
47
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L43)
48
48
 
49
49
  #### :gear: AssertFnOrObjectSchema
50
50
 
51
- | Function | Type |
52
- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
53
- | `AssertFnOrObjectSchema` | `<T extends z.ZodTypeAny>(hookConfigSchema: T) => ZodUnion<[T, ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>]>` |
51
+ | Function | Type |
52
+ | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
53
+ | `AssertFnOrObjectSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodUnion<[T, ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>]>` |
54
54
 
55
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assert.config.ts#L49)
55
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L47)
56
56
 
57
57
  #### :gear: defineAssert
58
58
 
59
- | Function | Type |
60
- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
61
- | `defineAssert` | `{ <T extends AssertConfig>(config: T): T; <T extends AssertConfig>(config: AssertFn<T>): AssertFn<T>; <T extends AssertConfig>(config: AssertFnOrObject<T>): AssertFnOrObject<...>; }` |
59
+ | Function | Type |
60
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
61
+ | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
62
62
 
63
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assert.config.ts#L53)
63
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L51)
64
64
 
65
65
  #### :gear: defineAssert
66
66
 
67
- | Function | Type |
68
- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
69
- | `defineAssert` | `{ <T extends AssertConfig>(config: T): T; <T extends AssertConfig>(config: AssertFn<T>): AssertFn<T>; <T extends AssertConfig>(config: AssertFnOrObject<T>): AssertFnOrObject<...>; }` |
67
+ | Function | Type |
68
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
69
+ | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
70
70
 
71
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assert.config.ts#L54)
71
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L52)
72
72
 
73
73
  #### :gear: defineAssert
74
74
 
75
- | Function | Type |
76
- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
77
- | `defineAssert` | `{ <T extends AssertConfig>(config: T): T; <T extends AssertConfig>(config: AssertFn<T>): AssertFn<T>; <T extends AssertConfig>(config: AssertFnOrObject<T>): AssertFnOrObject<...>; }` |
75
+ | Function | Type |
76
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
77
+ | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
78
78
 
79
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assert.config.ts#L55)
79
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L53)
80
80
 
81
81
  #### :gear: defineAssert
82
82
 
83
- | Function | Type |
84
- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
85
- | `defineAssert` | `{ <T extends AssertConfig>(config: T): T; <T extends AssertConfig>(config: AssertFn<T>): AssertFn<T>; <T extends AssertConfig>(config: AssertFnOrObject<T>): AssertFnOrObject<...>; }` |
83
+ | Function | Type |
84
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
85
+ | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
86
86
 
87
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assert.config.ts#L58)
87
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L54)
88
88
 
89
89
  #### :gear: HookFnSchema
90
90
 
91
- | Function | Type |
92
- | -------------- | --------------------------------------------------------------------------------------------------------------------------- |
93
- | `HookFnSchema` | `<T extends z.ZodTypeAny>(hookConfigSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>` |
91
+ | Function | Type |
92
+ | -------------- | --------------------------------------------------------------------------------------------------------------------- |
93
+ | `HookFnSchema` | `<T extends z.ZodTypeAny>(hookSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>` |
94
94
 
95
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hook.config.ts#L43)
95
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L43)
96
96
 
97
97
  #### :gear: HookFnOrObjectSchema
98
98
 
99
- | Function | Type |
100
- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
101
- | `HookFnOrObjectSchema` | `<T extends z.ZodTypeAny>(hookConfigSchema: T) => ZodUnion<[T, ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>]>` |
99
+ | Function | Type |
100
+ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
101
+ | `HookFnOrObjectSchema` | `<T extends z.ZodTypeAny>(hookSchema: T) => ZodUnion<[T, ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>]>` |
102
102
 
103
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hook.config.ts#L47)
103
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L47)
104
104
 
105
105
  #### :gear: defineHook
106
106
 
107
- | Function | Type |
108
- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
109
- | `defineHook` | `{ <T extends HookConfig>(config: T): T; <T extends HookConfig>(config: HookFn<T>): HookFn<T>; <T extends HookConfig>(config: HookFnOrObject<T>): HookFnOrObject<T>; }` |
107
+ | Function | Type |
108
+ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
109
+ | `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |
110
110
 
111
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hook.config.ts#L51)
111
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L51)
112
112
 
113
113
  #### :gear: defineHook
114
114
 
115
- | Function | Type |
116
- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
117
- | `defineHook` | `{ <T extends HookConfig>(config: T): T; <T extends HookConfig>(config: HookFn<T>): HookFn<T>; <T extends HookConfig>(config: HookFnOrObject<T>): HookFnOrObject<T>; }` |
115
+ | Function | Type |
116
+ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
117
+ | `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |
118
118
 
119
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hook.config.ts#L52)
119
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L52)
120
120
 
121
121
  #### :gear: defineHook
122
122
 
123
- | Function | Type |
124
- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
125
- | `defineHook` | `{ <T extends HookConfig>(config: T): T; <T extends HookConfig>(config: HookFn<T>): HookFn<T>; <T extends HookConfig>(config: HookFnOrObject<T>): HookFnOrObject<T>; }` |
123
+ | Function | Type |
124
+ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
125
+ | `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |
126
126
 
127
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hook.config.ts#L53)
127
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L53)
128
128
 
129
129
  #### :gear: defineHook
130
130
 
131
- | Function | Type |
132
- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
133
- | `defineHook` | `{ <T extends HookConfig>(config: T): T; <T extends HookConfig>(config: HookFn<T>): HookFn<T>; <T extends HookConfig>(config: HookFnOrObject<T>): HookFnOrObject<T>; }` |
131
+ | Function | Type |
132
+ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
133
+ | `defineHook` | `{ <T extends Hook>(hook: T): T; <T extends Hook>(hook: HookFn<T>): HookFn<T>; <T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>; }` |
134
134
 
135
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hook.config.ts#L54)
135
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L54)
136
136
 
137
137
  #### :gear: decodeDocData
138
138
 
139
- | Function | Type |
140
- | --------------- | ----------------------------------------- |
141
- | `decodeDocData` | `<T>(data: Uint8Array<ArrayBuffer>) => T` |
139
+ Decodes the raw data of a document into a JavaScript object.
142
140
 
143
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/datastore.sdk.ts#L4)
141
+ | Function | Type |
142
+ | --------------- | --------------------------------------------- |
143
+ | `decodeDocData` | `<T>(data: Uint8Array<ArrayBufferLike>) => T` |
144
+
145
+ Parameters:
146
+
147
+ - `data`: - The raw data to be decoded.
148
+
149
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/serializer.sdk.ts#L11)
144
150
 
145
151
  #### :gear: encodeDocData
146
152
 
147
- | Function | Type |
148
- | --------------- | ----------------------------------------- |
149
- | `encodeDocData` | `<T>(data: T) => Uint8Array<ArrayBuffer>` |
153
+ Encodes a JavaScript object into a raw data format to be applied to a document.
154
+
155
+ | Function | Type |
156
+ | --------------- | --------------------------------------------- |
157
+ | `encodeDocData` | `<T>(data: T) => Uint8Array<ArrayBufferLike>` |
158
+
159
+ Parameters:
150
160
 
151
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/datastore.sdk.ts#L7)
161
+ - `data`: - The data to be encoded.
162
+
163
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/serializer.sdk.ts#L21)
152
164
 
153
165
  ### :wrench: Constants
154
166
 
@@ -157,20 +169,21 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
157
169
  - [RawDataSchema](#gear-rawdataschema)
158
170
  - [RawPrincipalSchema](#gear-rawprincipalschema)
159
171
  - [RawUserIdSchema](#gear-rawuseridschema)
172
+ - [CollectionSchema](#gear-collectionschema)
173
+ - [KeySchema](#gear-keyschema)
160
174
  - [DocDescriptionSchema](#gear-docdescriptionschema)
161
175
  - [DocSchema](#gear-docschema)
162
176
  - [DocUpsertSchema](#gear-docupsertschema)
163
177
  - [ProposedDocSchema](#gear-proposeddocschema)
164
178
  - [DocAssertSetSchema](#gear-docassertsetschema)
165
- - [SetDocSchema](#gear-setdocschema)
166
179
  - [OnSetDocContextSchema](#gear-onsetdoccontextschema)
167
180
  - [AssertSetDocContextSchema](#gear-assertsetdoccontextschema)
168
181
  - [CollectionsConfigSchema](#gear-collectionsconfigschema)
169
- - [SatelliteConfigEnvSchema](#gear-satelliteconfigenvschema)
170
- - [AssertSetDocConfigSchema](#gear-assertsetdocconfigschema)
171
- - [AssertConfigSchema](#gear-assertconfigschema)
172
- - [OnSetDocConfigSchema](#gear-onsetdocconfigschema)
173
- - [HookConfigSchema](#gear-hookconfigschema)
182
+ - [SatelliteEnvSchema](#gear-satelliteenvschema)
183
+ - [AssertSetDocSchema](#gear-assertsetdocschema)
184
+ - [AssertSchema](#gear-assertschema)
185
+ - [OnSetDocSchema](#gear-onsetdocschema)
186
+ - [HookSchema](#gear-hookschema)
174
187
 
175
188
  #### :gear: TimestampSchema
176
189
 
@@ -190,9 +203,9 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
190
203
 
191
204
  #### :gear: RawDataSchema
192
205
 
193
- | Constant | Type |
194
- | --------------- | ----------------------------------------------------------------------- |
195
- | `RawDataSchema` | `ZodType<Uint8Array<ArrayBuffer>, ZodTypeDef, Uint8Array<ArrayBuffer>>` |
206
+ | Constant | Type |
207
+ | --------------- | ------------------------------------------------------------------------------- |
208
+ | `RawDataSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
196
209
 
197
210
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L30)
198
211
 
@@ -202,7 +215,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
202
215
  | -------------------- | ------------------------------------------------------------------------------- |
203
216
  | `RawPrincipalSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
204
217
 
205
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L42)
218
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L44)
206
219
 
207
220
  #### :gear: RawUserIdSchema
208
221
 
@@ -210,7 +223,23 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
210
223
  | ----------------- | ------------------------------------------------------------------------------- |
211
224
  | `RawUserIdSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
212
225
 
213
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L56)
226
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L58)
227
+
228
+ #### :gear: CollectionSchema
229
+
230
+ | Constant | Type |
231
+ | ------------------ | ----------- |
232
+ | `CollectionSchema` | `ZodString` |
233
+
234
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L70)
235
+
236
+ #### :gear: KeySchema
237
+
238
+ | Constant | Type |
239
+ | ----------- | ----------- |
240
+ | `KeySchema` | `ZodString` |
241
+
242
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L80)
214
243
 
215
244
  #### :gear: DocDescriptionSchema
216
245
 
@@ -238,9 +267,9 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
238
267
 
239
268
  #### :gear: ProposedDocSchema
240
269
 
241
- | Constant | Type |
242
- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
243
- | `ProposedDocSchema` | `ZodObject<{ data: ZodType<Uint8Array<ArrayBuffer>, ZodTypeDef, Uint8Array<ArrayBuffer>>; description: ZodOptional<ZodString>; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
270
+ | Constant | Type |
271
+ | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
272
+ | `ProposedDocSchema` | `ZodObject<{ data: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; description: ZodOptional<...>; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
244
273
 
245
274
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L85)
246
275
 
@@ -252,14 +281,6 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
252
281
 
253
282
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L113)
254
283
 
255
- #### :gear: SetDocSchema
256
-
257
- | Constant | Type |
258
- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
259
- | `SetDocSchema` | `ZodObject<{ data: ZodType<Uint8Array<ArrayBuffer>, ZodTypeDef, Uint8Array<ArrayBuffer>>; description: ZodOptional<ZodString>; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
260
-
261
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L140)
262
-
263
284
  #### :gear: OnSetDocContextSchema
264
285
 
265
286
  | Constant | Type |
@@ -278,60 +299,51 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
278
299
 
279
300
  #### :gear: CollectionsConfigSchema
280
301
 
281
- Defines the collections where a hook or assertion should run.
282
-
283
302
  | Constant | Type |
284
303
  | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
285
304
  | `CollectionsConfigSchema` | `ZodObject<{ collections: ZodArray<ZodString, "many">; }, "strict", ZodTypeAny, { collections: string[]; }, { collections: string[]; }>` |
286
305
 
287
306
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/collections.config.ts#L6)
288
307
 
289
- #### :gear: SatelliteConfigEnvSchema
308
+ #### :gear: SatelliteEnvSchema
290
309
 
291
- Placeholder for future environment-specific configurations.
292
-
293
- Currently unused, but it may support features such as:
310
+ | Constant | Type |
311
+ | -------------------- | ---------------------------------- |
312
+ | `SatelliteEnvSchema` | `ZodRecord<ZodString, ZodUnknown>` |
294
313
 
295
- - Defining the execution mode (e.g., staging or production).
296
- - Providing environment-specific values like `ckBtcLedgerId` for test or production.
314
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.env.ts#L6)
297
315
 
298
- | Constant | Type |
299
- | -------------------------- | ---------------------------------- |
300
- | `SatelliteConfigEnvSchema` | `ZodRecord<ZodString, ZodUnknown>` |
316
+ #### :gear: AssertSetDocSchema
301
317
 
302
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.config.ts#L10)
318
+ | Constant | Type |
319
+ | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
320
+ | `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, { ...; }, {...` |
303
321
 
304
- #### :gear: AssertSetDocConfigSchema
322
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L25)
305
323
 
306
- | Constant | Type |
307
- | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
308
- | `AssertSetDocConfigSchema` | `ZodObject<extendShape<{ collections: ZodArray<ZodString, "many">; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodPromise<...>>; }>, "strict", ZodTypeAny, { ....` |
324
+ #### :gear: AssertSchema
309
325
 
310
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assert.config.ts#L25)
326
+ | Constant | Type |
327
+ | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
328
+ | `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, { ...; }, {...` |
311
329
 
312
- #### :gear: AssertConfigSchema
330
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L36)
313
331
 
314
- | Constant | Type |
315
- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
316
- | `AssertConfigSchema` | `ZodObject<extendShape<{ collections: ZodArray<ZodString, "many">; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodPromise<...>>; }>, "strict", ZodTypeAny, { ....` |
332
+ #### :gear: OnSetDocSchema
317
333
 
318
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assert.config.ts#L36)
334
+ | Constant | Type |
335
+ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
336
+ | `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, { ...;...` |
319
337
 
320
- #### :gear: OnSetDocConfigSchema
338
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L25)
321
339
 
322
- | Constant | Type |
323
- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
324
- | `OnSetDocConfigSchema` | `ZodObject<extendShape<{ collections: ZodArray<ZodString, "many">; }, { run: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodPromise<...>>; }>, "strict", ZodTypeAny, { ...;...` |
340
+ #### :gear: HookSchema
325
341
 
326
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hook.config.ts#L25)
342
+ | Constant | Type |
343
+ | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
344
+ | `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, { ...;...` |
327
345
 
328
- #### :gear: HookConfigSchema
329
-
330
- | Constant | Type |
331
- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
332
- | `HookConfigSchema` | `ZodObject<extendShape<{ collections: ZodArray<ZodString, "many">; }, { run: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodPromise<...>>; }>, "strict", ZodTypeAny, { ...;...` |
333
-
334
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hook.config.ts#L36)
346
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L36)
335
347
 
336
348
  ### :cocktail: Types
337
349
 
@@ -340,24 +352,25 @@ Currently unused, but it may support features such as:
340
352
  - [RawData](#gear-rawdata)
341
353
  - [RawPrincipal](#gear-rawprincipal)
342
354
  - [RawUserId](#gear-rawuserid)
355
+ - [Collection](#gear-collection)
356
+ - [Key](#gear-key)
343
357
  - [DocDescription](#gear-docdescription)
344
358
  - [Doc](#gear-doc)
345
359
  - [DocUpsert](#gear-docupsert)
346
360
  - [ProposedDoc](#gear-proposeddoc)
347
361
  - [DocAssertSet](#gear-docassertset)
348
- - [SetDoc](#gear-setdoc)
349
362
  - [HookContext](#gear-hookcontext)
350
363
  - [DocContext](#gear-doccontext)
351
364
  - [OnSetDocContext](#gear-onsetdoccontext)
352
365
  - [AssertSetDocContext](#gear-assertsetdoccontext)
353
366
  - [CollectionsConfig](#gear-collectionsconfig)
354
- - [SatelliteConfigEnv](#gear-satelliteconfigenv)
355
- - [AssertSetDocConfig](#gear-assertsetdocconfig)
356
- - [AssertConfig](#gear-assertconfig)
367
+ - [SatelliteEnv](#gear-satelliteenv)
368
+ - [AssertSetDoc](#gear-assertsetdoc)
369
+ - [Assert](#gear-assert)
357
370
  - [AssertFn](#gear-assertfn)
358
371
  - [AssertFnOrObject](#gear-assertfnorobject)
359
- - [OnSetDocConfig](#gear-onsetdocconfig)
360
- - [HookConfig](#gear-hookconfig)
372
+ - [OnSetDoc](#gear-onsetdoc)
373
+ - [Hook](#gear-hook)
361
374
  - [HookFn](#gear-hookfn)
362
375
  - [HookFnOrObject](#gear-hookfnorobject)
363
376
 
@@ -395,7 +408,7 @@ This is used to store unstructured data in a document.
395
408
  | --------- | ------------------------------- |
396
409
  | `RawData` | `z.infer<typeof RawDataSchema>` |
397
410
 
398
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L37)
411
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L39)
399
412
 
400
413
  #### :gear: RawPrincipal
401
414
 
@@ -407,7 +420,7 @@ Principals are unique identities used in authentication and authorization.
407
420
  | -------------- | ------------------------------------ |
408
421
  | `RawPrincipal` | `z.infer<typeof RawPrincipalSchema>` |
409
422
 
410
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L51)
423
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L53)
411
424
 
412
425
  #### :gear: RawUserId
413
426
 
@@ -419,7 +432,27 @@ This is a principal associated with a user.
419
432
  | ----------- | --------------------------------- |
420
433
  | `RawUserId` | `z.infer<typeof RawUserIdSchema>` |
421
434
 
422
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L63)
435
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L65)
436
+
437
+ #### :gear: Collection
438
+
439
+ A collection name where data are stored.
440
+
441
+ | Type | Type |
442
+ | ------------ | ---------------------------------- |
443
+ | `Collection` | `z.infer<typeof CollectionSchema>` |
444
+
445
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L75)
446
+
447
+ #### :gear: Key
448
+
449
+ A unique key identifier within a collection.
450
+
451
+ | Type | Type |
452
+ | ----- | --------------------------- |
453
+ | `Key` | `z.infer<typeof KeySchema>` |
454
+
455
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L85)
423
456
 
424
457
  #### :gear: DocDescription
425
458
 
@@ -477,18 +510,6 @@ throw an error if their validation fails.
477
510
 
478
511
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L135)
479
512
 
480
- #### :gear: SetDoc
481
-
482
- Represents a request to set or update a document.
483
-
484
- This is used when submitting new document data.
485
-
486
- | Type | Type |
487
- | -------- | ------------------------------ |
488
- | `SetDoc` | `z.infer<typeof SetDocSchema>` |
489
-
490
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L165)
491
-
492
513
  #### :gear: HookContext
493
514
 
494
515
  Represents the context provided to hooks, containing information about the caller and related data.
@@ -537,47 +558,56 @@ it is created or updated. If validation fails, the developer should throw an err
537
558
 
538
559
  #### :gear: CollectionsConfig
539
560
 
561
+ Defines the collections where a hook or assertion should run.
562
+
540
563
  | Type | Type |
541
564
  | ------------------- | ----------------------------------------- |
542
565
  | `CollectionsConfig` | `z.infer<typeof CollectionsConfigSchema>` |
543
566
 
544
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/collections.config.ts#L16)
545
-
546
- #### :gear: SatelliteConfigEnv
567
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/collections.config.ts#L18)
547
568
 
548
- | Type | Type |
549
- | -------------------- | ------------------------------------------ |
550
- | `SatelliteConfigEnv` | `z.infer<typeof SatelliteConfigEnvSchema>` |
569
+ #### :gear: SatelliteEnv
551
570
 
552
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.config.ts#L13)
571
+ Placeholder for future environment-specific configurations.
553
572
 
554
- #### :gear: AssertSetDocConfig
573
+ Currently unused, but it may support features such as:
555
574
 
556
- Configuration schema for an assertion that runs when a document is created or updated.
575
+ - Defining the execution mode (e.g., staging or production).
576
+ - Providing environment-specific values like `ckBtcLedgerId` for test or production.
557
577
 
558
- | Type | Type |
559
- | -------------------- | ------------------------------------------ |
560
- | `AssertSetDocConfig` | `z.infer<typeof AssertSetDocConfigSchema>` |
578
+ | Type | Type |
579
+ | -------------- | ------------------------------------ |
580
+ | `SatelliteEnv` | `z.infer<typeof SatelliteEnvSchema>` |
561
581
 
562
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assert.config.ts#L30)
582
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.env.ts#L15)
563
583
 
564
- #### :gear: AssertConfig
584
+ #### :gear: AssertSetDoc
565
585
 
566
- All possible config for assertions.
586
+ An assertion that runs when a document is created or updated.
567
587
 
568
588
  | Type | Type |
569
589
  | -------------- | ------------------------------------ |
570
- | `AssertConfig` | `z.infer<typeof AssertConfigSchema>` |
590
+ | `AssertSetDoc` | `z.infer<typeof AssertSetDocSchema>` |
591
+
592
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L30)
593
+
594
+ #### :gear: Assert
571
595
 
572
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assert.config.ts#L41)
596
+ All assertions definitions.
597
+
598
+ | Type | Type |
599
+ | -------- | ------------------------------ |
600
+ | `Assert` | `z.infer<typeof AssertSchema>` |
601
+
602
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L41)
573
603
 
574
604
  #### :gear: AssertFn
575
605
 
576
- | Type | Type |
577
- | ---------- | ----------------------------------------------------------- |
578
- | `AssertFn` | `( config: z.infer<typeof SatelliteConfigEnvSchema> ) => T` |
606
+ | Type | Type |
607
+ | ---------- | --------------------------------------------------- |
608
+ | `AssertFn` | `(assert: z.infer<typeof SatelliteEnvSchema>) => T` |
579
609
 
580
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assert.config.ts#L45)
610
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L45)
581
611
 
582
612
  #### :gear: AssertFnOrObject
583
613
 
@@ -585,35 +615,35 @@ All possible config for assertions.
585
615
  | ------------------ | ------------------ |
586
616
  | `AssertFnOrObject` | `T or AssertFn<T>` |
587
617
 
588
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assert.config.ts#L51)
618
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L49)
589
619
 
590
- #### :gear: OnSetDocConfig
620
+ #### :gear: OnSetDoc
591
621
 
592
- Configuration for a hook that runs when a document is created or updated.
622
+ A hook that runs when a document is created or updated.
593
623
 
594
- | Type | Type |
595
- | ---------------- | -------------------------------------- |
596
- | `OnSetDocConfig` | `z.infer<typeof OnSetDocConfigSchema>` |
624
+ | Type | Type |
625
+ | ---------- | -------------------------------- |
626
+ | `OnSetDoc` | `z.infer<typeof OnSetDocSchema>` |
597
627
 
598
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hook.config.ts#L30)
628
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L30)
599
629
 
600
- #### :gear: HookConfig
630
+ #### :gear: Hook
601
631
 
602
- All possible config for assertions.
632
+ All hooks definitions.
603
633
 
604
- | Type | Type |
605
- | ------------ | ---------------------------------- |
606
- | `HookConfig` | `z.infer<typeof HookConfigSchema>` |
634
+ | Type | Type |
635
+ | ------ | ---------------------------- |
636
+ | `Hook` | `z.infer<typeof HookSchema>` |
607
637
 
608
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hook.config.ts#L41)
638
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L41)
609
639
 
610
640
  #### :gear: HookFn
611
641
 
612
- | Type | Type |
613
- | -------- | --------------------------------------------------------- |
614
- | `HookFn` | `(config: z.infer<typeof SatelliteConfigEnvSchema>) => T` |
642
+ | Type | Type |
643
+ | -------- | ------------------------------------------------- |
644
+ | `HookFn` | `(hook: z.infer<typeof SatelliteEnvSchema>) => T` |
615
645
 
616
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hook.config.ts#L45)
646
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L45)
617
647
 
618
648
  #### :gear: HookFnOrObject
619
649
 
@@ -621,7 +651,7 @@ All possible config for assertions.
621
651
  | ---------------- | ---------------- |
622
652
  | `HookFnOrObject` | `T or HookFn<T>` |
623
653
 
624
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hook.config.ts#L49)
654
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L49)
625
655
 
626
656
  <!-- TSDOC_END -->
627
657