@crvouga/mockingbird-service-aws 0.13.0 → 0.14.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 +14 -1
- package/dist/chunk-7LJ2FVWM.js +38 -0
- package/dist/chunk-7LJ2FVWM.js.map +7 -0
- package/dist/chunk-FQGIQLZR.js +99 -0
- package/dist/chunk-FQGIQLZR.js.map +7 -0
- package/dist/cli.js +3 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +254 -215
- package/dist/index.js +1 -3
- package/dist/server.d.ts +45 -37
- package/dist/server.js +2 -4
- package/package.json +3 -2
- package/dist/admin-ui.js +0 -27
- package/dist/admin-ui.js.map +0 -7
- package/dist/chunk-4WE7VKME.js +0 -7783
- package/dist/chunk-4WE7VKME.js.map +0 -7
- package/dist/chunk-BQ74Q6RF.js +0 -97
- package/dist/chunk-BQ74Q6RF.js.map +0 -7
- package/dist/chunk-NF2ZJTT3.js +0 -7
- package/dist/chunk-NF2ZJTT3.js.map +0 -7
- package/dist/chunk-QP2FVJNR.js +0 -5131
- package/dist/chunk-QP2FVJNR.js.map +0 -7
- package/dist/crypto-DOM3YBEA.js +0 -22
- package/dist/crypto-DOM3YBEA.js.map +0 -7
- package/dist/helpers-JBMEGUP7.js +0 -87
- package/dist/helpers-JBMEGUP7.js.map +0 -7
package/dist/index.d.ts
CHANGED
|
@@ -123,6 +123,19 @@ interface SqliteClient$3 {
|
|
|
123
123
|
transaction<T>(fn: () => T): T;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
/** Options every provider constructor accepts. */
|
|
127
|
+
type APIOptions = {
|
|
128
|
+
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
129
|
+
sqlite?: SqliteClient$3;
|
|
130
|
+
/** Clock used for `created`-style fields. Default `Date.now`. */
|
|
131
|
+
now?: () => number;
|
|
132
|
+
/**
|
|
133
|
+
* Storage namespace for this instance's records. Instances sharing one SQLite
|
|
134
|
+
* client stay isolated when their namespaces differ. Defaults to the service name.
|
|
135
|
+
*/
|
|
136
|
+
namespace?: string;
|
|
137
|
+
};
|
|
138
|
+
|
|
126
139
|
/** Every stored record carries a monotonically increasing sequence for stable ordering. */
|
|
127
140
|
type Stored<T> = {
|
|
128
141
|
seq: number;
|
|
@@ -167,19 +180,6 @@ declare class Collection$1<T> {
|
|
|
167
180
|
}>;
|
|
168
181
|
}
|
|
169
182
|
|
|
170
|
-
/** Options every provider constructor accepts. */
|
|
171
|
-
type APIOptions = {
|
|
172
|
-
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
173
|
-
sqlite?: SqliteClient$3;
|
|
174
|
-
/** Clock used for `created`-style fields. Default `Date.now`. */
|
|
175
|
-
now?: () => number;
|
|
176
|
-
/**
|
|
177
|
-
* Storage namespace for this instance's records. Instances sharing one SQLite
|
|
178
|
-
* client stay isolated when their namespaces differ. Defaults to the service name.
|
|
179
|
-
*/
|
|
180
|
-
namespace?: string;
|
|
181
|
-
};
|
|
182
|
-
|
|
183
183
|
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
184
184
|
type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
|
|
185
185
|
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
@@ -739,206 +739,6 @@ interface FetchAPI {
|
|
|
739
739
|
/** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
|
|
740
740
|
type FetchHandler = (request: Request) => Promise<Response>;
|
|
741
741
|
|
|
742
|
-
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
743
|
-
type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
|
|
744
|
-
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
745
|
-
type SqliteRunResult = {
|
|
746
|
-
changes: number;
|
|
747
|
-
lastInsertRowid: number | bigint;
|
|
748
|
-
};
|
|
749
|
-
/**
|
|
750
|
-
* Prepared statement bound to a {@link SqliteClient}.
|
|
751
|
-
*
|
|
752
|
-
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
753
|
-
*/
|
|
754
|
-
interface SqliteStatement {
|
|
755
|
-
run(...params: SqliteValue[]): SqliteRunResult;
|
|
756
|
-
all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
|
|
757
|
-
get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* Sync SQLite client port owned by Mockingbird.
|
|
761
|
-
*
|
|
762
|
-
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
763
|
-
* `bun:sqlite` instances all work when they expose this surface.
|
|
764
|
-
*/
|
|
765
|
-
interface SqliteClient {
|
|
766
|
-
exec(sql: string): void;
|
|
767
|
-
prepare(sql: string): SqliteStatement;
|
|
768
|
-
transaction<T>(fn: () => T): T;
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
/**
|
|
772
|
-
* What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
|
|
773
|
-
* which derives the base from the wall clock when the runtime is created.
|
|
774
|
-
*/
|
|
775
|
-
type IdBase = number | string;
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
|
|
779
|
-
* Unknown keys (including `x-*` extensions) are preserved on every object.
|
|
780
|
-
*/
|
|
781
|
-
type JsonPrimitive = string | number | boolean | null;
|
|
782
|
-
type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
783
|
-
[key: string]: JsonValue;
|
|
784
|
-
};
|
|
785
|
-
type ReferenceObject = {
|
|
786
|
-
$ref: string;
|
|
787
|
-
description?: string;
|
|
788
|
-
summary?: string;
|
|
789
|
-
};
|
|
790
|
-
type SchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
|
|
791
|
-
type SchemaObject = {
|
|
792
|
-
$ref?: string;
|
|
793
|
-
type?: SchemaType | SchemaType[];
|
|
794
|
-
title?: string;
|
|
795
|
-
description?: string;
|
|
796
|
-
format?: string;
|
|
797
|
-
enum?: JsonValue[];
|
|
798
|
-
const?: JsonValue;
|
|
799
|
-
default?: JsonValue;
|
|
800
|
-
example?: JsonValue;
|
|
801
|
-
examples?: JsonValue[];
|
|
802
|
-
nullable?: boolean;
|
|
803
|
-
deprecated?: boolean;
|
|
804
|
-
readOnly?: boolean;
|
|
805
|
-
writeOnly?: boolean;
|
|
806
|
-
minimum?: number;
|
|
807
|
-
maximum?: number;
|
|
808
|
-
exclusiveMinimum?: number;
|
|
809
|
-
exclusiveMaximum?: number;
|
|
810
|
-
multipleOf?: number;
|
|
811
|
-
minLength?: number;
|
|
812
|
-
maxLength?: number;
|
|
813
|
-
pattern?: string;
|
|
814
|
-
minItems?: number;
|
|
815
|
-
maxItems?: number;
|
|
816
|
-
uniqueItems?: boolean;
|
|
817
|
-
items?: SchemaObject;
|
|
818
|
-
prefixItems?: SchemaObject[];
|
|
819
|
-
minProperties?: number;
|
|
820
|
-
maxProperties?: number;
|
|
821
|
-
required?: string[];
|
|
822
|
-
properties?: Record<string, SchemaObject>;
|
|
823
|
-
additionalProperties?: boolean | SchemaObject;
|
|
824
|
-
propertyNames?: SchemaObject;
|
|
825
|
-
oneOf?: SchemaObject[];
|
|
826
|
-
anyOf?: SchemaObject[];
|
|
827
|
-
allOf?: SchemaObject[];
|
|
828
|
-
not?: SchemaObject;
|
|
829
|
-
discriminator?: {
|
|
830
|
-
propertyName: string;
|
|
831
|
-
mapping?: Record<string, string>;
|
|
832
|
-
};
|
|
833
|
-
[extension: `x-${string}`]: unknown;
|
|
834
|
-
};
|
|
835
|
-
type ParameterLocation = "path" | "query" | "header" | "cookie";
|
|
836
|
-
type ParameterObject = {
|
|
837
|
-
name: string;
|
|
838
|
-
in: ParameterLocation;
|
|
839
|
-
description?: string;
|
|
840
|
-
required?: boolean;
|
|
841
|
-
deprecated?: boolean;
|
|
842
|
-
style?: string;
|
|
843
|
-
explode?: boolean;
|
|
844
|
-
schema?: SchemaObject;
|
|
845
|
-
content?: Record<string, MediaTypeObject>;
|
|
846
|
-
example?: JsonValue;
|
|
847
|
-
[extension: `x-${string}`]: unknown;
|
|
848
|
-
};
|
|
849
|
-
type MediaTypeObject = {
|
|
850
|
-
schema?: SchemaObject;
|
|
851
|
-
example?: JsonValue;
|
|
852
|
-
examples?: Record<string, unknown>;
|
|
853
|
-
encoding?: Record<string, unknown>;
|
|
854
|
-
[extension: `x-${string}`]: unknown;
|
|
855
|
-
};
|
|
856
|
-
type RequestBodyObject = {
|
|
857
|
-
description?: string;
|
|
858
|
-
required?: boolean;
|
|
859
|
-
content: Record<string, MediaTypeObject>;
|
|
860
|
-
[extension: `x-${string}`]: unknown;
|
|
861
|
-
};
|
|
862
|
-
type HeaderObject = {
|
|
863
|
-
description?: string;
|
|
864
|
-
required?: boolean;
|
|
865
|
-
schema?: SchemaObject;
|
|
866
|
-
[extension: `x-${string}`]: unknown;
|
|
867
|
-
};
|
|
868
|
-
type ResponseObject = {
|
|
869
|
-
description: string;
|
|
870
|
-
headers?: Record<string, HeaderObject | ReferenceObject>;
|
|
871
|
-
content?: Record<string, MediaTypeObject>;
|
|
872
|
-
[extension: `x-${string}`]: unknown;
|
|
873
|
-
};
|
|
874
|
-
type ResponsesObject = Record<string, ResponseObject | ReferenceObject>;
|
|
875
|
-
type SecurityRequirementObject = Record<string, string[]>;
|
|
876
|
-
type OperationObject = {
|
|
877
|
-
operationId?: string;
|
|
878
|
-
summary?: string;
|
|
879
|
-
description?: string;
|
|
880
|
-
tags?: string[];
|
|
881
|
-
deprecated?: boolean;
|
|
882
|
-
parameters?: Array<ParameterObject | ReferenceObject>;
|
|
883
|
-
requestBody?: RequestBodyObject | ReferenceObject;
|
|
884
|
-
responses: ResponsesObject;
|
|
885
|
-
security?: SecurityRequirementObject[];
|
|
886
|
-
[extension: `x-${string}`]: unknown;
|
|
887
|
-
};
|
|
888
|
-
declare const HTTP_METHODS: readonly ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
|
|
889
|
-
type HttpMethod = (typeof HTTP_METHODS)[number];
|
|
890
|
-
type PathItemObject = {
|
|
891
|
-
summary?: string;
|
|
892
|
-
description?: string;
|
|
893
|
-
parameters?: Array<ParameterObject | ReferenceObject>;
|
|
894
|
-
[extension: `x-${string}`]: unknown;
|
|
895
|
-
} & Partial<Record<HttpMethod, OperationObject>>;
|
|
896
|
-
type SecuritySchemeObject = {
|
|
897
|
-
type: "apiKey" | "http" | "oauth2" | "openIdConnect" | "mutualTLS";
|
|
898
|
-
description?: string;
|
|
899
|
-
name?: string;
|
|
900
|
-
in?: ParameterLocation;
|
|
901
|
-
scheme?: string;
|
|
902
|
-
bearerFormat?: string;
|
|
903
|
-
flows?: Record<string, unknown>;
|
|
904
|
-
openIdConnectUrl?: string;
|
|
905
|
-
[extension: `x-${string}`]: unknown;
|
|
906
|
-
};
|
|
907
|
-
type ComponentsObject = {
|
|
908
|
-
schemas?: Record<string, SchemaObject>;
|
|
909
|
-
responses?: Record<string, ResponseObject>;
|
|
910
|
-
parameters?: Record<string, ParameterObject>;
|
|
911
|
-
requestBodies?: Record<string, RequestBodyObject>;
|
|
912
|
-
headers?: Record<string, HeaderObject>;
|
|
913
|
-
securitySchemes?: Record<string, SecuritySchemeObject>;
|
|
914
|
-
[extension: `x-${string}`]: unknown;
|
|
915
|
-
};
|
|
916
|
-
type ServerObject = {
|
|
917
|
-
url: string;
|
|
918
|
-
description?: string;
|
|
919
|
-
variables?: Record<string, unknown>;
|
|
920
|
-
[extension: `x-${string}`]: unknown;
|
|
921
|
-
};
|
|
922
|
-
type InfoObject = {
|
|
923
|
-
title: string;
|
|
924
|
-
version: string;
|
|
925
|
-
description?: string;
|
|
926
|
-
[extension: `x-${string}`]: unknown;
|
|
927
|
-
};
|
|
928
|
-
type OpenAPIDocument = {
|
|
929
|
-
openapi: string;
|
|
930
|
-
info: InfoObject;
|
|
931
|
-
servers?: ServerObject[];
|
|
932
|
-
paths: Record<string, PathItemObject>;
|
|
933
|
-
components?: ComponentsObject;
|
|
934
|
-
security?: SecurityRequirementObject[];
|
|
935
|
-
tags?: Array<{
|
|
936
|
-
name: string;
|
|
937
|
-
description?: string;
|
|
938
|
-
}>;
|
|
939
|
-
[extension: `x-${string}`]: unknown;
|
|
940
|
-
};
|
|
941
|
-
|
|
942
742
|
/**
|
|
943
743
|
* The single source of time for a service.
|
|
944
744
|
*
|
|
@@ -969,6 +769,17 @@ type Clock = {
|
|
|
969
769
|
state(): ClockState;
|
|
970
770
|
};
|
|
971
771
|
|
|
772
|
+
type UpstreamState = {
|
|
773
|
+
mode: "emulated" | "forward";
|
|
774
|
+
baseUrl: string;
|
|
775
|
+
};
|
|
776
|
+
type UpstreamOptions = {
|
|
777
|
+
fetch: (request: Request) => Response | Promise<Response>;
|
|
778
|
+
baseUrl: string;
|
|
779
|
+
mode?: "emulated" | "forward";
|
|
780
|
+
rewriteAuth?: (request: Request) => Request | Promise<Request>;
|
|
781
|
+
};
|
|
782
|
+
|
|
972
783
|
/**
|
|
973
784
|
* Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
|
|
974
785
|
* request a percentage fault hits — is reproducible from a seed.
|
|
@@ -1245,6 +1056,7 @@ declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
|
|
|
1245
1056
|
* `records` are required, so a hand-written seed file is a valid snapshot.
|
|
1246
1057
|
*/
|
|
1247
1058
|
type SnapshotDocument = {
|
|
1059
|
+
upstream?: UpstreamState;
|
|
1248
1060
|
format: typeof SNAPSHOT_FORMAT;
|
|
1249
1061
|
/** The service that wrote it. A snapshot is rejected by any other service. */
|
|
1250
1062
|
service?: string;
|
|
@@ -1318,6 +1130,7 @@ type LatencyState = LatencyRule & {
|
|
|
1318
1130
|
};
|
|
1319
1131
|
/** What {@link controlHeaders} turns into request headers. */
|
|
1320
1132
|
type ControlHeaderInput = {
|
|
1133
|
+
upstream?: "emulated" | "forward";
|
|
1321
1134
|
namespace?: string;
|
|
1322
1135
|
adminKey?: string;
|
|
1323
1136
|
branch?: string;
|
|
@@ -1335,6 +1148,200 @@ type ControlHeaderInput = {
|
|
|
1335
1148
|
snapshot?: string;
|
|
1336
1149
|
};
|
|
1337
1150
|
|
|
1151
|
+
/**
|
|
1152
|
+
* The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
|
|
1153
|
+
* Unknown keys (including `x-*` extensions) are preserved on every object.
|
|
1154
|
+
*/
|
|
1155
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
1156
|
+
type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
1157
|
+
[key: string]: JsonValue;
|
|
1158
|
+
};
|
|
1159
|
+
type ReferenceObject = {
|
|
1160
|
+
$ref: string;
|
|
1161
|
+
description?: string;
|
|
1162
|
+
summary?: string;
|
|
1163
|
+
};
|
|
1164
|
+
type SchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
|
|
1165
|
+
type SchemaObject = {
|
|
1166
|
+
$ref?: string;
|
|
1167
|
+
type?: SchemaType | SchemaType[];
|
|
1168
|
+
title?: string;
|
|
1169
|
+
description?: string;
|
|
1170
|
+
format?: string;
|
|
1171
|
+
enum?: JsonValue[];
|
|
1172
|
+
const?: JsonValue;
|
|
1173
|
+
default?: JsonValue;
|
|
1174
|
+
example?: JsonValue;
|
|
1175
|
+
examples?: JsonValue[];
|
|
1176
|
+
nullable?: boolean;
|
|
1177
|
+
deprecated?: boolean;
|
|
1178
|
+
readOnly?: boolean;
|
|
1179
|
+
writeOnly?: boolean;
|
|
1180
|
+
minimum?: number;
|
|
1181
|
+
maximum?: number;
|
|
1182
|
+
exclusiveMinimum?: number;
|
|
1183
|
+
exclusiveMaximum?: number;
|
|
1184
|
+
multipleOf?: number;
|
|
1185
|
+
minLength?: number;
|
|
1186
|
+
maxLength?: number;
|
|
1187
|
+
pattern?: string;
|
|
1188
|
+
minItems?: number;
|
|
1189
|
+
maxItems?: number;
|
|
1190
|
+
uniqueItems?: boolean;
|
|
1191
|
+
items?: SchemaObject;
|
|
1192
|
+
prefixItems?: SchemaObject[];
|
|
1193
|
+
minProperties?: number;
|
|
1194
|
+
maxProperties?: number;
|
|
1195
|
+
required?: string[];
|
|
1196
|
+
properties?: Record<string, SchemaObject>;
|
|
1197
|
+
additionalProperties?: boolean | SchemaObject;
|
|
1198
|
+
propertyNames?: SchemaObject;
|
|
1199
|
+
oneOf?: SchemaObject[];
|
|
1200
|
+
anyOf?: SchemaObject[];
|
|
1201
|
+
allOf?: SchemaObject[];
|
|
1202
|
+
not?: SchemaObject;
|
|
1203
|
+
discriminator?: {
|
|
1204
|
+
propertyName: string;
|
|
1205
|
+
mapping?: Record<string, string>;
|
|
1206
|
+
};
|
|
1207
|
+
[extension: `x-${string}`]: unknown;
|
|
1208
|
+
};
|
|
1209
|
+
type ParameterLocation = "path" | "query" | "header" | "cookie";
|
|
1210
|
+
type ParameterObject = {
|
|
1211
|
+
name: string;
|
|
1212
|
+
in: ParameterLocation;
|
|
1213
|
+
description?: string;
|
|
1214
|
+
required?: boolean;
|
|
1215
|
+
deprecated?: boolean;
|
|
1216
|
+
style?: string;
|
|
1217
|
+
explode?: boolean;
|
|
1218
|
+
schema?: SchemaObject;
|
|
1219
|
+
content?: Record<string, MediaTypeObject>;
|
|
1220
|
+
example?: JsonValue;
|
|
1221
|
+
[extension: `x-${string}`]: unknown;
|
|
1222
|
+
};
|
|
1223
|
+
type MediaTypeObject = {
|
|
1224
|
+
schema?: SchemaObject;
|
|
1225
|
+
example?: JsonValue;
|
|
1226
|
+
examples?: Record<string, unknown>;
|
|
1227
|
+
encoding?: Record<string, unknown>;
|
|
1228
|
+
[extension: `x-${string}`]: unknown;
|
|
1229
|
+
};
|
|
1230
|
+
type RequestBodyObject = {
|
|
1231
|
+
description?: string;
|
|
1232
|
+
required?: boolean;
|
|
1233
|
+
content: Record<string, MediaTypeObject>;
|
|
1234
|
+
[extension: `x-${string}`]: unknown;
|
|
1235
|
+
};
|
|
1236
|
+
type HeaderObject = {
|
|
1237
|
+
description?: string;
|
|
1238
|
+
required?: boolean;
|
|
1239
|
+
schema?: SchemaObject;
|
|
1240
|
+
[extension: `x-${string}`]: unknown;
|
|
1241
|
+
};
|
|
1242
|
+
type ResponseObject = {
|
|
1243
|
+
description: string;
|
|
1244
|
+
headers?: Record<string, HeaderObject | ReferenceObject>;
|
|
1245
|
+
content?: Record<string, MediaTypeObject>;
|
|
1246
|
+
[extension: `x-${string}`]: unknown;
|
|
1247
|
+
};
|
|
1248
|
+
type ResponsesObject = Record<string, ResponseObject | ReferenceObject>;
|
|
1249
|
+
type SecurityRequirementObject = Record<string, string[]>;
|
|
1250
|
+
type OperationObject = {
|
|
1251
|
+
operationId?: string;
|
|
1252
|
+
summary?: string;
|
|
1253
|
+
description?: string;
|
|
1254
|
+
tags?: string[];
|
|
1255
|
+
deprecated?: boolean;
|
|
1256
|
+
parameters?: Array<ParameterObject | ReferenceObject>;
|
|
1257
|
+
requestBody?: RequestBodyObject | ReferenceObject;
|
|
1258
|
+
responses: ResponsesObject;
|
|
1259
|
+
security?: SecurityRequirementObject[];
|
|
1260
|
+
[extension: `x-${string}`]: unknown;
|
|
1261
|
+
};
|
|
1262
|
+
declare const HTTP_METHODS: readonly ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
|
|
1263
|
+
type HttpMethod = (typeof HTTP_METHODS)[number];
|
|
1264
|
+
type PathItemObject = {
|
|
1265
|
+
summary?: string;
|
|
1266
|
+
description?: string;
|
|
1267
|
+
parameters?: Array<ParameterObject | ReferenceObject>;
|
|
1268
|
+
[extension: `x-${string}`]: unknown;
|
|
1269
|
+
} & Partial<Record<HttpMethod, OperationObject>>;
|
|
1270
|
+
type SecuritySchemeObject = {
|
|
1271
|
+
type: "apiKey" | "http" | "oauth2" | "openIdConnect" | "mutualTLS";
|
|
1272
|
+
description?: string;
|
|
1273
|
+
name?: string;
|
|
1274
|
+
in?: ParameterLocation;
|
|
1275
|
+
scheme?: string;
|
|
1276
|
+
bearerFormat?: string;
|
|
1277
|
+
flows?: Record<string, unknown>;
|
|
1278
|
+
openIdConnectUrl?: string;
|
|
1279
|
+
[extension: `x-${string}`]: unknown;
|
|
1280
|
+
};
|
|
1281
|
+
type ComponentsObject = {
|
|
1282
|
+
schemas?: Record<string, SchemaObject>;
|
|
1283
|
+
responses?: Record<string, ResponseObject>;
|
|
1284
|
+
parameters?: Record<string, ParameterObject>;
|
|
1285
|
+
requestBodies?: Record<string, RequestBodyObject>;
|
|
1286
|
+
headers?: Record<string, HeaderObject>;
|
|
1287
|
+
securitySchemes?: Record<string, SecuritySchemeObject>;
|
|
1288
|
+
[extension: `x-${string}`]: unknown;
|
|
1289
|
+
};
|
|
1290
|
+
type ServerObject = {
|
|
1291
|
+
url: string;
|
|
1292
|
+
description?: string;
|
|
1293
|
+
variables?: Record<string, unknown>;
|
|
1294
|
+
[extension: `x-${string}`]: unknown;
|
|
1295
|
+
};
|
|
1296
|
+
type InfoObject = {
|
|
1297
|
+
title: string;
|
|
1298
|
+
version: string;
|
|
1299
|
+
description?: string;
|
|
1300
|
+
[extension: `x-${string}`]: unknown;
|
|
1301
|
+
};
|
|
1302
|
+
type OpenAPIDocument = {
|
|
1303
|
+
openapi: string;
|
|
1304
|
+
info: InfoObject;
|
|
1305
|
+
servers?: ServerObject[];
|
|
1306
|
+
paths: Record<string, PathItemObject>;
|
|
1307
|
+
components?: ComponentsObject;
|
|
1308
|
+
security?: SecurityRequirementObject[];
|
|
1309
|
+
tags?: Array<{
|
|
1310
|
+
name: string;
|
|
1311
|
+
description?: string;
|
|
1312
|
+
}>;
|
|
1313
|
+
[extension: `x-${string}`]: unknown;
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1316
|
+
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
1317
|
+
type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
|
|
1318
|
+
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
1319
|
+
type SqliteRunResult = {
|
|
1320
|
+
changes: number;
|
|
1321
|
+
lastInsertRowid: number | bigint;
|
|
1322
|
+
};
|
|
1323
|
+
/**
|
|
1324
|
+
* Prepared statement bound to a {@link SqliteClient}.
|
|
1325
|
+
*
|
|
1326
|
+
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
1327
|
+
*/
|
|
1328
|
+
interface SqliteStatement {
|
|
1329
|
+
run(...params: SqliteValue[]): SqliteRunResult;
|
|
1330
|
+
all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
|
|
1331
|
+
get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Sync SQLite client port owned by Mockingbird.
|
|
1335
|
+
*
|
|
1336
|
+
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
1337
|
+
* `bun:sqlite` instances all work when they expose this surface.
|
|
1338
|
+
*/
|
|
1339
|
+
interface SqliteClient {
|
|
1340
|
+
exec(sql: string): void;
|
|
1341
|
+
prepare(sql: string): SqliteStatement;
|
|
1342
|
+
transaction<T>(fn: () => T): T;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1338
1345
|
/**
|
|
1339
1346
|
* One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
|
|
1340
1347
|
* `kind` is `media_type` when the body is present but its media type is not one the operation
|
|
@@ -1361,6 +1368,7 @@ type RejectedRequest = {
|
|
|
1361
1368
|
};
|
|
1362
1369
|
/** One handled request, as the structured log sees it. */
|
|
1363
1370
|
type RequestLog = {
|
|
1371
|
+
upstream?: boolean;
|
|
1364
1372
|
service: string;
|
|
1365
1373
|
namespace: string;
|
|
1366
1374
|
operationId: string | undefined;
|
|
@@ -1511,8 +1519,6 @@ type CredentialRegistry = {
|
|
|
1511
1519
|
}[];
|
|
1512
1520
|
};
|
|
1513
1521
|
|
|
1514
|
-
type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
|
|
1515
|
-
|
|
1516
1522
|
/**
|
|
1517
1523
|
* A point-in-time copy of everything a service namespace holds.
|
|
1518
1524
|
*
|
|
@@ -1634,6 +1640,28 @@ type AdminUi = {
|
|
|
1634
1640
|
}) => string;
|
|
1635
1641
|
};
|
|
1636
1642
|
|
|
1643
|
+
/** One service's vendor chip: what `GET <adminPrefix>/ui/brands.json` returns under its name. */
|
|
1644
|
+
type AdminBrand = {
|
|
1645
|
+
vendor: string;
|
|
1646
|
+
website: string;
|
|
1647
|
+
/** Vendor API reference, when there is one. */
|
|
1648
|
+
docs: string | null;
|
|
1649
|
+
/** The service's page on the docs site. A link only; the admin never fetches it. */
|
|
1650
|
+
guide: string;
|
|
1651
|
+
/** A `data:image/…;base64,` URI, so the chip loads nothing from the network; "" for none. */
|
|
1652
|
+
logo: string;
|
|
1653
|
+
color: string | null;
|
|
1654
|
+
description: string | null;
|
|
1655
|
+
};
|
|
1656
|
+
|
|
1657
|
+
/**
|
|
1658
|
+
* What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
|
|
1659
|
+
* which derives the base from the wall clock when the runtime is created.
|
|
1660
|
+
*/
|
|
1661
|
+
type IdBase = number | string;
|
|
1662
|
+
|
|
1663
|
+
type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
|
|
1664
|
+
|
|
1637
1665
|
type WebhookEndpoint = {
|
|
1638
1666
|
/** Stable id; generated when omitted. */
|
|
1639
1667
|
id?: string;
|
|
@@ -1742,6 +1770,11 @@ type InstanceContext = {
|
|
|
1742
1770
|
rng: Rng;
|
|
1743
1771
|
};
|
|
1744
1772
|
type RuntimeOptions<T extends ServiceInstance> = {
|
|
1773
|
+
upstream?: UpstreamOptions;
|
|
1774
|
+
/** Capture an accepted real send without invoking an emulated handler. */
|
|
1775
|
+
onForwardResponse?: (instance: T, request: Request, response: Response) => Promise<void>;
|
|
1776
|
+
/** Reject unsupported forwarding surfaces before any network request. */
|
|
1777
|
+
canForward?: (request: Request) => boolean;
|
|
1745
1778
|
/** Service name, e.g. `"junction"`. Also the default namespace's storage key. */
|
|
1746
1779
|
name: string;
|
|
1747
1780
|
/** Build the instance backing one namespace. Called once per namespace, on first use. */
|
|
@@ -1789,6 +1822,12 @@ type RuntimeOptions<T extends ServiceInstance> = {
|
|
|
1789
1822
|
journalSize?: number;
|
|
1790
1823
|
/** Reported in the `x-mockingbird` header. Default: the bundled package's version. */
|
|
1791
1824
|
version?: string;
|
|
1825
|
+
/**
|
|
1826
|
+
* The vendor chip `GET <adminPrefix>/ui/brands.json` serves. Default: the brand bundled into
|
|
1827
|
+
* this build; a service built on the shared `@crvouga/mockingbird-runtime` passes its own
|
|
1828
|
+
* (scripts/bundle-service-runtime.ts).
|
|
1829
|
+
*/
|
|
1830
|
+
adminBrand?: AdminBrand;
|
|
1792
1831
|
/**
|
|
1793
1832
|
* The vendor credential a request carries (API key, token, account SID, AWS access key
|
|
1794
1833
|
* id), for SDKs that cannot send `x-mockingbird-namespace`: a suite maps credentials to
|
package/dist/index.js
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -104,41 +104,6 @@ interface FetchAPI {
|
|
|
104
104
|
/** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
|
|
105
105
|
type FetchHandler = (request: Request) => Promise<Response>;
|
|
106
106
|
|
|
107
|
-
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
108
|
-
type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
|
|
109
|
-
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
110
|
-
type SqliteRunResult = {
|
|
111
|
-
changes: number;
|
|
112
|
-
lastInsertRowid: number | bigint;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Prepared statement bound to a {@link SqliteClient}.
|
|
116
|
-
*
|
|
117
|
-
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
118
|
-
*/
|
|
119
|
-
interface SqliteStatement {
|
|
120
|
-
run(...params: SqliteValue[]): SqliteRunResult;
|
|
121
|
-
all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
|
|
122
|
-
get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Sync SQLite client port owned by Mockingbird.
|
|
126
|
-
*
|
|
127
|
-
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
128
|
-
* `bun:sqlite` instances all work when they expose this surface.
|
|
129
|
-
*/
|
|
130
|
-
interface SqliteClient {
|
|
131
|
-
exec(sql: string): void;
|
|
132
|
-
prepare(sql: string): SqliteStatement;
|
|
133
|
-
transaction<T>(fn: () => T): T;
|
|
134
|
-
}
|
|
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 = number | string;
|
|
141
|
-
|
|
142
107
|
/**
|
|
143
108
|
* The single source of time for a service.
|
|
144
109
|
*
|
|
@@ -169,6 +134,11 @@ type Clock = {
|
|
|
169
134
|
state(): ClockState;
|
|
170
135
|
};
|
|
171
136
|
|
|
137
|
+
type UpstreamState = {
|
|
138
|
+
mode: "emulated" | "forward";
|
|
139
|
+
baseUrl: string;
|
|
140
|
+
};
|
|
141
|
+
|
|
172
142
|
/**
|
|
173
143
|
* Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
|
|
174
144
|
* request a percentage fault hits — is reproducible from a seed.
|
|
@@ -432,6 +402,7 @@ declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
|
|
|
432
402
|
* `records` are required, so a hand-written seed file is a valid snapshot.
|
|
433
403
|
*/
|
|
434
404
|
type SnapshotDocument = {
|
|
405
|
+
upstream?: UpstreamState;
|
|
435
406
|
format: typeof SNAPSHOT_FORMAT;
|
|
436
407
|
/** The service that wrote it. A snapshot is rejected by any other service. */
|
|
437
408
|
service?: string;
|
|
@@ -505,6 +476,7 @@ type LatencyState = LatencyRule & {
|
|
|
505
476
|
};
|
|
506
477
|
/** What {@link controlHeaders} turns into request headers. */
|
|
507
478
|
type ControlHeaderInput = {
|
|
479
|
+
upstream?: "emulated" | "forward";
|
|
508
480
|
namespace?: string;
|
|
509
481
|
adminKey?: string;
|
|
510
482
|
branch?: string;
|
|
@@ -522,6 +494,35 @@ type ControlHeaderInput = {
|
|
|
522
494
|
snapshot?: string;
|
|
523
495
|
};
|
|
524
496
|
|
|
497
|
+
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
498
|
+
type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
|
|
499
|
+
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
|
500
|
+
type SqliteRunResult = {
|
|
501
|
+
changes: number;
|
|
502
|
+
lastInsertRowid: number | bigint;
|
|
503
|
+
};
|
|
504
|
+
/**
|
|
505
|
+
* Prepared statement bound to a {@link SqliteClient}.
|
|
506
|
+
*
|
|
507
|
+
* Pass bind values as rest arguments on each call (no sticky `bind()`).
|
|
508
|
+
*/
|
|
509
|
+
interface SqliteStatement {
|
|
510
|
+
run(...params: SqliteValue[]): SqliteRunResult;
|
|
511
|
+
all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
|
|
512
|
+
get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Sync SQLite client port owned by Mockingbird.
|
|
516
|
+
*
|
|
517
|
+
* Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
|
|
518
|
+
* `bun:sqlite` instances all work when they expose this surface.
|
|
519
|
+
*/
|
|
520
|
+
interface SqliteClient {
|
|
521
|
+
exec(sql: string): void;
|
|
522
|
+
prepare(sql: string): SqliteStatement;
|
|
523
|
+
transaction<T>(fn: () => T): T;
|
|
524
|
+
}
|
|
525
|
+
|
|
525
526
|
/**
|
|
526
527
|
* One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
|
|
527
528
|
* `kind` is `media_type` when the body is present but its media type is not one the operation
|
|
@@ -548,6 +549,7 @@ type RejectedRequest = {
|
|
|
548
549
|
};
|
|
549
550
|
/** One handled request, as the structured log sees it. */
|
|
550
551
|
type RequestLog = {
|
|
552
|
+
upstream?: boolean;
|
|
551
553
|
service: string;
|
|
552
554
|
namespace: string;
|
|
553
555
|
operationId: string | undefined;
|
|
@@ -682,8 +684,6 @@ type CredentialRegistry = {
|
|
|
682
684
|
}[];
|
|
683
685
|
};
|
|
684
686
|
|
|
685
|
-
type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
|
|
686
|
-
|
|
687
687
|
/**
|
|
688
688
|
* A point-in-time copy of everything a service namespace holds.
|
|
689
689
|
*
|
|
@@ -736,6 +736,14 @@ type StateView = {
|
|
|
736
736
|
collections: StateCollectionView[];
|
|
737
737
|
};
|
|
738
738
|
|
|
739
|
+
/**
|
|
740
|
+
* What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
|
|
741
|
+
* which derives the base from the wall clock when the runtime is created.
|
|
742
|
+
*/
|
|
743
|
+
type IdBase = number | string;
|
|
744
|
+
|
|
745
|
+
type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
|
|
746
|
+
|
|
739
747
|
type WebhookEndpoint = {
|
|
740
748
|
/** Stable id; generated when omitted. */
|
|
741
749
|
id?: string;
|
package/dist/server.js
CHANGED
|
@@ -2,10 +2,8 @@ import {
|
|
|
2
2
|
DEFAULT_PORT,
|
|
3
3
|
createServer,
|
|
4
4
|
serveTarget
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-BQ74Q6RF.js";
|
|
8
|
-
import "./chunk-NF2ZJTT3.js";
|
|
5
|
+
} from "./chunk-7LJ2FVWM.js";
|
|
6
|
+
import "./chunk-FQGIQLZR.js";
|
|
9
7
|
export {
|
|
10
8
|
DEFAULT_PORT,
|
|
11
9
|
createServer,
|