Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ object DistributionAwareShapeBuilder {

val aggregator = aggregateTrailsAndValues(bodies)
val rootShape = toShapes(aggregator, ids)

val flattened = rootShape.flattenChildren

implicit val idGenerator: () => String = () => ids.nextId()

val commands = new MutableCommandStream
Expand Down Expand Up @@ -129,6 +127,7 @@ object DistributionAwareShapeBuilder {
}

private def fromJsons(values: Vector[JsonLike], trail: JsonTrail, inner: Boolean, totalSamples: Int)(implicit trailValues: TrailValueMap, idGenerator: SequentialIdGenerator): ShapesToMake = {

val isOptional = values.size != totalSamples
val kinds = values.groupBy(v => JsonLikeResolvers.jsonToCoreKind(v))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait SimpleLogger {
@JSExportAll
object Logger {
val printlnLogger: SimpleLogger = new SimpleLogger {
override def log(x: Any): Any = println(x)
override def log(x: Any): Any = println(x) //never delete this one, I'm allowed :)
}
val noopLogger: SimpleLogger = new SimpleLogger {
override def log(x: Any): Any = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class DiffManager(initialInteractions: Seq[HttpInteraction], onUpdated: () => Un
def updatedRfcState(rfcState: RfcState, resolvers: ShapesResolvers): Unit = {
if (_currentRfcState != rfcState) {
_currentRfcState = rfcState

_resolvers = resolvers
diffPreviewer = new DiffPreviewer(_resolvers, _currentRfcState)
recomputeDiff
Expand Down Expand Up @@ -266,11 +267,11 @@ abstract class PathAndMethodDiffManager(pathComponentId: PathComponentId, httpMe

val previewRender = (interaction: HttpInteraction) => diffPreviewer.previewBody(interaction.request.body)

val bodies = interactions.map(_.request.body).flatMap(BodyUtilities.parseBody).toVector
val preview = diffPreviewer.shapeOnlyFromShapeBuilder(bodies)

val previewShape = (interaction: HttpInteraction, inferPolymorphism: Boolean) => {
if (inferPolymorphism) {
val bodies = interactions.map(_.request.body).flatMap(BodyUtilities.parseBody).toVector
val preview = diffPreviewer.shapeOnlyFromShapeBuilder(bodies)
preview.map(_._2)
} else {
diffPreviewer.shapeOnlyFromShapeBuilder(Vector(BodyUtilities.parseBody(interaction.request.body)).flatten).map(_._2)
Expand All @@ -288,11 +289,11 @@ abstract class PathAndMethodDiffManager(pathComponentId: PathComponentId, httpMe

val previewRender = (interaction: HttpInteraction) => diffPreviewer.previewBody(interaction.response.body)

val bodies = interactions.map(_.response.body).flatMap(BodyUtilities.parseBody).toVector
val preview = diffPreviewer.shapeOnlyFromShapeBuilder(bodies)

val previewShape = (interaction: HttpInteraction, inferPolymorphism: Boolean) => {
if (inferPolymorphism) {
val bodies = interactions.map(_.response.body).flatMap(BodyUtilities.parseBody).toVector
val preview = diffPreviewer.shapeOnlyFromShapeBuilder(bodies)
preview.map(_._2)
} else {
diffPreviewer.shapeOnlyFromShapeBuilder(Vector(BodyUtilities.parseBody(interaction.response.body)).flatten).map(_._2)
Expand All @@ -310,11 +311,11 @@ abstract class PathAndMethodDiffManager(pathComponentId: PathComponentId, httpMe

val previewRender = (interaction: HttpInteraction) => diffPreviewer.previewBody(interaction.response.body)

val bodies = interactions.map(_.response.body).flatMap(BodyUtilities.parseBody).toVector
val preview = diffPreviewer.shapeOnlyFromShapeBuilder(bodies)

val previewShape = (interaction: HttpInteraction, inferPolymorphism: Boolean) => {
if (inferPolymorphism) {

val bodies = interactions.map(_.response.body).flatMap(BodyUtilities.parseBody).toVector
val preview = diffPreviewer.shapeOnlyFromShapeBuilder(bodies)
preview.map(_._2)
} else {
diffPreviewer.shapeOnlyFromShapeBuilder(Vector(BodyUtilities.parseBody(interaction.response.body)).flatten).map(_._2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ trait JsonFileFixture {
eventsAndInteractionsFrom(json)
}

case class Universe(rfcService: RfcService, rfcId: AggregateId, eventStore: EventStore[RfcEvent], interactions: Vector[HttpInteraction])
case class Universe(rfcService: RfcService, rfcId: AggregateId, eventStore: EventStore[RfcEvent], interactions: Vector[HttpInteraction]) {
def rfcState = rfcService.currentState(rfcId)
}

def eventsAndInteractionsFrom(slug: String): Universe = {
val json = fromFile(slug)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.useoptic.end_to_end

import com.useoptic.diff.JsonFileFixture
import com.useoptic.diff.helpers.DiffHelpers
import com.useoptic.diff.interactions.UnmatchedResponseBodyContentType
import com.useoptic.diff.shapes.resolvers.ShapesResolvers
import com.useoptic.ux.DiffManager
import org.scalatest.FunSpec

class NPMUniverseExample extends FunSpec with JsonFileFixture {
lazy val universe = universeFromExampleSession("npm-debug-capture")

it("can load in the npm universe") {

val interactions = universe.interactions.sortBy(_.uuid).slice(4, 10)

val diffManager = new DiffManager(interactions)
diffManager.updatedRfcState(universe.rfcState, ShapesResolvers.newCachingResolver(universe.rfcState))
val diffsForEndpoint = diffManager.endpointDiffs(Seq.empty).headOption.map(ed => diffManager.managerForPathAndMethod(ed.pathId, ed.method, Seq.empty)).get

val diffToEval = diffsForEndpoint.diffRegions.newRegions.collectFirst {
case a if a.diff.isInstanceOf[UnmatchedResponseBodyContentType] => a
}.get


val preview = diffToEval.previewShape(interactions.head, false)
val polyPreview =diffToEval.previewShape(interactions.head, true)
// println(polyPreview)
null
}

}
1 change: 1 addition & 0 deletions core/scripts/package-optimized.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash

export SBT_OPTS="-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M -Duser.timezone=GMT"
sbt fullOptJS
OUTPUT_FILE=../workspaces/domain/src/domain.js
Expand Down
3 changes: 3 additions & 0 deletions core/scripts/package.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env bash

echo "Packaging Development Domain"

export SBT_OPTS="-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M -Duser.timezone=GMT"
sbt fastOptJS
OUTPUT_FILE=../workspaces/domain/src/domain.js
Expand Down
2 changes: 2 additions & 0 deletions sourceme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ optic_install_from_local_registry() {
(
set -o errexit
YARN_REGISTRY=http://localhost:4873 yarn global add @useoptic/cli --registry=http://localhost:4873
YARN_REGISTRY=http://localhost:4873 yarn global add @useoptic/agent-cli --registry=http://localhost:4873
YARN_REGISTRY=http://localhost:4873 yarn global add @useoptic/ci-cli --registry=http://localhost:4873
)
}
# DEBUG=optic* apidev daemon:stop && DEBUG=optic* apidev agent:start
41 changes: 20 additions & 21 deletions workspaces/agent-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ npm install -g @useoptic/agent-cli
$ optic-agent COMMAND
running command...
$ optic-agent (-v|--version|version)
@useoptic/agent-cli/0.1.0 darwin-x64 node-v12.16.2
@useoptic/agent-cli/8.0.8 darwin-x64 node-v12.4.0
$ optic-agent --help [COMMAND]
USAGE
$ optic-agent COMMAND
Expand All @@ -28,43 +28,42 @@ USAGE
<!-- usagestop -->
# Commands
<!-- commands -->
* [`optic-agent hello [FILE]`](#optic-agent-hello-file)
* [`optic-agent help [COMMAND]`](#optic-agent-help-command)
* [`optic-agent run`](#optic-agent-run)

## `optic-agent hello [FILE]`
## `optic-agent help [COMMAND]`

describe the command here
display help for optic-agent

```
USAGE
$ optic-agent hello [FILE]
$ optic-agent help [COMMAND]

OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
ARGUMENTS
COMMAND command to show help for

EXAMPLE
$ optic-agent hello
hello world from ./src/hello.ts!
OPTIONS
--all see all commands in CLI
```

_See code: [src/commands/hello.ts](https://github.com/opticdev/optic/blob/v0.1.0/src/commands/hello.ts)_
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.0.1/src/commands/help.ts)_

## `optic-agent help [COMMAND]`
## `optic-agent run`

display help for optic-agent
describe the command here

```
USAGE
$ optic-agent help [COMMAND]

ARGUMENTS
COMMAND command to show help for
$ optic-agent run

OPTIONS
--all see all commands in CLI
--command=command (required) the command to run
--config=config (required) the output from optic-ci capture:start
--masquerade=masquerade (required) host:port Optic should start on

EXAMPLE
$ optic-agent run ????
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.0.1/src/commands/help.ts)_
_See code: [src/commands/run.ts](https://github.com/useoptic/optic-package/blob/v8.0.8/src/commands/run.ts)_
<!-- commandsstop -->
5 changes: 3 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.0.7",
"version": "8.0.8",
"author": "@useoptic",
"bin": {
"optic-agent": "./bin/run"
Expand All @@ -15,10 +15,11 @@
"@oclif/command": "^1",
"@oclif/config": "^1",
"@oclif/plugin-help": "^3",
"@useoptic/cli-shared": "8.0.7",
"@useoptic/cli-shared": "8.0.8",
"dotenv": "^8.2.0",
"jwt-decode": "^2.2.0",
"tslib": "^1",
"url-join": "^4.0.1",
"uuid": "^8.0.0"
},
"devDependencies": {
Expand Down
41 changes: 23 additions & 18 deletions workspaces/ci-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,53 @@
<!-- usage -->
```sh-session
$ npm install -g @useoptic/ci-cli
$ optic-ci COMMAND
$ optic-agent COMMAND
running command...
$ optic-ci (-v|--version|version)
@useoptic/ci-cli/0.1.0 darwin-x64 node-v12.16.2
$ optic-ci --help [COMMAND]
$ optic-agent (-v|--version|version)
@useoptic/ci-cli/8.0.8 darwin-x64 node-v12.4.0
$ optic-agent --help [COMMAND]
USAGE
$ optic-ci COMMAND
$ optic-agent COMMAND
...
```
<!-- usagestop -->
# Commands
<!-- commands -->
* [`optic-ci hello [FILE]`](#optic-ci-hello-file)
* [`optic-ci help [COMMAND]`](#optic-ci-help-command)
* [`optic-agent capture:start`](#optic-agent-capturestart)
* [`optic-agent help [COMMAND]`](#optic-agent-help-command)

## `optic-ci hello [FILE]`
## `optic-agent capture:start`

describe the command here

```
USAGE
$ optic-ci hello [FILE]
$ optic-agent capture:start

OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
--build-id=build-id (required) a unique identifier representing the version of the code, build process, and
build environment variables

--config=config (required) the path to your optic.yml file

--deployment-id=deployment-id (required) a unique identifier representing the version of the code, build process,
build environment variables, and runtime environment variables

--environment=environment (required) the name of the environment you are deploying into

EXAMPLE
$ optic-ci hello
hello world from ./src/hello.ts!
$ optic-ci capture:start ???
```

_See code: [src/commands/hello.ts](https://github.com/opticdev/optic/blob/v0.1.0/src/commands/hello.ts)_
_See code: [src/commands/capture/start.ts](https://github.com/useoptic/optic-package/blob/v8.0.8/src/commands/capture/start.ts)_

## `optic-ci help [COMMAND]`
## `optic-agent help [COMMAND]`

display help for optic-ci
display help for optic-agent

```
USAGE
$ optic-ci help [COMMAND]
$ optic-agent help [COMMAND]

ARGUMENTS
COMMAND command to show help for
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.0.7",
"version": "8.0.8",
"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.0.7",
"@useoptic/cli-shared": "8.0.7",
"@useoptic/cli-config": "8.0.8",
"@useoptic/cli-shared": "8.0.8",
"dotenv": "^8.2.0",
"jwt-decode": "^2.2.0",
"tslib": "^1",
Expand Down
4 changes: 3 additions & 1 deletion workspaces/ci-cli/src/commands/capture/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export default class Start extends Command {
// find the api jwt
const testingConfigExists = await fs.pathExists(testingConfigPath);
if (!testingConfigExists) {
return this.error(`Please run 'api testing:enable'`);
return this.error(
`No testing token found at ${testingConfigPath} \nPlease run 'api testing:enable'`
);
}
const { authToken }: ITestingConfig = await fs.readJson(testingConfigPath);

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.0.7",
"version": "8.0.8",
"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.0.7",
"@useoptic/client-utilities": "8.0.7",
"@useoptic/cli-config": "8.0.8",
"@useoptic/client-utilities": "8.0.8",
"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.0.7",
"version": "8.0.8",
"scripts": {
"ws:test": "echo config",
"ws:build": "yarn run tsc -b --verbose",
Expand Down
2 changes: 1 addition & 1 deletion 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.0.7",
"version": "8.0.8",
"scripts": {
"ws:test": "echo scripts",
"ws:build": "yarn run tsc -b --verbose",
Expand Down
10 changes: 5 additions & 5 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.0.7",
"version": "8.0.8",
"scripts": {
"ws:build": "yarn run tsc -b --verbose",
"ws:clean": "rm -rf build/*",
Expand All @@ -14,10 +14,10 @@
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@useoptic/cli-client": "8.0.7",
"@useoptic/cli-config": "8.0.7",
"@useoptic/cli-shared": "8.0.7",
"@useoptic/ui": "8.0.7",
"@useoptic/cli-client": "8.0.8",
"@useoptic/cli-config": "8.0.8",
"@useoptic/cli-shared": "8.0.8",
"@useoptic/ui": "8.0.8",
"avsc": "^5.4.18",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
Expand Down
Loading