@gcoredev/fastedge-test 0.1.7 → 0.2.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.
Files changed (40) hide show
  1. package/dist/frontend/assets/{index-BCXfEMSq.js → index-CiqeJ9rz.js} +24 -24
  2. package/dist/frontend/index.html +1 -1
  3. package/dist/lib/index.cjs +130 -62
  4. package/dist/lib/index.d.ts +1 -0
  5. package/dist/lib/index.js +130 -62
  6. package/dist/lib/runner/HeaderManager.d.ts +6 -4
  7. package/dist/lib/runner/HostFunctions.d.ts +5 -5
  8. package/dist/lib/runner/HttpWasmRunner.d.ts +13 -4
  9. package/dist/lib/runner/IStateManager.d.ts +7 -7
  10. package/dist/lib/runner/IWasmRunner.d.ts +17 -9
  11. package/dist/lib/runner/PropertyResolver.d.ts +3 -3
  12. package/dist/lib/runner/ProxyWasmRunner.d.ts +5 -2
  13. package/dist/lib/runner/standalone.d.ts +1 -1
  14. package/dist/lib/runner/types.d.ts +17 -8
  15. package/dist/lib/schemas/api.d.ts +0 -8
  16. package/dist/lib/schemas/config.d.ts +0 -13
  17. package/dist/lib/schemas/index.d.ts +2 -2
  18. package/dist/lib/test-framework/assertions.d.ts +18 -4
  19. package/dist/lib/test-framework/index.cjs +18593 -111
  20. package/dist/lib/test-framework/index.d.ts +2 -0
  21. package/dist/lib/test-framework/index.js +18610 -100
  22. package/dist/lib/test-framework/mock-origins.d.ts +56 -0
  23. package/dist/lib/test-framework/types.d.ts +1 -5
  24. package/dist/server.js +33 -33
  25. package/docs/API.md +19 -49
  26. package/docs/DEBUGGER.md +6 -7
  27. package/docs/INDEX.md +4 -1
  28. package/docs/RUNNER.md +96 -81
  29. package/docs/TEST_CONFIG.md +9 -22
  30. package/docs/TEST_FRAMEWORK.md +206 -31
  31. package/docs/WEBSOCKET.md +25 -21
  32. package/docs/quickstart.md +1 -13
  33. package/package.json +4 -1
  34. package/schemas/api-config.schema.json +0 -24
  35. package/schemas/api-send.schema.json +0 -20
  36. package/schemas/fastedge-config.test.schema.json +0 -24
  37. package/schemas/full-flow-result.schema.json +17 -7
  38. package/schemas/hook-call.schema.json +16 -6
  39. package/schemas/hook-result.schema.json +16 -6
  40. package/schemas/http-response.schema.json +227 -5
@@ -1,16 +1,25 @@
1
1
  export type HeaderMap = Record<string, string>;
2
2
  export type HeaderTuples = [string, string][];
