@junobuild/functions 0.3.3 → 0.4.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.
- package/README.md +35 -35
- package/{chunk-SFZECPH3.js → chunk-4ZHRSCXC.js} +2 -2
- package/chunk-7B6WU32N.js +2 -0
- package/chunk-7B6WU32N.js.map +7 -0
- package/ic-cdk/id.ic-cdk.d.ts +1 -1
- package/ic-cdk/schemas/call.d.ts +3 -3
- package/ic-cdk.js +1 -1
- package/ic-cdk.js.map +3 -3
- package/index.js +1 -1
- package/package.json +14 -6
- package/schemas/candid.d.ts +1 -1
- package/sdk.js +1 -1
- package/sdk.js.map +2 -2
- package/chunk-CCKUQNB5.js +0 -2
- package/chunk-CCKUQNB5.js.map +0 -7
- /package/{chunk-SFZECPH3.js.map → chunk-4ZHRSCXC.js.map} +0 -0
package/README.md
CHANGED
|
@@ -250,9 +250,9 @@ References:
|
|
|
250
250
|
|
|
251
251
|
Normalizes a user ID into a raw `Uint8Array` representation.
|
|
252
252
|
|
|
253
|
-
| Function | Type
|
|
254
|
-
| ----------------- |
|
|
255
|
-
| `normalizeCaller` | `(caller:
|
|
253
|
+
| Function | Type |
|
|
254
|
+
| ----------------- | ---------------------------------------------- |
|
|
255
|
+
| `normalizeCaller` | `(caller: any) => Uint8Array<ArrayBufferLike>` |
|
|
256
256
|
|
|
257
257
|
Parameters:
|
|
258
258
|
|
|
@@ -850,9 +850,9 @@ References:
|
|
|
850
850
|
|
|
851
851
|
#### :gear: PrincipalSchema
|
|
852
852
|
|
|
853
|
-
| Constant | Type
|
|
854
|
-
| ----------------- |
|
|
855
|
-
| `PrincipalSchema` | `ZodCustom<
|
|
853
|
+
| Constant | Type |
|
|
854
|
+
| ----------------- | --------------------------------------------- |
|
|
855
|
+
| `PrincipalSchema` | `ZodCustom<CandidPrincipal, CandidPrincipal>` |
|
|
856
856
|
|
|
857
857
|
References:
|
|
858
858
|
|
|
@@ -898,9 +898,9 @@ References:
|
|
|
898
898
|
|
|
899
899
|
#### :gear: UserIdSchema
|
|
900
900
|
|
|
901
|
-
| Constant | Type
|
|
902
|
-
| -------------- |
|
|
903
|
-
| `UserIdSchema` | `ZodCustom<
|
|
901
|
+
| Constant | Type |
|
|
902
|
+
| -------------- | --------------------------------------------- |
|
|
903
|
+
| `UserIdSchema` | `ZodCustom<CandidPrincipal, CandidPrincipal>` |
|
|
904
904
|
|
|
905
905
|
References:
|
|
906
906
|
|
|
@@ -1666,9 +1666,9 @@ References:
|
|
|
1666
1666
|
|
|
1667
1667
|
#### :gear: ControllerCheckParamsSchema
|
|
1668
1668
|
|
|
1669
|
-
| Constant | Type
|
|
1670
|
-
| ----------------------------- |
|
|
1671
|
-
| `ControllerCheckParamsSchema` | `ZodObject<{ caller: ZodUnion<[ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, ZodCustom<
|
|
1669
|
+
| Constant | Type |
|
|
1670
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1671
|
+
| `ControllerCheckParamsSchema` | `ZodObject<{ caller: ZodUnion<[ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, ZodCustom<CandidPrincipal, CandidPrincipal>]>; controllers: ZodArray<...>; }, $strip>` |
|
|
1672
1672
|
|
|
1673
1673
|
References:
|
|
1674
1674
|
|
|
@@ -1918,9 +1918,9 @@ References:
|
|
|
1918
1918
|
|
|
1919
1919
|
#### :gear: IDLTypeSchema
|
|
1920
1920
|
|
|
1921
|
-
| Constant | Type
|
|
1922
|
-
| --------------- |
|
|
1923
|
-
| `IDLTypeSchema` | `ZodCustom<Type<unknown>, Type<unknown>>` |
|
|
1921
|
+
| Constant | Type |
|
|
1922
|
+
| --------------- | ------------------------------------------------- |
|
|
1923
|
+
| `IDLTypeSchema` | `ZodCustom<IDL.Type<unknown>, IDL.Type<unknown>>` |
|
|
1924
1924
|
|
|
1925
1925
|
References:
|
|
1926
1926
|
|
|
@@ -1930,9 +1930,9 @@ References:
|
|
|
1930
1930
|
|
|
1931
1931
|
#### :gear: CallArgSchema
|
|
1932
1932
|
|
|
1933
|
-
| Constant | Type
|
|
1934
|
-
| --------------- |
|
|
1935
|
-
| `CallArgSchema` | `ZodTuple<[ZodCustom<Type<unknown>, Type<unknown>>, ZodUnknown], null>` |
|
|
1933
|
+
| Constant | Type |
|
|
1934
|
+
| --------------- | ------------------------------------------------------------------------------- |
|
|
1935
|
+
| `CallArgSchema` | `ZodTuple<[ZodCustom<IDL.Type<unknown>, IDL.Type<unknown>>, ZodUnknown], null>` |
|
|
1936
1936
|
|
|
1937
1937
|
References:
|
|
1938
1938
|
|
|
@@ -1944,9 +1944,9 @@ References:
|
|
|
1944
1944
|
|
|
1945
1945
|
Schema for encoding the call arguments.
|
|
1946
1946
|
|
|
1947
|
-
| Constant | Type
|
|
1948
|
-
| ---------------- |
|
|
1949
|
-
| `CallArgsSchema` | `ZodArray<ZodTuple<[ZodCustom<Type<unknown>, Type<unknown>>, ZodUnknown], null>>` |
|
|
1947
|
+
| Constant | Type |
|
|
1948
|
+
| ---------------- | ----------------------------------------------------------------------------------------- |
|
|
1949
|
+
| `CallArgsSchema` | `ZodArray<ZodTuple<[ZodCustom<IDL.Type<unknown>, IDL.Type<unknown>>, ZodUnknown], null>>` |
|
|
1950
1950
|
|
|
1951
1951
|
References:
|
|
1952
1952
|
|
|
@@ -1956,9 +1956,9 @@ References:
|
|
|
1956
1956
|
|
|
1957
1957
|
#### :gear: CallResultSchema
|
|
1958
1958
|
|
|
1959
|
-
| Constant | Type
|
|
1960
|
-
| ------------------ |
|
|
1961
|
-
| `CallResultSchema` | `ZodCustom<Type<unknown>, Type<unknown>>` |
|
|
1959
|
+
| Constant | Type |
|
|
1960
|
+
| ------------------ | ------------------------------------------------- |
|
|
1961
|
+
| `CallResultSchema` | `ZodCustom<IDL.Type<unknown>, IDL.Type<unknown>>` |
|
|
1962
1962
|
|
|
1963
1963
|
References:
|
|
1964
1964
|
|
|
@@ -1968,9 +1968,9 @@ References:
|
|
|
1968
1968
|
|
|
1969
1969
|
#### :gear: CallParamsSchema
|
|
1970
1970
|
|
|
1971
|
-
| Constant | Type
|
|
1972
|
-
| ------------------ |
|
|
1973
|
-
| `CallParamsSchema` | `ZodObject<{ canisterId: ZodUnion<[ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, ZodCustom<
|
|
1971
|
+
| Constant | Type |
|
|
1972
|
+
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1973
|
+
| `CallParamsSchema` | `ZodObject<{ canisterId: ZodUnion<[ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, ZodCustom<CandidPrincipal, CandidPrincipal>]>; method: ZodString; args: ZodOptional<...>; result: ZodOptional<...>; }, $strip>` |
|
|
1974
1974
|
|
|
1975
1975
|
References:
|
|
1976
1976
|
|
|
@@ -2286,7 +2286,7 @@ Represents the parameters required to perform controller checks.
|
|
|
2286
2286
|
|
|
2287
2287
|
| Property | Type | Description |
|
|
2288
2288
|
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
2289
|
-
| `caller` | `
|
|
2289
|
+
| `caller` | `any` | The identity of the caller to verify against the controller list. |
|
|
2290
2290
|
| `controllers` | `[Uint8Array<ArrayBufferLike>, { metadata: [string, string][]; created_at: bigint; updated_at: bigint; scope: "write" or "admin" or "submit"; expires_at?: bigint or undefined; }][]` | The list of controllers to check against. |
|
|
2291
2291
|
|
|
2292
2292
|
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/sdk/schemas/controllers.ts#L107)
|
|
@@ -2329,12 +2329,12 @@ The parameters required to retrieve a specific chunk from an asset.
|
|
|
2329
2329
|
|
|
2330
2330
|
Type representing the parameters required to make a canister call.
|
|
2331
2331
|
|
|
2332
|
-
| Property | Type
|
|
2333
|
-
| ------------ |
|
|
2334
|
-
| `canisterId` | `
|
|
2335
|
-
| `method` | `string`
|
|
2336
|
-
| `args` | `[Type<unknown>, unknown][] or undefined`
|
|
2337
|
-
| `result` | `
|
|
2332
|
+
| Property | Type | Description |
|
|
2333
|
+
| ------------ | --------------------------------------------- | ----------------------------------------------------------------- |
|
|
2334
|
+
| `canisterId` | `any` | The target canister's ID. |
|
|
2335
|
+
| `method` | `string` | The name of the method to call. Minimum one character. |
|
|
2336
|
+
| `args` | `[IDL.Type<unknown>, unknown][] or undefined` | The arguments, including types and values, for the canister call. |
|
|
2337
|
+
| `result` | `any` | The expected result type used for decoding the response. |
|
|
2338
2338
|
|
|
2339
2339
|
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/call.ts#L69)
|
|
2340
2340
|
|
|
@@ -3327,7 +3327,7 @@ The parameters required to list documents from the datastore.
|
|
|
3327
3327
|
|
|
3328
3328
|
#### :gear: IDLType
|
|
3329
3329
|
|
|
3330
|
-
Custom validation function to verify if a value is an instance of `IDL.Type` from `@
|
|
3330
|
+
Custom validation function to verify if a value is an instance of `IDL.Type` from `@icp-sdk/core/candid`.
|
|
3331
3331
|
|
|
3332
3332
|
| Type | Type |
|
|
3333
3333
|
| --------- | ------------------------------- |
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as s,b as h,c as l}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as s,b as h,c as l}from"./chunk-7B6WU32N.js";import*as i from"zod";var o=i.bigint(),r=i.bigint(),n=h,O=l,y=i.string(),c=i.string(),a=i.string().max(1024);import*as p from"zod";var g=s,_=p.object({owner:n,data:g,description:a.optional(),created_at:o,updated_at:o,version:r.optional()}).strict(),H=_.optional(),V=p.object({data:g,description:a.optional(),version:r.optional()}).strict(),P=p.object({version:r.optional()}).strict();import*as e from"zod";var u=e.tuple([e.string(),e.string()]),x=e.array(u),T=s,A=T,D=e.instanceof(Uint8Array).refine(m=>m.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:n,description:a.optional()}).strict(),S=e.object({modified:o,content_chunks:e.array(A),total_length:e.bigint(),sha256:D}),w=S.omit({content_chunks:!0}).strict(),d=e.enum(["identity","gzip","compress","deflate","br"]),f=e.object({key:z,headers:x,encodings:e.array(e.tuple([d,S])),created_at:o,updated_at:o,version:r.optional()}).strict(),q=f.omit({encodings:!0}).extend({encodings:e.array(e.tuple([d,w]))}).strict(),I=e.bigint(),Z=e.object({key:z,reference_id:I.optional(),expires_at:o,encoding_type:d.optional()}).strict(),U=e.bigint(),R=e.bigint(),G=e.object({batch_id:R,headers:x,chunk_ids:e.array(U)}).strict(),J=e.string(),Q=f.optional();import*as t from"zod";var b=t.union([t.object({equal:o}),t.object({greater_than:o}),t.object({less_than:o}),t.object({between:t.tuple([o,o])})]),k=t.object({key:c.optional(),description:a.optional(),created_at:b.optional(),updated_at:b.optional()}).strict(),j=t.object({start_after:c.optional(),limit:t.bigint().optional()}).strict(),C=t.enum(["keys","created_at","updated_at"]),L=t.object({desc:t.boolean(),field:C}).strict(),Y=t.object({matcher:k.optional(),paginate:j.optional(),order:L.optional(),owner:n.optional()}).strict(),$=m=>t.object({items:t.array(t.tuple([c,m])),items_length:t.bigint(),items_page:t.bigint().optional(),matches_length:t.bigint(),matches_pages:t.bigint().optional()}).strict();export{o as a,r as b,n as c,O as d,y as e,c as f,a as g,g as h,_ as i,H as j,V as k,P as l,x as m,T as n,z as o,S as p,f as q,q as r,Z as s,G as t,J as u,Q as v,b as w,k as x,j as y,C as z,L as A,Y as B,$ as C};
|
|
2
|
+
//# sourceMappingURL=chunk-4ZHRSCXC.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Principal as r}from"@icp-sdk/core/principal";import*as i from"zod";var n=i.custom(a=>a instanceof Uint8Array,{message:"Expected Uint8Array"}),c=n,t=i.custom(a=>a instanceof r,{message:"Expected an instance of a Principal"});export{n as a,c as b,t as c};
|
|
2
|
+
//# sourceMappingURL=chunk-7B6WU32N.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/schemas/candid.ts"],
|
|
4
|
+
"sourcesContent": ["import {Principal as CandidPrincipal} from '@icp-sdk/core/principal';\nimport * as z from 'zod';\n\n/**\n * A schema that validates a value is an Uint8Array.\n */\nexport const Uint8ArraySchema = z.custom<Uint8Array>((val) => val instanceof Uint8Array, {\n message: 'Expected Uint8Array'\n});\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 = z.infer<typeof RawPrincipalSchema>;\n\n/**\n * @see Principal\n */\nexport const PrincipalSchema = z.custom<CandidPrincipal>((val) => val instanceof CandidPrincipal, {\n message: 'Expected an instance of a Principal'\n});\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,OAAQ,aAAaA,MAAsB,0BAC3C,UAAYC,MAAO,MAKZ,IAAMC,EAAqB,SAAoBC,GAAQA,aAAe,WAAY,CACvF,QAAS,qBACX,CAAC,EAKYC,EAAqBF,EAUrBG,EAAoB,SAAyBF,GAAQA,aAAeH,EAAiB,CAChG,QAAS,qCACX,CAAC",
|
|
6
|
+
"names": ["CandidPrincipal", "z", "Uint8ArraySchema", "val", "RawPrincipalSchema", "PrincipalSchema"]
|
|
7
|
+
}
|
package/ic-cdk/id.ic-cdk.d.ts
CHANGED
package/ic-cdk/schemas/call.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IDL } from '@
|
|
2
|
-
import type { Principal } from '@
|
|
1
|
+
import { IDL } from '@icp-sdk/core/candid';
|
|
2
|
+
import type { Principal } from '@icp-sdk/core/principal';
|
|
3
3
|
import * as z from 'zod';
|
|
4
4
|
import { type RawPrincipal } from '../../schemas/candid';
|
|
5
5
|
/**
|
|
@@ -7,7 +7,7 @@ import { type RawPrincipal } from '../../schemas/candid';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const IDLTypeSchema: z.ZodCustom<IDL.Type<unknown>, IDL.Type<unknown>>;
|
|
9
9
|
/**
|
|
10
|
-
* Custom validation function to verify if a value is an instance of `IDL.Type` from `@
|
|
10
|
+
* Custom validation function to verify if a value is an instance of `IDL.Type` from `@icp-sdk/core/candid`.
|
|
11
11
|
*/
|
|
12
12
|
export type IDLType = z.infer<typeof IDLTypeSchema>;
|
|
13
13
|
/**
|
package/ic-cdk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as a,c as n}from"./chunk-
|
|
1
|
+
import{b as a,c as n}from"./chunk-7B6WU32N.js";import{toNullable as z}from"@dfinity/utils";import{IDL as i}from"@icp-sdk/core/candid";import{Principal as D}from"@icp-sdk/core/principal";import{IDL as A}from"@icp-sdk/core/candid";import*as r from"zod";var p=r.custom(e=>e instanceof A.Type,{message:"Invalid IDL.Type"}),_=r.tuple([p,r.unknown()]),w=r.array(_),S=p,s=r.object({canisterId:a.or(n),method:r.string().min(1),args:w.optional(),result:S.optional()});var t=class extends Error{constructor(){super(),this.message="More than one object returned by the response. This is unexpected."}};var N=async e=>{s.parse(e);let{canisterId:c,method:l,args:m,result:y}=e,f=D.from(c).toUint8Array(),[d,u]=(m??[]).reduce(([C,I],[P,T])=>[[...C,P],[...I,T]],[[],[]]),h=new Uint8Array(i.encode([...d],[...u])),x=await __ic_cdk_call_raw(f,l,h),o=i.decode(z(y),x);if(o.length>1)throw new t;let[g]=o;return g};import{Principal as L}from"@icp-sdk/core/principal";var F=()=>L.fromUint8Array(__ic_cdk_id());var H=()=>__ic_cdk_time();export{_ as CallArgSchema,w as CallArgsSchema,s as CallParamsSchema,t as CallResponseLengthError,S as CallResultSchema,p as IDLTypeSchema,N as call,F as id,H as time};
|
|
2
2
|
//# sourceMappingURL=ic-cdk.js.map
|
package/ic-cdk.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/ic-cdk/call.ic-cdk.ts", "src/ic-cdk/schemas/call.ts", "src/ic-cdk/types/errors.ts", "src/ic-cdk/id.ic-cdk.ts", "src/ic-cdk/time.ic-cdk.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "+CAAA,OAAQ,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import {toNullable} from '@dfinity/utils';\nimport {IDL} from '@icp-sdk/core/candid';\nimport {Principal} from '@icp-sdk/core/principal';\nimport {type CallParams, type IDLType, CallParamsSchema} from './schemas/call';\nimport {CallResponseLengthError} from './types/errors';\n\n/**\n * Makes an asynchronous call to a canister on the Internet Computer.\n *\n * This function encodes the provided arguments using Candid, performs the canister call,\n * and decodes the response based on the expected result types.\n *\n * @template T - The expected return type of the canister call.\n * @param {CallParams} params - The parameters required for the canister call\n * @returns {Promise<T | undefined>} A promise resolving to the decoded result of the call.\n * Returns `undefined` if the canister response is empty.\n * @throws {ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the canister call fails.\n */\nexport const call = async <T>(params: CallParams): Promise<T> => {\n CallParamsSchema.parse(params);\n\n const {canisterId: providedCanisterId, method, args: providedArgs, result: resultType} = params;\n\n const canisterId = Principal.from(providedCanisterId).toUint8Array();\n\n const [argsTypes, argsValues] = (providedArgs ?? []).reduce<[IDLType[], unknown[]]>(\n ([argsTypes, argsValues], [type, value]) => [\n [...argsTypes, type],\n [...argsValues, value]\n ],\n [[], []]\n );\n\n const args = new Uint8Array(IDL.encode([...argsTypes], [...argsValues]));\n\n const bytes: Uint8Array<ArrayBuffer> = await __ic_cdk_call_raw(canisterId, method, args);\n\n const result = IDL.decode(toNullable(resultType), bytes);\n\n // We have no test covering this use case because decode seems to never return more than one element, as we never specify more than one return type.\n if (result.length > 1) {\n throw new CallResponseLengthError();\n }\n\n const [response] = result as unknown as [T];\n return response;\n};\n", "import {IDL} from '@icp-sdk/core/candid';\nimport type {Principal} from '@icp-sdk/core/principal';\nimport * as z from 'zod';\nimport {PrincipalSchema, type RawPrincipal, RawPrincipalSchema} from '../../schemas/candid';\n\n/**\n * @see IDLType\n */\nexport const IDLTypeSchema = z.custom<IDL.Type<unknown>>((val) => val instanceof IDL.Type, {\n message: 'Invalid IDL.Type'\n});\n\n/**\n * Custom validation function to verify if a value is an instance of `IDL.Type` from `@icp-sdk/core/candid`.\n */\nexport type IDLType = z.infer<typeof IDLTypeSchema>;\n\n/**\n * @see CallArg\n */\nexport const CallArgSchema = z.tuple([IDLTypeSchema, z.unknown()]);\n\n/**\n * A call argument consisting of its IDL type and corresponding value.\n */\nexport type CallArg = z.infer<typeof CallArgSchema>;\n\n/**\n * Schema for encoding the call arguments.\n *\n * @see CallArgs\n */\nexport const CallArgsSchema = z.array(CallArgSchema);\n\n/**\n * Represents the arguments for a canister call on the IC.\n *\n * Requests and responses on the IC are encoded using Candid.\n * This schema ensures that each argument is provided with both its type and value\n * for proper encoding.\n *\n * The order of arguments is preserved for the function call.\n */\nexport type CallArgs = z.infer<typeof CallArgsSchema>;\n\n/**\n * @see CallResult\n */\nexport const CallResultSchema = IDLTypeSchema;\n\n/**\n * Defines the type used to decode the result of a canister call.\n */\nexport type CallResult = z.infer<typeof CallResultSchema>;\n\n/**\n * @see CallParams\n */\nexport const CallParamsSchema = z.object({\n canisterId: RawPrincipalSchema.or(PrincipalSchema),\n method: z.string().min(1),\n args: CallArgsSchema.optional(),\n result: CallResultSchema.optional()\n});\n\n/**\n * Type representing the parameters required to make a canister call.\n */\nexport interface CallParams {\n /**\n * The target canister's ID.\n */\n canisterId: RawPrincipal | Principal;\n\n /**\n * The name of the method to call. Minimum one character.\n */\n method: string;\n\n /**\n * The arguments, including types and values, for the canister call.\n */\n args?: CallArgs;\n\n /**\n * The expected result type used for decoding the response.\n */\n result?: CallResult;\n}\n", "export class CallResponseLengthError extends Error {\n constructor() {\n super();\n\n this.message = 'More than one object returned by the response. This is unexpected.';\n }\n}\n", "import {Principal} from '@icp-sdk/core/principal';\n\n/**\n * Retrieves the Satellite's Principal ID.\n *\n * This function is a JavaScript binding for the Rust function\n * [`ic_cdk::id()`](https://docs.rs/ic-cdk/latest/ic_cdk/fn.id.html), which returns\n * the Principal of the executing canister.\n *\n * @returns {Principal} The Principal ID of the Satellite.\n */\nexport const id = (): Principal => {\n const principal = Principal.fromUint8Array(__ic_cdk_id());\n\n // We assume the Principal is always built using the global function and is therefore always valid.\n // In other words, we do not validate it to conserve resources and optimize performance.\n\n return principal;\n};\n", "/**\n * Gets current timestamp, in nanoseconds since the epoch (1970-01-01)\n *\n * This function is a JavaScript binding for the Rust function\n * [`ic_cdk::time()`](https://docs.rs/ic-cdk/latest/ic_cdk/api/fn.time.html), which returns\n * the system time publicly exposed and verified part of the IC state tree\n *\n * @returns {bigint} The current timestamp.\n */\nexport const time = (): bigint => __ic_cdk_time();\n"],
|
|
5
|
+
"mappings": "+CAAA,OAAQ,cAAAA,MAAiB,iBACzB,OAAQ,OAAAC,MAAU,uBAClB,OAAQ,aAAAC,MAAgB,0BCFxB,OAAQ,OAAAC,MAAU,uBAElB,UAAYC,MAAO,MAMZ,IAAMC,EAAkB,SAA2BC,GAAQA,aAAeC,EAAI,KAAM,CACzF,QAAS,kBACX,CAAC,EAUYC,EAAkB,QAAM,CAACH,EAAiB,UAAQ,CAAC,CAAC,EAYpDI,EAAmB,QAAMD,CAAa,EAgBtCE,EAAmBL,EAUnBM,EAAqB,SAAO,CACvC,WAAYC,EAAmB,GAAGC,CAAe,EACjD,OAAU,SAAO,EAAE,IAAI,CAAC,EACxB,KAAMJ,EAAe,SAAS,EAC9B,OAAQC,EAAiB,SAAS,CACpC,CAAC,EC/DM,IAAMI,EAAN,cAAsC,KAAM,CACjD,aAAc,CACZ,MAAM,EAEN,KAAK,QAAU,oEACjB,CACF,EFaO,IAAMC,EAAO,MAAUC,GAAmC,CAC/DC,EAAiB,MAAMD,CAAM,EAE7B,GAAM,CAAC,WAAYE,EAAoB,OAAAC,EAAQ,KAAMC,EAAc,OAAQC,CAAU,EAAIL,EAEnFM,EAAaC,EAAU,KAAKL,CAAkB,EAAE,aAAa,EAE7D,CAACM,EAAWC,CAAU,GAAKL,GAAgB,CAAC,GAAG,OACnD,CAAC,CAACI,EAAWC,CAAU,EAAG,CAACC,EAAMC,CAAK,IAAM,CAC1C,CAAC,GAAGH,EAAWE,CAAI,EACnB,CAAC,GAAGD,EAAYE,CAAK,CACvB,EACA,CAAC,CAAC,EAAG,CAAC,CAAC,CACT,EAEMC,EAAO,IAAI,WAAWC,EAAI,OAAO,CAAC,GAAGL,CAAS,EAAG,CAAC,GAAGC,CAAU,CAAC,CAAC,EAEjEK,EAAiC,MAAM,kBAAkBR,EAAYH,EAAQS,CAAI,EAEjFG,EAASF,EAAI,OAAOG,EAAWX,CAAU,EAAGS,CAAK,EAGvD,GAAIC,EAAO,OAAS,EAClB,MAAM,IAAIE,EAGZ,GAAM,CAACC,CAAQ,EAAIH,EACnB,OAAOG,CACT,EG/CA,OAAQ,aAAAC,MAAgB,0BAWjB,IAAMC,EAAK,IACED,EAAU,eAAe,YAAY,CAAC,ECHnD,IAAME,EAAO,IAAc,cAAc",
|
|
6
|
+
"names": ["toNullable", "IDL", "Principal", "IDL", "z", "IDLTypeSchema", "val", "IDL", "CallArgSchema", "CallArgsSchema", "CallResultSchema", "CallParamsSchema", "RawPrincipalSchema", "PrincipalSchema", "CallResponseLengthError", "call", "params", "CallParamsSchema", "providedCanisterId", "method", "providedArgs", "resultType", "canisterId", "Principal", "argsTypes", "argsValues", "type", "value", "args", "IDL", "bytes", "result", "toNullable", "CallResponseLengthError", "response", "Principal", "id", "time"]
|
|
7
7
|
}
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as Ue,B as Me,C as je,a as ie,b as De,c as z,d as Ae,e as F,f as H,g as ye,h as Se,i as n,j as Oe,k as b,l as U,m as de,n as he,o as Ce,p as fe,q as r,r as Te,s as M,t as j,u as ue,v as ke,w as ze,x as Fe,y as He,z as be}from"./chunk-
|
|
1
|
+
import{A as Ue,B as Me,C as je,a as ie,b as De,c as z,d as Ae,e as F,f as H,g as ye,h as Se,i as n,j as Oe,k as b,l as U,m as de,n as he,o as Ce,p as fe,q as r,r as Te,s as M,t as j,u as ue,v as ke,w as ze,x as Fe,y as He,z as be}from"./chunk-4ZHRSCXC.js";import{a as xe,b as me,c as le}from"./chunk-7B6WU32N.js";import*as a from"zod";import*as v from"zod";var c=e=>v.custom(i=>e.implement(i));import*as m from"zod";var A=m.object({collections:m.array(m.string()).readonly()}).strict();import*as o from"zod";var t=e=>o.strictObject({caller:z,data:e}),_=e=>c(o.function({input:o.tuple([e]),output:o.void()})),Z=e=>c(o.function({input:o.tuple([e]),output:o.promise(o.void()).or(o.void())}));import*as l from"zod";import*as y from"zod";var C=y.object({before:n.optional(),after:n}).strict(),R=y.object({current:n.optional(),proposed:b}).strict(),g=y.object({current:n.optional(),proposed:U}).strict();var p=e=>l.strictObject({collection:F,key:H,data:e}),E=t(p(C)),B=t(l.array(p(C))),f=t(p(n.optional())),T=t(l.array(p(n.optional()))),u=t(l.array(p(n.optional()))),w=t(p(R)),I=t(p(g));import*as D from"zod";var S=D.record(D.string(),D.string());import*as k from"zod";import*as K from"zod";var P=K.object({current:r.optional(),batch:M,commit_batch:j}).strict();var J=t(r),N=t(r.optional()),q=t(k.array(r.optional())),G=t(k.array(r.optional())),L=t(P),Q=t(r);var O=e=>A.extend({assert:_(e)}).strict(),V=O(w),W=O(I),X=O(L),Y=O(Q),nt=a.union([V,W,X,Y]),$=e=>a.function({input:a.tuple([S]),output:e}),st=e=>a.union([e,c($(e))]);function rt(e){return e}import*as x from"zod";var s=e=>A.extend({run:Z(e)}).strict(),ee=s(E),te=s(B),Dt=s(f),At=s(T),yt=s(u),oe=s(J),ne=s(N),se=s(q),re=s(G),St=x.union([ee,te,f,T,u,oe,ne,se,re]),ce=e=>x.function({input:x.tuple([S]),output:e}),Ot=e=>x.union([e,c(ce(e))]);function dt(e){return e}import{jsonReplacer as pe}from"@dfinity/utils";var d=e=>{let i=e.map(h=>typeof h=="object"?JSON.stringify(h,pe):h).join(" ");globalThis.__ic_cdk_print(i)};globalThis.console={info(...e){d(e)},log(...e){d(e)},warn(...e){d(e)},error(...e){d(e)}};var ae=()=>(__juno_satellite_random()>>>0)/4294967296;globalThis.Math.random=ae;export{Q as AssertDeleteAssetContextSchema,Y as AssertDeleteAssetSchema,I as AssertDeleteDocContextSchema,W as AssertDeleteDocSchema,st as AssertFnOrObjectSchema,$ as AssertFnSchema,_ as AssertFunctionSchema,nt as AssertSchema,w as AssertSetDocContextSchema,V as AssertSetDocSchema,L as AssertUploadAssetContextSchema,X as AssertUploadAssetSchema,P as AssetAssertUploadSchema,fe as AssetEncodingSchema,Ce as AssetKeySchema,Te as AssetNoContentSchema,r as AssetSchema,M as BatchSchema,he as BlobSchema,F as CollectionSchema,A as CollectionsSchema,j as CommitBatchSchema,U as DelDocSchema,ye as DescriptionSchema,g as DocAssertDeleteSchema,R as DocAssertSetSchema,p as DocContextSchema,n as DocSchema,C as DocUpsertSchema,ue as FullPathSchema,de as HeaderFieldsSchema,t as HookContextSchema,Ot as HookFnOrObjectSchema,ce as HookFnSchema,St as HookSchema,H as KeySchema,Fe as ListMatcherSchema,be as ListOrderFieldSchema,Ue as ListOrderSchema,He as ListPaginateSchema,Me as ListParamsSchema,N as OnDeleteAssetContextSchema,ne as OnDeleteAssetSchema,f as OnDeleteDocContextSchema,Dt as OnDeleteDocSchema,G as OnDeleteFilteredAssetsContextSchema,re as OnDeleteFilteredAssetsSchema,u as OnDeleteFilteredDocsContextSchema,yt as OnDeleteFilteredDocsSchema,q as OnDeleteManyAssetsContextSchema,se as OnDeleteManyAssetsSchema,T as OnDeleteManyDocsContextSchema,At as OnDeleteManyDocsSchema,E as OnSetDocContextSchema,ee as OnSetDocSchema,B as OnSetManyDocsContextSchema,te as OnSetManyDocsSchema,J as OnUploadAssetContextSchema,oe as OnUploadAssetSchema,ke as OptionAssetSchema,Oe as OptionDocSchema,le as PrincipalSchema,Se as RawDataSchema,me as RawPrincipalSchema,z as RawUserIdSchema,Z as RunFunctionSchema,S as SatelliteEnvSchema,b as SetDocSchema,ze as TimestampMatcherSchema,ie as TimestampSchema,xe as Uint8ArraySchema,Ae as UserIdSchema,De as VersionSchema,je as createListResultsSchema,rt as defineAssert,dt as defineHook};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junobuild/functions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "JavaScript and TypeScript utilities for Juno Serverless Functions",
|
|
5
5
|
"author": "David Dal Busco (https://daviddalbusco.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,13 +44,21 @@
|
|
|
44
44
|
"bugs": {
|
|
45
45
|
"url": "https://github.com/junobuild/juno-js"
|
|
46
46
|
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"serverless",
|
|
49
|
+
"serverless-functions",
|
|
50
|
+
"wasm",
|
|
51
|
+
"self-hosted",
|
|
52
|
+
"cloud",
|
|
53
|
+
"auth",
|
|
54
|
+
"storage",
|
|
55
|
+
"database",
|
|
56
|
+
"hosting"
|
|
57
|
+
],
|
|
47
58
|
"homepage": "https://juno.build",
|
|
48
59
|
"peerDependencies": {
|
|
49
|
-
"@dfinity/
|
|
50
|
-
"@
|
|
51
|
-
"@dfinity/identity": "^3.2.6",
|
|
52
|
-
"@dfinity/principal": "^3.2.6",
|
|
53
|
-
"@dfinity/utils": "^3.1",
|
|
60
|
+
"@dfinity/utils": "^4",
|
|
61
|
+
"@icp-sdk/core": "^4.2",
|
|
54
62
|
"zod": "^4"
|
|
55
63
|
}
|
|
56
64
|
}
|
package/schemas/candid.d.ts
CHANGED
package/sdk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{B as I,a as S,c as n,d as m,e as D,f as y,k as x,l as u,m as f,n as A,o as g,p as U,u as j}from"./chunk-
|
|
1
|
+
import{B as I,a as S,c as n,d as m,e as D,f as y,k as x,l as u,m as f,n as A,o as g,p as U,u as j}from"./chunk-4ZHRSCXC.js";import{b as h}from"./chunk-7B6WU32N.js";import*as l from"zod";var q=l.enum(["write","admin","submit"]),Q=l.tuple([l.string(),l.string()]),V=l.object({metadata:l.array(Q),created_at:S,updated_at:S,expires_at:S.optional(),scope:q}).strict(),W=l.tuple([h,V]),X=l.array(W),P=l.object({caller:n.or(m),controllers:X});import{Principal as Y}from"@icp-sdk/core/principal";var a=e=>Y.from(e).toUint8Array();var ce=()=>__juno_satellite_get_admin_controllers(),ne=()=>__juno_satellite_get_controllers(),me=e=>{P.parse(e);let{caller:t,controllers:o}=e,r=a(t);return __juno_satellite_is_admin_controller(r,o)},ie=e=>{P.parse(e);let{caller:t,controllers:o}=e,r=a(t);return __juno_satellite_is_controller(r,o)};import*as L from"zod";var c=L.object({collection:D}).strict(),i=c.extend({caller:n.or(m),params:I}).strict();var _=c.extend({caller:n.or(m),key:y}).strict(),R=_.extend({doc:x}).strict(),z=_.extend({doc:u}).strict(),k=c,b=i,w=i,v=c,F=i;var ue=e=>{R.parse(e);let{caller:t,collection:o,key:r,doc:s}=e,d=a(t);return __juno_satellite_datastore_set_doc_store(d,o,r,s)},fe=e=>{z.parse(e);let{caller:t,collection:o,key:r,doc:s}=e,d=a(t);return __juno_satellite_datastore_delete_doc_store(d,o,r,s)},Ae=e=>{_.parse(e);let{caller:t,collection:o,key:r}=e,s=a(t);return __juno_satellite_datastore_get_doc_store(s,o,r)},ge=e=>{w.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_datastore_list_docs_store(s,o,r)},Ue=e=>{k.parse(e);let{collection:t}=e;return __juno_satellite_datastore_count_collection_docs_store(t)},je=e=>{b.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_datastore_count_docs_store(s,o,r)},Ie=e=>{v.parse(e);let{collection:t}=e;__juno_satellite_datastore_delete_docs_store(t)},Le=e=>{F.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_datastore_delete_filtered_docs_store(s,o,r)};import*as G from"zod";var M=G.enum(["heap","stable"]);import*as p from"zod";var C=c.extend({caller:n.or(m),full_path:j}).strict(),O=c,H=i,T=p.object({key:g,content:A,headers:f}).strict(),K=c,B=i,N=C,E=i,J=p.object({encoding:U,chunk_index:p.bigint(),memory:M}).strict();import{jsonReplacer as Z,jsonReviver as $}from"@dfinity/utils";var Me=e=>JSON.parse(__juno_satellite_datastore_raw_data_to_text(e),$),Oe=e=>__juno_satellite_datastore_raw_data_from_text(JSON.stringify(e,Z));var Be=e=>{O.parse(e);let{collection:t}=e;return __juno_satellite_storage_count_collection_assets_store(t)},Ne=e=>{H.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_storage_count_assets_store(s,o,r)},Ee=e=>{T.parse(e);let{key:t,content:o,headers:r}=e;__juno_satellite_storage_set_asset_handler(t,o,r)},Je=e=>{N.parse(e);let{caller:t,collection:o,full_path:r}=e,s=a(t);return __juno_satellite_storage_delete_asset_store(s,o,r)},qe=e=>{K.parse(e);let{collection:t}=e;__juno_satellite_storage_delete_assets_store(t)},Qe=e=>{B.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_storage_delete_filtered_assets_store(s,o,r)},Ve=e=>{C.parse(e);let{caller:t,collection:o,full_path:r}=e,s=a(t);return __juno_satellite_storage_get_asset_store(s,o,r)},We=e=>{E.parse(e);let{caller:t,collection:o,params:r}=e,s=a(t);return __juno_satellite_storage_list_assets_store(s,o,r)},Xe=e=>{J.parse(e);let{encoding:t,chunk_index:o,memory:r}=e;return __juno_satellite_storage_get_content_chunks_store(t,o,r)};export{c as CollectionParamsSchema,P as ControllerCheckParamsSchema,W as ControllerRecordSchema,V as ControllerSchema,q as ControllerScopeSchema,X as ControllersSchema,H as CountAssetsStoreParamsSchema,O as CountCollectionAssetsStoreParamsSchema,k as CountCollectionDocsStoreParamsSchema,b as CountDocsStoreParamsSchema,N as DeleteAssetStoreParamsSchema,K as DeleteAssetsStoreParamsSchema,z as DeleteDocStoreParamsSchema,v as DeleteDocsStoreParamsSchema,B as DeleteFilteredAssetsStoreParamsSchema,F as DeleteFilteredDocsStoreParamsSchema,C as GetAssetStoreParamsSchema,J as GetContentChunksStoreParamsSchema,_ as GetDocStoreParamsSchema,E as ListAssetsStoreParamsSchema,w as ListDocsStoreParamsSchema,i as ListStoreParamsSchema,M as MemorySchema,Q as MetadataSchema,T as SetAssetHandlerParamsSchema,R as SetDocStoreParamsSchema,Ne as countAssetsStore,Be as countCollectionAssetsStore,Ue as countCollectionDocsStore,je as countDocsStore,Me as decodeDocData,Je as deleteAssetStore,qe as deleteAssetsStore,fe as deleteDocStore,Ie as deleteDocsStore,Qe as deleteFilteredAssetsStore,Le as deleteFilteredDocsStore,Oe as encodeDocData,ce as getAdminControllers,Ve as getAssetStore,Xe as getContentChunksStore,ne as getControllers,Ae as getDocStore,me as isAdminController,ie as isController,We as listAssetsStore,ge as listDocsStore,Ee as setAssetHandler,ue as setDocStore};
|
|
2
2
|
//# sourceMappingURL=sdk.js.map
|
package/sdk.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/sdk/schemas/controllers.ts", "src/sdk/utils/caller.utils.ts", "src/sdk/controllers.sdk.ts", "src/sdk/schemas/params.ts", "src/sdk/schemas/db.ts", "src/sdk/db.sdk.ts", "src/sdk/schemas/collections.ts", "src/sdk/schemas/storage.ts", "src/sdk/serializer.sdk.ts", "src/sdk/storage.sdk.ts"],
|
|
4
|
-
"sourcesContent": ["import * as z from 'zod';\nimport {RawPrincipalSchema} from '../../schemas/candid';\nimport {\n type RawUserId,\n type Timestamp,\n type UserId,\n RawUserIdSchema,\n TimestampSchema,\n UserIdSchema\n} from '../../schemas/satellite';\n\n/**\n * @see ControllerScopeSchema\n */\nexport const ControllerScopeSchema = z.enum(['write', 'admin', 'submit']);\n\n/**\n * Represents the permission scope of a controller.\n */\nexport type ControllerScope = z.infer<typeof ControllerScopeSchema>;\n\n/**\n * @see MetadataSchema\n */\nexport const MetadataSchema = z.tuple([z.string(), z.string()]);\n\n/**\n * Represents a single metadata entry as a key-value tuple.\n */\nexport type Metadata = z.infer<typeof MetadataSchema>;\n\n/**\n * @see ControllerSchema\n */\nexport const ControllerSchema = z\n .object({\n metadata: z.array(MetadataSchema),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n expires_at: TimestampSchema.optional(),\n scope: ControllerScopeSchema\n })\n .strict();\n\n/**\n * Represents a controller with access scope and associated metadata.\n */\nexport interface Controller {\n /**\n * A list of key-value metadata pairs associated with the controller.\n */\n metadata: Metadata[];\n\n /**\n * The timestamp when the controller was created.\n */\n created_at: Timestamp;\n\n /**\n * The timestamp when the controller was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * Optional expiration timestamp for the controller.\n * \uD83D\uDC49 It's a placeholder for future implementation.\n */\n expires_at?: Timestamp;\n\n /**\n * The scope assigned to the controller.\n */\n scope: ControllerScope;\n}\n\n/**\n * @see ControllerRecordSchema\n */\nexport const ControllerRecordSchema = z.tuple([RawPrincipalSchema, ControllerSchema]);\n\n/**\n * Represents a tuple containing the principal ID and associated controller data.\n */\nexport type ControllerRecord = z.infer<typeof ControllerRecordSchema>;\n\n/**\n * @see ControllersSchema\n */\nexport const ControllersSchema = z.array(ControllerRecordSchema);\n\n/**\n * Represents a list of controllers.\n */\nexport type Controllers = z.infer<typeof ControllersSchema>;\n\n/**\n * @see ControllerCheckParamsSchema\n */\nexport const ControllerCheckParamsSchema = z.object({\n caller: RawUserIdSchema.or(UserIdSchema),\n controllers: ControllersSchema\n});\n\n/**\n * Represents the parameters required to perform controller checks.\n */\nexport interface ControllerCheckParams {\n /**\n * The identity of the caller to verify against the controller list.\n */\n caller: RawUserId | UserId;\n\n /**\n * The list of controllers to check against.\n */\n controllers: Controllers;\n}\n", "import {Principal} from '@dfinity/principal';\nimport type {RawUserId, UserId} from '../../schemas/satellite';\n\n/**\n * Normalizes a user ID into a raw `Uint8Array` representation.\n *\n * @param {RawUserId | UserId} caller - The caller identity, either a raw `Uint8Array`\n * or a `Principal` instance.\n *\n * @returns {RawUserId} The raw user ID as a `Uint8Array`.\n */\nexport const normalizeCaller = (caller: RawUserId | UserId): RawUserId =>\n Principal.from(caller).toUint8Array();\n", "import {\n type ControllerCheckParams,\n type Controllers,\n ControllerCheckParamsSchema\n} from './schemas/controllers';\nimport {normalizeCaller} from './utils/caller.utils';\n\n/**\n * Gets the list of admin controllers from the Satellite.\n *\n * @returns {Controllers} The list of admin controllers.\n *\n * @throws {z.ZodError} If the returned value does not match the expected schema.\n */\nexport const getAdminControllers = (): Controllers => __juno_satellite_get_admin_controllers();\n\n/**\n * Gets the list of controllers from the Satellite.\n *\n * @returns {Controllers} The list of all controllers.\n *\n * @throws {z.ZodError} If the returned value does not match the expected schema.\n */\nexport const getControllers = (): Controllers => __juno_satellite_get_controllers();\n\n/**\n * Checks if the given caller is an admin among the provided controllers.\n *\n * @param {ControllerCheckParams} params - The parameters including the caller identity\n * and the list of controllers to verify against.\n *\n * @returns {boolean} Whether the caller is an admin.\n *\n * @throws {z.ZodError} If any input does not match the expected schema.\n */\nexport const isAdminController = (params: ControllerCheckParams): boolean => {\n ControllerCheckParamsSchema.parse(params);\n\n const {caller: providedCaller, controllers} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_is_admin_controller(caller, controllers);\n};\n\n/**\n * Checks if the given caller exists among the provided controllers.\n *\n * @param {ControllerCheckParams} params - The parameters including the caller identity\n * and the list of controllers to verify against.\n *\n * @returns {boolean} Whether the caller is a controller.\n *\n * @throws {z.ZodError} If any input does not match the expected schema.\n */\nexport const isController = (params: ControllerCheckParams): boolean => {\n ControllerCheckParamsSchema.parse(params);\n\n const {caller: providedCaller, controllers} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_is_controller(caller, controllers);\n};\n", "import * as z from 'zod';\nimport {type ListParams, ListParamsSchema} from '../../schemas/list';\nimport {\n type Collection,\n CollectionSchema,\n type RawUserId,\n RawUserIdSchema,\n type UserId,\n UserIdSchema\n} from '../../schemas/satellite';\n\n/**\n * @see CollectionParams\n */\nexport const CollectionParamsSchema = z\n .object({\n collection: CollectionSchema\n })\n .strict();\n\n/**\n * The parameters required to scope an operation to a collection.\n */\nexport interface CollectionParams {\n /**\n * The name of the collection to target.\n */\n collection: Collection;\n}\n\n/**\n * @see ListStoreParams\n */\nexport const ListStoreParamsSchema = CollectionParamsSchema.extend({\n caller: RawUserIdSchema.or(UserIdSchema),\n params: ListParamsSchema\n}).strict();\n\n/**\n * The parameters required to list documents from the datastore respectively assets from the storage.\n */\nexport type ListStoreParams = CollectionParams & {\n /**\n * The identity of the caller requesting the list operation.\n */\n caller: RawUserId | UserId;\n\n /**\n * Optional filtering, ordering, and pagination parameters.\n */\n params: ListParams;\n};\n", "import {type DelDoc, DelDocSchema, type SetDoc, SetDocSchema} from '../../schemas/db';\nimport {\n type Key,\n KeySchema,\n type RawUserId,\n RawUserIdSchema,\n type UserId,\n UserIdSchema\n} from '../../schemas/satellite';\nimport {\n type CollectionParams,\n CollectionParamsSchema,\n type ListStoreParams,\n ListStoreParamsSchema\n} from './params';\n\n/**\n * @see GetDocStoreParams\n */\nexport const GetDocStoreParamsSchema = CollectionParamsSchema.extend({\n caller: RawUserIdSchema.or(UserIdSchema),\n key: KeySchema\n}).strict();\n\n/**\n * Represents the base parameters required to access the datastore and modify a document.\n */\nexport type GetDocStoreParams = CollectionParams & {\n /**\n * The caller who initiate the document operation.\n */\n caller: RawUserId | UserId;\n\n /**\n * The key identifying the document within the collection.\n */\n key: Key;\n};\n\n/**\n * @see SetDocStoreParams\n */\nexport const SetDocStoreParamsSchema = GetDocStoreParamsSchema.extend({\n doc: SetDocSchema\n}).strict();\n\n/**\n * Represents the parameters required to store or update a document.\n *\n * This includes the document data along with metadata such as the caller,\n * collection, and key.\n */\nexport type SetDocStoreParams = GetDocStoreParams & {\n /**\n * The data, optional description and version required to create or update a document.\n */\n doc: SetDoc;\n};\n\n/**\n * @see DeleteDocStoreParams\n */\nexport const DeleteDocStoreParamsSchema = GetDocStoreParamsSchema.extend({\n doc: DelDocSchema\n}).strict();\n\n/**\n * Represents the parameters required to delete a document.\n *\n * This includes the document version along with metadata such as the caller,\n * collection, and key.\n */\nexport type DeleteDocStoreParams = GetDocStoreParams & {\n /**\n * The version required to delete a document.\n */\n doc: DelDoc;\n};\n\n/**\n * @see CountCollectionDocsStoreParams\n */\nexport const CountCollectionDocsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to count documents from the datastore.\n */\nexport type CountCollectionDocsStoreParams = CollectionParams;\n\n/**\n * @see CountDocsStoreParams\n */\nexport const CountDocsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to count documents from the datastore.\n */\nexport type CountDocsStoreParams = ListStoreParams;\n\n/**\n * @see ListDocsStoreParams\n */\nexport const ListDocsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to list documents from the datastore.\n */\nexport type ListDocsStoreParams = ListStoreParams;\n\n/**\n * @see DeleteDocsStoreParams\n */\nexport const DeleteDocsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to delete the documents from a collection of the datastore.\n */\nexport type DeleteDocsStoreParams = CollectionParams;\n\n/**\n * @see DeleteFilteredDocsParams\n */\nexport const DeleteFilteredDocsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to delete documents from the datastore.\n */\nexport type DeleteFilteredDocsStoreParams = ListStoreParams;\n", "import type {DocContext} from '../hooks/schemas/db/context';\nimport type {DocUpsert} from '../hooks/schemas/db/payload';\nimport type {Doc, OptionDoc} from '../schemas/db';\nimport type {ListResults} from '../schemas/list';\nimport {\n type CountCollectionDocsStoreParams,\n CountCollectionDocsStoreParamsSchema,\n type CountDocsStoreParams,\n CountDocsStoreParamsSchema,\n type DeleteDocsStoreParams,\n DeleteDocsStoreParamsSchema,\n type DeleteDocStoreParams,\n DeleteDocStoreParamsSchema,\n type DeleteFilteredDocsStoreParams,\n DeleteFilteredDocsStoreParamsSchema,\n type GetDocStoreParams,\n GetDocStoreParamsSchema,\n type ListDocsStoreParams,\n ListDocsStoreParamsSchema,\n type SetDocStoreParams,\n SetDocStoreParamsSchema\n} from './schemas/db';\nimport {normalizeCaller} from './utils/caller.utils';\n\n/**\n * Stores or updates a document in the datastore.\n *\n * The data must have been encoded - using encodeDocData - before calling this function.\n *\n * @param {SetDocStoreParams} params - The parameters required to store the document,\n * including the caller, collection, key, and document data.\n *\n * @returns {DocContext<DocUpsert>} The context of the stored or updated document,\n * including its key, collection, and both the previous and current versions of the document.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate or store the document.\n */\nexport const setDocStore = (params: SetDocStoreParams): DocContext<DocUpsert> => {\n SetDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key, doc} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_set_doc_store(caller, collection, key, doc);\n};\n\n/**\n * Deletes a document from the datastore.\n *\n * @param {DeleteDocStoreParams} params - The parameters required to delete the document,\n * including the caller, collection, key, and the expected version of the document.\n *\n * @returns {DocContext<OptionDoc>} The context of the deleted document,\n * including its key, collection, and optionally the previous document data if it existed.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate the request or the document cannot be deleted.\n */\nexport const deleteDocStore = (params: DeleteDocStoreParams): DocContext<OptionDoc> => {\n DeleteDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key, doc} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_delete_doc_store(caller, collection, key, doc);\n};\n\n/**\n * Retrieve a document from the datastore.\n *\n * @param {GetDocStoreParams} params - The parameters required to get the document.\n *\n * @returns {OptionDoc} The document if found, or undefined if not.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails while retrieving the document.\n */\nexport const getDocStore = (params: GetDocStoreParams): OptionDoc => {\n GetDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_get_doc_store(caller, collection, key);\n};\n\n/**\n * Lists documents from the datastore using optional filtering, pagination, and ordering parameters.\n *\n * @param {ListStoreParams} params - The parameters required to perform the list operation.\n *\n * @returns {ListResults<Doc>} A list result containing matching documents and pagination metadata.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the listing operation.\n */\nexport const listDocsStore = (params: ListDocsStoreParams): ListResults<Doc> => {\n ListDocsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_list_docs_store(caller, collection, listParams);\n};\n\n/**\n * Counts the number of documents in a specific collection.\n *\n * @param {CountCollectionDocsStoreParams} params - The parameters required to count documents in the collection.\n *\n * @returns {bigint} The total number of documents in the specified collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countCollectionDocsStore = (params: CountCollectionDocsStoreParams): bigint => {\n CountCollectionDocsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n return __juno_satellite_datastore_count_collection_docs_store(collection);\n};\n\n/**\n * Counts the number of documents in a collection matching specific filters and owned by a specific caller.\n *\n * @param {CountDocsStoreParams} params - The parameters required to perform the filtered count.\n *\n * @returns {bigint} The number of documents that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countDocsStore = (params: CountDocsStoreParams): bigint => {\n CountDocsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_count_docs_store(caller, collection, listParams);\n};\n\n/**\n * Delete documents in a specific collection of the Datastore.\n *\n * @param {DeleteDocsStoreParams} params - The parameters required to delete documents in the collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteDocsStore = (params: DeleteDocsStoreParams): void => {\n DeleteDocsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n __juno_satellite_datastore_delete_docs_store(collection);\n};\n\n/**\n * Delete documents in a collection matching specific filters and owned by a specific caller.\n *\n * @param {DeleteFilteredDocsStoreParams} params - The parameters required to perform the filtered deletion.\n *\n * @returns {DocContext<OptionDoc>[]} The context resulting of the deletion of documents that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteFilteredDocsStore = (\n params: DeleteFilteredDocsStoreParams\n): DocContext<OptionDoc>[] => {\n DeleteFilteredDocsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_delete_filtered_docs_store(caller, collection, listParams);\n};\n", "import * as z from 'zod';\n\n/**\n * @see Memory\n */\nexport const MemorySchema = z.enum(['heap', 'stable']);\n\n/**\n * Memory type used to select storage or datastore location.\n */\nexport type Memory = z.infer<typeof MemorySchema>;\n", "import * as z from 'zod';\nimport {type RawUserId, type UserId, RawUserIdSchema, UserIdSchema} from '../../schemas/satellite';\nimport {\n type AssetEncoding,\n type AssetKey,\n type Blob,\n type FullPath,\n type HeaderFields,\n AssetEncodingSchema,\n AssetKeySchema,\n BlobSchema,\n FullPathSchema,\n HeaderFieldsSchema\n} from '../../schemas/storage';\nimport {type Memory, MemorySchema} from './collections';\nimport {\n type CollectionParams,\n type ListStoreParams,\n CollectionParamsSchema,\n ListStoreParamsSchema\n} from './params';\n\n/**\n * @see GetAssetStoreParams\n */\nexport const GetAssetStoreParamsSchema = CollectionParamsSchema.extend({\n caller: RawUserIdSchema.or(UserIdSchema),\n full_path: FullPathSchema\n}).strict();\n\n/**\n * Represents the base parameters required to access the storage and modify an asset.\n */\nexport type GetAssetStoreParams = CollectionParams & {\n /**\n * The caller who initiate the document operation.\n */\n caller: RawUserId | UserId;\n\n /**\n * The full_path identifying the asset within the collection.\n */\n full_path: FullPath;\n};\n\n/**\n * @see CountCollectionAssetsStoreParams\n */\nexport const CountCollectionAssetsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to count documents from the storage.\n */\nexport type CountCollectionAssetsStoreParams = CollectionParams;\n\n/**\n * @see CountAssetsStoreParams\n */\nexport const CountAssetsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to count documents from the storage.\n */\nexport type CountAssetsStoreParams = ListStoreParams;\n\n/**\n * @see SetAssetHandlerParams\n */\nexport const SetAssetHandlerParamsSchema = z\n .object({\n key: AssetKeySchema,\n content: BlobSchema,\n headers: HeaderFieldsSchema\n })\n .strict();\n\n/**\n * The parameters required to set (or update) an asset.\n */\nexport interface SetAssetHandlerParams {\n /**\n * The key identifying the asset.\n */\n key: AssetKey;\n\n /**\n * The binary content of the asset.\n */\n content: Blob;\n\n /**\n * Associated HTTP headers.\n */\n headers: HeaderFields;\n}\n\n/**\n * @see DeleteAssetsStoreParams\n */\nexport const DeleteAssetsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to delete the assets from a collection of the storage.\n */\nexport type DeleteAssetsStoreParams = CollectionParams;\n\n/**\n * @see DeleteFilteredAssetsParams\n */\nexport const DeleteFilteredAssetsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to delete assets from the storage.\n */\nexport type DeleteFilteredAssetsStoreParams = ListStoreParams;\n\n/**\n * @see DeleteAssetStoreParams\n */\nexport const DeleteAssetStoreParamsSchema = GetAssetStoreParamsSchema;\n\n/**\n * Represents the parameters required to delete an asset.\n */\nexport type DeleteAssetStoreParams = GetAssetStoreParams;\n\n/**\n * @see ListAssetsStoreParams\n */\nexport const ListAssetsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to list documents from the datastore.\n */\nexport type ListAssetsStoreParams = ListStoreParams;\n\n/**\n * @see GetContentChunksStoreParams\n */\nexport const GetContentChunksStoreParamsSchema = z\n .object({\n encoding: AssetEncodingSchema,\n chunk_index: z.bigint(),\n memory: MemorySchema\n })\n .strict();\n\n/**\n * The parameters required to retrieve a specific chunk from an asset.\n */\nexport interface GetContentChunksStoreParams {\n /**\n * The encoding of the chunks.\n */\n encoding: AssetEncoding;\n\n /**\n * The index of the chunk to retrieve.\n */\n chunk_index: bigint;\n\n /**\n * The memory type to retrieve the chunk from.\n */\n memory: Memory;\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", "import type {ListResults} from '../schemas/list';\nimport type {AssetNoContent, Blob, OptionAsset} from '../schemas/storage';\nimport {\n type CountAssetsStoreParams,\n CountAssetsStoreParamsSchema,\n type CountCollectionAssetsStoreParams,\n CountCollectionAssetsStoreParamsSchema,\n type DeleteAssetsStoreParams,\n DeleteAssetsStoreParamsSchema,\n type DeleteAssetStoreParams,\n DeleteAssetStoreParamsSchema,\n type DeleteFilteredAssetsStoreParams,\n DeleteFilteredAssetsStoreParamsSchema,\n type GetAssetStoreParams,\n GetAssetStoreParamsSchema,\n type GetContentChunksStoreParams,\n GetContentChunksStoreParamsSchema,\n type ListAssetsStoreParams,\n ListAssetsStoreParamsSchema,\n type SetAssetHandlerParams,\n SetAssetHandlerParamsSchema\n} from './schemas/storage';\nimport {normalizeCaller} from './utils/caller.utils';\n\n/**\n * Counts the number of assets in a specific collection.\n *\n * @param {CountCollectionAssetsStoreParams} params - The parameters required to count assets in the collection.\n *\n * @returns {bigint} The total number of assets in the specified collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countCollectionAssetsStore = (params: CountCollectionAssetsStoreParams): bigint => {\n CountCollectionAssetsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n return __juno_satellite_storage_count_collection_assets_store(collection);\n};\n\n/**\n * Counts the number of assets in a collection matching specific filters and owned by a specific caller.\n *\n * @param {CountAssetsStoreParams} params - The parameters required to perform the filtered count.\n *\n * @returns {bigint} The number of assets that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countAssetsStore = (params: CountAssetsStoreParams): bigint => {\n CountAssetsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_count_assets_store(caller, collection, listParams);\n};\n\n/**\n * Sets or updates an asset in the storage.\n *\n * @param {SetAssetHandlerParams} params - The parameters required to set or update an asset.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the operation.\n */\nexport const setAssetHandler = (params: SetAssetHandlerParams): void => {\n SetAssetHandlerParamsSchema.parse(params);\n\n const {key, content, headers} = params;\n\n __juno_satellite_storage_set_asset_handler(key, content, headers);\n};\n\n/**\n * Deletes an asset from the storage.\n *\n * @param {DeleteAssetStoreParams} params - The parameters required to delete the asset.\n *\n * @returns {OptionAsset} The potentially deleted asset.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate the request or the asset cannot be deleted.\n */\nexport const deleteAssetStore = (params: DeleteAssetStoreParams): OptionAsset => {\n DeleteAssetStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, full_path} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_delete_asset_store(caller, collection, full_path);\n};\n\n/**\n * Delete assets in a specific collection of the Storage.\n *\n * @param {DeleteAssetsStoreParams} params - The parameters required to delete assets in the collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteAssetsStore = (params: DeleteAssetsStoreParams): void => {\n DeleteAssetsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n __juno_satellite_storage_delete_assets_store(collection);\n};\n\n/**\n * Delete assets in a collection matching specific filters and owned by a specific caller.\n *\n * @param {DeleteFilteredAssetsStoreParams} params - The parameters required to perform the filtered deletion.\n *\n * @returns {OptionAsset[]} The potential asset resulting of the deletion that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteFilteredAssetsStore = (\n params: DeleteFilteredAssetsStoreParams\n): OptionAsset[] => {\n DeleteFilteredAssetsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_delete_filtered_assets_store(caller, collection, listParams);\n};\n\n/**\n * Retrieve an asset from the storage.\n *\n * @param {GetAssetStoreParams} params - The parameters required to get the asset.\n *\n * @returns {OptionAsset} The asset if found, or undefined if not.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails while retrieving the document.\n */\nexport const getAssetStore = (params: GetAssetStoreParams): OptionAsset => {\n GetAssetStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, full_path} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_get_asset_store(caller, collection, full_path);\n};\n\n/**\n * Lists assets (without content) from the storage using optional filtering, pagination, and ordering parameters.\n *\n * @param {ListStoreParams} params - The parameters required to perform the list operation.\n *\n * @returns {ListResults<AssetNoContent>} A list result containing matching assets and pagination metadata.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the listing operation.\n */\nexport const listAssetsStore = (params: ListAssetsStoreParams): ListResults<AssetNoContent> => {\n ListAssetsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_list_assets_store(caller, collection, listParams);\n};\n\n/**\n * Retrieves content chunks of an asset.\n *\n * This function fetches a content chunk of a given asset encoding using the specified parameters.\n *\n * @param {GetContentChunksStoreParams} params - The parameters including encoding, chunk index, and memory type.\n *\n * @returns {Blob | undefined} The content chunk if found, or `undefined` if not.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite throws an internal error during retrieval.\n */\nexport const getContentChunksStore = (params: GetContentChunksStoreParams): Blob | undefined => {\n GetContentChunksStoreParamsSchema.parse(params);\n\n const {encoding, chunk_index, memory} = params;\n\n return __juno_satellite_storage_get_content_chunks_store(encoding, chunk_index, memory);\n};\n"],
|
|
5
|
-
"mappings": "oKAAA,UAAYA,MAAO,MAcZ,IAAMC,EAA0B,OAAK,CAAC,QAAS,QAAS,QAAQ,CAAC,EAU3DC,EAAmB,QAAM,CAAG,SAAO,EAAK,SAAO,CAAC,CAAC,EAUjDC,EACV,SAAO,CACN,SAAY,QAAMD,CAAc,EAChC,WAAYE,EACZ,WAAYA,EACZ,WAAYA,EAAgB,SAAS,EACrC,MAAOH,CACT,CAAC,EACA,OAAO,EAoCGI,EAA2B,QAAM,CAACC,EAAoBH,CAAgB,CAAC,EAUvEI,EAAsB,QAAMF,CAAsB,EAUlDG,EAAgC,SAAO,CAClD,OAAQC,EAAgB,GAAGC,CAAY,EACvC,YAAaH,CACf,CAAC,ECrGD,OAAQ,aAAAI,MAAgB,
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\nimport {RawPrincipalSchema} from '../../schemas/candid';\nimport {\n type RawUserId,\n type Timestamp,\n type UserId,\n RawUserIdSchema,\n TimestampSchema,\n UserIdSchema\n} from '../../schemas/satellite';\n\n/**\n * @see ControllerScopeSchema\n */\nexport const ControllerScopeSchema = z.enum(['write', 'admin', 'submit']);\n\n/**\n * Represents the permission scope of a controller.\n */\nexport type ControllerScope = z.infer<typeof ControllerScopeSchema>;\n\n/**\n * @see MetadataSchema\n */\nexport const MetadataSchema = z.tuple([z.string(), z.string()]);\n\n/**\n * Represents a single metadata entry as a key-value tuple.\n */\nexport type Metadata = z.infer<typeof MetadataSchema>;\n\n/**\n * @see ControllerSchema\n */\nexport const ControllerSchema = z\n .object({\n metadata: z.array(MetadataSchema),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n expires_at: TimestampSchema.optional(),\n scope: ControllerScopeSchema\n })\n .strict();\n\n/**\n * Represents a controller with access scope and associated metadata.\n */\nexport interface Controller {\n /**\n * A list of key-value metadata pairs associated with the controller.\n */\n metadata: Metadata[];\n\n /**\n * The timestamp when the controller was created.\n */\n created_at: Timestamp;\n\n /**\n * The timestamp when the controller was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * Optional expiration timestamp for the controller.\n * \uD83D\uDC49 It's a placeholder for future implementation.\n */\n expires_at?: Timestamp;\n\n /**\n * The scope assigned to the controller.\n */\n scope: ControllerScope;\n}\n\n/**\n * @see ControllerRecordSchema\n */\nexport const ControllerRecordSchema = z.tuple([RawPrincipalSchema, ControllerSchema]);\n\n/**\n * Represents a tuple containing the principal ID and associated controller data.\n */\nexport type ControllerRecord = z.infer<typeof ControllerRecordSchema>;\n\n/**\n * @see ControllersSchema\n */\nexport const ControllersSchema = z.array(ControllerRecordSchema);\n\n/**\n * Represents a list of controllers.\n */\nexport type Controllers = z.infer<typeof ControllersSchema>;\n\n/**\n * @see ControllerCheckParamsSchema\n */\nexport const ControllerCheckParamsSchema = z.object({\n caller: RawUserIdSchema.or(UserIdSchema),\n controllers: ControllersSchema\n});\n\n/**\n * Represents the parameters required to perform controller checks.\n */\nexport interface ControllerCheckParams {\n /**\n * The identity of the caller to verify against the controller list.\n */\n caller: RawUserId | UserId;\n\n /**\n * The list of controllers to check against.\n */\n controllers: Controllers;\n}\n", "import {Principal} from '@icp-sdk/core/principal';\nimport type {RawUserId, UserId} from '../../schemas/satellite';\n\n/**\n * Normalizes a user ID into a raw `Uint8Array` representation.\n *\n * @param {RawUserId | UserId} caller - The caller identity, either a raw `Uint8Array`\n * or a `Principal` instance.\n *\n * @returns {RawUserId} The raw user ID as a `Uint8Array`.\n */\nexport const normalizeCaller = (caller: RawUserId | UserId): RawUserId =>\n Principal.from(caller).toUint8Array();\n", "import {\n type ControllerCheckParams,\n type Controllers,\n ControllerCheckParamsSchema\n} from './schemas/controllers';\nimport {normalizeCaller} from './utils/caller.utils';\n\n/**\n * Gets the list of admin controllers from the Satellite.\n *\n * @returns {Controllers} The list of admin controllers.\n *\n * @throws {z.ZodError} If the returned value does not match the expected schema.\n */\nexport const getAdminControllers = (): Controllers => __juno_satellite_get_admin_controllers();\n\n/**\n * Gets the list of controllers from the Satellite.\n *\n * @returns {Controllers} The list of all controllers.\n *\n * @throws {z.ZodError} If the returned value does not match the expected schema.\n */\nexport const getControllers = (): Controllers => __juno_satellite_get_controllers();\n\n/**\n * Checks if the given caller is an admin among the provided controllers.\n *\n * @param {ControllerCheckParams} params - The parameters including the caller identity\n * and the list of controllers to verify against.\n *\n * @returns {boolean} Whether the caller is an admin.\n *\n * @throws {z.ZodError} If any input does not match the expected schema.\n */\nexport const isAdminController = (params: ControllerCheckParams): boolean => {\n ControllerCheckParamsSchema.parse(params);\n\n const {caller: providedCaller, controllers} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_is_admin_controller(caller, controllers);\n};\n\n/**\n * Checks if the given caller exists among the provided controllers.\n *\n * @param {ControllerCheckParams} params - The parameters including the caller identity\n * and the list of controllers to verify against.\n *\n * @returns {boolean} Whether the caller is a controller.\n *\n * @throws {z.ZodError} If any input does not match the expected schema.\n */\nexport const isController = (params: ControllerCheckParams): boolean => {\n ControllerCheckParamsSchema.parse(params);\n\n const {caller: providedCaller, controllers} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_is_controller(caller, controllers);\n};\n", "import * as z from 'zod';\nimport {type ListParams, ListParamsSchema} from '../../schemas/list';\nimport {\n type Collection,\n CollectionSchema,\n type RawUserId,\n RawUserIdSchema,\n type UserId,\n UserIdSchema\n} from '../../schemas/satellite';\n\n/**\n * @see CollectionParams\n */\nexport const CollectionParamsSchema = z\n .object({\n collection: CollectionSchema\n })\n .strict();\n\n/**\n * The parameters required to scope an operation to a collection.\n */\nexport interface CollectionParams {\n /**\n * The name of the collection to target.\n */\n collection: Collection;\n}\n\n/**\n * @see ListStoreParams\n */\nexport const ListStoreParamsSchema = CollectionParamsSchema.extend({\n caller: RawUserIdSchema.or(UserIdSchema),\n params: ListParamsSchema\n}).strict();\n\n/**\n * The parameters required to list documents from the datastore respectively assets from the storage.\n */\nexport type ListStoreParams = CollectionParams & {\n /**\n * The identity of the caller requesting the list operation.\n */\n caller: RawUserId | UserId;\n\n /**\n * Optional filtering, ordering, and pagination parameters.\n */\n params: ListParams;\n};\n", "import {type DelDoc, DelDocSchema, type SetDoc, SetDocSchema} from '../../schemas/db';\nimport {\n type Key,\n KeySchema,\n type RawUserId,\n RawUserIdSchema,\n type UserId,\n UserIdSchema\n} from '../../schemas/satellite';\nimport {\n type CollectionParams,\n CollectionParamsSchema,\n type ListStoreParams,\n ListStoreParamsSchema\n} from './params';\n\n/**\n * @see GetDocStoreParams\n */\nexport const GetDocStoreParamsSchema = CollectionParamsSchema.extend({\n caller: RawUserIdSchema.or(UserIdSchema),\n key: KeySchema\n}).strict();\n\n/**\n * Represents the base parameters required to access the datastore and modify a document.\n */\nexport type GetDocStoreParams = CollectionParams & {\n /**\n * The caller who initiate the document operation.\n */\n caller: RawUserId | UserId;\n\n /**\n * The key identifying the document within the collection.\n */\n key: Key;\n};\n\n/**\n * @see SetDocStoreParams\n */\nexport const SetDocStoreParamsSchema = GetDocStoreParamsSchema.extend({\n doc: SetDocSchema\n}).strict();\n\n/**\n * Represents the parameters required to store or update a document.\n *\n * This includes the document data along with metadata such as the caller,\n * collection, and key.\n */\nexport type SetDocStoreParams = GetDocStoreParams & {\n /**\n * The data, optional description and version required to create or update a document.\n */\n doc: SetDoc;\n};\n\n/**\n * @see DeleteDocStoreParams\n */\nexport const DeleteDocStoreParamsSchema = GetDocStoreParamsSchema.extend({\n doc: DelDocSchema\n}).strict();\n\n/**\n * Represents the parameters required to delete a document.\n *\n * This includes the document version along with metadata such as the caller,\n * collection, and key.\n */\nexport type DeleteDocStoreParams = GetDocStoreParams & {\n /**\n * The version required to delete a document.\n */\n doc: DelDoc;\n};\n\n/**\n * @see CountCollectionDocsStoreParams\n */\nexport const CountCollectionDocsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to count documents from the datastore.\n */\nexport type CountCollectionDocsStoreParams = CollectionParams;\n\n/**\n * @see CountDocsStoreParams\n */\nexport const CountDocsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to count documents from the datastore.\n */\nexport type CountDocsStoreParams = ListStoreParams;\n\n/**\n * @see ListDocsStoreParams\n */\nexport const ListDocsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to list documents from the datastore.\n */\nexport type ListDocsStoreParams = ListStoreParams;\n\n/**\n * @see DeleteDocsStoreParams\n */\nexport const DeleteDocsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to delete the documents from a collection of the datastore.\n */\nexport type DeleteDocsStoreParams = CollectionParams;\n\n/**\n * @see DeleteFilteredDocsParams\n */\nexport const DeleteFilteredDocsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to delete documents from the datastore.\n */\nexport type DeleteFilteredDocsStoreParams = ListStoreParams;\n", "import type {DocContext} from '../hooks/schemas/db/context';\nimport type {DocUpsert} from '../hooks/schemas/db/payload';\nimport type {Doc, OptionDoc} from '../schemas/db';\nimport type {ListResults} from '../schemas/list';\nimport {\n type CountCollectionDocsStoreParams,\n CountCollectionDocsStoreParamsSchema,\n type CountDocsStoreParams,\n CountDocsStoreParamsSchema,\n type DeleteDocsStoreParams,\n DeleteDocsStoreParamsSchema,\n type DeleteDocStoreParams,\n DeleteDocStoreParamsSchema,\n type DeleteFilteredDocsStoreParams,\n DeleteFilteredDocsStoreParamsSchema,\n type GetDocStoreParams,\n GetDocStoreParamsSchema,\n type ListDocsStoreParams,\n ListDocsStoreParamsSchema,\n type SetDocStoreParams,\n SetDocStoreParamsSchema\n} from './schemas/db';\nimport {normalizeCaller} from './utils/caller.utils';\n\n/**\n * Stores or updates a document in the datastore.\n *\n * The data must have been encoded - using encodeDocData - before calling this function.\n *\n * @param {SetDocStoreParams} params - The parameters required to store the document,\n * including the caller, collection, key, and document data.\n *\n * @returns {DocContext<DocUpsert>} The context of the stored or updated document,\n * including its key, collection, and both the previous and current versions of the document.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate or store the document.\n */\nexport const setDocStore = (params: SetDocStoreParams): DocContext<DocUpsert> => {\n SetDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key, doc} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_set_doc_store(caller, collection, key, doc);\n};\n\n/**\n * Deletes a document from the datastore.\n *\n * @param {DeleteDocStoreParams} params - The parameters required to delete the document,\n * including the caller, collection, key, and the expected version of the document.\n *\n * @returns {DocContext<OptionDoc>} The context of the deleted document,\n * including its key, collection, and optionally the previous document data if it existed.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate the request or the document cannot be deleted.\n */\nexport const deleteDocStore = (params: DeleteDocStoreParams): DocContext<OptionDoc> => {\n DeleteDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key, doc} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_delete_doc_store(caller, collection, key, doc);\n};\n\n/**\n * Retrieve a document from the datastore.\n *\n * @param {GetDocStoreParams} params - The parameters required to get the document.\n *\n * @returns {OptionDoc} The document if found, or undefined if not.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails while retrieving the document.\n */\nexport const getDocStore = (params: GetDocStoreParams): OptionDoc => {\n GetDocStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, key} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_get_doc_store(caller, collection, key);\n};\n\n/**\n * Lists documents from the datastore using optional filtering, pagination, and ordering parameters.\n *\n * @param {ListStoreParams} params - The parameters required to perform the list operation.\n *\n * @returns {ListResults<Doc>} A list result containing matching documents and pagination metadata.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the listing operation.\n */\nexport const listDocsStore = (params: ListDocsStoreParams): ListResults<Doc> => {\n ListDocsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_list_docs_store(caller, collection, listParams);\n};\n\n/**\n * Counts the number of documents in a specific collection.\n *\n * @param {CountCollectionDocsStoreParams} params - The parameters required to count documents in the collection.\n *\n * @returns {bigint} The total number of documents in the specified collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countCollectionDocsStore = (params: CountCollectionDocsStoreParams): bigint => {\n CountCollectionDocsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n return __juno_satellite_datastore_count_collection_docs_store(collection);\n};\n\n/**\n * Counts the number of documents in a collection matching specific filters and owned by a specific caller.\n *\n * @param {CountDocsStoreParams} params - The parameters required to perform the filtered count.\n *\n * @returns {bigint} The number of documents that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countDocsStore = (params: CountDocsStoreParams): bigint => {\n CountDocsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_count_docs_store(caller, collection, listParams);\n};\n\n/**\n * Delete documents in a specific collection of the Datastore.\n *\n * @param {DeleteDocsStoreParams} params - The parameters required to delete documents in the collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteDocsStore = (params: DeleteDocsStoreParams): void => {\n DeleteDocsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n __juno_satellite_datastore_delete_docs_store(collection);\n};\n\n/**\n * Delete documents in a collection matching specific filters and owned by a specific caller.\n *\n * @param {DeleteFilteredDocsStoreParams} params - The parameters required to perform the filtered deletion.\n *\n * @returns {DocContext<OptionDoc>[]} The context resulting of the deletion of documents that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteFilteredDocsStore = (\n params: DeleteFilteredDocsStoreParams\n): DocContext<OptionDoc>[] => {\n DeleteFilteredDocsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_datastore_delete_filtered_docs_store(caller, collection, listParams);\n};\n", "import * as z from 'zod';\n\n/**\n * @see Memory\n */\nexport const MemorySchema = z.enum(['heap', 'stable']);\n\n/**\n * Memory type used to select storage or datastore location.\n */\nexport type Memory = z.infer<typeof MemorySchema>;\n", "import * as z from 'zod';\nimport {type RawUserId, type UserId, RawUserIdSchema, UserIdSchema} from '../../schemas/satellite';\nimport {\n type AssetEncoding,\n type AssetKey,\n type Blob,\n type FullPath,\n type HeaderFields,\n AssetEncodingSchema,\n AssetKeySchema,\n BlobSchema,\n FullPathSchema,\n HeaderFieldsSchema\n} from '../../schemas/storage';\nimport {type Memory, MemorySchema} from './collections';\nimport {\n type CollectionParams,\n type ListStoreParams,\n CollectionParamsSchema,\n ListStoreParamsSchema\n} from './params';\n\n/**\n * @see GetAssetStoreParams\n */\nexport const GetAssetStoreParamsSchema = CollectionParamsSchema.extend({\n caller: RawUserIdSchema.or(UserIdSchema),\n full_path: FullPathSchema\n}).strict();\n\n/**\n * Represents the base parameters required to access the storage and modify an asset.\n */\nexport type GetAssetStoreParams = CollectionParams & {\n /**\n * The caller who initiate the document operation.\n */\n caller: RawUserId | UserId;\n\n /**\n * The full_path identifying the asset within the collection.\n */\n full_path: FullPath;\n};\n\n/**\n * @see CountCollectionAssetsStoreParams\n */\nexport const CountCollectionAssetsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to count documents from the storage.\n */\nexport type CountCollectionAssetsStoreParams = CollectionParams;\n\n/**\n * @see CountAssetsStoreParams\n */\nexport const CountAssetsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to count documents from the storage.\n */\nexport type CountAssetsStoreParams = ListStoreParams;\n\n/**\n * @see SetAssetHandlerParams\n */\nexport const SetAssetHandlerParamsSchema = z\n .object({\n key: AssetKeySchema,\n content: BlobSchema,\n headers: HeaderFieldsSchema\n })\n .strict();\n\n/**\n * The parameters required to set (or update) an asset.\n */\nexport interface SetAssetHandlerParams {\n /**\n * The key identifying the asset.\n */\n key: AssetKey;\n\n /**\n * The binary content of the asset.\n */\n content: Blob;\n\n /**\n * Associated HTTP headers.\n */\n headers: HeaderFields;\n}\n\n/**\n * @see DeleteAssetsStoreParams\n */\nexport const DeleteAssetsStoreParamsSchema = CollectionParamsSchema;\n\n/**\n * The parameters required to delete the assets from a collection of the storage.\n */\nexport type DeleteAssetsStoreParams = CollectionParams;\n\n/**\n * @see DeleteFilteredAssetsParams\n */\nexport const DeleteFilteredAssetsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to delete assets from the storage.\n */\nexport type DeleteFilteredAssetsStoreParams = ListStoreParams;\n\n/**\n * @see DeleteAssetStoreParams\n */\nexport const DeleteAssetStoreParamsSchema = GetAssetStoreParamsSchema;\n\n/**\n * Represents the parameters required to delete an asset.\n */\nexport type DeleteAssetStoreParams = GetAssetStoreParams;\n\n/**\n * @see ListAssetsStoreParams\n */\nexport const ListAssetsStoreParamsSchema = ListStoreParamsSchema;\n\n/**\n * The parameters required to list documents from the datastore.\n */\nexport type ListAssetsStoreParams = ListStoreParams;\n\n/**\n * @see GetContentChunksStoreParams\n */\nexport const GetContentChunksStoreParamsSchema = z\n .object({\n encoding: AssetEncodingSchema,\n chunk_index: z.bigint(),\n memory: MemorySchema\n })\n .strict();\n\n/**\n * The parameters required to retrieve a specific chunk from an asset.\n */\nexport interface GetContentChunksStoreParams {\n /**\n * The encoding of the chunks.\n */\n encoding: AssetEncoding;\n\n /**\n * The index of the chunk to retrieve.\n */\n chunk_index: bigint;\n\n /**\n * The memory type to retrieve the chunk from.\n */\n memory: Memory;\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", "import type {ListResults} from '../schemas/list';\nimport type {AssetNoContent, Blob, OptionAsset} from '../schemas/storage';\nimport {\n type CountAssetsStoreParams,\n CountAssetsStoreParamsSchema,\n type CountCollectionAssetsStoreParams,\n CountCollectionAssetsStoreParamsSchema,\n type DeleteAssetsStoreParams,\n DeleteAssetsStoreParamsSchema,\n type DeleteAssetStoreParams,\n DeleteAssetStoreParamsSchema,\n type DeleteFilteredAssetsStoreParams,\n DeleteFilteredAssetsStoreParamsSchema,\n type GetAssetStoreParams,\n GetAssetStoreParamsSchema,\n type GetContentChunksStoreParams,\n GetContentChunksStoreParamsSchema,\n type ListAssetsStoreParams,\n ListAssetsStoreParamsSchema,\n type SetAssetHandlerParams,\n SetAssetHandlerParamsSchema\n} from './schemas/storage';\nimport {normalizeCaller} from './utils/caller.utils';\n\n/**\n * Counts the number of assets in a specific collection.\n *\n * @param {CountCollectionAssetsStoreParams} params - The parameters required to count assets in the collection.\n *\n * @returns {bigint} The total number of assets in the specified collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countCollectionAssetsStore = (params: CountCollectionAssetsStoreParams): bigint => {\n CountCollectionAssetsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n return __juno_satellite_storage_count_collection_assets_store(collection);\n};\n\n/**\n * Counts the number of assets in a collection matching specific filters and owned by a specific caller.\n *\n * @param {CountAssetsStoreParams} params - The parameters required to perform the filtered count.\n *\n * @returns {bigint} The number of assets that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const countAssetsStore = (params: CountAssetsStoreParams): bigint => {\n CountAssetsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_count_assets_store(caller, collection, listParams);\n};\n\n/**\n * Sets or updates an asset in the storage.\n *\n * @param {SetAssetHandlerParams} params - The parameters required to set or update an asset.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the operation.\n */\nexport const setAssetHandler = (params: SetAssetHandlerParams): void => {\n SetAssetHandlerParamsSchema.parse(params);\n\n const {key, content, headers} = params;\n\n __juno_satellite_storage_set_asset_handler(key, content, headers);\n};\n\n/**\n * Deletes an asset from the storage.\n *\n * @param {DeleteAssetStoreParams} params - The parameters required to delete the asset.\n *\n * @returns {OptionAsset} The potentially deleted asset.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails to validate the request or the asset cannot be deleted.\n */\nexport const deleteAssetStore = (params: DeleteAssetStoreParams): OptionAsset => {\n DeleteAssetStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, full_path} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_delete_asset_store(caller, collection, full_path);\n};\n\n/**\n * Delete assets in a specific collection of the Storage.\n *\n * @param {DeleteAssetsStoreParams} params - The parameters required to delete assets in the collection.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteAssetsStore = (params: DeleteAssetsStoreParams): void => {\n DeleteAssetsStoreParamsSchema.parse(params);\n\n const {collection} = params;\n\n __juno_satellite_storage_delete_assets_store(collection);\n};\n\n/**\n * Delete assets in a collection matching specific filters and owned by a specific caller.\n *\n * @param {DeleteFilteredAssetsStoreParams} params - The parameters required to perform the filtered deletion.\n *\n * @returns {OptionAsset[]} The potential asset resulting of the deletion that match the provided filters.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the count operation.\n */\nexport const deleteFilteredAssetsStore = (\n params: DeleteFilteredAssetsStoreParams\n): OptionAsset[] => {\n DeleteFilteredAssetsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_delete_filtered_assets_store(caller, collection, listParams);\n};\n\n/**\n * Retrieve an asset from the storage.\n *\n * @param {GetAssetStoreParams} params - The parameters required to get the asset.\n *\n * @returns {OptionAsset} The asset if found, or undefined if not.\n *\n * @throws {z.ZodError} If the provided parameters do not match the expected schema.\n * @throws {Error} If the Satellite fails while retrieving the document.\n */\nexport const getAssetStore = (params: GetAssetStoreParams): OptionAsset => {\n GetAssetStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, full_path} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_get_asset_store(caller, collection, full_path);\n};\n\n/**\n * Lists assets (without content) from the storage using optional filtering, pagination, and ordering parameters.\n *\n * @param {ListStoreParams} params - The parameters required to perform the list operation.\n *\n * @returns {ListResults<AssetNoContent>} A list result containing matching assets and pagination metadata.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite fails while performing the listing operation.\n */\nexport const listAssetsStore = (params: ListAssetsStoreParams): ListResults<AssetNoContent> => {\n ListAssetsStoreParamsSchema.parse(params);\n\n const {caller: providedCaller, collection, params: listParams} = params;\n\n const caller = normalizeCaller(providedCaller);\n\n return __juno_satellite_storage_list_assets_store(caller, collection, listParams);\n};\n\n/**\n * Retrieves content chunks of an asset.\n *\n * This function fetches a content chunk of a given asset encoding using the specified parameters.\n *\n * @param {GetContentChunksStoreParams} params - The parameters including encoding, chunk index, and memory type.\n *\n * @returns {Blob | undefined} The content chunk if found, or `undefined` if not.\n *\n * @throws {z.ZodError} If the input parameters do not conform to the schema.\n * @throws {Error} If the Satellite throws an internal error during retrieval.\n */\nexport const getContentChunksStore = (params: GetContentChunksStoreParams): Blob | undefined => {\n GetContentChunksStoreParamsSchema.parse(params);\n\n const {encoding, chunk_index, memory} = params;\n\n return __juno_satellite_storage_get_content_chunks_store(encoding, chunk_index, memory);\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["z", "ControllerScopeSchema", "MetadataSchema", "ControllerSchema", "TimestampSchema", "ControllerRecordSchema", "RawPrincipalSchema", "ControllersSchema", "ControllerCheckParamsSchema", "RawUserIdSchema", "UserIdSchema", "Principal", "normalizeCaller", "caller", "getAdminControllers", "getControllers", "isAdminController", "params", "ControllerCheckParamsSchema", "providedCaller", "controllers", "caller", "normalizeCaller", "isController", "z", "CollectionParamsSchema", "CollectionSchema", "ListStoreParamsSchema", "RawUserIdSchema", "UserIdSchema", "ListParamsSchema", "GetDocStoreParamsSchema", "CollectionParamsSchema", "RawUserIdSchema", "UserIdSchema", "KeySchema", "SetDocStoreParamsSchema", "SetDocSchema", "DeleteDocStoreParamsSchema", "DelDocSchema", "CountCollectionDocsStoreParamsSchema", "CountDocsStoreParamsSchema", "ListStoreParamsSchema", "ListDocsStoreParamsSchema", "DeleteDocsStoreParamsSchema", "DeleteFilteredDocsStoreParamsSchema", "setDocStore", "params", "SetDocStoreParamsSchema", "providedCaller", "collection", "key", "doc", "caller", "normalizeCaller", "deleteDocStore", "DeleteDocStoreParamsSchema", "getDocStore", "GetDocStoreParamsSchema", "listDocsStore", "ListDocsStoreParamsSchema", "listParams", "countCollectionDocsStore", "CountCollectionDocsStoreParamsSchema", "countDocsStore", "CountDocsStoreParamsSchema", "deleteDocsStore", "DeleteDocsStoreParamsSchema", "deleteFilteredDocsStore", "DeleteFilteredDocsStoreParamsSchema", "z", "MemorySchema", "z", "GetAssetStoreParamsSchema", "CollectionParamsSchema", "RawUserIdSchema", "UserIdSchema", "FullPathSchema", "CountCollectionAssetsStoreParamsSchema", "CountAssetsStoreParamsSchema", "ListStoreParamsSchema", "SetAssetHandlerParamsSchema", "AssetKeySchema", "BlobSchema", "HeaderFieldsSchema", "DeleteAssetsStoreParamsSchema", "DeleteFilteredAssetsStoreParamsSchema", "DeleteAssetStoreParamsSchema", "ListAssetsStoreParamsSchema", "GetContentChunksStoreParamsSchema", "AssetEncodingSchema", "MemorySchema", "jsonReplacer", "jsonReviver", "decodeDocData", "data", "encodeDocData", "countCollectionAssetsStore", "params", "CountCollectionAssetsStoreParamsSchema", "collection", "countAssetsStore", "CountAssetsStoreParamsSchema", "providedCaller", "listParams", "caller", "normalizeCaller", "setAssetHandler", "SetAssetHandlerParamsSchema", "key", "content", "headers", "deleteAssetStore", "DeleteAssetStoreParamsSchema", "full_path", "deleteAssetsStore", "DeleteAssetsStoreParamsSchema", "deleteFilteredAssetsStore", "DeleteFilteredAssetsStoreParamsSchema", "getAssetStore", "GetAssetStoreParamsSchema", "listAssetsStore", "ListAssetsStoreParamsSchema", "getContentChunksStore", "GetContentChunksStoreParamsSchema", "encoding", "chunk_index", "memory"]
|
|
7
7
|
}
|
package/chunk-CCKUQNB5.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Principal as r}from"@dfinity/principal";import*as i from"zod";var n=i.custom(a=>a instanceof Uint8Array,{message:"Expected Uint8Array"}),c=n,t=i.custom(a=>a instanceof r,{message:"Expected an instance of a Principal"});export{n as a,c as b,t as c};
|
|
2
|
-
//# sourceMappingURL=chunk-CCKUQNB5.js.map
|
package/chunk-CCKUQNB5.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["src/schemas/candid.ts"],
|
|
4
|
-
"sourcesContent": ["import {Principal as CandidPrincipal} from '@dfinity/principal';\nimport * as z from 'zod';\n\n/**\n * A schema that validates a value is an Uint8Array.\n */\nexport const Uint8ArraySchema = z.custom<Uint8Array>((val) => val instanceof Uint8Array, {\n message: 'Expected Uint8Array'\n});\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 = z.infer<typeof RawPrincipalSchema>;\n\n/**\n * @see Principal\n */\nexport const PrincipalSchema = z.custom<CandidPrincipal>((val) => val instanceof CandidPrincipal, {\n message: 'Expected an instance of a Principal'\n});\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,OAAQ,aAAaA,MAAsB,qBAC3C,UAAYC,MAAO,MAKZ,IAAMC,EAAqB,SAAoBC,GAAQA,aAAe,WAAY,CACvF,QAAS,qBACX,CAAC,EAKYC,EAAqBF,EAUrBG,EAAoB,SAAyBF,GAAQA,aAAeH,EAAiB,CAChG,QAAS,qCACX,CAAC",
|
|
6
|
-
"names": ["CandidPrincipal", "z", "Uint8ArraySchema", "val", "RawPrincipalSchema", "PrincipalSchema"]
|
|
7
|
-
}
|
|
File without changes
|