@junobuild/functions 0.0.11 → 0.0.12-next-2025-03-27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,11 +38,11 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
38
38
 
39
39
  #### :gear: HookContextSchema
40
40
 
41
- | Function | Type |
42
- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
43
- | `HookContextSchema` | `<T extends z.ZodTypeAny>(dataSchema: T) => ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; data: T; }, "strict", ZodTypeAny, { [k in keyof addQuestionMarks<...>]: addQuestionMarks<...>[k]; }, { [k in keyof baseObjectInputType<...>]: baseObjectInputType<...>[k]; }>` |
41
+ | Function | Type |
42
+ | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
43
+ | `HookContextSchema` | `<T extends z.ZodTypeAny>(dataSchema: T) => ZodObject<typeof schemaShape, "strict", ZodTypeAny, baseObjectOutputType<typeof schemaShape>, baseObjectInputType<typeof schemaShape>>` |
44
44
 
45
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L7)
45
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L8)
46
46
 
47
47
  #### :gear: AssertFunctionSchema
48
48
 
@@ -50,7 +50,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
50
50
  | ---------------------- | ----------------------------------------------------------------------------------------------- |
51
51
  | `AssertFunctionSchema` | `<T extends z.ZodTypeAny>(contextSchema: T) => ZodFunction<ZodTuple<[T], ZodUnknown>, ZodVoid>` |
52
52
 
53
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L32)
53
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L41)
54
54
 
55
55
  #### :gear: RunFunctionSchema
56
56
 
@@ -58,15 +58,15 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
58
58
  | ------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
59
59
  | `RunFunctionSchema` | `<T extends z.ZodTypeAny>(contextSchema: T) => ZodFunction<ZodTuple<[T], ZodUnknown>, ZodUnion<[ZodPromise<ZodVoid>, ZodVoid]>>` |
60
60
 
61
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L47)
61
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L56)
62
62
 
63
63
  #### :gear: DocContextSchema
64
64
 
65
- | Function | Type |
66
- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
67
- | `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...` |
65
+ | Function | Type |
66
+ | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
67
+ | `DocContextSchema` | `<T extends z.ZodTypeAny>(dataSchema: T) => ZodObject<typeof schemaShape, "strict", ZodTypeAny, baseObjectOutputType<typeof schemaShape>, baseObjectInputType<typeof schemaShape>>` |
68
68
 
69
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L9)
69
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L10)
70
70
 
71
71
  #### :gear: AssertFnSchema
72
72
 
@@ -74,7 +74,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
74
74
  | ---------------- | ----------------------------------------------------------------------------------------------------------------------- |
75
75
  | `AssertFnSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>` |
76
76
 
77
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L44)
77
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L53)
78
78
 
79
79
  #### :gear: AssertFnOrObjectSchema
80
80
 
@@ -82,7 +82,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
82
82
  | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
83
83
  | `AssertFnOrObjectSchema` | `<T extends z.ZodTypeAny>(assertSchema: T) => ZodUnion<[T, ZodFunction<ZodTuple<[ZodRecord<ZodString, ZodUnknown>], ZodUnknown>, T>]>` |
84
84
 
85
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L48)
85
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L57)
86
86
 
87
87
  #### :gear: defineAssert
88
88
 
@@ -90,7 +90,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
90
90
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
91
91
  | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
92
92
 
93
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L52)
93
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L61)
94
94
 
95
95
  #### :gear: defineAssert
96
96
 
@@ -98,7 +98,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
98
98
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
99
99
  | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
100
100
 
101
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L53)
101
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L62)
102
102
 
103
103
  #### :gear: defineAssert
104
104
 
@@ -106,7 +106,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
106
106
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
107
107
  | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
108
108
 
109
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L54)
109
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L63)
110
110
 
111
111
  #### :gear: defineAssert
112
112
 
@@ -114,7 +114,7 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
114
114
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
115
115
  | `defineAssert` | `{ <T extends Assert>(assert: T): T; <T extends Assert>(assert: AssertFn<T>): AssertFn<T>; <T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>; }` |
