init ceramic glaze

This commit is contained in:
boneyard93501 2023-05-01 02:02:14 -05:00
parent cdec8be7ae
commit a7551f11a3
28 changed files with 4246 additions and 0 deletions

View File

@ -0,0 +1,19 @@
data Result:
stdout: string
stderr: string
service Glaze("glaze"):
config_get() -> Result
did_create() -> Result
model_add_definition(model_name: string, definition_name: string, definition: string, sk: string) -> Result
model_add_schema(model_name: string, schema_name: string, schema: string, sk: string) -> Result
model_add_tile(model_name: string, tile_name: string, tile_data: string, sk: string) -> Result
model_create(model_name: string) -> Result
model_delete(model_name: string) -> Result
model_deploy(model_name: string) -> Result
model_inspect(model_name: string) -> Result
rsplitter(s: string, token: string) -> string
stream_commits(stream_id: string) -> Result
tile_create(payload: string, commit_id: string, sk: string) -> Result
tile_show(stream_id: string) -> Result
tile_update(stream_id: string, payload: string, commit_id: string, sk: string) -> Result

View File

@ -0,0 +1,31 @@
data GetWorkersInfoDealsDefaultWorker:
definition: string
timestamp: string
dealIdOriginal: string
dealId: string
chainNetwork: string
chainNetworkId: u64
data GetWorkersInfoDeals:
defaultWorker: GetWorkersInfoDealsDefaultWorker
data GetWorkersInfoHostsDefaultWorkerInstallationSpells:
hostId: string
spellId: string
workerId: string
data GetWorkersInfoHostsDefaultWorker:
definition: string
installationSpells: []GetWorkersInfoHostsDefaultWorkerInstallationSpells
timestamp: string
relayId: string
data GetWorkersInfoHosts:
defaultWorker: GetWorkersInfoHostsDefaultWorker
data GetWorkersInfo:
deals: GetWorkersInfoDeals
hosts: GetWorkersInfoHosts
func getWorkersInfo() -> GetWorkersInfo:
<- GetWorkersInfo(deals=GetWorkersInfoDeals(defaultWorker=GetWorkersInfoDealsDefaultWorker(definition="bafkreidgjmle7qttpgsfvqxbnm4ooisfhheanfq6gkutyxg2k7xszmzrtq",timestamp="2023-05-01T06:48:44.564Z",dealIdOriginal="0xD2181906da79FCD2d017Af995F1dd52A2a7C028c",dealId="d2181906da79fcd2d017af995f1dd52a2a7c028c",chainNetwork="testnet",chainNetworkId=1313161555)),hosts=GetWorkersInfoHosts(defaultWorker=GetWorkersInfoHostsDefaultWorker(definition="bafkreidgjmle7qttpgsfvqxbnm4ooisfhheanfq6gkutyxg2k7xszmzrtq",installationSpells=[GetWorkersInfoHostsDefaultWorkerInstallationSpells(hostId="12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR",spellId="9d233c72-fbc4-47a8-8b48-5b533419a544",workerId="12D3KooWJbjznxbJBZ8eRmwSUHgrMuPXSoZ1Mh3w4FDRYhvXMzeE")],timestamp="2023-05-01T06:22:26.736Z",relayId="12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR")))

View File

@ -0,0 +1,8 @@
# yaml-language-server: $schema=schemas/project-secrets.yaml.json
# Defines project's secret keys that are used only in the scope of this particular Fluence project. You can manage project's keys using commands from `fluence key` group of commands
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/project-secrets.md
version: 0
keyPairs: []

View File

