@polygonlabs/example-schemas 0.0.0 → 1.2.4

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAQ9D,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yDAgBD,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Registry composition for the Example REST API.
3
+ *
4
+ * `TypedRegistry` accumulates registered operations and security schemes
5
+ * into its type via chained method returns — `registerPath`,
6
+ * `registerSecurityScheme`, and `with(fn)` each return a `TypedRegistry`
7
+ * narrowed with what was just registered. The chain's final value is what
8
+ * `buildRegistry` returns; downstream consumers read the accumulated
9
+ * manifest via `OperationsOf<typeof buildRegistry>`.
10
+ *
11
+ * To add a new route: append a `.registerPath({...})` call inside the
12
+ * relevant per-domain helper under `./routes/`, or add a new domain
13
+ * helper and `.with(addNewDomainRoutes)` here. Nothing else needs
14
+ * updating — the OpenAPI spec, the codegen'd client, the server's
15
+ * request/response validation, and the typed handler binding all derive
16
+ * from the registry's accumulated type.
17
+ */
18
+ import { TypedRegistry } from '@polygonlabs/openapi-registry';
19
+ import { addBlockRoutes } from "./routes/blocks.js";
20
+ import { addCoreRoutes } from "./routes/core.js";
21
+ import { addEventRoutes } from "./routes/events.js";
22
+ import { addMessageRoutes } from "./routes/messages.js";
23
+ import { addWidgetRoutes } from "./routes/widgets.js";
24
+ export const buildRegistry = () => new TypedRegistry()
25
+ // Single security scheme demonstrating auth flow end-to-end. Operations
26
+ // opt in by declaring `security: [{ ApiKeyAuth: [] }]`; the registry-driven
27
+ // router then requires an `ApiKeyAuth` handler at compile time and runs
28
+ // it before request validation.
29
+ .registerSecurityScheme('ApiKeyAuth', {
30
+ type: 'apiKey',
31
+ in: 'header',
32
+ name: 'x-api-key',
33
+ description: 'Shared secret. Required on operations declaring ApiKeyAuth.'
34
+ })
35
+ .with(addCoreRoutes)
36
+ .with(addBlockRoutes)
37
+ .with(addMessageRoutes)
38
+ .with(addWidgetRoutes)
39
+ .with(addEventRoutes);
40
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,IAAI,aAAa,EAAE;IACjB,wEAAwE;IACxE,4EAA4E;IAC5E,wEAAwE;IACxE,gCAAgC;KAC/B,sBAAsB,CAAC,YAAY,EAAE;IACpC,IAAI,EAAE,QAAQ;IACd,EAAE,EAAE,QAAQ;IACZ,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,6DAA6D;CAC3E,CAAC;KACD,IAAI,CAAC,aAAa,CAAC;KACnB,IAAI,CAAC,cAAc,CAAC;KACpB,IAAI,CAAC,gBAAgB,CAAC;KACtB,IAAI,CAAC,eAAe,CAAC;KACrB,IAAI,CAAC,cAAc,CAAC,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Block-related routes — polled latest block number and the codec-on-path
3
+ * stress test (`Int64Codec` on `:blockNumber`).
4
+ */
5
+ import type { RouteWithOpId, TypedRegistry } from '@polygonlabs/openapi-registry';
6
+ /**
7
+ * Generic over the parent's `Ops` and `Schemes` so this helper preserves
8
+ * everything `.with(addBlockRoutes)` was called on. Each `.registerPath`
9
+ * narrows the chain; the final return carries the cumulative narrow back
10
+ * out to whatever the outer `.with(...)` is composing into.
11
+ */
12
+ export declare const addBlockRoutes: <Ops extends Record<string, RouteWithOpId>, Schemes extends Record<string, true>>(r: TypedRegistry<Ops, Schemes>) => TypedRegistry<Ops & {
13
+ getBlockNumber: import("@polygonlabs/openapi-registry").MergedRoute<{
14
+ readonly operationId: "getBlockNumber";
15
+ readonly method: "get";
16
+ readonly path: "/api/block-number";
17
+ readonly summary: "Current block number";
18
+ readonly description: "Returns the latest block number from the configured RPC endpoint.";
19
+ readonly responses: {
20
+ readonly 200: {
21
+ readonly description: "Latest block number";
22
+ readonly content: {
23
+ readonly 'application/json': {
24
+ readonly schema: import("zod").ZodObject<{
25
+ blockNumber: import("zod").ZodCodec<import("zod").ZodString, import("zod").ZodBigIntFormat>;
26
+ }, import("zod/v4/core").$strip>;
27
+ };
28
+ };
29
+ };
30
+ };
31
+ }, import("@polygonlabs/openapi-registry").DefaultErrors>;
32
+ } & {
33
+ getBlockMetadata: import("@polygonlabs/openapi-registry").MergedRoute<{
34
+ readonly operationId: "getBlockMetadata";
35
+ readonly method: "get";
36
+ readonly path: "/api/blocks/{blockNumber}";
37
+ readonly summary: "Block metadata by height";
38
+ readonly description: "Looks up a block by its height via RPC and returns header metadata.";
39
+ readonly security: [{
40
+ readonly ApiKeyAuth: [];
41
+ }];
42
+ readonly request: {
43
+ readonly params: import("zod").ZodObject<{
44
+ blockNumber: import("zod").ZodCodec<import("zod").ZodString, import("zod").ZodBigIntFormat>;
45
+ }, import("zod/v4/core").$strip>;
46
+ };
47
+ readonly responses: {
48
+ readonly 200: {
49
+ readonly description: "Block metadata";
50
+ readonly content: {
51
+ readonly 'application/json': {
52
+ readonly schema: import("zod").ZodObject<{
53
+ number: import("zod").ZodCodec<import("zod").ZodString, import("zod").ZodBigIntFormat>;
54
+ hash: import("zod").ZodString;
55
+ parentHash: import("zod").ZodString;
56
+ timestamp: import("zod").ZodCodec<import("zod").ZodString, import("zod").ZodBigIntFormat>;
57
+ }, import("zod/v4/core").$strip>;
58
+ };
59
+ };
60
+ };
61
+ readonly 404: {
62
+ readonly description: "Block not found";
63
+ readonly content: {
64
+ readonly 'application/json': {
65
+ readonly schema: import("zod").ZodObject<{
66
+ error: import("zod").ZodLiteral<true>;
67
+ message: import("zod").ZodString;
68
+ info: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
69
+ }, import("zod/v4/core").$strip>;
70
+ };
71
+ };
72
+ };
73
+ };
74
+ }, import("@polygonlabs/openapi-registry").DefaultErrors>;
75
+ }, Schemes, import("@polygonlabs/openapi-registry").DefaultErrors>;
76
+ //# sourceMappingURL=blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/routes/blocks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AASlF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACzB,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EACzC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAEpC,GAAG,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kEAoD1B,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Block-related routes — polled latest block number and the codec-on-path
3
+ * stress test (`Int64Codec` on `:blockNumber`).
4
+ */
5
+ // Renamed to match the OpenAPI registered name (`ErrorResponse`) — the
6
+ // codegen plugin emits imports keyed off that, not the upstream binding
7
+ // name. Re-exported under the same alias from the package barrel.
8
+ import { ErrorResponseSchema as ErrorResponse } from '@polygonlabs/openapi-registry/error-schemas';
9
+ import { BlockMetadata, BlockNumberPathParams, BlockNumberResponse } from "../schemas.js";
10
+ /**
11
+ * Generic over the parent's `Ops` and `Schemes` so this helper preserves
12
+ * everything `.with(addBlockRoutes)` was called on. Each `.registerPath`
13
+ * narrows the chain; the final return carries the cumulative narrow back
14
+ * out to whatever the outer `.with(...)` is composing into.
15
+ */
16
+ export const addBlockRoutes = (r) => r
17
+ .registerPath({
18
+ operationId: 'getBlockNumber',
19
+ method: 'get',
20
+ path: '/api/block-number',
21
+ summary: 'Current block number',
22
+ description: 'Returns the latest block number from the configured RPC endpoint.',
23
+ responses: {
24
+ 200: {
25
+ description: 'Latest block number',
26
+ content: { 'application/json': { schema: BlockNumberResponse } }
27
+ }
28
+ }
29
+ })
30
+ // Codec-on-path-param stress test: `:blockNumber` is `Int64Codec`. The
31
+ // wire shape is a digit string; the runtime shape on both client and
32
+ // server is `bigint`. The input schema (`BlockNumberPathParams`) is
33
+ // registered with a refId so the @polygonlabs/zod-to-openapi-heyapi
34
+ // plugin can emit a runtime-shaped `${Op}Input` type and an input
35
+ // transformer that runs `z.encode(BlockNumberPathParams, value)` —
36
+ // callers pass `bigint` and get a digit string in the URL.
37
+ //
38
+ // Also gated by ApiKeyAuth — exercises the registry router's auth
39
+ // flow. Without a valid x-api-key header the request fails with 401
40
+ // BEFORE the path codec runs, so the response validator never sees a
41
+ // decoded bigint. The 400 (path codec rejection) and 401 (auth
42
+ // failure) response slots are auto-injected by the registry from
43
+ // `request.params` and `security` respectively; only the 404 needs
44
+ // declaring here because it's emitted by the handler, not the
45
+ // framework.
46
+ .registerPath({
47
+ operationId: 'getBlockMetadata',
48
+ method: 'get',
49
+ path: '/api/blocks/{blockNumber}',
50
+ summary: 'Block metadata by height',
51
+ description: 'Looks up a block by its height via RPC and returns header metadata.',
52
+ security: [{ ApiKeyAuth: [] }],
53
+ request: {
54
+ params: BlockNumberPathParams
55
+ },
56
+ responses: {
57
+ 200: {
58
+ description: 'Block metadata',
59
+ content: { 'application/json': { schema: BlockMetadata } }
60
+ },
61
+ 404: {
62
+ description: 'Block not found',
63
+ content: { 'application/json': { schema: ErrorResponse } }
64
+ }
65
+ }
66
+ });
67
+ //# sourceMappingURL=blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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AkB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE;SAC3D;QACD,GAAG,EAAE;YACH,WAAW,EAAE,iBAAiB;YAC9B,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE;SAC3D;KACF;CACF,CAAC,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Core routes — service-level concerns (liveness, hello). These have no
3
+ * dependencies on other registered schemas; they're the smallest possible
4
+ * domain and a useful template for adding others.
5
+ */
6
+ import type { RouteWithOpId, TypedRegistry } from '@polygonlabs/openapi-registry';
7
+ /**
8
+ * Generic over the parent's `Ops` and `Schemes` so the helper preserves
9
+ * everything the caller had already registered. The chained `registerPath`
10
+ * calls narrow the registry; the return carries the cumulative narrow
11
+ * back through the outer `.with(addCoreRoutes)` call.
12
+ */
13
+ export declare const addCoreRoutes: <Ops extends Record<string, RouteWithOpId>, Schemes extends Record<string, true>>(r: TypedRegistry<Ops, Schemes>) => TypedRegistry<Ops & {
14
+ getHealthCheck: import("@polygonlabs/openapi-registry").MergedRoute<{
15
+ readonly operationId: "getHealthCheck";
16
+ readonly method: "get";
17
+ readonly path: "/health-check";
18
+ readonly summary: "Liveness check";
19
+ readonly responses: {
20
+ readonly 200: {
21
+ readonly description: "Service is alive";
22
+ readonly content: {
23
+ readonly 'application/json': {
24
+ readonly schema: import("zod").ZodObject<{
25
+ success: import("zod").ZodBoolean;
26
+ }, import("zod/v4/core").$strip>;
27
+ };
28
+ };
29
+ };
30
+ };
31
+ }, import("@polygonlabs/openapi-registry").DefaultErrors>;
32
+ } & {
33
+ getHello: import("@polygonlabs/openapi-registry").MergedRoute<{
34
+ readonly operationId: "getHello";
35
+ readonly method: "get";
36
+ readonly path: "/api/hello";
37
+ readonly summary: "Hello world";
38
+ readonly responses: {
39
+ readonly 200: {
40
+ readonly description: "Greeting response";
41
+ readonly content: {
42
+ readonly 'application/json': {
43
+ readonly schema: import("zod").ZodObject<{
44
+ message: import("zod").ZodString;
45
+ }, import("zod/v4/core").$strip>;
46
+ };
47
+ };
48
+ };
49
+ };
50
+ }, import("@polygonlabs/openapi-registry").DefaultErrors>;
51
+ }, Schemes, import("@polygonlabs/openapi-registry").DefaultErrors>;
52
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/routes/core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAIlF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EACzC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAEpC,GAAG,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kEA0B1B,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Core routes — service-level concerns (liveness, hello). These have no
3
+ * dependencies on other registered schemas; they're the smallest possible
4
+ * domain and a useful template for adding others.
5
+ */
6
+ import { HealthCheckResponse, HelloResponse } from "../schemas.js";
7
+ /**
8
+ * Generic over the parent's `Ops` and `Schemes` so the helper preserves
9
+ * everything the caller had already registered. The chained `registerPath`
10
+ * calls narrow the registry; the return carries the cumulative narrow
11
+ * back through the outer `.with(addCoreRoutes)` call.
12
+ */
13
+ export const addCoreRoutes = (r) => r
14
+ .registerPath({
15
+ operationId: 'getHealthCheck',
16
+ method: 'get',
17
+ path: '/health-check',
18
+ summary: 'Liveness check',
19
+ responses: {
20
+ 200: {
21
+ description: 'Service is alive',
22
+ content: { 'application/json': { schema: HealthCheckResponse } }
23
+ }
24
+ }
25
+ })
26
+ .registerPath({
27
+ operationId: 'getHello',
28
+ method: 'get',
29
+ path: '/api/hello',
30
+ summary: 'Hello world',
31
+ responses: {
32
+ 200: {
33
+ description: 'Greeting response',
34
+ content: { 'application/json': { schema: HelloResponse } }
35
+ }
36
+ }
37
+ });
38
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/routes/core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAI3B,CAA8B,EAC9B,EAAE,CACF,CAAC;KACE,YAAY,CAAC;IACZ,WAAW,EAAE,gBAAgB;IAC7B,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,gBAAgB;IACzB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,WAAW,EAAE,kBAAkB;YAC/B,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE;SACjE;KACF;CACF,CAAC;KACD,YAAY,CAAC;IACZ,WAAW,EAAE,UAAU;IACvB,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,aAAa;IACtB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,WAAW,EAAE,mBAAmB;YAChC,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE;SAC3D;KACF;CACF,CAAC,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Event route — the read side of the indexer→db→REST showcase. `GET /events`
3
+ * serves the decoded on-chain logs that `example-indexer` wrote to `example-db`
4
+ * via `@polygonlabs/viem-event-watcher`. An ordinary registry GET with optional
5
+ * equality filters and opaque-cursor pagination.
6
+ *
7
+ * 400 (query validation failure) is auto-injected from `request.query`.
8
+ */
9
+ import type { RouteWithOpId, TypedRegistry } from '@polygonlabs/openapi-registry';
10
+ export declare const addEventRoutes: <Ops extends Record<string, RouteWithOpId>, Schemes extends Record<string, true>>(r: TypedRegistry<Ops, Schemes>) => TypedRegistry<Ops & {
11
+ listEvents: import("@polygonlabs/openapi-registry").MergedRoute<{
12
+ readonly operationId: "listEvents";
13
+ readonly method: "get";
14
+ readonly path: "/events";
15
+ readonly summary: "List indexed on-chain events";
16
+ readonly description: string;
17
+ readonly request: {
18
+ readonly query: import("zod").ZodObject<{
19
+ chain: import("zod").ZodOptional<import("zod").ZodCodec<import("zod").ZodString, import("zod").ZodInt>>;
20
+ contractAddress: import("zod").ZodOptional<import("zod").ZodString>;
21
+ eventName: import("zod").ZodOptional<import("zod").ZodString>;
22
+ cursor: import("zod").ZodOptional<import("zod").ZodString>;
23
+ limit: import("zod").ZodOptional<import("zod").ZodCodec<import("zod").ZodString, import("zod").ZodNumber>>;
24
+ }, import("zod/v4/core").$strip>;
25
+ };
26
+ readonly responses: {
27
+ readonly 200: {
28
+ readonly description: "Page of indexed events";
29
+ readonly content: {
30
+ readonly 'application/json': {
31
+ readonly schema: import("zod").ZodObject<{
32
+ items: import("zod").ZodArray<import("zod").ZodObject<{
33
+ id: import("zod").ZodString;
34
+ chain: import("zod").ZodNumber;
35
+ contractAddress: import("zod").ZodString;
36
+ eventName: import("zod").ZodString;
37
+ blockNumber: import("zod").ZodNumber;
38
+ transactionIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
39
+ txHash: import("zod").ZodString;
40
+ logIndex: import("zod").ZodNumber;
41
+ args: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean]>>;
42
+ indexedAt: import("zod").ZodNumber;
43
+ }, import("zod/v4/core").$strip>>;
44
+ nextCursor: import("zod").ZodNullable<import("zod").ZodString>;
45
+ }, import("zod/v4/core").$strip>;
46
+ };
47
+ };
48
+ };
49
+ readonly 422: {
50
+ readonly description: "Malformed pagination cursor";
51
+ readonly content: {
52
+ readonly 'application/json': {
53
+ readonly schema: import("zod").ZodObject<{
54
+ error: import("zod").ZodLiteral<true>;
55
+ message: import("zod").ZodString;
56
+ info: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
57
+ }, import("zod/v4/core").$strip>;
58
+ };
59
+ };
60
+ };
61
+ };
62
+ }, import("@polygonlabs/openapi-registry").DefaultErrors>;
63
+ }, Schemes, import("@polygonlabs/openapi-registry").DefaultErrors>;
64
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/routes/events.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAMlF,eAAO,MAAM,cAAc,GACzB,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EACzC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAEpC,GAAG,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kEA2B5B,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Event route — the read side of the indexer→db→REST showcase. `GET /events`
3
+ * serves the decoded on-chain logs that `example-indexer` wrote to `example-db`
4
+ * via `@polygonlabs/viem-event-watcher`. An ordinary registry GET with optional
5
+ * equality filters and opaque-cursor pagination.
6
+ *
7
+ * 400 (query validation failure) is auto-injected from `request.query`.
8
+ */
9
+ import { ErrorResponseSchema as ErrorResponse } from '@polygonlabs/openapi-registry/error-schemas';
10
+ import { EventList, ListEventsQuery } from "../schemas.js";
11
+ export const addEventRoutes = (r) => r.registerPath({
12
+ operationId: 'listEvents',
13
+ method: 'get',
14
+ path: '/events',
15
+ summary: 'List indexed on-chain events',
16
+ description: 'Returns decoded events indexed by example-indexer, newest-first, with ' +
17
+ 'optional chain / contractAddress / eventName filters and opaque-cursor ' +
18
+ 'pagination.',
19
+ request: {
20
+ query: ListEventsQuery
21
+ },
22
+ responses: {
23
+ 200: {
24
+ description: 'Page of indexed events',
25
+ content: { 'application/json': { schema: EventList } }
26
+ },
27
+ // Handler-emitted: a syntactically valid `cursor` string that doesn't
28
+ // decode to a usable cursor. Distinct from the 400 the registry
29
+ // auto-injects for query-schema validation failures.
30
+ 422: {
31
+ description: 'Malformed pagination cursor',
32
+ content: { 'application/json': { schema: ErrorResponse } }
33
+ }
34
+ }
35
+ });
36
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/routes/events.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,mBAAmB,IAAI,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEnG,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE3D,MAAM,CAAC,MAAM,cAAc,GAAG,CAI5B,CAA8B,EAC9B,EAAE,CACF,CAAC,CAAC,YAAY,CAAC;IACb,WAAW,EAAE,YAAY;IACzB,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,8BAA8B;IACvC,WAAW,EACT,wEAAwE;QACxE,yEAAyE;QACzE,aAAa;IACf,OAAO,EAAE;QACP,KAAK,EAAE,eAAe;KACvB;IACD,SAAS,EAAE;QACT,GAAG,EAAE;YACH,WAAW,EAAE,wBAAwB;YACrC,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;SACvD;QACD,sEAAsE;QACtE,gEAAgE;QAChE,qDAAqD;QACrD,GAAG,EAAE;YACH,WAAW,EAAE,6BAA6B;YAC1C,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE;SAC3D;KACF;CACF,CAAC,CAAC"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Message-related routes — CRUD on the in-memory message store. Exercises
3
+ * body validation, query strings, UUID path params, and a 404 response shape
4
+ * distinct from the 200.
5
+ */
6
+ import { z } from 'zod';
7
+ import type { RouteWithOpId, TypedRegistry } from '@polygonlabs/openapi-registry';
8
+ export declare const addMessageRoutes: <Ops extends Record<string, RouteWithOpId>, Schemes extends Record<string, true>>(r: TypedRegistry<Ops, Schemes>) => TypedRegistry<Ops & {
9
+ createMessage: import("@polygonlabs/openapi-registry").MergedRoute<{
10
+ readonly operationId: "createMessage";
11
+ readonly method: "post";
12
+ readonly path: "/api/messages";
13
+ readonly summary: "Create a message";
14
+ readonly request: {
15
+ readonly body: {
16
+ readonly content: {
17
+ readonly 'application/json': {
18
+ readonly schema: z.ZodObject<{
19
+ text: z.ZodString;
20
+ }, z.core.$strip>;
21
+ };
22
+ };
23
+ };
24
+ };
25
+ readonly responses: {
26
+ readonly 200: {
27
+ readonly description: "Message created";
28
+ readonly content: {
29
+ readonly 'application/json': {
30
+ readonly schema: z.ZodObject<{
31
+ id: z.ZodUUID;
32
+ text: z.ZodString;
33
+ createdAt: z.ZodCodec<z.ZodISODateTime, z.ZodDate>;
34
+ }, z.core.$strip>;
35
+ };
36
+ };
37
+ };
38
+ };
39
+ }, import("@polygonlabs/openapi-registry").DefaultErrors>;
40
+ } & {
41
+ listMessages: import("@polygonlabs/openapi-registry").MergedRoute<{
42
+ readonly operationId: "listMessages";
43
+ readonly method: "get";
44
+ readonly path: "/api/messages";
45
+ readonly summary: "List messages";
46
+ readonly request: {
47
+ readonly query: z.ZodObject<{
48
+ cursor: z.ZodOptional<z.ZodString>;
49
+ since: z.ZodOptional<z.ZodCodec<z.ZodISODateTime, z.ZodDate>>;
50
+ }, z.core.$strip>;
51
+ };
52
+ readonly responses: {
53
+ readonly 200: {
54
+ readonly description: "Page of messages";
55
+ readonly content: {
56
+ readonly 'application/json': {
57
+ readonly schema: z.ZodObject<{
58
+ items: z.ZodArray<z.ZodObject<{
59
+ id: z.ZodUUID;
60
+ text: z.ZodString;
61
+ createdAt: z.ZodCodec<z.ZodISODateTime, z.ZodDate>;
62
+ }, z.core.$strip>>;
63
+ nextCursor: z.ZodNullable<z.ZodString>;
64
+ }, z.core.$strip>;
65
+ };
66
+ };
67
+ };
68
+ };
69
+ }, import("@polygonlabs/openapi-registry").DefaultErrors>;
70
+ } & {
71
+ getMessage: import("@polygonlabs/openapi-registry").MergedRoute<{
72
+ readonly operationId: "getMessage";
73
+ readonly method: "get";
74
+ readonly path: "/api/messages/{id}";
75
+ readonly summary: "Get a message by id";
76
+ readonly request: {
77
+ readonly params: z.ZodObject<{
78
+ id: z.ZodUUID;
79
+ }, z.core.$strip>;
80
+ };
81
+ readonly responses: {
82
+ readonly 200: {
83
+ readonly description: "Message";
84
+ readonly content: {
85
+ readonly 'application/json': {
86
+ readonly schema: z.ZodObject<{
87
+ id: z.ZodUUID;
88
+ text: z.ZodString;
89
+ createdAt: z.ZodCodec<z.ZodISODateTime, z.ZodDate>;
90
+ }, z.core.$strip>;
91
+ };
92
+ };
93
+ };
94
+ readonly 404: {
95
+ readonly description: "Not found";
96
+ readonly content: {
97
+ readonly 'application/json': {
98
+ readonly schema: z.ZodObject<{
99
+ error: z.ZodLiteral<true>;
100
+ message: z.ZodString;
101
+ info: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
102
+ }, z.core.$strip>;
103
+ };
104
+ };
105
+ };
106
+ };
107
+ }, import("@polygonlabs/openapi-registry").DefaultErrors>;
108
+ }, Schemes, import("@polygonlabs/openapi-registry").DefaultErrors>;
109
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/routes/messages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAMlF,eAAO,MAAM,gBAAgB,GAC3B,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EACzC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAEpC,GAAG,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kEAmE1B,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Message-related routes — CRUD on the in-memory message store. Exercises
3
+ * body validation, query strings, UUID path params, and a 404 response shape
4
+ * distinct from the 200.
5
+ */
6
+ import { z } from 'zod';
7
+ import { ErrorResponseSchema as ErrorResponse } from '@polygonlabs/openapi-registry/error-schemas';
8
+ import { CreateMessageRequest, Message, MessageList, RecentMessagesQuery } from "../schemas.js";
9
+ export const addMessageRoutes = (r) => r
10
+ // 400 (request validation failure) is auto-injected by the registry
11
+ // from `request.body`; the canonical `ValidationErrorResponse` shape
12
+ // it carries is what `@polygonlabs/express`'s request validator
13
+ // actually emits.
14
+ .registerPath({
15
+ operationId: 'createMessage',
16
+ method: 'post',
17
+ path: '/api/messages',
18
+ summary: 'Create a message',
19
+ request: {
20
+ body: { content: { 'application/json': { schema: CreateMessageRequest } } }
21
+ },
22
+ responses: {
23
+ 200: {
24
+ description: 'Message created',
25
+ content: { 'application/json': { schema: Message } }
26
+ }
27
+ }
28
+ })
29
+ // Mixed cursor (string) + `since` (IsoDateCodec.optional()) query schema.
30
+ // `since` is the request-side codec stress test that doesn't round-trip
31
+ // without the plugin's input transformer: `String(date)` produces the
32
+ // locale string, but the server expects ISO 8601. Registering the
33
+ // wrapping object as `RecentMessagesQuery` lets the plugin emit a
34
+ // runtime-shaped `ListMessagesInput['query']` (so callers pass `Date`)
35
+ // plus an input transformer that runs `IsoDateCodec.encode(date)` to
36
+ // produce `'2026-04-28T13:45:00.000Z'` for the URL.
37
+ .registerPath({
38
+ operationId: 'listMessages',
39
+ method: 'get',
40
+ path: '/api/messages',
41
+ summary: 'List messages',
42
+ request: {
43
+ query: RecentMessagesQuery
44
+ },
45
+ responses: {
46
+ 200: {
47
+ description: 'Page of messages',
48
+ content: { 'application/json': { schema: MessageList } }
49
+ }
50
+ }
51
+ })
52
+ // 400 (path UUID validation failure) is auto-injected from
53
+ // `request.params`. 404 is handler-emitted (`NotFound` from
54
+ // `@polygonlabs/verror`), so it's declared explicitly with the
55
+ // canonical `ErrorResponse` shape.
56
+ .registerPath({
57
+ operationId: 'getMessage',
58
+ method: 'get',
59
+ path: '/api/messages/{id}',
60
+ summary: 'Get a message by id',
61
+ request: {
62
+ params: z.object({ id: z.uuid() })
63
+ },
64
+ responses: {
65
+ 200: {
66
+ description: 'Message',
67
+ content: { 'application/json': { schema: Message } }
68
+ },
69
+ 404: {
70
+ description: 'Not found',
71
+ content: { 'application/json': { schema: ErrorResponse } }
72
+ }
73
+ }
74
+ });
75
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/routes/messages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,mBAAmB,IAAI,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEnG,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEhG,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAI9B,CAA8B,EAC9B,EAAE,CACF,CAAC;IACC,oEAAoE;IACpE,qEAAqE;IACrE,gEAAgE;IAChE,kBAAkB;KACjB,YAAY,CAAC;IACZ,WAAW,EAAE,eAAe;IAC5B,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE;QACP,IAAI,EAAE,EAAE,OAAO,EAAE,E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