@contractspec/lib.testing 1.46.2 → 1.48.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/dist/contracts/src/docs/index.d.ts +1 -1
- package/dist/contracts/src/examples/registry.d.ts +1 -1
- package/dist/contracts/src/integrations/openbanking/openbanking.feature.d.ts +1 -1
- package/dist/contracts/src/integrations/providers/elevenlabs.d.ts +2 -1
- package/dist/contracts/src/integrations/providers/gcs-storage.d.ts +2 -1
- package/dist/contracts/src/integrations/providers/gmail.d.ts +2 -1
- package/dist/contracts/src/integrations/providers/google-calendar.d.ts +2 -1
- package/dist/contracts/src/integrations/providers/mistral.d.ts +2 -1
- package/dist/contracts/src/integrations/providers/postmark.d.ts +2 -1
- package/dist/contracts/src/integrations/providers/powens.d.ts +2 -1
- package/dist/contracts/src/integrations/providers/qdrant.d.ts +2 -1
- package/dist/contracts/src/integrations/providers/stripe.d.ts +2 -1
- package/dist/contracts/src/integrations/providers/twilio-sms.d.ts +2 -1
- package/dist/generator/golden-test-generator.js.map +1 -1
- package/dist/recorder/traffic-recorder.js.map +1 -1
- package/dist/schema/src/FieldType.d.ts.map +1 -1
- package/package.json +7 -9
- /package/dist/contracts/src/docs/tech/{templates/runtime.docblock.d.ts → contracts/README.docblock.d.ts} +0 -0
|
@@ -5,11 +5,11 @@ import "./tech/lifecycle-stage-system.docblock.js";
|
|
|
5
5
|
import "./tech/presentation-runtime.docblock.js";
|
|
6
6
|
import "./tech/auth/better-auth-nextjs.docblock.js";
|
|
7
7
|
import "./tech/schema/README.docblock.js";
|
|
8
|
-
import "./tech/templates/runtime.docblock.js";
|
|
9
8
|
import "../workflow/overview.docblock.js";
|
|
10
9
|
import "./tech/mcp-endpoints.docblock.js";
|
|
11
10
|
import "./tech/vscode-extension.docblock.js";
|
|
12
11
|
import "./tech/telemetry-ingest.docblock.js";
|
|
12
|
+
import "./tech/contracts/README.docblock.js";
|
|
13
13
|
import "./tech/contracts/openapi-export.docblock.js";
|
|
14
14
|
import "./tech/contracts/openapi-import.docblock.js";
|
|
15
15
|
import "../workspace-config/workspace-config.docblock.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "../registry
|
|
1
|
+
import "../registry.js";
|
|
2
2
|
import "./types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import "../../
|
|
1
|
+
import "../../index.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import "../spec.js";
|
|
1
|
+
import "../spec.js";
|
|
2
|
+
import "../index.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import "../spec.js";
|
|
1
|
+
import "../spec.js";
|
|
2
|
+
import "../index.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import "../spec.js";
|
|
1
|
+
import "../spec.js";
|
|
2
|
+
import "../index.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import "../spec.js";
|
|
1
|
+
import "../spec.js";
|
|
2
|
+
import "../index.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import "../spec.js";
|
|
1
|
+
import "../spec.js";
|
|
2
|
+
import "../index.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import "../spec.js";
|
|
1
|
+
import "../spec.js";
|
|
2
|
+
import "../index.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import "../spec.js";
|
|
1
|
+
import "../spec.js";
|
|
2
|
+
import "../index.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import "../spec.js";
|
|
1
|
+
import "../spec.js";
|
|
2
|
+
import "../index.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import "../spec.js";
|
|
1
|
+
import "../spec.js";
|
|
2
|
+
import "../index.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import "../spec.js";
|
|
1
|
+
import "../spec.js";
|
|
2
|
+
import "../index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"golden-test-generator.js","names":[
|
|
1
|
+
{"version":3,"file":"golden-test-generator.js","names":[],"sources":["../../src/generator/golden-test-generator.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { performance } from 'node:perf_hooks';\nimport type { GoldenTestCase, TrafficSnapshot } from '../types';\nimport { generateVitestSuite } from '../adapters/vitest-adapter';\nimport { generateJestSuite } from '../adapters/jest-adapter';\n\nexport interface GoldenTestGeneratorOptions {\n suiteName: string;\n runnerImport: string;\n runnerFunction: string;\n framework?: 'vitest' | 'jest';\n serializeMetadata?: (snapshot: TrafficSnapshot) => Record<string, unknown>;\n}\n\nexport class GoldenTestGenerator {\n constructor(\n private readonly serializeMetadata: GoldenTestGeneratorOptions['serializeMetadata'] = (\n snapshot\n ) =>\n ({\n tenantId: snapshot.tenantId,\n userId: snapshot.userId,\n channel: snapshot.channel,\n }) as Record<string, unknown>\n ) {}\n\n createCases(snapshots: TrafficSnapshot[]): GoldenTestCase[] {\n return snapshots.map((snapshot, index) => ({\n id: snapshot.id ?? randomUUID(),\n name: snapshot.success\n ? `case-${index + 1}-success`\n : `case-${index + 1}-failure`,\n input: snapshot.input,\n expectedOutput: snapshot.output,\n expectedError: snapshot.error,\n success: snapshot.success,\n metadata: this.serializeMetadata?.(snapshot),\n }));\n }\n\n generate(\n snapshots: TrafficSnapshot[],\n options: GoldenTestGeneratorOptions\n ): string {\n const cases = this.createCases(snapshots);\n if (options.framework === 'jest') {\n return generateJestSuite({\n suiteName: options.suiteName,\n cases,\n runnerImport: options.runnerImport,\n runnerFunction: options.runnerFunction,\n });\n }\n return generateVitestSuite({\n suiteName: options.suiteName,\n cases,\n runnerImport: options.runnerImport,\n runnerFunction: options.runnerFunction,\n });\n }\n}\n\nexport type GoldenTestRunner = (\n input: unknown,\n metadata?: Record<string, unknown>\n) => Promise<unknown>;\n\nexport interface GoldenTestRunResult {\n caseId: string;\n passed: boolean;\n durationMs: number;\n error?: unknown;\n}\n\nexport async function runGoldenTests(\n cases: GoldenTestCase[],\n runner: GoldenTestRunner\n): Promise<GoldenTestRunResult[]> {\n const results: GoldenTestRunResult[] = [];\n for (const testCase of cases) {\n const startedAt = performance.now();\n try {\n const output = await runner(testCase.input, testCase.metadata);\n if (!testCase.success) {\n results.push({\n caseId: testCase.id,\n passed: false,\n durationMs: performance.now() - startedAt,\n error: new Error('Expected failure but runner resolved'),\n });\n continue;\n }\n const matches =\n JSON.stringify(output) ===\n JSON.stringify(testCase.expectedOutput ?? null);\n results.push({\n caseId: testCase.id,\n passed: matches,\n durationMs: performance.now() - startedAt,\n error: matches\n ? undefined\n : { expected: testCase.expectedOutput, received: output },\n });\n } catch (error) {\n const durationMs = performance.now() - startedAt;\n if (!testCase.success) {\n results.push({ caseId: testCase.id, passed: true, durationMs });\n } else {\n results.push({ caseId: testCase.id, passed: false, durationMs, error });\n }\n }\n }\n return results;\n}\n"],"mappings":";;;;;;AAcA,IAAa,sBAAb,MAAiC;CAC/B,YACE,AAAiB,qBACf,cAEC;EACC,UAAU,SAAS;EACnB,QAAQ,SAAS;EACjB,SAAS,SAAS;EACnB,GACH;EARiB;;CAUnB,YAAY,WAAgD;AAC1D,SAAO,UAAU,KAAK,UAAU,WAAW;GACzC,IAAI,SAAS,MAAM,YAAY;GAC/B,MAAM,SAAS,UACX,QAAQ,QAAQ,EAAE,YAClB,QAAQ,QAAQ,EAAE;GACtB,OAAO,SAAS;GAChB,gBAAgB,SAAS;GACzB,eAAe,SAAS;GACxB,SAAS,SAAS;GAClB,UAAU,KAAK,oBAAoB,SAAS;GAC7C,EAAE;;CAGL,SACE,WACA,SACQ;EACR,MAAM,QAAQ,KAAK,YAAY,UAAU;AACzC,MAAI,QAAQ,cAAc,OACxB,QAAO,kBAAkB;GACvB,WAAW,QAAQ;GACnB;GACA,cAAc,QAAQ;GACtB,gBAAgB,QAAQ;GACzB,CAAC;AAEJ,SAAO,oBAAoB;GACzB,WAAW,QAAQ;GACnB;GACA,cAAc,QAAQ;GACtB,gBAAgB,QAAQ;GACzB,CAAC;;;AAgBN,eAAsB,eACpB,OACA,QACgC;CAChC,MAAM,UAAiC,EAAE;AACzC,MAAK,MAAM,YAAY,OAAO;EAC5B,MAAM,YAAY,YAAY,KAAK;AACnC,MAAI;GACF,MAAM,SAAS,MAAM,OAAO,SAAS,OAAO,SAAS,SAAS;AAC9D,OAAI,CAAC,SAAS,SAAS;AACrB,YAAQ,KAAK;KACX,QAAQ,SAAS;KACjB,QAAQ;KACR,YAAY,YAAY,KAAK,GAAG;KAChC,uBAAO,IAAI,MAAM,uCAAuC;KACzD,CAAC;AACF;;GAEF,MAAM,UACJ,KAAK,UAAU,OAAO,KACtB,KAAK,UAAU,SAAS,kBAAkB,KAAK;AACjD,WAAQ,KAAK;IACX,QAAQ,SAAS;IACjB,QAAQ;IACR,YAAY,YAAY,KAAK,GAAG;IAChC,OAAO,UACH,SACA;KAAE,UAAU,SAAS;KAAgB,UAAU;KAAQ;IAC5D,CAAC;WACK,OAAO;GACd,MAAM,aAAa,YAAY,KAAK,GAAG;AACvC,OAAI,CAAC,SAAS,QACZ,SAAQ,KAAK;IAAE,QAAQ,SAAS;IAAI,QAAQ;IAAM;IAAY,CAAC;OAE/D,SAAQ,KAAK;IAAE,QAAQ,SAAS;IAAI,QAAQ;IAAO;IAAY;IAAO,CAAC;;;AAI7E,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traffic-recorder.js","names":[
|
|
1
|
+
{"version":3,"file":"traffic-recorder.js","names":[],"sources":["../../src/recorder/traffic-recorder.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport type { TrafficSnapshot } from '../types';\n\nexport interface TrafficStore {\n save(snapshot: TrafficSnapshot): Promise<void>;\n list(\n operation?: TrafficSnapshot['operation']['name']\n ): Promise<TrafficSnapshot[]>;\n}\n\nexport class InMemoryTrafficStore implements TrafficStore {\n private readonly items: TrafficSnapshot[] = [];\n\n async save(snapshot: TrafficSnapshot): Promise<void> {\n this.items.push(snapshot);\n }\n\n async list(operation?: string): Promise<TrafficSnapshot[]> {\n if (!operation) return [...this.items];\n return this.items.filter((item) => item.operation.name === operation);\n }\n}\n\nexport interface TrafficRecorderOptions {\n store: TrafficStore;\n sampleRate?: number;\n sanitize?: (snapshot: TrafficSnapshot) => TrafficSnapshot;\n}\n\nexport interface RecordOperationInput {\n operation: TrafficSnapshot['operation'];\n input: unknown;\n output?: unknown;\n error?: TrafficSnapshot['error'];\n success: boolean;\n durationMs?: number;\n tenantId?: string;\n userId?: string;\n channel?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport class TrafficRecorder {\n private readonly store: TrafficStore;\n private readonly sampleRate: number;\n private readonly sanitize?: (snapshot: TrafficSnapshot) => TrafficSnapshot;\n\n constructor(options: TrafficRecorderOptions) {\n this.store = options.store;\n this.sampleRate = options.sampleRate ?? 1;\n this.sanitize = options.sanitize;\n }\n\n async record(input: RecordOperationInput) {\n if (!this.shouldSample()) return;\n const snapshot: TrafficSnapshot = {\n id: randomUUID(),\n operation: input.operation,\n input: structuredCloneSafe(input.input),\n output: structuredCloneSafe(input.output),\n error: input.error ? structuredCloneSafe(input.error) : undefined,\n success: input.success,\n timestamp: new Date(),\n durationMs: input.durationMs,\n tenantId: input.tenantId,\n userId: input.userId,\n channel: input.channel,\n metadata: input.metadata,\n };\n const sanitized = this.sanitize ? this.sanitize(snapshot) : snapshot;\n await this.store.save(sanitized);\n }\n\n private shouldSample() {\n if (this.sampleRate >= 1) return true;\n return Math.random() <= this.sampleRate;\n }\n}\n\nfunction structuredCloneSafe<T>(value: T): T | undefined {\n if (value == null) return value ?? undefined;\n try {\n const clone = (globalThis as { structuredClone?: <R>(input: R) => R })\n .structuredClone;\n if (typeof clone === 'function') {\n return clone(value);\n }\n return JSON.parse(JSON.stringify(value));\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;AAUA,IAAa,uBAAb,MAA0D;CACxD,AAAiB,QAA2B,EAAE;CAE9C,MAAM,KAAK,UAA0C;AACnD,OAAK,MAAM,KAAK,SAAS;;CAG3B,MAAM,KAA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A,CAAE,QAAQ;EAJA,UAAA,EAAA,OAAe,GAAA,CAAA,GAAA,GAAA,OAAA,CAAA;;AAGE,KAMtB,YAAA,GAAe,SANO,CAAA,GAAA,EAAA,GAAA,CAAA;;;;;;AAMtB,cAOC,SAPW,
|
|
1
|
+
{"version":3,"file":"FieldType.d.ts","names":[],"sources":["../../../../schema/src/FieldType.ts"],"sourcesContent":[],"mappings":";;;;UAGiB,uCAEH,mBACJ,wBAAwB,WAAW;OACtC,CAAA,CAAE,QAAQ;EAJA,UAAA,EAAA,OAAe,GAAA,CAAA,GAAA,GAAA,OAAA,CAAA;;AAGE,KAMtB,YAAA,GAAe,SANO,CAAA,GAAA,EAAA,GAAA,CAAA;;;;;;AAMtB,cAOC,SAPW,CAAA,SAAG,EAAS,YAStB,SATsB,CAAA,SAU1B,iBAV0B,CAUR,SAVQ,EAUG,SAVH,CAAA,CAAA;EAOvB,QAAA,SAAS;EAER,iBAAA,aAAA;EACc,WAAA,CAAA,MAAA,EAIN,eAJM,CAIU,SAJV,EAIqB,SAJrB,CAAA;EAAW;EAID,MAAA,CAAA,CAAA,EAO1B,CAAA,CAAE,OAPwB,CAOhB,SAPgB,CAAA;EAAW;EAA3B,SAAA,CAAA,CAAA,EAYP,iBAZO,CAYW,SAZX,EAYsB,SAZtB,CAAA;EAOA;EAAR,OAAA,CAAA,CAAA,EAAA,OAAA;EAKmB,gBAAA,CAAA,CAAA,EAAA,OAAA,GAAA,CAAA,GAAA,GAAA,OAAA,CAAA;EAAW,aAAA,CAAA,CAAA,EAAA,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/lib.testing",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.48.0",
|
|
4
4
|
"description": "Contract-aware testing utilities and runners",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
"typescript"
|
|
10
10
|
],
|
|
11
11
|
"type": "module",
|
|
12
|
-
"main": "./dist/index.js",
|
|
13
|
-
"module": "./dist/index.js",
|
|
14
12
|
"types": "./dist/index.d.ts",
|
|
15
13
|
"files": [
|
|
16
14
|
"dist",
|
|
@@ -27,16 +25,16 @@
|
|
|
27
25
|
"lint": "bun lint:fix",
|
|
28
26
|
"lint:fix": "eslint src --fix",
|
|
29
27
|
"lint:check": "eslint src",
|
|
30
|
-
"test": "bun
|
|
28
|
+
"test": "bun test"
|
|
31
29
|
},
|
|
32
30
|
"dependencies": {
|
|
33
|
-
"@contractspec/lib.schema": "1.
|
|
34
|
-
"@contractspec/lib.contracts": "1.
|
|
31
|
+
"@contractspec/lib.schema": "1.48.0",
|
|
32
|
+
"@contractspec/lib.contracts": "1.48.0"
|
|
35
33
|
},
|
|
36
34
|
"devDependencies": {
|
|
37
|
-
"@contractspec/tool.tsdown": "1.
|
|
38
|
-
"@contractspec/tool.typescript": "1.
|
|
39
|
-
"tsdown": "^0.
|
|
35
|
+
"@contractspec/tool.tsdown": "1.48.0",
|
|
36
|
+
"@contractspec/tool.typescript": "1.48.0",
|
|
37
|
+
"tsdown": "^0.19.0",
|
|
40
38
|
"typescript": "^5.9.3"
|
|
41
39
|
},
|
|
42
40
|
"exports": {
|
|
File without changes
|