@ -0,0 +1,464 @@
{
"type": "object",
"properties": {
"services": {
"title": "Services",
"description": "A map with service names as keys and Service configs as values. You can have any number of services listed here (According to JSON schema they are called 'additionalProperties') as long as service name keys start with a lowercase letter and contain only letters numbers and underscores. You can use `fluence service add` command to add a service to this config",
"type": "object",
"additionalProperties": {
"title": "Service config",
"description": "Service names as keys (must start with a lowercase letter and contain only letters numbers and underscores) and Service config (defines where the service is and how to deploy it) as values",
"type": "object",
"properties": {
"get": {
"type": "string",
"description": "Path to service directory or URL to the tar.gz archive with the service"
},
"overrideModules": {
"type": "object",
"title": "Overrides",
"description": "A map of modules to override",
"additionalProperties": {
"type": "object",
"title": "Module overrides",
"description": "Module names as keys and overrides for the module config as values",
"properties": {
"get": {
"type": "string",
"nullable": true,
"description": "Path to module directory or URL to the tar.gz archive with the module"
},
"maxHeapSize": {
"type": "string",
"nullable": true,
"description": "Max size of the heap that a module can allocate in format: [number][whitespace?][specificator?] where ? is an optional field and specificator is one from the following (case-insensitive):\n\nK, Kb - kilobyte\n\nKi, KiB - kibibyte\n\nM, Mb - megabyte\n\nMi, MiB - mebibyte\n\nG, Gb - gigabyte\n\nGi, GiB - gibibyte\n\nCurrent limit is 4 GiB"
},
"loggerEnabled": {
"type": "boolean",
"nullable": true,
"description": "Set true to allow module to use the Marine SDK logger"
},
"loggingMask": {
"type": "number",
"nullable": true,
"description": "Used for logging management. Example:\n```rust\nconst TARGET_MAP: [(&str, i64); 4] = [\n(\"instruction\", 1 << 1),\n(\"data_cache\", 1 << 2),\n(\"next_peer_pks\", 1 << 3),\n(\"subtree_complete\", 1 << 4),\n];\npub fn main() {\nuse std::collections::HashMap;\nuse std::iter::FromIterator;\n\nlet target_map = HashMap::from_iter(TARGET_MAP.iter().cloned());\n\nmarine_rs_sdk::WasmLoggerBuilder::new()\n .with_target_map(target_map)\n .build()\n .unwrap();\n}\n#[marine]\npub fn foo() {\nlog::info!(target: \"instruction\", \"this will print if (loggingMask & 1) != 0\");\nlog::info!(target: \"data_cache\", \"this will print if (loggingMask & 2) != 0\");\n}\n```\n"
},
"volumes": {
"type": "object",
"nullable": true,
"required": [],
"title": "Volumes",
"description": "A map of accessible files and their aliases. Aliases should be used in Marine module development because it's hard to know the full path to a file"
},
"envs": {
"type": "object",
"title": "Environment variables",
"nullable": true,
"required": [],
"description": "environment variables accessible by a particular module with standard Rust env API like this: std::env::var(IPFS_ADDR_ENV_NAME).\n\nPlease note that Marine adds three additional environment variables. Module environment variables could be examined with repl"
},
"mountedBinaries": {
"title": "Mounted binaries",
"type": "object",
"nullable": true,
"required": [],
"description": "A map of binary executable files that module is allowed to call. Example: curl: /usr/bin/curl"
}
},
"required": [],
"nullable": true
},
"nullable": true,
"required": []
},
"deploy": {
"type": "array",
"title": "Deployment list",
"nullable": true,
"description": "List of deployments for the particular service",
"items": {
"type": "object",
"title": "Deployment",
"description": "A small config for a particular deployment. You can have specific overrides for each and specific deployment properties like count, etc.",
"properties": {
"keyPairName": {
"type": "string",
"nullable": true,
"description": "The name of the Key Pair to use. It is resolved in the following order (from the lowest to the highest priority):\n1. \"defaultKeyPairName\" property from user-secrets.yaml\n1. \"defaultKeyPairName\" property from project-secrets.yaml\n1. \"keyPairName\" property from the top level of fluence.yaml\n1. \"keyPairName\" property from the \"services\" level of fluence.yaml\n1. \"keyPairName\" property from the individual \"deploy\" property item level of fluence.yaml"
},
"deployId": {
"type": "string",
"description": "This id can be used in Aqua to access actually deployed peer and service ids. The ID must start with a lowercase letter and contain only letters, numbers, and underscores."
},
"count": {
"type": "number",
"minimum": 1,
"nullable": true,
"description": "Number of services to deploy. Default: 1 or if \"peerIds\" property is provided - exactly the number of peerIds"
},
"peerId": {
"type": "string",
"nullable": true,
"description": "Peer id or peer id name to deploy to. Default: Peer ids from the \"relay\" property of fluence.yaml are selected for each deploy. Named peerIds can be listed in \"peerIds\" property of fluence.yaml)"
},
"peerIds": {
"type": "array",
"items": {
"type": "string"
},
"nullable": true,
"title": "Peer ids",
"description": "Peer ids or peer id names to deploy to. Overrides \"peerId\" property. Named peerIds can be listed in \"peerIds\" property of fluence.yaml)"
},
"overrideModules": {
"type": "object",
"title": "Overrides",
"description": "A map of modules to override",
"additionalProperties": {
"type": "object",
"title": "Module overrides",
"description": "Module names as keys and overrides for the module config as values",
"properties": {
"get": {
"type": "string",
"nullable": true,
"description": "Path to module directory or URL to the tar.gz archive with the module"
},
"maxHeapSize": {
"type": "string",
"nullable": true,
"description": "Max size of the heap that a module can allocate in format: [number][whitespace?][specificator?] where ? is an optional field and specificator is one from the following (case-insensitive):\n\nK, Kb - kilobyte\n\nKi, KiB - kibibyte\n\nM, Mb - megabyte\n\nMi, MiB - mebibyte\n\nG, Gb - gigabyte\n\nGi, GiB - gibibyte\n\nCurrent limit is 4 GiB"
},
"loggerEnabled": {
"type": "boolean",
"nullable": true,
"description": "Set true to allow module to use the Marine SDK logger"
},
"loggingMask": {
"type": "number",
"nullable": true,
"description": "Used for logging management. Example:\n```rust\nconst TARGET_MAP: [(&str, i64); 4] = [\n(\"instruction\", 1 << 1),\n(\"data_cache\", 1 << 2),\n(\"next_peer_pks\", 1 << 3),\n(\"subtree_complete\", 1 << 4),\n];\npub fn main() {\nuse std::collections::HashMap;\nuse std::iter::FromIterator;\n\nlet target_map = HashMap::from_iter(TARGET_MAP.iter().cloned());\n\nmarine_rs_sdk::WasmLoggerBuilder::new()\n .with_target_map(target_map)\n .build()\n .unwrap();\n}\n#[marine]\npub fn foo() {\nlog::info!(target: \"instruction\", \"this will print if (loggingMask & 1) != 0\");\nlog::info!(target: \"data_cache\", \"this will print if (loggingMask & 2) != 0\");\n}\n```\n"
},
"volumes": {
"type": "object",
"nullable": true,
"required": [],
"title": "Volumes",
"description": "A map of accessible files and their aliases. Aliases should be used in Marine module development because it's hard to know the full path to a file"
},
"envs": {
"type": "object",
"title": "Environment variables",
"nullable": true,
"required": [],
"description": "environment variables accessible by a particular module with standard Rust env API like this: std::env::var(IPFS_ADDR_ENV_NAME).\n\nPlease note that Marine adds three additional environment variables. Module environment variables could be examined with repl"
},
"mountedBinaries": {
"title": "Mounted binaries",
"type": "object",
"nullable": true,
"required": [],
"description": "A map of binary executable files that module is allowed to call. Example: curl: /usr/bin/curl"
}
},
"required": [],
"nullable": true
},
"nullable": true,
"required": []
}
},
"required": [
"deployId"
]
}
},
"keyPairName": {
"type": "string",
"nullable": true,
"description": "The name of the Key Pair to use. It is resolved in the following order (from the lowest to the highest priority):\n1. \"defaultKeyPairName\" property from user-secrets.yaml\n1. \"defaultKeyPairName\" property from project-secrets.yaml\n1. \"keyPairName\" property from the top level of fluence.yaml\n1. \"keyPairName\" property from the \"services\" level of fluence.yaml\n1. \"keyPairName\" property from the individual \"deploy\" property item level of fluence.yaml"
}
},
"required": [
"get"
]
},
"required": [],
"nullable": true
},
"relays": {
"title": "Relays",
"description": "List of Fluence Peer multi addresses or a name of the network. This multi addresses are used for connecting to the Fluence network when deploying. Peer ids from these addresses are also used for deploying in case if you don't specify \"peerId\" or \"peerIds\" property in the deployment config. Default: kras",
"type": [
"string",
"array",
"null"
],
"oneOf": [
{
"type": "string",
"title": "Network name",
"enum": [
"kras",
"stage",
"testnet"
]
},
{
"type": "array",
"title": "Multi addresses",
"items": {
"type": "string"
},
"minItems": 1
}
],
"nullable": true
},
"peerIds": {
"title": "Peer ids",
"description": "A map of named peerIds. Example:\n\nMY_PEER: 12D3KooWCMr9mU894i8JXAFqpgoFtx6qnV1LFPSfVc3Y34N4h4LS",
"type": "object",
"nullable": true,
"required": [],
"additionalProperties": {
"type": "string",
"description": "Peer id names as keys and the actual peer ids as values"
}
},
"keyPairName": {
"type": "string",
"nullable": true,
"description": "The name of the Key Pair to use. It is resolved in the following order (from the lowest to the highest priority):\n1. \"defaultKeyPairName\" property from user-secrets.yaml\n1. \"defaultKeyPairName\" property from project-secrets.yaml\n1. \"keyPairName\" property from the top level of fluence.yaml\n1. \"keyPairName\" property from the \"services\" level of fluence.yaml\n1. \"keyPairName\" property from the individual \"deploy\" property item level of fluence.yaml"
},
"version": {
"type": "number",
"const": 2
},
"dependencies": {
"type": "object",
"title": "Dependencies",
"nullable": true,
"description": "(For advanced users) Overrides for the project dependencies",
"properties": {
"npm": {
"type": "object",
"title": "npm dependencies",
"nullable": true,
"description": "A map of npm dependency versions. CLI ensures dependencies are installed each time you run aqua",
"required": []
},
"cargo": {
"type": "object",
"title": "Cargo dependencies",
"nullable": true,
"description": "A map of cargo dependency versions. CLI ensures dependencies are installed each time you run commands that depend on Marine or Marine REPL",
"required": []
}
},
"required": []
},
"aquaInputPath": {
"type": "string",
"nullable": true,
"description": "Path to the aqua file or directory with aqua files that you want to compile by default. Must be relative to the project root dir"
},
"aquaOutputTSPath": {
"type": "string",
"nullable": true,
"description": "Path to the default compilation target dir from aqua to ts. Must be relative to the project root dir"
},
"aquaOutputJSPath": {
"type": "string",
"nullable": true,
"description": "Path to the default compilation target dir from aqua to js. Must be relative to the project root dir. Overrides 'aquaOutputTSPath' property"
},
"appTSPath": {
"type": "string",
"nullable": true,
"description": "Path to the directory where you want to generate app.ts after deployment. If you run registerApp() function in your typescript code after initializing FluenceJS client you will be able to access ids of the deployed services in aqua"
},
"appJSPath": {
"type": "string",
"nullable": true,
"description": "Path to the directory where you want to generate app.js after deployment. If you run registerApp() function in your javascript code after initializing FluenceJS client you will be able to access ids of the deployed services in aqua"
},
"hosts": {
"description": "A map of objects with worker names as keys, each object defines a list of peer IDs to host the worker on",
"type": "object",
"nullable": true,
"additionalProperties": {
"type": "object",
"properties": {
"peerIds": {
"type": "array",
"description": "An array of peer IDs to deploy on",
"items": {
"type": "string"
}
}
},
"required": [
"peerIds"
]
},
"required": []
},
"workers": {
"nullable": true,
"description": "A Map with worker names as keys and worker configs as values",
"type": "object",
"additionalProperties": {
"type": "object",
"description": "Worker config",
"properties": {
"services": {
"description": "An array of service names to include in this worker. Service names must be listed in fluence.yaml",
"type": "array",
"items": {
"type": "string"
},
"nullable": true
},
"spells": {
"description": "An array of spell names to include in this worker. Spell names must be listed in fluence.yaml",
"type": "array",
"items": {
"type": "string"
},
"nullable": true
}
},
"required": []
},
"required": []
},
"deals": {
"description": "A map of objects with worker names as keys, each object defines a deal",
"type": "object",
"nullable": true,
"additionalProperties": {
"type": "object",
"properties": {
"minWorkers": {
"type": "number",
"description": "Required workers to activate the deal",
"default": 1,
"nullable": true,
"minimum": 1
},
"targetWorkers": {
"type": "number",
"description": "Max workers in the deal",
"default": 3,
"nullable": true,
"minimum": 1
}
},
"required": []
},
"required": []
},
"chainNetwork": {
"type": "string",
"description": "The network in which the transactions will be carried out",
"enum": [
"local",
"testnet"
],
"default": "testnet",
"nullable": true
},
"spells": {
"type": "object",
"nullable": true,
"description": "A map with spell names as keys and spell configs as values",
"additionalProperties": {
"type": "object",
"description": "Spell config",
"properties": {
"get": {
"type": "string",
"description": "Path to spell"
},
"version": {
"type": "number",
"const": 0
},
"aquaFilePath": {
"type": "string",
"description": "Path to Aqua file which contains an Aqua function that you want to use as a spell",
"nullable": true
},
"function": {
"type": "string",
"description": "Name of the Aqua function that you want to use as a spell",
"nullable": true
},
"initArgs": {
"type": "object",
"description": "A map of Aqua function arguments names as keys and arguments values as values. They will be passed to the spell function and will be stored in the key-value storage for this particular spell.",
"nullable": true
},
"clock": {
"type": "object",
"nullable": true,
"description": "Trigger the spell execution periodically. If you want to disable this property by overriding it in fluence.yaml - pass empty config for it like this: `clock: {}`",
"properties": {
"periodSec": {
"type": "number",
"description": "How often the spell will be executed. If set to 0, the spell will be executed only once. If this value not provided at all - the spell will never be executed",
"minimum": 0,
"maximum": 3153600000,
"nullable": true
},
"startTimestamp": {
"type": "string",
"description": "An ISO timestamp when the periodic execution should start. If this property or `startDelaySec` not specified, periodic execution will start immediately. If it is set to 0 - the spell will never be executed",
"nullable": true
},
"endTimestamp": {
"type": "string",
"description": "An ISO timestamp when the periodic execution should end. If this property or `endDelaySec` not specified, periodic execution will never end. If it is in the past at the moment of spell creation on Rust peer - the spell will never be executed",
"nullable": true
},
"startDelaySec": {
"type": "number",
"description": "How long to wait before the first execution in seconds. If this property or `startTimestamp` not specified, periodic execution will start immediately. WARNING! Currently your computer's clock is used to determine a final timestamp that is sent to the server. This property conflicts with `startTimestamp`. You can specify only one of them",
"nullable": true,
"minimum": 0,
"maximum": 4294967295
},
"endDelaySec": {
"type": "number",
"description": "How long to wait before the last execution in seconds. If this property or `endTimestamp` not specified, periodic execution will never end. WARNING! Currently your computer's clock is used to determine a final timestamp that is sent to the server. If it is in the past at the moment of spell creation - the spell will never be executed. This property conflicts with `endTimestamp`. You can specify only one of them",
"nullable": true,
"minimum": 0,
"maximum": 4294967295
}
},
"required": []
}
},
"required": [
"get"
]
},
"required": []
},
"aquaImports": {
"type": "array",
"description": "A list of path to be considered by aqua compiler to be used as imports. First dependency in the list has the highest priority. Priority of imports is considered in the following order: imports from --import flags, imports from aquaImports property in fluence.yaml, project's .fluence/aqua dir, npm dependencies from fluence.yaml, npm dependencies from user's .fluence/config.yaml, npm dependencies recommended by fluence",
"items": {
"type": "string"
},
"nullable": true
}
},
"required": [
"version"
],
"$id": "https://fluence.dev/schemas/fluence.yaml",
"title": "fluence.yaml",
"description": "Defines Fluence Project, most importantly - what exactly you want to deploy and how. You can use `fluence init` command to generate a template for new Fluence project"
}