116
116
 
117
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L55)
117
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L64)
118
118
 
119
119
  #### :gear: HookFnSchema
120
120
 
@@ -256,12 +256,16 @@ the Principal of the executing canister.
256
256
  - [RawDataSchema](#gear-rawdataschema)
257
257
  - [DocSchema](#gear-docschema)
258
258
  - [DocUpsertSchema](#gear-docupsertschema)
259
- - [ProposedDocSchema](#gear-proposeddocschema)
259
+ - [SetDocSchema](#gear-setdocschema)
260
+ - [DelDocSchema](#gear-deldocschema)
260
261
  - [DocAssertSetSchema](#gear-docassertsetschema)
262
+ - [DocAssertDeleteSchema](#gear-docassertdeleteschema)
261
263
  - [OnSetDocContextSchema](#gear-onsetdoccontextschema)
262
264
  - [AssertSetDocContextSchema](#gear-assertsetdoccontextschema)
265
+ - [AssertDeleteDocContextSchema](#gear-assertdeletedoccontextschema)
263
266
  - [SatelliteEnvSchema](#gear-satelliteenvschema)
264
267
  - [AssertSetDocSchema](#gear-assertsetdocschema)
268
+ - [AssertDeleteDocSchema](#gear-assertdeletedocschema)
265
269
  - [AssertSchema](#gear-assertschema)
266
270
  - [OnSetDocSchema](#gear-onsetdocschema)
267
271
  - [HookSchema](#gear-hookschema)
@@ -387,37 +391,61 @@ A schema that validates a value is an Uint8Array.
387
391
 
388
392
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L8)
389
393
 
390
- #### :gear: ProposedDocSchema
394
+ #### :gear: SetDocSchema
391
395
 
392
- | Constant | Type |
393
- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
394
- | `ProposedDocSchema` | `ZodObject<{ data: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; description: ZodOptional<...>; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
396
+ | Constant | Type |
397
+ | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
398
+ | `SetDocSchema` | `ZodObject<{ data: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; description: ZodOptional<...>; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
395
399
 
396
400
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L33)
397
401
 
402
+ #### :gear: DelDocSchema
403
+
404
+ | Constant | Type |
405
+ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
406
+ | `DelDocSchema` | `ZodObject<{ version: ZodOptional<ZodBigInt>; }, "strict", ZodTypeAny, { version?: bigint or undefined; }, { version?: bigint or undefined; }>` |
407
+
408
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L61)
409
+
398
410
  #### :gear: DocAssertSetSchema
399
411
 
400
412
  | Constant | Type |
401
413
  | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
402
414
  | `DocAssertSetSchema` | `ZodObject<{ current: ZodOptional<ZodObject<{ owner: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; ... 4 more ...; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>>; proposed: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
403
415
 
404
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L61)
416
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L79)
417
+
418
+ #### :gear: DocAssertDeleteSchema
419
+
420
+ | Constant | Type |
421
+ | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
422
+ | `DocAssertDeleteSchema` | `ZodObject<{ current: ZodOptional<ZodObject<{ owner: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; ... 4 more ...; version: ZodOptional<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>>; proposed: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
423
+
424
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L106)
405
425
 
406
426
  #### :gear: OnSetDocContextSchema
407
427
 
408
- | Constant | Type |
409
- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
410
- | `OnSetDocContextSchema` | `ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
428
+ | Constant | Type |
429
+ | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
430
+ | `OnSetDocContextSchema` | `ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; data: ZodObject<...>; }, "strict", ZodTypeAny, baseObjectOutputType<...>, baseObjectInputType<...>>` |
411
431
 
412
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L39)
432
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L48)
413
433
 
414
434
  #### :gear: AssertSetDocContextSchema
415
435
 
416
- | Constant | Type |
417
- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
418
- | `AssertSetDocContextSchema` | `ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>` |
436
+ | Constant | Type |
437
+ | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
438
+ | `AssertSetDocContextSchema` | `ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; data: ZodObject<...>; }, "strict", ZodTypeAny, baseObjectOutputType<...>, baseObjectInputType<...>>` |
439
+
440
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L61)
441
+
442
+ #### :gear: AssertDeleteDocContextSchema
419
443
 
420
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L52)
444
+ | Constant | Type |
445
+ | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
446
+ | `AssertDeleteDocContextSchema` | `ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<ArrayBufferLike>>; data: ZodObject<...>; }, "strict", ZodTypeAny, baseObjectOutputType<...>, baseObjectInputType<...>>` |
447
+
448
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L74)
421
449
 
422
450
  #### :gear: SatelliteEnvSchema
423
451
 
@@ -431,23 +459,31 @@ A schema that validates a value is an Uint8Array.
431
459
 
432
460
  | Constant | Type |
433
461
  | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
434
- | `AssertSetDocSchema` | `ZodObject<extendShape<{ collections: ZodReadonly<ZodArray<ZodString, "many">>; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodVoid>; }>, "strict", ZodTypeAny...` |
462
+ | `AssertSetDocSchema` | `ZodObject<extendShape<{ collections: ZodReadonly<ZodArray<ZodString, "many">>; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, baseObjectOutputType<...>, baseObjectInputType<...>>], ZodUnknown>, Z...` |
435
463
 
436
464
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L26)
437
465
 
466
+ #### :gear: AssertDeleteDocSchema
467
+
468
+ | Constant | Type |
469
+ | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
470
+ | `AssertDeleteDocSchema` | `ZodObject<extendShape<{ collections: ZodReadonly<ZodArray<ZodString, "many">>; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, baseObjectOutputType<...>, baseObjectInputType<...>>], ZodUnknown>, Z...` |
471
+
472
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L36)
473
+
438
474
  #### :gear: AssertSchema
439
475
 
440
476
  | Constant | Type |
441
477
  | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
442
- | `AssertSchema` | `ZodObject<extendShape<{ collections: ZodReadonly<ZodArray<ZodString, "many">>; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodVoid>; }>, "strict", ZodTypeAny...` |
478
+ | `AssertSchema` | `ZodUnion<[ZodObject<extendShape<{ collections: ZodReadonly<ZodArray<ZodString, "many">>; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, baseObjectOutputType<...>, baseObjectInputType<...>>], ZodU...` |
443
479
 
444
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L37)
480
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L46)
445
481
 
446
482
  #### :gear: OnSetDocSchema
447
483
 
448
484
  | Constant | Type |
449
485
  | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
450
- | `OnSetDocSchema` | `ZodObject<extendShape<{ collections: ZodReadonly<ZodArray<ZodString, "many">>; }, { run: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodUnion<...>>; }>, "strict", ZodType...` |
486
+ | `OnSetDocSchema` | `ZodObject<extendShape<{ collections: ZodReadonly<ZodArray<ZodString, "many">>; }, { run: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, baseObjectOutputType<...>, baseObjectInputType<...>>], ZodUnknown>, ZodU...` |
451
487
 
452
488
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L26)
453
489
 
@@ -455,7 +491,7 @@ A schema that validates a value is an Uint8Array.
455
491
 
456
492
  | Constant | Type |
457
493
  | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
458
- | `HookSchema` | `ZodObject<extendShape<{ collections: ZodReadonly<ZodArray<ZodString, "many">>; }, { run: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodUnion<...>>; }>, "strict", ZodType...` |
494
+ | `HookSchema` | `ZodObject<extendShape<{ collections: ZodReadonly<ZodArray<ZodString, "many">>; }, { run: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, baseObjectOutputType<...>, baseObjectInputType<...>>], ZodUnknown>, ZodU...` |
459
495
 
460
496
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L37)
461
497
 
@@ -539,13 +575,17 @@ Schema for encoding the call arguments.
539
575
  - [RawData](#gear-rawdata)
540
576
  - [Doc](#gear-doc)
541
577
  - [DocUpsert](#gear-docupsert)
542
- - [ProposedDoc](#gear-proposeddoc)
578
+ - [SetDoc](#gear-setdoc)
579
+ - [DelDoc](#gear-deldoc)
543
580
  - [DocAssertSet](#gear-docassertset)
581
+ - [DocAssertDelete](#gear-docassertdelete)
544
582
  - [DocContext](#gear-doccontext)
545
583
  - [OnSetDocContext](#gear-onsetdoccontext)
546
584
  - [AssertSetDocContext](#gear-assertsetdoccontext)
585
+ - [AssertDeleteDocContext](#gear-assertdeletedoccontext)
547
586
  - [SatelliteEnv](#gear-satelliteenv)
548
587
  - [AssertSetDoc](#gear-assertsetdoc)
588
+ - [AssertDeleteDoc](#gear-assertdeletedoc)
549
589
  - [Assert](#gear-assert)
550
590
  - [AssertFn](#gear-assertfn)
551
591
  - [AssertFnOrObject](#gear-assertfnorobject)
@@ -667,7 +707,7 @@ Represents the context provided to hooks, containing information about the calle
667
707
  | ------------- | -------------------------------------------------- |
668
708
  | `HookContext` | `z.infer<ReturnType<typeof HookContextSchema<T>>>` |
669
709
 
670
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L27)
710
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L36)
671
711
 
672
712
  #### :gear: AssertFunction
673
713
 
@@ -679,7 +719,7 @@ The function takes a context argument and returns `void`.
679
719
  | ---------------- | ---------------------------------------------------------------- |
680
720
  | `AssertFunction` | `z.infer<ReturnType<typeof AssertFunctionSchema<z.ZodType<T>>>>` |
681
721
 
682
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L42)
722
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L51)
683
723
 
684
724
  #### :gear: RunFunction
685
725
 
@@ -691,7 +731,7 @@ The function takes a context argument and returns either a `Promise<void>` or `v
691
731
  | ------------- | ------------------------------------------------------------- |
692
732
  | `RunFunction` | `z.infer<ReturnType<typeof RunFunctionSchema<z.ZodType<T>>>>` |
693
733
 
694
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L57)
734
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L66)
695
735
 
696
736
  #### :gear: DocDescription
697
737
 
@@ -737,17 +777,28 @@ This is used in hooks where a document is either being created or updated.
737
777
 
738
778
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L28)
739
779
 
740
- #### :gear: ProposedDoc
780
+ #### :gear: SetDoc
741
781
 
742
- Represents the proposed version of a document.
782
+ Represents the proposed version of a document to be created or updated.
743
783
  This can be validated before allowing the operation.
744
784
 
745
- | Type | Type |
746
- | ------------- | ----------------------------------- |
747
- | `ProposedDoc` | `z.infer<typeof ProposedDocSchema>` |
785
+ | Type | Type |
786
+ | -------- | ------------------------------ |
787
+ | `SetDoc` | `z.infer<typeof SetDocSchema>` |
748
788
 
749
789
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L56)
750
790
 
791
+ #### :gear: DelDoc
792
+
793
+ Represents the proposed version of a document to be deleted.
794
+ This can be validated before allowing the operation.
795
+
796
+ | Type | Type |
797
+ | -------- | ------------------------------ |
798
+ | `DelDoc` | `z.infer<typeof SetDocSchema>` |
799
+
800
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L74)
801
+
751
802
  #### :gear: DocAssertSet
752
803
 
753
804
  Represents a validation check before setting a document.
@@ -759,7 +810,20 @@ throw an error if their validation fails.
759
810
  | -------------- | ------------------------------------ |
760
811
  | `DocAssertSet` | `z.infer<typeof DocAssertSetSchema>` |
761
812
 
762
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L83)
813
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L101)
814
+
815
+ #### :gear: DocAssertDelete
816
+
817
+ Represents a validation check before deleting a document.
818
+
819
+ The developer can compare the `current` and `proposed` versions and
820
+ throw an error if their validation fails.
821
+
822
+ | Type | Type |
823
+ | ----------------- | --------------------------------------- |
824
+ | `DocAssertDelete` | `z.infer<typeof DocAssertDeleteSchema>` |
825
+
826
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/payload.ts#L128)
763
827
 
764
828
  #### :gear: DocContext
765
829
 
@@ -769,7 +833,7 @@ Represents the context of a document operation within a collection.
769
833
  | ------------ | ------------------------------------------------- |
770
834
  | `DocContext` | `z.infer<ReturnType<typeof DocContextSchema<T>>>` |
771
835
 
772
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L34)
836
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L43)
773
837
 
774
838
  #### :gear: OnSetDocContext
775
839
 
@@ -782,11 +846,11 @@ along with details about the user who triggered the operation.
782
846
  | ----------------- | --------------------------------------- |
783
847
  | `OnSetDocContext` | `z.infer<typeof OnSetDocContextSchema>` |
784
848
 
785
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L47)
849
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L56)
786
850
 
787
851
  #### :gear: AssertSetDocContext
788
852
 
789
- The context provided to the `assertSetDoc` hook.
853
+ The context provided to the `assertDeleteDoc` hook.
790
854
 
791
855
  This context contains information about the document being validated before
792
856
  it is created or updated. If validation fails, the developer should throw an error.
@@ -795,7 +859,20 @@ it is created or updated. If validation fails, the developer should throw an err
795
859
  | --------------------- | ------------------------------------------- |
796
860
  | `AssertSetDocContext` | `z.infer<typeof AssertSetDocContextSchema>` |
797
861
 
798
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L60)
862
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L69)
863
+
864
+ #### :gear: AssertDeleteDocContext
865
+
866
+ The context provided to the `assertDeleteDoc` hook.
867
+
868
+ This context contains information about the document being validated before
869
+ it is deleted. If validation fails, the developer should throw an error.
870
+
871
+ | Type | Type |
872
+ | ------------------------ | ---------------------------------------------- |
873
+ | `AssertDeleteDocContext` | `z.infer<typeof AssertDeleteDocContextSchema>` |
874
+
875
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/db/context.ts#L84)
799
876
 
800
877
  #### :gear: SatelliteEnv
801
878
 
@@ -822,6 +899,16 @@ An assertion that runs when a document is created or updated.
822
899
 
823
900
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L31)
824
901
 
