executable-stories-showcase 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +17 -2
- package/dist/adapters/cookies.d.ts +11 -0
- package/dist/adapters/cookies.js +27 -0
- package/dist/adapters/cookies.js.map +1 -0
- package/dist/adapters/redux.d.ts +23 -0
- package/dist/adapters/redux.js +28 -0
- package/dist/adapters/redux.js.map +1 -0
- package/dist/adapters/tanstack-query.d.ts +17 -0
- package/dist/adapters/tanstack-query.js +43 -0
- package/dist/adapters/tanstack-query.js.map +1 -0
- package/dist/adapters/xstate.d.ts +33 -0
- package/dist/adapters/xstate.js +36 -0
- package/dist/adapters/xstate.js.map +1 -0
- package/dist/adapters/zustand.d.ts +17 -0
- package/dist/adapters/zustand.js +16 -0
- package/dist/adapters/zustand.js.map +1 -0
- package/dist/capture-CIKR46QE.js +10 -0
- package/dist/capture-CIKR46QE.js.map +1 -0
- package/dist/capture.d.ts +26 -0
- package/dist/catalog.d.ts +27 -0
- package/dist/chunk-BK4EEQXV.js +98 -0
- package/dist/chunk-BK4EEQXV.js.map +1 -0
- package/dist/chunk-C755RCRL.js +125 -0
- package/dist/chunk-C755RCRL.js.map +1 -0
- package/dist/chunk-COLHEOSE.js +148 -0
- package/dist/chunk-COLHEOSE.js.map +1 -0
- package/dist/chunk-DETES767.js +43 -0
- package/dist/chunk-DETES767.js.map +1 -0
- package/dist/chunk-ESIS3D6R.js +47 -0
- package/dist/chunk-ESIS3D6R.js.map +1 -0
- package/dist/chunk-MCC3CAWQ.js +208 -0
- package/dist/chunk-MCC3CAWQ.js.map +1 -0
- package/dist/chunk-XLNYICOI.js +234 -0
- package/dist/chunk-XLNYICOI.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +531 -0
- package/dist/index.js.map +1 -0
- package/dist/jwt.d.ts +7 -0
- package/dist/link.d.ts +33 -0
- package/dist/network-I5SB4F6T.js +7 -0
- package/dist/network-I5SB4F6T.js.map +1 -0
- package/dist/network.d.ts +3 -0
- package/dist/next.d.ts +21 -0
- package/dist/next.js +30 -0
- package/dist/next.js.map +1 -0
- package/dist/no-msw-browser.d.ts +2 -0
- package/dist/no-msw-browser.js +8 -0
- package/dist/no-msw-browser.js.map +1 -0
- package/dist/panel.d.ts +30 -0
- package/dist/panel.js +607 -0
- package/dist/panel.js.map +1 -0
- package/dist/playwright.d.ts +31 -0
- package/dist/playwright.js +92 -0
- package/dist/playwright.js.map +1 -0
- package/dist/ready-4MENAMNI.js +13 -0
- package/dist/ready-4MENAMNI.js.map +1 -0
- package/dist/ready.d.ts +39 -0
- package/dist/record.d.ts +49 -0
- package/dist/redact.d.ts +18 -0
- package/dist/runtime.d.ts +191 -0
- package/dist/save.d.ts +27 -0
- package/dist/schema.d.ts +161 -0
- package/dist/vite.d.ts +11 -0
- package/dist/vite.js +26 -0
- package/dist/vite.js.map +1 -0
- package/package.json +118 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# executable-stories-showcase
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Put a running app into any state from a URL. Scenarios are JSON files that set network fixtures, URL params and app state. A dev panel lets you switch between them, inspect and edit live state, and save it as a shareable link. Playwright helpers open scenarios in tests, and adapters connect TanStack Query, Zustand, Redux and XState.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { type ScenarioInput, startScenarios } from 'executable-stories-showcase';
|
|
7
|
+
import { mountPanel } from 'executable-stories-showcase/panel';
|
|
8
|
+
|
|
9
|
+
const session = await startScenarios({
|
|
10
|
+
scenarios: Object.values(
|
|
11
|
+
import.meta.glob<ScenarioInput>('./scenarios/*.json', { eager: true, import: 'default' }),
|
|
12
|
+
),
|
|
13
|
+
defaultScenario: 'default',
|
|
14
|
+
});
|
|
15
|
+
mountPanel(session);
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Documentation: https://github.com/jagreehal/executable-stories
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TypedAdapter } from '../runtime.js';
|
|
2
|
+
/**
|
|
3
|
+
* Connects `document.cookie` as `state.cookies` (or your key): `{ "authToken": "fake" }`.
|
|
4
|
+
* Applied before the app renders, so cookie-based auth gates let the scenario in.
|
|
5
|
+
* It overwrites real cookies with the same name: sign in again after leaving scenarios.
|
|
6
|
+
* Inline links can't set it; link to a catalog scenario by name instead.
|
|
7
|
+
*/
|
|
8
|
+
export declare const cookiesAdapter: ({ key, path }?: {
|
|
9
|
+
key?: string;
|
|
10
|
+
path?: string;
|
|
11
|
+
}) => TypedAdapter<Record<string, string>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/adapters/cookies.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var CookiesSchema = z.record(z.string(), z.string());
|
|
4
|
+
var cookiesAdapter = ({ key = "cookies", path = "/" } = {}) => ({
|
|
5
|
+
key,
|
|
6
|
+
schema: CookiesSchema,
|
|
7
|
+
apply: (cookies) => {
|
|
8
|
+
for (const [name, value] of Object.entries(cookies)) {
|
|
9
|
+
document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}; path=${path}`;
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
read: () => Object.fromEntries(
|
|
13
|
+
document.cookie.split("; ").filter(Boolean).map((c) => {
|
|
14
|
+
const i = c.indexOf("=");
|
|
15
|
+
return [decodeURIComponent(c.slice(0, i)), decodeURIComponent(c.slice(i + 1))];
|
|
16
|
+
})
|
|
17
|
+
),
|
|
18
|
+
// Cookie libraries (react-cookie, js-cookie) read once at startup.
|
|
19
|
+
inPlace: false,
|
|
20
|
+
// A cookie outlives the scenario and reaches the real backend, so only catalog
|
|
21
|
+
// scenarios, which live in the repo, set it.
|
|
22
|
+
fromLinks: false
|
|
23
|
+
});
|
|
24
|
+
export {
|
|
25
|
+
cookiesAdapter
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=cookies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/cookies.ts"],"sourcesContent":["import { z } from 'zod';\nimport type { TypedAdapter } from '../runtime.js';\n\nconst CookiesSchema = z.record(z.string(), z.string());\n\n/**\n * Connects `document.cookie` as `state.cookies` (or your key): `{ \"authToken\": \"fake\" }`.\n * Applied before the app renders, so cookie-based auth gates let the scenario in.\n * It overwrites real cookies with the same name: sign in again after leaving scenarios.\n * Inline links can't set it; link to a catalog scenario by name instead.\n */\nexport const cookiesAdapter = (\n { key = 'cookies', path = '/' }: { key?: string; path?: string; } = {},\n): TypedAdapter<Record<string, string>> => ({\n key,\n schema: CookiesSchema,\n apply: (cookies) => {\n for (const [name, value] of Object.entries(cookies)) {\n document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}; path=${path}`;\n }\n },\n read: () =>\n Object.fromEntries(\n document.cookie.split('; ').filter(Boolean).map((c) => {\n const i = c.indexOf('=');\n\n return [decodeURIComponent(c.slice(0, i)), decodeURIComponent(c.slice(i + 1))];\n }),\n ),\n // Cookie libraries (react-cookie, js-cookie) read once at startup.\n inPlace: false,\n // A cookie outlives the scenario and reaches the real backend, so only catalog\n // scenarios, which live in the repo, set it.\n fromLinks: false,\n});\n"],"mappings":";AAAA,SAAS,SAAS;AAGlB,IAAM,gBAAgB,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;AAQ9C,IAAM,iBAAiB,CAC5B,EAAE,MAAM,WAAW,OAAO,IAAI,IAAsC,CAAC,OAC3B;AAAA,EAC1C;AAAA,EACA,QAAQ;AAAA,EACR,OAAO,CAAC,YAAY;AAClB,eAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AACnD,eAAS,SAAS,GAAG,mBAAmB,IAAI,CAAC,IAAI,mBAAmB,KAAK,CAAC,UAAU,IAAI;AAAA,IAC1F;AAAA,EACF;AAAA,EACA,MAAM,MACJ,OAAO;AAAA,IACL,SAAS,OAAO,MAAM,IAAI,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,MAAM;AACrD,YAAM,IAAI,EAAE,QAAQ,GAAG;AAEvB,aAAO,CAAC,mBAAmB,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,mBAAmB,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC;AAAA,IAC/E,CAAC;AAAA,EACH;AAAA;AAAA,EAEF,SAAS;AAAA;AAAA;AAAA,EAGT,WAAW;AACb;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { JsonAdapter } from '../runtime.js';
|
|
3
|
+
import { type Json, type Serializable } from '../schema.js';
|
|
4
|
+
export declare const SCENARIO_HYDRATE = "@@scenarios/hydrate";
|
|
5
|
+
interface Action {
|
|
6
|
+
type: string;
|
|
7
|
+
payload?: Json;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Wrap your root reducer so scenario state can be merged in. Objects deep-merge into the
|
|
11
|
+
* current state and `null` removes a key; `schema` checks the result is still valid state.
|
|
12
|
+
*/
|
|
13
|
+
export declare function withScenarioState<S extends Serializable, A extends Action>(reducer: (state: S | undefined, action: A) => S, schema: z.ZodType<S>): (state: S | undefined, action: A) => S;
|
|
14
|
+
interface Store {
|
|
15
|
+
dispatch(action: Action): void;
|
|
16
|
+
getState(): Serializable;
|
|
17
|
+
subscribe(listener: () => void): () => void;
|
|
18
|
+
}
|
|
19
|
+
/** Connects a Redux store as `state.redux` (or your key). Needs `withScenarioState`. */
|
|
20
|
+
export declare const reduxAdapter: (store: Store, { key }?: {
|
|
21
|
+
key?: string;
|
|
22
|
+
}) => JsonAdapter;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deepMerge
|
|
3
|
+
} from "../chunk-MCC3CAWQ.js";
|
|
4
|
+
import {
|
|
5
|
+
parseJson
|
|
6
|
+
} from "../chunk-BK4EEQXV.js";
|
|
7
|
+
|
|
8
|
+
// src/adapters/redux.ts
|
|
9
|
+
var SCENARIO_HYDRATE = "@@scenarios/hydrate";
|
|
10
|
+
function withScenarioState(reducer, schema) {
|
|
11
|
+
return (state, action) => {
|
|
12
|
+
if (action.type !== SCENARIO_HYDRATE || action.payload === void 0) return reducer(state, action);
|
|
13
|
+
const base = state ?? reducer(void 0, action);
|
|
14
|
+
return schema.parse(deepMerge(parseJson(JSON.stringify(base)), action.payload));
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
var reduxAdapter = (store, { key = "redux" } = {}) => ({
|
|
18
|
+
key,
|
|
19
|
+
apply: (payload) => store.dispatch({ type: SCENARIO_HYDRATE, payload }),
|
|
20
|
+
read: () => parseJson(JSON.stringify(store.getState())),
|
|
21
|
+
subscribe: (onChange) => store.subscribe(onChange)
|
|
22
|
+
});
|
|
23
|
+
export {
|
|
24
|
+
SCENARIO_HYDRATE,
|
|
25
|
+
reduxAdapter,
|
|
26
|
+
withScenarioState
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=redux.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/redux.ts"],"sourcesContent":["import type { z } from 'zod';\nimport { deepMerge } from '../catalog.js';\nimport type { JsonAdapter } from '../runtime.js';\nimport { type Json, parseJson, type Serializable } from '../schema.js';\n\nexport const SCENARIO_HYDRATE = '@@scenarios/hydrate';\n\ninterface Action {\n type: string;\n payload?: Json;\n}\n\n/**\n * Wrap your root reducer so scenario state can be merged in. Objects deep-merge into the\n * current state and `null` removes a key; `schema` checks the result is still valid state.\n */\nexport function withScenarioState<S extends Serializable, A extends Action>(\n reducer: (state: S | undefined, action: A) => S,\n schema: z.ZodType<S>,\n) {\n return (state: S | undefined, action: A): S => {\n if (action.type !== SCENARIO_HYDRATE || action.payload === undefined) return reducer(state, action);\n // Reducers return their initial state for an action they don't handle.\n const base = state ?? reducer(undefined, action);\n\n return schema.parse(deepMerge(parseJson(JSON.stringify(base)), action.payload));\n };\n}\n\ninterface Store {\n dispatch(action: Action): void;\n getState(): Serializable;\n subscribe(listener: () => void): () => void;\n}\n\n/** Connects a Redux store as `state.redux` (or your key). Needs `withScenarioState`. */\nexport const reduxAdapter = (store: Store, { key = 'redux' }: { key?: string; } = {}): JsonAdapter => ({\n key,\n apply: (payload) => store.dispatch({ type: SCENARIO_HYDRATE, payload }),\n read: () => parseJson(JSON.stringify(store.getState())),\n subscribe: (onChange) => store.subscribe(onChange),\n});\n"],"mappings":";;;;;;;;AAKO,IAAM,mBAAmB;AAWzB,SAAS,kBACd,SACA,QACA;AACA,SAAO,CAAC,OAAsB,WAAiB;AAC7C,QAAI,OAAO,SAAS,oBAAoB,OAAO,YAAY,OAAW,QAAO,QAAQ,OAAO,MAAM;AAElG,UAAM,OAAO,SAAS,QAAQ,QAAW,MAAM;AAE/C,WAAO,OAAO,MAAM,UAAU,UAAU,KAAK,UAAU,IAAI,CAAC,GAAG,OAAO,OAAO,CAAC;AAAA,EAChF;AACF;AASO,IAAM,eAAe,CAAC,OAAc,EAAE,MAAM,QAAQ,IAAuB,CAAC,OAAoB;AAAA,EACrG;AAAA,EACA,OAAO,CAAC,YAAY,MAAM,SAAS,EAAE,MAAM,kBAAkB,QAAQ,CAAC;AAAA,EACtE,MAAM,MAAM,UAAU,KAAK,UAAU,MAAM,SAAS,CAAC,CAAC;AAAA,EACtD,WAAW,CAAC,aAAa,MAAM,UAAU,QAAQ;AACnD;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { TypedAdapter } from '../runtime.js';
|
|
4
|
+
export declare const tanstackQueryState: z.ZodArray<z.ZodObject<{
|
|
5
|
+
queryKey: z.ZodArray<z.ZodJSONSchema>;
|
|
6
|
+
data: z.ZodJSONSchema;
|
|
7
|
+
stale: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
}, z.core.$strip>>;
|
|
9
|
+
type CacheState = z.output<typeof tanstackQueryState>;
|
|
10
|
+
/**
|
|
11
|
+
* Connects the TanStack Query cache as `state["tanstack-query"]`:
|
|
12
|
+
* [{ "queryKey": ["countries"], "data": [...] }]
|
|
13
|
+
* Seeds states the network alone can't produce (cached data while a refetch hangs),
|
|
14
|
+
* and lets the panel inspect, edit and capture the live cache.
|
|
15
|
+
*/
|
|
16
|
+
export declare const tanstackQuery: (client: QueryClient) => TypedAdapter<CacheState>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
JsonSchema,
|
|
3
|
+
parseJson
|
|
4
|
+
} from "../chunk-BK4EEQXV.js";
|
|
5
|
+
|
|
6
|
+
// src/adapters/tanstack-query.ts
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
var tanstackQueryState = z.array(
|
|
9
|
+
z.object({
|
|
10
|
+
queryKey: z.array(JsonSchema).min(1),
|
|
11
|
+
data: JsonSchema,
|
|
12
|
+
/** Refetch on mount (e.g. to show a background refresh). Default: fresh, so the data stays as given. */
|
|
13
|
+
stale: z.boolean().optional()
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
var tanstackQuery = (client) => ({
|
|
17
|
+
key: "tanstack-query",
|
|
18
|
+
schema: tanstackQueryState,
|
|
19
|
+
async apply(entries) {
|
|
20
|
+
for (const { queryKey, data, stale } of entries) {
|
|
21
|
+
if (!stale) await client.cancelQueries({ queryKey, exact: true });
|
|
22
|
+
client.setQueryData(queryKey, data);
|
|
23
|
+
if (stale) void client.invalidateQueries({ queryKey, exact: true, refetchType: "none" });
|
|
24
|
+
else client.setQueryDefaults(queryKey, { staleTime: Infinity });
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
read: () => parseJson(JSON.stringify(
|
|
28
|
+
client.getQueryCache().getAll().flatMap(
|
|
29
|
+
(query) => query.state.data === void 0 ? [] : [{
|
|
30
|
+
queryKey: query.queryKey,
|
|
31
|
+
data: query.state.data,
|
|
32
|
+
// A refresh in flight is part of what's on screen ("Refreshing…"), so capture it.
|
|
33
|
+
stale: query.state.fetchStatus === "fetching" || void 0
|
|
34
|
+
}]
|
|
35
|
+
)
|
|
36
|
+
)),
|
|
37
|
+
subscribe: (onChange) => client.getQueryCache().subscribe(onChange)
|
|
38
|
+
});
|
|
39
|
+
export {
|
|
40
|
+
tanstackQuery,
|
|
41
|
+
tanstackQueryState
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=tanstack-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/tanstack-query.ts"],"sourcesContent":["import type { QueryClient } from '@tanstack/react-query';\nimport { z } from 'zod';\nimport type { TypedAdapter } from '../runtime.js';\nimport { JsonSchema, parseJson } from '../schema.js';\n\nexport const tanstackQueryState = z.array(\n z.object({\n queryKey: z.array(JsonSchema).min(1),\n data: JsonSchema,\n /** Refetch on mount (e.g. to show a background refresh). Default: fresh, so the data stays as given. */\n stale: z.boolean().optional(),\n }),\n);\n\ntype CacheState = z.output<typeof tanstackQueryState>;\n\n/**\n * Connects the TanStack Query cache as `state[\"tanstack-query\"]`:\n * [{ \"queryKey\": [\"countries\"], \"data\": [...] }]\n * Seeds states the network alone can't produce (cached data while a refetch hangs),\n * and lets the panel inspect, edit and capture the live cache.\n */\nexport const tanstackQuery = (client: QueryClient): TypedAdapter<CacheState> => ({\n key: 'tanstack-query',\n schema: tanstackQueryState,\n async apply(entries) {\n for (const { queryKey, data, stale } of entries) {\n // A refetch started by a scenario switch must not land on top of fresh scenario data.\n if (!stale) await client.cancelQueries({ queryKey, exact: true });\n client.setQueryData(queryKey, data);\n\n // Fresh by default, so a saved scenario reproduces the screen instead of refetching over it.\n if (stale) void client.invalidateQueries({ queryKey, exact: true, refetchType: 'none' });\n else client.setQueryDefaults(queryKey, { staleTime: Infinity });\n }\n },\n read: () =>\n parseJson(JSON.stringify(\n client.getQueryCache().getAll().flatMap((query) =>\n query.state.data === undefined ? [] : [{\n queryKey: query.queryKey,\n data: query.state.data,\n // A refresh in flight is part of what's on screen (\"Refreshing…\"), so capture it.\n stale: query.state.fetchStatus === 'fetching' || undefined,\n }]\n ),\n )),\n subscribe: (onChange) => client.getQueryCache().subscribe(onChange),\n});\n"],"mappings":";;;;;;AACA,SAAS,SAAS;AAIX,IAAM,qBAAqB,EAAE;AAAA,EAClC,EAAE,OAAO;AAAA,IACP,UAAU,EAAE,MAAM,UAAU,EAAE,IAAI,CAAC;AAAA,IACnC,MAAM;AAAA;AAAA,IAEN,OAAO,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,CAAC;AACH;AAUO,IAAM,gBAAgB,CAAC,YAAmD;AAAA,EAC/E,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM,MAAM,SAAS;AACnB,eAAW,EAAE,UAAU,MAAM,MAAM,KAAK,SAAS;AAE/C,UAAI,CAAC,MAAO,OAAM,OAAO,cAAc,EAAE,UAAU,OAAO,KAAK,CAAC;AAChE,aAAO,aAAa,UAAU,IAAI;AAGlC,UAAI,MAAO,MAAK,OAAO,kBAAkB,EAAE,UAAU,OAAO,MAAM,aAAa,OAAO,CAAC;AAAA,UAClF,QAAO,iBAAiB,UAAU,EAAE,WAAW,SAAS,CAAC;AAAA,IAChE;AAAA,EACF;AAAA,EACA,MAAM,MACJ,UAAU,KAAK;AAAA,IACb,OAAO,cAAc,EAAE,OAAO,EAAE;AAAA,MAAQ,CAAC,UACvC,MAAM,MAAM,SAAS,SAAY,CAAC,IAAI,CAAC;AAAA,QACrC,UAAU,MAAM;AAAA,QAChB,MAAM,MAAM,MAAM;AAAA;AAAA,QAElB,OAAO,MAAM,MAAM,gBAAgB,cAAc;AAAA,MACnD,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAAA,EACH,WAAW,CAAC,aAAa,OAAO,cAAc,EAAE,UAAU,QAAQ;AACpE;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { TypedAdapter } from '../runtime.js';
|
|
3
|
+
/** XState's state value: "loading", or { "checkout": "payment" } for nested states. */
|
|
4
|
+
type StateValue = string | {
|
|
5
|
+
[state: string]: StateValue;
|
|
6
|
+
};
|
|
7
|
+
export declare const xstateState: z.ZodObject<{
|
|
8
|
+
value: z.ZodType<StateValue, unknown, z.core.$ZodTypeInternals<StateValue, unknown>>;
|
|
9
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
interface Machine<Context, Snapshot> {
|
|
12
|
+
config: {
|
|
13
|
+
context?: unknown;
|
|
14
|
+
};
|
|
15
|
+
resolveState(config: {
|
|
16
|
+
value: StateValue;
|
|
17
|
+
context: Context;
|
|
18
|
+
}): Snapshot;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolves `state.xstate` into a snapshot. Start your actor from it:
|
|
22
|
+
* `createActor(machine, { snapshot: adapter.snapshot })`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function xstateAdapter<Context, Snapshot>(machine: Machine<Context, Snapshot>, { key, context: contextSchema }: {
|
|
25
|
+
key?: string;
|
|
26
|
+
context: z.ZodType<Context>;
|
|
27
|
+
}): TypedAdapter<{
|
|
28
|
+
value: StateValue;
|
|
29
|
+
context?: Record<string, z.core.util.JSONType> | undefined;
|
|
30
|
+
}> & {
|
|
31
|
+
snapshot?: Snapshot;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deepMerge
|
|
3
|
+
} from "../chunk-MCC3CAWQ.js";
|
|
4
|
+
import {
|
|
5
|
+
JsonSchema
|
|
6
|
+
} from "../chunk-BK4EEQXV.js";
|
|
7
|
+
|
|
8
|
+
// src/adapters/xstate.ts
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
var StateValueSchema = z.lazy(
|
|
11
|
+
() => z.union([z.string(), z.record(z.string(), StateValueSchema)])
|
|
12
|
+
);
|
|
13
|
+
var xstateState = z.object({
|
|
14
|
+
value: StateValueSchema,
|
|
15
|
+
/** Merged over the machine's initial context, then decoded with the context schema. */
|
|
16
|
+
context: z.record(z.string(), JsonSchema).optional()
|
|
17
|
+
});
|
|
18
|
+
function xstateAdapter(machine, { key = "xstate", context: contextSchema }) {
|
|
19
|
+
const adapter = {
|
|
20
|
+
key,
|
|
21
|
+
schema: xstateState,
|
|
22
|
+
// The actor starts from the snapshot once, so a new one needs a reload.
|
|
23
|
+
inPlace: false,
|
|
24
|
+
apply({ value, context }) {
|
|
25
|
+
const initial = JsonSchema.safeParse(machine.config.context ?? {});
|
|
26
|
+
const merged = deepMerge(initial.success ? initial.data : {}, context ?? {});
|
|
27
|
+
adapter.snapshot = machine.resolveState({ value, context: contextSchema.parse(merged) });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return adapter;
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
xstateAdapter,
|
|
34
|
+
xstateState
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=xstate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/xstate.ts"],"sourcesContent":["import { z } from 'zod';\nimport { deepMerge } from '../catalog.js';\nimport type { TypedAdapter } from '../runtime.js';\nimport { JsonSchema } from '../schema.js';\n\n/** XState's state value: \"loading\", or { \"checkout\": \"payment\" } for nested states. */\ntype StateValue = string | { [state: string]: StateValue; };\n\nconst StateValueSchema: z.ZodType<StateValue> = z.lazy(() =>\n z.union([z.string(), z.record(z.string(), StateValueSchema)])\n);\n\nexport const xstateState = z.object({\n value: StateValueSchema,\n /** Merged over the machine's initial context, then decoded with the context schema. */\n context: z.record(z.string(), JsonSchema).optional(),\n});\n\ntype MachineState = z.output<typeof xstateState>;\n\ninterface Machine<Context, Snapshot> {\n config: { context?: unknown; };\n resolveState(config: { value: StateValue; context: Context; }): Snapshot;\n}\n\n/**\n * Resolves `state.xstate` into a snapshot. Start your actor from it:\n * `createActor(machine, { snapshot: adapter.snapshot })`.\n */\nexport function xstateAdapter<Context, Snapshot>(\n machine: Machine<Context, Snapshot>,\n { key = 'xstate', context: contextSchema }: { key?: string; context: z.ZodType<Context>; },\n) {\n const adapter: TypedAdapter<MachineState> & { snapshot?: Snapshot; } = {\n key,\n schema: xstateState,\n // The actor starts from the snapshot once, so a new one needs a reload.\n inPlace: false,\n apply({ value, context }) {\n // Context factories can't be merged into; only a plain JSON context is.\n const initial = JsonSchema.safeParse(machine.config.context ?? {});\n const merged = deepMerge(initial.success ? initial.data : {}, context ?? {});\n adapter.snapshot = machine.resolveState({ value, context: contextSchema.parse(merged) });\n },\n };\n\n return adapter;\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,SAAS;AAQlB,IAAM,mBAA0C,EAAE;AAAA,EAAK,MACrD,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC;AAC9D;AAEO,IAAM,cAAc,EAAE,OAAO;AAAA,EAClC,OAAO;AAAA;AAAA,EAEP,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,UAAU,EAAE,SAAS;AACrD,CAAC;AAaM,SAAS,cACd,SACA,EAAE,MAAM,UAAU,SAAS,cAAc,GACzC;AACA,QAAM,UAAiE;AAAA,IACrE;AAAA,IACA,QAAQ;AAAA;AAAA,IAER,SAAS;AAAA,IACT,MAAM,EAAE,OAAO,QAAQ,GAAG;AAExB,YAAM,UAAU,WAAW,UAAU,QAAQ,OAAO,WAAW,CAAC,CAAC;AACjE,YAAM,SAAS,UAAU,QAAQ,UAAU,QAAQ,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC;AAC3E,cAAQ,WAAW,QAAQ,aAAa,EAAE,OAAO,SAAS,cAAc,MAAM,MAAM,EAAE,CAAC;AAAA,IACzF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { TypedAdapter } from '../runtime.js';
|
|
3
|
+
import { type Serializable } from '../schema.js';
|
|
4
|
+
interface Store<T> {
|
|
5
|
+
setState(partial: Partial<T>): void;
|
|
6
|
+
getState(): T;
|
|
7
|
+
subscribe(listener: () => void): () => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Connects a Zustand store as `state.zustand` (or your key). The schema decodes scenario
|
|
11
|
+
* JSON into the slice of state to merge, e.g. `StoreSchema.partial()`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const zustandAdapter: <T extends Serializable>(store: Store<T>, { key, schema }: {
|
|
14
|
+
key?: string;
|
|
15
|
+
schema: z.ZodType<Partial<T>>;
|
|
16
|
+
}) => TypedAdapter<Partial<T>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseJson
|
|
3
|
+
} from "../chunk-BK4EEQXV.js";
|
|
4
|
+
|
|
5
|
+
// src/adapters/zustand.ts
|
|
6
|
+
var zustandAdapter = (store, { key = "zustand", schema }) => ({
|
|
7
|
+
key,
|
|
8
|
+
schema,
|
|
9
|
+
apply: (state) => store.setState(state),
|
|
10
|
+
read: () => parseJson(JSON.stringify(store.getState())),
|
|
11
|
+
subscribe: (onChange) => store.subscribe(onChange)
|
|
12
|
+
});
|
|
13
|
+
export {
|
|
14
|
+
zustandAdapter
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=zustand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/zustand.ts"],"sourcesContent":["import type { z } from 'zod';\nimport type { TypedAdapter } from '../runtime.js';\nimport { parseJson, type Serializable } from '../schema.js';\n\ninterface Store<T> {\n setState(partial: Partial<T>): void;\n getState(): T;\n subscribe(listener: () => void): () => void;\n}\n\n/**\n * Connects a Zustand store as `state.zustand` (or your key). The schema decodes scenario\n * JSON into the slice of state to merge, e.g. `StoreSchema.partial()`.\n */\nexport const zustandAdapter = <T extends Serializable>(\n store: Store<T>,\n { key = 'zustand', schema }: { key?: string; schema: z.ZodType<Partial<T>>; },\n): TypedAdapter<Partial<T>> => ({\n key,\n schema,\n apply: (state) => store.setState(state),\n read: () => parseJson(JSON.stringify(store.getState())),\n subscribe: (onChange) => store.subscribe(onChange),\n});\n"],"mappings":";;;;;AAcO,IAAM,iBAAiB,CAC5B,OACA,EAAE,MAAM,WAAW,OAAO,OACI;AAAA,EAC9B;AAAA,EACA;AAAA,EACA,OAAO,CAAC,UAAU,MAAM,SAAS,KAAK;AAAA,EACtC,MAAM,MAAM,UAAU,KAAK,UAAU,MAAM,SAAS,CAAC,CAAC;AAAA,EACtD,WAAW,CAAC,aAAa,MAAM,UAAU,QAAQ;AACnD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ScenarioSession } from './runtime.js';
|
|
2
|
+
import { type Scenario, type ScenarioInput } from './schema.js';
|
|
3
|
+
export interface CaptureOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
/** Playwright selector that marks this UI state ready. */
|
|
7
|
+
ready?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Catalog scenario to `extends`. Diff uses its resolved (flattened) form.
|
|
10
|
+
* Omit for a full self-contained snapshot.
|
|
11
|
+
*/
|
|
12
|
+
base?: Scenario;
|
|
13
|
+
/** Relative `$schema` path stamped on the catalog file only, e.g. `../scenario.schema.json`. */
|
|
14
|
+
schemaPath?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CapturedScenario {
|
|
17
|
+
/** Flattened snapshot for inline share links. */
|
|
18
|
+
flat: Scenario;
|
|
19
|
+
/** File to commit: diffs against `base` when set, otherwise the flat snapshot as input. */
|
|
20
|
+
forCatalog: ScenarioInput;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Snapshot what the app shows now: current route and URL params, the active network
|
|
24
|
+
* fixtures (plus recorded responses), and every connected adapter's live state.
|
|
25
|
+
*/
|
|
26
|
+
export declare function captureScenario(session: ScenarioSession, options: CaptureOptions): CapturedScenario;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Json, type Scenario, type ScenarioInput } from './schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* A business rule a resolved scenario must satisfy, beyond schema shape.
|
|
4
|
+
* Return a message (or several) for each violation.
|
|
5
|
+
*/
|
|
6
|
+
export type ScenarioRule = (scenario: Scenario) => string | string[] | void | undefined;
|
|
7
|
+
/** Identity helper for typing rule lists. */
|
|
8
|
+
export declare const defineScenarioRules: (rules: ScenarioRule[]) => ScenarioRule[];
|
|
9
|
+
export interface Catalog {
|
|
10
|
+
list: Scenario[];
|
|
11
|
+
get(name: string): Scenario | undefined;
|
|
12
|
+
/** Flatten `extends` into one self-contained scenario, then check the rules. */
|
|
13
|
+
resolve(scenario: Scenario): Scenario;
|
|
14
|
+
/** Resolve every scenario; returns one message per problem. */
|
|
15
|
+
check(): string[];
|
|
16
|
+
}
|
|
17
|
+
export declare function createCatalog(raw: ScenarioInput[], { rules }?: {
|
|
18
|
+
rules?: ScenarioRule[];
|
|
19
|
+
}): Catalog;
|
|
20
|
+
/** Objects merge recursively, `null` deletes a key, anything else replaces. */
|
|
21
|
+
export declare function deepMerge(base: Json | undefined, over: Json): Json;
|
|
22
|
+
/**
|
|
23
|
+
* Inverse of `extends` merge: overrides that turn a resolved `base` into `captured`.
|
|
24
|
+
* Pass the flattened base (from `catalog.resolve`). Copy-link keeps `captured` as-is;
|
|
25
|
+
* Download JSON uses this so the file can `extends` the base instead of repeating it.
|
|
26
|
+
*/
|
|
27
|
+
export declare function diffScenario(captured: Scenario, base?: Scenario): ScenarioInput;
|