@thymian/plugin-sampler 0.1.1 → 0.1.2-canary.20260408-c479a4a
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 +53 -5
- package/dist/cli/commands/sampler/check.d.ts +16 -0
- package/dist/cli/commands/sampler/check.d.ts.map +1 -0
- package/dist/cli/commands/sampler/check.js +158 -0
- package/dist/cli/commands/sampler/check.js.map +1 -0
- package/dist/cli/commands/sampler/{hooks/generate.d.ts → generate/hook.d.ts} +1 -1
- package/dist/cli/commands/sampler/generate/hook.d.ts.map +1 -0
- package/dist/cli/commands/sampler/{hooks/generate.js → generate/hook.js} +2 -2
- package/dist/cli/commands/sampler/generate/hook.js.map +1 -0
- package/dist/cli/commands/sampler/init.d.ts.map +1 -1
- package/dist/cli/commands/sampler/init.js +5 -5
- package/dist/cli/commands/sampler/init.js.map +1 -1
- package/package.json +14 -5
- package/dist/cli/commands/sampler/hooks/generate.d.ts.map +0 -1
- package/dist/cli/commands/sampler/hooks/generate.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,11 +1,59 @@
|
|
|
1
|
+
<!-- HEADER:START - Do not remove or modify this section -->
|
|
2
|
+
<div align="center">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/thymianofficial/thymian/main/astro-docs/src/assets/logo.svg" alt="Thymian Logo" width="200"/>
|
|
4
|
+
|
|
1
5
|
# Thymian
|
|
2
6
|
|
|
3
|
-
Add resilience and HTTP conformance to your API development workflow
|
|
7
|
+
**Add resilience and HTTP conformance to your API development workflow**
|
|
8
|
+
|
|
9
|
+
[](https://github.com/thymianofficial/thymian/blob/main/LICENSE)
|
|
10
|
+
[](https://github.com/thymianofficial/thymian/actions/workflows/ci.yaml)
|
|
11
|
+
[](https://thymian.dev)
|
|
12
|
+
[](https://discord.gg/TRSwCxbz9f)
|
|
13
|
+
[](https://www.reddit.com/r/ThymianOfficial/)
|
|
14
|
+
[](https://x.com/thymiandev)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
<!-- HEADER:END -->
|
|
18
|
+
|
|
19
|
+
## @thymian/plugin-sampler
|
|
20
|
+
|
|
21
|
+
Generates example HTTP request and response payloads from API specifications. Used by the testing pipeline to create realistic sample data for endpoints that need to be exercised during conformance testing.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @thymian/plugin-sampler
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> **Getting started with Thymian?** See the [main Thymian package](https://www.npmjs.com/package/thymian) for quick installation and first-run instructions.
|
|
30
|
+
|
|
31
|
+
<!-- FOOTER:START - Do not remove or modify this section -->
|
|
32
|
+
|
|
33
|
+
## 📚 Documentation
|
|
34
|
+
|
|
35
|
+
- **[Getting Started](https://thymian.dev/introduction/getting-started)** - Set up Thymian in minutes
|
|
36
|
+
- **[Documentation](https://thymian.dev)** - Comprehensive guides and API reference
|
|
37
|
+
- **[CLI Reference](https://thymian.dev/references/cli)** - Complete CLI command documentation
|
|
38
|
+
- **[HTTP Rules](https://thymian.dev/guides/http-rules/how-to-use-rules)** - Learn about HTTP conformance validation
|
|
39
|
+
|
|
40
|
+
## 🏢 Enterprise Support
|
|
41
|
+
|
|
42
|
+
Get professional consulting and dedicated support from the creators of Thymian. We offer:
|
|
43
|
+
|
|
44
|
+
- API design and governance strategies
|
|
45
|
+
- HTTP standards compliance auditing
|
|
46
|
+
- Custom plugin development
|
|
47
|
+
- Custom rule development
|
|
48
|
+
- Team training and workshops
|
|
49
|
+
|
|
50
|
+
**[Learn more about Enterprise Support](https://thymian.dev/enterprise)** | **Email: [support@thymian.dev](mailto:support@thymian.dev)**
|
|
4
51
|
|
|
5
|
-
|
|
52
|
+
---
|
|
6
53
|
|
|
7
|
-
|
|
54
|
+
<div align="center">
|
|
8
55
|
|
|
9
|
-
|
|
56
|
+
**Shipped with 🌱 by [qupaya](https://qupaya.com)**
|
|
10
57
|
|
|
11
|
-
|
|
58
|
+
</div>
|
|
59
|
+
<!-- FOOTER:END -->
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCliRunCommand, oclif } from '@thymian/common-cli';
|
|
2
|
+
export default class Check extends BaseCliRunCommand<typeof Check> {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
incremental: oclif.Interfaces.BooleanFlag<boolean>;
|
|
7
|
+
"target-url": oclif.Interfaces.OptionFlag<string | undefined, oclif.Interfaces.CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
private checkAllTransactions;
|
|
11
|
+
private checkTransactionsIncremental;
|
|
12
|
+
private isCheckableTransaction;
|
|
13
|
+
private checkTransaction;
|
|
14
|
+
private logFailureDetails;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAW,MAAM,qBAAqB,CAAC;AAoBxE,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,iBAAiB,CAAC,OAAO,KAAK,CAAC;IAChE,OAAgB,WAAW,SACoD;IAE/E,OAAgB,QAAQ,WAItB;IAEF,OAAgB,KAAK;;;MAWnB;IAEa,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAoBrB,oBAAoB;YAiDpB,4BAA4B;IAyD1C,OAAO,CAAC,sBAAsB;YAOhB,gBAAgB;IAmC9B,OAAO,CAAC,iBAAiB;CAkC1B"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { BaseCliRunCommand, oclif, prompts } from '@thymian/common-cli';
|
|
2
|
+
import { Flags } from '@thymian/common-cli/oclif';
|
|
3
|
+
import { getHeader, httpStatusCodeToPhrase, isValidClientErrorStatusCode, isValidHttpStatusCode, isValidSuccessfulStatusCode, serializeRequest, thymianHttpTransactionToString, } from '@thymian/core';
|
|
4
|
+
const MAX_BODY_PREVIEW_LENGTH = 500;
|
|
5
|
+
export default class Check extends BaseCliRunCommand {
|
|
6
|
+
static description = 'Verify that all sampled transactions can be executed against the live API.';
|
|
7
|
+
static examples = [
|
|
8
|
+
'<%= config.bin %> <%= command.id %>',
|
|
9
|
+
'<%= config.bin %> <%= command.id %> --target-url http://localhost:8080',
|
|
10
|
+
'<%= config.bin %> <%= command.id %> --incremental',
|
|
11
|
+
];
|
|
12
|
+
static flags = {
|
|
13
|
+
incremental: Flags.boolean({
|
|
14
|
+
allowNo: true,
|
|
15
|
+
default: false,
|
|
16
|
+
description: 'Check transactions one by one and offer to generate hooks for failures.',
|
|
17
|
+
}),
|
|
18
|
+
['target-url']: Flags.string({
|
|
19
|
+
description: 'Override the target URL for all check requests. When set, all requests are sent to this origin instead of the servers defined in the specification.',
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
async run() {
|
|
23
|
+
await this.thymian.run(async () => {
|
|
24
|
+
const specifications = this.thymianConfig.specifications ?? [];
|
|
25
|
+
const format = await this.thymian.loadFormat({
|
|
26
|
+
inputs: specifications,
|
|
27
|
+
});
|
|
28
|
+
const transactions = format.getThymianHttpTransactions();
|
|
29
|
+
const targetUrl = this.flags['target-url'] ?? this.thymianConfig.targetUrl;
|
|
30
|
+
if (this.flags.incremental) {
|
|
31
|
+
await this.checkTransactionsIncremental(transactions, targetUrl);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
await this.checkAllTransactions(transactions, targetUrl);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async checkAllTransactions(transactions, targetUrl) {
|
|
39
|
+
let successful = 0;
|
|
40
|
+
let failed = 0;
|
|
41
|
+
for (const transaction of transactions) {
|
|
42
|
+
if (!this.isCheckableTransaction(transaction)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const transactionName = thymianHttpTransactionToString(transaction.thymianReq, transaction.thymianRes);
|
|
46
|
+
this.logger.debug('Checking transaction: ' + transactionName);
|
|
47
|
+
const result = await this.checkTransaction(transaction, targetUrl);
|
|
48
|
+
if (result.passed) {
|
|
49
|
+
this.log(oclif.ux.colorize('green', `✔ ${transactionName}`));
|
|
50
|
+
successful++;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.log(oclif.ux.colorize('red', `✖ ${transactionName}`));
|
|
54
|
+
this.logFailureDetails(result);
|
|
55
|
+
this.log();
|
|
56
|
+
failed++;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
this.log();
|
|
60
|
+
if (failed > 0) {
|
|
61
|
+
this.log(`Checked ${successful + failed} transactions. ${oclif.ux.colorize('red', `${failed} failed`)}.`);
|
|
62
|
+
this.exit(1);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.log(oclif.ux.colorize('green', `Checked ${successful + failed} transactions. All passed.`));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async checkTransactionsIncremental(transactions, targetUrl) {
|
|
69
|
+
for (const transaction of transactions) {
|
|
70
|
+
if (!this.isCheckableTransaction(transaction)) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const transactionName = thymianHttpTransactionToString(transaction.thymianReq, transaction.thymianRes);
|
|
74
|
+
this.logger.debug('Checking transaction: ' + transactionName);
|
|
75
|
+
const result = await this.checkTransaction(transaction, targetUrl);
|
|
76
|
+
if (result.passed) {
|
|
77
|
+
this.log(oclif.ux.colorize('green', `✔ ${transactionName}`));
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
this.log(oclif.ux.colorize('red', `✖ ${transactionName}`));
|
|
81
|
+
this.logFailureDetails(result);
|
|
82
|
+
this.log();
|
|
83
|
+
this.log('You can generate a hook for this transaction with:');
|
|
84
|
+
this.log(` $ thymian sampler generate hook --for-transaction ${transaction.transactionId}`);
|
|
85
|
+
this.log();
|
|
86
|
+
if (!this.config.findCommand('sampler generate hook')) {
|
|
87
|
+
this.debug('Command sampler generate hook is not available. Skipping hook generation prompt.');
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const answer = await prompts.confirm({
|
|
91
|
+
message: 'Do you want to generate a hook to fix this transaction?',
|
|
92
|
+
default: false,
|
|
93
|
+
});
|
|
94
|
+
if (answer) {
|
|
95
|
+
await this.config.runCommand('sampler generate hook', [
|
|
96
|
+
'--for-transaction',
|
|
97
|
+
transaction.transactionId,
|
|
98
|
+
'--cwd',
|
|
99
|
+
this.flags.cwd,
|
|
100
|
+
...(this.flags.config ? ['-c', this.flags.config] : []),
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
isCheckableTransaction(transaction) {
|
|
106
|
+
return (isValidSuccessfulStatusCode(transaction.thymianRes.statusCode) ||
|
|
107
|
+
isValidClientErrorStatusCode(transaction.thymianRes.statusCode));
|
|
108
|
+
}
|
|
109
|
+
async checkTransaction(transaction, targetUrl) {
|
|
110
|
+
try {
|
|
111
|
+
const template = await this.thymian.sample({ transaction });
|
|
112
|
+
const request = serializeRequest({
|
|
113
|
+
requestTemplate: template,
|
|
114
|
+
source: transaction,
|
|
115
|
+
});
|
|
116
|
+
if (targetUrl) {
|
|
117
|
+
request.origin = targetUrl;
|
|
118
|
+
}
|
|
119
|
+
const response = await this.thymian.dispatch({ request });
|
|
120
|
+
if (response.statusCode !== transaction.thymianRes.statusCode) {
|
|
121
|
+
return {
|
|
122
|
+
passed: false,
|
|
123
|
+
reason: `Expected status ${transaction.thymianRes.statusCode}, got ${response.statusCode}.`,
|
|
124
|
+
response,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return { passed: true };
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
return {
|
|
131
|
+
passed: false,
|
|
132
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
logFailureDetails(result) {
|
|
137
|
+
this.log(oclif.ux.colorize('dim', ` Reason: ${result.reason}`));
|
|
138
|
+
if (!result.response) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const { statusCode, headers, body } = result.response;
|
|
142
|
+
const phrase = isValidHttpStatusCode(statusCode)
|
|
143
|
+
? httpStatusCodeToPhrase[statusCode]
|
|
144
|
+
: '';
|
|
145
|
+
const contentType = getHeader(headers, 'content-type');
|
|
146
|
+
const contentTypeStr = Array.isArray(contentType)
|
|
147
|
+
? contentType[0]
|
|
148
|
+
: contentType;
|
|
149
|
+
this.log(oclif.ux.colorize('dim', ` Received: ${statusCode} ${phrase}${contentTypeStr ? ` (${contentTypeStr})` : ''}`));
|
|
150
|
+
if (body) {
|
|
151
|
+
const preview = body.length > MAX_BODY_PREVIEW_LENGTH
|
|
152
|
+
? body.slice(0, MAX_BODY_PREVIEW_LENGTH) + '…'
|
|
153
|
+
: body;
|
|
154
|
+
this.log(oclif.ux.colorize('dim', ` Body: ${preview}`));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EACL,SAAS,EAET,sBAAsB,EACtB,4BAA4B,EAC5B,qBAAqB,EACrB,2BAA2B,EAC3B,gBAAgB,EAEhB,8BAA8B,GAC/B,MAAM,eAAe,CAAC;AAMvB,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,iBAA+B;IAChE,MAAM,CAAU,WA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AEF,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,OAAO,GACX,IAAI,CAAC,MAAM,GAAG,uBAAuB;gBACnC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,uBAAuB,CAAC,GAAG,GAAG;gBAC9C,CAAC,CAAC,IAAI,CAAC;YAEX,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,OAAO,EAAE,CAAC,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/sampler/generate/hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAKxD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,iBAAiB,CACzD,OAAO,YAAY,CACpB;IACC,OAAgB,OAAO,WAAyC;IAEhE,OAAgB,KAAK;;MAKnB;IAEa,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAWpC"}
|
|
@@ -2,7 +2,7 @@ import { BaseCliRunCommand } from '@thymian/common-cli';
|
|
|
2
2
|
import { Flags } from '@thymian/common-cli/oclif';
|
|
3
3
|
import { generateHook } from '../../../generate-hook.js';
|
|
4
4
|
export default class GenerateHook extends BaseCliRunCommand {
|
|
5
|
-
static aliases = ['sampler:
|
|
5
|
+
static aliases = ['sampler:g:h', 'sampler:generate:h'];
|
|
6
6
|
static flags = {
|
|
7
7
|
'for-transaction': Flags.string({
|
|
8
8
|
description: 'For which transaction do you want to generate a hook?',
|
|
@@ -15,4 +15,4 @@ export default class GenerateHook extends BaseCliRunCommand {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
//# sourceMappingURL=
|
|
18
|
+
//# sourceMappingURL=hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../../../src/cli/commands/sampler/generate/hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,iBAEzC;IACC,MAAM,CAAU,OAAO,GAAG,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;IAEhE,MAAM,CAAU,KAAK,GAAG;QACtB,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC;YAC9B,WAAW,EAAE,uDAAuD;YACpE,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH,CAAC;IAEO,KAAK,CAAC,GAAG;QAChB,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACvC,MAAM,YAAY,CAChB,IAAI,CAAC,OAAO,EACZ,OAAO,EACP,IAAI,EACJ,IAAI,CAAC,KAAK,CAAC,GAAG,EACd,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAC9B,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAW,MAAM,qBAAqB,CAAC;AAExE,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,iBAAiB,CAAC,OAAO,IAAI,CAAC;IAC9D,OAAgB,KAAK;;;MAYnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAW,MAAM,qBAAqB,CAAC;AAExE,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,iBAAiB,CAAC,OAAO,IAAI,CAAC;IAC9D,OAAgB,KAAK;;;MAYnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAyD3B"}
|
|
@@ -6,7 +6,7 @@ export default class Init extends BaseCliRunCommand {
|
|
|
6
6
|
description: 'Overwrite existing samples.',
|
|
7
7
|
}),
|
|
8
8
|
check: oclif.Flags.boolean({
|
|
9
|
-
description: 'After initialization, run
|
|
9
|
+
description: 'After initialization, run sampler check to verify all transactions can be executed.',
|
|
10
10
|
allowNo: true,
|
|
11
11
|
default: false,
|
|
12
12
|
}),
|
|
@@ -18,7 +18,7 @@ export default class Init extends BaseCliRunCommand {
|
|
|
18
18
|
exit: 1,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
const format = await this.thymian.loadFormat({ inputs: [] }, {
|
|
21
|
+
const format = await this.thymian.loadFormat({ inputs: this.thymianConfig.specifications ?? [] }, {
|
|
22
22
|
emitFormat: true,
|
|
23
23
|
});
|
|
24
24
|
await emitter.emitAction('sampler.init', {
|
|
@@ -28,7 +28,7 @@ export default class Init extends BaseCliRunCommand {
|
|
|
28
28
|
});
|
|
29
29
|
this.log(oclif.ux.colorize('green', 'Sampler initialized.'));
|
|
30
30
|
if (this.flags.check) {
|
|
31
|
-
if (this.config.findCommand('
|
|
31
|
+
if (this.config.findCommand('sampler check')) {
|
|
32
32
|
this.log();
|
|
33
33
|
const answer = await prompts.confirm({
|
|
34
34
|
message: 'Do you want to run this check now?',
|
|
@@ -39,7 +39,7 @@ export default class Init extends BaseCliRunCommand {
|
|
|
39
39
|
if (this.flags.config) {
|
|
40
40
|
args.push('-c', this.flags.config);
|
|
41
41
|
}
|
|
42
|
-
await this.config.runCommand('
|
|
42
|
+
await this.config.runCommand('sampler check', args);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -47,7 +47,7 @@ export default class Init extends BaseCliRunCommand {
|
|
|
47
47
|
this.log();
|
|
48
48
|
this.log('To check if every transaction can be executed, run:');
|
|
49
49
|
this.log();
|
|
50
|
-
this.log('$ thymian
|
|
50
|
+
this.log('$ thymian sampler check');
|
|
51
51
|
this.log();
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,iBAA8B;IAC9D,MAAM,CAAU,KAAK,GAAG;QACtB,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;YAC7B,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,6BAA6B;SAC3C,CAAC;QAEF,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;YACzB,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../src/cli/commands/sampler/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,iBAA8B;IAC9D,MAAM,CAAU,KAAK,GAAG;QACtB,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;YAC7B,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,6BAA6B;SAC3C,CAAC;QAEF,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;YACzB,WAAW,EACT,qFAAqF;YACvF,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,KAAK;SACf,CAAC;KACH,CAAC;IAEF,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,OAAO,C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EAAE,CAAC;wBACtB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBACrC,CAAC;oBAED,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;gBACtD,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;YAChE,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;YACpC,IAAI,CAAC,GAAG,EAAE,CAAC;QACb,CAAC;IACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thymian/plugin-sampler",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-canary.20260408-c479a4a",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/thymianofficial/thymian/issues"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://thymian.dev",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/thymianofficial/thymian.git",
|
|
12
|
+
"directory": "packages/plugin-sampler"
|
|
13
|
+
},
|
|
5
14
|
"publishConfig": {
|
|
6
15
|
"access": "public"
|
|
7
16
|
},
|
|
@@ -22,9 +31,9 @@
|
|
|
22
31
|
"!**/*.tsbuildinfo"
|
|
23
32
|
],
|
|
24
33
|
"dependencies": {
|
|
25
|
-
"@thymian/common-cli": "0.1.
|
|
26
|
-
"@thymian/core": "0.1.
|
|
27
|
-
"@thymian/plugin-request-dispatcher": "0.1.
|
|
34
|
+
"@thymian/common-cli": "0.1.2-canary.20260408-c479a4a",
|
|
35
|
+
"@thymian/core": "0.1.2-canary.20260408-c479a4a",
|
|
36
|
+
"@thymian/plugin-request-dispatcher": "0.1.2-canary.20260408-c479a4a",
|
|
28
37
|
"code-block-writer": "^13.0.3",
|
|
29
38
|
"jiti": "^2.6.1",
|
|
30
39
|
"json-schema-to-typescript": "^15.0.4",
|
|
@@ -44,7 +53,7 @@
|
|
|
44
53
|
}
|
|
45
54
|
},
|
|
46
55
|
"devDependencies": {
|
|
47
|
-
"@thymian/core-testing": "0.1.
|
|
56
|
+
"@thymian/core-testing": "0.1.2-canary.20260408-c479a4a",
|
|
48
57
|
"fast-json-stable-stringify": "^2.1.0",
|
|
49
58
|
"ts-morph": "^27.0.2"
|
|
50
59
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/sampler/hooks/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAKxD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,iBAAiB,CACzD,OAAO,YAAY,CACpB;IACC,OAAgB,OAAO,WAAsC;IAE7D,OAAgB,KAAK;;MAKnB;IAEa,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAWpC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../../src/cli/commands/sampler/hooks/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,iBAEzC;IACC,MAAM,CAAU,OAAO,GAAG,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;IAE7D,MAAM,CAAU,KAAK,GAAG;QACtB,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC;YAC9B,WAAW,EAAE,uDAAuD;YACpE,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH,CAAC;IAEO,KAAK,CAAC,GAAG;QAChB,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACvC,MAAM,YAAY,CAChB,IAAI,CAAC,OAAO,EACZ,OAAO,EACP,IAAI,EACJ,IAAI,CAAC,KAAK,CAAC,GAAG,EACd,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAC9B,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC"}
|