@ultimabase/http 0.3.0-canary.20261031171107 → 0.3.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/CHANGELOG.md +7 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +4 -1
- package/dist/reset.d.ts +4 -0
- package/dist/reset.d.ts.map +1 -0
- package/dist/reset.js +12 -0
- package/package.json +3 -3
- package/src/app.ts +4 -1
- package/src/reset.ts +20 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# @ultimabase/http
|
|
2
2
|
|
|
3
|
-
## 0.3.0
|
|
3
|
+
## 0.3.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
+
- b06627c: Outside production, `POST /_ultimabase/reset` with the master key empties every model's rows and keeps the tables, for end-to-end tests; an adapter gains a required `empty()`, which the contract suite checks (D-188).
|
|
7
8
|
- 2eb7b9d: `httpPlugin({ upgrade })` refuses WebSocket upgrades with a response, as
|
|
8
9
|
during maintenance, and `closeUpgrades({ code, reason })` closes the sockets
|
|
9
10
|
open: GraphQL's with that code, those of a plugin without `close` cut (D-166).
|
|
@@ -17,14 +18,18 @@
|
|
|
17
18
|
- Updated dependencies [760560a]
|
|
18
19
|
- Updated dependencies [21b52bc]
|
|
19
20
|
- Updated dependencies [134d951]
|
|
21
|
+
- Updated dependencies [1195207]
|
|
20
22
|
- Updated dependencies [bc4d6de]
|
|
21
23
|
- Updated dependencies [9cd2dd4]
|
|
22
24
|
- Updated dependencies [f33c16f]
|
|
25
|
+
- Updated dependencies [b06627c]
|
|
23
26
|
- Updated dependencies [8ce42f6]
|
|
24
27
|
- Updated dependencies [b1bc387]
|
|
25
28
|
- Updated dependencies [353c2bf]
|
|
29
|
+
- Updated dependencies [a7588c3]
|
|
26
30
|
- Updated dependencies [aaf123c]
|
|
27
|
-
|
|
31
|
+
- Updated dependencies [714d3bb]
|
|
32
|
+
- ultimabase@0.3.0
|
|
28
33
|
|
|
29
34
|
## 0.2.0
|
|
30
35
|
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAM3B,OAAO,KAAK,EAAE,MAAM,EAAa,MAAM,EAAE,MAAM,YAAY,CAAA;AAK3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAExC;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG;IAAE,SAAS,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAA;AAExE,uEAAuE;AACvE,MAAM,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAA;AAElC,yFAAyF;AACzF,MAAM,WAAW,OAAO;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAC3B;AAED,6CAA6C;AAC7C,MAAM,WAAW,WAAW;IAC3B,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,iCAAiC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,kHAAkH;IAClH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAA;CACvB;AAmED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAI1E;AAgBD;;;GAGG;AACH,wBAAgB,KAAK,CACpB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,SAAS,OAAO,EAAE,EAC3B,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,EAC/C,MAAM,EAAE,MAAM,GACZ,IAAI,CAAC,OAAO,CAAC,CAwHf"}
|
package/dist/app.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// The Hono application `httpPlugin` serves (D-66, D-106): no caching, CORS,
|
|
2
2
|
// forms from other origins, the body limit, each request's caller, the
|
|
3
|
-
// routes, and errors as D-72
|
|
3
|
+
// routes, the reset route outside production (D-188), and errors as D-72
|
|
4
|
+
// sends them.
|
|
4
5
|
import { randomUUID } from 'node:crypto';
|
|
5
6
|
import { STATUS_CODES } from 'node:http';
|
|
6
7
|
import { Hono } from 'hono';
|
|
@@ -11,6 +12,7 @@ import { getPath } from 'hono/utils/url';
|
|
|
11
12
|
import { isLocalHost, PublicError } from 'ultimabase';
|
|
12
13
|
import { addresses, proxiesOf } from './address.js';
|
|
13
14
|
import { hold } from './request.js';
|
|
15
|
+
import { resetRoutes } from './reset.js';
|
|
14
16
|
const statuses = new Map([
|
|
15
17
|
['ACCESS_DENIED', 403],
|
|
16
18
|
['NOT_FOUND', 404],
|
|
@@ -189,6 +191,7 @@ export function appOf(options, mounted, identify, logger) {
|
|
|
189
191
|
for (const routes of [
|
|
190
192
|
...(options.routes ?? []),
|
|
191
193
|
...mounted.map((mount) => mount.routes),
|
|
194
|
+
...(local ? [resetRoutes] : []),
|
|
192
195
|
]) {
|
|
193
196
|
app.route('/', routes);
|
|
194
197
|
}
|
package/dist/reset.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../src/reset.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAEvC,eAAO,MAAM,WAAW,EAAE,IAAI,CAAC,OAAO,CAYrC,CAAA"}
|
package/dist/reset.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// `POST /_ultimabase/reset`, outside production: Master empties the database
|
|
2
|
+
// between end-to-end tests (D-188).
|
|
3
|
+
import { Hono } from 'hono';
|
|
4
|
+
import { PublicError } from 'ultimabase';
|
|
5
|
+
import { emptyRunning } from 'ultimabase/internal';
|
|
6
|
+
export const resetRoutes = new Hono().post('/_ultimabase/reset', async (c) => {
|
|
7
|
+
if (c.var.caller.kind !== 'master') {
|
|
8
|
+
throw new PublicError('ACCESS_DENIED', 'Only the master key empties the database.');
|
|
9
|
+
}
|
|
10
|
+
await emptyRunning();
|
|
11
|
+
return c.body(null, 204);
|
|
12
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimabase/http",
|
|
3
|
-
"version": "0.3.0
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "An HTTP server for UltimaBase: Hono routes that read the caller, CORS and a body limit.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"hono": "4.13.13"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"ultimabase": "0.3.0
|
|
40
|
+
"ultimabase": "^0.3.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"ultimabase": "0.3.0
|
|
43
|
+
"ultimabase": "0.3.0",
|
|
44
44
|
"vite": "8.3.4",
|
|
45
45
|
"vitest": "5.0.5"
|
|
46
46
|
}
|
package/src/app.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// The Hono application `httpPlugin` serves (D-66, D-106): no caching, CORS,
|
|
2
2
|
// forms from other origins, the body limit, each request's caller, the
|
|
3
|
-
// routes, and errors as D-72
|
|
3
|
+
// routes, the reset route outside production (D-188), and errors as D-72
|
|
4
|
+
// sends them.
|
|
4
5
|
import { randomUUID } from 'node:crypto'
|
|
5
6
|
import { STATUS_CODES } from 'node:http'
|
|
6
7
|
import type { Context } from 'hono'
|
|
@@ -14,6 +15,7 @@ import type { Caller, ErrorCode, Logger } from 'ultimabase'
|
|
|
14
15
|
import { isLocalHost, PublicError } from 'ultimabase'
|
|
15
16
|
import { addresses, proxiesOf } from './address.ts'
|
|
16
17
|
import { hold } from './request.ts'
|
|
18
|
+
import { resetRoutes } from './reset.ts'
|
|
17
19
|
import type { Gate } from './upgrade.ts'
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -253,6 +255,7 @@ export function appOf(
|
|
|
253
255
|
for (const routes of [
|
|
254
256
|
...(options.routes ?? []),
|
|
255
257
|
...mounted.map((mount) => mount.routes),
|
|
258
|
+
...(local ? [resetRoutes] : []),
|
|
256
259
|
]) {
|
|
257
260
|
app.route('/', routes)
|
|
258
261
|
}
|
package/src/reset.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// `POST /_ultimabase/reset`, outside production: Master empties the database
|
|
2
|
+
// between end-to-end tests (D-188).
|
|
3
|
+
import { Hono } from 'hono'
|
|
4
|
+
import { PublicError } from 'ultimabase'
|
|
5
|
+
import { emptyRunning } from 'ultimabase/internal'
|
|
6
|
+
import type { HttpEnv } from './app.ts'
|
|
7
|
+
|
|
8
|
+
export const resetRoutes: Hono<HttpEnv> = new Hono<HttpEnv>().post(
|
|
9
|
+
'/_ultimabase/reset',
|
|
10
|
+
async (c) => {
|
|
11
|
+
if (c.var.caller.kind !== 'master') {
|
|
12
|
+
throw new PublicError(
|
|
13
|
+
'ACCESS_DENIED',
|
|
14
|
+
'Only the master key empties the database.',
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
await emptyRunning()
|
|
18
|
+
return c.body(null, 204)
|
|
19
|
+
},
|
|
20
|
+
)
|