Skip to content

Commit f4a550d

Browse files
author
Akim
authored
feat(js-client)!: Segregation of responsibility between js-client packages [fixes DXJ-525] (#378)
Schema validation in js-client
1 parent 638da47 commit f4a550d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+10564
-18869
lines changed

.github/workflows/e2e.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
uses: fluencelabs/aqua/.github/workflows/tests.yml@main
4444
with:
4545
js-client-snapshots: "${{ needs.js-client.outputs.js-client-snapshots }}"
46-
nox-image: "fluencelabs/nox:unstable_minimal"
46+
nox-image: "fluencelabs/nox:0.4.2"
4747
flox:
4848
needs:
4949
- js-client

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
nox-image:
77
description: "nox image tag"
88
type: string
9-
default: "fluencelabs/nox:0.4.0"
9+
default: "fluencelabs/nox:0.4.2"
1010
avm-version:
1111
description: "@fluencelabs/avm version"
1212
type: string

.prettierignore

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
.eslintcache
33
pnpm-lock.yaml
44

5-
**/node_modules
6-
**/dist
7-
**/build
8-
**/public
5+
node_modules
6+
dist
7+
build
8+
public
99

1010
**/CHANGELOG.md
1111

12-
packages/core/js-client-isomorphic/src/versions.ts
12+
packages/core/js-client-isomorphic/src/versions.ts
13+
__snapshots__
14+
packages/@tests/aqua/src/_aqua/**

ci.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async function checkConsistency(file, versionsMap) {
9595

9696
for (const [name, versionInDep] of versionsMap) {
9797
const check = (x, version) => {
98-
if (version.includes("*")) {
98+
if (version.includes("*") || version.includes("^")) {
9999
return;
100100
}
101101

packages/@tests/aqua/compile-aqua.ts

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Copyright 2023 Fluence Labs Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { writeFile } from "fs/promises";
18+
import { join, dirname } from "path";
19+
import { fileURLToPath } from "url";
20+
21+
import { compileFromPath } from "@fluencelabs/aqua-api";
22+
import aquaToJs from "@fluencelabs/aqua-to-js";
23+
24+
const files = ["smoke_test", "finalize_particle"];
25+
26+
for (const file of files) {
27+
const cr = await compileFromPath({
28+
filePath: join(
29+
dirname(fileURLToPath(import.meta.url)),
30+
"_aqua",
31+
file + ".aqua",
32+
),
33+
targetType: "air",
34+
imports: [fileURLToPath(new URL("./node_modules", import.meta.url))],
35+
});
36+
37+
if (cr.errors.length > 0) {
38+
throw new Error(cr.errors.join("\n"));
39+
}
40+
41+
const res = await aquaToJs(cr, "ts");
42+
43+
if (res == null) {
44+
throw new Error("AquaToJs gave null value after compilation");
45+
}
46+
47+
await writeFile(
48+
fileURLToPath(new URL(join("src", "_aqua", file + ".ts"), import.meta.url)),
49+
res.sources,
50+
);
51+
}

packages/@tests/aqua/package.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"type": "module",
1212
"scripts": {
1313
"build": "tsc",
14-
"compile-aqua": "fluence aqua -i ./_aqua -o ./src/_aqua"
14+
"compile-aqua": "node --loader ts-node/esm compile-aqua.ts"
1515
},
1616
"repository": "https://github.com/fluencelabs/fluence-js",
1717
"author": "Fluence Labs",
@@ -20,10 +20,12 @@
2020
"base64-js": "1.5.1"
2121
},
2222
"devDependencies": {
23+
"@fluencelabs/aqua-api": "0.12.4-main-cee4448-2196-1",
2324
"@fluencelabs/aqua-lib": "0.6.0",
24-
"@fluencelabs/cli": "0.7.2",
25-
"@fluencelabs/js-client": "workspace:^",
26-
"@fluencelabs/registry": "0.8.2",
27-
"@fluencelabs/trust-graph": "3.1.2"
25+
"@fluencelabs/aqua-to-js": "workspace:*",
26+
"@fluencelabs/js-client": "workspace:*",
27+
"@fluencelabs/registry": "0.8.8-1",
28+
"@fluencelabs/trust-graph": "3.1.2",
29+
"ts-node": "10.9.1"
2830
}
2931
}

packages/@tests/aqua/src/_aqua/finalize_particle.ts

+51-54
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,68 @@
22
// @ts-nocheck
33
/**
44
*
5-
* This file is auto-generated. Do not edit manually: changes may be erased.
6-
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
7-
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
8-
* Aqua version: 0.12.0
5+
* This file is generated using:
6+
* @fluencelabs/aqua-api version: 0.12.4-main-cee4448-2196-1
7+
* @fluencelabs/aqua-to-js version: 0.2.0
8+
* If you find any bugs in generated AIR, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
9+
* If you find any bugs in generated JS/TS, please write an issue on GitHub: https://github.com/fluencelabs/js-client/issues
910
*
1011
*/
11-
import type {
12-
IFluenceClient as IFluenceClient$$,
13-
CallParams as CallParams$$,
14-
} from "@fluencelabs/js-client";
12+
import type { IFluenceClient as IFluenceClient$$, ParticleContext as ParticleContext$$ } from '@fluencelabs/js-client';
13+
14+
// Making aliases to reduce chance of accidental name collision
1515
import {
16-
v5_callFunction as callFunction$$,
17-
v5_registerService as registerService$$,
18-
} from "@fluencelabs/js-client";
16+
v5_callFunction as callFunction$$,
17+
v5_registerService as registerService$$
18+
} from '@fluencelabs/js-client';
1919

