@junobuild/functions 0.0.9 → 0.0.10

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
@@ -54,9 +54,9 @@ JavaScript and TypeScript utilities for [Juno] Serverless Functions.
54
54
 
55
55
  #### :gear: RunFunctionSchema
56
56
 
57
- | Function | Type |
58
- | ------------------- | ----------------------------------------------------------------------------------------------------------- |
59
- | `RunFunctionSchema` | `<T extends z.ZodTypeAny>(contextSchema: T) => ZodFunction<ZodTuple<[T], ZodUnknown>, ZodPromise<ZodVoid>>` |
57
+ | Function | Type |
58
+ | ------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
59
+ | `RunFunctionSchema` | `<T extends z.ZodTypeAny>(contextSchema: T) => ZodFunction<ZodTuple<[T], ZodUnknown>, ZodUnion<[ZodPromise<ZodVoid>, ZodVoid]>>` |
60
60
 
61
61
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/context.ts#L47)
62
62
 
@@ -275,9 +275,9 @@ the Principal of the executing canister.
275
275
 
276
276
  #### :gear: CollectionsSchema
277
277
 
278
- | Constant | Type |
279
- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
280
- | `CollectionsSchema` | `ZodObject<{ collections: ZodArray<ZodString, "many">; }, "strict", ZodTypeAny, { collections: string[]; }, { collections: string[]; }>` |
278
+ | Constant | Type |
279
+ | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
280
+ | `CollectionsSchema` | `ZodObject<{ collections: ZodReadonly<ZodArray<ZodString, "many">>; }, "strict", ZodTypeAny, { collections: readonly string[]; }, { collections: readonly string[]; }>` |
281
281
 
282
282
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/schemas/collections.ts#L6)
283
283
 
@@ -431,7 +431,7 @@ A schema that validates a value is an Uint8Array.
431
431
 
432
432
  | Constant | Type |
433
433
  | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
