Skip to content

Commit 1588e41

Browse files
authored
Merge pull request #121 from nitrictech/develop
Release v0.5.0
2 parents 72872c5 + 2d32d22 commit 1588e41

File tree

16 files changed

+180
-240
lines changed

16 files changed

+180
-240
lines changed

.github/workflows/release-rc.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
name: Release Candidate
22
on:
3-
pull_request:
4-
types: [closed]
3+
push:
54
branches:
6-
- 'develop'
5+
- develop
76

87
jobs:
98
# Bump the membrane version
109
version_bump:
11-
if: github.event.pull_request.merged == true
1210
name: Bump Version and Create Release
1311
runs-on: ubuntu-latest
1412
outputs:

.github/workflows/release.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
name: Production Release
22
on:
3-
pull_request:
4-
types: [closed]
3+
push:
54
branches:
6-
- 'main'
5+
- main
76
jobs:
87
# Bump the membrane version
98
version_bump:
10-
if: github.event.pull_request.merged == true
119
name: Bump Version and Create Release
1210
runs-on: ubuntu-latest
1311
outputs:

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
<p align="center">
2-
<img src="./docs/assets/dot-matrix-logo-node.png" alt="Nitric Logo"/>
2+
<a href="https://nitric.io">
3+
<img src="assets/nitric-logo.svg" width="120" alt="Nitric Logo"/>
4+
</a>
35
</p>
46

