Socket
Socket
Sign inDemoInstall

@airtasker/spot

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@airtasker/spot - npm Package Compare versions

Comparing version 0.2.17 to 0.2.18

build/lib/src/syntax/draft.d.ts

1

build/cli/src/commands/test.d.ts

@@ -17,2 +17,3 @@ import { Command, flags } from "@oclif/command";

debug: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
includeDraft: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
url: flags.IOptionFlag<string>;

@@ -19,0 +20,0 @@ stateUrl: flags.IOptionFlag<string | undefined>;

8

build/cli/src/commands/test.js

@@ -13,3 +13,3 @@ "use strict";

const { args, flags } = this.parse(Test);
const { url: baseUrl, stateUrl: baseStateUrl, testFilter, debug } = flags;
const { url: baseUrl, stateUrl: baseStateUrl, testFilter, debug, includeDraft } = flags;
const { definition } = safe_parse_1.safeParse.call(this, args[ARG_API]);

@@ -24,3 +24,4 @@ const testRunnerConfig = {

const testConfig = {
testFilter: testFilter ? parseTestFilter(testFilter) : undefined
testFilter: testFilter ? parseTestFilter(testFilter) : undefined,
includeDraft
};

@@ -51,2 +52,5 @@ const testRunner = new test_runner_1.TestRunner(testRunnerConfig);

debug: command_1.flags.boolean({ description: "Enable debug logs" }),
includeDraft: command_1.flags.boolean({
description: "Include draft endpoint tests"
}),
url: command_1.flags.string({

@@ -53,0 +57,0 @@ required: true,

@@ -10,2 +10,3 @@ "use strict";

const description = endpointNode.description && endpointNode.description.value;
const isDraft = endpointNode.isDraft;
const tags = endpointNode.tags ? endpointNode.tags.value : [];

@@ -24,2 +25,3 @@ const method = endpointNode.method.value;

description,
isDraft,
tags,

@@ -26,0 +28,0 @@ method,

@@ -58,2 +58,3 @@ "use strict";

case types_1.TypeKind.FLOAT:
case types_1.TypeKind.DOUBLE:
return {

@@ -60,0 +61,0 @@ type: "number"

@@ -48,4 +48,10 @@ "use strict";

return {
type: "number"
type: "number",
format: "float"
};
case types_1.TypeKind.DOUBLE:
return {
type: "number",
format: "double"
};
case types_1.TypeKind.NUMBER_LITERAL:

@@ -52,0 +58,0 @@ return Math.round(type.value) === type.value

@@ -38,3 +38,4 @@ "use strict";

paths: contractDefinition.endpoints.reduce((acc, endpoint) => {
const openApiPath = endpoint.path.replace(/:(\w+)/g, "{$1}");
const openApiPath = (endpoint.isDraft ? "/_draft" : "") +
endpoint.path.replace(/:(\w+)/g, "{$1}");
acc[openApiPath] = acc[openApiPath] || {};

@@ -41,0 +42,0 @@ acc[openApiPath][endpoint.method.toLowerCase()] = {

@@ -49,4 +49,10 @@ "use strict";

return {
type: "number"
type: "number",
format: "float"
};
case types_1.TypeKind.DOUBLE:
return {
type: "number",
format: "double"
};
case types_1.TypeKind.NUMBER_LITERAL:

@@ -53,0 +59,0 @@ return Math.round(type.value) === type.value

@@ -49,3 +49,4 @@ "use strict";

paths: contractDefinition.endpoints.reduce((acc, endpoint) => {
const openApiPath = endpoint.path.replace(/:(\w+)/g, "{$1}");
const openApiPath = (endpoint.isDraft ? "/_draft" : "") +
endpoint.path.replace(/:(\w+)/g, "{$1}");
acc[openApiPath] = acc[openApiPath] || {};

@@ -52,0 +53,0 @@ acc[openApiPath][endpoint.method.toLowerCase()] = {

@@ -25,2 +25,3 @@ "use strict";

case types_1.TypeKind.FLOAT:
case types_1.TypeKind.DOUBLE:
return randomDouble(100);

@@ -27,0 +28,0 @@ case types_1.TypeKind.INT32:

@@ -26,2 +26,3 @@ import { HttpMethod } from "./http";

description?: string;
isDraft: boolean;
tags: string[];

@@ -28,0 +29,0 @@ method: HttpMethod;

@@ -27,2 +27,3 @@ import { HttpMethod } from "./http";

description?: Locatable<string>;
isDraft: boolean;
tags?: Locatable<string[]>;

@@ -29,0 +30,0 @@ method: Locatable<HttpMethod>;

import { TypeKind } from "./kinds";
export declare type CustomPrimitiveType = Int32Type | Int64Type | DateType | DateTimeType;
export declare type CustomPrimitiveType = Int32Type | Int64Type | DoubleType | DateType | DateTimeType;
export declare const INT32: Int32Type;

@@ -19,1 +19,5 @@ export interface Int32Type {

}
export declare const DOUBLE: DoubleType;
export interface DoubleType {
kind: TypeKind.DOUBLE;
}

@@ -16,1 +16,4 @@ "use strict";

};
exports.DOUBLE = {
kind: kinds_1.TypeKind.DOUBLE
};

@@ -1,2 +0,2 @@

import { CustomPrimitiveType, DateTimeType, DateType, Int32Type, Int64Type } from "./custom-primitive-types";
import { CustomPrimitiveType, DateTimeType, DateType, DoubleType, Int32Type, Int64Type } from "./custom-primitive-types";
import { ArrayType, ObjectType } from "./object-types";

@@ -14,3 +14,3 @@ import { NumberLiteral, PrimitiveLiteral, StringLiteral } from "./primitive-literals";

export declare type DataType = PrimitiveType | CustomPrimitiveType | PrimitiveLiteral | ObjectType | ArrayType | ReferenceType | UnionType;
export declare type NumberLikeType = FloatType | NumberLiteral | Int32Type | Int64Type | ReferenceType;
export declare type NumberLikeType = FloatType | DoubleType | Int32Type | Int64Type | NumberLiteral | ReferenceType;
export declare type StringLikeType = StringType | StringLiteral | DateType | DateTimeType | ReferenceType;

@@ -17,0 +17,0 @@ export declare function isObjectType(type: DataType): type is ObjectType;

@@ -6,2 +6,3 @@ export declare enum TypeKind {

FLOAT = "float",
DOUBLE = "double",
INT32 = "int32",

@@ -8,0 +9,0 @@ INT64 = "int64",

@@ -9,2 +9,3 @@ "use strict";

TypeKind["FLOAT"] = "float";
TypeKind["DOUBLE"] = "double";
TypeKind["INT32"] = "int32";

@@ -30,6 +31,7 @@ TypeKind["INT64"] = "int64";

TypeKind.FLOAT,
TypeKind.NUMBER_LITERAL,
TypeKind.DOUBLE,
TypeKind.INT32,
TypeKind.INT64
TypeKind.INT64,
TypeKind.NUMBER_LITERAL
];
exports.BooleanLikeKind = [TypeKind.BOOLEAN, TypeKind.BOOLEAN_LITERAL];

@@ -16,2 +16,3 @@ "use strict";

const description = parser_utility_1.extractJsDocCommentLocatable(klass);
const isDraft = klass.getDecorator("draft") !== undefined;
const configuration = parser_utility_1.extractDecoratorFactoryConfiguration(decorator);

@@ -53,3 +54,4 @@ const tags = parser_utility_1.extractOptionalStringArrayPropertyValueLocatable(configuration, "tags");

defaultResponse,
tests
tests,
isDraft
},

@@ -56,0 +58,0 @@ location,

@@ -20,2 +20,16 @@ "use strict";

}
else if (ts_morph_1.TypeGuards.isPrefixUnaryExpression(expression)) {
const operand = expression.getOperand();
if (!ts_morph_1.TypeGuards.isNumericLiteral(operand)) {
throw new Error("unary operators may only be used with numeric literals");
}
switch (expression.getOperatorToken()) {
case ts_morph_1.SyntaxKind.MinusToken:
return types_1.numberExpression(-operand.getLiteralValue());
case ts_morph_1.SyntaxKind.PlusToken:
return types_1.numberExpression(operand.getLiteralValue());
default:
throw new Error("unknown prefix operator token");
}
}
else if (ts_morph_1.TypeGuards.isNumericLiteral(expression)) {

@@ -55,5 +69,5 @@ return types_1.numberExpression(expression.getLiteralValue());

else {
throw new Error("unknown expression type");
throw new Error(`unknown expression type: ${expression.getText()}`);
}
}
exports.parseExpression = parseExpression;

@@ -48,2 +48,4 @@ "use strict";

"DateTime",
"Number",
"Double",
"Float",

@@ -84,4 +86,7 @@ "Integer",

switch (name) {
case "Number":
case "Float":
return types_1.FLOAT;
case "Double":
return types_1.DOUBLE;
case "Integer":

@@ -88,0 +93,0 @@ case "Int32":

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_never_1 = __importDefault(require("assert-never"));
const lodash_1 = require("lodash");

@@ -96,2 +100,3 @@ const types_1 = require("../../models/types");

case types_1.TypeKind.FLOAT:
case types_1.TypeKind.DOUBLE:
case types_1.TypeKind.INT32:

@@ -122,5 +127,4 @@ case types_1.TypeKind.INT64:

}
default: {
throw new Error("unexpected type reference");
}
default:
throw assert_never_1.default(dataType.referenceKind);
}

@@ -127,0 +131,0 @@ }

@@ -13,1 +13,2 @@ export * from "./api";

export * from "./types";
export * from "./draft";

@@ -17,1 +17,2 @@ "use strict";

__export(require("./security-header"));
__export(require("./draft"));

@@ -1,3 +0,7 @@

/** A float */
/** A number */
export declare type Number = number;
/** A floating point number */
export declare type Float = number;
/** A double precision floating point number */
export declare type Double = number;
/** An integer */

@@ -4,0 +8,0 @@ export declare type Integer = number;

export interface TestConfig {
testFilter?: TestFilter;
includeDraft: boolean;
}

@@ -4,0 +5,0 @@ export interface TestFilter {

@@ -26,3 +26,3 @@ "use strict";

*/
async test(definition, config) {
async test(definition, config = { includeDraft: false }) {
const testSuiteStartTime = test_timer_1.TestTimer.startTime();

@@ -32,3 +32,7 @@ let allPassed = true;

for (const test of endpoint.tests) {
if (config && config.testFilter) {
if (endpoint.isDraft && !config.includeDraft) {
this.logger.warn(`Draft endpoint test ${endpoint.name}:${test.name} skipped`);
continue;
}
if (config.testFilter) {
if (config.testFilter.endpoint !== endpoint.name ||

@@ -35,0 +39,0 @@ (config.testFilter.test && config.testFilter.test !== test.name)) {

@@ -15,2 +15,3 @@ "use strict";

case types_1.TypeKind.FLOAT:
case types_1.TypeKind.DOUBLE:
case types_1.TypeKind.INT32:

@@ -17,0 +18,0 @@ case types_1.TypeKind.INT64:

@@ -18,2 +18,3 @@ "use strict";

case types_1.TypeKind.FLOAT:
case types_1.TypeKind.DOUBLE:
case types_1.TypeKind.INT32:

@@ -20,0 +21,0 @@ case types_1.TypeKind.INT64:

@@ -1,1 +0,1 @@

{"version":"0.2.17","commands":{"checksum":{"id":"checksum","description":"Generate a version tag 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}},"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},"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}]},"test":{"id":"test","description":"Test a Spot contract","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot test api.ts -u http://localhost:3000","$ spot test api.ts -u http://localhost:3000 -s http://localhost:3000/spot","$ spot test api.ts -u http://localhost:3000 -t MyEndpoint:myTest"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"debug":{"name":"debug","type":"boolean","description":"Enable debug logs","allowNo":false},"url":{"name":"url","type":"option","char":"u","description":"Base URL","required":true},"stateUrl":{"name":"stateUrl","type":"option","char":"s","description":"Base URL for state changes"},"testFilter":{"name":"testFilter","type":"option","char":"t","description":"Filter by endpoint and test"}},"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}]}}}
{"version":"0.2.18","commands":{"checksum":{"id":"checksum","description":"Generate a version tag 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}},"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},"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}]},"test":{"id":"test","description":"Test a Spot contract","pluginName":"@airtasker/spot","pluginType":"core","aliases":[],"examples":["$ spot test api.ts -u http://localhost:3000","$ spot test api.ts -u http://localhost:3000 -s http://localhost:3000/spot","$ spot test api.ts -u http://localhost:3000 -t MyEndpoint:myTest"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"debug":{"name":"debug","type":"boolean","description":"Enable debug logs","allowNo":false},"includeDraft":{"name":"includeDraft","type":"boolean","description":"Include draft endpoint tests","allowNo":false},"url":{"name":"url","type":"option","char":"u","description":"Base URL","required":true},"stateUrl":{"name":"stateUrl","type":"option","char":"s","description":"Base URL for state changes"},"testFilter":{"name":"testFilter","type":"option","char":"t","description":"Filter by endpoint and test"}},"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}]}}}
{
"name": "@airtasker/spot",
"version": "0.2.17",
"version": "0.2.18",
"author": "Francois Wouts, Leslie Fung",

@@ -17,3 +17,3 @@ "bin": {

"@types/randomstring": "^1.1.6",
"ajv": "^6.10.0",
"ajv": "^6.10.1",
"assert-never": "^1.2.0",

@@ -24,11 +24,11 @@ "axios": "^0.19.0",

"express": "^4.17.1",
"fs-extra": "^8.0.1",
"fs-extra": "^8.1.0",
"inquirer": "^6.4.1",
"js-yaml": "^3.13.1",
"lodash": "^4.17.11",
"lodash": "^4.17.14",
"qs": "^6.7.0",
"randomstring": "^1.1.5",
"ts-morph": "^2.3.0",
"ts-morph": "^3.1.0",
"tslib": "^1",
"typescript": "^3.5.2"
"typescript": "^3.5.3"
},

@@ -38,11 +38,10 @@ "devDependencies": {

"@types/chai": "^4",
"@types/fs-extra": "^7.0.0",
"@types/fs-extra": "^8.0.0",
"@types/inquirer": "^6.0.3",
"@types/jest": "^24.0.15",
"@types/js-yaml": "^3.12.1",
"@types/lodash": "^4.14.134",
"@types/lodash": "^4.14.136",
"@types/moxios": "^0.4.8",
"@types/nock": "^10.0.3",
"@types/node": "^12.0.10",
"globby": "^9.2.0",
"@types/node": "^12.6.2",
"jest": "^24.8.0",

@@ -49,0 +48,0 @@ "nock": "^10.0.6",

@@ -140,3 +140,3 @@ # Spot

_See code: [build/cli/src/commands/checksum.js](https://github.com/airtasker/spot/blob/v0.2.17/build/cli/src/commands/checksum.js)_
_See code: [build/cli/src/commands/checksum.js](https://github.com/airtasker/spot/blob/v0.2.18/build/cli/src/commands/checksum.js)_

@@ -162,3 +162,3 @@ ## `spot generate`

_See code: [build/cli/src/commands/generate.js](https://github.com/airtasker/spot/blob/v0.2.17/build/cli/src/commands/generate.js)_
_See code: [build/cli/src/commands/generate.js](https://github.com/airtasker/spot/blob/v0.2.18/build/cli/src/commands/generate.js)_

@@ -201,3 +201,3 @@ ## `spot help [COMMAND]`

_See code: [build/cli/src/commands/init.js](https://github.com/airtasker/spot/blob/v0.2.17/build/cli/src/commands/init.js)_
_See code: [build/cli/src/commands/init.js](https://github.com/airtasker/spot/blob/v0.2.18/build/cli/src/commands/init.js)_

@@ -222,3 +222,3 @@ ## `spot lint SPOT_CONTRACT`

_See code: [build/cli/src/commands/lint.js](https://github.com/airtasker/spot/blob/v0.2.17/build/cli/src/commands/lint.js)_
_See code: [build/cli/src/commands/lint.js](https://github.com/airtasker/spot/blob/v0.2.18/build/cli/src/commands/lint.js)_

@@ -245,3 +245,3 @@ ## `spot mock SPOT_CONTRACT`

_See code: [build/cli/src/commands/mock.js](https://github.com/airtasker/spot/blob/v0.2.17/build/cli/src/commands/mock.js)_
_See code: [build/cli/src/commands/mock.js](https://github.com/airtasker/spot/blob/v0.2.18/build/cli/src/commands/mock.js)_

@@ -265,2 +265,3 @@ ## `spot test SPOT_CONTRACT`

--debug Enable debug logs
--includeDraft Include draft endpoint tests

@@ -273,3 +274,3 @@ EXAMPLES

_See code: [build/cli/src/commands/test.js](https://github.com/airtasker/spot/blob/v0.2.17/build/cli/src/commands/test.js)_
_See code: [build/cli/src/commands/test.js](https://github.com/airtasker/spot/blob/v0.2.18/build/cli/src/commands/test.js)_

@@ -294,3 +295,3 @@ ## `spot validate SPOT_CONTRACT`

_See code: [build/cli/src/commands/validate.js](https://github.com/airtasker/spot/blob/v0.2.17/build/cli/src/commands/validate.js)_
_See code: [build/cli/src/commands/validate.js](https://github.com/airtasker/spot/blob/v0.2.18/build/cli/src/commands/validate.js)_
<!-- commandsstop -->
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc