@airtasker/spot
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -18,4 +18,4 @@ "use strict"; | ||
const { flags } = this.parse(Generate); | ||
// tslint:disable-next-line:prefer-const | ||
let { contract: contractPath, language, generator, out: outDir } = flags; | ||
const { contract: contractPath } = flags; | ||
let { language, generator, out: outDir } = flags; | ||
const contractFilename = path_1.default.basename(contractPath, ".ts"); | ||
@@ -94,2 +94,3 @@ if (!generator) { | ||
const jsonFormat = { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
formatter: (obj) => JSON.stringify(obj, null, 2), | ||
@@ -99,2 +100,3 @@ extension: "json" | ||
const yamlFormat = { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
formatter: (obj) => js_yaml_1.default.safeDump(obj, { skipInvalid: true /* for undefined */ }), | ||
@@ -105,2 +107,3 @@ extension: "yml" | ||
raw: { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
transformer: (contract) => { | ||
@@ -107,0 +110,0 @@ return contract; |
@@ -14,3 +14,2 @@ "use strict"; | ||
this.error(`There is already an API here!`); | ||
this.exit(1); | ||
} | ||
@@ -17,0 +16,0 @@ output_1.outputFile(".", "api.ts", `import { api, body, endpoint, request, response, String } from "@airtasker/spot"; |
@@ -22,3 +22,3 @@ "use strict"; | ||
port, | ||
pathPrefix: pathPrefix || "", | ||
pathPrefix: pathPrefix !== null && pathPrefix !== void 0 ? pathPrefix : "", | ||
...proxyConfig, | ||
@@ -25,0 +25,0 @@ logger: this |
@@ -19,3 +19,3 @@ "use strict"; | ||
this.log("Starting validation server..."); | ||
await server_1.runValidationServer(port, contract, this).defer(); | ||
await server_1.runValidationServer(port, contract).defer(); | ||
this.log(`Validation server running on port ${port}`); | ||
@@ -22,0 +22,0 @@ } |
@@ -7,3 +7,3 @@ "use strict"; | ||
} | ||
const [protocol] = proxyBaseUrl && proxyBaseUrl.split("://"); | ||
const [protocol] = proxyBaseUrl.split("://"); | ||
if (protocol !== "http" && protocol !== "https") { | ||
@@ -10,0 +10,0 @@ throw new Error('Could not infer protocol from proxy base url, should be either "http" or "https".'); |
@@ -6,6 +6,4 @@ "use strict"; | ||
const contractDefinitionString = JSON.stringify(contract); | ||
return crypto_1.createHash("sha1") | ||
.update(contractDefinitionString) | ||
.digest("hex"); | ||
return crypto_1.createHash("sha1").update(contractDefinitionString).digest("hex"); | ||
} | ||
exports.hashContract = hashContract; |
@@ -1,2 +0,2 @@ | ||
import { Type } from "./types"; | ||
import { Type, TypeDef } from "./types"; | ||
export interface Contract { | ||
@@ -8,3 +8,3 @@ name: string; | ||
name: string; | ||
type: Type; | ||
typeDef: TypeDef; | ||
}[]; | ||
@@ -11,0 +11,0 @@ security?: SecurityHeader; |
@@ -84,3 +84,3 @@ "use strict"; | ||
}; | ||
case types_1.TypeKind.UNION: | ||
case types_1.TypeKind.UNION: { | ||
const elements = type.types; | ||
@@ -122,2 +122,3 @@ if (elements.length === 0) | ||
} | ||
} | ||
case types_1.TypeKind.REFERENCE: | ||
@@ -124,0 +125,0 @@ return { |
@@ -8,3 +8,3 @@ "use strict"; | ||
definitions: contract.types.reduce((acc, typeNode) => { | ||
acc[typeNode.name] = json_schema_type_util_1.typeToJsonSchemaType(typeNode.type); | ||
acc[typeNode.name] = json_schema_type_util_1.typeToJsonSchemaType(typeNode.typeDef.type); | ||
return acc; | ||
@@ -11,0 +11,0 @@ }, {}) |
import { Type, TypeTable } from "../../types"; | ||
import { SchemaObject } from "./openapi2-specification"; | ||
import { ReferenceSchemaObject, SchemaObject } from "./openapi2-specification"; | ||
export declare function typeToSchemaObject(type: Type, typeTable: TypeTable, nullable?: boolean): SchemaObject; | ||
export declare function isReferenceSchemaObject(typeObject: SchemaObject): typeObject is ReferenceSchemaObject; |
@@ -83,3 +83,7 @@ "use strict"; | ||
? type.properties.reduce((acc, property) => { | ||
acc[property.name] = typeToSchemaObject(property.type, typeTable); | ||
const propType = typeToSchemaObject(property.type, typeTable); | ||
if (!isReferenceSchemaObject(propType)) { | ||
propType.description = property.description; | ||
} | ||
acc[property.name] = propType; | ||
return acc; | ||
@@ -176,1 +180,5 @@ }, {}) | ||
} | ||
function isReferenceSchemaObject(typeObject) { | ||
return "$ref" in typeObject; | ||
} | ||
exports.isReferenceSchemaObject = isReferenceSchemaObject; |
@@ -40,3 +40,7 @@ "use strict"; | ||
return types.reduce((acc, t) => { | ||
acc[t.name] = openapi2_type_util_1.typeToSchemaObject(t.type, typeTable); | ||
const schemaObject = openapi2_type_util_1.typeToSchemaObject(t.typeDef.type, typeTable); | ||
if (!openapi2_type_util_1.isReferenceSchemaObject(schemaObject)) { | ||
schemaObject.description = t.typeDef.description; | ||
} | ||
acc[t.name] = schemaObject; | ||
return acc; | ||
@@ -57,2 +61,3 @@ }, {}); | ||
return endpoints.reduce((acc, endpoint) => { | ||
var _a; | ||
const pathName = endpoint.path | ||
@@ -62,4 +67,3 @@ .split("/") | ||
.join("/"); | ||
// Note: acc[pathName] || {} breaks type safety, ternary operation is type safe | ||
acc[pathName] = acc[pathName] ? acc[pathName] : {}; | ||
acc[pathName] = (_a = acc[pathName]) !== null && _a !== void 0 ? _a : {}; | ||
const pathItemMethod = httpMethodToPathItemMethod(endpoint.method); | ||
@@ -97,3 +101,3 @@ acc[pathName][pathItemMethod] = endpointToOperationObject(endpoint, typeTable, config); | ||
.concat(pathParameters, queryParameters, headerParameters) | ||
.concat(bodyParameter || []); | ||
.concat(bodyParameter !== null && bodyParameter !== void 0 ? bodyParameter : []); | ||
} | ||
@@ -111,6 +115,6 @@ function endpointResponsesToResponsesObject(responses, typeTable) { | ||
function endpointResponseToResponseObject(response, typeTable) { | ||
const description = response.description || | ||
(definitions_1.isSpecificResponse(response) | ||
? `${response.status} response` | ||
: "default response"); | ||
var _a; | ||
const description = (_a = response.description) !== null && _a !== void 0 ? _a : (definitions_1.isSpecificResponse(response) | ||
? `${response.status} response` | ||
: "default response"); | ||
const headers = response.headers.length > 0 | ||
@@ -117,0 +121,0 @@ ? response.headers.reduce((acc, header) => { |
import { Type, TypeTable } from "../../types"; | ||
import { ReferenceObject, SchemaObject } from "./openapi3-specification"; | ||
export declare function typeToSchemaOrReferenceObject(type: Type, typeTable: TypeTable, nullable?: boolean): SchemaObject | ReferenceObject; | ||
export declare function isReferenceObject(typeObject: SchemaObject | ReferenceObject): typeObject is ReferenceObject; |
@@ -83,3 +83,7 @@ "use strict"; | ||
? type.properties.reduce((acc, property) => { | ||
acc[property.name] = typeToSchemaOrReferenceObject(property.type, typeTable); | ||
const propType = typeToSchemaOrReferenceObject(property.type, typeTable); | ||
if (!isReferenceObject(propType)) { | ||
propType.description = property.description; | ||
} | ||
acc[property.name] = propType; | ||
return acc; | ||
@@ -211,1 +215,5 @@ }, {}) | ||
} | ||
function isReferenceObject(typeObject) { | ||
return "$ref" in typeObject; | ||
} | ||
exports.isReferenceObject = isReferenceObject; |
@@ -51,2 +51,3 @@ "use strict"; | ||
return endpoints.reduce((acc, endpoint) => { | ||
var _a; | ||
const pathName = endpoint.path | ||
@@ -56,4 +57,3 @@ .split("/") | ||
.join("/"); | ||
// Note: acc[pathName] || {} breaks type safety, ternary operation is type safe | ||
acc[pathName] = acc[pathName] ? acc[pathName] : {}; | ||
acc[pathName] = (_a = acc[pathName]) !== null && _a !== void 0 ? _a : {}; | ||
const pathItemMethod = httpMethodToPathItemMethod(endpoint.method); | ||
@@ -66,3 +66,3 @@ acc[pathName][pathItemMethod] = endpointToOperationObject(endpoint, typeTable, config); | ||
const endpointRequest = endpoint.request; | ||
const endpointRequestBody = endpointRequest && endpointRequest.body; | ||
const endpointRequestBody = endpointRequest === null || endpointRequest === void 0 ? void 0 : endpointRequest.body; | ||
return { | ||
@@ -154,6 +154,6 @@ tags: endpoint.tags.length > 0 ? endpoint.tags : undefined, | ||
function endpointResponseToResponseObject(response, typeTable) { | ||
const description = response.description || | ||
(definitions_1.isSpecificResponse(response) | ||
? `${response.status} response` | ||
: "default response"); | ||
var _a; | ||
const description = (_a = response.description) !== null && _a !== void 0 ? _a : (definitions_1.isSpecificResponse(response) | ||
? `${response.status} response` | ||
: "default response"); | ||
const headers = response.headers.length > 0 | ||
@@ -181,3 +181,7 @@ ? response.headers.reduce((acc, header) => { | ||
return types.reduce((acc, t) => { | ||
acc[t.name] = openapi3_type_util_1.typeToSchemaOrReferenceObject(t.type, typeTable); | ||
const typeObject = openapi3_type_util_1.typeToSchemaOrReferenceObject(t.typeDef.type, typeTable); | ||
if (!openapi3_type_util_1.isReferenceObject(typeObject)) { | ||
typeObject.description = t.typeDef.description; | ||
} | ||
acc[t.name] = typeObject; | ||
return acc; | ||
@@ -184,0 +188,0 @@ }, {}); |
@@ -115,3 +115,3 @@ "use strict"; | ||
return findDisriminatorViolations(type.elementType, typeTable, typePath.concat("[]")); | ||
case types_1.TypeKind.UNION: | ||
case types_1.TypeKind.UNION: { | ||
const violationsInUnionTypes = type.types.reduce((acc, t) => { | ||
@@ -135,2 +135,3 @@ return acc.concat(findDisriminatorViolations(t, typeTable, typePath.concat())); | ||
: violationsInUnionTypes; | ||
} | ||
case types_1.TypeKind.REFERENCE: | ||
@@ -137,0 +138,0 @@ return findDisriminatorViolations(types_1.dereferenceType(type, typeTable), typeTable, typePath); |
@@ -18,5 +18,6 @@ "use strict"; | ||
contract.endpoints.forEach(endpoint => { | ||
var _a, _b; | ||
switch (endpoint.method) { | ||
case "GET": | ||
if (endpoint.request && endpoint.request.body) { | ||
if ((_a = endpoint.request) === null || _a === void 0 ? void 0 : _a.body) { | ||
violations.push({ | ||
@@ -30,3 +31,3 @@ message: `Endpoint (${endpoint.name}) with HTTP method ${endpoint.method} must not contain a request body` | ||
case "PUT": | ||
if (!(endpoint.request && endpoint.request.body)) { | ||
if (!((_b = endpoint.request) === null || _b === void 0 ? void 0 : _b.body)) { | ||
violations.push({ | ||
@@ -33,0 +34,0 @@ message: `Endpoint (${endpoint.name}) with HTTP method ${endpoint.method} must contain a request body` |
@@ -115,3 +115,3 @@ "use strict"; | ||
return findInlineObjectInUnionViolations(type.elementType, typeTable, typePath.concat("[]")); | ||
case types_1.TypeKind.UNION: | ||
case types_1.TypeKind.UNION: { | ||
const violationsInUnionTypes = type.types.reduce((acc, t) => { | ||
@@ -130,2 +130,3 @@ return acc.concat(findInlineObjectInUnionViolations(t, typeTable, typePath.concat())); | ||
: violationsInUnionTypes; | ||
} | ||
case types_1.TypeKind.REFERENCE: | ||
@@ -132,0 +133,0 @@ return findInlineObjectInUnionViolations(types_1.dereferenceType(type, typeTable), typeTable, typePath); |
@@ -113,3 +113,3 @@ "use strict"; | ||
return findNullableArrayViolations(type.elementType, typeTable, typePath.concat("[]")); | ||
case types_1.TypeKind.UNION: | ||
case types_1.TypeKind.UNION: { | ||
const violationsInUnionTypes = type.types.reduce((acc, t) => { | ||
@@ -122,2 +122,3 @@ return acc.concat(findNullableArrayViolations(t, typeTable, typePath.concat())); | ||
: violationsInUnionTypes; | ||
} | ||
case types_1.TypeKind.REFERENCE: | ||
@@ -124,0 +125,0 @@ return findNullableArrayViolations(types_1.dereferenceType(type, typeTable), typeTable, typePath); |
@@ -17,10 +17,9 @@ "use strict"; | ||
contract.endpoints.forEach(endpoint => { | ||
if (endpoint.request) { | ||
if (endpoint.request.body) { | ||
findNullableFieldViolation(endpoint.request.body.type, typeTable).forEach(path => { | ||
violations.push({ | ||
message: `Endpoint (${endpoint.name}) request body contains a nullable field: #/${path}` | ||
}); | ||
var _a; | ||
if ((_a = endpoint.request) === null || _a === void 0 ? void 0 : _a.body) { | ||
findNullableFieldViolation(endpoint.request.body.type, typeTable).forEach(path => { | ||
violations.push({ | ||
message: `Endpoint (${endpoint.name}) request body contains a nullable field: #/${path}` | ||
}); | ||
} | ||
}); | ||
} | ||
@@ -27,0 +26,0 @@ }); |
@@ -17,2 +17,3 @@ "use strict"; | ||
contract.endpoints.forEach(endpoint => { | ||
var _a; | ||
endpoint.responses.forEach(response => { | ||
@@ -27,10 +28,8 @@ if (response.body) { | ||
}); | ||
if (endpoint.defaultResponse) { | ||
if (endpoint.defaultResponse.body) { | ||
findOmittableFieldViolation(endpoint.defaultResponse.body.type, typeTable).forEach(path => { | ||
violations.push({ | ||
message: `Endpoint (${endpoint.name}) response (default) body contains an omittable field: #/${path}` | ||
}); | ||
if ((_a = endpoint.defaultResponse) === null || _a === void 0 ? void 0 : _a.body) { | ||
findOmittableFieldViolation(endpoint.defaultResponse.body.type, typeTable).forEach(path => { | ||
violations.push({ | ||
message: `Endpoint (${endpoint.name}) response (default) body contains an omittable field: #/${path}` | ||
}); | ||
} | ||
}); | ||
} | ||
@@ -65,3 +64,3 @@ }); | ||
return []; | ||
case types_1.TypeKind.OBJECT: | ||
case types_1.TypeKind.OBJECT: { | ||
const violationsInObjectPropTypes = type.properties.reduce((acc, prop) => { | ||
@@ -76,2 +75,3 @@ return acc.concat(findOmittableFieldViolation(prop.type, typeTable, typePath.concat(prop.name))); | ||
return violationsInObjectProps.concat(violationsInObjectPropTypes); | ||
} | ||
case types_1.TypeKind.ARRAY: | ||
@@ -78,0 +78,0 @@ return findOmittableFieldViolation(type.elementType, typeTable, typePath.concat("[]")); |
@@ -12,3 +12,5 @@ "use strict"; | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function generateData(types, type) { | ||
var _a; | ||
switch (type.kind) { | ||
@@ -39,2 +41,3 @@ case types_1.TypeKind.NULL: | ||
case types_1.TypeKind.OBJECT: | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return type.properties.reduce((acc, property) => { | ||
@@ -46,4 +49,5 @@ if (randomBoolean() || !property.optional) { | ||
}, {}); | ||
case types_1.TypeKind.ARRAY: | ||
case types_1.TypeKind.ARRAY: { | ||
const size = randomInteger(10); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const array = []; | ||
@@ -54,6 +58,7 @@ for (let i = 0; i < size; i++) { | ||
return array; | ||
} | ||
case types_1.TypeKind.UNION: | ||
return generateData(types, type.types[randomInteger(type.types.length - 1)]); | ||
case types_1.TypeKind.REFERENCE: | ||
const referencedType = types.get(type.name); | ||
case types_1.TypeKind.REFERENCE: { | ||
const referencedType = (_a = types.get(type.name)) === null || _a === void 0 ? void 0 : _a.type; | ||
if (!referencedType) { | ||
@@ -63,2 +68,3 @@ throw new Error(`Missing referenced type: ${type.name}`); | ||
return generateData(types, referencedType); | ||
} | ||
default: | ||
@@ -65,0 +71,0 @@ throw assert_never_1.default(type); |
@@ -16,4 +16,5 @@ "use strict"; | ||
const proxyRequest = requestHandler.request(proxyBaseUrl, options, res => { | ||
var _a; | ||
// Forward headers | ||
response.writeHead(res.statusCode || response.statusCode, res.headers); | ||
response.writeHead((_a = res.statusCode) !== null && _a !== void 0 ? _a : response.statusCode, res.headers); | ||
res.pipe(response); | ||
@@ -20,0 +21,0 @@ }); |
@@ -15,2 +15,3 @@ "use strict"; | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
function runMockServer(api, { port, pathPrefix, proxyConfig, logger }) { | ||
@@ -26,2 +27,3 @@ const app = express_1.default(); | ||
app.use((req, resp) => { | ||
var _a; | ||
for (const endpoint of api.endpoints) { | ||
@@ -39,3 +41,3 @@ if (matcher_1.isRequestForEndpoint(req, pathPrefix, endpoint)) { | ||
logger.log(`Request hit for ${endpoint.name} registered.`); | ||
const response = endpoint.responses[0] || endpoint.defaultResponse; | ||
const response = (_a = endpoint.responses[0]) !== null && _a !== void 0 ? _a : endpoint.defaultResponse; | ||
if (!response) { | ||
@@ -57,2 +59,3 @@ logger.error(`No response defined for endpoint ${endpoint.name}`); | ||
app, | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
defer: () => new Promise(resolve => app.listen(port, resolve)) | ||
@@ -59,0 +62,0 @@ }; |
@@ -7,2 +7,3 @@ "use strict"; | ||
function parseBody(parameter, typeTable, lociTable) { | ||
// TODO: retrieve JsDoc as body description https://github.com/dsherret/ts-morph/issues/753 | ||
parameter.getDecoratorOrThrow("body"); | ||
@@ -9,0 +10,0 @@ if (parameter.hasQuestionToken()) { |
@@ -38,3 +38,3 @@ "use strict"; | ||
const descriptionDoc = parser_helpers_1.getJsDoc(klass); | ||
const description = descriptionDoc && descriptionDoc.getDescription().trim(); | ||
const description = descriptionDoc === null || descriptionDoc === void 0 ? void 0 : descriptionDoc.getDescription().trim(); | ||
// Handle config | ||
@@ -51,3 +51,3 @@ const configResult = resolveConfig(klass); | ||
return securityResult; | ||
const security = securityResult && securityResult.unwrap(); | ||
const security = securityResult === null || securityResult === void 0 ? void 0 : securityResult.unwrap(); | ||
// Add location data | ||
@@ -54,0 +54,0 @@ lociTable.addMorphNode(locations_1.LociTable.apiClassKey(), klass); |
@@ -8,6 +8,6 @@ "use strict"; | ||
function parseDefaultResponse(method, typeTable, lociTable) { | ||
var _a; | ||
method.getDecoratorOrThrow("defaultResponse"); | ||
const headersParam = parser_helpers_1.getParamWithDecorator(method, "headers"); | ||
const bodyParam = parser_helpers_1.getParamWithDecorator(method, "body"); | ||
const descriptionDoc = parser_helpers_1.getJsDoc(method); | ||
const headers = []; | ||
@@ -29,3 +29,3 @@ if (headersParam) { | ||
headers, | ||
description: descriptionDoc && descriptionDoc.getDescription().trim(), | ||
description: (_a = parser_helpers_1.getJsDoc(method)) === null || _a === void 0 ? void 0 : _a.getDescription().trim(), | ||
body | ||
@@ -32,0 +32,0 @@ }); |
@@ -12,2 +12,3 @@ "use strict"; | ||
function parseEndpoint(klass, typeTable, lociTable) { | ||
var _a, _b; | ||
const decorator = klass.getDecoratorOrThrow("endpoint"); | ||
@@ -30,4 +31,3 @@ const decoratorConfig = parser_helpers_1.getDecoratorConfigOrThrow(decorator); | ||
// Handle jsdoc | ||
const descriptionDoc = parser_helpers_1.getJsDoc(klass); | ||
const description = descriptionDoc && descriptionDoc.getDescription().trim(); | ||
const description = (_a = parser_helpers_1.getJsDoc(klass)) === null || _a === void 0 ? void 0 : _a.getDescription().trim(); | ||
// Handle draft | ||
@@ -63,5 +63,3 @@ const draft = klass.getDecorator("draft") !== undefined; | ||
const pathParamsInPath = getDynamicPathComponents(path); | ||
const pathParamsInRequest = request | ||
? request.pathParams.map(pathParam => pathParam.name) | ||
: []; | ||
const pathParamsInRequest = (_b = request === null || request === void 0 ? void 0 : request.pathParams.map(pathParam => pathParam.name)) !== null && _b !== void 0 ? _b : []; | ||
const exclusivePathParamsInPath = pathParamsInPath.filter(pathParam => !pathParamsInRequest.includes(pathParam)); | ||
@@ -68,0 +66,0 @@ const exclusivePathParamsInRequest = pathParamsInRequest.filter(pathParam => !pathParamsInPath.includes(pathParam)); |
@@ -9,2 +9,3 @@ "use strict"; | ||
function parseHeaders(parameter, typeTable, lociTable) { | ||
var _a; | ||
parameter.getDecoratorOrThrow("headers"); | ||
@@ -28,4 +29,3 @@ if (parameter.hasQuestionToken()) { | ||
const type = typeResult.unwrap(); | ||
const pDescription = parser_helpers_1.getJsDoc(propertySignature); | ||
const description = pDescription && pDescription.getDescription().trim(); | ||
const description = (_a = parser_helpers_1.getJsDoc(propertySignature)) === null || _a === void 0 ? void 0 : _a.getDescription().trim(); | ||
const optional = propertySignature.hasQuestionToken(); | ||
@@ -32,0 +32,0 @@ headers.push({ name, type, description, optional }); |
@@ -215,6 +215,3 @@ "use strict"; | ||
function getPropertyName(property) { | ||
return property | ||
.getNameNode() | ||
.getSymbolOrThrow() | ||
.getEscapedName(); | ||
return property.getNameNode().getSymbolOrThrow().getEscapedName(); | ||
} | ||
@@ -221,0 +218,0 @@ exports.getPropertyName = getPropertyName; |
@@ -28,2 +28,3 @@ "use strict"; | ||
function extractPathParam(propertySignature, typeTable, lociTable) { | ||
var _a; | ||
if (propertySignature.hasQuestionToken()) { | ||
@@ -43,4 +44,3 @@ return util_1.err(new errors_1.OptionalNotAllowedError("@pathParams property cannot be optional", { | ||
const type = typeResult.unwrap(); | ||
const pDescription = parser_helpers_1.getJsDoc(propertySignature); | ||
const description = pDescription && pDescription.getDescription().trim(); | ||
const description = (_a = parser_helpers_1.getJsDoc(propertySignature)) === null || _a === void 0 ? void 0 : _a.getDescription().trim(); | ||
return util_1.ok({ name, type, description }); | ||
@@ -47,0 +47,0 @@ } |
@@ -9,2 +9,3 @@ "use strict"; | ||
function parseQueryParams(parameter, typeTable, lociTable) { | ||
var _a; | ||
parameter.getDecoratorOrThrow("queryParams"); | ||
@@ -28,4 +29,3 @@ if (parameter.hasQuestionToken()) { | ||
const type = typeResult.unwrap(); | ||
const pDescription = parser_helpers_1.getJsDoc(propertySignature); | ||
const description = pDescription && pDescription.getDescription().trim(); | ||
const description = (_a = parser_helpers_1.getJsDoc(propertySignature)) === null || _a === void 0 ? void 0 : _a.getDescription().trim(); | ||
const optional = propertySignature.hasQuestionToken(); | ||
@@ -32,0 +32,0 @@ queryParams.push({ name, type, description, optional }); |
@@ -8,2 +8,3 @@ "use strict"; | ||
function parseResponse(method, typeTable, lociTable) { | ||
var _a; | ||
const decorator = method.getDecoratorOrThrow("response"); | ||
@@ -15,3 +16,2 @@ const decoratorConfig = parser_helpers_1.getDecoratorConfigOrThrow(decorator); | ||
const bodyParam = parser_helpers_1.getParamWithDecorator(method, "body"); | ||
const descriptionDoc = parser_helpers_1.getJsDoc(method); | ||
const headers = []; | ||
@@ -34,3 +34,3 @@ if (headersParam) { | ||
headers, | ||
description: descriptionDoc && descriptionDoc.getDescription().trim(), | ||
description: (_a = parser_helpers_1.getJsDoc(method)) === null || _a === void 0 ? void 0 : _a.getDescription().trim(), | ||
body | ||
@@ -37,0 +37,0 @@ }); |
@@ -9,2 +9,3 @@ "use strict"; | ||
function parseSecurityHeader(property, typeTable, lociTable) { | ||
var _a; | ||
property.getDecoratorOrThrow("securityHeader"); | ||
@@ -23,4 +24,3 @@ if (property.hasQuestionToken()) { | ||
// Handle description | ||
const descriptionDoc = parser_helpers_1.getJsDoc(property); | ||
const description = descriptionDoc && descriptionDoc.getDescription().trim(); | ||
const description = (_a = parser_helpers_1.getJsDoc(property)) === null || _a === void 0 ? void 0 : _a.getDescription().trim(); | ||
// Handle type | ||
@@ -27,0 +27,0 @@ const typeResult = extractType(property, typeTable, lociTable); |
@@ -77,2 +77,3 @@ "use strict"; | ||
function parseTypeReference(typeNode, typeTable, lociTable) { | ||
var _a; | ||
const declarationResult = getTargetDeclarationFromTypeReference(typeNode); | ||
@@ -83,2 +84,3 @@ if (declarationResult.isErr()) | ||
const name = declaration.getName(); | ||
const description = (_a = parser_helpers_1.getJsDoc(declaration)) === null || _a === void 0 ? void 0 : _a.getDescription().trim(); | ||
if (ts_morph_1.TypeGuards.isTypeAliasDeclaration(declaration)) { | ||
@@ -134,3 +136,3 @@ const decTypeNode = declaration.getTypeNodeOrThrow(); | ||
return targetTypeResult; | ||
typeTable.add(name, targetTypeResult.unwrap()); | ||
typeTable.add(name, { type: targetTypeResult.unwrap(), description }); | ||
lociTable.addMorphNode(locations_1.LociTable.typeKey(name), decTypeNode); | ||
@@ -155,3 +157,3 @@ } | ||
return targetTypeResult; | ||
typeTable.add(name, targetTypeResult.unwrap()); | ||
typeTable.add(name, { type: targetTypeResult.unwrap(), description }); | ||
lociTable.addMorphNode(locations_1.LociTable.typeKey(name), declaration); | ||
@@ -239,2 +241,3 @@ } | ||
function parseObjectLiteralType(typeNode, typeTable, lociTable) { | ||
var _a; | ||
const indexSignatures = typeNode.getIndexSignatures(); | ||
@@ -252,6 +255,5 @@ if (indexSignatures.length > 0) { | ||
return propTypeResult; | ||
const psDescription = parser_helpers_1.getJsDoc(ps); | ||
const prop = { | ||
name: parser_helpers_1.getPropertyName(ps), | ||
description: psDescription && psDescription.getDescription().trim(), | ||
description: (_a = parser_helpers_1.getJsDoc(ps)) === null || _a === void 0 ? void 0 : _a.getDescription().trim(), | ||
type: propTypeResult.unwrap(), | ||
@@ -273,2 +275,3 @@ optional: ps.hasQuestionToken() | ||
function parseInterfaceDeclaration(interfaceDeclaration, typeTable, lociTable) { | ||
var _a; | ||
const indexSignatures = interfaceDeclaration.getIndexSignatures(); | ||
@@ -296,6 +299,5 @@ if (indexSignatures.length > 0) { | ||
return propTypeResult; | ||
const psDescription = parser_helpers_1.getJsDoc(ps); | ||
const prop = { | ||
name: parser_helpers_1.getPropertyName(ps), | ||
description: psDescription && psDescription.getDescription().trim(), | ||
description: (_a = parser_helpers_1.getJsDoc(ps)) === null || _a === void 0 ? void 0 : _a.getDescription().trim(), | ||
type: propTypeResult.unwrap(), | ||
@@ -328,3 +330,3 @@ optional: ps.hasQuestionToken() | ||
return parseType(allowedTargetTypes[0], typeTable, lociTable); | ||
default: | ||
default: { | ||
const types = []; | ||
@@ -338,2 +340,3 @@ for (const tn of allowedTargetTypes) { | ||
return util_1.ok(types_1.unionType(types, types_1.inferDiscriminator(types, typeTable))); | ||
} | ||
} | ||
@@ -386,3 +389,3 @@ } | ||
if (currentType.kind === types_1.TypeKind.REFERENCE) { | ||
const referencedType = typeTable.getOrError(currentType.name); | ||
const referencedType = typeTable.getOrError(currentType.name).type; | ||
return resolveIndexedAccessType(propertyChain, referencedType, typeTable); | ||
@@ -389,0 +392,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Project } from "ts-morph"; | ||
import { Project, SourceFile } from "ts-morph"; | ||
/** | ||
@@ -10,3 +10,3 @@ * Create an AST source file. Any files imported from the main file must also be provided. | ||
*/ | ||
export declare function createSourceFile(mainFile: FileDetail, ...referencedFiles: FileDetail[]): import("ts-morph").SourceFile; | ||
export declare function createSourceFile(mainFile: FileDetail, ...referencedFiles: FileDetail[]): SourceFile; | ||
interface FileDetail { | ||
@@ -24,3 +24,3 @@ /** File path */ | ||
project: Project; | ||
file: import("ts-morph").SourceFile; | ||
file: SourceFile; | ||
}; | ||
@@ -27,0 +27,0 @@ /** |
@@ -160,8 +160,8 @@ export declare enum TypeKind { | ||
get size(): number; | ||
static fromArray(types: { | ||
static fromArray(typeTableArr: { | ||
name: string; | ||
type: Type; | ||
typeDef: TypeDef; | ||
}[]): TypeTable; | ||
private types; | ||
constructor(types?: Map<string, Type>); | ||
private typeDefs; | ||
constructor(types?: Map<string, TypeDef>); | ||
/** | ||
@@ -172,3 +172,3 @@ * Return an object representation of the type table. | ||
name: string; | ||
type: Type; | ||
typeDef: TypeDef; | ||
}[]; | ||
@@ -179,5 +179,5 @@ /** | ||
* @param key lookup key | ||
* @param locus target locus | ||
* @param typeDef target type definition | ||
*/ | ||
add(key: string, type: Type): void; | ||
add(key: string, typeDef: TypeDef): void; | ||
/** | ||
@@ -188,3 +188,3 @@ * Retrieve a type by lookup key. | ||
*/ | ||
get(key: string): Type | undefined; | ||
get(key: string): TypeDef | undefined; | ||
/** | ||
@@ -195,3 +195,3 @@ * Retrieve a type by lookup key. | ||
*/ | ||
getOrError(key: string): Type; | ||
getOrError(key: string): TypeDef; | ||
/** | ||
@@ -204,1 +204,5 @@ * Check if a type exists in the table. | ||
} | ||
export interface TypeDef { | ||
type: Type; | ||
description?: string; | ||
} |
@@ -276,3 +276,3 @@ "use strict"; | ||
if (isReferenceType(type)) { | ||
return possibleRootTypes(typeTable.getOrError(type.name), typeTable); | ||
return possibleRootTypes(typeTable.getOrError(type.name).type, typeTable); | ||
} | ||
@@ -287,3 +287,3 @@ if (isUnionType(type)) { | ||
if (isReferenceType(type)) { | ||
return dereferenceType(typeTable.getOrError(type.name), typeTable); | ||
return dereferenceType(typeTable.getOrError(type.name).type, typeTable); | ||
} | ||
@@ -319,3 +319,3 @@ return type; | ||
const current = possibleDiscriminators.get(property.name); | ||
possibleDiscriminators.set(property.name, (current || []).concat({ | ||
possibleDiscriminators.set(property.name, (current !== null && current !== void 0 ? current : []).concat({ | ||
value: dereferencedPropertyType.value, | ||
@@ -329,2 +329,3 @@ type | ||
for (const candidate of possibleDiscriminators.keys()) { | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const values = possibleDiscriminators.get(candidate); | ||
@@ -348,3 +349,3 @@ if (new Set(values.map(v => v.value)).size !== | ||
constructor(types = new Map()) { | ||
this.types = types; | ||
this.typeDefs = types; | ||
} | ||
@@ -355,7 +356,7 @@ /** | ||
get size() { | ||
return this.types.size; | ||
return this.typeDefs.size; | ||
} | ||
static fromArray(types) { | ||
const entries = types.reduce((acc, t) => { | ||
acc.push([t.name, t.type]); | ||
static fromArray(typeTableArr) { | ||
const entries = typeTableArr.reduce((acc, t) => { | ||
acc.push([t.name, t.typeDef]); | ||
return acc; | ||
@@ -370,4 +371,4 @@ }, []); | ||
const arr = new Array(); | ||
this.types.forEach((type, key, _) => { | ||
arr.push({ name: key, type }); | ||
this.typeDefs.forEach((typeDef, key) => { | ||
arr.push({ name: key, typeDef }); | ||
}); | ||
@@ -380,9 +381,9 @@ return arr.sort((a, b) => (b.name > a.name ? -1 : 1)); | ||
* @param key lookup key | ||
* @param locus target locus | ||
* @param typeDef target type definition | ||
*/ | ||
add(key, type) { | ||
if (this.types.has(key)) { | ||
add(key, typeDef) { | ||
if (this.typeDefs.has(key)) { | ||
throw new Error(`Key already present in type table: ${key}`); | ||
} | ||
this.types.set(key, type); | ||
this.typeDefs.set(key, typeDef); | ||
} | ||
@@ -395,3 +396,3 @@ /** | ||
get(key) { | ||
return this.types.get(key); | ||
return this.typeDefs.get(key); | ||
} | ||
@@ -404,7 +405,7 @@ /** | ||
getOrError(key) { | ||
const type = this.get(key); | ||
if (type === undefined) { | ||
const typeDef = this.get(key); | ||
if (typeDef === undefined) { | ||
throw new Error(`Key not present in type table: ${key}`); | ||
} | ||
return type; | ||
return typeDef; | ||
} | ||
@@ -417,5 +418,5 @@ /** | ||
exists(key) { | ||
return this.types.has(key); | ||
return this.typeDefs.has(key); | ||
} | ||
} | ||
exports.TypeTable = TypeTable; |
import { Contract } from "../definitions"; | ||
import { Logger } from "../utilities/logger"; | ||
import { RecordedRequest, RecordedResponse } from "./spots/validate"; | ||
import { UserInputRequest, UserInputResponse } from "./verifications/user-input-models"; | ||
export declare function runValidationServer(port: number, contract: Contract, logger: Logger): { | ||
export declare function runValidationServer(port: number, contract: Contract): { | ||
app: import("express-serve-static-core").Express; | ||
@@ -7,0 +6,0 @@ defer: () => Promise<unknown>; |
@@ -8,3 +8,4 @@ "use strict"; | ||
const contract_mismatcher_1 = require("./verifications/contract-mismatcher"); | ||
function runValidationServer(port, contract, logger) { | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
function runValidationServer(port, contract) { | ||
const app = express_1.default(); | ||
@@ -40,2 +41,3 @@ app.use(express_1.default.json()); | ||
app, | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
defer: () => new Promise(resolve => app.listen(port, resolve)) | ||
@@ -42,0 +44,0 @@ }; |
@@ -28,2 +28,3 @@ "use strict"; | ||
findViolations(userInputRequest, userInputResponse) { | ||
var _a; | ||
const violations = []; | ||
@@ -55,3 +56,3 @@ // Get endpoint | ||
// Find request header mismatches | ||
const requestHeaderMismatches = this.findHeaderMismatches((expectedRequest && expectedRequest.headers) || [], userInputRequest.headers, true); | ||
const requestHeaderMismatches = this.findHeaderMismatches((_a = expectedRequest === null || expectedRequest === void 0 ? void 0 : expectedRequest.headers) !== null && _a !== void 0 ? _a : [], userInputRequest.headers, true); | ||
requestHeaderMismatches.forEach(m => { | ||
@@ -90,3 +91,3 @@ switch (m.kind) { | ||
// Find request body mismatches | ||
const requestBodyMismatches = this.findBodyMismatches(expectedRequest && expectedRequest.body, userInputRequest.body, true); | ||
const requestBodyMismatches = this.findBodyMismatches(expectedRequest === null || expectedRequest === void 0 ? void 0 : expectedRequest.body, userInputRequest.body, true); | ||
requestBodyMismatches.forEach(m => { | ||
@@ -175,3 +176,4 @@ switch (m.kind) { | ||
findPathParamMismatches(contractEndpoint, inputPath) { | ||
const contractPathParams = (contractEndpoint.request && contractEndpoint.request.pathParams) || []; | ||
var _a, _b; | ||
const contractPathParams = (_b = (_a = contractEndpoint.request) === null || _a === void 0 ? void 0 : _a.pathParams) !== null && _b !== void 0 ? _b : []; | ||
const contractPathArray = contractEndpoint.path.split("/"); | ||
@@ -218,3 +220,3 @@ const inputPathArray = inputPath.split("?")[0].split("/"); | ||
return { | ||
[typeNode.name]: json_schema_type_util_1.typeToJsonSchemaType(typeNode.type, !strict), | ||
[typeNode.name]: json_schema_type_util_1.typeToJsonSchemaType(typeNode.typeDef.type, !strict), | ||
...defAcc | ||
@@ -233,4 +235,4 @@ }; | ||
const bodyTypeMismatches = validateFn.errors.map(e => { | ||
return `#${e.dataPath} ${e.message || | ||
"JsonSchemaValidator encountered an unexpected error"}`; | ||
var _a; | ||
return `#${e.dataPath} ${(_a = e.message) !== null && _a !== void 0 ? _a : "JsonSchemaValidator encountered an unexpected error"}`; | ||
}); | ||
@@ -249,4 +251,5 @@ if (bodyTypeMismatches.length > 0) { | ||
findQueryParamMismatches(contractEndpoint, inputPath) { | ||
const contractQueryParams = (contractEndpoint.request && contractEndpoint.request.queryParams) || []; | ||
const queryStringComponent = url.parse(inputPath).query || ""; | ||
var _a, _b, _c; | ||
const contractQueryParams = (_b = (_a = contractEndpoint.request) === null || _a === void 0 ? void 0 : _a.queryParams) !== null && _b !== void 0 ? _b : []; | ||
const queryStringComponent = (_c = url.parse(inputPath).query) !== null && _c !== void 0 ? _c : ""; | ||
const inputQueryParams = qs_1.default.parse(queryStringComponent, { | ||
@@ -279,4 +282,4 @@ ...this.getQueryParamsArraySerializationStrategy() | ||
Object.entries(verifiedQueryParams) | ||
.filter(([_, value]) => !value) | ||
.map(([key, _]) => key) | ||
.filter(([, value]) => !value) | ||
.map(([key]) => key) | ||
.forEach(key => { | ||
@@ -311,7 +314,7 @@ mismatches.push(mismatches_1.undefinedQueryParamMismatch(key)); | ||
const userInputRequestPath = userInputRequest.path.split("?")[0]; | ||
const endpoint = this.contract.endpoints.find((value, _0, _1) => { | ||
const endpoint = this.contract.endpoints.find(value => { | ||
return (value.method === userInputRequest.method.toUpperCase() && | ||
exports.pathMatchesVariablePath(value.path, userInputRequestPath)); | ||
}); | ||
return endpoint || null; | ||
return endpoint !== null && endpoint !== void 0 ? endpoint : null; | ||
} | ||
@@ -322,3 +325,3 @@ } | ||
const regexForVariablePath = (path) => { | ||
const regexp = path.replace(/:[^\/]+/g, ".+"); | ||
const regexp = path.replace(/:[^/]+/g, ".+"); | ||
return new RegExp(`^${regexp}$`); | ||
@@ -325,0 +328,0 @@ }; |
@@ -69,2 +69,3 @@ "use strict"; | ||
case types_1.TypeKind.UNION: | ||
// eslint-disable-next-line no-case-declarations | ||
const anyValid = type.types.some(t => { | ||
@@ -71,0 +72,0 @@ const unionStringValidator = new StringValidator(this.typeTable); |
@@ -1,1 +0,1 @@ | ||
{"version":"1.0.1","commands":{"checksum":{"id":"checksum","description":"Generate a checksum for a Spot contract","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot checksum api.ts"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"spot_contract","description":"path to Spot contract","required":true,"hidden":false}]},"docs":{"id":"docs","description":"Preview Spot contract as OpenAPI3 documentation. The documentation server will start on http://localhost:8080.","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot docs api.ts"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"Documentation server port","default":8080}},"args":[{"name":"spot_contract","description":"path to Spot contract","required":true,"hidden":false}]},"generate":{"id":"generate","description":"Runs a generator on an API. Used to produce client libraries, server boilerplates and well-known API contract formats such as OpenAPI.","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot generate --contract api.ts --language yaml --generator openapi3 --out output/"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"contract":{"name":"contract","type":"option","char":"c","description":"Path to a TypeScript Contract definition","required":true},"language":{"name":"language","type":"option","char":"l","description":"Language to generate"},"generator":{"name":"generator","type":"option","char":"g","description":"Generator to run"},"out":{"name":"out","type":"option","char":"o","description":"Directory in which to output generated files"}},"args":[]},"init":{"id":"init","description":"Generates the boilerplate for an API.","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot init\nGenerated the following files:\n- api.ts\n- tsconfig.json\n- package.json\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"lint":{"id":"lint","description":"Lint a Spot contract","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot lint api.ts"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"spot_contract","description":"path to Spot contract","required":true,"hidden":false}]},"mock":{"id":"mock","description":"Run a mock server based on a Spot contract","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot mock api.ts"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"proxyBaseUrl":{"name":"proxyBaseUrl","type":"option","description":"If set, the server will act as a proxy and fetch data from the given remote server instead of mocking it"},"port":{"name":"port","type":"option","char":"p","description":"Port on which to run the mock server","required":true,"default":3010},"pathPrefix":{"name":"pathPrefix","type":"option","description":"Prefix to prepend to each endpoint path"}},"args":[{"name":"spot_contract","description":"path to Spot contract","required":true,"hidden":false}]},"validate":{"id":"validate","description":"Validate a Spot contract","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot validate api.ts"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"spot_contract","description":"path to Spot contract","required":true,"hidden":false}]},"validation-server":{"id":"validation-server","description":"Start the spot contract validation server","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot validation-server api.ts"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"The port where application will be available","default":5907}},"args":[{"name":"spot_contract","description":"path to Spot contract","required":true,"hidden":false}]}}} | ||
{"version":"1.0.2","commands":{"checksum":{"id":"checksum","description":"Generate a checksum for a Spot contract","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot checksum api.ts"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"spot_contract","description":"path to Spot contract","required":true,"hidden":false}]},"docs":{"id":"docs","description":"Preview Spot contract as OpenAPI3 documentation. The documentation server will start on http://localhost:8080.","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot docs api.ts"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"Documentation server port","default":8080}},"args":[{"name":"spot_contract","description":"path to Spot contract","required":true,"hidden":false}]},"generate":{"id":"generate","description":"Runs a generator on an API. Used to produce client libraries, server boilerplates and well-known API contract formats such as OpenAPI.","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot generate --contract api.ts --language yaml --generator openapi3 --out output/"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"contract":{"name":"contract","type":"option","char":"c","description":"Path to a TypeScript Contract definition","required":true},"language":{"name":"language","type":"option","char":"l","description":"Language to generate"},"generator":{"name":"generator","type":"option","char":"g","description":"Generator to run"},"out":{"name":"out","type":"option","char":"o","description":"Directory in which to output generated files"}},"args":[]},"init":{"id":"init","description":"Generates the boilerplate for an API.","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot init\nGenerated the following files:\n- api.ts\n- tsconfig.json\n- package.json\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"lint":{"id":"lint","description":"Lint a Spot contract","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot lint api.ts"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"spot_contract","description":"path to Spot contract","required":true,"hidden":false}]},"mock":{"id":"mock","description":"Run a mock server based on a Spot contract","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot mock api.ts"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"proxyBaseUrl":{"name":"proxyBaseUrl","type":"option","description":"If set, the server will act as a proxy and fetch data from the given remote server instead of mocking it"},"port":{"name":"port","type":"option","char":"p","description":"Port on which to run the mock server","required":true,"default":3010},"pathPrefix":{"name":"pathPrefix","type":"option","description":"Prefix to prepend to each endpoint path"}},"args":[{"name":"spot_contract","description":"path to Spot contract","required":true,"hidden":false}]},"validate":{"id":"validate","description":"Validate a Spot contract","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot validate api.ts"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"spot_contract","description":"path to Spot contract","required":true,"hidden":false}]},"validation-server":{"id":"validation-server","description":"Start the spot contract validation server","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot validation-server api.ts"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"The port where application will be available","default":5907}},"args":[{"name":"spot_contract","description":"path to Spot contract","required":true,"hidden":false}]}}} |
{ | ||
"name": "@airtasker/spot", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"author": "Francois Wouts, Leslie Fung", | ||
@@ -11,53 +11,54 @@ "bin": { | ||
"@oclif/command": "^1.5.19", | ||
"@oclif/config": "^1.13.3", | ||
"@oclif/config": "^1.14.0", | ||
"@oclif/plugin-help": "^2.2.3", | ||
"ajv": "^6.11.0", | ||
"ajv": "^6.12.0", | ||
"assert-never": "^1.2.0", | ||
"cors": "^2.8.5", | ||
"express": "^4.17.1", | ||
"fs-extra": "^8.1.0", | ||
"inquirer": "^7.0.4", | ||
"fs-extra": "^9.0.0", | ||
"inquirer": "^7.1.0", | ||
"js-yaml": "^3.13.1", | ||
"qs": "^6.9.1", | ||
"qs": "^6.9.3", | ||
"randomstring": "^1.1.5", | ||
"ts-morph": "^6.0.2", | ||
"typescript": "^3.7.5", | ||
"validator": "^12.2.0" | ||
"ts-morph": "^7.0.0", | ||
"typescript": "^3.8.3", | ||
"validator": "^13.0.0" | ||
}, | ||
"devDependencies": { | ||
"@oclif/dev-cli": "^1.22.2", | ||
"@stoplight/spectral": "^5.0.0", | ||
"@stoplight/spectral": "^5.2.0", | ||
"@types/cors": "^2.8.6", | ||
"@types/express": "^4.17.2", | ||
"@types/fs-extra": "^8.0.1", | ||
"@types/express": "^4.17.3", | ||
"@types/fs-extra": "^8.1.0", | ||
"@types/inquirer": "^6.5.0", | ||
"@types/jest": "^25.1.0", | ||
"@types/js-yaml": "^3.12.2", | ||
"@types/jest": "^25.1.4", | ||
"@types/js-yaml": "^3.12.3", | ||
"@types/moxios": "^0.4.8", | ||
"@types/qs": "^6.9.0", | ||
"@types/qs": "^6.9.1", | ||
"@types/randomstring": "^1.1.6", | ||
"@types/react": "^16.9.19", | ||
"@types/react": "^16.9.25", | ||
"@types/react-dom": "^16.9.5", | ||
"@types/supertest": "^2.0.8", | ||
"@types/validator": "^12.0.1", | ||
"@typescript-eslint/eslint-plugin": "^2.25.0", | ||
"@typescript-eslint/parser": "^2.25.0", | ||
"core-js": "^3.6.4", | ||
"css-loader": "^3.4.2", | ||
"html-webpack-plugin": "^3.2.0", | ||
"jest": "^25.1.0", | ||
"eslint": "^6.8.0", | ||
"html-webpack-plugin": "^4.0.1", | ||
"jest": "^25.2.0", | ||
"jest-junit": "^10.0.0", | ||
"mini-css-extract-plugin": "^0.9.0", | ||
"mobx": "^5.15.4", | ||
"nock": "^11.7.2", | ||
"prettier": "^1.19.1", | ||
"react": "^16.12.0", | ||
"react-dom": "^16.12.0", | ||
"redoc": "^2.0.0-rc.20", | ||
"nock": "^12.0.3", | ||
"prettier": "^2.0.2", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"redoc": "^2.0.0-rc.24", | ||
"styled-components": "^4.4.1", | ||
"supertest": "^4.0.2", | ||
"ts-jest": "^25.0.0", | ||
"ts-loader": "^6.2.1", | ||
"tslint": "^6.0.0", | ||
"tslint-config-prettier": "^1.18.0", | ||
"webpack": "^4.41.5", | ||
"webpack-cli": "^3.3.10" | ||
"ts-jest": "^25.2.1", | ||
"ts-loader": "^6.2.2", | ||
"webpack": "^4.42.1", | ||
"webpack-cli": "^3.3.11" | ||
}, | ||
@@ -95,9 +96,9 @@ "engines": { | ||
"ci:test": "jest --config=jest.ci.config.js --ci -w 4", | ||
"lint:check": "yarn prettier:check && yarn tslint:check", | ||
"tslint:check": "tslint -p .", | ||
"prettier:check": "prettier --list-different \"**/*.js\" \"**/*.jsx\" \"**/*.ts\" \"**/*.tsx\"", | ||
"lint:fix": "yarn prettier:fix && yarn tslint:fix", | ||
"tslint:fix": "tslint -p . --fix", | ||
"prettier:fix": "prettier --write \"**/*.js\" \"**/*.jsx\" \"**/*.ts\" \"**/*.tsx\"" | ||
"lint:check": "yarn prettier:check && yarn eslint:check", | ||
"eslint:check": "eslint . --ext .js,.ts,.tsx", | ||
"prettier:check": "prettier --list-different \"**/*.js\" \"**/*.ts\" \"**/*.tsx\"", | ||
"lint:fix": "yarn prettier:fix && yarn eslint:fix", | ||
"eslint:fix": "eslint . --fix --ext .js,.ts,.tsx", | ||
"prettier:fix": "prettier --write \"**/*.js\" \"**/*.ts\" \"**/*.tsx\"" | ||
} | ||
} |
@@ -147,3 +147,3 @@ # Spot | ||
_See code: [build/cli/src/commands/checksum.js](https://github.com/airtasker/spot/blob/v1.0.1/build/cli/src/commands/checksum.js)_ | ||
_See code: [build/cli/src/commands/checksum.js](https://github.com/airtasker/spot/blob/v1.0.2/build/cli/src/commands/checksum.js)_ | ||
@@ -169,3 +169,3 @@ ## `spot docs SPOT_CONTRACT` | ||
_See code: [build/cli/src/commands/docs.js](https://github.com/airtasker/spot/blob/v1.0.1/build/cli/src/commands/docs.js)_ | ||
_See code: [build/cli/src/commands/docs.js](https://github.com/airtasker/spot/blob/v1.0.2/build/cli/src/commands/docs.js)_ | ||
@@ -191,3 +191,3 @@ ## `spot generate` | ||
_See code: [build/cli/src/commands/generate.js](https://github.com/airtasker/spot/blob/v1.0.1/build/cli/src/commands/generate.js)_ | ||
_See code: [build/cli/src/commands/generate.js](https://github.com/airtasker/spot/blob/v1.0.2/build/cli/src/commands/generate.js)_ | ||
@@ -230,3 +230,3 @@ ## `spot help [COMMAND]` | ||
_See code: [build/cli/src/commands/init.js](https://github.com/airtasker/spot/blob/v1.0.1/build/cli/src/commands/init.js)_ | ||
_See code: [build/cli/src/commands/init.js](https://github.com/airtasker/spot/blob/v1.0.2/build/cli/src/commands/init.js)_ | ||
@@ -251,3 +251,3 @@ ## `spot lint SPOT_CONTRACT` | ||
_See code: [build/cli/src/commands/lint.js](https://github.com/airtasker/spot/blob/v1.0.1/build/cli/src/commands/lint.js)_ | ||
_See code: [build/cli/src/commands/lint.js](https://github.com/airtasker/spot/blob/v1.0.2/build/cli/src/commands/lint.js)_ | ||
@@ -277,3 +277,3 @@ ## `spot mock SPOT_CONTRACT` | ||
_See code: [build/cli/src/commands/mock.js](https://github.com/airtasker/spot/blob/v1.0.1/build/cli/src/commands/mock.js)_ | ||
_See code: [build/cli/src/commands/mock.js](https://github.com/airtasker/spot/blob/v1.0.2/build/cli/src/commands/mock.js)_ | ||
@@ -298,3 +298,3 @@ ## `spot validate SPOT_CONTRACT` | ||
_See code: [build/cli/src/commands/validate.js](https://github.com/airtasker/spot/blob/v1.0.1/build/cli/src/commands/validate.js)_ | ||
_See code: [build/cli/src/commands/validate.js](https://github.com/airtasker/spot/blob/v1.0.2/build/cli/src/commands/validate.js)_ | ||
@@ -320,3 +320,3 @@ ## `spot validation-server SPOT_CONTRACT` | ||
_See code: [build/cli/src/commands/validation-server.js](https://github.com/airtasker/spot/blob/v1.0.1/build/cli/src/commands/validation-server.js)_ | ||
_See code: [build/cli/src/commands/validation-server.js](https://github.com/airtasker/spot/blob/v1.0.2/build/cli/src/commands/validation-server.js)_ | ||
<!-- commandsstop --> |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1611879
12917
36
+ Added@ts-morph/common@0.5.2(transitive)
+ Addedat-least-node@1.0.0(transitive)
+ Addedfs-extra@9.1.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addedts-morph@7.3.0(transitive)
+ Addeduniversalify@2.0.1(transitive)
+ Addedvalidator@13.12.0(transitive)
- Removed@ts-morph/common@0.2.2(transitive)
- Removedts-morph@6.0.3(transitive)
- Removedtypescript@3.7.7(transitive)
- Removedvalidator@12.2.0(transitive)
Updated@oclif/config@^1.14.0
Updatedajv@^6.12.0
Updatedfs-extra@^9.0.0
Updatedinquirer@^7.1.0
Updatedqs@^6.9.3
Updatedts-morph@^7.0.0
Updatedtypescript@^3.8.3
Updatedvalidator@^13.0.0