mirror of
https://github.com/fluencelabs/aqua.git
synced 2025-04-24 22:42:13 +00:00
Adjust ts and js backend to support updated JS SDK public interface (#298)
This commit is contained in:
parent
5b8a253fe7
commit
5c67987346
@ -30,7 +30,7 @@ object JavaScriptFile {
|
||||
| * Aqua version: ${Version.version}
|
||||
| *
|
||||
| */
|
||||
|import { FluencePeer } from '@fluencelabs/fluence';
|
||||
|import { Fluence, FluencePeer } from '@fluencelabs/fluence';
|
||||
|import {
|
||||
| ResultCodes,
|
||||
| RequestFlow,
|
||||
|
@ -91,11 +91,11 @@ case class JavaScriptFunc(func: FuncRes) {
|
||||
| let peer;
|
||||
| ${argsLets}
|
||||
| let config;
|
||||
| if (args[0] instanceof FluencePeer) {
|
||||
| if (FluencePeer.isInstance(args[0])) {
|
||||
| peer = args[0];
|
||||
| ${argsAssignmentStartingFrom1}
|
||||
| } else {
|
||||
| peer = FluencePeer.default;
|
||||
| peer = Fluence.getPeer();
|
||||
| ${argsAssignmentStartingFrom0}
|
||||
| }
|
||||
|
|
||||
@ -111,7 +111,7 @@ case class JavaScriptFunc(func: FuncRes) {
|
||||
| .configHandler((h) => {
|
||||
| ${conf.relayVarName.fold("") { r =>
|
||||
s"""h.on('${conf.getDataService}', '$r', () => {
|
||||
| return peer.connectionInfo.connectedRelay ;
|
||||
| return peer.getStatus().relayPeerId;
|
||||
| });""".stripMargin }}
|
||||
| $setCallbacks
|
||||
| $returnCallback
|
||||
|
@ -39,10 +39,10 @@ case class JavaScriptService(srv: ServiceRes) {
|
||||
| let peer;
|
||||
| let serviceId;
|
||||
| let service;
|
||||
| if (args[0] instanceof FluencePeer) {
|
||||
| if (FluencePeer.isInstance(args[0])) {
|
||||
| peer = args[0];
|
||||
| } else {
|
||||
| peer = FluencePeer.default;
|
||||
| peer = Fluence.getPeer();
|
||||
| }
|
||||
|
|
||||
| if (typeof args[0] === 'string') {
|
||||
@ -51,7 +51,12 @@ case class JavaScriptService(srv: ServiceRes) {
|
||||
| serviceId = args[1];
|
||||
| } ${defaultServiceIdBranch}
|
||||
|
|
||||
| if (!(args[0] instanceof FluencePeer) && typeof args[0] === 'object') {
|
||||
| // Figuring out which overload is the service.
|
||||
| // If the first argument is not Fluence Peer and it is an object, then it can only be the service def
|
||||
| // If the first argument is peer, we are checking further. The second argument might either be
|
||||
| // an object, that it must be the service object
|
||||
| // or a string, which is the service id. In that case the service is the third argument
|
||||
| if (!(FluencePeer.isInstance(args[0])) && typeof args[0] === 'object') {
|
||||
| service = args[0];
|
||||
| } else if (typeof args[1] === 'object') {
|
||||
| service = args[1];
|
||||
|
@ -30,7 +30,7 @@ object TypeScriptFile {
|
||||
| * Aqua version: ${Version.version}
|
||||
| *
|
||||
| */
|
||||
|import { FluencePeer } from '@fluencelabs/fluence';
|
||||
|import { Fluence, FluencePeer } from '@fluencelabs/fluence';
|
||||
|import {
|
||||
| ResultCodes,
|
||||
| RequestFlow,
|
||||
|
@ -108,11 +108,11 @@ case class TypeScriptFunc(func: FuncRes) {
|
||||
| let peer: FluencePeer;
|
||||
| ${argsLets}
|
||||
| let config: any;
|
||||
| if (args[0] instanceof FluencePeer) {
|
||||
| if (FluencePeer.isInstance(args[0])) {
|
||||
| peer = args[0];
|
||||
| ${argsAssignmentStartingFrom1}
|
||||
| } else {
|
||||
| peer = FluencePeer.default;
|
||||
| peer = Fluence.getPeer();
|
||||
| ${argsAssignmentStartingFrom0}
|
||||
| }
|
||||
|
|
||||
@ -128,7 +128,7 @@ case class TypeScriptFunc(func: FuncRes) {
|
||||
| .configHandler((h) => {
|
||||
| ${conf.relayVarName.fold("") { r =>
|
||||
s"""h.on('${conf.getDataService}', '$r', () => {
|
||||
| return peer.connectionInfo.connectedRelay ;
|
||||
| return peer.getStatus().relayPeerId;
|
||||
| });""".stripMargin }}
|
||||
| $setCallbacks
|
||||
| $returnCallback
|
||||
|
@ -90,10 +90,10 @@ case class TypeScriptService(srv: ServiceRes) {
|
||||
| let peer: FluencePeer;
|
||||
| let serviceId: any;
|
||||
| let service: any;
|
||||
| if (args[0] instanceof FluencePeer) {
|
||||
| if (FluencePeer.isInstance(args[0])) {
|
||||
| peer = args[0];
|
||||
| } else {
|
||||
| peer = FluencePeer.default;
|
||||
| peer = Fluence.getPeer();
|
||||
| }
|
||||
|
|
||||
| if (typeof args[0] === 'string') {
|
||||
@ -102,7 +102,12 @@ case class TypeScriptService(srv: ServiceRes) {
|
||||
| serviceId = args[1];
|
||||
| } ${defaultServiceIdBranch}
|
||||
|
|
||||
| if (!(args[0] instanceof FluencePeer) && typeof args[0] === 'object') {
|
||||
| // Figuring out which overload is the service.
|
||||
| // If the first argument is not Fluence Peer and it is an object, then it can only be the service def
|
||||
| // If the first argument is peer, we are checking further. The second argument might either be
|
||||
| // an object, that it must be the service object
|
||||
| // or a string, which is the service id. In that case the service is the third argument
|
||||
| if (!(FluencePeer.isInstance(args[0])) && typeof args[0] === 'object') {
|
||||
| service = args[0];
|
||||
| } else if (typeof args[1] === 'object') {
|
||||
| service = args[1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user