@q32/core 0.1.1

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.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +60 -0
  3. package/dist/ai.d.ts +26 -0
  4. package/dist/ai.d.ts.map +1 -0
  5. package/dist/ai.js +16 -0
  6. package/dist/ai.js.map +1 -0
  7. package/dist/api.d.ts +25 -0
  8. package/dist/api.d.ts.map +1 -0
  9. package/dist/api.js +66 -0
  10. package/dist/api.js.map +1 -0
  11. package/dist/billing.d.ts +21 -0
  12. package/dist/billing.d.ts.map +1 -0
  13. package/dist/billing.js +18 -0
  14. package/dist/billing.js.map +1 -0
  15. package/dist/cloudflare.d.ts +12 -0
  16. package/dist/cloudflare.d.ts.map +1 -0
  17. package/dist/cloudflare.js +25 -0
  18. package/dist/cloudflare.js.map +1 -0
  19. package/dist/crypto.d.ts +10 -0
  20. package/dist/crypto.d.ts.map +1 -0
  21. package/dist/crypto.js +42 -0
  22. package/dist/crypto.js.map +1 -0
  23. package/dist/d1.d.ts +34 -0
  24. package/dist/d1.d.ts.map +1 -0
  25. package/dist/d1.js +44 -0
  26. package/dist/d1.js.map +1 -0
  27. package/dist/email.d.ts +33 -0
  28. package/dist/email.d.ts.map +1 -0
  29. package/dist/email.js +16 -0
  30. package/dist/email.js.map +1 -0
  31. package/dist/env.d.ts +11 -0
  32. package/dist/env.d.ts.map +1 -0
  33. package/dist/env.js +55 -0
  34. package/dist/env.js.map +1 -0
  35. package/dist/http.d.ts +14 -0
  36. package/dist/http.d.ts.map +1 -0
  37. package/dist/http.js +53 -0
  38. package/dist/http.js.map +1 -0
  39. package/dist/ids.d.ts +7 -0
  40. package/dist/ids.d.ts.map +1 -0
  41. package/dist/ids.js +35 -0
  42. package/dist/ids.js.map +1 -0
  43. package/dist/index.d.ts +22 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +22 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/jobs.d.ts +52 -0
  48. package/dist/jobs.d.ts.map +1 -0
  49. package/dist/jobs.js +195 -0
  50. package/dist/jobs.js.map +1 -0
  51. package/dist/mcp.d.ts +18 -0
  52. package/dist/mcp.d.ts.map +1 -0
  53. package/dist/mcp.js +33 -0
  54. package/dist/mcp.js.map +1 -0
  55. package/dist/oauth.d.ts +17 -0
  56. package/dist/oauth.d.ts.map +1 -0
  57. package/dist/oauth.js +33 -0
  58. package/dist/oauth.js.map +1 -0
  59. package/dist/ops-events.d.ts +25 -0
  60. package/dist/ops-events.d.ts.map +1 -0
  61. package/dist/ops-events.js +43 -0
  62. package/dist/ops-events.js.map +1 -0
  63. package/dist/pg.d.ts +27 -0
  64. package/dist/pg.d.ts.map +1 -0
  65. package/dist/pg.js +51 -0
  66. package/dist/pg.js.map +1 -0
  67. package/dist/r2-json.d.ts +8 -0
  68. package/dist/r2-json.d.ts.map +1 -0
  69. package/dist/r2-json.js +21 -0
  70. package/dist/r2-json.js.map +1 -0
  71. package/dist/rate-limit.d.ts +19 -0
  72. package/dist/rate-limit.d.ts.map +1 -0
  73. package/dist/rate-limit.js +48 -0
  74. package/dist/rate-limit.js.map +1 -0
  75. package/dist/seo.d.ts +23 -0
  76. package/dist/seo.d.ts.map +1 -0
  77. package/dist/seo.js +60 -0
  78. package/dist/seo.js.map +1 -0
  79. package/dist/session.d.ts +11 -0
  80. package/dist/session.d.ts.map +1 -0
  81. package/dist/session.js +55 -0
  82. package/dist/session.js.map +1 -0
  83. package/dist/testing.d.ts +25 -0
  84. package/dist/testing.d.ts.map +1 -0
  85. package/dist/testing.js +94 -0
  86. package/dist/testing.js.map +1 -0
  87. package/dist/time.d.ts +5 -0
  88. package/dist/time.d.ts.map +1 -0
  89. package/dist/time.js +17 -0
  90. package/dist/time.js.map +1 -0
  91. package/docs/evaluation.md +74 -0
  92. package/docs/goal-audit.md +28 -0
  93. package/package.json +129 -0
