@pgds/api-interface 1.4.0 → 1.4.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/constants/index.d.ts +1 -0
- package/constants/index.js +2 -1
- package/constants/index.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +16 -0
- package/dist/lib/constants/constants.d.ts +2 -0
- package/dist/lib/index.d.ts +188 -0
- package/dist/lib/index.js +331 -0
- package/dist/lib/models/Http.d.ts +61 -0
- package/dist/lib/models/User.d.ts +8 -0
- package/dist/lib/utils/jsonSchemaUtils.d.ts +7 -0
- package/dist/lib/utils/logger.d.ts +4 -0
- package/dist/lib/utils/metadataUtils.d.ts +2 -0
- package/dist/lib/utils/urlUtils.d.ts +1 -0
- package/package.json +99 -99
package/constants/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export declare const AUTH_ACTIVITIES_HEADER = "auth-activities";
|
|
|
5
5
|
export declare const AUTH_ACTIVE_LOGIN_HEADER = "auth-active-login";
|
|
6
6
|
export declare const GLOBAL_ACTIVITY = "global";
|
|
7
7
|
export declare const CAN_MANAGE_ORGANIZATION_ACTIVITY = "canManageOrganization";
|
|
8
|
+
export declare const CAN_MANAGE_PLATFORM_ACTIVITY = "canManagePlatform";
|
|
8
9
|
export declare const REQUEST_ID_HEADER = "request-id";
|
package/constants/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REQUEST_ID_HEADER = exports.CAN_MANAGE_ORGANIZATION_ACTIVITY = exports.GLOBAL_ACTIVITY = exports.AUTH_ACTIVE_LOGIN_HEADER = exports.AUTH_ACTIVITIES_HEADER = exports.AUTH_ORGANIZATION_HIERARCHY_HEADER = exports.AUTH_ORGANIZATION_HEADER = exports.AUTH_USER_HEADER = void 0;
|
|
3
|
+
exports.REQUEST_ID_HEADER = exports.CAN_MANAGE_PLATFORM_ACTIVITY = exports.CAN_MANAGE_ORGANIZATION_ACTIVITY = exports.GLOBAL_ACTIVITY = exports.AUTH_ACTIVE_LOGIN_HEADER = exports.AUTH_ACTIVITIES_HEADER = exports.AUTH_ORGANIZATION_HIERARCHY_HEADER = exports.AUTH_ORGANIZATION_HEADER = exports.AUTH_USER_HEADER = void 0;
|
|
4
4
|
/* Note: These will be exported to the library as @hiotlabs/hiot-api-interface/constants */
|
|
5
5
|
exports.AUTH_USER_HEADER = "auth-user";
|
|
6
6
|
exports.AUTH_ORGANIZATION_HEADER = "auth-organization";
|
|
@@ -9,5 +9,6 @@ exports.AUTH_ACTIVITIES_HEADER = "auth-activities";
|
|
|
9
9
|
exports.AUTH_ACTIVE_LOGIN_HEADER = "auth-active-login";
|
|
10
10
|
exports.GLOBAL_ACTIVITY = "global";
|
|
11
11
|
exports.CAN_MANAGE_ORGANIZATION_ACTIVITY = "canManageOrganization";
|
|
12
|
+
exports.CAN_MANAGE_PLATFORM_ACTIVITY = "canManagePlatform";
|
|
12
13
|
exports.REQUEST_ID_HEADER = "request-id";
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
package/constants/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2FAA2F;AAC9E,QAAA,gBAAgB,GAAG,WAAW,CAAC;AAC/B,QAAA,wBAAwB,GAAG,mBAAmB,CAAC;AAC/C,QAAA,kCAAkC,GAAG,6BAA6B,CAAC;AACnE,QAAA,sBAAsB,GAAG,iBAAiB,CAAC;AAC3C,QAAA,wBAAwB,GAAG,mBAAmB,CAAC;AAE/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,gCAAgC,GAAG,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2FAA2F;AAC9E,QAAA,gBAAgB,GAAG,WAAW,CAAC;AAC/B,QAAA,wBAAwB,GAAG,mBAAmB,CAAC;AAC/C,QAAA,kCAAkC,GAAG,6BAA6B,CAAC;AACnE,QAAA,sBAAsB,GAAG,iBAAiB,CAAC;AAC3C,QAAA,wBAAwB,GAAG,mBAAmB,CAAC;AAE/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,gCAAgC,GAAG,uBAAuB,CAAC;AAC3D,QAAA,4BAA4B,GAAG,mBAAmB,CAAC;AAEnD,QAAA,iBAAiB,GAAG,YAAY,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { setupApiInterface, JsonResponse, del, endpointMetadata, get, getRouteHelpers, head, options, patch, post, put, internal, Method } from "./lib";
|
|
2
|
+
import { Next, Request, Response } from "./lib/models/Http";
|
|
3
|
+
import { User } from "./lib/models/User";
|
|
4
|
+
export { endpointMetadata, del, get, getRouteHelpers, head, options, patch, post, put, internal, setupApiInterface, JsonResponse, Request, Response, Next, Method, User, };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Method = exports.setupApiInterface = exports.internal = exports.put = exports.post = exports.patch = exports.options = exports.head = exports.getRouteHelpers = exports.get = exports.del = exports.endpointMetadata = void 0;
|
|
4
|
+
var lib_1 = require("./lib");
|
|
5
|
+
Object.defineProperty(exports, "setupApiInterface", { enumerable: true, get: function () { return lib_1.setupApiInterface; } });
|
|
6
|
+
Object.defineProperty(exports, "del", { enumerable: true, get: function () { return lib_1.del; } });
|
|
7
|
+
Object.defineProperty(exports, "endpointMetadata", { enumerable: true, get: function () { return lib_1.endpointMetadata; } });
|
|
8
|
+
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return lib_1.get; } });
|
|
9
|
+
Object.defineProperty(exports, "getRouteHelpers", { enumerable: true, get: function () { return lib_1.getRouteHelpers; } });
|
|
10
|
+
Object.defineProperty(exports, "head", { enumerable: true, get: function () { return lib_1.head; } });
|
|
11
|
+
Object.defineProperty(exports, "options", { enumerable: true, get: function () { return lib_1.options; } });
|
|
12
|
+
Object.defineProperty(exports, "patch", { enumerable: true, get: function () { return lib_1.patch; } });
|
|
13
|
+
Object.defineProperty(exports, "post", { enumerable: true, get: function () { return lib_1.post; } });
|
|
14
|
+
Object.defineProperty(exports, "put", { enumerable: true, get: function () { return lib_1.put; } });
|
|
15
|
+
Object.defineProperty(exports, "internal", { enumerable: true, get: function () { return lib_1.internal; } });
|
|
16
|
+
Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return lib_1.Method; } });
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/// <reference path="../../types/hiot.d.ts" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import App, { Locator } from "hiot";
|
|
5
|
+
import { RouteOptions } from "restify";
|
|
6
|
+
import { Next, Request, Response } from "./models/Http";
|
|
7
|
+
export declare const readDirAsync: typeof fs.readdir.__promisify__;
|
|
8
|
+
export declare enum Method {
|
|
9
|
+
Post = "post",
|
|
10
|
+
Get = "get",
|
|
11
|
+
Put = "put",
|
|
12
|
+
Patch = "patch",
|
|
13
|
+
Del = "del",
|
|
14
|
+
Head = "head",
|
|
15
|
+
Options = "options"
|
|
16
|
+
}
|
|
17
|
+
type OmittedFields = "internal" | "method";
|
|
18
|
+
export declare function get(options: Omit<EndpointOptions, OmittedFields>): {
|
|
19
|
+
(api: App): void;
|
|
20
|
+
/**
|
|
21
|
+
* Makes it possible to access the requestHandler through the exported function.
|
|
22
|
+
* If you need to test the function separately, without starting the server
|
|
23
|
+
*/
|
|
24
|
+
requestHandler: (req: Request<any, any>, res?: Response<any> | undefined, next?: Next | undefined) => Promise<void | JsonResponse<any>>;
|
|
25
|
+
/** Endpoint's full path (including any version number and internal prefix) */
|
|
26
|
+
PATH: string;
|
|
27
|
+
};
|
|
28
|
+
export declare function post(options: Omit<EndpointOptions, OmittedFields>): {
|
|
29
|
+
(api: App): void;
|
|
30
|
+
/**
|
|
31
|
+
* Makes it possible to access the requestHandler through the exported function.
|
|
32
|
+
* If you need to test the function separately, without starting the server
|
|
33
|
+
*/
|
|
34
|
+
requestHandler: (req: Request<any, any>, res?: Response<any> | undefined, next?: Next | undefined) => Promise<void | JsonResponse<any>>;
|
|
35
|
+
/** Endpoint's full path (including any version number and internal prefix) */
|
|
36
|
+
PATH: string;
|
|
37
|
+
};
|
|
38
|
+
export declare function put(options: Omit<EndpointOptions, OmittedFields>): {
|
|
39
|
+
(api: App): void;
|
|
40
|
+
/**
|
|
41
|
+
* Makes it possible to access the requestHandler through the exported function.
|
|
42
|
+
* If you need to test the function separately, without starting the server
|
|
43
|
+
*/
|
|
44
|
+
requestHandler: (req: Request<any, any>, res?: Response<any> | undefined, next?: Next | undefined) => Promise<void | JsonResponse<any>>;
|
|
45
|
+
/** Endpoint's full path (including any version number and internal prefix) */
|
|
46
|
+
PATH: string;
|
|
47
|
+
};
|
|
48
|
+
export declare function patch(options: Omit<EndpointOptions, OmittedFields>): {
|
|
49
|
+
(api: App): void;
|
|
50
|
+
/**
|
|
51
|
+
* Makes it possible to access the requestHandler through the exported function.
|
|
52
|
+
* If you need to test the function separately, without starting the server
|
|
53
|
+
*/
|
|
54
|
+
requestHandler: (req: Request<any, any>, res?: Response<any> | undefined, next?: Next | undefined) => Promise<void | JsonResponse<any>>;
|
|
55
|
+
/** Endpoint's full path (including any version number and internal prefix) */
|
|
56
|
+
PATH: string;
|
|
57
|
+
};
|
|
58
|
+
export declare function del(options: Omit<EndpointOptions, OmittedFields>): {
|
|
59
|
+
(api: App): void;
|
|
60
|
+
/**
|
|
61
|
+
* Makes it possible to access the requestHandler through the exported function.
|
|
62
|
+
* If you need to test the function separately, without starting the server
|
|
63
|
+
*/
|
|
64
|
+
requestHandler: (req: Request<any, any>, res?: Response<any> | undefined, next?: Next | undefined) => Promise<void | JsonResponse<any>>;
|
|
65
|
+
/** Endpoint's full path (including any version number and internal prefix) */
|
|
66
|
+
PATH: string;
|
|
67
|
+
};
|
|
68
|
+
export declare function head(options: Omit<EndpointOptions, OmittedFields>): {
|
|
69
|
+
(api: App): void;
|
|
70
|
+
/**
|
|
71
|
+
* Makes it possible to access the requestHandler through the exported function.
|
|
72
|
+
* If you need to test the function separately, without starting the server
|
|
73
|
+
*/
|
|
74
|
+
requestHandler: (req: Request<any, any>, res?: Response<any> | undefined, next?: Next | undefined) => Promise<void | JsonResponse<any>>;
|
|
75
|
+
/** Endpoint's full path (including any version number and internal prefix) */
|
|
76
|
+
PATH: string;
|
|
77
|
+
};
|
|
78
|
+
export declare function options(options: Omit<EndpointOptions, OmittedFields>): {
|
|
79
|
+
(api: App): void;
|
|
80
|
+
/**
|
|
81
|
+
* Makes it possible to access the requestHandler through the exported function.
|
|
82
|
+
* If you need to test the function separately, without starting the server
|
|
83
|
+
*/
|
|
84
|
+
requestHandler: (req: Request<any, any>, res?: Response<any> | undefined, next?: Next | undefined) => Promise<void | JsonResponse<any>>;
|
|
85
|
+
/** Endpoint's full path (including any version number and internal prefix) */
|
|
86
|
+
PATH: string;
|
|
87
|
+
};
|
|
88
|
+
/** Internal endpoints are not available through the API */
|
|
89
|
+
export declare function internal(options: Omit<EndpointOptions, "internal">): {
|
|
90
|
+
(api: App): void;
|
|
91
|
+
/**
|
|
92
|
+
* Makes it possible to access the requestHandler through the exported function.
|
|
93
|
+
* If you need to test the function separately, without starting the server
|
|
94
|
+
*/
|
|
95
|
+
requestHandler: (req: Request<any, any>, res?: Response<any> | undefined, next?: Next | undefined) => Promise<void | JsonResponse<any>>;
|
|
96
|
+
/** Endpoint's full path (including any version number and internal prefix) */
|
|
97
|
+
PATH: string;
|
|
98
|
+
};
|
|
99
|
+
export interface JsonResponse<T> {
|
|
100
|
+
/** Response body */
|
|
101
|
+
body?: T;
|
|
102
|
+
/** HTTP status code. @default 200 */
|
|
103
|
+
status?: number;
|
|
104
|
+
/** Additional headers */
|
|
105
|
+
headers?: {
|
|
106
|
+
totalcount?: number;
|
|
107
|
+
[key: string]: any;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export { Next, Request, Response };
|
|
111
|
+
export interface EndpointOptions {
|
|
112
|
+
/** Whether to add the endpoint to the metadata or not. @default true */
|
|
113
|
+
addToMetadata?: boolean;
|
|
114
|
+
/** Whether the endpoint is internal or not */
|
|
115
|
+
internal?: boolean;
|
|
116
|
+
/** The path to the endpoint */
|
|
117
|
+
path: string;
|
|
118
|
+
/** The activity that is required to access this endpoint */
|
|
119
|
+
authorized?: string;
|
|
120
|
+
/** Whether you need to be logged in or not to access the endpoint. Only needed if authorized is not used. */
|
|
121
|
+
authenticated?: boolean;
|
|
122
|
+
/** HTTP method */
|
|
123
|
+
method: Method;
|
|
124
|
+
/**
|
|
125
|
+
* The request schema, either a JSON schema or the name of a typescript type
|
|
126
|
+
* (See below. The name must match the name of the file in ./api/schemas).
|
|
127
|
+
**/
|
|
128
|
+
requestSchema?: object | string;
|
|
129
|
+
/** Additional route options */
|
|
130
|
+
opts?: RouteOptions;
|
|
131
|
+
/** prefix for the path, e.g. /v1, defaults to what was set in setupApiInterface */
|
|
132
|
+
version?: string;
|
|
133
|
+
/** The documentation for the endpoint */
|
|
134
|
+
documentation?: {
|
|
135
|
+
/** Short description of the endpoint */
|
|
136
|
+
summary: string;
|
|
137
|
+
/** Long description of the endpoint */
|
|
138
|
+
description?: string;
|
|
139
|
+
/** Optional array of tags */
|
|
140
|
+
tags?: string[];
|
|
141
|
+
/**
|
|
142
|
+
* Optional description for query params (can also be defined and described in the json schema,
|
|
143
|
+
* since that's how we validate them)
|
|
144
|
+
**/
|
|
145
|
+
query?: Record<string, string>;
|
|
146
|
+
/**
|
|
147
|
+
* Optional description of url parameters.
|
|
148
|
+
* Usually unnecessary since url params should be self descriptive, e.g. /dashboards/:dashboardId
|
|
149
|
+
**/
|
|
150
|
+
parameters?: Record<string, string>;
|
|
151
|
+
/** Response schemas */
|
|
152
|
+
responses?: {
|
|
153
|
+
/** HTTP status code */
|
|
154
|
+
status: number;
|
|
155
|
+
/** An optional description of the response */
|
|
156
|
+
description?: string;
|
|
157
|
+
/**
|
|
158
|
+
* An optional response schema, either a JSON schema or the name of a typescript type
|
|
159
|
+
* (See below. The name must match the name of the file in ./api/schemas).
|
|
160
|
+
**/
|
|
161
|
+
schema?: any | any[];
|
|
162
|
+
}[];
|
|
163
|
+
};
|
|
164
|
+
/** The request handler function */
|
|
165
|
+
requestHandler: (req: Request<any>, res?: Response<any>, next?: Next) => Promise<JsonResponse<any> | void>;
|
|
166
|
+
}
|
|
167
|
+
export type EndpointMetadata = Omit<EndpointOptions, "requestHandler" | "opts">;
|
|
168
|
+
export declare const endpointMetadata: {
|
|
169
|
+
[key in Method]: Record<string, EndpointMetadata>;
|
|
170
|
+
};
|
|
171
|
+
export declare function getRouteHelpers(): {
|
|
172
|
+
authenticated: () => App.RequestHandlerType;
|
|
173
|
+
authorized: (activity: string) => App.RequestHandlerType;
|
|
174
|
+
};
|
|
175
|
+
export interface ApiInterfaceOptions {
|
|
176
|
+
/** Name of the service */
|
|
177
|
+
serviceName: string;
|
|
178
|
+
/** Default log level for the service */
|
|
179
|
+
serviceLogLevel: string;
|
|
180
|
+
/** Whether to use typescript or not */
|
|
181
|
+
typescript: boolean;
|
|
182
|
+
/** Global version of the API @default v1. Can be overridden per endpoint */
|
|
183
|
+
apiVersion: string;
|
|
184
|
+
/** The base path to the schemas. @default api/schemas */
|
|
185
|
+
schemaBasePath?: string;
|
|
186
|
+
}
|
|
187
|
+
export declare function getApiOptions(): ApiInterfaceOptions;
|
|
188
|
+
export declare function setupApiInterface(options: ApiInterfaceOptions): (locator: Locator) => Promise<App.Locator>;
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
73
|
+
var t = {};
|
|
74
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
75
|
+
t[p] = s[p];
|
|
76
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
77
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
78
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
79
|
+
t[p[i]] = s[p[i]];
|
|
80
|
+
}
|
|
81
|
+
return t;
|
|
82
|
+
};
|
|
83
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
84
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
85
|
+
if (ar || !(i in from)) {
|
|
86
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
87
|
+
ar[i] = from[i];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
91
|
+
};
|
|
92
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
93
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
94
|
+
};
|
|
95
|
+
var _a;
|
|
96
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
97
|
+
exports.setupApiInterface = exports.getApiOptions = exports.getRouteHelpers = exports.endpointMetadata = exports.internal = exports.options = exports.head = exports.del = exports.patch = exports.put = exports.post = exports.get = exports.Method = exports.readDirAsync = void 0;
|
|
98
|
+
var fs_1 = __importDefault(require("fs"));
|
|
99
|
+
var hiot_restify5_1 = require("hiot-restify5");
|
|
100
|
+
var mustbe_1 = __importDefault(require("mustbe"));
|
|
101
|
+
var restify_errors_1 = __importDefault(require("restify-errors"));
|
|
102
|
+
var util_1 = require("util");
|
|
103
|
+
var constants_1 = require("./constants/constants");
|
|
104
|
+
var jsonSchemaUtils_1 = require("./utils/jsonSchemaUtils");
|
|
105
|
+
var logger_1 = __importStar(require("./utils/logger"));
|
|
106
|
+
var urlUtils_1 = require("./utils/urlUtils");
|
|
107
|
+
exports.readDirAsync = (0, util_1.promisify)(fs_1.default.readdir);
|
|
108
|
+
var Method;
|
|
109
|
+
(function (Method) {
|
|
110
|
+
Method["Post"] = "post";
|
|
111
|
+
Method["Get"] = "get";
|
|
112
|
+
Method["Put"] = "put";
|
|
113
|
+
Method["Patch"] = "patch";
|
|
114
|
+
Method["Del"] = "del";
|
|
115
|
+
Method["Head"] = "head";
|
|
116
|
+
Method["Options"] = "options";
|
|
117
|
+
})(Method || (exports.Method = Method = {}));
|
|
118
|
+
function get(options) {
|
|
119
|
+
return registerEndpoint(__assign(__assign({}, options), { method: Method.Get }));
|
|
120
|
+
}
|
|
121
|
+
exports.get = get;
|
|
122
|
+
function post(options) {
|
|
123
|
+
return registerEndpoint(__assign(__assign({}, options), { method: Method.Post }));
|
|
124
|
+
}
|
|
125
|
+
exports.post = post;
|
|
126
|
+
function put(options) {
|
|
127
|
+
return registerEndpoint(__assign(__assign({}, options), { method: Method.Put }));
|
|
128
|
+
}
|
|
129
|
+
exports.put = put;
|
|
130
|
+
function patch(options) {
|
|
131
|
+
return registerEndpoint(__assign(__assign({}, options), { method: Method.Patch }));
|
|
132
|
+
}
|
|
133
|
+
exports.patch = patch;
|
|
134
|
+
function del(options) {
|
|
135
|
+
return registerEndpoint(__assign(__assign({}, options), { method: Method.Del }));
|
|
136
|
+
}
|
|
137
|
+
exports.del = del;
|
|
138
|
+
function head(options) {
|
|
139
|
+
return registerEndpoint(__assign(__assign({}, options), { method: Method.Head }));
|
|
140
|
+
}
|
|
141
|
+
exports.head = head;
|
|
142
|
+
function options(options) {
|
|
143
|
+
return registerEndpoint(__assign(__assign({}, options), { method: Method.Options }));
|
|
144
|
+
}
|
|
145
|
+
exports.options = options;
|
|
146
|
+
/** Internal endpoints are not available through the API */
|
|
147
|
+
function internal(options) {
|
|
148
|
+
return registerEndpoint(__assign(__assign({}, options), { internal: true }));
|
|
149
|
+
}
|
|
150
|
+
exports.internal = internal;
|
|
151
|
+
exports.endpointMetadata = (_a = {},
|
|
152
|
+
_a[Method.Post] = {},
|
|
153
|
+
_a[Method.Get] = {},
|
|
154
|
+
_a[Method.Put] = {},
|
|
155
|
+
_a[Method.Patch] = {},
|
|
156
|
+
_a[Method.Del] = {},
|
|
157
|
+
_a[Method.Head] = {},
|
|
158
|
+
_a.options = {},
|
|
159
|
+
_a);
|
|
160
|
+
var metadataRegistered = false;
|
|
161
|
+
function registerMetadataEndpoint(api) {
|
|
162
|
+
var _this = this;
|
|
163
|
+
if (metadataRegistered) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
metadataRegistered = true;
|
|
167
|
+
registerEndpoint({
|
|
168
|
+
path: "/".concat(apiOptions.serviceName, "/metadata"),
|
|
169
|
+
method: Method.Get,
|
|
170
|
+
addToMetadata: false,
|
|
171
|
+
version: "",
|
|
172
|
+
requestHandler: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
173
|
+
return __generator(this, function (_a) {
|
|
174
|
+
// prepare metadata here so that we get schemas and not just ids in the response
|
|
175
|
+
return [2 /*return*/, {
|
|
176
|
+
body: exports.endpointMetadata,
|
|
177
|
+
}];
|
|
178
|
+
});
|
|
179
|
+
}); },
|
|
180
|
+
})(api);
|
|
181
|
+
}
|
|
182
|
+
var mustBe;
|
|
183
|
+
function getRouteHelpers() {
|
|
184
|
+
if (!mustBe) {
|
|
185
|
+
mustBe = mustbe_1.default.routeHelpers();
|
|
186
|
+
}
|
|
187
|
+
return mustBe;
|
|
188
|
+
}
|
|
189
|
+
exports.getRouteHelpers = getRouteHelpers;
|
|
190
|
+
function registerEndpoint(options) {
|
|
191
|
+
var _this = this;
|
|
192
|
+
var _a;
|
|
193
|
+
var requestHandler = options.requestHandler, opts = options.opts, _b = options.addToMetadata, addToMetadata = _b === void 0 ? true : _b, metadata = __rest(options, ["requestHandler", "opts", "addToMetadata"]);
|
|
194
|
+
if (!constants_1.CI) {
|
|
195
|
+
if (addToMetadata) {
|
|
196
|
+
exports.endpointMetadata[options.method][options.path] = metadata;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
var fn = function (api) {
|
|
200
|
+
// registerMetadataEndpoint(api);
|
|
201
|
+
var _a;
|
|
202
|
+
var mustBe = getRouteHelpers();
|
|
203
|
+
var routeOptions = {
|
|
204
|
+
path: (0, urlUtils_1.route)((_a = options.version) !== null && _a !== void 0 ? _a : apiVersion, options.path, options.internal),
|
|
205
|
+
};
|
|
206
|
+
if (options.opts) {
|
|
207
|
+
routeOptions = __assign(__assign({}, routeOptions), options.opts);
|
|
208
|
+
}
|
|
209
|
+
var requestHandlers = [];
|
|
210
|
+
if (options.authenticated) {
|
|
211
|
+
requestHandlers.push(mustBe.authenticated());
|
|
212
|
+
}
|
|
213
|
+
if (options.authorized) {
|
|
214
|
+
requestHandlers.push(mustBe.authorized(options.authorized));
|
|
215
|
+
}
|
|
216
|
+
if (options.requestSchema) {
|
|
217
|
+
var schema = options.requestSchema;
|
|
218
|
+
if (typeof schema === "string") {
|
|
219
|
+
schema = (0, jsonSchemaUtils_1.getSchema)(schema);
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
var validatedSchema = (0, hiot_restify5_1.validate)(schema);
|
|
223
|
+
requestHandlers.push(validatedSchema);
|
|
224
|
+
}
|
|
225
|
+
catch (err) {
|
|
226
|
+
console.error(err);
|
|
227
|
+
throw err;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
var responseSchemas = [];
|
|
231
|
+
if (constants_1.CI) {
|
|
232
|
+
responseSchemas = (0, jsonSchemaUtils_1.prepareResponseSchemas)(options);
|
|
233
|
+
}
|
|
234
|
+
requestHandlers.push(function (req, res, next) { return __awaiter(_this, void 0, void 0, function () {
|
|
235
|
+
var response, header, err_1;
|
|
236
|
+
var _a, _b;
|
|
237
|
+
return __generator(this, function (_c) {
|
|
238
|
+
switch (_c.label) {
|
|
239
|
+
case 0:
|
|
240
|
+
_c.trys.push([0, 2, , 3]);
|
|
241
|
+
return [4 /*yield*/, options.requestHandler(req, res, next)];
|
|
242
|
+
case 1:
|
|
243
|
+
response = _c.sent();
|
|
244
|
+
if (response) {
|
|
245
|
+
res.statusCode = (_a = response.status) !== null && _a !== void 0 ? _a : 200;
|
|
246
|
+
if (response.headers) {
|
|
247
|
+
for (header in response.headers) {
|
|
248
|
+
res.header(header, response.headers[header]);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (response.body) {
|
|
252
|
+
if (constants_1.CI && !!responseSchemas.length) {
|
|
253
|
+
(0, jsonSchemaUtils_1.validateResponseBody)(responseSchemas, response.body);
|
|
254
|
+
}
|
|
255
|
+
res.json(response.body);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
res.end();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return [2 /*return*/, next()];
|
|
262
|
+
case 2:
|
|
263
|
+
err_1 = _c.sent();
|
|
264
|
+
if ((_b = err_1 === null || err_1 === void 0 ? void 0 : err_1.body) === null || _b === void 0 ? void 0 : _b.code) {
|
|
265
|
+
if (constants_1.CI) {
|
|
266
|
+
console.error(err_1.toString());
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
logger_1.default.error(err_1);
|
|
270
|
+
}
|
|
271
|
+
return [2 /*return*/, next(err_1)];
|
|
272
|
+
}
|
|
273
|
+
if (constants_1.CI) {
|
|
274
|
+
console.error(err_1.toString ? err_1.toString() : err_1);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
logger_1.default.error(err_1);
|
|
278
|
+
}
|
|
279
|
+
return [2 /*return*/, next(new restify_errors_1.default.InternalError(err_1))];
|
|
280
|
+
case 3: return [2 /*return*/];
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}); });
|
|
284
|
+
var pendingRoute = {
|
|
285
|
+
method: options.method,
|
|
286
|
+
opts: routeOptions,
|
|
287
|
+
handlers: requestHandlers,
|
|
288
|
+
};
|
|
289
|
+
// @ts-ignore
|
|
290
|
+
api[pendingRoute.method].apply(api, __spreadArray([pendingRoute.opts], pendingRoute.handlers, false));
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Makes it possible to access the requestHandler through the exported function.
|
|
294
|
+
* If you need to test the function separately, without starting the server
|
|
295
|
+
*/
|
|
296
|
+
fn.requestHandler = options.requestHandler;
|
|
297
|
+
/** Endpoint's full path (including any version number and internal prefix) */
|
|
298
|
+
fn.PATH = (0, urlUtils_1.route)((_a = options.version) !== null && _a !== void 0 ? _a : apiVersion, options.path, options.internal);
|
|
299
|
+
return fn;
|
|
300
|
+
}
|
|
301
|
+
var apiVersion = "v1";
|
|
302
|
+
var apiOptions = {};
|
|
303
|
+
function getApiOptions() {
|
|
304
|
+
return apiOptions;
|
|
305
|
+
}
|
|
306
|
+
exports.getApiOptions = getApiOptions;
|
|
307
|
+
function setupApiInterface(options) {
|
|
308
|
+
var _this = this;
|
|
309
|
+
apiOptions = options;
|
|
310
|
+
return function (locator) { return __awaiter(_this, void 0, void 0, function () {
|
|
311
|
+
var files;
|
|
312
|
+
var _a;
|
|
313
|
+
return __generator(this, function (_b) {
|
|
314
|
+
switch (_b.label) {
|
|
315
|
+
case 0:
|
|
316
|
+
if (!(options.typescript &&
|
|
317
|
+
/** This check is only applicable during tests, so it's only run once */
|
|
318
|
+
jsonSchemaUtils_1.schemaCache.size === 0)) return [3 /*break*/, 2];
|
|
319
|
+
return [4 /*yield*/, (0, exports.readDirAsync)((_a = options.schemaBasePath) !== null && _a !== void 0 ? _a : constants_1.SCHEMA_BASE_PATH)];
|
|
320
|
+
case 1:
|
|
321
|
+
files = _b.sent();
|
|
322
|
+
(0, jsonSchemaUtils_1.getSchemas)(files.map(function (file) { return file.replace(".ts", ""); }));
|
|
323
|
+
_b.label = 2;
|
|
324
|
+
case 2:
|
|
325
|
+
(0, logger_1.setupLogger)(options.serviceName, options.serviceLogLevel);
|
|
326
|
+
return [2 /*return*/, locator];
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}); };
|
|
330
|
+
}
|
|
331
|
+
exports.setupApiInterface = setupApiInterface;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { User } from "./User";
|
|
2
|
+
import { Request as RestifyRequest, Response as RestifyResponse, Next as RestifyNext } from "restify";
|
|
3
|
+
export interface Request<BodyParams = Record<string, any>, QueryParams = any> extends RestifyRequest {
|
|
4
|
+
params: BodyParams;
|
|
5
|
+
user: User;
|
|
6
|
+
query: QueryParams;
|
|
7
|
+
}
|
|
8
|
+
export interface Next extends RestifyNext {
|
|
9
|
+
(err?: any): void;
|
|
10
|
+
}
|
|
11
|
+
export interface Response<Body = Record<string, any>> extends RestifyResponse {
|
|
12
|
+
/**
|
|
13
|
+
* short hand method for:
|
|
14
|
+
* res.contentType = 'json';
|
|
15
|
+
* res.send({hello: 'world'});
|
|
16
|
+
* @param code http status code
|
|
17
|
+
* @param body value to json.stringify
|
|
18
|
+
* @param [headers] headers to set on the response
|
|
19
|
+
*/
|
|
20
|
+
json(code: number, body: Body, headers?: {
|
|
21
|
+
[header: string]: string;
|
|
22
|
+
}): any;
|
|
23
|
+
/**
|
|
24
|
+
* short hand method for:
|
|
25
|
+
* res.contentType = 'json';
|
|
26
|
+
* res.send({hello: 'world'});
|
|
27
|
+
* @param code http status code
|
|
28
|
+
*/
|
|
29
|
+
json(code: number): any;
|
|
30
|
+
/**
|
|
31
|
+
* short hand method for:
|
|
32
|
+
* res.contentType = 'json';
|
|
33
|
+
* res.send({hello: 'world'});
|
|
34
|
+
* @param body value to json.stringify
|
|
35
|
+
* @param [headers] headers to set on the response
|
|
36
|
+
*/
|
|
37
|
+
json(body: Body, headers?: {
|
|
38
|
+
[header: string]: string;
|
|
39
|
+
}): any;
|
|
40
|
+
/**
|
|
41
|
+
* sends the response object. pass through to internal __send that uses a
|
|
42
|
+
* formatter based on the content-type header.
|
|
43
|
+
* @param [code] http status code
|
|
44
|
+
* @param [body] the content to send
|
|
45
|
+
* @param [headers] any add'l headers to set
|
|
46
|
+
* @returns the response object
|
|
47
|
+
*/
|
|
48
|
+
send(code?: number, body?: Body, headers?: {
|
|
49
|
+
[header: string]: string;
|
|
50
|
+
}): any;
|
|
51
|
+
/**
|
|
52
|
+
* sends the response object. pass through to internal __send that uses a
|
|
53
|
+
* formatter based on the content-type header.
|
|
54
|
+
* @param [body] the content to send
|
|
55
|
+
* @param [headers] any add'l headers to set
|
|
56
|
+
* @returns the response object
|
|
57
|
+
*/
|
|
58
|
+
send(body?: Body, headers?: {
|
|
59
|
+
[header: string]: string;
|
|
60
|
+
}): any;
|
|
61
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EndpointOptions } from "..";
|
|
2
|
+
/** Speeds up loading schemas when testing by only loading the schemas once instead of once per test file */
|
|
3
|
+
export declare const schemaCache: Map<string, object>;
|
|
4
|
+
export declare function getSchemas(schemaNames: string[]): void;
|
|
5
|
+
export declare function getSchema(schemaName: string): object | undefined;
|
|
6
|
+
export declare function prepareResponseSchemas(options: EndpointOptions): object[];
|
|
7
|
+
export declare function validateResponseBody(schemas: object[], body: object): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function route(version: string, path: string, internal?: boolean): string;
|
package/package.json
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
2
|
+
"name": "@pgds/api-interface",
|
|
3
|
+
"description": "Api interface for pgds services",
|
|
4
|
+
"authors": "Florry",
|
|
5
|
+
"version": "1.4.1",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"types": "types/",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prepublish": "npm run build",
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"pretest": "npm run build",
|
|
12
|
+
"test": "nyc --require ts-node/register --reporter=html mocha --colors",
|
|
13
|
+
"clean": "git clean -f -x -e node_modules/ -e coverage/"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"**/*.d.ts",
|
|
17
|
+
"./index.js",
|
|
18
|
+
"lib/**/*.js",
|
|
19
|
+
"lib/**/*.js.map",
|
|
20
|
+
"lib/**/*.d.ts",
|
|
21
|
+
"errors/**/*.js",
|
|
22
|
+
"errors/**/*.js.map",
|
|
23
|
+
"errors/**/*.d.ts",
|
|
24
|
+
"constants/**/*.js",
|
|
25
|
+
"constants/**/*.js.map",
|
|
26
|
+
"constants/**/*.d.ts",
|
|
27
|
+
"utils/**/*.js",
|
|
28
|
+
"utils/**/*.js.map",
|
|
29
|
+
"utils/**/*.d.ts",
|
|
30
|
+
"client/**/*.js",
|
|
31
|
+
"client/**/*.js.map",
|
|
32
|
+
"client/**/*.d.ts"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@types/restify": "^8.5.12",
|
|
36
|
+
"@types/restify-errors": "^4.3.9",
|
|
37
|
+
"@pgds/utils": "1.0.7",
|
|
38
|
+
"ajv": "8.17.1",
|
|
39
|
+
"ajv-formats": "3.0.1",
|
|
40
|
+
"axios": "1.7.9",
|
|
41
|
+
"mustbe": "0.4.0",
|
|
42
|
+
"nyc": "^17.1.0",
|
|
43
|
+
"prom-client": "^12.0.0",
|
|
44
|
+
"restify": "^11.1.0",
|
|
45
|
+
"restify-errors": "8.0.2",
|
|
46
|
+
"semver": "^7.3.8",
|
|
47
|
+
"ts-node": "^10.9.2",
|
|
48
|
+
"ts-node-test-register": "^10.0.0",
|
|
49
|
+
"uuid": "9.0.1",
|
|
50
|
+
"typescript": "^5.7.2",
|
|
51
|
+
"typescript-json-schema": "0.65.1"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/chai": "4.3.12",
|
|
55
|
+
"@types/mocha": "^10.0.6",
|
|
56
|
+
"@types/mockery": "^1.4.30",
|
|
57
|
+
"@types/nock": "11.1.0",
|
|
58
|
+
"@types/semver": "^7.3.13",
|
|
59
|
+
"@types/supertest": "^2.0.11",
|
|
60
|
+
"@types/uuid": "^8.3.4",
|
|
61
|
+
"chai": "^4.3.6",
|
|
62
|
+
"chai-subset": "^1.6.0",
|
|
63
|
+
"mocha": "10.2.0",
|
|
64
|
+
"mockery": "2.1.0",
|
|
65
|
+
"supertest": "6.3.4",
|
|
66
|
+
"nock": "13.5.5"
|
|
67
|
+
},
|
|
68
|
+
"directories": {
|
|
69
|
+
"example": "examples",
|
|
70
|
+
"lib": "lib",
|
|
71
|
+
"types": "types"
|
|
72
|
+
},
|
|
73
|
+
"repository": {
|
|
74
|
+
"type": "git",
|
|
75
|
+
"url": "git+https://github.com/hiotlabs/hiot-api-interface.git"
|
|
76
|
+
},
|
|
77
|
+
"keywords": [
|
|
78
|
+
"restify"
|
|
79
|
+
],
|
|
80
|
+
"author": "",
|
|
81
|
+
"license": "ISC",
|
|
82
|
+
"bugs": {
|
|
83
|
+
"url": "https://github.com/hiotlabs/hiot-api-interface/issues"
|
|
84
|
+
},
|
|
85
|
+
"homepage": "https://github.com/hiotlabs/hiot-api-interface#readme",
|
|
86
|
+
"mocha": {
|
|
87
|
+
"extension": [
|
|
88
|
+
"ts",
|
|
89
|
+
"js"
|
|
33
90
|
],
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"restify-errors": "8.0.2",
|
|
46
|
-
"semver": "^7.3.8",
|
|
47
|
-
"ts-node": "^10.9.2",
|
|
48
|
-
"ts-node-test-register": "^10.0.0",
|
|
49
|
-
"uuid": "9.0.1",
|
|
50
|
-
"typescript": "^5.7.2",
|
|
51
|
-
"typescript-json-schema": "0.65.1"
|
|
52
|
-
},
|
|
53
|
-
"devDependencies": {
|
|
54
|
-
"@types/chai": "4.3.12",
|
|
55
|
-
"@types/mocha": "^10.0.6",
|
|
56
|
-
"@types/mockery": "^1.4.30",
|
|
57
|
-
"@types/nock": "11.1.0",
|
|
58
|
-
"@types/semver": "^7.3.13",
|
|
59
|
-
"@types/supertest": "^2.0.11",
|
|
60
|
-
"@types/uuid": "^8.3.4",
|
|
61
|
-
"chai": "^4.3.6",
|
|
62
|
-
"chai-subset": "^1.6.0",
|
|
63
|
-
"mocha": "10.2.0",
|
|
64
|
-
"mockery": "2.1.0",
|
|
65
|
-
"supertest": "6.3.4",
|
|
66
|
-
"nock": "13.5.5"
|
|
67
|
-
},
|
|
68
|
-
"directories": {
|
|
69
|
-
"example": "examples",
|
|
70
|
-
"lib": "lib",
|
|
71
|
-
"types": "types"
|
|
72
|
-
},
|
|
73
|
-
"repository": {
|
|
74
|
-
"type": "git",
|
|
75
|
-
"url": "git+https://github.com/hiotlabs/hiot-api-interface.git"
|
|
76
|
-
},
|
|
77
|
-
"keywords": [
|
|
78
|
-
"restify"
|
|
79
|
-
],
|
|
80
|
-
"author": "",
|
|
81
|
-
"license": "ISC",
|
|
82
|
-
"bugs": {
|
|
83
|
-
"url": "https://github.com/hiotlabs/hiot-api-interface/issues"
|
|
84
|
-
},
|
|
85
|
-
"homepage": "https://github.com/hiotlabs/hiot-api-interface#readme",
|
|
86
|
-
"mocha": {
|
|
87
|
-
"extension": [
|
|
88
|
-
"ts",
|
|
89
|
-
"js"
|
|
90
|
-
],
|
|
91
|
-
"spec": "test/**/*.test.{ts,js}"
|
|
92
|
-
},
|
|
93
|
-
"nyc": {
|
|
94
|
-
"exclude": [
|
|
95
|
-
"coverage",
|
|
96
|
-
"test",
|
|
97
|
-
"**/*.d.ts",
|
|
98
|
-
"**/*.js.map"
|
|
99
|
-
]
|
|
100
|
-
}
|
|
101
|
-
}
|
|
91
|
+
"spec": "test/**/*.test.{ts,js}"
|
|
92
|
+
},
|
|
93
|
+
"nyc": {
|
|
94
|
+
"exclude": [
|
|
95
|
+
"coverage",
|
|
96
|
+
"test",
|
|
97
|
+
"**/*.d.ts",
|
|
98
|
+
"**/*.js.map"
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
}
|