From f630795ce66b81006a106af58ad94d9b4e740a35 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Tue, 10 Jun 2025 21:45:32 +0200 Subject: [PATCH 1/3] feat: support for merging DID files --- README.md | 10 +- src/main.rs | 18 +-- tests/cli_test.rs | 14 +++ tests/data/output.did | 253 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 286 insertions(+), 9 deletions(-) create mode 100644 tests/data/output.did diff --git a/README.md b/README.md index 218ab53..73d4068 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # JunoBuild-Didc -`junobuild-didc` is a CLI tool for generating JavaScript or TypeScript content from a DID file using the [didc](https://github.com/dfinity/candid) tool. +`junobuild-didc` is a CLI tool for generating JavaScript, TypeScript, or DID output from a Candid `.did` file using the [didc](https://github.com/dfinity/candid) tool. This utility is designed to be integrated in Juno's CLI. @@ -42,6 +42,14 @@ cd didc cargo build --release ``` +Once built, the binary will be located in `target/release`. You can run it from the root directory: + +```bash +./target/release/junobuild-didc --help +``` + +This will display the available commands and usage instructions. + ### Running Tests You can run the tests with: diff --git a/src/main.rs b/src/main.rs index 1342608..335a1f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use anyhow::Result; use candid_parser::bindings::{javascript, typescript}; +use candid_parser::pretty; use candid_parser::pretty_check_file; use clap::Parser; use std::fs::{create_dir_all, write}; @@ -18,8 +19,8 @@ struct Cli { #[clap(short, long)] output: Option, - /// Target output format: either `js` for JavaScript or `ts` for TypeScript. - #[clap(short, long, value_parser = ["js", "ts"])] + /// Target output format: either `js` for JavaScript, `ts` for TypeScript or `did` for Candid. + #[clap(short, long, value_parser = ["js", "ts", "did"])] target: String, } @@ -45,14 +46,14 @@ fn write_output(output_path: &Path, content: &str) -> Result<()> { Ok(()) } -/// A function to generate JavaScript or TypeScript content from a DID file. +/// A function to generate JavaScript, TypeScript, or DID content from a `.did` file. /// -/// This main function serves as a wrapper around the `didc` tool, parsing the command-line arguments, -/// processing the input `.did` file, and either printing the compiled output to stdout or writing it -/// to a specified file based on user input. +/// This `main` function serves as a wrapper around the `didc` tool. It parses command-line arguments, +/// processes the input `.did` file, and outputs the result either to stdout or to a specified file, +/// depending on user input. /// -/// This function leverages `didc`'s capabilities for parsing and compiling Candid files into JavaScript -/// or TypeScript bindings, allowing users to seamlessly generate the necessary bindings for their projects. +/// The parser resolves any imported services and produces a single, self-contained output file +/// — whether it's JavaScript, TypeScript, or a `.did` definition. /// /// # Errors /// @@ -65,6 +66,7 @@ fn main() -> Result<()> { let content = match cli.target.as_str() { "ts" => typescript::compile(&env, &actor), "js" => javascript::compile(&env, &actor), + "did" => pretty::candid::compile(&env, &actor), _ => unreachable!(), }; diff --git a/tests/cli_test.rs b/tests/cli_test.rs index 03d8d97..b52addf 100644 --- a/tests/cli_test.rs +++ b/tests/cli_test.rs @@ -69,6 +69,11 @@ fn test_ts_target() { run_test_for_target("ts", "tests/data/satellite.ts", None); } +#[test] +fn test_did_target() { + run_test_for_target("did", "tests/data/output.did", None); +} + #[test] fn test_js_target_with_output_file() { run_test_for_target( @@ -86,3 +91,12 @@ fn test_ts_target_with_output_file() { Some("target/test/output.ts"), ); } + +#[test] +fn test_did_target_with_output_file() { + run_test_for_target( + "did", + "tests/data/output.did", + Some("target/test/custom_output.did"), + ); +} diff --git a/tests/data/output.did b/tests/data/output.did new file mode 100644 index 0000000..49d0637 --- /dev/null +++ b/tests/data/output.did @@ -0,0 +1,253 @@ +type AssetEncodingNoContent = record { + modified : nat64; + sha256 : blob; + total_length : nat; +}; +type AssetKey = record { + token : opt text; + collection : text; + owner : principal; + name : text; + description : opt text; + full_path : text; +}; +type AssetNoContent = record { + key : AssetKey; + updated_at : nat64; + encodings : vec record { text; AssetEncodingNoContent }; + headers : vec record { text; text }; + created_at : nat64; + version : opt nat64; +}; +type AuthenticationConfig = record { + internet_identity : opt AuthenticationConfigInternetIdentity; +}; +type AuthenticationConfigInternetIdentity = record { + derivation_origin : opt text; +}; +type CommitBatch = record { + batch_id : nat; + headers : vec record { text; text }; + chunk_ids : vec nat; +}; +type Config = record { + db : opt DbConfig; + authentication : opt AuthenticationConfig; + storage : StorageConfig; +}; +type ConfigMaxMemorySize = record { stable : opt nat64; heap : opt nat64 }; +type Controller = record { + updated_at : nat64; + metadata : vec record { text; text }; + created_at : nat64; + scope : ControllerScope; + expires_at : opt nat64; +}; +type ControllerScope = variant { Write; Admin }; +type CustomDomain = record { + updated_at : nat64; + created_at : nat64; + version : opt nat64; + bn_id : opt text; +}; +type DbConfig = record { max_memory_size : opt ConfigMaxMemorySize }; +type DelDoc = record { version : opt nat64 }; +type DelRule = record { version : opt nat64 }; +type DeleteControllersArgs = record { controllers : vec principal }; +type DepositCyclesArgs = record { cycles : nat; destination_id : principal }; +type Doc = record { + updated_at : nat64; + owner : principal; + data : blob; + description : opt text; + created_at : nat64; + version : opt nat64; +}; +type HttpRequest = record { + url : text; + method : text; + body : blob; + headers : vec record { text; text }; + certificate_version : opt nat16; +}; +type HttpResponse = record { + body : blob; + headers : vec record { text; text }; + streaming_strategy : opt StreamingStrategy; + status_code : nat16; +}; +type InitAssetKey = record { + token : opt text; + collection : text; + name : text; + description : opt text; + encoding_type : opt text; + full_path : text; +}; +type InitUploadResult = record { batch_id : nat }; +type ListMatcher = record { + key : opt text; + updated_at : opt TimestampMatcher; + description : opt text; + created_at : opt TimestampMatcher; +}; +type ListOrder = record { field : ListOrderField; desc : bool }; +type ListOrderField = variant { UpdatedAt; Keys; CreatedAt }; +type ListPaginate = record { start_after : opt text; limit : opt nat64 }; +type ListParams = record { + order : opt ListOrder; + owner : opt principal; + matcher : opt ListMatcher; + paginate : opt ListPaginate; +}; +type ListResults = record { + matches_pages : opt nat64; + matches_length : nat64; + items_page : opt nat64; + items : vec record { text; AssetNoContent }; + items_length : nat64; +}; +type ListResults_1 = record { + matches_pages : opt nat64; + matches_length : nat64; + items_page : opt nat64; + items : vec record { text; Doc }; + items_length : nat64; +}; +type Memory = variant { Heap; Stable }; +type MemorySize = record { stable : nat64; heap : nat64 }; +type Permission = variant { Controllers; Private; Public; Managed }; +type Rule = record { + max_capacity : opt nat32; + memory : opt Memory; + updated_at : nat64; + max_size : opt nat; + read : Permission; + created_at : nat64; + version : opt nat64; + mutable_permissions : opt bool; + write : Permission; +}; +type RulesType = variant { Db; Storage }; +type SetController = record { + metadata : vec record { text; text }; + scope : ControllerScope; + expires_at : opt nat64; +}; +type SetControllersArgs = record { + controller : SetController; + controllers : vec principal; +}; +type SetDoc = record { + data : blob; + description : opt text; + version : opt nat64; +}; +type SetRule = record { + max_capacity : opt nat32; + memory : opt Memory; + max_size : opt nat; + read : Permission; + version : opt nat64; + mutable_permissions : opt bool; + write : Permission; +}; +type StorageConfig = record { + iframe : opt StorageConfigIFrame; + rewrites : vec record { text; text }; + headers : vec record { text; vec record { text; text } }; + max_memory_size : opt ConfigMaxMemorySize; + raw_access : opt StorageConfigRawAccess; + redirects : opt vec record { text; StorageConfigRedirect }; +}; +type StorageConfigIFrame = variant { Deny; AllowAny; SameOrigin }; +type StorageConfigRawAccess = variant { Deny; Allow }; +type StorageConfigRedirect = record { status_code : nat16; location : text }; +type StreamingCallbackHttpResponse = record { + token : opt StreamingCallbackToken; + body : blob; +}; +type StreamingCallbackToken = record { + memory : Memory; + token : opt text; + sha256 : opt blob; + headers : vec record { text; text }; + index : nat64; + encoding_type : text; + full_path : text; +}; +type StreamingStrategy = variant { + Callback : record { + token : StreamingCallbackToken; + callback : func () -> () query; + }; +}; +type TimestampMatcher = variant { + Equal : nat64; + Between : record { nat64; nat64 }; + GreaterThan : nat64; + LessThan : nat64; +}; +type UploadChunk = record { + content : blob; + batch_id : nat; + order_id : opt nat; +}; +type UploadChunkResult = record { chunk_id : nat }; +service : { + build_version : () -> (text) query; + commit_asset_upload : (CommitBatch) -> (); + count_assets : (text, ListParams) -> (nat64) query; + count_collection_assets : (text) -> (nat64) query; + count_collection_docs : (text) -> (nat64) query; + count_docs : (text, ListParams) -> (nat64) query; + del_asset : (text, text) -> (); + del_assets : (text) -> (); + del_controllers : (DeleteControllersArgs) -> ( + vec record { principal; Controller }, + ); + del_custom_domain : (text) -> (); + del_doc : (text, text, DelDoc) -> (); + del_docs : (text) -> (); + del_many_assets : (vec record { text; text }) -> (); + del_many_docs : (vec record { text; text; DelDoc }) -> (); + del_rule : (RulesType, text, DelRule) -> (); + deposit_cycles : (DepositCyclesArgs) -> (); + get_asset : (text, text) -> (opt AssetNoContent) query; + get_auth_config : () -> (opt AuthenticationConfig) query; + get_config : () -> (Config); + get_db_config : () -> (opt DbConfig) query; + get_doc : (text, text) -> (opt Doc) query; + get_many_assets : (vec record { text; text }) -> ( + vec record { text; opt AssetNoContent }, + ) query; + get_many_docs : (vec record { text; text }) -> ( + vec record { text; opt Doc }, + ) query; + get_storage_config : () -> (StorageConfig) query; + http_request : (HttpRequest) -> (HttpResponse) query; + http_request_streaming_callback : (StreamingCallbackToken) -> ( + StreamingCallbackHttpResponse, + ) query; + init_asset_upload : (InitAssetKey) -> (InitUploadResult); + list_assets : (text, ListParams) -> (ListResults) query; + list_controllers : () -> (vec record { principal; Controller }) query; + list_custom_domains : () -> (vec record { text; CustomDomain }) query; + list_docs : (text, ListParams) -> (ListResults_1) query; + list_rules : (RulesType) -> (vec record { text; Rule }) query; + memory_size : () -> (MemorySize) query; + set_auth_config : (AuthenticationConfig) -> (); + set_controllers : (SetControllersArgs) -> ( + vec record { principal; Controller }, + ); + set_custom_domain : (text, opt text) -> (); + set_db_config : (DbConfig) -> (); + set_doc : (text, text, SetDoc) -> (Doc); + set_many_docs : (vec record { text; text; SetDoc }) -> ( + vec record { text; Doc }, + ); + set_rule : (RulesType, text, SetRule) -> (); + set_storage_config : (StorageConfig) -> (); + upload_asset_chunk : (UploadChunk) -> (UploadChunkResult); + version : () -> (text) query; +} \ No newline at end of file From c42dbdab05460971e5c862b5ae7e77a942d34188 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Tue, 10 Jun 2025 21:50:57 +0200 Subject: [PATCH 2/3] test: add more custom extended code for samples --- tests/data/output.did | 5 +- tests/data/satellite.js | 663 +++++++++++++++-------------- tests/data/satellite.ts | 402 ++++++++--------- tests/data/satellite_extension.did | 4 +- 4 files changed, 543 insertions(+), 531 deletions(-) diff --git a/tests/data/output.did b/tests/data/output.did index 49d0637..ee0b58a 100644 --- a/tests/data/output.did +++ b/tests/data/output.did @@ -54,6 +54,7 @@ type DbConfig = record { max_memory_size : opt ConfigMaxMemorySize }; type DelDoc = record { version : opt nat64 }; type DelRule = record { version : opt nat64 }; type DeleteControllersArgs = record { controllers : vec principal }; +type DemoArg = record { status : text; message : text }; type DepositCyclesArgs = record { cycles : nat; destination_id : principal }; type Doc = record { updated_at : nat64; @@ -117,6 +118,7 @@ type ListResults_1 = record { type Memory = variant { Heap; Stable }; type MemorySize = record { stable : nat64; heap : nat64 }; type Permission = variant { Controllers; Private; Public; Managed }; +type Result = variant { Ok : text; Err : text }; type Rule = record { max_capacity : opt nat32; memory : opt Memory; @@ -195,7 +197,6 @@ type UploadChunk = record { }; type UploadChunkResult = record { chunk_id : nat }; service : { - build_version : () -> (text) query; commit_asset_upload : (CommitBatch) -> (); count_assets : (text, ListParams) -> (nat64) query; count_collection_assets : (text) -> (nat64) query; @@ -212,6 +213,7 @@ service : { del_many_assets : (vec record { text; text }) -> (); del_many_docs : (vec record { text; text; DelDoc }) -> (); del_rule : (RulesType, text, DelRule) -> (); + demo : (DemoArg) -> (Result) query; deposit_cycles : (DepositCyclesArgs) -> (); get_asset : (text, text) -> (opt AssetNoContent) query; get_auth_config : () -> (opt AuthenticationConfig) query; @@ -236,6 +238,7 @@ service : { list_docs : (text, ListParams) -> (ListResults_1) query; list_rules : (RulesType) -> (vec record { text; Rule }) query; memory_size : () -> (MemorySize) query; + say : () -> () query; set_auth_config : (AuthenticationConfig) -> (); set_controllers : (SetControllersArgs) -> ( vec record { principal; Controller }, diff --git a/tests/data/satellite.js b/tests/data/satellite.js index 152088a..b060583 100644 --- a/tests/data/satellite.js +++ b/tests/data/satellite.js @@ -1,333 +1,336 @@ export const idlFactory = ({ IDL }) => { - const CommitBatch = IDL.Record({ - 'batch_id' : IDL.Nat, - 'headers' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), - 'chunk_ids' : IDL.Vec(IDL.Nat), - }); - const ListOrderField = IDL.Variant({ - 'UpdatedAt' : IDL.Null, - 'Keys' : IDL.Null, - 'CreatedAt' : IDL.Null, - }); - const ListOrder = IDL.Record({ 'field' : ListOrderField, 'desc' : IDL.Bool }); - const TimestampMatcher = IDL.Variant({ - 'Equal' : IDL.Nat64, - 'Between' : IDL.Tuple(IDL.Nat64, IDL.Nat64), - 'GreaterThan' : IDL.Nat64, - 'LessThan' : IDL.Nat64, - }); - const ListMatcher = IDL.Record({ - 'key' : IDL.Opt(IDL.Text), - 'updated_at' : IDL.Opt(TimestampMatcher), - 'description' : IDL.Opt(IDL.Text), - 'created_at' : IDL.Opt(TimestampMatcher), - }); - const ListPaginate = IDL.Record({ - 'start_after' : IDL.Opt(IDL.Text), - 'limit' : IDL.Opt(IDL.Nat64), - }); - const ListParams = IDL.Record({ - 'order' : IDL.Opt(ListOrder), - 'owner' : IDL.Opt(IDL.Principal), - 'matcher' : IDL.Opt(ListMatcher), - 'paginate' : IDL.Opt(ListPaginate), - }); - const DeleteControllersArgs = IDL.Record({ - 'controllers' : IDL.Vec(IDL.Principal), - }); - const ControllerScope = IDL.Variant({ - 'Write' : IDL.Null, - 'Admin' : IDL.Null, - }); - const Controller = IDL.Record({ - 'updated_at' : IDL.Nat64, - 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), - 'created_at' : IDL.Nat64, - 'scope' : ControllerScope, - 'expires_at' : IDL.Opt(IDL.Nat64), - }); - const DelDoc = IDL.Record({ 'version' : IDL.Opt(IDL.Nat64) }); - const RulesType = IDL.Variant({ 'Db' : IDL.Null, 'Storage' : IDL.Null }); - const DelRule = IDL.Record({ 'version' : IDL.Opt(IDL.Nat64) }); - const DepositCyclesArgs = IDL.Record({ - 'cycles' : IDL.Nat, - 'destination_id' : IDL.Principal, - }); - const AssetKey = IDL.Record({ - 'token' : IDL.Opt(IDL.Text), - 'collection' : IDL.Text, - 'owner' : IDL.Principal, - 'name' : IDL.Text, - 'description' : IDL.Opt(IDL.Text), - 'full_path' : IDL.Text, - }); - const AssetEncodingNoContent = IDL.Record({ - 'modified' : IDL.Nat64, - 'sha256' : IDL.Vec(IDL.Nat8), - 'total_length' : IDL.Nat, - }); - const AssetNoContent = IDL.Record({ - 'key' : AssetKey, - 'updated_at' : IDL.Nat64, - 'encodings' : IDL.Vec(IDL.Tuple(IDL.Text, AssetEncodingNoContent)), - 'headers' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), - 'created_at' : IDL.Nat64, - 'version' : IDL.Opt(IDL.Nat64), - }); - const AuthenticationConfigInternetIdentity = IDL.Record({ - 'derivation_origin' : IDL.Opt(IDL.Text), - }); - const AuthenticationConfig = IDL.Record({ - 'internet_identity' : IDL.Opt(AuthenticationConfigInternetIdentity), - }); - const ConfigMaxMemorySize = IDL.Record({ - 'stable' : IDL.Opt(IDL.Nat64), - 'heap' : IDL.Opt(IDL.Nat64), - }); - const DbConfig = IDL.Record({ - 'max_memory_size' : IDL.Opt(ConfigMaxMemorySize), - }); - const StorageConfigIFrame = IDL.Variant({ - 'Deny' : IDL.Null, - 'AllowAny' : IDL.Null, - 'SameOrigin' : IDL.Null, - }); - const StorageConfigRawAccess = IDL.Variant({ - 'Deny' : IDL.Null, - 'Allow' : IDL.Null, - }); - const StorageConfigRedirect = IDL.Record({ - 'status_code' : IDL.Nat16, - 'location' : IDL.Text, - }); - const StorageConfig = IDL.Record({ - 'iframe' : IDL.Opt(StorageConfigIFrame), - 'rewrites' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), - 'headers' : IDL.Vec( - IDL.Tuple(IDL.Text, IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))) - ), - 'max_memory_size' : IDL.Opt(ConfigMaxMemorySize), - 'raw_access' : IDL.Opt(StorageConfigRawAccess), - 'redirects' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, StorageConfigRedirect))), - }); - const Config = IDL.Record({ - 'db' : IDL.Opt(DbConfig), - 'authentication' : IDL.Opt(AuthenticationConfig), - 'storage' : StorageConfig, - }); - const Doc = IDL.Record({ - 'updated_at' : IDL.Nat64, - 'owner' : IDL.Principal, - 'data' : IDL.Vec(IDL.Nat8), - 'description' : IDL.Opt(IDL.Text), - 'created_at' : IDL.Nat64, - 'version' : IDL.Opt(IDL.Nat64), - }); - const HttpRequest = IDL.Record({ - 'url' : IDL.Text, - 'method' : IDL.Text, - 'body' : IDL.Vec(IDL.Nat8), - 'headers' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), - 'certificate_version' : IDL.Opt(IDL.Nat16), - }); - const Memory = IDL.Variant({ 'Heap' : IDL.Null, 'Stable' : IDL.Null }); - const StreamingCallbackToken = IDL.Record({ - 'memory' : Memory, - 'token' : IDL.Opt(IDL.Text), - 'sha256' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'headers' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), - 'index' : IDL.Nat64, - 'encoding_type' : IDL.Text, - 'full_path' : IDL.Text, - }); - const StreamingStrategy = IDL.Variant({ - 'Callback' : IDL.Record({ - 'token' : StreamingCallbackToken, - 'callback' : IDL.Func([], [], ['query']), - }), - }); - const HttpResponse = IDL.Record({ - 'body' : IDL.Vec(IDL.Nat8), - 'headers' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), - 'streaming_strategy' : IDL.Opt(StreamingStrategy), - 'status_code' : IDL.Nat16, - }); - const StreamingCallbackHttpResponse = IDL.Record({ - 'token' : IDL.Opt(StreamingCallbackToken), - 'body' : IDL.Vec(IDL.Nat8), - }); - const InitAssetKey = IDL.Record({ - 'token' : IDL.Opt(IDL.Text), - 'collection' : IDL.Text, - 'name' : IDL.Text, - 'description' : IDL.Opt(IDL.Text), - 'encoding_type' : IDL.Opt(IDL.Text), - 'full_path' : IDL.Text, - }); - const InitUploadResult = IDL.Record({ 'batch_id' : IDL.Nat }); - const ListResults = IDL.Record({ - 'matches_pages' : IDL.Opt(IDL.Nat64), - 'matches_length' : IDL.Nat64, - 'items_page' : IDL.Opt(IDL.Nat64), - 'items' : IDL.Vec(IDL.Tuple(IDL.Text, AssetNoContent)), - 'items_length' : IDL.Nat64, - }); - const CustomDomain = IDL.Record({ - 'updated_at' : IDL.Nat64, - 'created_at' : IDL.Nat64, - 'version' : IDL.Opt(IDL.Nat64), - 'bn_id' : IDL.Opt(IDL.Text), - }); - const ListResults_1 = IDL.Record({ - 'matches_pages' : IDL.Opt(IDL.Nat64), - 'matches_length' : IDL.Nat64, - 'items_page' : IDL.Opt(IDL.Nat64), - 'items' : IDL.Vec(IDL.Tuple(IDL.Text, Doc)), - 'items_length' : IDL.Nat64, - }); - const Permission = IDL.Variant({ - 'Controllers' : IDL.Null, - 'Private' : IDL.Null, - 'Public' : IDL.Null, - 'Managed' : IDL.Null, - }); - const Rule = IDL.Record({ - 'max_capacity' : IDL.Opt(IDL.Nat32), - 'memory' : IDL.Opt(Memory), - 'updated_at' : IDL.Nat64, - 'max_size' : IDL.Opt(IDL.Nat), - 'read' : Permission, - 'created_at' : IDL.Nat64, - 'version' : IDL.Opt(IDL.Nat64), - 'mutable_permissions' : IDL.Opt(IDL.Bool), - 'write' : Permission, - }); - const MemorySize = IDL.Record({ 'stable' : IDL.Nat64, 'heap' : IDL.Nat64 }); - const SetController = IDL.Record({ - 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), - 'scope' : ControllerScope, - 'expires_at' : IDL.Opt(IDL.Nat64), - }); - const SetControllersArgs = IDL.Record({ - 'controller' : SetController, - 'controllers' : IDL.Vec(IDL.Principal), - }); - const SetDoc = IDL.Record({ - 'data' : IDL.Vec(IDL.Nat8), - 'description' : IDL.Opt(IDL.Text), - 'version' : IDL.Opt(IDL.Nat64), - }); - const SetRule = IDL.Record({ - 'max_capacity' : IDL.Opt(IDL.Nat32), - 'memory' : IDL.Opt(Memory), - 'max_size' : IDL.Opt(IDL.Nat), - 'read' : Permission, - 'version' : IDL.Opt(IDL.Nat64), - 'mutable_permissions' : IDL.Opt(IDL.Bool), - 'write' : Permission, - }); - const UploadChunk = IDL.Record({ - 'content' : IDL.Vec(IDL.Nat8), - 'batch_id' : IDL.Nat, - 'order_id' : IDL.Opt(IDL.Nat), - }); - const UploadChunkResult = IDL.Record({ 'chunk_id' : IDL.Nat }); - return IDL.Service({ - 'build_version' : IDL.Func([], [IDL.Text], ['query']), - 'commit_asset_upload' : IDL.Func([CommitBatch], [], []), - 'count_assets' : IDL.Func([IDL.Text, ListParams], [IDL.Nat64], ['query']), - 'count_collection_assets' : IDL.Func([IDL.Text], [IDL.Nat64], ['query']), - 'count_collection_docs' : IDL.Func([IDL.Text], [IDL.Nat64], ['query']), - 'count_docs' : IDL.Func([IDL.Text, ListParams], [IDL.Nat64], ['query']), - 'del_asset' : IDL.Func([IDL.Text, IDL.Text], [], []), - 'del_assets' : IDL.Func([IDL.Text], [], []), - 'del_controllers' : IDL.Func( - [DeleteControllersArgs], - [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))], - [], - ), - 'del_custom_domain' : IDL.Func([IDL.Text], [], []), - 'del_doc' : IDL.Func([IDL.Text, IDL.Text, DelDoc], [], []), - 'del_docs' : IDL.Func([IDL.Text], [], []), - 'del_many_assets' : IDL.Func( - [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))], - [], - [], - ), - 'del_many_docs' : IDL.Func( - [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text, DelDoc))], - [], - [], - ), - 'del_rule' : IDL.Func([RulesType, IDL.Text, DelRule], [], []), - 'deposit_cycles' : IDL.Func([DepositCyclesArgs], [], []), - 'get_asset' : IDL.Func( - [IDL.Text, IDL.Text], - [IDL.Opt(AssetNoContent)], - ['query'], - ), - 'get_auth_config' : IDL.Func( - [], - [IDL.Opt(AuthenticationConfig)], - ['query'], - ), - 'get_config' : IDL.Func([], [Config], []), - 'get_db_config' : IDL.Func([], [IDL.Opt(DbConfig)], ['query']), - 'get_doc' : IDL.Func([IDL.Text, IDL.Text], [IDL.Opt(Doc)], ['query']), - 'get_many_assets' : IDL.Func( - [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))], - [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Opt(AssetNoContent)))], - ['query'], - ), - 'get_many_docs' : IDL.Func( - [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))], - [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Opt(Doc)))], - ['query'], - ), - 'get_storage_config' : IDL.Func([], [StorageConfig], ['query']), - 'http_request' : IDL.Func([HttpRequest], [HttpResponse], ['query']), - 'http_request_streaming_callback' : IDL.Func( - [StreamingCallbackToken], - [StreamingCallbackHttpResponse], - ['query'], - ), - 'init_asset_upload' : IDL.Func([InitAssetKey], [InitUploadResult], []), - 'list_assets' : IDL.Func([IDL.Text, ListParams], [ListResults], ['query']), - 'list_controllers' : IDL.Func( - [], - [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))], - ['query'], - ), - 'list_custom_domains' : IDL.Func( - [], - [IDL.Vec(IDL.Tuple(IDL.Text, CustomDomain))], - ['query'], - ), - 'list_docs' : IDL.Func([IDL.Text, ListParams], [ListResults_1], ['query']), - 'list_rules' : IDL.Func( - [RulesType], - [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], - ['query'], - ), - 'memory_size' : IDL.Func([], [MemorySize], ['query']), - 'set_auth_config' : IDL.Func([AuthenticationConfig], [], []), - 'set_controllers' : IDL.Func( - [SetControllersArgs], - [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))], - [], - ), - 'set_custom_domain' : IDL.Func([IDL.Text, IDL.Opt(IDL.Text)], [], []), - 'set_db_config' : IDL.Func([DbConfig], [], []), - 'set_doc' : IDL.Func([IDL.Text, IDL.Text, SetDoc], [Doc], []), - 'set_many_docs' : IDL.Func( - [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text, SetDoc))], - [IDL.Vec(IDL.Tuple(IDL.Text, Doc))], - [], - ), - 'set_rule' : IDL.Func([RulesType, IDL.Text, SetRule], [], []), - 'set_storage_config' : IDL.Func([StorageConfig], [], []), - 'upload_asset_chunk' : IDL.Func([UploadChunk], [UploadChunkResult], []), - 'version' : IDL.Func([], [IDL.Text], ['query']), - }); + const CommitBatch = IDL.Record({ + 'batch_id' : IDL.Nat, + 'headers' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), + 'chunk_ids' : IDL.Vec(IDL.Nat), + }); + const ListOrderField = IDL.Variant({ + 'UpdatedAt' : IDL.Null, + 'Keys' : IDL.Null, + 'CreatedAt' : IDL.Null, + }); + const ListOrder = IDL.Record({ 'field' : ListOrderField, 'desc' : IDL.Bool }); + const TimestampMatcher = IDL.Variant({ + 'Equal' : IDL.Nat64, + 'Between' : IDL.Tuple(IDL.Nat64, IDL.Nat64), + 'GreaterThan' : IDL.Nat64, + 'LessThan' : IDL.Nat64, + }); + const ListMatcher = IDL.Record({ + 'key' : IDL.Opt(IDL.Text), + 'updated_at' : IDL.Opt(TimestampMatcher), + 'description' : IDL.Opt(IDL.Text), + 'created_at' : IDL.Opt(TimestampMatcher), + }); + const ListPaginate = IDL.Record({ + 'start_after' : IDL.Opt(IDL.Text), + 'limit' : IDL.Opt(IDL.Nat64), + }); + const ListParams = IDL.Record({ + 'order' : IDL.Opt(ListOrder), + 'owner' : IDL.Opt(IDL.Principal), + 'matcher' : IDL.Opt(ListMatcher), + 'paginate' : IDL.Opt(ListPaginate), + }); + const DeleteControllersArgs = IDL.Record({ + 'controllers' : IDL.Vec(IDL.Principal), + }); + const ControllerScope = IDL.Variant({ + 'Write' : IDL.Null, + 'Admin' : IDL.Null, + }); + const Controller = IDL.Record({ + 'updated_at' : IDL.Nat64, + 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), + 'created_at' : IDL.Nat64, + 'scope' : ControllerScope, + 'expires_at' : IDL.Opt(IDL.Nat64), + }); + const DelDoc = IDL.Record({ 'version' : IDL.Opt(IDL.Nat64) }); + const RulesType = IDL.Variant({ 'Db' : IDL.Null, 'Storage' : IDL.Null }); + const DelRule = IDL.Record({ 'version' : IDL.Opt(IDL.Nat64) }); + const DemoArg = IDL.Record({ 'status' : IDL.Text, 'message' : IDL.Text }); + const Result = IDL.Variant({ 'Ok' : IDL.Text, 'Err' : IDL.Text }); + const DepositCyclesArgs = IDL.Record({ + 'cycles' : IDL.Nat, + 'destination_id' : IDL.Principal, + }); + const AssetKey = IDL.Record({ + 'token' : IDL.Opt(IDL.Text), + 'collection' : IDL.Text, + 'owner' : IDL.Principal, + 'name' : IDL.Text, + 'description' : IDL.Opt(IDL.Text), + 'full_path' : IDL.Text, + }); + const AssetEncodingNoContent = IDL.Record({ + 'modified' : IDL.Nat64, + 'sha256' : IDL.Vec(IDL.Nat8), + 'total_length' : IDL.Nat, + }); + const AssetNoContent = IDL.Record({ + 'key' : AssetKey, + 'updated_at' : IDL.Nat64, + 'encodings' : IDL.Vec(IDL.Tuple(IDL.Text, AssetEncodingNoContent)), + 'headers' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), + 'created_at' : IDL.Nat64, + 'version' : IDL.Opt(IDL.Nat64), + }); + const AuthenticationConfigInternetIdentity = IDL.Record({ + 'derivation_origin' : IDL.Opt(IDL.Text), + }); + const AuthenticationConfig = IDL.Record({ + 'internet_identity' : IDL.Opt(AuthenticationConfigInternetIdentity), + }); + const ConfigMaxMemorySize = IDL.Record({ + 'stable' : IDL.Opt(IDL.Nat64), + 'heap' : IDL.Opt(IDL.Nat64), + }); + const DbConfig = IDL.Record({ + 'max_memory_size' : IDL.Opt(ConfigMaxMemorySize), + }); + const StorageConfigIFrame = IDL.Variant({ + 'Deny' : IDL.Null, + 'AllowAny' : IDL.Null, + 'SameOrigin' : IDL.Null, + }); + const StorageConfigRawAccess = IDL.Variant({ + 'Deny' : IDL.Null, + 'Allow' : IDL.Null, + }); + const StorageConfigRedirect = IDL.Record({ + 'status_code' : IDL.Nat16, + 'location' : IDL.Text, + }); + const StorageConfig = IDL.Record({ + 'iframe' : IDL.Opt(StorageConfigIFrame), + 'rewrites' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), + 'headers' : IDL.Vec( + IDL.Tuple(IDL.Text, IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))) + ), + 'max_memory_size' : IDL.Opt(ConfigMaxMemorySize), + 'raw_access' : IDL.Opt(StorageConfigRawAccess), + 'redirects' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, StorageConfigRedirect))), + }); + const Config = IDL.Record({ + 'db' : IDL.Opt(DbConfig), + 'authentication' : IDL.Opt(AuthenticationConfig), + 'storage' : StorageConfig, + }); + const Doc = IDL.Record({ + 'updated_at' : IDL.Nat64, + 'owner' : IDL.Principal, + 'data' : IDL.Vec(IDL.Nat8), + 'description' : IDL.Opt(IDL.Text), + 'created_at' : IDL.Nat64, + 'version' : IDL.Opt(IDL.Nat64), + }); + const HttpRequest = IDL.Record({ + 'url' : IDL.Text, + 'method' : IDL.Text, + 'body' : IDL.Vec(IDL.Nat8), + 'headers' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), + 'certificate_version' : IDL.Opt(IDL.Nat16), + }); + const Memory = IDL.Variant({ 'Heap' : IDL.Null, 'Stable' : IDL.Null }); + const StreamingCallbackToken = IDL.Record({ + 'memory' : Memory, + 'token' : IDL.Opt(IDL.Text), + 'sha256' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'headers' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), + 'index' : IDL.Nat64, + 'encoding_type' : IDL.Text, + 'full_path' : IDL.Text, + }); + const StreamingStrategy = IDL.Variant({ + 'Callback' : IDL.Record({ + 'token' : StreamingCallbackToken, + 'callback' : IDL.Func([], [], ['query']), + }), + }); + const HttpResponse = IDL.Record({ + 'body' : IDL.Vec(IDL.Nat8), + 'headers' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), + 'streaming_strategy' : IDL.Opt(StreamingStrategy), + 'status_code' : IDL.Nat16, + }); + const StreamingCallbackHttpResponse = IDL.Record({ + 'token' : IDL.Opt(StreamingCallbackToken), + 'body' : IDL.Vec(IDL.Nat8), + }); + const InitAssetKey = IDL.Record({ + 'token' : IDL.Opt(IDL.Text), + 'collection' : IDL.Text, + 'name' : IDL.Text, + 'description' : IDL.Opt(IDL.Text), + 'encoding_type' : IDL.Opt(IDL.Text), + 'full_path' : IDL.Text, + }); + const InitUploadResult = IDL.Record({ 'batch_id' : IDL.Nat }); + const ListResults = IDL.Record({ + 'matches_pages' : IDL.Opt(IDL.Nat64), + 'matches_length' : IDL.Nat64, + 'items_page' : IDL.Opt(IDL.Nat64), + 'items' : IDL.Vec(IDL.Tuple(IDL.Text, AssetNoContent)), + 'items_length' : IDL.Nat64, + }); + const CustomDomain = IDL.Record({ + 'updated_at' : IDL.Nat64, + 'created_at' : IDL.Nat64, + 'version' : IDL.Opt(IDL.Nat64), + 'bn_id' : IDL.Opt(IDL.Text), + }); + const ListResults_1 = IDL.Record({ + 'matches_pages' : IDL.Opt(IDL.Nat64), + 'matches_length' : IDL.Nat64, + 'items_page' : IDL.Opt(IDL.Nat64), + 'items' : IDL.Vec(IDL.Tuple(IDL.Text, Doc)), + 'items_length' : IDL.Nat64, + }); + const Permission = IDL.Variant({ + 'Controllers' : IDL.Null, + 'Private' : IDL.Null, + 'Public' : IDL.Null, + 'Managed' : IDL.Null, + }); + const Rule = IDL.Record({ + 'max_capacity' : IDL.Opt(IDL.Nat32), + 'memory' : IDL.Opt(Memory), + 'updated_at' : IDL.Nat64, + 'max_size' : IDL.Opt(IDL.Nat), + 'read' : Permission, + 'created_at' : IDL.Nat64, + 'version' : IDL.Opt(IDL.Nat64), + 'mutable_permissions' : IDL.Opt(IDL.Bool), + 'write' : Permission, + }); + const MemorySize = IDL.Record({ 'stable' : IDL.Nat64, 'heap' : IDL.Nat64 }); + const SetController = IDL.Record({ + 'metadata' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), + 'scope' : ControllerScope, + 'expires_at' : IDL.Opt(IDL.Nat64), + }); + const SetControllersArgs = IDL.Record({ + 'controller' : SetController, + 'controllers' : IDL.Vec(IDL.Principal), + }); + const SetDoc = IDL.Record({ + 'data' : IDL.Vec(IDL.Nat8), + 'description' : IDL.Opt(IDL.Text), + 'version' : IDL.Opt(IDL.Nat64), + }); + const SetRule = IDL.Record({ + 'max_capacity' : IDL.Opt(IDL.Nat32), + 'memory' : IDL.Opt(Memory), + 'max_size' : IDL.Opt(IDL.Nat), + 'read' : Permission, + 'version' : IDL.Opt(IDL.Nat64), + 'mutable_permissions' : IDL.Opt(IDL.Bool), + 'write' : Permission, + }); + const UploadChunk = IDL.Record({ + 'content' : IDL.Vec(IDL.Nat8), + 'batch_id' : IDL.Nat, + 'order_id' : IDL.Opt(IDL.Nat), + }); + const UploadChunkResult = IDL.Record({ 'chunk_id' : IDL.Nat }); + return IDL.Service({ + 'commit_asset_upload' : IDL.Func([CommitBatch], [], []), + 'count_assets' : IDL.Func([IDL.Text, ListParams], [IDL.Nat64], ['query']), + 'count_collection_assets' : IDL.Func([IDL.Text], [IDL.Nat64], ['query']), + 'count_collection_docs' : IDL.Func([IDL.Text], [IDL.Nat64], ['query']), + 'count_docs' : IDL.Func([IDL.Text, ListParams], [IDL.Nat64], ['query']), + 'del_asset' : IDL.Func([IDL.Text, IDL.Text], [], []), + 'del_assets' : IDL.Func([IDL.Text], [], []), + 'del_controllers' : IDL.Func( + [DeleteControllersArgs], + [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))], + [], + ), + 'del_custom_domain' : IDL.Func([IDL.Text], [], []), + 'del_doc' : IDL.Func([IDL.Text, IDL.Text, DelDoc], [], []), + 'del_docs' : IDL.Func([IDL.Text], [], []), + 'del_many_assets' : IDL.Func( + [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))], + [], + [], + ), + 'del_many_docs' : IDL.Func( + [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text, DelDoc))], + [], + [], + ), + 'del_rule' : IDL.Func([RulesType, IDL.Text, DelRule], [], []), + 'demo' : IDL.Func([DemoArg], [Result], ['query']), + 'deposit_cycles' : IDL.Func([DepositCyclesArgs], [], []), + 'get_asset' : IDL.Func( + [IDL.Text, IDL.Text], + [IDL.Opt(AssetNoContent)], + ['query'], + ), + 'get_auth_config' : IDL.Func( + [], + [IDL.Opt(AuthenticationConfig)], + ['query'], + ), + 'get_config' : IDL.Func([], [Config], []), + 'get_db_config' : IDL.Func([], [IDL.Opt(DbConfig)], ['query']), + 'get_doc' : IDL.Func([IDL.Text, IDL.Text], [IDL.Opt(Doc)], ['query']), + 'get_many_assets' : IDL.Func( + [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))], + [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Opt(AssetNoContent)))], + ['query'], + ), + 'get_many_docs' : IDL.Func( + [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text))], + [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Opt(Doc)))], + ['query'], + ), + 'get_storage_config' : IDL.Func([], [StorageConfig], ['query']), + 'http_request' : IDL.Func([HttpRequest], [HttpResponse], ['query']), + 'http_request_streaming_callback' : IDL.Func( + [StreamingCallbackToken], + [StreamingCallbackHttpResponse], + ['query'], + ), + 'init_asset_upload' : IDL.Func([InitAssetKey], [InitUploadResult], []), + 'list_assets' : IDL.Func([IDL.Text, ListParams], [ListResults], ['query']), + 'list_controllers' : IDL.Func( + [], + [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))], + ['query'], + ), + 'list_custom_domains' : IDL.Func( + [], + [IDL.Vec(IDL.Tuple(IDL.Text, CustomDomain))], + ['query'], + ), + 'list_docs' : IDL.Func([IDL.Text, ListParams], [ListResults_1], ['query']), + 'list_rules' : IDL.Func( + [RulesType], + [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], + ['query'], + ), + 'memory_size' : IDL.Func([], [MemorySize], ['query']), + 'say' : IDL.Func([], [], ['query']), + 'set_auth_config' : IDL.Func([AuthenticationConfig], [], []), + 'set_controllers' : IDL.Func( + [SetControllersArgs], + [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))], + [], + ), + 'set_custom_domain' : IDL.Func([IDL.Text, IDL.Opt(IDL.Text)], [], []), + 'set_db_config' : IDL.Func([DbConfig], [], []), + 'set_doc' : IDL.Func([IDL.Text, IDL.Text, SetDoc], [Doc], []), + 'set_many_docs' : IDL.Func( + [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text, SetDoc))], + [IDL.Vec(IDL.Tuple(IDL.Text, Doc))], + [], + ), + 'set_rule' : IDL.Func([RulesType, IDL.Text, SetRule], [], []), + 'set_storage_config' : IDL.Func([StorageConfig], [], []), + 'upload_asset_chunk' : IDL.Func([UploadChunk], [UploadChunkResult], []), + 'version' : IDL.Func([], [IDL.Text], ['query']), + }); }; export const init = ({ IDL }) => { return []; }; \ No newline at end of file diff --git a/tests/data/satellite.ts b/tests/data/satellite.ts index a95b8b1..8a3fe90 100644 --- a/tests/data/satellite.ts +++ b/tests/data/satellite.ts @@ -3,284 +3,288 @@ import type { ActorMethod } from '@dfinity/agent'; import type { IDL } from '@dfinity/candid'; export interface AssetEncodingNoContent { - 'modified' : bigint, - 'sha256' : Uint8Array | number[], - 'total_length' : bigint, + 'modified' : bigint, + 'sha256' : Uint8Array | number[], + 'total_length' : bigint, } export interface AssetKey { - 'token' : [] | [string], - 'collection' : string, - 'owner' : Principal, - 'name' : string, - 'description' : [] | [string], - 'full_path' : string, + 'token' : [] | [string], + 'collection' : string, + 'owner' : Principal, + 'name' : string, + 'description' : [] | [string], + 'full_path' : string, } export interface AssetNoContent { - 'key' : AssetKey, - 'updated_at' : bigint, - 'encodings' : Array<[string, AssetEncodingNoContent]>, - 'headers' : Array<[string, string]>, - 'created_at' : bigint, - 'version' : [] | [bigint], + 'key' : AssetKey, + 'updated_at' : bigint, + 'encodings' : Array<[string, AssetEncodingNoContent]>, + 'headers' : Array<[string, string]>, + 'created_at' : bigint, + 'version' : [] | [bigint], } export interface AuthenticationConfig { - 'internet_identity' : [] | [AuthenticationConfigInternetIdentity], + 'internet_identity' : [] | [AuthenticationConfigInternetIdentity], } export interface AuthenticationConfigInternetIdentity { - 'derivation_origin' : [] | [string], + 'derivation_origin' : [] | [string], } export interface CommitBatch { - 'batch_id' : bigint, - 'headers' : Array<[string, string]>, - 'chunk_ids' : Array, + 'batch_id' : bigint, + 'headers' : Array<[string, string]>, + 'chunk_ids' : Array, } export interface Config { - 'db' : [] | [DbConfig], - 'authentication' : [] | [AuthenticationConfig], - 'storage' : StorageConfig, + 'db' : [] | [DbConfig], + 'authentication' : [] | [AuthenticationConfig], + 'storage' : StorageConfig, } export interface ConfigMaxMemorySize { - 'stable' : [] | [bigint], - 'heap' : [] | [bigint], + 'stable' : [] | [bigint], + 'heap' : [] | [bigint], } export interface Controller { - 'updated_at' : bigint, - 'metadata' : Array<[string, string]>, - 'created_at' : bigint, - 'scope' : ControllerScope, - 'expires_at' : [] | [bigint], + 'updated_at' : bigint, + 'metadata' : Array<[string, string]>, + 'created_at' : bigint, + 'scope' : ControllerScope, + 'expires_at' : [] | [bigint], } export type ControllerScope = { 'Write' : null } | - { 'Admin' : null }; + { 'Admin' : null }; export interface CustomDomain { - 'updated_at' : bigint, - 'created_at' : bigint, - 'version' : [] | [bigint], - 'bn_id' : [] | [string], + 'updated_at' : bigint, + 'created_at' : bigint, + 'version' : [] | [bigint], + 'bn_id' : [] | [string], } export interface DbConfig { 'max_memory_size' : [] | [ConfigMaxMemorySize] } export interface DelDoc { 'version' : [] | [bigint] } export interface DelRule { 'version' : [] | [bigint] } export interface DeleteControllersArgs { 'controllers' : Array } +export interface DemoArg { 'status' : string, 'message' : string } export interface DepositCyclesArgs { - 'cycles' : bigint, - 'destination_id' : Principal, + 'cycles' : bigint, + 'destination_id' : Principal, } export interface Doc { - 'updated_at' : bigint, - 'owner' : Principal, - 'data' : Uint8Array | number[], - 'description' : [] | [string], - 'created_at' : bigint, - 'version' : [] | [bigint], + 'updated_at' : bigint, + 'owner' : Principal, + 'data' : Uint8Array | number[], + 'description' : [] | [string], + 'created_at' : bigint, + 'version' : [] | [bigint], } export interface HttpRequest { - 'url' : string, - 'method' : string, - 'body' : Uint8Array | number[], - 'headers' : Array<[string, string]>, - 'certificate_version' : [] | [number], + 'url' : string, + 'method' : string, + 'body' : Uint8Array | number[], + 'headers' : Array<[string, string]>, + 'certificate_version' : [] | [number], } export interface HttpResponse { - 'body' : Uint8Array | number[], - 'headers' : Array<[string, string]>, - 'streaming_strategy' : [] | [StreamingStrategy], - 'status_code' : number, + 'body' : Uint8Array | number[], + 'headers' : Array<[string, string]>, + 'streaming_strategy' : [] | [StreamingStrategy], + 'status_code' : number, } export interface InitAssetKey { - 'token' : [] | [string], - 'collection' : string, - 'name' : string, - 'description' : [] | [string], - 'encoding_type' : [] | [string], - 'full_path' : string, + 'token' : [] | [string], + 'collection' : string, + 'name' : string, + 'description' : [] | [string], + 'encoding_type' : [] | [string], + 'full_path' : string, } export interface InitUploadResult { 'batch_id' : bigint } export interface ListMatcher { - 'key' : [] | [string], - 'updated_at' : [] | [TimestampMatcher], - 'description' : [] | [string], - 'created_at' : [] | [TimestampMatcher], + 'key' : [] | [string], + 'updated_at' : [] | [TimestampMatcher], + 'description' : [] | [string], + 'created_at' : [] | [TimestampMatcher], } export interface ListOrder { 'field' : ListOrderField, 'desc' : boolean } export type ListOrderField = { 'UpdatedAt' : null } | - { 'Keys' : null } | - { 'CreatedAt' : null }; + { 'Keys' : null } | + { 'CreatedAt' : null }; export interface ListPaginate { - 'start_after' : [] | [string], - 'limit' : [] | [bigint], + 'start_after' : [] | [string], + 'limit' : [] | [bigint], } export interface ListParams { - 'order' : [] | [ListOrder], - 'owner' : [] | [Principal], - 'matcher' : [] | [ListMatcher], - 'paginate' : [] | [ListPaginate], + 'order' : [] | [ListOrder], + 'owner' : [] | [Principal], + 'matcher' : [] | [ListMatcher], + 'paginate' : [] | [ListPaginate], } export interface ListResults { - 'matches_pages' : [] | [bigint], - 'matches_length' : bigint, - 'items_page' : [] | [bigint], - 'items' : Array<[string, AssetNoContent]>, - 'items_length' : bigint, + 'matches_pages' : [] | [bigint], + 'matches_length' : bigint, + 'items_page' : [] | [bigint], + 'items' : Array<[string, AssetNoContent]>, + 'items_length' : bigint, } export interface ListResults_1 { - 'matches_pages' : [] | [bigint], - 'matches_length' : bigint, - 'items_page' : [] | [bigint], - 'items' : Array<[string, Doc]>, - 'items_length' : bigint, + 'matches_pages' : [] | [bigint], + 'matches_length' : bigint, + 'items_page' : [] | [bigint], + 'items' : Array<[string, Doc]>, + 'items_length' : bigint, } export type Memory = { 'Heap' : null } | - { 'Stable' : null }; + { 'Stable' : null }; export interface MemorySize { 'stable' : bigint, 'heap' : bigint } export type Permission = { 'Controllers' : null } | - { 'Private' : null } | - { 'Public' : null } | - { 'Managed' : null }; + { 'Private' : null } | + { 'Public' : null } | + { 'Managed' : null }; +export type Result = { 'Ok' : string } | + { 'Err' : string }; export interface Rule { - 'max_capacity' : [] | [number], - 'memory' : [] | [Memory], - 'updated_at' : bigint, - 'max_size' : [] | [bigint], - 'read' : Permission, - 'created_at' : bigint, - 'version' : [] | [bigint], - 'mutable_permissions' : [] | [boolean], - 'write' : Permission, + 'max_capacity' : [] | [number], + 'memory' : [] | [Memory], + 'updated_at' : bigint, + 'max_size' : [] | [bigint], + 'read' : Permission, + 'created_at' : bigint, + 'version' : [] | [bigint], + 'mutable_permissions' : [] | [boolean], + 'write' : Permission, } export type RulesType = { 'Db' : null } | - { 'Storage' : null }; + { 'Storage' : null }; export interface SetController { - 'metadata' : Array<[string, string]>, - 'scope' : ControllerScope, - 'expires_at' : [] | [bigint], + 'metadata' : Array<[string, string]>, + 'scope' : ControllerScope, + 'expires_at' : [] | [bigint], } export interface SetControllersArgs { - 'controller' : SetController, - 'controllers' : Array, + 'controller' : SetController, + 'controllers' : Array, } export interface SetDoc { - 'data' : Uint8Array | number[], - 'description' : [] | [string], - 'version' : [] | [bigint], + 'data' : Uint8Array | number[], + 'description' : [] | [string], + 'version' : [] | [bigint], } export interface SetRule { - 'max_capacity' : [] | [number], - 'memory' : [] | [Memory], - 'max_size' : [] | [bigint], - 'read' : Permission, - 'version' : [] | [bigint], - 'mutable_permissions' : [] | [boolean], - 'write' : Permission, + 'max_capacity' : [] | [number], + 'memory' : [] | [Memory], + 'max_size' : [] | [bigint], + 'read' : Permission, + 'version' : [] | [bigint], + 'mutable_permissions' : [] | [boolean], + 'write' : Permission, } export interface StorageConfig { - 'iframe' : [] | [StorageConfigIFrame], - 'rewrites' : Array<[string, string]>, - 'headers' : Array<[string, Array<[string, string]>]>, - 'max_memory_size' : [] | [ConfigMaxMemorySize], - 'raw_access' : [] | [StorageConfigRawAccess], - 'redirects' : [] | [Array<[string, StorageConfigRedirect]>], + 'iframe' : [] | [StorageConfigIFrame], + 'rewrites' : Array<[string, string]>, + 'headers' : Array<[string, Array<[string, string]>]>, + 'max_memory_size' : [] | [ConfigMaxMemorySize], + 'raw_access' : [] | [StorageConfigRawAccess], + 'redirects' : [] | [Array<[string, StorageConfigRedirect]>], } export type StorageConfigIFrame = { 'Deny' : null } | - { 'AllowAny' : null } | - { 'SameOrigin' : null }; + { 'AllowAny' : null } | + { 'SameOrigin' : null }; export type StorageConfigRawAccess = { 'Deny' : null } | - { 'Allow' : null }; + { 'Allow' : null }; export interface StorageConfigRedirect { - 'status_code' : number, - 'location' : string, + 'status_code' : number, + 'location' : string, } export interface StreamingCallbackHttpResponse { - 'token' : [] | [StreamingCallbackToken], - 'body' : Uint8Array | number[], + 'token' : [] | [StreamingCallbackToken], + 'body' : Uint8Array | number[], } export interface StreamingCallbackToken { - 'memory' : Memory, - 'token' : [] | [string], - 'sha256' : [] | [Uint8Array | number[]], - 'headers' : Array<[string, string]>, - 'index' : bigint, - 'encoding_type' : string, - 'full_path' : string, + 'memory' : Memory, + 'token' : [] | [string], + 'sha256' : [] | [Uint8Array | number[]], + 'headers' : Array<[string, string]>, + 'index' : bigint, + 'encoding_type' : string, + 'full_path' : string, } export type StreamingStrategy = { 'Callback' : { - 'token' : StreamingCallbackToken, - 'callback' : [Principal, string], + 'token' : StreamingCallbackToken, + 'callback' : [Principal, string], } -}; + }; export type TimestampMatcher = { 'Equal' : bigint } | - { 'Between' : [bigint, bigint] } | - { 'GreaterThan' : bigint } | - { 'LessThan' : bigint }; + { 'Between' : [bigint, bigint] } | + { 'GreaterThan' : bigint } | + { 'LessThan' : bigint }; export interface UploadChunk { - 'content' : Uint8Array | number[], - 'batch_id' : bigint, - 'order_id' : [] | [bigint], + 'content' : Uint8Array | number[], + 'batch_id' : bigint, + 'order_id' : [] | [bigint], } export interface UploadChunkResult { 'chunk_id' : bigint } export interface _SERVICE { - 'build_version' : ActorMethod<[], string>, - 'commit_asset_upload' : ActorMethod<[CommitBatch], undefined>, - 'count_assets' : ActorMethod<[string, ListParams], bigint>, - 'count_collection_assets' : ActorMethod<[string], bigint>, - 'count_collection_docs' : ActorMethod<[string], bigint>, - 'count_docs' : ActorMethod<[string, ListParams], bigint>, - 'del_asset' : ActorMethod<[string, string], undefined>, - 'del_assets' : ActorMethod<[string], undefined>, - 'del_controllers' : ActorMethod< - [DeleteControllersArgs], - Array<[Principal, Controller]> - >, - 'del_custom_domain' : ActorMethod<[string], undefined>, - 'del_doc' : ActorMethod<[string, string, DelDoc], undefined>, - 'del_docs' : ActorMethod<[string], undefined>, - 'del_many_assets' : ActorMethod<[Array<[string, string]>], undefined>, - 'del_many_docs' : ActorMethod<[Array<[string, string, DelDoc]>], undefined>, - 'del_rule' : ActorMethod<[RulesType, string, DelRule], undefined>, - 'deposit_cycles' : ActorMethod<[DepositCyclesArgs], undefined>, - 'get_asset' : ActorMethod<[string, string], [] | [AssetNoContent]>, - 'get_auth_config' : ActorMethod<[], [] | [AuthenticationConfig]>, - 'get_config' : ActorMethod<[], Config>, - 'get_db_config' : ActorMethod<[], [] | [DbConfig]>, - 'get_doc' : ActorMethod<[string, string], [] | [Doc]>, - 'get_many_assets' : ActorMethod< - [Array<[string, string]>], - Array<[string, [] | [AssetNoContent]]> - >, - 'get_many_docs' : ActorMethod< - [Array<[string, string]>], - Array<[string, [] | [Doc]]> - >, - 'get_storage_config' : ActorMethod<[], StorageConfig>, - 'http_request' : ActorMethod<[HttpRequest], HttpResponse>, - 'http_request_streaming_callback' : ActorMethod< - [StreamingCallbackToken], - StreamingCallbackHttpResponse - >, - 'init_asset_upload' : ActorMethod<[InitAssetKey], InitUploadResult>, - 'list_assets' : ActorMethod<[string, ListParams], ListResults>, - 'list_controllers' : ActorMethod<[], Array<[Principal, Controller]>>, - 'list_custom_domains' : ActorMethod<[], Array<[string, CustomDomain]>>, - 'list_docs' : ActorMethod<[string, ListParams], ListResults_1>, - 'list_rules' : ActorMethod<[RulesType], Array<[string, Rule]>>, - 'memory_size' : ActorMethod<[], MemorySize>, - 'set_auth_config' : ActorMethod<[AuthenticationConfig], undefined>, - 'set_controllers' : ActorMethod< - [SetControllersArgs], - Array<[Principal, Controller]> - >, - 'set_custom_domain' : ActorMethod<[string, [] | [string]], undefined>, - 'set_db_config' : ActorMethod<[DbConfig], undefined>, - 'set_doc' : ActorMethod<[string, string, SetDoc], Doc>, - 'set_many_docs' : ActorMethod< - [Array<[string, string, SetDoc]>], - Array<[string, Doc]> - >, - 'set_rule' : ActorMethod<[RulesType, string, SetRule], undefined>, - 'set_storage_config' : ActorMethod<[StorageConfig], undefined>, - 'upload_asset_chunk' : ActorMethod<[UploadChunk], UploadChunkResult>, - 'version' : ActorMethod<[], string>, + 'commit_asset_upload' : ActorMethod<[CommitBatch], undefined>, + 'count_assets' : ActorMethod<[string, ListParams], bigint>, + 'count_collection_assets' : ActorMethod<[string], bigint>, + 'count_collection_docs' : ActorMethod<[string], bigint>, + 'count_docs' : ActorMethod<[string, ListParams], bigint>, + 'del_asset' : ActorMethod<[string, string], undefined>, + 'del_assets' : ActorMethod<[string], undefined>, + 'del_controllers' : ActorMethod< + [DeleteControllersArgs], + Array<[Principal, Controller]> + >, + 'del_custom_domain' : ActorMethod<[string], undefined>, + 'del_doc' : ActorMethod<[string, string, DelDoc], undefined>, + 'del_docs' : ActorMethod<[string], undefined>, + 'del_many_assets' : ActorMethod<[Array<[string, string]>], undefined>, + 'del_many_docs' : ActorMethod<[Array<[string, string, DelDoc]>], undefined>, + 'del_rule' : ActorMethod<[RulesType, string, DelRule], undefined>, + 'demo' : ActorMethod<[DemoArg], Result>, + 'deposit_cycles' : ActorMethod<[DepositCyclesArgs], undefined>, + 'get_asset' : ActorMethod<[string, string], [] | [AssetNoContent]>, + 'get_auth_config' : ActorMethod<[], [] | [AuthenticationConfig]>, + 'get_config' : ActorMethod<[], Config>, + 'get_db_config' : ActorMethod<[], [] | [DbConfig]>, + 'get_doc' : ActorMethod<[string, string], [] | [Doc]>, + 'get_many_assets' : ActorMethod< + [Array<[string, string]>], + Array<[string, [] | [AssetNoContent]]> + >, + 'get_many_docs' : ActorMethod< + [Array<[string, string]>], + Array<[string, [] | [Doc]]> + >, + 'get_storage_config' : ActorMethod<[], StorageConfig>, + 'http_request' : ActorMethod<[HttpRequest], HttpResponse>, + 'http_request_streaming_callback' : ActorMethod< + [StreamingCallbackToken], + StreamingCallbackHttpResponse + >, + 'init_asset_upload' : ActorMethod<[InitAssetKey], InitUploadResult>, + 'list_assets' : ActorMethod<[string, ListParams], ListResults>, + 'list_controllers' : ActorMethod<[], Array<[Principal, Controller]>>, + 'list_custom_domains' : ActorMethod<[], Array<[string, CustomDomain]>>, + 'list_docs' : ActorMethod<[string, ListParams], ListResults_1>, + 'list_rules' : ActorMethod<[RulesType], Array<[string, Rule]>>, + 'memory_size' : ActorMethod<[], MemorySize>, + 'say' : ActorMethod<[], undefined>, + 'set_auth_config' : ActorMethod<[AuthenticationConfig], undefined>, + 'set_controllers' : ActorMethod< + [SetControllersArgs], + Array<[Principal, Controller]> + >, + 'set_custom_domain' : ActorMethod<[string, [] | [string]], undefined>, + 'set_db_config' : ActorMethod<[DbConfig], undefined>, + 'set_doc' : ActorMethod<[string, string, SetDoc], Doc>, + 'set_many_docs' : ActorMethod< + [Array<[string, string, SetDoc]>], + Array<[string, Doc]> + >, + 'set_rule' : ActorMethod<[RulesType, string, SetRule], undefined>, + 'set_storage_config' : ActorMethod<[StorageConfig], undefined>, + 'upload_asset_chunk' : ActorMethod<[UploadChunk], UploadChunkResult>, + 'version' : ActorMethod<[], string>, } export declare const idlFactory: IDL.InterfaceFactory; export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; \ No newline at end of file diff --git a/tests/data/satellite_extension.did b/tests/data/satellite_extension.did index 0596cd3..8a0d794 100644 --- a/tests/data/satellite_extension.did +++ b/tests/data/satellite_extension.did @@ -1 +1,3 @@ -service : { build_version : () -> (text) query } +type DemoArg = record { status : text; message : text }; +type Result = variant { Ok : text; Err : text }; +service : { demo : (DemoArg) -> (Result) query; say : () -> () query } From 97ae2d527e352f4bfae822923579c42267a1a0f1 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Thu, 12 Jun 2025 10:49:27 +0200 Subject: [PATCH 3/3] chore: merge main --- tests/data/satellite.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/data/satellite.js b/tests/data/satellite.js index f99cf6c..b060583 100644 --- a/tests/data/satellite.js +++ b/tests/data/satellite.js @@ -319,7 +319,6 @@ export const idlFactory = ({ IDL }) => { [IDL.Vec(IDL.Tuple(IDL.Principal, Controller))], [], ), - 'set_custom_domain' : IDL.Func([IDL.Text, IDL.Opt(IDL.Text)], [], []), 'set_db_config' : IDL.Func([DbConfig], [], []), 'set_doc' : IDL.Func([IDL.Text, IDL.Text, SetDoc], [Doc], []),