Skip to content

Commit 0fc6db0

Browse files
authored
Merge pull request #145 from nitrictech/remove-api-dep
build: generate proto sources locally.
2 parents b7c744b + d44b027 commit 0fc6db0

Some content is hidden

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

45 files changed

+35424
-40
lines changed

.github/workflows/test.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ jobs:
2323
run: yarn license:header:check
2424
- name: OSS License Whitelist Check
2525
run: yarn license:check
26+
- name: Check sources
27+
run: |
28+
yarn gen:proto
29+
git add .
30+
git diff --cached --quiet
2631
- name: Build
2732
run: yarn build
2833
- name: Run tests

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ typings/
9292

9393
lib/
9494

95-
*_pb.*
95+
contracts/

codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ignore:
2+
- "./src/gen"

jest.config.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

jest.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { pathsToModuleNameMapper } from 'ts-jest';
2+
import { compilerOptions } from './tsconfig.json';
3+
4+
module.exports = {
5+
preset: 'ts-jest',
6+
testEnvironment: 'node',
7+
// Ignore the auto generated code for code coverage
8+
roots: ['<rootDir>'],
9+
coveragePathIgnorePatterns: ['src/gen/'],
10+
modulePaths: [compilerOptions.baseUrl],
11+
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths,/*, { prefix: '<rootDir>/' } */),
12+
};

licenseconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
"**/*.md",
1414
"*.lock",
1515
"*.html",
16-
"**/.eslintignore"
16+
"**/.eslintignore",
17+
"makefile",
18+
"./src/gen/**/*",
19+
"codecov.yml"
1720
],
1821
"license": "./assets/license_header.txt",
1922
"licenseFormats": {

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@nitric/sdk",
33
"description": "Nitric NodeJS client sdk",
4+
"nitric": "v0.20.0-rc.2",
45
"author": "Nitric <https://github.com/nitrictech>",
56
"repository": "https://github.com/nitrictech/node-sdk",
67
"main": "lib/index.js",
@@ -18,7 +19,9 @@
1819
"license:header:remove": "license-check-and-add remove -f ./licenseconfig.json",
1920
"license:header:add": "license-check-and-add add -f ./licenseconfig.json",
2021
"license:header:check": "license-check-and-add check -f ./licenseconfig.json",
21-
"license:check": "licensee --production"
22+
"license:check": "licensee --production",
23+
"download:contracts": "curl -L https://github.com/nitrictech/nitric/releases/download/${npm_package_nitric}/contracts.tgz -o contracts.tgz && tar xvzf contracts.tgz && rm contracts.tgz",
24+
"gen:proto": "yarn run download:contracts && mkdir -p ./src/gen && grpc_tools_node_protoc --ts_out=service=grpc-node,mode=grpc-js:./src/gen --js_out=import_style=commonjs,binary:./src/gen --grpc_out=grpc_js:./src/gen -I ./contracts ./contracts/**/*.proto ./contracts/proto/**/*/*.proto"
2225
},
2326
"contributors": [
2427
"Jye Cusch <jye.cusch@nitric.io>",
@@ -27,7 +30,6 @@
2730
],
2831
"dependencies": {
2932
"@grpc/grpc-js": "^1.5.9",
30-
"@nitric/api": "v0.20.0-rc.2",
3133
"google-protobuf": "3.14.0",
3234
"tslib": "^2.1.0"
3335
},
@@ -41,13 +43,14 @@
4143
}
4244
},
4345
"devDependencies": {
44-
"@types/google-protobuf": "3.2.7",
46+
"@types/google-protobuf": "^3.15.6",
4547
"@types/jest": "^26.0.15",
4648
"@typescript-eslint/eslint-plugin": "^4.22.0",
4749
"@typescript-eslint/parser": "^4.22.0",
4850
"codecov": "^3.8.3",
4951
"eslint": "^7.24.0",
5052
"glob-run": "^0.1.7",
53+
"grpc-tools": "^1.11.3",
5154
"husky": "^6.0.0",
5255
"jest": "^26.6.1",
5356
"license-check-and-add": "^4.0.2",
@@ -56,6 +59,8 @@
5659
"prettier": "^2.2.1",
5760
"standard-version": "^9.0.0",
5861
"ts-jest": "^26.4.3",
62+
"ts-node": "^10.9.1",
63+
"ts-protoc-gen": "^0.15.0",
5964
"typescript": "^3.3"
6065
},
6166
"license-check-config": {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// GENERATED CODE -- DO NOT EDIT!
2+
3+
// package: nitric.document.v1
4+
// file: proto/document/v1/document.proto
5+
6+
import * as proto_document_v1_document_pb from "../../../proto/document/v1/document_pb";
7+
import * as grpc from "@grpc/grpc-js";
8+
9+
interface IDocumentServiceService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
10+
get: grpc.MethodDefinition<proto_document_v1_document_pb.DocumentGetRequest, proto_document_v1_document_pb.DocumentGetResponse>;
11+
set: grpc.MethodDefinition<proto_document_v1_document_pb.DocumentSetRequest, proto_document_v1_document_pb.DocumentSetResponse>;
12+
delete: grpc.MethodDefinition<proto_document_v1_document_pb.DocumentDeleteRequest, proto_document_v1_document_pb.DocumentDeleteResponse>;
13+
query: grpc.MethodDefinition<proto_document_v1_document_pb.DocumentQueryRequest, proto_document_v1_document_pb.DocumentQueryResponse>;
14+
queryStream: grpc.MethodDefinition<proto_document_v1_document_pb.DocumentQueryStreamRequest, proto_document_v1_document_pb.DocumentQueryStreamResponse>;
15+
}
16+
17+
export const DocumentServiceService: IDocumentServiceService;
18+
19+
export interface IDocumentServiceServer extends grpc.UntypedServiceImplementation {
20+
get: grpc.handleUnaryCall<proto_document_v1_document_pb.DocumentGetRequest, proto_document_v1_document_pb.DocumentGetResponse>;
21+
set: grpc.handleUnaryCall<proto_document_v1_document_pb.DocumentSetRequest, proto_document_v1_document_pb.DocumentSetResponse>;
22+
delete: grpc.handleUnaryCall<proto_document_v1_document_pb.DocumentDeleteRequest, proto_document_v1_document_pb.DocumentDeleteResponse>;
23+
query: grpc.handleUnaryCall<proto_document_v1_document_pb.DocumentQueryRequest, proto_document_v1_document_pb.DocumentQueryResponse>;
24+
queryStream: grpc.handleServerStreamingCall<proto_document_v1_document_pb.DocumentQueryStreamRequest, proto_document_v1_document_pb.DocumentQueryStreamResponse>;
25+
}
26+
27+
export class DocumentServiceClient extends grpc.Client {
28+
constructor(address: string, credentials: grpc.ChannelCredentials, options?: object);
29+
get(argument: proto_document_v1_document_pb.DocumentGetRequest, callback: grpc.requestCallback<proto_document_v1_document_pb.DocumentGetResponse>): grpc.ClientUnaryCall;
30+
get(argument: proto_document_v1_document_pb.DocumentGetRequest, metadataOrOptions: grpc.Metadata | grpc.CallOptions | null, callback: grpc.requestCallback<proto_document_v1_document_pb.DocumentGetResponse>): grpc.ClientUnaryCall;
31+
get(argument: proto_document_v1_document_pb.DocumentGetRequest, metadata: grpc.Metadata | null, options: grpc.CallOptions | null, callback: grpc.requestCallback<proto_document_v1_document_pb.DocumentGetResponse>): grpc.ClientUnaryCall;
32+
set(argument: proto_document_v1_document_pb.DocumentSetRequest, callback: grpc.requestCallback<proto_document_v1_document_pb.DocumentSetResponse>): grpc.ClientUnaryCall;
33+
set(argument: proto_document_v1_document_pb.DocumentSetRequest, metadataOrOptions: grpc.Metadata | grpc.CallOptions | null, callback: grpc.requestCallback<proto_document_v1_document_pb.DocumentSetResponse>): grpc.ClientUnaryCall;
34+
set(argument: proto_document_v1_document_pb.DocumentSetRequest, metadata: grpc.Metadata | null, options: grpc.CallOptions | null, callback: grpc.requestCallback<proto_document_v1_document_pb.DocumentSetResponse>): grpc.ClientUnaryCall;
35+
delete(argument: proto_document_v1_document_pb.DocumentDeleteRequest, callback: grpc.requestCallback<proto_document_v1_document_pb.DocumentDeleteResponse>): grpc.ClientUnaryCall;
36+
delete(argument: proto_document_v1_document_pb.DocumentDeleteRequest, metadataOrOptions: grpc.Metadata | grpc.CallOptions | null, callback: grpc.requestCallback<proto_document_v1_document_pb.DocumentDeleteResponse>): grpc.ClientUnaryCall;
37+
delete(argument: proto_document_v1_document_pb.DocumentDeleteRequest, metadata: grpc.Metadata | null, options: grpc.CallOptions | null, callback: grpc.requestCallback<proto_document_v1_document_pb.DocumentDeleteResponse>): grpc.ClientUnaryCall;
38+
query(argument: proto_document_v1_document_pb.DocumentQueryRequest, callback: grpc.requestCallback<proto_document_v1_document_pb.DocumentQueryResponse>): grpc.ClientUnaryCall;
39+
query(argument: proto_document_v1_document_pb.DocumentQueryRequest, metadataOrOptions: grpc.Metadata | grpc.CallOptions | null, callback: grpc.requestCallback<proto_document_v1_document_pb.DocumentQueryResponse>): grpc.ClientUnaryCall;
40+
query(argument: proto_document_v1_document_pb.DocumentQueryRequest, metadata: grpc.Metadata | null, options: grpc.CallOptions | null, callback: grpc.requestCallback<proto_document_v1_document_pb.DocumentQueryResponse>): grpc.ClientUnaryCall;
41+
queryStream(argument: proto_document_v1_document_pb.DocumentQueryStreamRequest, metadataOrOptions?: grpc.Metadata | grpc.CallOptions | null): grpc.ClientReadableStream<proto_document_v1_document_pb.DocumentQueryStreamResponse>;
42+
queryStream(argument: proto_document_v1_document_pb.DocumentQueryStreamRequest, metadata?: grpc.Metadata | null, options?: grpc.CallOptions | null): grpc.ClientReadableStream<proto_document_v1_document_pb.DocumentQueryStreamResponse>;
43+
}
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
// GENERATED CODE -- DO NOT EDIT!
2+
3+
'use strict';
4+
var grpc = require('@grpc/grpc-js');
5+
var proto_document_v1_document_pb = require('../../../proto/document/v1/document_pb.js');
6+
var google_protobuf_struct_pb = require('google-protobuf/google/protobuf/struct_pb.js');
7+
var validate_validate_pb = require('../../../validate/validate_pb.js');
8+
9+
function serialize_nitric_document_v1_DocumentDeleteRequest(arg) {
10+
if (!(arg instanceof proto_document_v1_document_pb.DocumentDeleteRequest)) {
11+
throw new Error('Expected argument of type nitric.document.v1.DocumentDeleteRequest');
12+
}
13+
return Buffer.from(arg.serializeBinary());
14+
}
15+
16+
function deserialize_nitric_document_v1_DocumentDeleteRequest(buffer_arg) {
17+
return proto_document_v1_document_pb.DocumentDeleteRequest.deserializeBinary(new Uint8Array(buffer_arg));
18+
}
19+
20+
function serialize_nitric_document_v1_DocumentDeleteResponse(arg) {
21+
if (!(arg instanceof proto_document_v1_document_pb.DocumentDeleteResponse)) {
22+
throw new Error('Expected argument of type nitric.document.v1.DocumentDeleteResponse');
23+
}
24+
return Buffer.from(arg.serializeBinary());
25+
}
26+
27+
function deserialize_nitric_document_v1_DocumentDeleteResponse(buffer_arg) {
28+
return proto_document_v1_document_pb.DocumentDeleteResponse.deserializeBinary(new Uint8Array(buffer_arg));
29+
}
30+
31+
function serialize_nitric_document_v1_DocumentGetRequest(arg) {
32+
if (!(arg instanceof proto_document_v1_document_pb.DocumentGetRequest)) {
33+
throw new Error('Expected argument of type nitric.document.v1.DocumentGetRequest');
34+
}
35+
return Buffer.from(arg.serializeBinary());
36+
}
37+
38+
function deserialize_nitric_document_v1_DocumentGetRequest(buffer_arg) {
39+
return proto_document_v1_document_pb.DocumentGetRequest.deserializeBinary(new Uint8Array(buffer_arg));
40+
}
41+
42+
function serialize_nitric_document_v1_DocumentGetResponse(arg) {
43+
if (!(arg instanceof proto_document_v1_document_pb.DocumentGetResponse)) {
44+
throw new Error('Expected argument of type nitric.document.v1.DocumentGetResponse');
45+
}
46+
return Buffer.from(arg.serializeBinary());
47+
}
48+
49+
function deserialize_nitric_document_v1_DocumentGetResponse(buffer_arg) {
50+
return proto_document_v1_document_pb.DocumentGetResponse.deserializeBinary(new Uint8Array(buffer_arg));
51+
}
52+
53+
function serialize_nitric_document_v1_DocumentQueryRequest(arg) {
54+
if (!(arg instanceof proto_document_v1_document_pb.DocumentQueryRequest)) {
55+
throw new Error('Expected argument of type nitric.document.v1.DocumentQueryRequest');
56+
}
57+
return Buffer.from(arg.serializeBinary());
58+
}
59+
60+
function deserialize_nitric_document_v1_DocumentQueryRequest(buffer_arg) {
61+
return proto_document_v1_document_pb.DocumentQueryRequest.deserializeBinary(new Uint8Array(buffer_arg));
62+
}
63+
64+
function serialize_nitric_document_v1_DocumentQueryResponse(arg) {
65+
if (!(arg instanceof proto_document_v1_document_pb.DocumentQueryResponse)) {
66+
throw new Error('Expected argument of type nitric.document.v1.DocumentQueryResponse');
67+
}
68+
return Buffer.from(arg.serializeBinary());
69+
}
70+
71+
function deserialize_nitric_document_v1_DocumentQueryResponse(buffer_arg) {
72+
return proto_document_v1_document_pb.DocumentQueryResponse.deserializeBinary(new Uint8Array(buffer_arg));
73+
}
74+
75+
function serialize_nitric_document_v1_DocumentQueryStreamRequest(arg) {
76+
if (!(arg instanceof proto_document_v1_document_pb.DocumentQueryStreamRequest)) {
77+
throw new Error('Expected argument of type nitric.document.v1.DocumentQueryStreamRequest');
78+
}
79+
return Buffer.from(arg.serializeBinary());
80+
}
81+
82+
function deserialize_nitric_document_v1_DocumentQueryStreamRequest(buffer_arg) {
83+
return proto_document_v1_document_pb.DocumentQueryStreamRequest.deserializeBinary(new Uint8Array(buffer_arg));
84+
}
85+
86+
function serialize_nitric_document_v1_DocumentQueryStreamResponse(arg) {
87+
if (!(arg instanceof proto_document_v1_document_pb.DocumentQueryStreamResponse)) {
88+
throw new Error('Expected argument of type nitric.document.v1.DocumentQueryStreamResponse');
89+
}
90+
return Buffer.from(arg.serializeBinary());
91+
}
92+
93+
function deserialize_nitric_document_v1_DocumentQueryStreamResponse(buffer_arg) {
94+
return proto_document_v1_document_pb.DocumentQueryStreamResponse.deserializeBinary(new Uint8Array(buffer_arg));
95+
}
96+
97+
function serialize_nitric_document_v1_DocumentSetRequest(arg) {
98+
if (!(arg instanceof proto_document_v1_document_pb.DocumentSetRequest)) {
99+
throw new Error('Expected argument of type nitric.document.v1.DocumentSetRequest');
100+
}
101+
return Buffer.from(arg.serializeBinary());
102+
}
103+
104+
function deserialize_nitric_document_v1_DocumentSetRequest(buffer_arg) {
105+
return proto_document_v1_document_pb.DocumentSetRequest.deserializeBinary(new Uint8Array(buffer_arg));
106+
}
107+
108+
function serialize_nitric_document_v1_DocumentSetResponse(arg) {
109+
if (!(arg instanceof proto_document_v1_document_pb.DocumentSetResponse)) {
110+
throw new Error('Expected argument of type nitric.document.v1.DocumentSetResponse');
111+
}
112+
return Buffer.from(arg.serializeBinary());
113+
}
114+
115+
function deserialize_nitric_document_v1_DocumentSetResponse(buffer_arg) {
116+
return proto_document_v1_document_pb.DocumentSetResponse.deserializeBinary(new Uint8Array(buffer_arg));
117+
}
118+
119+
120+
// Service for storage and retrieval of simple JSON keyValue
121+
var DocumentServiceService = exports.DocumentServiceService = {
122+
// Get an existing document
123+
get: {
124+
path: '/nitric.document.v1.DocumentService/Get',
125+
requestStream: false,
126+
responseStream: false,
127+
requestType: proto_document_v1_document_pb.DocumentGetRequest,
128+
responseType: proto_document_v1_document_pb.DocumentGetResponse,
129+
requestSerialize: serialize_nitric_document_v1_DocumentGetRequest,
130+
requestDeserialize: deserialize_nitric_document_v1_DocumentGetRequest,
131+
responseSerialize: serialize_nitric_document_v1_DocumentGetResponse,
132+
responseDeserialize: deserialize_nitric_document_v1_DocumentGetResponse,
133+
},
134+
// Create a new or overwrite an existing document
135+
set: {
136+
path: '/nitric.document.v1.DocumentService/Set',
137+
requestStream: false,
138+
responseStream: false,
139+
requestType: proto_document_v1_document_pb.DocumentSetRequest,
140+
responseType: proto_document_v1_document_pb.DocumentSetResponse,
141+
requestSerialize: serialize_nitric_document_v1_DocumentSetRequest,
142+
requestDeserialize: deserialize_nitric_document_v1_DocumentSetRequest,
143+
responseSerialize: serialize_nitric_document_v1_DocumentSetResponse,
144+
responseDeserialize: deserialize_nitric_document_v1_DocumentSetResponse,
145+
},
146+
// Delete an existing document
147+
delete: {
148+
path: '/nitric.document.v1.DocumentService/Delete',
149+
requestStream: false,
150+
responseStream: false,
151+
requestType: proto_document_v1_document_pb.DocumentDeleteRequest,
152+
responseType: proto_document_v1_document_pb.DocumentDeleteResponse,
153+
requestSerialize: serialize_nitric_document_v1_DocumentDeleteRequest,
154+
requestDeserialize: deserialize_nitric_document_v1_DocumentDeleteRequest,
155+
responseSerialize: serialize_nitric_document_v1_DocumentDeleteResponse,
156+
responseDeserialize: deserialize_nitric_document_v1_DocumentDeleteResponse,
157+
},
158+
// Query the document collection (supports pagination)
159+
query: {
160+
path: '/nitric.document.v1.DocumentService/Query',
161+
requestStream: false,
162+
responseStream: false,
163+
requestType: proto_document_v1_document_pb.DocumentQueryRequest,
164+
responseType: proto_document_v1_document_pb.DocumentQueryResponse,
165+
requestSerialize: serialize_nitric_document_v1_DocumentQueryRequest,
166+
requestDeserialize: deserialize_nitric_document_v1_DocumentQueryRequest,
167+
responseSerialize: serialize_nitric_document_v1_DocumentQueryResponse,
168+
responseDeserialize: deserialize_nitric_document_v1_DocumentQueryResponse,
169+
},
170+
// Query the document collection (supports streaming)
171+
queryStream: {
172+
path: '/nitric.document.v1.DocumentService/QueryStream',
173+
requestStream: false,
174+
responseStream: true,
175+
requestType: proto_document_v1_document_pb.DocumentQueryStreamRequest,
176+
responseType: proto_document_v1_document_pb.DocumentQueryStreamResponse,
177+
requestSerialize: serialize_nitric_document_v1_DocumentQueryStreamRequest,
178+
requestDeserialize: deserialize_nitric_document_v1_DocumentQueryStreamRequest,
179+
responseSerialize: serialize_nitric_document_v1_DocumentQueryStreamResponse,
180+
responseDeserialize: deserialize_nitric_document_v1_DocumentQueryStreamResponse,
181+
},
182+
};
183+
184+
exports.DocumentServiceClient = grpc.makeGenericClientConstructor(DocumentServiceService);

0 commit comments

Comments
 (0)