@ripplo/testing 0.4.8 → 0.5.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 +48 -18
- package/dist/actions.d.ts +2 -0
- package/dist/actions.js +1 -0
- 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/compiler.d.ts +2 -2
- 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 +220 -86
- package/dist/koa.d.ts +3 -3
- package/dist/koa.js +17 -20
- package/dist/lockfile.d.ts +8 -2
- package/dist/lockfile.js +6 -1
- 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 +1 -1
package/dist/nestjs.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
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/nestjs.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 {
|
|
11
11
|
__decorateClass,
|
|
12
12
|
__decorateParam
|
|
@@ -45,25 +45,15 @@ function createController(path) {
|
|
|
45
45
|
}
|
|
46
46
|
const parsed = batchRequestSchema.safeParse(req.body);
|
|
47
47
|
if (!parsed.success) {
|
|
48
|
-
res.status(400).json({ error: "Invalid request body"
|
|
48
|
+
res.status(400).json({ error: "Invalid request body" });
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
const host = req.get("host") ?? "";
|
|
52
52
|
const proto = req.get("x-forwarded-proto") ?? req.protocol;
|
|
53
53
|
const appUrl = `${proto}://${host}`;
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
result.cookies.forEach((cookie) => {
|
|
58
|
-
res.append("Set-Cookie", buildSetCookieHeader(serializeCookie(cookie)));
|
|
59
|
-
});
|
|
60
|
-
res.status(200).json({
|
|
61
|
-
data: result.data,
|
|
62
|
-
error: result.error,
|
|
63
|
-
executed: result.executed,
|
|
64
|
-
runId: result.runId,
|
|
65
|
-
success: result.success
|
|
66
|
-
});
|
|
54
|
+
const items = parsed.data.batch.map((b) => ({ names: b.preconditions, runId: b.runId }));
|
|
55
|
+
const results = await this.opts.engine.executePreconditions(items, { appUrl });
|
|
56
|
+
res.status(200).json({ results: toBatchRunResults(results) });
|
|
67
57
|
}
|
|
68
58
|
async executeObserver(req, res) {
|
|
69
59
|
if (!guard(req, res, this.opts)) {
|
|
@@ -86,11 +76,16 @@ function createController(path) {
|
|
|
86
76
|
}
|
|
87
77
|
const parsed = teardownRequestSchema.safeParse(req.body);
|
|
88
78
|
if (!parsed.success) {
|
|
89
|
-
res.status(400).json({ error: "Invalid request body"
|
|
79
|
+
res.status(400).json({ error: "Invalid request body" });
|
|
90
80
|
return;
|
|
91
81
|
}
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
const items = parsed.data.batch.map((b) => ({
|
|
83
|
+
data: b.data,
|
|
84
|
+
names: b.preconditions,
|
|
85
|
+
runId: b.runId
|
|
86
|
+
}));
|
|
87
|
+
const results = await this.opts.engine.teardown(items);
|
|
88
|
+
res.status(200).json({ results: toTeardownResults(results) });
|
|
94
89
|
}
|
|
95
90
|
};
|
|
96
91
|
__decorateClass([
|
package/dist/nextjs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as RipploEngine } from './engine-
|
|
2
|
-
import './builder-
|
|
3
|
-
import './types-
|
|
1
|
+
import { R as RipploEngine } from './engine-DVbF4E5A.js';
|
|
2
|
+
import './builder-DiVz3t1D.js';
|
|
3
|
+
import './types-BzZrl65Z.js';
|
|
4
4
|
import './step-De52hTLd.js';
|
|
5
5
|
import '@ripplo/spec';
|
|
6
6
|
|
package/dist/nextjs.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/nextjs.ts
|
|
@@ -59,38 +59,31 @@ async function handleExecutePreconditions({
|
|
|
59
59
|
const json = tryParseJson(body);
|
|
60
60
|
const parsed = json == null ? null : batchRequestSchema.safeParse(json);
|
|
61
61
|
if (parsed == null || !parsed.success) {
|
|
62
|
-
return jsonResponse({ error: "Invalid request body"
|
|
62
|
+
return jsonResponse({ error: "Invalid request body" }, 400);
|
|
63
63
|
}
|
|
64
64
|
const host = req.headers.get("host");
|
|
65
65
|
if (host == null || host.length === 0) {
|
|
66
|
-
return jsonResponse({ error: "Missing host header"
|
|
66
|
+
return jsonResponse({ error: "Missing host header" }, 400);
|
|
67
67
|
}
|
|
68
68
|
const proto = req.headers.get("x-forwarded-proto") ?? "http";
|
|
69
69
|
const appUrl = `${proto}://${host}`;
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
headers.append("Set-Cookie", buildSetCookieHeader(serializeCookie(cookie)));
|
|
74
|
-
});
|
|
75
|
-
return new Response(
|
|
76
|
-
JSON.stringify({
|
|
77
|
-
data: result.data,
|
|
78
|
-
error: result.error,
|
|
79
|
-
executed: result.executed,
|
|
80
|
-
runId: result.runId,
|
|
81
|
-
success: result.success
|
|
82
|
-
}),
|
|
83
|
-
{ headers, status: 200 }
|
|
84
|
-
);
|
|
70
|
+
const items = parsed.data.batch.map((b) => ({ names: b.preconditions, runId: b.runId }));
|
|
71
|
+
const results = await engine.executePreconditions(items, { appUrl });
|
|
72
|
+
return jsonResponse({ results: toBatchRunResults(results) }, 200);
|
|
85
73
|
}
|
|
86
74
|
async function handleTeardown({ body, engine }) {
|
|
87
75
|
const json = tryParseJson(body);
|
|
88
76
|
const parsed = json == null ? null : teardownRequestSchema.safeParse(json);
|
|
89
77
|
if (parsed == null || !parsed.success) {
|
|
90
|
-
return jsonResponse({ error: "Invalid request body"
|
|
78
|
+
return jsonResponse({ error: "Invalid request body" }, 400);
|
|
91
79
|
}
|
|
92
|
-
|
|
93
|
-
|
|
80
|
+
const items = parsed.data.batch.map((b) => ({
|
|
81
|
+
data: b.data,
|
|
82
|
+
names: b.preconditions,
|
|
83
|
+
runId: b.runId
|
|
84
|
+
}));
|
|
85
|
+
const results = await engine.teardown(items);
|
|
86
|
+
return jsonResponse({ results: toTeardownResults(results) }, 200);
|
|
94
87
|
}
|
|
95
88
|
async function verifyAndReadBody(req, webhookSecret) {
|
|
96
89
|
if (webhookSecret.length === 0) {
|
|
@@ -40,6 +40,13 @@ interface Precondition<TData extends Record<string, Primitive> = Record<string,
|
|
|
40
40
|
}
|
|
41
41
|
type PreconditionData<T extends Precondition> = T[typeof PRECONDITION_DATA];
|
|
42
42
|
type PreconditionDeps<T extends Precondition> = T[typeof PRECONDITION_DEPS];
|
|
43
|
+
interface PreconditionDefinitionSetupItem {
|
|
44
|
+
readonly ctx: SetupContext;
|
|
45
|
+
readonly deps: Record<string, Record<string, Primitive>>;
|
|
46
|
+
}
|
|
47
|
+
interface PreconditionDefinitionTeardownItem {
|
|
48
|
+
readonly ctx: TeardownContext<Record<string, Primitive>>;
|
|
49
|
+
}
|
|
43
50
|
interface PreconditionDefinition {
|
|
44
51
|
readonly dependsOn: ReadonlyArray<string>;
|
|
45
52
|
readonly depMapping: ReadonlyArray<readonly [string, string]>;
|
|
@@ -47,8 +54,8 @@ interface PreconditionDefinition {
|
|
|
47
54
|
readonly implemented: boolean;
|
|
48
55
|
readonly name: string;
|
|
49
56
|
readonly returns: ReadonlyArray<string>;
|
|
50
|
-
readonly teardown: ((
|
|
51
|
-
readonly setup: (
|
|
57
|
+
readonly teardown: ((items: ReadonlyArray<PreconditionDefinitionTeardownItem>) => Promise<void>) | undefined;
|
|
58
|
+
readonly setup: (items: ReadonlyArray<PreconditionDefinitionSetupItem>) => Promise<ReadonlyArray<Record<string, Primitive>>>;
|
|
52
59
|
}
|
|
53
60
|
type VarsFn<T> = (vars: Record<string, Record<string, Primitive>>) => T;
|
|
54
61
|
interface TestDefinition {
|