@junobuild/functions 0.5.6 → 0.6.0

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.
Files changed (60) hide show
  1. package/README.md +753 -323
  2. package/canisters/_canister.d.ts +1 -1
  3. package/canisters/cmc/index.js +1 -1
  4. package/canisters/index.js +1 -1
  5. package/canisters/ledger/icp/index.js +1 -1
  6. package/canisters/ledger/icrc/index.js +1 -1
  7. package/canisters/ledger/icrc/schemas.d.ts +1 -1
  8. package/canisters/schemas.d.ts +1 -1
  9. package/{chunk-5NZMOUKF.js → chunk-2LVPADWI.js} +2 -2
  10. package/chunk-7JYM2CKB.js +2 -0
  11. package/chunk-7JYM2CKB.js.map +7 -0
  12. package/chunk-HVIYPRXX.js +2 -0
  13. package/chunk-HVIYPRXX.js.map +7 -0
  14. package/{chunk-EMQQE34V.js → chunk-W42LR3ZN.js} +2 -2
  15. package/chunk-XRHVLXYG.js +2 -0
  16. package/functions/constants.d.ts +8 -0
  17. package/functions/query.d.ts +49 -0
  18. package/functions/schemas/function.d.ts +170 -0
  19. package/functions/update.d.ts +49 -0
  20. package/functions/wrappers.d.ts +1 -0
  21. package/global.d.ts +1 -0
  22. package/hooks/assertions.d.ts +57 -57
  23. package/hooks/hooks.d.ts +116 -116
  24. package/hooks/schemas/context.d.ts +1 -1
  25. package/hooks/schemas/db/context.d.ts +26 -26
  26. package/hooks/schemas/db/payload.d.ts +9 -9
  27. package/hooks/schemas/storage/context.d.ts +19 -19
  28. package/hooks/schemas/storage/payload.d.ts +3 -3
  29. package/ic-cdk/caller.ic-cdk.d.ts +15 -0
  30. package/ic-cdk/id.ic-cdk.d.ts +11 -1
  31. package/ic-cdk/schemas/call.d.ts +1 -1
  32. package/ic-cdk.d.ts +1 -0
  33. package/ic-cdk.js +1 -1
  34. package/ic-cdk.js.map +4 -4
  35. package/index.d.ts +5 -1
  36. package/index.js +1 -1
  37. package/index.js.map +4 -4
  38. package/package.json +3 -2
  39. package/schemas/candid.d.ts +5 -6
  40. package/schemas/db.d.ts +7 -8
  41. package/schemas/list.d.ts +1 -1
  42. package/schemas/satellite.d.ts +4 -3
  43. package/schemas/storage.d.ts +9 -9
  44. package/sdk/schemas/controllers.d.ts +4 -4
  45. package/sdk/schemas/db.d.ts +10 -10
  46. package/sdk/schemas/params.d.ts +2 -2
  47. package/sdk/schemas/storage.d.ts +12 -12
  48. package/sdk.js +1 -1
  49. package/sdk.js.map +4 -4
  50. package/src/global.d.ts +1 -0
  51. package/utils/zod.utils.d.ts +4 -1
  52. package/chunk-7B6WU32N.js +0 -2
  53. package/chunk-7B6WU32N.js.map +0 -7
  54. package/chunk-KVADXJMF.js +0 -2
  55. package/chunk-KVADXJMF.js.map +0 -7
  56. package/chunk-TZVF5LQY.js +0 -2
  57. /package/{chunk-5NZMOUKF.js.map → chunk-2LVPADWI.js.map} +0 -0
  58. /package/{chunk-EMQQE34V.js.map → chunk-W42LR3ZN.js.map} +0 -0
  59. /package/{chunk-TZVF5LQY.js.map → chunk-XRHVLXYG.js.map} +0 -0
  60. /package/{hooks/schemas → schemas}/satellite.env.d.ts +0 -0
@@ -4,7 +4,7 @@ import * as z from 'zod';
4
4
  * @see CanisterParameters
5
5
  */
6
6
  export declare const CanisterParametersSchema: z.ZodObject<{
7
- canisterId: z.ZodCustom<Principal, Principal>;
7
+ canisterId: z.ZodPipe<z.ZodCustom<Principal, Principal>, z.ZodTransform<Principal, Principal>>;
8
8
  }, z.core.$strict>;
