From 8db811843c6c377c68b9927bc3bae1eca6944ab6 Mon Sep 17 00:00:00 2001 From: Aleksey Proshutisnkiy Date: Wed, 28 Jun 2023 15:51:36 +0300 Subject: [PATCH] feat: update blueprint API [NET-488] (#45) --- builtin.aqua | 32 ++++++++++++++------------------ workers.aqua | 8 ++++---- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/builtin.aqua b/builtin.aqua index a918568..2de9171 100644 --- a/builtin.aqua +++ b/builtin.aqua @@ -7,13 +7,8 @@ alias PeerId : string alias Pairs : [][]string alias Base58String : string alias Hash : string - --- There are two types of dependencies: named and by-hash. --- name:foobar – specifies dependency by module name, points to a module with import name 'foobar' --- hash:04dc884... – specifies dependency by module hash --- By-hash dependencies are preffered since they are determenistic --- while by-name dependency can yield different modules at different points in time -alias Dependency : string +alias IPLDBlueprint : string +alias CID : string data Service: id: string @@ -61,14 +56,10 @@ data Module: hash: string config: ModuleConfig -data AddBlueprint: - name: string - dependencies: []Dependency - data Blueprint: id: string name: string - dependencies: []Dependency + dependencies: []CID data ScriptInfo: id: string @@ -304,10 +295,15 @@ service Dist("dist"): -- Get the interface of a module get_module_interface(module_hash: string) -> Interface - -- Creates Blueprint structure from from blueprint name and dependencies (modules) - make_blueprint(name: string, dependencies: []Dependency) -> AddBlueprint - -- Add a blueprint to the node - add_blueprint(blueprint: AddBlueprint) -> string + -- Creates IPLD Blueprint structure from blueprint name and dependencies (modules) + make_blueprint(name: string, dependencies: []CID) -> IPLDBlueprint + -- Add an IPLD blueprint to the node + add_blueprint(blueprint: IPLDBlueprint) -> string + + -- Loads blueprint by copying it from Particle Vault directory + -- Arguments: + -- blueprint_path – path in Particle Vault + load_blueprint(blueprint_path: string) -> IPLDBlueprint -- Used to get the blueprints available on the node specified in the service call. -- A blueprint is an object of the following structure @@ -335,7 +331,7 @@ service Script("script"): -- (NOTE: an actual interval may vary by up to 3 seconds) add_from_vault(path: string, interval: ?u64) -> string - -- Removes recurring script from a node. Only a creator of the script can delete it + -- Removes recurring script from a node. Only the creator of the script can delete it remove(script_id: string) -> bool -- Returns a list of existing scripts on the node. @@ -382,6 +378,6 @@ service Stat("stat"): service Debug("debug"): -- Convert any object into a string stringify(o: ⊤) -> string - + service Console("run-console"): print(any: ⊤) diff --git a/workers.aqua b/workers.aqua index f95cd0a..84b66d1 100644 --- a/workers.aqua +++ b/workers.aqua @@ -5,11 +5,11 @@ service DealWorker("worker"): -- Creates new worker associated with `deal_id`. -- Throws an error if worker exists. create(deal_id: ?string) -> PeerId - + -- Returns worker peer id associated with `deal_id`. -- Throws an error if worker doesn't exist. get_peer_id(deal_id: ?string) -> PeerId - + -- Removes worker with all deployed spells and services. -- Throws an error if worker doesn't exist. -- Worker can be removed only by worker creator or worker itself. @@ -21,11 +21,11 @@ service Worker("worker"): -- Creates new worker associated with `init_peer_id`. -- Throws an error if worker exists. create() -> PeerId - + -- Returns worker peer id associated with `init_peer_id`. -- Throws an error if worker doesn't exist. get_peer_id() -> PeerId - + -- Removes worker with all deployed spells and services. -- Throws an error if worker doesn't exist. -- Worker can be removed only by worker creator or worker itself.