Skip to content

Commit c3785c3

Browse files
Merge branch 'dev'
2 parents bd847e2 + 55bf202 commit c3785c3

9 files changed

+65
-2
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.1.0-alpha.4 (2020-10-27)
2+
3+
### New Features & Enhancements
4+
- feat(\*) Implement "Methods" API and types
5+
16
## 0.1.0-alpha.3 (2020-10-21)
27

38
### New Features & Enhancements

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@connio/js-sdk",
3-
"version": "0.1.0-alpha.3",
3+
"version": "0.1.0-alpha.4",
44
"description": "Connio JavaScript SDK",
55
"main": "./src/index.ts",
66
"repository": {

src/entities/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export { IDeviceProfile } from './device-profile';
2323
export { EntityStatus } from './entity-status';
2424
export { EntityType } from './entity-type';
2525
export { IEnvConfig } from './env-config';
26+
export { IMethod, IMethodImplementation, MethodLanguage } from './method';
2627
export { IBoundaries as IPropertyBoundaries, IProperty } from './property';
2728
export { PropertyType } from './property-type';
2829
export { PublishType } from './publish-type';

src/entities/method.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { AccessType } from './access-type';
2+
import { IBaseEntity } from './base';
3+
4+
export enum MethodLanguage {
5+
JavaScript = 'javascript',
6+
}
7+
8+
export interface IMethodImplementation {
9+
funcBody: string;
10+
script: MethodLanguage;
11+
}
12+
13+
export interface IMethod extends IBaseEntity {
14+
readonly accountId: string;
15+
readonly ownerId: string;
16+
/** @deprecated */
17+
friendlyName: string;
18+
qualifiedName: string;
19+
access: AccessType;
20+
methodImpl: IMethodImplementation;
21+
}

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ export { DataConnectors, IDataConnectors } from './data-connectors';
77
export { DeviceProfiles, IDeviceProfiles } from './device-profiles';
88
export { Devices, IDevices } from './devices';
99
export { IDisposable } from './disposable';
10+
export { IMethods, Methods } from './methods';
1011
export { RestClient } from './rest-client';

src/instance.ts

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { DataConnectors, IDataConnectors } from './data-connectors';
77
import { DeviceProfiles, IDeviceProfiles } from './device-profiles';
88
import { Devices, IDevices } from './devices';
99
import { IEnvConfig } from './entities';
10+
import { IMethods, Methods } from './methods';
1011
import { IProperties, Properties } from './properties';
1112
import { IRestClient, RestClient } from './rest-client';
1213

@@ -22,6 +23,7 @@ export interface IPlatform {
2223
appProfiles: IAppProfiles;
2324
apiClients: IApiClients;
2425
dataConnectors: IDataConnectors;
26+
methods: IMethods;
2527
}
2628

2729
let platform: IPlatform;
@@ -66,6 +68,9 @@ export async function bootstrap(env: IEnvConfig): Promise<IPlatform> {
6668
dataConnectors: new DataConnectors({
6769
client: restClient,
6870
}),
71+
methods: new Methods({
72+
client: restClient,
73+
}),
6974
};
7075

7176
return platform;

src/methods/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { IMethods, Methods } from './methods';

src/methods/methods.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {
2+
AbstractEntityApi,
3+
IAbstractEntityApi,
4+
IAbstractEntityOptions,
5+
} from '../abstract-entity-api';
6+
import { IMethod } from '../entities';
7+
8+
export interface IMethods extends IAbstractEntityApi<IMethod> {
9+
makeQualifiedName(methodName: string, profileName: string): string;
10+
}
11+
export interface IMethodsOptions extends IAbstractEntityOptions {}
12+
13+
export class Methods extends AbstractEntityApi<IMethod> implements IMethods {
14+
private readonly QUALIFIED_NAME_SEPARATOR = '$';
15+
16+
protected BASE_URL = '/methods';
17+
18+
constructor(options: IMethodsOptions) {
19+
super(options);
20+
}
21+
22+
public async list({ ownerId }: { ownerId: string }): Promise<IMethod[]> {
23+
return await super.list({ ownerId });
24+
}
25+
26+
public makeQualifiedName(methodName: string, profileName: string): string {
27+
return `${profileName}${this.QUALIFIED_NAME_SEPARATOR}${methodName}`;
28+
}
29+
}

0 commit comments

Comments
 (0)