@entifix/service-shell 0.11.0 → 0.12.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/README.md +1 -4
- package/dist/auth/require-organization.d.ts +1 -1
- package/dist/auth/require-organization.d.ts.map +1 -1
- package/dist/auth/require-organization.js.map +1 -1
- package/dist/auth/require-principal.d.ts +9 -55
- package/dist/auth/require-principal.d.ts.map +1 -1
- package/dist/auth/require-principal.js +15 -13
- package/dist/auth/require-principal.js.map +1 -1
- package/dist/auth/require-service-crossing.d.ts.map +1 -1
- package/dist/auth/require-service-crossing.js +3 -13
- package/dist/auth/require-service-crossing.js.map +1 -1
- package/dist/auth/shared-token.d.ts +2 -0
- package/dist/auth/shared-token.d.ts.map +1 -1
- package/dist/auth/shared-token.js +2 -2
- package/dist/auth/shared-token.js.map +1 -1
- package/dist/auth/verified-context.d.ts +1 -2
- package/dist/auth/verified-context.d.ts.map +1 -1
- package/dist/auth/verified-context.js.map +1 -1
- package/dist/entity-facet-routes.d.ts +2 -2
- package/dist/entity-facet-routes.d.ts.map +1 -1
- package/dist/entity-facet-routes.js.map +1 -1
- package/dist/entity-route-guard.d.ts +2 -2
- package/dist/entity-route-guard.d.ts.map +1 -1
- package/dist/entity-route-guard.js.map +1 -1
- package/dist/entity-routes.d.ts +1 -1
- package/dist/entity-routes.d.ts.map +1 -1
- package/dist/entity-routes.js.map +1 -1
- package/dist/http-api/build-api.d.ts +78 -0
- package/dist/http-api/build-api.d.ts.map +1 -0
- package/dist/http-api/build-api.js +189 -0
- package/dist/http-api/build-api.js.map +1 -0
- package/dist/http-api/entity-api.d.ts +69 -0
- package/dist/http-api/entity-api.d.ts.map +1 -0
- package/dist/http-api/entity-api.js +522 -0
- package/dist/http-api/entity-api.js.map +1 -0
- package/dist/http-api/guards.d.ts +92 -0
- package/dist/http-api/guards.d.ts.map +1 -0
- package/dist/http-api/guards.js +131 -0
- package/dist/http-api/guards.js.map +1 -0
- package/dist/http-api/index.d.ts +6 -0
- package/dist/http-api/index.d.ts.map +1 -0
- package/dist/http-api/index.js +7 -0
- package/dist/http-api/index.js.map +1 -0
- package/dist/http-api/problem-codec.d.ts +14 -0
- package/dist/http-api/problem-codec.d.ts.map +1 -0
- package/dist/http-api/problem-codec.js +26 -0
- package/dist/http-api/problem-codec.js.map +1 -0
- package/dist/http-api/service-group.d.ts +74 -0
- package/dist/http-api/service-group.d.ts.map +1 -0
- package/dist/http-api/service-group.js +168 -0
- package/dist/http-api/service-group.js.map +1 -0
- package/dist/idempotency.d.ts +9 -4
- package/dist/idempotency.d.ts.map +1 -1
- package/dist/idempotency.js +11 -6
- package/dist/idempotency.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/make-service.d.ts +39 -6
- package/dist/make-service.d.ts.map +1 -1
- package/dist/make-service.js +54 -16
- package/dist/make-service.js.map +1 -1
- package/dist/narrowing.d.ts +1 -15
- package/dist/narrowing.d.ts.map +1 -1
- package/dist/narrowing.js.map +1 -1
- package/dist/respond.d.ts +6 -4
- package/dist/respond.d.ts.map +1 -1
- package/dist/respond.js +11 -7
- package/dist/respond.js.map +1 -1
- package/dist/serve-test-service.d.ts +2 -1
- package/dist/serve-test-service.d.ts.map +1 -1
- package/dist/serve-test-service.js.map +1 -1
- package/package.json +7 -6
- package/dist/health-routes.d.ts +0 -24
- package/dist/health-routes.d.ts.map +0 -1
- package/dist/health-routes.js +0 -86
- package/dist/health-routes.js.map +0 -1
- package/dist/service-description-route.d.ts +0 -66
- package/dist/service-description-route.d.ts.map +0 -1
- package/dist/service-description-route.js +0 -60
- package/dist/service-description-route.js.map +0 -1
package/dist/respond.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/respond.ts"],"sourcesContent":["import {\n DEADLINE_HEADER,\n deadlineFromHeader,\n DeadlineTag,\n type EntifixFailure,\n type FailureCategory,\n Internal,\n isFailure,\n PROBLEM_CONTENT_TYPE,\n problemOf,\n} from '@entifix/core';\nimport { Cause, Clock, Effect, Option } from 'effect';\nimport type { HttpBody } from 'effect/http';\nimport { HttpRouter, HttpServerRequest, HttpServerResponse } from 'effect/http';\nimport type { Severity } from 'effect/LogLevel';\n\n/**\n * What a mounted handler may fail with: a categorised failure, or the\n * response body failing to encode. Anything else — a plain `Error`, a string —\n * does not compile at the mount, which is the point: a failure the shell cannot\n * categorise is one it cannot answer honestly\n * ([ADR 0013](../../../../docs/adr/0013-failures-are-typed-values-decided-at-the-shell.md)).\n */\nexport type RouteFailure = EntifixFailure | HttpBody.HttpBodyError;\n\n/**\n * How a host answers and logs its failures: the status a category answers with\n * and the level it is logged at, each overridable per tag.\n *\n * The composition root owns it. A cell never decides a status, a retry or a\n * log line; it fails, and the shell's policy says what that means.\n */\nexport interface FailurePolicy {\n readonly categoryStatus: Readonly<Record<FailureCategory, number>>;\n readonly tagStatus: Readonly<Record<string, number>>;\n readonly categoryLogLevel: Readonly<Record<FailureCategory, Severity>>;\n readonly tagLogLevel: Readonly<Record<string, Severity>>;\n}\n\n/**\n * The defaults: the category table's statuses, business failures at `Debug`\n * because an answer is not an incident, the transient technical categories at\n * `Warn`, and what is broken — a peer speaking nonsense, a bug — at `Error`.\n */\nexport const defaultFailurePolicy: FailurePolicy = {\n categoryStatus: {\n invalid: 400,\n unauthenticated: 401,\n forbidden: 403,\n notFound: 404,\n conflict: 409,\n declined: 422,\n contention: 409,\n exhausted: 429,\n unavailable: 503,\n timeout: 504,\n protocol: 502,\n internal: 500,\n },\n tagStatus: {},\n categoryLogLevel: {\n invalid: 'Debug',\n unauthenticated: 'Debug',\n forbidden: 'Debug',\n notFound: 'Debug',\n conflict: 'Debug',\n declined: 'Debug',\n contention: 'Warn',\n exhausted: 'Warn',\n unavailable: 'Warn',\n timeout: 'Warn',\n protocol: 'Error',\n internal: 'Error',\n },\n tagLogLevel: {},\n};\n\nexport interface FailurePolicyOverrides {\n readonly categoryStatus?: Partial<Record<FailureCategory, number>>;\n readonly tagStatus?: Readonly<Record<string, number>>;\n readonly categoryLogLevel?: Partial<Record<FailureCategory, Severity>>;\n readonly tagLogLevel?: Readonly<Record<string, Severity>>;\n}\n\n/** A policy with some of its entries replaced — how a slice extends the fleet's. */\nexport const extendFailurePolicy = (\n base: FailurePolicy,\n overrides: FailurePolicyOverrides,\n): FailurePolicy => ({\n categoryStatus: { ...base.categoryStatus, ...overrides.categoryStatus },\n tagStatus: { ...base.tagStatus, ...overrides.tagStatus },\n categoryLogLevel: {\n ...base.categoryLogLevel,\n ...overrides.categoryLogLevel,\n },\n tagLogLevel: { ...base.tagLogLevel, ...overrides.tagLogLevel },\n});\n\nexport const statusFor = (\n failure: EntifixFailure,\n policy: FailurePolicy,\n): number =>\n policy.tagStatus[failure._tag] ?? policy.categoryStatus[failure.category];\n\nexport const logLevelFor = (\n failure: EntifixFailure,\n policy: FailurePolicy,\n): Severity =>\n policy.tagLogLevel[failure._tag] ?? policy.categoryLogLevel[failure.category];\n\nexport interface ProblemResponseOptions {\n readonly traceId?: string | undefined;\n readonly instance?: string | undefined;\n}\n\nconst retryAfterOf = (failure: EntifixFailure): number | undefined => {\n const seconds = (failure as { readonly retryAfterSeconds?: unknown })\n .retryAfterSeconds;\n return typeof seconds === 'number' ? seconds : undefined;\n};\n\n/**\n * The `application/problem+json` answer to a failure, with the policy's\n * status. Built synchronously — the body is already plain data — so it cannot\n * itself fail to encode.\n */\nexport const problemResponse = (\n failure: EntifixFailure,\n policy: FailurePolicy = defaultFailurePolicy,\n options: ProblemResponseOptions = {},\n): HttpServerResponse.HttpServerResponse => {\n const status = statusFor(failure, policy);\n const retryAfter = retryAfterOf(failure);\n return HttpServerResponse.text(\n JSON.stringify(\n problemOf(failure, {\n status,\n ...(options.traceId === undefined ? {} : { traceId: options.traceId }),\n ...(options.instance === undefined\n ? {}\n : { instance: options.instance }),\n }),\n ),\n {\n status,\n contentType: PROBLEM_CONTENT_TYPE,\n ...(retryAfter === undefined\n ? {}\n : { headers: { 'retry-after': String(retryAfter) } }),\n },\n );\n};\n\n/** The current span's trace id, when a span is open. */\nconst currentTraceId: Effect.Effect<string | undefined> = Effect.option(\n Effect.currentSpan,\n).pipe(\n Effect.map(span => Option.getOrUndefined(Option.map(span, s => s.traceId))),\n);\n\n/** The path being answered, when a request is in scope. */\nconst currentInstance: Effect.Effect<string | undefined> = Effect.serviceOption(\n HttpServerRequest.HttpServerRequest,\n).pipe(\n Effect.map(request =>\n Option.getOrUndefined(Option.map(request, r => r.url.split('?')[0])),\n ),\n);\n\nconst answerFailure = (failure: EntifixFailure, policy: FailurePolicy) =>\n Effect.gen(function* () {\n const traceId = yield* currentTraceId;\n const instance = yield* currentInstance;\n yield* Effect.logWithLevel(logLevelFor(failure, policy))(\n 'request failed',\n ).pipe(\n Effect.annotateLogs({\n code: failure.code,\n category: failure.category,\n tag: failure._tag,\n ...(traceId === undefined ? {} : { traceId }),\n }),\n );\n return problemResponse(failure, policy, { traceId, instance });\n });\n\n/**\n * The opaque `500` for anything nobody categorised. The defect is logged in\n * full here, where it was caught; the body carries the trace id to find that\n * line by, and nothing of the defect itself.\n */\nconst answerDefect = (defect: unknown) =>\n Effect.gen(function* () {\n const traceId = yield* currentTraceId;\n const instance = yield* currentInstance;\n yield* Effect.logError('request defect').pipe(\n Effect.annotateLogs({\n code: 'internal',\n category: 'internal',\n cause: Cause.pretty(Cause.die(defect)),\n ...(traceId === undefined ? {} : { traceId }),\n }),\n );\n return problemResponse(new Internal(), defaultFailurePolicy, {\n traceId,\n instance,\n });\n });\n\n/**\n * The request's deadline, when its caller sent one, provided to the handler\n * so a retry below it never starts past it and an outbound call forwards what\n * is left ([ADR 0014](../../../../docs/adr/0014-retry-once-at-the-layer-above-under-a-budget.md)).\n */\nconst withRequestDeadline = <A, E, R>(effect: Effect.Effect<A, E, R>) =>\n Effect.gen(function* () {\n const request = yield* Effect.serviceOption(\n HttpServerRequest.HttpServerRequest,\n );\n const now = yield* Clock.currentTimeMillis;\n const deadline = Option.isSome(request)\n ? deadlineFromHeader(request.value.headers[DEADLINE_HEADER], now)\n : undefined;\n return yield* deadline === undefined\n ? effect\n : Effect.provideService(effect, DeadlineTag, deadline);\n });\n\n/**\n * The terminal reaction: every failure answered as a problem body with the\n * policy's status and logged at the policy's level, every defect answered as\n * an opaque `500`. Interruption is left alone — a request whose client went\n * away has nobody to answer.\n */\nexport const respond = <E extends RouteFailure, R>(\n effect: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>,\n policy: FailurePolicy = defaultFailurePolicy,\n): Effect.Effect<HttpServerResponse.HttpServerResponse, never, R> =>\n withRequestDeadline(effect).pipe(\n Effect.catch((failure: E) =>\n isFailure(failure)\n ? answerFailure(failure, policy)\n : answerDefect(failure),\n ),\n Effect.catchDefect(answerDefect),\n );\n\n/**\n * Mounts a set of routes with every handler wrapped in {@link respond}, once,\n * at the composition root. A route whose handler fails with anything but a\n * {@link RouteFailure} does not compile here.\n */\nexport const mountRoutes = <\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const Routes extends ReadonlyArray<HttpRouter.Route<RouteFailure, any>>,\n>(\n routes: Routes,\n policy: FailurePolicy = defaultFailurePolicy,\n) =>\n HttpRouter.addAll(\n routes.map(route =>\n HttpRouter.route(\n route.method,\n route.path,\n respond(route.handler, policy),\n {\n uninterruptible: route.uninterruptible,\n },\n ),\n ) as unknown as {\n readonly [K in keyof Routes]: HttpRouter.Route<\n never,\n HttpRouter.Route.Context<Routes[K]>\n >;\n },\n );\n\n/**\n * The router's last net: a defect that escaped every route — one not mounted\n * through {@link mountRoutes}, or one thrown while a response was being\n * written — answers the same opaque `500` problem. It catches defects only,\n * never the whole cause, so an interruption still interrupts.\n */\nexport const problemNet = HttpRouter.middleware(\n effect => effect.pipe(Effect.catchDefect(answerDefect)),\n { global: true },\n);\n\n/**\n * What a mechanism reports instead of logging — a relay pass, a shutdown drain\n * ([ADR 0013](../../../../docs/adr/0013-failures-are-typed-values-decided-at-the-shell.md)).\n * Structural, so the shell can log an outcome from a package it does not\n * depend on.\n */\nexport interface MechanismOutcome {\n readonly _tag: string;\n readonly failure?: unknown;\n readonly [field: string]: unknown;\n}\n\n/** The level each outcome is logged at; anything unnamed is `Debug`. */\nexport const MECHANISM_OUTCOME_LEVELS: Readonly<Record<string, Severity>> = {\n quarantined: 'Error',\n sweepFailed: 'Error',\n hookFailed: 'Error',\n drainFailed: 'Warn',\n draining: 'Info',\n drained: 'Debug',\n};\n\n/**\n * The fork site's logger for a mechanism's outcomes: the level from the\n * outcome's tag, the outcome's own fields as annotations, and a typed\n * failure's code and category beside them — never `String(error)`.\n */\nexport const logMechanismOutcome = (\n outcome: MechanismOutcome,\n): Effect.Effect<void> => {\n const { _tag, failure, ...fields } = outcome;\n const typed = isFailure(failure)\n ? { code: failure.code, category: failure.category, tag: failure._tag }\n : failure === undefined\n ? {}\n : { code: 'internal', category: 'internal' };\n return Effect.logWithLevel(MECHANISM_OUTCOME_LEVELS[_tag] ?? 'Debug')(\n _tag,\n ).pipe(Effect.annotateLogs({ ...fields, ...typed }));\n};\n"],"names":["DEADLINE_HEADER","deadlineFromHeader","DeadlineTag","Internal","isFailure","PROBLEM_CONTENT_TYPE","problemOf","Cause","Clock","Effect","Option","HttpRouter","HttpServerRequest","HttpServerResponse","defaultFailurePolicy","categoryStatus","invalid","unauthenticated","forbidden","notFound","conflict","declined","contention","exhausted","unavailable","timeout","protocol","internal","tagStatus","categoryLogLevel","tagLogLevel","extendFailurePolicy","base","overrides","statusFor","failure","policy","_tag","category","logLevelFor","retryAfterOf","seconds","retryAfterSeconds","undefined","problemResponse","options","status","retryAfter","text","JSON","stringify","traceId","instance","contentType","headers","String","currentTraceId","option","currentSpan","pipe","map","span","getOrUndefined","s","currentInstance","serviceOption","request","r","url","split","answerFailure","gen","logWithLevel","annotateLogs","code","tag","answerDefect","defect","logError","cause","pretty","die","withRequestDeadline","effect","now","currentTimeMillis","deadline","isSome","value","provideService","respond","catch","catchDefect","mountRoutes","routes","addAll","route","method","path","handler","uninterruptible","problemNet","middleware","global","MECHANISM_OUTCOME_LEVELS","quarantined","sweepFailed","hookFailed","drainFailed","draining","drained","logMechanismOutcome","outcome","fields","typed"],"mappings":";;AAAA,SACEA,eAAe,EACfC,kBAAkB,EAClBC,WAAW,EAGXC,QAAQ,EACRC,SAAS,EACTC,oBAAoB,EACpBC,SAAS,QACJ,gBAAgB;AACvB,SAASC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,QAAQ,SAAS;AAEtD,SAASC,UAAU,EAAEC,iBAAiB,EAAEC,kBAAkB,QAAQ,cAAc;AA0BhF;;;;CAIC,GACD,OAAO,MAAMC,uBAAsC;IACjDC,gBAAgB;QACdC,SAAS;QACTC,iBAAiB;QACjBC,WAAW;QACXC,UAAU;QACVC,UAAU;QACVC,UAAU;QACVC,YAAY;QACZC,WAAW;QACXC,aAAa;QACbC,SAAS;QACTC,UAAU;QACVC,UAAU;IACZ;IACAC,WAAW,CAAC;IACZC,kBAAkB;QAChBb,SAAS;QACTC,iBAAiB;QACjBC,WAAW;QACXC,UAAU;QACVC,UAAU;QACVC,UAAU;QACVC,YAAY;QACZC,WAAW;QACXC,aAAa;QACbC,SAAS;QACTC,UAAU;QACVC,UAAU;IACZ;IACAG,aAAa,CAAC;AAChB,EAAE;AASF,kFAAkF,GAClF,OAAO,MAAMC,sBAAsB,CACjCC,MACAC,YACmB,CAAA;QACnBlB,gBAAgB,aAAKiB,KAAKjB,cAAc,EAAKkB,UAAUlB,cAAc;QACrEa,WAAW,aAAKI,KAAKJ,SAAS,EAAKK,UAAUL,SAAS;QACtDC,kBAAkB,aACbG,KAAKH,gBAAgB,EACrBI,UAAUJ,gBAAgB;QAE/BC,aAAa,aAAKE,KAAKF,WAAW,EAAKG,UAAUH,WAAW;IAC9D,CAAA,EAAG;AAEH,OAAO,MAAMI,YAAY,CACvBC,SACAC;QAEAA;YAAAA,iCAAAA,OAAOR,SAAS,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,MAAM;QAAYpC,UAAU;IAAW;IAC/C,OAAO7B,OAAO+D,YAAY,EAACgC,iCAAAA,wBAAwB,CAACnE,KAAK,YAA9BmE,iCAAkC,SAC3DnE,MACAsB,IAAI,CAAClD,OAAOgE,YAAY,CAAC,aAAKwC,QAAWC;AAC7C,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../src/respond.ts"],"sourcesContent":["import {\n DEADLINE_HEADER,\n deadlineFromHeader,\n DeadlineTag,\n type EntifixFailure,\n type FailureCategory,\n Internal,\n isFailure,\n NotFound,\n PROBLEM_CONTENT_TYPE,\n problemOf,\n} from '@entifix/core';\nimport { Cause, Clock, Effect, Option } from 'effect';\nimport type { HttpBody } from 'effect/http';\nimport {\n HttpRouter,\n HttpServerError,\n HttpServerRequest,\n HttpServerResponse,\n} from 'effect/http';\nimport type { Severity } from 'effect/LogLevel';\n\n/**\n * What a mounted handler may fail with: a categorised failure, or the\n * response body failing to encode. Anything else — a plain `Error`, a string —\n * does not compile at the mount, which is the point: a failure the shell cannot\n * categorise is one it cannot answer honestly\n * ([ADR 0013](../../../../docs/adr/0013-failures-are-typed-values-decided-at-the-shell.md)).\n */\nexport type RouteFailure = EntifixFailure | HttpBody.HttpBodyError;\n\n/**\n * How a host answers and logs its failures: the status a category answers with\n * and the level it is logged at, each overridable per tag.\n *\n * The composition root owns it. A cell never decides a status, a retry or a\n * log line; it fails, and the shell's policy says what that means.\n */\nexport interface FailurePolicy {\n readonly categoryStatus: Readonly<Record<FailureCategory, number>>;\n readonly tagStatus: Readonly<Record<string, number>>;\n readonly categoryLogLevel: Readonly<Record<FailureCategory, Severity>>;\n readonly tagLogLevel: Readonly<Record<string, Severity>>;\n}\n\n/**\n * The defaults: the category table's statuses, business failures at `Debug`\n * because an answer is not an incident, the transient technical categories at\n * `Warn`, and what is broken — a peer speaking nonsense, a bug — at `Error`.\n */\nexport const defaultFailurePolicy: FailurePolicy = {\n categoryStatus: {\n invalid: 400,\n unauthenticated: 401,\n forbidden: 403,\n notFound: 404,\n conflict: 409,\n declined: 422,\n contention: 409,\n exhausted: 429,\n unavailable: 503,\n timeout: 504,\n protocol: 502,\n internal: 500,\n },\n tagStatus: {},\n categoryLogLevel: {\n invalid: 'Debug',\n unauthenticated: 'Debug',\n forbidden: 'Debug',\n notFound: 'Debug',\n conflict: 'Debug',\n declined: 'Debug',\n contention: 'Warn',\n exhausted: 'Warn',\n unavailable: 'Warn',\n timeout: 'Warn',\n protocol: 'Error',\n internal: 'Error',\n },\n tagLogLevel: {},\n};\n\nexport interface FailurePolicyOverrides {\n readonly categoryStatus?: Partial<Record<FailureCategory, number>>;\n readonly tagStatus?: Readonly<Record<string, number>>;\n readonly categoryLogLevel?: Partial<Record<FailureCategory, Severity>>;\n readonly tagLogLevel?: Readonly<Record<string, Severity>>;\n}\n\n/** A policy with some of its entries replaced — how a slice extends the fleet's. */\nexport const extendFailurePolicy = (\n base: FailurePolicy,\n overrides: FailurePolicyOverrides,\n): FailurePolicy => ({\n categoryStatus: { ...base.categoryStatus, ...overrides.categoryStatus },\n tagStatus: { ...base.tagStatus, ...overrides.tagStatus },\n categoryLogLevel: {\n ...base.categoryLogLevel,\n ...overrides.categoryLogLevel,\n },\n tagLogLevel: { ...base.tagLogLevel, ...overrides.tagLogLevel },\n});\n\nexport const statusFor = (\n failure: EntifixFailure,\n policy: FailurePolicy,\n): number =>\n policy.tagStatus[failure._tag] ?? policy.categoryStatus[failure.category];\n\nexport const logLevelFor = (\n failure: EntifixFailure,\n policy: FailurePolicy,\n): Severity =>\n policy.tagLogLevel[failure._tag] ?? policy.categoryLogLevel[failure.category];\n\nexport interface ProblemResponseOptions {\n readonly traceId?: string | undefined;\n readonly instance?: string | undefined;\n}\n\nconst retryAfterOf = (failure: EntifixFailure): number | undefined => {\n const seconds = (failure as { readonly retryAfterSeconds?: unknown })\n .retryAfterSeconds;\n return typeof seconds === 'number' ? seconds : undefined;\n};\n\n/**\n * The `application/problem+json` answer to a failure, with the policy's\n * status. Built synchronously — the body is already plain data — so it cannot\n * itself fail to encode.\n */\nexport const problemResponse = (\n failure: EntifixFailure,\n policy: FailurePolicy = defaultFailurePolicy,\n options: ProblemResponseOptions = {},\n): HttpServerResponse.HttpServerResponse => {\n const status = statusFor(failure, policy);\n const retryAfter = retryAfterOf(failure);\n return HttpServerResponse.text(\n JSON.stringify(\n problemOf(failure, {\n status,\n ...(options.traceId === undefined ? {} : { traceId: options.traceId }),\n ...(options.instance === undefined\n ? {}\n : { instance: options.instance }),\n }),\n ),\n {\n status,\n contentType: PROBLEM_CONTENT_TYPE,\n ...(retryAfter === undefined\n ? {}\n : { headers: { 'retry-after': String(retryAfter) } }),\n },\n );\n};\n\n/** The current span's trace id, when a span is open. */\nconst currentTraceId: Effect.Effect<string | undefined> = Effect.option(\n Effect.currentSpan,\n).pipe(\n Effect.map(span => Option.getOrUndefined(Option.map(span, s => s.traceId))),\n);\n\n/** The path being answered, when a request is in scope. */\nconst currentInstance: Effect.Effect<string | undefined> = Effect.serviceOption(\n HttpServerRequest.HttpServerRequest,\n).pipe(\n Effect.map(request =>\n Option.getOrUndefined(Option.map(request, r => r.url.split('?')[0])),\n ),\n);\n\nconst answerFailure = (failure: EntifixFailure, policy: FailurePolicy) =>\n Effect.gen(function* () {\n const traceId = yield* currentTraceId;\n const instance = yield* currentInstance;\n yield* Effect.logWithLevel(logLevelFor(failure, policy))(\n 'request failed',\n ).pipe(\n Effect.annotateLogs({\n code: failure.code,\n category: failure.category,\n tag: failure._tag,\n ...(traceId === undefined ? {} : { traceId }),\n }),\n );\n return problemResponse(failure, policy, { traceId, instance });\n });\n\n/**\n * The opaque `500` for anything nobody categorised. The defect is logged in\n * full here, where it was caught; the body carries the trace id to find that\n * line by, and nothing of the defect itself.\n */\nconst answerDefect = (defect: unknown) =>\n Effect.gen(function* () {\n const traceId = yield* currentTraceId;\n const instance = yield* currentInstance;\n yield* Effect.logError('request defect').pipe(\n Effect.annotateLogs({\n code: 'internal',\n category: 'internal',\n cause: Cause.pretty(Cause.die(defect)),\n ...(traceId === undefined ? {} : { traceId }),\n }),\n );\n return problemResponse(new Internal(), defaultFailurePolicy, {\n traceId,\n instance,\n });\n });\n\n/**\n * The request's deadline, when its caller sent one, provided to the handler\n * so a retry below it never starts past it and an outbound call forwards what\n * is left ([ADR 0014](../../../../docs/adr/0014-retry-once-at-the-layer-above-under-a-budget.md)).\n */\nconst withRequestDeadline = <A, E, R>(effect: Effect.Effect<A, E, R>) =>\n Effect.gen(function* () {\n const request = yield* Effect.serviceOption(\n HttpServerRequest.HttpServerRequest,\n );\n const now = yield* Clock.currentTimeMillis;\n const deadline = Option.isSome(request)\n ? deadlineFromHeader(request.value.headers[DEADLINE_HEADER], now)\n : undefined;\n return yield* deadline === undefined\n ? effect\n : Effect.provideService(effect, DeadlineTag, deadline);\n });\n\n/**\n * The terminal reaction: every failure answered as a problem body with the\n * policy's status and logged at the policy's level, every defect answered as\n * an opaque `500`. Interruption is left alone — a request whose client went\n * away has nobody to answer.\n */\nexport const respond = <E extends RouteFailure, R>(\n effect: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>,\n policy: FailurePolicy = defaultFailurePolicy,\n): Effect.Effect<HttpServerResponse.HttpServerResponse, never, R> =>\n withRequestDeadline(effect).pipe(\n Effect.catch((failure: E) =>\n isFailure(failure)\n ? answerFailure(failure, policy)\n : answerDefect(failure),\n ),\n Effect.catchDefect(answerDefect),\n );\n\n/**\n * Mounts a set of routes with every handler wrapped in {@link respond}, once,\n * at the composition root. A route whose handler fails with anything but a\n * {@link RouteFailure} does not compile here.\n */\nexport const mountRoutes = <\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const Routes extends ReadonlyArray<HttpRouter.Route<RouteFailure, any>>,\n>(\n routes: Routes,\n policy: FailurePolicy = defaultFailurePolicy,\n) =>\n HttpRouter.addAll(\n routes.map(route =>\n HttpRouter.route(\n route.method,\n route.path,\n respond(route.handler, policy),\n {\n uninterruptible: route.uninterruptible,\n },\n ),\n ) as unknown as {\n readonly [K in keyof Routes]: HttpRouter.Route<\n never,\n HttpRouter.Route.Context<Routes[K]>\n >;\n },\n );\n\n/**\n * The router's last net. A path no route matches answers a `404` problem\n * rather than an empty body, and a defect that escaped every route — one not\n * mounted through {@link mountRoutes}, or one thrown while a response was\n * being written — answers the same opaque `500` problem. It catches those two\n * and nothing else, never the whole cause, so an interruption still\n * interrupts.\n */\nexport const problemNet = HttpRouter.middleware(\n effect =>\n effect.pipe(\n Effect.catchIf(\n (error: unknown) =>\n HttpServerError.isHttpServerError(error) &&\n error.reason._tag === 'RouteNotFound',\n () =>\n Effect.map(currentInstance, instance =>\n problemResponse(new NotFound({}), defaultFailurePolicy, {\n instance,\n }),\n ),\n ),\n Effect.catchDefect(answerDefect),\n ),\n { global: true },\n);\n\n/**\n * What a mechanism reports instead of logging — a relay pass, a shutdown drain\n * ([ADR 0013](../../../../docs/adr/0013-failures-are-typed-values-decided-at-the-shell.md)).\n * Structural, so the shell can log an outcome from a package it does not\n * depend on.\n */\nexport interface MechanismOutcome {\n readonly _tag: string;\n readonly failure?: unknown;\n readonly [field: string]: unknown;\n}\n\n/** The level each outcome is logged at; anything unnamed is `Debug`. */\nexport const MECHANISM_OUTCOME_LEVELS: Readonly<Record<string, Severity>> = {\n quarantined: 'Error',\n sweepFailed: 'Error',\n hookFailed: 'Error',\n drainFailed: 'Warn',\n draining: 'Info',\n drained: 'Debug',\n};\n\n/**\n * The fork site's logger for a mechanism's outcomes: the level from the\n * outcome's tag, the outcome's own fields as annotations, and a typed\n * failure's code and category beside them — never `String(error)`.\n */\nexport const logMechanismOutcome = (\n outcome: MechanismOutcome,\n): Effect.Effect<void> => {\n const { _tag, failure, ...fields } = outcome;\n const typed = isFailure(failure)\n ? { code: failure.code, category: failure.category, tag: failure._tag }\n : failure === undefined\n ? {}\n : { code: 'internal', category: 'internal' };\n return Effect.logWithLevel(MECHANISM_OUTCOME_LEVELS[_tag] ?? 'Debug')(\n _tag,\n ).pipe(Effect.annotateLogs({ ...fields, ...typed }));\n};\n"],"names":["DEADLINE_HEADER","deadlineFromHeader","DeadlineTag","Internal","isFailure","NotFound","PROBLEM_CONTENT_TYPE","problemOf","Cause","Clock","Effect","Option","HttpRouter","HttpServerError","HttpServerRequest","HttpServerResponse","defaultFailurePolicy","categoryStatus","invalid","unauthenticated","forbidden","notFound","conflict","declined","contention","exhausted","unavailable","timeout","protocol","internal","tagStatus","categoryLogLevel","tagLogLevel","extendFailurePolicy","base","overrides","statusFor","failure","policy","_tag","category","logLevelFor","retryAfterOf","seconds","retryAfterSeconds","undefined","problemResponse","options","status","retryAfter","text","JSON","stringify","traceId","instance","contentType","headers","String","currentTraceId","option","currentSpan","pipe","map","span","getOrUndefined","s","currentInstance","serviceOption","request","r","url","split","answerFailure","gen","logWithLevel","annotateLogs","code","tag","answerDefect","defect","logError","cause","pretty","die","withRequestDeadline","effect","now","currentTimeMillis","deadline","isSome","value","provideService","respond","catch","catchDefect","mountRoutes","routes","addAll","route","method","path","handler","uninterruptible","problemNet","middleware","catchIf","error","isHttpServerError","reason","global","MECHANISM_OUTCOME_LEVELS","quarantined","sweepFailed","hookFailed","drainFailed","draining","drained","logMechanismOutcome","outcome","fields","typed"],"mappings":";;AAAA,SACEA,eAAe,EACfC,kBAAkB,EAClBC,WAAW,EAGXC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,oBAAoB,EACpBC,SAAS,QACJ,gBAAgB;AACvB,SAASC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,QAAQ,SAAS;AAEtD,SACEC,UAAU,EACVC,eAAe,EACfC,iBAAiB,EACjBC,kBAAkB,QACb,cAAc;AA0BrB;;;;CAIC,GACD,OAAO,MAAMC,uBAAsC;IACjDC,gBAAgB;QACdC,SAAS;QACTC,iBAAiB;QACjBC,WAAW;QACXC,UAAU;QACVC,UAAU;QACVC,UAAU;QACVC,YAAY;QACZC,WAAW;QACXC,aAAa;QACbC,SAAS;QACTC,UAAU;QACVC,UAAU;IACZ;IACAC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;QACxC,KAQJ;AAEJ;;;;;;;CAOC,GACD,OAAO,MAAMC,aAAa3F,WAAW4F,UAAU,CAC7CnB,CAAAA,SACEA,OAAOxB,IAAI,CACTnD,OAAO+F,OAAO,CACZ,CAACC,QACC7F,gBAAgB8F,iBAAiB,CAACD,UAClCA,MAAME,MAAM,CAACrE,IAAI,KAAK,iBACxB,IACE7B,OAAOoD,GAAG,CAACI,iBAAiBZ,CAAAA,WAC1BR,gBAAgB,IAAIzC,SAAS,CAAC,IAAIW,sBAAsB;gBACtDsC;YACF,MAGN5C,OAAOoF,WAAW,CAAChB,gBAEvB;IAAE+B,QAAQ;AAAK,GACf;AAcF,sEAAsE,GACtE,OAAO,MAAMC,2BAA+D;IAC1EC,aAAa;IACbC,aAAa;IACbC,YAAY;IACZC,aAAa;IACbC,UAAU;IACVC,SAAS;AACX,EAAE;AAEF;;;;CAIC,GACD,OAAO,MAAMC,sBAAsB,CACjCC;QAQ2BR;IAN3B,MAAM,EAAEvE,IAAI,EAAEF,OAAO,EAAa,GAAGiF,SAAXC,0CAAWD;;;;IACrC,MAAME,QAAQpH,UAAUiC,WACpB;QAAEuC,MAAMvC,QAAQuC,IAAI;QAAEpC,UAAUH,QAAQG,QAAQ;QAAEqC,KAAKxC,QAAQE,IAAI;IAAC,IACpEF,YAAYQ,YACV,CAAC,IACD;QAAE+B,MAAM;QAAYpC,UAAU;IAAW;IAC/C,OAAO9B,OAAOgE,YAAY,EAACoC,iCAAAA,wBAAwB,CAACvE,KAAK,YAA9BuE,iCAAkC,SAC3DvE,MACAsB,IAAI,CAACnD,OAAOiE,YAAY,CAAC,aAAK4C,QAAWC;AAC7C,EAAE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AnyEndpointGroup } from './http-api/build-api.js';
|
|
1
2
|
import { type ServiceDefinition } from './make-service.js';
|
|
2
3
|
import { type WaitForHttpOptions } from './wait-for-http.js';
|
|
3
4
|
/** A service booted in-process, and the handle that shuts it down. */
|
|
@@ -33,5 +34,5 @@ export declare const freePort: () => Promise<number>;
|
|
|
33
34
|
* timeout: the launch fiber is raced against the health check, so a missing
|
|
34
35
|
* dependency reports its own cause.
|
|
35
36
|
*/
|
|
36
|
-
export declare const serveTestService: <RRoutes>(def: ServiceDefinition<RRoutes>, { port, ...waitOptions }?: ServeTestServiceOptions) => Promise<RunningTestService>;
|
|
37
|
+
export declare const serveTestService: <RRoutes, const Groups extends ReadonlyArray<AnyEndpointGroup> = readonly []>(def: ServiceDefinition<RRoutes, Groups>, { port, ...waitOptions }?: ServeTestServiceOptions) => Promise<RunningTestService>;
|
|
37
38
|
//# sourceMappingURL=serve-test-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve-test-service.d.ts","sourceRoot":"","sources":["../src/serve-test-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE1E,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,QAAO,OAAO,CAAC,MAAM,CAUtC,CAAC;AAEL;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"serve-test-service.d.ts","sourceRoot":"","sources":["../src/serve-test-service.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE1E,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,QAAO,OAAO,CAAC,MAAM,CAUtC,CAAC;AAEL;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,GAC3B,OAAO,EACP,KAAK,CAAC,MAAM,SAAS,aAAa,CAAC,gBAAgB,CAAC,GAAG,SAAS,EAAE,EAElE,KAAK,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,EACvC,2BAA0B,uBAA4B,KACrD,OAAO,CAAC,kBAAkB,CA6B5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/serve-test-service.ts"],"sourcesContent":["import { createServer } from 'node:http';\nimport type { AddressInfo } from 'node:net';\n\nimport { Effect, Fiber, Layer } from 'effect';\n\nimport { makeServerLayer, type ServiceDefinition } from './make-service.js';\nimport { waitForHttp, type WaitForHttpOptions } from './wait-for-http.js';\n\n/** A service booted in-process, and the handle that shuts it down. */\nexport interface RunningTestService {\n /** Origin the service is listening on, e.g. `http://127.0.0.1:53211`. */\n readonly baseUrl: string;\n /** Interrupts the launch fiber, releasing every Layer finalizer. */\n close(): Promise<void>;\n}\n\nexport interface ServeTestServiceOptions extends WaitForHttpOptions {\n /** Fixed port. Omit to bind an ephemeral one, which is what tests want. */\n port?: number;\n}\n\n/**\n * Asks the OS for a free port by binding one and letting it go again.\n *\n * Exported because an ephemeral port is useful to any in-process boot, and\n * because a helper with its own name is easier to reason about than an inline\n * promise inside the launch sequence.\n */\nexport const freePort = (): Promise<number> =>\n new Promise<number>((resolve, reject) => {\n const probe = createServer();\n probe.on('error', reject);\n probe.listen(0, '127.0.0.1', () => {\n const { port } = probe.address() as AddressInfo;\n probe.close(() => {\n resolve(port);\n });\n });\n });\n\n/**\n * Boots a service definition in-process on an ephemeral port and waits until it\n * answers `/api/health`.\n *\n * This is the seam the e2e `mock` profile runs on: the service's REAL `router`\n * and the REAL {@link makeServerLayer} wiring are used, with only the `appLayer`\n * swapped for one built from driver fakes. So the routes, the use-cases, the\n * repository adapter and the query translation all execute — what is absent is\n * the infrastructure, not the service.\n *\n * A boot failure (a Layer that dies) surfaces here rather than as a readiness\n * timeout: the launch fiber is raced against the health check, so a missing\n * dependency reports its own cause.\n */\nexport const serveTestService = async <
|
|
1
|
+
{"version":3,"sources":["../src/serve-test-service.ts"],"sourcesContent":["import { createServer } from 'node:http';\nimport type { AddressInfo } from 'node:net';\n\nimport { Effect, Fiber, Layer } from 'effect';\n\nimport type { AnyEndpointGroup } from './http-api/build-api.js';\nimport { makeServerLayer, type ServiceDefinition } from './make-service.js';\nimport { waitForHttp, type WaitForHttpOptions } from './wait-for-http.js';\n\n/** A service booted in-process, and the handle that shuts it down. */\nexport interface RunningTestService {\n /** Origin the service is listening on, e.g. `http://127.0.0.1:53211`. */\n readonly baseUrl: string;\n /** Interrupts the launch fiber, releasing every Layer finalizer. */\n close(): Promise<void>;\n}\n\nexport interface ServeTestServiceOptions extends WaitForHttpOptions {\n /** Fixed port. Omit to bind an ephemeral one, which is what tests want. */\n port?: number;\n}\n\n/**\n * Asks the OS for a free port by binding one and letting it go again.\n *\n * Exported because an ephemeral port is useful to any in-process boot, and\n * because a helper with its own name is easier to reason about than an inline\n * promise inside the launch sequence.\n */\nexport const freePort = (): Promise<number> =>\n new Promise<number>((resolve, reject) => {\n const probe = createServer();\n probe.on('error', reject);\n probe.listen(0, '127.0.0.1', () => {\n const { port } = probe.address() as AddressInfo;\n probe.close(() => {\n resolve(port);\n });\n });\n });\n\n/**\n * Boots a service definition in-process on an ephemeral port and waits until it\n * answers `/api/health`.\n *\n * This is the seam the e2e `mock` profile runs on: the service's REAL `router`\n * and the REAL {@link makeServerLayer} wiring are used, with only the `appLayer`\n * swapped for one built from driver fakes. So the routes, the use-cases, the\n * repository adapter and the query translation all execute — what is absent is\n * the infrastructure, not the service.\n *\n * A boot failure (a Layer that dies) surfaces here rather than as a readiness\n * timeout: the launch fiber is raced against the health check, so a missing\n * dependency reports its own cause.\n */\nexport const serveTestService = async <\n RRoutes,\n const Groups extends ReadonlyArray<AnyEndpointGroup> = readonly [],\n>(\n def: ServiceDefinition<RRoutes, Groups>,\n { port, ...waitOptions }: ServeTestServiceOptions = {},\n): Promise<RunningTestService> => {\n const boundPort = port ?? (await freePort());\n const baseUrl = `http://127.0.0.1:${boundPort}`;\n\n const fiber = Effect.runFork(Layer.launch(makeServerLayer(def, boundPort)));\n\n // `Layer.launch` only ends when the service stops, so any failure of the\n // launch fiber during startup is the real reason the health check would\n // otherwise have timed out. `Fiber.join` re-raises the cause, so the defect\n // that killed the Layer — not a generic timeout — is what gets reported.\n const launchFailure = Effect.runPromise(Fiber.join(fiber)).catch(\n (error: unknown) => {\n throw new Error(`The service exited during startup: ${String(error)}`);\n },\n );\n // The same rejection fires again on a clean shutdown, when nobody is racing\n // it any more. Observed here so it is never an unhandled rejection.\n launchFailure.catch(() => undefined);\n\n await Promise.race([\n waitForHttp(`${baseUrl}/api/health`, waitOptions),\n launchFailure,\n ]);\n\n return {\n baseUrl,\n close: () =>\n Effect.runPromise(Fiber.interrupt(fiber)).then(() => undefined),\n };\n};\n"],"names":["createServer","Effect","Fiber","Layer","makeServerLayer","waitForHttp","freePort","Promise","resolve","reject","probe","on","listen","port","address","close","serveTestService","def","waitOptions","boundPort","baseUrl","fiber","runFork","launch","launchFailure","runPromise","join","catch","error","Error","String","undefined","race","interrupt","then"],"mappings":";AAAA,SAASA,YAAY,QAAQ,YAAY;AAGz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@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entifix/service-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Effect HTTP service skeleton: server layer, health and metadata routes, permission guards, remote configuration and OpenTelemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@swc/helpers": "0.5.23",
|
|
69
|
-
"@entifix/
|
|
70
|
-
"@entifix/
|
|
71
|
-
"@entifix/
|
|
72
|
-
"@entifix/tooling": "0.
|
|
69
|
+
"@entifix/authz": "0.12.0",
|
|
70
|
+
"@entifix/business": "0.12.0",
|
|
71
|
+
"@entifix/core": "0.12.0",
|
|
72
|
+
"@entifix/tooling": "0.12.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@effect/opentelemetry": "4.0.6",
|
|
@@ -81,7 +81,8 @@
|
|
|
81
81
|
"@opentelemetry/sdk-metrics": "2.12.0",
|
|
82
82
|
"@opentelemetry/sdk-trace-base": "2.12.0",
|
|
83
83
|
"effect": "4.0.6",
|
|
84
|
-
"@entifix/
|
|
84
|
+
"@entifix/rest": "0.12.0",
|
|
85
|
+
"@entifix/testing-unit": "0.12.0"
|
|
85
86
|
},
|
|
86
87
|
"peerDependencies": {
|
|
87
88
|
"@effect/opentelemetry": "^4.0.6",
|
package/dist/health-routes.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { HealthRegistryTag, ShutdownRegistryTag } from '@entifix/business';
|
|
2
|
-
import { HttpRouter } from 'effect/http';
|
|
3
|
-
/**
|
|
4
|
-
* The probe endpoints, as a route layer to merge beside a service's own.
|
|
5
|
-
*
|
|
6
|
-
* - `GET /api/health` — the original endpoint, unchanged. Kept because
|
|
7
|
-
* Playwright's `readyPath` and existing tooling point at it.
|
|
8
|
-
* - `GET /api/health/live` — **liveness**. Answers from the process alone: no
|
|
9
|
-
* datastore, no config-service, no session. This is deliberate and load
|
|
10
|
-
* bearing. A liveness probe that checks dependencies turns a Mongo blip into
|
|
11
|
-
* "Kubernetes restarts every replica", which is an outage the probe caused.
|
|
12
|
-
* - `GET /api/health/ready` — **readiness**: `200` when every registered probe
|
|
13
|
-
* passes, `503 {status:'degraded', failing:[…]}` otherwise. Kubernetes pulls
|
|
14
|
-
* a not-ready pod out of the load balancer without killing it, which is what
|
|
15
|
-
* a reconnecting client wants. A process that has begun terminating answers
|
|
16
|
-
* `503 {status:'terminating'}` instead, **before** any probe runs: nothing is
|
|
17
|
-
* failing, and running the probes would ask a closing pool a question whose
|
|
18
|
-
* answer changes nothing.
|
|
19
|
-
*
|
|
20
|
-
* The failing list carries probe **names** only — never a URI, host, or driver
|
|
21
|
-
* message. This endpoint answers anyone who can reach the port.
|
|
22
|
-
*/
|
|
23
|
-
export declare const healthRoutes: (serviceName: string) => import("effect/Layer").Layer<never, never, HttpRouter.HttpRouter | HttpRouter.Request<"Requires", HealthRegistryTag> | HttpRouter.Request<"Requires", ShutdownRegistryTag> | HttpRouter.Request<"Error", import("effect/http/HttpBody").HttpBodyError>>;
|
|
24
|
-
//# sourceMappingURL=health-routes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"health-routes.d.ts","sourceRoot":"","sources":["../src/health-routes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAsB,MAAM,aAAa,CAAC;AAiB7D;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,eAAO,MAAM,YAAY,GAAI,aAAa,MAAM,4PA0D/C,CAAC"}
|
package/dist/health-routes.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { HealthRegistryTag, ShutdownRegistryTag } from '@entifix/business';
|
|
2
|
-
import { Effect, Ref } from 'effect';
|
|
3
|
-
import { HttpRouter, HttpServerResponse } from 'effect/http';
|
|
4
|
-
import { respond } from './respond.js';
|
|
5
|
-
/**
|
|
6
|
-
* How long a readiness result is reused. These endpoints are unauthenticated by
|
|
7
|
-
* necessity (a probe cannot hold a session), so without a cache every request
|
|
8
|
-
* would reach Mongo — a cheap lever for anyone who can reach the port, and
|
|
9
|
-
* noise in the datastore's own metrics.
|
|
10
|
-
*/ const READY_CACHE_MS = 1000;
|
|
11
|
-
/**
|
|
12
|
-
* The probe endpoints, as a route layer to merge beside a service's own.
|
|
13
|
-
*
|
|
14
|
-
* - `GET /api/health` — the original endpoint, unchanged. Kept because
|
|
15
|
-
* Playwright's `readyPath` and existing tooling point at it.
|
|
16
|
-
* - `GET /api/health/live` — **liveness**. Answers from the process alone: no
|
|
17
|
-
* datastore, no config-service, no session. This is deliberate and load
|
|
18
|
-
* bearing. A liveness probe that checks dependencies turns a Mongo blip into
|
|
19
|
-
* "Kubernetes restarts every replica", which is an outage the probe caused.
|
|
20
|
-
* - `GET /api/health/ready` — **readiness**: `200` when every registered probe
|
|
21
|
-
* passes, `503 {status:'degraded', failing:[…]}` otherwise. Kubernetes pulls
|
|
22
|
-
* a not-ready pod out of the load balancer without killing it, which is what
|
|
23
|
-
* a reconnecting client wants. A process that has begun terminating answers
|
|
24
|
-
* `503 {status:'terminating'}` instead, **before** any probe runs: nothing is
|
|
25
|
-
* failing, and running the probes would ask a closing pool a question whose
|
|
26
|
-
* answer changes nothing.
|
|
27
|
-
*
|
|
28
|
-
* The failing list carries probe **names** only — never a URI, host, or driver
|
|
29
|
-
* message. This endpoint answers anyone who can reach the port.
|
|
30
|
-
*/ // The return type is inferred rather than annotated: `HttpServerResponse.json`
|
|
31
|
-
// widens the routes' error channel with `HttpBodyError`, and spelling that out
|
|
32
|
-
// here would only duplicate what the platform types already say.
|
|
33
|
-
export const healthRoutes = (serviceName)=>{
|
|
34
|
-
// One cache per server instance (the e2e mock profile boots services
|
|
35
|
-
// in-process, so a module-level cache would leak across them).
|
|
36
|
-
const cache = Ref.makeUnsafe(null);
|
|
37
|
-
const cachedReport = Effect.gen(function*() {
|
|
38
|
-
const now = Date.now();
|
|
39
|
-
const entry = yield* Ref.get(cache);
|
|
40
|
-
if (entry !== null && now - entry.at < READY_CACHE_MS) return entry.report;
|
|
41
|
-
const registry = yield* HealthRegistryTag;
|
|
42
|
-
const report = yield* registry.report;
|
|
43
|
-
yield* Ref.set(cache, {
|
|
44
|
-
at: now,
|
|
45
|
-
report
|
|
46
|
-
});
|
|
47
|
-
return report;
|
|
48
|
-
});
|
|
49
|
-
return HttpRouter.addAll([
|
|
50
|
-
HttpRouter.route('GET', '/api/health', HttpServerResponse.json({
|
|
51
|
-
status: 'ok',
|
|
52
|
-
service: serviceName
|
|
53
|
-
})),
|
|
54
|
-
HttpRouter.route('GET', '/api/health/live', HttpServerResponse.json({
|
|
55
|
-
status: 'live',
|
|
56
|
-
service: serviceName
|
|
57
|
-
})),
|
|
58
|
-
HttpRouter.route('GET', '/api/health/ready', respond(Effect.gen(function*() {
|
|
59
|
-
const shutdown = yield* ShutdownRegistryTag;
|
|
60
|
-
// Ahead of the cache, deliberately: a report cached a moment before the
|
|
61
|
-
// signal landed would go on answering `200` for up to READY_CACHE_MS,
|
|
62
|
-
// which is precisely the window a rolling restart lives in.
|
|
63
|
-
if (yield* shutdown.terminating) {
|
|
64
|
-
return yield* HttpServerResponse.json({
|
|
65
|
-
status: 'terminating',
|
|
66
|
-
service: serviceName
|
|
67
|
-
}, {
|
|
68
|
-
status: 503
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
const report = yield* cachedReport;
|
|
72
|
-
return yield* HttpServerResponse.json(report.ready ? {
|
|
73
|
-
status: 'ready',
|
|
74
|
-
service: serviceName
|
|
75
|
-
} : {
|
|
76
|
-
status: 'degraded',
|
|
77
|
-
service: serviceName,
|
|
78
|
-
failing: report.failing
|
|
79
|
-
}, {
|
|
80
|
-
status: report.ready ? 200 : 503
|
|
81
|
-
});
|
|
82
|
-
})))
|
|
83
|
-
]);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
//# sourceMappingURL=health-routes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/health-routes.ts"],"sourcesContent":["import type { HealthReport } from '@entifix/business';\nimport { HealthRegistryTag, ShutdownRegistryTag } from '@entifix/business';\nimport { Effect, Ref } from 'effect';\nimport { HttpRouter, HttpServerResponse } from 'effect/http';\n\nimport { respond } from './respond.js';\n\n/**\n * How long a readiness result is reused. These endpoints are unauthenticated by\n * necessity (a probe cannot hold a session), so without a cache every request\n * would reach Mongo — a cheap lever for anyone who can reach the port, and\n * noise in the datastore's own metrics.\n */\nconst READY_CACHE_MS = 1_000;\n\ninterface CacheEntry {\n readonly at: number;\n readonly report: HealthReport;\n}\n\n/**\n * The probe endpoints, as a route layer to merge beside a service's own.\n *\n * - `GET /api/health` — the original endpoint, unchanged. Kept because\n * Playwright's `readyPath` and existing tooling point at it.\n * - `GET /api/health/live` — **liveness**. Answers from the process alone: no\n * datastore, no config-service, no session. This is deliberate and load\n * bearing. A liveness probe that checks dependencies turns a Mongo blip into\n * \"Kubernetes restarts every replica\", which is an outage the probe caused.\n * - `GET /api/health/ready` — **readiness**: `200` when every registered probe\n * passes, `503 {status:'degraded', failing:[…]}` otherwise. Kubernetes pulls\n * a not-ready pod out of the load balancer without killing it, which is what\n * a reconnecting client wants. A process that has begun terminating answers\n * `503 {status:'terminating'}` instead, **before** any probe runs: nothing is\n * failing, and running the probes would ask a closing pool a question whose\n * answer changes nothing.\n *\n * The failing list carries probe **names** only — never a URI, host, or driver\n * message. This endpoint answers anyone who can reach the port.\n */\n// The return type is inferred rather than annotated: `HttpServerResponse.json`\n// widens the routes' error channel with `HttpBodyError`, and spelling that out\n// here would only duplicate what the platform types already say.\nexport const healthRoutes = (serviceName: string) => {\n // One cache per server instance (the e2e mock profile boots services\n // in-process, so a module-level cache would leak across them).\n const cache = Ref.makeUnsafe<CacheEntry | null>(null);\n\n const cachedReport = Effect.gen(function* () {\n const now = Date.now();\n const entry = yield* Ref.get(cache);\n if (entry !== null && now - entry.at < READY_CACHE_MS) return entry.report;\n\n const registry = yield* HealthRegistryTag;\n const report = yield* registry.report;\n yield* Ref.set(cache, { at: now, report });\n return report;\n });\n\n return HttpRouter.addAll([\n HttpRouter.route(\n 'GET',\n '/api/health',\n HttpServerResponse.json({ status: 'ok', service: serviceName }),\n ),\n HttpRouter.route(\n 'GET',\n '/api/health/live',\n HttpServerResponse.json({ status: 'live', service: serviceName }),\n ),\n HttpRouter.route(\n 'GET',\n '/api/health/ready',\n respond(\n Effect.gen(function* () {\n const shutdown = yield* ShutdownRegistryTag;\n // Ahead of the cache, deliberately: a report cached a moment before the\n // signal landed would go on answering `200` for up to READY_CACHE_MS,\n // which is precisely the window a rolling restart lives in.\n if (yield* shutdown.terminating) {\n return yield* HttpServerResponse.json(\n { status: 'terminating', service: serviceName },\n { status: 503 },\n );\n }\n\n const report = yield* cachedReport;\n return yield* HttpServerResponse.json(\n report.ready\n ? { status: 'ready', service: serviceName }\n : {\n status: 'degraded',\n service: serviceName,\n failing: report.failing,\n },\n { status: report.ready ? 200 : 503 },\n );\n }),\n ),\n ),\n ]);\n};\n"],"names":["HealthRegistryTag","ShutdownRegistryTag","Effect","Ref","HttpRouter","HttpServerResponse","respond","READY_CACHE_MS","healthRoutes","serviceName","cache","makeUnsafe","cachedReport","gen","now","Date","entry","get","at","report","registry","set","addAll","route","json","status","service","shutdown","terminating","ready","failing"],"mappings":"AACA,SAASA,iBAAiB,EAAEC,mBAAmB,QAAQ,oBAAoB;AAC3E,SAASC,MAAM,EAAEC,GAAG,QAAQ,SAAS;AACrC,SAASC,UAAU,EAAEC,kBAAkB,QAAQ,cAAc;AAE7D,SAASC,OAAO,QAAQ,eAAe;AAEvC;;;;;CAKC,GACD,MAAMC,iBAAiB;AAOvB;;;;;;;;;;;;;;;;;;;CAmBC,GACD,+EAA+E;AAC/E,+EAA+E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U,KAAK,GAAG,MAAM;YAAI;QAEvC;KAGL;AACH,EAAE"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type { BoundSubscription } from '@entifix/business';
|
|
2
|
-
import { HealthRegistryTag, WiringRegistryTag } from '@entifix/business';
|
|
3
|
-
import { HttpRouter } from 'effect/http';
|
|
4
|
-
import { type SharedToken } from './auth/shared-token.js';
|
|
5
|
-
/**
|
|
6
|
-
* The path the wiring document is served at.
|
|
7
|
-
*
|
|
8
|
-
* Two **static** segments, which matters: `HttpRouter` resolves through
|
|
9
|
-
* `find-my-way-ts`, where a static segment beats a parametric one but there is
|
|
10
|
-
* no backtracking once a parametric branch has matched. A `/api/:something`
|
|
11
|
-
* route registered anywhere in the same router would otherwise swallow this one
|
|
12
|
-
* and answer its own `404` — the failure the `$metadata` route hit first.
|
|
13
|
-
*/
|
|
14
|
-
export declare const SERVICE_DESCRIPTION_PATH = "/api/$service";
|
|
15
|
-
/** One thing this process is connected to, named logically. */
|
|
16
|
-
export interface DescribedTarget {
|
|
17
|
-
/** The Store's register name, an exchange, or a service. Never a URI. */
|
|
18
|
-
readonly name: string;
|
|
19
|
-
/** The readiness probe that covers it, so the two documents line up. */
|
|
20
|
-
readonly probe: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* What a service says about its own wiring.
|
|
24
|
-
*
|
|
25
|
-
* Shape, not values — `/api/config` is the sibling that serves the parameters a
|
|
26
|
-
* service was given, redacted. Keeping them apart is deliberate: one is redacted
|
|
27
|
-
* because it holds credentials, the other gated because it holds a map, and
|
|
28
|
-
* merging them forces the stricter rule onto both.
|
|
29
|
-
*/
|
|
30
|
-
export interface ServiceDescription {
|
|
31
|
-
readonly service: string;
|
|
32
|
-
/**
|
|
33
|
-
* The slices this process hosts. More than one means co-deployment
|
|
34
|
-
* — `marketplace-admin-service` runs the `transaction` slice too.
|
|
35
|
-
*/
|
|
36
|
-
readonly slices: readonly string[];
|
|
37
|
-
readonly stores: readonly DescribedTarget[];
|
|
38
|
-
readonly brokers: readonly DescribedTarget[];
|
|
39
|
-
readonly upstreams: readonly DescribedTarget[];
|
|
40
|
-
/** Distinct event names this process has emitted since boot. */
|
|
41
|
-
readonly published: readonly string[];
|
|
42
|
-
/** The bus bindings this process actually made. */
|
|
43
|
-
readonly subscriptions: readonly BoundSubscription[];
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* `GET /api/$service`, as a route layer to merge beside a service's own.
|
|
47
|
-
*
|
|
48
|
-
* **Gated by a shared token**, which the host names. This names every store, exchange and upstream
|
|
49
|
-
* a service has, which is a reconnaissance map rather than diagnostics. The
|
|
50
|
-
* repository's precedent on maps of the model is uniform: `$metadata` answers
|
|
51
|
-
* `404` rather than `403` so it cannot be walked as an oracle, readiness serves
|
|
52
|
-
* probe names only, and `redactConfiguration` blanks anything flagged secret
|
|
53
|
-
* because `/api/config` is unauthenticated. The health endpoints stay open —
|
|
54
|
-
* a probe cannot hold a credential.
|
|
55
|
-
*
|
|
56
|
-
* The token is fleet membership, which is the right shape here: the readers are
|
|
57
|
-
* tooling and CI, not a person and not a browser.
|
|
58
|
-
*
|
|
59
|
-
* **Logical names only.** Nothing in the response is a URI, and emphatically
|
|
60
|
-
* nothing is `tenant_<organizationId>` — the tenant databases are named after
|
|
61
|
-
* organizations, so leaking one turns a wiring document into a customer list.
|
|
62
|
-
* The names come from a probe's `targets`, which are Store register names by
|
|
63
|
-
* construction.
|
|
64
|
-
*/
|
|
65
|
-
export declare const serviceDescriptionRoute: (serviceName: string, slices: readonly string[], guard: SharedToken) => import("effect/Layer").Layer<never, never, HttpRouter.HttpRouter | HttpRouter.Request<"Requires", HealthRegistryTag> | HttpRouter.Request<"Requires", WiringRegistryTag>>;
|
|
66
|
-
//# sourceMappingURL=service-description-route.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-description-route.d.ts","sourceRoot":"","sources":["../src/service-description-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAa,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAsB,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG9E;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AAExD,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,QAAQ,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IAC/C,gEAAgE;IAChE,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,mDAAmD;IACnD,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACtD;AAwCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,uBAAuB,GAClC,aAAa,MAAM,EACnB,QAAQ,SAAS,MAAM,EAAE,EACzB,OAAO,WAAW,8KAYjB,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { HealthRegistryTag, WiringRegistryTag } from '@entifix/business';
|
|
2
|
-
import { Effect } from 'effect';
|
|
3
|
-
import { HttpRouter, HttpServerResponse } from 'effect/http';
|
|
4
|
-
import { requireSharedToken } from './auth/shared-token.js';
|
|
5
|
-
import { respond } from './respond.js';
|
|
6
|
-
/**
|
|
7
|
-
* The path the wiring document is served at.
|
|
8
|
-
*
|
|
9
|
-
* Two **static** segments, which matters: `HttpRouter` resolves through
|
|
10
|
-
* `find-my-way-ts`, where a static segment beats a parametric one but there is
|
|
11
|
-
* no backtracking once a parametric branch has matched. A `/api/:something`
|
|
12
|
-
* route registered anywhere in the same router would otherwise swallow this one
|
|
13
|
-
* and answer its own `404` — the failure the `$metadata` route hit first.
|
|
14
|
-
*/ export const SERVICE_DESCRIPTION_PATH = '/api/$service';
|
|
15
|
-
/**
|
|
16
|
-
* Everything the two registries know, sorted by what it is.
|
|
17
|
-
*
|
|
18
|
-
* Generated from the **health probe registrations**, which is the one source
|
|
19
|
-
* that cannot drift: a service that gains a datastore gains its probe by merging
|
|
20
|
-
* the client's probe layer, so it gains a line here with no edit of its own.
|
|
21
|
-
*/ const describe = (service, slices)=>Effect.gen(function*() {
|
|
22
|
-
const health = yield* HealthRegistryTag;
|
|
23
|
-
const wiring = yield* WiringRegistryTag;
|
|
24
|
-
const probes = yield* health.probes;
|
|
25
|
-
const ofKind = (kind)=>probes.filter((probe)=>probe.kind === kind).flatMap((probe)=>probe.targets.map((name)=>({
|
|
26
|
-
name,
|
|
27
|
-
probe: probe.name
|
|
28
|
-
})));
|
|
29
|
-
return {
|
|
30
|
-
service,
|
|
31
|
-
slices,
|
|
32
|
-
stores: ofKind('datastore'),
|
|
33
|
-
brokers: ofKind('broker'),
|
|
34
|
-
upstreams: ofKind('upstream'),
|
|
35
|
-
published: yield* wiring.published,
|
|
36
|
-
subscriptions: yield* wiring.subscriptions
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
/**
|
|
40
|
-
* `GET /api/$service`, as a route layer to merge beside a service's own.
|
|
41
|
-
*
|
|
42
|
-
* **Gated by a shared token**, which the host names. This names every store, exchange and upstream
|
|
43
|
-
* a service has, which is a reconnaissance map rather than diagnostics. The
|
|
44
|
-
* repository's precedent on maps of the model is uniform: `$metadata` answers
|
|
45
|
-
* `404` rather than `403` so it cannot be walked as an oracle, readiness serves
|
|
46
|
-
* probe names only, and `redactConfiguration` blanks anything flagged secret
|
|
47
|
-
* because `/api/config` is unauthenticated. The health endpoints stay open —
|
|
48
|
-
* a probe cannot hold a credential.
|
|
49
|
-
*
|
|
50
|
-
* The token is fleet membership, which is the right shape here: the readers are
|
|
51
|
-
* tooling and CI, not a person and not a browser.
|
|
52
|
-
*
|
|
53
|
-
* **Logical names only.** Nothing in the response is a URI, and emphatically
|
|
54
|
-
* nothing is `tenant_<organizationId>` — the tenant databases are named after
|
|
55
|
-
* organizations, so leaking one turns a wiring document into a customer list.
|
|
56
|
-
* The names come from a probe's `targets`, which are Store register names by
|
|
57
|
-
* construction.
|
|
58
|
-
*/ export const serviceDescriptionRoute = (serviceName, slices, guard)=>HttpRouter.add('GET', SERVICE_DESCRIPTION_PATH, respond(requireSharedToken(guard)(Effect.flatMap(describe(serviceName, slices), (description)=>HttpServerResponse.json(description)))));
|
|
59
|
-
|
|
60
|
-
//# sourceMappingURL=service-description-route.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/service-description-route.ts"],"sourcesContent":["import type { BoundSubscription, ProbeKind } from '@entifix/business';\nimport { HealthRegistryTag, WiringRegistryTag } from '@entifix/business';\nimport { Effect } from 'effect';\nimport { HttpRouter, HttpServerResponse } from 'effect/http';\n\nimport { requireSharedToken, type SharedToken } from './auth/shared-token.js';\nimport { respond } from './respond.js';\n\n/**\n * The path the wiring document is served at.\n *\n * Two **static** segments, which matters: `HttpRouter` resolves through\n * `find-my-way-ts`, where a static segment beats a parametric one but there is\n * no backtracking once a parametric branch has matched. A `/api/:something`\n * route registered anywhere in the same router would otherwise swallow this one\n * and answer its own `404` — the failure the `$metadata` route hit first.\n */\nexport const SERVICE_DESCRIPTION_PATH = '/api/$service';\n\n/** One thing this process is connected to, named logically. */\nexport interface DescribedTarget {\n /** The Store's register name, an exchange, or a service. Never a URI. */\n readonly name: string;\n /** The readiness probe that covers it, so the two documents line up. */\n readonly probe: string;\n}\n\n/**\n * What a service says about its own wiring.\n *\n * Shape, not values — `/api/config` is the sibling that serves the parameters a\n * service was given, redacted. Keeping them apart is deliberate: one is redacted\n * because it holds credentials, the other gated because it holds a map, and\n * merging them forces the stricter rule onto both.\n */\nexport interface ServiceDescription {\n readonly service: string;\n /**\n * The slices this process hosts. More than one means co-deployment\n * — `marketplace-admin-service` runs the `transaction` slice too.\n */\n readonly slices: readonly string[];\n readonly stores: readonly DescribedTarget[];\n readonly brokers: readonly DescribedTarget[];\n readonly upstreams: readonly DescribedTarget[];\n /** Distinct event names this process has emitted since boot. */\n readonly published: readonly string[];\n /** The bus bindings this process actually made. */\n readonly subscriptions: readonly BoundSubscription[];\n}\n\n/**\n * Everything the two registries know, sorted by what it is.\n *\n * Generated from the **health probe registrations**, which is the one source\n * that cannot drift: a service that gains a datastore gains its probe by merging\n * the client's probe layer, so it gains a line here with no edit of its own.\n */\nconst describe = (\n service: string,\n slices: readonly string[],\n): Effect.Effect<\n ServiceDescription,\n never,\n HealthRegistryTag | WiringRegistryTag\n> =>\n Effect.gen(function* () {\n const health = yield* HealthRegistryTag;\n const wiring = yield* WiringRegistryTag;\n const probes = yield* health.probes;\n\n const ofKind = (kind: ProbeKind): readonly DescribedTarget[] =>\n probes\n .filter(probe => probe.kind === kind)\n .flatMap(probe =>\n probe.targets.map(name => ({ name, probe: probe.name })),\n );\n\n return {\n service,\n slices,\n stores: ofKind('datastore'),\n brokers: ofKind('broker'),\n upstreams: ofKind('upstream'),\n published: yield* wiring.published,\n subscriptions: yield* wiring.subscriptions,\n };\n });\n\n/**\n * `GET /api/$service`, as a route layer to merge beside a service's own.\n *\n * **Gated by a shared token**, which the host names. This names every store, exchange and upstream\n * a service has, which is a reconnaissance map rather than diagnostics. The\n * repository's precedent on maps of the model is uniform: `$metadata` answers\n * `404` rather than `403` so it cannot be walked as an oracle, readiness serves\n * probe names only, and `redactConfiguration` blanks anything flagged secret\n * because `/api/config` is unauthenticated. The health endpoints stay open —\n * a probe cannot hold a credential.\n *\n * The token is fleet membership, which is the right shape here: the readers are\n * tooling and CI, not a person and not a browser.\n *\n * **Logical names only.** Nothing in the response is a URI, and emphatically\n * nothing is `tenant_<organizationId>` — the tenant databases are named after\n * organizations, so leaking one turns a wiring document into a customer list.\n * The names come from a probe's `targets`, which are Store register names by\n * construction.\n */\nexport const serviceDescriptionRoute = (\n serviceName: string,\n slices: readonly string[],\n guard: SharedToken,\n) =>\n HttpRouter.add(\n 'GET',\n SERVICE_DESCRIPTION_PATH,\n respond(\n requireSharedToken(guard)(\n Effect.flatMap(describe(serviceName, slices), description =>\n HttpServerResponse.json(description),\n ),\n ),\n ),\n );\n"],"names":["HealthRegistryTag","WiringRegistryTag","Effect","HttpRouter","HttpServerResponse","requireSharedToken","respond","SERVICE_DESCRIPTION_PATH","describe","service","slices","gen","health","wiring","probes","ofKind","kind","filter","probe","flatMap","targets","map","name","stores","brokers","upstreams","published","subscriptions","serviceDescriptionRoute","serviceName","guard","add","description","json"],"mappings":"AACA,SAASA,iBAAiB,EAAEC,iBAAiB,QAAQ,oBAAoB;AACzE,SAASC,MAAM,QAAQ,SAAS;AAChC,SAASC,UAAU,EAAEC,kBAAkB,QAAQ,cAAc;AAE7D,SAASC,kBAAkB,QAA0B,yBAAyB;AAC9E,SAASC,OAAO,QAAQ,eAAe;AAEvC;;;;;;;;CAQC,GACD,OAAO,MAAMC,2BAA2B,gBAAgB;AAkCxD;;;;;;CAMC,GACD,MAAMC,WAAW,CACfC,SACAC,SAMAR,OAAOS,GAAG,CAAC;QACT,MAAMC,SAAS,OAAOZ;QACtB,MAAMa,SAAS,OAAOZ;QACtB,MAAMa,SAAS,OAAOF,OAAOE,MAAM;QAEnC,MAAMC,SAAS,CAACC,OACdF,OACGG,MAAM,CAACC,CAAAA,QAASA,MAAMF,IAAI,KAAKA,MAC/BG,OAAO,CAACD,CAAAA,QACPA,MAAME,OAAO,CAACC,GAAG,CAACC,CAAAA,OAAS,CAAA;wBAAEA;wBAAMJ,OAAOA,MAAMI,IAAI;oBAAC,CAAA;QAG3D,OAAO;YACLb;YACAC;YACAa,QAAQR,OAAO;YACfS,SAAST,OAAO;YAChBU,WAAWV,OAAO;YAClBW,WAAW,OAAOb,OAAOa,SAAS;YAClCC,eAAe,OAAOd,OAAOc,aAAa;QAC5C;IACF;AAEF;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,0BAA0B,CACrCC,aACAnB,QACAoB,QAEA3B,WAAW4B,GAAG,CACZ,OACAxB,0BACAD,QACED,mBAAmByB,OACjB5B,OAAOiB,OAAO,CAACX,SAASqB,aAAanB,SAASsB,CAAAA,cAC5C5B,mBAAmB6B,IAAI,CAACD,iBAI9B"}
|