434
- | `AssertSetDocSchema` | `ZodObject<extendShape<{ collections: ZodArray<ZodString, "many">; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodVoid>; }>, "strict", ZodTypeAny, { ...; }, {...` |
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...` |
435
435
 
436
436
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L26)
437
437
 
@@ -439,7 +439,7 @@ A schema that validates a value is an Uint8Array.
439
439
 
440
440
  | Constant | Type |
441
441
  | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
442
- | `AssertSchema` | `ZodObject<extendShape<{ collections: ZodArray<ZodString, "many">; }, { assert: ZodFunction<ZodTuple<[ZodObject<{ caller: ZodType<Uint8Array<ArrayBufferLike>, ZodTypeDef, Uint8Array<...>>; data: ZodObject<...>; }, "strict", ZodTypeAny, { ...; }, { ...; }>], ZodUnknown>, ZodVoid>; }>, "strict", ZodTypeAny, { ...; }, {...` |
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...` |
443
443
 
444
444
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/assertions.ts#L37)
445
445
 
@@ -447,7 +447,7 @@ A schema that validates a value is an Uint8Array.
447
447
 
448
448
  | Constant | Type |
449
449
  | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
450
- | `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, { ...;...` |
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...` |
451
451
 
452
452
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L26)
453
453
 
@@ -455,7 +455,7 @@ A schema that validates a value is an Uint8Array.
455
455
 
456
456
  | Constant | Type |
457
457
  | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
458
- | `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, { ...;...` |
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...` |
459
459
 
460
460
  [:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/hooks/db/hooks.ts#L37)
461
461
 
@@ -685,7 +685,7 @@ The function takes a context argument and returns `void`.
685
685
 
686
686
  Defines the `run` function schema for hooks.
687
687
 
688
- The function takes a context argument and returns a `Promise<void>`.
688
+ The function takes a context argument and returns either a `Promise<void>` or `void`.
689
689
 
690
690
  | Type | Type |
691
691
  | ------------- | ------------------------------------------------------------- |
@@ -4,7 +4,7 @@ import { SatelliteEnvSchema } from '../schemas/satellite.env';
4
4
  * @see AssertSetDoc
5
5
  */
6
6
  export declare const AssertSetDocSchema: z.ZodObject<z.objectUtil.extendShape<{
7
- collections: z.ZodArray<z.ZodString, "many">;
7
+ collections: z.ZodReadonly<z.ZodArray<z.ZodString, "many">>;
8
8
  }, {
9
9
  /**
10
10
  * A function that runs when the assertion is triggered for the specified collections.
@@ -163,7 +163,7 @@ export declare const AssertSetDocSchema: z.ZodObject<z.objectUtil.extendShape<{
163
163
  caller: Uint8Array<ArrayBufferLike>;
164
164
  }>], z.ZodUnknown>, z.ZodVoid>;
165
165
  }>, "strict", z.ZodTypeAny, {
166
- collections: string[];
166
+ collections: readonly string[];
167
167
  assert: (args_0: {
168
168
  data: {
169
169
  data: {
@@ -187,7 +187,7 @@ export declare const AssertSetDocSchema: z.ZodObject<z.objectUtil.extendShape<{
187
187
  caller: Uint8Array<ArrayBufferLike>;
188
188
  }, ...args: unknown[]) => void;
189
189
  }, {
190
- collections: string[];
190
+ collections: readonly string[];
191
191
  assert: (args_0: {
192
192
  data: {
193
193
  data: {
@@ -219,7 +219,7 @@ export type AssertSetDoc = z.infer<typeof AssertSetDocSchema>;
219
219
  * @see Assert
220
220
  */
221
221
  export declare const AssertSchema: z.ZodObject<z.objectUtil.extendShape<{
222
- collections: z.ZodArray<z.ZodString, "many">;
222
+ collections: z.ZodReadonly<z.ZodArray<z.ZodString, "many">>;
223
223
  }, {
224
224
  /**
225
225
  * A function that runs when the assertion is triggered for the specified collections.
@@ -378,7 +378,7 @@ export declare const AssertSchema: z.ZodObject<z.objectUtil.extendShape<{
378
378
  caller: Uint8Array<ArrayBufferLike>;
379
379
  }>], z.ZodUnknown>, z.ZodVoid>;
380
380
  }>, "strict", z.ZodTypeAny, {
381
- collections: string[];
381
+ collections: readonly string[];
382
382
  assert: (args_0: {
383
383
  data: {
384
384
  data: {
@@ -402,7 +402,7 @@ export declare const AssertSchema: z.ZodObject<z.objectUtil.extendShape<{
402
402
  caller: Uint8Array<ArrayBufferLike>;
403
403
  }, ...args: unknown[]) => void;
404
404
  }, {
405
- collections: string[];
405
+ collections: readonly string[];
406
406
  assert: (args_0: {
407
407
  data: {
408
408
  data: {
@@ -4,7 +4,7 @@ import { SatelliteEnvSchema } from '../schemas/satellite.env';
4
4
  * @see OnSetDoc
5
5
  */
6
6
  export declare const OnSetDocSchema: z.ZodObject<z.objectUtil.extendShape<{
7
- collections: z.ZodArray<z.ZodString, "many">;
7
+ collections: z.ZodReadonly<z.ZodArray<z.ZodString, "many">>;
8
8
  }, {
9
9
  /**
10
10
  * A function that runs when the hook is triggered for the specified collections.
@@ -188,9 +188,9 @@ export declare const OnSetDocSchema: z.ZodObject<z.objectUtil.extendShape<{
188
188
  collection: string;
189
189
  };
190
190
  caller: Uint8Array<ArrayBufferLike>;
191
- }>], z.ZodUnknown>, z.ZodPromise<z.ZodVoid>>;
191
+ }>], z.ZodUnknown>, z.ZodUnion<[z.ZodPromise<z.ZodVoid>, z.ZodVoid]>>;
192
192
  }>, "strict", z.ZodTypeAny, {
193
- collections: string[];
193
+ collections: readonly string[];
194
194
  run: (args_0: {
195
195
  data: {
196
196
  data: {
@@ -215,9 +215,9 @@ export declare const OnSetDocSchema: z.ZodObject<z.objectUtil.extendShape<{
215
215
  collection: string;
216
216
  };
217
217
  caller: Uint8Array<ArrayBufferLike>;
218
- }, ...args: unknown[]) => Promise<void>;
218
+ }, ...args: unknown[]) => void | Promise<void>;
219
219
  }, {
220
- collections: string[];
220
+ collections: readonly string[];
221
221
  run: (args_0: {
222
222
  data: {
223
223
  data: {
@@ -242,7 +242,7 @@ export declare const OnSetDocSchema: z.ZodObject<z.objectUtil.extendShape<{
242
242
  collection: string;
243
243
  };
244
244
  caller: Uint8Array<ArrayBufferLike>;
245
- }, ...args: unknown[]) => Promise<void>;
245
+ }, ...args: unknown[]) => void | Promise<void>;
246
246
  }>;
247
247
  /**
248
248
  * A hook that runs when a document is created or updated.
@@ -252,7 +252,7 @@ export type OnSetDoc = z.infer<typeof OnSetDocSchema>;
252
252
  * @see Hook
253
253
  */
254
254
  export declare const HookSchema: z.ZodObject<z.objectUtil.extendShape<{
255
- collections: z.ZodArray<z.ZodString, "many">;
255
+ collections: z.ZodReadonly<z.ZodArray<z.ZodString, "many">>;
256
256
  }, {
257
257
  /**
258
258
  * A function that runs when the hook is triggered for the specified collections.
@@ -436,9 +436,9 @@ export declare const HookSchema: z.ZodObject<z.objectUtil.extendShape<{
436
436
  collection: string;
437
437
  };
438
438
  caller: Uint8Array<ArrayBufferLike>;
439
- }>], z.ZodUnknown>, z.ZodPromise<z.ZodVoid>>;
439
+ }>], z.ZodUnknown>, z.ZodUnion<[z.ZodPromise<z.ZodVoid>, z.ZodVoid]>>;
440
440
  }>, "strict", z.ZodTypeAny, {
441
- collections: string[];
441
+ collections: readonly string[];
442
442
  run: (args_0: {
443
443
  data: {
444
444
  data: {
@@ -463,9 +463,9 @@ export declare const HookSchema: z.ZodObject<z.objectUtil.extendShape<{
463
463
  collection: string;
464
464
  };
465
465
  caller: Uint8Array<ArrayBufferLike>;
466
- }, ...args: unknown[]) => Promise<void>;
466
+ }, ...args: unknown[]) => void | Promise<void>;
467
467
  }, {
468
- collections: string[];
468
+ collections: readonly string[];
469
469
  run: (args_0: {
470
470
  data: {
471
471
  data: {
@@ -490,7 +490,7 @@ export declare const HookSchema: z.ZodObject<z.objectUtil.extendShape<{
490
490
  collection: string;
491
491
  };
492
492
  caller: Uint8Array<ArrayBufferLike>;
493
- }, ...args: unknown[]) => Promise<void>;
493
+ }, ...args: unknown[]) => void | Promise<void>;
494
494
  }>;
495
495
  /**
496
496
  * All hooks definitions.
@@ -6,11 +6,11 @@ export declare const CollectionsSchema: z.ZodObject<{
6
6
  /**
7
7
  * An array containing at least one collection name where the hook or assertion will be executed.
8
8
  */
9
- collections: z.ZodArray<z.ZodString, "many">;
9
+ collections: z.ZodReadonly<z.ZodArray<z.ZodString, "many">>;
10
10
  }, "strict", z.ZodTypeAny, {
11
- collections: string[];
11
+ collections: readonly string[];
12
12
  }, {
13
- collections: string[];
13
+ collections: readonly string[];
14
14
  }>;
15
15
  /**
16
16
  * Defines the collections where a hook or assertion should run.
@@ -69,11 +69,11 @@ export type AssertFunction<T> = z.infer<ReturnType<typeof AssertFunctionSchema<z
69
69
  /**
70
70
  * @see RunFunction
71
71
  */
72
- export declare const RunFunctionSchema: <T extends z.ZodTypeAny>(contextSchema: T) => z.ZodFunction<z.ZodTuple<[T], z.ZodUnknown>, z.ZodPromise<z.ZodVoid>>;
72
+ export declare const RunFunctionSchema: <T extends z.ZodTypeAny>(contextSchema: T) => z.ZodFunction<z.ZodTuple<[T], z.ZodUnknown>, z.ZodUnion<[z.ZodPromise<z.ZodVoid>, z.ZodVoid]>>;
73
73
  /**
74
74
  * Defines the `run` function schema for hooks.
75
75
  *
76
- * The function takes a context argument and returns a `Promise<void>`.
76
+ * The function takes a context argument and returns either a `Promise<void>` or `void`.
77
77
  *
78
78
  * @template T - The type of context passed to the function.
79
79
  */
package/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as I,b as T,c as S,d as J,e as y,f as d,g as h,h as z,i as r}from"./chunk-LVVTFR6B.js";import{a as U,b as w,c as P}from"./chunk-CCKUQNB5.js";import*as i from"zod";import*as o from"zod";var n=o.object({collections:o.array(o.string()).min(1)}).strict();import*as t from"zod";var f=e=>t.object({caller:S,data:e}).strict(),A=e=>t.function().args(e).returns(t.void()),l=e=>t.function().args(e).returns(t.promise(t.void()));import*as O from"zod";import*as s from"zod";var u=s.object({before:r.optional(),after:r}).strict(),j=s.object({data:z,description:h.optional(),version:T.optional()}).strict(),k=s.object({current:r.optional(),proposed:j}).strict();var D=e=>O.object({collection:y,key:d,data:e}).strict(),F=f(D(u)),H=f(D(k));import*as c from"zod";var p=c.record(c.unknown());var C=e=>n.extend({assert:A(e)}).strict(),Z=C(H),oe=Z,R=e=>i.function().args(p).returns(e),re=e=>i.union([e,R(e)]);function ne(e){return e}import*as m from"zod";var v=e=>n.extend({run:l(e)}).strict(),g=v(F),ae=g,_=e=>m.function().args(p).returns(e),xe=e=>m.union([e,_(e)]);function fe(e){return e}import{jsonReplacer as E}from"@dfinity/utils";var a=e=>{let b=e.map(x=>typeof x=="object"?JSON.stringify(x,E):x).join(" ");globalThis.__ic_cdk_print(b)};globalThis.console={info(...e){a(e)},log(...e){a(e)},warn(...e){a(e)},error(...e){a(e)}};export{re as AssertFnOrObjectSchema,R as AssertFnSchema,A as AssertFunctionSchema,oe as AssertSchema,H as AssertSetDocContextSchema,Z as AssertSetDocSchema,y as CollectionSchema,n as CollectionsSchema,k as DocAssertSetSchema,D as DocContextSchema,h as DocDescriptionSchema,r as DocSchema,u as DocUpsertSchema,f as HookContextSchema,xe as HookFnOrObjectSchema,_ as HookFnSchema,ae as HookSchema,d as KeySchema,F as OnSetDocContextSchema,g as OnSetDocSchema,P as PrincipalSchema,j as ProposedDocSchema,z as RawDataSchema,w as RawPrincipalSchema,S as RawUserIdSchema,l as RunFunctionSchema,p as SatelliteEnvSchema,I as TimestampSchema,U as Uint8ArraySchema,J as UserIdSchema,T as VersionSchema,ne as defineAssert,fe as defineHook};
1
+ import{a as I,b as T,c as S,d as J,e as y,f as d,g as h,h as z,i as r}from"./chunk-LVVTFR6B.js";import{a as U,b as w,c as P}from"./chunk-CCKUQNB5.js";import*as i from"zod";import*as o from"zod";var n=o.object({collections:o.array(o.string()).min(1).readonly()}).strict();import*as t from"zod";var f=e=>t.object({caller:S,data:e}).strict(),A=e=>t.function().args(e).returns(t.void()),l=e=>t.function().args(e).returns(t.promise(t.void()).or(t.void()));import*as O from"zod";import*as s from"zod";var u=s.object({before:r.optional(),after:r}).strict(),j=s.object({data:z,description:h.optional(),version:T.optional()}).strict(),k=s.object({current:r.optional(),proposed:j}).strict();var D=e=>O.object({collection:y,key:d,data:e}).strict(),F=f(D(u)),H=f(D(k));import*as c from"zod";var p=c.record(c.unknown());var C=e=>n.extend({assert:A(e)}).strict(),Z=C(H),oe=Z,v=e=>i.function().args(p).returns(e),re=e=>i.union([e,v(e)]);function ne(e){return e}import*as m from"zod";var R=e=>n.extend({run:l(e)}).strict(),g=R(F),ae=g,_=e=>m.function().args(p).returns(e),xe=e=>m.union([e,_(e)]);function fe(e){return e}import{jsonReplacer as E}from"@dfinity/utils";var a=e=>{let b=e.map(x=>typeof x=="object"?JSON.stringify(x,E):x).join(" ");globalThis.__ic_cdk_print(b)};globalThis.console={info(...e){a(e)},log(...e){a(e)},warn(...e){a(e)},error(...e){a(e)}};export{re as AssertFnOrObjectSchema,v as AssertFnSchema,A as AssertFunctionSchema,oe as AssertSchema,H as AssertSetDocContextSchema,Z as AssertSetDocSchema,y as CollectionSchema,n as CollectionsSchema,k as DocAssertSetSchema,D as DocContextSchema,h as DocDescriptionSchema,r as DocSchema,u as DocUpsertSchema,f as HookContextSchema,xe as HookFnOrObjectSchema,_ as HookFnSchema,ae as HookSchema,d as KeySchema,F as OnSetDocContextSchema,g as OnSetDocSchema,P as PrincipalSchema,j as ProposedDocSchema,z as RawDataSchema,w as RawPrincipalSchema,S as RawUserIdSchema,l as RunFunctionSchema,p as SatelliteEnvSchema,I as TimestampSchema,U as Uint8ArraySchema,J as UserIdSchema,T as VersionSchema,ne as defineAssert,fe as defineHook};
2
2
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["src/hooks/db/assertions.ts", "src/hooks/schemas/collections.ts", "src/hooks/schemas/context.ts", "src/hooks/schemas/db/context.ts", "src/hooks/schemas/db/payload.ts", "src/hooks/schemas/satellite.env.ts", "src/hooks/db/hooks.ts", "src/polyfills/console.polyfill.ts"],
4
- "sourcesContent": ["import * as z from 'zod';\nimport {CollectionsSchema} from '../schemas/collections';\nimport {AssertFunctionSchema} from '../schemas/context';\nimport {AssertSetDocContextSchema} from '../schemas/db/context';\nimport {SatelliteEnvSchema} from '../schemas/satellite.env';\n\n/**\n * A generic schema for defining assertions related to collections.\n *\n * @template T - The type of context passed to the assertions when triggered.\n */\nconst OnAssertSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the assertion is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {void} Resolves when the assertion completes.\n */\n assert: AssertFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * @see AssertSetDoc\n */\nexport const AssertSetDocSchema = OnAssertSchema(AssertSetDocContextSchema);\n\n/**\n * An assertion that runs when a document is created or updated.\n */\nexport type AssertSetDoc = z.infer<typeof AssertSetDocSchema>;\n\n// TODO: to be extended\n/**\n * @see Assert\n */\nexport const AssertSchema = AssertSetDocSchema;\n\n/**\n * All assertions definitions.\n */\nexport type Assert = z.infer<typeof AssertSchema>;\n\nexport const AssertFnSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.function().args(SatelliteEnvSchema).returns(assertSchema);\nexport type AssertFn<T extends Assert> = (assert: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const AssertFnOrObjectSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.union([assertSchema, AssertFnSchema(assertSchema)]);\nexport type AssertFnOrObject<T extends Assert> = T | AssertFn<T>;\n\nexport function defineAssert<T extends Assert>(assert: T): T;\nexport function defineAssert<T extends Assert>(assert: AssertFn<T>): AssertFn<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T> {\n return assert;\n}\n", "import * as z from 'zod';\n\n/**\n * @see Collections\n */\nexport const CollectionsSchema = z\n .object({\n /**\n * An array containing at least one collection name where the hook or assertion will be executed.\n */\n collections: z.array(z.string()).min(1)\n })\n .strict();\n\n/**\n * Defines the collections where a hook or assertion should run.\n */\nexport type Collections = z.infer<typeof CollectionsSchema>;\n", "import * as z from 'zod';\nimport {RawUserIdSchema} from '../../schemas/satellite';\n\n/**\n * @see HookContext\n */\nexport const HookContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z\n .object({\n /**\n * The user who originally triggered the function that in turn triggered the hook.\n */\n caller: RawUserIdSchema,\n\n /**\n * The data associated with the hook execution.\n */\n data: dataSchema\n })\n .strict();\n\n/**\n * Represents the context provided to hooks, containing information about the caller and related data.\n *\n * @template T - The type of data associated with the hook.\n */\nexport type HookContext<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof HookContextSchema<T>>>;\n\n/**\n * @see AssertFunction\n */\nexport const AssertFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n z.function().args(contextSchema).returns(z.void());\n\n/**\n * Defines the `assert` function schema for assertions.\n *\n * The function takes a context argument and returns `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type AssertFunction<T> = z.infer<ReturnType<typeof AssertFunctionSchema<z.ZodType<T>>>>;\n\n/**\n * @see RunFunction\n */\nexport const RunFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n z.function().args(contextSchema).returns(z.promise(z.void()));\n\n/**\n * Defines the `run` function schema for hooks.\n *\n * The function takes a context argument and returns a `Promise<void>`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type RunFunction<T> = z.infer<ReturnType<typeof RunFunctionSchema<z.ZodType<T>>>>;\n", "import * as z from 'zod';\nimport {CollectionSchema, KeySchema} from '../../../schemas/satellite';\nimport {HookContextSchema} from '../context';\nimport {DocAssertSetSchema, DocUpsertSchema} from './payload';\n\n/**\n * @see DocContext\n */\nexport const DocContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z\n .object({\n /**\n * The name of the collection where the document is stored.\n */\n collection: CollectionSchema,\n\n /**\n * The unique key identifying the document within the collection.\n */\n key: KeySchema,\n\n /**\n * The data associated with the document operation.\n */\n data: dataSchema\n })\n .strict();\n\n/**\n * Represents the context of a document operation within a collection.\n *\n * @template T - The type of data associated with the document.\n */\nexport type DocContext<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof DocContextSchema<T>>>;\n\n/**\n * @see OnSetDocContext\n */\nexport const OnSetDocContextSchema = HookContextSchema(DocContextSchema(DocUpsertSchema));\n\n/**\n * The context provided to the `onSetDoc` hook.\n *\n * This context contains information about the document being created or updated,\n * along with details about the user who triggered the operation.\n */\nexport type OnSetDocContext = z.infer<typeof OnSetDocContextSchema>;\n\n/**\n * @see AssertSetDocContext\n */\nexport const AssertSetDocContextSchema = HookContextSchema(DocContextSchema(DocAssertSetSchema));\n\n/**\n * The context provided to the `assertSetDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is created or updated. If validation fails, the developer should throw an error.\n */\nexport type AssertSetDocContext = z.infer<typeof AssertSetDocContextSchema>;\n", "import * as z from 'zod';\nimport {DocDescriptionSchema, DocSchema, RawDataSchema} from '../../../schemas/db';\nimport {VersionSchema} from '../../../schemas/satellite';\n\n/**\n * @see DocUpsert\n */\nexport const DocUpsertSchema = z\n .object({\n /**\n * The previous version of the document before the update.\n * Undefined if this is a new document.\n */\n before: DocSchema.optional(),\n\n /**\n * The new version of the document after the update.\n */\n after: DocSchema\n })\n .strict();\n\n/**\n * Represents a document update operation.\n *\n * This is used in hooks where a document is either being created or updated.\n */\nexport type DocUpsert = z.infer<typeof DocUpsertSchema>;\n\n/**\n * @see ProposedDoc\n */\nexport const ProposedDocSchema = z\n .object({\n /**\n * The raw data of the document.\n */\n data: RawDataSchema,\n\n /**\n * An optional description of the document.\n */\n description: DocDescriptionSchema.optional(),\n\n /**\n * The expected version number to ensure consistency.\n */\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document.\n * This can be validated before allowing the operation.\n */\nexport type ProposedDoc = z.infer<typeof ProposedDocSchema>;\n\n/**\n * @see DocAssertSet\n */\nexport const DocAssertSetSchema = z\n .object({\n /**\n * The current version of the document before the operation.\n * Undefined if this is a new document.\n */\n current: DocSchema.optional(),\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: ProposedDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before setting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport type DocAssertSet = z.infer<typeof DocAssertSetSchema>;\n", "import * as z from 'zod';\n\n/**\n * @see SatelliteEnv\n */\nexport const SatelliteEnvSchema = z.record(z.unknown());\n\n/**\n * Placeholder for future environment-specific configurations.\n *\n * Currently unused, but it may support features such as:\n * - Defining the execution mode (e.g., staging or production).\n * - Providing environment-specific values like `ckBtcLedgerId` for test or production.\n */\nexport type SatelliteEnv = z.infer<typeof SatelliteEnvSchema>;\n", "import * as z from 'zod';\nimport {CollectionsSchema} from '../schemas/collections';\nimport {RunFunctionSchema} from '../schemas/context';\nimport {OnSetDocContextSchema} from '../schemas/db/context';\nimport {SatelliteEnvSchema} from '../schemas/satellite.env';\n\n/**\n * A generic schema for defining hooks related to collections.\n *\n * @template T - The type of context passed to the hook when triggered.\n */\nconst OnHookSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the hook is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {Promise<void>} Resolves when the operation completes.\n */\n run: RunFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * @see OnSetDoc\n */\nexport const OnSetDocSchema = OnHookSchema(OnSetDocContextSchema);\n\n/**\n * A hook that runs when a document is created or updated.\n */\nexport type OnSetDoc = z.infer<typeof OnSetDocSchema>;\n\n// TODO: to be extended\n/**\n * @see Hook\n */\nexport const HookSchema = OnSetDocSchema;\n\n/**\n * All hooks definitions.\n */\nexport type Hook = z.infer<typeof HookSchema>;\n\nexport const HookFnSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.function().args(SatelliteEnvSchema).returns(hookSchema);\nexport type HookFn<T extends Hook> = (hook: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const HookFnOrObjectSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.union([hookSchema, HookFnSchema(hookSchema)]);\nexport type HookFnOrObject<T extends Hook> = T | HookFn<T>;\n\nexport function defineHook<T extends Hook>(hook: T): T;\nexport function defineHook<T extends Hook>(hook: HookFn<T>): HookFn<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T> {\n return hook;\n}\n", "import {jsonReplacer} from '@dfinity/utils';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst __juno_satellite_console_log = (v: any[]) => {\n const msg = v\n .map((arg) => (typeof arg === 'object' ? JSON.stringify(arg, jsonReplacer) : arg))\n .join(' ');\n\n globalThis.__ic_cdk_print(msg);\n};\n\n// @ts-expect-error We want to override the console\nglobalThis.console = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n info(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n log(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n warn(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error(...v: any[]) {\n __juno_satellite_console_log(v);\n }\n};\n"],
5
- "mappings": "sJAAA,UAAYA,MAAO,MCAnB,UAAYC,MAAO,MAKZ,IAAMC,EACV,SAAO,CAIN,YAAe,QAAQ,SAAO,CAAC,EAAE,IAAI,CAAC,CACxC,CAAC,EACA,OAAO,ECZV,UAAYC,MAAO,MAMZ,IAAMC,EAA6CC,GAErD,SAAO,CAIN,OAAQC,EAKR,KAAMD,CACR,CAAC,EACA,OAAO,EAYCE,EAAgDC,GACzD,WAAS,EAAE,KAAKA,CAAa,EAAE,QAAU,OAAK,CAAC,EActCC,EAA6CD,GACtD,WAAS,EAAE,KAAKA,CAAa,EAAE,QAAU,UAAU,OAAK,CAAC,CAAC,EC/C9D,UAAYE,MAAO,MCAnB,UAAYC,MAAO,MAOZ,IAAMC,EACV,SAAO,CAKN,OAAQC,EAAU,SAAS,EAK3B,MAAOA,CACT,CAAC,EACA,OAAO,EAYGC,EACV,SAAO,CAIN,KAAMC,EAKN,YAAaC,EAAqB,SAAS,EAK3C,QAASC,EAAc,SAAS,CAClC,CAAC,EACA,OAAO,EAWGC,EACV,SAAO,CAKN,QAASL,EAAU,SAAS,EAM5B,SAAUC,CACZ,CAAC,EACA,OAAO,EDlEH,IAAMK,EAA4CC,GAEpD,SAAO,CAIN,WAAYC,EAKZ,IAAKC,EAKL,KAAMF,CACR,CAAC,EACA,OAAO,EAYCG,EAAwBC,EAAkBL,EAAiBM,CAAe,CAAC,EAa3EC,EAA4BF,EAAkBL,EAAiBQ,CAAkB,CAAC,EEnD/F,UAAYC,MAAO,MAKZ,IAAMC,EAAuB,SAAS,UAAQ,CAAC,ELMtD,IAAMC,EAA0CC,GAC9CC,EAAkB,OAAO,CAOvB,OAAQC,EAAwBF,CAAa,CAC/C,CAAC,EAAE,OAAO,EAKCG,EAAqBJ,EAAeK,CAAyB,EAW7DC,GAAeF,EAOfG,EAA0CC,GACnD,WAAS,EAAE,KAAKC,CAAkB,EAAE,QAAQD,CAAY,EAG/CE,GAAkDF,GAC3D,QAAM,CAACA,EAAcD,EAAeC,CAAY,CAAC,CAAC,EAM/C,SAASG,GAA+BC,EAAkD,CAC/F,OAAOA,CACT,CMxDA,UAAYC,MAAO,MAWnB,IAAMC,EAAwCC,GAC5CC,EAAkB,OAAO,CAOvB,IAAKC,EAAqBF,CAAa,CACzC,CAAC,EAAE,OAAO,EAKCG,EAAiBJ,EAAaK,CAAqB,EAWnDC,GAAaF,EAObG,EAAwCC,GACjD,WAAS,EAAE,KAAKC,CAAkB,EAAE,QAAQD,CAAU,EAG7CE,GAAgDF,GACzD,QAAM,CAACA,EAAYD,EAAaC,CAAU,CAAC,CAAC,EAMzC,SAASG,GAA2BC,EAA4C,CACrF,OAAOA,CACT,CCxDA,OAAQ,gBAAAC,MAAmB,iBAG3B,IAAMC,EAAgCC,GAAa,CACjD,IAAMC,EAAMD,EACT,IAAKE,GAAS,OAAOA,GAAQ,SAAW,KAAK,UAAUA,EAAKJ,CAAY,EAAII,CAAI,EAChF,KAAK,GAAG,EAEX,WAAW,eAAeD,CAAG,CAC/B,EAGA,WAAW,QAAU,CAEnB,QAAQD,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,OAAOA,EAAU,CACfD,EAA6BC,CAAC,CAChC,EAEA,QAAQA,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,SAASA,EAAU,CACjBD,EAA6BC,CAAC,CAChC,CACF",
4
+ "sourcesContent": ["import * as z from 'zod';\nimport {CollectionsSchema} from '../schemas/collections';\nimport {AssertFunctionSchema} from '../schemas/context';\nimport {AssertSetDocContextSchema} from '../schemas/db/context';\nimport {SatelliteEnvSchema} from '../schemas/satellite.env';\n\n/**\n * A generic schema for defining assertions related to collections.\n *\n * @template T - The type of context passed to the assertions when triggered.\n */\nconst OnAssertSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the assertion is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {void} Resolves when the assertion completes.\n */\n assert: AssertFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * @see AssertSetDoc\n */\nexport const AssertSetDocSchema = OnAssertSchema(AssertSetDocContextSchema);\n\n/**\n * An assertion that runs when a document is created or updated.\n */\nexport type AssertSetDoc = z.infer<typeof AssertSetDocSchema>;\n\n// TODO: to be extended\n/**\n * @see Assert\n */\nexport const AssertSchema = AssertSetDocSchema;\n\n/**\n * All assertions definitions.\n */\nexport type Assert = z.infer<typeof AssertSchema>;\n\nexport const AssertFnSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.function().args(SatelliteEnvSchema).returns(assertSchema);\nexport type AssertFn<T extends Assert> = (assert: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const AssertFnOrObjectSchema = <T extends z.ZodTypeAny>(assertSchema: T) =>\n z.union([assertSchema, AssertFnSchema(assertSchema)]);\nexport type AssertFnOrObject<T extends Assert> = T | AssertFn<T>;\n\nexport function defineAssert<T extends Assert>(assert: T): T;\nexport function defineAssert<T extends Assert>(assert: AssertFn<T>): AssertFn<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T>;\nexport function defineAssert<T extends Assert>(assert: AssertFnOrObject<T>): AssertFnOrObject<T> {\n return assert;\n}\n", "import * as z from 'zod';\n\n/**\n * @see Collections\n */\nexport const CollectionsSchema = z\n .object({\n /**\n * An array containing at least one collection name where the hook or assertion will be executed.\n */\n collections: z.array(z.string()).min(1).readonly()\n })\n .strict();\n\n/**\n * Defines the collections where a hook or assertion should run.\n */\nexport type Collections = z.infer<typeof CollectionsSchema>;\n", "import * as z from 'zod';\nimport {RawUserIdSchema} from '../../schemas/satellite';\n\n/**\n * @see HookContext\n */\nexport const HookContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z\n .object({\n /**\n * The user who originally triggered the function that in turn triggered the hook.\n */\n caller: RawUserIdSchema,\n\n /**\n * The data associated with the hook execution.\n */\n data: dataSchema\n })\n .strict();\n\n/**\n * Represents the context provided to hooks, containing information about the caller and related data.\n *\n * @template T - The type of data associated with the hook.\n */\nexport type HookContext<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof HookContextSchema<T>>>;\n\n/**\n * @see AssertFunction\n */\nexport const AssertFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n z.function().args(contextSchema).returns(z.void());\n\n/**\n * Defines the `assert` function schema for assertions.\n *\n * The function takes a context argument and returns `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type AssertFunction<T> = z.infer<ReturnType<typeof AssertFunctionSchema<z.ZodType<T>>>>;\n\n/**\n * @see RunFunction\n */\nexport const RunFunctionSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n z.function().args(contextSchema).returns(z.promise(z.void()).or(z.void()));\n\n/**\n * Defines the `run` function schema for hooks.\n *\n * The function takes a context argument and returns either a `Promise<void>` or `void`.\n *\n * @template T - The type of context passed to the function.\n */\nexport type RunFunction<T> = z.infer<ReturnType<typeof RunFunctionSchema<z.ZodType<T>>>>;\n", "import * as z from 'zod';\nimport {CollectionSchema, KeySchema} from '../../../schemas/satellite';\nimport {HookContextSchema} from '../context';\nimport {DocAssertSetSchema, DocUpsertSchema} from './payload';\n\n/**\n * @see DocContext\n */\nexport const DocContextSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>\n z\n .object({\n /**\n * The name of the collection where the document is stored.\n */\n collection: CollectionSchema,\n\n /**\n * The unique key identifying the document within the collection.\n */\n key: KeySchema,\n\n /**\n * The data associated with the document operation.\n */\n data: dataSchema\n })\n .strict();\n\n/**\n * Represents the context of a document operation within a collection.\n *\n * @template T - The type of data associated with the document.\n */\nexport type DocContext<T extends z.ZodTypeAny> = z.infer<ReturnType<typeof DocContextSchema<T>>>;\n\n/**\n * @see OnSetDocContext\n */\nexport const OnSetDocContextSchema = HookContextSchema(DocContextSchema(DocUpsertSchema));\n\n/**\n * The context provided to the `onSetDoc` hook.\n *\n * This context contains information about the document being created or updated,\n * along with details about the user who triggered the operation.\n */\nexport type OnSetDocContext = z.infer<typeof OnSetDocContextSchema>;\n\n/**\n * @see AssertSetDocContext\n */\nexport const AssertSetDocContextSchema = HookContextSchema(DocContextSchema(DocAssertSetSchema));\n\n/**\n * The context provided to the `assertSetDoc` hook.\n *\n * This context contains information about the document being validated before\n * it is created or updated. If validation fails, the developer should throw an error.\n */\nexport type AssertSetDocContext = z.infer<typeof AssertSetDocContextSchema>;\n", "import * as z from 'zod';\nimport {DocDescriptionSchema, DocSchema, RawDataSchema} from '../../../schemas/db';\nimport {VersionSchema} from '../../../schemas/satellite';\n\n/**\n * @see DocUpsert\n */\nexport const DocUpsertSchema = z\n .object({\n /**\n * The previous version of the document before the update.\n * Undefined if this is a new document.\n */\n before: DocSchema.optional(),\n\n /**\n * The new version of the document after the update.\n */\n after: DocSchema\n })\n .strict();\n\n/**\n * Represents a document update operation.\n *\n * This is used in hooks where a document is either being created or updated.\n */\nexport type DocUpsert = z.infer<typeof DocUpsertSchema>;\n\n/**\n * @see ProposedDoc\n */\nexport const ProposedDocSchema = z\n .object({\n /**\n * The raw data of the document.\n */\n data: RawDataSchema,\n\n /**\n * An optional description of the document.\n */\n description: DocDescriptionSchema.optional(),\n\n /**\n * The expected version number to ensure consistency.\n */\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document.\n * This can be validated before allowing the operation.\n */\nexport type ProposedDoc = z.infer<typeof ProposedDocSchema>;\n\n/**\n * @see DocAssertSet\n */\nexport const DocAssertSetSchema = z\n .object({\n /**\n * The current version of the document before the operation.\n * Undefined if this is a new document.\n */\n current: DocSchema.optional(),\n\n /**\n * The proposed version of the document.\n * This can be validated before allowing the operation.\n */\n proposed: ProposedDocSchema\n })\n .strict();\n\n/**\n * Represents a validation check before setting a document.\n *\n * The developer can compare the `current` and `proposed` versions and\n * throw an error if their validation fails.\n */\nexport type DocAssertSet = z.infer<typeof DocAssertSetSchema>;\n", "import * as z from 'zod';\n\n/**\n * @see SatelliteEnv\n */\nexport const SatelliteEnvSchema = z.record(z.unknown());\n\n/**\n * Placeholder for future environment-specific configurations.\n *\n * Currently unused, but it may support features such as:\n * - Defining the execution mode (e.g., staging or production).\n * - Providing environment-specific values like `ckBtcLedgerId` for test or production.\n */\nexport type SatelliteEnv = z.infer<typeof SatelliteEnvSchema>;\n", "import * as z from 'zod';\nimport {CollectionsSchema} from '../schemas/collections';\nimport {RunFunctionSchema} from '../schemas/context';\nimport {OnSetDocContextSchema} from '../schemas/db/context';\nimport {SatelliteEnvSchema} from '../schemas/satellite.env';\n\n/**\n * A generic schema for defining hooks related to collections.\n *\n * @template T - The type of context passed to the hook when triggered.\n */\nconst OnHookSchema = <T extends z.ZodTypeAny>(contextSchema: T) =>\n CollectionsSchema.extend({\n /**\n * A function that runs when the hook is triggered for the specified collections.\n *\n * @param {T} context - Contains information about the affected document(s).\n * @returns {Promise<void>} Resolves when the operation completes.\n */\n run: RunFunctionSchema<T>(contextSchema)\n }).strict();\n\n/**\n * @see OnSetDoc\n */\nexport const OnSetDocSchema = OnHookSchema(OnSetDocContextSchema);\n\n/**\n * A hook that runs when a document is created or updated.\n */\nexport type OnSetDoc = z.infer<typeof OnSetDocSchema>;\n\n// TODO: to be extended\n/**\n * @see Hook\n */\nexport const HookSchema = OnSetDocSchema;\n\n/**\n * All hooks definitions.\n */\nexport type Hook = z.infer<typeof HookSchema>;\n\nexport const HookFnSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.function().args(SatelliteEnvSchema).returns(hookSchema);\nexport type HookFn<T extends Hook> = (hook: z.infer<typeof SatelliteEnvSchema>) => T;\n\nexport const HookFnOrObjectSchema = <T extends z.ZodTypeAny>(hookSchema: T) =>\n z.union([hookSchema, HookFnSchema(hookSchema)]);\nexport type HookFnOrObject<T extends Hook> = T | HookFn<T>;\n\nexport function defineHook<T extends Hook>(hook: T): T;\nexport function defineHook<T extends Hook>(hook: HookFn<T>): HookFn<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T>;\nexport function defineHook<T extends Hook>(hook: HookFnOrObject<T>): HookFnOrObject<T> {\n return hook;\n}\n", "import {jsonReplacer} from '@dfinity/utils';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst __juno_satellite_console_log = (v: any[]) => {\n const msg = v\n .map((arg) => (typeof arg === 'object' ? JSON.stringify(arg, jsonReplacer) : arg))\n .join(' ');\n\n globalThis.__ic_cdk_print(msg);\n};\n\n// @ts-expect-error We want to override the console\nglobalThis.console = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n info(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n log(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n warn(...v: any[]) {\n __juno_satellite_console_log(v);\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error(...v: any[]) {\n __juno_satellite_console_log(v);\n }\n};\n"],
5
+ "mappings": "sJAAA,UAAYA,MAAO,MCAnB,UAAYC,MAAO,MAKZ,IAAMC,EACV,SAAO,CAIN,YAAe,QAAQ,SAAO,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS,CACnD,CAAC,EACA,OAAO,ECZV,UAAYC,MAAO,MAMZ,IAAMC,EAA6CC,GAErD,SAAO,CAIN,OAAQC,EAKR,KAAMD,CACR,CAAC,EACA,OAAO,EAYCE,EAAgDC,GACzD,WAAS,EAAE,KAAKA,CAAa,EAAE,QAAU,OAAK,CAAC,EActCC,EAA6CD,GACtD,WAAS,EAAE,KAAKA,CAAa,EAAE,QAAU,UAAU,OAAK,CAAC,EAAE,GAAK,OAAK,CAAC,CAAC,EC/C3E,UAAYE,MAAO,MCAnB,UAAYC,MAAO,MAOZ,IAAMC,EACV,SAAO,CAKN,OAAQC,EAAU,SAAS,EAK3B,MAAOA,CACT,CAAC,EACA,OAAO,EAYGC,EACV,SAAO,CAIN,KAAMC,EAKN,YAAaC,EAAqB,SAAS,EAK3C,QAASC,EAAc,SAAS,CAClC,CAAC,EACA,OAAO,EAWGC,EACV,SAAO,CAKN,QAASL,EAAU,SAAS,EAM5B,SAAUC,CACZ,CAAC,EACA,OAAO,EDlEH,IAAMK,EAA4CC,GAEpD,SAAO,CAIN,WAAYC,EAKZ,IAAKC,EAKL,KAAMF,CACR,CAAC,EACA,OAAO,EAYCG,EAAwBC,EAAkBL,EAAiBM,CAAe,CAAC,EAa3EC,EAA4BF,EAAkBL,EAAiBQ,CAAkB,CAAC,EEnD/F,UAAYC,MAAO,MAKZ,IAAMC,EAAuB,SAAS,UAAQ,CAAC,ELMtD,IAAMC,EAA0CC,GAC9CC,EAAkB,OAAO,CAOvB,OAAQC,EAAwBF,CAAa,CAC/C,CAAC,EAAE,OAAO,EAKCG,EAAqBJ,EAAeK,CAAyB,EAW7DC,GAAeF,EAOfG,EAA0CC,GACnD,WAAS,EAAE,KAAKC,CAAkB,EAAE,QAAQD,CAAY,EAG/CE,GAAkDF,GAC3D,QAAM,CAACA,EAAcD,EAAeC,CAAY,CAAC,CAAC,EAM/C,SAASG,GAA+BC,EAAkD,CAC/F,OAAOA,CACT,CMxDA,UAAYC,MAAO,MAWnB,IAAMC,EAAwCC,GAC5CC,EAAkB,OAAO,CAOvB,IAAKC,EAAqBF,CAAa,CACzC,CAAC,EAAE,OAAO,EAKCG,EAAiBJ,EAAaK,CAAqB,EAWnDC,GAAaF,EAObG,EAAwCC,GACjD,WAAS,EAAE,KAAKC,CAAkB,EAAE,QAAQD,CAAU,EAG7CE,GAAgDF,GACzD,QAAM,CAACA,EAAYD,EAAaC,CAAU,CAAC,CAAC,EAMzC,SAASG,GAA2BC,EAA4C,CACrF,OAAOA,CACT,CCxDA,OAAQ,gBAAAC,MAAmB,iBAG3B,IAAMC,EAAgCC,GAAa,CACjD,IAAMC,EAAMD,EACT,IAAKE,GAAS,OAAOA,GAAQ,SAAW,KAAK,UAAUA,EAAKJ,CAAY,EAAII,CAAI,EAChF,KAAK,GAAG,EAEX,WAAW,eAAeD,CAAG,CAC/B,EAGA,WAAW,QAAU,CAEnB,QAAQD,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,OAAOA,EAAU,CACfD,EAA6BC,CAAC,CAChC,EAEA,QAAQA,EAAU,CAChBD,EAA6BC,CAAC,CAChC,EAEA,SAASA,EAAU,CACjBD,EAA6BC,CAAC,CAChC,CACF",
6
6
  "names": ["z", "z", "CollectionsSchema", "z", "HookContextSchema", "dataSchema", "RawUserIdSchema", "AssertFunctionSchema", "contextSchema", "RunFunctionSchema", "z", "z", "DocUpsertSchema", "DocSchema", "ProposedDocSchema", "RawDataSchema", "DocDescriptionSchema", "VersionSchema", "DocAssertSetSchema", "DocContextSchema", "dataSchema", "CollectionSchema", "KeySchema", "OnSetDocContextSchema", "HookContextSchema", "DocUpsertSchema", "AssertSetDocContextSchema", "DocAssertSetSchema", "z", "SatelliteEnvSchema", "OnAssertSchema", "contextSchema", "CollectionsSchema", "AssertFunctionSchema", "AssertSetDocSchema", "AssertSetDocContextSchema", "AssertSchema", "AssertFnSchema", "assertSchema", "SatelliteEnvSchema", "AssertFnOrObjectSchema", "defineAssert", "assert", "z", "OnHookSchema", "contextSchema", "CollectionsSchema", "RunFunctionSchema", "OnSetDocSchema", "OnSetDocContextSchema", "HookSchema", "HookFnSchema", "hookSchema", "SatelliteEnvSchema", "HookFnOrObjectSchema", "defineHook", "hook", "jsonReplacer", "__juno_satellite_console_log", "v", "msg", "arg"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/functions",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "JavaScript and TypeScript utilities for Juno Serverless Functions",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",