@@ -0,0 +1,74 @@
1
+ # Suitability Evaluation
2
+
3
+ This package was seeded from repeated infrastructure found across Erik/Q32 TypeScript projects, including `adgiro`, `bizsnipe`, `dirtsignal`, `getflight`, `graphilize`, `ipogrid`, `logtura`, `onwardtravel`, `relin`, `zura`, and the `domains/*` apps.
4
+
5
+ ## Replacement Matrix
6
+
7
+ | Common pattern | Current module | Suitable replacement scope |
8
+ | --- | --- | --- |
9
+ | AI JSON helper conventions | `ai` | Standardize model request/response contracts and JSON extraction around official provider SDK calls. |
10
+ | Typed environment helpers and app URL fallback | `env` | Replace local `getAppUrl`, required env, optional boolean, and binding guard helpers. |
11
+ | Cloudflare binding checks | `cloudflare` | Replace repeated `DB`, `R2`, and Queue binding guard code in Workers. |
12
+ | JSON responses, bearer/admin token checks, request body parsing | `http` | Replace repeated Worker/Hono-adjacent HTTP utility functions. |
13
+ | Prefixed IDs, random tokens, base64url, SHA-256 | `ids` | Replace local `createId`, token, digest-key, and hash helpers. |
14
+ | Signed session tokens and cookies | `session` | Replace small HMAC session implementations where full auth frameworks are unnecessary. |
15
+ | Credential or provider-secret encryption | `crypto` | Replace local AES-GCM JSON encryption helpers backed by WebCrypto. |
16
+ | D1-like database typing and explicit migrations | `d1` | Replace duplicated `D1DatabaseLike` types and simple migration runners. |
17
+ | Postgres migration and JSON helpers | `pg` | Replace small pg migration scripts while still using official `pg` or `postgres` clients in apps. |
18
+ | Background job table behavior | `jobs` | Replace D1 job enqueue/claim/run/requeue/succeed/fail loops in small Worker apps. |
19
+ | Operator event recording and listing | `ops-events` | Replace repeated `ops_events` insert/list helpers. |
20
+ | D1 fixed-window rate limits | `rate-limit` | Replace lead, login, public API, and admin throttle tables. |
21
+ | R2 JSON payload/artifact storage | `r2-json` | Replace raw provider payload and generated artifact JSON storage helpers. |
22
+ | SEO/static output conventions | `seo` | Replace ad hoc sitemap, robots, canonical, Open Graph, and noindex tag helpers. |
23
+ | Email provider boundary | `email` | Standardize provider-independent send input/result shapes and address helpers. |
24
+ | Billing plan/status checks | `billing` | Replace local plan rank and active subscription status helpers around Stripe-backed apps. |
25
+ | Worker test helpers | `testing` | Replace small fake Queue/R2 helpers and JSON response assertions in unit tests; complements workerd/Miniflare integration tests. |
26
+ | OAuth/MCP metadata | `oauth`, `mcp` | Replace repeated discovery metadata and API-to-tool descriptors; full OAuth token stores remain app-specific for now. |
27
+ | API operation registries | `api` | Replace local operation registries used for OpenAPI, admin APIs, and MCP exposure. |
28
+
29
+ ## Current Fit
30
+
31
+ The package is suitable for new Q32 Worker projects and for incremental replacement of local helpers in existing projects where the app-specific behavior is already separated from infrastructure primitives.
32
+
33
+ Strong first replacement candidates:
34
+
35
+ - D1-like interfaces duplicated in `relin` and `graphilize`.
36
+ - `ops_events` helpers in `onwardtravel`, `bizsnipe`, `logtura`, and `bce.email`.
37
+ - D1 jobs in `travelerideas`, `bizsnipe`, `logtura`, and smaller domain apps.
38
+ - signed session, ID, token, and base64url helpers in `zura`, `relin`, `getflight`, and `adgiro`.
39
+ - API operation metadata from `bce.email` and `relin`.
40
+ - OAuth/MCP metadata from `getflight`, `captcha`, `ipogrid`, `relin`, and `bce.email`.
41
+
42
+ ## Not Yet Complete
43
+
44
+ The package intentionally does not yet replace:
45
+
46
+ - full app account systems
47
+ - full OAuth authorization-code and refresh-token stores
48
+ - Stripe billing repositories
49
+ - Postgres job runners and migration orchestration
50
+ - email provider clients
51
+ - Mantine app shells or SEO page components
52
+ - OpenAI/provider retry adapters beyond the shared request/result contracts
53
+ - Stripe webhook verification or Checkout/session creation, which should remain on the official Stripe SDK
54
+ - Mantine app shells or React components
55
+
56
+ Those should be added only after extracting one or two real migrations from existing apps so the shared API follows production usage rather than speculation.
57
+
58
+ ## Verification
59
+
60
+ Current local gates:
61
+
62
+ - `pnpm typecheck`
63
+ - `pnpm test:coverage`
64
+ - `pnpm build`
65
+ - `pnpm pack --dry-run`
66
+
67
+ Coverage threshold is enforced in `vitest.config.ts` and CI runs the same gates.
68
+
69
+ Current coverage after the expanded common-module pass:
70
+
71
+ - Statements: 89.26%
72
+ - Branches: 75.25%
73
+ - Functions: 96.66%
74
+ - Lines: 95.15%
@@ -0,0 +1,28 @@
1
+ # Goal Audit
2
+
3
+ Objective: working Q32 core libraries, with the common libraries discussed in the project inventory, a public repo at the `q32llc` org, working CI/CD, strong types and good test coverage, evaluated as suitable to replace much common code in existing projects.
4
+
5
+ ## Proven Complete
6
+
7
+ | Requirement | Evidence |
8
+ | --- | --- |
9
+ | Public repo under `q32llc` | `https://github.com/q32llc/q32-core`, public, default branch `main`. |
10
+ | Working local package | `pnpm build` succeeds and `pnpm pack --dry-run` produces a clean tarball. |
11
+ | Strong TypeScript types | `pnpm typecheck` succeeds under `strict` TypeScript with generated declarations. |
12
+ | Good test coverage | `pnpm test:coverage` succeeds with enforced thresholds; latest local coverage is 89.26% statements, 75.25% branches, 96.66% functions, 95.15% lines. |
13
+ | Working CI | GitHub Actions CI passes on `main` and runs install, typecheck, coverage, build, and pack dry run. |
14
+ | Common code surfaces | Modules exist for `api`, `ai`, `billing`, `cloudflare`, `crypto`, `d1`, `email`, `env`, `http`, `ids`, `jobs`, `mcp`, `oauth`, `ops-events`, `pg`, `r2-json`, `rate-limit`, `seo`, `session`, `testing`, and `time`. |
15
+ | Suitability evaluation | `docs/evaluation.md` maps modules to common patterns found in existing projects and identifies first replacement candidates. |
16
+ | Consumer install smoke | Packed tarball was installed into a clean temp project and imported successfully from `@q32/core`. |
17
+
18
+ ## Incomplete Or Externally Blocked
19
+
20
+ | Requirement | Status |
21
+ | --- | --- |
22
+ | npm package published | Not complete. Local `npm whoami` returns `E401`, and `@q32/core` does not exist on npm yet. |
23
+ | npm publish step in CD | Workflow exists and skips safely when `NPM_TOKEN` is absent. Actual npm publishing cannot be proven until npm publishing is configured through `NPM_TOKEN` or npm trusted publishing for this repo/package. |
24
+ | Proven replacement in existing apps | Not complete. The library is evaluated as suitable, but no existing app has been migrated to consume it yet. |
25
+
26
+ ## Recommended Next Proof Step
27
+
28
+ Migrate one low-risk repeated slice in an existing app, such as replacing the duplicated `D1DatabaseLike` type in `relin` or `graphilize`, or replacing `ops_events` helpers in `onwardtravel`. That will validate the public API against production code and expose any ergonomics issues before broad adoption.
package/package.json ADDED
@@ -0,0 +1,129 @@
1
+ {
2
+ "name": "@q32/core",
3
+ "version": "0.1.1",
4
+ "description": "Shared TypeScript primitives for Q32 Cloudflare Worker projects.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/q32llc/q32-core.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/q32llc/q32-core/issues"
13
+ },
14
+ "homepage": "https://github.com/q32llc/q32-core#readme",
15
+ "sideEffects": false,
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "./api": {
24
+ "types": "./dist/api.d.ts",
25
+ "default": "./dist/api.js"
26
+ },
27
+ "./ai": {
28
+ "types": "./dist/ai.d.ts",
29
+ "default": "./dist/ai.js"
30
+ },
31
+ "./billing": {
32
+ "types": "./dist/billing.d.ts",
33
+ "default": "./dist/billing.js"
34
+ },
35
+ "./cloudflare": {
36
+ "types": "./dist/cloudflare.d.ts",
37
+ "default": "./dist/cloudflare.js"
38
+ },
39
+ "./crypto": {
40
+ "types": "./dist/crypto.d.ts",
41
+ "default": "./dist/crypto.js"
42
+ },
43
+ "./d1": {
44
+ "types": "./dist/d1.d.ts",
45
+ "default": "./dist/d1.js"
46
+ },
47
+ "./email": {
48
+ "types": "./dist/email.d.ts",
49
+ "default": "./dist/email.js"
50
+ },
51
+ "./env": {
52
+ "types": "./dist/env.d.ts",
53
+ "default": "./dist/env.js"
54
+ },
55
+ "./http": {
56
+ "types": "./dist/http.d.ts",
57
+ "default": "./dist/http.js"
58
+ },
59
+ "./ids": {
60
+ "types": "./dist/ids.d.ts",
61
+ "default": "./dist/ids.js"
62
+ },
63
+ "./jobs": {
64
+ "types": "./dist/jobs.d.ts",
65
+ "default": "./dist/jobs.js"
66
+ },
67
+ "./mcp": {
68
+ "types": "./dist/mcp.d.ts",
69
+ "default": "./dist/mcp.js"
70
+ },
71
+ "./oauth": {
72
+ "types": "./dist/oauth.d.ts",
73
+ "default": "./dist/oauth.js"
74
+ },
75
+ "./ops-events": {
76
+ "types": "./dist/ops-events.d.ts",
77
+ "default": "./dist/ops-events.js"
78
+ },
79
+ "./pg": {
80
+ "types": "./dist/pg.d.ts",
81
+ "default": "./dist/pg.js"
82
+ },
83
+ "./r2-json": {
84
+ "types": "./dist/r2-json.d.ts",
85
+ "default": "./dist/r2-json.js"
86
+ },
87
+ "./rate-limit": {
88
+ "types": "./dist/rate-limit.d.ts",
89
+ "default": "./dist/rate-limit.js"
90
+ },
91
+ "./seo": {
92
+ "types": "./dist/seo.d.ts",
93
+ "default": "./dist/seo.js"
94
+ },
95
+ "./session": {
96
+ "types": "./dist/session.d.ts",
97
+ "default": "./dist/session.js"
98
+ },
99
+ "./testing": {
100
+ "types": "./dist/testing.d.ts",
101
+ "default": "./dist/testing.js"
102
+ },
103
+ "./time": {
104
+ "types": "./dist/time.d.ts",
105
+ "default": "./dist/time.js"
106
+ }
107
+ },
108
+ "files": [
109
+ "dist",
110
+ "docs",
111
+ "README.md",
112
+ "LICENSE"
113
+ ],
114
+ "devDependencies": {
115
+ "@cloudflare/workers-types": "^4.20260606.0",
116
+ "@vitest/coverage-v8": "^4.1.8",
117
+ "typescript": "^5.9.3",
118
+ "vitest": "^4.0.15"
119
+ },
120
+ "publishConfig": {
121
+ "access": "public"
122
+ },
123
+ "scripts": {
124
+ "build": "tsc -p tsconfig.json",
125
+ "test": "vitest run",
126
+ "test:coverage": "vitest run --coverage",
127
+ "typecheck": "tsc -p tsconfig.json --noEmit"
128
+ }
129
+ }