@olane/o-client-limited 0.7.12-alpha.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,34 @@
1
+ # Dual License: MIT OR Apache-2.0
2
+
3
+ Copyright (c) 2025 Olane Inc.
4
+
5
+ Olane OS is dual-licensed under your choice of either:
6
+
7
+ - **MIT License** (LICENSE-MIT or https://opensource.org/licenses/MIT)
8
+ - **Apache License, Version 2.0** (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
9
+
10
+ ## Why Dual Licensing?
11
+
12
+ Dual licensing provides developers with flexibility when integrating Olane OS into their projects:
13
+
14
+ - **Choose MIT**: If you prefer a simple, permissive license without patent provisions
15
+ - **Choose Apache 2.0**: If you desire explicit patent protection and other features of the Apache license
16
+
17
+ You may choose either license to govern your use of this software.
18
+
19
+ ## License Terms
20
+
21
+ ### MIT License
22
+ The MIT license is very permissive and allows users to do almost anything with the software, including using, copying, modifying, merging, publishing, distributing, and selling it. The primary requirement is that the original copyright and license notice must be included in all copies of the software.
23
+
24
+ See LICENSE-MIT for the full license text.
25
+
26
+ ### Apache License 2.0
27
+ The Apache License 2.0 is also a permissive free software license. It grants users the right to use, modify, and distribute the software. It also includes provisions regarding patent grants, which are not present in the MIT license.
28
+
29
+ See LICENSE-APACHE for the full license text.
30
+
31
+ ## Contributing
32
+
33
+ Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual-licensed as above, without any additional terms or conditions.
34
+
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Limited Client
2
+
3
+ Re-use connections + streams for libp2p.
@@ -0,0 +1,3 @@
1
+ export * from './o-limited-connection.js';
2
+ export * from './o-limited-connection-manager.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './o-limited-connection.js';
2
+ export * from './o-limited-connection-manager.js';
@@ -0,0 +1,11 @@
1
+ import { oNodeConnectionManager } from '@olane/o-node';
2
+ import { oConnectionConfig } from '@olane/o-core';
3
+ import { oLimitedConnection } from './o-limited-connection.js';
4
+ export declare class oLimitedConnectionManager extends oNodeConnectionManager {
5
+ private readonly _token?;
6
+ /**
7
+ * Override connect to return oPrivateConnection with _token injected
8
+ */
9
+ connect(config: oConnectionConfig): Promise<oLimitedConnection>;
10
+ }
11
+ //# sourceMappingURL=o-limited-connection-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-limited-connection-manager.d.ts","sourceRoot":"","sources":["../../../src/connection/o-limited-connection-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,qBAAa,yBAA0B,SAAQ,sBAAsB;IACnE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;IAEjC;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA4BtE"}
@@ -0,0 +1,29 @@
1
+ import { oNodeConnectionManager } from '@olane/o-node';
2
+ import { oLimitedConnection } from './o-limited-connection.js';
3
+ export class oLimitedConnectionManager extends oNodeConnectionManager {
4
+ /**
5
+ * Override connect to return oPrivateConnection with _token injected
6
+ */
7
+ async connect(config) {
8
+ const { address, nextHopAddress, callerAddress } = config;
9
+ // First time setup connection
10
+ try {
11
+ const p2pConnection = await this.getOrCreateConnection(nextHopAddress, address);
12
+ const connection = new oLimitedConnection({
13
+ nextHopAddress: nextHopAddress,
14
+ address: address,
15
+ p2pConnection: p2pConnection,
16
+ callerAddress: callerAddress,
17
+ runOnLimitedConnection: this.config.runOnLimitedConnection ?? false,
18
+ });
19
+ return connection;
20
+ }
21
+ catch (error) {
22
+ this.logger.error(`[${callerAddress?.toString() || 'unknown'}] Error connecting to address! Next hop:` +
23
+ nextHopAddress +
24
+ ' With Address:' +
25
+ address.toString(), error);
26
+ throw error;
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,7 @@
1
+ import { Stream } from '@olane/o-config';
2
+ import { oNodeConnection } from '@olane/o-node';
3
+ export declare class oLimitedConnection extends oNodeConnection {
4
+ getOrCreateStream(): Promise<Stream>;
5
+ postTransmit(stream: Stream): Promise<void>;
6
+ }
7
+ //# sourceMappingURL=o-limited-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-limited-connection.d.ts","sourceRoot":"","sources":["../../../src/connection/o-limited-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAQzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,qBAAa,kBAAmB,SAAQ,eAAe;IAC/C,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAqBpC,YAAY,CAAC,MAAM,EAAE,MAAM;CAGlC"}
@@ -0,0 +1,21 @@
1
+ import { oError, oErrorCodes, } from '@olane/o-core';
2
+ import { oNodeConnection } from '@olane/o-node';
3
+ export class oLimitedConnection extends oNodeConnection {
4
+ async getOrCreateStream() {
5
+ if (this.p2pConnection.status !== 'open') {
6
+ throw new oError(oErrorCodes.INVALID_STATE, 'Connection not open');
7
+ }
8
+ // check if we have an open stream
9
+ const stream = this.p2pConnection.streams.find((stream) => stream.status === 'open');
10
+ if (stream) {
11
+ this.logger.debug('Reusing existing stream for address: ' +
12
+ this.nextHopAddress.toString());
13
+ return stream;
14
+ }
15
+ this.logger.debug('Creating new stream for address: ' + this.nextHopAddress.toString());
16
+ return super.getOrCreateStream();
17
+ }
18
+ async postTransmit(stream) {
19
+ // do nothing as we don't want to close the stream
20
+ }
21
+ }
@@ -0,0 +1,3 @@
1
+ export * from './o-limited.tool.js';
2
+ export * from './connection/index.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './o-limited.tool.js';
2
+ export * from './connection/index.js';
@@ -0,0 +1,5 @@
1
+ import { oNodeTool } from '@olane/o-node';
2
+ export declare class oLimitedTool extends oNodeTool {
3
+ initConnectionManager(): Promise<void>;
4
+ }
5
+ //# sourceMappingURL=o-limited.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-limited.tool.d.ts","sourceRoot":"","sources":["../../src/o-limited.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,qBAAa,YAAa,SAAQ,SAAS;IACnC,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ7C"}
@@ -0,0 +1,12 @@
1
+ import { oNodeTool } from '@olane/o-node';
2
+ import { oLimitedConnectionManager } from './connection/o-limited-connection-manager.js';
3
+ export class oLimitedTool extends oNodeTool {
4
+ async initConnectionManager() {
5
+ this.connectionManager = new oLimitedConnectionManager({
6
+ p2pNode: this.p2pNode,
7
+ defaultReadTimeoutMs: this.config.connectionTimeouts?.readTimeoutMs,
8
+ defaultDrainTimeoutMs: this.config.connectionTimeouts?.drainTimeoutMs,
9
+ runOnLimitedConnection: this.config.runOnLimitedConnection ?? false,
10
+ });
11
+ }
12
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=method.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method.spec.d.ts","sourceRoot":"","sources":["../../test/method.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ // import { oAddress, NodeState, oRequest } from '@olane/o-core';
3
+ // import { oVirtualTool } from '../src/virtual.tool.js';
4
+ // import { expect } from 'chai';
5
+ // describe('o-tool @methods', () => {
6
+ // it('should call the hello_world method', async () => {
7
+ // const node = new oVirtualTool({
8
+ // address: new oAddress('o://test'),
9
+ // leader: null,
10
+ // parent: null,
11
+ // });
12
+ // await node.start();
13
+ // expect(node.state).to.equal(NodeState.RUNNING);
14
+ // // call the tool
15
+ // const req = new oRequest({
16
+ // method: 'hello_world',
17
+ // id: '123',
18
+ // params: {
19
+ // _connectionId: '123',
20
+ // _requestMethod: 'hello_world',
21
+ // },
22
+ // });
23
+ // const data = await node.callMyTool(req);
24
+ // expect(data.message).to.equal('Hello, world!');
25
+ // // stop the node
26
+ // await node.stop();
27
+ // expect(node.state).to.equal(NodeState.STOPPED);
28
+ // });
29
+ // });
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@olane/o-client-limited",
3
+ "version": "0.7.12-alpha.51",
4
+ "type": "module",
5
+ "main": "dist/src/index.js",
6
+ "types": "dist/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/src/index.d.ts",
10
+ "default": "./dist/src/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist/**/*",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "scripts": {
19
+ "test": "aegir test",
20
+ "test:node": "aegir test -t node",
21
+ "test:browser": "aegir test -t browser",
22
+ "build": "tsc",
23
+ "deep:clean": "rm -rf node_modules && rm package-lock.json",
24
+ "start:prod": "node dist/index.js",
25
+ "prepublishOnly": "npm run build",
26
+ "lint": "eslint src/**/*.ts"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/olane-labs/olane.git"
31
+ },
32
+ "author": "oLane Inc.",
33
+ "license": "(MIT OR Apache-2.0)",
34
+ "description": "oLane client limited connection manager",
35
+ "devDependencies": {
36
+ "@eslint/eslintrc": "^3.3.1",
37
+ "@eslint/js": "^9.29.0",
38
+ "@tsconfig/node20": "^20.1.6",
39
+ "@types/jest": "^30.0.0",
40
+ "@typescript-eslint/eslint-plugin": "^8.34.1",
41
+ "@typescript-eslint/parser": "^8.34.1",
42
+ "aegir": "^47.0.21",
43
+ "eslint": "^9.29.0",
44
+ "eslint-config-prettier": "^10.1.6",
45
+ "eslint-plugin-prettier": "^5.5.0",
46
+ "globals": "^16.2.0",
47
+ "jest": "^30.0.0",
48
+ "prettier": "^3.5.3",
49
+ "ts-jest": "^29.4.0",
50
+ "ts-node": "^10.9.2",
51
+ "tsconfig-paths": "^4.2.0",
52
+ "tsx": "^4.20.3",
53
+ "typescript": "5.4.5"
54
+ },
55
+ "dependencies": {
56
+ "@olane/o-config": "0.7.12-alpha.51",
57
+ "@olane/o-core": "0.7.12-alpha.51",
58
+ "@olane/o-lane": "0.7.12-alpha.51",
59
+ "@olane/o-protocol": "0.7.12-alpha.51",
60
+ "@olane/o-tool": "0.7.12-alpha.51",
61
+ "debug": "^4.4.1",
62
+ "dotenv": "^16.5.0"
63
+ },
64
+ "gitHead": "b877e1e95a2bf32845ec30072eb72422fd25aba7"
65
+ }