3
+ export type HeaderRecord = Record<string, string | string[]>;
3
4
  export type HookCall = {
4
5
  hook: string;
5
6
  request: {
6
- headers: HeaderMap;
7
+ headers: HeaderRecord;
7
8
  body: string;
8
9
  method?: string;
9
10
  path?: string;
10
11
  scheme?: string;
11
12
  };
12
- response: {
13
- headers: HeaderMap;
13
+ /**
14
+ * Seed state for the response hooks (`onResponseHeaders` / `onResponseBody`)
15
+ * when calling them in isolation via `callHook()`. The full-flow path
16
+ * (`callFullFlow`) generates the upstream response at runtime and does not
17
+ * consume this field — request hooks ignore it, and response hooks are
18
+ * called with the response built from the live origin fetch or built-in
19
+ * responder output.
20
+ */
21
+ response?: {
22
+ headers: HeaderRecord;
14
23
  body: string;
15
24
  status?: number;
16
25
  statusText?: string;
@@ -27,22 +36,22 @@ export type HookResult = {
27
36
  }[];
28
37
  input: {
29
38
  request: {
30
- headers: HeaderMap;
39
+ headers: HeaderRecord;
31
40
  body: string;
32
41
  };
33
42
  response: {
34
- headers: HeaderMap;
43
+ headers: HeaderRecord;
35
44
  body: string;
36
45
  };
37
46
  properties?: Record<string, unknown>;
38
47
  };
39
48
  output: {
40
49
  request: {
41
- headers: HeaderMap;
50
+ headers: HeaderRecord;
42
51
  body: string;
43
52
  };
44
53
  response: {
45
- headers: HeaderMap;
54
+ headers: HeaderRecord;
46
55
  body: string;
47
56
  };
48
57
  properties?: Record<string, unknown>;
@@ -78,7 +87,7 @@ export type FullFlowResult = {
78
87
  finalResponse: {
79
88
  status: number;
80
89
  statusText: string;
81
- headers: HeaderMap;
90
+ headers: HeaderRecord;
82
91
  body: string;
83
92
  contentType: string;
84
93
  isBase64?: boolean;
@@ -16,10 +16,6 @@ export declare const ApiSendBodySchema: z.ZodObject<{
16
16
  headers: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>>;
17
17
  body: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>;
18
18
  }, z.core.$strip>>;
19
- response: z.ZodOptional<z.ZodObject<{
20
- headers: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>>;
21
- body: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>;
22
- }, z.core.$strip>>;
23
19
  properties: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
24
20
  }, z.core.$strip>;
25
21
  export declare const ApiCallBodySchema: z.ZodObject<{
@@ -79,10 +75,6 @@ export declare const ApiConfigBodySchema: z.ZodObject<{
79
75
  headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
80
76
  body: z.ZodDefault<z.ZodOptional<z.ZodString>>;
81
77
  }, z.core.$strip>;
82
- response: z.ZodOptional<z.ZodObject<{
83
- headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
84
- body: z.ZodDefault<z.ZodOptional<z.ZodString>>;
85
- }, z.core.$strip>>;
86
78
  }, z.core.$strip>]>;
87
79
  }, z.core.$strip>;
88
80
  export type ApiLoadBody = z.infer<typeof ApiLoadBodySchema>;
@@ -15,10 +15,6 @@ export declare const HttpRequestConfigSchema: z.ZodObject<{
15
15
  headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
16
16
  body: z.ZodDefault<z.ZodOptional<z.ZodString>>;
17
17
  }, z.core.$strip>;
18
- export declare const ResponseConfigSchema: z.ZodObject<{
19
- headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
20
- body: z.ZodDefault<z.ZodOptional<z.ZodString>>;
21
- }, z.core.$strip>;
22
18
  declare const CdnConfigSchema: z.ZodObject<{
23
19
  $schema: z.ZodOptional<z.ZodString>;
24
20
  description: z.ZodOptional<z.ZodString>;
@@ -38,10 +34,6 @@ declare const CdnConfigSchema: z.ZodObject<{
38
34
  headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
39
35
  body: z.ZodDefault<z.ZodOptional<z.ZodString>>;
40
36
  }, z.core.$strip>;
41
- response: z.ZodOptional<z.ZodObject<{
42
- headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
43
- body: z.ZodDefault<z.ZodOptional<z.ZodString>>;
44
- }, z.core.$strip>>;
45
37
  }, z.core.$strip>;
46
38
  declare const HttpConfigSchema: z.ZodObject<{
47
39
  $schema: z.ZodOptional<z.ZodString>;
@@ -103,10 +95,6 @@ export declare const TestConfigSchema: z.ZodUnion<readonly [z.ZodObject<{
103
95
  headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
104
96
  body: z.ZodDefault<z.ZodOptional<z.ZodString>>;
105
97
  }, z.core.$strip>;
106
- response: z.ZodOptional<z.ZodObject<{
107
- headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
108
- body: z.ZodDefault<z.ZodOptional<z.ZodString>>;
109
- }, z.core.$strip>>;
110
98
  }, z.core.$strip>]>;
111
99
  export declare const RequestConfigSchema: z.ZodObject<{
112
100
  method: z.ZodDefault<z.ZodString>;
@@ -118,7 +106,6 @@ export type WasmConfig = z.infer<typeof WasmConfigSchema>;
118
106
  export type CdnRequestConfig = z.infer<typeof CdnRequestConfigSchema>;
119
107
  export type HttpRequestConfig = z.infer<typeof HttpRequestConfigSchema>;
120
108
  export type RequestConfig = z.infer<typeof CdnRequestConfigSchema>;
121
- export type ResponseConfig = z.infer<typeof ResponseConfigSchema>;
122
109
  export type CdnConfig = z.infer<typeof CdnConfigSchema>;
123
110
  export type HttpConfig = z.infer<typeof HttpConfigSchema>;
124
111
  export type TestConfig = z.infer<typeof TestConfigSchema>;
@@ -1,4 +1,4 @@
1
- export { WasmConfigSchema, RequestConfigSchema, ResponseConfigSchema, TestConfigSchema, } from './config';
2
- export type { WasmConfig, RequestConfig, ResponseConfig, TestConfig, } from './config';
1
+ export { WasmConfigSchema, RequestConfigSchema, TestConfigSchema, } from './config';
2
+ export type { WasmConfig, RequestConfig, TestConfig, } from './config';
3
3
  export { ApiLoadBodySchema, ApiSendBodySchema, ApiCallBodySchema, ApiConfigBodySchema, } from './api';
4
4
  export type { ApiLoadBody, ApiSendBody, ApiCallBody, ApiConfigBody, } from './api';
@@ -9,8 +9,12 @@ import type { HttpResponse } from "../runner/IWasmRunner.js";
9
9
  /**
10
10
  * Assert that a named header exists (and optionally matches a value)
11
11
  * in the hook's output request headers.
12
+ *
13
+ * When `expected` is a string and the header is multi-valued, passes if
14
+ * any value matches (`.includes()` semantics). When `expected` is a string[],
15
+ * requires an exact array match.
12
16
  */
13
- export declare function assertRequestHeader(result: HookResult, name: string, expected?: string): void;
17
+ export declare function assertRequestHeader(result: HookResult, name: string, expected?: string | string[]): void;
14
18
  /**
15
19
  * Assert that a named header is absent in the hook's output request headers.
16
20
  */
@@ -18,8 +22,12 @@ export declare function assertNoRequestHeader(result: HookResult, name: string):
18
22
  /**
19
23
  * Assert that a named header exists (and optionally matches a value)
20
24
  * in the hook's output response headers.
25
+ *
26
+ * When `expected` is a string and the header is multi-valued (e.g. set-cookie),
27
+ * passes if any value matches (`.includes()` semantics). When `expected` is a
28
+ * string[], requires an exact array match.
21
29
  */
22
- export declare function assertResponseHeader(result: HookResult, name: string, expected?: string): void;
30
+ export declare function assertResponseHeader(result: HookResult, name: string, expected?: string | string[]): void;
23
31
  /**
24
32
  * Assert that a named header is absent in the hook's output response headers.
25
33
  */
@@ -31,8 +39,10 @@ export declare function assertFinalStatus(result: FullFlowResult, expected: numb
31
39
  /**
32
40
  * Assert that a named header exists (and optionally matches a value)
33
41
  * in the final response headers from a full-flow run.
42
+ *
43
+ * Multi-value semantics match {@link assertResponseHeader}.
34
44
  */
35
- export declare function assertFinalHeader(result: FullFlowResult, name: string, expected?: string): void;
45
+ export declare function assertFinalHeader(result: FullFlowResult, name: string, expected?: string | string[]): void;
36
46
  /**
37
47
  * Assert the hook return code (e.g. 0 = Ok, 1 = Pause).
38
48
  */
@@ -68,8 +78,12 @@ export declare function assertHttpStatus(response: HttpResponse, expected: numbe
68
78
  /**
69
79
  * Assert that a named header exists (and optionally matches a value)
70
80
  * in the HTTP response.
81
+ *
82
+ * Multi-value semantics: when `expected` is a string and the header is
83
+ * multi-valued (e.g. set-cookie is `string[]` per RFC 6265), passes if any
84
+ * value matches. When `expected` is a string[], requires exact array match.
71
85
  */
72
- export declare function assertHttpHeader(response: HttpResponse, name: string, expected?: string): void;
86
+ export declare function assertHttpHeader(response: HttpResponse, name: string, expected?: string | string[]): void;
73
87
  /**
74
88
  * Assert that a named header is absent in the HTTP response.
75
89
  */