@crvouga/mockingbird-service-formbricks 3.6.0 → 3.8.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/CHANGELOG.md +13 -1
- package/README.md +20 -1
- package/dist/{chunk-VZ55MOOA.js → chunk-5ZAU7WOP.js} +242 -16
- package/dist/chunk-5ZAU7WOP.js.map +7 -0
- package/dist/{chunk-THESW6F4.js → chunk-XJB56QGS.js} +107 -23
- package/dist/chunk-XJB56QGS.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +28 -0
- package/dist/index.js +1 -1
- package/dist/server.d.ts +78 -1
- package/dist/server.js +4 -2
- package/package.json +1 -1
- package/dist/chunk-THESW6F4.js.map +0 -7
- package/dist/chunk-VZ55MOOA.js.map +0 -7
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -184,9 +184,15 @@ declare class Collection<T> {
|
|
|
184
184
|
}>;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
/**
|
|
188
|
+
* What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
|
|
189
|
+
* which derives the base from the wall clock when the runtime is created.
|
|
190
|
+
*/
|
|
191
|
+
type IdBase = number | string;
|
|
187
192
|
/**
|
|
188
193
|
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
189
194
|
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
195
|
+
* A runtime's `idBase` is mixed in, so a different base reissues none of another's ids.
|
|
190
196
|
*/
|
|
191
197
|
declare class IdSequence {
|
|
192
198
|
private readonly sqlite;
|
|
@@ -525,6 +531,15 @@ type FaultRule = {
|
|
|
525
531
|
requestHeaders?: Record<string, string>;
|
|
526
532
|
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
527
533
|
query?: Record<string, string>;
|
|
534
|
+
/**
|
|
535
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
536
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
537
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
538
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
539
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
540
|
+
* response a rule injects.
|
|
541
|
+
*/
|
|
542
|
+
requestBody?: Record<string, RequestBodyValue>;
|
|
528
543
|
/**
|
|
529
544
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
530
545
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
@@ -591,6 +606,8 @@ type FaultRule = {
|
|
|
591
606
|
/** The preset this rule was expanded from, if any. */
|
|
592
607
|
fromPreset?: string;
|
|
593
608
|
};
|
|
609
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
610
|
+
type RequestBodyValue = string | number | boolean | null;
|
|
594
611
|
/** A fault that fired for one request. */
|
|
595
612
|
type FaultHit = {
|
|
596
613
|
id: string;
|
|
@@ -628,6 +645,11 @@ type FaultCandidate = {
|
|
|
628
645
|
/** Request headers and query, for rules that match on them. */
|
|
629
646
|
headers?: Headers;
|
|
630
647
|
query?: URLSearchParams;
|
|
648
|
+
/**
|
|
649
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
650
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
651
|
+
*/
|
|
652
|
+
readJson?: () => Promise<unknown>;
|
|
631
653
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
632
654
|
now?: number;
|
|
633
655
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
@@ -1150,6 +1172,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
1150
1172
|
mount(prefix: string): MountedAPI;
|
|
1151
1173
|
readonly sqlite: SqliteClient$1;
|
|
1152
1174
|
readonly clock: Clock;
|
|
1175
|
+
/**
|
|
1176
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
1177
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
1178
|
+
* one run.
|
|
1179
|
+
*/
|
|
1180
|
+
setIdBase(base: IdBase): number;
|
|
1153
1181
|
readonly faults: FaultRegistry;
|
|
1154
1182
|
/** Baseline response time per namespace. */
|
|
1155
1183
|
readonly latency: LatencyRegistry;
|
package/dist/index.js
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -133,6 +133,12 @@ interface SqliteClient$2 {
|
|
|
133
133
|
transaction<T>(fn: () => T): T;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
|
|
138
|
+
* which derives the base from the wall clock when the runtime is created.
|
|
139
|
+
*/
|
|
140
|
+
type IdBase$1 = number | string;
|
|
141
|
+
|
|
136
142
|
/**
|
|
137
143
|
* The single source of time for a service.
|
|
138
144
|
*
|
|
@@ -215,6 +221,15 @@ type FaultRule$1 = {
|
|
|
215
221
|
requestHeaders?: Record<string, string>;
|
|
216
222
|
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
217
223
|
query?: Record<string, string>;
|
|
224
|
+
/**
|
|
225
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
226
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
227
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
228
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
229
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
230
|
+
* response a rule injects.
|
|
231
|
+
*/
|
|
232
|
+
requestBody?: Record<string, RequestBodyValue$1>;
|
|
218
233
|
/**
|
|
219
234
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
220
235
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
@@ -281,6 +296,8 @@ type FaultRule$1 = {
|
|
|
281
296
|
/** The preset this rule was expanded from, if any. */
|
|
282
297
|
fromPreset?: string;
|
|
283
298
|
};
|
|
299
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
300
|
+
type RequestBodyValue$1 = string | number | boolean | null;
|
|
284
301
|
/** A fault that fired for one request. */
|
|
285
302
|
type FaultHit$1 = {
|
|
286
303
|
id: string;
|
|
@@ -305,6 +322,11 @@ type FaultCandidate$1 = {
|
|
|
305
322
|
/** Request headers and query, for rules that match on them. */
|
|
306
323
|
headers?: Headers;
|
|
307
324
|
query?: URLSearchParams;
|
|
325
|
+
/**
|
|
326
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
327
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
328
|
+
*/
|
|
329
|
+
readJson?: () => Promise<unknown>;
|
|
308
330
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
309
331
|
now?: number;
|
|
310
332
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
@@ -827,6 +849,12 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
|
|
|
827
849
|
mount(prefix: string): MountedAPI$1;
|
|
828
850
|
readonly sqlite: SqliteClient$2;
|
|
829
851
|
readonly clock: Clock$1;
|
|
852
|
+
/**
|
|
853
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
854
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
855
|
+
* one run.
|
|
856
|
+
*/
|
|
857
|
+
setIdBase(base: IdBase$1): number;
|
|
830
858
|
readonly faults: FaultRegistry$1;
|
|
831
859
|
/** Baseline response time per namespace. */
|
|
832
860
|
readonly latency: LatencyRegistry$1;
|
|
@@ -932,6 +960,12 @@ type CommonServeOptions = {
|
|
|
932
960
|
/** Synthetic provider fixture objects supplied by a fleet entry. */
|
|
933
961
|
fixtures?: Record<string, unknown>;
|
|
934
962
|
baseUrl?: string;
|
|
963
|
+
/**
|
|
964
|
+
* Boot settings from `--settings`, `MOCKINGBIRD_SETTINGS` or a fleet entry's `settings`,
|
|
965
|
+
* already checked by the target's {@link ServeTarget.parseSettings}. Pass them to the
|
|
966
|
+
* service's own `settings` option so they become every namespace's defaults.
|
|
967
|
+
*/
|
|
968
|
+
settings?: Record<string, unknown>;
|
|
935
969
|
};
|
|
936
970
|
/**
|
|
937
971
|
* What a service contributes to `serve`: how to build its runtime from CLI flags,
|
|
@@ -944,7 +978,16 @@ type ServeTarget = {
|
|
|
944
978
|
defaultPort: number;
|
|
945
979
|
/** Serve flags beyond the common ones. */
|
|
946
980
|
options?: Record<string, CliOption>;
|
|
981
|
+
/**
|
|
982
|
+
* Check the boot settings a caller supplied (`--settings`, `MOCKINGBIRD_SETTINGS`, a fleet
|
|
983
|
+
* entry's `settings`) against the service's settings schema, returning them normalized
|
|
984
|
+
* or throwing a message naming the bad field. A target without one takes no boot settings,
|
|
985
|
+
* and supplying some is refused before a port is bound.
|
|
986
|
+
*/
|
|
987
|
+
parseSettings?(settings: Record<string, unknown>): Record<string, unknown>;
|
|
947
988
|
create(values: CliValues, common: CommonServeOptions): Promise<ServiceRuntime$1<ServiceInstance$1>> | ServiceRuntime$1<ServiceInstance$1>;
|
|
989
|
+
/** Largest request body the HTTP server accepts. Default 16 MiB. */
|
|
990
|
+
maxBodyBytes?: number;
|
|
948
991
|
/** Startup lines after the listen address, e.g. the loaded corpus version. */
|
|
949
992
|
banner?(runtime: ServiceRuntime$1<ServiceInstance$1>): string[];
|
|
950
993
|
/** After the HTTP server is bound. A service that speaks more than HTTP attaches it here. */
|
|
@@ -1125,9 +1168,15 @@ declare class Collection<T> {
|
|
|
1125
1168
|
}>;
|
|
1126
1169
|
}
|
|
1127
1170
|
|
|
1171
|
+
/**
|
|
1172
|
+
* What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
|
|
1173
|
+
* which derives the base from the wall clock when the runtime is created.
|
|
1174
|
+
*/
|
|
1175
|
+
type IdBase = number | string;
|
|
1128
1176
|
/**
|
|
1129
1177
|
* Sequential id source persisted in SQLite. Ids are deterministic for a given
|
|
1130
1178
|
* sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
|
|
1179
|
+
* A runtime's `idBase` is mixed in, so a different base reissues none of another's ids.
|
|
1131
1180
|
*/
|
|
1132
1181
|
declare class IdSequence {
|
|
1133
1182
|
private readonly sqlite;
|
|
@@ -1466,6 +1515,15 @@ type FaultRule = {
|
|
|
1466
1515
|
requestHeaders?: Record<string, string>;
|
|
1467
1516
|
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
1468
1517
|
query?: Record<string, string>;
|
|
1518
|
+
/**
|
|
1519
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
1520
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
1521
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
1522
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
1523
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
1524
|
+
* response a rule injects.
|
|
1525
|
+
*/
|
|
1526
|
+
requestBody?: Record<string, RequestBodyValue>;
|
|
1469
1527
|
/**
|
|
1470
1528
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
1471
1529
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
@@ -1532,6 +1590,8 @@ type FaultRule = {
|
|
|
1532
1590
|
/** The preset this rule was expanded from, if any. */
|
|
1533
1591
|
fromPreset?: string;
|
|
1534
1592
|
};
|
|
1593
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
1594
|
+
type RequestBodyValue = string | number | boolean | null;
|
|
1535
1595
|
/** A fault that fired for one request. */
|
|
1536
1596
|
type FaultHit = {
|
|
1537
1597
|
id: string;
|
|
@@ -1556,6 +1616,11 @@ type FaultCandidate = {
|
|
|
1556
1616
|
/** Request headers and query, for rules that match on them. */
|
|
1557
1617
|
headers?: Headers;
|
|
1558
1618
|
query?: URLSearchParams;
|
|
1619
|
+
/**
|
|
1620
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
1621
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
1622
|
+
*/
|
|
1623
|
+
readJson?: () => Promise<unknown>;
|
|
1559
1624
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
1560
1625
|
now?: number;
|
|
1561
1626
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
@@ -2078,6 +2143,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
|
|
|
2078
2143
|
mount(prefix: string): MountedAPI;
|
|
2079
2144
|
readonly sqlite: SqliteClient$1;
|
|
2080
2145
|
readonly clock: Clock;
|
|
2146
|
+
/**
|
|
2147
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
2148
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
2149
|
+
* one run.
|
|
2150
|
+
*/
|
|
2151
|
+
setIdBase(base: IdBase): number;
|
|
2081
2152
|
readonly faults: FaultRegistry;
|
|
2082
2153
|
/** Baseline response time per namespace. */
|
|
2083
2154
|
readonly latency: LatencyRegistry;
|
|
@@ -2381,8 +2452,14 @@ type FormbricksServer = Listening & {
|
|
|
2381
2452
|
};
|
|
2382
2453
|
/** Serve the Formbricks mock over `node:http`. */
|
|
2383
2454
|
declare const createServer: (options?: FormbricksServerOptions) => Promise<FormbricksServer>;
|
|
2455
|
+
/**
|
|
2456
|
+
* Read a surveys file (a list, or `{surveys: [...]}`) and lay it after the corpus surveys
|
|
2457
|
+
* (`append`, the default; a survey whose id the corpus or an earlier row has is skipped) or use it
|
|
2458
|
+
* as the whole corpus (`replace`). A survey without a `workspaceId` is served by every workspace.
|
|
2459
|
+
*/
|
|
2460
|
+
declare const loadSurveysFile: (path: string, mode?: "append" | "replace", legacyEnvironmentIds?: Record<string, string>) => Survey[];
|
|
2384
2461
|
/** How `serve` (and `serve --config`) builds the Formbricks mock from flags. */
|
|
2385
2462
|
declare const serveTarget: ServeTarget;
|
|
2386
2463
|
|
|
2387
|
-
export { DEFAULT_PORT, createServer, serveTarget };
|
|
2464
|
+
export { DEFAULT_PORT, createServer, loadSurveysFile, serveTarget };
|
|
2388
2465
|
export type { FormbricksServer, FormbricksServerOptions };
|
package/dist/server.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_PORT,
|
|
3
3
|
createServer,
|
|
4
|
+
loadSurveysFile,
|
|
4
5
|
serveTarget
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-5ZAU7WOP.js";
|
|
7
|
+
import "./chunk-XJB56QGS.js";
|
|
7
8
|
export {
|
|
8
9
|
DEFAULT_PORT,
|
|
9
10
|
createServer,
|
|
11
|
+
loadSurveysFile,
|
|
10
12
|
serveTarget
|
|
11
13
|
};
|
|
12
14
|
//# sourceMappingURL=server.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/mockingbird-service-formbricks",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Stateful emulator of open-source Formbricks: the client environment state (seeded with a synthetic survey corpus), response creation with upstream's validation and {code, message, details} errors, the v1 management API, the widget script, and signed response webhooks.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|