Skip to content

Commit

Permalink
Added typescript definitions to js module (#757)
Browse files Browse the repository at this point in the history
* Added typescript definitions to js module

* Added license to the index definitions file

* Updated build process, reverted package.json version

* Added missing empty string after license header
  • Loading branch information
daniil-sloboda authored Dec 13, 2024
1 parent 9a062e1 commit c38e800
Show file tree
Hide file tree
Showing 7 changed files with 3,442 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Install protoc
run: |
mkdir protoc
Expand All @@ -87,6 +90,7 @@ jobs:
unzip protoc-22.3-linux-x86_64.zip
wget https://github.com/protocolbuffers/protobuf-javascript/releases/download/v3.21.2/protobuf-javascript-3.21.2-linux-x86_64.zip
unzip protobuf-javascript-3.21.2-linux-x86_64.zip
npm i -g [email protected]
PATH=$GITHUB_WORKSPACE/protoc/bin:$PATH protoc --version
- name: Run protoc
run: |
Expand Down
3 changes: 2 additions & 1 deletion compile_proto_wrappers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ protoc \
--python_out=. \
--pyi_out=. \
--js_out=import_style=commonjs,binary:js \
../ord-schema/proto/*.proto
../ord-schema/proto/*.proto \
--ts_out=./js/ \
23 changes: 23 additions & 0 deletions js/ord-schema/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright 2024 Open Reaction Database Project Authors
*
* 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 * as Dataset from './proto/dataset_pb';
import * as Reaction from './proto/reaction_pb';

export default {
...Dataset,
...Reaction,
}
2 changes: 2 additions & 0 deletions js/ord-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"google-protobuf": "<3.20"
},
"devDependencies": {
"@types/google-protobuf": "^3.15.12",
"jest": "^29.3.1",
"ts-protoc-gen": "^0.15.0",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1"
}
Expand Down
96 changes: 96 additions & 0 deletions js/ord-schema/proto/dataset_pb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* Copyright 2024 Open Reaction Database Project Authors
*
* 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.
*/

// package: ord
// file: ord-schema/proto/dataset.proto

import * as jspb from "google-protobuf";
import * as ord_schema_proto_reaction_pb from "../../ord-schema/proto/reaction_pb";

export class Dataset extends jspb.Message {
getName(): string;
setName(value: string): void;

getDescription(): string;
setDescription(value: string): void;

clearReactionsList(): void;
getReactionsList(): Array<ord_schema_proto_reaction_pb.Reaction>;
setReactionsList(value: Array<ord_schema_proto_reaction_pb.Reaction>): void;
addReactions(value?: ord_schema_proto_reaction_pb.Reaction, index?: number): ord_schema_proto_reaction_pb.Reaction;

clearReactionIdsList(): void;
getReactionIdsList(): Array<string>;
setReactionIdsList(value: Array<string>): void;
addReactionIds(value: string, index?: number): string;

getDatasetId(): string;
setDatasetId(value: string): void;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): Dataset.AsObject;
static toObject(includeInstance: boolean, msg: Dataset): Dataset.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: Dataset, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): Dataset;
static deserializeBinaryFromReader(message: Dataset, reader: jspb.BinaryReader): Dataset;
}

export namespace Dataset {
export type AsObject = {
name: string,
description: string,
reactionsList: Array<ord_schema_proto_reaction_pb.Reaction.AsObject>,
reactionIdsList: Array<string>,
datasetId: string,
}
}

export class DatasetExample extends jspb.Message {
getDatasetId(): string;
setDatasetId(value: string): void;

getDescription(): string;
setDescription(value: string): void;

getUrl(): string;
setUrl(value: string): void;

hasCreated(): boolean;
clearCreated(): void;
getCreated(): ord_schema_proto_reaction_pb.RecordEvent | undefined;
setCreated(value?: ord_schema_proto_reaction_pb.RecordEvent): void;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): DatasetExample.AsObject;
static toObject(includeInstance: boolean, msg: DatasetExample): DatasetExample.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: DatasetExample, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): DatasetExample;
static deserializeBinaryFromReader(message: DatasetExample, reader: jspb.BinaryReader): DatasetExample;
}

export namespace DatasetExample {
export type AsObject = {
datasetId: string,
description: string,
url: string,
created?: ord_schema_proto_reaction_pb.RecordEvent.AsObject,
}
}

Loading

0 comments on commit c38e800

Please sign in to comment.