@vireocodedev/infrastructure 0.2.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/LICENSE +21 -0
- package/README.md +78 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 vireocodedev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @vireocodedev/infrastructure
|
|
2
|
+
|
|
3
|
+
React-free browser infrastructure primitives for validated HTTP transport, connectivity, persistent state, session-expiry coordination, and execution-mode-aware services.
|
|
4
|
+
|
|
5
|
+
The package owns reusable mechanisms. Applications still own configured transports, endpoint vocabulary, authentication and routing, heartbeat adapters, persistence services, query caching, service-worker lifecycle, and product UI.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @vireocodedev/infrastructure axios zod @preact/signals-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The package is published publicly on npm; installation requires no registry
|
|
14
|
+
authentication. TypeScript declarations are verified from the packed artifact
|
|
15
|
+
with TypeScript 6, `moduleResolution: "Bundler"`, and `skipLibCheck: false`.
|
|
16
|
+
Relative source maps with embedded source content are published intentionally
|
|
17
|
+
for debugging.
|
|
18
|
+
|
|
19
|
+
The package has no React, MUI, React Query, locale, or application singleton dependency.
|
|
20
|
+
|
|
21
|
+
React adapters live in Starter UI:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { useVireoOnlineStatus } from "@vireocodedev/ui";
|
|
25
|
+
import { createVireoPagedSearchQueries } from "@vireocodedev/ui/tanstack-query";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Public architecture
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
application runtime and policy
|
|
32
|
+
-> createConnectivityState / getAppOnlineStatus
|
|
33
|
+
-> createModeAwareApi
|
|
34
|
+
-> AxiosHttpClient or postPagedSearch
|
|
35
|
+
-> Zod-validated response data
|
|
36
|
+
-> application cache and product state
|
|
37
|
+
|
|
38
|
+
application storage -> createPersistentSignal
|
|
39
|
+
application authentication -> createSessionExpiryChannel
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
All stateful factories are instance-scoped. Importing the package creates no query client, listeners, timers, session state, or storage state.
|
|
43
|
+
|
|
44
|
+
## Mode-aware services
|
|
45
|
+
|
|
46
|
+
`createModeAwareApi` composes online and offline service modules behind one application API. The application injects the current mode, guards, fallback classification, timing, and diagnostics policy. `transactional` can mark offline methods whose writes should prefer the online implementation while connectivity exists.
|
|
47
|
+
|
|
48
|
+
## HTTP and pagination
|
|
49
|
+
|
|
50
|
+
`AxiosHttpClient` centralizes injected Axios transport and Zod response validation. `postPagedSearch` validates the complete pageable envelope, not only its rows. Malformed filter JSON and invalid metadata fail closed.
|
|
51
|
+
|
|
52
|
+
`sanitizeAxiosError` produces a deliberately small diagnostic object and never exposes request bodies, headers, query strings, or response data.
|
|
53
|
+
|
|
54
|
+
## Connectivity
|
|
55
|
+
|
|
56
|
+
`getAppOnlineStatus` and `subscribeToAppNetworkStatus` expose the browser's lightweight network hint. `createConnectivityState` combines that hint with optional heartbeat freshness and explicit backend availability. Runtime adapters own browser subscriptions and scheduling; the state factory enforces one active runtime owner.
|
|
57
|
+
|
|
58
|
+
## Persistent state
|
|
59
|
+
|
|
60
|
+
`createPersistentSignal` mirrors one typed storage key into a Preact core signal. Persistence occurs before the in-memory signal changes, so a failed write cannot leave the two representations inconsistent.
|
|
61
|
+
|
|
62
|
+
## Session expiry
|
|
63
|
+
|
|
64
|
+
`createSessionExpiryChannel` creates an isolated coordination channel. It deduplicates expiry notifications, suppresses them during intentional logout, and lets applications decide how listeners affect routing or authentication.
|
|
65
|
+
|
|
66
|
+
## Failure semantics
|
|
67
|
+
|
|
68
|
+
- Invalid HTTP data raises the original Zod error without logging raw payloads.
|
|
69
|
+
- Malformed query filters fail before a request is sent.
|
|
70
|
+
- Invalid pageable metadata is rejected at the API boundary.
|
|
71
|
+
- Request cancellation is recognized without assuming DOM globals exist.
|
|
72
|
+
- Connectivity policy and concurrent runtime ownership fail synchronously.
|
|
73
|
+
- Persistence failures leave the signal unchanged.
|
|
74
|
+
- Session listeners are isolated and may report failures through injected policy.
|
|
75
|
+
|
|
76
|
+
## Verification and live documentation
|
|
77
|
+
|
|
78
|
+
Package tests cover public services, transport boundaries, connectivity lifecycle, persistence, session isolation, and the React-free contract. The unified Vireo Storybook contains executable examples under **Infrastructure**; every displayed source file is the same TypeScript module Storybook executes.
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vireocodedev/infrastructure",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "React-free browser infrastructure primitives for validated HTTP transport, connectivity, persistence, and execution-mode-aware services.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/vireocodedev/starter.git",
|
|
11
|
+
"directory": "packages/infrastructure"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"infrastructure",
|
|
15
|
+
"network-status",
|
|
16
|
+
"signals",
|
|
17
|
+
"http",
|
|
18
|
+
"starter"
|
|
19
|
+
],
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./network-status": {
|
|
26
|
+
"types": "./dist/network/appNetworkStatus.d.ts",
|
|
27
|
+
"import": "./dist/network/appNetworkStatus.js"
|
|
28
|
+
},
|
|
29
|
+
"./pagination": {
|
|
30
|
+
"types": "./dist/http/pagination.d.ts",
|
|
31
|
+
"import": "./dist/http/pagination.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"main": "./dist/index.js",
|
|
35
|
+
"module": "./dist/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "vite build",
|
|
42
|
+
"dev": "vite build --watch --mode watch",
|
|
43
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
44
|
+
"test": "vitest run"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@preact/signals-core": ">=1.8",
|
|
48
|
+
"axios": ">=1.7",
|
|
49
|
+
"zod": ">=4.4 <5"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@preact/signals-core": "^1.14.4",
|
|
53
|
+
"axios": "^1.19.0",
|
|
54
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
55
|
+
"vite": "^8.2.2",
|
|
56
|
+
"vite-plugin-dts": "^5.0.3",
|
|
57
|
+
"vitest": "^4.1.11",
|
|
58
|
+
"zod": "^4.4.3"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public",
|
|
62
|
+
"provenance": true,
|
|
63
|
+
"registry": "https://registry.npmjs.org"
|
|
64
|
+
}
|
|
65
|
+
}
|