View File

@ -0,0 +1,66 @@
{
"type": "object",
"$id": "https://fluence.dev/schemas/module.yaml",
"title": "module.yaml",
"description": "Defines [Marine Module](https://fluence.dev/docs/build/concepts/#modules). You can use `fluence module new` command to generate a template for new module",
"properties": {
"name": {
"type": "string",
"description": "\"name\" property from the Cargo.toml (for module type \"rust\") or name of the precompiled .wasm file (for module type \"compiled\")"
},
"type": {
"type": "string",
"enum": [
"rust",
"compiled"
],
"nullable": true,
"default": "compiled",
"description": "Module type \"compiled\" is for the precompiled modules. Module type \"rust\" is for the source code written in rust which can be compiled into a Marine module"
},
"maxHeapSize": {
"type": "string",
"nullable": true,
"description": "Max size of the heap that a module can allocate in format: [number][whitespace?][specificator?] where ? is an optional field and specificator is one from the following (case-insensitive):\n\nK, Kb - kilobyte\n\nKi, KiB - kibibyte\n\nM, Mb - megabyte\n\nMi, MiB - mebibyte\n\nG, Gb - gigabyte\n\nGi, GiB - gibibyte\n\nCurrent limit is 4 GiB"
},
"loggerEnabled": {
"type": "boolean",
"nullable": true,
"description": "Set true to allow module to use the Marine SDK logger"
},
"loggingMask": {
"type": "number",
"nullable": true,
"description": "Used for logging management. Example:\n```rust\nconst TARGET_MAP: [(&str, i64); 4] = [\n(\"instruction\", 1 << 1),\n(\"data_cache\", 1 << 2),\n(\"next_peer_pks\", 1 << 3),\n(\"subtree_complete\", 1 << 4),\n];\npub fn main() {\nuse std::collections::HashMap;\nuse std::iter::FromIterator;\n\nlet target_map = HashMap::from_iter(TARGET_MAP.iter().cloned());\n\nmarine_rs_sdk::WasmLoggerBuilder::new()\n .with_target_map(target_map)\n .build()\n .unwrap();\n}\n#[marine]\npub fn foo() {\nlog::info!(target: \"instruction\", \"this will print if (loggingMask & 1) != 0\");\nlog::info!(target: \"data_cache\", \"this will print if (loggingMask & 2) != 0\");\n}\n```\n"
},
"volumes": {
"type": "object",
"nullable": true,
"required": [],
"title": "Volumes",
"description": "A map of accessible files and their aliases. Aliases should be used in Marine module development because it's hard to know the full path to a file"
},
"envs": {
"type": "object",
"title": "Environment variables",
"nullable": true,
"required": [],
"description": "environment variables accessible by a particular module with standard Rust env API like this: std::env::var(IPFS_ADDR_ENV_NAME).\n\nPlease note that Marine adds three additional environment variables. Module environment variables could be examined with repl"
},
"mountedBinaries": {
"title": "Mounted binaries",
"type": "object",
"nullable": true,
"required": [],
"description": "A map of binary executable files that module is allowed to call. Example: curl: /usr/bin/curl"
},
"version": {
"type": "number",
"const": 0
}
},
"required": [
"version",
"name"
]
}

