mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 14:40:17 +00:00
feat: Create structs with stream maps [fixes LNG-244] (#893)
This commit is contained in:
parent
b2ca1d35bf
commit
878990a837
@ -1,12 +1,26 @@
|
|||||||
service Console("run-console"):
|
aqua M
|
||||||
print(s: string)
|
|
||||||
|
|
||||||
func main():
|
export getObj
|
||||||
ss: *string
|
|
||||||
dd: *string
|
service OpNum("op"):
|
||||||
peerId = "peerId"
|
identity(n: u32) -> u32
|
||||||
relay = "relay"
|
|
||||||
parsec s <- ss on peerId via relay:
|
service OpStr("op"):
|
||||||
Console.print(s)
|
identity(n: string) -> string
|
||||||
for d <- dd par:
|
|
||||||
Console.print(d)
|
service OpArr("op"):
|
||||||
|
identity(arr: []string) -> []string
|
||||||
|
|
||||||
|
data InnerObj:
|
||||||
|
arr: []string
|
||||||
|
num: u32
|
||||||
|
|
||||||
|
data SomeObj:
|
||||||
|
str: string
|
||||||
|
num: u64
|
||||||
|
inner: InnerObj
|
||||||
|
|
||||||
|
func getObj() -> SomeObj:
|
||||||
|
b = SomeObj(str = OpStr.identity("some str"), num = 5, inner = InnerObj(arr = ["a", "b", "c"], num = 6))
|
||||||
|
c = b.copy(str = "new str", inner = b.inner.copy(num = 3))
|
||||||
|
<- c
|
||||||
|
@ -110,6 +110,8 @@ object Air {
|
|||||||
case class Call(triplet: Triplet, args: List[DataView], result: Option[String])
|
case class Call(triplet: Triplet, args: List[DataView], result: Option[String])
|
||||||
extends Air(Keyword.Call)
|
extends Air(Keyword.Call)
|
||||||
|
|
||||||
|
case class ApStreamMap(key: DataView, op: DataView, result: String) extends Air(Keyword.Ap)
|
||||||
|
|
||||||
case class Ap(op: DataView, result: String) extends Air(Keyword.Ap)
|
case class Ap(op: DataView, result: String) extends Air(Keyword.Ap)
|
||||||
|
|
||||||
case class Fail(op: DataView) extends Air(Keyword.Fail)
|
case class Fail(op: DataView) extends Air(Keyword.Fail)
|
||||||
@ -147,6 +149,7 @@ object Air {
|
|||||||
case Air.Call(triplet, args, res) ⇒
|
case Air.Call(triplet, args, res) ⇒
|
||||||
s" ${triplet.show} [${args.map(_.show).mkString(" ")}]${res.fold("")(" " + _)}"
|
s" ${triplet.show} [${args.map(_.show).mkString(" ")}]${res.fold("")(" " + _)}"
|
||||||
case Air.Ap(operand, result) ⇒ s" ${operand.show} $result"
|
case Air.Ap(operand, result) ⇒ s" ${operand.show} $result"
|
||||||
|
case Air.ApStreamMap(key, operand, result) ⇒ s" (${key.show} ${operand.show}) $result"
|
||||||
case Air.Fail(operand) => s" ${operand.show}"
|
case Air.Fail(operand) => s" ${operand.show}"
|
||||||
case Air.Canon(operand, peerId, result) ⇒ s" ${peerId.show} ${operand.show} $result"
|
case Air.Canon(operand, peerId, result) ⇒ s" ${peerId.show} ${operand.show} $result"
|
||||||
case Air.Comment(_, _) => ";; Should not be displayed"
|
case Air.Comment(_, _) => ";; Should not be displayed"
|
||||||
|
@ -3,7 +3,7 @@ package aqua.backend.air
|
|||||||
import aqua.model.*
|
import aqua.model.*
|
||||||
import aqua.raw.ops.Call
|
import aqua.raw.ops.Call
|
||||||
import aqua.res.*
|
import aqua.res.*
|
||||||
import aqua.types.{ArrayType, CanonStreamType, StreamType, Type}
|
import aqua.types.{ArrayType, CanonStreamType, StreamMapType, StreamType, Type}
|
||||||
import cats.Eval
|
import cats.Eval
|
||||||
import cats.data.Chain
|
import cats.data.Chain
|
||||||
import cats.free.Cofree
|
import cats.free.Cofree
|
||||||
@ -30,6 +30,7 @@ object AirGen extends Logging {
|
|||||||
(`type` match {
|
(`type` match {
|
||||||
case _: StreamType => "$" + name
|
case _: StreamType => "$" + name
|
||||||
case _: CanonStreamType => "#" + name
|
case _: CanonStreamType => "#" + name
|
||||||
|
case _: StreamMapType => "%" + name
|
||||||
case _ => name
|
case _ => name
|
||||||
}).replace('.', '_')
|
}).replace('.', '_')
|
||||||
|
|
||||||
@ -54,10 +55,8 @@ object AirGen extends Logging {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def exportToString(exportTo: CallModel.Export): String = (exportTo match {
|
def exportToString(exportTo: CallModel.Export): String = (exportTo match {
|
||||||
case CallModel.Export(name, _: StreamType) => "$" + name
|
case CallModel.Export(name, t) => varNameToString(name, t)
|
||||||
case CallModel.Export(name, _: CanonStreamType) => "#" + name
|
})
|
||||||
case CallModel.Export(name, _) => name
|
|
||||||
}).replace('.', '_')
|
|
||||||
|
|
||||||
private def folder(op: ResolvedOp, ops: Chain[AirGen]): Eval[AirGen] =
|
private def folder(op: ResolvedOp, ops: Chain[AirGen]): Eval[AirGen] =
|
||||||
op match {
|
op match {
|
||||||
@ -113,6 +112,10 @@ object AirGen extends Logging {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
case ApStreamMapRes(key, value, exportTo) =>
|
||||||
|
Eval.later(
|
||||||
|
ApStreamMapGen(valueToData(key), valueToData(value), exportToString(exportTo))
|
||||||
|
)
|
||||||
case ApRes(operand, exportTo) =>
|
case ApRes(operand, exportTo) =>
|
||||||
Eval.later(
|
Eval.later(
|
||||||
ApGen(valueToData(operand), exportToString(exportTo))
|
ApGen(valueToData(operand), exportToString(exportTo))
|
||||||
@ -163,6 +166,12 @@ case class CommentGen(comment: String, op: AirGen) extends AirGen {
|
|||||||
Air.Comment(comment, op.generate)
|
Air.Comment(comment, op.generate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case class ApStreamMapGen(key: DataView, operand: DataView, result: String) extends AirGen {
|
||||||
|
|
||||||
|
override def generate: Air =
|
||||||
|
Air.ApStreamMap(key, operand, result)
|
||||||
|
}
|
||||||
|
|
||||||
case class ApGen(operand: DataView, result: String) extends AirGen {
|
case class ApGen(operand: DataView, result: String) extends AirGen {
|
||||||
|
|
||||||
override def generate: Air =
|
override def generate: Air =
|
||||||
|
@ -56,7 +56,9 @@ object TypeScriptCommon {
|
|||||||
case BottomType => "nothing"
|
case BottomType => "nothing"
|
||||||
|
|
||||||
// impossible. Made to avoid compilation warning
|
// impossible. Made to avoid compilation warning
|
||||||
case t: CanonStreamType => "any"
|
case _: CanonStreamType => "any"
|
||||||
|
case _: StreamMapType => "any"
|
||||||
|
case _: ServiceType => "any"
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: handle cases if there is already peer_ or config_ variable defined
|
// TODO: handle cases if there is already peer_ or config_ variable defined
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
aqua StructCreation declares getObj, getObjRelay, getObjAssign
|
aqua StructCreation declares getObj, getObjRelay, getObjAssign
|
||||||
|
|
||||||
export getObj, getObjRelay, getObjAssign
|
export getObj, getObjRelay, getObjAssign, getObjFor
|
||||||
|
|
||||||
import "@fluencelabs/aqua-lib/builtin.aqua"
|
import "@fluencelabs/aqua-lib/builtin.aqua"
|
||||||
|
|
||||||
@ -37,4 +37,26 @@ func getObjAssign() -> SomeObj, SomeObj, u32:
|
|||||||
inner = InnerObj(arr = ["d", "e", "f"], num = 7)
|
inner = InnerObj(arr = ["d", "e", "f"], num = 7)
|
||||||
)
|
)
|
||||||
copiedObj = obj.copy(str = "some str", inner = obj.inner.copy(arr = ["a", "b", "c"])).copy(num = 6)
|
copiedObj = obj.copy(str = "some str", inner = obj.inner.copy(arr = ["a", "b", "c"])).copy(num = 6)
|
||||||
<- obj, copiedObj, copiedObj.inner.copy(arr = ["g"]).arr.length
|
<- obj, copiedObj, copiedObj.inner.copy(arr = ["g"]).arr.length
|
||||||
|
|
||||||
|
func getObjFor() -> []SomeObj:
|
||||||
|
all: *SomeObj
|
||||||
|
|
||||||
|
arr = [
|
||||||
|
SomeObj(str = "first", num = OpNum.identity(1), inner = InnerObj(arr = ["1", "1", "1"], num = 11)),
|
||||||
|
SomeObj(str = "second", num = OpNum.identity(2), inner = InnerObj(arr = ["2", "2", "2"], num = 22)),
|
||||||
|
SomeObj(str = "third", num = OpNum.identity(3), inner = InnerObj(arr = ["3", "3", "3"], num = 33))
|
||||||
|
]
|
||||||
|
|
||||||
|
for obj <- arr:
|
||||||
|
copied = obj.copy(str = Op.concat_strings(obj.str, " copied"), inner = obj.inner.copy(arr = ["copy"]))
|
||||||
|
all <<- copied
|
||||||
|
|
||||||
|
arri = [1, 2, 3]
|
||||||
|
for i <- arri:
|
||||||
|
obj = SomeObj(str = "for", num = OpNum.identity(i), inner = InnerObj(arr = [], num = i))
|
||||||
|
all <<- obj
|
||||||
|
|
||||||
|
<- all
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
"compile-aqua": "ts-node ./src/compile.ts",
|
"compile-aqua": "ts-node ./src/compile.ts",
|
||||||
"compile-aqua:air": "aqua -i ./aqua/ -o ./compiled-air -a",
|
"compile-aqua:air": "aqua -i ./aqua/ -o ./compiled-air -a",
|
||||||
"prettify-compiled": "prettier --write src/compiled",
|
"prettify-compiled": "prettier --write src/compiled",
|
||||||
|
"prettify": "prettier --write src",
|
||||||
"aqua": "aqua",
|
"aqua": "aqua",
|
||||||
"do": "aqua dist deploy --addr /dns4/kras-04.fluence.dev/tcp/19001/wss/p2p/12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi --config-path deploy.json --service tsOracle"
|
"do": "aqua dist deploy --addr /dns4/kras-04.fluence.dev/tcp/19001/wss/p2p/12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi --config-path deploy.json --service tsOracle"
|
||||||
},
|
},
|
||||||
@ -33,6 +34,7 @@
|
|||||||
"@fluencelabs/aqua-api": "0.12.2",
|
"@fluencelabs/aqua-api": "0.12.2",
|
||||||
"@fluencelabs/aqua-dht": "0.2.5",
|
"@fluencelabs/aqua-dht": "0.2.5",
|
||||||
"@fluencelabs/aqua-lib": "0.7.3",
|
"@fluencelabs/aqua-lib": "0.7.3",
|
||||||
|
"prettier": "3.0.3",
|
||||||
"@types/jest": "29.5.2",
|
"@types/jest": "29.5.2",
|
||||||
"@types/node": "18.11.18",
|
"@types/node": "18.11.18",
|
||||||
"jest": "29.5.0",
|
"jest": "29.5.0",
|
||||||
|
@ -3,6 +3,7 @@ import {
|
|||||||
getObjAssignCall,
|
getObjAssignCall,
|
||||||
getObjCall,
|
getObjCall,
|
||||||
getObjRelayCall,
|
getObjRelayCall,
|
||||||
|
getObjForCall,
|
||||||
} from "../examples/objectCall.js";
|
} from "../examples/objectCall.js";
|
||||||
import {
|
import {
|
||||||
callArrowCall,
|
callArrowCall,
|
||||||
@ -358,6 +359,61 @@ describe("Testing examples", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("object creation in 'for' instruction getObjFor", async () => {
|
||||||
|
const result = await getObjForCall();
|
||||||
|
const res = [
|
||||||
|
{
|
||||||
|
str: "first copied",
|
||||||
|
num: 1,
|
||||||
|
inner: {
|
||||||
|
arr: ["copy"],
|
||||||
|
num: 11,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
str: "second copied",
|
||||||
|
num: 2,
|
||||||
|
inner: {
|
||||||
|
arr: ["copy"],
|
||||||
|
num: 22,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
str: "third copied",
|
||||||
|
num: 3,
|
||||||
|
inner: {
|
||||||
|
arr: ["copy"],
|
||||||
|
num: 33,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
str: "for",
|
||||||
|
num: 1,
|
||||||
|
inner: {
|
||||||
|
arr: [],
|
||||||
|
num: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
str: "for",
|
||||||
|
num: 2,
|
||||||
|
inner: {
|
||||||
|
arr: [],
|
||||||
|
num: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
str: "for",
|
||||||
|
num: 3,
|
||||||
|
inner: {
|
||||||
|
arr: [],
|
||||||
|
num: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
expect(result).toEqual(res);
|
||||||
|
});
|
||||||
|
|
||||||
it("object creation getObjAssign", async () => {
|
it("object creation getObjAssign", async () => {
|
||||||
let result = await getObjAssignCall();
|
let result = await getObjAssignCall();
|
||||||
expect(result).toEqual([
|
expect(result).toEqual([
|
||||||
|
@ -1,51 +1,73 @@
|
|||||||
import { krasnodar, stage, testNet } from '@fluencelabs/fluence-network-environment';
|
import {
|
||||||
import { local } from './local-nodes.js';
|
krasnodar,
|
||||||
|
stage,
|
||||||
|
testNet,
|
||||||
|
} from "@fluencelabs/fluence-network-environment";
|
||||||
|
import { local } from "./local-nodes.js";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace NodeJS {
|
namespace NodeJS {
|
||||||
interface ProcessEnv {
|
interface ProcessEnv {
|
||||||
FLUENCE_ENV?: string;
|
FLUENCE_ENV?: string;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setConfig(env) {
|
function setConfig(env) {
|
||||||
switch (env) {
|
switch (env) {
|
||||||
case 'krasnodar':
|
case "krasnodar":
|
||||||
return { config: krasnodarConfig, isEphemeral: false };
|
return { config: krasnodarConfig, isEphemeral: false };
|
||||||
case 'testnet':
|
case "testnet":
|
||||||
return { config: testNetConfig, isEphemeral: false };
|
return { config: testNetConfig, isEphemeral: false };
|
||||||
case 'ephemeral':
|
case "ephemeral":
|
||||||
return { config: null, isEphemeral: true };
|
return { config: null, isEphemeral: true };
|
||||||
case 'local':
|
case "local":
|
||||||
return { config: localConfig, isEphemeral: false };
|
return { config: localConfig, isEphemeral: false };
|
||||||
default:
|
default:
|
||||||
return { config: stageConfig, isEphemeral: false };
|
return { config: stageConfig, isEphemeral: false };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const krasnodarConfig = {
|
export const krasnodarConfig = {
|
||||||
relays: krasnodar,
|
relays: krasnodar,
|
||||||
externalAddressesRelay1: ['/ip4/164.90.171.139/tcp/7770', '/ip4/164.90.171.139/tcp/9990/ws'],
|
externalAddressesRelay1: [
|
||||||
externalAddressesRelay2: ['/ip4/164.90.164.229/tcp/7001', '/ip4/164.90.164.229/tcp/9001/ws'],
|
"/ip4/164.90.171.139/tcp/7770",
|
||||||
tryCatchError:
|
"/ip4/164.90.171.139/tcp/9990/ws",
|
||||||
"Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
|
],
|
||||||
|
externalAddressesRelay2: [
|
||||||
|
"/ip4/164.90.164.229/tcp/7001",
|
||||||
|
"/ip4/164.90.164.229/tcp/9001/ws",
|
||||||
|
],
|
||||||
|
tryCatchError:
|
||||||
|
"Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const stageConfig = {
|
export const stageConfig = {
|
||||||
relays: stage,
|
relays: stage,
|
||||||
externalAddressesRelay1: ['/ip4/134.209.186.43/tcp/7001', '/ip4/134.209.186.43/tcp/9001/ws'],
|
externalAddressesRelay1: [
|
||||||
externalAddressesRelay2: ['/ip4/134.209.186.43/tcp/7770', '/ip4/134.209.186.43/tcp/9990/ws'],
|
"/ip4/134.209.186.43/tcp/7001",
|
||||||
tryCatchError:
|
"/ip4/134.209.186.43/tcp/9001/ws",
|
||||||
"Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
|
],
|
||||||
|
externalAddressesRelay2: [
|
||||||
|
"/ip4/134.209.186.43/tcp/7770",
|
||||||
|
"/ip4/134.209.186.43/tcp/9990/ws",
|
||||||
|
],
|
||||||
|
tryCatchError:
|
||||||
|
"Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const testNetConfig = {
|
export const testNetConfig = {
|
||||||
relays: testNet,
|
relays: testNet,
|
||||||
externalAddressesRelay1: ['/ip4/165.227.164.206/tcp/7001', '/ip4/165.227.164.206/tcp/9001/ws'],
|
externalAddressesRelay1: [
|
||||||
externalAddressesRelay2: ['/ip4/142.93.169.49/tcp/7001', '/ip4/142.93.169.49/tcp/9001/ws'],
|
"/ip4/165.227.164.206/tcp/7001",
|
||||||
tryCatchError:
|
"/ip4/165.227.164.206/tcp/9001/ws",
|
||||||
"Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
|
],
|
||||||
|
externalAddressesRelay2: [
|
||||||
|
"/ip4/142.93.169.49/tcp/7001",
|
||||||
|
"/ip4/142.93.169.49/tcp/9001/ws",
|
||||||
|
],
|
||||||
|
tryCatchError:
|
||||||
|
"Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
|
||||||
};
|
};
|
||||||
|
|
||||||
// export const ephemeralConfig = {
|
// export const ephemeralConfig = {
|
||||||
@ -60,21 +82,21 @@ export const testNetConfig = {
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
export const localConfig = {
|
export const localConfig = {
|
||||||
relays: local,
|
relays: local,
|
||||||
externalAddressesRelay1: [
|
externalAddressesRelay1: [
|
||||||
'/ip4/10.50.10.10/tcp/7771',
|
"/ip4/10.50.10.10/tcp/7771",
|
||||||
'/ip4/10.50.10.10/tcp/9991/ws',
|
"/ip4/10.50.10.10/tcp/9991/ws",
|
||||||
'/dns4/nox-1/tcp/7771',
|
"/dns4/nox-1/tcp/7771",
|
||||||
'/dns4/nox-1/tcp/9991/ws',
|
"/dns4/nox-1/tcp/9991/ws",
|
||||||
],
|
],
|
||||||
externalAddressesRelay2: [
|
externalAddressesRelay2: [
|
||||||
'/ip4/10.50.10.60/tcp/7776',
|
"/ip4/10.50.10.60/tcp/7776",
|
||||||
'/ip4/10.50.10.60/tcp/9996/ws',
|
"/ip4/10.50.10.60/tcp/9996/ws",
|
||||||
'/dns4/nox-6/tcp/7776',
|
"/dns4/nox-6/tcp/7776",
|
||||||
'/dns4/nox-6/tcp/9996/ws',
|
"/dns4/nox-6/tcp/9996/ws",
|
||||||
],
|
],
|
||||||
tryCatchError:
|
tryCatchError:
|
||||||
"Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
|
"Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const { config, isEphemeral } = setConfig('local');
|
export const { config, isEphemeral } = setConfig("local");
|
||||||
|
@ -1,19 +1,24 @@
|
|||||||
import {handleAb, registerSomeService, bug214, checkAbCalls} from "../compiled/examples/abilities";
|
import {
|
||||||
|
handleAb,
|
||||||
|
registerSomeService,
|
||||||
|
bug214,
|
||||||
|
checkAbCalls,
|
||||||
|
} from "../compiled/examples/abilities";
|
||||||
|
|
||||||
export async function abilityCall(): Promise<[string, string, string, number]> {
|
export async function abilityCall(): Promise<[string, string, string, number]> {
|
||||||
registerSomeService({
|
registerSomeService({
|
||||||
getStr: (s: string) => {
|
getStr: (s: string) => {
|
||||||
return s + "123"
|
return s + "123";
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
return await handleAb("some_string")
|
return await handleAb("some_string");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function complexAbilityCall(): Promise<[boolean, boolean]> {
|
export async function complexAbilityCall(): Promise<[boolean, boolean]> {
|
||||||
return await bug214()
|
return await bug214();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkAbCallsCall(): Promise<[boolean, boolean]> {
|
export async function checkAbCallsCall(): Promise<[boolean, boolean]> {
|
||||||
return await checkAbCalls()
|
return await checkAbCalls();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { doSmth } from '../compiled/examples/assignment.js';
|
import { doSmth } from "../compiled/examples/assignment.js";
|
||||||
|
|
||||||
export async function assignmentCall(): Promise<string[]> {
|
export async function assignmentCall(): Promise<string[]> {
|
||||||
return await doSmth({ value: 'abc' }, { ttl: 6000 });
|
return await doSmth({ value: "abc" }, { ttl: 6000 });
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,28 @@
|
|||||||
import { main, compareStreams, compareStructs, registerEffector } from '../compiled/examples/boolAlgebra.js';
|
import {
|
||||||
|
main,
|
||||||
|
compareStreams,
|
||||||
|
compareStructs,
|
||||||
|
registerEffector,
|
||||||
|
} from "../compiled/examples/boolAlgebra.js";
|
||||||
|
|
||||||
export async function boolAlgebraCall(relay: string): Promise<boolean[]> {
|
export async function boolAlgebraCall(relay: string): Promise<boolean[]> {
|
||||||
registerEffector({
|
registerEffector({
|
||||||
effect(name, _) {
|
effect(name, _) {
|
||||||
if (name == 'true') return Promise.resolve(true);
|
if (name == "true") return Promise.resolve(true);
|
||||||
else return Promise.reject(`unknown effect: ${name}`);
|
else return Promise.reject(`unknown effect: ${name}`);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await main(relay);
|
return await main(relay);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function compareStreamsCall(relay: string): Promise<boolean> {
|
export async function compareStreamsCall(relay: string): Promise<boolean> {
|
||||||
return await compareStreams(relay);
|
return await compareStreams(relay);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function compareStructsCall(relay: string, str: string): Promise<boolean> {
|
export async function compareStructsCall(
|
||||||
return await compareStructs(relay, str);
|
relay: string,
|
||||||
|
str: string,
|
||||||
|
): Promise<boolean> {
|
||||||
|
return await compareStructs(relay, str);
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,28 @@
|
|||||||
import {passFunctionAsArg, reproArgsBug426} from '../compiled/examples/callArrow.js';
|
import {
|
||||||
|
passFunctionAsArg,
|
||||||
|
reproArgsBug426,
|
||||||
|
} from "../compiled/examples/callArrow.js";
|
||||||
|
|
||||||
export async function callArrowCall(relayPeerId: string): Promise<string> {
|
export async function callArrowCall(relayPeerId: string): Promise<string> {
|
||||||
return new Promise<string>((resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
passFunctionAsArg(relayPeerId, 'callArrow call', (a: string) => {
|
passFunctionAsArg(
|
||||||
let result = 'Hello, ' + a + '!';
|
relayPeerId,
|
||||||
console.log(result)
|
"callArrow call",
|
||||||
resolve(result);
|
(a: string) => {
|
||||||
return result;
|
let result = "Hello, " + a + "!";
|
||||||
}, {ttl: 10000});
|
console.log(result);
|
||||||
});
|
resolve(result);
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
{ ttl: 10000 },
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function reproArgsBug426Call(): Promise<string> {
|
export async function reproArgsBug426Call(): Promise<string> {
|
||||||
return new Promise<string>((resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
reproArgsBug426((a: string) => {
|
reproArgsBug426((a: string) => {
|
||||||
resolve(a);
|
resolve(a);
|
||||||
}, "privet");
|
}, "privet");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
import {bugLng79, registerSer} from "../compiled/examples/canon.js";
|
import { bugLng79, registerSer } from "../compiled/examples/canon.js";
|
||||||
|
|
||||||
export async function bugLng79Call(pid: string, relay: string): Promise<number> {
|
export async function bugLng79Call(
|
||||||
registerSer({
|
pid: string,
|
||||||
getRecord: () => {
|
relay: string,
|
||||||
return {peer_id: pid, relay_id: [relay]};
|
): Promise<number> {
|
||||||
}
|
registerSer({
|
||||||
})
|
getRecord: () => {
|
||||||
return await bugLng79((s) => {
|
return { peer_id: pid, relay_id: [relay] };
|
||||||
console.log(s)
|
},
|
||||||
});
|
});
|
||||||
|
return await bugLng79((s) => {
|
||||||
|
console.log(s);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import {
|
import { lng193Bug } from "../compiled/examples/closureReturnRename.js";
|
||||||
lng193Bug
|
import { config } from "../config.js";
|
||||||
} from '../compiled/examples/closureReturnRename.js';
|
|
||||||
import { config } from '../config.js'
|
|
||||||
|
|
||||||
const relays = config.relays
|
const relays = config.relays;
|
||||||
|
|
||||||
export async function lng193BugCall(): Promise<number> {
|
export async function lng193BugCall(): Promise<number> {
|
||||||
return lng193Bug(relays[4].peerId, relays[5].peerId)
|
return lng193Bug(relays[4].peerId, relays[5].peerId);
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,34 @@
|
|||||||
import {
|
import {
|
||||||
closureIn,
|
closureIn,
|
||||||
closureOut,
|
closureOut,
|
||||||
closureBig,
|
closureBig,
|
||||||
registerLocalSrv,
|
registerLocalSrv,
|
||||||
closureOut2,
|
closureOut2,
|
||||||
lng58Bug
|
lng58Bug,
|
||||||
} from '../compiled/examples/closures.js';
|
} from "../compiled/examples/closures.js";
|
||||||
import { config } from '../config.js'
|
import { config } from "../config.js";
|
||||||
|
|
||||||
const relays = config.relays
|
const relays = config.relays;
|
||||||
|
|
||||||
export async function closuresCall(): Promise<[string, string[], string[], [string, string]]> {
|
export async function closuresCall(): Promise<
|
||||||
|
[string, string[], string[], [string, string]]
|
||||||
|
> {
|
||||||
|
registerLocalSrv({ inside: () => console.log("call inside") });
|
||||||
|
|
||||||
registerLocalSrv({inside: () => console.log("call inside")})
|
console.log("closurein");
|
||||||
|
const resIn = await closureIn(relays[4].peerId, { ttl: 25000 });
|
||||||
|
console.log("closureout");
|
||||||
|
const resOut = await closureOut(relays[5].peerId, { ttl: 25000 });
|
||||||
|
console.log("closureout2");
|
||||||
|
const resOut2 = await closureOut2(relays[5].peerId, { ttl: 25000 });
|
||||||
|
console.log("closurebig");
|
||||||
|
const resBig = await closureBig(relays[4].peerId, relays[5].peerId, {
|
||||||
|
ttl: 25000,
|
||||||
|
});
|
||||||
|
|
||||||
console.log("closurein")
|
return [resIn, resOut.external_addresses, resOut2.external_addresses, resBig];
|
||||||
const resIn = await closureIn(relays[4].peerId, {ttl: 25000})
|
|
||||||
console.log("closureout")
|
|
||||||
const resOut = await closureOut(relays[5].peerId, {ttl: 25000})
|
|
||||||
console.log("closureout2")
|
|
||||||
const resOut2 = await closureOut2(relays[5].peerId, {ttl: 25000})
|
|
||||||
console.log("closurebig")
|
|
||||||
const resBig = await closureBig(relays[4].peerId, relays[5].peerId, {ttl: 25000})
|
|
||||||
|
|
||||||
return [resIn, resOut.external_addresses, resOut2.external_addresses, resBig]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function lng58CBugCall(): Promise<string> {
|
export async function lng58CBugCall(): Promise<string> {
|
||||||
return lng58Bug()
|
return lng58Bug();
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
import { parFunc } from '../compiled/examples/par.js';
|
import { parFunc } from "../compiled/examples/par.js";
|
||||||
import { registerCoService } from '../compiled/examples/co.js';
|
import { registerCoService } from "../compiled/examples/co.js";
|
||||||
import {relay1} from "../__test__/examples.spec.js";
|
import { relay1 } from "../__test__/examples.spec.js";
|
||||||
|
|
||||||
export async function coCall(): Promise<string[]> {
|
export async function coCall(): Promise<string[]> {
|
||||||
registerCoService({
|
registerCoService({
|
||||||
call: () => {
|
call: () => {
|
||||||
return 'hello';
|
return "hello";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Promise<string[]>((resolve, reject) => {
|
return new Promise<string[]>((resolve, reject) => {
|
||||||
parFunc(relay1.peerId, (c) => {
|
parFunc(
|
||||||
resolve(c.external_addresses);
|
relay1.peerId,
|
||||||
}, {ttl: 60000});
|
(c) => {
|
||||||
});
|
resolve(c.external_addresses);
|
||||||
|
},
|
||||||
|
{ ttl: 60000 },
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,32 @@
|
|||||||
import {
|
import {
|
||||||
arraySugar,
|
arraySugar,
|
||||||
bugLNG59,
|
bugLNG59,
|
||||||
optionSugar,
|
optionSugar,
|
||||||
registerGetArr,
|
registerGetArr,
|
||||||
streamSugar
|
streamSugar,
|
||||||
} from "../compiled/examples/collectionSugar.js";
|
} from "../compiled/examples/collectionSugar.js";
|
||||||
|
|
||||||
export async function arraySugarCall(): Promise<[number[], number[]]> {
|
export async function arraySugarCall(): Promise<[number[], number[]]> {
|
||||||
return await arraySugar(3, 6)
|
return await arraySugar(3, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function streamSugarCall(): Promise<[number[], number[]]> {
|
export async function streamSugarCall(): Promise<[number[], number[]]> {
|
||||||
return await streamSugar(3, 6)
|
return await streamSugar(3, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function optionSugarCall(): Promise<[number[], string[], string[]]> {
|
export async function optionSugarCall(): Promise<
|
||||||
return await optionSugar(1, "some", null, null)
|
[number[], string[], string[]]
|
||||||
|
> {
|
||||||
|
return await optionSugar(1, "some", null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function bugLNG59Call(nodes: string[]): Promise<string> {
|
export async function bugLNG59Call(nodes: string[]): Promise<string> {
|
||||||
|
registerGetArr({
|
||||||
|
getArr: () => {
|
||||||
|
return nodes;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
registerGetArr({
|
const a = await bugLNG59();
|
||||||
getArr: () => {
|
return a;
|
||||||
return nodes
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const a = await bugLNG59()
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
|
@ -1,15 +1,22 @@
|
|||||||
import { doStuff, registerTestS } from '../compiled/examples/complex.js';
|
import { doStuff, registerTestS } from "../compiled/examples/complex.js";
|
||||||
|
|
||||||
export async function complexCall(selfPeerId: string, relayPeerId: string) {
|
export async function complexCall(selfPeerId: string, relayPeerId: string) {
|
||||||
|
registerTestS({
|
||||||
|
t: (arg0) => {
|
||||||
|
return arg0;
|
||||||
|
},
|
||||||
|
multiline: (a, b, c) => {
|
||||||
|
return b;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
registerTestS({
|
return await doStuff(
|
||||||
t: (arg0) => {
|
relayPeerId,
|
||||||
return arg0;
|
selfPeerId,
|
||||||
},
|
true,
|
||||||
multiline: (a, b, c) => {
|
true,
|
||||||
return b;
|
["1", "2"],
|
||||||
},
|
["3", "4"],
|
||||||
});
|
"some str",
|
||||||
|
);
|
||||||
return await doStuff(relayPeerId, selfPeerId, true, true, ['1', '2'], ['3', '4'], 'some str');
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,21 @@
|
|||||||
import {callConstant, registerGetter, timestampAndTtl} from '../compiled/examples/constants.js';
|
import {
|
||||||
|
callConstant,
|
||||||
|
registerGetter,
|
||||||
|
timestampAndTtl,
|
||||||
|
} from "../compiled/examples/constants.js";
|
||||||
|
|
||||||
export async function constantsCall(): Promise<string[]> {
|
export async function constantsCall(): Promise<string[]> {
|
||||||
registerGetter({
|
registerGetter({
|
||||||
createStr: (arg0) => {
|
createStr: (arg0) => {
|
||||||
return '' + arg0;
|
return "" + arg0;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await callConstant();
|
return await callConstant();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function particleTtlAndTimestampCall(ttl: number): Promise<[number, number]> {
|
export async function particleTtlAndTimestampCall(
|
||||||
|
ttl: number,
|
||||||
return await timestampAndTtl({ttl: ttl});
|
): Promise<[number, number]> {
|
||||||
|
return await timestampAndTtl({ ttl: ttl });
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
import { getAliasedData, registerNodeIdGetter } from '../compiled/examples/dataAlias.js';
|
import {
|
||||||
|
getAliasedData,
|
||||||
|
registerNodeIdGetter,
|
||||||
|
} from "../compiled/examples/dataAlias.js";
|
||||||
|
|
||||||
export async function dataAliasCall() {
|
export async function dataAliasCall() {
|
||||||
registerNodeIdGetter({
|
registerNodeIdGetter({
|
||||||
get: () => {
|
get: () => {
|
||||||
return {
|
return {
|
||||||
peerId: 'peer id str',
|
peerId: "peer id str",
|
||||||
name: 'name str',
|
name: "name str",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await getAliasedData();
|
return await getAliasedData();
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,26 @@
|
|||||||
import { concat_foobars, registerStringService } from '../compiled/examples/imports_exports/imports.js';
|
import {
|
||||||
import { registerMyExportSrv } from '../compiled/examples/imports_exports/exports.js';
|
concat_foobars,
|
||||||
import { registerSuperFoo } from '../compiled/examples/imports_exports/declare.js';
|
registerStringService,
|
||||||
|
} from "../compiled/examples/imports_exports/imports.js";
|
||||||
|
import { registerMyExportSrv } from "../compiled/examples/imports_exports/exports.js";
|
||||||
|
import { registerSuperFoo } from "../compiled/examples/imports_exports/declare.js";
|
||||||
|
|
||||||
export async function declareCall() {
|
export async function declareCall() {
|
||||||
registerSuperFoo({
|
registerSuperFoo({
|
||||||
small_foo: () => {
|
small_foo: () => {
|
||||||
return 'small_foo';
|
return "small_foo";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
registerStringService({
|
registerStringService({
|
||||||
concat: (a, b) => {
|
concat: (a, b) => {
|
||||||
return a + b;
|
return a + b;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
registerMyExportSrv({
|
registerMyExportSrv({
|
||||||
another_str: () => {
|
another_str: () => {
|
||||||
return 'str_from_my_export_srv';
|
return "str_from_my_export_srv";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return await concat_foobars();
|
return await concat_foobars();
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,27 @@
|
|||||||
import {forBug499, iterateAndPrint, iterateAndPrintParallel} from '../compiled/examples/fold.js';
|
import {
|
||||||
|
forBug499,
|
||||||
|
iterateAndPrint,
|
||||||
|
iterateAndPrintParallel,
|
||||||
|
} from "../compiled/examples/fold.js";
|
||||||
|
|
||||||
export async function foldCall(relayPeerId: string) {
|
export async function foldCall(relayPeerId: string) {
|
||||||
await iterateAndPrint([relayPeerId], {ttl: 10000});
|
await iterateAndPrint([relayPeerId], { ttl: 10000 });
|
||||||
|
|
||||||
return new Promise<string[]>((resolve, reject) => {
|
return new Promise<string[]>((resolve, reject) => {
|
||||||
iterateAndPrintParallel([relayPeerId], (c) => {
|
iterateAndPrintParallel(
|
||||||
console.log('iterateAndPrintParallel. external addresses: ' + c.external_addresses);
|
[relayPeerId],
|
||||||
resolve(c.external_addresses);
|
(c) => {
|
||||||
}, {ttl: 10000});
|
console.log(
|
||||||
});
|
"iterateAndPrintParallel. external addresses: " +
|
||||||
|
c.external_addresses,
|
||||||
|
);
|
||||||
|
resolve(c.external_addresses);
|
||||||
|
},
|
||||||
|
{ ttl: 10000 },
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function foldBug499Call(): Promise<number[]> {
|
export async function foldBug499Call(): Promise<number[]> {
|
||||||
return forBug499()
|
return forBug499();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { getTwoResults } from '../compiled/examples/foldJoin.js';
|
import { getTwoResults } from "../compiled/examples/foldJoin.js";
|
||||||
|
|
||||||
export async function foldJoinCall(relayPeerId: string): Promise<number[]> {
|
export async function foldJoinCall(relayPeerId: string): Promise<number[]> {
|
||||||
return await getTwoResults(relayPeerId, {ttl: 16000});
|
return await getTwoResults(relayPeerId, { ttl: 16000 });
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { testFunc, registerTestSrv } from '../compiled/examples/func.js';
|
import { testFunc, registerTestSrv } from "../compiled/examples/func.js";
|
||||||
|
|
||||||
export async function funcCall() {
|
export async function funcCall() {
|
||||||
registerTestSrv({
|
registerTestSrv({
|
||||||
str: () => {
|
str: () => {
|
||||||
return `some str`;
|
return `some str`;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await testFunc();
|
return await testFunc();
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,31 @@
|
|||||||
import {main, registerA, calc, calc2, ifCalc} from '../compiled/examples/funcs.js';
|
import {
|
||||||
|
main,
|
||||||
|
registerA,
|
||||||
|
calc,
|
||||||
|
calc2,
|
||||||
|
ifCalc,
|
||||||
|
} from "../compiled/examples/funcs.js";
|
||||||
|
|
||||||
export async function funcsCall() {
|
export async function funcsCall() {
|
||||||
|
registerA({
|
||||||
|
getJ: (n) => {
|
||||||
|
return n;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
registerA({
|
let res1 = await main((c, arr) => {
|
||||||
getJ: (n) => {
|
console.log(c + ": " + arr);
|
||||||
return n
|
});
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
let res1 = await main((c, arr) => {
|
let res2 = await calc((c, arr) => {
|
||||||
console.log(c + ": " + arr)
|
console.log(c + ": " + arr);
|
||||||
})
|
});
|
||||||
|
|
||||||
let res2 = await calc((c, arr) => {
|
let res3 = await calc2((c, arr) => {
|
||||||
console.log(c + ": " + arr)
|
console.log(c + ": " + arr);
|
||||||
})
|
});
|
||||||
|
|
||||||
let res3 = await calc2((c, arr) => {
|
let res4 = await ifCalc();
|
||||||
console.log(c + ": " + arr)
|
|
||||||
})
|
|
||||||
|
|
||||||
let res4 = await ifCalc()
|
return [res1, res2, res3, res4];
|
||||||
|
}
|
||||||
return [res1, res2, res3, res4]
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {lng119Bug} from "../compiled/examples/functors.js";
|
import { lng119Bug } from "../compiled/examples/functors.js";
|
||||||
|
|
||||||
export async function bugLng119Call(): Promise<number[]> {
|
export async function bugLng119Call(): Promise<number[]> {
|
||||||
return lng119Bug();
|
return lng119Bug();
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
import { helloWorld, registerStringExtra } from '../compiled/examples/helloWorld.js';
|
import {
|
||||||
|
helloWorld,
|
||||||
|
registerStringExtra,
|
||||||
|
} from "../compiled/examples/helloWorld.js";
|
||||||
|
|
||||||
export async function helloWorldCall() {
|
export async function helloWorldCall() {
|
||||||
// helloWorld.aqua
|
// helloWorld.aqua
|
||||||
registerStringExtra({
|
registerStringExtra({
|
||||||
addNameToHello: (args0) => {
|
addNameToHello: (args0) => {
|
||||||
return `Hello, ${args0}!`;
|
return `Hello, ${args0}!`;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await helloWorld('NAME');
|
return await helloWorld("NAME");
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,22 @@
|
|||||||
import {bugLNG69, ifCorrectXorWrap, ifElseCall, ifElseNumCall} from '../compiled/examples/if.js';
|
import {
|
||||||
|
bugLNG69,
|
||||||
|
ifCorrectXorWrap,
|
||||||
|
ifElseCall,
|
||||||
|
ifElseNumCall,
|
||||||
|
} from "../compiled/examples/if.js";
|
||||||
|
|
||||||
export async function ifCall() {
|
export async function ifCall() {
|
||||||
await ifElseCall(false);
|
await ifElseCall(false);
|
||||||
await ifElseCall(true);
|
await ifElseCall(true);
|
||||||
|
|
||||||
await ifElseNumCall(1);
|
await ifElseNumCall(1);
|
||||||
await ifElseNumCall(5);
|
await ifElseNumCall(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function ifWrapCall(node: string) {
|
export async function ifWrapCall(node: string) {
|
||||||
return ifCorrectXorWrap(node)
|
return ifCorrectXorWrap(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function bugNG69Call(node: string): Promise<boolean> {
|
export async function bugNG69Call(node: string): Promise<boolean> {
|
||||||
return bugLNG69(node)
|
return bugLNG69(node);
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
import { registerOneMore } from '../compiled/examples/imports_exports/gen/OneMore.js';
|
import { registerOneMore } from "../compiled/examples/imports_exports/gen/OneMore.js";
|
||||||
import { barfoo, wrap } from '../compiled/examples/imports_exports/import2.js';
|
import { barfoo, wrap } from "../compiled/examples/imports_exports/import2.js";
|
||||||
|
|
||||||
export async function import2Call() {
|
export async function import2Call() {
|
||||||
registerOneMore('hello', {
|
registerOneMore("hello", {
|
||||||
more_call: () => {
|
more_call: () => {},
|
||||||
},
|
});
|
||||||
});
|
|
||||||
|
|
||||||
registerOneMore('ohmygod', {
|
registerOneMore("ohmygod", {
|
||||||
more_call: () => {
|
more_call: () => {},
|
||||||
},
|
});
|
||||||
});
|
|
||||||
|
|
||||||
let first = await wrap();
|
let first = await wrap();
|
||||||
let second = await barfoo();
|
let second = await barfoo();
|
||||||
|
|
||||||
return { first, second };
|
return { first, second };
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,38 @@
|
|||||||
import {joinIdx, joinIdxLocal, joinIdxRelay} from "../compiled/examples/join.js";
|
import {
|
||||||
import { config } from '../config.js';
|
joinIdx,
|
||||||
|
joinIdxLocal,
|
||||||
|
joinIdxRelay,
|
||||||
|
} from "../compiled/examples/join.js";
|
||||||
|
import { config } from "../config.js";
|
||||||
|
|
||||||
const relays = config.relays
|
const relays = config.relays;
|
||||||
|
|
||||||
export async function joinIdxCall(relayPeerId: string) {
|
export async function joinIdxCall(relayPeerId: string) {
|
||||||
// join.aqua
|
// join.aqua
|
||||||
|
|
||||||
return await joinIdx(1, [relayPeerId, relays[2].peerId, relays[4].peerId, relays[5].peerId], {ttl: 10000});
|
return await joinIdx(
|
||||||
|
1,
|
||||||
|
[relayPeerId, relays[2].peerId, relays[4].peerId, relays[5].peerId],
|
||||||
|
{ ttl: 10000 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function joinIdxLocalCall(relayPeerId: string) {
|
export async function joinIdxLocalCall(relayPeerId: string) {
|
||||||
// join.aqua
|
// join.aqua
|
||||||
|
|
||||||
return await joinIdxLocal(2, [relayPeerId, relays[2].peerId, relays[4].peerId]);
|
return await joinIdxLocal(2, [
|
||||||
|
relayPeerId,
|
||||||
|
relays[2].peerId,
|
||||||
|
relays[4].peerId,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function joinIdxRelayCall(relayPeerId: string) {
|
export async function joinIdxRelayCall(relayPeerId: string) {
|
||||||
// join.aqua
|
// join.aqua
|
||||||
|
|
||||||
return await joinIdxRelay(2, [relayPeerId, relays[2].peerId, relays[4].peerId], {ttl: 30000});
|
return await joinIdxRelay(
|
||||||
|
2,
|
||||||
|
[relayPeerId, relays[2].peerId, relays[4].peerId],
|
||||||
|
{ ttl: 30000 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,32 @@
|
|||||||
import {test1, test2, testI16, testI32, testI64, testU64} from '../compiled/examples/math.js';
|
import {
|
||||||
|
test1,
|
||||||
|
test2,
|
||||||
|
testI16,
|
||||||
|
testI32,
|
||||||
|
testI64,
|
||||||
|
testU64,
|
||||||
|
} from "../compiled/examples/math.js";
|
||||||
|
|
||||||
export async function mathTest1Call(): Promise<number> {
|
export async function mathTest1Call(): Promise<number> {
|
||||||
return await test1();
|
return await test1();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mathTest2Call(): Promise<number> {
|
export async function mathTest2Call(): Promise<number> {
|
||||||
return await test2();
|
return await test2();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mathTestI16Call(peer: string): Promise<number[]> {
|
export async function mathTestI16Call(peer: string): Promise<number[]> {
|
||||||
return await testI16(peer);
|
return await testI16(peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mathTestI32Call(peer: string): Promise<number[]> {
|
export async function mathTestI32Call(peer: string): Promise<number[]> {
|
||||||
return await testI32(peer);
|
return await testI32(peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mathTestI64Call(peer: string): Promise<number[]> {
|
export async function mathTestI64Call(peer: string): Promise<number[]> {
|
||||||
return await testI64(peer);
|
return await testI64(peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mathTestU64Call(peer: string): Promise<number[]> {
|
export async function mathTestU64Call(peer: string): Promise<number[]> {
|
||||||
return await testU64(peer);
|
return await testU64(peer);
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
import { multiReturnFunc, registerGetStr, registerGetNum } from '../compiled/examples/multiReturn.js';
|
import {
|
||||||
|
multiReturnFunc,
|
||||||
|
registerGetStr,
|
||||||
|
registerGetNum,
|
||||||
|
} from "../compiled/examples/multiReturn.js";
|
||||||
|
|
||||||
export async function multiReturnCall(): Promise<[string[], number, string, number[], string | null, number]> {
|
export async function multiReturnCall(): Promise<
|
||||||
registerGetStr({
|
[string[], number, string, number[], string | null, number]
|
||||||
retStr: (args0) => {
|
> {
|
||||||
return args0;
|
registerGetStr({
|
||||||
},
|
retStr: (args0) => {
|
||||||
});
|
return args0;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
registerGetNum({
|
registerGetNum({
|
||||||
retNum: () => {
|
retNum: () => {
|
||||||
return 10;
|
return 10;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await multiReturnFunc([1, 2], null);
|
return await multiReturnFunc([1, 2], null);
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,28 @@
|
|||||||
import {test, registerTest, TestResult} from '../compiled/examples/nestedData.js';
|
import {
|
||||||
|
test,
|
||||||
|
registerTest,
|
||||||
|
TestResult,
|
||||||
|
} from "../compiled/examples/nestedData.js";
|
||||||
|
|
||||||
export async function nestedDataCall(): Promise<TestResult> {
|
export async function nestedDataCall(): Promise<TestResult> {
|
||||||
let nested = {
|
let nested = {
|
||||||
|
one: {
|
||||||
|
val: "hello",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
registerTest({
|
||||||
|
test1: () => {
|
||||||
|
return nested;
|
||||||
|
},
|
||||||
|
test2: (arg1: { val: string }, arg2: string) => {
|
||||||
|
let res = {
|
||||||
one: {
|
one: {
|
||||||
val: "hello"
|
val: arg1.val + arg2,
|
||||||
}
|
|
||||||
}
|
|
||||||
registerTest({
|
|
||||||
test1: () => {
|
|
||||||
return nested;
|
|
||||||
},
|
},
|
||||||
test2: (arg1: { val: string; }, arg2: string) => {
|
};
|
||||||
let res = {
|
return res;
|
||||||
one: {
|
},
|
||||||
val: (arg1.val + arg2)
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return await test();
|
return await test();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { d, registerOpH } from '../compiled/examples/nestedFuncs.js';
|
import { d, registerOpH } from "../compiled/examples/nestedFuncs.js";
|
||||||
|
|
||||||
export async function nestedFuncsCall(): Promise<string> {
|
export async function nestedFuncsCall(): Promise<string> {
|
||||||
registerOpH({
|
registerOpH({
|
||||||
identity: (args0) => {
|
identity: (args0) => {
|
||||||
return args0;
|
return args0;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await d('some-str');
|
return await d("some-str");
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
import {getObj, getObjAssign, getObjRelay} from "../compiled/examples/object.js";
|
import {
|
||||||
|
getObj,
|
||||||
|
getObjAssign,
|
||||||
|
getObjRelay,
|
||||||
|
getObjFor,
|
||||||
|
} from "../compiled/examples/object.js";
|
||||||
|
|
||||||
export async function getObjCall() {
|
export async function getObjCall() {
|
||||||
return await getObj();
|
return await getObj();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getObjRelayCall() {
|
export async function getObjRelayCall() {
|
||||||
return await getObjRelay();
|
return await getObjRelay();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getObjAssignCall() {
|
export async function getObjAssignCall() {
|
||||||
return await getObjAssign();
|
return await getObjAssign();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getObjForCall() {
|
||||||
|
return await getObjFor();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { getPeerExternalAddresses } from '../compiled/examples/on.js';
|
import { getPeerExternalAddresses } from "../compiled/examples/on.js";
|
||||||
|
|
||||||
export async function onCall(relayPeerId: string): Promise<string[]> {
|
export async function onCall(relayPeerId: string): Promise<string[]> {
|
||||||
return await getPeerExternalAddresses(relayPeerId);
|
return await getPeerExternalAddresses(relayPeerId);
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,51 @@
|
|||||||
import {IFluenceClient} from '@fluencelabs/js-client';
|
import { IFluenceClient } from "@fluencelabs/js-client";
|
||||||
import {registerTest, onPropagate, nestedOnPropagate, seqOnPropagate} from "../compiled/examples/onErrorPropagation.js"
|
import {
|
||||||
|
registerTest,
|
||||||
|
onPropagate,
|
||||||
|
nestedOnPropagate,
|
||||||
|
seqOnPropagate,
|
||||||
|
} from "../compiled/examples/onErrorPropagation.js";
|
||||||
|
|
||||||
export async function onPropagateCall(peer2: IFluenceClient, relay2: string): Promise<number> {
|
export async function onPropagateCall(
|
||||||
registerTest(peer2, {
|
peer2: IFluenceClient,
|
||||||
fail(err, callParams) {
|
relay2: string,
|
||||||
return Promise.reject(err);
|
): Promise<number> {
|
||||||
},
|
registerTest(peer2, {
|
||||||
})
|
fail(err, callParams) {
|
||||||
|
return Promise.reject(err);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return onPropagate(peer2.getPeerId(), relay2)
|
return onPropagate(peer2.getPeerId(), relay2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function nestedOnPropagateCall(
|
export async function nestedOnPropagateCall(
|
||||||
peer2: IFluenceClient,
|
peer2: IFluenceClient,
|
||||||
relay2: string,
|
relay2: string,
|
||||||
iPeer: string,
|
iPeer: string,
|
||||||
iRelay: string,
|
iRelay: string,
|
||||||
friend: string
|
friend: string,
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
registerTest(peer2, {
|
registerTest(peer2, {
|
||||||
fail(err, callParams) {
|
fail(err, callParams) {
|
||||||
return Promise.reject(err);
|
return Promise.reject(err);
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
return nestedOnPropagate(peer2.getPeerId(), relay2, iPeer, iRelay, friend)
|
return nestedOnPropagate(peer2.getPeerId(), relay2, iPeer, iRelay, friend);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function seqOnPropagateCall(
|
export async function seqOnPropagateCall(
|
||||||
peer2: IFluenceClient,
|
peer2: IFluenceClient,
|
||||||
relay2: string,
|
relay2: string,
|
||||||
iPeer: string,
|
iPeer: string,
|
||||||
iRelay: string
|
iRelay: string,
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
registerTest(peer2, {
|
registerTest(peer2, {
|
||||||
fail(err, callParams) {
|
fail(err, callParams) {
|
||||||
return Promise.reject(err);
|
return Promise.reject(err);
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
return seqOnPropagate(peer2.getPeerId(), relay2, iPeer, iRelay)
|
return seqOnPropagate(peer2.getPeerId(), relay2, iPeer, iRelay);
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
import {checkEmpty, checkNoneEmpty, emptyString, registerOptionString} from "../compiled/examples/options/option_gen.js";
|
import {
|
||||||
|
checkEmpty,
|
||||||
|
checkNoneEmpty,
|
||||||
|
emptyString,
|
||||||
|
registerOptionString,
|
||||||
|
} from "../compiled/examples/options/option_gen.js";
|
||||||
|
|
||||||
export async function genOptions(): Promise<[string, string]> {
|
export async function genOptions(): Promise<[string, string]> {
|
||||||
registerOptionString({
|
registerOptionString({
|
||||||
checkOption: (str: string | null) => {
|
checkOption: (str: string | null) => {
|
||||||
if (str) {
|
if (str) {
|
||||||
return "some"
|
return "some";
|
||||||
} else {
|
} else {
|
||||||
return "none"
|
return "none";
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
const a = await checkEmpty();
|
const a = await checkEmpty();
|
||||||
const b = await checkNoneEmpty("some_string");
|
const b = await checkNoneEmpty("some_string");
|
||||||
return [a, b]
|
return [a, b];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function genOptionsEmptyString(): Promise<string | null> {
|
export async function genOptionsEmptyString(): Promise<string | null> {
|
||||||
return await emptyString();
|
return await emptyString();
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,31 @@
|
|||||||
import {parFunc, registerParService, testTimeout} from '../compiled/examples/par.js';
|
import {
|
||||||
import {config} from "../config.js";
|
parFunc,
|
||||||
|
registerParService,
|
||||||
|
testTimeout,
|
||||||
|
} from "../compiled/examples/par.js";
|
||||||
|
import { config } from "../config.js";
|
||||||
|
|
||||||
export async function parCall(relayPeerId: string) {
|
export async function parCall(relayPeerId: string) {
|
||||||
let promise = new Promise<string>((resolve, reject) => {
|
let promise = new Promise<string>((resolve, reject) => {
|
||||||
registerParService({
|
registerParService({
|
||||||
call: () => {
|
call: () => {
|
||||||
console.log('hello from parservice-id');
|
console.log("hello from parservice-id");
|
||||||
let result = 'hello';
|
let result = "hello";
|
||||||
resolve(result);
|
resolve(result);
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
await parFunc(relayPeerId, (c) => {
|
await parFunc(relayPeerId, (c) => {
|
||||||
console.log('parFunc. external addresses par: ' + c.external_addresses);
|
console.log("parFunc. external addresses par: " + c.external_addresses);
|
||||||
});
|
});
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
const relays = config.relays
|
const relays = config.relays;
|
||||||
|
|
||||||
export async function testTimeoutCall() {
|
export async function testTimeoutCall() {
|
||||||
return testTimeout([relays[3].peerId, relays[4].peerId])
|
return testTimeout([relays[3].peerId, relays[4].peerId]);
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
import {bugLNG60, create_client_util, registerAquaDHT} from '../compiled/examples/passArgs.js';
|
import {
|
||||||
|
bugLNG60,
|
||||||
|
create_client_util,
|
||||||
|
registerAquaDHT,
|
||||||
|
} from "../compiled/examples/passArgs.js";
|
||||||
|
|
||||||
export async function passArgsCall() {
|
export async function passArgsCall() {
|
||||||
registerAquaDHT({
|
registerAquaDHT({
|
||||||
put_host_value: (args0, args1) => {
|
put_host_value: (args0, args1) => {
|
||||||
return args0 + args1;
|
return args0 + args1;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await create_client_util('sid');
|
return await create_client_util("sid");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function bugLNG60Call(relayPeerId: string): Promise<boolean> {
|
export async function bugLNG60Call(relayPeerId: string): Promise<boolean> {
|
||||||
return bugLNG60(relayPeerId, {ttl: 10000})
|
return bugLNG60(relayPeerId, { ttl: 10000 });
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { get_results, registerOpA } from '../compiled/examples/pushToStream.js';
|
import { get_results, registerOpA } from "../compiled/examples/pushToStream.js";
|
||||||
|
|
||||||
export async function pushToStreamCall() {
|
export async function pushToStreamCall() {
|
||||||
registerOpA({
|
registerOpA({
|
||||||
get_str: () => {
|
get_str: () => {
|
||||||
return 'get_string';
|
return "get_string";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await get_results();
|
return await get_results();
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
import {recursiveStream, registerYesNoService} from "../compiled/examples/recursiveStreams.js";
|
import {
|
||||||
|
recursiveStream,
|
||||||
|
registerYesNoService,
|
||||||
|
} from "../compiled/examples/recursiveStreams.js";
|
||||||
|
|
||||||
export async function recursiveStreamsCall(): Promise<[string[], string[]]> {
|
export async function recursiveStreamsCall(): Promise<[string[], string[]]> {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
registerYesNoService({
|
registerYesNoService({
|
||||||
get: () => {
|
get: () => {
|
||||||
i++;
|
i++;
|
||||||
if (i > 3) {
|
if (i > 3) {
|
||||||
console.log("return no")
|
console.log("return no");
|
||||||
return "no"
|
return "no";
|
||||||
} else {
|
} else {
|
||||||
console.log("return yes")
|
console.log("return yes");
|
||||||
return "yes"
|
return "yes";
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
}
|
return await recursiveStream();
|
||||||
})
|
}
|
||||||
|
|
||||||
return await recursiveStream()
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { rename_s } from '../compiled/examples/renameVars.js';
|
import { rename_s } from "../compiled/examples/renameVars.js";
|
||||||
|
|
||||||
export async function renameVarsCall(): Promise<string[]> {
|
export async function renameVarsCall(): Promise<string[]> {
|
||||||
return await rename_s();
|
return await rename_s();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
import {callReturnedArrow, callReturnedChainArrow} from "../compiled/examples/returnArrow.js";
|
import {
|
||||||
|
callReturnedArrow,
|
||||||
|
callReturnedChainArrow,
|
||||||
|
} from "../compiled/examples/returnArrow.js";
|
||||||
|
|
||||||
export async function returnArrowCall(): Promise<[string, string]> {
|
export async function returnArrowCall(): Promise<[string, string]> {
|
||||||
return await callReturnedArrow("arg for func ", "arg for closure ")
|
return await callReturnedArrow("arg for func ", "arg for closure ");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function returnArrowChainCall(): Promise<[string, string, string, string, string, string, string, string]> {
|
export async function returnArrowChainCall(): Promise<
|
||||||
return await callReturnedChainArrow("arg for func1 ", "arg for func2 ")
|
[string, string, string, string, string, string, string, string]
|
||||||
}
|
> {
|
||||||
|
return await callReturnedChainArrow("arg for func1 ", "arg for func2 ");
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { returnLiteral } from '../compiled/examples/returnLiteral.js';
|
import { returnLiteral } from "../compiled/examples/returnLiteral.js";
|
||||||
|
|
||||||
export async function literalCall() {
|
export async function literalCall() {
|
||||||
return returnLiteral();
|
return returnLiteral();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
import { retrieve_records, registerTestService } from '../compiled/examples/streamArgs.js';
|
import {
|
||||||
|
retrieve_records,
|
||||||
|
registerTestService,
|
||||||
|
} from "../compiled/examples/streamArgs.js";
|
||||||
|
|
||||||
export async function streamArgsCall() {
|
export async function streamArgsCall() {
|
||||||
registerTestService({
|
registerTestService({
|
||||||
get_records: (key) => {
|
get_records: (key) => {
|
||||||
return [key, key];
|
return [key, key];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await retrieve_records('peer_id');
|
return await retrieve_records("peer_id");
|
||||||
}
|
}
|
||||||
|
@ -1,54 +1,59 @@
|
|||||||
import {
|
import {
|
||||||
checkStreams,
|
checkStreams,
|
||||||
registerStringer, returnNilLength, returnNilLiteral,
|
registerStringer,
|
||||||
returnStreamFromFunc, streamAssignment,
|
returnNilLength,
|
||||||
streamFunctor, streamIntFunctor, streamJoin,
|
returnNilLiteral,
|
||||||
stringNil,
|
returnStreamFromFunc,
|
||||||
stringNone
|
streamAssignment,
|
||||||
} from '../compiled/examples/stream.js';
|
streamFunctor,
|
||||||
|
streamIntFunctor,
|
||||||
|
streamJoin,
|
||||||
|
stringNil,
|
||||||
|
stringNone,
|
||||||
|
} from "../compiled/examples/stream.js";
|
||||||
|
|
||||||
export async function streamCall() {
|
export async function streamCall() {
|
||||||
registerStringer({
|
registerStringer({
|
||||||
returnString: (args0) => {
|
returnString: (args0) => {
|
||||||
return args0 + ' updated';
|
return args0 + " updated";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return checkStreams(['third', 'fourth']);
|
return checkStreams(["third", "fourth"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function returnNilCall() {
|
export async function returnNilCall() {
|
||||||
return stringNil()
|
return stringNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function returnNoneCall() {
|
export async function returnNoneCall() {
|
||||||
return stringNone()
|
return stringNone();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function streamReturnFromInnerFunc() {
|
export async function streamReturnFromInnerFunc() {
|
||||||
return await returnStreamFromFunc();
|
return await returnStreamFromFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function streamFunctorCall() {
|
export async function streamFunctorCall() {
|
||||||
return await streamFunctor(["333"]);
|
return await streamFunctor(["333"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function streamJoinCall() {
|
export async function streamJoinCall() {
|
||||||
return await streamJoin(["444"]);
|
return await streamJoin(["444"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function streamAssignmentCall() {
|
export async function streamAssignmentCall() {
|
||||||
return await streamAssignment(["333"]);
|
return await streamAssignment(["333"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function nilLiteralCall() {
|
export async function nilLiteralCall() {
|
||||||
return await returnNilLiteral();
|
return await returnNilLiteral();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function nilLengthCall() {
|
export async function nilLengthCall() {
|
||||||
return await returnNilLength();
|
return await returnNilLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function streamIntFunctorCall() {
|
export async function streamIntFunctorCall() {
|
||||||
return await streamIntFunctor([0]);
|
return await streamIntFunctor([0]);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import {someFunc} from "../compiled/examples/streamCallback.js";
|
import { someFunc } from "../compiled/examples/streamCallback.js";
|
||||||
|
|
||||||
export async function streamCallbackCall(): Promise<string[]> {
|
export async function streamCallbackCall(): Promise<string[]> {
|
||||||
return new Promise<string[]>((resolve, reject) => {
|
return new Promise<string[]>((resolve, reject) => {
|
||||||
someFunc((a: string[]) => {
|
someFunc((a: string[]) => {
|
||||||
resolve(a);
|
resolve(a);
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,22 @@
|
|||||||
import {accumRes, bugLNG63, bugLNG63_2, bugLNG63_3} from "../compiled/examples/streamCan.js";
|
import {
|
||||||
|
accumRes,
|
||||||
|
bugLNG63,
|
||||||
|
bugLNG63_2,
|
||||||
|
bugLNG63_3,
|
||||||
|
} from "../compiled/examples/streamCan.js";
|
||||||
|
|
||||||
export async function streamCanCall() {
|
export async function streamCanCall() {
|
||||||
return await accumRes();
|
return await accumRes();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function bugLNG63Call(): Promise<string> {
|
export async function bugLNG63Call(): Promise<string> {
|
||||||
return await bugLNG63();
|
return await bugLNG63();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function bugLNG63_2Call(): Promise<[string, string[], string[]]> {
|
export async function bugLNG63_2Call(): Promise<[string, string[], string[]]> {
|
||||||
return await bugLNG63_2();
|
return await bugLNG63_2();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function bugLNG63_3Call(): Promise<[string, number, number[]]> {
|
export async function bugLNG63_3Call(): Promise<[string, number, number[]]> {
|
||||||
return await bugLNG63_3();
|
return await bugLNG63_3();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import { testStreamCaptureSimple, testStreamCaptureReturn } from '../compiled/examples/streamCapture.js';
|
import {
|
||||||
|
testStreamCaptureSimple,
|
||||||
|
testStreamCaptureReturn,
|
||||||
|
} from "../compiled/examples/streamCapture.js";
|
||||||
|
|
||||||
export async function streamCaptureSimpleCall() {
|
export async function streamCaptureSimpleCall() {
|
||||||
return await testStreamCaptureSimple();
|
return await testStreamCaptureSimple();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function streamCaptureReturnCall() {
|
export async function streamCaptureReturnCall() {
|
||||||
return await testStreamCaptureReturn();
|
return await testStreamCaptureReturn();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { streamRes } from '../compiled/examples/streamRestriction.js';
|
import { streamRes } from "../compiled/examples/streamRestriction.js";
|
||||||
|
|
||||||
export async function streamResCall(): Promise<any> {
|
export async function streamResCall(): Promise<any> {
|
||||||
return await streamRes(["a", "b", "c"]);
|
return await streamRes(["a", "b", "c"]);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
import { use_name2, registerDTGetter } from '../compiled/examples/streamResults.js';
|
import {
|
||||||
|
use_name2,
|
||||||
|
registerDTGetter,
|
||||||
|
} from "../compiled/examples/streamResults.js";
|
||||||
|
|
||||||
export async function streamResultsCall() {
|
export async function streamResultsCall() {
|
||||||
registerDTGetter({
|
registerDTGetter({
|
||||||
get_dt: (args0) => {
|
get_dt: (args0) => {
|
||||||
return {
|
return {
|
||||||
field: args0,
|
field: args0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await use_name2('new_name');
|
return await use_name2("new_name");
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { testReturnStream } from '../compiled/examples/streamReturn.js';
|
import { testReturnStream } from "../compiled/examples/streamReturn.js";
|
||||||
|
|
||||||
export async function streamReturnCall() {
|
export async function streamReturnCall() {
|
||||||
return await testReturnStream();
|
return await testReturnStream();
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
import {
|
import {
|
||||||
streamIf,
|
streamIf,
|
||||||
streamTry,
|
streamTry,
|
||||||
streamFor,
|
streamFor,
|
||||||
streamComplex,
|
streamComplex,
|
||||||
registerFailureSrv,
|
registerFailureSrv,
|
||||||
} from '../compiled/examples/streamScopes.js';
|
} from "../compiled/examples/streamScopes.js";
|
||||||
|
|
||||||
export async function streamIfCall() {
|
export async function streamIfCall() {
|
||||||
return await streamIf();
|
return await streamIf();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function streamTryCall() {
|
export async function streamTryCall() {
|
||||||
registerFailureSrv({
|
registerFailureSrv({
|
||||||
fail: (msg) => {
|
fail: (msg) => {
|
||||||
return Promise.reject(msg);
|
return Promise.reject(msg);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await streamTry();
|
return await streamTry();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function streamForCall() {
|
export async function streamForCall() {
|
||||||
return await streamFor();
|
return await streamFor();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function streamComplexCall() {
|
export async function streamComplexCall() {
|
||||||
registerFailureSrv({
|
registerFailureSrv({
|
||||||
fail: (msg) => {
|
fail: (msg) => {
|
||||||
return Promise.reject(msg);
|
return Promise.reject(msg);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await streamComplex();
|
return await streamComplex();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {structuralTypingTest} from "../compiled/examples/structuraltyping";
|
import { structuralTypingTest } from "../compiled/examples/structuraltyping";
|
||||||
|
|
||||||
export async function structuralTypingCall(): Promise<string> {
|
export async function structuralTypingCall(): Promise<string> {
|
||||||
return await structuralTypingTest();
|
return await structuralTypingTest();
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,27 @@
|
|||||||
import { registerSubService } from '../compiled/examples/imports_exports/subImport.js';
|
import { registerSubService } from "../compiled/examples/imports_exports/subImport.js";
|
||||||
import { registerConcatSubs, subImportUsage } from '../compiled/examples/subImportUsage.js';
|
import {
|
||||||
|
registerConcatSubs,
|
||||||
|
subImportUsage,
|
||||||
|
} from "../compiled/examples/subImportUsage.js";
|
||||||
|
|
||||||
export async function subImportCall() {
|
export async function subImportCall() {
|
||||||
// helloWorld.aqua
|
// helloWorld.aqua
|
||||||
registerSubService({
|
registerSubService({
|
||||||
sub: (s) => {
|
sub: (s) => {
|
||||||
return {
|
return {
|
||||||
one: s,
|
one: s,
|
||||||
two: 42,
|
two: 42,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
registerConcatSubs({
|
registerConcatSubs({
|
||||||
get_some: (s, sr) => {
|
get_some: (s, sr) => {
|
||||||
return {
|
return {
|
||||||
one: s,
|
one: s,
|
||||||
two: sr.two,
|
two: sr.two,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await subImportUsage('random_string');
|
return await subImportUsage("random_string");
|
||||||
}
|
}
|
||||||
|
@ -1,45 +1,68 @@
|
|||||||
import { IFluenceClient } from '@fluencelabs/js-client';
|
import { IFluenceClient } from "@fluencelabs/js-client";
|
||||||
import {
|
import {
|
||||||
topologyTest,
|
topologyTest,
|
||||||
registerTesto,
|
registerTesto,
|
||||||
registerLocalPrint,
|
registerLocalPrint,
|
||||||
topologyBug205,
|
topologyBug205,
|
||||||
topologyBug394, topologyBug427
|
topologyBug394,
|
||||||
} from '../compiled/examples/topology.js';
|
topologyBug427,
|
||||||
|
} from "../compiled/examples/topology.js";
|
||||||
|
|
||||||
export async function topologyBug394Call(peer1: string, relay1: string, peer2: string, relay2: string): Promise<string> {
|
export async function topologyBug394Call(
|
||||||
return topologyBug394(relay1, peer2, relay2)
|
peer1: string,
|
||||||
|
relay1: string,
|
||||||
|
peer2: string,
|
||||||
|
relay2: string,
|
||||||
|
): Promise<string> {
|
||||||
|
return topologyBug394(relay1, peer2, relay2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function topologyBug205Call(relay1: string, relay2: string): Promise<string[]> {
|
export async function topologyBug205Call(
|
||||||
return topologyBug205(relay1, relay2)
|
relay1: string,
|
||||||
|
relay2: string,
|
||||||
|
): Promise<string[]> {
|
||||||
|
return topologyBug205(relay1, relay2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function topologyBug427Call(relay1: string, relay2: string): Promise<string[]> {
|
export async function topologyBug427Call(
|
||||||
return topologyBug427([relay1, relay2])
|
relay1: string,
|
||||||
|
relay2: string,
|
||||||
|
): Promise<string[]> {
|
||||||
|
return topologyBug427([relay1, relay2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function topologyCall(peer1: IFluenceClient, relay1: string, peer2: IFluenceClient, relay2: string): Promise<string> {
|
export async function topologyCall(
|
||||||
const relayPeerId = relay1;
|
peer1: IFluenceClient,
|
||||||
const selfPeerId = peer1.getPeerId();
|
relay1: string,
|
||||||
|
peer2: IFluenceClient,
|
||||||
|
relay2: string,
|
||||||
|
): Promise<string> {
|
||||||
|
const relayPeerId = relay1;
|
||||||
|
const selfPeerId = peer1.getPeerId();
|
||||||
|
|
||||||
const relayPeerId2 = relay2;
|
const relayPeerId2 = relay2;
|
||||||
const selfPeerId2 = peer2.getPeerId();
|
const selfPeerId2 = peer2.getPeerId();
|
||||||
|
|
||||||
registerTesto(peer2, {
|
registerTesto(peer2, {
|
||||||
getString: (args0) => {
|
getString: (args0) => {
|
||||||
console.log('hello from client2: ' + args0);
|
console.log("hello from client2: " + args0);
|
||||||
return 'hello from client2: ' + args0;
|
return "hello from client2: " + args0;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
registerLocalPrint({
|
registerLocalPrint({
|
||||||
print: (args0) => {
|
print: (args0) => {
|
||||||
console.log('print on client1: ' + args0);
|
console.log("print on client1: " + args0);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await topologyTest(selfPeerId, relayPeerId, selfPeerId2, relayPeerId2, {
|
return await topologyTest(
|
||||||
ttl: 10000,
|
selfPeerId,
|
||||||
});
|
relayPeerId,
|
||||||
|
selfPeerId2,
|
||||||
|
relayPeerId2,
|
||||||
|
{
|
||||||
|
ttl: 10000,
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { tryCatchTest } from '../compiled/examples/tryCatch.js';
|
import { tryCatchTest } from "../compiled/examples/tryCatch.js";
|
||||||
|
|
||||||
export async function tryCatchCall(relayPeerId: string): Promise<string[]> {
|
export async function tryCatchCall(relayPeerId: string): Promise<string[]> {
|
||||||
return await tryCatchTest(relayPeerId, {ttl: 60000});
|
return await tryCatchTest(relayPeerId, { ttl: 60000 });
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { tryOtherwiseTest } from '../compiled/examples/tryOtherwise.js';
|
import { tryOtherwiseTest } from "../compiled/examples/tryOtherwise.js";
|
||||||
|
|
||||||
export async function tryOtherwiseCall(relayPeerId: string): Promise<string> {
|
export async function tryOtherwiseCall(relayPeerId: string): Promise<string> {
|
||||||
return await tryOtherwiseTest(relayPeerId, {ttl: 60000});
|
return await tryOtherwiseTest(relayPeerId, { ttl: 60000 });
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,33 @@
|
|||||||
import { returnNone, returnOptional, useOptional, registerSomeS } from '../compiled/examples/option.js';
|
import {
|
||||||
|
returnNone,
|
||||||
|
returnOptional,
|
||||||
|
useOptional,
|
||||||
|
registerSomeS,
|
||||||
|
} from "../compiled/examples/option.js";
|
||||||
|
|
||||||
export function registerHandlers(): void {
|
export function registerHandlers(): void {
|
||||||
registerSomeS({
|
registerSomeS({
|
||||||
getStr: (arg0) => {
|
getStr: (arg0) => {
|
||||||
return arg0;
|
return arg0;
|
||||||
},
|
},
|
||||||
getStr1: () => {
|
getStr1: () => {
|
||||||
return 'optional';
|
return "optional";
|
||||||
},
|
},
|
||||||
getStr2: (arg0) => {
|
getStr2: (arg0) => {
|
||||||
return arg0;
|
return arg0;
|
||||||
},
|
},
|
||||||
checkU32: (arg) => {
|
checkU32: (arg) => {},
|
||||||
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function useOptionalCall(): Promise<string> {
|
export async function useOptionalCall(): Promise<string> {
|
||||||
return await useOptional('hello');
|
return await useOptional("hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function returnOptionalCall(): Promise<string | null> {
|
export async function returnOptionalCall(): Promise<string | null> {
|
||||||
return await returnOptional();
|
return await returnOptional();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function returnNull(): Promise<string | null> {
|
export async function returnNull(): Promise<string | null> {
|
||||||
return await returnNone();
|
return await returnNone();
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,43 @@
|
|||||||
import { viaArr, viaOpt, viaStream } from '../compiled/examples/via.js';
|
import { viaArr, viaOpt, viaStream } from "../compiled/examples/via.js";
|
||||||
import { config } from '../config.js';
|
import { config } from "../config.js";
|
||||||
|
|
||||||
const relays = config.relays
|
const relays = config.relays;
|
||||||
|
|
||||||
export async function viaArrCall(): Promise<string[]> {
|
export async function viaArrCall(): Promise<string[]> {
|
||||||
let res = await viaArr(relays[4].peerId, [relays[2].peerId, relays[1].peerId], {ttl: 30000});
|
let res = await viaArr(
|
||||||
|
relays[4].peerId,
|
||||||
|
[relays[2].peerId, relays[1].peerId],
|
||||||
|
{ ttl: 30000 },
|
||||||
|
);
|
||||||
|
|
||||||
return res.external_addresses;
|
return res.external_addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function viaOptCall(relayPeerId: string): Promise<string[]> {
|
export async function viaOptCall(relayPeerId: string): Promise<string[]> {
|
||||||
|
let res2 = await viaOpt(relayPeerId, relays[4].peerId, relays[2].peerId, {
|
||||||
|
ttl: 30000,
|
||||||
|
});
|
||||||
|
|
||||||
let res2 = await viaOpt(relayPeerId, relays[4].peerId, relays[2].peerId, {ttl: 30000});
|
return res2.external_addresses;
|
||||||
|
|
||||||
return res2.external_addresses;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function viaOptNullCall(relayPeerId: string): Promise<string[]> {
|
export async function viaOptNullCall(relayPeerId: string): Promise<string[]> {
|
||||||
|
let res3 = await viaOpt(
|
||||||
|
relayPeerId,
|
||||||
|
relays[4].peerId,
|
||||||
|
relays[2].peerId || null,
|
||||||
|
{ ttl: 30000 },
|
||||||
|
);
|
||||||
|
|
||||||
let res3 = await viaOpt(relayPeerId, relays[4].peerId, relays[2].peerId || null, {ttl: 30000});
|
return res3.external_addresses;
|
||||||
|
|
||||||
return res3.external_addresses;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function viaStreamCall(relayPeerId: string): Promise<string[]> {
|
export async function viaStreamCall(relayPeerId: string): Promise<string[]> {
|
||||||
|
let res4 = await viaStream(
|
||||||
|
relays[4].peerId,
|
||||||
|
[relays[2].peerId, relays[1].peerId],
|
||||||
|
{ ttl: 30000 },
|
||||||
|
);
|
||||||
|
|
||||||
let res4 = await viaStream(relays[4].peerId, [relays[2].peerId, relays[1].peerId], {ttl: 30000});
|
return res4.external_addresses;
|
||||||
|
|
||||||
return res4.external_addresses;
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
main().catch((err) => {
|
main().catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
@ -1,27 +1,33 @@
|
|||||||
export type Node = { peerId: string; multiaddr: string };
|
export type Node = { peerId: string; multiaddr: string };
|
||||||
export const local: Node[] = [
|
export const local: Node[] = [
|
||||||
{
|
{
|
||||||
multiaddr: '/ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR',
|
multiaddr:
|
||||||
peerId: '12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR'
|
"/ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR",
|
||||||
|
peerId: "12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
multiaddr: '/ip4/127.0.0.1/tcp/9992/ws/p2p/12D3KooWQdpukY3p2DhDfUfDgphAqsGu5ZUrmQ4mcHSGrRag6gQK',
|
multiaddr:
|
||||||
peerId: '12D3KooWQdpukY3p2DhDfUfDgphAqsGu5ZUrmQ4mcHSGrRag6gQK'
|
"/ip4/127.0.0.1/tcp/9992/ws/p2p/12D3KooWQdpukY3p2DhDfUfDgphAqsGu5ZUrmQ4mcHSGrRag6gQK",
|
||||||
|
peerId: "12D3KooWQdpukY3p2DhDfUfDgphAqsGu5ZUrmQ4mcHSGrRag6gQK",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
multiaddr: '/ip4/127.0.0.1/tcp/9993/ws/p2p/12D3KooWRT8V5awYdEZm6aAV9HWweCEbhWd7df4wehqHZXAB7yMZ',
|
multiaddr:
|
||||||
peerId: '12D3KooWRT8V5awYdEZm6aAV9HWweCEbhWd7df4wehqHZXAB7yMZ'
|
"/ip4/127.0.0.1/tcp/9993/ws/p2p/12D3KooWRT8V5awYdEZm6aAV9HWweCEbhWd7df4wehqHZXAB7yMZ",
|
||||||
|
peerId: "12D3KooWRT8V5awYdEZm6aAV9HWweCEbhWd7df4wehqHZXAB7yMZ",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
multiaddr: '/ip4/127.0.0.1/tcp/9994/ws/p2p/12D3KooWBzLSu9RL7wLP6oUowzCbkCj2AGBSXkHSJKuq4wwTfwof',
|
multiaddr:
|
||||||
peerId: '12D3KooWBzLSu9RL7wLP6oUowzCbkCj2AGBSXkHSJKuq4wwTfwof'
|
"/ip4/127.0.0.1/tcp/9994/ws/p2p/12D3KooWBzLSu9RL7wLP6oUowzCbkCj2AGBSXkHSJKuq4wwTfwof",
|
||||||
|
peerId: "12D3KooWBzLSu9RL7wLP6oUowzCbkCj2AGBSXkHSJKuq4wwTfwof",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
multiaddr: '/ip4/127.0.0.1/tcp/9995/ws/p2p/12D3KooWBf6hFgrnXwHkBnwPGMysP3b1NJe5HGtAWPYfwmQ2MBiU',
|
multiaddr:
|
||||||
peerId: '12D3KooWBf6hFgrnXwHkBnwPGMysP3b1NJe5HGtAWPYfwmQ2MBiU'
|
"/ip4/127.0.0.1/tcp/9995/ws/p2p/12D3KooWBf6hFgrnXwHkBnwPGMysP3b1NJe5HGtAWPYfwmQ2MBiU",
|
||||||
|
peerId: "12D3KooWBf6hFgrnXwHkBnwPGMysP3b1NJe5HGtAWPYfwmQ2MBiU",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
multiaddr: '/ip4/127.0.0.1/tcp/9996/ws/p2p/12D3KooWPisGn7JhooWhggndz25WM7vQ2JmA121EV8jUDQ5xMovJ',
|
multiaddr:
|
||||||
peerId: '12D3KooWPisGn7JhooWhggndz25WM7vQ2JmA121EV8jUDQ5xMovJ'
|
"/ip4/127.0.0.1/tcp/9996/ws/p2p/12D3KooWPisGn7JhooWhggndz25WM7vQ2JmA121EV8jUDQ5xMovJ",
|
||||||
}
|
peerId: "12D3KooWPisGn7JhooWhggndz25WM7vQ2JmA121EV8jUDQ5xMovJ",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
@ -1,49 +1,61 @@
|
|||||||
package aqua.model.inline
|
package aqua.model.inline
|
||||||
|
|
||||||
import aqua.model.{
|
import aqua.model.inline.RawValueInliner.unfold
|
||||||
CallModel,
|
|
||||||
CallServiceModel,
|
|
||||||
LiteralModel,
|
|
||||||
OpModel,
|
|
||||||
SeqModel,
|
|
||||||
ValueModel,
|
|
||||||
VarModel
|
|
||||||
}
|
|
||||||
import aqua.model.inline.raw.RawInliner
|
import aqua.model.inline.raw.RawInliner
|
||||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||||
import aqua.raw.value.{LiteralRaw, MakeStructRaw}
|
import aqua.model.*
|
||||||
import aqua.model.inline.Inline
|
import aqua.raw.value.MakeStructRaw
|
||||||
import aqua.model.inline.RawValueInliner.{unfold, valueToModel}
|
import aqua.types.{StreamMapType, StructType}
|
||||||
import aqua.types.ScalarType
|
|
||||||
|
|
||||||
import cats.data.Chain
|
import cats.data.{Chain, NonEmptyMap, State}
|
||||||
import cats.data.{NonEmptyMap, State}
|
|
||||||
import cats.syntax.traverse.*
|
|
||||||
import cats.syntax.monoid.*
|
|
||||||
import cats.syntax.functor.*
|
|
||||||
import cats.syntax.flatMap.*
|
|
||||||
import cats.syntax.apply.*
|
|
||||||
import cats.syntax.foldable.*
|
import cats.syntax.foldable.*
|
||||||
|
import cats.syntax.bifunctor.*
|
||||||
|
import cats.syntax.functor.*
|
||||||
|
|
||||||
object MakeStructRawInliner extends RawInliner[MakeStructRaw] {
|
object MakeStructRawInliner extends RawInliner[MakeStructRaw] {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates structure using stream map.
|
||||||
|
* @param mapName stream map name
|
||||||
|
* @param mapType stream map type
|
||||||
|
* @param result variable with structure
|
||||||
|
* @param fields fields to insert
|
||||||
|
* @param prefix operations that must be inside stream map restriction
|
||||||
|
* @return tree with traversed fields and tree with structure creation.
|
||||||
|
* They are split to combine it later with other trees in a more natural way.
|
||||||
|
*/
|
||||||
|
def constructThroughMap[S: Mangler](
|
||||||
|
mapName: String,
|
||||||
|
mapType: StreamMapType,
|
||||||
|
result: CallModel.Export,
|
||||||
|
fields: NonEmptyMap[String, ValueModel],
|
||||||
|
prefix: List[OpModel.Tree] = Nil
|
||||||
|
): State[S, OpModel.Tree] = {
|
||||||
|
fields.nonEmptyTraverse(TagInliner.canonicalizeIfStream(_)).map { fieldsTraversed =>
|
||||||
|
val (values, ops) = fieldsTraversed.toNel.map { case (name, (model, ops)) =>
|
||||||
|
(name -> model, ops)
|
||||||
|
}.unzip.bimap(_.toList, _.toList.flatten)
|
||||||
|
|
||||||
|
val models = values.map { case (k, v) =>
|
||||||
|
InsertKeyValueModel(LiteralModel.quote(k), v, mapName, mapType).leaf
|
||||||
|
}
|
||||||
|
|
||||||
|
val toResult =
|
||||||
|
CanonicalizeModel(VarModel(mapName, mapType), result).leaf
|
||||||
|
|
||||||
|
RestrictionModel(mapName, mapType).wrap(ops ++ prefix ++ models :+ toResult)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private def createObj[S: Mangler](
|
private def createObj[S: Mangler](
|
||||||
fields: NonEmptyMap[String, ValueModel],
|
fields: NonEmptyMap[String, ValueModel],
|
||||||
result: VarModel
|
resultName: String,
|
||||||
|
resultType: StructType
|
||||||
): State[S, OpModel.Tree] = {
|
): State[S, OpModel.Tree] = {
|
||||||
fields.toSortedMap.toList.flatMap { case (name, value) =>
|
val mapType = StreamMapType.top()
|
||||||
LiteralModel.quote(name) :: value :: Nil
|
val mapName = resultName + "_map"
|
||||||
}.traverse(TagInliner.canonicalizeIfStream(_)).map { argsWithOps =>
|
|
||||||
val (args, ops) = argsWithOps.unzip
|
constructThroughMap(mapName, mapType, CallModel.Export(resultName, resultType), fields)
|
||||||
val createOp =
|
|
||||||
CallServiceModel(
|
|
||||||
"json",
|
|
||||||
"obj",
|
|
||||||
args,
|
|
||||||
result
|
|
||||||
).leaf
|
|
||||||
SeqModel.wrap(ops.flatten :+ createOp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override def apply[S: Mangler: Exports: Arrows](
|
override def apply[S: Mangler: Exports: Arrows](
|
||||||
@ -56,7 +68,7 @@ object MakeStructRawInliner extends RawInliner[MakeStructRaw] {
|
|||||||
varModel = VarModel(name, raw.baseType)
|
varModel = VarModel(name, raw.baseType)
|
||||||
valsInline = foldedFields.foldMap { case (_, inline) => inline }.desugar
|
valsInline = foldedFields.foldMap { case (_, inline) => inline }.desugar
|
||||||
fields = foldedFields.map { case (vm, _) => vm }
|
fields = foldedFields.map { case (vm, _) => vm }
|
||||||
objCreation <- createObj(fields, varModel)
|
objCreation <- createObj(fields, name, raw.structType)
|
||||||
} yield {
|
} yield {
|
||||||
(
|
(
|
||||||
varModel,
|
varModel,
|
||||||
|
@ -1,72 +1,72 @@
|
|||||||
package aqua.model.inline.raw
|
package aqua.model.inline.raw
|
||||||
|
|
||||||
import aqua.model.{
|
import aqua.errors.Errors.internalError
|
||||||
CallModel,
|
import aqua.model.*
|
||||||
CallServiceModel,
|
|
||||||
LiteralModel,
|
|
||||||
OpModel,
|
|
||||||
SeqModel,
|
|
||||||
ValueModel,
|
|
||||||
VarModel
|
|
||||||
}
|
|
||||||
import aqua.model.inline.Inline.MergeMode.*
|
import aqua.model.inline.Inline.MergeMode.*
|
||||||
import aqua.model.inline.{Inline, TagInliner}
|
|
||||||
import aqua.model.inline.MakeStructRawInliner.createObj
|
|
||||||
import aqua.model.inline.RawValueInliner.unfold
|
import aqua.model.inline.RawValueInliner.unfold
|
||||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||||
import aqua.raw.value.{IntoCopyRaw, LiteralRaw}
|
import aqua.model.inline.{Inline, MakeStructRawInliner}
|
||||||
import aqua.types.ScalarType
|
import aqua.raw.value.IntoCopyRaw
|
||||||
|
import aqua.types.{StreamMapType, StructType}
|
||||||
import cats.data.{Chain, NonEmptyMap, State}
|
import cats.data.{Chain, NonEmptyMap, State}
|
||||||
import scribe.Logging
|
|
||||||
import cats.syntax.traverse.*
|
|
||||||
import cats.syntax.monoid.*
|
|
||||||
import cats.syntax.functor.*
|
|
||||||
import cats.syntax.flatMap.*
|
|
||||||
import cats.syntax.apply.*
|
|
||||||
import cats.syntax.foldable.*
|
import cats.syntax.foldable.*
|
||||||
|
import cats.syntax.functor.*
|
||||||
|
import scribe.Logging
|
||||||
|
|
||||||
object ApplyIntoCopyRawInliner extends Logging {
|
object ApplyIntoCopyRawInliner extends Logging {
|
||||||
|
|
||||||
private def copyObj[S: Mangler](
|
private def copyObj[S: Mangler](
|
||||||
value: VarModel,
|
oldValue: VarModel,
|
||||||
fields: NonEmptyMap[String, ValueModel],
|
resultName: String,
|
||||||
result: VarModel
|
resultType: StructType,
|
||||||
|
fields: NonEmptyMap[String, ValueModel]
|
||||||
): State[S, OpModel.Tree] = {
|
): State[S, OpModel.Tree] = {
|
||||||
fields.toSortedMap.toList.flatMap { case (name, value) =>
|
val mapType = StreamMapType.top()
|
||||||
LiteralModel.quote(name) :: value :: Nil
|
val mapName = resultName + "_map"
|
||||||
}.traverse(TagInliner.canonicalizeIfStream(_)).map { argsWithOps =>
|
|
||||||
val (args, ops) = argsWithOps.unzip
|
val nonCopiedValues = resultType.fields.toNel.filterNot { case (k, _) =>
|
||||||
val copyOp = CallServiceModel(
|
fields.contains(k)
|
||||||
"json",
|
}.flatMap { case (k, _) =>
|
||||||
"puts",
|
oldValue
|
||||||
value +: args,
|
.intoField(k)
|
||||||
result
|
.map(vm =>
|
||||||
).leaf
|
InsertKeyValueModel(
|
||||||
SeqModel.wrap(ops.flatten :+ copyOp)
|
LiteralModel.quote(k),
|
||||||
|
vm,
|
||||||
|
mapName,
|
||||||
|
mapType
|
||||||
|
).leaf
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MakeStructRawInliner
|
||||||
|
.constructThroughMap(mapName, mapType, CallModel.Export(resultName, resultType), fields, nonCopiedValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
def apply[S: Mangler: Exports: Arrows](
|
def apply[S: Mangler: Exports: Arrows](
|
||||||
value: VarModel,
|
value: VarModel,
|
||||||
intoCopy: IntoCopyRaw
|
intoCopy: IntoCopyRaw
|
||||||
): State[S, (VarModel, Inline)] = {
|
): State[S, (VarModel, Inline)] = {
|
||||||
for {
|
value.`type` match {
|
||||||
name <- Mangler[S].findAndForbidName(value.name + "_obj_copy")
|
case st: StructType =>
|
||||||
foldedFields <- intoCopy.fields.nonEmptyTraverse(unfold(_))
|
for {
|
||||||
varModel = VarModel(name, value.baseType)
|
resultName <- Mangler[S].findAndForbidName(st.name + "_obj_copy")
|
||||||
valsInline = foldedFields.toList.foldMap { case (_, inline) => inline }.desugar
|
foldedFields <- intoCopy.fields.nonEmptyTraverse(unfold(_))
|
||||||
fields = foldedFields.map(_._1)
|
varModel = VarModel(resultName, st)
|
||||||
objCopy <- copyObj(value, fields, varModel)
|
valsInline = foldedFields.toList.foldMap { case (_, inline) => inline }.desugar
|
||||||
} yield {
|
fields = foldedFields.map(_._1)
|
||||||
(
|
objCopy <- copyObj(value, resultName, st, fields)
|
||||||
varModel,
|
} yield {
|
||||||
Inline(
|
(
|
||||||
Chain.one(SeqModel.wrap(valsInline.predo :+ objCopy)),
|
varModel,
|
||||||
SeqMode
|
Inline(
|
||||||
)
|
Chain.one(SeqModel.wrap(valsInline.predo :+ objCopy)),
|
||||||
)
|
SeqMode
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case _ =>
|
||||||
|
internalError("Unreachable. Cannot copy a value that is not a data type")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -161,10 +161,10 @@ object ApplyPropertiesRawInliner extends RawInliner[ApplyPropertyRaw] with Loggi
|
|||||||
if (varModel.properties.nonEmpty) removeProperties(varModel)
|
if (varModel.properties.nonEmpty) removeProperties(varModel)
|
||||||
else State.pure(varModel, Inline.empty)
|
else State.pure(varModel, Inline.empty)
|
||||||
(flatten, inline) = flattenVI
|
(flatten, inline) = flattenVI
|
||||||
newVI <- ApplyIntoCopyRawInliner(varModel, ic)
|
newVI <- ApplyIntoCopyRawInliner(flatten, ic)
|
||||||
} yield {
|
} yield {
|
||||||
newVI._1 -> Inline(
|
newVI._1 -> Inline(
|
||||||
inline.predo ++ newVI._2.predo,
|
Chain.one(SeqModel.wrap(inline.predo ++ newVI._2.predo)),
|
||||||
mergeMode = SeqMode
|
mergeMode = SeqMode
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,16 @@
|
|||||||
package aqua.model.inline.raw
|
package aqua.model.inline.raw
|
||||||
|
|
||||||
import aqua.errors.Errors.internalError
|
import aqua.errors.Errors.internalError
|
||||||
import aqua.model.inline.Inline.parDesugarPrefixOpt
|
import aqua.model.*
|
||||||
import aqua.model.{CallServiceModel, FuncArrow, MetaModel, SeqModel, ValueModel, VarModel}
|
|
||||||
import aqua.model.inline.{ArrowInliner, Inline, TagInliner}
|
|
||||||
import aqua.model.inline.RawValueInliner.{callToModel, valueToModel}
|
import aqua.model.inline.RawValueInliner.{callToModel, valueToModel}
|
||||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||||
|
import aqua.model.inline.{ArrowInliner, Inline, TagInliner}
|
||||||
import aqua.raw.ops.Call
|
import aqua.raw.ops.Call
|
||||||
import aqua.types.ArrowType
|
|
||||||
import aqua.raw.value.CallArrowRaw
|
import aqua.raw.value.CallArrowRaw
|
||||||
|
|
||||||
import cats.syntax.traverse.*
|
|
||||||
import cats.data.{Chain, State}
|
import cats.data.{Chain, State}
|
||||||
|
import cats.syntax.traverse.*
|
||||||
import scribe.Logging
|
import scribe.Logging
|
||||||
|
|
||||||
import scala.collection.immutable.ListMap
|
|
||||||
|
|
||||||
object CallArrowRawInliner extends RawInliner[CallArrowRaw] with Logging {
|
object CallArrowRawInliner extends RawInliner[CallArrowRaw] with Logging {
|
||||||
|
|
||||||
private[inline] def unfoldArrow[S: Mangler: Exports: Arrows](
|
private[inline] def unfoldArrow[S: Mangler: Exports: Arrows](
|
||||||
|
@ -5,7 +5,7 @@ import aqua.model.inline.raw.{ApplyIntoCopyRawInliner, CollectionRawInliner}
|
|||||||
import aqua.model.inline.state.InliningState
|
import aqua.model.inline.state.InliningState
|
||||||
import aqua.raw.ops.*
|
import aqua.raw.ops.*
|
||||||
import aqua.raw.value.{CollectionRaw, LiteralRaw, MakeStructRaw, VarRaw}
|
import aqua.raw.value.{CollectionRaw, LiteralRaw, MakeStructRaw, VarRaw}
|
||||||
import aqua.types.{CanonStreamType, OptionType, ScalarType, StreamType, StructType}
|
import aqua.types.{CanonStreamType, OptionType, ScalarType, StreamMapType, StreamType, StructType}
|
||||||
import cats.data.{NonEmptyList, NonEmptyMap}
|
import cats.data.{NonEmptyList, NonEmptyMap}
|
||||||
import cats.syntax.show.*
|
import cats.syntax.show.*
|
||||||
import org.scalatest.flatspec.AnyFlatSpec
|
import org.scalatest.flatspec.AnyFlatSpec
|
||||||
@ -32,18 +32,17 @@ class CollectionRawInlinerSpec extends AnyFlatSpec with Matchers {
|
|||||||
|
|
||||||
v shouldBe resultValue
|
v shouldBe resultValue
|
||||||
|
|
||||||
|
val streamMapType = StreamMapType.top()
|
||||||
|
val streamMapVar = VarModel("nested_type_obj_map", streamMapType)
|
||||||
|
|
||||||
val expected =
|
val expected =
|
||||||
RestrictionModel("option-inline", StreamType(nestedType)).wrap( // create a stream
|
RestrictionModel("option-inline", StreamType(nestedType)).wrap( // create a stream
|
||||||
SeqModel.wrap(
|
SeqModel.wrap(
|
||||||
// create an object
|
// create an object
|
||||||
CallServiceModel(
|
RestrictionModel(streamMapVar.name, streamMapType).wrap(
|
||||||
"json",
|
InsertKeyValueModel(LiteralModel.quote("field1"), LiteralModel.number(3), streamMapVar.name, streamMapType).leaf,
|
||||||
"obj",
|
CanonicalizeModel(streamMapVar, CallModel.Export("nested_type_obj", nestedType)).leaf
|
||||||
LiteralModel.fromRaw(LiteralRaw.quote("field1")) :: LiteralModel.fromRaw(
|
),
|
||||||
LiteralRaw.number(3)
|
|
||||||
) :: Nil,
|
|
||||||
VarModel("nested_type_obj", nestedType)
|
|
||||||
).leaf,
|
|
||||||
XorModel.wrap(
|
XorModel.wrap(
|
||||||
SeqModel.wrap(
|
SeqModel.wrap(
|
||||||
// push object to the stream
|
// push object to the stream
|
||||||
|
@ -16,7 +16,7 @@ class CopyInlinerSpec extends AnyFlatSpec with Matchers {
|
|||||||
"copy inliner" should "unfold values in parallel" in {
|
"copy inliner" should "unfold values in parallel" in {
|
||||||
|
|
||||||
val structType = StructType(
|
val structType = StructType(
|
||||||
"struct_type",
|
"some_struct",
|
||||||
NonEmptyMap.of("field1" -> ScalarType.u32, "field2" -> ScalarType.string)
|
NonEmptyMap.of("field1" -> ScalarType.u32, "field2" -> ScalarType.string)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,6 +45,9 @@ class CopyInlinerSpec extends AnyFlatSpec with Matchers {
|
|||||||
|
|
||||||
val lengthModel = FunctorModel("length", ScalarType.u32)
|
val lengthModel = FunctorModel("length", ScalarType.u32)
|
||||||
|
|
||||||
|
val streamMapName = "some_struct_obj_copy_map"
|
||||||
|
val streamMapType = StreamMapType.top()
|
||||||
|
|
||||||
tree.get.equalsOrShowDiff(
|
tree.get.equalsOrShowDiff(
|
||||||
SeqModel.wrap(
|
SeqModel.wrap(
|
||||||
ParModel.wrap(
|
ParModel.wrap(
|
||||||
@ -59,16 +62,11 @@ class CopyInlinerSpec extends AnyFlatSpec with Matchers {
|
|||||||
VarModel("get_field", ScalarType.string)
|
VarModel("get_field", ScalarType.string)
|
||||||
).leaf
|
).leaf
|
||||||
),
|
),
|
||||||
CallServiceModel(
|
RestrictionModel(streamMapName, streamMapType).wrap(
|
||||||
"json",
|
InsertKeyValueModel(LiteralModel.quote("field1"), VarModel("l_length", ScalarType.u32), streamMapName, streamMapType).leaf,
|
||||||
"puts",
|
InsertKeyValueModel(LiteralModel.quote("field2"), VarModel("get_field", ScalarType.string), streamMapName, streamMapType).leaf,
|
||||||
VarModel(varName, structType) :: LiteralModel.fromRaw(
|
CanonicalizeModel(VarModel(streamMapName, streamMapType), CallModel.Export(result.name, result.`type`)).leaf
|
||||||
LiteralRaw.quote("field1")
|
)
|
||||||
) :: VarModel("l_length", ScalarType.u32) :: LiteralModel.fromRaw(
|
|
||||||
LiteralRaw.quote("field2")
|
|
||||||
) :: VarModel("get_field", ScalarType.string) :: Nil,
|
|
||||||
result
|
|
||||||
).leaf
|
|
||||||
)
|
)
|
||||||
) shouldBe true
|
) shouldBe true
|
||||||
|
|
||||||
|
@ -44,6 +44,9 @@ class MakeStructInlinerSpec extends AnyFlatSpec with Matchers {
|
|||||||
|
|
||||||
val lengthModel = FunctorModel("length", ScalarType.u32)
|
val lengthModel = FunctorModel("length", ScalarType.u32)
|
||||||
|
|
||||||
|
val streamMapName = "struct_type_obj_map"
|
||||||
|
val streamMapType = StreamMapType.top()
|
||||||
|
|
||||||
tree.get.equalsOrShowDiff(
|
tree.get.equalsOrShowDiff(
|
||||||
SeqModel.wrap(
|
SeqModel.wrap(
|
||||||
ParModel.wrap(
|
ParModel.wrap(
|
||||||
@ -58,16 +61,11 @@ class MakeStructInlinerSpec extends AnyFlatSpec with Matchers {
|
|||||||
VarModel("get_field", ScalarType.string)
|
VarModel("get_field", ScalarType.string)
|
||||||
).leaf
|
).leaf
|
||||||
),
|
),
|
||||||
CallServiceModel(
|
RestrictionModel(streamMapName, streamMapType).wrap(
|
||||||
"json",
|
InsertKeyValueModel(LiteralModel.quote("field1"), VarModel("l_length", ScalarType.u32), streamMapName, streamMapType).leaf,
|
||||||
"obj",
|
InsertKeyValueModel(LiteralModel.quote("field2"), VarModel("get_field", ScalarType.string), streamMapName, streamMapType).leaf,
|
||||||
LiteralModel.fromRaw(
|
CanonicalizeModel(VarModel(streamMapName, streamMapType), CallModel.Export(result.name, result.`type`)).leaf
|
||||||
LiteralRaw.quote("field1")
|
)
|
||||||
) :: VarModel("l_length", ScalarType.u32) :: LiteralModel.fromRaw(
|
|
||||||
LiteralRaw.quote("field2")
|
|
||||||
) :: VarModel("get_field", ScalarType.string) :: Nil,
|
|
||||||
result
|
|
||||||
).leaf
|
|
||||||
)
|
)
|
||||||
) shouldBe true
|
) shouldBe true
|
||||||
|
|
||||||
|
@ -72,6 +72,8 @@ object MakeRes {
|
|||||||
orInit(currentPeerId),
|
orInit(currentPeerId),
|
||||||
exportTo
|
exportTo
|
||||||
).leaf
|
).leaf
|
||||||
|
case InsertKeyValueModel(key, value, assignTo, assignToType) =>
|
||||||
|
ApStreamMapRes(key, value, CallModel.Export(assignTo, assignToType)).leaf
|
||||||
case FlattenModel(operand @ VarModel(_, CanonStreamType(el), _), assignTo) =>
|
case FlattenModel(operand @ VarModel(_, CanonStreamType(el), _), assignTo) =>
|
||||||
ApRes(operand, CallModel.Export(assignTo, ArrayType(el))).leaf
|
ApRes(operand, CallModel.Export(assignTo, ArrayType(el))).leaf
|
||||||
case FlattenModel(operand, assignTo) =>
|
case FlattenModel(operand, assignTo) =>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package aqua.res
|
package aqua.res
|
||||||
|
|
||||||
import aqua.model.{CallModel, ForModel, ValueModel, VarModel}
|
import aqua.model.{CallModel, ForModel, LiteralModel, ValueModel, VarModel}
|
||||||
import aqua.raw.ops.Call
|
import aqua.raw.ops.Call
|
||||||
import aqua.tree.{TreeNode, TreeNodeCompanion}
|
import aqua.tree.{TreeNode, TreeNodeCompanion}
|
||||||
import aqua.types.DataType
|
import aqua.types.DataType
|
||||||
@ -50,6 +50,10 @@ case class CallServiceRes(
|
|||||||
override def toString: String = s"(call $peerId ($serviceId $funcName) $call)"
|
override def toString: String = s"(call $peerId ($serviceId $funcName) $call)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case class ApStreamMapRes(key: ValueModel, value: ValueModel, exportTo: CallModel.Export) extends ResolvedOp {
|
||||||
|
override def toString: String = s"(ap ($key $value) $exportTo)"
|
||||||
|
}
|
||||||
|
|
||||||
case class ApRes(operand: ValueModel, exportTo: CallModel.Export) extends ResolvedOp {
|
case class ApRes(operand: ValueModel, exportTo: CallModel.Export) extends ResolvedOp {
|
||||||
override def toString: String = s"(ap $operand $exportTo)"
|
override def toString: String = s"(ap $operand $exportTo)"
|
||||||
}
|
}
|
||||||
|
@ -174,6 +174,13 @@ case class DeclareStreamModel(value: ValueModel) extends NoExecModel {
|
|||||||
override def usesVarNames: Set[String] = value.usesVarNames
|
override def usesVarNames: Set[String] = value.usesVarNames
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// key must be only string or number
|
||||||
|
case class InsertKeyValueModel(key: ValueModel, value: ValueModel, assignTo: String, assignToType: StreamMapType) extends OpModel {
|
||||||
|
override def usesVarNames: Set[String] = value.usesVarNames
|
||||||
|
|
||||||
|
override def exportsVarNames: Set[String] = Set(assignTo)
|
||||||
|
}
|
||||||
|
|
||||||
case class FlattenModel(value: ValueModel, assignTo: String) extends OpModel {
|
case class FlattenModel(value: ValueModel, assignTo: String) extends OpModel {
|
||||||
override def usesVarNames: Set[String] = value.usesVarNames
|
override def usesVarNames: Set[String] = value.usesVarNames
|
||||||
|
|
||||||
|
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
@ -54,6 +54,9 @@ importers:
|
|||||||
jest:
|
jest:
|
||||||
specifier: 29.5.0
|
specifier: 29.5.0
|
||||||
version: 29.5.0(@types/node@18.11.18)(ts-node@10.9.1)
|
version: 29.5.0(@types/node@18.11.18)(ts-node@10.9.1)
|
||||||
|
prettier:
|
||||||
|
specifier: 3.0.3
|
||||||
|
version: 3.0.3
|
||||||
ts-jest:
|
ts-jest:
|
||||||
specifier: 29.1.0
|
specifier: 29.1.0
|
||||||
version: 29.1.0(@babel/core@7.22.5)(jest@29.5.0)(typescript@5.1.3)
|
version: 29.1.0(@babel/core@7.22.5)(jest@29.5.0)(typescript@5.1.3)
|
||||||
@ -3309,6 +3312,12 @@ packages:
|
|||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/prettier@3.0.3:
|
||||||
|
resolution: {integrity: sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==}
|
||||||
|
engines: {node: '>=14'}
|
||||||
|
hasBin: true
|
||||||
|
dev: true
|
||||||
|
|
||||||
/pretty-format@29.5.0:
|
/pretty-format@29.5.0:
|
||||||
resolution: {integrity: sha512-V2mGkI31qdttvTFX7Mt4efOqHXqJWMu4/r66Xh3Z3BwZaPfPJgp6/gbwoujRpPUtfEF6AUUWx3Jim3GCw5g/Qw==}
|
resolution: {integrity: sha512-V2mGkI31qdttvTFX7Mt4efOqHXqJWMu4/r66Xh3Z3BwZaPfPJgp6/gbwoujRpPUtfEF6AUUWx3Jim3GCw5g/Qw==}
|
||||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||||
|
@ -323,6 +323,16 @@ case class StructType(name: String, fields: NonEmptyMap[String, Type])
|
|||||||
s"$name{${fields.map(_.toString).toNel.toList.map(kv => kv._1 + ": " + kv._2).mkString(", ")}}"
|
s"$name{${fields.map(_.toString).toNel.toList.map(kv => kv._1 + ": " + kv._2).mkString(", ")}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case class StreamMapType(element: Type)
|
||||||
|
extends DataType {
|
||||||
|
|
||||||
|
override def toString: String = s"%$element"
|
||||||
|
}
|
||||||
|
|
||||||
|
object StreamMapType {
|
||||||
|
def top(): StreamMapType = StreamMapType(TopType)
|
||||||
|
}
|
||||||
|
|
||||||
case class ServiceType(name: String, fields: NonEmptyMap[String, ArrowType]) extends NamedType {
|
case class ServiceType(name: String, fields: NonEmptyMap[String, ArrowType]) extends NamedType {
|
||||||
|
|
||||||
override def toString: String =
|
override def toString: String =
|
||||||
|
Loading…
Reference in New Issue
Block a user