@junobuild/functions 0.0.4 → 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 +151 -151
- 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} +60 -60
- package/dist/types/configs/collections.config.d.ts +4 -2
- package/dist/types/configs/{hook.config.d.ts → hooks.d.ts} +60 -60
- package/dist/types/configs/{satellite.config.d.ts → satellite.env.d.ts} +5 -3
- package/dist/types/hooks/context.d.ts +36 -36
- package/dist/types/hooks/core.d.ts +1 -1
- package/dist/types/hooks/datastore.d.ts +29 -29
- package/dist/types/index.d.ts +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,113 +40,113 @@ 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
|
-
| Function | Type
|
|
140
|
-
| --------------- |
|
|
141
|
-
| `decodeDocData` | `<T>(data: Uint8Array<
|
|
139
|
+
| Function | Type |
|
|
140
|
+
| --------------- | --------------------------------------------- |
|
|
141
|
+
| `decodeDocData` | `<T>(data: Uint8Array<ArrayBufferLike>) => T` |
|
|
142
142
|
|
|
143
143
|
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/datastore.sdk.ts#L4)
|
|
144
144
|
|
|
145
145
|
#### :gear: encodeDocData
|
|
146
146
|
|
|
147
|
-
| Function | Type
|
|
148
|
-
| --------------- |
|
|
149
|
-
| `encodeDocData` | `<T>(data: T) => Uint8Array<
|
|
147
|
+
| Function | Type |
|
|
148
|
+
| --------------- | --------------------------------------------- |
|
|
149
|
+
| `encodeDocData` | `<T>(data: T) => Uint8Array<ArrayBufferLike>` |
|
|
150
150
|
|
|
151
151
|
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/datastore.sdk.ts#L7)
|
|
152
152
|
|
|
@@ -166,11 +166,11 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
|
|
|
166
166
|
- [OnSetDocContextSchema](#gear-onsetdoccontextschema)
|
|
167
167
|
- [AssertSetDocContextSchema](#gear-assertsetdoccontextschema)
|
|
168
168
|
- [CollectionsConfigSchema](#gear-collectionsconfigschema)
|
|
169
|
-
- [
|
|
170
|
-
- [
|
|
171
|
-
- [
|
|
172
|
-
- [
|
|
173
|
-
- [
|
|
169
|
+
- [SatelliteEnvSchema](#gear-satelliteenvschema)
|
|
170
|
+
- [AssertSetDocSchema](#gear-assertsetdocschema)
|
|
171
|
+
- [AssertSchema](#gear-assertschema)
|
|
172
|
+
- [OnSetDocSchema](#gear-onsetdocschema)
|
|
173
|
+
- [HookSchema](#gear-hookschema)
|
|
174
174
|
|
|
175
175
|
#### :gear: TimestampSchema
|
|
176
176
|
|
|
@@ -190,9 +190,9 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
|
|
|
190
190
|
|
|
191
191
|
#### :gear: RawDataSchema
|
|
192
192
|
|
|
193
|
-
| Constant | Type
|
|
194
|
-
| --------------- |
|
|
195
|
-
| `RawDataSchema` | `ZodType<Uint8Array<
|
|
193
|
+
| Constant | Type |
|
|
194
|
+
| --------------- | ------------------------------------------------------------------------------- |
|
|
195
|
+
| `RawDataSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
|
|
196
196
|
|
|
197
197
|
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L30)
|
|
198
198
|
|
|
@@ -202,7 +202,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
|
|
|
202
202
|
| -------------------- | ------------------------------------------------------------------------------- |
|
|
203
203
|
| `RawPrincipalSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
|
|
204
204
|
|
|
205
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#
|
|
205
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L44)
|
|
206
206
|
|
|
207
207
|
#### :gear: RawUserIdSchema
|
|
208
208
|
|
|
@@ -210,7 +210,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
|
|
|
210
210
|
| ----------------- | ------------------------------------------------------------------------------- |
|
|
211
211
|
| `RawUserIdSchema` | `ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>` |
|
|
212
212
|
|
|
213
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#
|
|
213
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L58)
|
|
214
214
|
|
|
215
215
|
#### :gear: DocDescriptionSchema
|
|
216
216
|
|
|
@@ -238,9 +238,9 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
|
|
|
238
238
|
|
|
239
239
|
#### :gear: ProposedDocSchema
|
|
240
240
|
|
|
241
|
-
| Constant | Type
|
|
242
|
-
| ------------------- |
|
|
243
|
-
| `ProposedDocSchema` | `ZodObject<{ data: ZodType<Uint8Array<
|
|
241
|
+
| Constant | Type |
|
|
242
|
+
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
243
|
+
| `ProposedDocSchema` | `ZodObject<{ data: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; description: ZodOptional<...>; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
|
|
244
244
|
|
|
245
245
|
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L85)
|
|
246
246
|
|
|
@@ -254,9 +254,9 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
|
|
|
254
254
|
|
|
255
255
|
#### :gear: SetDocSchema
|
|
256
256
|
|
|
257
|
-
| Constant | Type
|
|
258
|
-
| -------------- |
|
|
259
|
-
| `SetDocSchema` | `ZodObject<{ data: ZodType<Uint8Array<
|
|
257
|
+
| Constant | Type |
|
|
258
|
+
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
259
|
+
| `SetDocSchema` | `ZodObject<{ data: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; description: ZodOptional<...>; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
|
|
260
260
|
|
|
261
261
|
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/datastore.ts#L140)
|
|
262
262
|
|
|
@@ -278,60 +278,51 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
|
|
|
278
278
|
|
|
279
279
|
#### :gear: CollectionsConfigSchema
|
|
280
280
|
|
|
281
|
-
Defines the collections where a hook or assertion should run.
|
|
282
|
-
|
|
283
281
|
| Constant | Type |
|
|
284
282
|
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
285
283
|
| `CollectionsConfigSchema` | `ZodObject<{ collections: ZodArray<ZodString, "many">; }, "strict", ZodTypeAny, { collections: string[]; }, { collections: string[]; }>` |
|
|
286
284
|
|
|
287
285
|
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/collections.config.ts#L6)
|
|
288
286
|
|
|
289
|
-
#### :gear:
|
|
290
|
-
|
|
291
|
-
Placeholder for future environment-specific configurations.
|
|
292
|
-
|
|
293
|
-
Currently unused, but it may support features such as:
|
|
294
|
-
|
|
295
|
-
- Defining the execution mode (e.g., staging or production).
|
|
296
|
-
- Providing environment-specific values like `ckBtcLedgerId` for test or production.
|
|
287
|
+
#### :gear: SatelliteEnvSchema
|
|
297
288
|
|
|
298
|
-
| Constant
|
|
299
|
-
|
|
|
300
|
-
| `
|
|
289
|
+
| Constant | Type |
|
|
290
|
+
| -------------------- | ---------------------------------- |
|
|
291
|
+
| `SatelliteEnvSchema` | `ZodRecord<ZodString, ZodUnknown>` |
|
|
301
292
|
|
|
302
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.
|
|
293
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.env.ts#L6)
|
|
303
294
|
|
|
304
|
-
#### :gear:
|
|
295
|
+
#### :gear: AssertSetDocSchema
|
|
305
296
|
|
|
306
|
-
| Constant
|
|
307
|
-
|
|
|
308
|
-
| `
|
|
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, { ....` |
|
|
309
300
|
|
|
310
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/
|
|
301
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L25)
|
|
311
302
|
|
|
312
|
-
#### :gear:
|
|
303
|
+
#### :gear: AssertSchema
|
|
313
304
|
|
|
314
|
-
| Constant
|
|
315
|
-
|
|
|
316
|
-
| `
|
|
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, { ....` |
|
|
317
308
|
|
|
318
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/
|
|
309
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L36)
|
|
319
310
|
|
|
320
|
-
#### :gear:
|
|
311
|
+
#### :gear: OnSetDocSchema
|
|
321
312
|
|
|
322
|
-
| Constant
|
|
323
|
-
|
|
|
324
|
-
| `
|
|
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, { ...;...` |
|
|
325
316
|
|
|
326
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/
|
|
317
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L25)
|
|
327
318
|
|
|
328
|
-
#### :gear:
|
|
319
|
+
#### :gear: HookSchema
|
|
329
320
|
|
|
330
|
-
| Constant
|
|
331
|
-
|
|
|
332
|
-
| `
|
|
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, { ...;...` |
|
|
333
324
|
|
|
334
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/
|
|
325
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L36)
|
|
335
326
|
|
|
336
327
|
### :cocktail: Types
|
|
337
328
|
|
|
@@ -351,13 +342,13 @@ Currently unused, but it may support features such as:
|
|
|
351
342
|
- [OnSetDocContext](#gear-onsetdoccontext)
|
|
352
343
|
- [AssertSetDocContext](#gear-assertsetdoccontext)
|
|
353
344
|
- [CollectionsConfig](#gear-collectionsconfig)
|
|
354
|
-
- [
|
|
355
|
-
- [
|
|
356
|
-
- [
|
|
345
|
+
- [SatelliteEnv](#gear-satelliteenv)
|
|
346
|
+
- [AssertSetDoc](#gear-assertsetdoc)
|
|
347
|
+
- [Assert](#gear-assert)
|
|
357
348
|
- [AssertFn](#gear-assertfn)
|
|
358
349
|
- [AssertFnOrObject](#gear-assertfnorobject)
|
|
359
|
-
- [
|
|
360
|
-
- [
|
|
350
|
+
- [OnSetDoc](#gear-onsetdoc)
|
|
351
|
+
- [Hook](#gear-hook)
|
|
361
352
|
- [HookFn](#gear-hookfn)
|
|
362
353
|
- [HookFnOrObject](#gear-hookfnorobject)
|
|
363
354
|
|
|
@@ -395,7 +386,7 @@ This is used to store unstructured data in a document.
|
|
|
395
386
|
| --------- | ------------------------------- |
|
|
396
387
|
| `RawData` | `z.infer<typeof RawDataSchema>` |
|
|
397
388
|
|
|
398
|
-
[: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)
|
|
399
390
|
|
|
400
391
|
#### :gear: RawPrincipal
|
|
401
392
|
|
|
@@ -407,7 +398,7 @@ Principals are unique identities used in authentication and authorization.
|
|
|
407
398
|
| -------------- | ------------------------------------ |
|
|
408
399
|
| `RawPrincipal` | `z.infer<typeof RawPrincipalSchema>` |
|
|
409
400
|
|
|
410
|
-
[: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)
|
|
411
402
|
|
|
412
403
|
#### :gear: RawUserId
|
|
413
404
|
|
|
@@ -419,7 +410,7 @@ This is a principal associated with a user.
|
|
|
419
410
|
| ----------- | --------------------------------- |
|
|
420
411
|
| `RawUserId` | `z.infer<typeof RawUserIdSchema>` |
|
|
421
412
|
|
|
422
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#
|
|
413
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/core.ts#L65)
|
|
423
414
|
|
|
424
415
|
#### :gear: DocDescription
|
|
425
416
|
|
|
@@ -537,47 +528,56 @@ it is created or updated. If validation fails, the developer should throw an err
|
|
|
537
528
|
|
|
538
529
|
#### :gear: CollectionsConfig
|
|
539
530
|
|
|
531
|
+
Defines the collections where a hook or assertion should run.
|
|
532
|
+
|
|
540
533
|
| Type | Type |
|
|
541
534
|
| ------------------- | ----------------------------------------- |
|
|
542
535
|
| `CollectionsConfig` | `z.infer<typeof CollectionsConfigSchema>` |
|
|
543
536
|
|
|
544
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/collections.config.ts#
|
|
537
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/collections.config.ts#L18)
|
|
545
538
|
|
|
546
|
-
#### :gear:
|
|
539
|
+
#### :gear: SatelliteEnv
|
|
547
540
|
|
|
548
|
-
|
|
549
|
-
| -------------------- | ------------------------------------------ |
|
|
550
|
-
| `SatelliteConfigEnv` | `z.infer<typeof SatelliteConfigEnvSchema>` |
|
|
551
|
-
|
|
552
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.config.ts#L13)
|
|
541
|
+
Placeholder for future environment-specific configurations.
|
|
553
542
|
|
|
554
|
-
|
|
543
|
+
Currently unused, but it may support features such as:
|
|
555
544
|
|
|
556
|
-
|
|
545
|
+
- Defining the execution mode (e.g., staging or production).
|
|
546
|
+
- Providing environment-specific values like `ckBtcLedgerId` for test or production.
|
|
557
547
|
|
|
558
|
-
| Type
|
|
559
|
-
|
|
|
560
|
-
| `
|
|
548
|
+
| Type | Type |
|
|
549
|
+
| -------------- | ------------------------------------ |
|
|
550
|
+
| `SatelliteEnv` | `z.infer<typeof SatelliteEnvSchema>` |
|
|
561
551
|
|
|
562
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/
|
|
552
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/satellite.env.ts#L15)
|
|
563
553
|
|
|
564
|
-
#### :gear:
|
|
554
|
+
#### :gear: AssertSetDoc
|
|
565
555
|
|
|
566
|
-
|
|
556
|
+
An assertion that runs when a document is created or updated.
|
|
567
557
|
|
|
568
558
|
| Type | Type |
|
|
569
559
|
| -------------- | ------------------------------------ |
|
|
570
|
-
| `
|
|
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)
|
|
571
563
|
|
|
572
|
-
|
|
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)
|
|
573
573
|
|
|
574
574
|
#### :gear: AssertFn
|
|
575
575
|
|
|
576
|
-
| Type | Type
|
|
577
|
-
| ---------- |
|
|
578
|
-
| `AssertFn` | `(
|
|
576
|
+
| Type | Type |
|
|
577
|
+
| ---------- | --------------------------------------------------- |
|
|
578
|
+
| `AssertFn` | `(assert: z.infer<typeof SatelliteEnvSchema>) => T` |
|
|
579
579
|
|
|
580
|
-
[: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)
|
|
581
581
|
|
|
582
582
|
#### :gear: AssertFnOrObject
|
|
583
583
|
|
|
@@ -585,35 +585,35 @@ All possible config for assertions.
|
|
|
585
585
|
| ------------------ | ------------------ |
|
|
586
586
|
| `AssertFnOrObject` | `T or AssertFn<T>` |
|
|
587
587
|
|
|
588
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/
|
|
588
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/assertions.ts#L49)
|
|
589
589
|
|
|
590
|
-
#### :gear:
|
|
590
|
+
#### :gear: OnSetDoc
|
|
591
591
|
|
|
592
|
-
|
|
592
|
+
A hook that runs when a document is created or updated.
|
|
593
593
|
|
|
594
|
-
| Type
|
|
595
|
-
|
|
|
596
|
-
| `
|
|
594
|
+
| Type | Type |
|
|
595
|
+
| ---------- | -------------------------------- |
|
|
596
|
+
| `OnSetDoc` | `z.infer<typeof OnSetDocSchema>` |
|
|
597
597
|
|
|
598
|
-
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/
|
|
598
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/configs/hooks.ts#L30)
|
|
599
599
|
|
|
600
|
-
#### :gear:
|
|
600
|
+
#### :gear: Hook
|
|
601
601
|
|
|
602
|
-
All
|
|
602
|
+
All hooks definitions.
|
|
603
603
|
|
|
604
|
-
| Type
|
|
605
|
-
|
|
|
606
|
-
| `
|
|
604
|
+
| Type | Type |
|
|
605
|
+
| ------ | ---------------------------- |
|
|
606
|
+
| `Hook` | `z.infer<typeof HookSchema>` |
|
|
607
607
|
|
|
608
|
-
[: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)
|
|
609
609
|
|
|
610
610
|
#### :gear: HookFn
|
|
611
611
|
|
|
612
|
-
| Type | Type
|
|
613
|
-
| -------- |
|
|
614
|
-
| `HookFn` | `(
|
|
612
|
+
| Type | Type |
|
|
613
|
+
| -------- | ------------------------------------------------- |
|
|
614
|
+
| `HookFn` | `(hook: z.infer<typeof SatelliteEnvSchema>) => T` |
|
|
615
615
|
|
|
616
|
-
[: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)
|
|
617
617
|
|
|
618
618
|
#### :gear: HookFnOrObject
|
|
619
619
|
|
|
@@ -621,7 +621,7 @@ All possible config for assertions.
|
|
|
621
621
|
| ---------------- | ---------------- |
|
|
622
622
|
| `HookFnOrObject` | `T or HookFn<T>` |
|
|
623
623
|
|
|
624
|
-
[: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)
|
|
625
625
|
|
|
626
626
|
<!-- TSDOC_END -->
|
|
627
627
|
|
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as t from"zod";import*as s from"zod";import*as n from"zod";var T=n.bigint(),p=n.bigint(),a=n.custom(e=>e instanceof Uint8Array,{message:"Expected Uint8Array"}),j=n.custom(e=>e instanceof Uint8Array,{message:"Expected Uint8Array"}),i=j;import*as r from"zod";var z=r.string().max(1024),d=r.object({owner:i,data:a,description:z.optional(),created_at:T,updated_at:T,version:p.optional()}).strict(),h=r.object({before:d.optional(),after:d}).strict(),H=r.object({data:a,description:z.optional(),version:p.optional()}).strict(),l=r.object({current:d.optional(),proposed:H}).strict(),P=r.object({data:a,description:z.optional(),version:p.optional()}).strict();var A=e=>s.object({caller:i,data:e}).strict(),D=e=>s.object({collection:s.string(),key:s.string(),data:e}).strict(),O=A(D(h)),k=A(D(l));import*as c from"zod";var m=c.object({collections:c.array(c.string()).min(1)}).strict();import*as x from"zod";var f=x.record(x.unknown());var _=e=>m.extend({assert:t.function().args(e).returns(t.promise(t.void()))}).strict(),b=_(k),M=b,C=e=>t.function().args(f).returns(e),Q=e=>t.union([e,C(e)]);function W(e){return e}import*as o from"zod";var g=e=>m.extend({run:o.function().args(e).returns(o.promise(o.void()))}).strict(),F=g(O),te=F,w=e=>o.function().args(f).returns(e),oe=e=>o.union([e,w(e)]);function re(e){return e}import{jsonReplacer as R,jsonReviver as U}from"@dfinity/utils";var ce=e=>JSON.parse(__juno_satellite_datastore_raw_data_to_text(e),U),pe=e=>__juno_satellite_datastore_raw_data_from_text(JSON.stringify(e,R));import{jsonReplacer as v}from"@dfinity/utils";var S=e=>{let u=e.map(y=>typeof y=="object"?JSON.stringify(y,v):y).join(" ");globalThis.__ic_cdk_print(u)};globalThis.console={info(...e){S(e)},log(...e){S(e)},warn(...e){S(e)},error(...e){S(e)}};export{Q as AssertFnOrObjectSchema,C as AssertFnSchema,M as AssertSchema,k as AssertSetDocContextSchema,b as AssertSetDocSchema,m as CollectionsConfigSchema,l as DocAssertSetSchema,D as DocContextSchema,z as DocDescriptionSchema,d as DocSchema,h as DocUpsertSchema,oe as HookFnOrObjectSchema,w as HookFnSchema,te as HookSchema,O as OnSetDocContextSchema,F as OnSetDocSchema,H as ProposedDocSchema,a as RawDataSchema,j as RawPrincipalSchema,i as RawUserIdSchema,f as SatelliteEnvSchema,P as SetDocSchema,T as TimestampSchema,p as VersionSchema,ce as decodeDocData,W as defineAssert,re as defineHook,pe as encodeDocData};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|