View File

@ -0,0 +1,42 @@
{
"$id": "https://fluence.dev/schemas/project-secrets.yaml",
"title": "project-secrets.yaml",
"type": "object",
"description": "Defines project's secret keys that are used only in the scope of this particular Fluence project. You can manage project's keys using commands from `fluence key` group of commands",
"properties": {
"keyPairs": {
"title": "Key Pairs",
"description": "Key Pairs available for the particular project",
"type": "array",
"items": {
"title": "Key Pair",
"type": "object",
"properties": {
"secretKey": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"secretKey",
"name"
]
}
},
"defaultKeyPairName": {
"type": "string",
"nullable": true,
"description": "Key pair with this name will be used for the deployment by default. You can override it with flags or by using keyPair properties in fluence.yaml"
},
"version": {
"type": "number",
"const": 0
}
},
"required": [
"version",
"keyPairs"
]
}

View File

@ -0,0 +1,129 @@
{
"type": "object",
"$id": "https://fluence.dev/schemas/service.yaml",
"title": "service.yaml",
"description": "Defines a [Marine service](https://fluence.dev/docs/build/concepts/#services), most importantly the modules that the service consists of. You can use `fluence service new` command to generate a template for new service",
"properties": {
"name": {
"type": "string",
"description": "Service name. Currently it is used for the service name only when you add service to fluence.yaml using \"add\" command. But this name can be overridden to any other with the --name flag or manually in fluence.yaml"
},
"modules": {
"title": "Modules",
"description": "Service must have a facade module. Each module properties can be overridden by the same properties in the service config",
"type": "object",
"additionalProperties": {
"type": "object",
"title": "Module",
"properties": {
"get": {
"type": "string",
"description": "Either path to the module directory or URL to the tar.gz archive which contains the content of the module directory"
},
"maxHeapSize": {
"type": "string",
"nullable": true,
"description": "Max size of the heap that a module can allocate in format: [number][whitespace?][specificator?] where ? is an optional field and specificator is one from the following (case-insensitive):\n\nK, Kb - kilobyte\n\nKi, KiB - kibibyte\n\nM, Mb - megabyte\n\nMi, MiB - mebibyte\n\nG, Gb - gigabyte\n\nGi, GiB - gibibyte\n\nCurrent limit is 4 GiB"
},
"loggerEnabled": {
"type": "boolean",
"nullable": true,
"description": "Set true to allow module to use the Marine SDK logger"
},
"loggingMask": {
"type": "number",
"nullable": true,
"description": "Used for logging management. Example:\n```rust\nconst TARGET_MAP: [(&str, i64); 4] = [\n(\"instruction\", 1 << 1),\n(\"data_cache\", 1 << 2),\n(\"next_peer_pks\", 1 << 3),\n(\"subtree_complete\", 1 << 4),\n];\npub fn main() {\nuse std::collections::HashMap;\nuse std::iter::FromIterator;\n\nlet target_map = HashMap::from_iter(TARGET_MAP.iter().cloned());\n\nmarine_rs_sdk::WasmLoggerBuilder::new()\n .with_target_map(target_map)\n .build()\n .unwrap();\n}\n#[marine]\npub fn foo() {\nlog::info!(target: \"instruction\", \"this will print if (loggingMask & 1) != 0\");\nlog::info!(target: \"data_cache\", \"this will print if (loggingMask & 2) != 0\");\n}\n```\n"
},
"volumes": {
"type": "object",
"nullable": true,
"required": [],
"title": "Volumes",
"description": "A map of accessible files and their aliases. Aliases should be used in Marine module development because it's hard to know the full path to a file"
},
"envs": {
"type": "object",
"title": "Environment variables",
"nullable": true,
"required": [],
"description": "environment variables accessible by a particular module with standard Rust env API like this: std::env::var(IPFS_ADDR_ENV_NAME).\n\nPlease note that Marine adds three additional environment variables. Module environment variables could be examined with repl"
},
"mountedBinaries": {
"title": "Mounted binaries",
"type": "object",
"nullable": true,
"required": [],
"description": "A map of binary executable files that module is allowed to call. Example: curl: /usr/bin/curl"
}
},
"required": [
"get"
]
},
"properties": {
"facade": {
"type": "object",
"title": "Module",
"properties": {
"get": {
"type": "string",
"description": "Either path to the module directory or URL to the tar.gz archive which contains the content of the module directory"
},
"maxHeapSize": {
"type": "string",
"nullable": true,
"description": "Max size of the heap that a module can allocate in format: [number][whitespace?][specificator?] where ? is an optional field and specificator is one from the following (case-insensitive):\n\nK, Kb - kilobyte\n\nKi, KiB - kibibyte\n\nM, Mb - megabyte\n\nMi, MiB - mebibyte\n\nG, Gb - gigabyte\n\nGi, GiB - gibibyte\n\nCurrent limit is 4 GiB"
},
"loggerEnabled": {
"type": "boolean",
"nullable": true,
"description": "Set true to allow module to use the Marine SDK logger"
},
"loggingMask": {
"type": "number",
"nullable": true,
"description": "Used for logging management. Example:\n```rust\nconst TARGET_MAP: [(&str, i64); 4] = [\n(\"instruction\", 1 << 1),\n(\"data_cache\", 1 << 2),\n(\"next_peer_pks\", 1 << 3),\n(\"subtree_complete\", 1 << 4),\n];\npub fn main() {\nuse std::collections::HashMap;\nuse std::iter::FromIterator;\n\nlet target_map = HashMap::from_iter(TARGET_MAP.iter().cloned());\n\nmarine_rs_sdk::WasmLoggerBuilder::new()\n .with_target_map(target_map)\n .build()\n .unwrap();\n}\n#[marine]\npub fn foo() {\nlog::info!(target: \"instruction\", \"this will print if (loggingMask & 1) != 0\");\nlog::info!(target: \"data_cache\", \"this will print if (loggingMask & 2) != 0\");\n}\n```\n"
},
"volumes": {
"type": "object",
"nullable": true,
"required": [],
"title": "Volumes",
"description": "A map of accessible files and their aliases. Aliases should be used in Marine module development because it's hard to know the full path to a file"
},
"envs": {
"type": "object",
"title": "Environment variables",
"nullable": true,
"required": [],
"description": "environment variables accessible by a particular module with standard Rust env API like this: std::env::var(IPFS_ADDR_ENV_NAME).\n\nPlease note that Marine adds three additional environment variables. Module environment variables could be examined with repl"
},
"mountedBinaries": {
"title": "Mounted binaries",
"type": "object",
"nullable": true,
"required": [],
"description": "A map of binary executable files that module is allowed to call. Example: curl: /usr/bin/curl"
}
},
"required": [
"get"
]
}
},
"required": [
"facade"
]
},
"version": {
"type": "number",
"const": 0
}
},
"required": [
"version",
"name",
"modules"
]
}

