@thymian/plugin-sampler 0.3.0-canary.20261007-e6cb8dc → 0.3.0-canary.20261007-cdbe1d3
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/dist/cli/check-result.d.ts +88 -0
- package/dist/cli/check-result.d.ts.map +1 -0
- package/dist/cli/check-result.js +160 -0
- package/dist/cli/check-result.js.map +1 -0
- package/dist/cli/commands/sampler/check.d.ts +32 -4
- package/dist/cli/commands/sampler/check.d.ts.map +1 -1
- package/dist/cli/commands/sampler/check.js +126 -88
- package/dist/cli/commands/sampler/check.js.map +1 -1
- package/dist/cli/commands/sampler/init.d.ts +4 -6
- package/dist/cli/commands/sampler/init.d.ts.map +1 -1
- package/dist/cli/commands/sampler/init.js +33 -49
- package/dist/cli/commands/sampler/init.js.map +1 -1
- package/dist/cli/commands/sampler/show.d.ts +11 -0
- package/dist/cli/commands/sampler/show.d.ts.map +1 -0
- package/dist/cli/commands/sampler/show.js +36 -0
- package/dist/cli/commands/sampler/show.js.map +1 -0
- package/dist/cli/commands/sampler/sync.d.ts +11 -0
- package/dist/cli/commands/sampler/sync.d.ts.map +1 -0
- package/dist/cli/commands/sampler/sync.js +65 -0
- package/dist/cli/commands/sampler/sync.js.map +1 -0
- package/dist/cli/commands/sampler/validate.d.ts +3 -10
- package/dist/cli/commands/sampler/validate.d.ts.map +1 -1
- package/dist/cli/commands/sampler/validate.js +57 -126
- package/dist/cli/commands/sampler/validate.js.map +1 -1
- package/dist/generation/closed-schema.d.ts +22 -0
- package/dist/generation/closed-schema.d.ts.map +1 -0
- package/dist/generation/closed-schema.js +45 -0
- package/dist/generation/closed-schema.js.map +1 -0
- package/dist/generation/content-type-strategies/json.content-type-strategy.d.ts.map +1 -1
- package/dist/generation/content-type-strategies/json.content-type-strategy.js +3 -1
- package/dist/generation/content-type-strategies/json.content-type-strategy.js.map +1 -1
- package/dist/generation/content-type-strategies/xml.content-type-strategy.d.ts.map +1 -1
- package/dist/generation/content-type-strategies/xml.content-type-strategy.js +3 -1
- package/dist/generation/content-type-strategies/xml.content-type-strategy.js.map +1 -1
- package/dist/generation/generate-request-sample.d.ts +12 -0
- package/dist/generation/generate-request-sample.d.ts.map +1 -0
- package/dist/generation/{generate-samples.js → generate-request-sample.js} +11 -4
- package/dist/generation/generate-request-sample.js.map +1 -0
- package/dist/generation/request-generators/default-request-generator.d.ts +14 -0
- package/dist/generation/request-generators/default-request-generator.d.ts.map +1 -1
- package/dist/generation/request-generators/default-request-generator.js +18 -1
- package/dist/generation/request-generators/default-request-generator.js.map +1 -1
- package/dist/generation/types/declaration-set.d.ts +124 -0
- package/dist/generation/types/declaration-set.d.ts.map +1 -0
- package/dist/generation/types/declaration-set.js +389 -0
- package/dist/generation/types/declaration-set.js.map +1 -0
- package/dist/generation/types/example-reflection.d.ts +21 -0
- package/dist/generation/types/example-reflection.d.ts.map +1 -0
- package/dist/generation/types/example-reflection.js +135 -0
- package/dist/generation/types/example-reflection.js.map +1 -0
- package/dist/generation/types/generate-type-surface.d.ts +23 -0
- package/dist/generation/types/generate-type-surface.d.ts.map +1 -0
- package/dist/generation/types/generate-type-surface.js +671 -0
- package/dist/generation/types/generate-type-surface.js.map +1 -0
- package/dist/generation/types/schema-type.d.ts +20 -0
- package/dist/generation/types/schema-type.d.ts.map +1 -0
- package/dist/generation/types/schema-type.js +203 -0
- package/dist/generation/types/schema-type.js.map +1 -0
- package/dist/generation/types/self-check-surface.d.ts +32 -0
- package/dist/generation/types/self-check-surface.d.ts.map +1 -0
- package/dist/generation/types/self-check-surface.js +92 -0
- package/dist/generation/types/self-check-surface.js.map +1 -0
- package/dist/generation/types/type-names.d.ts +135 -0
- package/dist/generation/types/type-names.d.ts.map +1 -0
- package/dist/generation/types/type-names.js +213 -0
- package/dist/generation/types/type-names.js.map +1 -0
- package/dist/generation/types/write-type-surface.d.ts +58 -0
- package/dist/generation/types/write-type-surface.d.ts.map +1 -0
- package/dist/generation/types/write-type-surface.js +119 -0
- package/dist/generation/types/write-type-surface.js.map +1 -0
- package/dist/hooks/create-hook-utils.d.ts +22 -6
- package/dist/hooks/create-hook-utils.d.ts.map +1 -1
- package/dist/hooks/create-hook-utils.js +74 -96
- package/dist/hooks/create-hook-utils.js.map +1 -1
- package/dist/hooks/hook-api.d.ts +49 -0
- package/dist/hooks/hook-api.d.ts.map +1 -0
- package/dist/hooks/hook-api.js +105 -0
- package/dist/hooks/hook-api.js.map +1 -0
- package/dist/hooks/hook-diagnostics.d.ts +45 -0
- package/dist/hooks/hook-diagnostics.d.ts.map +1 -0
- package/dist/hooks/hook-diagnostics.js +80 -0
- package/dist/hooks/hook-diagnostics.js.map +1 -0
- package/dist/hooks/hook-errors.d.ts +33 -0
- package/dist/hooks/hook-errors.d.ts.map +1 -1
- package/dist/hooks/hook-errors.js +46 -0
- package/dist/hooks/hook-errors.js.map +1 -1
- package/dist/hooks/hook-registration.d.ts +108 -0
- package/dist/hooks/hook-registration.d.ts.map +1 -0
- package/dist/hooks/hook-registration.js +69 -0
- package/dist/hooks/hook-registration.js.map +1 -0
- package/dist/hooks/hook-runner.d.ts +111 -11
- package/dist/hooks/hook-runner.d.ts.map +1 -1
- package/dist/hooks/hook-runner.js +309 -142
- package/dist/hooks/hook-runner.js.map +1 -1
- package/dist/hooks/hook-utils-factory.d.ts +19 -0
- package/dist/hooks/hook-utils-factory.d.ts.map +1 -0
- package/dist/hooks/hook-utils-factory.js +2 -0
- package/dist/hooks/hook-utils-factory.js.map +1 -0
- package/dist/hooks/hook-utils.d.ts +80 -12
- package/dist/hooks/hook-utils.d.ts.map +1 -1
- package/dist/hooks/invoke-hook.d.ts +71 -0
- package/dist/hooks/invoke-hook.d.ts.map +1 -0
- package/dist/hooks/invoke-hook.js +161 -0
- package/dist/hooks/invoke-hook.js.map +1 -0
- package/dist/hooks/load-user-hooks.d.ts +96 -0
- package/dist/hooks/load-user-hooks.d.ts.map +1 -0
- package/dist/hooks/load-user-hooks.js +432 -0
- package/dist/hooks/load-user-hooks.js.map +1 -0
- package/dist/hooks/nested-request.d.ts +21 -0
- package/dist/hooks/nested-request.d.ts.map +1 -0
- package/dist/hooks/nested-request.js +24 -0
- package/dist/hooks/nested-request.js.map +1 -0
- package/dist/hooks/overlay-args.d.ts +40 -0
- package/dist/hooks/overlay-args.d.ts.map +1 -0
- package/dist/hooks/overlay-args.js +84 -0
- package/dist/hooks/overlay-args.js.map +1 -0
- package/dist/hooks/resolve-targeting.d.ts +16 -0
- package/dist/hooks/resolve-targeting.d.ts.map +1 -0
- package/dist/hooks/resolve-targeting.js +168 -0
- package/dist/hooks/resolve-targeting.js.map +1 -0
- package/dist/hooks/run-scoped-hooks.d.ts +83 -0
- package/dist/hooks/run-scoped-hooks.d.ts.map +1 -0
- package/dist/hooks/run-scoped-hooks.js +153 -0
- package/dist/hooks/run-scoped-hooks.js.map +1 -0
- package/dist/index.d.ts +42 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +152 -165
- package/dist/index.js.map +1 -1
- package/dist/request-sampler.d.ts +40 -11
- package/dist/request-sampler.d.ts.map +1 -1
- package/dist/request-sampler.js +51 -76
- package/dist/request-sampler.js.map +1 -1
- package/dist/sampler-paths.d.ts +19 -0
- package/dist/sampler-paths.d.ts.map +1 -0
- package/dist/sampler-paths.js +22 -0
- package/dist/sampler-paths.js.map +1 -0
- package/dist/selectors/nearest-paths.d.ts +14 -0
- package/dist/selectors/nearest-paths.d.ts.map +1 -0
- package/dist/selectors/nearest-paths.js +32 -0
- package/dist/selectors/nearest-paths.js.map +1 -0
- package/dist/selectors/path-glob.d.ts +94 -0
- package/dist/selectors/path-glob.d.ts.map +1 -0
- package/dist/selectors/path-glob.js +136 -0
- package/dist/selectors/path-glob.js.map +1 -0
- package/dist/selectors/selector-errors.d.ts +17 -0
- package/dist/selectors/selector-errors.d.ts.map +1 -0
- package/dist/selectors/selector-errors.js +139 -0
- package/dist/selectors/selector-errors.js.map +1 -0
- package/dist/selectors/selector.d.ts +55 -0
- package/dist/selectors/selector.d.ts.map +1 -0
- package/dist/selectors/selector.js +305 -0
- package/dist/selectors/selector.js.map +1 -0
- package/dist/selectors/transaction-catalog.d.ts +96 -0
- package/dist/selectors/transaction-catalog.d.ts.map +1 -0
- package/dist/selectors/transaction-catalog.js +193 -0
- package/dist/selectors/transaction-catalog.js.map +1 -0
- package/dist/selectors/transaction-filter.d.ts +119 -0
- package/dist/selectors/transaction-filter.d.ts.map +1 -0
- package/dist/selectors/transaction-filter.js +191 -0
- package/dist/selectors/transaction-filter.js.map +1 -0
- package/dist/ts-path.d.ts +36 -0
- package/dist/ts-path.d.ts.map +1 -0
- package/dist/ts-path.js +46 -0
- package/dist/ts-path.js.map +1 -0
- package/dist/utils.d.ts +1 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -20
- package/dist/utils.js.map +1 -1
- package/dist/validation/canonicalize.d.ts +17 -0
- package/dist/validation/canonicalize.d.ts.map +1 -0
- package/dist/validation/canonicalize.js +29 -0
- package/dist/validation/canonicalize.js.map +1 -0
- package/dist/validation/shared-compiler-host.d.ts +17 -0
- package/dist/validation/shared-compiler-host.d.ts.map +1 -0
- package/dist/validation/shared-compiler-host.js +58 -0
- package/dist/validation/shared-compiler-host.js.map +1 -0
- package/dist/validation/typecheck-hooks.d.ts +37 -0
- package/dist/validation/typecheck-hooks.d.ts.map +1 -0
- package/dist/validation/typecheck-hooks.js +169 -0
- package/dist/validation/typecheck-hooks.js.map +1 -0
- package/dist/validation/validate-sampler.d.ts +79 -0
- package/dist/validation/validate-sampler.d.ts.map +1 -0
- package/dist/validation/validate-sampler.js +89 -0
- package/dist/validation/validate-sampler.js.map +1 -0
- package/package.json +7 -11
- package/dist/cli/commands/sampler/generate/hook.d.ts +0 -10
- package/dist/cli/commands/sampler/generate/hook.d.ts.map +0 -1
- package/dist/cli/commands/sampler/generate/hook.js +0 -19
- package/dist/cli/commands/sampler/generate/hook.js.map +0 -1
- package/dist/cli/generate-hook.d.ts +0 -4
- package/dist/cli/generate-hook.d.ts.map +0 -1
- package/dist/cli/generate-hook.js +0 -96
- package/dist/cli/generate-hook.js.map +0 -1
- package/dist/cli/templates.d.ts +0 -4
- package/dist/cli/templates.d.ts.map +0 -1
- package/dist/cli/templates.js +0 -28
- package/dist/cli/templates.js.map +0 -1
- package/dist/constants.d.ts +0 -12
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -16
- package/dist/constants.js.map +0 -1
- package/dist/generation/generate-samples-for-thymian-format.d.ts +0 -4
- package/dist/generation/generate-samples-for-thymian-format.d.ts.map +0 -1
- package/dist/generation/generate-samples-for-thymian-format.js +0 -18
- package/dist/generation/generate-samples-for-thymian-format.js.map +0 -1
- package/dist/generation/generate-samples.d.ts +0 -4
- package/dist/generation/generate-samples.d.ts.map +0 -1
- package/dist/generation/generate-samples.js.map +0 -1
- package/dist/hooks/generate-request-types.d.ts +0 -34
- package/dist/hooks/generate-request-types.d.ts.map +0 -1
- package/dist/hooks/generate-request-types.js +0 -458
- package/dist/hooks/generate-request-types.js.map +0 -1
- package/dist/hooks/hook-types.d.ts +0 -7
- package/dist/hooks/hook-types.d.ts.map +0 -1
- package/dist/hooks/hook-types.js +0 -2
- package/dist/hooks/hook-types.js.map +0 -1
- package/dist/hooks/load-hooks-from-samples.d.ts +0 -3
- package/dist/hooks/load-hooks-from-samples.d.ts.map +0 -1
- package/dist/hooks/load-hooks-from-samples.js +0 -22
- package/dist/hooks/load-hooks-from-samples.js.map +0 -1
- package/dist/hooks/ts-config.d.ts +0 -10
- package/dist/hooks/ts-config.d.ts.map +0 -1
- package/dist/hooks/ts-config.js +0 -10
- package/dist/hooks/ts-config.js.map +0 -1
- package/dist/samples-structure/file-request-sample.d.ts +0 -20
- package/dist/samples-structure/file-request-sample.d.ts.map +0 -1
- package/dist/samples-structure/file-request-sample.js +0 -5
- package/dist/samples-structure/file-request-sample.js.map +0 -1
- package/dist/samples-structure/get-path-transaction-id.d.ts +0 -3
- package/dist/samples-structure/get-path-transaction-id.d.ts.map +0 -1
- package/dist/samples-structure/get-path-transaction-id.js +0 -22
- package/dist/samples-structure/get-path-transaction-id.js.map +0 -1
- package/dist/samples-structure/merge-tree.d.ts +0 -5
- package/dist/samples-structure/merge-tree.d.ts.map +0 -1
- package/dist/samples-structure/merge-tree.js +0 -118
- package/dist/samples-structure/merge-tree.js.map +0 -1
- package/dist/samples-structure/read-samples-from-dir.d.ts +0 -13
- package/dist/samples-structure/read-samples-from-dir.d.ts.map +0 -1
- package/dist/samples-structure/read-samples-from-dir.js +0 -205
- package/dist/samples-structure/read-samples-from-dir.js.map +0 -1
- package/dist/samples-structure/samples-from-transactions.d.ts +0 -5
- package/dist/samples-structure/samples-from-transactions.d.ts.map +0 -1
- package/dist/samples-structure/samples-from-transactions.js +0 -120
- package/dist/samples-structure/samples-from-transactions.js.map +0 -1
- package/dist/samples-structure/samples-tree-structure.d.ts +0 -106
- package/dist/samples-structure/samples-tree-structure.d.ts.map +0 -1
- package/dist/samples-structure/samples-tree-structure.js +0 -26
- package/dist/samples-structure/samples-tree-structure.js.map +0 -1
- package/dist/samples-structure/structure-meta-on-disc.d.ts +0 -11
- package/dist/samples-structure/structure-meta-on-disc.d.ts.map +0 -1
- package/dist/samples-structure/structure-meta-on-disc.js +0 -2
- package/dist/samples-structure/structure-meta-on-disc.js.map +0 -1
- package/dist/samples-structure/traverse.d.ts +0 -4
- package/dist/samples-structure/traverse.d.ts.map +0 -1
- package/dist/samples-structure/traverse.js +0 -13
- package/dist/samples-structure/traverse.js.map +0 -1
- package/dist/samples-structure/write-samples-to-dir.d.ts +0 -37
- package/dist/samples-structure/write-samples-to-dir.d.ts.map +0 -1
- package/dist/samples-structure/write-samples-to-dir.js +0 -183
- package/dist/samples-structure/write-samples-to-dir.js.map +0 -1
- package/dist/validation/validate-sampler-output.d.ts +0 -38
- package/dist/validation/validate-sampler-output.d.ts.map +0 -1
- package/dist/validation/validate-sampler-output.js +0 -288
- package/dist/validation/validate-sampler-output.js.map +0 -1
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { mergeHooks } from '../samples-structure/merge-tree.js';
|
|
2
|
-
import { nodeIsType, } from '../samples-structure/samples-tree-structure.js';
|
|
3
|
-
import { traverse } from '../samples-structure/traverse.js';
|
|
4
|
-
export function loadHooksFromSamples(samples) {
|
|
5
|
-
const result = new Map();
|
|
6
|
-
traverse(samples, {
|
|
7
|
-
afterEachResponse: [],
|
|
8
|
-
authorize: [],
|
|
9
|
-
beforeEachRequest: [],
|
|
10
|
-
}, (node, hooks) => {
|
|
11
|
-
let nextHooks = hooks;
|
|
12
|
-
if (node.hooks) {
|
|
13
|
-
nextHooks = mergeHooks(nextHooks, node.hooks);
|
|
14
|
-
}
|
|
15
|
-
if (nodeIsType(node, 'samples')) {
|
|
16
|
-
result.set(node.meta.sourceTransaction, nextHooks);
|
|
17
|
-
}
|
|
18
|
-
return nextHooks;
|
|
19
|
-
});
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=load-hooks-from-samples.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load-hooks-from-samples.js","sourceRoot":"","sources":["../../src/hooks/load-hooks-from-samples.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAEL,UAAU,GAEX,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAE5D,MAAM,UAAU,oBAAoB,CAClC,OAAyB;IAEzB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAC;IAExC,QAAQ,CACN,OAAO,EACP;QACE,iBAAiB,EAAE,EAAE;QACrB,SAAS,EAAE,EAAE;QACb,iBAAiB,EAAE,EAAE;KACtB,EACD,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACd,IAAI,SAAS,GAAG,KAAK,CAAC;QAEtB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ts-config.d.ts","sourceRoot":"","sources":["../../src/hooks/ts-config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;;;;;;CAQpB,CAAC"}
|
package/dist/hooks/ts-config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ts-config.js","sourceRoot":"","sources":["../../src/hooks/ts-config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,eAAe,EAAE;QACf,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE;YACL,gBAAgB,EAAE,CAAC,cAAc,CAAC;SACnC;KACF;IACD,OAAO,EAAE,CAAC,WAAW,CAAC;CACvB,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export type InlineValue = unknown;
|
|
2
|
-
export type FileValue = {
|
|
3
|
-
$file: string;
|
|
4
|
-
$encoding?: string;
|
|
5
|
-
};
|
|
6
|
-
export type Value = InlineValue | FileValue;
|
|
7
|
-
export type FileRequestSample = {
|
|
8
|
-
origin: string;
|
|
9
|
-
path: string;
|
|
10
|
-
method: string;
|
|
11
|
-
authorize: boolean;
|
|
12
|
-
bodyEncoding?: string;
|
|
13
|
-
headers: Record<string, Value>;
|
|
14
|
-
cookies: Record<string, Value>;
|
|
15
|
-
pathParameters: Record<string, Value>;
|
|
16
|
-
query: Record<string, Value>;
|
|
17
|
-
body?: Value;
|
|
18
|
-
};
|
|
19
|
-
export declare function isFileValue(value: Value): value is FileValue;
|
|
20
|
-
//# sourceMappingURL=file-request-sample.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-request-sample.d.ts","sourceRoot":"","sources":["../../src/samples-structure/file-request-sample.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;AAElC,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,WAAW,GAAG,SAAS,CAAC;AAG5C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,SAAS,CAE5D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-request-sample.js","sourceRoot":"","sources":["../../src/samples-structure/file-request-sample.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAyBzC,MAAM,UAAU,WAAW,CAAC,KAAY;IACtC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;AAC/D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-path-transaction-id.d.ts","sourceRoot":"","sources":["../../src/samples-structure/get-path-transaction-id.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,6BAA6B,CAAC;AAIrC,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,GACxB,MAAM,GAAG,SAAS,CAuBpB"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { isValidNodeType, nodeIsType, } from './samples-tree-structure.js';
|
|
3
|
-
import { traverse } from './traverse.js';
|
|
4
|
-
import { getFolderNameFromNode } from './write-samples-to-dir.js';
|
|
5
|
-
export function getPathTransactionId(id, path, samples) {
|
|
6
|
-
let finalPath = path;
|
|
7
|
-
traverse(samples, path, (node, currentPath, prev) => {
|
|
8
|
-
if (!isValidNodeType(node.type)) {
|
|
9
|
-
throw new Error(`Invalid node type: ${node.type}`);
|
|
10
|
-
}
|
|
11
|
-
const folderName = getFolderNameFromNode(node);
|
|
12
|
-
const newName = join(currentPath, folderName);
|
|
13
|
-
if (nodeIsType(node, 'requests') &&
|
|
14
|
-
nodeIsType(prev, 'samples') &&
|
|
15
|
-
prev.meta.sourceTransaction === id) {
|
|
16
|
-
finalPath = newName;
|
|
17
|
-
}
|
|
18
|
-
return newName;
|
|
19
|
-
});
|
|
20
|
-
return finalPath === path ? undefined : finalPath;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=get-path-transaction-id.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-path-transaction-id.js","sourceRoot":"","sources":["../../src/samples-structure/get-path-transaction-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,eAAe,EACf,UAAU,GAEX,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,UAAU,oBAAoB,CAClC,EAAU,EACV,IAAY,EACZ,OAAyB;IAEzB,IAAI,SAAS,GAAG,IAAI,CAAC;IAErB,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE;QAClD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,UAAU,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAE9C,IACE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC;YAC5B,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC;YAC3B,IAAI,CAAC,IAAI,CAAC,iBAAiB,KAAK,EAAE,EAClC,CAAC;YACD,SAAS,GAAG,OAAO,CAAC;QACtB,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type Hooks, type Node, type SamplesStructure } from './samples-tree-structure.js';
|
|
2
|
-
export declare function mergeHooks(a: Hooks | undefined, b: Hooks | undefined): Hooks;
|
|
3
|
-
export declare function mergeNodes(a: Node, b: Node): Node;
|
|
4
|
-
export declare function mergeTrees(a: SamplesStructure, b: SamplesStructure): SamplesStructure;
|
|
5
|
-
//# sourceMappingURL=merge-tree.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-tree.d.ts","sourceRoot":"","sources":["../../src/samples-structure/merge-tree.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,IAAI,EAGT,KAAK,gBAAgB,EAEtB,MAAM,6BAA6B,CAAC;AAErC,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,EAAE,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,CAoB5E;AAuDD,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,CAiCjD;AAED,wBAAgB,UAAU,CACxB,CAAC,EAAE,gBAAgB,EACnB,CAAC,EAAE,gBAAgB,GAClB,gBAAgB,CAqBlB"}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { ThymianBaseError } from '@thymian/core';
|
|
2
|
-
import { nodeIsType, } from './samples-tree-structure.js';
|
|
3
|
-
export function mergeHooks(a, b) {
|
|
4
|
-
if (!a && !b) {
|
|
5
|
-
return {
|
|
6
|
-
afterEachResponse: [],
|
|
7
|
-
beforeEachRequest: [],
|
|
8
|
-
authorize: [],
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
return {
|
|
12
|
-
beforeEachRequest: [
|
|
13
|
-
...(a?.beforeEachRequest || []),
|
|
14
|
-
...(b?.beforeEachRequest || []),
|
|
15
|
-
],
|
|
16
|
-
afterEachResponse: [
|
|
17
|
-
...(a?.afterEachResponse || []),
|
|
18
|
-
...(b?.afterEachResponse || []),
|
|
19
|
-
],
|
|
20
|
-
authorize: [...(a?.authorize || []), ...(b?.authorize || [])],
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function getNodeKey(node) {
|
|
24
|
-
switch (node.type) {
|
|
25
|
-
case 'samples':
|
|
26
|
-
return node.type + node.meta.sourceTransaction;
|
|
27
|
-
case 'requests':
|
|
28
|
-
return node.type;
|
|
29
|
-
case 'root':
|
|
30
|
-
return node.meta.version;
|
|
31
|
-
case 'source':
|
|
32
|
-
case 'statusCode':
|
|
33
|
-
case 'path':
|
|
34
|
-
case 'method':
|
|
35
|
-
case 'host':
|
|
36
|
-
case 'port':
|
|
37
|
-
case 'pathParameter':
|
|
38
|
-
case 'requestMediaType':
|
|
39
|
-
case 'responseMediaType':
|
|
40
|
-
return node.type + node.value;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function mergeChildLists(as, bs) {
|
|
44
|
-
const map = new Map();
|
|
45
|
-
for (const node of as) {
|
|
46
|
-
map.set(getNodeKey(node), node);
|
|
47
|
-
}
|
|
48
|
-
for (const nodeB of bs) {
|
|
49
|
-
const key = getNodeKey(nodeB);
|
|
50
|
-
const nodeA = map.get(key);
|
|
51
|
-
if (nodeA) {
|
|
52
|
-
map.set(key, mergeNodes(nodeA, nodeB));
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
map.set(key, nodeB);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return Array.from(map.values());
|
|
59
|
-
}
|
|
60
|
-
function mergeRequestNodes(a, b) {
|
|
61
|
-
return {
|
|
62
|
-
type: 'requests',
|
|
63
|
-
meta: { ...a.meta, ...b.meta },
|
|
64
|
-
hooks: mergeHooks(a.hooks, b.hooks),
|
|
65
|
-
// just combine the lists of samples
|
|
66
|
-
value: [...(a.value ?? []), ...(b.value ?? [])],
|
|
67
|
-
children: [],
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
export function mergeNodes(a, b) {
|
|
71
|
-
if (a.type !== b.type) {
|
|
72
|
-
throw new ThymianBaseError(`Cannot merge nodes of different types: ${a.type} vs ${b.type}`, {
|
|
73
|
-
name: 'NodeTypeMismatchError',
|
|
74
|
-
ref: 'https://thymian.dev/references/errors/node-type-mismatch-error/',
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
if (nodeIsType(a, 'requests') && nodeIsType(b, 'requests')) {
|
|
78
|
-
return mergeRequestNodes(a, b);
|
|
79
|
-
}
|
|
80
|
-
else if (!nodeIsType(a, 'requests') && !nodeIsType(b, 'requests')) {
|
|
81
|
-
const node = {
|
|
82
|
-
type: a.type,
|
|
83
|
-
value: a.value,
|
|
84
|
-
hooks: mergeHooks(a.hooks, b.hooks),
|
|
85
|
-
children: mergeChildLists(a.children, b.children),
|
|
86
|
-
meta: { ...(a.meta ?? {}), ...(b.meta ?? {}) },
|
|
87
|
-
};
|
|
88
|
-
if (a.meta || b.meta) {
|
|
89
|
-
node.meta = { ...(a.meta ?? {}), ...(b.meta ?? {}) };
|
|
90
|
-
}
|
|
91
|
-
// this is VERY ugly, but it's currently the price for the type safe tree structure. We should probably refactor this later.
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
93
|
-
// @ts-expect-error
|
|
94
|
-
return node;
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
throw new Error('This should never happen: ' + a + ' ' + b);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
export function mergeTrees(a, b) {
|
|
101
|
-
if (a.meta.version !== b.meta.version) {
|
|
102
|
-
throw new ThymianBaseError(`Cannot merge SamplesTrees with different versions: ${a.meta.version} vs ${b.meta.version}`, {
|
|
103
|
-
name: 'SamplesVersionMismatchError',
|
|
104
|
-
ref: 'https://thymian.dev/references/errors/samples-version-mismatch-error/',
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
type: 'root',
|
|
109
|
-
meta: {
|
|
110
|
-
version: a.meta.version,
|
|
111
|
-
timestamp: Math.max(a.meta.timestamp, b.meta.timestamp),
|
|
112
|
-
},
|
|
113
|
-
hooks: mergeHooks(a.hooks, b.hooks),
|
|
114
|
-
// this cast is ugly, but it's the price for the type safe tree structure
|
|
115
|
-
children: mergeChildLists(a.children, b.children),
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=merge-tree.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-tree.js","sourceRoot":"","sources":["../../src/samples-structure/merge-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAGL,UAAU,GAIX,MAAM,6BAA6B,CAAC;AAErC,MAAM,UAAU,UAAU,CAAC,CAAoB,EAAE,CAAoB;IACnE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACb,OAAO;YACL,iBAAiB,EAAE,EAAE;YACrB,iBAAiB,EAAE,EAAE;YACrB,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;IAED,OAAO;QACL,iBAAiB,EAAE;YACjB,GAAG,CAAC,CAAC,EAAE,iBAAiB,IAAI,EAAE,CAAC;YAC/B,GAAG,CAAC,CAAC,EAAE,iBAAiB,IAAI,EAAE,CAAC;SAChC;QACD,iBAAiB,EAAE;YACjB,GAAG,CAAC,CAAC,EAAE,iBAAiB,IAAI,EAAE,CAAC;YAC/B,GAAG,CAAC,CAAC,EAAE,iBAAiB,IAAI,EAAE,CAAC;SAChC;QACD,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;KAC9D,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,IAAU;IAC5B,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC;QACjD,KAAK,UAAU;YACb,OAAO,IAAI,CAAC,IAAI,CAAC;QACnB,KAAK,MAAM;YACT,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QAC3B,KAAK,QAAQ,CAAC;QACd,KAAK,YAAY,CAAC;QAClB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EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;QACvD,CAAC;QAED,4HAA4H;QAC5H,6DAA6D;QAC7D,mBAAmB;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,CAAmB,EACnB,CAAmB;IAEnB,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACtC,MAAM,IAAI,gBAAgB,CACxB,sDAAsD,CAAC,CAAC,IAAI,CAAC,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,EAC3F;YACE,IAAI,EAAE,6BAA6B;YACnC,GAAG,EAAE,uEAAuE;SAC7E,CACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE;YACJ,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO;YACvB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;SACxD;QACD,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC;QACnC,yEAAyE;QACzE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAiB;KAClE,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ContentSource, HttpRequestSample } from '../http-request-sample.js';
|
|
2
|
-
import { type Value } from './file-request-sample.js';
|
|
3
|
-
import type { Hooks, Node, NodeTypes, SamplesNode, SamplesStructure } from './samples-tree-structure.js';
|
|
4
|
-
import type { PathToNodeType } from './structure-meta-on-disc.js';
|
|
5
|
-
export declare function tryImport<T>(path: string): Promise<T>;
|
|
6
|
-
export declare function extractParameterValues(parameters: Record<string, Value>, basePath: string): Promise<Record<string, ContentSource>>;
|
|
7
|
-
export declare function extractSample(path: string): Promise<HttpRequestSample>;
|
|
8
|
-
export declare function extractSamplesNode<T extends Exclude<Node, SamplesNode | SamplesStructure>['type']>(dir: string, type: T): Promise<NodeTypes[T]>;
|
|
9
|
-
export declare function extractHooksFromDir(dir: string): Promise<Hooks>;
|
|
10
|
-
export declare function dirNameToValue(dirName: string, type: Exclude<Node, SamplesNode | SamplesStructure>['type']): string;
|
|
11
|
-
export declare function extractNodes(baseDir: string, relativeDir: string, currentDirName: string, meta: PathToNodeType): Promise<Node>;
|
|
12
|
-
export declare function readSamplesFromDir(dir: string): Promise<SamplesStructure>;
|
|
13
|
-
//# sourceMappingURL=read-samples-from-dir.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read-samples-from-dir.d.ts","sourceRoot":"","sources":["../../src/samples-structure/read-samples-from-dir.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAGL,KAAK,KAAK,EACX,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,SAAS,EAET,WAAW,EAEX,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,cAAc,EAEf,MAAM,6BAA6B,CAAC;AAIrC,wBAAsB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAc3D;AAED,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACjC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAuBxC;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAqD5E;AAED,wBAAsB,kBAAkB,CACtC,CAAC,SAAS,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,gBAAgB,CAAC,CAAC,MAAM,CAAC,EAC/D,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAoC7C;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAiCrE;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,gBAAgB,CAAC,CAAC,MAAM,CAAC,GAC1D,MAAM,CASR;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,IAAI,CAAC,CAgDf;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,gBAAgB,CAAC,CAwB3B"}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { readdir, readFile } from 'node:fs/promises';
|
|
2
|
-
import { type } from 'node:os';
|
|
3
|
-
import { basename, dirname, join } from 'node:path';
|
|
4
|
-
import { ThymianBaseError } from '@thymian/core';
|
|
5
|
-
import { createJiti } from 'jiti';
|
|
6
|
-
import { AFTER_EACH_HOOK, AUTHORIZE_HOOK, BEFORE_EACH_HOOK, SAMPLE_FILE, } from '../constants.js';
|
|
7
|
-
import { checkForSafePath } from '../utils.js';
|
|
8
|
-
import { isFileValue, } from './file-request-sample.js';
|
|
9
|
-
const jiti = createJiti(import.meta.url);
|
|
10
|
-
export async function tryImport(path) {
|
|
11
|
-
const module = await jiti.import(path, { default: true });
|
|
12
|
-
if (module === null || typeof module !== 'function') {
|
|
13
|
-
throw new ThymianBaseError(`Could not import hook from "${path}".`, {
|
|
14
|
-
name: 'HookImportError',
|
|
15
|
-
ref: 'https://thymian.dev/references/errors/hook-import-error/',
|
|
16
|
-
suggestions: [
|
|
17
|
-
'Check that the hook file exists and the hook function is exported as default.',
|
|
18
|
-
],
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return module;
|
|
22
|
-
}
|
|
23
|
-
export async function extractParameterValues(parameters, basePath) {
|
|
24
|
-
const result = {};
|
|
25
|
-
for (const [key, value] of Object.entries(parameters)) {
|
|
26
|
-
if (isFileValue(value)) {
|
|
27
|
-
const fullPath = join(basePath, value.$file);
|
|
28
|
-
checkForSafePath(fullPath, basePath);
|
|
29
|
-
result[key] = {
|
|
30
|
-
$content: await readFile(fullPath, (value.$encoding ?? 'utf-8')),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
result[key] = {
|
|
35
|
-
$content: value,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
export async function extractSample(path) {
|
|
42
|
-
const sampleFile = await readFile(path, 'utf-8');
|
|
43
|
-
const requestsDir = dirname(path);
|
|
44
|
-
let fileSample;
|
|
45
|
-
try {
|
|
46
|
-
fileSample = JSON.parse(sampleFile);
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
throw new ThymianBaseError(`Could not parse JSON sample file "${path}".`, {
|
|
50
|
-
name: 'InvalidSampleJSONError',
|
|
51
|
-
ref: 'https://thymian.dev/references/errors/invalid-sample-json-error/',
|
|
52
|
-
suggestions: ['Check that the sample file is valid JSON.'],
|
|
53
|
-
cause: err,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
const sample = {
|
|
57
|
-
authorize: fileSample.authorize,
|
|
58
|
-
cookies: await extractParameterValues(fileSample.cookies, requestsDir),
|
|
59
|
-
headers: await extractParameterValues(fileSample.headers, requestsDir),
|
|
60
|
-
method: fileSample.method,
|
|
61
|
-
origin: fileSample.origin,
|
|
62
|
-
path: fileSample.path,
|
|
63
|
-
pathParameters: await extractParameterValues(fileSample.pathParameters, requestsDir),
|
|
64
|
-
query: await extractParameterValues(fileSample.query, requestsDir),
|
|
65
|
-
bodyEncoding: fileSample.bodyEncoding,
|
|
66
|
-
};
|
|
67
|
-
if (fileSample.body) {
|
|
68
|
-
if (isFileValue(fileSample.body)) {
|
|
69
|
-
const bodyPath = join(requestsDir, fileSample.body.$file);
|
|
70
|
-
checkForSafePath(bodyPath, requestsDir);
|
|
71
|
-
sample.body = {
|
|
72
|
-
$content: await readFile(bodyPath, (fileSample.body.$encoding ??
|
|
73
|
-
fileSample.bodyEncoding ??
|
|
74
|
-
'utf-8')),
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
sample.body = {
|
|
79
|
-
$content: fileSample.body,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return sample;
|
|
84
|
-
}
|
|
85
|
-
export async function extractSamplesNode(dir, type) {
|
|
86
|
-
const metaPath = join(dir, 'meta.json');
|
|
87
|
-
const meta = JSON.parse(await readFile(metaPath, 'utf-8'));
|
|
88
|
-
const request = {
|
|
89
|
-
children: [],
|
|
90
|
-
type: 'requests',
|
|
91
|
-
value: [],
|
|
92
|
-
};
|
|
93
|
-
for (const dirent of await readdir(join(dir, 'requests'), {
|
|
94
|
-
recursive: false,
|
|
95
|
-
withFileTypes: true,
|
|
96
|
-
})) {
|
|
97
|
-
if (dirent.isFile() && SAMPLE_FILE.test(dirent.name)) {
|
|
98
|
-
request.value.push(await extractSample(join(dir, 'requests', dirent.name)));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
const samplesNode = {
|
|
102
|
-
meta,
|
|
103
|
-
type: 'samples',
|
|
104
|
-
hooks: await extractHooksFromDir(dir),
|
|
105
|
-
children: [request],
|
|
106
|
-
};
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
108
|
-
// @ts-expect-error
|
|
109
|
-
return {
|
|
110
|
-
type,
|
|
111
|
-
children: [samplesNode],
|
|
112
|
-
value: dirNameToValue(basename(dir), type),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
export async function extractHooksFromDir(dir) {
|
|
116
|
-
const hooks = {
|
|
117
|
-
afterEachResponse: [],
|
|
118
|
-
authorize: [],
|
|
119
|
-
beforeEachRequest: [],
|
|
120
|
-
};
|
|
121
|
-
for (const dirent of await readdir(dir, {
|
|
122
|
-
recursive: false,
|
|
123
|
-
withFileTypes: true,
|
|
124
|
-
})) {
|
|
125
|
-
if (dirent.isFile()) {
|
|
126
|
-
const filePath = join(dir, dirent.name);
|
|
127
|
-
if (BEFORE_EACH_HOOK.test(dirent.name)) {
|
|
128
|
-
hooks.beforeEachRequest.push(await tryImport(filePath));
|
|
129
|
-
}
|
|
130
|
-
if (AFTER_EACH_HOOK.test(dirent.name)) {
|
|
131
|
-
hooks.afterEachResponse.push(await tryImport(filePath));
|
|
132
|
-
}
|
|
133
|
-
if (AUTHORIZE_HOOK.test(dirent.name)) {
|
|
134
|
-
hooks.authorize.push(await tryImport(filePath));
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return hooks;
|
|
139
|
-
}
|
|
140
|
-
export function dirNameToValue(dirName, type) {
|
|
141
|
-
switch (type) {
|
|
142
|
-
case 'pathParameter':
|
|
143
|
-
return `${dirName.substring(1, dirName.length - 1)}`;
|
|
144
|
-
case 'method':
|
|
145
|
-
return dirName.replace('@', '').toLowerCase();
|
|
146
|
-
default:
|
|
147
|
-
return dirName;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
export async function extractNodes(baseDir, relativeDir, currentDirName, meta) {
|
|
151
|
-
const { type, containsSamples } = meta[relativeDir] ?? {};
|
|
152
|
-
if (typeof type === 'undefined') {
|
|
153
|
-
throw new Error(`Unknown type: ${relativeDir}`);
|
|
154
|
-
}
|
|
155
|
-
if (type === 'root' || type === 'samples') {
|
|
156
|
-
throw new Error('Cannot extract root node from samples directory.');
|
|
157
|
-
}
|
|
158
|
-
const fullPath = join(baseDir, relativeDir);
|
|
159
|
-
if (containsSamples) {
|
|
160
|
-
return await extractSamplesNode(fullPath, type);
|
|
161
|
-
}
|
|
162
|
-
else if (type === 'requests') {
|
|
163
|
-
/**
|
|
164
|
-
* is extracted within the extractSamplesNode function
|
|
165
|
-
*/
|
|
166
|
-
throw new Error('Should not happen');
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
const fullPath = join(baseDir, relativeDir);
|
|
170
|
-
const node = {
|
|
171
|
-
value: dirNameToValue(currentDirName, type),
|
|
172
|
-
children: [],
|
|
173
|
-
type,
|
|
174
|
-
hooks: await extractHooksFromDir(fullPath),
|
|
175
|
-
};
|
|
176
|
-
for (const dirent of await readdir(fullPath, {
|
|
177
|
-
recursive: false,
|
|
178
|
-
withFileTypes: true,
|
|
179
|
-
})) {
|
|
180
|
-
if (dirent.isDirectory()) {
|
|
181
|
-
node.children.push(await extractNodes(baseDir, join(relativeDir, dirent.name), dirent.name, meta));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return node;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
export async function readSamplesFromDir(dir) {
|
|
188
|
-
const meta = JSON.parse(await readFile(join(dir, 'meta.json'), 'utf-8'));
|
|
189
|
-
const samples = {
|
|
190
|
-
children: [],
|
|
191
|
-
meta: meta.version,
|
|
192
|
-
type: 'root',
|
|
193
|
-
hooks: await extractHooksFromDir(dir),
|
|
194
|
-
};
|
|
195
|
-
for (const dirent of await readdir(dir, {
|
|
196
|
-
recursive: false,
|
|
197
|
-
withFileTypes: true,
|
|
198
|
-
})) {
|
|
199
|
-
if (dirent.isDirectory()) {
|
|
200
|
-
samples.children.push(await extractNodes(dir, dirent.name, dirent.name, meta.types));
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return samples;
|
|
204
|
-
}
|
|
205
|
-
//# sourceMappingURL=read-samples-from-dir.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read-samples-from-dir.js","sourceRoot":"","sources":["../../src/samples-structure/read-samples-from-dir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EACL,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAEL,WAAW,GAEZ,MAAM,0BAA0B,CAAC;AAelC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,IAAY;IAC7C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAI,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7D,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;QACpD,MAAM,IAAI,gBAAgB,CAAC,+BAA+B,IAAI,IAAI,EAAE;YAClE,IAAI,EAAE,iBAAiB;YACvB,GAAG,EAAE,0DAA0D;YAC/D,WAAW,EAAE;gBACX,+EAA+E;aAChF;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AM,CAAC,IAAI,EACX,IAAI,CACL,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,GAAW;IAEX,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CACrB,MAAM,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,OAAO,CAAC,CACzB,CAAC;IAEzB,MAAM,OAAO,GAAqB;QAChC,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,IAAI,CAAC,OAAO;QAClB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM,mBAAmB,CAAC,GAAG,CAAC;KACtC,CAAC;IAEF,KAAK,MAAM,MAAM,IAAI,MAAM,OAAO,CAAC,GAAG,EAAE;QACtC,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,IAAI;KACpB,CAAC,EAAE,CAAC;QACH,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;YACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CACnB,MAAM,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAC9D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type ThymianHttpTransaction } from '@thymian/core';
|
|
2
|
-
import type { HttpRequestSample } from '../http-request-sample.js';
|
|
3
|
-
import type { SamplesStructure } from './samples-tree-structure.js';
|
|
4
|
-
export declare function samplesTreeFromThymianHttpTransaction(sample: HttpRequestSample, transaction: ThymianHttpTransaction, version: string): SamplesStructure;
|
|
5
|
-
//# sourceMappingURL=samples-from-transactions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"samples-from-transactions.d.ts","sourceRoot":"","sources":["../../src/samples-structure/samples-from-transactions.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,KAAK,EASV,gBAAgB,EAGjB,MAAM,6BAA6B,CAAC;AAErC,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,iBAAiB,EACzB,WAAW,EAAE,sBAAsB,EACnC,OAAO,EAAE,MAAM,GACd,gBAAgB,CA+HlB"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { URL } from 'node:url';
|
|
2
|
-
import { thymianRequestToOrigin, } from '@thymian/core';
|
|
3
|
-
import { sanitize } from '../utils.js';
|
|
4
|
-
export function samplesTreeFromThymianHttpTransaction(sample, transaction, version) {
|
|
5
|
-
const tree = {
|
|
6
|
-
type: 'root',
|
|
7
|
-
children: [],
|
|
8
|
-
meta: {
|
|
9
|
-
version,
|
|
10
|
-
timestamp: Date.now(),
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
const url = new URL(thymianRequestToOrigin(transaction.thymianReq));
|
|
14
|
-
const host = sanitize(url.hostname);
|
|
15
|
-
const sourceNode = {
|
|
16
|
-
children: [],
|
|
17
|
-
type: 'source',
|
|
18
|
-
value: transaction.transaction.sourceName,
|
|
19
|
-
};
|
|
20
|
-
tree.children.push(sourceNode);
|
|
21
|
-
const hostNode = {
|
|
22
|
-
type: 'host',
|
|
23
|
-
value: host,
|
|
24
|
-
children: [],
|
|
25
|
-
};
|
|
26
|
-
sourceNode.children.push(hostNode);
|
|
27
|
-
const portNode = {
|
|
28
|
-
type: 'port',
|
|
29
|
-
value: url.port,
|
|
30
|
-
children: [],
|
|
31
|
-
};
|
|
32
|
-
hostNode.children.push(portNode);
|
|
33
|
-
const nextNode = transaction.thymianReq.path
|
|
34
|
-
.split('/')
|
|
35
|
-
.filter((s) => s.length > 0)
|
|
36
|
-
.reduce((prev, path) => {
|
|
37
|
-
if (/^\{.*}$/.test(path)) {
|
|
38
|
-
const pathParameterNode = {
|
|
39
|
-
type: 'pathParameter',
|
|
40
|
-
value: path.substring(1, path.length - 1),
|
|
41
|
-
children: [],
|
|
42
|
-
};
|
|
43
|
-
prev.children.push(pathParameterNode);
|
|
44
|
-
return pathParameterNode;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
const pathNode = {
|
|
48
|
-
type: 'path',
|
|
49
|
-
value: path,
|
|
50
|
-
children: [],
|
|
51
|
-
};
|
|
52
|
-
prev.children.push(pathNode);
|
|
53
|
-
return pathNode;
|
|
54
|
-
}
|
|
55
|
-
}, portNode);
|
|
56
|
-
const methodNode = {
|
|
57
|
-
type: 'method',
|
|
58
|
-
value: transaction.thymianReq.method.toLowerCase(),
|
|
59
|
-
children: [],
|
|
60
|
-
};
|
|
61
|
-
nextNode.children.push(methodNode);
|
|
62
|
-
let maybeReqMediaTypeNode;
|
|
63
|
-
if (transaction.thymianReq.mediaType) {
|
|
64
|
-
maybeReqMediaTypeNode = {
|
|
65
|
-
type: 'requestMediaType',
|
|
66
|
-
value: transaction.thymianReq.mediaType,
|
|
67
|
-
children: [],
|
|
68
|
-
};
|
|
69
|
-
methodNode.children.push(maybeReqMediaTypeNode);
|
|
70
|
-
}
|
|
71
|
-
const statusCodeNode = {
|
|
72
|
-
type: 'statusCode',
|
|
73
|
-
value: transaction.thymianRes.statusCode.toString(),
|
|
74
|
-
children: [],
|
|
75
|
-
};
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
77
|
-
maybeReqMediaTypeNode
|
|
78
|
-
? maybeReqMediaTypeNode.children.push(statusCodeNode)
|
|
79
|
-
: methodNode.children.push(statusCodeNode);
|
|
80
|
-
let maybeResMediaTypeNode;
|
|
81
|
-
if (transaction.thymianRes.mediaType) {
|
|
82
|
-
maybeResMediaTypeNode = {
|
|
83
|
-
type: 'responseMediaType',
|
|
84
|
-
value: transaction.thymianRes.mediaType,
|
|
85
|
-
children: [],
|
|
86
|
-
};
|
|
87
|
-
statusCodeNode.children.push(maybeResMediaTypeNode);
|
|
88
|
-
}
|
|
89
|
-
const requestsNode = {
|
|
90
|
-
children: [],
|
|
91
|
-
type: 'requests',
|
|
92
|
-
value: [sample],
|
|
93
|
-
};
|
|
94
|
-
if (maybeResMediaTypeNode) {
|
|
95
|
-
maybeResMediaTypeNode.children.push({
|
|
96
|
-
type: 'samples',
|
|
97
|
-
meta: {
|
|
98
|
-
sourceTransaction: transaction.transactionId,
|
|
99
|
-
samplingStrategy: {
|
|
100
|
-
type: 'random',
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
children: [requestsNode],
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
statusCodeNode.children.push({
|
|
108
|
-
type: 'samples',
|
|
109
|
-
meta: {
|
|
110
|
-
sourceTransaction: transaction.transactionId,
|
|
111
|
-
samplingStrategy: {
|
|
112
|
-
type: 'random',
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
children: [requestsNode],
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
return tree;
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=samples-from-transactions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"samples-from-transactions.js","sourceRoot":"","sources":["../../src/samples-structure/samples-from-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,EAEL,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAevC,MAAM,UAAU,qCAAqC,CACnD,MAAyB,EACzB,WAAmC,EACnC,OAAe;IAEf,MAAM,IAAI,GAAqB;QAC7B,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE;YACJ,OAAO;YACP,SAAS,EAAE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