Skip to content

Commit cf8a294

Browse files
committed
feat(npm): cross publish some package on npm
1 parent 4fcff11 commit cf8a294

26 files changed

+1130
-345
lines changed

.github/workflows/ga-check-linter-fmt.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
name: 👾 Check, Lint, and Format
2-
32
on:
4-
pull_request:
5-
types: [opened, reopened, synchronize]
6-
push:
7-
branches: [master]
3+
push: { branches: [master] }
4+
pull_request: { types: [opened, reopened, synchronize] }
85

96
jobs:
107
lint-and-format-check:
@@ -18,9 +15,7 @@ jobs:
1815

1916
- name: 🦖 Set up Deno
2017
uses: denoland/setup-deno@v2
21-
with:
22-
deno-version: v2.x
23-
cache: true
18+
with: { deno-version: v2.x, cache: true }
2419

2520
- name: 🦊 Run Types Checks
2621
run: deno check

.github/workflows/ga-jsr-publish-manual.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
name: Publish Selected Packages
2-
on:
3-
workflow_dispatch:
1+
name: 🤙 Publish Selected Packages
2+
on: { workflow_dispatch: {} }
43

54
jobs:
65
publish:
@@ -15,9 +14,7 @@ jobs:
1514

1615
- name: 🦖 Set up Deno
1716
uses: denoland/setup-deno@v2
18-
with:
19-
deno-version: v2.x
20-
cache: true
17+
with: { deno-version: v2.x, cache: true }
2118

2219
- name: 🚀 Publish selected packages
2320
run: |

.github/workflows/ga-jsr-publish.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
name: Publish
2-
on:
3-
push:
4-
branches: [master]
1+
name: 🦖 Publish
2+
on: { push: { branches: [master] } }
53

64
jobs:
75
publish:
@@ -16,9 +14,7 @@ jobs:
1614

1715
- name: 🦖 Set up Deno
1816
uses: denoland/setup-deno@v2
19-
with:
20-
deno-version: v2.x
21-
cache: true
17+
with: { deno-version: v2.x, cache: true }
2218