View File

@ -0,0 +1,107 @@
{
"$id": "https://fluence.dev/schemas/workers.yaml",
"title": "workers.yaml",
"type": "object",
"description": "A result of app deployment. This file is created automatically after successful deployment using `fluence workers deploy` command",
"properties": {
"version": {
"type": "number",
"const": 0
},
"deals": {
"type": "object",
"description": "A map of created deals",
"additionalProperties": {
"type": "object",
"properties": {
"definition": {
"type": "string"
},
"timestamp": {
"type": "string",
"description": "ISO timestamp of the time when the worker was deployed"
},
"dealId": {
"type": "string"
},
"dealIdOriginal": {
"type": "string"
},
"chainNetwork": {
"type": "string",
"enum": [
"local",
"testnet"
]
},
"chainNetworkId": {
"type": "number"
}
},
"required": [
"timestamp",
"definition",
"dealId",
"dealIdOriginal",
"chainNetwork",
"chainNetworkId"
]
},
"required": [],
"nullable": true
},
"hosts": {
"type": "object",
"description": "A map of deployed workers",
"additionalProperties": {
"type": "object",
"properties": {
"definition": {
"type": "string"
},
"timestamp": {
"type": "string",
"description": "ISO timestamp of the time when the worker was deployed"
},
"installation_spells": {
"type": "array",
"description": "A list of installation spells",
"items": {
"type": "object",
"properties": {
"host_id": {
"type": "string"
},
"spell_id": {
"type": "string"
},
"worker_id": {
"type": "string"
}
},
"required": [
"host_id",
"spell_id",
"worker_id"
]
}
},
"relayId": {
"type": "string"
}
},
"required": [
"timestamp",
"definition",
"installation_spells",
"relayId"
]
},
"required": [],
"nullable": true
}
},
"required": [
"version"
]
}

