@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.
- package/CHANGELOG.md +248 -0
- package/LICENSE +201 -0
- package/MIGRATION.md +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.d.ts +903 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +40 -0
- package/dist/registry.js.map +1 -0
- package/dist/routes/blocks.d.ts +76 -0
- package/dist/routes/blocks.d.ts.map +1 -0
- package/dist/routes/blocks.js +67 -0
- package/dist/routes/blocks.js.map +1 -0
- package/dist/routes/core.d.ts +52 -0
- package/dist/routes/core.d.ts.map +1 -0
- package/dist/routes/core.js +38 -0
- package/dist/routes/core.js.map +1 -0
- package/dist/routes/events.d.ts +64 -0
- package/dist/routes/events.d.ts.map +1 -0
- package/dist/routes/events.js +36 -0
- package/dist/routes/events.js.map +1 -0
- package/dist/routes/messages.d.ts +109 -0
- package/dist/routes/messages.d.ts.map +1 -0
- package/dist/routes/messages.js +75 -0
- package/dist/routes/messages.js.map +1 -0
- package/dist/routes/widgets.d.ts +56 -0
- package/dist/routes/widgets.d.ts.map +1 -0
- package/dist/routes/widgets.js +39 -0
- package/dist/routes/widgets.js.map +1 -0
- package/dist/schemas.d.ts +78 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +187 -0
- package/dist/schemas.js.map +1 -0
- package/openapi.json +807 -0
- package/package.json +46 -3
- package/README.md +0 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# @polygonlabs/example-schemas
|
|
2
|
+
|
|
3
|
+
## 1.2.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#94](https://github.com/0xPolygon/apps-team-ts-template/pull/94) [`f2dc54d`](https://github.com/0xPolygon/apps-team-ts-template/commit/f2dc54dcaa9540bfb8775e6642e82111727ce7a5) Thanks [@MaximusHaximus](https://github.com/MaximusHaximus)! - Exercise a release of a public package on the current release workflow.
|
|
8
|
+
|
|
9
|
+
## 1.2.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#73](https://github.com/0xPolygon/apps-team-ts-template/pull/73) [`123ff82`](https://github.com/0xPolygon/apps-team-ts-template/commit/123ff82761b606aaf8f14177e09ee8ef9ad4ffc5) Thanks [@MaximusHaximus](https://github.com/MaximusHaximus)! - Publish @polygonlabs/example-schemas to npm as a public package.
|
|
14
|
+
|
|
15
|
+
## 1.2.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#67](https://github.com/0xPolygon/apps-team-ts-template/pull/67) [`7135bf6`](https://github.com/0xPolygon/apps-team-ts-template/commit/7135bf677ec05e7e13b52e1e603cee7c3ae2c660) Thanks [@MaximusHaximus](https://github.com/MaximusHaximus)! - Adopt the registry-v3 package line
|
|
20
|
+
|
|
21
|
+
Bumps `@polygonlabs/openapi-registry` to ^3.0.0 (generate-time rejection of coercing parameter schemas; configurable standard-error injection), `@polygonlabs/zod-codecs` to ^1.2.0 (`SafeIntegerCodec`), `@polygonlabs/zod-to-openapi-heyapi` to ^2.0.4 (2xx schema violations now surface as `ResponseValidationError`), and `@polygonlabs/express` to ^5.0.0 (registry v3 peer). Generated output is unchanged — the codec-based query parameters landed in the companion change.
|
|
22
|
+
|
|
23
|
+
- [#67](https://github.com/0xPolygon/apps-team-ts-template/pull/67) [`dc581d8`](https://github.com/0xPolygon/apps-team-ts-template/commit/dc581d87abfbc7bf8800ff4e3fb846c3fbb2ce03) Thanks [@MaximusHaximus](https://github.com/MaximusHaximus)! - Replace `z.coerce` query parameters with codecs
|
|
24
|
+
|
|
25
|
+
`ListEventsQuery.chain` now uses `SafeIntegerCodec` from `@polygonlabs/zod-codecs` and `limit` rolls a local range-constrained codec. In zod v4 a coercing schema's input type is `unknown`, so the generated OpenAPI documented these parameters as optional and nullable regardless of intent; `@polygonlabs/openapi-registry` v3 rejects coercing schemas in parameter positions at generate time. The regenerated spec documents the wire honestly (string + pattern) while the validator and generated client expose runtime numbers through the codec machinery.
|
|
26
|
+
|
|
27
|
+
## 1.2.1
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- [#62](https://github.com/0xPolygon/apps-team-ts-template/pull/62) [`90dc551`](https://github.com/0xPolygon/apps-team-ts-template/commit/90dc551650f743fa9ab29084ae52728db6a7c213) Thanks [@MaximusHaximus](https://github.com/MaximusHaximus)! - Ship the LICENSE file inside each package directory
|
|
32
|
+
|
|
33
|
+
The previous release added the Apache-2.0 license at the repo root and
|
|
34
|
+
declared it in package.json, but npm only auto-includes a LICENSE file
|
|
35
|
+
in the packed tarball when it lives in the same directory as the
|
|
36
|
+
package's own package.json. These packages are all private today, but
|
|
37
|
+
this keeps the pattern correct for any package that publishes later.
|
|
38
|
+
|
|
39
|
+
## 1.2.0
|
|
40
|
+
|
|
41
|
+
### Minor Changes
|
|
42
|
+
|
|
43
|
+
- [#55](https://github.com/0xPolygon/apps-team-ts-template/pull/55) [`35e35fa`](https://github.com/0xPolygon/apps-team-ts-template/commit/35e35fa75acba3a2658ec96a17b6ff995c7814f7) Thanks [@MaximusHaximus](https://github.com/MaximusHaximus)! - Add an indexer → shared-db → REST-API showcase built on the new canonical
|
|
44
|
+
`@polygonlabs/viem-event-watcher` package.
|
|
45
|
+
|
|
46
|
+
## What's new
|
|
47
|
+
- **`example-db`** — a Firestore-backed library exposing an `EventStore` of
|
|
48
|
+
decoded on-chain events and a per-chain `CursorStore`. Zod schemas are the
|
|
49
|
+
source of truth, applied as a Firestore converter so every read is validated
|
|
50
|
+
at the boundary.
|
|
51
|
+
- **`example-indexer`** — a deployable service that drives
|
|
52
|
+
`@polygonlabs/viem-event-watcher`'s `streamEvents` to consume a contract's
|
|
53
|
+
logs and persist them to `example-db`, advancing the cursor to each scanned
|
|
54
|
+
batch's high-water-mark. It owns the cursor, restart loop, and logging; the
|
|
55
|
+
watcher uses `eth_getLogs` polling (not `watchEvent`) so log delivery is
|
|
56
|
+
reliable on Polygon bor.
|
|
57
|
+
- **`example-e2e`** — an end-to-end suite that deploys a minimal event-emitter
|
|
58
|
+
contract to a live kurtosis-pos bor devnet, emits events, runs the indexer,
|
|
59
|
+
and asserts they land in `example-db` with the cursor advanced.
|
|
60
|
+
|
|
61
|
+
## Changed
|
|
62
|
+
- **`example-rest-api`** gains `GET /events`, serving the indexed events back
|
|
63
|
+
out of `example-db` with optional filters and opaque-cursor pagination.
|
|
64
|
+
- **`example-schemas`** / **`example-client`** add the `IndexedEvent` /
|
|
65
|
+
`EventList` schemas and the `listEvents` operation (spec + generated client
|
|
66
|
+
regenerated).
|
|
67
|
+
- **`example-rest-api`** now follows the four-layer test doctrine: unit and
|
|
68
|
+
service-integration tests run together under the one `vitest.config.ts`
|
|
69
|
+
(which owns the Firestore-emulator + Redis `globalSetup`), so `pnpm test`
|
|
70
|
+
runs both on every PR. The separate `vitest.integration.config.ts`, the
|
|
71
|
+
`tests/integration/` directory, and the `test:integration` /
|
|
72
|
+
`test:*-integration` scripts are removed — the prior split was the
|
|
73
|
+
antipattern the doctrine replaces. The config now excludes
|
|
74
|
+
`tests/prod-smoke/**` so a bare `pnpm test` can never reach a deployed
|
|
75
|
+
instance.
|
|
76
|
+
- **`example-rest-api`** gains the fourth test tier — a **prod-smoke** suite
|
|
77
|
+
(`tests/prod-smoke/*.prod-smoke.test.ts` + `vitest.prod-smoke.config.ts`)
|
|
78
|
+
that hits a deployed instance over HTTPS and validates each response against
|
|
79
|
+
the route's own Zod schema (`HealthCheckResponse`, `EventList`). It runs only
|
|
80
|
+
via the new `test:prod-smoke` / `test:dev-smoke` scripts, never in CI, and
|
|
81
|
+
skips cleanly when the target URL is unset — so the template now demonstrates
|
|
82
|
+
all four test tiers (unit, service-integration, e2e, prod-smoke).
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- [#60](https://github.com/0xPolygon/apps-team-ts-template/pull/60) [`bcec096`](https://github.com/0xPolygon/apps-team-ts-template/commit/bcec096723b0875b7696ef63251e3580c9bf8e2b) Thanks [@MaximusHaximus](https://github.com/MaximusHaximus)! - Add Apache-2.0 license
|
|
87
|
+
|
|
88
|
+
The repository now ships an Apache License 2.0 `LICENSE` file at the root, and every package declares `"license": "Apache-2.0"` in its `package.json`.
|
|
89
|
+
|
|
90
|
+
## 1.1.0
|
|
91
|
+
|
|
92
|
+
### Minor Changes
|
|
93
|
+
|
|
94
|
+
- b598714: Add a canonical "managed local resource" integration-test example: a cache-aside widget read path where Firestore is the source of truth and Redis is a lookaside cache in front of it.
|
|
95
|
+
|
|
96
|
+
## What's new
|
|
97
|
+
- `GET /api/widgets/{id}` — registry-driven route returning a `Widget`, served via the codegen client. The handler delegates to a `WidgetService` doing cache-aside (Redis hit → return; miss → Firestore → populate cache), and throws `NotFound` for an unknown id.
|
|
98
|
+
- `src/redis.ts` (single-node ioredis, `enableOfflineQueue: false`, `host:port` parse) and `src/firestore.ts` (emulator-aware client). Both clients are built lazily on first widget request so the hermetic unit suite never connects.
|
|
99
|
+
- New env: `REDIS_URL`, `REDIS_CLUSTER`, `FIRESTORE_EMULATOR_HOST`, `GOOGLE_CLOUD_PROJECT_ID` (validated in `src/env.ts`).
|
|
100
|
+
|
|
101
|
+
## The point — one globalSetup owns BOTH resources
|
|
102
|
+
|
|
103
|
+
`vitest.globalSetup.ts` stands up a Firestore emulator AND Redis from one place and shows both discovery styles: Redis via an explicit `REDIS_URL`, Firestore via the SDK-detected `FIRESTORE_EMULATOR_HOST`. Both publish on EPHEMERAL host ports (discovered with `docker compose port`) so concurrent suites never collide on a fixed port. A single gate decides whether to manage Docker, defer to externally-provided resources (CI), or skip for a URL target. Firestore state is cleared per-test (`beforeEach`) for order-independence; the cache isn't, illustrating the stateful-store-vs-cache distinction.
|
|
104
|
+
|
|
105
|
+
Split configs: `vitest.config.ts` stays hermetic (excludes `tests/integration/**`); `vitest.integration.config.ts` carries the globalSetup; `test = test:unit && test:integration`. `.env.test` is committed and non-secret — the `demo-*` Firestore project and Redis need no credentials, so a fresh clone runs `pnpm test` with no setup.
|
|
106
|
+
|
|
107
|
+
The `@polygonlabs/example-schemas` and `@polygonlabs/example-client` packages gain the `Widget` schema and the generated `getWidget` client.
|
|
108
|
+
|
|
109
|
+
## 1.0.0
|
|
110
|
+
|
|
111
|
+
### Major Changes
|
|
112
|
+
|
|
113
|
+
- 95385cf: Adopt the chainable `TypedRegistry` API from `@polygonlabs/openapi-registry` v2 and the `HandlerMapFor` pattern from `@polygonlabs/express` v2.
|
|
114
|
+
|
|
115
|
+
## Breaking changes
|
|
116
|
+
|
|
117
|
+
`@polygonlabs/example-schemas` now composes its registry by chaining `registerPath`, `registerSecurityScheme`, and `with(fn)` on a single inferred-return `TypedRegistry`, instead of the earlier statement-form `registry.registerPath(...); registry.extend(fn);` pattern. The exported `Operations` type is now derived via `OperationsOf<typeof buildRegistry>` from `@polygonlabs/openapi-registry` rather than a hand-rolled conditional type.
|
|
118
|
+
|
|
119
|
+
Per-domain route helpers under `src/routes/` are now generic over both `Ops` and `Schemes`, take a `TypedRegistry`, chain registrations, and return the chain's final value.
|
|
120
|
+
|
|
121
|
+
## Why
|
|
122
|
+
|
|
123
|
+
The new chainable shape removes the function-wrapper-plus-explicit-annotation requirement that the asserts-based API needed for the operation narrow to flow across the export boundary. Consumers can write `export const buildRegistry = () => new TypedRegistry().registerPath(...).with(...)` directly and the inferred return carries the full manifest. `OperationsOf` brands the empty-manifest case as a type-level error, which surfaces the silent failure where every chain return was discarded.
|
|
124
|
+
|
|
125
|
+
`example-rest-api` handlers switch from `defineHandlers<Operations, AppAuthMap>()({ ... })` to `({ ... }) satisfies Partial<HandlerMapFor<typeof buildRegistry, AppAuthMap>>`. `HandlerMapFor` reads the registry-builder type directly so handler bags stay in sync with the registry without an intermediate `Operations` import.
|
|
126
|
+
|
|
127
|
+
See `apps-team-packages/packages/openapi-registry/MIGRATION.md` for the full migration playbook.
|
|
128
|
+
|
|
129
|
+
## 0.3.0
|
|
130
|
+
|
|
131
|
+
### Minor Changes
|
|
132
|
+
|
|
133
|
+
- 155f133: Migrate `example-client` from orval to `@hey-api/openapi-ts` with the registry-driven `@polygonlabs/zod-to-openapi-heyapi` plugin.
|
|
134
|
+
|
|
135
|
+
The generated client now imports the actual `@polygonlabs/example-schemas` Zod schemas the backend uses to validate the wire — instead of regenerating them from the OpenAPI spec — so codecs (`Int64Codec`, `IsoDateCodec`, etc.) round-trip end-to-end. Response transformers run `parseAsync` on every response, so the wire string for `BlockNumberResponse.blockNumber` reaches callers as a `bigint` rather than a `string`.
|
|
136
|
+
|
|
137
|
+
`example-schemas` adopts `@polygonlabs/zod-codecs` for `Int64Codec` (replacing the inline `z.number().int()` block-number type) and renames schema exports to match the registered names the plugin requires (`HealthCheckResponse`, `HelloResponse`, `BlockNumberResponse` — `*Schema` suffix dropped). The pre-existing `BlockNumberResponse` / `HealthCheckResponse` / `HelloResponse` type aliases are gone — derive types via `z.output<typeof Schema>` (or `z.infer`) where needed.
|
|
138
|
+
|
|
139
|
+
Consumers of `example-client`:
|
|
140
|
+
- Configure the singleton client once at app entry: `client.setConfig({ baseUrl })`. The orval `createExampleClient(baseUrl)` factory and the `createExampleQueryHooks(baseUrl)` factory are gone.
|
|
141
|
+
- Call SDK functions directly: `getBlockNumber()`, `getHealthCheck()`, `getHello()` — each returns `{ data, error, ... }` (hey-api's `responseStyle: 'fields'` shape).
|
|
142
|
+
- React: import options factories from `@polygonlabs/example-client/react` and pass to `useQuery`: `useQuery(getBlockNumberOptions())`.
|
|
143
|
+
|
|
144
|
+
- 1acf577: Adopt the registry-driven service architecture from
|
|
145
|
+
`@polygonlabs/openapi-registry` and `@polygonlabs/express`.
|
|
146
|
+
|
|
147
|
+
The same `TypedRegistry` instance now feeds the served OpenAPI spec, the
|
|
148
|
+
runtime Express router, and the codegen'd client — there is no parallel
|
|
149
|
+
"register routes here, also list them in the OpenAPI doc" duplication
|
|
150
|
+
anymore. Operation handlers are bound exhaustively at compile time;
|
|
151
|
+
`security: [{ ApiKeyAuth: [] }]` declarations on a route route through
|
|
152
|
+
declarative `.auth(...)` handlers that run before request validation.
|
|
153
|
+
|
|
154
|
+
## Schemas (`@polygonlabs/example-schemas`)
|
|
155
|
+
- Drop the locally-vendored `TypedRegistry` class; depend on
|
|
156
|
+
`@polygonlabs/openapi-registry@^1.1.0` instead. The class is a drop-in
|
|
157
|
+
superset of `OpenAPIRegistry` and accumulates operations + security
|
|
158
|
+
schemes into the registry's type so downstream consumers (the Express
|
|
159
|
+
router, the codegen plugin) see the literal-typed manifest without a
|
|
160
|
+
separate declaration.
|
|
161
|
+
- Split routes into per-domain helpers under `src/routes/`:
|
|
162
|
+
`addCoreRoutes`, `addBlockRoutes`, `addMessageRoutes`. `buildRegistry()`
|
|
163
|
+
composes them via `registry.extend(addX)`.
|
|
164
|
+
- New schemas: `Message`, `MessageList`, `CreateMessageRequest`,
|
|
165
|
+
`BlockMetadata`, `BlockNumberPathParams`, `RecentMessagesQuery`. The
|
|
166
|
+
last two are raw exports (no `.openapi('Name')` chain) so the
|
|
167
|
+
zod-to-openapi-heyapi plugin's identity-based input lookup picks them
|
|
168
|
+
up at codegen time.
|
|
169
|
+
- `BlockNumberPathParams.blockNumber` and `RecentMessagesQuery.since`
|
|
170
|
+
are the codec-input stress tests: a path param whose runtime shape is
|
|
171
|
+
`bigint` (Int64Codec) and a query param whose runtime shape is `Date`
|
|
172
|
+
(IsoDateCodec).
|
|
173
|
+
- Register an `ApiKeyAuth` security scheme; `getBlockMetadata` declares
|
|
174
|
+
`security: [{ ApiKeyAuth: [] }]`.
|
|
175
|
+
- Re-export the canonical `ErrorResponseSchema` from
|
|
176
|
+
`@polygonlabs/openapi-registry/error-schemas` as `ErrorResponse`. The
|
|
177
|
+
alias is required because the schema is registered under
|
|
178
|
+
`.openapi('ErrorResponse', …)` and the codegen plugin's audit checks
|
|
179
|
+
the binding name matches the registered name.
|
|
180
|
+
|
|
181
|
+
## Client (`@polygonlabs/example-client`)
|
|
182
|
+
- Bump `@polygonlabs/zod-to-openapi-heyapi` to `^1.1.1` for codec-input
|
|
183
|
+
encoding (the input transformer runs `z.encode` before the wire is
|
|
184
|
+
built — so `getBlockMetadata({ path: { blockNumber: 123n } })` and
|
|
185
|
+
`listMessages({ query: { since: new Date(...) } })` both round-trip
|
|
186
|
+
end-to-end).
|
|
187
|
+
- `openapi-ts.config.ts`: drop the `getRefId` option (now identity-based
|
|
188
|
+
inside the plugin) and pass `transformer: true` +
|
|
189
|
+
`includeInEntry: false` on `@hey-api/sdk` so the plugin's wrappers
|
|
190
|
+
replace the auto-emitted barrel exports without collision.
|
|
191
|
+
- `src/index.ts`: re-export the codec-aware SDK functions from
|
|
192
|
+
`./generated/registry-validator.gen.ts` (the pass-through wrappers for
|
|
193
|
+
ops without input codecs come from `./generated/sdk.gen.ts` for
|
|
194
|
+
zero-overhead).
|
|
195
|
+
- Regenerated client reflects all of the above.
|
|
196
|
+
|
|
197
|
+
## Service (`example-rest-api`)
|
|
198
|
+
- Bump to `@polygonlabs/express@^1.1.1` and add
|
|
199
|
+
`@polygonlabs/openapi-registry@^1.1.0`. Replace the imperative
|
|
200
|
+
`Router()` setup with `createRegistryRouter({ registry })` from
|
|
201
|
+
`@polygonlabs/express/registry`. The router materialises every route
|
|
202
|
+
in the typed `Operations` manifest exhaustively — a missing handler
|
|
203
|
+
is a TypeScript error at the wiring site, not a 404 at request time.
|
|
204
|
+
- Per-domain handler bags via `defineHandlers<Operations, AppAuthMap>()`
|
|
205
|
+
under `src/handlers/`: `static.ts`, `network.ts`, `messages.ts`, plus
|
|
206
|
+
the `auth.ts` factory that returns the `ApiKeyAuth` handler. Handlers
|
|
207
|
+
call `getLogger()` from `@polygonlabs/express` instead of threading
|
|
208
|
+
`req.log`.
|
|
209
|
+
- New `MessageStore` service (in-memory cursor-paginated store) backs
|
|
210
|
+
the message routes.
|
|
211
|
+
- `MANAGEMENT_API_KEY` env var validates a non-empty string at startup;
|
|
212
|
+
a request to an `ApiKeyAuth`-gated route without the matching
|
|
213
|
+
`x-api-key` header returns 401 before the request validator runs.
|
|
214
|
+
- Tests updated to send the API-key header on auth-gated calls and to
|
|
215
|
+
assert against the registry validator's error shape
|
|
216
|
+
(`info.body.properties.<field>.errors` from `z.treeifyError`). The
|
|
217
|
+
obsolete local `error-sanitisation.test.ts` is removed; the
|
|
218
|
+
team-standard `createErrorHandler` from `@polygonlabs/express` covers
|
|
219
|
+
that surface.
|
|
220
|
+
- The previous `routes/index.ts` and `errors.ts` are deleted — both
|
|
221
|
+
responsibilities now live in `@polygonlabs/express` and the registry.
|
|
222
|
+
|
|
223
|
+
## CI
|
|
224
|
+
- `MANAGEMENT_API_KEY` flows through the docker-release-trigger so the
|
|
225
|
+
integration-test container has the value the in-process auth handler
|
|
226
|
+
expects. CI uses a throwaway placeholder; production deployments
|
|
227
|
+
inject a real secret via External Secrets Operator.
|
|
228
|
+
|
|
229
|
+
## 0.2.1
|
|
230
|
+
|
|
231
|
+
### Patch Changes
|
|
232
|
+
|
|
233
|
+
- 297dc24: Exercise every package bump through the migrated pipelines-backed workflows (CI, npm release, Docker release). No runtime or API change.
|
|
234
|
+
|
|
235
|
+
## 0.2.0
|
|
236
|
+
|
|
237
|
+
### Minor Changes
|
|
238
|
+
|
|
239
|
+
- a2de5fe: Add `example-schemas` and `example-client` packages to implement the three-package monorepo pattern.
|
|
240
|
+
|
|
241
|
+
`example-schemas` publishes Zod response schemas, an OpenAPI registry, and a committed `openapi.json`
|
|
242
|
+
spec. `example-client` consumes the spec via orval to generate a typed fetch client and TanStack
|
|
243
|
+
Query hooks. `example-rest-api` now imports schemas from the shared package and its tests assert
|
|
244
|
+
against the typed client. `example-frontend` uses the client's React hooks to display the current
|
|
245
|
+
block number.
|
|
246
|
+
|
|
247
|
+
This establishes the template as the canonical reference for the schemas/service/client pattern
|
|
248
|
+
documented in `apps-team-ops/docs/best-practices/backend.md`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 PT Services DMCC
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/MIGRATION.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { BlockMetadata, BlockNumberPathParams, BlockNumberResponse, CreateMessageRequest, EventList, HealthCheckResponse, HelloResponse, IndexedEvent, ListEventsQuery, Message, MessageList, RecentMessagesQuery, Widget } from './schemas.ts';
|
|
2
|
+
export { ErrorResponseSchema as ErrorResponse, ValidationErrorResponseSchema as ValidationErrorResponse } from '@polygonlabs/openapi-registry/error-schemas';
|
|
3
|
+
export { buildRegistry } from './registry.ts';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,MAAM,EACP,MAAM,cAAc,CAAC;AAoBtB,OAAO,EACL,mBAAmB,IAAI,aAAa,EACpC,6BAA6B,IAAI,uBAAuB,EACzD,MAAM,6CAA6C,CAAC;AASrD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Schemas are exported under their registered names so the
|
|
2
|
+
// @polygonlabs/zod-to-openapi-heyapi plugin's generated client can import
|
|
3
|
+
// them by the same name it sees in the OpenAPI components map.
|
|
4
|
+
//
|
|
5
|
+
// schemas.ts calls extendZodWithOpenApi(z) at load time — keep importing
|
|
6
|
+
// from this barrel (or directly from schemas.ts) so the side effect runs
|
|
7
|
+
// before any caller chains .openapi(...) on the schema.
|
|
8
|
+
export { BlockMetadata, BlockNumberPathParams, BlockNumberResponse, CreateMessageRequest, EventList, HealthCheckResponse, HelloResponse, IndexedEvent, ListEventsQuery, Message, MessageList, RecentMessagesQuery, Widget } from "./schemas.js";
|
|
9
|
+
// Re-export the canonical error response schemas from
|
|
10
|
+
// `@polygonlabs/openapi-registry/error-schemas`. The registry's
|
|
11
|
+
// `TypedRegistry.registerPath` auto-injects these into every route's
|
|
12
|
+
// `responses` based on what the route declares — `ErrorResponse` for
|
|
13
|
+
// 5xx (always) and 401 (when `security` is declared), and
|
|
14
|
+
// `ValidationErrorResponse` for 400 (when any of `request.{params,
|
|
15
|
+
// query, body, headers}` is declared). The shapes exactly match what
|
|
16
|
+
// `createErrorHandler` and the request validator from
|
|
17
|
+
// `@polygonlabs/express` actually emit, so the served spec, the
|
|
18
|
+
// runtime body, and the typed client agree without per-service drift.
|
|
19
|
+
//
|
|
20
|
+
// The subpath has zero Express-runtime imports — these re-exports add
|
|
21
|
+
// no transitive runtime weight to the codegen'd client or the frontend.
|
|
22
|
+
//
|
|
23
|
+
// Renamed to drop the `Schema` suffix so the binding matches the
|
|
24
|
+
// OpenAPI registered name (`ErrorResponse` / `ValidationErrorResponse`).
|
|
25
|
+
// The `@polygonlabs/zod-to-openapi-heyapi` plugin's codegen-time audit
|
|
26
|
+
// fails the build if the export name doesn't match the registered name.
|
|
27
|
+
export { ErrorResponseSchema as ErrorResponse, ValidationErrorResponseSchema as ValidationErrorResponse } from '@polygonlabs/openapi-registry/error-schemas';
|
|
28
|
+
// Registry composition — `buildRegistry` is a chained `TypedRegistry`
|
|
29
|
+
// builder; every chain step's narrow flows through the inferred return
|
|
30
|
+
// into anything that consumes `typeof buildRegistry`. Service handlers
|
|
31
|
+
// derive their typed manifest from it directly via
|
|
32
|
+
// `HandlerMapFor<typeof buildRegistry, AppAuthMap>` (see
|
|
33
|
+
// `@polygonlabs/express/registry`); no separate `Operations` alias is
|
|
34
|
+
// needed or re-exported here.
|
|
35
|
+
export { buildRegistry } from "./registry.js";
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,0EAA0E;AAC1E,+DAA+D;AAC/D,EAAE;AACF,yEAAyE;AACzE,yEAAyE;AACzE,wDAAwD;AACxD,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,MAAM,EACP,MAAM,cAAc,CAAC;AAEtB,sDAAsD;AACtD,gEAAgE;AAChE,qEAAqE;AACrE,qEAAqE;AACrE,0DAA0D;AAC1D,mEAAmE;AACnE,qEAAqE;AACrE,sDAAsD;AACtD,gEAAgE;AAChE,sEAAsE;AACtE,EAAE;AACF,sEAAsE;AACtE,wEAAwE;AACxE,EAAE;AACF,iEAAiE;AACjE,yEAAyE;AACzE,uEAAuE;AACvE,wEAAwE;AACxE,OAAO,EACL,mBAAmB,IAAI,aAAa,EACpC,6BAA6B,IAAI,uBAAuB,EACzD,MAAM,6CAA6C,CAAC;AAErD,sEAAsE;AACtE,uEAAuE;AACvE,uEAAuE;AACvE,mDAAmD;AACnD,yDAAyD;AACzD,sEAAsE;AACtE,8BAA8B;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|