@crvouga/mockingbird-runtime 0.5.0 → 0.6.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/README.md +32 -1
- package/dist/adapter-node.js +11 -4
- package/dist/adapter-node.js.map +2 -2
- package/dist/authoring.d.ts +1599 -0
- package/dist/authoring.js +83 -0
- package/dist/authoring.js.map +7 -0
- package/dist/chunk-BK5KDNUE.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +2 -2
- package/package.json +5 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Collection,
|
|
3
|
+
IdSequence,
|
|
4
|
+
bodyIssues,
|
|
5
|
+
createRuntime,
|
|
6
|
+
createService,
|
|
7
|
+
defineOperations,
|
|
8
|
+
jsonRes
|
|
9
|
+
} from "./chunk-BK5KDNUE.js";
|
|
10
|
+
import "./chunk-2KDYLZXC.js";
|
|
11
|
+
import "./chunk-GAIPLMRY.js";
|
|
12
|
+
import "./chunk-U36J5GCB.js";
|
|
13
|
+
import "./chunk-EQLY2YOA.js";
|
|
14
|
+
import "./chunk-HU6IOAFC.js";
|
|
15
|
+
import "./chunk-4SAK6MQT.js";
|
|
16
|
+
|
|
17
|
+
// src/authoring.ts
|
|
18
|
+
function defineHttpService(definition) {
|
|
19
|
+
const {
|
|
20
|
+
name,
|
|
21
|
+
version,
|
|
22
|
+
defaultPort = 0,
|
|
23
|
+
document,
|
|
24
|
+
handlers,
|
|
25
|
+
before,
|
|
26
|
+
unsupported,
|
|
27
|
+
notFound = () => Response.json({ error: "not_found" }, { status: 404 }),
|
|
28
|
+
onError = () => Response.json({ error: "internal_error" }, { status: 500 }),
|
|
29
|
+
...runtimeOptions
|
|
30
|
+
} = definition;
|
|
31
|
+
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name))
|
|
32
|
+
throw new Error("expected a lowercase hyphenated service name");
|
|
33
|
+
if (!version.trim()) throw new Error("service version is required");
|
|
34
|
+
if (!Number.isInteger(defaultPort) || defaultPort < 0 || defaultPort > 65535)
|
|
35
|
+
throw new Error("defaultPort must be 0-65535");
|
|
36
|
+
const boot = (options = {}) => createRuntime({
|
|
37
|
+
...options,
|
|
38
|
+
...runtimeOptions,
|
|
39
|
+
name,
|
|
40
|
+
version,
|
|
41
|
+
document,
|
|
42
|
+
create(context) {
|
|
43
|
+
return createService({
|
|
44
|
+
sqlite: context.sqlite,
|
|
45
|
+
namespace: context.namespace,
|
|
46
|
+
now: context.clock.now,
|
|
47
|
+
document,
|
|
48
|
+
handlers: handlers(context),
|
|
49
|
+
notFound,
|
|
50
|
+
onError,
|
|
51
|
+
...before && { before },
|
|
52
|
+
...unsupported && { unsupported }
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
createRuntime: boot,
|
|
58
|
+
serveTarget: {
|
|
59
|
+
name,
|
|
60
|
+
packageVersion: version,
|
|
61
|
+
defaultPort,
|
|
62
|
+
create(_values, common) {
|
|
63
|
+
const { adminKey, adminPrefix, seed, adminControls, onLog } = common;
|
|
64
|
+
return boot({
|
|
65
|
+
...adminKey !== void 0 && { adminKey },
|
|
66
|
+
...adminPrefix !== void 0 && { adminPrefix },
|
|
67
|
+
...seed !== void 0 && { seed },
|
|
68
|
+
...adminControls !== void 0 && { adminControls },
|
|
69
|
+
...onLog && { onLog }
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
Collection,
|
|
77
|
+
IdSequence,
|
|
78
|
+
bodyIssues,
|
|
79
|
+
defineHttpService,
|
|
80
|
+
defineOperations,
|
|
81
|
+
jsonRes as jsonResponse
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=authoring.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/authoring.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n createRuntime,\n createService,\n type InstanceContext,\n type MockCreateOptions,\n type OperationHandlers,\n type RuntimeOptions,\n type Service,\n type ServiceOptions,\n type ServiceRuntime,\n} from \"@crvouga/mockingbird-service\"\n\nexport type { InstanceContext, OperationHandlers } from \"@crvouga/mockingbird-service\"\nexport {\n bodyIssues,\n Collection,\n defineOperations,\n IdSequence,\n jsonResponse,\n} from \"@crvouga/mockingbird-service\"\n\nexport type HttpServiceDefinition = Pick<\n RuntimeOptions<Service>,\n \"name\" | \"presets\" | \"credential\" | \"state\" | \"admin\"\n> &\n Pick<ServiceOptions, \"document\" | \"before\" | \"unsupported\"> &\n Partial<Pick<ServiceOptions, \"onError\" | \"notFound\">> & {\n version: string\n defaultPort?: number\n handlers(context: InstanceContext): OperationHandlers\n }\n\nexport type HttpRuntimeFactory = (\n options?: MockCreateOptions & Pick<RuntimeOptions<Service>, \"onLog\">,\n) => ServiceRuntime<Service>\n\n/** Structural subset of the fleet boot options consumed by HTTP services. */\ntype HttpBootControls = {\n [K in \"adminKey\" | \"adminPrefix\" | \"seed\" | \"adminControls\" | \"onLog\"]?:\n | RuntimeOptions<Service>[K]\n | undefined\n}\n\nexport interface HttpServeTarget {\n name: string\n packageVersion: string\n defaultPort: number\n create(values: unknown, common: HttpBootControls): ServiceRuntime<Service>\n}\n\n/** Define once for Fetch, a Node listener, or a fleet. Each boot owns its storage and clock. */\nexport function defineHttpService(definition: HttpServiceDefinition): {\n createRuntime: HttpRuntimeFactory\n serveTarget: HttpServeTarget\n} {\n const {\n name,\n version,\n defaultPort = 0,\n document,\n handlers,\n before,\n unsupported,\n notFound = () => Response.json({ error: \"not_found\" }, { status: 404 }),\n onError = () => Response.json({ error: \"internal_error\" }, { status: 500 }),\n ...runtimeOptions\n } = definition\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name))\n throw new Error(\"expected a lowercase hyphenated service name\")\n if (!version.trim()) throw new Error(\"service version is required\")\n if (!Number.isInteger(defaultPort) || defaultPort < 0 || defaultPort > 65535)\n throw new Error(\"defaultPort must be 0-65535\")\n const boot = (\n options: MockCreateOptions & Pick<RuntimeOptions<Service>, \"onLog\"> = {},\n ): ServiceRuntime<Service> =>\n createRuntime({\n ...options,\n ...runtimeOptions,\n name,\n version,\n document,\n create(context) {\n return createService({\n sqlite: context.sqlite,\n namespace: context.namespace,\n now: context.clock.now,\n document,\n handlers: handlers(context),\n notFound,\n onError,\n ...(before && { before }),\n ...(unsupported && { unsupported }),\n })\n },\n })\n return {\n createRuntime: boot,\n serveTarget: {\n name,\n packageVersion: version,\n defaultPort,\n create(_values: unknown, common: HttpBootControls) {\n const { adminKey, adminPrefix, seed, adminControls, onLog } = common\n return boot({\n ...(adminKey !== undefined && { adminKey }),\n ...(adminPrefix !== undefined && { adminPrefix }),\n ...(seed !== undefined && { seed }),\n ...(adminControls !== undefined && { adminControls }),\n ...(onLog && { onLog }),\n })\n },\n },\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAmDO,SAAS,kBAAkB,YAGhC;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,MAAM,SAAS,KAAK,EAAE,OAAO,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,IACtE,UAAU,MAAM,SAAS,KAAK,EAAE,OAAO,iBAAiB,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,IAC1E,GAAG;AAAA,EACL,IAAI;AACJ,MAAI,CAAC,6BAA6B,KAAK,IAAI;AACzC,UAAM,IAAI,MAAM,8CAA8C;AAChE,MAAI,CAAC,QAAQ,KAAK,EAAG,OAAM,IAAI,MAAM,6BAA6B;AAClE,MAAI,CAAC,OAAO,UAAU,WAAW,KAAK,cAAc,KAAK,cAAc;AACrE,UAAM,IAAI,MAAM,6BAA6B;AAC/C,QAAM,OAAO,CACX,UAAsE,CAAC,MAEvE,cAAc;AAAA,IACZ,GAAG;AAAA,IACH,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,SAAS;AACd,aAAO,cAAc;AAAA,QACnB,QAAQ,QAAQ;AAAA,QAChB,WAAW,QAAQ;AAAA,QACnB,KAAK,QAAQ,MAAM;AAAA,QACnB;AAAA,QACA,UAAU,SAAS,OAAO;AAAA,QAC1B;AAAA,QACA;AAAA,QACA,GAAI,UAAU,EAAE,OAAO;AAAA,QACvB,GAAI,eAAe,EAAE,YAAY;AAAA,MACnC,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH,SAAO;AAAA,IACL,eAAe;AAAA,IACf,aAAa;AAAA,MACX;AAAA,MACA,gBAAgB;AAAA,MAChB;AAAA,MACA,OAAO,SAAkB,QAA0B;AACjD,cAAM,EAAE,UAAU,aAAa,MAAM,eAAe,MAAM,IAAI;AAC9D,eAAO,KAAK;AAAA,UACV,GAAI,aAAa,UAAa,EAAE,SAAS;AAAA,UACzC,GAAI,gBAAgB,UAAa,EAAE,YAAY;AAAA,UAC/C,GAAI,SAAS,UAAa,EAAE,KAAK;AAAA,UACjC,GAAI,kBAAkB,UAAa,EAAE,cAAc;AAAA,UACnD,GAAI,SAAS,EAAE,MAAM;AAAA,QACvB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/chunk-BK5KDNUE.js
CHANGED
|
@@ -5899,8 +5899,8 @@ var stateAdminRoutes = (routes) => {
|
|
|
5899
5899
|
};
|
|
5900
5900
|
|
|
5901
5901
|
// ../service/core/dist/version.js
|
|
5902
|
-
var UNRELEASED_VERSION = "0.
|
|
5903
|
-
var PACKAGE_VERSION = true ? "0.
|
|
5902
|
+
var UNRELEASED_VERSION = "0.6.0";
|
|
5903
|
+
var PACKAGE_VERSION = true ? "0.6.0" : UNRELEASED_VERSION;
|
|
5904
5904
|
|
|
5905
5905
|
// ../service/core/dist/webhooks.js
|
|
5906
5906
|
var signers = {
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* copy (scripts/bundle-service-runtime.ts).
|
|
6
6
|
*/
|
|
7
7
|
/** Every subpath this package exports, in `package.json` order. */
|
|
8
|
-
declare const RUNTIME_SUBPATHS: readonly ["core", "openapi", "openapi-metadata", "http-codec", "http-provider", "mqtt-broker", "mqtt-broker/node", "ui", "sqlite", "service", "service/admin", "adapter-node", "preview/bridge", "preview/host", "preview/artifacts", "preview/harness"];
|
|
8
|
+
declare const RUNTIME_SUBPATHS: readonly ["authoring", "core", "openapi", "openapi-metadata", "http-codec", "http-provider", "mqtt-broker", "mqtt-broker/node", "ui", "sqlite", "service", "service/admin", "adapter-node", "preview/bridge", "preview/host", "preview/artifacts", "preview/harness"];
|
|
9
9
|
|
|
10
10
|
export { RUNTIME_SUBPATHS };
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The shared Mockingbird runtime, published once so every emulator service depends on the same\n * copy. Each subpath re-exports one workspace helper (`@crvouga/mockingbird-runtime/<subpath>` is\n * `@crvouga/mockingbird-<subpath>`); a service's build imports these instead of inlining its own\n * copy (scripts/bundle-service-runtime.ts).\n */\n\n/** Every subpath this package exports, in `package.json` order. */\nexport const RUNTIME_SUBPATHS = [\n \"core\",\n \"openapi\",\n \"openapi-metadata\",\n \"http-codec\",\n \"http-provider\",\n \"mqtt-broker\",\n \"mqtt-broker/node\",\n \"ui\",\n \"sqlite\",\n \"service\",\n \"service/admin\",\n \"adapter-node\",\n \"preview/bridge\",\n \"preview/host\",\n \"preview/artifacts\",\n \"preview/harness\",\n] as const\n"],
|
|
5
|
-
"mappings": ";AAQO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
4
|
+
"sourcesContent": ["/**\n * The shared Mockingbird runtime, published once so every emulator service depends on the same\n * copy. Each subpath re-exports one workspace helper (`@crvouga/mockingbird-runtime/<subpath>` is\n * `@crvouga/mockingbird-<subpath>`); a service's build imports these instead of inlining its own\n * copy (scripts/bundle-service-runtime.ts).\n */\n\n/** Every subpath this package exports, in `package.json` order. */\nexport const RUNTIME_SUBPATHS = [\n \"authoring\",\n \"core\",\n \"openapi\",\n \"openapi-metadata\",\n \"http-codec\",\n \"http-provider\",\n \"mqtt-broker\",\n \"mqtt-broker/node\",\n \"ui\",\n \"sqlite\",\n \"service\",\n \"service/admin\",\n \"adapter-node\",\n \"preview/bridge\",\n \"preview/host\",\n \"preview/artifacts\",\n \"preview/harness\",\n] as const\n"],
|
|
5
|
+
"mappings": ";AAQO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/mockingbird-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The shared Mockingbird runtime every emulator service depends on: router, admin API and page, snapshots, faults and clock, installed once however many emulators an application uses.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"default": "./dist/index.js"
|
|
18
18
|
},
|
|
19
|
+
"./authoring": {
|
|
20
|
+
"types": "./dist/authoring.d.ts",
|
|
21
|
+
"default": "./dist/authoring.js"
|
|
22
|
+
},
|
|
19
23
|
"./core": {
|
|
20
24
|
"types": "./dist/core.d.ts",
|
|
21
25
|
"default": "./dist/core.js"
|