@epilot/metering-client 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [0.1.1](https://github.com/epilot-dev/sdk-js/compare/v1.0.0...v0.1.1) (2022-03-09)
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # `@epilot/ts-sam-client`
2
+
3
+ API Client for epilot ts-sam API.
4
+
5
+ Uses [`openapi-client-axios`](https://github.com/anttiviljami/openapi-client-axios)
6
+
7
+ ## Getting Started
8
+
9
+ Install the package:
10
+
11
+ ```bash
12
+ npm install --save-dev @epilot/ts-sam-client
13
+ ```
14
+
15
+ Import the package:
16
+
17
+ ```typescript
18
+ import { getClient } from '@epilot/ts-sam-client';
19
+ ```
20
+
21
+ Use the client:
22
+ ```typescript
23
+ // get typed client
24
+ const client = await getClient();
25
+
26
+ // call an operation
27
+ const res = await client.testS3();
28
+ ```
29
+
30
+ ## BaseURL & Authorization
31
+
32
+ To pass an authorization header and set up the API url, you can use axios
33
+ defaults:
34
+
35
+ ```typescript
36
+ const client = getClient();
37
+ client.defaults.baseURL = config.API_URL;
38
+ client.defaults.headers['authorization'] = `Bearer ${token}`;
39
+ ```
40
+
41
+ ## API Docs:
42
+
43
+ https://docs.api.epilot.io/
@@ -0,0 +1,2 @@
1
+ import { Client } from './openapi';
2
+ export declare const getClient: () => Client;
package/dist/client.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getClient = void 0;
7
+ var openapi_client_axios_1 = __importDefault(require("openapi-client-axios"));
8
+ var definition_1 = __importDefault(require("./definition"));
9
+ var getClient = function () {
10
+ var api = new openapi_client_axios_1.default({ definition: definition_1.default, quick: true });
11
+ return api.initSync();
12
+ };
13
+ exports.getClient = getClient;
14
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,3 @@
1
+ import type { Document } from 'openapi-client-axios';
2
+ declare const _default: Document;
3
+ export default _default;
@@ -0,0 +1 @@
1
+ !function(e,t){for(var r in t)e[r]=t[r];t.__esModule&&Object.defineProperty(e,"__esModule",{value:!0})}(exports,(()=>{"use strict";var e={914:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=n(r(279));t.default=a.default},279:e=>{e.exports=JSON.parse('{"openapi":"3.0.3","info":{"title":"Metering API","version":"1.0.0"},"tags":[{"name":"Epilot_360","description":"Epilot_360"},{"name":"ECP","description":"End customer portal"}],"security":[{"EpilotAuth":[]},{"CustomerPortalAuth":[]}],"paths":{"/v1/metering/reading":{"post":{"operationId":"saveMeterReading","summary":"saveMeterReading","description":"This operation inserts a new meter reading","tags":["Epilot_360","ECP"],"security":[{"EpilotAuth":[]},{"CustomerPortalAuth":[]}],"requestBody":{"description":"Meter reading payload","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeterReading"}}}},"responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/MeterReading"}}}}}}}}},"/v1/metering/reading/{meter_id}/{counter_id}":{"get":{"operationId":"fetchReadingsByInterval","summary":"fetchReadingsByInterval","description":"- Get all readings specified in an interval\\n- If the start_date & end_date are equal, then returns the readings of the specified date\\n- start_date should <= end_date\\n","tags":["Epilot_360","ECP"],"security":[{"EpilotAuth":[]},{"CustomerPortalAuth":[]}],"parameters":[{"in":"path","name":"meter_id","schema":{"$ref":"#/components/schemas/Id"},"required":true,"description":"The Id of meter"},{"in":"path","name":"counter_id","schema":{"$ref":"#/components/schemas/Id"},"required":true,"description":"The Id of counter"},{"in":"query","name":"start_date","required":true,"schema":{"type":"string","example":"2022-10-01T00:00:00.000Z"}},{"in":"query","name":"end_date","required":true,"schema":{"type":"string","example":"2022-10-10T00:00:00.000Z"}}],"responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"type":"object","properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/MeterReading"}},"total_count":{"type":"number","example":120}}}}}}}}},"/v1/metering/down-sample/readings/{meter_id}/{counter_id}":{"get":{"operationId":"fetchDownSampleReadingsByInterval","summary":"fetchDownSampleReadingsByInterval","description":"- Get the down sampled data of the entire readings specified in an interval\\n- If the start_date & end_date are equal, then returns the readings of the specified date\\n- start_date should <= end_date\\n","tags":["Epilot_360","ECP"],"security":[{"EpilotAuth":[]},{"CustomerPortalAuth":[]}],"parameters":[{"in":"path","name":"meter_id","schema":{"$ref":"#/components/schemas/Id"},"required":true,"description":"The Id of meter"},{"in":"path","name":"counter_id","schema":{"$ref":"#/components/schemas/Id"},"required":true,"description":"The Id of counter"},{"in":"query","name":"start_date","required":true,"schema":{"type":"string","example":"2022-10-01T00:00:00.000Z"}},{"in":"query","name":"end_date","required":true,"schema":{"type":"string","example":"2022-10-10T00:00:00.000Z"}},{"in":"query","name":"unit","schema":{"type":"string","default":"day","enum":["day","week","month","year"]}}],"responses":{"200":{"description":"ok","content":{"application/json":{"schema":{"type":"object","properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/MeterReading"}}}}}}}}}}},"components":{"securitySchemes":{"EpilotAuth":{"type":"http","scheme":"bearer","description":"Authorization header with epilot OAuth2 bearer token","bearerFormat":"JWT"},"CustomerPortalAuth":{"type":"http","scheme":"bearer","description":"Authorization header with customer pilot OAuth2 bearer token","bearerFormat":"JWT"}},"schemas":{"Id":{"type":"string"},"MeterReading":{"type":"object","properties":{"value":{"type":"number","example":240},"unit":{"type":"string","enum":["W","WH","KW","KWH","KVARH","MW","MWH","unit","cubic meter","hour","day","month","year","percentage"]},"read_by":{"type":"string","example":"John Doe"},"reason":{"type":"string","example":"Storing the feed-in record"},"meter_id":{"type":"string","example":"1446829f-4b6f-474e-b978-3997d89a7928"},"counter_id":{"type":"string","example":"2A-3"}}}}}}')}},t={};return function r(n){if(t[n])return t[n].exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(914)})());
@@ -0,0 +1,3 @@
1
+ export * from './client';
2
+ export type { Client, Components, Paths, PathsDictionary, OperationMethods } from './openapi';
3
+ export type { OpenAPIClient, OpenAPIClientAxios, Document } from 'openapi-client-axios';
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./client"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,219 @@
1
+ /* eslint-disable */
2
+ import type {
3
+ OpenAPIClient,
4
+ Parameters,
5
+ UnknownParamsObject,
6
+ OperationResponse,
7
+ AxiosRequestConfig,
8
+ } from 'openapi-client-axios';
9
+
10
+ declare namespace Components {
11
+ namespace Schemas {
12
+ export type Id = string;
13
+ export interface MeterReading {
14
+ /**
15
+ * example:
16
+ * 240
17
+ */
18
+ value?: number;
19
+ unit?: "W" | "WH" | "KW" | "KWH" | "KVARH" | "MW" | "MWH" | "unit" | "cubic meter" | "hour" | "day" | "month" | "year" | "percentage";
20
+ /**
21
+ * example:
22
+ * John Doe
23
+ */
24
+ read_by?: string;
25
+ /**
26
+ * example:
27
+ * Storing the feed-in record
28
+ */
29
+ reason?: string;
30
+ /**
31
+ * example:
32
+ * 1446829f-4b6f-474e-b978-3997d89a7928
33
+ */
34
+ meter_id?: string;
35
+ /**
36
+ * example:
37
+ * 2A-3
38
+ */
39
+ counter_id?: string;
40
+ }
41
+ }
42
+ }
43
+ declare namespace Paths {
44
+ namespace FetchDownSampleReadingsByInterval {
45
+ namespace Parameters {
46
+ export type CounterId = Components.Schemas.Id;
47
+ /**
48
+ * example:
49
+ * "2022-10-10T00:00:00.000Z"
50
+ */
51
+ export type EndDate = string;
52
+ export type MeterId = Components.Schemas.Id;
53
+ /**
54
+ * example:
55
+ * "2022-10-01T00:00:00.000Z"
56
+ */
57
+ export type StartDate = string;
58
+ export type Unit = "day" | "week" | "month" | "year";
59
+ }
60
+ export interface PathParameters {
61
+ meter_id: Parameters.MeterId;
62
+ counter_id: Parameters.CounterId;
63
+ }
64
+ export interface QueryParameters {
65
+ start_date: /**
66
+ * example:
67
+ * "2022-10-01T00:00:00.000Z"
68
+ */
69
+ Parameters.StartDate;
70
+ end_date: /**
71
+ * example:
72
+ * "2022-10-10T00:00:00.000Z"
73
+ */
74
+ Parameters.EndDate;
75
+ unit?: Parameters.Unit;
76
+ }
77
+ namespace Responses {
78
+ export interface $200 {
79
+ results?: Components.Schemas.MeterReading[];
80
+ }
81
+ }
82
+ }
83
+ namespace FetchReadingsByInterval {
84
+ namespace Parameters {
85
+ export type CounterId = Components.Schemas.Id;
86
+ /**
87
+ * example:
88
+ * "2022-10-10T00:00:00.000Z"
89
+ */
90
+ export type EndDate = string;
91
+ export type MeterId = Components.Schemas.Id;
92
+ /**
93
+ * example:
94
+ * "2022-10-01T00:00:00.000Z"
95
+ */
96
+ export type StartDate = string;
97
+ }
98
+ export interface PathParameters {
99
+ meter_id: Parameters.MeterId;
100
+ counter_id: Parameters.CounterId;
101
+ }
102
+ export interface QueryParameters {
103
+ start_date: /**
104
+ * example:
105
+ * "2022-10-01T00:00:00.000Z"
106
+ */
107
+ Parameters.StartDate;
108
+ end_date: /**
109
+ * example:
110
+ * "2022-10-10T00:00:00.000Z"
111
+ */
112
+ Parameters.EndDate;
113
+ }
114
+ namespace Responses {
115
+ export interface $200 {
116
+ results?: Components.Schemas.MeterReading[];
117
+ /**
118
+ * example:
119
+ * 120
120
+ */
121
+ total_count?: number;
122
+ }
123
+ }
124
+ }
125
+ namespace SaveMeterReading {
126
+ export type RequestBody = Components.Schemas.MeterReading;
127
+ namespace Responses {
128
+ export interface $200 {
129
+ data?: Components.Schemas.MeterReading;
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+ export interface OperationMethods {
136
+ /**
137
+ * saveMeterReading - saveMeterReading
138
+ *
139
+ * This operation inserts a new meter reading
140
+ */
141
+ 'saveMeterReading'(
142
+ parameters?: Parameters<UnknownParamsObject> | null,
143
+ data?: Paths.SaveMeterReading.RequestBody,
144
+ config?: AxiosRequestConfig
145
+ ): OperationResponse<Paths.SaveMeterReading.Responses.$200>
146
+ /**
147
+ * fetchReadingsByInterval - fetchReadingsByInterval
148
+ *
149
+ * - Get all readings specified in an interval
150
+ * - If the start_date & end_date are equal, then returns the readings of the specified date
151
+ * - start_date should <= end_date
152
+ *
153
+ */
154
+ 'fetchReadingsByInterval'(
155
+ parameters?: Parameters<Paths.FetchReadingsByInterval.PathParameters & Paths.FetchReadingsByInterval.QueryParameters> | null,
156
+ data?: any,
157
+ config?: AxiosRequestConfig
158
+ ): OperationResponse<Paths.FetchReadingsByInterval.Responses.$200>
159
+ /**
160
+ * fetchDownSampleReadingsByInterval - fetchDownSampleReadingsByInterval
161
+ *
162
+ * - Get the down sampled data of the entire readings specified in an interval
163
+ * - If the start_date & end_date are equal, then returns the readings of the specified date
164
+ * - start_date should <= end_date
165
+ *
166
+ */
167
+ 'fetchDownSampleReadingsByInterval'(
168
+ parameters?: Parameters<Paths.FetchDownSampleReadingsByInterval.PathParameters & Paths.FetchDownSampleReadingsByInterval.QueryParameters> | null,
169
+ data?: any,
170
+ config?: AxiosRequestConfig
171
+ ): OperationResponse<Paths.FetchDownSampleReadingsByInterval.Responses.$200>
172
+ }
173
+
174
+ export interface PathsDictionary {
175
+ ['/v1/metering/reading']: {
176
+ /**
177
+ * saveMeterReading - saveMeterReading
178
+ *
179
+ * This operation inserts a new meter reading
180
+ */
181
+ 'post'(
182
+ parameters?: Parameters<UnknownParamsObject> | null,
183
+ data?: Paths.SaveMeterReading.RequestBody,
184
+ config?: AxiosRequestConfig
185
+ ): OperationResponse<Paths.SaveMeterReading.Responses.$200>
186
+ }
187
+ ['/v1/metering/reading/{meter_id}/{counter_id}']: {
188
+ /**
189
+ * fetchReadingsByInterval - fetchReadingsByInterval
190
+ *
191
+ * - Get all readings specified in an interval
192
+ * - If the start_date & end_date are equal, then returns the readings of the specified date
193
+ * - start_date should <= end_date
194
+ *
195
+ */
196
+ 'get'(
197
+ parameters?: Parameters<Paths.FetchReadingsByInterval.PathParameters & Paths.FetchReadingsByInterval.QueryParameters> | null,
198
+ data?: any,
199
+ config?: AxiosRequestConfig
200
+ ): OperationResponse<Paths.FetchReadingsByInterval.Responses.$200>
201
+ }
202
+ ['/v1/metering/down-sample/readings/{meter_id}/{counter_id}']: {
203
+ /**
204
+ * fetchDownSampleReadingsByInterval - fetchDownSampleReadingsByInterval
205
+ *
206
+ * - Get the down sampled data of the entire readings specified in an interval
207
+ * - If the start_date & end_date are equal, then returns the readings of the specified date
208
+ * - start_date should <= end_date
209
+ *
210
+ */
211
+ 'get'(
212
+ parameters?: Parameters<Paths.FetchDownSampleReadingsByInterval.PathParameters & Paths.FetchDownSampleReadingsByInterval.QueryParameters> | null,
213
+ data?: any,
214
+ config?: AxiosRequestConfig
215
+ ): OperationResponse<Paths.FetchDownSampleReadingsByInterval.Responses.$200>
216
+ }
217
+ }
218
+
219
+ export type Client = OpenAPIClient<OperationMethods, PathsDictionary>
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@epilot/metering-client",
3
+ "version": "0.1.1",
4
+ "description": "API Client for epilot Metering API",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "test": "jest",
9
+ "typescript": "tsc",
10
+ "bundle-definition": "webpack",
11
+ "openapi": "openapi read --json ../lambda/ApiHandlerFunction/openapi.yml > src/openapi.json",
12
+ "typegen": "echo '/* eslint-disable */' > src/openapi.d.ts && typegen ../lambda/ApiHandlerFunction/openapi.yml >> src/openapi.d.ts",
13
+ "build": "npm run openapi && npm run typegen && npm run typescript && npm run bundle-definition",
14
+ "eslint": "../node_modules/.bin/eslint -c ../.eslintrc.yml",
15
+ "prepublishOnly": "npm run build"
16
+ },
17
+ "files": [
18
+ "*.js",
19
+ "*.d.ts",
20
+ "**/*.js",
21
+ "**/*.d.ts",
22
+ "!*.test.*",
23
+ "!**/*.test.*",
24
+ "!node_modules",
25
+ "!src",
26
+ "!*.config.js"
27
+ ],
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/epilot-dev/sdk-js",
31
+ "directory": "clients/ts-sam-client"
32
+ },
33
+ "keywords": [],
34
+ "author": "epilot GmbH",
35
+ "license": "UNLICENSED",
36
+ "peerDependencies": {
37
+ "axios": "^0.21.4"
38
+ },
39
+ "dependencies": {
40
+ "buffer": "^6.0.3",
41
+ "https-browserify": "^1.0.0",
42
+ "openapi-client-axios": "^4.4.9",
43
+ "stream-http": "^3.1.1",
44
+ "url": "^0.11.0",
45
+ "util": "^0.12.3"
46
+ },
47
+ "devDependencies": {
48
+ "@types/jest": "^26.0.20",
49
+ "axios": "^0.21.1",
50
+ "copy-webpack-plugin": "^7.0.0",
51
+ "jest": "^26.6.3",
52
+ "json-loader": "^0.5.7",
53
+ "openapi-client-axios-typegen": "^4.4.9",
54
+ "openapicmd": "^1.8.2",
55
+ "ts-jest": "^26.5.6",
56
+ "ts-loader": "^8.3.0",
57
+ "ts-node": "^9.1.1",
58
+ "typescript": "^4.5.4",
59
+ "webpack": "^5.18.0",
60
+ "webpack-cli": "^4.4.0"
61
+ }
62
+ }