@junobuild/functions 0.7.2 → 0.8.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 +399 -223
- package/canisters/ckbtc/index.js +1 -1
- package/canisters/cketh/index.js +1 -1
- package/canisters/cmc/index.js +1 -1
- package/canisters/declarations/ckbtc/bitcoin.did.d.ts +1 -1
- package/canisters/declarations/ckbtc/minter.did.d.ts +1 -1
- package/canisters/declarations/cketh/minter.did.d.ts +1 -1
- package/canisters/declarations/cketh/orchestrator.did.d.ts +1 -1
- package/canisters/declarations/cmc/cmc.did.d.ts +1 -1
- package/canisters/declarations/ic-management/ic-management.did.d.ts +1 -1
- package/canisters/declarations/ledger-icp/index.did.d.ts +1 -1
- package/canisters/declarations/ledger-icp/ledger.did.d.ts +1 -1
- package/canisters/declarations/ledger-icrc/icrc_icrc-1.did.d.ts +1 -1
- package/canisters/declarations/ledger-icrc/icrc_icrc-10.did.d.ts +1 -1
- package/canisters/declarations/ledger-icrc/icrc_index.did.d.ts +1 -1
- package/canisters/declarations/ledger-icrc/icrc_ledger.did.d.ts +1 -1
- package/canisters/declarations/ledger-icrc/icrc_nft-ledger.did.d.ts +1 -1
- package/canisters/declarations/nns/genesis_token.did.d.ts +1 -1
- package/canisters/declarations/nns/governance.did.d.ts +1 -1
- package/canisters/declarations/nns/governance_test.did.d.ts +1 -1
- package/canisters/declarations/nns/sns_wasm.did.d.ts +1 -1
- package/canisters/declarations/sns/governance.did.d.ts +1 -1
- package/canisters/declarations/sns/governance_test.did.d.ts +1 -1
- package/canisters/declarations/sns/root.did.d.ts +1 -1
- package/canisters/declarations/sns/swap.did.d.ts +1 -1
- package/canisters/ic-management/index.js +1 -1
- package/canisters/index.js +1 -1
- package/canisters/ledger/icp/index.js +1 -1
- package/canisters/ledger/icrc/index.js +1 -1
- package/canisters/nns/index.js +1 -1
- package/canisters/sns/index.js +1 -1
- package/{chunk-CAQXR2VB.js → chunk-I4MVAQHI.js} +1 -1
- package/{chunk-CAQXR2VB.js.map → chunk-I4MVAQHI.js.map} +1 -1
- package/chunk-JU5CZHLY.js +2 -0
- package/chunk-JU5CZHLY.js.map +7 -0
- package/chunk-VIFVPVUD.js +2 -0
- package/chunk-VIFVPVUD.js.map +7 -0
- package/chunk-X3EF7OU6.js +2 -0
- package/chunk-X3EF7OU6.js.map +7 -0
- package/chunk-YHNBR22R.js +2 -0
- package/chunk-YHNBR22R.js.map +7 -0
- package/chunk-ZBCLFWQJ.js +2 -0
- package/chunk-ZBCLFWQJ.js.map +7 -0
- package/functions/query.d.ts +8 -0
- package/functions/schemas/function.d.ts +27 -0
- package/functions/update.d.ts +8 -0
- package/global.d.ts +15 -6
- package/ic-cdk/http-request.ic-cdk.d.ts +10 -0
- package/ic-cdk/schemas/call.d.ts +1 -1
- package/ic-cdk/schemas/http-request.d.ts +142 -0
- package/ic-cdk.d.ts +2 -0
- package/ic-cdk.js +1 -1
- package/ic-cdk.js.map +4 -4
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.js.map +3 -3
- package/package.json +3 -3
- package/schemas/principal.d.ts +8 -0
- package/schemas/satellite.d.ts +1 -1
- package/sdk/access-keys.sdk.d.ts +50 -0
- package/sdk/guards.sdk.d.ts +25 -0
- package/sdk/schemas/{controllers.d.ts → access-keys.d.ts} +39 -38
- package/sdk.d.ts +3 -2
- package/sdk.js +1 -1
- package/sdk.js.map +4 -4
- package/src/canisters/declarations/ckbtc/bitcoin.did.d.ts +1 -1
- package/src/canisters/declarations/ckbtc/bitcoin.did.idl.js +1 -1
- package/src/canisters/declarations/ckbtc/minter.did.d.ts +1 -1
- package/src/canisters/declarations/ckbtc/minter.did.idl.js +1 -1
- package/src/canisters/declarations/cketh/minter.did.d.ts +1 -1
- package/src/canisters/declarations/cketh/minter.did.idl.js +1 -1
- package/src/canisters/declarations/cketh/orchestrator.did.d.ts +1 -1
- package/src/canisters/declarations/cketh/orchestrator.did.idl.js +1 -1
- package/src/canisters/declarations/cmc/cmc.did.d.ts +1 -1
- package/src/canisters/declarations/cmc/cmc.did.idl.js +1 -1
- package/src/canisters/declarations/ic-management/ic-management.did.d.ts +1 -1
- package/src/canisters/declarations/ic-management/ic-management.did.idl.js +1 -1
- package/src/canisters/declarations/ledger-icp/index.did.d.ts +1 -1
- package/src/canisters/declarations/ledger-icp/index.did.idl.js +1 -1
- package/src/canisters/declarations/ledger-icp/ledger.did.d.ts +1 -1
- package/src/canisters/declarations/ledger-icp/ledger.did.idl.js +1 -1
- package/src/canisters/declarations/ledger-icrc/icrc_icrc-1.did.d.ts +1 -1
- package/src/canisters/declarations/ledger-icrc/icrc_icrc-1.did.idl.js +1 -1
- package/src/canisters/declarations/ledger-icrc/icrc_icrc-10.did.d.ts +1 -1
- package/src/canisters/declarations/ledger-icrc/icrc_icrc-10.did.idl.js +1 -1
- package/src/canisters/declarations/ledger-icrc/icrc_index.did.d.ts +1 -1
- package/src/canisters/declarations/ledger-icrc/icrc_index.did.idl.js +1 -1
- package/src/canisters/declarations/ledger-icrc/icrc_ledger.did.d.ts +1 -1
- package/src/canisters/declarations/ledger-icrc/icrc_ledger.did.idl.js +1 -1
- package/src/canisters/declarations/ledger-icrc/icrc_nft-ledger.did.d.ts +1 -1
- package/src/canisters/declarations/ledger-icrc/icrc_nft-ledger.did.idl.js +1 -1
- package/src/canisters/declarations/nns/genesis_token.did.d.ts +1 -1
- package/src/canisters/declarations/nns/genesis_token.did.idl.js +1 -1
- package/src/canisters/declarations/nns/governance.did.d.ts +1 -1
- package/src/canisters/declarations/nns/governance.did.idl.js +1 -1
- package/src/canisters/declarations/nns/governance_test.did.d.ts +1 -1
- package/src/canisters/declarations/nns/governance_test.did.idl.js +1 -1
- package/src/canisters/declarations/nns/sns_wasm.did.d.ts +1 -1
- package/src/canisters/declarations/nns/sns_wasm.did.idl.js +1 -1
- package/src/canisters/declarations/sns/governance.did.d.ts +1 -1
- package/src/canisters/declarations/sns/governance.did.idl.js +1 -1
- package/src/canisters/declarations/sns/governance_test.did.d.ts +1 -1
- package/src/canisters/declarations/sns/governance_test.did.idl.js +1 -1
- package/src/canisters/declarations/sns/root.did.d.ts +1 -1
- package/src/canisters/declarations/sns/root.did.idl.js +1 -1
- package/src/canisters/declarations/sns/swap.did.d.ts +1 -1
- package/src/canisters/declarations/sns/swap.did.idl.js +1 -1
- package/src/global.d.ts +15 -6
- package/chunk-3CCXJJ4Y.js +0 -2
- package/chunk-3CCXJJ4Y.js.map +0 -7
- package/chunk-5IWIJYKG.js +0 -2
- package/chunk-5IWIJYKG.js.map +0 -7
- package/chunk-6QTAU2M5.js +0 -2
- package/chunk-6QTAU2M5.js.map +0 -7
- package/chunk-BAYP4XBH.js +0 -2
- package/chunk-BAYP4XBH.js.map +0 -7
- package/chunk-EHQF2DOU.js +0 -2
- package/chunk-EHQF2DOU.js.map +0 -7
- package/schemas/candid.d.ts +0 -21
- package/sdk/controllers.sdk.d.ts +0 -39
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
|
|
5
|
-
// This file was automatically generated by @icp-sdk/bindgen@0.
|
|
5
|
+
// This file was automatically generated by @icp-sdk/bindgen@0.3.0.
|
|
6
6
|
// You should NOT make any changes in this file as it will be overwritten.
|
|
7
7
|
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
|
|
5
|
-
// This file was automatically generated by @icp-sdk/bindgen@0.
|
|
5
|
+
// This file was automatically generated by @icp-sdk/bindgen@0.3.0.
|
|
6
6
|
// You should NOT make any changes in this file as it will be overwritten.
|
|
7
7
|
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
|
|
5
|
-
// This file was automatically generated by @icp-sdk/bindgen@0.
|
|
5
|
+
// This file was automatically generated by @icp-sdk/bindgen@0.3.0.
|
|
6
6
|
// You should NOT make any changes in this file as it will be overwritten.
|
|
7
7
|
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
|
|
5
|
-
// This file was automatically generated by @icp-sdk/bindgen@0.
|
|
5
|
+
// This file was automatically generated by @icp-sdk/bindgen@0.3.0.
|
|
6
6
|
// You should NOT make any changes in this file as it will be overwritten.
|
|
7
7
|
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
|
|
5
|
-
// This file was automatically generated by @icp-sdk/bindgen@0.
|
|
5
|
+
// This file was automatically generated by @icp-sdk/bindgen@0.3.0.
|
|
6
6
|
// You should NOT make any changes in this file as it will be overwritten.
|
|
7
7
|
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
|
|
5
|
-
// This file was automatically generated by @icp-sdk/bindgen@0.
|
|
5
|
+
// This file was automatically generated by @icp-sdk/bindgen@0.3.0.
|
|
6
6
|
// You should NOT make any changes in this file as it will be overwritten.
|
|
7
7
|
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
|
|
5
|
-
// This file was automatically generated by @icp-sdk/bindgen@0.
|
|
5
|
+
// This file was automatically generated by @icp-sdk/bindgen@0.3.0.
|
|
6
6
|
// You should NOT make any changes in this file as it will be overwritten.
|
|
7
7
|
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
8
8
|
|
package/src/global.d.ts
CHANGED
|
@@ -13,17 +13,25 @@ import type {
|
|
|
13
13
|
HeaderFields,
|
|
14
14
|
OptionAsset
|
|
15
15
|
} from './schemas/storage';
|
|
16
|
+
import type {AccessKeys} from './sdk/schemas/access-keys';
|
|
16
17
|
import type {Memory} from './sdk/schemas/collections';
|
|
17
|
-
import type {Controllers} from './sdk/schemas/controllers';
|
|
18
18
|
|
|
19
19
|
declare global {
|
|
20
|
-
function
|
|
21
|
-
function
|
|
22
|
-
function
|
|
20
|
+
function __juno_satellite_get_admin_access_keys(): AccessKeys;
|
|
21
|
+
function __juno_satellite_get_access_keys(): AccessKeys;
|
|
22
|
+
function __juno_satellite_is_write_access_key(
|
|
23
23
|
caller: RawUserId,
|
|
24
|
-
controllers:
|
|
24
|
+
controllers: AccessKeys
|
|
25
25
|
): boolean;
|
|
26
|
-
function
|
|
26
|
+
function __juno_satellite_is_valid_access_key(
|
|
27
|
+
caller: RawUserId,
|
|
28
|
+
controllers: AccessKeys
|
|
29
|
+
): boolean;
|
|
30
|
+
function __juno_satellite_is_admin_controller(caller: RawUserId, accessKeys: AccessKeys): boolean;
|
|
31
|
+
|
|
32
|
+
function __juno_satellite_caller_is_admin();
|
|
33
|
+
function __juno_satellite_caller_has_write_permission();
|
|
34
|
+
function __juno_satellite_caller_is_access_key();
|
|
27
35
|
|
|
28
36
|
function __juno_satellite_random(): number;
|
|
29
37
|
|
|
@@ -118,4 +126,5 @@ declare global {
|
|
|
118
126
|
method: string,
|
|
119
127
|
args: Uint8Array<ArrayBuffer>
|
|
120
128
|
): Promise<Uint8Array<ArrayBuffer>>;
|
|
129
|
+
function __ic_cdk_http_request(args: HttpRequestArgs): Promise<HttpRequestResult>;
|
|
121
130
|
}
|
package/chunk-3CCXJJ4Y.js
DELETED
package/chunk-3CCXJJ4Y.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["src/schemas/candid.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n PrincipalSchema as DfnPrincipalSchema,\n Uint8ArraySchema as DfnUint8ArraySchema\n} from '@junobuild/schema';\nimport type * as z from 'zod';\n\n/**\n * A schema that validates a value is an Uint8Array.\n */\nexport const Uint8ArraySchema = DfnUint8ArraySchema;\n\n/**\n * @see RawPrincipal\n */\nexport const RawPrincipalSchema = Uint8ArraySchema;\n\n/**\n * Represents a raw principal - a Uint8Array representation of a Principal.\n */\nexport type RawPrincipal = Uint8Array;\n\n/**\n * @see Principal\n */\nexport const PrincipalSchema = DfnPrincipalSchema;\n\n/**\n * Represents a principal - i.e. an object instantiated with the class Principal.\n */\nexport type Principal = z.infer<typeof PrincipalSchema>;\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,mBAAmBA,EACnB,oBAAoBC,MACf,oBAMA,IAAMC,EAAmBD,EAKnBE,EAAqBD,EAUrBE,EAAkBJ",
|
|
6
|
-
"names": ["DfnPrincipalSchema", "DfnUint8ArraySchema", "Uint8ArraySchema", "RawPrincipalSchema", "PrincipalSchema"]
|
|
7
|
-
}
|
package/chunk-5IWIJYKG.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as c,b as h,c as l}from"./chunk-3CCXJJ4Y.js";import*as a from"zod";var o=a.bigint(),n=a.bigint(),s=h,E=l,y=a.string(),p=a.string(),r=a.string().max(1024);import*as m from"zod";var g=c,b=m.object({owner:s,data:g,description:r.optional(),created_at:o,updated_at:o,version:n.optional()}).strict(),V=b.optional(),v=m.object({data:g,description:r.optional(),version:n.optional()}).strict(),M=m.object({version:n.optional()}).strict();import*as e from"zod";var u=e.tuple([e.string(),e.string()]),x=e.array(u),T=c,D=T,A=e.instanceof(Uint8Array).refine(i=>i.length===32,{message:"Hash must be a Uint8Array of length 32"}),z=e.object({name:e.string(),full_path:e.string(),token:e.string().optional(),collection:y,owner:s,description:r.optional()}).strict(),S=e.object({modified:o,content_chunks:e.array(D),total_length:e.bigint(),sha256:A}),w=S.omit({content_chunks:!0}).strict(),d=e.enum(["identity","gzip","compress","deflate","br"]),_=e.object({key:z,headers:x,encodings:e.array(e.tuple([d,S])),created_at:o,updated_at:o,version:n.optional()}).strict(),Z=_.omit({encodings:!0}).extend({encodings:e.array(e.tuple([d,w]))}).strict(),R=e.bigint(),G=e.object({key:z,reference_id:R.optional(),expires_at:o,encoding_type:d.optional()}).strict(),I=e.bigint(),U=e.bigint(),Q=e.object({batch_id:U,headers:x,chunk_ids:e.array(I)}).strict(),W=e.string(),X=e.string().optional(),Y=_.optional();import*as t from"zod";var f=t.union([t.object({equal:o}),t.object({greater_than:o}),t.object({less_than:o}),t.object({between:t.tuple([o,o])})]),j=t.object({key:p.optional(),description:r.optional(),created_at:f.optional(),updated_at:f.optional()}).strict(),k=t.object({start_after:p.optional(),limit:t.bigint().optional()}).strict(),O=t.enum(["keys","created_at","updated_at"]),C=t.object({desc:t.boolean(),field:O}).strict(),te=t.object({matcher:j.optional(),paginate:k.optional(),order:C.optional(),owner:s.optional()}).strict(),oe=i=>t.object({items:t.array(t.tuple([p,i])),items_length:t.bigint(),items_page:t.bigint().optional(),matches_length:t.bigint(),matches_pages:t.bigint().optional()}).strict();import{jsonReplacer as L,jsonReviver as K}from"@dfinity/utils";var re=i=>JSON.parse(__juno_satellite_datastore_raw_data_to_text(i),K),ne=i=>__juno_satellite_datastore_raw_data_from_text(JSON.stringify(i,L));export{o as a,n as b,s as c,E as d,y as e,p as f,r as g,g as h,b as i,V as j,v as k,M as l,x as m,T as n,z as o,S as p,_ as q,Z as r,G as s,Q as t,W as u,X as v,Y as w,f as x,j as y,k as z,O as A,C as B,te as C,oe as D,re as E,ne as F};
|
|
2
|
-
//# sourceMappingURL=chunk-5IWIJYKG.js.map
|
package/chunk-5IWIJYKG.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["src/schemas/satellite.ts", "src/schemas/db.ts", "src/schemas/storage.ts", "src/schemas/list.ts", "src/sdk/serializer.sdk.ts"],
|
|
4
|
-
"sourcesContent": ["import * as z from 'zod';\nimport {type RawPrincipal, PrincipalSchema, RawPrincipalSchema} from './candid';\n\n/**\n * @see Timestamp\n */\nexport const TimestampSchema = z.bigint();\n\n/**\n * Represents a timestamp in nanoseconds since the Unix epoch.\n *\n * Used for tracking when events occur, such as document creation and updates.\n */\nexport type Timestamp = z.infer<typeof TimestampSchema>;\n\n/**\n * @see Version\n */\nexport const VersionSchema = z.bigint();\n\n/**\n * Represents a version number for tracking changes.\n *\n * This is typically incremented with each update to ensure consistency.\n */\nexport type Version = z.infer<typeof VersionSchema>;\n\n/**\n * @see RawUserId\n */\nexport const RawUserIdSchema = RawPrincipalSchema;\n\n/**\n * Represents a raw user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type RawUserId = RawPrincipal;\n\n/**\n * @see UserId\n */\nexport const UserIdSchema = PrincipalSchema;\n\n/**\n * Represents a user identifier.\n *\n * This is a principal associated with a user.\n */\nexport type UserId = z.infer<typeof UserIdSchema>;\n\n/**\n * @see Collection\n */\nexport const CollectionSchema = z.string();\n\n/**\n * A collection name where data are stored.\n */\nexport type Collection = z.infer<typeof CollectionSchema>;\n\n/**\n * @see Key\n */\nexport const KeySchema = z.string();\n\n/**\n * A key identifier within a collection.\n */\nexport type Key = z.infer<typeof KeySchema>;\n\n/**\n * @see Description\n */\nexport const DescriptionSchema = z.string().max(1024);\n\n/**\n * Represents a description with a maximum length of 1024 characters.\n * Used for document and asset fields which can be useful for search purpose.\n */\nexport type Description = z.infer<typeof DescriptionSchema>;\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {\n type Description,\n DescriptionSchema,\n type RawUserId,\n RawUserIdSchema,\n type Timestamp,\n TimestampSchema,\n type Version,\n VersionSchema\n} from './satellite';\n\n/**\n * @see RawData\n */\nexport const RawDataSchema = Uint8ArraySchema;\n\n/**\n * Represents raw binary data.\n *\n * This is used to store structured data in a document.\n */\nexport type RawData = Uint8Array;\n\n/**\n * @see Doc\n */\nexport const DocSchema = z\n .object({\n owner: RawUserIdSchema,\n data: RawDataSchema,\n description: DescriptionSchema.optional(),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents a document stored in a collection.\n */\nexport interface Doc {\n /**\n * The user who owns this document.\n */\n owner: RawUserId;\n\n /**\n * The raw data of the document.\n */\n data: RawData;\n\n /**\n * An optional description of the document.\n */\n description?: Description;\n\n /**\n * The timestamp when the document was first created.\n */\n created_at: Timestamp;\n\n /**\n * The timestamp when the document was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * The version number of the document, used for consistency checks.\n * If not provided, it's assumed to be the first version.\n */\n version?: Version;\n}\n\n/**\n * @see OptionDoc\n */\nexport const OptionDocSchema = DocSchema.optional();\n\n/**\n * A shorthand for a document that might or not be defined.\n */\nexport type OptionDoc = Doc | undefined;\n\n/**\n * @see SetDoc\n */\nexport const SetDocSchema = z\n .object({\n data: RawDataSchema,\n description: DescriptionSchema.optional(),\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document to be created or updated.\n * This can be validated before allowing the operation.\n */\nexport interface SetDoc {\n /**\n * The raw data of the document.\n */\n data: RawData;\n\n /**\n * An optional description of the document.\n */\n description?: Description;\n\n /**\n * The expected version number to ensure consistency.\n */\n version?: Version;\n}\n\n/**\n * @see DelDoc\n */\nexport const DelDocSchema = z\n .object({\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * Represents the proposed version of a document to be deleted.\n * This can be validated before allowing the operation.\n */\nexport interface DelDoc {\n /**\n * The expected version number to ensure consistency.\n */\n version?: Version;\n}\n", "import * as z from 'zod';\nimport {Uint8ArraySchema} from './candid';\nimport {\n type Collection,\n CollectionSchema,\n type Description,\n DescriptionSchema,\n type RawUserId,\n RawUserIdSchema,\n type Timestamp,\n TimestampSchema,\n type Version,\n VersionSchema\n} from './satellite';\n\n/**\n * @see HeaderField\n */\nconst HeaderFieldSchema = z.tuple([z.string(), z.string()]);\n\n/**\n * Represents a single HTTP header as a tuple of name and value.\n */\nexport type HeaderField = [string, string];\n\n/**\n * @see HeaderFields\n */\nexport const HeaderFieldsSchema = z.array(HeaderFieldSchema);\n\n/**\n * Represents a list of HTTP headers.\n */\nexport type HeaderFields = HeaderField[];\n\n/**\n * @see Blob\n */\nexport const BlobSchema = Uint8ArraySchema;\n\n/**\n * Binary content used in asset encoding.\n */\nexport type Blob = Uint8Array;\n\n/**\n * @see BlobOrKey\n */\nconst BlobOrKeySchema = BlobSchema;\n\n/**\n * When stable memory is used, chunks are saved within a StableBTreeMap and their keys - StableEncodingChunkKey - are saved for reference as serialized values\n */\nexport type BlobOrKey = Uint8Array;\n\n/**\n * @see Hash\n */\nconst HashSchema = z.instanceof(Uint8Array).refine((val) => val.length === 32, {\n message: 'Hash must be a Uint8Array of length 32'\n});\n\n/**\n * Represents a SHA-256 hash as a 32-byte binary value.\n */\nexport type Hash = Uint8Array;\n\n/**\n * @see AssetKey\n */\nexport const AssetKeySchema = z\n .object({\n name: z.string(),\n full_path: z.string(),\n token: z.string().optional(),\n collection: CollectionSchema,\n owner: RawUserIdSchema,\n description: DescriptionSchema.optional()\n })\n .strict();\n\n/**\n * Metadata identifying an asset within a collection and the storage system.\n */\nexport interface AssetKey {\n /**\n * The name of the asset (e.g., \"logo.png\").\n */\n name: string;\n\n /**\n * The full relative path of the asset (e.g., \"/images/logo.png\").\n */\n full_path: string;\n\n /**\n * Optional access token for the asset.\n * If set, can be used using a query parameter e.g. /full_path/?token=1223-3345-5564-3333\n */\n token?: string;\n\n /**\n * The collection to which this asset belongs.\n */\n collection: Collection;\n\n /**\n * The owner of the asset.\n */\n owner: RawUserId;\n\n /**\n * Optional description of the asset for indexing/search.\n */\n description?: Description;\n}\n\n/**\n * @see AssetEncoding\n */\nexport const AssetEncodingSchema = z.object({\n modified: TimestampSchema,\n content_chunks: z.array(BlobOrKeySchema),\n total_length: z.bigint(),\n sha256: HashSchema\n});\n\n/**\n * Represents a specific encoding of an asset, such as \"gzip\" or \"identity\" (no compression).\n */\nexport interface AssetEncoding {\n /**\n * Timestamp when the encoding was last modified.\n */\n modified: Timestamp;\n\n /**\n * Chunks of binary content or references to them.\n */\n content_chunks: BlobOrKey[];\n\n /**\n * Total byte size of the encoded content.\n */\n total_length: bigint;\n\n /**\n * SHA-256 hash of the encoded content.\n */\n sha256: Hash;\n}\n\n/**\n * @see AssetEncodingNoContent\n */\nconst AssetEncodingNoContentSchema = AssetEncodingSchema.omit({content_chunks: true}).strict();\n\n/**\n * Represents a specific encoding of an asset, such as \"gzip\" or \"identity\" (no compression), without the chunks.\n */\nexport type AssetEncodingNoContent = Omit<AssetEncoding, 'content_chunks'>;\n\n/**\n * @see EncodingType\n */\nconst EncodingTypeSchema = z.enum(['identity', 'gzip', 'compress', 'deflate', 'br']);\n\n/**\n * A string identifier representing a specific encoding format (e.g., \"gzip\", \"identity\").\n */\nexport type EncodingType = 'identity' | 'gzip' | 'compress' | 'deflate' | 'br';\n\n/**\n * @see Asset\n */\nexport const AssetSchema = z\n .object({\n key: AssetKeySchema,\n headers: HeaderFieldsSchema,\n encodings: z.array(z.tuple([EncodingTypeSchema, AssetEncodingSchema])),\n created_at: TimestampSchema,\n updated_at: TimestampSchema,\n version: VersionSchema.optional()\n })\n .strict();\n\n/**\n * A stored asset including its metadata, encodings, and timestamps.\n */\nexport interface Asset {\n /**\n * Metadata about the asset's identity and ownership.\n */\n key: AssetKey;\n\n /**\n * Optional HTTP headers associated with the asset.\n */\n headers: HeaderField[];\n\n /**\n * A mapping from encoding types (e.g., \"identity\", \"gzip\") to the corresponding encoded version.\n */\n encodings: [EncodingType, AssetEncoding][];\n\n /**\n * Timestamp when the asset was created.\n */\n created_at: Timestamp;\n\n /**\n * Timestamp when the asset was last updated.\n */\n updated_at: Timestamp;\n\n /**\n * Optional version number of the asset.\n */\n version?: Version;\n}\n\n/**\n * @see AssetNoContent\n */\nexport const AssetNoContentSchema = AssetSchema.omit({encodings: true})\n .extend({\n encodings: z.array(z.tuple([EncodingTypeSchema, AssetEncodingNoContentSchema]))\n })\n .strict();\n\n/**\n * A stored asset including its metadata, encodings without chunks, and timestamps.\n */\nexport type AssetNoContent = Omit<Asset, 'encodings'> & {\n encodings: [EncodingType, AssetEncodingNoContent][];\n};\n\n/**\n * @see ReferenceId\n */\nconst ReferenceIdSchema = z.bigint();\n\n/**\n * A unique reference identifier for batches.\n */\nexport type ReferenceId = bigint;\n\n/**\n * @see Batch\n */\nexport const BatchSchema = z\n .object({\n key: AssetKeySchema,\n reference_id: ReferenceIdSchema.optional(),\n expires_at: TimestampSchema,\n encoding_type: EncodingTypeSchema.optional()\n })\n .strict();\n\n/**\n * Represents a batch of chunks to be uploaded and committed to an asset.\n */\nexport interface Batch {\n /**\n * The metadata key for the asset being uploaded.\n */\n key: AssetKey;\n\n /**\n * Optional reference ID for tracking or validation.\n */\n reference_id?: ReferenceId;\n\n /**\n * Timestamp when this batch expires.\n */\n expires_at: Timestamp;\n\n /**\n * Optional encoding format (e.g., \"gzip\").\n */\n encoding_type?: EncodingType;\n}\n\n/**\n * @see ChunkId\n */\nconst ChunkIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a single chunk of data.\n */\nexport type ChunkId = bigint;\n\n/**\n * @see BatchId\n */\nconst BatchIdSchema = z.bigint();\n\n/**\n * A unique identifier representing a batch of upload.\n */\nexport type BatchId = bigint;\n\n/**\n * @see CommitBatch\n */\nexport const CommitBatchSchema = z\n .object({\n batch_id: BatchIdSchema,\n headers: HeaderFieldsSchema,\n chunk_ids: z.array(ChunkIdSchema)\n })\n .strict();\n\n/**\n * Represents the final step in uploading an asset, committing the batch to storage.\n */\nexport interface CommitBatch {\n /**\n * The ID of the batch being committed.\n */\n batch_id: BatchId;\n\n /**\n * HTTP headers associated with this asset.\n */\n headers: HeaderField[];\n\n /**\n * List of chunk IDs that make up the asset content.\n */\n chunk_ids: ChunkId[];\n}\n\n/**\n * @see FullPath\n */\nexport const FullPathSchema = z.string();\n\n/**\n * Represents the relative path of an asset in storage.\n * For assets that are not part of the frontend app, the collection must be included at the root of the path.\n *\n * Example: `/images/a-sun-above-the-mountains.png`\n */\nexport type FullPath = string;\n\n/**\n * @see AssetAccessToken\n */\nexport const AssetAccessTokenSchema = z.string().optional();\n\n/**\n * An optional access token that can be used to make an asset private on the web.\n * Private as in practically unguessable (if complex enough and not shared of course).\n *\n * Example: `/images/a-sun-above-the-mountains.png?token=a-super-long-unguessable-not-shared-id`\n */\nexport type AssetAccessToken = string | undefined;\n\n/**\n * @see OptionAsset\n */\nexport const OptionAssetSchema = AssetSchema.optional();\n\n/**\n * A shorthand for an asset that might or not be defined.\n */\nexport type OptionAsset = Asset | undefined;\n", "import * as z from 'zod';\nimport {\n type Description,\n type Key,\n type RawUserId,\n type Timestamp,\n DescriptionSchema,\n KeySchema,\n RawUserIdSchema,\n TimestampSchema\n} from './satellite';\n\n/**\n * @see TimestampMatcher\n */\nexport const TimestampMatcherSchema = z.union([\n z.object({equal: TimestampSchema}),\n z.object({greater_than: TimestampSchema}),\n z.object({less_than: TimestampSchema}),\n z.object({between: z.tuple([TimestampSchema, TimestampSchema])})\n]);\n\n/**\n * TimestampMatcher matches a timestamp field using a specific strategy.\n */\nexport type TimestampMatcher =\n | {equal: Timestamp}\n | {greater_than: Timestamp}\n | {less_than: Timestamp}\n | {between: [Timestamp, Timestamp]};\n\n/**\n * @see ListMatcher\n */\nexport const ListMatcherSchema = z\n .object({\n key: KeySchema.optional(),\n description: DescriptionSchema.optional(),\n created_at: TimestampMatcherSchema.optional(),\n updated_at: TimestampMatcherSchema.optional()\n })\n .strict();\n\n/**\n * Matcher used to filter list results.\n */\nexport interface ListMatcher {\n key?: Key;\n description?: Description;\n created_at?: TimestampMatcher;\n updated_at?: TimestampMatcher;\n}\n\n/**\n * @see ListPaginate\n */\nexport const ListPaginateSchema = z\n .object({\n start_after: KeySchema.optional(),\n limit: z.bigint().optional()\n })\n .strict();\n\n/**\n * Optional pagination controls for listing.\n */\nexport interface ListPaginate {\n start_after?: Key;\n limit?: bigint;\n}\n\n/**\n * @see ListOrderField\n */\nexport const ListOrderFieldSchema = z.enum(['keys', 'created_at', 'updated_at']);\n\n/**\n * Enum representing possible fields to order by.\n */\nexport type ListOrderField = 'keys' | 'updated_at' | 'created_at';\n\n/**\n * @see ListOrder\n */\nexport const ListOrderSchema = z\n .object({\n desc: z.boolean(),\n field: ListOrderFieldSchema\n })\n .strict();\n\n/**\n * Ordering strategy for listing documents.\n */\nexport interface ListOrder {\n desc: boolean;\n field: ListOrderField;\n}\n\n/**\n * @see ListParams\n */\nexport const ListParamsSchema = z\n .object({\n matcher: ListMatcherSchema.optional(),\n paginate: ListPaginateSchema.optional(),\n order: ListOrderSchema.optional(),\n owner: RawUserIdSchema.optional()\n })\n .strict();\n\n/**\n * Full set of listing parameters.\n */\nexport interface ListParams {\n matcher?: ListMatcher;\n paginate?: ListPaginate;\n order?: ListOrder;\n owner?: RawUserId;\n}\n\n/**\n * Represents a list result.\n *\n * @template T - The type of the data returned per item.\n * @see JsListResults\n */\nexport const createListResultsSchema = <T extends z.ZodTypeAny>(itemData: T) =>\n z\n .object({\n items: z.array(z.tuple([KeySchema, itemData])),\n items_length: z.bigint(),\n items_page: z.bigint().optional(),\n matches_length: z.bigint(),\n matches_pages: z.bigint().optional()\n })\n .strict();\n\n/**\n * List results, parameterized by type of returned item.\n */\nexport interface ListResults<T> {\n items: [Key, T][];\n items_length: bigint;\n items_page?: bigint;\n matches_length: bigint;\n matches_pages?: bigint;\n}\n", "import {jsonReplacer, jsonReviver} from '@dfinity/utils';\nimport type {RawData} from '../schemas/db';\n\n/**\n * Decodes the raw data of a document into a JavaScript object.\n *\n * @template T The expected type of the decoded object.\n * @param {RawData} data - The raw data to be decoded.\n * @returns {T} The parsed JavaScript object.\n */\nexport const decodeDocData = <T>(data: RawData): T =>\n JSON.parse(__juno_satellite_datastore_raw_data_to_text(data), jsonReviver);\n\n/**\n * Encodes a JavaScript object into a raw data format to be applied to a document.\n *\n * @template T The type of the object to be encoded.\n * @param {T} data - The data to be encoded.\n * @returns {RawData} The serialized raw data.\n */\nexport const encodeDocData = <T>(data: T): RawData =>\n __juno_satellite_datastore_raw_data_from_text(JSON.stringify(data, jsonReplacer));\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["z", "TimestampSchema", "VersionSchema", "RawUserIdSchema", "RawPrincipalSchema", "UserIdSchema", "PrincipalSchema", "CollectionSchema", "KeySchema", "DescriptionSchema", "z", "RawDataSchema", "Uint8ArraySchema", "DocSchema", "RawUserIdSchema", "DescriptionSchema", "TimestampSchema", "VersionSchema", "OptionDocSchema", "SetDocSchema", "DelDocSchema", "z", "HeaderFieldSchema", "HeaderFieldsSchema", "BlobSchema", "Uint8ArraySchema", "BlobOrKeySchema", "HashSchema", "val", "AssetKeySchema", "CollectionSchema", "RawUserIdSchema", "DescriptionSchema", "AssetEncodingSchema", "TimestampSchema", "AssetEncodingNoContentSchema", "EncodingTypeSchema", "AssetSchema", "VersionSchema", "AssetNoContentSchema", "ReferenceIdSchema", "BatchSchema", "ChunkIdSchema", "BatchIdSchema", "CommitBatchSchema", "FullPathSchema", "AssetAccessTokenSchema", "OptionAssetSchema", "z", "TimestampMatcherSchema", "TimestampSchema", "ListMatcherSchema", "KeySchema", "DescriptionSchema", "ListPaginateSchema", "ListOrderFieldSchema", "ListOrderSchema", "ListParamsSchema", "RawUserIdSchema", "createListResultsSchema", "itemData", "jsonReplacer", "jsonReviver", "decodeDocData", "data", "encodeDocData"]
|
|
7
|
-
}
|
package/chunk-6QTAU2M5.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as o,c as s}from"./chunk-3CCXJJ4Y.js";import{IDL as w}from"@icp-sdk/core/candid";import*as e from"zod";var n=e.custom(r=>r instanceof w.Type,{message:"Invalid IDL.Type"}),A=e.tuple([n,e.unknown()]),S=e.array(A),z=n,l=e.object({canisterId:o.or(s),method:e.string().min(1),args:S.optional(),result:z.optional()});var t=class extends Error{constructor(){super(),this.message="More than one object returned by the response. This is unexpected."}};import{toNullable as D}from"@dfinity/utils";import{IDL as p}from"@icp-sdk/core/candid";import{Principal as L}from"@icp-sdk/core/principal";var M=async r=>{l.parse(r);let{canisterId:c,method:i,args:m,result:y}=r,u=L.from(c).toUint8Array(),[f,d]=(m??[]).reduce(([I,x],[T,P])=>[[...I,T],[...x,P]],[[],[]]),h=new Uint8Array(p.encode([...f],[...d])),g=await __ic_cdk_call_raw(u,i,h),a=p.decode(D(y),g);if(a.length>1)throw new t;let[C]=a;return C};export{n as a,A as b,S as c,z as d,l as e,t as f,M as g};
|
|
2
|
-
//# sourceMappingURL=chunk-6QTAU2M5.js.map
|
package/chunk-6QTAU2M5.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["src/ic-cdk/schemas/call.ts", "src/ic-cdk/types/errors.ts", "src/ic-cdk/call.ic-cdk.ts"],
|
|
4
|
-
"sourcesContent": ["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 {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"],
|
|
5
|
-
"mappings": "+CAAA,OAAQ,OAAAA,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,ECNA,OAAQ,cAAAC,MAAiB,iBACzB,OAAQ,OAAAC,MAAU,uBAClB,OAAQ,aAAAC,MAAgB,0BAiBjB,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",
|
|
6
|
-
"names": ["IDL", "z", "IDLTypeSchema", "val", "IDL", "CallArgSchema", "CallArgsSchema", "CallResultSchema", "CallParamsSchema", "RawPrincipalSchema", "PrincipalSchema", "CallResponseLengthError", "toNullable", "IDL", "Principal", "call", "params", "CallParamsSchema", "providedCanisterId", "method", "providedArgs", "resultType", "canisterId", "Principal", "argsTypes", "argsValues", "type", "value", "args", "IDL", "bytes", "result", "toNullable", "CallResponseLengthError", "response"]
|
|
7
|
-
}
|
package/chunk-BAYP4XBH.js
DELETED
package/chunk-BAYP4XBH.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["src/canisters/schemas.ts"],
|
|
4
|
-
"sourcesContent": ["import * as z from 'zod';\nimport {PrincipalSchema} from '../schemas/candid';\n\n/**\n * @see CanisterOptions\n */\nexport const CanisterOptionsSchema = z.strictObject({\n canisterId: PrincipalSchema.optional()\n});\n\n/**\n * The options to initialize a canister.\n */\nexport type CanisterOptions = z.infer<typeof CanisterOptionsSchema>;\n"],
|
|
5
|
-
"mappings": "wCAAA,UAAYA,MAAO,MAMZ,IAAMC,EAA0B,eAAa,CAClD,WAAYC,EAAgB,SAAS,CACvC,CAAC",
|
|
6
|
-
"names": ["z", "CanisterOptionsSchema", "PrincipalSchema"]
|
|
7
|
-
}
|
package/chunk-EHQF2DOU.js
DELETED
package/chunk-EHQF2DOU.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["src/canisters/_canister.ts"],
|
|
4
|
-
"sourcesContent": ["import type {Principal} from '@icp-sdk/core/principal';\nimport * as z from 'zod';\nimport {PrincipalSchema} from '../schemas/candid';\n\n/**\n * @see CanisterParameters\n */\nexport const CanisterParametersSchema = z.strictObject({\n canisterId: PrincipalSchema\n});\n\n/**\n * The parameters that define a canister.\n */\nexport type CanisterParameters = z.infer<typeof CanisterParametersSchema>;\n\nexport abstract class Canister {\n readonly #id: Principal;\n\n protected constructor({canisterId}: CanisterParameters) {\n this.#id = canisterId;\n }\n\n get canisterId(): Principal {\n return this.#id;\n }\n}\n"],
|
|
5
|
-
"mappings": "wCACA,UAAYA,MAAO,MAMZ,IAAMC,EAA6B,eAAa,CACrD,WAAYC,CACd,CAAC,EAOqBC,EAAf,KAAwB,CACpBC,GAEC,YAAY,CAAC,WAAAC,CAAU,EAAuB,CACtD,KAAKD,GAAMC,CACb,CAEA,IAAI,YAAwB,CAC1B,OAAO,KAAKD,EACd,CACF",
|
|
6
|
-
"names": ["z", "CanisterParametersSchema", "PrincipalSchema", "Canister", "#id", "canisterId"]
|
|
7
|
-
}
|
package/schemas/candid.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type * as z from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* A schema that validates a value is an Uint8Array.
|
|
4
|
-
*/
|
|
5
|
-
export declare const Uint8ArraySchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
6
|
-
/**
|
|
7
|
-
* @see RawPrincipal
|
|
8
|
-
*/
|
|
9
|
-
export declare const RawPrincipalSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
10
|
-
/**
|
|
11
|
-
* Represents a raw principal - a Uint8Array representation of a Principal.
|
|
12
|
-
*/
|
|
13
|
-
export type RawPrincipal = Uint8Array;
|
|
14
|
-
/**
|
|
15
|
-
* @see Principal
|
|
16
|
-
*/
|
|
17
|
-
export declare const PrincipalSchema: z.ZodPipe<z.ZodCustom<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>, z.ZodTransform<import("@icp-sdk/core/principal").Principal, import("@icp-sdk/core/principal").Principal>>;
|
|
18
|
-
/**
|
|
19
|
-
* Represents a principal - i.e. an object instantiated with the class Principal.
|
|
20
|
-
*/
|
|
21
|
-
export type Principal = z.infer<typeof PrincipalSchema>;
|
package/sdk/controllers.sdk.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { type ControllerCheckParams, type Controllers } from './schemas/controllers';
|
|
2
|
-
/**
|
|
3
|
-
* Gets the list of admin controllers from the Satellite.
|
|
4
|
-
*
|
|
5
|
-
* @returns {Controllers} The list of admin controllers.
|
|
6
|
-
*
|
|
7
|
-
* @throws {z.ZodError} If the returned value does not match the expected schema.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getAdminControllers: () => Controllers;
|
|
10
|
-
/**
|
|
11
|
-
* Gets the list of controllers from the Satellite.
|
|
12
|
-
*
|
|
13
|
-
* @returns {Controllers} The list of all controllers.
|
|
14
|
-
*
|
|
15
|
-
* @throws {z.ZodError} If the returned value does not match the expected schema.
|
|
16
|
-
*/
|
|
17
|
-
export declare const getControllers: () => Controllers;
|
|
18
|
-
/**
|
|
19
|
-
* Checks if the given caller is an admin among the provided controllers.
|
|
20
|
-
*
|
|
21
|
-
* @param {ControllerCheckParams} params - The parameters including the caller identity
|
|
22
|
-
* and the list of controllers to verify against.
|
|
23
|
-
*
|
|
24
|
-
* @returns {boolean} Whether the caller is an admin.
|
|
25
|
-
*
|
|
26
|
-
* @throws {z.ZodError} If any input does not match the expected schema.
|
|
27
|
-
*/
|
|
28
|
-
export declare const isAdminController: (params: ControllerCheckParams) => boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Checks if the given caller exists among the provided controllers.
|
|
31
|
-
*
|
|
32
|
-
* @param {ControllerCheckParams} params - The parameters including the caller identity
|
|
33
|
-
* and the list of controllers to verify against.
|
|
34
|
-
*
|
|
35
|
-
* @returns {boolean} Whether the caller is a controller.
|
|
36
|
-
*
|
|
37
|
-
* @throws {z.ZodError} If any input does not match the expected schema.
|
|
38
|
-
*/
|
|
39
|
-
export declare const isController: (params: ControllerCheckParams) => boolean;
|