20-
// Services
2120

2221
// Functions
2322
export const test_script = `
24-
(seq
25-
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
26-
(xor
27-
(xor
28-
(call -relay- ("op" "noop") [])
29-
(fail %last_error%)
30-
)
31-
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 0])
32-
)
33-
)
34-
`;
23+
(xor
24+
(seq
25+
(seq
26+
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
27+
(xor
28+
(call -relay- ("op" "noop") [])
29+
(fail :error:)
30+
)
31+
)
32+
(call %init_peer_id% ("callbackSrv" "response") [])
33+
)
34+
(call %init_peer_id% ("errorHandlingSrv" "error") [:error: 0])
35+
)
36+
`;
3537

36-
export function test(config?: { ttl?: number }): Promise<void>;
38+
export type TestParams = [config?: {ttl?: number}] | [peer: IFluenceClient$$, config?: {ttl?: number}];
3739

38-
export function test(
39-
peer: IFluenceClient$$,
40-
config?: { ttl?: number },
41-
): Promise<void>;
40+
export type TestResult = Promise<void>;
4241

43-
export function test(...args: any) {
44-
return callFunction$$(
45-
args,
46-
{
47-
functionName: "test",
48-
arrow: {
49-
tag: "arrow",
50-
domain: {
51-
tag: "labeledProduct",
52-
fields: {},
42+
export function test(...args: TestParams): TestResult {
43+
return callFunction$$(
44+
args,
45+
{
46+
"functionName": "test",
47+
"arrow": {
48+
"domain": {
49+
"fields": {},
50+
"tag": "labeledProduct"
5351
},
54-
codomain: {
55-
tag: "nil",
52+
"codomain": {
53+
"tag": "nil"
5654
},
57-
},
58-
names: {
59-
relay: "-relay-",
60-
getDataSrv: "getDataSrv",
61-
callbackSrv: "callbackSrv",
62-
responseSrv: "callbackSrv",
63-
responseFnName: "response",
64-
errorHandlingSrv: "errorHandlingSrv",
65-
errorFnName: "error",
66-
},
55+
"tag": "arrow"
6756
},
68-
test_script,
69-
);
57+
"names": {
58+
"relay": "-relay-",
59+
"getDataSrv": "getDataSrv",
60+
"callbackSrv": "callbackSrv",
61+
"responseSrv": "callbackSrv",
62+
"responseFnName": "response",
63+
"errorHandlingSrv": "errorHandlingSrv",
64+
"errorFnName": "error"
65+
}
66+
},
67+
test_script
68+
);
7069
}
71-
72-
/* eslint-enable */

0 commit comments

Comments
 (0)