Skip to content

Commit c7d063a

Browse files
authored
Separate internal APIs from public ones (#568)
Includes the following: * Marks internal modules and class members with @internal tag which is supported by both tsc and typedoc * Fixes typedoc flags, so that it now ignores internal stuff * Excludes internal modules and members from tsc output * Excludes source maps from tsc output * Moves typings for long and bluebird into non-dev dependencies, as TS users need them (see #537) * Adds test for declarations produced by tsc * Also includes some code improvements, like reformatting, interface extraction, etc.
1 parent e585515 commit c7d063a

File tree

382 files changed

+1416
-509
lines changed

Some content is hidden

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

382 files changed

+1416
-509
lines changed

.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea/
2+
.vscode/
23
.nyc_output/
34
benchmark/
45
code_samples/
@@ -7,6 +8,8 @@ docs/
78
scripts/
89
src/
910
test/
11+
tsconfig.json
12+
typedoc.json
1013
.editorconfig
1114
.eslintignore
1215
.eslintrc.js
@@ -15,6 +18,5 @@ test/
1518
DOCUMENTATION.md
1619
download-remote-controller.js
1720
*.iml
18-
.editorconfig
1921
*.jar
2022
*.log

DOCUMENTATION.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,7 @@ An example configuration is shown below.
26942694
```javascript
26952695
const readFile = util.promisify(fs.readFile);
26962696

2697-
class SSLFactory {
2697+
class SSLOptionsFactory {
26982698
async init(properties) {
26992699
const promises = [];
27002700
this.keepOrder = properties.userDefinedProperty1;
@@ -2732,7 +2732,7 @@ const cfg = {
27322732
network: {
27332733
ssl: {
27342734
enabled: true,
2735-
sslOptionsFactory: new SSLFactory(),
2735+
sslOptionsFactory: new SSLOptionsFactory(),
27362736
sslOptionsFactoryProperties: {
27372737
caPath: 'ca.pem',
27382738
keyPath: 'key.pem',
@@ -2744,7 +2744,7 @@ const cfg = {
27442744
};
27452745
```
27462746

2747-
The client calls the method `init` with the properties section defined in the configuration. Then the client calls the method `getSSLOptions` of `SSLFactory` to create the `options` object.
2747+
The client calls the `init()` method with the `properties` configuration option. Then the client calls the `getSSLOptions()` method of `SSLOptionsFactory` to create the `options` object.
27482748

27492749
## 8.2. Credentials
27502750

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
"version": "4.0.0",
44
"description": "Hazelcast - open source In-Memory Data Grid - client for Node.js",
55
"main": "lib/index.js",
6+
"types": "lib/index.d.ts",
67
"dependencies": {
78
"bluebird": "3.7.2",
8-
"long": "4.0.0"
9+
"@types/bluebird": "3.5.32",
10+
"long": "4.0.0",
11+
"@types/long": "4.0.1"
912
},
1013
"devDependencies": {
11-
"@types/bluebird": "^3.5.32",
12-
"@types/long": "^4.0.1",
1314
"@types/node": "^8.10.60",
1415
"@typescript-eslint/eslint-plugin": "^2.34.0",
1516
"@typescript-eslint/parser": "^2.34.0",
@@ -24,6 +25,7 @@
2425
"rimraf": "^3.0.2",
2526
"sinon": "^9.0.2",
2627
"thrift": "^0.12.0",
28+
"typedoc": "^0.18.0",
2729
"typescript": "^3.9.5",
2830
"winston": "^3.2.1"
2931
},
@@ -35,10 +37,11 @@
3537
"compile": "tsc",
3638
"pretest": "node download-remote-controller.js",
3739
"test": "mocha --recursive",
40+
"validate-user-code": "tsc --build test/user_code/tsconfig.json",
3841
"precoverage": "node download-remote-controller.js",
3942
"coverage": "rimraf coverage && nyc node_modules/mocha/bin/_mocha -- --recursive --reporter-options mochaFile=report.xml --reporter mocha-junit-reporter",
4043
"pregenerate-docs": "rimraf docs",
41-
"generate-docs": "typedoc --out docs/ --exclude **/codec/**/* src/ --excludeExternals --ignoreCompilerErrors --excludePrivate",
44+
"generate-docs": "typedoc --options typedoc.json",
4245
"lint": "eslint --ext .ts ."
4346
},
4447
"repository": {
@@ -57,6 +60,5 @@
5760
"bugs": {
5861
"url": "https://github.com/hazelcast/hazelcast-nodejs-client/issues"
5962
},
60-
"homepage": "https://github.com/hazelcast/hazelcast-nodejs-client#readme",
61-
"typings": "./lib/index"
63+
"homepage": "https://github.com/hazelcast/hazelcast-nodejs-client#readme"
6264
}

src/Address.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,30 @@ import {CLUSTER_DATA_FACTORY_ID, CLUSTER_DATA_ADDRESS_CLASS_ID} from './ClusterD
1919
import {DataInput, DataOutput} from './serialization/Data';
2020
import {IdentifiedDataSerializable} from './serialization/Serializable';
2121

22-
export class Address implements IdentifiedDataSerializable {
22+
/**
23+
* Represents a network address (e.g. of the client or a cluster member).
24+
*/
25+
export interface Address {
26+
27+
/**
28+
* Host name or IP address.
29+
*/
30+
host: string;
31+
32+
/**
33+
* Port number.
34+
*/
35+
port: number;
36+
37+
/**
38+
* Returns string representation of the address.
39+
*/
40+
toString(): string;
41+
42+
}
43+
44+
/** @internal */
45+
export class AddressImpl implements Address, IdentifiedDataSerializable {
2346

2447
factoryId = CLUSTER_DATA_FACTORY_ID;
2548
classId = CLUSTER_DATA_ADDRESS_CLASS_ID;
@@ -49,7 +72,7 @@ export class Address implements IdentifiedDataSerializable {
4972
output.writeUTF(this.host);
5073
}
5174

52-
equals(other: Address): boolean {
75+
equals(other: AddressImpl): boolean {
5376
if (other === this) {
5477
return true;
5578
}

src/BitsUtil.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
/** @ignore *//** */
1617

18+
/** @internal */
1719
export class BitsUtil {
1820
static BYTE_SIZE_IN_BYTES = 1;
1921
static BOOLEAN_SIZE_IN_BYTES = 1;

src/BuildInfo.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
/** @ignore *//** */
1617

1718
const clientVersion = require('../package.json').version;
1819

20+
/** @internal */
1921
export class BuildInfo {
2022

2123
public static readonly UNKNOWN_VERSION_ID = -1;

src/ClientInfo.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
import {Address} from './Address';
1818
import {UUID} from './core/UUID';
1919

20+
/**
21+
* Local information of the client.
22+
*/
2023
export class ClientInfo {
2124

2225
/**
@@ -43,4 +46,5 @@ export class ClientInfo {
4346
* Set of all labels of this client.
4447
*/
4548
labels: Set<string>;
49+
4650
}

src/ClientMessage.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
/** @ignore *//** */
1617

1718
import {BitsUtil} from './BitsUtil';
1819
import {ClientConnection} from './network/ClientConnection';
1920
import {FixSizedTypesCodec} from './codec/builtin/FixSizedTypesCodec';
2021

2122
const MESSAGE_TYPE_OFFSET = 0;
2223
const CORRELATION_ID_OFFSET = MESSAGE_TYPE_OFFSET + BitsUtil.INT_SIZE_IN_BYTES;
24+
/** @internal */
2325
export const RESPONSE_BACKUP_ACKS_OFFSET = CORRELATION_ID_OFFSET + BitsUtil.LONG_SIZE_IN_BYTES;
26+
/** @internal */
2427
export const PARTITION_ID_OFFSET = CORRELATION_ID_OFFSET + BitsUtil.LONG_SIZE_IN_BYTES;
2528
const FRAGMENTATION_ID_OFFSET = 0;
2629

30+
/** @internal */
2731
export const DEFAULT_FLAGS = 0;
2832
const BEGIN_FRAGMENT_FLAG = 1 << 15;
2933
const END_FRAGMENT_FLAG = 1 << 14;
@@ -34,8 +38,10 @@ const END_DATA_STRUCTURE_FLAG = 1 << 11;
3438
const IS_NULL_FLAG = 1 << 10;
3539
const IS_EVENT_FLAG = 1 << 9;
3640

41+
/** @internal */
3742
export const SIZE_OF_FRAME_LENGTH_AND_FLAGS = BitsUtil.INT_SIZE_IN_BYTES + BitsUtil.SHORT_SIZE_IN_BYTES;
3843

44+
/** @internal */
3945
export class Frame {
4046
content: Buffer;
4147
flags: number;
@@ -105,10 +111,14 @@ export class Frame {
105111
}
106112
}
107113

114+
/** @internal */
108115
export const NULL_FRAME = new Frame(Buffer.allocUnsafe(0), IS_NULL_FLAG);
116+
/** @internal */
109117
export const BEGIN_FRAME = new Frame(Buffer.allocUnsafe(0), BEGIN_DATA_STRUCTURE_FLAG);
118+
/** @internal */
110119
export const END_FRAME = new Frame(Buffer.allocUnsafe(0), END_DATA_STRUCTURE_FLAG);
111120

121+
/** @internal */
112122
export class ClientMessage {
113123
startFrame: Frame;
114124
endFrame: Frame;

src/ClusterDataFactory.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,20 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
/** @ignore *//** */
1617

1718
import {IdentifiedDataSerializable} from './serialization/Serializable';
18-
import {Address} from './Address';
19+
import {AddressImpl} from './Address';
1920

21+
/** @internal */
2022
export const CLUSTER_DATA_FACTORY_ID = 0;
23+
/** @internal */
2124
export const CLUSTER_DATA_ADDRESS_CLASS_ID = 1;
2225

26+
/** @internal */
2327
export function clusterDataFactory(classId: number): IdentifiedDataSerializable {
2428
if (classId === CLUSTER_DATA_ADDRESS_CLASS_ID) {
25-
return new Address();
29+
return new AddressImpl();
2630
}
2731
return null;
2832
}

src/DataStoreHashMap.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
/** @ignore *//** */
1617

1718
import {Data} from './serialization/Data';
1819

20+
/** @internal */
1921
export class DataKeyedHashMap<T> {
2022

2123
size: number;

src/DistributedObjectInfo.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
/** @ignore *//** */
1617

18+
/** @internal */
1719
export class DistributedObjectInfo {
1820
serviceName: string;
1921
name: string;

0 commit comments

Comments
 (0)