@ripplo/testing 0.4.7 → 0.5.0
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 +62 -19
- package/dist/actions.d.ts +10 -2
- package/dist/actions.js +24 -2
- package/dist/assert.d.ts +1 -1
- package/dist/{builder-BMjy83Iy.d.ts → builder-DiVz3t1D.d.ts} +10 -3
- package/dist/{chunk-V6LMXKGL.js → chunk-XO36IU66.js} +32 -38
- package/dist/{chunk-DL3HLCD7.js → chunk-YFOTJIVF.js} +1 -1
- package/dist/compiler.d.ts +8 -3
- package/dist/compiler.js +1 -1
- package/dist/elysia.d.ts +3 -3
- package/dist/elysia.js +16 -23
- package/dist/{engine-DMOkJdjd.d.ts → engine-DVbF4E5A.d.ts} +20 -6
- package/dist/express.d.ts +3 -3
- package/dist/express.js +16 -45
- package/dist/fastify.d.ts +3 -3
- package/dist/fastify.js +16 -24
- package/dist/hono.d.ts +3 -3
- package/dist/hono.js +17 -24
- package/dist/index.d.ts +32 -13
- package/dist/index.js +247 -88
- package/dist/koa.d.ts +3 -3
- package/dist/koa.js +17 -20
- package/dist/lockfile.d.ts +20 -5
- package/dist/lockfile.js +89 -3
- package/dist/nestjs.d.ts +3 -3
- package/dist/nestjs.js +15 -20
- package/dist/nextjs.d.ts +3 -3
- package/dist/nextjs.js +16 -23
- package/dist/{types-16SB7zjP.d.ts → types-BzZrl65Z.d.ts} +9 -2
- package/package.json +3 -3
package/dist/express.js
CHANGED
|
@@ -2,10 +2,11 @@ import {
|
|
|
2
2
|
batchRequestSchema,
|
|
3
3
|
observerRequestSchema,
|
|
4
4
|
readAdapterWebhookSecret,
|
|
5
|
-
serializeCookie,
|
|
6
5
|
teardownRequestSchema,
|
|
6
|
+
toBatchRunResults,
|
|
7
|
+
toTeardownResults,
|
|
7
8
|
verifyWebhookSignature
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XO36IU66.js";
|
|
9
10
|
import "./chunk-4MGIQFAJ.js";
|
|
10
11
|
|
|
11
12
|
// src/adapters/express.ts
|
|
@@ -29,22 +30,13 @@ function createExpressHandler({ enabled, engine }) {
|
|
|
29
30
|
router.put("/execute-preconditions", (req, res) => {
|
|
30
31
|
const parsed = batchRequestSchema.safeParse(req.body);
|
|
31
32
|
if (!parsed.success) {
|
|
32
|
-
res.status(400).json({ error: "Invalid request body"
|
|
33
|
+
res.status(400).json({ error: "Invalid request body" });
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
36
|
const appUrl = `${req.protocol}://${req.get("host") ?? ""}`;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
res.cookie(s.name, s.value, buildExpressCookieOptions(s));
|
|
40
|
-
});
|
|
41
|
-
res.json({
|
|
42
|
-
data: result.data,
|
|
43
|
-
error: result.error,
|
|
44
|
-
executed: result.executed,
|
|
45
|
-
runId: result.runId,
|
|
46
|
-
success: result.success
|
|
47
|
-
});
|
|
37
|
+
const items = parsed.data.batch.map((b) => ({ names: b.preconditions, runId: b.runId }));
|
|
38
|
+
void engine.executePreconditions(items, { appUrl }).then((results) => {
|
|
39
|
+
res.json({ results: toBatchRunResults(results) });
|
|
48
40
|
});
|
|
49
41
|
});
|
|
50
42
|
router.put("/execute-observer", (req, res) => {
|
|
@@ -54,21 +46,22 @@ function createExpressHandler({ enabled, engine }) {
|
|
|
54
46
|
return;
|
|
55
47
|
}
|
|
56
48
|
void engine.executeObserver(parsed.data.observer, parsed.data.params).then((result) => {
|
|
57
|
-
res.json({
|
|
58
|
-
error: result.error,
|
|
59
|
-
outcome: result.outcome,
|
|
60
|
-
success: result.success
|
|
61
|
-
});
|
|
49
|
+
res.json({ error: result.error, outcome: result.outcome, success: result.success });
|
|
62
50
|
});
|
|
63
51
|
});
|
|
64
52
|
router.put("/teardown-preconditions", (req, res) => {
|
|
65
53
|
const parsed = teardownRequestSchema.safeParse(req.body);
|
|
66
54
|
if (!parsed.success) {
|
|
67
|
-
res.status(400).json({ error: "Invalid request body"
|
|
55
|
+
res.status(400).json({ error: "Invalid request body" });
|
|
68
56
|
return;
|
|
69
57
|
}
|
|
70
|
-
|
|
71
|
-
|
|
58
|
+
const items = parsed.data.batch.map((b) => ({
|
|
59
|
+
data: b.data,
|
|
60
|
+
names: b.preconditions,
|
|
61
|
+
runId: b.runId
|
|
62
|
+
}));
|
|
63
|
+
void engine.teardown(items).then((results) => {
|
|
64
|
+
res.json({ results: toTeardownResults(results) });
|
|
72
65
|
});
|
|
73
66
|
});
|
|
74
67
|
return router;
|
|
@@ -89,28 +82,6 @@ function asString(value) {
|
|
|
89
82
|
}
|
|
90
83
|
return void 0;
|
|
91
84
|
}
|
|
92
|
-
function buildExpressCookieOptions(s) {
|
|
93
|
-
const opts = {};
|
|
94
|
-
if (s.domain != null) {
|
|
95
|
-
opts.domain = s.domain;
|
|
96
|
-
}
|
|
97
|
-
if (s.expires != null) {
|
|
98
|
-
opts.expires = s.expires;
|
|
99
|
-
}
|
|
100
|
-
if (s.httpOnly != null) {
|
|
101
|
-
opts.httpOnly = s.httpOnly;
|
|
102
|
-
}
|
|
103
|
-
if (s.path != null) {
|
|
104
|
-
opts.path = s.path;
|
|
105
|
-
}
|
|
106
|
-
if (s.sameSite != null) {
|
|
107
|
-
opts.sameSite = s.sameSite;
|
|
108
|
-
}
|
|
109
|
-
if (s.secure != null) {
|
|
110
|
-
opts.secure = s.secure;
|
|
111
|
-
}
|
|
112
|
-
return opts;
|
|
113
|
-
}
|
|
114
85
|
export {
|
|
115
86
|
createExpressHandler
|
|
116
87
|
};
|
package/dist/fastify.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FastifyInstance } from 'fastify';
|
|
2
|
-
import { R as RipploEngine } from './engine-
|
|
3
|
-
import './builder-
|
|
4
|
-
import './types-
|
|
2
|
+
import { R as RipploEngine } from './engine-DVbF4E5A.js';
|
|
3
|
+
import './builder-DiVz3t1D.js';
|
|
4
|
+
import './types-BzZrl65Z.js';
|
|
5
5
|
import './step-De52hTLd.js';
|
|
6
6
|
import '@ripplo/spec';
|
|
7
7
|
|
package/dist/fastify.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
batchRequestSchema,
|
|
3
|
-
buildSetCookieHeader,
|
|
4
3
|
observerRequestSchema,
|
|
5
4
|
readAdapterWebhookSecret,
|
|
6
|
-
serializeCookie,
|
|
7
5
|
teardownRequestSchema,
|
|
6
|
+
toBatchRunResults,
|
|
7
|
+
toTeardownResults,
|
|
8
8
|
verifyWebhookSignature
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XO36IU66.js";
|
|
10
10
|
import "./chunk-4MGIQFAJ.js";
|
|
11
11
|
|
|
12
12
|
// src/adapters/fastify.ts
|
|
@@ -34,21 +34,12 @@ function registerFastifyHandler({
|
|
|
34
34
|
fastify.put("/execute-preconditions", async (req, reply) => {
|
|
35
35
|
const parsed = batchRequestSchema.safeParse(req.body);
|
|
36
36
|
if (!parsed.success) {
|
|
37
|
-
return reply.code(400).send({ error: "Invalid request body"
|
|
37
|
+
return reply.code(400).send({ error: "Invalid request body" });
|
|
38
38
|
}
|
|
39
39
|
const appUrl = `${req.protocol}://${req.hostname}`;
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
reply.header("Set-Cookie", buildSetCookieHeader(s));
|
|
44
|
-
});
|
|
45
|
-
return reply.send({
|
|
46
|
-
data: result.data,
|
|
47
|
-
error: result.error,
|
|
48
|
-
executed: result.executed,
|
|
49
|
-
runId: result.runId,
|
|
50
|
-
success: result.success
|
|
51
|
-
});
|
|
40
|
+
const items = parsed.data.batch.map((b) => ({ names: b.preconditions, runId: b.runId }));
|
|
41
|
+
const results = await engine.executePreconditions(items, { appUrl });
|
|
42
|
+
return reply.send({ results: toBatchRunResults(results) });
|
|
52
43
|
});
|
|
53
44
|
fastify.put("/execute-observer", async (req, reply) => {
|
|
54
45
|
const parsed = observerRequestSchema.safeParse(req.body);
|
|
@@ -56,19 +47,20 @@ function registerFastifyHandler({
|
|
|
56
47
|
return reply.code(400).send({ error: "Invalid request body", success: false });
|
|
57
48
|
}
|
|
58
49
|
const result = await engine.executeObserver(parsed.data.observer, parsed.data.params);
|
|
59
|
-
return reply.send({
|
|
60
|
-
error: result.error,
|
|
61
|
-
outcome: result.outcome,
|
|
62
|
-
success: result.success
|
|
63
|
-
});
|
|
50
|
+
return reply.send({ error: result.error, outcome: result.outcome, success: result.success });
|
|
64
51
|
});
|
|
65
52
|
fastify.put("/teardown-preconditions", async (req, reply) => {
|
|
66
53
|
const parsed = teardownRequestSchema.safeParse(req.body);
|
|
67
54
|
if (!parsed.success) {
|
|
68
|
-
return reply.code(400).send({ error: "Invalid request body"
|
|
55
|
+
return reply.code(400).send({ error: "Invalid request body" });
|
|
69
56
|
}
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
const items = parsed.data.batch.map((b) => ({
|
|
58
|
+
data: b.data,
|
|
59
|
+
names: b.preconditions,
|
|
60
|
+
runId: b.runId
|
|
61
|
+
}));
|
|
62
|
+
const results = await engine.teardown(items);
|
|
63
|
+
return reply.send({ results: toTeardownResults(results) });
|
|
72
64
|
});
|
|
73
65
|
};
|
|
74
66
|
}
|
package/dist/hono.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import { R as RipploEngine } from './engine-
|
|
3
|
-
import './builder-
|
|
4
|
-
import './types-
|
|
2
|
+
import { R as RipploEngine } from './engine-DVbF4E5A.js';
|
|
3
|
+
import './builder-DiVz3t1D.js';
|
|
4
|
+
import './types-BzZrl65Z.js';
|
|
5
5
|
import './step-De52hTLd.js';
|
|
6
6
|
import '@ripplo/spec';
|
|
7
7
|
|
package/dist/hono.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
batchRequestSchema,
|
|
3
|
-
buildSetCookieHeader,
|
|
4
3
|
observerRequestSchema,
|
|
5
4
|
readAdapterWebhookSecret,
|
|
6
|
-
serializeCookie,
|
|
7
5
|
teardownRequestSchema,
|
|
6
|
+
toBatchRunResults,
|
|
7
|
+
toTeardownResults,
|
|
8
8
|
verifyWebhookSignature
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XO36IU66.js";
|
|
10
10
|
import "./chunk-4MGIQFAJ.js";
|
|
11
11
|
|
|
12
12
|
// src/adapters/hono.ts
|
|
@@ -22,25 +22,17 @@ function createHonoHandler({ enabled, engine }) {
|
|
|
22
22
|
const body = tryParseJson(c.get("rawBody"));
|
|
23
23
|
const parsed = body == null ? null : batchRequestSchema.safeParse(body);
|
|
24
24
|
if (parsed == null || !parsed.success) {
|
|
25
|
-
return c.json({ error: "Invalid request body"
|
|
25
|
+
return c.json({ error: "Invalid request body" }, 400);
|
|
26
26
|
}
|
|
27
27
|
const host = c.req.header("host");
|
|
28
28
|
if (host == null || host.length === 0) {
|
|
29
|
-
return c.json({ error: "Missing host header"
|
|
29
|
+
return c.json({ error: "Missing host header" }, 400);
|
|
30
30
|
}
|
|
31
31
|
const proto = c.req.header("x-forwarded-proto") ?? "http";
|
|
32
32
|
const appUrl = `${proto}://${host}`;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
37
|
-
return c.json({
|
|
38
|
-
data: result.data,
|
|
39
|
-
error: result.error,
|
|
40
|
-
executed: result.executed,
|
|
41
|
-
runId: result.runId,
|
|
42
|
-
success: result.success
|
|
43
|
-
});
|
|
33
|
+
const items = parsed.data.batch.map((b) => ({ names: b.preconditions, runId: b.runId }));
|
|
34
|
+
const results = await engine.executePreconditions(items, { appUrl });
|
|
35
|
+
return c.json({ results: toBatchRunResults(results) });
|
|
44
36
|
});
|
|
45
37
|
app.put("/execute-observer", async (c) => {
|
|
46
38
|
const body = tryParseJson(c.get("rawBody"));
|
|
@@ -49,20 +41,21 @@ function createHonoHandler({ enabled, engine }) {
|
|
|
49
41
|
return c.json({ error: "Invalid request body", success: false }, 400);
|
|
50
42
|
}
|
|
51
43
|
const result = await engine.executeObserver(parsed.data.observer, parsed.data.params);
|
|
52
|
-
return c.json({
|
|
53
|
-
error: result.error,
|
|
54
|
-
outcome: result.outcome,
|
|
55
|
-
success: result.success
|
|
56
|
-
});
|
|
44
|
+
return c.json({ error: result.error, outcome: result.outcome, success: result.success });
|
|
57
45
|
});
|
|
58
46
|
app.put("/teardown-preconditions", async (c) => {
|
|
59
47
|
const body = tryParseJson(c.get("rawBody"));
|
|
60
48
|
const parsed = body == null ? null : teardownRequestSchema.safeParse(body);
|
|
61
49
|
if (parsed == null || !parsed.success) {
|
|
62
|
-
return c.json({ error: "Invalid request body"
|
|
50
|
+
return c.json({ error: "Invalid request body" }, 400);
|
|
63
51
|
}
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
const items = parsed.data.batch.map((b) => ({
|
|
53
|
+
data: b.data,
|
|
54
|
+
names: b.preconditions,
|
|
55
|
+
runId: b.runId
|
|
56
|
+
}));
|
|
57
|
+
const results = await engine.teardown(items);
|
|
58
|
+
return c.json({ results: toTeardownResults(results) });
|
|
66
59
|
});
|
|
67
60
|
return app;
|
|
68
61
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { C as CoverageRegistry, O as ObserverImplFn, a as ObserverRegistry, P as PreconditionImpl, b as PreconditionRecord, c as PreconditionRegistry, R as ResolveDeps, d as RipploBuilder, e as RipploInstance, f as RipploRegistries, g as createRipplo, o as observer, p as precondition, t as test } from './builder-
|
|
1
|
+
export { C as CoverageRegistry, O as ObserverImplFn, a as ObserverRegistry, P as PreconditionImpl, b as PreconditionRecord, c as PreconditionRegistry, R as ResolveDeps, d as RipploBuilder, e as RipploInstance, f as RipploRegistries, g as createRipplo, o as observer, p as precondition, t as test } from './builder-DiVz3t1D.js';
|
|
2
2
|
import { CompileResult } from './compiler.js';
|
|
3
3
|
export { CompiledTest, compile } from './compiler.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { E as EngineRunResult, T as TeardownRunResult$1 } from './engine-DVbF4E5A.js';
|
|
5
|
+
export { a as EngineImpls, b as ExecuteBatchItem, c as ExecuteBatchOptions, N as NotImplemented, O as ObserverImplFnFor, P as PreconditionImplFor, R as RipploEngine, d as TeardownBatchItem, e as createEngine, n as notImplemented } from './engine-DVbF4E5A.js';
|
|
6
|
+
import { C as CookieEntry } from './types-BzZrl65Z.js';
|
|
7
|
+
export { c as CookieOptions, D as DEFAULT_IGNORE_PATHS, d as DEFAULT_WATCH_PATHS, e as ObserverContext, f as ObserverDefinition, O as ObserverHandle, a as ObserverInput, g as ObserverOutcome, h as Precondition, i as PreconditionDeps, P as Primitive, S as SetupContext, T as TeardownContext, j as TestDefinition, k as TestValue } from './types-BzZrl65Z.js';
|
|
7
8
|
export { D as DslNodeInput } from './step-De52hTLd.js';
|
|
8
9
|
import '@ripplo/spec';
|
|
9
10
|
|
|
@@ -18,15 +19,10 @@ interface LintResult {
|
|
|
18
19
|
}
|
|
19
20
|
declare function lint(result: CompileResult): LintResult;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
readonly "webhook-id": string | undefined;
|
|
23
|
-
readonly "webhook-signature": string | undefined;
|
|
24
|
-
readonly "webhook-timestamp": string | undefined;
|
|
25
|
-
}
|
|
26
|
-
declare function verifyWebhookSignature(payload: string, headers: WebhookHeaders, secret: string): boolean;
|
|
22
|
+
declare function readAdapterWebhookSecret(): string;
|
|
27
23
|
interface SerializedCookie {
|
|
28
24
|
readonly domain: string | undefined;
|
|
29
|
-
readonly expires:
|
|
25
|
+
readonly expires: number | undefined;
|
|
30
26
|
readonly httpOnly: boolean | undefined;
|
|
31
27
|
readonly name: string;
|
|
32
28
|
readonly path: string | undefined;
|
|
@@ -34,7 +30,30 @@ interface SerializedCookie {
|
|
|
34
30
|
readonly secure: boolean | undefined;
|
|
35
31
|
readonly value: string;
|
|
36
32
|
}
|
|
33
|
+
type BatchRunResult = {
|
|
34
|
+
readonly cookies: ReadonlyArray<SerializedCookie>;
|
|
35
|
+
readonly data: Record<string, Record<string, string | number | boolean>>;
|
|
36
|
+
readonly executed: ReadonlyArray<string>;
|
|
37
|
+
readonly ok: true;
|
|
38
|
+
readonly runId: string;
|
|
39
|
+
} | {
|
|
40
|
+
readonly error: string;
|
|
41
|
+
readonly ok: false;
|
|
42
|
+
readonly runId: string;
|
|
43
|
+
};
|
|
44
|
+
type TeardownRunResult = {
|
|
45
|
+
readonly error: string | undefined;
|
|
46
|
+
readonly ok: boolean;
|
|
47
|
+
readonly runId: string;
|
|
48
|
+
};
|
|
49
|
+
interface WebhookHeaders {
|
|
50
|
+
readonly "webhook-id": string | undefined;
|
|
51
|
+
readonly "webhook-signature": string | undefined;
|
|
52
|
+
readonly "webhook-timestamp": string | undefined;
|
|
53
|
+
}
|
|
54
|
+
declare function verifyWebhookSignature(payload: string, headers: WebhookHeaders, secret: string): boolean;
|
|
37
55
|
declare function serializeCookie(cookie: CookieEntry): SerializedCookie;
|
|
38
|
-
declare function
|
|
56
|
+
declare function toBatchRunResults(results: ReadonlyArray<EngineRunResult>): ReadonlyArray<BatchRunResult>;
|
|
57
|
+
declare function toTeardownResults(results: ReadonlyArray<TeardownRunResult$1>): ReadonlyArray<TeardownRunResult>;
|
|
39
58
|
|
|
40
|
-
export { CompileResult, CookieEntry, type LintDiagnostic, type LintResult, type SerializedCookie,
|
|
59
|
+
export { CompileResult, CookieEntry, EngineRunResult, type LintDiagnostic, type LintResult, type SerializedCookie, TeardownRunResult$1 as TeardownRunResult, lint, readAdapterWebhookSecret, serializeCookie, toBatchRunResults, toTeardownResults, verifyWebhookSignature };
|