Adjust ts and js backend to support updated JS SDK public interface (#298)

This commit is contained in:
Pavel 2021-09-10 19:53:52 +03:00 committed by GitHub
parent 5b8a253fe7
commit 5c67987346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 15 deletions

View File

@ -30,7 +30,7 @@ object JavaScriptFile {
| * Aqua version: ${Version.version}
| *
| */
|import { FluencePeer } from '@fluencelabs/fluence';
|import { Fluence, FluencePeer } from '@fluencelabs/fluence';
|import {
| ResultCodes,
| RequestFlow,

View File

@ -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

View File

@ -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') {
@ -50,8 +50,13 @@ case class JavaScriptService(srv: ServiceRes) {
| } else if (typeof args[1] === 'string') {
| 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];

View File

@ -30,7 +30,7 @@ object TypeScriptFile {
| * Aqua version: ${Version.version}
| *
| */
|import { FluencePeer } from '@fluencelabs/fluence';
|import { Fluence, FluencePeer } from '@fluencelabs/fluence';
|import {
| ResultCodes,
| RequestFlow,

View File

@ -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

View File

@ -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];