902
+ #### :gear: AssertDeleteDoc
903
+
904
+ An assertion that runs when a document is deleted.
905
+
906
+ | Type | Type |
907
+ | ----------------- | --------------------------------------- |
908
+ | `AssertDeleteDoc` | `z.infer<typeof AssertDeleteDocSchema>` |
909
+
910
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L41)
911
+
825
912
  #### :gear: Assert
826
913
 
827
914
  All assertions definitions.
@@ -830,7 +917,7 @@ All assertions definitions.
830
917
  | -------- | ------------------------------ |
831
918
  | `Assert` | `z.infer<typeof AssertSchema>` |
832
919
 
833
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L42)
920
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L51)
834
921
 
835
922
  #### :gear: AssertFn
836
923
 
@@ -838,7 +925,7 @@ All assertions definitions.
838
925
  | ---------- | --------------------------------------------------- |
839
926
  | `AssertFn` | `(assert: z.infer<typeof SatelliteEnvSchema>) => T` |
840
927
 
841
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L46)
928
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L55)
842
929
 
843
930
  #### :gear: AssertFnOrObject
844
931
 
@@ -846,7 +933,7 @@ All assertions definitions.
846
933
  | ------------------ | ------------------ |
847
934
  | `AssertFnOrObject` | `T or AssertFn<T>` |
848
935
 
849
- [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L50)
936
+ [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L59)
850
937
 
851
938
  #### :gear: OnSetDoc
852
939