@crvouga/mockingbird-service-aws-speech 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/dist/{chunk-PFJYH66F.js → chunk-KGBYMBBR.js} +103 -22
- package/dist/chunk-KGBYMBBR.js.map +7 -0
- package/dist/{chunk-M7JQW4G3.js → chunk-ML4QWID2.js} +2 -2
- package/dist/cli.js +115 -15
- package/dist/cli.js.map +3 -3
- package/dist/index.d.ts +28 -0
- package/dist/index.js +1 -1
- package/dist/server.d.ts +71 -0
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-PFJYH66F.js.map +0 -7
- /package/dist/{chunk-M7JQW4G3.js.map → chunk-ML4QWID2.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRuntime
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KGBYMBBR.js";
|
|
4
4
|
|
|
5
5
|
// src/h2c.ts
|
|
6
6
|
import {
|
|
@@ -305,4 +305,4 @@ export {
|
|
|
305
305
|
createServer,
|
|
306
306
|
serveTarget
|
|
307
307
|
};
|
|
308
|
-
//# sourceMappingURL=chunk-
|
|
308
|
+
//# sourceMappingURL=chunk-ML4QWID2.js.map
|
package/dist/cli.js
CHANGED
|
@@ -2,22 +2,36 @@
|
|
|
2
2
|
import {
|
|
3
3
|
listenH2c,
|
|
4
4
|
serveTarget
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ML4QWID2.js";
|
|
6
6
|
import {
|
|
7
7
|
createClock,
|
|
8
8
|
normalizeBootControls,
|
|
9
9
|
normalizeControls,
|
|
10
|
+
normalizeIdBase,
|
|
10
11
|
ownedTransport,
|
|
11
12
|
parseDuration,
|
|
12
13
|
parseFaultHeader,
|
|
13
14
|
resolveAdminPrefix,
|
|
14
15
|
restoreClock
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-KGBYMBBR.js";
|
|
16
17
|
|
|
17
18
|
// ../../adapters/node/dist/cli.js
|
|
18
19
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
19
20
|
import { parseArgs } from "node:util";
|
|
20
21
|
|
|
22
|
+
// ../../adapters/node/dist/boot-settings.js
|
|
23
|
+
var checkSettings = (target, settings, label) => {
|
|
24
|
+
if (!target.parseSettings)
|
|
25
|
+
throw new Error(`${label}: ${target.name} takes no boot settings`);
|
|
26
|
+
try {
|
|
27
|
+
return target.parseSettings(settings);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
throw new Error(`${label}: ${error instanceof Error ? error.message : String(error)}`, {
|
|
30
|
+
cause: error
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
21
35
|
// ../../adapters/node/dist/fleet.js
|
|
22
36
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
23
37
|
import { createHash as createHash4, randomUUID as randomUUID4 } from "node:crypto";
|
|
@@ -2667,6 +2681,9 @@ var fleet_config_schema_default = {
|
|
|
2667
2681
|
adminControls: {
|
|
2668
2682
|
$ref: "#/$defs/controls"
|
|
2669
2683
|
},
|
|
2684
|
+
idBase: {
|
|
2685
|
+
$ref: "#/$defs/idBase"
|
|
2686
|
+
},
|
|
2670
2687
|
namespace: {
|
|
2671
2688
|
type: "string",
|
|
2672
2689
|
pattern: "^[A-Za-z0-9_.-]{1,64}$"
|
|
@@ -2756,6 +2773,12 @@ var fleet_config_schema_default = {
|
|
|
2756
2773
|
adminControls: {
|
|
2757
2774
|
$ref: "#/$defs/controls"
|
|
2758
2775
|
},
|
|
2776
|
+
idBase: {
|
|
2777
|
+
$ref: "#/$defs/idBase"
|
|
2778
|
+
},
|
|
2779
|
+
settings: {
|
|
2780
|
+
type: "object"
|
|
2781
|
+
},
|
|
2759
2782
|
fixtures: {
|
|
2760
2783
|
type: "object"
|
|
2761
2784
|
},
|
|
@@ -2802,6 +2825,18 @@ var fleet_config_schema_default = {
|
|
|
2802
2825
|
}
|
|
2803
2826
|
}
|
|
2804
2827
|
},
|
|
2828
|
+
idBase: {
|
|
2829
|
+
anyOf: [
|
|
2830
|
+
{
|
|
2831
|
+
type: "integer",
|
|
2832
|
+
minimum: 0
|
|
2833
|
+
},
|
|
2834
|
+
{
|
|
2835
|
+
type: "string",
|
|
2836
|
+
pattern: "^(boot|[0-9]+)$"
|
|
2837
|
+
}
|
|
2838
|
+
]
|
|
2839
|
+
},
|
|
2805
2840
|
controls: {
|
|
2806
2841
|
type: "object",
|
|
2807
2842
|
additionalProperties: false,
|
|
@@ -2951,6 +2986,8 @@ async function preflightFleet(config, options) {
|
|
|
2951
2986
|
throw new Error("protected archive policy requires a protected repository; configure its protector before startup");
|
|
2952
2987
|
resolveAdminPrefix(config.adminPrefix);
|
|
2953
2988
|
normalizeBootControls(config.adminControls);
|
|
2989
|
+
if (config.idBase !== void 0)
|
|
2990
|
+
normalizeIdBase(config.idBase, "idBase");
|
|
2954
2991
|
const targets = /* @__PURE__ */ new Map();
|
|
2955
2992
|
const ports = /* @__PURE__ */ new Set();
|
|
2956
2993
|
for (const [name, entry] of Object.entries(config.services)) {
|
|
@@ -2982,6 +3019,13 @@ async function preflightFleet(config, options) {
|
|
|
2982
3019
|
throw new Error("invalid protocol namespace selector");
|
|
2983
3020
|
}
|
|
2984
3021
|
}
|
|
3022
|
+
if (entry.idBase !== void 0)
|
|
3023
|
+
normalizeIdBase(entry.idBase, "idBase");
|
|
3024
|
+
if (entry.settings !== void 0) {
|
|
3025
|
+
if (protocol !== "http" || !("create" in target))
|
|
3026
|
+
throw new Error("settings: only HTTP services take boot settings");
|
|
3027
|
+
checkSettings(target, entry.settings, "settings");
|
|
3028
|
+
}
|
|
2985
3029
|
const port = entry.port ?? target.defaultPort;
|
|
2986
3030
|
if (port !== 0) {
|
|
2987
3031
|
const key = `${entry.host ?? "127.0.0.1"}:${port}`;
|
|
@@ -3017,7 +3061,7 @@ async function preflightFleet(config, options) {
|
|
|
3017
3061
|
break;
|
|
3018
3062
|
}
|
|
3019
3063
|
}
|
|
3020
|
-
targets.set(name, { ...target, packageVersion: packageVersion ?? "3.
|
|
3064
|
+
targets.set(name, { ...target, packageVersion: packageVersion ?? "3.8.0" });
|
|
3021
3065
|
} catch (error) {
|
|
3022
3066
|
throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
3023
3067
|
}
|
|
@@ -3243,7 +3287,11 @@ var serve = async (api, options = {}) => {
|
|
|
3243
3287
|
// ../../adapters/node/dist/listen.js
|
|
3244
3288
|
var listen = async (api, options = {}) => {
|
|
3245
3289
|
const host = options.host ?? "127.0.0.1";
|
|
3246
|
-
const server = await serve(api, {
|
|
3290
|
+
const server = await serve(api, {
|
|
3291
|
+
port: options.port ?? 0,
|
|
3292
|
+
host,
|
|
3293
|
+
...options.maxBodyBytes !== void 0 ? { maxBodyBytes: options.maxBodyBytes } : {}
|
|
3294
|
+
});
|
|
3247
3295
|
const address = server.address();
|
|
3248
3296
|
const port = typeof address === "object" && address !== null ? address.port : options.port ?? 0;
|
|
3249
3297
|
const shown = host.includes(":") ? `[${host}]` : host;
|
|
@@ -3337,6 +3385,7 @@ var httpChild = async (target, entry, options, admission, generation, privateAcc
|
|
|
3337
3385
|
options.onLog?.(entry2);
|
|
3338
3386
|
},
|
|
3339
3387
|
...entry.adminControls !== void 0 ? { adminControls: entry.adminControls } : {},
|
|
3388
|
+
...entry.settings !== void 0 ? { settings: checkSettings(target, entry.settings, "settings") } : {},
|
|
3340
3389
|
...entry.fixtures !== void 0 ? { fixtures: entry.fixtures } : {},
|
|
3341
3390
|
...(advertisedHttpBase(entry) ?? entry.baseUrl) !== void 0 ? { baseUrl: advertisedHttpBase(entry) ?? entry.baseUrl } : {}
|
|
3342
3391
|
});
|
|
@@ -3355,6 +3404,8 @@ var httpChild = async (target, entry, options, admission, generation, privateAcc
|
|
|
3355
3404
|
].some((method) => typeof created[method] !== "function"))
|
|
3356
3405
|
throw new Error("HTTP target does not implement the fleet runtime protocol; build/install matching supported service versions");
|
|
3357
3406
|
const runtime = created;
|
|
3407
|
+
if (entry.idBase !== void 0)
|
|
3408
|
+
runtime.setIdBase?.(entry.idBase);
|
|
3358
3409
|
const unobserve = runtime.webhooks?.observeDeliveries(observer.delivery);
|
|
3359
3410
|
if (options.outbound && runtime.webhooks)
|
|
3360
3411
|
runtime.webhooks.setTransportPolicy(ownedTransport(options.outbound));
|
|
@@ -3439,7 +3490,8 @@ var httpChild = async (target, entry, options, admission, generation, privateAcc
|
|
|
3439
3490
|
try {
|
|
3440
3491
|
server = await listen(api, {
|
|
3441
3492
|
port: entry.port ?? target.defaultPort,
|
|
3442
|
-
host: entry.host ?? "127.0.0.1"
|
|
3493
|
+
host: entry.host ?? "127.0.0.1",
|
|
3494
|
+
...target.maxBodyBytes !== void 0 ? { maxBodyBytes: target.maxBodyBytes } : {}
|
|
3443
3495
|
});
|
|
3444
3496
|
target.listening?.(server);
|
|
3445
3497
|
} catch (error) {
|
|
@@ -3953,6 +4005,7 @@ async function startFleet(config, options) {
|
|
|
3953
4005
|
...entry,
|
|
3954
4006
|
adminPrefix: resolveAdminPrefix(entry.adminPrefix ?? adminPrefix),
|
|
3955
4007
|
...adminKey !== void 0 ? { adminKey } : {},
|
|
4008
|
+
...(entry.idBase ?? config.idBase) !== void 0 ? { idBase: entry.idBase ?? config.idBase } : {},
|
|
3956
4009
|
// Fleet-wide controls, with the service's own keys replacing them.
|
|
3957
4010
|
...config.adminControls !== void 0 || entry.adminControls !== void 0 ? { adminControls: { ...config.adminControls, ...entry.adminControls } } : {}
|
|
3958
4011
|
}, options, (namespace, request) => management?.admit(namespace, request), (namespace) => management?.generation(namespace), (namespace, request) => management?.privateRequest(namespace, request) ?? false, {
|
|
@@ -4637,6 +4690,16 @@ var COMMON_SERVE_OPTIONS = {
|
|
|
4637
4690
|
value: "<seed>",
|
|
4638
4691
|
description: "Seed for every random choice (env MOCKINGBIRD_SEED)"
|
|
4639
4692
|
},
|
|
4693
|
+
"id-base": {
|
|
4694
|
+
type: "string",
|
|
4695
|
+
value: "<n|boot>",
|
|
4696
|
+
description: "Start generated ids at this base so a restart does not reissue the last boot's ids; boot derives one from the clock (env MOCKINGBIRD_ID_BASE; default 0, the same ids every boot)"
|
|
4697
|
+
},
|
|
4698
|
+
settings: {
|
|
4699
|
+
type: "string",
|
|
4700
|
+
value: "<json|file>",
|
|
4701
|
+
description: "Service settings to boot with, as JSON or a JSON file; every namespace starts from them (env MOCKINGBIRD_SETTINGS; only for services that declare settings)"
|
|
4702
|
+
},
|
|
4640
4703
|
"admin-controls": {
|
|
4641
4704
|
type: "string",
|
|
4642
4705
|
value: "<json|file>",
|
|
@@ -4731,19 +4794,40 @@ var readJsonFile = async (path, label) => {
|
|
|
4731
4794
|
}
|
|
4732
4795
|
};
|
|
4733
4796
|
var isObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4797
|
+
var readJsonOption = async (source, label) => {
|
|
4798
|
+
const trimmed = source.trim();
|
|
4799
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
4800
|
+
try {
|
|
4801
|
+
return JSON.parse(trimmed);
|
|
4802
|
+
} catch {
|
|
4803
|
+
throw new Error(`${label}: not valid JSON`);
|
|
4804
|
+
}
|
|
4805
|
+
}
|
|
4806
|
+
return readJsonFile(source, label);
|
|
4807
|
+
};
|
|
4808
|
+
var resolveServeIdBase = (values, env = process.env) => {
|
|
4809
|
+
const source = asString(values["id-base"]) ?? env.MOCKINGBIRD_ID_BASE;
|
|
4810
|
+
if (source === void 0 || source.trim() === "")
|
|
4811
|
+
return void 0;
|
|
4812
|
+
normalizeIdBase(source.trim(), "--id-base");
|
|
4813
|
+
return source.trim();
|
|
4814
|
+
};
|
|
4815
|
+
var resolveServeSettings = async (target, values, env = process.env) => {
|
|
4816
|
+
const flag = asString(values.settings);
|
|
4817
|
+
const source = flag ?? env.MOCKINGBIRD_SETTINGS;
|
|
4818
|
+
if (source === void 0 || source.trim() === "")
|
|
4819
|
+
return void 0;
|
|
4820
|
+
const label = flag !== void 0 ? "--settings" : "MOCKINGBIRD_SETTINGS";
|
|
4821
|
+
const parsed = await readJsonOption(source, label);
|
|
4822
|
+
if (!isObject2(parsed))
|
|
4823
|
+
throw new Error(`${label}: expected a JSON object`);
|
|
4824
|
+
return checkSettings(target, parsed, label);
|
|
4825
|
+
};
|
|
4734
4826
|
var resolveServeControls = async (values, env = process.env, base) => {
|
|
4735
4827
|
const source = asString(values["admin-controls"]) ?? env.MOCKINGBIRD_ADMIN_CONTROLS;
|
|
4736
4828
|
let document = isObject2(base) ? { ...base } : {};
|
|
4737
4829
|
if (source !== void 0 && source.trim() !== "") {
|
|
4738
|
-
|
|
4739
|
-
if (source.trim().startsWith("{")) {
|
|
4740
|
-
try {
|
|
4741
|
-
parsed = JSON.parse(source);
|
|
4742
|
-
} catch {
|
|
4743
|
-
throw new Error("--admin-controls: not valid JSON");
|
|
4744
|
-
}
|
|
4745
|
-
} else
|
|
4746
|
-
parsed = await readJsonFile(source, "--admin-controls");
|
|
4830
|
+
const parsed = source.trim().startsWith("{") ? await readJsonOption(source, "--admin-controls") : await readJsonFile(source, "--admin-controls");
|
|
4747
4831
|
if (!isObject2(parsed))
|
|
4748
4832
|
throw new Error("--admin-controls: expected a JSON object");
|
|
4749
4833
|
document = { ...document, ...parsed };
|
|
@@ -4793,9 +4877,16 @@ var start = async (target, values, config) => {
|
|
|
4793
4877
|
adminKey: config.adminKey,
|
|
4794
4878
|
seed: config.seed,
|
|
4795
4879
|
onLog: formatLog(config.log),
|
|
4880
|
+
...config.settings !== void 0 ? { settings: config.settings } : {},
|
|
4796
4881
|
...config.adminControls !== void 0 ? { adminControls: config.adminControls } : {}
|
|
4797
4882
|
});
|
|
4798
|
-
|
|
4883
|
+
if (config.idBase !== void 0)
|
|
4884
|
+
runtime.setIdBase?.(config.idBase);
|
|
4885
|
+
const listening = await listen(runtime, {
|
|
4886
|
+
port: config.port,
|
|
4887
|
+
host: config.host,
|
|
4888
|
+
...target.maxBodyBytes !== void 0 ? { maxBodyBytes: target.maxBodyBytes } : {}
|
|
4889
|
+
});
|
|
4799
4890
|
target.listening?.(listening);
|
|
4800
4891
|
console.log(`${target.name} emulator listening on ${listening.url}`);
|
|
4801
4892
|
console.log(`${target.name} health: GET ${listening.url}${adminPrefix}/health`);
|
|
@@ -4840,6 +4931,11 @@ var serveCommand = (target) => ({
|
|
|
4840
4931
|
const adminControls = await resolveServeControls(values, process.env, config.adminControls);
|
|
4841
4932
|
if (adminControls !== void 0)
|
|
4842
4933
|
config.adminControls = adminControls;
|
|
4934
|
+
if (values.settings !== void 0)
|
|
4935
|
+
throw new Error("--settings serves a single service; give each service its own `settings` in the config");
|
|
4936
|
+
const idBase = config.idBase ?? resolveServeIdBase(values);
|
|
4937
|
+
if (idBase !== void 0)
|
|
4938
|
+
config.idBase = idBase;
|
|
4843
4939
|
const fleet = await startFleet(config, {
|
|
4844
4940
|
load: (name) => loadTarget(name, target),
|
|
4845
4941
|
onLog: formatLog(config.log ?? log),
|
|
@@ -4869,8 +4965,12 @@ var serveCommand = (target) => ({
|
|
|
4869
4965
|
let listening;
|
|
4870
4966
|
try {
|
|
4871
4967
|
const adminControls = await resolveServeControls(values);
|
|
4968
|
+
const idBase = resolveServeIdBase(values);
|
|
4969
|
+
const settings = await resolveServeSettings(target, values);
|
|
4872
4970
|
listening = await start(target, values, {
|
|
4873
4971
|
...adminControls !== void 0 ? { adminControls } : {},
|
|
4972
|
+
...idBase !== void 0 ? { idBase } : {},
|
|
4973
|
+
...settings !== void 0 ? { settings } : {},
|
|
4874
4974
|
adminPrefix: resolveAdminPrefix(asString(values["admin-prefix"]) ?? process.env.MOCKINGBIRD_ADMIN_PREFIX),
|
|
4875
4975
|
port: port === void 0 ? target.defaultPort : Number.parseInt(port, 10),
|
|
4876
4976
|
host: asString(values.host) ?? "127.0.0.1",
|