Skip to content

Commit

Permalink
Merge pull request #251 from opticdev/develop
Browse files Browse the repository at this point in the history
8.2.1
  • Loading branch information
acunniffe authored Jul 13, 2020
2 parents cfeb7c2 + 445d7c1 commit 350bd82
Show file tree
Hide file tree
Showing 28 changed files with 1,611 additions and 1,438 deletions.
55 changes: 0 additions & 55 deletions .github/workflows/publish.yml

This file was deleted.

13 changes: 7 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ jobs:
release-npm:
runs-on: ubuntu-latest
steps:
- run: echo "NPM Release has not been configured yet"
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v1
# with:
# node-version: 12
# - run: npm run publish
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm run publish
env:
NPM_TOKEN: ${{ secrets.PUBLISH_NPM_OPTIC_BOT }}

# Creates debian package for users to install, hosted on s3
release-deb:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ object DiffResultHelper {

val allEndpoints = AllEndpointsProjection.fromRfcState(rfcState)

println("total diffs "+ diffs.size)

val normalizedDiffs = {
val groupedByNormalized = diffs.groupBy(_._1.normalize())

Expand All @@ -69,9 +67,7 @@ object DiffResultHelper {
.toSeq.distinct)
.toMap
}

println("total diffs normalized "+ normalizedDiffs.size)


val endpointsFromDiff = {
normalizedDiffs.filterNot {
case (a: UnmatchedRequestUrl, _) => true
Expand Down Expand Up @@ -448,5 +444,6 @@ case class PreviewShapeAndCommands(shape: Option[ShapeOnlyRenderHelper], suggest

@JSExportAll
case class SplitUndocumentedUrls(urls: Seq[NewEndpoint], undocumented: Seq[NewEndpoint], totalCount: Int, allPaths: Seq[String]) {
def showing: Int = urls.length
def showing: Int = urls.length
def total: Int = undocumented.length + urls.length
}
4 changes: 2 additions & 2 deletions workspaces/agent-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@useoptic/agent-cli",
"version": "8.2.0",
"version": "8.2.1",
"author": "@useoptic",
"bin": {
"optic-agent": "./bin/run"
Expand All @@ -15,7 +15,7 @@
"@oclif/command": "^1",
"@oclif/config": "^1",
"@oclif/plugin-help": "^3",
"@useoptic/cli-shared": "8.2.0",
"@useoptic/cli-shared": "8.2.1",
"dotenv": "^8.2.0",
"jwt-decode": "^2.2.0",
"tslib": "^1",
Expand Down
6 changes: 3 additions & 3 deletions workspaces/ci-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@useoptic/ci-cli",
"version": "8.2.0",
"version": "8.2.1",
"author": "@useoptic",
"bin": {
"optic-ci": "./bin/run"
Expand All @@ -15,8 +15,8 @@
"@oclif/command": "^1",
"@oclif/config": "^1",
"@oclif/plugin-help": "^3",
"@useoptic/cli-config": "8.2.0",
"@useoptic/cli-shared": "8.2.0",
"@useoptic/cli-config": "8.2.1",
"@useoptic/cli-shared": "8.2.1",
"dotenv": "^8.2.0",
"jwt-decode": "^2.2.0",
"tslib": "^1",
Expand Down
6 changes: 3 additions & 3 deletions workspaces/cli-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@useoptic/cli-client",
"version": "8.2.0",
"version": "8.2.1",
"scripts": {
"ws:build": "yarn run tsc -b --verbose",
"ws:clean": "rm -rf build/*",
Expand All @@ -14,8 +14,8 @@
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@useoptic/cli-config": "8.2.0",
"@useoptic/client-utilities": "8.2.0",
"@useoptic/cli-config": "8.2.1",
"@useoptic/client-utilities": "8.2.1",
"bottleneck": "^2.19.5",
"cross-fetch": "^3.0.4"
},
Expand Down
2 changes: 1 addition & 1 deletion workspaces/cli-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@useoptic/cli-config",
"version": "8.2.0",
"version": "8.2.1",
"scripts": {
"ws:test": "echo config",
"ws:build": "yarn run tsc -b --verbose",
Expand Down
5 changes: 2 additions & 3 deletions workspaces/cli-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ export async function readApiConfig(
const rawFile = await fs.readFile(configPath);
let parsed = null;
try {
parsed = yaml.safeLoad(rawFile.toString());
// @ts-ignore
return (parsed = yaml.safeLoad(rawFile.toString()));
} catch (e) {
throw new InvalidOpticConfigurationSyntaxError(
'`optic.yml` will not parse. Make sure it is valid YAML.'
);
}

return parsed;
}

export async function readTestingConfig(
Expand Down
4 changes: 2 additions & 2 deletions workspaces/cli-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@useoptic/cli-scripts",
"version": "8.2.0",
"version": "8.2.1",
"scripts": {
"ws:test": "echo scripts",
"ws:build": "yarn run tsc -b --verbose",
Expand All @@ -16,7 +16,7 @@
"dependencies": {
"node-notifier": "^7.0.0",
"analytics-node": "^3.4.0-beta.1",
"@useoptic/cli-shared": "8.2.0"
"@useoptic/cli-shared": "8.2.1"
},
"devDependencies": {
"@types/node-notifier": "^6.0.1"
Expand Down
12 changes: 6 additions & 6 deletions workspaces/cli-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@useoptic/cli-server",
"version": "8.2.0",
"version": "8.2.1",
"scripts": {
"ws:build": "yarn run tsc -b --verbose",
"ws:clean": "rm -rf build/*",
Expand All @@ -14,11 +14,11 @@
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@useoptic/cli-client": "8.2.0",
"@useoptic/cli-config": "8.2.0",
"@useoptic/cli-scripts": "8.2.0",
"@useoptic/cli-shared": "8.2.0",
"@useoptic/ui": "8.2.0",
"@useoptic/cli-client": "8.2.1",
"@useoptic/cli-config": "8.2.1",
"@useoptic/cli-scripts": "8.2.1",
"@useoptic/cli-shared": "8.2.1",
"@useoptic/ui": "8.2.1",
"avsc": "^5.4.18",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
Expand Down
18 changes: 9 additions & 9 deletions workspaces/cli-shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@useoptic/cli-shared",
"version": "8.2.0",
"version": "8.2.1",
"scripts": {
"ws:build": "yarn run tsc -b --verbose",
"ws:clean": "rm -rf build/*",
Expand All @@ -15,12 +15,12 @@
"types": "build/index.d.ts",
"dependencies": {
"@oclif/command": "^1.6.1",
"@useoptic/cli-client": "8.2.0",
"@useoptic/cli-config": "8.2.0",
"@useoptic/client-utilities": "8.2.0",
"@useoptic/domain": "8.2.0",
"@useoptic/domain-types": "8.2.0",
"@useoptic/domain-utilities": "8.2.0",
"@useoptic/cli-client": "8.2.1",
"@useoptic/cli-config": "8.2.1",
"@useoptic/client-utilities": "8.2.1",
"@useoptic/domain": "8.2.1",
"@useoptic/domain-types": "8.2.1",
"@useoptic/domain-utilities": "8.2.1",
"avsc": "^5.4.21",
"proper-lockfile": "^4.1.1",
"bottleneck": "^2.19.5",
Expand All @@ -29,12 +29,12 @@
"ora": "^4.0.4",
"tree-kill": "^1.2.2",
"uuid": "^8.0.0",
"mockttp": "^0.19.2",
"shape-hash": "^1.0.6",
"whatwg-mimetype": "^2.3.0"
},
"devDependencies": {
"@types/whatwg-mimetype": "^2.1.0"
"@types/whatwg-mimetype": "^2.1.0",
"mockttp": "^0.19.2"
},
"files": [
"/build"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CommandSession } from './command-session';
import { HttpToolkitCapturingProxy } from './httptoolkit-capturing-proxy';
import { developerDebugLogger, ICaptureSaver, userDebugLogger, fromOptic } from './index';
import url from 'url';
import { buildQueryStringParser } from './query/build-query-string-parser';

class CommandAndProxySessionManager {
constructor(private config: IOpticTaskRunnerConfig) {}
Expand Down Expand Up @@ -39,13 +40,15 @@ class CommandAndProxySessionManager {
includeTextBody: process.env.OPTIC_ENABLE_CAPTURE_BODY === 'yes',
includeJsonBody: process.env.OPTIC_ENABLE_CAPTURE_BODY === 'yes',
includeShapeHash: true,
includeQueryString: true,
},
host: this.config.proxyConfig.host,
proxyTarget:
process.env.OPTIC_ENABLE_TRANSPARENT_PROXY === 'yes'
? undefined
: target,
proxyPort: this.config.proxyConfig.port,
queryParser: buildQueryStringParser(),
});

userDebugLogger(
Expand Down
41 changes: 35 additions & 6 deletions workspaces/cli-shared/src/httptoolkit-capturing-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ import fs from 'fs-extra';
import { CallbackResponseResult } from 'mockttp/dist/rules/handlers';
import { CompletedRequest, MockRuleData } from 'mockttp';
import mime from 'whatwg-mimetype';
import { IBody, IHttpInteraction } from '@useoptic/domain-types';
import {
IArbitraryData,
IBody,
IHttpInteraction,
} from '@useoptic/domain-types';
//@ts-ignore
import { toBytes } from 'shape-hash';
import { developerDebugLogger } from './index';
import url from 'url';
import { IQueryParser } from './query/query-parser-interfaces';

export interface IHttpToolkitCapturingProxyConfig {
proxyTarget?: string;
Expand All @@ -19,7 +25,9 @@ export interface IHttpToolkitCapturingProxyConfig {
includeJsonBody: boolean;
includeTextBody: boolean;
includeShapeHash: boolean;
includeQueryString: boolean;
};
queryParser: IQueryParser;
}

export interface IRequestFilter {
Expand Down Expand Up @@ -136,6 +144,7 @@ export class HttpToolkitCapturingProxy {
if (!req) {
return;
}

developerDebugLogger(req);
const sample: IHttpInteraction = {
tags: [],
Expand All @@ -149,11 +158,7 @@ export class HttpToolkitCapturingProxy {
asText: null,
shapeHashV1Base64: null,
},
query: {
asJsonString: null,
asText: null,
shapeHashV1Base64: null,
},
query: this.extractQueryParameters(req),
body: this.extractBody(req),
},
response: {
Expand Down Expand Up @@ -193,6 +198,30 @@ export class HttpToolkitCapturingProxy {
}
}

extractQueryParameters(req: mockttp.CompletedRequest): IArbitraryData {
const rawQuery = url.parse(req.url).query;

developerDebugLogger('extracting query params', { rawQuery });

if (rawQuery) {
const jsonLikeValue = this.config.queryParser.parse(rawQuery);
return {
asJsonString: this.config.flags.includeQueryString
? JSON.stringify(jsonLikeValue)
: null,
asText: this.config.flags.includeQueryString ? rawQuery : null,
shapeHashV1Base64:
jsonLikeValue && toBytes(jsonLikeValue).toString('base64'),
};
} else {
return {
asJsonString: null,
asText: null,
shapeHashV1Base64: null,
};
}
}

extractBody(
req: mockttp.CompletedRequest | mockttp.CompletedResponse
): IBody {
Expand Down
6 changes: 6 additions & 0 deletions workspaces/cli-shared/src/query/build-query-string-parser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { IQueryParser } from './query-parser-interfaces';
import { DefaultQueryParser } from './parsers/query-string/DefaultQueryParser';

export function buildQueryStringParser(): IQueryParser {
return new DefaultQueryParser();
}
Loading

0 comments on commit 350bd82

Please sign in to comment.