9
9
  /**
10
10
  * The parameters that define a canister.
@@ -1,2 +1,2 @@
1
- import{a as s}from"../../chunk-BXZ5PSUW.js";import{a as e}from"../../chunk-5NZMOUKF.js";import{g as i}from"../../chunk-EMQQE34V.js";import{a as p}from"../../chunk-TZVF5LQY.js";import"../../chunk-7B6WU32N.js";import{e as o}from"../../chunk-CAQXR2VB.js";import"../../chunk-4C666HHU.js";var r=class extends e{constructor(t={}){p.parse(t),super({canisterId:t?.canisterId??s})}notifyTopUp=async({args:t})=>await i({canisterId:this.canisterId,method:"notify_top_up",args:[[o.NotifyTopUpArg,t]],result:o.NotifyTopUpResult})};export{r as CMCCanister,o as CmcIdl};
1
+ import{a as s}from"../../chunk-BXZ5PSUW.js";import{a as e}from"../../chunk-2LVPADWI.js";import{g as i}from"../../chunk-W42LR3ZN.js";import{a as p}from"../../chunk-XRHVLXYG.js";import"../../chunk-7JYM2CKB.js";import{e as o}from"../../chunk-CAQXR2VB.js";import"../../chunk-4C666HHU.js";var r=class extends e{constructor(t={}){p.parse(t),super({canisterId:t?.canisterId??s})}notifyTopUp=async({args:t})=>await i({canisterId:this.canisterId,method:"notify_top_up",args:[[o.NotifyTopUpArg,t]],result:o.NotifyTopUpResult})};export{r as CMCCanister,o as CmcIdl};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{a as o}from"../chunk-TZVF5LQY.js";import"../chunk-7B6WU32N.js";import"../chunk-4C666HHU.js";export{o as CanisterOptionsSchema};
1
+ import{a as o}from"../chunk-XRHVLXYG.js";import"../chunk-7JYM2CKB.js";import"../chunk-4C666HHU.js";export{o as CanisterOptionsSchema};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{b as d}from"../../../chunk-BXZ5PSUW.js";import{a}from"../../../chunk-5NZMOUKF.js";import{g as t}from"../../../chunk-EMQQE34V.js";import{a as p}from"../../../chunk-TZVF5LQY.js";import"../../../chunk-7B6WU32N.js";import{g as i,h as e}from"../../../chunk-CAQXR2VB.js";import"../../../chunk-4C666HHU.js";var s=class extends a{constructor(r={}){p.parse(r),super({canisterId:r?.canisterId??d})}transfer=async({args:r})=>await t({canisterId:this.canisterId,method:"transfer",args:[[e.TransferArgs,r]],result:e.TransferResult})};export{i as IcpIndexIdl,s as IcpLedgerCanister,e as IcpLedgerIdl};
1
+ import{b as d}from"../../../chunk-BXZ5PSUW.js";import{a}from"../../../chunk-2LVPADWI.js";import{g as t}from"../../../chunk-W42LR3ZN.js";import{a as p}from"../../../chunk-XRHVLXYG.js";import"../../../chunk-7JYM2CKB.js";import{g as i,h as e}from"../../../chunk-CAQXR2VB.js";import"../../../chunk-4C666HHU.js";var s=class extends a{constructor(r={}){p.parse(r),super({canisterId:r?.canisterId??d})}transfer=async({args:r})=>await t({canisterId:this.canisterId,method:"transfer",args:[[e.TransferArgs,r]],result:e.TransferResult})};export{i as IcpIndexIdl,s as IcpLedgerCanister,e as IcpLedgerIdl};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"../../../chunk-5NZMOUKF.js";import{g as c}from"../../../chunk-EMQQE34V.js";import{a as t}from"../../../chunk-TZVF5LQY.js";import"../../../chunk-7B6WU32N.js";import{i as n,j as e}from"../../../chunk-CAQXR2VB.js";import"../../../chunk-4C666HHU.js";var i=t.required();var s=class extends a{constructor(r){i.parse(r),super({canisterId:r.canisterId})}icrc1BalanceOf=async({account:r})=>await c({canisterId:this.canisterId,method:"icrc1_balance_of",args:[[e.Account,r]],result:e.Tokens});icrc1Transfer=async({args:r})=>await c({canisterId:this.canisterId,method:"icrc1_transfer",args:[[e.TransferArg,r]],result:e.TransferResult});icrc2TransferFrom=async({args:r})=>await c({canisterId:this.canisterId,method:"icrc2_transfer_from",args:[[e.TransferFromArgs,r]],result:e.TransferFromResult})};export{i as IcrcCanisterOptionsSchema,n as IcrcIndexIdl,s as IcrcLedgerCanister,e as IcrcLedgerIdl};
1
+ import{a}from"../../../chunk-2LVPADWI.js";import{g as c}from"../../../chunk-W42LR3ZN.js";import{a as t}from"../../../chunk-XRHVLXYG.js";import"../../../chunk-7JYM2CKB.js";import{i as n,j as e}from"../../../chunk-CAQXR2VB.js";import"../../../chunk-4C666HHU.js";var i=t.required();var s=class extends a{constructor(r){i.parse(r),super({canisterId:r.canisterId})}icrc1BalanceOf=async({account:r})=>await c({canisterId:this.canisterId,method:"icrc1_balance_of",args:[[e.Account,r]],result:e.Tokens});icrc1Transfer=async({args:r})=>await c({canisterId:this.canisterId,method:"icrc1_transfer",args:[[e.TransferArg,r]],result:e.TransferResult});icrc2TransferFrom=async({args:r})=>await c({canisterId:this.canisterId,method:"icrc2_transfer_from",args:[[e.TransferFromArgs,r]],result:e.TransferFromResult})};export{i as IcrcCanisterOptionsSchema,n as IcrcIndexIdl,s as IcrcLedgerCanister,e as IcrcLedgerIdl};
2
2
  //# sourceMappingURL=index.js.map
@@ -3,7 +3,7 @@ import type * as z from 'zod';
3
3
  * @see CanisterOptions
4
4
  */
5
5
  export declare const IcrcCanisterOptionsSchema: z.ZodObject<{
6
- canisterId: z.ZodNonOptional<z.ZodOptional<z.ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>>;
6
+ canisterId: z.ZodNonOptional<z.ZodOptional<z.ZodPipe<z.ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, z.ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>>>;
7
7
  }, z.core.$strict>;
8
8
  /**
9
9
  * The options to initialize an Icrc canister.
@@ -3,7 +3,7 @@ import * as z from 'zod';
3
3
  * @see CanisterOptions
4
4
  */
5
5
  export declare const CanisterOptionsSchema: z.ZodObject<{
6
- canisterId: z.ZodOptional<z.ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>;
6
+ canisterId: z.ZodOptional<z.ZodPipe<z.ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, z.ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>>;
7
7
  }, z.core.$strict>;
8
8
  /**
9
9
  * The options to initialize a canister.
@@ -1,2 +1,2 @@
1
- import{c as r}from"./chunk-7B6WU32N.js";import*as e from"zod";var s=e.strictObject({canisterId:r}),t=class{#r;constructor({canisterId:a}){this.#r=a}get canisterId(){return this.#r}};export{t as a};
2
- //# sourceMappingURL=chunk-5NZMOUKF.js.map
1
+ import{c as r}from"./chunk-7JYM2CKB.js";import*as e from"zod";var s=e.strictObject({canisterId:r}),t=class{#r;constructor({canisterId:a}){this.#r=a}get canisterId(){return this.#r}};export{t as a};
2
+ //# sourceMappingURL=chunk-2LVPADWI.js.map
@@ -0,0 +1,2 @@
1
+ import{PrincipalSchema as r,Uint8ArraySchema as a}from"@junobuild/zod";var i=a,e=i,p=r;export{i as a,e as b,p as c};
2
+ //# sourceMappingURL=chunk-7JYM2CKB.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["src/schemas/candid.ts"],
4
+ "sourcesContent": ["import {\n PrincipalSchema as DfnPrincipalSchema,\n Uint8ArraySchema as DfnUint8ArraySchema\n} from '@junobuild/zod';\nimport type * as z from 'zod';\n\n/**\n * A schema that validates a value is an Uint8Array.\n */\nexport const Uint8ArraySchema = DfnUint8ArraySchema;\n\n/**\n * @see RawPrincipal\n */\nexport const RawPrincipalSchema = Uint8ArraySchema;\n\n/**\n * Represents a raw principal - a Uint8Array representation of a Principal.\n */\nexport type RawPrincipal = Uint8Array;\n\n/**\n * @see Principal\n */\nexport const PrincipalSchema = DfnPrincipalSchema;\n\n/**\n * Represents a principal - i.e. an object instantiated with the class Principal.\n */\nexport type Principal = z.infer<typeof PrincipalSchema>;\n"],
5
+ "mappings": "AAAA,OACE,mBAAmBA,EACnB,oBAAoBC,MACf,iBAMA,IAAMC,EAAmBD,EAKnBE,EAAqBD,EAUrBE,EAAkBJ",
6
+ "names": ["DfnPrincipalSchema", "DfnUint8ArraySchema", "Uint8ArraySchema", "RawPrincipalSchema", "PrincipalSchema"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{a as c,b as h,c as l}from"./chunk-7JYM2CKB.js";import*as a from"zod";var o=a.bigint(),n=a.bigint(),s=h,E=l,y=a.string(),p=a.string(),r=a.string().max(1024);import*as m from"zod";var g=c,b=m.object({owner:s,data:g,description:r.optional(),created_at:o,updated_at:o,version:n.optional()}).strict(),V=b.optional(),v=m.object({data:g,description:r.optional(),version:n.optional()}).strict(),M=m.object({version:n.optional()}).strict();import*as e from"zod";var u=e.tuple([e.string(),e.string()]),x=e.array(u),T=c,D=T,A=e.instanceof(Uint8Array).refine(i=>i.length===32,{message:"Hash must be a Uint8Array of length 32"}),z=e.object({name:e.string(),full_path:e.string(),token:e.string().optional(),collection:y,owner:s,description:r.optional()}).strict(),S=e.object({modified:o,content_chunks:e.array(D),total_length:e.bigint(),sha256:A}),w=S.omit({content_chunks:!0}).strict(),d=e.enum(["identity","gzip","compress","deflate","br"]),_=e.object({key:z,headers:x,encodings:e.array(e.tuple([d,S])),created_at:o,updated_at:o,version:n.optional()}).strict(),Z=_.omit({encodings:!0}).extend({encodings:e.array(e.tuple([d,w]))}).strict(),R=e.bigint(),G=e.object({key:z,reference_id:R.optional(),expires_at:o,encoding_type:d.optional()}).strict(),I=e.bigint(),U=e.bigint(),Q=e.object({batch_id:U,headers:x,chunk_ids:e.array(I)}).strict(),W=e.string(),X=e.string().optional(),Y=_.optional();import*as t from"zod";var f=t.union([t.object({equal:o}),t.object({greater_than:o}),t.object({less_than:o}),t.object({between:t.tuple([o,o])})]),j=t.object({key:p.optional(),description:r.optional(),created_at:f.optional(),updated_at:f.optional()}).strict(),k=t.object({start_after:p.optional(),limit:t.bigint().optional()}).strict(),O=t.enum(["keys","created_at","updated_at"]),C=t.object({desc:t.boolean(),field:O}).strict(),te=t.object({matcher:j.optional(),paginate:k.optional(),order:C.optional(),owner:s.optional()}).strict(),oe=i=>t.object({items:t.array(t.tuple([p,i])),items_length:t.bigint(),items_page:t.bigint().optional(),matches_length:t.bigint(),matches_pages:t.bigint().optional()}).strict();import{jsonReplacer as L,jsonReviver as K}from"@dfinity/utils";var re=i=>JSON.parse(__juno_satellite_datastore_raw_data_to_text(i),K),ne=i=>__juno_satellite_datastore_raw_data_from_text(JSON.stringify(i,L));export{o as a,n as b,s as c,E as d,y as e,p as f,r as g,g as h,b as i,V as j,v as k,M as l,x as m,T as n,z as o,S as p,_ as q,Z as r,G as s,Q as t,W as u,X as v,Y as w,f as x,j as y,k as z,O as A,C as B,te as C,oe as D,re as E,ne as F};
2
+ //# sourceMappingURL=chunk-HVIYPRXX.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["src/schemas/satellite.ts", "src/schemas/db.ts", "src/schemas/storage.ts", "src/schemas/list.ts", "src/sdk/serializer.sdk.ts"],
4
+ "sourcesContent": ["import * as z from 'zod';\nimport {type RawPrincipal, PrincipalSchema, RawPrincipalSchema} from './candid';\n\n/**\n * @see Timestamp\n */\nexport const TimestampSchema = z.bigint();\n\n/**\n * Represents a timestamp in nanoseconds since the Unix epoch.\n *\n * Used for tracking when events occur, such as document creation and updates.\n */\nexport type Timestamp = z.infer<typeof TimestampSchema>;\n\n/**\n * @see Version\n */\nexport const VersionSchema = z.bigint();\n\n/**\n * Represents a version number for tracking changes.\n *\n * This is typically incremented with each update to ensure consistency.\n */\nexport type Version = z.infer<typeof VersionSchema>;\n\n/**\n * @see RawUserId\n */\nexport const RawUserIdSchema = RawPrincipalSchema;\n\n/**\n * Represents a raw user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type RawUserId = RawPrincipal;\n\n/**\n * @see UserId\n */\nexport const UserIdSchema = PrincipalSchema;\n\n/**\n * Represents a user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type UserId = z.infer<typeof UserIdSchema>;\n\n/**\n * @see Collection\n */\nexport const CollectionSchema = z.string();\n\n/**\n * A collection name where data are stored.\n */\nexport type Collection = z.infer<typeof CollectionSchema>;\n\n/**\n * @see Key\n */\nexport const KeySchema = z.string();\n\n/**\n * A key identifier within a collection.\n */\nexport type Key = z.infer<typeof KeySchema>;\n\n/**\n * @see Description\n */\nexport const DescriptionSchema = z.string().max(1024);\n\n/**\n * Represents a description with a maximum length of 1024 characters.\n * Used for document and asset fields which can be useful for search purpose.\n */\nexport type Description = z.infer<typeof DescriptionSchema>;\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {\n type Description,\n DescriptionSchema,\n type RawUserId,\n RawUserIdSchema,\n type Timestamp,\n TimestampSchema,\n type Version,\n VersionSchema\n} from './satellite';\n\n/**\n * @see RawData\n */\nexport const RawDataSchema = Uint8ArraySchema;\n\n/**\n * Represents raw binary data.\n *\n * This is used to store structured data in a document.\n */\nexport type RawData = Uint8Array;\n\n/**\n * @see Doc\n */\nexport const DocSchema = z\n .object({\n owner: RawUserIdSchema,\n data: RawDataSchema,\n description: DescriptionSchema.optional(),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents a document stored in a collection.\n */\nexport interface Doc {\n /**\n * The user who owns this document.\n */\n owner: RawUserId;\n\n /**\n * The raw data of the document.\n */\n data: RawData;\n\n /**\n * An optional description of the document.\n */\n description?: Description;\n\n /**\n * The timestamp when the document was first created.\n */\n created_at: Timestamp;\n\n /**\n * The timestamp when the document was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * The version number of the document, used for consistency checks.\n * If not provided, it's assumed to be the first version.\n */\n version?: Version;\n}\n\n/**\n * @see OptionDoc\n */\nexport const OptionDocSchema = DocSchema.optional();\n\n/**\n * A shorthand for a document that might or not be defined.\n */\nexport type OptionDoc = Doc | undefined;\n\n/**\n * @see SetDoc\n */\nexport const SetDocSchema = z\n .object({\n data: RawDataSchema,\n description: DescriptionSchema.optional(),\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document to be created or updated.\n * This can be validated before allowing the operation.\n */\nexport interface SetDoc {\n /**\n * The raw data of the document.\n */\n data: RawData;\n\n /**\n * An optional description of the document.\n */\n description?: Description;\n\n /**\n * The expected version number to ensure consistency.\n */\n version?: Version;\n}\n\n/**\n * @see DelDoc\n */\nexport const DelDocSchema = z\n .object({\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document to be deleted.\n * This can be validated before allowing the operation.\n */\nexport interface DelDoc {\n /**\n * The expected version number to ensure consistency.\n */\n version?: Version;\n}\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {\n type Collection,\n CollectionSchema,\n type Description,\n DescriptionSchema,\n type RawUserId,\n RawUserIdSchema,\n type Timestamp,\n TimestampSchema,\n type Version,\n VersionSchema\n} from './satellite';\n\n/**\n * @see HeaderField\n */\nconst HeaderFieldSchema = z.tuple([z.string(), z.string()]);\n\n/**\n * Represents a single HTTP header as a tuple of name and value.\n */\nexport type HeaderField = [string, string];\n\n/**\n * @see HeaderFields\n */\nexport const HeaderFieldsSchema = z.array(HeaderFieldSchema);\n\n/**\n * Represents a list of HTTP headers.\n */\nexport type HeaderFields = HeaderField[];\n\n/**\n * @see Blob\n */\nexport const BlobSchema = Uint8ArraySchema;\n\n/**\n * Binary content used in asset encoding.\n */\nexport type Blob = Uint8Array;\n\n/**\n * @see BlobOrKey\n */\nconst BlobOrKeySchema = BlobSchema;\n\n/**\n * When stable memory is used, chunks are saved within a StableBTreeMap and their keys - StableEncodingChunkKey - are saved for reference as serialized values\n */\nexport type BlobOrKey = Uint8Array;\n\n/**\n * @see Hash\n */\nconst HashSchema = z.instanceof(Uint8Array).refine((val) => val.length === 32, {\n message: 'Hash must be a Uint8Array of length 32'\n});\n\n/**\n * Represents a SHA-256 hash as a 32-byte binary value.\n */\nexport type Hash = Uint8Array;\n\n/**\n * @see AssetKey\n */\nexport const AssetKeySchema = z\n .object({\n name: z.string(),\n full_path: z.string(),\n token: z.string().optional(),\n collection: CollectionSchema,\n owner: RawUserIdSchema,\n description: DescriptionSchema.optional()\n })\n .strict();\n\n/**\n * Metadata identifying an asset within a collection and the storage system.\n */\nexport interface AssetKey {\n /**\n * The name of the asset (e.g., \"logo.png\").\n */\n name: string;\n\n /**\n * The full relative path of the asset (e.g., \"/images/logo.png\").\n */\n full_path: string;\n\n /**\n * Optional access token for the asset.\n * If set, can be used using a query parameter e.g. /full_path/?token=1223-3345-5564-3333\n */\n token?: string;\n\n /**\n * The collection to which this asset belongs.\n */\n collection: Collection;\n\n /**\n * The owner of the asset.\n */\n owner: RawUserId;\n\n /**\n * Optional description of the asset for indexing/search.\n */\n description?: Description;\n}\n\n/**\n * @see AssetEncoding\n */\nexport const AssetEncodingSchema = z.object({\n modified: TimestampSchema,\n content_chunks: z.array(BlobOrKeySchema),\n total_length: z.bigint(),\n sha256: HashSchema\n});\n\n/**\n * Represents a specific encoding of an asset, such as \"gzip\" or \"identity\" (no compression).\n */\nexport interface AssetEncoding {\n /**\n * Timestamp when the encoding was last modified.\n */\n modified: Timestamp;\n\n /**\n * Chunks of binary content or references to them.\n */\n content_chunks: BlobOrKey[];\n\n /**\n * Total byte size of the encoded content.\n */\n total_length: bigint;\n\n /**\n * SHA-256 hash of the encoded content.\n */\n sha256: Hash;\n}\n\n/**\n * @see AssetEncodingNoContent\n */\nconst AssetEncodingNoContentSchema = AssetEncodingSchema.omit({content_chunks: true}).strict();\n\n/**\n * Represents a specific encoding of an asset, such as \"gzip\" or \"identity\" (no compression), without the chunks.\n */\nexport type AssetEncodingNoContent = Omit<AssetEncoding, 'content_chunks'>;\n\n/**\n * @see EncodingType\n */\nconst EncodingTypeSchema = z.enum(['identity', 'gzip', 'compress', 'deflate', 'br']);\n\n/**\n * A string identifier representing a specific encoding format (e.g., \"gzip\", \"identity\").\n */\nexport type EncodingType = 'identity' | 'gzip' | 'compress' | 'deflate' | 'br';\n\n/**\n * @see Asset\n */\nexport const AssetSchema = z\n .object({\n key: AssetKeySchema,\n headers: HeaderFieldsSchema,\n encodings: z.array(z.tuple([EncodingTypeSchema, AssetEncodingSchema])),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * A stored asset including its metadata, encodings, and timestamps.\n */\nexport interface Asset {\n /**\n * Metadata about the asset's identity and ownership.\n */\n key: AssetKey;\n\n /**\n * Optional HTTP headers associated with the asset.\n */\n headers: HeaderField[];\n\n /**\n * A mapping from encoding types (e.g., \"identity\", \"gzip\") to the corresponding encoded version.\n */\n encodings: [EncodingType, AssetEncoding][];\n\n /**\n * Timestamp when the asset was created.\n */\n created_at: Timestamp;\n\n /**\n * Timestamp when the asset was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * Optional version number of the asset.\n */\n version?: Version;\n}\n\n/**\n * @see AssetNoContent\n */\nexport const AssetNoContentSchema = AssetSchema.omit({encodings: true})\n .extend({\n encodings: z.array(z.tuple([EncodingTypeSchema, AssetEncodingNoContentSchema]))\n })\n .strict();\n\n/**\n * A stored asset including its metadata, encodings without chunks, and timestamps.\n */\nexport type AssetNoContent = Omit<Asset, 'encodings'> & {\n encodings: [EncodingType, AssetEncodingNoContent][];\n};\n\n/**\n * @see ReferenceId\n */\nconst ReferenceIdSchema = z.bigint();\n\n/**\n * A unique reference identifier for batches.\n */\nexport type ReferenceId = bigint;\n\n/**\n * @see Batch\n */\nexport const BatchSchema = z\n .object({\n key: AssetKeySchema,\n reference_id: ReferenceIdSchema.optional(),\n expires_at: TimestampSchema,\n encoding_type: EncodingTypeSchema.optional()\n })\n .strict();\n\n/**\n * Represents a batch of chunks to be uploaded and committed to an asset.\n */\nexport interface Batch {\n /**\n * The metadata key for the asset being uploaded.\n */\n key: AssetKey;\n\n /**\n * Optional reference ID for tracking or validation.\n */\n reference_id?: ReferenceId;\n\n /**\n * Timestamp when this batch expires.\n */\n expires_at: Timestamp;\n\n /**\n * Optional encoding format (e.g., \"gzip\").\n */\n encoding_type?: EncodingType;\n}\n\n/**\n * @see ChunkId\n */\nconst ChunkIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a single chunk of data.\n */\nexport type ChunkId = bigint;\n\n/**\n * @see BatchId\n */\nconst BatchIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a batch of upload.\n */\nexport type BatchId = bigint;\n\n/**\n * @see CommitBatch\n */\nexport const CommitBatchSchema = z\n .object({\n batch_id: BatchIdSchema,\n headers: HeaderFieldsSchema,\n chunk_ids: z.array(ChunkIdSchema)\n })\n .strict();\n\n/**\n * Represents the final step in uploading an asset, committing the batch to storage.\n */\nexport interface CommitBatch {\n /**\n * The ID of the batch being committed.\n */\n batch_id: BatchId;\n\n /**\n * HTTP headers associated with this asset.\n */\n headers: HeaderField[];\n\n /**\n * List of chunk IDs that make up the asset content.\n */\n chunk_ids: ChunkId[];\n}\n\n/**\n * @see FullPath\n */\nexport const FullPathSchema = z.string();\n\n/**\n * Represents the relative path of an asset in storage.\n * For assets that are not part of the frontend app, the collection must be included at the root of the path.\n *\n * Example: `/images/a-sun-above-the-mountains.png`\n */\nexport type FullPath = string;\n\n/**\n * @see AssetAccessToken\n */\nexport const AssetAccessTokenSchema = z.string().optional();\n\n/**\n * An optional access token that can be used to make an asset private on the web.\n * Private as in practically unguessable (if complex enough and not shared of course).\n *\n * Example: `/images/a-sun-above-the-mountains.png?token=a-super-long-unguessable-not-shared-id`\n */\nexport type AssetAccessToken = string | undefined;\n\n/**\n * @see OptionAsset\n */\nexport const OptionAssetSchema = AssetSchema.optional();\n\n/**\n * A shorthand for an asset that might or not be defined.\n */\nexport type OptionAsset = Asset | undefined;\n", "import * as z from 'zod';\nimport {\n type Description,\n type Key,\n type RawUserId,\n type Timestamp,\n DescriptionSchema,\n KeySchema,\n RawUserIdSchema,\n TimestampSchema\n} from './satellite';\n\n/**\n * @see TimestampMatcher\n */\nexport const TimestampMatcherSchema = z.union([\n z.object({equal: TimestampSchema}),\n z.object({greater_than: TimestampSchema}),\n z.object({less_than: TimestampSchema}),\n z.object({between: z.tuple([TimestampSchema, TimestampSchema])})\n]);\n\n/**\n * TimestampMatcher matches a timestamp field using a specific strategy.\n */\nexport type TimestampMatcher =\n | {equal: Timestamp}\n | {greater_than: Timestamp}\n | {less_than: Timestamp}\n | {between: [Timestamp, Timestamp]};\n\n/**\n * @see ListMatcher\n */\nexport const ListMatcherSchema = z\n .object({\n key: KeySchema.optional(),\n description: DescriptionSchema.optional(),\n created_at: TimestampMatcherSchema.optional(),\n updated_at: TimestampMatcherSchema.optional()\n })\n .strict();\n\n/**\n * Matcher used to filter list results.\n */\nexport interface ListMatcher {\n key?: Key;\n description?: Description;\n created_at?: TimestampMatcher;\n updated_at?: TimestampMatcher;\n}\n\n/**\n * @see ListPaginate\n */\nexport const ListPaginateSchema = z\n .object({\n start_after: KeySchema.optional(),\n limit: z.bigint().optional()\n })\n .strict();\n\n/**\n * Optional pagination controls for listing.\n */\nexport interface ListPaginate {\n start_after?: Key;\n limit?: bigint;\n}\n\n/**\n * @see ListOrderField\n */\nexport const ListOrderFieldSchema = z.enum(['keys', 'created_at', 'updated_at']);\n\n/**\n * Enum representing possible fields to order by.\n */\nexport type ListOrderField = 'keys' | 'updated_at' | 'created_at';\n\n/**\n * @see ListOrder\n */\nexport const ListOrderSchema = z\n .object({\n desc: z.boolean(),\n field: ListOrderFieldSchema\n })\n .strict();\n\n/**\n * Ordering strategy for listing documents.\n */\nexport interface ListOrder {\n desc: boolean;\n field: ListOrderField;\n}\n\n/**\n * @see ListParams\n */\nexport const ListParamsSchema = z\n .object({\n matcher: ListMatcherSchema.optional(),\n paginate: ListPaginateSchema.optional(),\n order: ListOrderSchema.optional(),\n owner: RawUserIdSchema.optional()\n })\n .strict();\n\n/**\n * Full set of listing parameters.\n */\nexport interface ListParams {\n matcher?: ListMatcher;\n paginate?: ListPaginate;\n order?: ListOrder;\n owner?: RawUserId;\n}\n\n/**\n * Represents a list result.\n *\n * @template T - The type of the data returned per item.\n * @see JsListResults\n */\nexport const createListResultsSchema = <T extends z.ZodTypeAny>(itemData: T) =>\n z\n .object({\n items: z.array(z.tuple([KeySchema, itemData])),\n items_length: z.bigint(),\n items_page: z.bigint().optional(),\n matches_length: z.bigint(),\n matches_pages: z.bigint().optional()\n })\n .strict();\n\n/**\n * List results, parameterized by type of returned item.\n */\nexport interface ListResults<T> {\n items: [Key, T][];\n items_length: bigint;\n items_page?: bigint;\n matches_length: bigint;\n matches_pages?: bigint;\n}\n", "import {jsonReplacer, jsonReviver} from '@dfinity/utils';\nimport type {RawData} from '../schemas/db';\n\n/**\n * Decodes the raw data of a document into a JavaScript object.\n *\n * @template T The expected type of the decoded object.\n * @param {RawData} data - The raw data to be decoded.\n * @returns {T} The parsed JavaScript object.\n */\nexport const decodeDocData = <T>(data: RawData): T =>\n JSON.parse(__juno_satellite_datastore_raw_data_to_text(data), jsonReviver);\n\n/**\n * Encodes a JavaScript object into a raw data format to be applied to a document.\n *\n * @template T The type of the object to be encoded.\n * @param {T} data - The data to be encoded.\n * @returns {RawData} The serialized raw data.\n */\nexport const encodeDocData = <T>(data: T): RawData =>\n __juno_satellite_datastore_raw_data_from_text(JSON.stringify(data, jsonReplacer));\n"],
5
+ "mappings": "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",
6
+ "names": ["z", "TimestampSchema", "VersionSchema", "RawUserIdSchema", "RawPrincipalSchema", "UserIdSchema", "PrincipalSchema", "CollectionSchema", "KeySchema", "DescriptionSchema", "z", "RawDataSchema", "Uint8ArraySchema", "DocSchema", "RawUserIdSchema", "DescriptionSchema", "TimestampSchema", "VersionSchema", "OptionDocSchema", "SetDocSchema", "DelDocSchema", "z", "HeaderFieldSchema", "HeaderFieldsSchema", "BlobSchema", "Uint8ArraySchema", "BlobOrKeySchema", "HashSchema", "val", "AssetKeySchema", "CollectionSchema", "RawUserIdSchema", "DescriptionSchema", "AssetEncodingSchema", "TimestampSchema", "AssetEncodingNoContentSchema", "EncodingTypeSchema", "AssetSchema", "VersionSchema", "AssetNoContentSchema", "ReferenceIdSchema", "BatchSchema", "ChunkIdSchema", "BatchIdSchema", "CommitBatchSchema", "FullPathSchema", "AssetAccessTokenSchema", "OptionAssetSchema", "z", "TimestampMatcherSchema", "TimestampSchema", "ListMatcherSchema", "KeySchema", "DescriptionSchema", "ListPaginateSchema", "ListOrderFieldSchema", "ListOrderSchema", "ListParamsSchema", "RawUserIdSchema", "createListResultsSchema", "itemData", "jsonReplacer", "jsonReviver", "decodeDocData", "data", "encodeDocData"]
7
+ }
@@ -1,2 +1,2 @@
1
- import{b as o,c as s}from"./chunk-7B6WU32N.js";import{IDL as w}from"@icp-sdk/core/candid";import*as e from"zod";var n=e.custom(r=>r instanceof w.Type,{message:"Invalid IDL.Type"}),A=e.tuple([n,e.unknown()]),S=e.array(A),z=n,l=e.object({canisterId:o.or(s),method:e.string().min(1),args:S.optional(),result:z.optional()});var t=class extends Error{constructor(){super(),this.message="More than one object returned by the response. This is unexpected."}};import{toNullable as D}from"@dfinity/utils";import{IDL as p}from"@icp-sdk/core/candid";import{Principal as L}from"@icp-sdk/core/principal";var M=async r=>{l.parse(r);let{canisterId:c,method:i,args:m,result:y}=r,u=L.from(c).toUint8Array(),[f,d]=(m??[]).reduce(([I,x],[T,P])=>[[...I,T],[...x,P]],[[],[]]),h=new Uint8Array(p.encode([...f],[...d])),g=await __ic_cdk_call_raw(u,i,h),a=p.decode(D(y),g);if(a.length>1)throw new t;let[C]=a;return C};export{n as a,A as b,S as c,z as d,l as e,t as f,M as g};
2
- //# sourceMappingURL=chunk-EMQQE34V.js.map
1
+ import{b as o,c as s}from"./chunk-7JYM2CKB.js";import{IDL as w}from"@icp-sdk/core/candid";import*as e from"zod";var n=e.custom(r=>r instanceof w.Type,{message:"Invalid IDL.Type"}),A=e.tuple([n,e.unknown()]),S=e.array(A),z=n,l=e.object({canisterId:o.or(s),method:e.string().min(1),args:S.optional(),result:z.optional()});var t=class extends Error{constructor(){super(),this.message="More than one object returned by the response. This is unexpected."}};import{toNullable as D}from"@dfinity/utils";import{IDL as p}from"@icp-sdk/core/candid";import{Principal as L}from"@icp-sdk/core/principal";var M=async r=>{l.parse(r);let{canisterId:c,method:i,args:m,result:y}=r,u=L.from(c).toUint8Array(),[f,d]=(m??[]).reduce(([I,x],[T,P])=>[[...I,T],[...x,P]],[[],[]]),h=new Uint8Array(p.encode([...f],[...d])),g=await __ic_cdk_call_raw(u,i,h),a=p.decode(D(y),g);if(a.length>1)throw new t;let[C]=a;return C};export{n as a,A as b,S as c,z as d,l as e,t as f,M as g};
2
+ //# sourceMappingURL=chunk-W42LR3ZN.js.map
@@ -0,0 +1,2 @@
1
+ import{c as t}from"./chunk-7JYM2CKB.js";import*as i from"zod";var o=i.strictObject({canisterId:t.optional()});export{o as a};
2
+ //# sourceMappingURL=chunk-XRHVLXYG.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Internal constant used by Juno's tooling to discover serverless functions.
3
+ * Not intended for direct use by developers.
4
+ */
5
+ export declare const JUNO_FUNCTION_TYPE: {
6
+ readonly QUERY: "__juno_function_query";
7
+ readonly UPDATE: "__juno_function_update";
8
+ };
@@ -0,0 +1,49 @@
1
+ import * as z from 'zod';
2
+ import { type SatelliteEnv } from '../schemas/satellite.env';
3
+ import { JUNO_FUNCTION_TYPE } from './constants';
4
+ import { type CustomFunctionWithArgs, type CustomFunctionWithArgsAndResult, type CustomFunctionWithoutArgsAndResult, type CustomFunctionWithResult } from './schemas/function';
5
+ /**
6
+ * @see Query
7
+ */
8
+ export declare const QuerySchema: z.ZodUnion<readonly [z.ZodObject<{
9
+ type: z.ZodLiteral<"__juno_function_query">;
10
+ args: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
11
+ result: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
12
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>>;
13
+ }, z.core.$strict>, z.ZodObject<{
14
+ type: z.ZodLiteral<"__juno_function_query">;
15
+ args: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
16
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
17
+ }, z.core.$strict>, z.ZodObject<{
18
+ type: z.ZodLiteral<"__juno_function_query">;
19
+ result: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
20
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>>;
21
+ }, z.core.$strict>, z.ZodObject<{
22
+ type: z.ZodLiteral<"__juno_function_query">;
23
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
24
+ }, z.core.$strict>]>;
25
+ /**
26
+ * The input shape for defining a query serverless function.
27
+ * Does not include `type`, which is injected by `defineQuery`.
28
+ */
29
+ export type Query<TArgs extends z.ZodRawShape = z.ZodRawShape, TResult extends z.ZodRawShape = z.ZodRawShape> = Omit<CustomFunctionWithArgsAndResult<TArgs, TResult>, 'type'> | Omit<CustomFunctionWithArgs<TArgs>, 'type'> | Omit<CustomFunctionWithResult<TResult>, 'type'> | Omit<CustomFunctionWithoutArgsAndResult, 'type'>;
30
+ /**
31
+ * A query function definition with `type` injected by `defineQuery`.
32
+ * Queries are read-only functions that do not modify state.
33
+ */
34
+ export type QueryDefinition<TArgs extends z.ZodRawShape = z.ZodRawShape, TResult extends z.ZodRawShape = z.ZodRawShape> = Query<TArgs, TResult> & {
35
+ type: typeof JUNO_FUNCTION_TYPE.QUERY;
36
+ };
37
+ export declare const QueryFnSchema: <T extends z.ZodTypeAny>(querySchema: T) => z.ZodFunction<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodString>], null>, T>;
38
+ /**
39
+ * A factory function that receives the satellite environment and returns a query definition.
40
+ */
41
+ export type QueryFn<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape> = (env: SatelliteEnv) => Query<TArgs, TResult>;
42
+ export declare const QueryFnOrObjectSchema: <T extends z.ZodTypeAny>(querySchema: T) => z.ZodUnion<readonly [T, z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodString>], null>, T>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodString>], null>, T>>]>;
43
+ /**
44
+ * A query definition or a factory function that returns one.
45
+ */
46
+ export type QueryFnOrObject<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape> = Query<TArgs, TResult> | QueryFn<TArgs, TResult>;
47
+ export declare function defineQuery<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(query: Query<TArgs, TResult>): QueryDefinition<TArgs, TResult>;
48
+ export declare function defineQuery<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(query: QueryFn<TArgs, TResult>): (env: SatelliteEnv) => QueryDefinition<TArgs, TResult>;
49
+ export declare function defineQuery<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(query: QueryFnOrObject<TArgs, TResult>): QueryDefinition<TArgs, TResult> | ((env: SatelliteEnv) => QueryDefinition<TArgs, TResult>);
@@ -0,0 +1,170 @@
1
+ import * as z from 'zod';
2
+ import { JUNO_FUNCTION_TYPE } from '../constants';
3
+ /**
4
+ * The type of a serverless function. Not exposed to the developer. It allows the CLI
5
+ * to discover the functions when parsing the code.
6
+ */
7
+ export type CustomFunctionType = (typeof JUNO_FUNCTION_TYPE)[keyof typeof JUNO_FUNCTION_TYPE];
8
+ /**
9
+ * @see CustomFunctionWithArgsAndResult
10
+ */
11
+ export declare const CustomFunctionWithArgsAndResultSchema: z.ZodObject<{
12
+ args: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
13
+ result: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
14
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>>;
15
+ type: z.ZodEnum<{
16
+ __juno_function_query: "__juno_function_query";
17
+ __juno_function_update: "__juno_function_update";
18
+ }>;
19
+ }, z.core.$strict>;
20
+ /**
21
+ * @see CustomFunctionWithArgs
22
+ */
23
+ export declare const CustomFunctionWithArgsSchema: z.ZodObject<{
24
+ args: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
25
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
26
+ type: z.ZodEnum<{
27
+ __juno_function_query: "__juno_function_query";
28
+ __juno_function_update: "__juno_function_update";
29
+ }>;
30
+ }, z.core.$strict>;
31
+ /**
32
+ * @see CustomFunctionWithResult
33
+ */
34
+ export declare const CustomFunctionWithResultSchema: z.ZodObject<{
35
+ result: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
36
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>>;
37
+ type: z.ZodEnum<{
38
+ __juno_function_query: "__juno_function_query";
39
+ __juno_function_update: "__juno_function_update";
40
+ }>;
41
+ }, z.core.$strict>;
42
+ /**
43
+ * @see CustomFunctionWithoutArgsAndResult
44
+ */
45
+ export declare const CustomFunctionWithoutArgsAndResultSchema: z.ZodObject<{
46
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
47
+ type: z.ZodEnum<{
48
+ __juno_function_query: "__juno_function_query";
49
+ __juno_function_update: "__juno_function_update";
50
+ }>;
51
+ }, z.core.$strict>;
52
+ /**
53
+ * @see CustomFunction
54
+ */
55
+ export declare const CustomFunctionSchema: z.ZodUnion<readonly [z.ZodObject<{
56
+ args: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
57
+ result: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
58
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>>;
59
+ type: z.ZodEnum<{
60
+ __juno_function_query: "__juno_function_query";
61
+ __juno_function_update: "__juno_function_update";
62
+ }>;
63
+ }, z.core.$strict>, z.ZodObject<{
64
+ args: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
65
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
66
+ type: z.ZodEnum<{
67
+ __juno_function_query: "__juno_function_query";
68
+ __juno_function_update: "__juno_function_update";
69
+ }>;
70
+ }, z.core.$strict>, z.ZodObject<{
71
+ result: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
72
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>>;
73
+ type: z.ZodEnum<{
74
+ __juno_function_query: "__juno_function_query";
75
+ __juno_function_update: "__juno_function_update";
76
+ }>;
77
+ }, z.core.$strict>, z.ZodObject<{
78
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
79
+ type: z.ZodEnum<{
80
+ __juno_function_query: "__juno_function_query";
81
+ __juno_function_update: "__juno_function_update";
82
+ }>;
83
+ }, z.core.$strict>]>;
84
+ /**
85
+ * Base interface for all serverless function variants.
86
+ */
87
+ interface CustomFunctionBase {
88
+ /**
89
+ * The type of the function, either a query or an update.
90
+ */
91
+ type: CustomFunctionType;
92
+ }
93
+ /**
94
+ * A serverless function with both input arguments and an output result.
95
+ *
96
+ * @template TArgs - The type of the input arguments.
97
+ * @template TResult - The type of the output result.
98
+ */
99
+ export interface CustomFunctionWithArgsAndResult<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape> extends CustomFunctionBase {
100
+ /**
101
+ * A Zod schema describing the input arguments.
102
+ */
103
+ args: z.ZodObject<TArgs>;
104
+ /**
105
+ * A Zod schema describing the output result.
106
+ */
107
+ result: z.ZodObject<TResult>;
108
+ /**
109
+ * The function handler. Can be synchronous or asynchronous.
110
+ *
111
+ * @param {TArgs} args - The input arguments.
112
+ * @returns {TResult | Promise<TResult>}
113
+ */
114
+ handler: (args: z.infer<z.ZodObject<TArgs>>) => z.infer<z.ZodObject<TResult>> | Promise<z.infer<z.ZodObject<TResult>>>;
115
+ }
116
+ /**
117
+ * A serverless function with input arguments but no output result.
118
+ *
119
+ * @template TArgs - The type of the input arguments.
120
+ */
121
+ export interface CustomFunctionWithArgs<TArgs extends z.ZodRawShape> extends CustomFunctionBase {
122
+ /**
123
+ * A Zod schema describing the input arguments.
124
+ */
125
+ args: z.ZodObject<TArgs>;
126
+ /**
127
+ * The function handler. Can be synchronous or asynchronous.
128
+ *
129
+ * @param {TArgs} args - The input arguments.
130
+ * @returns {void | Promise<void>}
131
+ */
132
+ handler: (args: z.infer<z.ZodObject<TArgs>>) => void | Promise<void>;
133
+ }
134
+ /**
135
+ * A serverless function with an output result but no input arguments.
136
+ *
137
+ * @template TResult - The type of the output result.
138
+ */
139
+ export interface CustomFunctionWithResult<TResult extends z.ZodRawShape> extends CustomFunctionBase {
140
+ /**
141
+ * A Zod schema describing the output result.
142
+ */
143
+ result: z.ZodObject<TResult>;
144
+ /**
145
+ * The function handler. Can be synchronous or asynchronous.
146
+ *
147
+ * @returns {TResult | Promise<TResult>}
148
+ */
149
+ handler: () => z.infer<z.ZodObject<TResult>> | Promise<z.infer<z.ZodObject<TResult>>>;
150
+ }
151
+ /**
152
+ * A serverless function with no input arguments and no output result.
153
+ */
154
+ export interface CustomFunctionWithoutArgsAndResult extends CustomFunctionBase {
155
+ /**
156
+ * The function handler. Can be synchronous or asynchronous.
157
+ *
158
+ * @returns {void | Promise<void>}
159
+ */
160
+ handler: () => void | Promise<void>;
161
+ }
162
+ /**
163
+ * A serverless function definition. The four variants cover all combinations
164
+ * of optional input arguments and output result.
165
+ *
166
+ * @template TArgs - The type of the input arguments.
167
+ * @template TResult - The type of the output result.
168
+ */
169
+ export type CustomFunction<TArgs extends z.ZodRawShape = z.ZodRawShape, TResult extends z.ZodRawShape = z.ZodRawShape> = CustomFunctionWithArgsAndResult<TArgs, TResult> | CustomFunctionWithArgs<TArgs> | CustomFunctionWithResult<TResult> | CustomFunctionWithoutArgsAndResult;
170
+ export {};
@@ -0,0 +1,49 @@
1
+ import * as z from 'zod';
2
+ import { type SatelliteEnv } from '../schemas/satellite.env';
3
+ import { JUNO_FUNCTION_TYPE } from './constants';
4
+ import { type CustomFunctionWithArgs, type CustomFunctionWithArgsAndResult, type CustomFunctionWithoutArgsAndResult, type CustomFunctionWithResult } from './schemas/function';
5
+ /**
6
+ * @see Update
7
+ */
8
+ export declare const UpdateSchema: z.ZodUnion<readonly [z.ZodObject<{
9
+ type: z.ZodLiteral<"__juno_function_update">;
10
+ args: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
11
+ result: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
12
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>>;
13
+ }, z.core.$strict>, z.ZodObject<{
14
+ type: z.ZodLiteral<"__juno_function_update">;
15
+ args: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
16
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodUnknown], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
17
+ }, z.core.$strict>, z.ZodObject<{
18
+ type: z.ZodLiteral<"__juno_function_update">;
19
+ result: z.ZodCustom<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>;
20
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodUnknown, z.ZodPromise<z.ZodUnknown>]>>>;
21
+ }, z.core.$strict>, z.ZodObject<{
22
+ type: z.ZodLiteral<"__juno_function_update">;
23
+ handler: z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>, z.core.$InferInnerFunctionType<z.ZodTuple<[], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
24
+ }, z.core.$strict>]>;
25
+ /**
26
+ * The input shape for defining an update serverless function.
27
+ * Does not include `type`, which is injected by `defineUpdate`.
28
+ */
29
+ export type Update<TArgs extends z.ZodRawShape = z.ZodRawShape, TResult extends z.ZodRawShape = z.ZodRawShape> = Omit<CustomFunctionWithArgsAndResult<TArgs, TResult>, 'type'> | Omit<CustomFunctionWithArgs<TArgs>, 'type'> | Omit<CustomFunctionWithResult<TResult>, 'type'> | Omit<CustomFunctionWithoutArgsAndResult, 'type'>;
30
+ /**
31
+ * A update function definition with `type` injected by `defineUpdate`.
32
+ * Queries are read-only functions that do not modify state.
33
+ */
34
+ export type UpdateDefinition<TArgs extends z.ZodRawShape = z.ZodRawShape, TResult extends z.ZodRawShape = z.ZodRawShape> = Update<TArgs, TResult> & {
35
+ type: typeof JUNO_FUNCTION_TYPE.UPDATE;
36
+ };
37
+ export declare const UpdateFnSchema: <T extends z.ZodTypeAny>(updateSchema: T) => z.ZodFunction<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodString>], null>, T>;
38
+ /**
39
+ * A factory function that receives the satellite environment and returns an update definition.
40
+ */
41
+ export type UpdateFn<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape> = (env: SatelliteEnv) => Update<TArgs, TResult>;
42
+ export declare const UpdateFnOrObjectSchema: <T extends z.ZodTypeAny>(updateSchema: T) => z.ZodUnion<readonly [T, z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodString>], null>, T>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodRecord<z.ZodString, z.ZodString>], null>, T>>]>;
43
+ /**
44
+ * A update definition or a factory function that returns one.
45
+ */
46
+ export type UpdateFnOrObject<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape> = Update<TArgs, TResult> | UpdateFn<TArgs, TResult>;
47
+ export declare function defineUpdate<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(update: Update<TArgs, TResult>): UpdateDefinition<TArgs, TResult>;
48
+ export declare function defineUpdate<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(update: UpdateFn<TArgs, TResult>): (env: SatelliteEnv) => UpdateDefinition<TArgs, TResult>;
49
+ export declare function defineUpdate<TArgs extends z.ZodRawShape, TResult extends z.ZodRawShape>(update: UpdateFnOrObject<TArgs, TResult>): UpdateDefinition<TArgs, TResult> | ((env: SatelliteEnv) => UpdateDefinition<TArgs, TResult>);
@@ -0,0 +1 @@
1
+ export {};
package/global.d.ts CHANGED
@@ -110,6 +110,7 @@ declare global {
110
110
  ): void;
111
111
 
112
112
  function __ic_cdk_id(): RawPrincipal;
113
+ function __ic_cdk_caller(): RawPrincipal;
113
114
  function __ic_cdk_time(): bigint;
114
115
  function __ic_cdk_print(msg: string): void;
115
116
  function __ic_cdk_call_raw(