@crvouga/mockingbird-service-wholescripts 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 +13 -1
- package/dist/{chunk-T6P2TKQO.js → chunk-4BLJLSNN.js} +260 -67
- package/dist/chunk-4BLJLSNN.js.map +7 -0
- package/dist/{chunk-6T4MXYKN.js → chunk-NS2QQO5Y.js} +153 -15
- package/dist/chunk-NS2QQO5Y.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +41 -1
- package/dist/index.js +5 -1
- package/dist/server.d.ts +129 -51
- package/dist/server.js +4 -2
- package/package.json +1 -1
- package/dist/chunk-6T4MXYKN.js.map +0 -7
- package/dist/chunk-T6P2TKQO.js.map +0 -7
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -184,6 +184,12 @@ 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;
|
|
192
|
+
|
|
187
193
|
/** Options every provider constructor accepts. */
|
|
188
194
|
type APIOptions = {
|
|
189
195
|
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
@@ -279,6 +285,15 @@ type FaultRule = {
|
|
|
279
285
|
requestHeaders?: Record<string, string>;
|
|
280
286
|
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
281
287
|
query?: Record<string, string>;
|
|
288
|
+
/**
|
|
289
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
290
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
291
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
292
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
293
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
294
|
+
* response a rule injects.
|
|
295
|
+
*/
|
|
296
|
+
requestBody?: Record<string, RequestBodyValue>;
|
|
282
297
|
/**
|
|
283
298
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
284
299
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
@@ -345,6 +360,8 @@ type FaultRule = {
|
|
|
345
360
|
/** The preset this rule was expanded from, if any. */
|
|
346
361
|
fromPreset?: string;
|
|
347
362
|
};
|
|
363
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
364
|
+
type RequestBodyValue = string | number | boolean | null;
|
|
348
365
|
/** A fault that fired for one request. */
|
|
349
366
|
type FaultHit = {
|
|
350
367
|
id: string;
|
|
@@ -382,6 +399,11 @@ type FaultCandidate = {
|
|
|
382
399
|
/** Request headers and query, for rules that match on them. */
|
|
383
400
|
headers?: Headers;
|
|
384
401
|
query?: URLSearchParams;
|
|
402
|
+
/**
|
|
403
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
404
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
405
|
+
*/
|
|
406
|
+
readJson?: () => Promise<unknown>;
|
|
385
407
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
386
408
|
now?: number;
|
|
387
409
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
@@ -904,6 +926,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
904
926
|
mount(prefix: string): MountedAPI;
|
|
905
927
|
readonly sqlite: SqliteClient$1;
|
|
906
928
|
readonly clock: Clock;
|
|
929
|
+
/**
|
|
930
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
931
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
932
|
+
* one run.
|
|
933
|
+
*/
|
|
934
|
+
setIdBase(base: IdBase): number;
|
|
907
935
|
readonly faults: FaultRegistry;
|
|
908
936
|
/** Baseline response time per namespace. */
|
|
909
937
|
readonly latency: LatencyRegistry;
|
|
@@ -1070,6 +1098,18 @@ declare const MEDPAX_BOX_SKU = "000000000200095263";
|
|
|
1070
1098
|
* scheduler's catalog sync reads. `Protein Powder` is out of stock (`instockonly` drops it).
|
|
1071
1099
|
*/
|
|
1072
1100
|
declare const DEFAULT_CATALOG: Catalog;
|
|
1101
|
+
/**
|
|
1102
|
+
* Check a catalog document and fill the fields a row may leave out. The document is
|
|
1103
|
+
* `{products?, medPaxPills?, privateLabelCartons?}` (or a bare array of products); a row needs
|
|
1104
|
+
* its `sku` (and a product its `productName`), and every other string defaults to `""`,
|
|
1105
|
+
* every number to `0`, and `defaultDosing` to none. Throws a message naming the bad field.
|
|
1106
|
+
*/
|
|
1107
|
+
declare const parseCatalogDocument: (input: unknown) => Partial<Catalog>;
|
|
1108
|
+
/**
|
|
1109
|
+
* Lay `extra` onto `base`: a row with a SKU `base` already has replaces it in place, any other
|
|
1110
|
+
* is appended, and a list `extra` leaves out is kept as it is.
|
|
1111
|
+
*/
|
|
1112
|
+
declare const mergeCatalog: (base: Catalog, extra: Partial<Catalog>) => Catalog;
|
|
1073
1113
|
|
|
1074
1114
|
type Tracking = {
|
|
1075
1115
|
trackingNumber: string;
|
|
@@ -1390,5 +1430,5 @@ declare class WholescriptsAPI implements FetchAPI$1 {
|
|
|
1390
1430
|
orders(): OrderRecord[];
|
|
1391
1431
|
}
|
|
1392
1432
|
|
|
1393
|
-
export { DEFAULT_CATALOG, MEDPAX_BOX_SKU, WHOLESCRIPTS_NAMESPACE, WHOLESCRIPTS_PRESETS, WholescriptsAPI, basicUsername, canonicalStatus, createRuntime, document, operationIds, supportedOperationIds };
|
|
1433
|
+
export { DEFAULT_CATALOG, MEDPAX_BOX_SKU, WHOLESCRIPTS_NAMESPACE, WHOLESCRIPTS_PRESETS, WholescriptsAPI, basicUsername, canonicalStatus, createRuntime, document, mergeCatalog, operationIds, parseCatalogDocument, supportedOperationIds };
|
|
1394
1434
|
export type { AutoAdvance, Catalog, FetchAPI$1 as FetchAPI, MedPaxDetails, MedPaxPill, OperationId, OrderRecord, PrivateLabelCarton, Product, Settings, SqliteClient, SupportedOperationId, Tracking, TransitionInput, WholescriptsAPIOptions, WholescriptsRuntime, WholescriptsRuntimeOptions };
|
package/dist/index.js
CHANGED
|
@@ -8,9 +8,11 @@ import {
|
|
|
8
8
|
canonicalStatus,
|
|
9
9
|
createRuntime,
|
|
10
10
|
document,
|
|
11
|
+
mergeCatalog,
|
|
11
12
|
operationIds,
|
|
13
|
+
parseCatalogDocument,
|
|
12
14
|
supportedOperationIds
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-4BLJLSNN.js";
|
|
14
16
|
export {
|
|
15
17
|
DEFAULT_CATALOG,
|
|
16
18
|
MEDPAX_BOX_SKU,
|
|
@@ -21,7 +23,9 @@ export {
|
|
|
21
23
|
canonicalStatus,
|
|
22
24
|
createRuntime,
|
|
23
25
|
document,
|
|
26
|
+
mergeCatalog,
|
|
24
27
|
operationIds,
|
|
28
|
+
parseCatalogDocument,
|
|
25
29
|
supportedOperationIds
|
|
26
30
|
};
|
|
27
31
|
//# sourceMappingURL=index.js.map
|
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,13 +978,72 @@ 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. */
|
|
951
994
|
listening?(server: Listening): void;
|
|
952
995
|
};
|
|
953
996
|
|
|
997
|
+
/** MedPax-specific pricing and stock, present on products that can go into a MedPax pack. */
|
|
998
|
+
type MedPaxDetails = {
|
|
999
|
+
name: string;
|
|
1000
|
+
genericName: string;
|
|
1001
|
+
quantity: number;
|
|
1002
|
+
wholesalePrice: number;
|
|
1003
|
+
retailPrice: number;
|
|
1004
|
+
};
|
|
1005
|
+
/** One `GET /api/Orders/ProductList` row, in the field names our consumers parse. */
|
|
1006
|
+
type Product = {
|
|
1007
|
+
productName: string;
|
|
1008
|
+
sku: string;
|
|
1009
|
+
medPaxSku: string;
|
|
1010
|
+
categories: string;
|
|
1011
|
+
retailPrice: number;
|
|
1012
|
+
upc: string;
|
|
1013
|
+
descriptionShort: string;
|
|
1014
|
+
descriptionFull?: string;
|
|
1015
|
+
brand: string;
|
|
1016
|
+
productImage: string;
|
|
1017
|
+
quantity: number;
|
|
1018
|
+
countUnit: string;
|
|
1019
|
+
wholesalePrice: number;
|
|
1020
|
+
supplementFactsHTML: string;
|
|
1021
|
+
defaultDosing: {
|
|
1022
|
+
time: string;
|
|
1023
|
+
qty: number;
|
|
1024
|
+
}[];
|
|
1025
|
+
medPaxDetails?: MedPaxDetails | null;
|
|
1026
|
+
};
|
|
1027
|
+
/** One `medPaxPills` row of `GET /api/Orders/PrivateLabelProductList`. */
|
|
1028
|
+
type MedPaxPill = {
|
|
1029
|
+
sku: string;
|
|
1030
|
+
genericName: string;
|
|
1031
|
+
privateLabelName: string;
|
|
1032
|
+
quantity: number;
|
|
1033
|
+
};
|
|
1034
|
+
/** One `privateLabelCartons` row of `GET /api/Orders/PrivateLabelProductList`. */
|
|
1035
|
+
type PrivateLabelCarton = {
|
|
1036
|
+
sku: string;
|
|
1037
|
+
name: string;
|
|
1038
|
+
cartonImage: string;
|
|
1039
|
+
quantity: number;
|
|
1040
|
+
};
|
|
1041
|
+
type Catalog = {
|
|
1042
|
+
products: Product[];
|
|
1043
|
+
medPaxPills: MedPaxPill[];
|
|
1044
|
+
privateLabelCartons: PrivateLabelCarton[];
|
|
1045
|
+
};
|
|
1046
|
+
|
|
954
1047
|
type MountedAPI = FetchAPI$1 & {
|
|
955
1048
|
readonly prefix: string;
|
|
956
1049
|
GET: FetchHandler;
|
|
@@ -1125,6 +1218,12 @@ declare class Collection<T> {
|
|
|
1125
1218
|
}>;
|
|
1126
1219
|
}
|
|
1127
1220
|
|
|
1221
|
+
/**
|
|
1222
|
+
* What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
|
|
1223
|
+
* which derives the base from the wall clock when the runtime is created.
|
|
1224
|
+
*/
|
|
1225
|
+
type IdBase = number | string;
|
|
1226
|
+
|
|
1128
1227
|
/** Options every provider constructor accepts. */
|
|
1129
1228
|
type APIOptions = {
|
|
1130
1229
|
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
@@ -1220,6 +1319,15 @@ type FaultRule = {
|
|
|
1220
1319
|
requestHeaders?: Record<string, string>;
|
|
1221
1320
|
/** Fault only requests carrying these query parameters. `"*"` matches any value. */
|
|
1222
1321
|
query?: Record<string, string>;
|
|
1322
|
+
/**
|
|
1323
|
+
* Fault only requests whose JSON body carries these fields. Each key is a dotted path into
|
|
1324
|
+
* the parsed body (`"patient_details.email"`; a number steps into an array, `"items.0.sku"`)
|
|
1325
|
+
* and each value is what the field must equal: a string, number, boolean or `null`, compared
|
|
1326
|
+
* strictly (`3` is not `"3"`). `"*"` matches any value that is present. A request whose body
|
|
1327
|
+
* is missing, is not JSON, or is not a JSON object never matches. Not `body`, which is the
|
|
1328
|
+
* response a rule injects.
|
|
1329
|
+
*/
|
|
1330
|
+
requestBody?: Record<string, RequestBodyValue>;
|
|
1223
1331
|
/**
|
|
1224
1332
|
* Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
|
|
1225
1333
|
* an in-process caller usually wants, and what a parallel worker usually does not:
|
|
@@ -1286,6 +1394,8 @@ type FaultRule = {
|
|
|
1286
1394
|
/** The preset this rule was expanded from, if any. */
|
|
1287
1395
|
fromPreset?: string;
|
|
1288
1396
|
};
|
|
1397
|
+
/** What a field of the request body must equal in {@link FaultRule.requestBody}. */
|
|
1398
|
+
type RequestBodyValue = string | number | boolean | null;
|
|
1289
1399
|
/** A fault that fired for one request. */
|
|
1290
1400
|
type FaultHit = {
|
|
1291
1401
|
id: string;
|
|
@@ -1310,6 +1420,11 @@ type FaultCandidate = {
|
|
|
1310
1420
|
/** Request headers and query, for rules that match on them. */
|
|
1311
1421
|
headers?: Headers;
|
|
1312
1422
|
query?: URLSearchParams;
|
|
1423
|
+
/**
|
|
1424
|
+
* The request body parsed as JSON, read only when a rule matches on `requestBody`. Resolve
|
|
1425
|
+
* `undefined` for a body that is missing or not JSON. It must leave the request readable.
|
|
1426
|
+
*/
|
|
1427
|
+
readJson?: () => Promise<unknown>;
|
|
1313
1428
|
/** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
|
|
1314
1429
|
now?: number;
|
|
1315
1430
|
/** How to spend a delay for this request. Default: the registry's own sleep. */
|
|
@@ -1832,6 +1947,12 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
|
|
|
1832
1947
|
mount(prefix: string): MountedAPI;
|
|
1833
1948
|
readonly sqlite: SqliteClient$1;
|
|
1834
1949
|
readonly clock: Clock;
|
|
1950
|
+
/**
|
|
1951
|
+
* Change the id base ({@link RuntimeOptions.idBase}) for ids generated from now on, and
|
|
1952
|
+
* return the number it resolved to. Set it before the first request so a boot's ids stay
|
|
1953
|
+
* one run.
|
|
1954
|
+
*/
|
|
1955
|
+
setIdBase(base: IdBase): number;
|
|
1835
1956
|
readonly faults: FaultRegistry;
|
|
1836
1957
|
/** Baseline response time per namespace. */
|
|
1837
1958
|
readonly latency: LatencyRegistry;
|
|
@@ -1939,56 +2060,6 @@ interface SqliteClient {
|
|
|
1939
2060
|
transaction<T>(fn: () => T): T;
|
|
1940
2061
|
}
|
|
1941
2062
|
|
|
1942
|
-
/** MedPax-specific pricing and stock, present on products that can go into a MedPax pack. */
|
|
1943
|
-
type MedPaxDetails = {
|
|
1944
|
-
name: string;
|
|
1945
|
-
genericName: string;
|
|
1946
|
-
quantity: number;
|
|
1947
|
-
wholesalePrice: number;
|
|
1948
|
-
retailPrice: number;
|
|
1949
|
-
};
|
|
1950
|
-
/** One `GET /api/Orders/ProductList` row, in the field names our consumers parse. */
|
|
1951
|
-
type Product = {
|
|
1952
|
-
productName: string;
|
|
1953
|
-
sku: string;
|
|
1954
|
-
medPaxSku: string;
|
|
1955
|
-
categories: string;
|
|
1956
|
-
retailPrice: number;
|
|
1957
|
-
upc: string;
|
|
1958
|
-
descriptionShort: string;
|
|
1959
|
-
descriptionFull?: string;
|
|
1960
|
-
brand: string;
|
|
1961
|
-
productImage: string;
|
|
1962
|
-
quantity: number;
|
|
1963
|
-
countUnit: string;
|
|
1964
|
-
wholesalePrice: number;
|
|
1965
|
-
supplementFactsHTML: string;
|
|
1966
|
-
defaultDosing: {
|
|
1967
|
-
time: string;
|
|
1968
|
-
qty: number;
|
|
1969
|
-
}[];
|
|
1970
|
-
medPaxDetails?: MedPaxDetails | null;
|
|
1971
|
-
};
|
|
1972
|
-
/** One `medPaxPills` row of `GET /api/Orders/PrivateLabelProductList`. */
|
|
1973
|
-
type MedPaxPill = {
|
|
1974
|
-
sku: string;
|
|
1975
|
-
genericName: string;
|
|
1976
|
-
privateLabelName: string;
|
|
1977
|
-
quantity: number;
|
|
1978
|
-
};
|
|
1979
|
-
/** One `privateLabelCartons` row of `GET /api/Orders/PrivateLabelProductList`. */
|
|
1980
|
-
type PrivateLabelCarton = {
|
|
1981
|
-
sku: string;
|
|
1982
|
-
name: string;
|
|
1983
|
-
cartonImage: string;
|
|
1984
|
-
quantity: number;
|
|
1985
|
-
};
|
|
1986
|
-
type Catalog = {
|
|
1987
|
-
products: Product[];
|
|
1988
|
-
medPaxPills: MedPaxPill[];
|
|
1989
|
-
privateLabelCartons: PrivateLabelCarton[];
|
|
1990
|
-
};
|
|
1991
|
-
|
|
1992
2063
|
/**
|
|
1993
2064
|
* Anything that can answer a Fetch `Request` with a `Response`.
|
|
1994
2065
|
*
|
|
@@ -2144,8 +2215,15 @@ type WholescriptsServer = Listening & {
|
|
|
2144
2215
|
};
|
|
2145
2216
|
/** Serve the Wholescripts mock over `node:http`, with auto-advance ticking every 100 ms. */
|
|
2146
2217
|
declare const createServer: (options?: WholescriptsServerOptions) => Promise<WholescriptsServer>;
|
|
2218
|
+
/**
|
|
2219
|
+
* Read a catalog file (`{products?, medPaxPills?, privateLabelCartons?}`, or a bare array of
|
|
2220
|
+
* products) and lay it onto {@link DEFAULT_CATALOG} (`merge`, the default: a SKU the default has
|
|
2221
|
+
* is replaced in place, any other is added) or use it as the whole catalog (`replace`: a list the
|
|
2222
|
+
* file leaves out is empty).
|
|
2223
|
+
*/
|
|
2224
|
+
declare const loadCatalogFile: (path: string, mode?: "merge" | "replace") => Catalog;
|
|
2147
2225
|
/** How `serve` (and `serve --config`) builds the Wholescripts mock from flags. */
|
|
2148
2226
|
declare const serveTarget: ServeTarget;
|
|
2149
2227
|
|
|
2150
|
-
export { DEFAULT_PORT, createServer, serveTarget };
|
|
2228
|
+
export { DEFAULT_PORT, createServer, loadCatalogFile, serveTarget };
|
|
2151
2229
|
export type { WholescriptsServer, WholescriptsServerOptions };
|
package/dist/server.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_PORT,
|
|
3
3
|
createServer,
|
|
4
|
+
loadCatalogFile,
|
|
4
5
|
serveTarget
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-NS2QQO5Y.js";
|
|
7
|
+
import "./chunk-4BLJLSNN.js";
|
|
7
8
|
export {
|
|
8
9
|
DEFAULT_PORT,
|
|
9
10
|
createServer,
|
|
11
|
+
loadCatalogFile,
|
|
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-wholescripts",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Stateful emulator of the Wholescripts supplement fulfilment API: product and private-label catalogs, order submit, status polling and cancel, with admin status transitions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|