@junobuild/functions 0.0.3 → 0.0.5
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 +424 -195
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/types/configs/assertions.d.ts +439 -0
- package/dist/types/configs/collections.config.d.ts +18 -0
- package/dist/types/configs/hooks.d.ts +505 -0
- package/dist/types/configs/{satellite.config.d.ts → satellite.env.d.ts} +6 -1
- package/dist/types/hooks/context.d.ts +475 -16
- package/dist/types/hooks/core.d.ts +26 -5
- package/dist/types/hooks/datastore.d.ts +324 -45
- package/dist/types/index.d.ts +7 -7
- package/package.json +3 -2
- package/dist/types/configs/assert.config.d.ts +0 -30
- package/dist/types/configs/collection.config.d.ts +0 -9
- package/dist/types/configs/hook.config.d.ts +0 -28
package/README.md
CHANGED
|
@@ -14,10 +14,15 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
|
|
|
14
14
|
|
|
15
15
|
### :toolbox: Functions
|
|
16
16
|
|
|
17
|
+
- [DocContextSchema](#gear-doccontextschema)
|
|
18
|
+
- [AssertFnSchema](#gear-assertfnschema)
|
|
19
|
+
- [AssertFnOrObjectSchema](#gear-assertfnorobjectschema)
|
|
17
20
|
- [defineAssert](#gear-defineassert)
|
|
18
21
|
- [defineAssert](#gear-defineassert)
|
|
19
22
|
- [defineAssert](#gear-defineassert)
|
|
20
23
|
- [defineAssert](#gear-defineassert)
|
|
24
|
+
- [HookFnSchema](#gear-hookfnschema)
|
|
25
|
+
- [HookFnOrObjectSchema](#gear-hookfnorobjectschema)
|
|
21
26
|
- [defineHook](#gear-definehook)
|
|
22
27
|
- [defineHook](#gear-definehook)
|
|
23
28
|
- [defineHook](#gear-definehook)
|
|
@@ -25,252 +30,339 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
|
|
|
25
30
|
- [decodeDocData](#gear-decodedocdata)
|
|
26
31
|
- [encodeDocData](#gear-encodedocdata)
|
|
27
32
|
|
|
33
|
+
#### :gear: DocContextSchema
|
|
34
|
+
|
|
35
|
+
| Function | Type |
|
|
36
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
37
|
+
| `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
|
+
|
|
39
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#L33)
|
|
40
|
+
|
|
41
|
+
#### :gear: AssertFnSchema
|
|
42
|
+
|
|
43
|
+
| Function | Type |
|
|
44
|
+
| ---------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
45
|
+
| `AssertFnSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>` |
|
|
46
|
+
|
|
47
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L43)
|
|
48
|
+
|
|
49
|
+
#### :gear: AssertFnOrObjectSchema
|
|
50
|
+
|
|
51
|
+
| Function | Type |
|
|
52
|
+
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
53
|
+
| `AssertFnOrObjectSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodUnion<[T, ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>]>` |
|
|
54
|
+
|
|
55
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L47)
|
|
56
|
+
|
|
28
57
|
#### :gear: defineAssert
|
|
29
58
|
|
|
30
|
-
| Function | Type
|
|
31
|
-
| -------------- |
|
|
32
|
-
| `defineAssert` | `{ (
|
|
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>; }` |
|
|
33
62
|
|
|
34
|
-
[: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)
|
|
35
64
|
|
|
36
65
|
#### :gear: defineAssert
|
|
37
66
|
|
|
38
|
-
| Function | Type
|
|
39
|
-
| -------------- |
|
|
40
|
-
| `defineAssert` | `{ (
|
|
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>; }` |
|
|
41
70
|
|
|
42
|
-
[: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)
|
|
43
72
|
|
|
44
73
|
#### :gear: defineAssert
|
|
45
74
|
|
|
46
|
-
| Function | Type
|
|
47
|
-
| -------------- |
|
|
48
|
-
| `defineAssert` | `{ (
|
|
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>; }` |
|
|
49
78
|
|
|
50
|
-
[: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)
|
|
51
80
|
|
|
52
81
|
#### :gear: defineAssert
|
|
53
82
|
|
|
54
|
-
| Function | Type
|
|
55
|
-
| -------------- |
|
|
56
|
-
| `defineAssert` | `{ (
|
|
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
|
+
|
|
87
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L54)
|
|
57
88
|
|
|
58
|
-
|
|
89
|
+
#### :gear: HookFnSchema
|
|
90
|
+
|
|
91
|
+
| Function | Type |
|
|
92
|
+
| -------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
93
|
+
| `HookFnSchema` | `<T extends z.ZodTypeAny>(hookSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>` |
|
|
94
|
+
|
|
95
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L43)
|
|
96
|
+
|
|
97
|
+
#### :gear: HookFnOrObjectSchema
|
|
98
|
+
|
|
99
|
+
| Function | Type |
|
|
100
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
101
|
+
| `HookFnOrObjectSchema` | `<T extends z.ZodTypeAny>(hookSchema: T) => ZodUnion<[T, ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>]>` |
|
|
102
|
+
|
|
103
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L47)
|
|
59
104
|
|
|
60
105
|
#### :gear: defineHook
|
|
61
106
|
|
|
62
|
-
| Function | Type
|
|
63
|
-
| ------------ |
|
|
64
|
-
| `defineHook` | `{ (
|
|
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>; }` |
|
|
65
110
|
|
|
66
|
-
[: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)
|
|
67
112
|
|
|
68
113
|
#### :gear: defineHook
|
|
69
114
|
|
|
70
|
-
| Function | Type
|
|
71
|
-
| ------------ |
|
|
72
|
-
| `defineHook` | `{ (
|
|
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>; }` |
|
|
73
118
|
|
|
74
|
-
[: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)
|
|
75
120
|
|
|
76
121
|
#### :gear: defineHook
|
|
77
122
|
|
|
78
|
-
| Function | Type
|
|
79
|
-
| ------------ |
|
|
80
|
-
| `defineHook` | `{ (
|
|
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>; }` |
|
|
81
126
|
|
|
82
|
-
[: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)
|
|
83
128
|
|
|
84
129
|
#### :gear: defineHook
|
|
85
130
|
|
|
86
|
-
| Function | Type
|
|
87
|
-
| ------------ |
|
|
88
|
-
| `defineHook` | `{ (
|
|
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>; }` |
|
|
89
134
|
|
|
90
|
-
[: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)
|
|
91
136
|
|
|
92
137
|
#### :gear: decodeDocData
|
|
93
138
|
|
|
94
|
-
| Function | Type
|
|
95
|
-
| --------------- |
|
|
96
|
-
| `decodeDocData` | `<T>(data:
|
|
139
|
+
| Function | Type |
|
|
140
|
+
| --------------- | --------------------------------------------- |
|
|
141
|
+
| `decodeDocData` | `<T>(data: Uint8Array<ArrayBufferLike>) => T` |
|
|
97
142
|
|
|
98
143
|
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/datastore.sdk.ts#L4)
|
|
99
144
|
|
|
100
145
|
#### :gear: encodeDocData
|
|
101
146
|
|
|
102
|
-
| Function | Type
|
|
103
|
-
| --------------- |
|
|
104
|
-
| `encodeDocData` | `<T>(data: T) =>
|
|
147
|
+
| Function | Type |
|
|
148
|
+
| --------------- | --------------------------------------------- |
|
|
149
|
+
| `encodeDocData` | `<T>(data: T) => Uint8Array<ArrayBufferLike>` |
|
|
105
150
|
|
|
106
151
|
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/datastore.sdk.ts#L7)
|
|
107
152
|
|
|
108
|
-
### :
|
|
153
|
+
### :wrench: Constants
|
|
154
|
+
|
|
155
|
+
- [TimestampSchema](#gear-timestampschema)
|
|
156
|
+
- [VersionSchema](#gear-versionschema)
|
|
157
|
+
- [RawDataSchema](#gear-rawdataschema)
|
|
158
|
+
- [RawPrincipalSchema](#gear-rawprincipalschema)
|
|
159
|
+
- [RawUserIdSchema](#gear-rawuseridschema)
|
|
160
|
+
- [DocDescriptionSchema](#gear-docdescriptionschema)
|
|
161
|
+
- [DocSchema](#gear-docschema)
|
|
162
|
+
- [DocUpsertSchema](#gear-docupsertschema)
|
|
163
|
+
- [ProposedDocSchema](#gear-proposeddocschema)
|
|
164
|
+
- [DocAssertSetSchema](#gear-docassertsetschema)
|
|
165
|
+
- [SetDocSchema](#gear-setdocschema)
|
|
166
|
+
- [OnSetDocContextSchema](#gear-onsetdoccontextschema)
|
|
167
|
+
- [AssertSetDocContextSchema](#gear-assertsetdoccontextschema)
|
|
168
|
+
- [CollectionsConfigSchema](#gear-collectionsconfigschema)
|
|
169
|
+
- [SatelliteEnvSchema](#gear-satelliteenvschema)
|
|
170
|
+
- [AssertSetDocSchema](#gear-assertsetdocschema)
|
|
171
|
+
- [AssertSchema](#gear-assertschema)
|
|
172
|
+
- [OnSetDocSchema](#gear-onsetdocschema)
|
|
173
|
+
- [HookSchema](#gear-hookschema)
|
|
174
|
+
|
|
175
|
+
#### :gear: TimestampSchema
|
|
176
|
+
|
|
177
|
+
| Constant | Type |
|
|
178
|
+
| ----------------- | ----------- |
|
|
179
|
+
| `TimestampSchema` | `ZodBigInt` |
|
|
109
180
|
|
|
110
|
-
|
|
111
|
-
- [DocUpsert](#gear-docupsert)
|
|
112
|
-
- [DocAssertSet](#gear-docassertset)
|
|
113
|
-
- [Doc](#gear-doc)
|
|
114
|
-
- [SetDoc](#gear-setdoc)
|
|
115
|
-
- [HookContext](#gear-hookcontext)
|
|
116
|
-
- [DocContext](#gear-doccontext)
|
|
117
|
-
- [AssertAssertConfig](#gear-assertassertconfig)
|
|
118
|
-
- [AssertSetDocConfig](#gear-assertsetdocconfig)
|
|
119
|
-
- [OnHookConfig](#gear-onhookconfig)
|
|
120
|
-
- [OnSetDocConfig](#gear-onsetdocconfig)
|
|
181
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L6)
|
|
121
182
|
|
|
122
|
-
#### :gear:
|
|
183
|
+
#### :gear: VersionSchema
|
|
123
184
|
|
|
124
|
-
|
|
185
|
+
| Constant | Type |
|
|
186
|
+
| --------------- | ----------- |
|
|
187
|
+
| `VersionSchema` | `ZodBigInt` |
|
|
125
188
|
|
|
126
|
-
|
|
127
|
-
| ------------- | ---------- | ------------------------------------------------------------------------ |
|
|
128
|
-
| `collections` | `string[]` | A list of collection names where the hook or assertion will be executed. |
|
|
189
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L18)
|
|
129
190
|
|
|
130
|
-
#### :gear:
|
|
191
|
+
#### :gear: RawDataSchema
|
|
131
192
|
|
|
132
|
-
|
|
193
|
+
| Constant | Type |
|
|
194
|
+
| --------------- | ------------------------------------------------------------------------------- |
|
|
195
|
+
| `RawDataSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
|
|
133
196
|
|
|
134
|
-
|
|
197
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L30)
|
|
135
198
|
|
|
136
|
-
|
|
137
|
-
| -------- | ------------------ | -------------------------------------------------------------------------------------------- |
|
|
138
|
-
| `before` | `Doc or undefined` | The previous version of the document before the update. Undefined if this is a new document. |
|
|
139
|
-
| `after` | `Doc` | The new version of the document after the update. |
|
|
199
|
+
#### :gear: RawPrincipalSchema
|
|
140
200
|
|
|
141
|
-
|
|
201
|
+
| Constant | Type |
|
|
202
|
+
| -------------------- | ------------------------------------------------------------------------------- |
|
|
203
|
+
| `RawPrincipalSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
|
|
142
204
|
|
|
143
|
-
|
|
205
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L44)
|
|
144
206
|
|
|
145
|
-
|
|
146
|
-
throw an error if their validation fails.
|
|
207
|
+
#### :gear: RawUserIdSchema
|
|
147
208
|
|
|
148
|
-
|
|
|
149
|
-
|
|
|
150
|
-
| `
|
|
151
|
-
| `proposed` | `SetDoc` | The proposed version of the document. This can be validated before allowing the operation. |
|
|
209
|
+
| Constant | Type |
|
|
210
|
+
| ----------------- | ------------------------------------------------------------------------------- |
|
|
211
|
+
| `RawUserIdSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
|
|
152
212
|
|
|
153
|
-
|
|
213
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L58)
|
|
154
214
|
|
|
155
|
-
|
|
215
|
+
#### :gear: DocDescriptionSchema
|
|
156
216
|
|
|
157
|
-
|
|
|
158
|
-
|
|
|
159
|
-
| `
|
|
160
|
-
| `data` | `RawData` | The raw data of the document. |
|
|
161
|
-
| `description` | `string or undefined` | An optional description of the document. |
|
|
162
|
-
| `created_at` | `bigint` | The timestamp when the document was first created. |
|
|
163
|
-
| `updated_at` | `bigint` | The timestamp when the document was last updated. |
|
|
164
|
-
| `version` | `bigint or undefined` | The version number of the document, used for consistency checks. If not provided, it's assumed to be the first version. |
|
|
217
|
+
| Constant | Type |
|
|
218
|
+
| ---------------------- | ----------- |
|
|
219
|
+
| `DocDescriptionSchema` | `ZodString` |
|
|
165
220
|
|
|
166
|
-
|
|
221
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L7)
|
|
167
222
|
|
|
168
|
-
|
|
223
|
+
#### :gear: DocSchema
|
|
169
224
|
|
|
170
|
-
|
|
225
|
+
| Constant | Type |
|
|
226
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
227
|
+
| `DocSchema` | `ZodObject<{ owner: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; ... 4 more ...; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
|
|
171
228
|
|
|
172
|
-
|
|
173
|
-
| ------------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
174
|
-
| `data` | `RawData` | The raw data of the document. |
|
|
175
|
-
| `description` | `string or undefined` | An optional description of the document. |
|
|
176
|
-
| `version` | `bigint or undefined` | The expected version number to ensure consistency. If provided, the operation will fail if the stored version does not match. |
|
|
229
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L17)
|
|
177
230
|
|
|
178
|
-
#### :gear:
|
|
231
|
+
#### :gear: DocUpsertSchema
|
|
179
232
|
|
|
180
|
-
|
|
233
|
+
| Constant | Type |
|
|
234
|
+
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
235
|
+
| `DocUpsertSchema` | `ZodObject<{ before: ZodOptional<ZodObject<{ owner: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; ... 4 more ...; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>>; after: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
|
|
181
236
|
|
|
182
|
-
|
|
183
|
-
| -------- | -------------- | ------------------------------------------------------------------------------- |
|
|
184
|
-
| `caller` | `RawPrincipal` | The user who originally triggered the function that in turn triggered the hook. |
|
|
185
|
-
| `data` | `T` | The data associated with the hook execution. |
|
|
237
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L60)
|
|
186
238
|
|
|
187
|
-
#### :gear:
|
|
239
|
+
#### :gear: ProposedDocSchema
|
|
188
240
|
|
|
189
|
-
|
|
241
|
+
| Constant | Type |
|
|
242
|
+
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
243
|
+
| `ProposedDocSchema` | `ZodObject<{ data: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; description: ZodOptional<...>; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
|
|
244
|
+
|
|
245
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L85)
|
|
246
|
+
|
|
247
|
+
#### :gear: DocAssertSetSchema
|
|
248
|
+
|
|
249
|
+
| Constant | Type |
|
|
250
|
+
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
251
|
+
| `DocAssertSetSchema` | `ZodObject<{ current: ZodOptional<ZodObject<{ owner: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; ... 4 more ...; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>>; proposed: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
|
|
252
|
+
|
|
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)
|
|
262
|
+
|
|
263
|
+
#### :gear: OnSetDocContextSchema
|
|
264
|
+
|
|
265
|
+
| Constant | Type |
|
|
266
|
+
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
267
|
+
| `OnSetDocContextSchema` | `ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
|
|
268
|
+
|
|
269
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#L63)
|
|
270
|
+
|
|
271
|
+
#### :gear: AssertSetDocContextSchema
|
|
272
|
+
|
|
273
|
+
| Constant | Type |
|
|
274
|
+
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
275
|
+
| `AssertSetDocContextSchema` | `ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
|
|
276
|
+
|
|
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)
|
|
286
|
+
|
|
287
|
+
#### :gear: SatelliteEnvSchema
|
|
288
|
+
|
|
289
|
+
| Constant | Type |
|
|
290
|
+
| -------------------- | ---------------------------------- |
|
|
291
|
+
| `SatelliteEnvSchema` | `ZodRecord<ZodString, ZodUnknown>` |
|
|
190
292
|
|
|
191
|
-
|
|
192
|
-
| ------------ | -------- | -------------------------------------------------------------- |
|
|
193
|
-
| `collection` | `string` | The name of the collection where the document is stored. |
|
|
194
|
-
| `key` | `string` | The unique key identifying the document within the collection. |
|
|
195
|
-
| `data` | `T` | The data associated with the document operation. |
|
|
293
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.env.ts#L6)
|
|
196
294
|
|
|
197
|
-
#### :gear:
|
|
295
|
+
#### :gear: AssertSetDocSchema
|
|
198
296
|
|
|
199
|
-
|
|
297
|
+
| Constant | Type |
|
|
298
|
+
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
299
|
+
| `AssertSetDocSchema` | `ZodObject<extendShape<{ collections: ZodArray<ZodString, "many">; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodPromise<...>>; }>, "strict", ZodTypeAny, { ....` |
|
|
200
300
|
|
|
201
|
-
|
|
202
|
-
| -------------- | ------- | ----------- |
|
|
203
|
-
| `assertSetDoc` | `never` | |
|
|
301
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L25)
|
|
204
302
|
|
|
205
|
-
#### :gear:
|
|
303
|
+
#### :gear: AssertSchema
|
|
206
304
|
|
|
207
|
-
|
|
208
|
-
|
|
305
|
+
| Constant | Type |
|
|
306
|
+
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
307
|
+
| `AssertSchema` | `ZodObject<extendShape<{ collections: ZodArray<ZodString, "many">; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodPromise<...>>; }>, "strict", ZodTypeAny, { ....` |
|
|
209
308
|
|
|
210
|
-
|
|
211
|
-
| -------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
212
|
-
| `assertSetDoc` | `(context: AssertSetDocContext) => void` | A function that runs synchronously before a document is set in the Datastore. This can be used to enforce your validation rules. param: context - Provides details about the document being validated.throws: {Error} If your validation fails, throw an exception to prevent the document from being saved. |
|
|
309
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L36)
|
|
213
310
|
|
|
214
|
-
#### :gear:
|
|
311
|
+
#### :gear: OnSetDocSchema
|
|
215
312
|
|
|
216
|
-
|
|
313
|
+
| Constant | Type |
|
|
314
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
315
|
+
| `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, { ...;...` |
|
|
217
316
|
|
|
218
|
-
|
|
219
|
-
| ---------- | ------- | ----------- |
|
|
220
|
-
| `onSetDoc` | `never` | |
|
|
317
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L25)
|
|
221
318
|
|
|
222
|
-
#### :gear:
|
|
319
|
+
#### :gear: HookSchema
|
|
223
320
|
|
|
224
|
-
|
|
225
|
-
|
|
321
|
+
| Constant | Type |
|
|
322
|
+
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
323
|
+
| `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, { ...;...` |
|
|
226
324
|
|
|
227
|
-
|
|
228
|
-
| ---------- | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
229
|
-
| `onSetDoc` | `(context: OnSetDocContext) => Promise<void>` | A function that runs when a document is set in the Datastore. param: context - Provides details about the document being saved.returns: Resolves when your operation is complete. |
|
|
325
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L36)
|
|
230
326
|
|
|
231
327
|
### :cocktail: Types
|
|
232
328
|
|
|
233
|
-
- [SatelliteConfigEnv](#gear-satelliteconfigenv)
|
|
234
329
|
- [Timestamp](#gear-timestamp)
|
|
235
330
|
- [Version](#gear-version)
|
|
236
331
|
- [RawData](#gear-rawdata)
|
|
237
332
|
- [RawPrincipal](#gear-rawprincipal)
|
|
238
333
|
- [RawUserId](#gear-rawuserid)
|
|
334
|
+
- [DocDescription](#gear-docdescription)
|
|
335
|
+
- [Doc](#gear-doc)
|
|
336
|
+
- [DocUpsert](#gear-docupsert)
|
|
337
|
+
- [ProposedDoc](#gear-proposeddoc)
|
|
338
|
+
- [DocAssertSet](#gear-docassertset)
|
|
339
|
+
- [SetDoc](#gear-setdoc)
|
|
340
|
+
- [HookContext](#gear-hookcontext)
|
|
341
|
+
- [DocContext](#gear-doccontext)
|
|
239
342
|
- [OnSetDocContext](#gear-onsetdoccontext)
|
|
240
343
|
- [AssertSetDocContext](#gear-assertsetdoccontext)
|
|
241
|
-
- [
|
|
344
|
+
- [CollectionsConfig](#gear-collectionsconfig)
|
|
345
|
+
- [SatelliteEnv](#gear-satelliteenv)
|
|
346
|
+
- [AssertSetDoc](#gear-assertsetdoc)
|
|
347
|
+
- [Assert](#gear-assert)
|
|
242
348
|
- [AssertFn](#gear-assertfn)
|
|
243
349
|
- [AssertFnOrObject](#gear-assertfnorobject)
|
|
244
|
-
- [
|
|
350
|
+
- [OnSetDoc](#gear-onsetdoc)
|
|
351
|
+
- [Hook](#gear-hook)
|
|
245
352
|
- [HookFn](#gear-hookfn)
|
|
246
353
|
- [HookFnOrObject](#gear-hookfnorobject)
|
|
247
354
|
|
|
248
|
-
#### :gear: SatelliteConfigEnv
|
|
249
|
-
|
|
250
|
-
Placeholder for future environment-specific configurations.
|
|
251
|
-
|
|
252
|
-
Currently unused, but it may support features such as:
|
|
253
|
-
|
|
254
|
-
- Defining the execution mode (e.g., staging or production).
|
|
255
|
-
- Providing environment-specific values like `ckBtcLedgerId` for test or production.
|
|
256
|
-
|
|
257
|
-
| Type | Type |
|
|
258
|
-
| -------------------- | ---- |
|
|
259
|
-
| `SatelliteConfigEnv` | |
|
|
260
|
-
|
|
261
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.config.ts#L8)
|
|
262
|
-
|
|
263
355
|
#### :gear: Timestamp
|
|
264
356
|
|
|
265
357
|
Represents a timestamp in nanoseconds since the Unix epoch.
|
|
266
358
|
|
|
267
359
|
Used for tracking when events occur, such as document creation and updates.
|
|
268
360
|
|
|
269
|
-
| Type | Type
|
|
270
|
-
| ----------- |
|
|
271
|
-
| `Timestamp` |
|
|
361
|
+
| Type | Type |
|
|
362
|
+
| ----------- | --------------------------------- |
|
|
363
|
+
| `Timestamp` | `z.infer<typeof TimestampSchema>` |
|
|
272
364
|
|
|
273
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#
|
|
365
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L13)
|
|
274
366
|
|
|
275
367
|
#### :gear: Version
|
|
276
368
|
|
|
@@ -278,11 +370,11 @@ Represents a version number for tracking changes.
|
|
|
278
370
|
|
|
279
371
|
This is typically incremented with each update to ensure consistency.
|
|
280
372
|
|
|
281
|
-
| Type | Type
|
|
282
|
-
| --------- |
|
|
283
|
-
| `Version` |
|
|
373
|
+
| Type | Type |
|
|
374
|
+
| --------- | ------------------------------- |
|
|
375
|
+
| `Version` | `z.infer<typeof VersionSchema>` |
|
|
284
376
|
|
|
285
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#
|
|
377
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L25)
|
|
286
378
|
|
|
287
379
|
#### :gear: RawData
|
|
288
380
|
|
|
@@ -290,11 +382,11 @@ Represents raw binary data.
|
|
|
290
382
|
|
|
291
383
|
This is used to store unstructured data in a document.
|
|
292
384
|
|
|
293
|
-
| Type | Type
|
|
294
|
-
| --------- |
|
|
295
|
-
| `RawData` | `
|
|
385
|
+
| Type | Type |
|
|
386
|
+
| --------- | ------------------------------- |
|
|
387
|
+
| `RawData` | `z.infer<typeof RawDataSchema>` |
|
|
296
388
|
|
|
297
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#
|
|
389
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L39)
|
|
298
390
|
|
|
299
391
|
#### :gear: RawPrincipal
|
|
300
392
|
|
|
@@ -302,11 +394,11 @@ Represents a raw principal identifier.
|
|
|
302
394
|
|
|
303
395
|
Principals are unique identities used in authentication and authorization.
|
|
304
396
|
|
|
305
|
-
| Type | Type
|
|
306
|
-
| -------------- |
|
|
307
|
-
| `RawPrincipal` | `
|
|
397
|
+
| Type | Type |
|
|
398
|
+
| -------------- | ------------------------------------ |
|
|
399
|
+
| `RawPrincipal` | `z.infer<typeof RawPrincipalSchema>` |
|
|
308
400
|
|
|
309
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#
|
|
401
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L53)
|
|
310
402
|
|
|
311
403
|
#### :gear: RawUserId
|
|
312
404
|
|
|
@@ -314,11 +406,99 @@ Represents a raw user identifier.
|
|
|
314
406
|
|
|
315
407
|
This is a principal associated with a user.
|
|
316
408
|
|
|
317
|
-
| Type | Type
|
|
318
|
-
| ----------- |
|
|
319
|
-
| `RawUserId` | `
|
|
409
|
+
| Type | Type |
|
|
410
|
+
| ----------- | --------------------------------- |
|
|
411
|
+
| `RawUserId` | `z.infer<typeof RawUserIdSchema>` |
|
|
412
|
+
|
|
413
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L65)
|
|
414
|
+
|
|
415
|
+
#### :gear: DocDescription
|
|
416
|
+
|
|
417
|
+
Represents a document description with a maximum length of 1024 characters.
|
|
418
|
+
|
|
419
|
+
| Type | Type |
|
|
420
|
+
| ---------------- | -------------------------------------- |
|
|
421
|
+
| `DocDescription` | `z.infer<typeof DocDescriptionSchema>` |
|
|
422
|
+
|
|
423
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L12)
|
|
424
|
+
|
|
425
|
+
#### :gear: Doc
|
|
426
|
+
|
|
427
|
+
Represents a document stored in a collection.
|
|
428
|
+
|
|
429
|
+
| Type | Type |
|
|
430
|
+
| ----- | --------------------------- |
|
|
431
|
+
| `Doc` | `z.infer<typeof DocSchema>` |
|
|
432
|
+
|
|
433
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L55)
|
|
434
|
+
|
|
435
|
+
#### :gear: DocUpsert
|
|
436
|
+
|
|
437
|
+
Represents a document update operation.
|
|
438
|
+
|
|
439
|
+
This is used in hooks where a document is either being created or updated.
|
|
440
|
+
|
|
441
|
+
| Type | Type |
|
|
442
|
+
| ----------- | --------------------------------- |
|
|
443
|
+
| `DocUpsert` | `z.infer<typeof DocUpsertSchema>` |
|
|
444
|
+
|
|
445
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L80)
|
|
446
|
+
|
|
447
|
+
#### :gear: ProposedDoc
|
|
448
|
+
|
|
449
|
+
Represents the proposed version of a document.
|
|
450
|
+
This can be validated before allowing the operation.
|
|
451
|
+
|
|
452
|
+
| Type | Type |
|
|
453
|
+
| ------------- | ----------------------------------- |
|
|
454
|
+
| `ProposedDoc` | `z.infer<typeof ProposedDocSchema>` |
|
|
455
|
+
|
|
456
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L108)
|
|
457
|
+
|
|
458
|
+
#### :gear: DocAssertSet
|
|
459
|
+
|
|
460
|
+
Represents a validation check before setting a document.
|
|
461
|
+
|
|
462
|
+
The developer can compare the `current` and `proposed` versions and
|
|
463
|
+
throw an error if their validation fails.
|
|
464
|
+
|
|
465
|
+
| Type | Type |
|
|
466
|
+
| -------------- | ------------------------------------ |
|
|
467
|
+
| `DocAssertSet` | `z.infer<typeof DocAssertSetSchema>` |
|
|
468
|
+
|
|
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)
|
|
492
|
+
|
|
493
|
+
#### :gear: DocContext
|
|
494
|
+
|
|
495
|
+
Represents the context of a document operation within a collection.
|
|
496
|
+
|
|
497
|
+
| Type | Type |
|
|
498
|
+
| ------------ | ------------------------------------------------- |
|
|
499
|
+
| `DocContext` | `z.infer<ReturnType<typeof DocContextSchema<T>>>` |
|
|
320
500
|
|
|
321
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/
|
|
501
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#L58)
|
|
322
502
|
|
|
323
503
|
#### :gear: OnSetDocContext
|
|
324
504
|
|
|
@@ -327,11 +507,11 @@ The context provided to the `onSetDoc` hook.
|
|
|
327
507
|
This context contains information about the document being created or updated,
|
|
328
508
|
along with details about the user who triggered the operation.
|
|
329
509
|
|
|
330
|
-
| Type | Type
|
|
331
|
-
| ----------------- |
|
|
332
|
-
| `OnSetDocContext` | `
|
|
510
|
+
| Type | Type |
|
|
511
|
+
| ----------------- | --------------------------------------- |
|
|
512
|
+
| `OnSetDocContext` | `z.infer<typeof OnSetDocContextSchema>` |
|
|
333
513
|
|
|
334
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#
|
|
514
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#L71)
|
|
335
515
|
|
|
336
516
|
#### :gear: AssertSetDocContext
|
|
337
517
|
|
|
@@ -340,59 +520,108 @@ The context provided to the `assertSetDoc` hook.
|
|
|
340
520
|
This context contains information about the document being validated before
|
|
341
521
|
it is created or updated. If validation fails, the developer should throw an error.
|
|
342
522
|
|
|
343
|
-
| Type | Type
|
|
344
|
-
| --------------------- |
|
|
345
|
-
| `AssertSetDocContext` | `
|
|
523
|
+
| Type | Type |
|
|
524
|
+
| --------------------- | ------------------------------------------- |
|
|
525
|
+
| `AssertSetDocContext` | `z.infer<typeof AssertSetDocContextSchema>` |
|
|
526
|
+
|
|
527
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/context.ts#L84)
|
|
528
|
+
|
|
529
|
+
#### :gear: CollectionsConfig
|
|
346
530
|
|
|
347
|
-
|
|
531
|
+
Defines the collections where a hook or assertion should run.
|
|
348
532
|
|
|
349
|
-
|
|
533
|
+
| Type | Type |
|
|
534
|
+
| ------------------- | ----------------------------------------- |
|
|
535
|
+
| `CollectionsConfig` | `z.infer<typeof CollectionsConfigSchema>` |
|
|
350
536
|
|
|
351
|
-
|
|
352
|
-
| -------------- | -------------------- |
|
|
353
|
-
| `AssertConfig` | `AssertSetDocConfig` |
|
|
537
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/collections.config.ts#L18)
|
|
354
538
|
|
|
355
|
-
|
|
539
|
+
#### :gear: SatelliteEnv
|
|
540
|
+
|
|
541
|
+
Placeholder for future environment-specific configurations.
|
|
542
|
+
|
|
543
|
+
Currently unused, but it may support features such as:
|
|
544
|
+
|
|
545
|
+
- Defining the execution mode (e.g., staging or production).
|
|
546
|
+
- Providing environment-specific values like `ckBtcLedgerId` for test or production.
|
|
547
|
+
|
|
548
|
+
| Type | Type |
|
|
549
|
+
| -------------- | ------------------------------------ |
|
|
550
|
+
| `SatelliteEnv` | `z.infer<typeof SatelliteEnvSchema>` |
|
|
551
|
+
|
|
552
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.env.ts#L15)
|
|
553
|
+
|
|
554
|
+
#### :gear: AssertSetDoc
|
|
555
|
+
|
|
556
|
+
An assertion that runs when a document is created or updated.
|
|
557
|
+
|
|
558
|
+
| Type | Type |
|
|
559
|
+
| -------------- | ------------------------------------ |
|
|
560
|
+
| `AssertSetDoc` | `z.infer<typeof AssertSetDocSchema>` |
|
|
561
|
+
|
|
562
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L30)
|
|
563
|
+
|
|
564
|
+
#### :gear: Assert
|
|
565
|
+
|
|
566
|
+
All assertions definitions.
|
|
567
|
+
|
|
568
|
+
| Type | Type |
|
|
569
|
+
| -------- | ------------------------------ |
|
|
570
|
+
| `Assert` | `z.infer<typeof AssertSchema>` |
|
|
571
|
+
|
|
572
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L41)
|
|
356
573
|
|
|
357
574
|
#### :gear: AssertFn
|
|
358
575
|
|
|
359
|
-
| Type | Type
|
|
360
|
-
| ---------- |
|
|
361
|
-
| `AssertFn` | `(
|
|
576
|
+
| Type | Type |
|
|
577
|
+
| ---------- | --------------------------------------------------- |
|
|
578
|
+
| `AssertFn` | `(assert: z.infer<typeof SatelliteEnvSchema>) => T` |
|
|
362
579
|
|
|
363
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/
|
|
580
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L45)
|
|
364
581
|
|
|
365
582
|
#### :gear: AssertFnOrObject
|
|
366
583
|
|
|
367
|
-
| Type | Type
|
|
368
|
-
| ------------------ |
|
|
369
|
-
| `AssertFnOrObject` | `
|
|
584
|
+
| Type | Type |
|
|
585
|
+
| ------------------ | ------------------ |
|
|
586
|
+
| `AssertFnOrObject` | `T or AssertFn<T>` |
|
|
587
|
+
|
|
588
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L49)
|
|
589
|
+
|
|
590
|
+
#### :gear: OnSetDoc
|
|
591
|
+
|
|
592
|
+
A hook that runs when a document is created or updated.
|
|
593
|
+
|
|
594
|
+
| Type | Type |
|
|
595
|
+
| ---------- | -------------------------------- |
|
|
596
|
+
| `OnSetDoc` | `z.infer<typeof OnSetDocSchema>` |
|
|
597
|
+
|
|
598
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L30)
|
|
370
599
|
|
|
371
|
-
|
|
600
|
+
#### :gear: Hook
|
|
372
601
|
|
|
373
|
-
|
|
602
|
+
All hooks definitions.
|
|
374
603
|
|
|
375
|
-
| Type
|
|
376
|
-
|
|
|
377
|
-
| `
|
|
604
|
+
| Type | Type |
|
|
605
|
+
| ------ | ---------------------------- |
|
|
606
|
+
| `Hook` | `z.infer<typeof HookSchema>` |
|
|
378
607
|
|
|
379
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/
|
|
608
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L41)
|
|
380
609
|
|
|
381
610
|
#### :gear: HookFn
|
|
382
611
|
|
|
383
|
-
| Type | Type
|
|
384
|
-
| -------- |
|
|
385
|
-
| `HookFn` | `(
|
|
612
|
+
| Type | Type |
|
|
613
|
+
| -------- | ------------------------------------------------- |
|
|
614
|
+
| `HookFn` | `(hook: z.infer<typeof SatelliteEnvSchema>) => T` |
|
|
386
615
|
|
|
387
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/
|
|
616
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L45)
|
|
388
617
|
|
|
389
618
|
#### :gear: HookFnOrObject
|
|
390
619
|
|
|
391
|
-
| Type | Type
|
|
392
|
-
| ---------------- |
|
|
393
|
-
| `HookFnOrObject` | `
|
|
620
|
+
| Type | Type |
|
|
621
|
+
| ---------------- | ---------------- |
|
|
622
|
+
| `HookFnOrObject` | `T or HookFn<T>` |
|
|
394
623
|
|
|
395
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/
|
|
624
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L49)
|
|
396
625
|
|
|
397
626
|
<!-- TSDOC_END -->
|
|
398
627
|
|