@thymian/core 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/actions/action.d.ts +5 -0
- package/dist/actions/action.d.ts.map +1 -0
- package/dist/actions/action.js +2 -0
- package/dist/actions/action.js.map +1 -0
- package/dist/actions/close.action.d.ts +3 -0
- package/dist/actions/close.action.d.ts.map +1 -0
- package/dist/actions/close.action.js +2 -0
- package/dist/actions/close.action.js.map +1 -0
- package/dist/actions/index.d.ts +16 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +5 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/load-format.action.d.ts +6 -0
- package/dist/actions/load-format.action.d.ts.map +1 -0
- package/dist/actions/load-format.action.js +62 -0
- package/dist/actions/load-format.action.js.map +1 -0
- package/dist/actions/ready.action.d.ts +3 -0
- package/dist/actions/ready.action.d.ts.map +1 -0
- package/dist/actions/ready.action.js +2 -0
- package/dist/actions/ready.action.js.map +1 -0
- package/dist/actions/run.action.d.ts +11 -0
- package/dist/actions/run.action.d.ts.map +1 -0
- package/dist/actions/run.action.js +16 -0
- package/dist/actions/run.action.js.map +1 -0
- package/dist/ajv.d.ts +5 -0
- package/dist/ajv.d.ts.map +1 -0
- package/dist/ajv.js +7 -0
- package/dist/ajv.js.map +1 -0
- package/dist/chalk.d.ts +2 -0
- package/dist/chalk.d.ts.map +1 -0
- package/dist/chalk.js +2 -0
- package/dist/chalk.js.map +1 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +6 -0
- package/dist/constants.js.map +1 -0
- package/dist/core-plugin.d.ts +5 -0
- package/dist/core-plugin.d.ts.map +1 -0
- package/dist/core-plugin.js +38 -0
- package/dist/core-plugin.js.map +1 -0
- package/dist/emitter/action-event.d.ts +19 -0
- package/dist/emitter/action-event.d.ts.map +1 -0
- package/dist/emitter/action-event.js +2 -0
- package/dist/emitter/action-event.js.map +1 -0
- package/dist/emitter/error-event.d.ts +13 -0
- package/dist/emitter/error-event.d.ts.map +1 -0
- package/dist/emitter/error-event.js +2 -0
- package/dist/emitter/error-event.js.map +1 -0
- package/dist/emitter/events.d.ts +10 -0
- package/dist/emitter/events.d.ts.map +1 -0
- package/dist/emitter/events.js +2 -0
- package/dist/emitter/events.js.map +1 -0
- package/dist/emitter/index.d.ts +6 -0
- package/dist/emitter/index.d.ts.map +1 -0
- package/dist/emitter/index.js +6 -0
- package/dist/emitter/index.js.map +1 -0
- package/dist/emitter/thymian-emitter.d.ts +51 -0
- package/dist/emitter/thymian-emitter.d.ts.map +1 -0
- package/dist/emitter/thymian-emitter.js +306 -0
- package/dist/emitter/thymian-emitter.js.map +1 -0
- package/dist/emitter/utils.d.ts +8 -0
- package/dist/emitter/utils.d.ts.map +1 -0
- package/dist/emitter/utils.js +16 -0
- package/dist/emitter/utils.js.map +1 -0
- package/dist/events/error.event.d.ts +5 -0
- package/dist/events/error.event.d.ts.map +1 -0
- package/dist/events/error.event.js +49 -0
- package/dist/events/error.event.js.map +1 -0
- package/dist/events/exit.event.d.ts +14 -0
- package/dist/events/exit.event.d.ts.map +1 -0
- package/dist/events/exit.event.js +9 -0
- package/dist/events/exit.event.js.map +1 -0
- package/dist/events/index.d.ts +15 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +4 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/register-plugin.event.d.ts +51 -0
- package/dist/events/register-plugin.event.d.ts.map +1 -0
- package/dist/events/register-plugin.event.js +29 -0
- package/dist/events/register-plugin.event.js.map +1 -0
- package/dist/events/report.event.d.ts +28 -0
- package/dist/events/report.event.d.ts.map +1 -0
- package/dist/events/report.event.js +128 -0
- package/dist/events/report.event.js.map +1 -0
- package/dist/format/edges/edge.d.ts +8 -0
- package/dist/format/edges/edge.d.ts.map +1 -0
- package/dist/format/edges/edge.js +2 -0
- package/dist/format/edges/edge.js.map +1 -0
- package/dist/format/edges/has-sample.edge.d.ts +5 -0
- package/dist/format/edges/has-sample.edge.d.ts.map +1 -0
- package/dist/format/edges/has-sample.edge.js +2 -0
- package/dist/format/edges/has-sample.edge.js.map +1 -0
- package/dist/format/edges/http-link.edge.d.ts +10 -0
- package/dist/format/edges/http-link.edge.d.ts.map +1 -0
- package/dist/format/edges/http-link.edge.js +2 -0
- package/dist/format/edges/http-link.edge.js.map +1 -0
- package/dist/format/edges/http-transaction.edge.d.ts +5 -0
- package/dist/format/edges/http-transaction.edge.d.ts.map +1 -0
- package/dist/format/edges/http-transaction.edge.js +2 -0
- package/dist/format/edges/http-transaction.edge.js.map +1 -0
- package/dist/format/edges/is-secured-with.edge.d.ts +5 -0
- package/dist/format/edges/is-secured-with.edge.d.ts.map +1 -0
- package/dist/format/edges/is-secured-with.edge.js +2 -0
- package/dist/format/edges/is-secured-with.edge.js.map +1 -0
- package/dist/format/edges/sample-http-transaction.edge.d.ts +5 -0
- package/dist/format/edges/sample-http-transaction.edge.d.ts.map +1 -0
- package/dist/format/edges/sample-http-transaction.edge.js +2 -0
- package/dist/format/edges/sample-http-transaction.edge.js.map +1 -0
- package/dist/format/format-location.d.ts +13 -0
- package/dist/format/format-location.d.ts.map +1 -0
- package/dist/format/format-location.js +2 -0
- package/dist/format/format-location.js.map +1 -0
- package/dist/format/index.d.ts +14 -0
- package/dist/format/index.d.ts.map +1 -0
- package/dist/format/index.js +14 -0
- package/dist/format/index.js.map +1 -0
- package/dist/format/nodes/http-request.node.d.ts +29 -0
- package/dist/format/nodes/http-request.node.d.ts.map +1 -0
- package/dist/format/nodes/http-request.node.js +2 -0
- package/dist/format/nodes/http-request.node.js.map +1 -0
- package/dist/format/nodes/http-response.node.d.ts +12 -0
- package/dist/format/nodes/http-response.node.d.ts.map +1 -0
- package/dist/format/nodes/http-response.node.js +2 -0
- package/dist/format/nodes/http-response.node.js.map +1 -0
- package/dist/format/nodes/node.d.ts +8 -0
- package/dist/format/nodes/node.d.ts.map +1 -0
- package/dist/format/nodes/node.js +2 -0
- package/dist/format/nodes/node.js.map +1 -0
- package/dist/format/nodes/sample-http-request.node.d.ts +7 -0
- package/dist/format/nodes/sample-http-request.node.d.ts.map +1 -0
- package/dist/format/nodes/sample-http-request.node.js +2 -0
- package/dist/format/nodes/sample-http-request.node.js.map +1 -0
- package/dist/format/nodes/sample-http-response.node.d.ts +7 -0
- package/dist/format/nodes/sample-http-response.node.d.ts.map +1 -0
- package/dist/format/nodes/sample-http-response.node.js +2 -0
- package/dist/format/nodes/sample-http-response.node.js.map +1 -0
- package/dist/format/nodes/security-scheme.node.d.ts +17 -0
- package/dist/format/nodes/security-scheme.node.d.ts.map +1 -0
- package/dist/format/nodes/security-scheme.node.js +2 -0
- package/dist/format/nodes/security-scheme.node.js.map +1 -0
- package/dist/format/parameter.d.ts +10 -0
- package/dist/format/parameter.d.ts.map +1 -0
- package/dist/format/parameter.js +2 -0
- package/dist/format/parameter.js.map +1 -0
- package/dist/format/serialization-style/cookie.serialization-style.d.ts +5 -0
- package/dist/format/serialization-style/cookie.serialization-style.d.ts.map +1 -0
- package/dist/format/serialization-style/cookie.serialization-style.js +7 -0
- package/dist/format/serialization-style/cookie.serialization-style.js.map +1 -0
- package/dist/format/serialization-style/header.serialization-style.d.ts +5 -0
- package/dist/format/serialization-style/header.serialization-style.d.ts.map +1 -0
- package/dist/format/serialization-style/header.serialization-style.js +7 -0
- package/dist/format/serialization-style/header.serialization-style.js.map +1 -0
- package/dist/format/serialization-style/index.d.ts +6 -0
- package/dist/format/serialization-style/index.d.ts.map +1 -0
- package/dist/format/serialization-style/index.js +6 -0
- package/dist/format/serialization-style/index.js.map +1 -0
- package/dist/format/serialization-style/path.serialization-style.d.ts +5 -0
- package/dist/format/serialization-style/path.serialization-style.d.ts.map +1 -0
- package/dist/format/serialization-style/path.serialization-style.js +7 -0
- package/dist/format/serialization-style/path.serialization-style.js.map +1 -0
- package/dist/format/serialization-style/query.serialization-style.d.ts +5 -0
- package/dist/format/serialization-style/query.serialization-style.d.ts.map +1 -0
- package/dist/format/serialization-style/query.serialization-style.js +7 -0
- package/dist/format/serialization-style/query.serialization-style.js.map +1 -0
- package/dist/format/serialization-style/serialization-style.d.ts +13 -0
- package/dist/format/serialization-style/serialization-style.d.ts.map +1 -0
- package/dist/format/serialization-style/serialization-style.js +25 -0
- package/dist/format/serialization-style/serialization-style.js.map +1 -0
- package/dist/format/thymian-format.d.ts +85 -0
- package/dist/format/thymian-format.d.ts.map +1 -0
- package/dist/format/thymian-format.js +297 -0
- package/dist/format/thymian-format.js.map +1 -0
- package/dist/format/thymian-schema.d.ts +55 -0
- package/dist/format/thymian-schema.d.ts.map +1 -0
- package/dist/format/thymian-schema.js +2 -0
- package/dist/format/thymian-schema.js.map +1 -0
- package/dist/format/utils.d.ts +12 -0
- package/dist/format/utils.d.ts.map +1 -0
- package/dist/format/utils.js +81 -0
- package/dist/format/utils.js.map +1 -0
- package/dist/http-filter-visitor.d.ts +73 -0
- package/dist/http-filter-visitor.d.ts.map +1 -0
- package/dist/http-filter-visitor.js +163 -0
- package/dist/http-filter-visitor.js.map +1 -0
- package/dist/http-filter.d.ts +135 -0
- package/dist/http-filter.d.ts.map +1 -0
- package/dist/http-filter.js +132 -0
- package/dist/http-filter.js.map +1 -0
- package/dist/http-status-codes/1xx/index.d.ts +15 -0
- package/dist/http-status-codes/1xx/index.d.ts.map +1 -0
- package/dist/http-status-codes/1xx/index.js +15 -0
- package/dist/http-status-codes/1xx/index.js.map +1 -0
- package/dist/http-status-codes/1xx/informational.phrases.d.ts +4 -0
- package/dist/http-status-codes/1xx/informational.phrases.d.ts.map +1 -0
- package/dist/http-status-codes/1xx/informational.phrases.js +10 -0
- package/dist/http-status-codes/1xx/informational.phrases.js.map +1 -0
- package/dist/http-status-codes/1xx/informational.status-codes.d.ts +4 -0
- package/dist/http-status-codes/1xx/informational.status-codes.d.ts.map +1 -0
- package/dist/http-status-codes/1xx/informational.status-codes.js +5 -0
- package/dist/http-status-codes/1xx/informational.status-codes.js.map +1 -0
- package/dist/http-status-codes/2xx/index.d.ts +25 -0
- package/dist/http-status-codes/2xx/index.d.ts.map +1 -0
- package/dist/http-status-codes/2xx/index.js +25 -0
- package/dist/http-status-codes/2xx/index.js.map +1 -0
- package/dist/http-status-codes/2xx/successful.phrases.d.ts +4 -0
- package/dist/http-status-codes/2xx/successful.phrases.d.ts.map +1 -0
- package/dist/http-status-codes/2xx/successful.phrases.js +15 -0
- package/dist/http-status-codes/2xx/successful.phrases.js.map +1 -0
- package/dist/http-status-codes/2xx/successful.status-codes.d.ts +4 -0
- package/dist/http-status-codes/2xx/successful.status-codes.d.ts.map +1 -0
- package/dist/http-status-codes/2xx/successful.status-codes.js +7 -0
- package/dist/http-status-codes/2xx/successful.status-codes.js.map +1 -0
- package/dist/http-status-codes/3xx/index.d.ts +21 -0
- package/dist/http-status-codes/3xx/index.d.ts.map +1 -0
- package/dist/http-status-codes/3xx/index.js +21 -0
- package/dist/http-status-codes/3xx/index.js.map +1 -0
- package/dist/http-status-codes/3xx/redirection.phrases.d.ts +4 -0
- package/dist/http-status-codes/3xx/redirection.phrases.d.ts.map +1 -0
- package/dist/http-status-codes/3xx/redirection.phrases.js +13 -0
- package/dist/http-status-codes/3xx/redirection.phrases.js.map +1 -0
- package/dist/http-status-codes/3xx/redirection.status-codes.d.ts +4 -0
- package/dist/http-status-codes/3xx/redirection.status-codes.d.ts.map +1 -0
- package/dist/http-status-codes/3xx/redirection.status-codes.js +7 -0
- package/dist/http-status-codes/3xx/redirection.status-codes.js.map +1 -0
- package/dist/http-status-codes/4xx/client-error.phrases.d.ts +4 -0
- package/dist/http-status-codes/4xx/client-error.phrases.d.ts.map +1 -0
- package/dist/http-status-codes/4xx/client-error.phrases.js +34 -0
- package/dist/http-status-codes/4xx/client-error.phrases.js.map +1 -0
- package/dist/http-status-codes/4xx/client-error.status-codes.d.ts +4 -0
- package/dist/http-status-codes/4xx/client-error.status-codes.d.ts.map +1 -0
- package/dist/http-status-codes/4xx/client-error.status-codes.js +8 -0
- package/dist/http-status-codes/4xx/client-error.status-codes.js.map +1 -0
- package/dist/http-status-codes/4xx/index.d.ts +63 -0
- package/dist/http-status-codes/4xx/index.d.ts.map +1 -0
- package/dist/http-status-codes/4xx/index.js +63 -0
- package/dist/http-status-codes/4xx/index.js.map +1 -0
- package/dist/http-status-codes/5xx/index.d.ts +29 -0
- package/dist/http-status-codes/5xx/index.d.ts.map +1 -0
- package/dist/http-status-codes/5xx/index.js +29 -0
- package/dist/http-status-codes/5xx/index.js.map +1 -0
- package/dist/http-status-codes/5xx/server-error.phrases.d.ts +4 -0
- package/dist/http-status-codes/5xx/server-error.phrases.d.ts.map +1 -0
- package/dist/http-status-codes/5xx/server-error.phrases.js +17 -0
- package/dist/http-status-codes/5xx/server-error.phrases.js.map +1 -0
- package/dist/http-status-codes/5xx/server-error.status-codes.d.ts +4 -0
- package/dist/http-status-codes/5xx/server-error.status-codes.d.ts.map +1 -0
- package/dist/http-status-codes/5xx/server-error.status-codes.js +7 -0
- package/dist/http-status-codes/5xx/server-error.status-codes.js.map +1 -0
- package/dist/http-status-codes/http-status-code-ranges.d.ts +11 -0
- package/dist/http-status-codes/http-status-code-ranges.d.ts.map +1 -0
- package/dist/http-status-codes/http-status-code-ranges.js +19 -0
- package/dist/http-status-codes/http-status-code-ranges.js.map +1 -0
- package/dist/http-status-codes/http-status-code.d.ts +8 -0
- package/dist/http-status-codes/http-status-code.d.ts.map +1 -0
- package/dist/http-status-codes/http-status-code.js +13 -0
- package/dist/http-status-codes/http-status-code.js.map +1 -0
- package/dist/http-status-codes/http-status-phrase.d.ts +8 -0
- package/dist/http-status-codes/http-status-phrase.d.ts.map +1 -0
- package/dist/http-status-codes/http-status-phrase.js +13 -0
- package/dist/http-status-codes/http-status-phrase.js.map +1 -0
- package/dist/http-status-codes/index.d.ts +10 -0
- package/dist/http-status-codes/index.d.ts.map +1 -0
- package/dist/http-status-codes/index.js +10 -0
- package/dist/http-status-codes/index.js.map +1 -0
- package/dist/http-status-codes/phrase-to-status-code.d.ts +62 -0
- package/dist/http-status-codes/phrase-to-status-code.d.ts.map +1 -0
- package/dist/http-status-codes/phrase-to-status-code.js +13 -0
- package/dist/http-status-codes/phrase-to-status-code.js.map +1 -0
- package/dist/http-status-codes/status-code-to-phrase.d.ts +62 -0
- package/dist/http-status-codes/status-code-to-phrase.d.ts.map +1 -0
- package/dist/http-status-codes/status-code-to-phrase.js +13 -0
- package/dist/http-status-codes/status-code-to-phrase.js.map +1 -0
- package/dist/http-status-codes/validate.d.ts +5 -0
- package/dist/http-status-codes/validate.d.ts.map +1 -0
- package/dist/http-status-codes/validate.js +28 -0
- package/dist/http-status-codes/validate.js.map +1 -0
- package/dist/http.d.ts +29 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +2 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/logger.d.ts +12 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logger/logger.js +2 -0
- package/dist/logger/logger.js.map +1 -0
- package/dist/logger/noop.logger.d.ts +14 -0
- package/dist/logger/noop.logger.d.ts.map +1 -0
- package/dist/logger/noop.logger.js +18 -0
- package/dist/logger/noop.logger.js.map +1 -0
- package/dist/logger/text.logger.d.ts +15 -0
- package/dist/logger/text.logger.d.ts.map +1 -0
- package/dist/logger/text.logger.js +41 -0
- package/dist/logger/text.logger.js.map +1 -0
- package/dist/thymian-plugin.d.ts +38 -0
- package/dist/thymian-plugin.d.ts.map +1 -0
- package/dist/thymian-plugin.js +22 -0
- package/dist/thymian-plugin.js.map +1 -0
- package/dist/thymian.d.ts +33 -0
- package/dist/thymian.d.ts.map +1 -0
- package/dist/thymian.error.d.ts +26 -0
- package/dist/thymian.error.d.ts.map +1 -0
- package/dist/thymian.error.js +34 -0
- package/dist/thymian.error.js.map +1 -0
- package/dist/thymian.js +148 -0
- package/dist/thymian.js.map +1 -0
- package/dist/utils.d.ts +34 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +115 -0
- package/dist/utils.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SerializationStyleBuilder } from './serialization-style.js';
|
|
2
|
+
export declare class QuerySerializationStyleBuilder extends SerializationStyleBuilder<'form' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject'> {
|
|
3
|
+
constructor();
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=query.serialization-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.serialization-style.d.ts","sourceRoot":"","sources":["../../../src/format/serialization-style/query.serialization-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,qBAAa,8BAA+B,SAAQ,yBAAyB,CAC3E,MAAM,GAAG,gBAAgB,GAAG,eAAe,GAAG,YAAY,CAC3D;;CAIA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.serialization-style.js","sourceRoot":"","sources":["../../../src/format/serialization-style/query.serialization-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,MAAM,OAAO,8BAA+B,SAAQ,yBAEnD;IACC;QACE,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type Style = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
|
|
2
|
+
export interface SerializationStyle {
|
|
3
|
+
explode: boolean;
|
|
4
|
+
style: Style;
|
|
5
|
+
}
|
|
6
|
+
export declare class SerializationStyleBuilder<T extends Style = Style> {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(style?: T, explode?: boolean);
|
|
9
|
+
withExplode(explode?: boolean): this;
|
|
10
|
+
withStyle(style?: T | string): this;
|
|
11
|
+
build(): SerializationStyle;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=serialization-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization-style.d.ts","sourceRoot":"","sources":["../../../src/format/serialization-style/serialization-style.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,KAAK,GACb,QAAQ,GACR,OAAO,GACP,MAAM,GACN,QAAQ,GACR,gBAAgB,GAChB,eAAe,GACf,YAAY,CAAC;AAEjB,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IAEjB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,qBAAa,yBAAyB,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK;;gBAGhD,KAAK,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO;IAOxC,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI;IAOpC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,MAAM,GAAG,IAAI;IAOnC,KAAK,IAAI,kBAAkB;CAG5B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class SerializationStyleBuilder {
|
|
2
|
+
#result;
|
|
3
|
+
constructor(style, explode) {
|
|
4
|
+
this.#result = {
|
|
5
|
+
style: style ?? 'form',
|
|
6
|
+
explode: explode ?? false,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
withExplode(explode) {
|
|
10
|
+
if (typeof explode === 'boolean') {
|
|
11
|
+
this.#result.explode = explode;
|
|
12
|
+
}
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
withStyle(style) {
|
|
16
|
+
if (typeof style === 'string') {
|
|
17
|
+
this.#result.style = style;
|
|
18
|
+
}
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
build() {
|
|
22
|
+
return this.#result;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=serialization-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization-style.js","sourceRoot":"","sources":["../../../src/format/serialization-style/serialization-style.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,yBAAyB;IAC3B,OAAO,CAAqB;IAErC,YAAY,KAAS,EAAE,OAAiB;QACtC,IAAI,CAAC,OAAO,GAAG;YACb,KAAK,EAAE,KAAK,IAAK,MAAY;YAC7B,OAAO,EAAE,OAAO,IAAI,KAAK;SAC1B,CAAC;IACJ,CAAC;IAED,WAAW,CAAC,OAAiB;QAC3B,IAAI,OAAO,OAAO,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;QACjC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS,CAAC,KAAkB;QAC1B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,KAAU,CAAC;QAClC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { MultiDirectedGraph } from 'graphology';
|
|
2
|
+
import type { SerializedGraph } from 'graphology-types';
|
|
3
|
+
import type { HttpRequest, HttpResponse } from '../http.js';
|
|
4
|
+
import { type PartialBy } from '../utils.js';
|
|
5
|
+
import { type StringAndNumberProperties } from '../utils.js';
|
|
6
|
+
import type { HasSample } from './edges/has-sample.edge.js';
|
|
7
|
+
import type { HttpLink } from './edges/http-link.edge.js';
|
|
8
|
+
import type { HttpTransaction } from './edges/http-transaction.edge.js';
|
|
9
|
+
import type { IsSecuredWith } from './edges/is-secured-with.edge.js';
|
|
10
|
+
import type { SampleHttpTransaction } from './edges/sample-http-transaction.edge.js';
|
|
11
|
+
import type { ThymianHttpRequest } from './nodes/http-request.node.js';
|
|
12
|
+
import type { ThymianHttpResponse } from './nodes/http-response.node.js';
|
|
13
|
+
import type { SampleHttpRequest } from './nodes/sample-http-request.node.js';
|
|
14
|
+
import type { SampleHttpResponse } from './nodes/sample-http-response.node.js';
|
|
15
|
+
import type { SecurityScheme } from './nodes/security-scheme.node.js';
|
|
16
|
+
export type MatchResult = {
|
|
17
|
+
reqId: string;
|
|
18
|
+
parameters: Partial<Record<string, string | string[]>>;
|
|
19
|
+
};
|
|
20
|
+
export declare function isNodeType<T extends ThymianNodeType>(node: ThymianNode, type: T): node is ThymianNodes[T];
|
|
21
|
+
export declare function isEdgeType<T extends ThymianEdgeType>(edge: ThymianEdge, type: T): edge is ThymianEdges[T];
|
|
22
|
+
export interface ThymianNodes {
|
|
23
|
+
'http-request': ThymianHttpRequest;
|
|
24
|
+
'http-response': ThymianHttpResponse;
|
|
25
|
+
'security-scheme': SecurityScheme;
|
|
26
|
+
'sample-http-request': SampleHttpRequest;
|
|
27
|
+
'sample-http-response': SampleHttpResponse;
|
|
28
|
+
}
|
|
29
|
+
export interface ThymianEdges {
|
|
30
|
+
'http-link': HttpLink;
|
|
31
|
+
'http-transaction': HttpTransaction;
|
|
32
|
+
'is-secured': IsSecuredWith;
|
|
33
|
+
'sample-http-transaction': SampleHttpTransaction;
|
|
34
|
+
'has-sample': HasSample;
|
|
35
|
+
}
|
|
36
|
+
export type ThymianHttpTransaction = {
|
|
37
|
+
thymianReq: ThymianHttpRequest;
|
|
38
|
+
thymianReqId: string;
|
|
39
|
+
thymianRes: ThymianHttpResponse;
|
|
40
|
+
thymianResId: string;
|
|
41
|
+
transactionId: string;
|
|
42
|
+
transaction: HttpTransaction;
|
|
43
|
+
};
|
|
44
|
+
export type ThymianNode = ThymianNodes[keyof ThymianNodes];
|
|
45
|
+
export type ThymianEdge = ThymianEdges[keyof ThymianEdges];
|
|
46
|
+
export type ThymianNodeType = keyof ThymianNodes;
|
|
47
|
+
export type ThymianEdgeType = keyof ThymianEdges;
|
|
48
|
+
export type ThymianGraph = MultiDirectedGraph<ThymianNode, ThymianEdge>;
|
|
49
|
+
export type SerializedThymianFormat = SerializedGraph<ThymianNode, ThymianEdge>;
|
|
50
|
+
export declare function thymianHttpRequestToLabel(req: PartialBy<ThymianHttpRequest, 'label'>): string;
|
|
51
|
+
export declare function thymianHttpResponseToLabel(res: PartialBy<ThymianHttpResponse, 'label'>): string;
|
|
52
|
+
export declare class ThymianFormat {
|
|
53
|
+
readonly graph: ThymianGraph;
|
|
54
|
+
constructor(graph?: ThymianGraph);
|
|
55
|
+
addEdge(source: string, target: string, edge: PartialBy<ThymianEdge, 'label'>): string;
|
|
56
|
+
addHttpLink(source: string, target: string, edge: PartialBy<HttpLink, 'type' | 'label'>): string;
|
|
57
|
+
addResponseToRequest(requestId: string, response: PartialBy<ThymianHttpResponse, 'label'>, transaction?: Partial<HttpTransaction>): [string, string];
|
|
58
|
+
addHttpTransaction(request: PartialBy<ThymianHttpRequest, 'label'>, response: PartialBy<ThymianHttpResponse, 'label'>): [string, string, string];
|
|
59
|
+
addSecurityScheme(scheme: PartialBy<SecurityScheme, 'label'>): string;
|
|
60
|
+
addRequest(request: PartialBy<ThymianHttpRequest, 'label'>): string;
|
|
61
|
+
private addResponse;
|
|
62
|
+
addNode(node: ThymianNode, id?: string): string;
|
|
63
|
+
getNode<T extends ThymianNode = ThymianNode>(id: string): T | undefined;
|
|
64
|
+
getEdge<T extends ThymianEdge = ThymianEdge>(id: string): T | undefined;
|
|
65
|
+
findNodeByExtension(extensionName: string, values: Record<PropertyKey, string | number | boolean>): ThymianNode | undefined;
|
|
66
|
+
requestIsSecured(reqId: string): boolean;
|
|
67
|
+
getHttpResponsesOf(reqId: string): [string, ThymianHttpResponse, string][];
|
|
68
|
+
getNeighboursOfType<Type extends ThymianNodeType>(id: string, type: Type): [string, ThymianNodes[Type]][];
|
|
69
|
+
getNodesByExtension(extensionName: string, values: Record<PropertyKey, string | number | boolean>): ThymianNode[];
|
|
70
|
+
getHttpTransactions(): [string, string, string][];
|
|
71
|
+
getThymianHttpTransactions(): ThymianHttpTransaction[];
|
|
72
|
+
matchTransaction(req: HttpRequest, res: HttpResponse): [string, string, string] | undefined;
|
|
73
|
+
matchHtpRequestByUrl(url: string): MatchResult | undefined;
|
|
74
|
+
findNode<Type extends ThymianNodeType>(type: Type, properties: StringAndNumberProperties<ThymianNodes[Type]>): ThymianNodes[Type] | undefined;
|
|
75
|
+
addSampleHttpRequest(request: HttpRequest): string;
|
|
76
|
+
addSampleHttpResponse(response: HttpResponse): string;
|
|
77
|
+
addSampleHttpTransaction(request: HttpRequest, response: HttpResponse): [string, string, string];
|
|
78
|
+
export(): SerializedThymianFormat;
|
|
79
|
+
toJSON(): SerializedThymianFormat;
|
|
80
|
+
merge(format: ThymianFormat): ThymianFormat;
|
|
81
|
+
static fromHttpTransactions(transactions: [HttpRequest, HttpResponse][]): ThymianFormat;
|
|
82
|
+
static import(graph: SerializedThymianFormat): ThymianFormat;
|
|
83
|
+
private hash;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=thymian-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thymian-format.d.ts","sourceRoot":"","sources":["../../src/format/thymian-format.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM5D,OAAO,EAOL,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAgB,KAAK,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KA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
import { match } from 'path-to-regexp';
|
|
4
|
+
import { httpStatusCodeToPhrase, isValidHttpStatusCode, } from '../http-status-codes/index.js';
|
|
5
|
+
import { ThymianBaseError } from '../thymian.error.js';
|
|
6
|
+
import { capitalizeFirstChar, equalsIgnoreCase, getContentType, httpRequestToLabel, httpResponseToLabel, normalizeUrl, thymianRequestToOrigin, } from '../utils.js';
|
|
7
|
+
import { matchObjects } from '../utils.js';
|
|
8
|
+
import { httpRequestToThymianHttpRequest, httpResponseToThymianHttpResponse, } from './utils.js';
|
|
9
|
+
export function isNodeType(node, type) {
|
|
10
|
+
return node.type === type;
|
|
11
|
+
}
|
|
12
|
+
export function isEdgeType(edge, type) {
|
|
13
|
+
return edge.type === type;
|
|
14
|
+
}
|
|
15
|
+
export function thymianHttpRequestToLabel(req) {
|
|
16
|
+
const label = `${req.method.toUpperCase()} ${req.protocol}://${req.host}:${req.port}${req.path.startsWith('/') ? req.path : '/' + req.path}`;
|
|
17
|
+
return req.mediaType ? label + ` - ${req.mediaType}` : label;
|
|
18
|
+
}
|
|
19
|
+
export function thymianHttpResponseToLabel(res) {
|
|
20
|
+
const statusCode = res.statusCode;
|
|
21
|
+
const phrase = isValidHttpStatusCode(statusCode)
|
|
22
|
+
? httpStatusCodeToPhrase[statusCode]
|
|
23
|
+
: '';
|
|
24
|
+
const label = `${statusCode} ${phrase.toUpperCase()}`;
|
|
25
|
+
return res.mediaType ? label + ` - ${res.mediaType}` : label;
|
|
26
|
+
}
|
|
27
|
+
export class ThymianFormat {
|
|
28
|
+
graph;
|
|
29
|
+
constructor(graph = new MultiDirectedGraph()) {
|
|
30
|
+
this.graph = graph;
|
|
31
|
+
}
|
|
32
|
+
addEdge(source, target, edge) {
|
|
33
|
+
return this.graph.addEdge(source, target, {
|
|
34
|
+
label: edge.type,
|
|
35
|
+
...edge,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
addHttpLink(source, target, edge) {
|
|
39
|
+
const res = this.getNode(source);
|
|
40
|
+
const req = this.getNode(target);
|
|
41
|
+
if (!res || !req) {
|
|
42
|
+
throw new ThymianBaseError('Invalid HTTP link.', {
|
|
43
|
+
name: 'InvalidHttpLink',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const label = `${thymianHttpResponseToLabel(res)} \u2192 ${thymianHttpRequestToLabel(req)}`;
|
|
47
|
+
return this.addEdge(source, target, {
|
|
48
|
+
label,
|
|
49
|
+
...edge,
|
|
50
|
+
type: 'http-link',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
addResponseToRequest(requestId, response, transaction = {}) {
|
|
54
|
+
const req = this.getNode(requestId);
|
|
55
|
+
if (!req) {
|
|
56
|
+
throw new Error(`Invalid request ID${requestId}. Cannot add response to request.`);
|
|
57
|
+
}
|
|
58
|
+
const resLabel = thymianHttpResponseToLabel(response);
|
|
59
|
+
const resId = this.addResponse({ ...response, label: resLabel }, this.hash(req.label + resLabel));
|
|
60
|
+
return [
|
|
61
|
+
resId,
|
|
62
|
+
this.addEdge(requestId, resId, {
|
|
63
|
+
type: 'http-transaction',
|
|
64
|
+
...transaction,
|
|
65
|
+
label: `${req.label} \u2192 ${resLabel}`,
|
|
66
|
+
}),
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
addHttpTransaction(request, response) {
|
|
70
|
+
const reqLabel = thymianHttpRequestToLabel(request);
|
|
71
|
+
const resLabel = thymianHttpResponseToLabel(response);
|
|
72
|
+
const reqId = this.hash(reqLabel);
|
|
73
|
+
if (!this.graph.hasNode(reqId)) {
|
|
74
|
+
this.addRequest({ ...request, label: reqLabel });
|
|
75
|
+
}
|
|
76
|
+
const resId = this.addResponse({ ...response, label: resLabel }, this.hash(reqLabel + resLabel));
|
|
77
|
+
return [
|
|
78
|
+
reqId,
|
|
79
|
+
resId,
|
|
80
|
+
this.addEdge(reqId, resId, {
|
|
81
|
+
type: 'http-transaction',
|
|
82
|
+
label: `${reqLabel} \u2192 ${resLabel}`,
|
|
83
|
+
}),
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
addSecurityScheme(scheme) {
|
|
87
|
+
let label = capitalizeFirstChar(scheme.scheme);
|
|
88
|
+
if (scheme.scheme === 'bearer' && 'bearerFormat' in scheme) {
|
|
89
|
+
label += scheme.bearerFormat;
|
|
90
|
+
}
|
|
91
|
+
else if (scheme.scheme === 'api-key' && 'in' in scheme) {
|
|
92
|
+
label += scheme.in;
|
|
93
|
+
}
|
|
94
|
+
label += 'Auth';
|
|
95
|
+
return this.addNode({
|
|
96
|
+
label,
|
|
97
|
+
...scheme,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
addRequest(request) {
|
|
101
|
+
const label = thymianHttpRequestToLabel(request);
|
|
102
|
+
return this.addNode({
|
|
103
|
+
label,
|
|
104
|
+
...request,
|
|
105
|
+
type: 'http-request',
|
|
106
|
+
}, this.hash(label));
|
|
107
|
+
}
|
|
108
|
+
addResponse(response, id) {
|
|
109
|
+
const label = thymianHttpResponseToLabel(response);
|
|
110
|
+
return this.addNode({
|
|
111
|
+
label,
|
|
112
|
+
...response,
|
|
113
|
+
type: 'http-response',
|
|
114
|
+
}, id);
|
|
115
|
+
}
|
|
116
|
+
addNode(node, id = randomUUID()) {
|
|
117
|
+
return this.graph.addNode(id, node);
|
|
118
|
+
}
|
|
119
|
+
getNode(id) {
|
|
120
|
+
return this.graph.getNodeAttributes(id);
|
|
121
|
+
}
|
|
122
|
+
getEdge(id) {
|
|
123
|
+
return this.graph.getEdgeAttributes(id);
|
|
124
|
+
}
|
|
125
|
+
findNodeByExtension(extensionName, values) {
|
|
126
|
+
const id = this.graph.findNode((id, attributes) => attributes.extensions &&
|
|
127
|
+
extensionName in attributes.extensions &&
|
|
128
|
+
matchObjects(attributes.extensions[extensionName], values));
|
|
129
|
+
return this.graph.getNodeAttributes(id);
|
|
130
|
+
}
|
|
131
|
+
requestIsSecured(reqId) {
|
|
132
|
+
return !!this.graph.findOutEdge(reqId, (_, edge) => isEdgeType(edge, 'is-secured'));
|
|
133
|
+
}
|
|
134
|
+
getHttpResponsesOf(reqId) {
|
|
135
|
+
return this.graph.reduceOutNeighbors(reqId, (acc, id, attributes) => {
|
|
136
|
+
if (isNodeType(attributes, 'http-response')) {
|
|
137
|
+
const transactionId = this.graph.findEdge(reqId, id, (_, edge) => edge.type === 'http-transaction');
|
|
138
|
+
if (!transactionId) {
|
|
139
|
+
throw new Error('Invalid HTTP transaction.');
|
|
140
|
+
}
|
|
141
|
+
acc.push([id, attributes, transactionId]);
|
|
142
|
+
}
|
|
143
|
+
return acc;
|
|
144
|
+
}, []);
|
|
145
|
+
}
|
|
146
|
+
getNeighboursOfType(id, type) {
|
|
147
|
+
return this.graph.reduceNeighbors(id, (acc, id, node) => {
|
|
148
|
+
if (isNodeType(node, type)) {
|
|
149
|
+
acc.push([id, node]);
|
|
150
|
+
}
|
|
151
|
+
return acc;
|
|
152
|
+
}, []);
|
|
153
|
+
}
|
|
154
|
+
getNodesByExtension(extensionName, values) {
|
|
155
|
+
return this.graph.reduceNodes((acc, _, attributes) => {
|
|
156
|
+
if (attributes.extensions &&
|
|
157
|
+
extensionName in attributes.extensions &&
|
|
158
|
+
matchObjects(attributes.extensions[extensionName], values)) {
|
|
159
|
+
acc.push(attributes);
|
|
160
|
+
}
|
|
161
|
+
return acc;
|
|
162
|
+
}, []);
|
|
163
|
+
}
|
|
164
|
+
getHttpTransactions() {
|
|
165
|
+
return this.graph.reduceEdges((transactions, id, edge, source, target) => {
|
|
166
|
+
if (edge.type === 'http-transaction') {
|
|
167
|
+
transactions.push([source, target, id]);
|
|
168
|
+
}
|
|
169
|
+
return transactions;
|
|
170
|
+
}, []);
|
|
171
|
+
}
|
|
172
|
+
getThymianHttpTransactions() {
|
|
173
|
+
return this.graph.reduceEdges((transactions, id, edge, sourceId, targetId, source, target) => {
|
|
174
|
+
if (isEdgeType(edge, 'http-transaction')) {
|
|
175
|
+
transactions.push({
|
|
176
|
+
thymianReq: source,
|
|
177
|
+
thymianReqId: sourceId,
|
|
178
|
+
thymianRes: target,
|
|
179
|
+
thymianResId: targetId,
|
|
180
|
+
transactionId: id,
|
|
181
|
+
transaction: edge,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return transactions;
|
|
185
|
+
}, []);
|
|
186
|
+
}
|
|
187
|
+
matchTransaction(req, res) {
|
|
188
|
+
const edgeId = this.graph.findEdge((id, edge, sourceId, targetId, source, target) => {
|
|
189
|
+
if (!isEdgeType(edge, 'http-transaction'))
|
|
190
|
+
return false;
|
|
191
|
+
const thymianReq = source;
|
|
192
|
+
const thymianRes = target;
|
|
193
|
+
const origin = thymianRequestToOrigin(thymianReq);
|
|
194
|
+
const reqMediaType = getContentType(req.headers);
|
|
195
|
+
const resMediaType = getContentType(res.headers);
|
|
196
|
+
const reqOriginUrl = normalizeUrl(req.origin);
|
|
197
|
+
return (equalsIgnoreCase(thymianReq.method, req.method) &&
|
|
198
|
+
equalsIgnoreCase(thymianReq.path, req.path) &&
|
|
199
|
+
equalsIgnoreCase(origin, reqOriginUrl.toString()) &&
|
|
200
|
+
thymianRes.statusCode === res.statusCode &&
|
|
201
|
+
equalsIgnoreCase(reqMediaType, thymianReq.mediaType) &&
|
|
202
|
+
equalsIgnoreCase(resMediaType, thymianRes.mediaType));
|
|
203
|
+
});
|
|
204
|
+
if (!edgeId) {
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
return [edgeId, ...this.graph.extremities(edgeId)];
|
|
208
|
+
}
|
|
209
|
+
matchHtpRequestByUrl(url) {
|
|
210
|
+
let urlObj;
|
|
211
|
+
if (/^(http|https)/.test(url)) {
|
|
212
|
+
urlObj = new URL(url);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
urlObj = new URL('http://localhost:8080' + url);
|
|
216
|
+
}
|
|
217
|
+
const pathname = urlObj.pathname;
|
|
218
|
+
return this.graph.reduceNodes((result, id, node) => {
|
|
219
|
+
if (isNodeType(node, 'http-request')) {
|
|
220
|
+
const path = node.path.replaceAll(/{([^}]+)}/gi, ':$1');
|
|
221
|
+
const matchFn = match(path);
|
|
222
|
+
const r = matchFn(pathname);
|
|
223
|
+
if (r) {
|
|
224
|
+
result = {
|
|
225
|
+
reqId: id,
|
|
226
|
+
parameters: r.params,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return result;
|
|
231
|
+
}, undefined);
|
|
232
|
+
}
|
|
233
|
+
findNode(type, properties) {
|
|
234
|
+
const nodeId = this.graph.findNode((id, node) => isNodeType(node, type) && matchObjects(node, properties));
|
|
235
|
+
if (typeof nodeId === 'undefined') {
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
return this.getNode(nodeId);
|
|
239
|
+
}
|
|
240
|
+
addSampleHttpRequest(request) {
|
|
241
|
+
return this.addNode({
|
|
242
|
+
type: 'sample-http-request',
|
|
243
|
+
label: httpRequestToLabel(request),
|
|
244
|
+
sample: request,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
addSampleHttpResponse(response) {
|
|
248
|
+
return this.addNode({
|
|
249
|
+
type: 'sample-http-response',
|
|
250
|
+
label: httpResponseToLabel(response),
|
|
251
|
+
sample: response,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
addSampleHttpTransaction(request, response) {
|
|
255
|
+
const reqId = this.addSampleHttpRequest(request);
|
|
256
|
+
const resId = this.addSampleHttpResponse(response);
|
|
257
|
+
const transactionId = this.addEdge(reqId, reqId, {
|
|
258
|
+
type: 'sample-http-transaction',
|
|
259
|
+
label: `Sample HTTP Transaction`,
|
|
260
|
+
});
|
|
261
|
+
return [reqId, resId, transactionId];
|
|
262
|
+
}
|
|
263
|
+
export() {
|
|
264
|
+
return this.graph.export();
|
|
265
|
+
}
|
|
266
|
+
toJSON() {
|
|
267
|
+
return this.export();
|
|
268
|
+
}
|
|
269
|
+
// TODO must implement this feature. But before we should think about the node and edge ID generation
|
|
270
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
271
|
+
merge(format) {
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
static fromHttpTransactions(transactions) {
|
|
275
|
+
const format = new ThymianFormat();
|
|
276
|
+
for (const [req, res] of transactions) {
|
|
277
|
+
const thymianReq = httpRequestToThymianHttpRequest(req);
|
|
278
|
+
const thymianRes = httpResponseToThymianHttpResponse(res);
|
|
279
|
+
const [sampleReqId, sampleResId] = format.addSampleHttpTransaction(req, res);
|
|
280
|
+
const [reqId, resId] = format.addHttpTransaction(thymianReq, thymianRes);
|
|
281
|
+
format.addEdge(reqId, sampleReqId, {
|
|
282
|
+
type: 'has-sample',
|
|
283
|
+
});
|
|
284
|
+
format.addEdge(resId, sampleResId, {
|
|
285
|
+
type: 'has-sample',
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
return format;
|
|
289
|
+
}
|
|
290
|
+
static import(graph) {
|
|
291
|
+
return new ThymianFormat(new MultiDirectedGraph().import(graph));
|
|
292
|
+
}
|
|
293
|
+
hash(input) {
|
|
294
|
+
return createHash('sha1').update(input).digest('hex');
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=thymian-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thymian-format.js","sourceRoot":"","sources":["../../src/format/thymian-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EAEZ,sBAAsB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|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type ThymianSchemaType = 'null' | 'boolean' | 'object' | 'array' | 'number' | 'string' | 'integer';
|
|
2
|
+
export type ThymianSchema = {
|
|
3
|
+
type?: ThymianSchemaType | ThymianSchemaType[];
|
|
4
|
+
const?: unknown;
|
|
5
|
+
enum?: unknown[];
|
|
6
|
+
examples?: unknown[];
|
|
7
|
+
default?: unknown;
|
|
8
|
+
multipleOf?: number;
|
|
9
|
+
maximum?: number;
|
|
10
|
+
exclusiveMaximum?: number;
|
|
11
|
+
minimum?: number;
|
|
12
|
+
exclusiveMinimum?: number;
|
|
13
|
+
maxLength?: number;
|
|
14
|
+
minLength?: number;
|
|
15
|
+
pattern?: string;
|
|
16
|
+
format?: string;
|
|
17
|
+
contentEncoding?: string;
|
|
18
|
+
contentMediaType?: string;
|
|
19
|
+
prefixItems?: ThymianSchema[];
|
|
20
|
+
items?: ThymianSchema;
|
|
21
|
+
contains?: ThymianSchema;
|
|
22
|
+
minItems?: number;
|
|
23
|
+
maxItems?: number;
|
|
24
|
+
uniqueItems?: boolean;
|
|
25
|
+
minContains?: number;
|
|
26
|
+
maxContains?: number;
|
|
27
|
+
properties?: Record<string, ThymianSchema>;
|
|
28
|
+
patternProperties?: Record<string, ThymianSchema>;
|
|
29
|
+
additionalProperties?: ThymianSchema | boolean;
|
|
30
|
+
propertyNames?: ThymianSchema;
|
|
31
|
+
required?: string[];
|
|
32
|
+
minProperties?: number;
|
|
33
|
+
maxProperties?: number;
|
|
34
|
+
dependentSchemas?: Record<string, ThymianSchema>;
|
|
35
|
+
dependentRequired?: Record<string, string[]>;
|
|
36
|
+
allOf?: ThymianSchema[];
|
|
37
|
+
anyOf?: ThymianSchema[];
|
|
38
|
+
oneOf?: ThymianSchema[];
|
|
39
|
+
not?: ThymianSchema;
|
|
40
|
+
if?: ThymianSchema;
|
|
41
|
+
then?: ThymianSchema;
|
|
42
|
+
else?: ThymianSchema;
|
|
43
|
+
unevaluatedProperties?: ThymianSchema | boolean;
|
|
44
|
+
unevaluatedItems?: ThymianSchema | boolean;
|
|
45
|
+
$ref?: string;
|
|
46
|
+
$anchor?: string;
|
|
47
|
+
xml?: {
|
|
48
|
+
name?: string;
|
|
49
|
+
namespace?: string;
|
|
50
|
+
prefix?: string;
|
|
51
|
+
attribute?: string;
|
|
52
|
+
wrapped?: boolean;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=thymian-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thymian-schema.d.ts","sourceRoot":"","sources":["../../src/format/thymian-schema.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,SAAS,GACT,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,MAAM,aAAa,GAAG;IAE1B,IAAI,CAAC,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IAEjB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAGlB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAG1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAG1B,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B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AAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thymian-schema.js","sourceRoot":"","sources":["../../src/format/thymian-schema.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HttpRequest, HttpResponse } from '../http.js';
|
|
2
|
+
import { type PartialBy } from '../utils.js';
|
|
3
|
+
import type { ThymianHttpRequest } from './nodes/http-request.node.js';
|
|
4
|
+
import type { ThymianHttpResponse } from './nodes/http-response.node.js';
|
|
5
|
+
import type { Parameter } from './parameter.js';
|
|
6
|
+
import type { SerializationStyle } from './serialization-style/index.js';
|
|
7
|
+
export declare function extractSchemaForValue(value: string): 'string' | 'integer' | 'number' | 'boolean';
|
|
8
|
+
export declare function valueToParameter(value: string | string[] | undefined, style: SerializationStyle): Parameter | undefined;
|
|
9
|
+
export declare function parameterValuesToParameters(values: Record<string, string | string[] | undefined>, style: SerializationStyle): Record<string, Parameter>;
|
|
10
|
+
export declare function httpRequestToThymianHttpRequest(request: HttpRequest): PartialBy<ThymianHttpRequest, 'label'>;
|
|
11
|
+
export declare function httpResponseToThymianHttpResponse(response: HttpResponse): ThymianHttpResponse;
|
|
12
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/format/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,GACZ,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAc7C;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACpC,KAAK,EAAE,kBAAkB,GACxB,SAAS,GAAG,SAAS,CAwBvB;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,EACrD,KAAK,EAAE,kBAAkB,GACxB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAe3B;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,WAAW,GACnB,SAAS,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAmBxC;AAED,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,YAAY,GACrB,mBAAmB,CAoBrB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { DEFAULT_HEADER_SERIALIZATION_STYLE } from '../constants.js';
|
|
2
|
+
import { equalsIgnoreCase, getContentType, getHeader, } from '../utils.js';
|
|
3
|
+
export function extractSchemaForValue(value) {
|
|
4
|
+
if (!isNaN(parseInt(value))) {
|
|
5
|
+
return 'integer';
|
|
6
|
+
}
|
|
7
|
+
if (!isNaN(parseFloat(value))) {
|
|
8
|
+
return 'number';
|
|
9
|
+
}
|
|
10
|
+
if (value === 'true' || value === 'false') {
|
|
11
|
+
return 'boolean';
|
|
12
|
+
}
|
|
13
|
+
return 'string';
|
|
14
|
+
}
|
|
15
|
+
export function valueToParameter(value, style) {
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
return {
|
|
18
|
+
required: true,
|
|
19
|
+
schema: {
|
|
20
|
+
type: extractSchemaForValue(value[0] ?? ''),
|
|
21
|
+
examples: value,
|
|
22
|
+
},
|
|
23
|
+
style,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (typeof value === 'string') {
|
|
27
|
+
return {
|
|
28
|
+
required: false,
|
|
29
|
+
schema: {
|
|
30
|
+
type: extractSchemaForValue(value),
|
|
31
|
+
examples: [value],
|
|
32
|
+
},
|
|
33
|
+
style,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
export function parameterValuesToParameters(values, style) {
|
|
39
|
+
return Object.entries(values).reduce((acc, [key, value]) => {
|
|
40
|
+
if (equalsIgnoreCase(key, 'content-type'))
|
|
41
|
+
return acc;
|
|
42
|
+
const parameter = valueToParameter(value, style);
|
|
43
|
+
if (!parameter)
|
|
44
|
+
return acc;
|
|
45
|
+
acc[key] = parameter;
|
|
46
|
+
return acc;
|
|
47
|
+
}, {});
|
|
48
|
+
}
|
|
49
|
+
export function httpRequestToThymianHttpRequest(request) {
|
|
50
|
+
const url = new URL(request.path, request.origin);
|
|
51
|
+
return {
|
|
52
|
+
host: url.host,
|
|
53
|
+
mediaType: getContentType(request.headers),
|
|
54
|
+
method: request.method,
|
|
55
|
+
path: request.path,
|
|
56
|
+
port: parseInt(url.port) || (url.protocol === 'https:' ? 443 : 80),
|
|
57
|
+
protocol: url.protocol === 'https:' ? 'https' : 'http',
|
|
58
|
+
type: 'http-request',
|
|
59
|
+
cookies: {},
|
|
60
|
+
headers: parameterValuesToParameters(request.headers ?? {}, DEFAULT_HEADER_SERIALIZATION_STYLE),
|
|
61
|
+
pathParameters: {},
|
|
62
|
+
queryParameters: {},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export function httpResponseToThymianHttpResponse(response) {
|
|
66
|
+
const thymianHttpResponse = {
|
|
67
|
+
type: 'http-response',
|
|
68
|
+
label: '',
|
|
69
|
+
statusCode: response.statusCode,
|
|
70
|
+
mediaType: getContentType(response.headers),
|
|
71
|
+
headers: parameterValuesToParameters(response.headers ?? {}, DEFAULT_HEADER_SERIALIZATION_STYLE),
|
|
72
|
+
};
|
|
73
|
+
if (response.body) {
|
|
74
|
+
thymianHttpResponse.schema = {
|
|
75
|
+
type: 'string',
|
|
76
|
+
examples: [response.body],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return thymianHttpResponse;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=utils.js.map
|