{"_id":"@codepunter-labs/mock-core","_rev":"2-aa7a675af79af1731eb9137de176dd25","name":"@codepunter-labs/mock-core","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@codepunter-labs/mock-core","version":"0.1.0","license":"MIT","_id":"@codepunter-labs/mock-core@0.1.0","maintainers":[{"name":"codepunter","email":"derrickmensahtorkornoo@gmail.com"}],"homepage":"https://github.com/DERRICK-TORKORNOO/mock-sdks#readme","bugs":{"url":"https://github.com/DERRICK-TORKORNOO/mock-sdks/issues"},"dist":{"shasum":"8191924dc3bbe528add844d2d31b63fdc5a2d075","tarball":"https://registry.npmjs.org/@codepunter-labs/mock-core/-/mock-core-0.1.0.tgz","fileCount":9,"integrity":"sha512-XnQLHzcfX5JFBrGBYy2ZD02nI2GSV4uPh63cBB74eXgk3gzcAA9/vhzfJ3vZMCGfkl5cg/ZqwUXBxbLFIfqkbg==","signatures":[{"sig":"MEYCIQDYeFGzFD1I3UX+bQljrjqHH0LKCBF3SrqT92/6qZCWagIhAMIxoFtiL3OiYz7LNEkbRUSOi2f0L+r8mZtJg3LrwudO","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":123742},"main":"./dist/index.cjs","type":"module","_from":"file:codepunter-labs-mock-core-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"codepunter","email":"derrickmensahtorkornoo@gmail.com"},"_resolved":"/tmp/73ed2ed4c593eda597fe83fdae2f6003/codepunter-labs-mock-core-0.1.0.tgz","_integrity":"sha512-XnQLHzcfX5JFBrGBYy2ZD02nI2GSV4uPh63cBB74eXgk3gzcAA9/vhzfJ3vZMCGfkl5cg/ZqwUXBxbLFIfqkbg==","repository":{"url":"git+https://github.com/DERRICK-TORKORNOO/mock-sdks.git","type":"git","directory":"packages/core"},"_npmVersion":"10.8.2","description":"TODO","directories":{},"_nodeVersion":"20.20.2","_hasShrinkwrap":false,"devDependencies":{"tsup":"*","vitest":"*","typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/mock-core_0.1.0_1783371655673_0.3386365704612002","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@codepunter-labs/mock-core","version":"0.2.0","description":"TODO","repository":{"type":"git","url":"git+https://github.com/DERRICK-TORKORNOO/mock-sdks.git","directory":"packages/core"},"license":"MIT","type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","devDependencies":{"tsup":"*","typescript":"*","vitest":"*"},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest run","typecheck":"tsc --noEmit"},"_id":"@codepunter-labs/mock-core@0.2.0","bugs":{"url":"https://github.com/DERRICK-TORKORNOO/mock-sdks/issues"},"homepage":"https://github.com/DERRICK-TORKORNOO/mock-sdks#readme","_integrity":"sha512-UnlT1X3zmdwd2Gdgw8maZVUYNlOQQVKTWdwUvyqZyi4JJ5+IVD13eneS6LnuI5BOSNZjfzDGtsfDyibE+HmQeQ==","_resolved":"/tmp/7d2854ad148ea32c2d26e70311fda42d/codepunter-labs-mock-core-0.2.0.tgz","_from":"file:codepunter-labs-mock-core-0.2.0.tgz","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-UnlT1X3zmdwd2Gdgw8maZVUYNlOQQVKTWdwUvyqZyi4JJ5+IVD13eneS6LnuI5BOSNZjfzDGtsfDyibE+HmQeQ==","shasum":"50309e583f7d8494a75cc9f994dff9299a77b9b0","tarball":"https://registry.npmjs.org/@codepunter-labs/mock-core/-/mock-core-0.2.0.tgz","fileCount":9,"unpackedSize":123742,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGbiTxUUuo9OTDeBYvKxoqrBrbZydhnskA0OpzCGiuC5AiEAw2LuteSl+Yejv8ddE+ePEnESEtcrF+KkJt1ll3M9zSA="}]},"_npmUser":{"name":"codepunter","email":"derrickmensahtorkornoo@gmail.com"},"directories":{},"maintainers":[{"name":"codepunter","email":"derrickmensahtorkornoo@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mock-core_0.2.0_1783446217898_0.31038151200507325"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-06T21:00:55.508Z","modified":"2026-07-07T17:43:38.179Z","0.1.0":"2026-07-06T21:00:55.815Z","0.2.0":"2026-07-07T17:43:38.060Z"},"bugs":{"url":"https://github.com/DERRICK-TORKORNOO/mock-sdks/issues"},"license":"MIT","homepage":"https://github.com/DERRICK-TORKORNOO/mock-sdks#readme","repository":{"type":"git","url":"git+https://github.com/DERRICK-TORKORNOO/mock-sdks.git","directory":"packages/core"},"description":"TODO","maintainers":[{"name":"codepunter","email":"derrickmensahtorkornoo@gmail.com"}],"readme":"# @codepunter-labs/mock-core\n\nCore primitives and utilities for building mock SDKs. This package provides the foundation for all `@codepunter-labs/mock-*` packages.\n\n## Installation\n\n```bash\nnpm install @codepunter-labs/mock-core\n```\n\n## Features\n\n- **MockError**: Standardized error shapes for simulating API failures\n- **MockScenario**: Define sequences of mock outcomes (success/failure patterns)\n- **SpyFactory**: Type-safe spy creation for Jest and Vitest\n- **ValidationHelpers**: Request validation to catch integration bugs early\n- **DelayHelpers**: Simulate network latency for testing loading states\n- **WebhookHelpers**: Build webhook payloads and signature placeholders\n\n## Usage\n\n### Error Simulation\n\n```typescript\nimport { MockErrors } from '@codepunter-labs/mock-core';\n\n// Simulate API errors\nauth.verifyIdToken.mockRejectedValue(\n  MockErrors.unauthorized('Token has expired')\n);\n\nauth.createUser.mockRejectedValue(\n  MockErrors.badRequest('Invalid email format')\n);\n```\n\n### Scenario Management\n\n```typescript\nimport { MockScenario } from '@codepunter-labs/mock-core';\n\n// Define a sequence of outcomes\nconst scenario = new MockScenario()\n  .success({ user: { id: '123' } })\n  .failure(MockErrors.rateLimited('Too many requests'))\n  .success({ user: { id: '456' } });\n\n// Apply to a spy\nspy.mockImplementation(() => scenario.next());\n```\n\n### Validation\n\n```typescript\nimport { validateObject, ValidationRules } from '@codepunter-labs/mock-core';\n\nconst schema = {\n  email: ValidationRules.email(true),\n  age: ValidationRules.range(18, 120, true),\n  name: ValidationRules.string(true),\n};\n\nconst errors = validateObject(request, schema);\nif (errors.length > 0) {\n  throw new Error(errors.join(', '));\n}\n```\n\n### Delay Simulation\n\n```typescript\nimport { withDelay, randomDelay } from '@codepunter-labs/mock-core';\n\n// Add fixed delay\nconst delayedFn = withDelay(apiCall, 200);\n\n// Add random network jitter\nconst jitteryFn = withRandomDelay(apiCall, 50, 200);\n```\n\n### Webhook Helpers\n\n```typescript\nimport { makeWebhookPayload, MOCK_WEBHOOK_SIGNATURE } from '@codepunter-labs/mock-core';\n\nconst payload = makeWebhookPayload('charge.success', {\n  reference: 'ref-123',\n  amount: 5000,\n});\n\nconst signature = MOCK_WEBHOOK_SIGNATURE;\n```\n\n## API Reference\n\n### MockErrors\n\nStandard HTTP error factories:\n- `badRequest(message?, raw?)` - 400\n- `unauthorized(message?, raw?)` - 401\n- `forbidden(message?, raw?)` - 403\n- `notFound(message?, raw?)` - 404\n- `conflict(message?, raw?)` - 409\n- `unprocessable(message?, raw?)` - 422\n- `rateLimited(message?, raw?)` - 429\n- `serverError(message?, raw?)` - 500\n- `badGateway(message?, raw?)` - 502\n- `serviceUnavailable(message?, raw?)` - 503\n- `custom(statusCode, code, message, raw?)` - Custom error\n\n### ValidationRules\n\nCommon validation rules:\n- `string(required?)`\n- `number(required?)`\n- `boolean(required?)`\n- `array(required?)`\n- `object(required?)`\n- `email(required?)`\n- `url(required?)`\n- `phone(required?)`\n- `range(min, max, required?)`\n- `minLength(min, required?)`\n- `maxLength(max, required?)`\n- `enum(values, required?)`\n\n### Delay Helpers\n\n- `delay(ms)` - Delay execution\n- `withDelay(fn, delayMs)` - Wrap with pre-delay\n- `withPostDelay(fn, delayMs)` - Wrap with post-delay\n- `randomDelay(minMs, maxMs)` - Random delay\n- `withRandomDelay(fn, minMs, maxMs)` - Wrap with random delay\n\n## License\n\nMIT\n","readmeFilename":"README.md"}