Skip to content

Commit 054a7bf

Browse files
authored
Mass rename (#48)
* Update terminology and namings * Use renamed to `avm` package
1 parent 9aa077e commit 054a7bf

17 files changed

+126
-152
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"author": "Fluence Labs",
2020
"license": "Apache-2.0",
2121
"dependencies": {
22-
"@fluencelabs/air-interpreter": "0.9.7",
22+
"@fluencelabs/avm": "0.9.6",
2323
"async": "3.2.0",
2424
"base64-js": "1.3.1",
2525
"bs58": "4.0.1",

src/FluenceClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import log from 'loglevel';
22
import Multiaddr from 'multiaddr';
33
import PeerId, { isPeerId } from 'peer-id';
44

5-
import { AquaCallHandler } from './internal/AquaHandler';
5+
import { CallServiceHandler } from './internal/CallServiceHandler';
66
import { ClientImpl } from './internal/ClientImpl';
77
import { PeerIdB58 } from './internal/commonTypes';
88
import { FluenceConnectionOptions } from './internal/FluenceConnection';
@@ -34,7 +34,7 @@ export interface FluenceClient {
3434
* Please note, that the handler is combined with the handler from RequestFlow before the execution occures.
3535
* After this combination, middlewares from RequestFlow are executed before client handler's middlewares.
3636
*/
37-
readonly aquaCallHandler: AquaCallHandler;
37+
readonly callServiceHandler: CallServiceHandler;
3838

3939
/**
4040
* Disconnects the client from the network
@@ -84,7 +84,7 @@ export const createClient = async (
8484
}
8585

8686
const client = new ClientImpl(peerId);
87-
await client.initAquamarineRuntime();
87+
await client.initAirInterpreter();
8888

8989
if (connectTo) {
9090
let theAddress: Multiaddr;

src/__test__/integration/builtins.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describe('Builtins usage suite', () => {
101101
`;
102102

103103
let resMakingPromise = new Promise((resolve) => {
104-
client.aquaCallHandler.on('test', 'test1', (args, _) => {
104+
client.callServiceHandler.on('test', 'test1', (args, _) => {
105105
resolve([...args]);
106106
return {};
107107
});

src/__test__/integration/client.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('Typescript usage suite', () => {
5858
const client2 = await createClient(nodes[0].multiaddr);
5959

6060
let resMakingPromise = new Promise((resolve) => {
61-
client2.aquaCallHandler.onEvent('test', 'test', (args, _) => {
61+
client2.callServiceHandler.onEvent('test', 'test', (args, _) => {
6262
resolve([...args]);
6363
return {};
6464
});
@@ -241,8 +241,7 @@ describe('Typescript usage suite', () => {
241241

242242
// assert
243243
await expect(res).rejects.toMatchObject({
244-
error:
245-
"Local service error: ret_code is 1024, error message is '\"The handler did not set any result. Make sure you are calling the right peer and the handler has been registered. Original request data was: serviceId='peer' fnName='identify' args=''\"'",
244+
error: "Local service error: ret_code is 1024, error message is '\"The handler did not set any result. Make sure you are calling the right peer and the handler has been registered. Original request data was: serviceId='peer' fnName='identify' args=''\"'",
246245
instruction: 'call %init_peer_id% ("peer" "identify") [] res',
247246
});
248247
});

src/__test__/unit/AquaHandler.spec.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { AquaCallHandler, errorHandler } from '../../internal/AquaHandler';
2-
import { ResultCodes } from '../../internal/commonTypes';
1+
import { CallServiceHandler, errorHandler, ResultCodes } from '../../internal/CallServiceHandler';
32

43
const req = () => ({
54
serviceId: 'service',
@@ -15,10 +14,10 @@ const res = () => ({
1514
res,
1615
});
1716

18-
describe('Aqua handler tests', () => {
17+
describe('Call service handler tests', () => {
1918
it('Should work without middlewares', () => {
2019
// arrange
21-
const handler = new AquaCallHandler();
20+
const handler = new CallServiceHandler();
2221

2322
// act
2423
const res = handler.execute(req());
@@ -29,7 +28,7 @@ describe('Aqua handler tests', () => {
2928

3029
it('Should work with no-op middleware', () => {
3130
// arrange
32-
const handler = new AquaCallHandler();
31+
const handler = new CallServiceHandler();
3332
handler.use((req, res, next) => {
3433
next();
3534
});
@@ -43,7 +42,7 @@ describe('Aqua handler tests', () => {
4342

4443
it('Should work with two overlapping middlewares', () => {
4544
// arrange
46-
const handler = new AquaCallHandler();
45+
const handler = new CallServiceHandler();
4746
handler
4847
.use((req, res, next) => {
4948
res.result = { hello: 'world' };
@@ -64,7 +63,7 @@ describe('Aqua handler tests', () => {
6463

6564
it('Should work with two NON-overlapping middlewares', () => {
6665
// arrange
67-
const handler = new AquaCallHandler();
66+
const handler = new CallServiceHandler();
6867
handler
6968
.use((req, res, next) => {
7069
res.result = {};
@@ -90,7 +89,7 @@ describe('Aqua handler tests', () => {
9089

9190
it('Should work with provided error handling middleware', () => {
9291
// arrange
93-
const handler = new AquaCallHandler();
92+
const handler = new CallServiceHandler();
9493

9594
handler.use(errorHandler);
9695
handler.use((req, res, next) => {
@@ -110,7 +109,7 @@ describe('Aqua handler tests', () => {
110109
describe('Service handler tests', () => {
111110
it('Should register service function', () => {
112111
// arrange
113-
const handler = new AquaCallHandler();
112+
const handler = new CallServiceHandler();
114113
handler.on('service', 'function', (args) => {
115114
return { called: args };
116115
});
@@ -132,7 +131,7 @@ describe('Aqua handler tests', () => {
132131

133132
it('Should UNregister service function', () => {
134133
// arrange
135-
const handler = new AquaCallHandler();
134+
const handler = new CallServiceHandler();
136135
const unreg = handler.on('service', 'function', (args) => {
137136
return { called: args };
138137
});
@@ -154,7 +153,7 @@ describe('Aqua handler tests', () => {
154153

155154
it('Should register event', async () => {
156155
// arrange
157-
const handler = new AquaCallHandler();
156+
const handler = new CallServiceHandler();
158157
const returnPromise = new Promise((resolve) => {
159158
handler.onEvent('service', 'function', (args) => {
160159
resolve({ called: args });
@@ -178,7 +177,7 @@ describe('Aqua handler tests', () => {
178177

179178
it('Should UNregister event', () => {
180179
// arrange
181-
const handler = new AquaCallHandler();
180+
const handler = new CallServiceHandler();
182181
const unreg = handler.onEvent('service', 'function', (args) => {
183182
// don't care
184183
});
@@ -200,7 +199,7 @@ describe('Aqua handler tests', () => {
200199

201200
it('Should register multiple service functions', () => {
202201
// arrange
203-
const handler = new AquaCallHandler();
202+
const handler = new CallServiceHandler();
204203
handler.on('service', 'function1', (args) => {
205204
return 'called function1';
206205
});
@@ -233,7 +232,7 @@ describe('Aqua handler tests', () => {
233232

234233
it('Should override previous function registration', () => {
235234
// arrange
236-
const handler = new AquaCallHandler();
235+
const handler = new CallServiceHandler();
237236
handler.on('service', 'function', (args) => {
238237
return { called: args };
239238
});
@@ -259,11 +258,11 @@ describe('Aqua handler tests', () => {
259258
describe('Middleware combination tests', () => {
260259
it('Should work with NON overlapping function registration', () => {
261260
// arrange
262-
const base = new AquaCallHandler();
261+
const base = new CallServiceHandler();
263262
base.on('service', 'function1', (args) => {
264263
return 'called function1';
265264
});
266-
const another = new AquaCallHandler();
265+
const another = new CallServiceHandler();
267266
base.on('service', 'function2', (args) => {
268267
return 'called function2';
269268
});
@@ -295,11 +294,11 @@ describe('Aqua handler tests', () => {
295294

296295
it('Should work with overlapping function registration', () => {
297296
// arrange
298-
const base = new AquaCallHandler();
297+
const base = new CallServiceHandler();
299298
base.on('service', 'function', (args) => {
300299
return { called: args };
301300
});
302-
const another = new AquaCallHandler();
301+
const another = new CallServiceHandler();
303302
another.on('service', 'function', (args) => {
304303
return 'overridden';
305304
});

src/__test__/unit/RequestFlow.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import PeerId from 'peer-id';
2-
import { genUUID } from '../../internal/particle';
31
import { seedToPeerId } from '../../internal/peerIdUtils';
42
import { RequestFlow } from '../../internal/RequestFlow';
53

src/__test__/unit/air.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('== AIR suite', () => {
3939
client = await createClient();
4040

4141
let res;
42-
client.aquaCallHandler.on(serviceId, fnName, (args, _) => {
42+
client.callServiceHandler.on(serviceId, fnName, (args, _) => {
4343
res = args[0];
4444
return res;
4545
});
@@ -118,13 +118,13 @@ describe('== AIR suite', () => {
118118

119119
client = await createClient();
120120

121-
client.aquaCallHandler.on(makeDataServiceId, makeDataFnName, (args, _) => {
121+
client.callServiceHandler.on(makeDataServiceId, makeDataFnName, (args, _) => {
122122
return {
123123
field: 42,
124124
};
125125
});
126126
let res;
127-
client.aquaCallHandler.on(getDataServiceId, getDataFnName, (args, tetraplets) => {
127+
client.callServiceHandler.on(getDataServiceId, getDataFnName, (args, tetraplets) => {
128128
res = {
129129
args: args,
130130
tetraplets: tetraplets,
@@ -156,23 +156,23 @@ describe('== AIR suite', () => {
156156
const serviceId1 = 'check1';
157157
const fnName1 = 'fn1';
158158
let res1;
159-
client.aquaCallHandler.on(serviceId1, fnName1, (args, _) => {
159+
client.callServiceHandler.on(serviceId1, fnName1, (args, _) => {
160160
res1 = args[0];
161161
return res1;
162162
});
163163

164164
const serviceId2 = 'check2';
165165
const fnName2 = 'fn2';
166166
let res2;
167-
client.aquaCallHandler.on(serviceId2, fnName2, (args, _) => {
167+
client.callServiceHandler.on(serviceId2, fnName2, (args, _) => {
168168
res2 = args[0];
169169
return res2;
170170
});
171171

172172
const serviceId3 = 'check3';
173173
const fnName3 = 'fn3';
174174
let res3;
175-
client.aquaCallHandler.on(serviceId3, fnName3, (args, _) => {
175+
client.callServiceHandler.on(serviceId3, fnName3, (args, _) => {
176176
res3 = args;
177177
return res3;
178178
});

src/__test__/unit/ast.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { AirInterpreter } from '@fluencelabs/air-interpreter';
2-
import { genUUID } from '../../internal/particle';
1+
import { AirInterpreter } from '@fluencelabs/avm';
32

43
describe('== AST parsing suite', () => {
54
it('parse simple script and return ast', async function () {

src/api.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { SecurityTetraplet } from './internal/commonTypes';
21
import { RequestFlowBuilder } from './internal/RequestFlowBuilder';
32
import { FluenceClient } from './FluenceClient';
4-
import { AquaResultType } from './internal/AquaHandler';
3+
import { CallServiceResultType } from './internal/CallServiceHandler';
4+
import { SecurityTetraplet } from '@fluencelabs/avm';
55

66
/**
77
* The class representing Particle - a data structure used to perform operations on Fluence Network. It originates on some peer in the network, travels the network through a predefined path, triggering function execution along its way.
@@ -15,7 +15,7 @@ export class Particle {
1515
* Creates a particle with specified parameters.
1616
* @param { String }script - Air script which defines the execution of a particle – its path, functions it triggers on peers, and so on.
1717
* @param { Map<string, any> | Record<string, any> } data - Variables passed to the particle in the form of either JS Map or JS object with keys representing variable names and values representing values correspondingly
18-
* @param { [Number]=7000 } ttl - Time to live, a timout after which the particle execution is stopped by Aquamarine.
18+
* @param { [Number]=7000 } ttl - Time to live, a timout after which the particle execution is stopped by AVM.
1919
*/
2020
constructor(script: string, data?: Map<string, any> | Record<string, any>, ttl?: number) {
2121
this.script = script;
@@ -68,19 +68,19 @@ const makeKey = (client: FluenceClient, serviceId: string, fnName: string) => {
6868
};
6969

7070
/**
71-
* Registers a function which can be called on the client from Aquamarine. The registration is per client basis.
71+
* Registers a function which can be called on the client from AVM. The registration is per client basis.
7272
* @param { FluenceClient } client - The Fluence Client instance.
73-
* @param { string } serviceId - The identifier of service which would be used to make calls from Aquamarine
74-
* @param { string } fnName - The identifier of function which would be used to make calls from Aquamarine
75-
* @param { (args: any[], tetraplets: SecurityTetraplet[][]) => object | boolean | number | string } handler - The handler which would be called by Aquamarine infrastructure. The result is any object passed back to Aquamarine
73+
* @param { string } serviceId - The identifier of service which would be used to make calls from AVM
74+
* @param { string } fnName - The identifier of function which would be used to make calls from AVM
75+
* @param { (args: any[], tetraplets: SecurityTetraplet[][]) => object | boolean | number | string } handler - The handler which would be called by AVM. The result is any object passed back to AVM
7676
*/
7777
export const registerServiceFunction = (
7878
client: FluenceClient,
7979
serviceId: string,
8080
fnName: string,
81-
handler: (args: any[], tetraplets: SecurityTetraplet[][]) => AquaResultType,
81+
handler: (args: any[], tetraplets: SecurityTetraplet[][]) => CallServiceResultType,
8282
) => {
83-
const unregister = client.aquaCallHandler.on(serviceId, fnName, handler);
83+
const unregister = client.callServiceHandler.on(serviceId, fnName, handler);
8484
handlersUnregistratorsMap.set(makeKey(client, serviceId, fnName), unregister);
8585
};
8686

@@ -105,12 +105,12 @@ export const unregisterServiceFunction = (
105105
};
106106

107107
/**
108-
* Registers an event-like handler for all calls to the specific service\function pair from from Aquamarine. The registration is per client basis. Return a function which when called removes the subscription.
108+
* Registers an event-like handler for all calls to the specific service\function pair from AVM. The registration is per client basis. Return a function which when called removes the subscription.
109109
* Same as registerServiceFunction which immediately returns empty object.
110110
* @param { FluenceClient } client - The Fluence Client instance.
111-
* @param { string } serviceId - The identifier of service calls to which from Aquamarine are transformed into events.
112-
* @param { string } fnName - The identifier of function calls to which from Aquamarine are transformed into events.
113-
* @param { (args: any[], tetraplets: SecurityTetraplet[][]) => object } handler - The handler which would be called by Aquamarine infrastructure
111+
* @param { string } serviceId - The identifier of service calls to which from AVM are transformed into events.
112+
* @param { string } fnName - The identifier of function calls to which from AVM are transformed into events.
113+
* @param { (args: any[], tetraplets: SecurityTetraplet[][]) => object } handler - The handler which would be called by AVM
114114
* @returns { Function } - A function which when called removes the subscription.
115115
*/
116116
export const subscribeToEvent = (
@@ -139,7 +139,7 @@ export const subscribeToEvent = (
139139
* @param { Particle } particle - The particle to send.
140140
* @param { string } callbackFnName - The identifier of function which should be used in Air script to pass the data to fetch "promise"
141141
* @param { [string]='_callback' } callbackServiceId - The service identifier which should be used in Air script to pass the data to fetch "promise"
142-
* @returns { Promise<T> } - A promise which would be resolved with the data returned from Aquamarine
142+
* @returns { Promise<T> } - A promise which would be resolved with the data returned from AVM
143143
*/
144144
export const sendParticleAsFetch = async <T>(
145145
client: FluenceClient,

src/api.unstable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { RequestFlowBuilder } from './internal/RequestFlowBuilder';
2-
export * from './internal/AquaHandler';
2+
export * from './internal/CallServiceHandler';

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
*/
1616

1717
export { seedToPeerId, peerIdToSeed, generatePeerId } from './internal/peerIdUtils';
18-
export { SecurityTetraplet, PeerIdB58 } from './internal/commonTypes';
18+
export { PeerIdB58 } from './internal/commonTypes';
19+
export { SecurityTetraplet } from '@fluencelabs/avm';
1920
export * from './api';
2021
export * from './FluenceClient';
2122
export * from './internal/builtins';

0 commit comments

Comments
 (0)