mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-06-26 22:31:32 +00:00
feat(js-client)!: Segregation of responsibility between js-client packages [fixes DXJ-525] (#378)
Schema validation in js-client
This commit is contained in:
51
packages/@tests/aqua/compile-aqua.ts
Normal file
51
packages/@tests/aqua/compile-aqua.ts
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright 2023 Fluence Labs Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { writeFile } from "fs/promises";
|
||||
import { join, dirname } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
import { compileFromPath } from "@fluencelabs/aqua-api";
|
||||
import aquaToJs from "@fluencelabs/aqua-to-js";
|
||||
|
||||
const files = ["smoke_test", "finalize_particle"];
|
||||
|
||||
for (const file of files) {
|
||||
const cr = await compileFromPath({
|
||||
filePath: join(
|
||||
dirname(fileURLToPath(import.meta.url)),
|
||||
"_aqua",
|
||||
file + ".aqua",
|
||||
),
|
||||
targetType: "air",
|
||||
imports: [fileURLToPath(new URL("./node_modules", import.meta.url))],
|
||||
});
|
||||
|
||||
if (cr.errors.length > 0) {
|
||||
throw new Error(cr.errors.join("\n"));
|
||||
}
|
||||
|
||||
const res = await aquaToJs(cr, "ts");
|
||||
|
||||
if (res == null) {
|
||||
throw new Error("AquaToJs gave null value after compilation");
|
||||
}
|
||||
|
||||
await writeFile(
|
||||
fileURLToPath(new URL(join("src", "_aqua", file + ".ts"), import.meta.url)),
|
||||
res.sources,
|
||||
);
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"compile-aqua": "fluence aqua -i ./_aqua -o ./src/_aqua"
|
||||
"compile-aqua": "node --loader ts-node/esm compile-aqua.ts"
|
||||
},
|
||||
"repository": "https://github.com/fluencelabs/fluence-js",
|
||||
"author": "Fluence Labs",
|
||||
@ -20,10 +20,12 @@
|
||||
"base64-js": "1.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fluencelabs/aqua-api": "0.12.4-main-cee4448-2196-1",
|
||||
"@fluencelabs/aqua-lib": "0.6.0",
|
||||
"@fluencelabs/cli": "0.7.2",
|
||||
"@fluencelabs/js-client": "workspace:^",
|
||||
"@fluencelabs/registry": "0.8.2",
|
||||
"@fluencelabs/trust-graph": "3.1.2"
|
||||
"@fluencelabs/aqua-to-js": "workspace:*",
|
||||
"@fluencelabs/js-client": "workspace:*",
|
||||
"@fluencelabs/registry": "0.8.8-1",
|
||||
"@fluencelabs/trust-graph": "3.1.2",
|
||||
"ts-node": "10.9.1"
|
||||
}
|
||||
}
|
||||
|
@ -2,71 +2,68 @@
|
||||
// @ts-nocheck
|
||||
/**
|
||||
*
|
||||
* This file is auto-generated. Do not edit manually: changes may be erased.
|
||||
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
|
||||
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
|
||||
* Aqua version: 0.12.0
|
||||
* This file is generated using:
|
||||
* @fluencelabs/aqua-api version: 0.12.4-main-cee4448-2196-1
|
||||
* @fluencelabs/aqua-to-js version: 0.2.0
|
||||
* If you find any bugs in generated AIR, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
|
||||
* If you find any bugs in generated JS/TS, please write an issue on GitHub: https://github.com/fluencelabs/js-client/issues
|
||||
*
|
||||
*/
|
||||
import type {
|
||||
IFluenceClient as IFluenceClient$$,
|
||||
CallParams as CallParams$$,
|
||||
} from "@fluencelabs/js-client";
|
||||
import {
|
||||
v5_callFunction as callFunction$$,
|
||||
v5_registerService as registerService$$,
|
||||
} from "@fluencelabs/js-client";
|
||||
import type { IFluenceClient as IFluenceClient$$, ParticleContext as ParticleContext$$ } from '@fluencelabs/js-client';
|
||||
|
||||
// Making aliases to reduce chance of accidental name collision
|
||||
import {
|
||||
v5_callFunction as callFunction$$,
|
||||
v5_registerService as registerService$$
|
||||
} from '@fluencelabs/js-client';
|
||||
|
||||
// Services
|
||||
|
||||
// Functions
|
||||
export const test_script = `
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(xor
|
||||
(xor
|
||||
(call -relay- ("op" "noop") [])
|
||||
(fail %last_error%)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 0])
|
||||
)
|
||||
)
|
||||
`;
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(xor
|
||||
(call -relay- ("op" "noop") [])
|
||||
(fail :error:)
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("callbackSrv" "response") [])
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [:error: 0])
|
||||
)
|
||||
`;
|
||||
|
||||
export function test(config?: { ttl?: number }): Promise<void>;
|
||||
export type TestParams = [config?: {ttl?: number}] | [peer: IFluenceClient$$, config?: {ttl?: number}];
|
||||
|
||||
export function test(
|
||||
peer: IFluenceClient$$,
|
||||
config?: { ttl?: number },
|
||||
): Promise<void>;
|
||||
export type TestResult = Promise<void>;
|
||||
|
||||
export function test(...args: any) {
|
||||
return callFunction$$(
|
||||
args,
|
||||
{
|
||||
functionName: "test",
|
||||
arrow: {
|
||||
tag: "arrow",
|
||||
domain: {
|
||||
tag: "labeledProduct",
|
||||
fields: {},
|
||||
export function test(...args: TestParams): TestResult {
|
||||
return callFunction$$(
|
||||
args,
|
||||
{
|
||||
"functionName": "test",
|
||||
"arrow": {
|
||||
"domain": {
|
||||
"fields": {},
|
||||
"tag": "labeledProduct"
|
||||
},
|
||||
codomain: {
|
||||
tag: "nil",
|
||||
"codomain": {
|
||||
"tag": "nil"
|
||||
},
|
||||
},
|
||||
names: {
|
||||
relay: "-relay-",
|
||||
getDataSrv: "getDataSrv",
|
||||
callbackSrv: "callbackSrv",
|
||||
responseSrv: "callbackSrv",
|
||||
responseFnName: "response",
|
||||
errorHandlingSrv: "errorHandlingSrv",
|
||||
errorFnName: "error",
|
||||
},
|
||||
"tag": "arrow"
|
||||
},
|
||||
test_script,
|
||||
);
|
||||
"names": {
|
||||
"relay": "-relay-",
|
||||
"getDataSrv": "getDataSrv",
|
||||
"callbackSrv": "callbackSrv",
|
||||
"responseSrv": "callbackSrv",
|
||||
"responseFnName": "response",
|
||||
"errorHandlingSrv": "errorHandlingSrv",
|
||||
"errorFnName": "error"
|
||||
}
|
||||
},
|
||||
test_script
|
||||
);
|
||||
}
|
||||
|
||||
/* eslint-enable */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -90,11 +90,11 @@ export const runTest = async (): Promise<TestResult> => {
|
||||
|
||||
console.log("running marine test...");
|
||||
const marine = await marineTest(wasm);
|
||||
console.log("marine test finished, result: ", marine);
|
||||
|
||||
console.log("running particle test...");
|
||||
await particleTest();
|
||||
|
||||
console.log("marine test finished, result: ", marine);
|
||||
await particleTest();
|
||||
|
||||
const returnVal = {
|
||||
hello,
|
||||
|
@ -19,7 +19,7 @@
|
||||
"author": "Fluence Labs",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@fluencelabs/js-client": "workspace:*",
|
||||
"@fluencelabs/js-client-isomorphic": "workspace:*",
|
||||
"@test/test-utils": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -77,7 +77,6 @@ const getRelayTime = () => {
|
||||
|
||||
return callAquaFunction({
|
||||
args,
|
||||
def,
|
||||
script,
|
||||
config,
|
||||
peer: Fluence.defaultClient,
|
||||
|
@ -61,21 +61,16 @@ export const startContentServer = (
|
||||
source: "/js-client.min.js",
|
||||
destination: "/source/index.min.js",
|
||||
},
|
||||
// TODO:
|
||||
// something like this
|
||||
// {
|
||||
// source: "/@fluencelabs/:name(\\w+)@:version([\\d.]+)/:path*",
|
||||
// destination: "/deps/@fluencelabs/:name/:path",
|
||||
// }
|
||||
// not supported for some reason. Need to manually iterate over all possible paths
|
||||
{
|
||||
source: "/@fluencelabs/:name([\\w-]+)@:version([\\d.]+)/dist/:asset",
|
||||
destination: "/node_modules/@fluencelabs/:name/dist/:asset",
|
||||
destination:
|
||||
"/node_modules/@fluencelabs/js-client-isomorphic/node_modules/@fluencelabs/:name/dist/:asset",
|
||||
},
|
||||
{
|
||||
source:
|
||||
"/@fluencelabs/:name([\\w-]+)@:version([\\d.]+)/dist/:prefix/:asset",
|
||||
destination: "/node_modules/@fluencelabs/:name/dist/:prefix/:asset",
|
||||
destination:
|
||||
"/node_modules/@fluencelabs/js-client-isomorphic/node_modules/@fluencelabs/:name/dist/:prefix/:asset",
|
||||
},
|
||||
],
|
||||
headers: [
|
||||
|
Reference in New Issue
Block a user