View File

@ -0,0 +1,10 @@
[[module]]
name = "glaze_adapter"
load_from = "/Users/bebo/localdev/examples/aqua-examples/ceramic-streams/target/wasm32-wasi/release/glaze_adapter.wasm"
[module.mounted_binaries]
glaze = "/Users/bebo/.nvm/versions/node/v16.19.0/bin/glaze"
[[module]]
name = "glaze"
load_from = "/Users/bebo/localdev/examples/aqua-examples/ceramic-streams/target/wasm32-wasi/release/glaze.wasm"

View File

@ -0,0 +1,24 @@
# yaml-language-server: $schema=schemas/workers.yaml.json
# A result of app deployment. This file is created automatically after successful deployment using `fluence workers deploy` command
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/workers.md
version: 0
hosts:
defaultWorker:
definition: bafkreidgjmle7qttpgsfvqxbnm4ooisfhheanfq6gkutyxg2k7xszmzrtq
installation_spells:
- host_id: 12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR
spell_id: 9d233c72-fbc4-47a8-8b48-5b533419a544
worker_id: 12D3KooWJbjznxbJBZ8eRmwSUHgrMuPXSoZ1Mh3w4FDRYhvXMzeE
timestamp: 2023-05-01T06:22:26.736Z
relayId: 12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR
deals:
defaultWorker:
definition: bafkreidgjmle7qttpgsfvqxbnm4ooisfhheanfq6gkutyxg2k7xszmzrtq
timestamp: 2023-05-01T06:48:44.564Z
dealIdOriginal: "0xD2181906da79FCD2d017Af995F1dd52A2a7C028c"
dealId: d2181906da79fcd2d017af995f1dd52a2a7c028c
chainNetwork: testnet
chainNetworkId: 1313161555

View File

@ -0,0 +1,9 @@
.idea
.DS_Store
.fluence
**/node_modules
**/target/
.repl_history
.vscode/settings.json
src/ts/src/aqua
src/js/src/aqua

2827
aqua-examples/ceramic-streams/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
[workspace]
members = [ "service/modules/glaze", "service/modules/glaze_adapter" ]

View File

@ -0,0 +1,27 @@
# yaml-language-server: $schema=.fluence/schemas/fluence.yaml.json
# Defines Fluence Project, most importantly - what exactly you want to deploy and how. You can use `fluence init` command to generate a template for new Fluence project
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/fluence.md
version: 2
aquaInputPath: src/aqua/main.aqua
workers:
defaultWorker:
services: [ glaze ]
deals:
defaultWorker:
minWorkers: 1
targetWorkers: 3
hosts:
defaultWorker:
peerIds:
- 12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt # kras
# - 12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR # local
relays: kras
# - /ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR
# - /ip4/127.0.0.1/tcp/9992/ws/p2p/12D3KooWQdpukY3p2DhDfUfDgphAqsGu5ZUrmQ4mcHSGrRag6gQK
# - /ip4/127.0.0.1/tcp/9993/ws/p2p/12D3KooWRT8V5awYdEZm6aAV9HWweCEbhWd7df4wehqHZXAB7yMZ
services:
glaze:
get: service

View File

@ -0,0 +1,15 @@
[package]
name = "glaze"
version = "0.1.0"
edition = "2018"
[[bin]]
name = "glaze"
path = "src/main.rs"
[dependencies]
marine-rs-sdk = "0.7.1"
serde_json = "1.0.86"
[dev-dependencies]
marine-rs-sdk-test = "0.9.1"

View File

@ -0,0 +1,9 @@
# yaml-language-server: $schema=../../../.fluence/schemas/module.yaml.json
# Defines [Marine Module](https://fluence.dev/docs/build/concepts/#modules). You can use `fluence module new` command to generate a template for new module
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/module.md
version: 0
type: rust
name: glaze

View File

@ -0,0 +1,21 @@
use marine_rs_sdk::marine;
#[marine]
pub struct Result {
pub stdout: String,
pub stderr: String,
}
#[marine]
pub fn rsplitter(s: String, token: String) -> String {
let res: Vec<&str> = s.split(&token).collect();
if res.len() == 2 {
let res = res[1]
.replace("\"", "")
.replace("'", "")
.replace("{", "")
.replace("}", "");
return res.to_string();
}
"".to_string()
}

