@specprism/db 0.0.0-stage → 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SpecPrism Contributors (@orphik)
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 CHANGED
@@ -1,3 +1,50 @@
1
- # Temporary Holding Version
1
+ # SpecPrism (`specprism`)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Turn a rough 1-to-2 sentence idea into verified, traceable software specifications (`REQ-*` <-> `TC-*`) without vibe-coding drift.**
4
+
5
+ SpecPrism is a free, open-core AI Product & QA Co-Architect usable directly in your IDE as an **Agent Skill** or **MCP `2026-07-28` Server**, via CLI (`npx specprism`), or visually in the hosted split-pane workbench at **[https://spec-prism.app](https://spec-prism.app)**.
6
+
7
+ - **Full Interactive How-To Guide (`v1.0`):** **[https://spec-prism.app/guide](https://spec-prism.app/guide)**
8
+ - **Verified Reference Specifications Gallery:** **[https://spec-prism.app/examples](https://spec-prism.app/examples)**
9
+
10
+ ## Quickstart
11
+
12
+ ### 1. Visual Web Workbench (Recommended)
13
+ Sign in free with **Google** or **GitHub** at **[https://spec-prism.app](https://spec-prism.app)** to co-design specifications interactively, inspect side-by-side **Annotated Dialect Diffs** across 6 model families (`Claude`, `OpenAI`, `Gemini`, `DeepSeek`, `Qwen`, `Ollama`), get auto-matched Official MCP Registry tools, and export Gherkin/Playwright `.zip` test bundles.
14
+
15
+ ### 2. Install as an Agent Skill or Run via npm CLI
16
+ ```bash
17
+ # Install zero-dependency Agent Skill (Antigravity, Claude Code, Cursor, Codex)
18
+ npx skills add orphik/specprism
19
+
20
+ # Or run the SpecPrism v1.0 CLI & stdio MCP server directly from npm
21
+ npx specprism@latest --help
22
+ npx specprism@latest validate .specprism/spec.json
23
+ npx specprism@latest mcp
24
+ ```
25
+
26
+ ### 3. Connect via Stateless MCP (`2026-07-28`) or Local CLI
27
+ Mint an optional cloud-sync token (`sp_pat_*`) at **[https://spec-prism.app/settings](https://spec-prism.app/settings)** or connect directly via Streamable HTTP / local `stdio` (`npx specprism mcp`):
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "specprism": {
32
+ "url": "https://spec-prism.app/mcp",
33
+ "serverUrl": "https://spec-prism.app/mcp",
34
+ "headers": {
35
+ "Authorization": "Bearer sp_pat_YOUR_OPTIONAL_SYNC_TOKEN"
36
+ }
37
+ }
38
+ }
39
+ }
40
+ ```
41
+
42
+ ## Core 5-Stage Pipeline
43
+ 1. **Socratic Scope & Boundary Triage** — Surfaces 3–4 clickable/editable ambiguity forks (`ASM-*`).
44
+ 2. **Vertical-Slice Feature & Story Decomposition** — Enforces end-to-end UI + Domain + Persistence slices (`US-*`) + Official MCP Registry recommendations.
45
+ 3. **Guided Acceptance Criteria Co-Design** — Generates deterministic Given/When/Then + EARS (`REQ-*`) with inline QA coaching.
46
+ 4. **Traceable Test Blueprint & Dialect Diff Coach** — Maps every `REQ-*` to `TC-*` across Unit, API Contract, and Playwright/Gherkin tiers and compiles vendor-tuned handoff prompts across 6 model dialects.
47
+ 5. **Iterative Delta Mode** — Computes `ADDED`, `MODIFIED`, and `REMOVED` deltas while badging existing tests as Regression Shields.
48
+
49
+ ## Keep SpecPrism Free & Evergreen
50
+ SpecPrism is free to use and open-core (MIT). If SpecPrism saves your team hours of rework, consider supporting ongoing AI/MCP radar maintenance via **[GitHub Sponsors](https://github.com/sponsors/orphik)** or at **[spec-prism.app](https://spec-prism.app)**.
@@ -0,0 +1,5 @@
1
+ import type { PgDatabase, PgQueryResultHKT } from "drizzle-orm/pg-core";
2
+ import * as schema from "./schema/index.js";
3
+ export type AnySpecPrismDrizzleDb = PgDatabase<PgQueryResultHKT, typeof schema>;
4
+ export declare function ensureSpecPrismSchema(db: AnySpecPrismDrizzleDb): Promise<void>;
5
+ //# sourceMappingURL=bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,gBAAgB,EAAE,OAAO,MAAM,CAAC,CAAC;AAEhF,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2LpF"}
@@ -0,0 +1,177 @@
1
+ import { sql } from "drizzle-orm";
2
+ export async function ensureSpecPrismSchema(db) {
3
+ await db.execute(sql `CREATE EXTENSION IF NOT EXISTS vector;`);
4
+ await db.execute(sql `
5
+ CREATE TABLE IF NOT EXISTS "user" (
6
+ "id" text PRIMARY KEY,
7
+ "name" text NOT NULL,
8
+ "email" text NOT NULL UNIQUE,
9
+ "email_verified" boolean NOT NULL DEFAULT false,
10
+ "image" text,
11
+ "is_supporter" boolean NOT NULL DEFAULT false,
12
+ "supporter_since" timestamptz,
13
+ "radar_opt_in" boolean NOT NULL DEFAULT true,
14
+ "daily_free_runs_used" integer NOT NULL DEFAULT 0,
15
+ "daily_quota_reset_at" timestamptz,
16
+ "created_at" timestamptz NOT NULL DEFAULT now(),
17
+ "updated_at" timestamptz NOT NULL DEFAULT now()
18
+ );
19
+ `);
20
+ await db.execute(sql `
21
+ CREATE TABLE IF NOT EXISTS "session" (
22
+ "id" text PRIMARY KEY,
23
+ "expires_at" timestamptz NOT NULL,
24
+ "token" text NOT NULL UNIQUE,
25
+ "created_at" timestamptz NOT NULL DEFAULT now(),
26
+ "updated_at" timestamptz NOT NULL DEFAULT now(),
27
+ "ip_address" text,
28
+ "user_agent" text,
29
+ "user_id" text NOT NULL REFERENCES "user"("id") ON DELETE CASCADE
30
+ );
31
+ `);
32
+ await db.execute(sql `
33
+ CREATE TABLE IF NOT EXISTS "account" (
34
+ "id" text PRIMARY KEY,
35
+ "account_id" text NOT NULL,
36
+ "provider_id" text NOT NULL,
37
+ "user_id" text NOT NULL REFERENCES "user"("id") ON DELETE CASCADE,
38
+ "access_token" text,
39
+ "refresh_token" text,
40
+ "id_token" text,
41
+ "access_token_expires_at" timestamptz,
42
+ "refresh_token_expires_at" timestamptz,
43
+ "scope" text,
44
+ "password" text,
45
+ "created_at" timestamptz NOT NULL DEFAULT now(),
46
+ "updated_at" timestamptz NOT NULL DEFAULT now()
47
+ );
48
+ `);
49
+ await db.execute(sql `
50
+ CREATE TABLE IF NOT EXISTS "verification" (
51
+ "id" text PRIMARY KEY,
52
+ "identifier" text NOT NULL,
53
+ "value" text NOT NULL,
54
+ "expires_at" timestamptz NOT NULL,
55
+ "created_at" timestamptz DEFAULT now(),
56
+ "updated_at" timestamptz DEFAULT now()
57
+ );
58
+ `);
59
+ await db.execute(sql `
60
+ CREATE TABLE IF NOT EXISTS "user_api_keys" (
61
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
62
+ "user_id" text NOT NULL REFERENCES "user"("id") ON DELETE CASCADE,
63
+ "provider" text NOT NULL,
64
+ "key_hint" text NOT NULL,
65
+ "encrypted_key" text NOT NULL,
66
+ "created_at" timestamptz NOT NULL DEFAULT now()
67
+ );
68
+ `);
69
+ await db.execute(sql `
70
+ CREATE TABLE IF NOT EXISTS "personal_access_tokens" (
71
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
72
+ "user_id" text NOT NULL REFERENCES "user"("id") ON DELETE CASCADE,
73
+ "label" text NOT NULL,
74
+ "token_hash" text NOT NULL UNIQUE,
75
+ "last_used_at" timestamptz,
76
+ "expires_at" timestamptz,
77
+ "created_at" timestamptz NOT NULL DEFAULT now()
78
+ );
79
+ `);
80
+ await db.execute(sql `
81
+ CREATE TABLE IF NOT EXISTS "supporter_contributions" (
82
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
83
+ "user_id" text REFERENCES "user"("id") ON DELETE SET NULL,
84
+ "rail" text NOT NULL,
85
+ "external_reference_id" text NOT NULL UNIQUE,
86
+ "amount_cents" integer NOT NULL,
87
+ "currency" text NOT NULL DEFAULT 'usd',
88
+ "cadence" text NOT NULL,
89
+ "created_at" timestamptz NOT NULL DEFAULT now()
90
+ );
91
+ `);
92
+ await db.execute(sql `
93
+ CREATE TABLE IF NOT EXISTS "spec_projects" (
94
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
95
+ "owner_id" text REFERENCES "user"("id") ON DELETE CASCADE,
96
+ "slug" text NOT NULL,
97
+ "title" text NOT NULL,
98
+ "visibility" text NOT NULL DEFAULT 'private',
99
+ "latest_iteration_number" integer NOT NULL DEFAULT 1,
100
+ "created_at" timestamptz NOT NULL DEFAULT now(),
101
+ "updated_at" timestamptz NOT NULL DEFAULT now()
102
+ );
103
+ `);
104
+ await db.execute(sql `
105
+ CREATE TABLE IF NOT EXISTS "spec_iterations" (
106
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
107
+ "project_id" uuid NOT NULL REFERENCES "spec_projects"("id") ON DELETE CASCADE,
108
+ "iteration_number" integer NOT NULL,
109
+ "stage" text NOT NULL,
110
+ "raw_prompt" text NOT NULL,
111
+ "target_dialect_id" text NOT NULL DEFAULT 'anthropic-claude',
112
+ "document" jsonb NOT NULL,
113
+ "created_at" timestamptz NOT NULL DEFAULT now(),
114
+ CONSTRAINT "spec_iterations_project_iter_idx" UNIQUE ("project_id", "iteration_number")
115
+ );
116
+ `);
117
+ await db.execute(sql `
118
+ CREATE TABLE IF NOT EXISTS "traceability_links" (
119
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
120
+ "iteration_id" uuid NOT NULL REFERENCES "spec_iterations"("id") ON DELETE CASCADE,
121
+ "story_id" text NOT NULL,
122
+ "req_id" text NOT NULL,
123
+ "test_case_id" text NOT NULL,
124
+ "verification_tier" text NOT NULL,
125
+ "impact_status" text NOT NULL DEFAULT 'regression_shield',
126
+ "created_at" timestamptz NOT NULL DEFAULT now()
127
+ );
128
+ `);
129
+ await db.execute(sql `
130
+ CREATE TABLE IF NOT EXISTS "ai_models" (
131
+ "id" text PRIMARY KEY,
132
+ "provider" text NOT NULL,
133
+ "display_name" text NOT NULL,
134
+ "context_window" integer NOT NULL,
135
+ "max_output_tokens" integer,
136
+ "supports_structured_output" boolean NOT NULL DEFAULT false,
137
+ "supports_tools" boolean NOT NULL DEFAULT false,
138
+ "supports_reasoning" boolean NOT NULL DEFAULT false,
139
+ "input_cost_per_million_usd" numeric(10, 4),
140
+ "output_cost_per_million_usd" numeric(10, 4),
141
+ "source_catalog" text NOT NULL,
142
+ "source_etag" text,
143
+ "raw_metadata" jsonb,
144
+ "synced_at" timestamptz NOT NULL DEFAULT now()
145
+ );
146
+ `);
147
+ await db.execute(sql `
148
+ CREATE TABLE IF NOT EXISTS "mcp_servers" (
149
+ "id" text PRIMARY KEY,
150
+ "display_name" text NOT NULL,
151
+ "description" text NOT NULL,
152
+ "transport" text NOT NULL,
153
+ "endpoint_or_command" text NOT NULL,
154
+ "repository_url" text,
155
+ "tags" jsonb NOT NULL DEFAULT '[]'::jsonb,
156
+ "embedding" vector(384),
157
+ "synced_at" timestamptz NOT NULL DEFAULT now()
158
+ );
159
+ `);
160
+ await db.execute(sql `
161
+ CREATE TABLE IF NOT EXISTS "radar_events" (
162
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
163
+ "source" text NOT NULL,
164
+ "category" text NOT NULL,
165
+ "external_slug" text NOT NULL UNIQUE,
166
+ "title" text NOT NULL,
167
+ "summary" text NOT NULL,
168
+ "source_url" text,
169
+ "suggested_dialect_id" text,
170
+ "draft_pr_url" text,
171
+ "admin_alert_sent_at" timestamptz,
172
+ "digest_included_at" timestamptz,
173
+ "created_at" timestamptz NOT NULL DEFAULT now()
174
+ );
175
+ `);
176
+ }
177
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAMlC,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,EAAyB;IACnE,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA,wCAAwC,CAAC,CAAC;IAE9D,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;GAenB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;;;GAWnB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;GAgBnB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;GASnB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;GASnB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;;GAUnB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;;;GAWnB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;;;GAWnB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;;;;GAYnB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;;;GAWnB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;GAiBnB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;;;;GAYnB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;GAenB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type AnySpecPrismDrizzleDb } from "./bootstrap.js";
2
+ export interface SpecPrismDbConnection {
3
+ db: AnySpecPrismDrizzleDb;
4
+ engine: "pglite" | "postgres";
5
+ close: () => Promise<void>;
6
+ }
7
+ export declare function createSpecPrismDb(rawDatabaseUrl?: string, options?: {
8
+ autoBootstrap?: boolean;
9
+ }): Promise<SpecPrismDbConnection>;
10
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,qBAAqB,EAAyB,MAAM,gBAAgB,CAAC;AAGnF,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,qBAAqB,CAAC;IAC1B,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC9B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,wBAAsB,iBAAiB,CACrC,cAAc,CAAC,EAAE,MAAM,EACvB,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAA4B,GAC7D,OAAO,CAAC,qBAAqB,CAAC,CA+ChC"}
package/dist/client.js ADDED
@@ -0,0 +1,53 @@
1
+ import { mkdirSync } from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ import { PGlite } from "@electric-sql/pglite";
4
+ import { vector } from "@electric-sql/pglite/vector";
5
+ import { drizzle as drizzlePglite } from "drizzle-orm/pglite";
6
+ import { drizzle as drizzlePostgresJs } from "drizzle-orm/postgres-js";
7
+ import postgres from "postgres";
8
+ import { ensureSpecPrismSchema } from "./bootstrap.js";
9
+ import * as schema from "./schema/index.js";
10
+ export async function createSpecPrismDb(rawDatabaseUrl, options = { autoBootstrap: true }) {
11
+ const url = (rawDatabaseUrl ?? process.env.DATABASE_URL ?? "pglite://./.specprism/pgdata").trim();
12
+ if (url.startsWith("postgres://") || url.startsWith("postgresql://")) {
13
+ const client = postgres(url, {
14
+ max: 10,
15
+ idle_timeout: 20,
16
+ connect_timeout: 10,
17
+ });
18
+ const db = drizzlePostgresJs(client, { schema });
19
+ if (options.autoBootstrap) {
20
+ await ensureSpecPrismSchema(db);
21
+ }
22
+ return {
23
+ db,
24
+ engine: "postgres",
25
+ close: async () => {
26
+ await client.end({ timeout: 5 });
27
+ },
28
+ };
29
+ }
30
+ // Zero-config embedded PostgreSQL via PGlite (+ pgvector WASM extension)
31
+ let dataDir;
32
+ if (url !== "memory://" && url !== "pglite://memory") {
33
+ const cleanPath = url.replace(/^pglite:\/\//, "");
34
+ dataDir = resolve(process.cwd(), cleanPath);
35
+ mkdirSync(dirname(dataDir), { recursive: true });
36
+ }
37
+ const pg = await PGlite.create({
38
+ dataDir,
39
+ extensions: { vector },
40
+ });
41
+ const db = drizzlePglite(pg, { schema });
42
+ if (options.autoBootstrap) {
43
+ await ensureSpecPrismSchema(db);
44
+ }
45
+ return {
46
+ db,
47
+ engine: "pglite",
48
+ close: async () => {
49
+ await pg.close();
50
+ },
51
+ };
52
+ }
53
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAA8B,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAQ5C,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,cAAuB,EACvB,UAAuC,EAAE,aAAa,EAAE,IAAI,EAAE;IAE9D,MAAM,GAAG,GAAG,CAAC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,8BAA8B,CAAC,CAAC,IAAI,EAAE,CAAC;IAElG,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACrE,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,EAAE;YAC3B,GAAG,EAAE,EAAE;YACP,YAAY,EAAE,EAAE;YAChB,eAAe,EAAE,EAAE;SACpB,CAAC,CAAC;QACH,MAAM,EAAE,GAAG,iBAAiB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAqC,CAAC;QACrF,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;YAC1B,MAAM,qBAAqB,CAAC,EAAE,CAAC,CAAC;QAClC,CAAC;QACD,OAAO;YACL,EAAE;YACF,MAAM,EAAE,UAAU;YAClB,KAAK,EAAE,KAAK,IAAI,EAAE;gBAChB,MAAM,MAAM,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;YACnC,CAAC;SACF,CAAC;IACJ,CAAC;IAED,yEAAyE;IACzE,IAAI,OAA2B,CAAC;IAChC,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,iBAAiB,EAAE,CAAC;QACrD,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAClD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;QAC5C,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QAC7B,OAAO;QACP,UAAU,EAAE,EAAE,MAAM,EAAE;KACvB,CAAC,CAAC;IACH,MAAM,EAAE,GAAG,aAAa,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAqC,CAAC;IAE7E,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;QAC1B,MAAM,qBAAqB,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IAED,OAAO;QACL,EAAE;QACF,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function encryptSecret(plaintext: string, encryptionKey: string): string;
2
+ export declare function decryptSecret(envelope: string, encryptionKey: string): string;
3
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAaA,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAe9E;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAiB7E"}
package/dist/crypto.js ADDED
@@ -0,0 +1,45 @@
1
+ import { createCipheriv, createDecipheriv, createHash, randomBytes } from "node:crypto";
2
+ const ALGORITHM = "aes-256-gcm";
3
+ const IV_BYTES = 12;
4
+ const VERSION_PREFIX = "v1";
5
+ function deriveKeyBuffer(rawKeyMaterial) {
6
+ if (/^[0-9a-fA-F]{64}$/.test(rawKeyMaterial)) {
7
+ return Buffer.from(rawKeyMaterial, "hex");
8
+ }
9
+ return createHash("sha256").update(rawKeyMaterial, "utf8").digest();
10
+ }
11
+ export function encryptSecret(plaintext, encryptionKey) {
12
+ if (!encryptionKey || encryptionKey.length < 16) {
13
+ throw new Error("Encryption key must be at least 16 characters.");
14
+ }
15
+ const key = deriveKeyBuffer(encryptionKey);
16
+ const iv = randomBytes(IV_BYTES);
17
+ const cipher = createCipheriv(ALGORITHM, key, iv);
18
+ const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
19
+ const authTag = cipher.getAuthTag();
20
+ return [
21
+ VERSION_PREFIX,
22
+ iv.toString("base64url"),
23
+ authTag.toString("base64url"),
24
+ encrypted.toString("base64url"),
25
+ ].join(":");
26
+ }
27
+ export function decryptSecret(envelope, encryptionKey) {
28
+ const parts = envelope.split(":");
29
+ if (parts.length !== 4 || parts[0] !== VERSION_PREFIX) {
30
+ throw new Error("Unsupported or malformed encrypted secret envelope.");
31
+ }
32
+ const [, ivB64, tagB64, dataB64] = parts;
33
+ if (!ivB64 || !tagB64 || !dataB64) {
34
+ throw new Error("Malformed encrypted secret segments.");
35
+ }
36
+ const key = deriveKeyBuffer(encryptionKey);
37
+ const decipher = createDecipheriv(ALGORITHM, key, Buffer.from(ivB64, "base64url"));
38
+ decipher.setAuthTag(Buffer.from(tagB64, "base64url"));
39
+ const decrypted = Buffer.concat([
40
+ decipher.update(Buffer.from(dataB64, "base64url")),
41
+ decipher.final(),
42
+ ]);
43
+ return decrypted.toString("utf8");
44
+ }
45
+ //# sourceMappingURL=crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExF,MAAM,SAAS,GAAG,aAAa,CAAC;AAChC,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,SAAS,eAAe,CAAC,cAAsB;IAC7C,IAAI,mBAAmB,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;QAC7C,OAAO,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,SAAiB,EAAE,aAAqB;IACpE,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IACD,MAAM,GAAG,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,EAAE,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACpF,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IACpC,OAAO;QACL,cAAc;QACd,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;QACxB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC7B,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC;KAChC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,aAAqB;IACnE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,cAAc,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IACD,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;IACzC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,GAAG,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IACnF,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;QAC9B,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAClD,QAAQ,CAAC,KAAK,EAAE;KACjB,CAAC,CAAC;IACH,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from "./schema/index.js";
2
+ export * from "./bootstrap.js";
3
+ export * from "./client.js";
4
+ export * from "./crypto.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./schema/index.js";
2
+ export * from "./bootstrap.js";
3
+ export * from "./client.js";
4
+ export * from "./crypto.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { createSpecPrismDb } from "./client.js";
2
+ async function main() {
3
+ const conn = await createSpecPrismDb(process.env.DATABASE_URL, { autoBootstrap: true });
4
+ console.log(`[@specprism/db] Schema ensured successfully on engine=${conn.engine}.`);
5
+ await conn.close();
6
+ }
7
+ main().catch((err) => {
8
+ console.error("[@specprism/db] Migration failed:", err);
9
+ process.exit(1);
10
+ });
11
+ //# sourceMappingURL=migrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IACxF,OAAO,CAAC,GAAG,CAAC,yDAAyD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACrF,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;AACrB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAC;IACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./platform.js";
2
+ export * from "./specs.js";
3
+ export * from "./registries.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./platform.js";
2
+ export * from "./specs.js";
3
+ export * from "./registries.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}