Skip to content

Commit e90603c

Browse files
authored
Merge pull request #14 from alphamanuscript/update-versions
Update versions and fixes a few things
2 parents 80aa25e + a76a254 commit e90603c

File tree

11 files changed

+29
-103
lines changed

11 files changed

+29
-103
lines changed

packages/client/README.md

+8-20
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,20 @@ Create Client instance:
1616
const client = new Client();
1717
```
1818

19-
Create Client for the staging server
20-
21-
```javascript
22-
const client = new Client({ environment: 'staging' });
23-
```
19+
Create Client for the server
2420

2521
Use custom base URL
2622

2723
```javascript
28-
const client = new Client({ baseUrl: 'https://mydomain.com/api' });
24+
const client = new Client({
25+
environment: 'staging', // staging or production
26+
baseUrl: 'https://mydomain.com/api', // custom server
27+
keyId: 'key id provided by surix',
28+
keySecret: 'key secret provided by surix'
29+
});
2930
```
3031

31-
Authenticate
32-
33-
```javascript
34-
await client.authenticate({ email: 'me@email.com', password: 'strong password' });
35-
// Continue using client
36-
37-
// Or
38-
client.authenticate({
39-
email: 'me@email.com',
40-
password: 'strong password'
41-
}).then(authenticatedClient => {
42-
// Continue using authenticatedClient
43-
})
44-
```
32+
Note: `keyId` and `keySecret` are provided in the surix dashboard, under account settings.
4533

4634
Select project to work with:
4735

packages/client/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@surix/client",
3-
"version": "0.6.2",
3+
"version": "0.7.2",
44
"description": "Surix API Client",
55
"keywords": [
66
"surix",
@@ -29,7 +29,7 @@
2929
"test": "jest src",
3030
"test:watch": "jest --watch src",
3131
"test:e2e": "jest test/e2e",
32-
"test:all": "yarn test && yarn test:e2e",
32+
"test:all": "yarn test",
3333
"clean": "rm -rf lib dist",
3434
"build": "yarn clean && yarn build:node && yarn build:umd",
3535
"build:node": "tsc",

packages/client/src/client/test/__snapshots__/client.test.ts.snap

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ exports[`Client new instance should create http client based on production Surix
44
Array [
55
Array [
66
"https://api.surix.co/api",
7+
"someid:somesecret",
78
],
89
]
910
`;
@@ -12,6 +13,7 @@ exports[`Client new instance should override baseUrl if baseUrl option is provid
1213
Array [
1314
Array [
1415
"http://mydomain.com/api",
16+
"someid:somesecret",
1517
],
1618
]
1719
`;
@@ -20,6 +22,7 @@ exports[`Client new instance when environment is not set to production should cr
2022
Array [
2123
Array [
2224
"https://surix-staging.herokuapp.com/api",
25+
"someid:somesecret",
2326
],
2427
]
2528
`;

packages/client/src/client/test/client.test.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,30 @@ import * as projectApi from '../../project';
33
import { Client } from '../client';
44

55
describe('Client', () => {
6+
const authKey = {
7+
keyId: 'someid',
8+
keySecret: 'somesecret'
9+
}
10+
611
describe('new instance', () => {
712
it('should create http client based on production Surix API url', () => {
813
const spy = jest.spyOn(api, 'getApiClient');
9-
new Client();
14+
new Client({ ...authKey });
1015
expect(spy.mock.calls).toMatchSnapshot();
1116
spy.mockRestore();
1217
});
1318
describe('when environment is not set to production', () => {
1419
it('should create http client based on staging url', () => {
1520
const spy = jest.spyOn(api, 'getApiClient');
16-
new Client({ environment: 'staging' });
21+
new Client({ environment: 'staging', ...authKey });
1722
expect(spy.mock.calls).toMatchSnapshot();
1823
spy.mockRestore();
1924
});
2025
});
2126
it('should override baseUrl if baseUrl option is provided', () => {
2227
const spy = jest.spyOn(api, 'getApiClient');
2328
const baseUrl = 'http://mydomain.com/api';
24-
new Client({ baseUrl });
29+
new Client({ baseUrl, ...authKey });
2530
expect(spy.mock.calls).toMatchSnapshot();
2631
spy.mockRestore();
2732
});
@@ -32,7 +37,7 @@ describe('Client', () => {
3237
const apiClient = {};
3338
jest.spyOn(api, 'getApiClient').mockReturnValue(apiClient);
3439
jest.spyOn(projectApi, 'getProjectApi');
35-
const client = new Client();
40+
const client = new Client({ ...authKey });
3641
client.project('id');
3742
expect(projectApi.getProjectApi).toHaveBeenCalledWith('id', apiClient);
3843
});

packages/client/src/project/tests/entities.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('Project Entities', () => {
4141
describe('get', () => {
4242
let apiClient: AxiosInstance;
4343
async function callMockedGet (): Promise<dataHelpers.WrappedEntity> {
44-
apiClient = api.getApiClient('http://baseurl');
44+
apiClient = api.getApiClient('http://baseurl', 'somekey');
4545
jest.spyOn(apiClient, 'get').mockReturnValue(Promise.resolve({ data: apiEntities[0] }));
4646
jest.spyOn(dataHelpers, 'wrapEntity');
4747
const project = getProjectApi('project1', apiClient);
@@ -61,7 +61,7 @@ describe('Project Entities', () => {
6161
describe('query', () => {
6262
let apiClient: AxiosInstance;
6363
async function callMockedQuery (query?: Query): Promise<dataHelpers.WrappedEntity[]> {
64-
apiClient = api.getApiClient('http://baseurl');
64+
apiClient = api.getApiClient('http://baseurl', 'somekey');
6565
jest.spyOn(apiClient, 'post').mockReturnValue(Promise.resolve({ data: apiEntities }));
6666
jest.spyOn(dataHelpers, 'wrapEntityArray');
6767
const project = getProjectApi('project1', apiClient);

packages/client/src/project/tests/files.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('Project Files', () => {
4343
describe('get', () => {
4444
let apiClient: AxiosInstance;
4545
function callMockedGet (): Promise<dataHelpers.WrappedFile> {
46-
apiClient = api.getApiClient('http://baseurl');
46+
apiClient = api.getApiClient('http://baseurl', 'somekey');
4747
jest.spyOn(apiClient, 'get').mockReturnValue(
4848
Promise.resolve({ data: apiFiles[0] })
4949
);
@@ -65,7 +65,7 @@ describe('Project Files', () => {
6565
describe('list', () => {
6666
let apiClient: AxiosInstance;
6767
function callMockedList (): Promise<dataHelpers.WrappedFile[]> {
68-
apiClient = api.getApiClient('http://baseurl');
68+
apiClient = api.getApiClient('http://baseurl', 'somekey');
6969
jest.spyOn(apiClient, 'get').mockReturnValue(
7070
Promise.resolve({ data: apiFiles })
7171
);

packages/client/src/project/tests/tags.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('Project tags', () => {
1111
{ name: 'users' }
1212
];
1313
function callMockedList(): Promise<any[]> {
14-
apiClient = api.getApiClient('http://baseurl');
14+
apiClient = api.getApiClient('http://baseurl', 'somekey');
1515
jest.spyOn(apiClient, 'get').mockReturnValue(
1616
Promise.resolve({ data: tags })
1717
);

packages/client/test/e2e/basic.test.ts

-58
This file was deleted.

packages/client/test/index.html

-12
This file was deleted.

packages/data-helpers/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ const codeFromRaw = raw.data.address
5959
- `wrappedEntity.get(key, defaultValue?)`: returns plain value of the specified field
6060
- `wrappedEntity.type(key, defaultType?)`: returns type of the specified field
6161
- `wrappedEntity.field(key, defaultType?)`: returns the raw field with the specified key
62-
- `wrappedEntity.label(key, defaultLabel?)`: return the label of the specified field
6362
- `wrappedEntity.data()`: returns the data of the entity as a plain key-value object (without field metadata)
6463

6564
#### properties
@@ -69,4 +68,5 @@ You can access the top-level properties of the entity directly:
6968
- `wrappedEntity.createdAt`
7069
- `wrappedEntity.updatedAt`
7170
- `wrappedEntity.createdBy`
71+
- `wrappedEntity.updatedBy`
7272
- `wrappedEntity.rawEntity`: Returns the raw entity from the API

packages/data-helpers/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@surix/data-helpers",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Utilities for making it easy to work with Surix data",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",

0 commit comments

Comments
 (0)