@jaypie/testkit 1.1.34 → 1.1.36
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/dist/index.d.ts +2 -10
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/matchers/toBeMockFunction.matcher.d.ts +2 -10
- package/dist/mock/aws.d.ts +5 -7
- package/dist/mock/core.d.ts +21 -13
- package/dist/mock/datadog.d.ts +4 -4
- package/dist/mock/express.d.ts +14 -14
- package/dist/mock/index.d.ts +129 -88
- package/dist/mock/index.js +636 -9
- package/dist/mock/index.js.map +1 -1
- package/dist/mock/kit.d.ts +2 -0
- package/dist/mock/llm.d.ts +4 -43
- package/dist/mock/logger.d.ts +5 -0
- package/dist/mock/matchers/toBeMockFunction.matcher.d.ts +2 -10
- package/dist/mock/mock/aws.d.ts +5 -7
- package/dist/mock/mock/core.d.ts +21 -13
- package/dist/mock/mock/datadog.d.ts +4 -4
- package/dist/mock/mock/express.d.ts +14 -14
- package/dist/mock/mock/index.d.ts +4 -2
- package/dist/mock/mock/kit.d.ts +2 -0
- package/dist/mock/mock/llm.d.ts +4 -43
- package/dist/mock/mock/logger.d.ts +5 -0
- package/dist/mock/mock/mongoose.d.ts +3 -3
- package/dist/mock/mock/original.d.ts +4 -0
- package/dist/mock/mock/textract.d.ts +2 -2
- package/dist/mock/mock/utils.d.ts +6 -5
- package/dist/mock/mongoose.d.ts +3 -3
- package/dist/mock/original.d.ts +4 -0
- package/dist/mock/textract.d.ts +2 -2
- package/dist/mock/utils.d.ts +6 -5
- package/package.json +7 -3
package/dist/mock/index.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
2
|
+
/// <reference types="jest-extended" />
|
|
3
|
+
import * as vitest from 'vitest';
|
|
1
4
|
import * as original from '@jaypie/core';
|
|
2
5
|
export { log } from '@jaypie/core';
|
|
3
6
|
import * as original$1 from '@jaypie/datadog';
|
|
4
|
-
import * as vitest from 'vitest';
|
|
5
7
|
import * as original$2 from '@jaypie/llm';
|
|
6
8
|
import * as original$3 from '@jaypie/textract';
|
|
9
|
+
export { FORMAT, LEVEL, Logger } from '@jaypie/logger';
|
|
7
10
|
export { mongoose } from '@jaypie/mongoose';
|
|
8
11
|
|
|
9
|
-
declare const getMessages: (...args:
|
|
10
|
-
declare const getSecret: (...args:
|
|
11
|
-
declare const sendMessage: (...args:
|
|
12
|
-
MessageId: string;
|
|
13
|
-
}>;
|
|
12
|
+
declare const getMessages: vitest.Mock<(...args: any[]) => any>;
|
|
13
|
+
declare const getSecret: vitest.Mock<(...args: any[]) => any>;
|
|
14
|
+
declare const sendMessage: vitest.Mock<(...args: any[]) => any>;
|
|
14
15
|
declare const getEnvSecret: ((key: string) => Promise<string>) & {
|
|
15
16
|
mock: any;
|
|
16
17
|
};
|
|
17
|
-
declare const getSingletonMessage: (...args:
|
|
18
|
+
declare const getSingletonMessage: vitest.Mock<(...args: any[]) => any>;
|
|
18
19
|
declare const getTextractJob: ((jobId: string) => Promise<any>) & {
|
|
19
20
|
mock: any;
|
|
20
21
|
};
|
|
21
|
-
declare const sendBatchMessages: (...args:
|
|
22
|
+
declare const sendBatchMessages: vitest.Mock<(...args: any[]) => any>;
|
|
22
23
|
declare const sendTextractJob: (({ bucket, key, featureTypes, }: {
|
|
23
24
|
bucket: string;
|
|
24
25
|
key: string;
|
|
@@ -74,17 +75,17 @@ declare const validate: {
|
|
|
74
75
|
};
|
|
75
76
|
};
|
|
76
77
|
|
|
77
|
-
declare const cloneDeep: (...args:
|
|
78
|
-
declare const envBoolean: (...args:
|
|
79
|
-
declare const envsKey: (...args:
|
|
78
|
+
declare const cloneDeep: vitest.Mock<(...args: any[]) => any>;
|
|
79
|
+
declare const envBoolean: vitest.Mock<(...args: any[]) => any>;
|
|
80
|
+
declare const envsKey: vitest.Mock<(...args: any[]) => any>;
|
|
80
81
|
declare const errorFromStatusCode: ((statusCode: number, message?: string) => Error) & {
|
|
81
82
|
mock: any;
|
|
82
83
|
};
|
|
83
|
-
declare const formatError: (...args:
|
|
84
|
-
declare const getHeaderFrom: (...args:
|
|
85
|
-
declare const getObjectKeyCaseInsensitive: (...args:
|
|
86
|
-
declare const isClass: (...args:
|
|
87
|
-
declare const isJaypieError: (...args:
|
|
84
|
+
declare const formatError: vitest.Mock<(...args: any[]) => any>;
|
|
85
|
+
declare const getHeaderFrom: vitest.Mock<(...args: any[]) => any>;
|
|
86
|
+
declare const getObjectKeyCaseInsensitive: vitest.Mock<(...args: any[]) => any>;
|
|
87
|
+
declare const isClass: vitest.Mock<(...args: any[]) => any>;
|
|
88
|
+
declare const isJaypieError: vitest.Mock<(...args: any[]) => any>;
|
|
88
89
|
declare const optional: {
|
|
89
90
|
(value: unknown, type: unknown, options?: Record<string, unknown>): boolean;
|
|
90
91
|
array<T = unknown>(value: unknown): value is T[] | undefined;
|
|
@@ -103,9 +104,9 @@ declare const required: {
|
|
|
103
104
|
positive(value: unknown): value is number;
|
|
104
105
|
string(value: unknown, defaultValue?: string): value is string;
|
|
105
106
|
};
|
|
106
|
-
declare const resolveValue: (...args:
|
|
107
|
-
declare const safeParseFloat: (...args:
|
|
108
|
-
declare const placeholders: (...args:
|
|
107
|
+
declare const resolveValue: vitest.Mock<(...args: any[]) => any>;
|
|
108
|
+
declare const safeParseFloat: vitest.Mock<(...args: any[]) => any>;
|
|
109
|
+
declare const placeholders: vitest.Mock<(...args: any[]) => any>;
|
|
109
110
|
declare const force: {
|
|
110
111
|
(value: unknown, type: unknown, options?: string | {
|
|
111
112
|
key?: string;
|
|
@@ -128,8 +129,8 @@ declare const jaypieHandler: ((handler: Function, options?: {
|
|
|
128
129
|
}) => Function) & {
|
|
129
130
|
mock: any;
|
|
130
131
|
};
|
|
131
|
-
declare const sleep: (...args:
|
|
132
|
-
declare const uuid: (...args:
|
|
132
|
+
declare const sleep: vitest.Mock<(...args: any[]) => any>;
|
|
133
|
+
declare const uuid: vitest.Mock<(...args: any[]) => any>;
|
|
133
134
|
declare const ERROR: {
|
|
134
135
|
MESSAGE: {
|
|
135
136
|
BAD_GATEWAY: "An unexpected error occurred on an upstream resource";
|
|
@@ -294,12 +295,19 @@ declare const JAYPIE: {
|
|
|
294
295
|
CORE: "@jaypie/core";
|
|
295
296
|
ESLINT: "@jaypie/eslint";
|
|
296
297
|
EXPRESS: "@jaypie/express";
|
|
298
|
+
FABRICATOR: "@jaypie/fabricator";
|
|
297
299
|
ERRORS: "@jaypie/errors";
|
|
298
300
|
JAYPIE: "jaypie";
|
|
301
|
+
KIT: "@jaypie/kit";
|
|
299
302
|
LAMBDA: "@jaypie/lambda";
|
|
300
303
|
LLM: "@jaypie/llm";
|
|
304
|
+
LOGGER: "@jaypie/logger";
|
|
305
|
+
MCP: "@jaypie/mcp";
|
|
306
|
+
MOCK: "@jaypie/mock";
|
|
301
307
|
MONGOOSE: "@jaypie/mongoose";
|
|
302
308
|
TESTKIT: "@jaypie/testkit";
|
|
309
|
+
TEXTTRACT: "@jaypie/textract";
|
|
310
|
+
TYPES: "@jaypie/types";
|
|
303
311
|
WEBKIT: "@jaypie/webkit";
|
|
304
312
|
};
|
|
305
313
|
LAYER: {
|
|
@@ -308,6 +316,7 @@ declare const JAYPIE: {
|
|
|
308
316
|
JAYPIE: "jaypie";
|
|
309
317
|
LAMBDA: "lambda";
|
|
310
318
|
MODULE: "module";
|
|
319
|
+
NEXTJS: "nextjs";
|
|
311
320
|
};
|
|
312
321
|
LOGGER: {
|
|
313
322
|
DEFAULT: "default";
|
|
@@ -336,28 +345,28 @@ declare const VALIDATE: {
|
|
|
336
345
|
};
|
|
337
346
|
|
|
338
347
|
declare const DATADOG: original$1.DatadogConstants;
|
|
339
|
-
declare const hasDatadogEnv: (...args:
|
|
340
|
-
declare const submitDistribution: (...args:
|
|
341
|
-
declare const submitMetric: (...args:
|
|
342
|
-
declare const submitMetricSet: (...args:
|
|
348
|
+
declare const hasDatadogEnv: vitest.Mock<(...args: any[]) => any>;
|
|
349
|
+
declare const submitDistribution: vitest.Mock<(...args: any[]) => any>;
|
|
350
|
+
declare const submitMetric: vitest.Mock<(...args: any[]) => any>;
|
|
351
|
+
declare const submitMetricSet: vitest.Mock<(...args: any[]) => any>;
|
|
343
352
|
|
|
344
353
|
declare const EXPRESS: {
|
|
345
|
-
PATH: {
|
|
346
|
-
ANY: "*";
|
|
347
|
-
ID: "/:id";
|
|
348
|
-
ROOT: RegExp;
|
|
354
|
+
readonly PATH: {
|
|
355
|
+
readonly ANY: "*";
|
|
356
|
+
readonly ID: "/:id";
|
|
357
|
+
readonly ROOT: RegExp;
|
|
349
358
|
};
|
|
350
359
|
};
|
|
351
|
-
declare const badRequestRoute: (...args:
|
|
352
|
-
declare const echoRoute: (...args:
|
|
353
|
-
declare const forbiddenRoute: (...args:
|
|
354
|
-
declare const goneRoute: (...args:
|
|
355
|
-
declare const methodNotAllowedRoute: (...args:
|
|
356
|
-
declare const noContentRoute: (...args:
|
|
357
|
-
declare const notFoundRoute: (...args:
|
|
358
|
-
declare const notImplementedRoute: (...args:
|
|
359
|
-
declare const expressHttpCodeHandler: (...args:
|
|
360
|
-
declare const cors: (...args:
|
|
360
|
+
declare const badRequestRoute: vitest.Mock<(...args: any[]) => any>;
|
|
361
|
+
declare const echoRoute: vitest.Mock<(...args: any[]) => any>;
|
|
362
|
+
declare const forbiddenRoute: vitest.Mock<(...args: any[]) => any>;
|
|
363
|
+
declare const goneRoute: vitest.Mock<(...args: any[]) => any>;
|
|
364
|
+
declare const methodNotAllowedRoute: vitest.Mock<(...args: any[]) => any>;
|
|
365
|
+
declare const noContentRoute: vitest.Mock<(...args: any[]) => any>;
|
|
366
|
+
declare const notFoundRoute: vitest.Mock<(...args: any[]) => any>;
|
|
367
|
+
declare const notImplementedRoute: vitest.Mock<(...args: any[]) => any>;
|
|
368
|
+
declare const expressHttpCodeHandler: vitest.Mock<(...args: any[]) => any>;
|
|
369
|
+
declare const cors: vitest.Mock<(...args: any[]) => any>;
|
|
361
370
|
interface ExpressHandlerFunction {
|
|
362
371
|
(req: any, res: any, ...extra: any[]): Promise<any> | any;
|
|
363
372
|
}
|
|
@@ -373,6 +382,9 @@ declare const expressHandler: ((handlerOrProps: ExpressHandlerParameter, propsOr
|
|
|
373
382
|
mock: any;
|
|
374
383
|
};
|
|
375
384
|
|
|
385
|
+
declare const isProductionEnv: vitest.Mock<(...args: any[]) => any>;
|
|
386
|
+
declare const isNodeTestEnv: vitest.Mock<(...args: any[]) => any>;
|
|
387
|
+
|
|
376
388
|
type HandlerFunction = (...args: unknown[]) => unknown;
|
|
377
389
|
type LifecycleFunction = (...args: unknown[]) => unknown | Promise<unknown>;
|
|
378
390
|
interface LambdaOptions {
|
|
@@ -390,60 +402,89 @@ declare const lambdaHandler: ((handler: HandlerFunction, props?: LambdaOptions)
|
|
|
390
402
|
|
|
391
403
|
declare const LLM: typeof original$2.LLM;
|
|
392
404
|
declare const Llm: vitest.Mock<(...args: any[]) => any> & {
|
|
393
|
-
operate: (...args:
|
|
394
|
-
|
|
395
|
-
content: string;
|
|
396
|
-
role: string;
|
|
397
|
-
type: string;
|
|
398
|
-
id?: undefined;
|
|
399
|
-
status?: undefined;
|
|
400
|
-
} | {
|
|
401
|
-
id: string;
|
|
402
|
-
type: string;
|
|
403
|
-
status: string;
|
|
404
|
-
content: string;
|
|
405
|
-
role: string;
|
|
406
|
-
})[];
|
|
407
|
-
model: string;
|
|
408
|
-
output: {
|
|
409
|
-
id: string;
|
|
410
|
-
type: string;
|
|
411
|
-
status: string;
|
|
412
|
-
content: string;
|
|
413
|
-
role: string;
|
|
414
|
-
}[];
|
|
415
|
-
provider: string;
|
|
416
|
-
responses: {
|
|
417
|
-
id: string;
|
|
418
|
-
object: string;
|
|
419
|
-
created_at: number;
|
|
420
|
-
status: string;
|
|
421
|
-
error: null;
|
|
422
|
-
output_text: string;
|
|
423
|
-
}[];
|
|
424
|
-
status: string;
|
|
425
|
-
usage: {
|
|
426
|
-
input: number;
|
|
427
|
-
output: number;
|
|
428
|
-
reasoning: number;
|
|
429
|
-
total: number;
|
|
430
|
-
provider: string;
|
|
431
|
-
model: string;
|
|
432
|
-
}[];
|
|
433
|
-
content: string;
|
|
434
|
-
}>;
|
|
435
|
-
send: (...args: unknown[]) => Promise<string>;
|
|
405
|
+
operate: vitest.Mock<(...args: any[]) => any>;
|
|
406
|
+
send: vitest.Mock<(...args: any[]) => any>;
|
|
436
407
|
};
|
|
437
408
|
declare const Toolkit: typeof original$2.Toolkit;
|
|
438
409
|
declare const JaypieToolkit: typeof original$2.JaypieToolkit;
|
|
439
410
|
declare const LlmMessageRole: typeof original$2.LlmMessageRole;
|
|
440
411
|
declare const LlmMessageType: typeof original$2.LlmMessageType;
|
|
412
|
+
declare const GeminiProvider: typeof original$2.GeminiProvider;
|
|
413
|
+
declare const OpenRouterProvider: typeof original$2.OpenRouterProvider;
|
|
441
414
|
declare const toolkit: original$2.JaypieToolkit;
|
|
442
415
|
declare const tools: Omit<original$2.LlmTool, "call">[];
|
|
443
416
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
417
|
+
interface JsonApiError {
|
|
418
|
+
errors: Array<{
|
|
419
|
+
status: number;
|
|
420
|
+
title: string;
|
|
421
|
+
detail?: string;
|
|
422
|
+
}>;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// Import and re-export all matcher types
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
// Make sure this is exported so it can be used by consumers
|
|
429
|
+
interface CustomMatchers<R = unknown> {
|
|
430
|
+
// Custom Jaypie matchers
|
|
431
|
+
toBeCalledAboveTrace(): R;
|
|
432
|
+
toBeCalledWithInitialParams(...params: unknown[]): R;
|
|
433
|
+
toBeClass(): R;
|
|
434
|
+
toBeJaypieError(): R;
|
|
435
|
+
toBeMockFunction(): R;
|
|
436
|
+
toMatchBase64(): R;
|
|
437
|
+
toMatchJwt(): R;
|
|
438
|
+
toMatchMongoId(): R;
|
|
439
|
+
toMatchSignedCookie(): R;
|
|
440
|
+
toMatchUuid(): R;
|
|
441
|
+
toMatchUuid4(): R;
|
|
442
|
+
toMatchUuid5(): R;
|
|
443
|
+
toThrowBadGatewayError(): R;
|
|
444
|
+
toThrowBadRequestError(): R;
|
|
445
|
+
toThrowConfigurationError(): R;
|
|
446
|
+
toThrowForbiddenError(): R;
|
|
447
|
+
toThrowGatewayTimeoutError(): R;
|
|
448
|
+
toThrowInternalError(): R;
|
|
449
|
+
toThrowJaypieError(expected?: JsonApiError): R;
|
|
450
|
+
toThrowNotFoundError(): R;
|
|
451
|
+
toThrowUnauthorizedError(): R;
|
|
452
|
+
toThrowUnavailableError(): R;
|
|
453
|
+
|
|
454
|
+
// Include jest-extended matchers
|
|
455
|
+
// These are already included via jest-extended reference
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// Export combined interface that includes both custom matchers and jest-extended matchers
|
|
459
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
460
|
+
interface JaypieMatchers<R = unknown> extends CustomMatchers<R> {}
|
|
461
|
+
|
|
462
|
+
declare global {
|
|
463
|
+
namespace Vi {
|
|
464
|
+
interface Assertion<T = unknown> extends JaypieMatchers<T> {
|
|
465
|
+
not: Assertion<T>;
|
|
466
|
+
}
|
|
467
|
+
interface AsymmetricMatchersContaining extends JaypieMatchers {
|
|
468
|
+
not: AsymmetricMatchersContaining;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// This is needed for module augmentation to work properly
|
|
474
|
+
declare module "vitest" {
|
|
475
|
+
interface Assertion<T = unknown> extends JaypieMatchers<T> {
|
|
476
|
+
not: Assertion<T>;
|
|
477
|
+
}
|
|
478
|
+
interface AsymmetricMatchersContaining extends JaypieMatchers {
|
|
479
|
+
not: AsymmetricMatchersContaining;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
declare const createLogger: vitest.Mock<(...args: any[]) => any>;
|
|
484
|
+
|
|
485
|
+
declare const connect: vitest.Mock<(...args: any[]) => any>;
|
|
486
|
+
declare const connectFromSecretEnv: vitest.Mock<(...args: any[]) => any>;
|
|
487
|
+
declare const disconnect: vitest.Mock<(...args: any[]) => any>;
|
|
447
488
|
|
|
448
489
|
/**
|
|
449
490
|
* Mock for MarkdownPage class from @jaypie/textract
|
|
@@ -452,9 +493,9 @@ declare const MarkdownPage: typeof original$3.MarkdownPage;
|
|
|
452
493
|
/**
|
|
453
494
|
* Mock for textractJsonToMarkdown function from @jaypie/textract
|
|
454
495
|
*/
|
|
455
|
-
declare const textractJsonToMarkdown: (...args:
|
|
496
|
+
declare const textractJsonToMarkdown: vitest.Mock<(...args: any[]) => any>;
|
|
456
497
|
|
|
457
|
-
declare const
|
|
498
|
+
declare const mock: Record<string, any>;
|
|
458
499
|
|
|
459
|
-
export { BadGatewayError, BadRequestError, ConfigurationError, DATADOG, ERROR, EXPRESS, ForbiddenError, GatewayTimeoutError, GoneError, HTTP, IllogicalError, InternalError, JAYPIE, JaypieToolkit, LLM, Llm, LlmMessageRole, LlmMessageType, MarkdownPage, MethodNotAllowedError, MultiError, NotFoundError, NotImplementedError, PROJECT, ProjectError, ProjectMultiError, RejectedError, TeapotError, Toolkit, UnauthorizedError, UnavailableError, UnhandledError, UnreachableCodeError, VALIDATE, badRequestRoute, cloneDeep, connect, connectFromSecretEnv, cors,
|
|
500
|
+
export { BadGatewayError, BadRequestError, ConfigurationError, DATADOG, ERROR, EXPRESS, ForbiddenError, GatewayTimeoutError, GeminiProvider, GoneError, HTTP, IllogicalError, InternalError, JAYPIE, JaypieToolkit, LLM, Llm, LlmMessageRole, LlmMessageType, MarkdownPage, MethodNotAllowedError, MultiError, NotFoundError, NotImplementedError, OpenRouterProvider, PROJECT, ProjectError, ProjectMultiError, RejectedError, TeapotError, Toolkit, UnauthorizedError, UnavailableError, UnhandledError, UnreachableCodeError, VALIDATE, badRequestRoute, cloneDeep, connect, connectFromSecretEnv, cors, createLogger, mock as default, disconnect, echoRoute, envBoolean, envsKey, errorFromStatusCode, expressHandler, expressHttpCodeHandler, forbiddenRoute, force, formatError, getEnvSecret, getHeaderFrom, getMessages, getObjectKeyCaseInsensitive, getSecret, getSingletonMessage, getTextractJob, goneRoute, hasDatadogEnv, isClass, isJaypieError, isNodeTestEnv, isProductionEnv, jaypieHandler, lambdaHandler, methodNotAllowedRoute, noContentRoute, notFoundRoute, notImplementedRoute, optional, placeholders, required, resolveValue, safeParseFloat, sendBatchMessages, sendMessage, sendTextractJob, sleep, submitDistribution, submitMetric, submitMetricSet, textractJsonToMarkdown, toolkit, tools, uuid, validate };
|
|
460
501
|
export type { ExpressHandlerFunction, ExpressHandlerOptions, LambdaOptions };
|