View File

@ -0,0 +1,28 @@
use crate::ceramic_common::Result;
use marine_rs_sdk::marine;
use crate::glaze_adapter::glaze_request;
#[marine]
fn config_get() -> Result {
let cmd = "config:show";
let args = vec![cmd.to_owned()];
let res = glaze_request(args);
let mut stdout = String::from_utf8(res.stdout).unwrap();
let mut stderr = String::from_utf8(res.stderr).unwrap();
if stdout.contains("Ceramic API URL") {
let s = stdout.split(" ceramic-url ").collect::<Vec<&str>>()[1];
let s = s.replace("\u{1b}[90m│\u{1b}[39m ","").replace(" \u{1b}[90m│\u{1b}[39m\n\u{1b}[90m└─────────────────\u{1b}[39m\u{1b}[90m┴─────────────\u{1b}[39m\u{1b}[90m┴───────────────────────┘\u{1b}[39m\n","");
let obj = serde_json::json!({ "api": s }).to_string();
stdout = obj;
stderr = "".to_string();
}
Result {
stdout: stdout,
stderr: stderr,
}
}

View File

@ -0,0 +1,7 @@
use marine_rs_sdk::{marine, MountedBinaryResult};
#[marine]
#[link(wasm_import_module = "glaze_adapter")]
extern "C" {
pub fn glaze_request(cmd: Vec<String>) -> MountedBinaryResult;
}

View File

@ -0,0 +1,29 @@
use crate::glaze_adapter::glaze_request;
use crate::ceramic_common::Result;
use serde_json::json;
use marine_rs_sdk::marine;
#[marine]
pub fn did_create() -> Result {
// create a new DID
let cmd = "did:create";
let args = vec![cmd.to_owned()];
let res = glaze_request(args);
let mut stdout = String::from_utf8(res.stderr).unwrap();
let mut stderr = String::from_utf8(res.stdout).unwrap();
if stdout.contains("Created DID") {
let s: Vec<&str> = stdout.split("DID ").collect();
let s = s[1].replace("\n", "");
let did_sk: Vec<&str> = s.split(" with seed ").collect();
let pk = did_sk[0].clone().split(":").collect::<Vec<&str>>();
let pk = pk.last().unwrap();
let obj = json!({"did": did_sk[0], "pk":pk,"sk": did_sk[1]});
stdout = obj.to_string();
stderr = "".to_string();
}
Result { stdout, stderr }
}

View File

@ -0,0 +1,160 @@
use crate::ceramic_common::Result;
use marine_rs_sdk::marine;
use serde_json::json;
use crate::glaze_adapter::glaze_request;
#[marine]
pub fn model_create(model_name: String) -> Result {
let args = vec!["model:create".to_owned(), model_name];
let res = glaze_request(args);
let stdout = String::from_utf8(res.stdout).unwrap();
let stderr = String::from_utf8(res.stderr).unwrap();
Result {
stdout: stdout,
stderr: stderr,
}
}
#[marine]
pub fn model_delete(model_name: String) -> Result {
let args = vec!["model:delete".to_owned(), "-f".to_owned(), model_name];
let res = glaze_request(args);
let mut stdout = String::from_utf8(res.stdout).unwrap();
let mut stderr = String::from_utf8(res.stderr).unwrap();
if stderr.contains("successfully delete") {
stdout = json!({"deleted": true}).to_string();
stderr = "".to_string();
}
Result {
stdout: stdout,
stderr: stderr,
}
}
#[marine]
pub fn model_add_schema(
model_name: String,
schema_name: String,
schema: String,
sk: String,
) -> Result {
let args = vec![
"model:add".to_owned(),
model_name,
"schema".to_owned(),
schema_name,
schema,
"--key".to_owned(),
sk,
];
let res = glaze_request(args);
let stdout = String::from_utf8(res.stderr).unwrap();
let stderr = String::from_utf8(res.stdout).unwrap();
Result {
stdout: stdout,
stderr: stderr,
}
}
#[marine]
pub fn model_add_definition(
model_name: String,
definition_name: String,
definition: String,
sk: String,
) -> Result {
let args = vec![
"model:add".to_owned(),
model_name,
"definition".to_owned(),
definition_name,
definition,
"--key".to_owned(),
sk,
];
let res = glaze_request(args);
let stdout = String::from_utf8(res.stderr).unwrap();
let stderr = String::from_utf8(res.stdout).unwrap();
Result {
stdout: stdout,
stderr: stderr,
}
}
#[marine]
pub fn model_add_tile(
model_name: String,
tile_name: String,
tile_data: String,
sk: String,
) -> Result {
let args = vec![
"model:add".to_owned(),
model_name,
"tile".to_owned(),
tile_name,
tile_data,
"--key".to_owned(),
sk,
];
let res = glaze_request(args);
let stdout = String::from_utf8(res.stderr).unwrap();
let stderr = String::from_utf8(res.stdout).unwrap();
Result {
stdout: stdout,
stderr: stderr,
}
}
#[marine]
pub fn model_inspect(model_name: String) -> Result {
let args = vec!["model:inspect".to_owned(), model_name];
let res = glaze_request(args);
let stdout = String::from_utf8(res.stderr).unwrap();
let stderr = String::from_utf8(res.stdout).unwrap();
Result {
stdout: stdout,
stderr: stderr,
}
}
#[marine]
pub fn model_deploy(model_name: String) -> Result {
let args = vec!["model:deploy".to_owned(), model_name];
let res = glaze_request(args);
let stdout = String::from_utf8(res.stderr).unwrap();
let stderr = String::from_utf8(res.stdout).unwrap();
Result {
stdout: stdout,
stderr: stderr,
}
}
#[cfg(test)]
mod tests {
use super::*;
const MODEL_NAME: &'static str = "test_model";
#[test]
fn test_model_create() {
let res = model_create(MODEL_NAME);
println!("create: {:?}", res);
}
}

View File