5-
![Tests](https://github.com/nitrictech/node-sdk/actions/workflows/test.yaml/badge.svg?branch=main)
6-
[![codecov](https://codecov.io/gh/nitrictech/node-sdk/branch/main/graph/badge.svg?token=N46TTGPE4G)](https://codecov.io/gh/nitrictech/node-sdk)
7-
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=nitrictech_node-sdk&metric=alert_status)](https://sonarcloud.io/dashboard?id=nitrictech_node-sdk)
8-
[![Version](https://img.shields.io/npm/v/@nitric/sdk.svg)](https://npmjs.org/package/@nitric/sdk)
9-
[![Downloads/week](https://img.shields.io/npm/dw/@nitric/sdk.svg)](https://npmjs.org/package/@nitric/sdk)
7+
<p align="center">
8+
Build <a href="https://nitric.io">nitric</a> applications with Node.js
9+
</p>
1010

11-
# Node SDK for Nitric
11+
<p align="center">
12+
<img alt="Tests" src="https://github.com/nitrictech/node-sdk/actions/workflows/test.yaml/badge.svg?branch=main">
13+
<a href="https://codecov.io/gh/nitrictech/node-sdk">
14+
<img alt="codecov" src="https://codecov.io/gh/nitrictech/node-sdk/branch/main/graph/badge.svg?token=N46TTGPE4G">
15+
</a>
16+
<a href="https://npmjs.org/package/@nitric/sdk">
17+
<img alt="Version" src="https://img.shields.io/npm/v/@nitric/sdk.svg">
18+
</a>
19+
<a href="https://npmjs.org/package/@nitric/sdk">
20+
<img alt="Downloads/week" src="https://img.shields.io/npm/dw/@nitric/sdk.svg">
21+
</a>
22+
</p>
1223

1324
The NodeJS SDK supports the use of the Nitric framework with NodeJS 12+. For more information, check out the main [Nitric repo](https://github.com/nitrictech/nitric).
1425

assets/nitric-logo.svg

Lines changed: 14 additions & 0 deletions
Loading

licenseconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"ignoreFile": ".gitignore",
33
"ignore": [
44
"README",
5+
"**/*.svg",
56
".*",
67
"**/*.config.*",
78
"**/.gitignore",

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
"dependencies": {
2929
"@grpc/grpc-js": "^1.5.9",
3030
"@nitric/api": "0.15.0",
31-
"common-tags": "^1.8.0",
3231
"google-protobuf": "3.14.0",
33-
"path-parser": "^6.1.0",
3432
"tslib": "^2.1.0"
3533
},
3634
"license": "Apache-2.0",
@@ -56,7 +54,6 @@
5654
"licensee": "^8.2.0",
5755
"lint-staged": "^10.5.4",
5856
"prettier": "^2.2.1",
59-
"replace-in-files-cli": "latest",
6057
"standard-version": "^9.0.0",
6158
"ts-jest": "^26.4.3",
6259
"typescript": "^3.3"

src/api/events/v0/events.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class Topic {
6969
* }
7070
* ```
7171
*/
72-
publish = async (event: NitricEvent): Promise<NitricEvent> => {
72+
async publish(event: NitricEvent): Promise<NitricEvent> {
7373
const { id, payloadType = 'none', payload } = event;
7474
const request = new EventPublishRequest();
7575
const evt = new PbEvent();
@@ -140,7 +140,7 @@ export class Eventing {
140140
* ```
141141
*
142142
*/
143-
topic = (name: string): Topic => {
143+
public topic(name: string): Topic {
144144
if (!name) {
145145
throw new InvalidArgumentError('A topic name is needed to use a Topic.');
146146
}
@@ -162,7 +162,7 @@ export class Eventing {
162162
* const topics = await eventing.topics();
163163
* ```
164164
*/
165-
topics = async (): Promise<Topic[]> => {
165+
public async topics(): Promise<Topic[]> {
166166
return new Promise((resolve, reject) => {
167167
this.TopicServiceClient.list(null, (error, response) => {
168168
if (error) {

src/api/queues/v0/queues.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ export class Queue {
109109
* };
110110
* });
111111
*/
112-
async send(tasks: Task[]): Promise<FailedMessage[]>;
113-
async send(tasks: Task): Promise<void>;
114-
async send(tasks: Task | Task[]): Promise<void | FailedMessage[]> {
112+
public async send(tasks: Task[]): Promise<FailedMessage[]>;
113+
public async send(tasks: Task): Promise<void>;
114+
public async send(tasks: Task | Task[]): Promise<void | FailedMessage[]> {
115115
return new Promise((resolve, reject) => {
116116
const request = new QueueSendBatchRequest();
117117

@@ -170,7 +170,7 @@ export class Queue {
170170
* // do something with task
171171
* ```
172172
*/
173-
receive = async (depth?: number): Promise<ReceivedTask[]> => {
173+
public async receive(depth?: number): Promise<ReceivedTask[]> {
174174
return new Promise((resolve, reject) => {
175175
const request = new QueueReceiveRequest();
176176

@@ -243,7 +243,7 @@ export class ReceivedTask implements Task {
243243
* await task.complete();
244244
* ```
245245
*/
246-
complete = async (): Promise<void> => {
246+
public async complete(): Promise<void> {
247247
try {
248248
const request = new QueueCompleteRequest();
249249

src/api/secrets/v0/secrets.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class Secrets {
5151
* const secret = secrets().secret("my-secret");
5252
* ```
5353
*/
54-
secret = (name: string): Secret => {
54+
public secret = (name: string): Secret => {
5555
if (!name) {
5656
throw new InvalidArgumentError('A name is required to use a Secret.');
5757
}
@@ -86,7 +86,7 @@ export class Secret {
8686
* }
8787
* ```
8888
*/
89-
put = async (secret: string | Uint8Array) => {
89+
public async put(secret: string | Uint8Array) {
9090
return new Promise<SecretVersion>((resolve, reject) => {
9191
const secretBuff =
9292
typeof secret === 'string' ? ENCODER.encode(secret) : secret;
@@ -128,7 +128,7 @@ export class Secret {
128128
* ```
129129
*
130130
*/
131-
latest = () => {
131+
public latest() {
132132
return this.version('latest');
133133
};
134134

@@ -146,7 +146,7 @@ export class Secret {
146146
* ```
147147
*
148148
*/
149-
version = (version: string) => {
149+
public version(version: string) {
150150
if (!version) {
151151
throw new InvalidArgumentError(
152152
'A version is required to create a version reference.'
@@ -193,7 +193,7 @@ class SecretVersion {
193193
* }
194194
* ```
195195
*/
196-
access = async (): Promise<SecretValue> => {
196+
public async access(): Promise<SecretValue> {
197197
return new Promise((resolve, reject) => {
198198
const request = new SecretAccessRequest();
199199
request.setSecretVersion(SecretVersion.toWire(this));
@@ -259,7 +259,7 @@ class SecretValue {
259259
* }
260260
* ```
261261
*/
262-
asBytes = () => {
262+
public asBytes = () => {
263263
return this.val;
264264
};
265265

@@ -277,7 +277,7 @@ class SecretValue {
277277
* }
278278
* ```
279279
*/
280-
asString = () => {
280+
public asString = () => {
281281
return DECODER.decode(this.asBytes());
282282
};
283283
}

src/api/storage/v0/storage.test.ts

Lines changed: 84 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ describe('Storage Client Tests', () => {
228228
jest.resetAllMocks();
229229
});
230230

231-
test('Then StorageClient.delete should reject', async () => {
231+
test('Then file.signUrl should reject', async () => {
232232
const client = new Storage();
233233
await expect(client.bucket('test').file('test').signUrl(FileMode.Read)).rejects.toEqual(
234234
new UnimplementedError("UNIMPLEMENTED")
235235
);
236236
});
237237

238-
test('The Grpc client for Storage.delete should have been called exactly once', () => {
238+
test('The Grpc client for file.signUrl should have been called exactly once', () => {
239239
expect(signUrlMock).toBeCalledTimes(1);
240240
});
241241
});
@@ -244,38 +244,101 @@ describe('Storage Client Tests', () => {
244244
const MOCK_REPLY = new StoragePreSignUrlResponse();
245245
MOCK_REPLY.setUrl("testingUrl");
246246

247-
let preSignUrlMock;
247+
let preSignUrlMock: jest.SpyInstance;
248248

249249
beforeAll(() => {
250250
preSignUrlMock = jest
251251
.spyOn(GrpcStorageClient.prototype, 'preSignUrl')
252252
.mockImplementation((_, callback: any) => {
253253
callback(null, MOCK_REPLY);
254-
255254
return null as any;
256255
});
257256
});
258257

259258
afterAll(() => {
260259
jest.resetAllMocks();
261260
});
262-
263-
test('Then StorageClient.delete should delete the bytes from the bucket', async () => {
264-
const client = new Storage().bucket('test_bucket').file('test/item');
265-
await expect(client.signUrl(FileMode.Read)).resolves.toEqual("testingUrl");
266-
});
267-
268-
test('The Grpc client for Storage.delete should have been called exactly once', () => {
269-
expect(preSignUrlMock).toBeCalledTimes(1);
270-
});
271-
272-
test('The Grpc client for Storage.delete should have been called with provided options', () => {
273-
const MOCK_REQUEST = new StoragePreSignUrlRequest();
274-
MOCK_REQUEST.setBucketName("test_bucket");
275-
MOCK_REQUEST.setKey("test/item");
276-
MOCK_REQUEST.setOperation(FileMode.Read);
277-
MOCK_REQUEST.setExpiry(600);
278-
expect(preSignUrlMock).toBeCalledWith(MOCK_REQUEST, expect.anything());
261+
262+
263+
describe('When calling file.signUrl', () => {
264+
let signUrl;
265+
266+
beforeAll(async () => {
267+
preSignUrlMock.mockClear();
268+
const client = new Storage().bucket('test_bucket').file('test/item');
269+
signUrl = await client.signUrl(FileMode.Read)
270+
})
271+
272+
test('Then file.signUrl should delete the bytes from the bucket', () => {
273+
expect(signUrl).toEqual("testingUrl");
274+
});
275+
276+
test('The Grpc client for file.signUrl should have been called exactly once', () => {
277+
expect(preSignUrlMock).toBeCalledTimes(1);
278+
});
279+
280+
test('The Grpc client for file.signUrl should have been called with provided options', () => {
281+
const MOCK_REQUEST = new StoragePreSignUrlRequest();
282+
MOCK_REQUEST.setBucketName("test_bucket");
283+
MOCK_REQUEST.setKey("test/item");
284+
MOCK_REQUEST.setOperation(FileMode.Read);
285+
MOCK_REQUEST.setExpiry(600);
286+
expect(preSignUrlMock).toBeCalledWith(MOCK_REQUEST, expect.anything());
287+
});
288+
});
289+
290+
describe('When calling file.getUploadUrl', () => {
291+
let signUrl;
292+
293+
beforeAll(async () => {
294+
preSignUrlMock.mockClear();
295+
const client = new Storage().bucket('test_bucket').file('test/item');
296+
signUrl = await client.getUploadUrl()
297+
})
298+
299+
test('Then file.signUrl should delete the bytes from the bucket', () => {
300+
expect(signUrl).toEqual("testingUrl");
301+
});
302+
303+
test('The Grpc client for file.signUrl should have been called exactly once', () => {
304+
expect(preSignUrlMock).toBeCalledTimes(1);
305+
});
306+
307+
test('The Grpc client for file.signUrl should have been called with provided options', () => {
308+
const MOCK_REQUEST = new StoragePreSignUrlRequest();
309+
MOCK_REQUEST.setBucketName("test_bucket");
310+
MOCK_REQUEST.setKey("test/item");
311+
MOCK_REQUEST.setOperation(FileMode.Write);
312+
MOCK_REQUEST.setExpiry(600);
313+
expect(preSignUrlMock).toBeCalledWith(MOCK_REQUEST, expect.anything());
314+
});
315+
});
316+
317+
describe('When calling file.getUploadUrl', () => {
318+
let signUrl;
319+
320+
beforeAll(async () => {
321+
preSignUrlMock.mockClear();
322+
const client = new Storage().bucket('test_bucket').file('test/item');
323+
signUrl = await client.getDownloadUrl()
324+
})
325+
326+
test('Then file.signUrl should delete the bytes from the bucket', () => {
327+
expect(signUrl).toEqual("testingUrl");
328+
});
329+
330+
test('The Grpc client for file.signUrl should have been called exactly once', () => {
331+
expect(preSignUrlMock).toBeCalledTimes(1);
332+
});
333+
334+
test('The Grpc client for file.signUrl should have been called with provided options', () => {
335+
const MOCK_REQUEST = new StoragePreSignUrlRequest();
336+
MOCK_REQUEST.setBucketName("test_bucket");
337+
MOCK_REQUEST.setKey("test/item");
338+
MOCK_REQUEST.setOperation(FileMode.Read);
339+
MOCK_REQUEST.setExpiry(600);
340+
expect(preSignUrlMock).toBeCalledWith(MOCK_REQUEST, expect.anything());
341+
});
279342
});
280343
});
281344
});

0 commit comments

Comments
 (0)