2319
- name: Publish changed packages
2420
run: |
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 📦 Publish NPM
2+
on: { push: { branches: [master] } }
3+
4+
jobs:
5+
publish-npm:
6+
runs-on: ubuntu-latest
7+
permissions:
8+
contents: read
9+
id-token: write
10+
steps:
11+
- name: 🐧 Checkout
12+
uses: actions/checkout@v5
13+
with: { fetch-depth: 0 }
14+
15+
- name: 🦖 Set up Deno
16+
uses: denoland/setup-deno@v2
17+
with: { deno-version: v2.x, cache: true }
18+
19+
- name: 📦 Build npm packages
20+
run: deno run -A npm.ts

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,5 @@ dist
137137
# Vite logs files
138138
vite.config.js.timestamp-*
139139
vite.config.ts.timestamp-*
140+
141+
.npm/*

README.md

Lines changed: 102 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,102 @@
1-
# framework
2-
3-
Modular TypeScript/Deno utilities for building type‑safe web apps: HTTP routing, typed clients, SPA URL-as-state navigation, SQLite helpers, time utilities, and shared types.
4-
5-
## [`api`](./api)
6-
Type-safe HTTP toolkit: router, server wrapper, request context, logger, response helpers, env utilities, and validator. Compose end-to-end typed APIs with consistent logging and errors.
7-
8-
### [`api/router`](./api/router.ts)
9-
Define routes with input/output schemas, optional authorization, and automatic responses. Produces types for clients; validates GET params/body and logs with sensitive-key redaction.
10-
11-
### [`api/server`](./api/server.ts)
12-
Wraps your router with logging, error barrier, cookie parsing, trace/span IDs, and `RequestContext` creation. Handles OPTIONS and integrates respond.* errors.
13-
14-
### [`api/context`](./api/context.ts)
15-
AsyncLocalStorage-powered `RequestContext` with `getContext`/`newContext`/`runContext`. Carries Request, URL, cookies, trace and span across async boundaries.
16-
17-
### [`api/log`](./api/log.ts)
18-
Environment-aware logger (dev/test/prod) with pretty colors, call-chain, batching to devtool, filtering, and context trace/span metadata. Exposes info/warn/error/debug.
19-
20-
### [`api/response`](./api/response.ts)
21-
`respond.*` helpers to build JSON Responses for every status and paired Error classes (`ResponseError`). Adds default JSON headers and bodyless handling (204/304, etc.).
22-
23-
### [`api/env`](./api/env.ts)
24-
`ENV()` getter with fallback and required enforcement; typed `APP_ENV` guard (dev/test/prod) with validation; `CI_COMMIT_SHA`, `DEVTOOL_TOKEN`, `DEVTOOL_URL` accessors.
25-
26-
### [`api/validator`](./api/validator.ts)
27-
High-performance, schema-based validation with `OBJ`, `ARR`, `STR`, `NUM`, `BOOL`, `LIST`, `UNION`, optional. Generates assert/report functions and infers types via `Asserted<T>`.
28-
29-
## [`api-client`](./api-client)
30-
Generates a strongly typed client from server route definitions. Provides fetch and reactive signal() helpers with abort/dedupe and rich JSON/body error types.
31-
32-
## [`api-proxy`](./api-proxy)
33-
Vite dev proxy for `/api/*` to a localhost backend. Streams requests/responses, preserves headers/status/cookies, merges Set-Cookie, and aborts on client disconnect—avoids CORS.
34-
35-
## [`db`](./db)
36-
SQLite helpers: declare tables, auto-generate insert/update/get/exists, foreign-key joins, tagged SQL and existence checks, singleton connection, and test restore points.
37-
38-
39-
### [`db/migration`](./db/migration.ts)
40-
Versioned migrations via SQLite `PRAGMA user_version`. Reads a migrations directory for files named `NNN-*.ts|js`, imports each `run(sql)` in order, applies them, and updates `user_version`. Skips work on a clean DB, logs progress, and surfaces errors.
41-
42-
### [`db/entries`](./db/entries.ts)
43-
Event-sourcing style “entries” with a star‑schema. `initEntries(ids, relations, types)` creates the `entryInternal` table, the `entry` view (active rows), per‑type views (`entry_<lowercase>`), and basic indexes. Generates per‑type `insert` functions that capture `RequestContext` `trace`/`span` and timestamps, supports optional typed `fields` stored in dedicated tables, soft‑archive via `archivedAt`, plus `insertListeners` for streaming/SSE triggers.
44-
45-
46-
## [`signal-router`](./signal-router)
47-
URL-as-state SPA routing on `@preact/signals`. Typed `A` component, `navigate`, `replaceParams`, reactive url helpers; normalizes trailing slashes and skips external and /api links.
48-
49-
## [`time`](./time)
50-
Time utilities in seconds: startTime, `now()` is a more precise `Date.now()`, and constants `SEC`, `MIN`, `HOUR`, `DAY`, `WEEK`, `YEAR`.
51-
52-
## [`types`](./types)
53-
Generic utility types: deep `Readonly`, `Expand`, `Awaitable`, `Nullish`, `IsUnknown`, `UnionToIntersection`, and `MatchKeys`.
1+
# framework
2+
3+
Modular TypeScript/Deno utilities for building type‑safe web apps: HTTP routing,
4+
typed clients, SPA URL-as-state navigation, SQLite helpers, time utilities, and
5+
shared types.
6+
7+
## [`api`](./api)
8+
9+
Type-safe HTTP toolkit: router, server wrapper, request context, logger,
10+
response helpers, env utilities, and validator. Compose end-to-end typed APIs
11+
with consistent logging and errors.
12+
13+
### [`api/router`](./api/router.ts)
14+
15+
Define routes with input/output schemas, optional authorization, and automatic
16+
responses. Produces types for clients; validates GET params/body and logs with
17+
sensitive-key redaction.
18+
19+
### [`api/server`](./api/server.ts)
20+
21+
Wraps your router with logging, error barrier, cookie parsing, trace/span IDs,
22+
and `RequestContext` creation. Handles OPTIONS and integrates respond.* errors.
23+
24+
### [`api/context`](./api/context.ts)
25+
26+
AsyncLocalStorage-powered `RequestContext` with
27+
`getContext`/`newContext`/`runContext`. Carries Request, URL, cookies, trace and
28+
span across async boundaries.
29+
30+
### [`api/log`](./api/log.ts)
31+
32+
Environment-aware logger (dev/test/prod) with pretty colors, call-chain,
33+
batching to devtool, filtering, and context trace/span metadata. Exposes
34+
info/warn/error/debug.
35+
36+
### [`api/response`](./api/response.ts)
37+
38+
`respond.*` helpers to build JSON Responses for every status and paired Error
39+
classes (`ResponseError`). Adds default JSON headers and bodyless handling
40+
(204/304, etc.).
41+
42+
### [`api/env`](./api/env.ts)
43+
44+
`ENV()` getter with fallback and required enforcement; typed `APP_ENV` guard
45+
(dev/test/prod) with validation; `CI_COMMIT_SHA`, `DEVTOOL_TOKEN`, `DEVTOOL_URL`
46+
accessors.
47+
48+
### [`api/validator`](./api/validator.ts)
49+
50+
High-performance, schema-based validation with `OBJ`, `ARR`, `STR`, `NUM`,
51+
`BOOL`, `LIST`, `UNION`, optional. Generates assert/report functions and infers
52+
types via `Asserted<T>`.
53+
54+
## [`api-client`](./api-client)
55+
56+
Generates a strongly typed client from server route definitions. Provides fetch
57+
and reactive signal() helpers with abort/dedupe and rich JSON/body error types.
58+
59+
## [`api-proxy`](./api-proxy)
60+
61+
Vite dev proxy for `/api/*` to a localhost backend. Streams requests/responses,
62+
preserves headers/status/cookies, merges Set-Cookie, and aborts on client
63+
disconnect—avoids CORS.
64+
65+
## [`db`](./db)
66+
67+
SQLite helpers: declare tables, auto-generate insert/update/get/exists,
68+
foreign-key joins, tagged SQL and existence checks, singleton connection, and
69+
test restore points.
70+
71+
### [`db/migration`](./db/migration.ts)
72+
73+
Versioned migrations via SQLite `PRAGMA user_version`. Reads a migrations
74+
directory for files named `NNN-*.ts|js`, imports each `run(sql)` in order,
75+
applies them, and updates `user_version`. Skips work on a clean DB, logs
76+
progress, and surfaces errors.
77+
78+
### [`db/entries`](./db/entries.ts)
79+
80+
Event-sourcing style “entries” with a star‑schema.
81+
`initEntries(ids, relations, types)` creates the `entryInternal` table, the
82+
`entry` view (active rows), per‑type views (`entry_<lowercase>`), and basic
83+
indexes. Generates per‑type `insert` functions that capture `RequestContext`
84+
`trace`/`span` and timestamps, supports optional typed `fields` stored in
85+
dedicated tables, soft‑archive via `archivedAt`, plus `insertListeners` for
86+
streaming/SSE triggers.
87+
88+
## [`signal-router`](./signal-router)
89+
90+
URL-as-state SPA routing on `@preact/signals`. Typed `A` component, `navigate`,
91+
`replaceParams`, reactive url helpers; normalizes trailing slashes and skips
92+
external and /api links.
93+
94+
## [`time`](./time)
95+
96+
Time utilities in seconds: startTime, `now()` is a more precise `Date.now()`,
97+
and constants `SEC`, `MIN`, `HOUR`, `DAY`, `WEEK`, `YEAR`.
98+
99+
## [`types`](./types)
100+
101+
Generic utility types: deep `Readonly`, `Expand`, `Awaitable`, `Nullish`,
102+
`IsUnknown`, `UnionToIntersection`, and `MatchKeys`.

api-client/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# api-client
22

3-
Tiny, type-safe HTTP API client meant to be used alongside the
4-
`@01edu/api` router (see
5-
[`@01edu/api/router`](https://jsr.io/@01edu/api/doc/router)). It
3+
Tiny, type-safe HTTP API client meant to be used alongside the `@01edu/api`
4+
router (see [`@01edu/api/router`](https://jsr.io/@01edu/api/doc/router)). It
65
builds a strongly-typed client from your server route definitions.
76

87
## Install
@@ -11,8 +10,7 @@ builds a strongly-typed client from your server route definitions.
1110

1211
## How it fits
1312

14-
- Define routes on the server with @01edu/api/router and export their
15-
type.
13+
- Define routes on the server with @01edu/api/router and export their type.
1614
- Use that type on the client with `createClient` for end-to-end typing.
1715

1816
## Server (types export)

api-client/deno.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"@preact/signals": "npm:@preact/signals@^2.5.1"
44
},
55
"name": "@01edu/api-client",
6-
"version": "0.1.1",
6+
"version": "0.1.2",
77
"license": "MIT",
88
"exports": { ".": "./mod.ts" },
99
"compilerOptions": {
10-
"lib": ["deno.ns", "DOM", "DOM.Iterable", "esnext"]
10+
"lib": ["DOM", "DOM.Iterable", "esnext"]
1111
}
1212
}

api-client/mod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
* @module
3232
*/
3333
import { Signal } from '@preact/signals'
34-
import type { Asserted } from '@01edu/api/validator'
35-
import type { GenericRoutes, Handler, HttpMethod } from '@01edu/api/router'
34+
import type { Asserted } from '@01edu/types/validator'
35+
import type { GenericRoutes, Handler, HttpMethod } from '@01edu/types/router'
3636

3737
/**
3838
* Error thrown when the server returns a JSON error payload.

api-client/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"description": "Type-safe HTTP API Client"
3+
}

0 commit comments

Comments
 (0)