@ -0,0 +1,27 @@
use crate::ceramic_common::Result;
use marine_rs_sdk::marine;
use serde_json::json;
use crate::glaze_adapter::glaze_request;
#[marine]
pub fn stream_commits(stream_id: String) -> Result {
let args = vec!["stream:commits".to_owned(), stream_id];
let res = glaze_request(args);
let mut stderr = String::from_utf8(res.stderr).unwrap();
let mut stdout = String::from_utf8(res.stdout).unwrap();
if stderr.contains("Stream commits loaded") && stdout.chars().count() > 0 {
let s = stdout
.replace("[\n \u{1b}[32m", "")
.replace("'\u{1b}[39m,\n", "");
let s = s.split(" ").collect::<Vec<&str>>()[0];
stdout = json!({ "commit_id": s }).to_string();
stderr = "".to_string();
}
Result {
stdout: stdout,
stderr: stderr,
}
}

View File

@ -0,0 +1,124 @@
use crate::ceramic_common::Result;
use marine_rs_sdk::marine;
use crate::glaze_adapter::glaze_request;
#[marine]
pub fn tile_create(payload: String, commit_id: String, sk: String) -> Result {
let mut args = vec![
"tile:create".to_owned(),
"--key".to_owned(),
sk,
"--content".to_owned(),
payload,
];
if commit_id.chars().count() > 0 {
args.push("--metadata".to_owned());
args.push(format!("{{\"schema\": {} }}", commit_id));
}
let res = glaze_request(args);
let mut stdout = String::from_utf8(res.stdout).unwrap();
let mut stderr = String::from_utf8(res.stderr).unwrap();
if stderr.contains("Created stream") {
let s: Vec<&str> = stderr.split("Creating stream...\n").collect();
let sid = s[1]
.strip_suffix("\n")
.unwrap_or("")
.trim()
.replace("Created stream ", "")
.replace(".", "");
let did = s[0]
.trim()
.replace("-", "")
.strip_suffix("\n")
.unwrap_or(s[0])
.replace("Using DID ", "");
let did = did.split(" ").collect::<Vec<&str>>()[1];
let obj = serde_json::json!({"stream_id": sid, "did":did});
stdout = obj.to_string();
stderr = "".to_string()
}
Result {
stdout: stdout,
stderr: stderr,
}
}
#[marine]
pub fn tile_show(stream_id: String) -> Result {
let args = vec!["tile:show".to_owned(), stream_id];
let res = glaze_request(args);
let mut stderr = String::from_utf8(res.stderr).unwrap();
let mut stdout = String::from_utf8(res.stdout).unwrap();
if stderr.contains("Loading stream") && stdout.chars().count() > 0 {
let s = stdout
.trim()
.replace("\u{1b}[32m", "")
.replace("\u{1b}[39m }", "")
.replace("\n", "");
let s: Vec<&str> = s.split(":").collect();
let k = s[0].trim().replace("{", "");
let v = s[1].trim().replace("}", "").replace("'", "");
let obj = serde_json::json!({ k: v }).to_string();
stdout = obj;
stderr = "".to_string();
}
Result {
stdout: stdout,
stderr: stderr,
}
}
#[marine]
pub fn tile_update(stream_id: String, payload: String, commit_id: String, sk: String) -> Result {
let mut args = vec![
"tile:update".to_owned(),
stream_id,
"--key".to_owned(),
sk,
"--content".to_owned(),
payload,
];
if commit_id.chars().count() > 0 {
args.push("--metadata".to_owned());
args.push(format!("{{\"schema\": {} }}", commit_id));
}
let res = glaze_request(args);
let mut stderr = String::from_utf8(res.stderr).unwrap();
let mut stdout = String::from_utf8(res.stdout).unwrap();
if stdout.contains("streamID") {
let s: Vec<&str> = stdout.split("content: ").collect();
let s = s[1]
.trim()
.replace("\u{1b}[32m", "")
.replace("\u{1b}[39m }", "")
.replace("\n", "");
let s: Vec<&str> = s.split(":").collect();
let k = s[0].trim().replace("{", "");
let v = s[1].trim().replace("}", "").replace("'", "");
let obj = serde_json::json!({ k: v }).to_string();
stdout = obj;
stderr = "".to_string();
}
Result {
stdout: stdout,
stderr: stderr,
}
}

View File

@ -0,0 +1,9 @@
mod ceramic_common;
mod glaze_adapter;
mod ceramic_config;
mod glaze_did;
mod glaze_model;
mod glaze_stream;
mod glaze_tile;
pub fn main() {}

View File

@ -0,0 +1,14 @@
[package]
name = "glaze_adapter"
version = "0.1.0"
edition = "2018"
[[bin]]
name = "glaze_adapter"
path = "src/main.rs"
[dependencies]
marine-rs-sdk = "0.7.1"
[dev-dependencies]
marine-rs-sdk-test = "0.9.1"

View File

@ -0,0 +1,11 @@
# yaml-language-server: $schema=../../../.fluence/schemas/module.yaml.json
# Defines [Marine Module](https://fluence.dev/docs/build/concepts/#modules). You can use `fluence module new` command to generate a template for new module
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/module.md
version: 0
type: rust
name: glaze_adapter
mountedBinaries:
glaze: /Users/bebo/.nvm/versions/node/v16.19.0/bin/glaze

View File

@ -0,0 +1,14 @@
use marine_rs_sdk::{marine, MountedBinaryResult};
pub fn main() {}
#[marine]
pub fn glaze_request(cmd: Vec<String>) -> MountedBinaryResult {
glaze(cmd)
}
#[marine]
#[link(wasm_import_module = "host")]
extern "C" {
pub fn glaze(cmd: Vec<String>) -> MountedBinaryResult;
}

View File

@ -0,0 +1,13 @@
# yaml-language-server: $schema=../.fluence/schemas/service.yaml.json
# Defines a [Marine service](https://fluence.dev/docs/build/concepts/#services), most importantly the modules that the service consists of. You can use `fluence service new` command to generate a template for new service
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/service.md
version: 0
name: glaze
modules:
facade:
get: modules/glaze
glaze_adapter:
get: modules/glaze_adapter