@przeslijmi/real-fake-data-playwright 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Karol Nowakowski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # @przeslijmi/real-fake-data-playwright
2
+
3
+ Playwright fixtures for [Real Fake Data](https://github.com/przeslijmi/rfd) — realistic, synthetic **Polish** test data with one line per record: valid PESELs (correct checksums), NIPs, REGONs, IBANs, addresses drawn from real cities and streets, people, company names, and vehicle plates.
4
+
5
+ Output _looks_ real but is fake — safe for staging, demos, and seed data.
6
+
7
+ - **Seeded and reproducible by default.** Each test derives a stable seed from its title, so a failing test replays the exact same data on the next run — no flakiness, trivial repro.
8
+ - **Typed end to end.** One method per generator, fully typed inputs and results.
9
+ - **Zero ceremony.** A `fakeData` fixture; no manual client wiring.
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ npm install -D @przeslijmi/real-fake-data-playwright
15
+ # or: pnpm add -D @przeslijmi/real-fake-data-playwright
16
+ ```
17
+
18
+ Requires `@playwright/test` (peer dependency) and Node 18+ (for global `fetch`).
19
+
20
+ ## Quick start
21
+
22
+ Point the fixture at a Real Fake Data API instance, then pull data inside any test:
23
+
24
+ ```ts
25
+ import { test, expect } from '@przeslijmi/real-fake-data-playwright';
26
+
27
+ test.use({ realFakeData: { baseUrl: 'https://api.real-fake-data.example' } });
28
+
29
+ test('registers a new customer', async ({ page, fakeData }) => {
30
+ const person = await fakeData.person({ sex: 'f' });
31
+
32
+ await page.goto('/signup');
33
+ await page.getByLabel('First name').fill(person.name);
34
+ await page.getByLabel('Surname').fill(person.surname);
35
+ await page.getByLabel('PESEL').fill(person.pesel);
36
+ await page.getByRole('button', { name: 'Create account' }).click();
37
+
38
+ await expect(page.getByText(person.surname)).toBeVisible();
39
+ });
40
+ ```
41
+
42
+ `test` and `expect` are the standard Playwright exports, extended with the `fakeData` fixture — use them exactly as you would `@playwright/test`.
43
+
44
+ ## Configuration
45
+
46
+ Set options with `test.use({ realFakeData: { … } })`, at any scope (file, `describe`, or project, via your Playwright config).
47
+
48
+ | Option | Type | Description |
49
+ | --------- | ------------------------ | ------------------------------------------------------------------------------------------------------- |
50
+ | `baseUrl` | `string` (required) | Base URL of the Real Fake Data API, e.g. `https://api.example.com`. |
51
+ | `seed` | `number` | Base seed for the test. Omit to derive a stable seed from the test title (reproducible-by-default). |
52
+ | `headers` | `Record<string, string>` | Extra headers sent with every request (e.g. an API key once your plan requires one). |
53
+
54
+ ### Determinism
55
+
56
+ With a base seed in play, the **Nth call within a test uses `seed + N`** — so calls are reproducible across runs yet distinct from one another. Because the default seed comes from the test title, every test is already deterministic without configuring anything; set `seed` explicitly only when you want to pin a test to a known fixed dataset.
57
+
58
+ ```ts
59
+ test.use({ realFakeData: { baseUrl, seed: 42 } }); // pin this file to a fixed dataset
60
+ ```
61
+
62
+ ## Generators
63
+
64
+ Every method returns a typed result and accepts optional constraints. Pass `seed` on any call to override that call's automatic seed.
65
+
66
+ | Method | Returns | Common options |
67
+ | --------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------- |
68
+ | `fakeData.pesel(opts?)` | `{ value, birthDate, sex }` | `sex`, `atAge`, `olderThan`, `youngerThan`, `bornOn/Before/After`, `invalid` |
69
+ | `fakeData.person(opts?)` | `{ name, surname, initials, birthDate, pesel }` | same as `pesel` |
70
+ | `fakeData.address(opts?)` | `{ buildingNumber, postalCode, cityName, …, terytCodes }` | `teryt` (1–7 digit prefix) |
71
+ | `fakeData.nip(opts?)` | `{ value, digits }` | `format`, `invalid` |
72
+ | `fakeData.iban(opts?)` | `{ value, electronicFormat, bankCode, bankName }` | `format`, `bankCode`, `bankName`, `invalid` |
73
+ | `fakeData.regon(opts?)` | `{ value, variant }` | `variant` (`short`/`long`/`any`), `invalid` |
74
+ | `fakeData.companyName(opts?)` | `{ value, legalForm, strategy }` | `strategy`, `legalForm`, `activityPrefix` |
75
+ | `fakeData.vehicleRegistration(opts?)` | `{ value, prefix, individualPart, type, … }` | `type`, `voivodeship`, `county`, `format` |
76
+
77
+ ### Testing your validators
78
+
79
+ Every checksum generator accepts `invalid: true` to produce a value with a **deliberately wrong check digit** (the rest stays well-formed) — for asserting that your own validators reject bad input:
80
+
81
+ ```ts
82
+ const bad = await fakeData.nip({ invalid: true });
83
+ await expect(submitNip(bad.value)).rejects.toThrow('invalid checksum');
84
+ ```
85
+
86
+ ## Error handling
87
+
88
+ A non-2xx API response throws a `RealFakeDataError` carrying `status` (HTTP code), `code` (the API's machine error code), and `details` (per-field validation messages):
89
+
90
+ ```ts
91
+ import { RealFakeDataError } from '@przeslijmi/real-fake-data-playwright';
92
+
93
+ try {
94
+ await fakeData.address({ teryt: 'not-digits' });
95
+ } catch (error) {
96
+ if (error instanceof RealFakeDataError) {
97
+ console.log(error.status, error.code, error.details);
98
+ // 400 'VALIDATION_ERROR' [{ path: 'teryt', message: 'teryt must be 1–7 digits' }]
99
+ }
100
+ }
101
+ ```
102
+
103
+ ## Advanced: using the client without the fixture
104
+
105
+ The fixture is a thin wrapper over a provider and a facade you can use directly — handy in global setup, scripts, or non-Playwright code:
106
+
107
+ ```ts
108
+ import { CloudFakeDataProvider, createFakeData } from '@przeslijmi/real-fake-data-playwright';
109
+
110
+ const provider = new CloudFakeDataProvider({ baseUrl: 'https://api.example.com' });
111
+ const fakeData = createFakeData(provider, { seed: 42 });
112
+
113
+ const company = await fakeData.companyName({ legalForm: 'S.A.' });
114
+ ```
115
+
116
+ The `FakeDataProvider` interface is the swap point: the cloud provider talks HTTP to the hosted API, and the same facade can run against other backends.
117
+
118
+ ## License
119
+
120
+ MIT
@@ -0,0 +1,17 @@
1
+ /** One field-level problem reported by the API for a bad request. */
2
+ export interface RealFakeDataErrorDetail {
3
+ readonly path: string;
4
+ readonly message: string;
5
+ }
6
+ /**
7
+ * Thrown when a Real Fake Data request fails: a non-2xx API response
8
+ * (`status` carries the HTTP code, `code` the API's machine error code) or a
9
+ * transport/configuration failure (`status` is `0`).
10
+ */
11
+ export declare class RealFakeDataError extends Error {
12
+ readonly status: number;
13
+ readonly code: string | undefined;
14
+ readonly details: readonly RealFakeDataErrorDetail[] | undefined;
15
+ constructor(message: string, status: number, code?: string, details?: readonly RealFakeDataErrorDetail[]);
16
+ }
17
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,SAAgB,OAAO,EAAE,SAAS,uBAAuB,EAAE,GAAG,SAAS,CAAC;gBAGtE,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,SAAS,uBAAuB,EAAE;CAQ/C"}
package/dist/errors.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Thrown when a Real Fake Data request fails: a non-2xx API response
3
+ * (`status` carries the HTTP code, `code` the API's machine error code) or a
4
+ * transport/configuration failure (`status` is `0`).
5
+ */
6
+ export class RealFakeDataError extends Error {
7
+ status;
8
+ code;
9
+ details;
10
+ constructor(message, status, code, details) {
11
+ super(message);
12
+ this.name = 'RealFakeDataError';
13
+ this.status = status;
14
+ this.code = code;
15
+ this.details = details;
16
+ }
17
+ }
18
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1B,MAAM,CAAS;IACf,IAAI,CAAqB;IACzB,OAAO,CAAiD;IAExE,YACE,OAAe,EACf,MAAc,EACd,IAAa,EACb,OAA4C;QAE5C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,26 @@
1
+ /** A query value as it goes on the wire; `undefined` entries are dropped. */
2
+ export type QueryValue = string | number | boolean | undefined;
3
+ /** Reproducibility metadata every generator response carries. */
4
+ export interface GeneratorMeta {
5
+ readonly seed: number;
6
+ readonly generatorId: string;
7
+ readonly [key: string]: unknown;
8
+ }
9
+ /** The `{ data, meta }` envelope every Real Fake Data endpoint returns. */
10
+ export interface GeneratorResponse<Data> {
11
+ readonly data: Data;
12
+ readonly meta: GeneratorMeta;
13
+ }
14
+ /**
15
+ * The swappable transport seam.
16
+ *
17
+ * The cloud provider speaks HTTP to the Real Fake Data API; a future
18
+ * on-premise provider will run the generators in-process. Both produce the
19
+ * same `{ data, meta }` envelope, so the typed {@link FakeData} facade is
20
+ * written once on top of this interface and never needs to know which
21
+ * backend is behind it.
22
+ */
23
+ export interface FakeDataProvider {
24
+ generate<Data>(path: string, query: Readonly<Record<string, QueryValue>>): Promise<GeneratorResponse<Data>>;
25
+ }
26
+ //# sourceMappingURL=fake-data-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-data-provider.d.ts","sourceRoot":"","sources":["../src/fake-data-provider.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAE/D,iEAAiE;AACjE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAED,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB,CAAC,IAAI;IACrC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EACX,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAC1C,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;CACrC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fake-data-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-data-provider.js","sourceRoot":"","sources":["../src/fake-data-provider.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
1
+ import type { FakeDataProvider } from './fake-data-provider.js';
2
+ import type { AddressOptions, CompanyNameOptions, IbanOptions, NipOptions, PeselOptions, PersonOptions, PolishAddressData, PolishCompanyNameData, PolishIbanData, PolishNipData, PolishPeselData, PolishPersonData, PolishRegonData, PolishVehicleRegistrationData, RegonOptions, VehicleRegistrationOptions } from './types.js';
3
+ /** The typed surface tests use; one method per Real Fake Data generator. */
4
+ export interface FakeData {
5
+ pesel(options?: PeselOptions): Promise<PolishPeselData>;
6
+ person(options?: PersonOptions): Promise<PolishPersonData>;
7
+ address(options?: AddressOptions): Promise<PolishAddressData>;
8
+ nip(options?: NipOptions): Promise<PolishNipData>;
9
+ iban(options?: IbanOptions): Promise<PolishIbanData>;
10
+ regon(options?: RegonOptions): Promise<PolishRegonData>;
11
+ companyName(options?: CompanyNameOptions): Promise<PolishCompanyNameData>;
12
+ vehicleRegistration(options?: VehicleRegistrationOptions): Promise<PolishVehicleRegistrationData>;
13
+ }
14
+ export interface CreateFakeDataOptions {
15
+ /**
16
+ * Base seed for this instance. When set, the Nth call uses `seed + N`, so a
17
+ * re-run with the same base seed produces identical-but-distinct data.
18
+ * When omitted, the API randomises each call.
19
+ */
20
+ readonly seed?: number;
21
+ }
22
+ /**
23
+ * Builds a {@link FakeData} facade over any {@link FakeDataProvider}. Owns the
24
+ * per-call seed sequence so that calls are reproducible across runs yet
25
+ * distinct within a run.
26
+ */
27
+ export declare const createFakeData: (provider: FakeDataProvider, options?: CreateFakeDataOptions) => FakeData;
28
+ //# sourceMappingURL=fake-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-data.d.ts","sourceRoot":"","sources":["../src/fake-data.ts"],"names":[],"mappings":"AAAA,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Data} facade over any {@link FakeDataProvider}. Owns the
3
+ * per-call seed sequence so that calls are reproducible across runs yet
4
+ * distinct within a run.
5
+ */
6
+ export const createFakeData = (provider, options = {}) => {
7
+ const baseSeed = options.seed;
8
+ let counter = 0;
9
+ const nextSeed = (override) => {
10
+ if (override !== undefined) {
11
+ return override;
12
+ }
13
+ if (baseSeed === undefined) {
14
+ return undefined;
15
+ }
16
+ const seed = baseSeed + counter;
17
+ counter += 1;
18
+ return seed;
19
+ };
20
+ const run = async (path, callOptions) => {
21
+ const { seed, ...rest } = callOptions;
22
+ // `rest` carries each method's wire params verbatim; the facade only adds
23
+ // the resolved seed before handing them to the transport.
24
+ const response = await provider.generate(path, {
25
+ ...rest,
26
+ seed: nextSeed(seed),
27
+ });
28
+ return response.data;
29
+ };
30
+ return {
31
+ pesel: async (peselOptions = {}) => await run('pl/pesel', peselOptions),
32
+ person: async (personOptions = {}) => await run('pl/person', personOptions),
33
+ address: async (addressOptions = {}) => await run('pl/address', addressOptions),
34
+ nip: async (nipOptions = {}) => await run('pl/nip', nipOptions),
35
+ iban: async (ibanOptions = {}) => await run('pl/iban', ibanOptions),
36
+ regon: async (regonOptions = {}) => await run('pl/regon', regonOptions),
37
+ companyName: async (companyNameOptions = {}) => await run('pl/company-name', companyNameOptions),
38
+ vehicleRegistration: async (vehicleOptions = {}) => await run('pl/vehicle-registration', vehicleOptions),
39
+ };
40
+ };
41
+ //# sourceMappingURL=fake-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-data.js","sourceRoot":"","sources":["../src/fake-data.ts"],"names":[],"mappings":"AA4CA;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,QAA0B,EAC1B,UAAiC,EAAE,EACzB,EAAE;IACZ,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAC9B,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,MAAM,QAAQ,GAAG,CAAC,QAA4B,EAAsB,EAAE;QACpE,IAA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YAAY,GAAG,EAAE,EAAE,EAAE,CAAC,MAAM,GAAG,CAAkB,UAAU,EAAE,YAAY,CAAC;QACxF,WAAW,EAAE,KAAK,EAAE,kBAAkB,GAAG,EAAE,EAAE,EAAE,CAC7C,MAAM,GAAG,CAAwB,iBAAiB,EAAE,kBAAkB,CAAC;QACzE,mBAAmB,EAAE,KAAK,EAAE,cAAc,GAAG,EAAE,EAAE,EAAE,CACjD,MAAM,GAAG,CAAgC,yBAAyB,EAAE,cAAc,CAAC;KACtF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { FakeData } from './fake-data.js';
2
+ /** Test-level configuration, set with `test.use({ realFakeData: { … } })`. */
3
+ export interface RealFakeDataConfig {
4
+ /** Base URL of the Real Fake Data API, e.g. `https://api.example.com`. */
5
+ baseUrl: string;
6
+ /**
7
+ * Base seed for the test. When omitted, a stable seed is derived from the
8
+ * test title, so each test is reproducible-by-default yet distinct from its
9
+ * neighbours. Set it explicitly to pin a test to known data.
10
+ */
11
+ seed?: number;
12
+ /** Extra headers (e.g. authentication) sent with every request. */
13
+ headers?: Record<string, string>;
14
+ }
15
+ export interface RealFakeDataFixtures {
16
+ realFakeData: RealFakeDataConfig;
17
+ fakeData: FakeData;
18
+ }
19
+ /**
20
+ * A Playwright `test` extended with a `fakeData` fixture. Configure the API
21
+ * location once with `test.use({ realFakeData: { baseUrl: '…' } })`, then pull
22
+ * synthetic data inside any test via the `fakeData` fixture.
23
+ */
24
+ export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & RealFakeDataFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
25
+ export { expect } from '@playwright/test';
26
+ //# sourceMappingURL=fixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixture.d.ts","sourceRoot":"","sources":["../src/fixture.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,kBAAkB,CAAC;IACjC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,IAAI,oQAUf,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { test as base } from '@playwright/test';
2
+ import { createFakeData } from './fake-data.js';
3
+ import { hashString } from './hash.js';
4
+ import { CloudFakeDataProvider } from './providers/cloud-provider.js';
5
+ /**
6
+ * A Playwright `test` extended with a `fakeData` fixture. Configure the API
7
+ * location once with `test.use({ realFakeData: { baseUrl: '…' } })`, then pull
8
+ * synthetic data inside any test via the `fakeData` fixture.
9
+ */
10
+ export const test = base.extend({
11
+ realFakeData: [{ baseUrl: '' }, { option: true }],
12
+ fakeData: async ({ realFakeData }, use, testInfo) => {
13
+ const provider = new CloudFakeDataProvider({
14
+ baseUrl: realFakeData.baseUrl,
15
+ ...(realFakeData.headers === undefined ? {} : { headers: realFakeData.headers }),
16
+ });
17
+ const seed = realFakeData.seed ?? hashString(testInfo.titlePath.join(' › '));
18
+ await use(createFakeData(provider, { seed }));
19
+ },
20
+ });
21
+ export { expect } from '@playwright/test';
22
+ //# sourceMappingURL=fixture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixture.js","sourceRoot":"","sources":["../src/fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAqBtE;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAuB;IACpD,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACjD,QAAQ,EAAE,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE;QAClD,MAAM,QAAQ,GAAG,IAAI,qBAAqB,CAAC;YACzC,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,GAAG,CAAC,YAAY,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC;SACjF,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7E,MAAM,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACF,CAAC,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/hash.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A stable 32-bit FNV-1a hash of a string, returned as an unsigned integer.
3
+ * Used to derive a per-test base seed from the test title so that, absent an
4
+ * explicit seed, each test still gets reproducible-but-distinct data.
5
+ */
6
+ export declare const hashString: (value: string) => number;
7
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,MAO1C,CAAC"}
package/dist/hash.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * A stable 32-bit FNV-1a hash of a string, returned as an unsigned integer.
3
+ * Used to derive a per-test base seed from the test title so that, absent an
4
+ * explicit seed, each test still gets reproducible-but-distinct data.
5
+ */
6
+ export const hashString = (value) => {
7
+ let hash = 2_166_136_261;
8
+ for (const character of value) {
9
+ hash ^= character.codePointAt(0) ?? 0;
10
+ hash = Math.imul(hash, 16_777_619);
11
+ }
12
+ return hash >>> 0;
13
+ };
14
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE;IAClD,IAAI,IAAI,GAAG,aAAa,CAAC;IACzB,KAAK,MAAM,SAAS,IAAI,KAAK,EAAE,CAAC;QAC9B,IAAI,IAAI,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,CAAC;AACpB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export { test, expect } from './fixture.js';
2
+ export type { RealFakeDataConfig, RealFakeDataFixtures } from './fixture.js';
3
+ export { createFakeData } from './fake-data.js';
4
+ export type { CreateFakeDataOptions, FakeData } from './fake-data.js';
5
+ export { CloudFakeDataProvider } from './providers/cloud-provider.js';
6
+ export type { CloudFakeDataProviderOptions, FetchLike } from './providers/cloud-provider.js';
7
+ export type { FakeDataProvider, GeneratorMeta, GeneratorResponse, QueryValue, } from './fake-data-provider.js';
8
+ export { RealFakeDataError } from './errors.js';
9
+ export type { RealFakeDataErrorDetail } from './errors.js';
10
+ export type * from './types.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,YAAY,EAAE,4BAA4B,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE7F,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,mBAAmB,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { test, expect } from './fixture.js';
2
+ export { createFakeData } from './fake-data.js';
3
+ export { CloudFakeDataProvider } from './providers/cloud-provider.js';
4
+ export { RealFakeDataError } from './errors.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAUtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { FakeDataProvider, GeneratorResponse, QueryValue } from '../fake-data-provider.js';
2
+ /** The subset of the global `fetch` signature this provider relies on. */
3
+ export type FetchLike = (input: string | URL, init?: RequestInit) => Promise<Response>;
4
+ export interface CloudFakeDataProviderOptions {
5
+ /** Base URL of the Real Fake Data API, e.g. `https://api.example.com`. */
6
+ readonly baseUrl: string;
7
+ /** Extra headers (e.g. authentication) sent with every request. */
8
+ readonly headers?: Readonly<Record<string, string>>;
9
+ /** Custom fetch implementation; defaults to the global `fetch`. */
10
+ readonly fetch?: FetchLike;
11
+ }
12
+ /**
13
+ * A {@link FakeDataProvider} that calls the hosted Real Fake Data API over
14
+ * HTTP. It maps `(path, query)` to `GET {baseUrl}/v1/{path}?{query}` and
15
+ * unwraps the `{ data, meta }` envelope, turning non-2xx responses into a
16
+ * {@link RealFakeDataError}.
17
+ */
18
+ export declare class CloudFakeDataProvider implements FakeDataProvider {
19
+ #private;
20
+ constructor(options: CloudFakeDataProviderOptions);
21
+ generate<Data>(path: string, query: Readonly<Record<string, QueryValue>>): Promise<GeneratorResponse<Data>>;
22
+ }
23
+ //# sourceMappingURL=cloud-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-provider.d.ts","sourceRoot":"","sources":["../../src/providers/cloud-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEhG,0EAA0E;AAC1E,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvF,MAAM,WAAW,4BAA4B;IAC3C,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,mEAAmE;IACnE,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;CAC5B;AAED;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,gBAAgB;;gBAKzC,OAAO,EAAE,4BAA4B;IAM3C,QAAQ,CAAC,IAAI,EACxB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAC1C,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;CAiCpC"}
@@ -0,0 +1,64 @@
1
+ import { RealFakeDataError } from '../errors.js';
2
+ /**
3
+ * A {@link FakeDataProvider} that calls the hosted Real Fake Data API over
4
+ * HTTP. It maps `(path, query)` to `GET {baseUrl}/v1/{path}?{query}` and
5
+ * unwraps the `{ data, meta }` envelope, turning non-2xx responses into a
6
+ * {@link RealFakeDataError}.
7
+ */
8
+ export class CloudFakeDataProvider {
9
+ #baseUrl;
10
+ #headers;
11
+ #fetch;
12
+ constructor(options) {
13
+ this.#baseUrl = options.baseUrl.replace(/\/+$/u, '');
14
+ this.#headers = { ...options.headers };
15
+ this.#fetch = options.fetch ?? globalThis.fetch;
16
+ }
17
+ async generate(path, query) {
18
+ if (this.#baseUrl === '') {
19
+ throw new RealFakeDataError('Real Fake Data baseUrl is not configured. Set it via ' +
20
+ 'test.use({ realFakeData: { baseUrl: "https://…" } }).', 0);
21
+ }
22
+ const url = new URL(`${this.#baseUrl}/v1/${path}`);
23
+ for (const [key, value] of Object.entries(query)) {
24
+ if (value !== undefined) {
25
+ url.searchParams.set(key, String(value));
26
+ }
27
+ }
28
+ let response;
29
+ try {
30
+ response = await this.#fetch(url, { headers: this.#headers });
31
+ }
32
+ catch (error) {
33
+ throw new RealFakeDataError(`Request to ${url.pathname} failed: ${error instanceof Error ? error.message : String(error)}`, 0);
34
+ }
35
+ if (!response.ok) {
36
+ throw await toError(response, url);
37
+ }
38
+ const body = await response.json();
39
+ return body;
40
+ }
41
+ }
42
+ const isErrorDetail = (value) => typeof value === 'object' &&
43
+ value !== null &&
44
+ typeof value.path === 'string' &&
45
+ typeof value.message === 'string';
46
+ const toError = async (response, url) => {
47
+ let parsed;
48
+ try {
49
+ parsed = await response.json();
50
+ }
51
+ catch {
52
+ parsed = undefined;
53
+ }
54
+ const apiError = parsed?.error;
55
+ const message = typeof apiError?.message === 'string'
56
+ ? apiError.message
57
+ : `Request to ${url.pathname} failed with status ${String(response.status)}`;
58
+ const code = typeof apiError?.code === 'string' ? apiError.code : undefined;
59
+ const details = Array.isArray(apiError?.details)
60
+ ? apiError.details.filter((detail) => isErrorDetail(detail))
61
+ : undefined;
62
+ return new RealFakeDataError(message, response.status, code, details !== undefined && details.length > 0 ? details : undefined);
63
+ };
64
+ //# sourceMappingURL=cloud-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-provider.js","sourceRoot":"","sources":["../../src/providers/cloud-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAgBjD;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IACvB,QAAQ,CAAS;IACjB,QAAQ,CAAyB;IACjC,MAAM,CAAY;IAE3B,YAAmB,OAAqC;QACtD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACrD,IAAI,CAAC,QAAQ,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,QAAQ,CACnB,IAAY,EACZ,KAA2C;QAE3C,IAAI,IAAI,CAAC,QAAQ,KAAK,EAAE,EAAE,CAAC;YACzB,MAAM,IAAI,iBAAiB,CACzB,uDAAuD;gBACrD,uDAAuD,EACzD,CAAC,CACF,CAAC;QACJ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B,EAAE,GAAQ,EAA8B,EAAE;IACjF,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,QAAQ,GAAI,MAAmC,EAAE,KAAK,CAAC;IAC7D,MAAM,OAAO,GACX,OAAO,QAAQ,EAAE,OAAO,KAAK,QAAQ;QACnC,CAAC,CAAC,QAAQ,CAAC,OAAO;QAClB,CAAC,CAAC,cAAc,GAAG,CAAC,QAAQ,uBAAuB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;IACjF,MAAM,IAAI,GAAG,OAAO,QAAQ,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC9C,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5D,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,IAAI,iBAAiB,CAC1B,OAAO,EACP,QAAQ,CAAC,MAAM,EACf,IAAI,EACJ,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAClE,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Result and option types for every generator. The result shapes mirror the
3
+ * API's response `data` schemas; the option shapes mirror its query params
4
+ * (minus `seed`, which the facade manages — see {@link RequestOptions}).
5
+ */
6
+ /** Sex marker used by the PESEL and person generators. */
7
+ export type Sex = 'm' | 'f';
8
+ /** A Polish legal form the company-name generator can append. */
9
+ export type PolishLegalForm = 'Sp. z o.o.' | 'Sp. z o.o. sp.k.' | 'S.A.' | 'Sp. j.' | 'Sp. k.' | 'S.C.';
10
+ /** Naming family the company-name generator drew from. */
11
+ export type CompanyNameStrategy = 'morpheme' | 'surname' | 'descriptive' | 'modern';
12
+ /** Kind of vehicle registration plate produced. */
13
+ export type VehicleRegistrationType = 'standard' | 'custom' | 'police' | 'military';
14
+ /**
15
+ * Per-call options shared by every method. A `seed` here overrides the
16
+ * fixture's automatic per-call seed for this one request.
17
+ */
18
+ export interface RequestOptions {
19
+ readonly seed?: number;
20
+ }
21
+ /** Shared inputs of the PESEL and person generators. */
22
+ export interface PersonConstraintOptions extends RequestOptions {
23
+ readonly sex?: Sex;
24
+ readonly olderThan?: number;
25
+ readonly youngerThan?: number;
26
+ readonly atAge?: number;
27
+ /** `YYYY`, `YYYY-MM`, or `YYYY-MM-DD`. */
28
+ readonly bornOn?: string;
29
+ /** `YYYY`, `YYYY-MM`, or `YYYY-MM-DD`. */
30
+ readonly bornBefore?: string;
31
+ /** `YYYY`, `YYYY-MM`, or `YYYY-MM-DD`. */
32
+ readonly bornAfter?: string;
33
+ /** Produce a value with a deliberately wrong check digit. */
34
+ readonly invalid?: boolean;
35
+ }
36
+ export type PeselOptions = PersonConstraintOptions;
37
+ export type PersonOptions = PersonConstraintOptions;
38
+ export interface AddressOptions extends RequestOptions {
39
+ /** TERYT prefix, 1–7 digits, narrowing the location. */
40
+ readonly teryt?: string;
41
+ }
42
+ export interface NipOptions extends RequestOptions {
43
+ readonly format?: 'with-hyphens' | 'digits-only';
44
+ readonly invalid?: boolean;
45
+ }
46
+ export interface IbanOptions extends RequestOptions {
47
+ readonly format?: 'grouped' | 'compact';
48
+ readonly invalid?: boolean;
49
+ /** Pin the issuing bank by its four-digit code. Mutually exclusive with `bankName`. */
50
+ readonly bankCode?: string;
51
+ /** Pin the issuing bank by a case-insensitive name fragment. Mutually exclusive with `bankCode`. */
52
+ readonly bankName?: string;
53
+ }
54
+ export interface RegonOptions extends RequestOptions {
55
+ readonly variant?: 'short' | 'long' | 'any';
56
+ readonly invalid?: boolean;
57
+ }
58
+ export interface CompanyNameOptions extends RequestOptions {
59
+ readonly strategy?: CompanyNameStrategy | 'any';
60
+ readonly legalForm?: PolishLegalForm | 'any' | 'none';
61
+ readonly activityPrefix?: boolean;
62
+ }
63
+ export interface VehicleRegistrationOptions extends RequestOptions {
64
+ readonly type?: VehicleRegistrationType;
65
+ readonly voivodeship?: string;
66
+ readonly county?: string;
67
+ readonly format?: 'with-space' | 'compact';
68
+ }
69
+ export interface PolishPeselData {
70
+ readonly value: string;
71
+ readonly birthDate: string;
72
+ readonly sex: Sex;
73
+ }
74
+ export interface PolishPersonData {
75
+ readonly name: string;
76
+ readonly surname: string;
77
+ readonly initials: string;
78
+ readonly birthDate: string;
79
+ readonly pesel: string;
80
+ }
81
+ export interface PolishAddressTerytCodes {
82
+ readonly voivodeshipCode: string;
83
+ readonly countyCode: string;
84
+ readonly municipalityCode: string;
85
+ readonly cityCode: string;
86
+ readonly streetCode?: string;
87
+ }
88
+ export interface PolishAddressData {
89
+ readonly streetFullName?: string;
90
+ readonly buildingNumber: string;
91
+ readonly postalCode: string;
92
+ readonly cityName: string;
93
+ readonly municipalityName: string;
94
+ readonly countyName: string;
95
+ readonly voivodeshipName: string;
96
+ readonly terytCodes: PolishAddressTerytCodes;
97
+ }
98
+ export interface PolishNipData {
99
+ readonly value: string;
100
+ readonly digits: string;
101
+ }
102
+ export interface PolishIbanData {
103
+ readonly value: string;
104
+ readonly electronicFormat: string;
105
+ readonly bankCode: string;
106
+ readonly bankName: string;
107
+ }
108
+ export interface PolishRegonData {
109
+ readonly value: string;
110
+ readonly variant: 'short' | 'long';
111
+ }
112
+ export interface PolishCompanyNameData {
113
+ readonly value: string;
114
+ readonly legalForm: PolishLegalForm | null;
115
+ readonly strategy: CompanyNameStrategy;
116
+ }
117
+ export interface PolishVehicleRegistrationData {
118
+ readonly value: string;
119
+ readonly prefix: string;
120
+ readonly individualPart: string;
121
+ readonly type: VehicleRegistrationType;
122
+ readonly voivodeship?: string;
123
+ readonly county?: string;
124
+ }
125
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0DAA0D;AAC1D,MAAM,MAAM,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAE5B,iEAAiE;AACjE,MAAM,MAAM,eAAe,GACvB,YAAY,GACZ,kBAAkB,GAClB,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,MAAM,CAAC;AAEX,0DAA0D;AAC1D,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,QAAQ,CAAC;AAEpF,mDAAmD;AACnD,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEpF;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wDAAwD;AACxD,MAAM,WAAW,uBAAwB,SAAQ,cAAc;IAC7D,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;IACnB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MA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AC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;CACxC;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B"}
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Result and option types for every generator. The result shapes mirror the
3
+ * API's response `data` schemas; the option shapes mirror its query params
4
+ * (minus `seed`, which the facade manages — see {@link RequestOptions}).
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@przeslijmi/real-fake-data-playwright",
3
+ "version": "0.1.0",
4
+ "description": "Playwright fixtures for Real Fake Data — seeded, realistic Polish test data (PESEL, NIP, REGON, IBAN, addresses, companies, people, vehicle plates).",
5
+ "keywords": [
6
+ "playwright",
7
+ "playwright-fixtures",
8
+ "fake-data",
9
+ "test-data",
10
+ "seed-data",
11
+ "pesel",
12
+ "nip",
13
+ "regon",
14
+ "poland"
15
+ ],
16
+ "homepage": "https://github.com/przeslijmi/rfd/tree/main/packages/addon-playwright",
17
+ "bugs": "https://github.com/przeslijmi/rfd/issues",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/przeslijmi/rfd.git",
21
+ "directory": "packages/addon-playwright"
22
+ },
23
+ "license": "MIT",
24
+ "type": "module",
25
+ "main": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "peerDependencies": {
40
+ "@playwright/test": ">=1.40.0"
41
+ },
42
+ "devDependencies": {
43
+ "@playwright/test": "^1.40.0",
44
+ "@types/node": "^22.0.0",
45
+ "typescript": "^5.6.0",
46
+ "@przeslijmi/rfd-eslint-config": "0.0.0",
47
+ "@przeslijmi/rfd-tsconfig": "0.0.0"
48
+ },
49
+ "scripts": {
50
+ "build": "tsc -b tsconfig.build.json",
51
+ "dev": "tsc -b tsconfig.build.json --watch",
52
+ "clean": "rm -rf dist .turbo *.tsbuildinfo",
53
+ "lint": "eslint .",
54
+ "typecheck": "tsc -b tsconfig.build.json --noEmit"
55
+ }
56
+ }