@crvouga/mockingbird-service-oauth 1.0.0 → 1.0.2
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 -4
- package/dist/{chunk-PCHI2SDJ.js → chunk-I24F66FL.js} +12 -3
- package/dist/chunk-I24F66FL.js.map +7 -0
- package/dist/{chunk-QQXXWRJ3.js → chunk-X5QMVVR5.js} +5 -3
- package/dist/{chunk-QQXXWRJ3.js.map → chunk-X5QMVVR5.js.map} +2 -2
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +117 -89
- package/dist/index.js +1 -1
- package/dist/server.d.ts +221 -165
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-PCHI2SDJ.js.map +0 -7
package/dist/server.d.ts
CHANGED
|
@@ -169,82 +169,6 @@ type FaultRegistry$1 = {
|
|
|
169
169
|
take(candidate: FaultCandidate$1): Promise<FaultHit$1[]>;
|
|
170
170
|
};
|
|
171
171
|
|
|
172
|
-
/** One handled request, as the structured log sees it. */
|
|
173
|
-
type RequestLog$1 = {
|
|
174
|
-
service: string;
|
|
175
|
-
namespace: string;
|
|
176
|
-
operationId: string | undefined;
|
|
177
|
-
method: string;
|
|
178
|
-
path: string;
|
|
179
|
-
status: number;
|
|
180
|
-
durationMs: number;
|
|
181
|
-
/** True when the path matched no operation in the contract. */
|
|
182
|
-
unmatched: boolean;
|
|
183
|
-
/** Set when a fault rule produced the response. */
|
|
184
|
-
faultId?: string;
|
|
185
|
-
/** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
|
|
186
|
-
ids?: Record<string, string>;
|
|
187
|
-
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
188
|
-
adopted?: boolean;
|
|
189
|
-
};
|
|
190
|
-
type MetricsReport$1 = {
|
|
191
|
-
requests: number;
|
|
192
|
-
/** Counts keyed `<operationId> <status>`. */
|
|
193
|
-
byOperation: Record<string, number>;
|
|
194
|
-
/**
|
|
195
|
-
* Paths that matched no operation, most frequent first.
|
|
196
|
-
*
|
|
197
|
-
* This is the early-warning signal: a consumer calling something the mock does
|
|
198
|
-
* not implement shows up here as a count, before it fails a suite as a 404.
|
|
199
|
-
*/
|
|
200
|
-
unmatched: {
|
|
201
|
-
method: string;
|
|
202
|
-
path: string;
|
|
203
|
-
count: number;
|
|
204
|
-
}[];
|
|
205
|
-
faults: number;
|
|
206
|
-
totalDurationMs: number;
|
|
207
|
-
};
|
|
208
|
-
type Metrics$1 = {
|
|
209
|
-
record(entry: RequestLog$1): void;
|
|
210
|
-
report(): MetricsReport$1;
|
|
211
|
-
reset(): void;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
/** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
|
|
215
|
-
type JournalEntry$1 = RequestLog$1 & {
|
|
216
|
-
at: string;
|
|
217
|
-
};
|
|
218
|
-
type JournalQuery$1 = {
|
|
219
|
-
/** Only this namespace. Omit for every namespace, oldest first across all of them. */
|
|
220
|
-
namespace?: string;
|
|
221
|
-
operationId?: string;
|
|
222
|
-
status?: number;
|
|
223
|
-
/** Only entries at or after this instant (epoch ms). */
|
|
224
|
-
since?: number;
|
|
225
|
-
/** At most this many, the most recent kept. */
|
|
226
|
-
limit?: number;
|
|
227
|
-
};
|
|
228
|
-
type Journal$1 = {
|
|
229
|
-
readonly size: number;
|
|
230
|
-
record(entry: JournalEntry$1): void;
|
|
231
|
-
list(query?: JournalQuery$1): JournalEntry$1[];
|
|
232
|
-
/** Forget one namespace's entries, or every namespace's. */
|
|
233
|
-
clear(namespace?: string): void;
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
/** Credential → namespace mapping behind `PUT /__admin/credentials`. */
|
|
237
|
-
type CredentialRegistry$1 = {
|
|
238
|
-
set(credential: string, namespace: string): void;
|
|
239
|
-
get(credential: string): string | undefined;
|
|
240
|
-
remove(credential: string): boolean;
|
|
241
|
-
clear(): void;
|
|
242
|
-
entries(): {
|
|
243
|
-
credential: string;
|
|
244
|
-
namespace: string;
|
|
245
|
-
}[];
|
|
246
|
-
};
|
|
247
|
-
|
|
248
172
|
/** A stable identifier for a point in a {@link Timeline}. */
|
|
249
173
|
type CheckpointId$1 = string;
|
|
250
174
|
/** An immutable node in a timeline's checkpoint DAG. */
|
|
@@ -335,6 +259,110 @@ interface FetchAPI$1 {
|
|
|
335
259
|
fetch(request: Request): Promise<Response>;
|
|
336
260
|
}
|
|
337
261
|
|
|
262
|
+
/**
|
|
263
|
+
* One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
|
|
264
|
+
* `kind` is `media_type` when the body is present but its media type is not one the operation
|
|
265
|
+
* accepts (a `415` on most vendors), `syntax` when it could not be decoded, `required` when
|
|
266
|
+
* the operation needs a body and none arrived, and `schema` for a contract violation.
|
|
267
|
+
*/
|
|
268
|
+
type BodyIssue$1 = {
|
|
269
|
+
path: string;
|
|
270
|
+
message: string;
|
|
271
|
+
kind?: "media_type" | "syntax" | "required" | "schema";
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* What the mock received from a request it rejected, so a 4xx can be attributed after the
|
|
276
|
+
* fact (an empty body, a missing `content-type`, a schema violation) without logging the body.
|
|
277
|
+
*/
|
|
278
|
+
type RejectedRequest$1 = {
|
|
279
|
+
/** The raw `content-type` header, or `null` when the request sent none. */
|
|
280
|
+
contentType: string | null;
|
|
281
|
+
/** Bytes of body received from `content-length` (`0` for none), or `null` when the client sent no length (a streamed / chunked body). */
|
|
282
|
+
bodyBytes: number | null;
|
|
283
|
+
/** The raw `transfer-encoding` header (`chunked`), or `null`. */
|
|
284
|
+
transferEncoding: string | null;
|
|
285
|
+
};
|
|
286
|
+
/** One handled request, as the structured log sees it. */
|
|
287
|
+
type RequestLog$1 = {
|
|
288
|
+
service: string;
|
|
289
|
+
namespace: string;
|
|
290
|
+
operationId: string | undefined;
|
|
291
|
+
method: string;
|
|
292
|
+
path: string;
|
|
293
|
+
status: number;
|
|
294
|
+
durationMs: number;
|
|
295
|
+
/** True when the path matched no operation in the contract. */
|
|
296
|
+
unmatched: boolean;
|
|
297
|
+
/** Set when a fault rule produced the response. */
|
|
298
|
+
faultId?: string;
|
|
299
|
+
/** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
|
|
300
|
+
ids?: Record<string, string>;
|
|
301
|
+
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
302
|
+
adopted?: boolean;
|
|
303
|
+
/** Set on a rejection (status ≥ 400) the mock produced itself, never on a scripted fault. */
|
|
304
|
+
request?: RejectedRequest$1;
|
|
305
|
+
/** The validation issues behind a rejection, when the service found any. */
|
|
306
|
+
issues?: BodyIssue$1[];
|
|
307
|
+
};
|
|
308
|
+
type MetricsReport$1 = {
|
|
309
|
+
requests: number;
|
|
310
|
+
/** Counts keyed `<operationId> <status>`. */
|
|
311
|
+
byOperation: Record<string, number>;
|
|
312
|
+
/**
|
|
313
|
+
* Paths that matched no operation, most frequent first.
|
|
314
|
+
*
|
|
315
|
+
* This is the early-warning signal: a consumer calling something the mock does
|
|
316
|
+
* not implement shows up here as a count, before it fails a suite as a 404.
|
|
317
|
+
*/
|
|
318
|
+
unmatched: {
|
|
319
|
+
method: string;
|
|
320
|
+
path: string;
|
|
321
|
+
count: number;
|
|
322
|
+
}[];
|
|
323
|
+
faults: number;
|
|
324
|
+
totalDurationMs: number;
|
|
325
|
+
};
|
|
326
|
+
type Metrics$1 = {
|
|
327
|
+
record(entry: RequestLog$1): void;
|
|
328
|
+
report(): MetricsReport$1;
|
|
329
|
+
reset(): void;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
/** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
|
|
333
|
+
type JournalEntry$1 = RequestLog$1 & {
|
|
334
|
+
at: string;
|
|
335
|
+
};
|
|
336
|
+
type JournalQuery$1 = {
|
|
337
|
+
/** Only this namespace. Omit for every namespace, oldest first across all of them. */
|
|
338
|
+
namespace?: string;
|
|
339
|
+
operationId?: string;
|
|
340
|
+
status?: number;
|
|
341
|
+
/** Only entries at or after this instant (epoch ms). */
|
|
342
|
+
since?: number;
|
|
343
|
+
/** At most this many, the most recent kept. */
|
|
344
|
+
limit?: number;
|
|
345
|
+
};
|
|
346
|
+
type Journal$1 = {
|
|
347
|
+
readonly size: number;
|
|
348
|
+
record(entry: JournalEntry$1): void;
|
|
349
|
+
list(query?: JournalQuery$1): JournalEntry$1[];
|
|
350
|
+
/** Forget one namespace's entries, or every namespace's. */
|
|
351
|
+
clear(namespace?: string): void;
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
/** Credential → namespace mapping behind `PUT /__admin/credentials`. */
|
|
355
|
+
type CredentialRegistry$1 = {
|
|
356
|
+
set(credential: string, namespace: string): void;
|
|
357
|
+
get(credential: string): string | undefined;
|
|
358
|
+
remove(credential: string): boolean;
|
|
359
|
+
clear(): void;
|
|
360
|
+
entries(): {
|
|
361
|
+
credential: string;
|
|
362
|
+
namespace: string;
|
|
363
|
+
}[];
|
|
364
|
+
};
|
|
365
|
+
|
|
338
366
|
/**
|
|
339
367
|
* A point-in-time copy of everything a service namespace holds.
|
|
340
368
|
*
|
|
@@ -727,82 +755,6 @@ type FaultRegistry = {
|
|
|
727
755
|
take(candidate: FaultCandidate): Promise<FaultHit[]>;
|
|
728
756
|
};
|
|
729
757
|
|
|
730
|
-
/** One handled request, as the structured log sees it. */
|
|
731
|
-
type RequestLog = {
|
|
732
|
-
service: string;
|
|
733
|
-
namespace: string;
|
|
734
|
-
operationId: string | undefined;
|
|
735
|
-
method: string;
|
|
736
|
-
path: string;
|
|
737
|
-
status: number;
|
|
738
|
-
durationMs: number;
|
|
739
|
-
/** True when the path matched no operation in the contract. */
|
|
740
|
-
unmatched: boolean;
|
|
741
|
-
/** Set when a fault rule produced the response. */
|
|
742
|
-
faultId?: string;
|
|
743
|
-
/** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
|
|
744
|
-
ids?: Record<string, string>;
|
|
745
|
-
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
746
|
-
adopted?: boolean;
|
|
747
|
-
};
|
|
748
|
-
type MetricsReport = {
|
|
749
|
-
requests: number;
|
|
750
|
-
/** Counts keyed `<operationId> <status>`. */
|
|
751
|
-
byOperation: Record<string, number>;
|
|
752
|
-
/**
|
|
753
|
-
* Paths that matched no operation, most frequent first.
|
|
754
|
-
*
|
|
755
|
-
* This is the early-warning signal: a consumer calling something the mock does
|
|
756
|
-
* not implement shows up here as a count, before it fails a suite as a 404.
|
|
757
|
-
*/
|
|
758
|
-
unmatched: {
|
|
759
|
-
method: string;
|
|
760
|
-
path: string;
|
|
761
|
-
count: number;
|
|
762
|
-
}[];
|
|
763
|
-
faults: number;
|
|
764
|
-
totalDurationMs: number;
|
|
765
|
-
};
|
|
766
|
-
type Metrics = {
|
|
767
|
-
record(entry: RequestLog): void;
|
|
768
|
-
report(): MetricsReport;
|
|
769
|
-
reset(): void;
|
|
770
|
-
};
|
|
771
|
-
|
|
772
|
-
/** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
|
|
773
|
-
type JournalEntry = RequestLog & {
|
|
774
|
-
at: string;
|
|
775
|
-
};
|
|
776
|
-
type JournalQuery = {
|
|
777
|
-
/** Only this namespace. Omit for every namespace, oldest first across all of them. */
|
|
778
|
-
namespace?: string;
|
|
779
|
-
operationId?: string;
|
|
780
|
-
status?: number;
|
|
781
|
-
/** Only entries at or after this instant (epoch ms). */
|
|
782
|
-
since?: number;
|
|
783
|
-
/** At most this many, the most recent kept. */
|
|
784
|
-
limit?: number;
|
|
785
|
-
};
|
|
786
|
-
type Journal = {
|
|
787
|
-
readonly size: number;
|
|
788
|
-
record(entry: JournalEntry): void;
|
|
789
|
-
list(query?: JournalQuery): JournalEntry[];
|
|
790
|
-
/** Forget one namespace's entries, or every namespace's. */
|
|
791
|
-
clear(namespace?: string): void;
|
|
792
|
-
};
|
|
793
|
-
|
|
794
|
-
/** Credential → namespace mapping behind `PUT /__admin/credentials`. */
|
|
795
|
-
type CredentialRegistry = {
|
|
796
|
-
set(credential: string, namespace: string): void;
|
|
797
|
-
get(credential: string): string | undefined;
|
|
798
|
-
remove(credential: string): boolean;
|
|
799
|
-
clear(): void;
|
|
800
|
-
entries(): {
|
|
801
|
-
credential: string;
|
|
802
|
-
namespace: string;
|
|
803
|
-
}[];
|
|
804
|
-
};
|
|
805
|
-
|
|
806
758
|
/** A stable identifier for a point in a {@link Timeline}. */
|
|
807
759
|
type CheckpointId = string;
|
|
808
760
|
/** An immutable node in a timeline's checkpoint DAG. */
|
|
@@ -893,6 +845,123 @@ interface FetchAPI {
|
|
|
893
845
|
fetch(request: Request): Promise<Response>;
|
|
894
846
|
}
|
|
895
847
|
|
|
848
|
+
/** Options every provider constructor accepts. */
|
|
849
|
+
type APIOptions = {
|
|
850
|
+
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
851
|
+
sqlite?: SqliteClient$1;
|
|
852
|
+
/** Clock used for `created`-style fields. Default `Date.now`. */
|
|
853
|
+
now?: () => number;
|
|
854
|
+
/**
|
|
855
|
+
* Storage namespace for this instance's records. Instances sharing one SQLite
|
|
856
|
+
* client stay isolated when their namespaces differ. Defaults to the service name.
|
|
857
|
+
*/
|
|
858
|
+
namespace?: string;
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
|
|
863
|
+
* `kind` is `media_type` when the body is present but its media type is not one the operation
|
|
864
|
+
* accepts (a `415` on most vendors), `syntax` when it could not be decoded, `required` when
|
|
865
|
+
* the operation needs a body and none arrived, and `schema` for a contract violation.
|
|
866
|
+
*/
|
|
867
|
+
type BodyIssue = {
|
|
868
|
+
path: string;
|
|
869
|
+
message: string;
|
|
870
|
+
kind?: "media_type" | "syntax" | "required" | "schema";
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* What the mock received from a request it rejected, so a 4xx can be attributed after the
|
|
875
|
+
* fact (an empty body, a missing `content-type`, a schema violation) without logging the body.
|
|
876
|
+
*/
|
|
877
|
+
type RejectedRequest = {
|
|
878
|
+
/** The raw `content-type` header, or `null` when the request sent none. */
|
|
879
|
+
contentType: string | null;
|
|
880
|
+
/** Bytes of body received from `content-length` (`0` for none), or `null` when the client sent no length (a streamed / chunked body). */
|
|
881
|
+
bodyBytes: number | null;
|
|
882
|
+
/** The raw `transfer-encoding` header (`chunked`), or `null`. */
|
|
883
|
+
transferEncoding: string | null;
|
|
884
|
+
};
|
|
885
|
+
/** One handled request, as the structured log sees it. */
|
|
886
|
+
type RequestLog = {
|
|
887
|
+
service: string;
|
|
888
|
+
namespace: string;
|
|
889
|
+
operationId: string | undefined;
|
|
890
|
+
method: string;
|
|
891
|
+
path: string;
|
|
892
|
+
status: number;
|
|
893
|
+
durationMs: number;
|
|
894
|
+
/** True when the path matched no operation in the contract. */
|
|
895
|
+
unmatched: boolean;
|
|
896
|
+
/** Set when a fault rule produced the response. */
|
|
897
|
+
faultId?: string;
|
|
898
|
+
/** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
|
|
899
|
+
ids?: Record<string, string>;
|
|
900
|
+
/** Set when the service created a resource the request referred to but that did not exist. */
|
|
901
|
+
adopted?: boolean;
|
|
902
|
+
/** Set on a rejection (status ≥ 400) the mock produced itself, never on a scripted fault. */
|
|
903
|
+
request?: RejectedRequest;
|
|
904
|
+
/** The validation issues behind a rejection, when the service found any. */
|
|
905
|
+
issues?: BodyIssue[];
|
|
906
|
+
};
|
|
907
|
+
type MetricsReport = {
|
|
908
|
+
requests: number;
|
|
909
|
+
/** Counts keyed `<operationId> <status>`. */
|
|
910
|
+
byOperation: Record<string, number>;
|
|
911
|
+
/**
|
|
912
|
+
* Paths that matched no operation, most frequent first.
|
|
913
|
+
*
|
|
914
|
+
* This is the early-warning signal: a consumer calling something the mock does
|
|
915
|
+
* not implement shows up here as a count, before it fails a suite as a 404.
|
|
916
|
+
*/
|
|
917
|
+
unmatched: {
|
|
918
|
+
method: string;
|
|
919
|
+
path: string;
|
|
920
|
+
count: number;
|
|
921
|
+
}[];
|
|
922
|
+
faults: number;
|
|
923
|
+
totalDurationMs: number;
|
|
924
|
+
};
|
|
925
|
+
type Metrics = {
|
|
926
|
+
record(entry: RequestLog): void;
|
|
927
|
+
report(): MetricsReport;
|
|
928
|
+
reset(): void;
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
/** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
|
|
932
|
+
type JournalEntry = RequestLog & {
|
|
933
|
+
at: string;
|
|
934
|
+
};
|
|
935
|
+
type JournalQuery = {
|
|
936
|
+
/** Only this namespace. Omit for every namespace, oldest first across all of them. */
|
|
937
|
+
namespace?: string;
|
|
938
|
+
operationId?: string;
|
|
939
|
+
status?: number;
|
|
940
|
+
/** Only entries at or after this instant (epoch ms). */
|
|
941
|
+
since?: number;
|
|
942
|
+
/** At most this many, the most recent kept. */
|
|
943
|
+
limit?: number;
|
|
944
|
+
};
|
|
945
|
+
type Journal = {
|
|
946
|
+
readonly size: number;
|
|
947
|
+
record(entry: JournalEntry): void;
|
|
948
|
+
list(query?: JournalQuery): JournalEntry[];
|
|
949
|
+
/** Forget one namespace's entries, or every namespace's. */
|
|
950
|
+
clear(namespace?: string): void;
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
/** Credential → namespace mapping behind `PUT /__admin/credentials`. */
|
|
954
|
+
type CredentialRegistry = {
|
|
955
|
+
set(credential: string, namespace: string): void;
|
|
956
|
+
get(credential: string): string | undefined;
|
|
957
|
+
remove(credential: string): boolean;
|
|
958
|
+
clear(): void;
|
|
959
|
+
entries(): {
|
|
960
|
+
credential: string;
|
|
961
|
+
namespace: string;
|
|
962
|
+
}[];
|
|
963
|
+
};
|
|
964
|
+
|
|
896
965
|
/**
|
|
897
966
|
* A point-in-time copy of everything a service namespace holds.
|
|
898
967
|
*
|
|
@@ -1043,19 +1112,6 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
|
|
|
1043
1112
|
timeline(namespace?: string): Timeline<ServiceTimelineState>;
|
|
1044
1113
|
};
|
|
1045
1114
|
|
|
1046
|
-
/** Options every provider constructor accepts. */
|
|
1047
|
-
type APIOptions = {
|
|
1048
|
-
/** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
|
|
1049
|
-
sqlite?: SqliteClient$1;
|
|
1050
|
-
/** Clock used for `created`-style fields. Default `Date.now`. */
|
|
1051
|
-
now?: () => number;
|
|
1052
|
-
/**
|
|
1053
|
-
* Storage namespace for this instance's records. Instances sharing one SQLite
|
|
1054
|
-
* client stay isolated when their namespaces differ. Defaults to the service name.
|
|
1055
|
-
*/
|
|
1056
|
-
namespace?: string;
|
|
1057
|
-
};
|
|
1058
|
-
|
|
1059
1115
|
/** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
|
|
1060
1116
|
type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
|
|
1061
1117
|
/** Mutation counters returned by {@link SqliteStatement.run}. */
|
package/dist/server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/mockingbird-service-oauth",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Portable social-login mock with Google, Apple, Microsoft, GitHub and generic OIDC profiles, private relay identities, reproducible edge cases, signed tokens and an accessible UI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|