@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 +202 -172
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/types/configs/{assert.config.d.ts → assertions.d.ts} +80 -80
- package/dist/types/configs/collections.config.d.ts +4 -2
- package/dist/types/configs/{hook.config.d.ts → hooks.d.ts} +72 -72
- package/dist/types/configs/{satellite.config.d.ts → satellite.env.d.ts} +5 -3
- package/dist/types/global.d.ts +9 -1
- package/dist/types/hooks/context.d.ts +44 -44
- package/dist/types/hooks/core.d.ts +17 -1
- package/dist/types/hooks/datastore.d.ts +26 -58
- package/dist/types/hooks/sdk.d.ts +109 -0
- package/dist/types/index.d.ts +4 -4
- package/dist/types/sdk/datastore.sdk.d.ts +13 -3
- package/dist/types/sdk/serializer.sdk.d.ts +17 -0
- package/package.json +4 -4
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>(
|
|
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/
|
|
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>(
|
|
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/
|
|
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
|
|
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/
|
|
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
|
|
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/
|
|
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
|
|
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/
|
|
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
|
|
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/
|
|
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>(
|
|
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/
|
|
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>(
|
|
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/
|
|
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
|
|
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/
|
|
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
|
|
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/
|
|
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
|
|
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/
|
|
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
|
|
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/
|
|
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
|
-
|
|
140
|
-
| --------------- | ----------------------------------------- |
|
|
141
|
-
| `decodeDocData` | `<T>(data: Uint8Array<ArrayBuffer>) => T` |
|
|
139
|
+
Decodes the raw data of a document into a JavaScript object.
|
|
142
140
|
|
|
143
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
|
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
|
-
|
|
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
|
-
- [
|
|
170
|
-
- [
|
|
171
|
-
- [
|
|
172
|
-
- [
|
|
173
|
-
- [
|
|
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<
|
|
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#
|
|
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#
|
|
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<
|
|
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:
|
|
308
|
+
#### :gear: SatelliteEnvSchema
|
|
290
309
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
310
|
+
| Constant | Type |
|
|
311
|
+
| -------------------- | ---------------------------------- |
|
|
312
|
+
| `SatelliteEnvSchema` | `ZodRecord<ZodString, ZodUnknown>` |
|
|
294
313
|
|
|
295
|
-
|
|
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
|
-
|
|
299
|
-
| -------------------------- | ---------------------------------- |
|
|
300
|
-
| `SatelliteConfigEnvSchema` | `ZodRecord<ZodString, ZodUnknown>` |
|
|
316
|
+
#### :gear: AssertSetDocSchema
|
|
301
317
|
|
|
302
|
-
|
|
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
|
-
|
|
322
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L25)
|
|
305
323
|
|
|
306
|
-
|
|
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
|
-
|
|
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
|
-
|
|
330
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L36)
|
|
313
331
|
|
|
314
|
-
|
|
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
|
-
|
|
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
|
-
|
|
338
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L25)
|
|
321
339
|
|
|
322
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
- [
|
|
355
|
-
- [
|
|
356
|
-
- [
|
|
367
|
+
- [SatelliteEnv](#gear-satelliteenv)
|
|
368
|
+
- [AssertSetDoc](#gear-assertsetdoc)
|
|
369
|
+
- [Assert](#gear-assert)
|
|
357
370
|
- [AssertFn](#gear-assertfn)
|
|
358
371
|
- [AssertFnOrObject](#gear-assertfnorobject)
|
|
359
|
-
- [
|
|
360
|
-
- [
|
|
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#
|
|
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#
|
|
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#
|
|
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#
|
|
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
|
-
|
|
549
|
-
| -------------------- | ------------------------------------------ |
|
|
550
|
-
| `SatelliteConfigEnv` | `z.infer<typeof SatelliteConfigEnvSchema>` |
|
|
569
|
+
#### :gear: SatelliteEnv
|
|
551
570
|
|
|
552
|
-
|
|
571
|
+
Placeholder for future environment-specific configurations.
|
|
553
572
|
|
|
554
|
-
|
|
573
|
+
Currently unused, but it may support features such as:
|
|
555
574
|
|
|
556
|
-
|
|
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
|
|
559
|
-
|
|
|
560
|
-
| `
|
|
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/
|
|
582
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.env.ts#L15)
|
|
563
583
|
|
|
564
|
-
#### :gear:
|
|
584
|
+
#### :gear: AssertSetDoc
|
|
565
585
|
|
|
566
|
-
|
|
586
|
+
An assertion that runs when a document is created or updated.
|
|
567
587
|
|
|
568
588
|
| Type | Type |
|
|
569
589
|
| -------------- | ------------------------------------ |
|
|
570
|
-
| `
|
|
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
|
-
|
|
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` | `(
|
|
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/
|
|
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/
|
|
618
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L49)
|
|
589
619
|
|
|
590
|
-
#### :gear:
|
|
620
|
+
#### :gear: OnSetDoc
|
|
591
621
|
|
|
592
|
-
|
|
622
|
+
A hook that runs when a document is created or updated.
|
|
593
623
|
|
|
594
|
-
| Type
|
|
595
|
-
|
|
|
596
|
-
| `
|
|
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/
|
|
628
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L30)
|
|
599
629
|
|
|
600
|
-
#### :gear:
|
|
630
|
+
#### :gear: Hook
|
|
601
631
|
|
|
602
|
-
All
|
|
632
|
+
All hooks definitions.
|
|
603
633
|
|
|
604
|
-
| Type
|
|
605
|
-
|
|
|
606
|
-
| `
|
|
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/
|
|
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` | `(
|
|
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/
|
|
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/
|
|
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
|
|