@niscorp/strata 0.1.3 → 0.1.5
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 +56 -0
- package/README.md +2 -2
- package/dist/check/index.cjs +23 -228
- package/dist/check/index.cjs.map +1 -1
- package/dist/check/index.js +2 -2
- package/dist/{chunk-274M232S.js → chunk-4BLHBVSC.js} +3 -3
- package/dist/{chunk-274M232S.js.map → chunk-4BLHBVSC.js.map} +1 -1
- package/dist/{chunk-U5CPF4LQ.js → chunk-5KTXEN43.js} +3 -3
- package/dist/{chunk-U5CPF4LQ.js.map → chunk-5KTXEN43.js.map} +1 -1
- package/dist/{chunk-EGFF63GA.js → chunk-AKKWEXO2.js} +2 -2
- package/dist/{chunk-EGFF63GA.js.map → chunk-AKKWEXO2.js.map} +1 -1
- package/dist/chunk-ATHZ7HT5.cjs +18 -0
- package/dist/chunk-ATHZ7HT5.cjs.map +1 -0
- package/dist/chunk-CL5DF2IQ.cjs +192 -0
- package/dist/chunk-CL5DF2IQ.cjs.map +1 -0
- package/dist/chunk-IHYBGLNW.cjs +161 -0
- package/dist/chunk-IHYBGLNW.cjs.map +1 -0
- package/dist/chunk-KNBS3AJZ.cjs +223 -0
- package/dist/chunk-KNBS3AJZ.cjs.map +1 -0
- package/dist/{chunk-TWAEZHTB.js → chunk-OLDORFOQ.js} +4 -4
- package/dist/{chunk-TWAEZHTB.js.map → chunk-OLDORFOQ.js.map} +1 -1
- package/dist/{chunk-2FIZEJXW.js → chunk-WU3OJHVZ.js} +4 -4
- package/dist/{chunk-2FIZEJXW.js.map → chunk-WU3OJHVZ.js.map} +1 -1
- package/dist/chunk-YXFEJJMC.cjs +136 -0
- package/dist/chunk-YXFEJJMC.cjs.map +1 -0
- package/dist/index.cjs +75 -330
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/node/index.cjs +14 -493
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +5 -5
- package/dist/{plan-BEIlXVUt.d.cts → plan-CxuteSH1.d.cts} +2 -2
- package/dist/{plan-BAewc8DG.d.ts → plan-mFmdh0qT.d.ts} +2 -2
- package/dist/postgres/index.cjs +30 -198
- package/dist/postgres/index.cjs.map +1 -1
- package/dist/postgres/index.d.cts +7 -2
- package/dist/postgres/index.d.ts +7 -2
- package/dist/postgres/index.js +17 -3
- package/dist/postgres/index.js.map +1 -1
- package/dist/upgrade/index.cjs +19 -240
- package/dist/upgrade/index.cjs.map +1 -1
- package/dist/upgrade/index.js +3 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schema.ts","../src/checksum.ts","../src/plan.ts"],"names":[],"mappings":";;;AAiBO,IAAM,WAAA,GAAc;AAIpB,IAAM,aAAA,GAAgB;AAItB,IAAM,SAAA,GAAY;AAClB,IAAM,QAAA,GAAW;AAOjB,IAAM,UAAA,GAAa;AAEnB,IAAM,aAAA,GAAgB,EAC1B,MAAA,CAAO;AAAA,EACN,IAAA,EAAM,CAAA,CAAE,OAAA,CAAQ,KAAK,CAAA;AAAA,EACrB,KAAK,CAAA,CACF,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,QAAA;AAAA,IACC;AAAA;AAGN,CAAC,CAAA,CACA,MAAA,EAAO,CACP,QAAA,CAAS,yEAAyE;AAE9E,IAAM,kBAAA,GAAqB,EAC/B,MAAA,CAAO;AAAA,EACN,IAAA,EAAM,CAAA,CAAE,OAAA,CAAQ,UAAU,CAAA;AAAA,EAC1B,EAAA,EAAI,EACD,MAAA,EAAO,CACP,MAAM,QAAQ,CAAA,CACd,SAAS,0GAAqG,CAAA;AAAA,EACjH,SAAA,EAAW,CAAA,CACR,OAAA,EAAQ,CACR,QAAA;AAAA,IACC;AAAA;AAIN,CAAC,CAAA,CACA,MAAA,EAAO,CACP,QAAA,CAAS,iDAAiD;AAEtD,IAA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A4C,KAAK,QAAA,CAAS,GAAA,CAAI,CAAC,CAAA,KAAM,GAAG,CAAA,CAAE,IAAI,KAAK,CAAA,CAAE,MAAM,EAAE,CAAC,CAAA;AAClI","file":"chunk-U5CPF4LQ.js","sourcesContent":["import { z } from 'zod';\n\n// ═══════════════════════════════════════════════════════════════\n// The grammar of a migration.\n//\n// A SEQUENCE is an append-only list of migrations owned by one grammar owner —\n// a package's tables (`nisc.vex.cache`), a package's documents (`nisc.nova`,\n// later), an app's own (`midas.app`). A migration's number is its POSITION, so\n// the sequence's version is its length: nobody bumps a number, you append.\n//\n// Sequences are data. They are authored in TS for type-checking, but nothing\n// here is a function, so a sequence can be stored, shipped and inspected like\n// every other nisc artifact — and is parsed at the boundary like one.\n// ═══════════════════════════════════════════════════════════════\n\n// Namespaced, lowercase: `<owner>.<name>[.<name>…]`. The owner prefix keeps two\n// packages (or a package and an app) from ever claiming the same sequence.\nexport const SEQUENCE_ID = /^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$/;\n\n// `<sequence>/<n>` — how a migration is named everywhere: the ledger, a\n// dependency, an error.\nexport const MIGRATION_REF = /^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+\\/[1-9][0-9]*$/;\n\n// A document kind, named by its owner: `<sequence>/<kind>`, e.g.\n// \"nisc.nova/layout\". The kind part is a plain lowercase word.\nexport const KIND_NAME = /^[a-z][a-z0-9-]*$/;\nexport const KIND_REF = /^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+\\/[a-z][a-z0-9-]*$/;\n\n// Where, inside a document, another document sits. Dot-separated keys, with\n// two wildcards that say WHICH shape they cross — `children[]` is every item of\n// the array at `children`, `endpoints.*` every value of the record at\n// `endpoints`. Kept apart on purpose: nova's `children` is a single node OR an\n// array, and one wildcard for both would read a lone node's `props` as layouts.\nexport const EMBED_PATH = /^([A-Za-z_$][\\w$]*|\\*)(\\[\\])?(\\.([A-Za-z_$][\\w$]*|\\*)(\\[\\])?)*$/;\n\nexport const SqlStepSchema = z\n .object({\n kind: z.literal('sql'),\n sql: z\n .string()\n .min(1)\n .describe(\n 'ONE SQL statement. A driver that prepares statements (PGlite, pg with parameters) refuses a string ' +\n 'carrying several — split them into steps rather than joining them with semicolons.',\n ),\n })\n .strict()\n .describe('A statement run against the database, inside the migration transaction.');\n\nexport const DocumentStepSchema = z\n .object({\n kind: z.literal('document'),\n at: z\n .string()\n .regex(KIND_REF)\n .describe('The kind of document this step rewrites, e.g. \"nisc.nova/layout\" — wherever one sits, at any depth.'),\n transform: z\n .unknown()\n .describe(\n 'A transform config (Prism) run by the injected evaluator over { document, path }: `document` is ONE document of ' +\n 'the `at` kind, `path` where it sits. It returns that document rewritten. Nested documents are found by the ' +\n 'grammar\\'s embeddings and rewritten on their own, deepest first — a transform only ever sees one flat node.',\n ),\n })\n .strict()\n .describe('A rewrite of stored JSON documents of one kind.');\n\nexport const StepSchema = z.discriminatedUnion('kind', [SqlStepSchema, DocumentStepSchema]);\n\nexport const DocumentKindSchema = z\n .object({\n embeds: z\n .record(z.string().regex(EMBED_PATH), z.string().regex(KIND_REF))\n .optional()\n .describe('Where other documents sit inside this one: path → the kind found there (possibly this kind itself).'),\n })\n .strict();\n\nexport const MigrationSchema = z\n .object({\n description: z\n .string()\n .min(1)\n .describe('One sentence: what this migration does. It is the changelog line and the ledger\\'s description.'),\n steps: z\n .array(StepSchema)\n .describe(\n 'Applied in order, in the same transaction as every other pending migration. Empty is a MARKER: ' +\n 'the version moves and nothing runs — how an addition to a strict grammar tells older readers to refuse.',\n ),\n dependsOn: z\n .array(z.string().regex(MIGRATION_REF))\n .optional()\n .describe('Migrations of OTHER sequences that must be applied first, each as \"<sequence>/<n>\".'),\n })\n .strict();\n\nexport const SequenceSchema = z\n .object({\n id: z.string().regex(SEQUENCE_ID).describe('Namespaced and lowercase, e.g. \"nisc.vex.cache\" or \"midas.app\".'),\n documents: z\n .record(z.string().regex(KIND_NAME), DocumentKindSchema)\n .optional()\n .describe('The document kinds this sequence owns (a GRAMMAR sequence), each named \"<id>/<kind>\" elsewhere.'),\n migrations: z\n .array(MigrationSchema)\n .describe('Append-only. A migration is numbered by its position (from 1); the sequence\\'s version is its length.'),\n })\n .strict()\n // TWO KINDS OF OWNER. A table sequence (sql steps) is recorded per DATABASE,\n // in its ledger. A grammar sequence (document steps) is tracked per DOCUMENT,\n // by the stamp the document carries — because documents travel: an add-on\n // built on older code submits older documents to a newer host. One sequence\n // cannot be both; the two versions would mean different things.\n .superRefine((sequence, ctx) => {\n const kinds = new Set(sequence.migrations.flatMap((m) => m.steps.map((s) => s.kind)));\n if (kinds.has('sql') && (kinds.has('document') || sequence.documents !== undefined)) {\n ctx.addIssue({\n code: 'custom',\n message: 'A sequence either owns tables (sql steps) or documents (document steps and `documents`), not both.',\n });\n }\n });\n\nexport type SqlStep = z.infer<typeof SqlStepSchema>;\nexport type DocumentStep = z.infer<typeof DocumentStepSchema>;\nexport type DocumentKind = z.infer<typeof DocumentKindSchema>;\nexport type Step = z.infer<typeof StepSchema>;\nexport type Migration = z.infer<typeof MigrationSchema>;\nexport type Sequence = z.infer<typeof SequenceSchema>;\n","import type { Migration } from './schema';\n\n// ═══════════════════════════════════════════════════════════════\n// What a migration DID, as a hash — the ledger's proof that the code still says\n// what the database ran.\n//\n// Over the steps only. The description is prose: fixing a typo in it must not\n// read as an edited migration. `dependsOn` orders, it does not act. The steps\n// are the effect, and changing an applied step is the one thing that has to\n// be refused — the database already holds the old effect.\n//\n// For the same reason a step's SQL is hashed without its full-line comments\n// (`-- …` on a line of its own) and without trailing whitespace: a migration\n// can carry its documentation verbatim, and rewording it is not an edit.\n//\n// WebCrypto (SHA-256), which Node ≥ 22 and every browser carry as\n// `crypto.subtle` — the same primitive Prism fingerprints with, so strata runs\n// unchanged in a server, a test and the showroom page.\n// ═══════════════════════════════════════════════════════════════\n\n// Sorted keys, recursively: the same value always serializes the same way,\n// whatever order its object literal was written in.\nconst canonical = (value: unknown): string => {\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;\n if (value !== null && typeof value === 'object') {\n const entries = Object.entries(value)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(',')}}`;\n }\n return JSON.stringify(value);\n};\n\nconst effectOf = (sql: string): string =>\n sql\n .split('\\n')\n .filter((line) => !line.trimStart().startsWith('--'))\n .map((line) => line.trimEnd())\n .join('\\n')\n .trim();\n\nexport const checksumOf = async (migration: Migration): Promise<string> => {\n const steps = migration.steps.map((step) => (step.kind === 'sql' ? { ...step, sql: effectOf(step.sql) } : step));\n const bytes = new TextEncoder().encode(canonical(steps));\n const digest = await crypto.subtle.digest('SHA-256', bytes);\n return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('');\n};\n","import { SequenceSchema, type DocumentKind, type Sequence, type Step } from './schema';\nimport { checksumOf } from './checksum';\nimport { StrataError, type StrataErrorCode } from './errors';\n\n// ═══════════════════════════════════════════════════════════════\n// The plan — what the code says, against what the database has run.\n//\n// Pure: sequences and ledger rows in, a plan out. No database, no clock. The\n// postgres runner reads the ledger, calls this, and applies what it says; a\n// showroom page or a CI check can call it with a ledger it made up.\n// ═══════════════════════════════════════════════════════════════\n\n// A migration the code declares, numbered and hashed.\nexport type PreparedMigration = {\n sequence: string;\n n: number;\n ref: string;\n description: string;\n checksum: string;\n steps: readonly Step[];\n dependsOn: readonly string[];\n};\n\nexport type PreparedSequence = {\n id: string;\n // A grammar sequence owns documents (tracked by stamps); otherwise it owns\n // tables (tracked by a database's ledger). See SequenceSchema.\n grammar: boolean;\n documents: Readonly<Record<string, DocumentKind>>;\n migrations: readonly PreparedMigration[];\n};\n\n// One row of the ledger, as a runner read it back.\nexport type LedgerRow = { sequence: string; n: number; checksum: string; description: string; appliedAt: string };\n\nexport type Problem = { code: Exclude<StrataErrorCode, 'PENDING' | 'STEP_FAILED' | 'NO_TRANSACTION' | 'UNKNOWN_KIND' | 'WRONG_OWNER'>; detail: string };\n\nexport type Plan = {\n // Already run, per sequence this code knows: how far each one is.\n applied: Readonly<Record<string, number>>;\n // To run, in the order they must run.\n pending: readonly PreparedMigration[];\n // Anything that makes applying unsafe. A plan with problems is never applied.\n problems: readonly Problem[];\n};\n\nconst refOf = (sequence: string, n: number): string => `${sequence}/${n}`;\n\n// Parse, number and hash. Async only for the hash (WebCrypto).\nexport const prepare = async (sequences: readonly Sequence[]): Promise<readonly PreparedSequence[]> => {\n const seen = new Set<string>();\n const prepared: PreparedSequence[] = [];\n for (const input of sequences) {\n const parsed = SequenceSchema.safeParse(input);\n if (!parsed.success) {\n const issues = parsed.error.issues.map((i) => `${i.path.join('.') || '(root)'}: ${i.message}`);\n throw new StrataError('INVALID_SEQUENCE', `A sequence does not parse${typeof input.id === 'string' ? ` (\"${input.id}\")` : ''}.`, issues);\n }\n const sequence = parsed.data;\n if (seen.has(sequence.id)) {\n throw new StrataError('INVALID_SEQUENCE', `Two sequences are both called \"${sequence.id}\" — a sequence id names one owner.`);\n }\n seen.add(sequence.id);\n const migrations: PreparedMigration[] = [];\n for (const [index, migration] of sequence.migrations.entries()) {\n const n = index + 1;\n migrations.push({\n sequence: sequence.id,\n n,\n ref: refOf(sequence.id, n),\n description: migration.description,\n checksum: await checksumOf(migration),\n steps: migration.steps,\n dependsOn: migration.dependsOn ?? [],\n });\n }\n const grammar = sequence.documents !== undefined || sequence.migrations.some((m) => m.steps.some((s) => s.kind === 'document'));\n prepared.push({ id: sequence.id, grammar, documents: sequence.documents ?? {}, migrations });\n }\n return prepared;\n};\n\n// Order: walk the sequences in the order given, and let each run as far as its\n// dependencies allow before moving on; repeat until nothing moves. The same\n// input always yields the same order, and a sequence's own migrations stay\n// together unless a dependency splits them. Shared by the ledger's plan and a\n// document's upgrade, so both order the same migrations the same way.\nexport const orderPending = (\n queues: readonly { waiting: readonly PreparedMigration[] }[],\n alreadyDone: ReadonlySet<string>,\n): { pending: PreparedMigration[]; stuck: PreparedMigration[] } => {\n const done = new Set(alreadyDone);\n const waiting = queues.map((q) => [...q.waiting]);\n const pending: PreparedMigration[] = [];\n let moved = true;\n while (moved) {\n moved = false;\n for (const queue of waiting) {\n for (let head = queue[0]; head !== undefined; head = queue[0]) {\n if (!head.dependsOn.every((d) => done.has(d))) break;\n pending.push(head);\n done.add(head.ref);\n queue.shift();\n moved = true;\n }\n }\n }\n return { pending, stuck: waiting.flat() };\n};\n\nexport const planMigrations = (sequences: readonly PreparedSequence[], ledger: readonly LedgerRow[]): Plan => {\n const problems: Problem[] = [];\n const applied: Record<string, number> = {};\n const done = new Set(ledger.map((row) => refOf(row.sequence, row.n)));\n const byRef = new Map(ledger.map((row) => [refOf(row.sequence, row.n), row]));\n\n const queues: { id: string; waiting: PreparedMigration[] }[] = [];\n for (const sequence of sequences) {\n const rows = ledger.filter((row) => row.sequence === sequence.id);\n applied[sequence.id] = rows.length;\n\n // The database ran migrations this code has never seen: newer code migrated\n // it. Applying ours on top would be guessing — refuse.\n const beyond = rows.filter((row) => row.n > sequence.migrations.length);\n if (beyond.length > 0) {\n problems.push({\n code: 'TOO_NEW',\n detail: `${sequence.id}: the database is at ${Math.max(...rows.map((r) => r.n))}, this code knows ${sequence.migrations.length} — it was migrated by newer code.`,\n });\n }\n\n const waiting: PreparedMigration[] = [];\n for (const migration of sequence.migrations) {\n const row = byRef.get(migration.ref);\n if (row === undefined) {\n waiting.push(migration);\n } else if (row.checksum !== migration.checksum) {\n problems.push({\n code: 'EDITED',\n detail: `${migration.ref} (\"${migration.description}\") was applied ${row.appliedAt} and its steps have changed since. An applied migration is history — append a new one.`,\n });\n }\n }\n // A hole: something later ran, something earlier did not. The ledger was\n // written by hand, or by a different ordering of the same sequence.\n const firstWaiting = waiting[0];\n if (firstWaiting !== undefined && rows.some((row) => row.n > firstWaiting.n)) {\n problems.push({ code: 'EDITED', detail: `${sequence.id}: ${firstWaiting.ref} never ran, but a later migration of the sequence did.` });\n }\n queues.push({ id: sequence.id, waiting });\n }\n\n // Every dependency must be satisfiable by the ledger or by this plan.\n const provided = new Set(sequences.flatMap((s) => s.migrations.map((m) => m.ref)));\n for (const { waiting } of queues) {\n for (const migration of waiting) {\n for (const dependency of migration.dependsOn) {\n if (!done.has(dependency) && !provided.has(dependency)) {\n problems.push({ code: 'UNKNOWN_DEPENDENCY', detail: `${migration.ref} depends on ${dependency}, which nothing provides and the database has not run.` });\n }\n }\n }\n }\n\n const { pending, stuck } = orderPending(queues, done);\n if (stuck.length > 0 && !problems.some((p) => p.code === 'UNKNOWN_DEPENDENCY')) {\n problems.push({ code: 'CYCLE', detail: `These wait on each other and can never run: ${stuck.map((m) => m.ref).join(', ')}.` });\n }\n\n return { applied, pending, problems };\n};\n\n// Throw the plan's problems as one error, named by the first.\nexport const refuseProblems = (plan: Plan): void => {\n const first = plan.problems[0];\n if (first === undefined) return;\n throw new StrataError(first.code, 'The migrations cannot be applied safely.', plan.problems.map((p) => `${p.code}: ${p.detail}`));\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/schema.ts","../src/checksum.ts","../src/plan.ts"],"names":[],"mappings":";;;AAiBO,IAAM,WAAA,GAAc;AAIpB,IAAM,aAAA,GAAgB;AAItB,IAAM,SAAA,GAAY;AAClB,IAAM,QAAA,GAAW;AAOjB,IAAM,UAAA,GAAa;AAEnB,IAAM,aAAA,GAAgB,EAC1B,MAAA,CAAO;AAAA,EACN,IAAA,EAAM,CAAA,CAAE,OAAA,CAAQ,KAAK,CAAA;AAAA,EACrB,KAAK,CAAA,CACF,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,QAAA;AAAA,IACC;AAAA;AAGN,CAAC,CAAA,CACA,MAAA,EAAO,CACP,QAAA,CAAS,yEAAyE;AAE9E,IAAM,kBAAA,GAAqB,EAC/B,MAAA,CAAO;AAAA,EACN,IAAA,EAAM,CAAA,CAAE,OAAA,CAAQ,UAAU,CAAA;AAAA,EAC1B,EAAA,EAAI,E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AAM,cAAA,GAAiB,CAAC,IAAA,KAAqB;AAClD,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,QAAA,CAAS,CAAC,CAAA;AAC7B,EAAA,IAAI,UAAU,MAAA,EAAW;AACzB,EAAA,MAAM,IAAI,WAAA,CAAY,KAAA,CAAM,IAAA,EAAM,0CAAA,EAA4C,KAAK,QAAA,CAAS,GAAA,CAAI,CAAC,CAAA,KAAM,GAAG,CAAA,CAAE,IAAI,KAAK,CAAA,CAAE,MAAM,EAAE,CAAC,CAAA;AAClI","file":"chunk-5KTXEN43.js","sourcesContent":["import { z } from 'zod';\n\n// ═══════════════════════════════════════════════════════════════\n// The grammar of a migration.\n//\n// A SEQUENCE is an append-only list of migrations owned by one grammar owner —\n// a package's tables (`nisc.vex.cache`), a package's documents (`nisc.nova`,\n// later), an app's own (`midas.app`). A migration's number is its POSITION, so\n// the sequence's version is its length: nobody bumps a number, you append.\n//\n// Sequences are data. They are authored in TS for type-checking, but nothing\n// here is a function, so a sequence can be stored, shipped and inspected like\n// every other nisc artifact — and is parsed at the boundary like one.\n// ═══════════════════════════════════════════════════════════════\n\n// Namespaced, lowercase: `<owner>.<name>[.<name>…]`. The owner prefix keeps two\n// packages (or a package and an app) from ever claiming the same sequence.\nexport const SEQUENCE_ID = /^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$/;\n\n// `<sequence>/<n>` — how a migration is named everywhere: the ledger, a\n// dependency, an error.\nexport const MIGRATION_REF = /^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+\\/[1-9][0-9]*$/;\n\n// A document kind, named by its owner: `<sequence>/<kind>`, e.g.\n// \"nisc.nova/layout\". The kind part is a plain lowercase word.\nexport const KIND_NAME = /^[a-z][a-z0-9-]*$/;\nexport const KIND_REF = /^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+\\/[a-z][a-z0-9-]*$/;\n\n// Where, inside a document, another document sits. Dot-separated keys, with\n// two wildcards that say WHICH shape they cross — `children[]` is every item of\n// the array at `children`, `endpoints.*` every value of the record at\n// `endpoints`. Kept apart on purpose: nova's `children` is a single node OR an\n// array, and one wildcard for both would read a lone node's `props` as layouts.\nexport const EMBED_PATH = /^([A-Za-z_$][\\w$]*|\\*)(\\[\\])?(\\.([A-Za-z_$][\\w$]*|\\*)(\\[\\])?)*$/;\n\nexport const SqlStepSchema = z\n .object({\n kind: z.literal('sql'),\n sql: z\n .string()\n .min(1)\n .describe(\n 'ONE SQL statement. A driver that prepares statements (PGlite, pg with parameters) refuses a string ' +\n 'carrying several — split them into steps rather than joining them with semicolons.',\n ),\n })\n .strict()\n .describe('A statement run against the database, inside the migration transaction.');\n\nexport const DocumentStepSchema = z\n .object({\n kind: z.literal('document'),\n at: z\n .string()\n .regex(KIND_REF)\n .describe('The kind of document this step rewrites, e.g. \"nisc.nova/layout\" — wherever one sits, at any depth.'),\n transform: z\n .unknown()\n .describe(\n 'A transform config (Prism) run by the injected evaluator over { document, path }: `document` is ONE document of ' +\n 'the `at` kind, `path` where it sits. It returns that document rewritten. Nested documents are found by the ' +\n 'grammar\\'s embeddings and rewritten on their own, deepest first — a transform only ever sees one flat node.',\n ),\n })\n .strict()\n .describe('A rewrite of stored JSON documents of one kind.');\n\nexport const StepSchema = z.discriminatedUnion('kind', [SqlStepSchema, DocumentStepSchema]);\n\nexport const DocumentKindSchema = z\n .object({\n embeds: z\n .record(z.string().regex(EMBED_PATH), z.string().regex(KIND_REF))\n .optional()\n .describe('Where other documents sit inside this one: path → the kind found there (possibly this kind itself).'),\n })\n .strict();\n\nexport const MigrationSchema = z\n .object({\n description: z\n .string()\n .min(1)\n .describe('One sentence: what this migration does. It is the changelog line and the ledger\\'s description.'),\n steps: z\n .array(StepSchema)\n .describe(\n 'Applied in order, in the same transaction as every other pending migration. Empty is a MARKER: ' +\n 'the version moves and nothing runs — how an addition to a strict grammar tells older readers to refuse.',\n ),\n dependsOn: z\n .array(z.string().regex(MIGRATION_REF))\n .optional()\n .describe('Migrations of OTHER sequences that must be applied first, each as \"<sequence>/<n>\".'),\n })\n .strict();\n\nexport const SequenceSchema = z\n .object({\n id: z.string().regex(SEQUENCE_ID).describe('Namespaced and lowercase, e.g. \"nisc.vex.cache\" or \"midas.app\".'),\n documents: z\n .record(z.string().regex(KIND_NAME), DocumentKindSchema)\n .optional()\n .describe('The document kinds this sequence owns (a GRAMMAR sequence), each named \"<id>/<kind>\" elsewhere.'),\n migrations: z\n .array(MigrationSchema)\n .describe('Append-only. A migration is numbered by its position (from 1); the sequence\\'s version is its length.'),\n })\n .strict()\n // TWO KINDS OF OWNER. A table sequence (sql steps) is recorded per DATABASE,\n // in its ledger. A grammar sequence (document steps) is tracked per DOCUMENT,\n // by the stamp the document carries — because documents travel: an add-on\n // built on older code submits older documents to a newer host. One sequence\n // cannot be both; the two versions would mean different things.\n .superRefine((sequence, ctx) => {\n const kinds = new Set(sequence.migrations.flatMap((m) => m.steps.map((s) => s.kind)));\n if (kinds.has('sql') && (kinds.has('document') || sequence.documents !== undefined)) {\n ctx.addIssue({\n code: 'custom',\n message: 'A sequence either owns tables (sql steps) or documents (document steps and `documents`), not both.',\n });\n }\n });\n\nexport type SqlStep = z.infer<typeof SqlStepSchema>;\nexport type DocumentStep = z.infer<typeof DocumentStepSchema>;\nexport type DocumentKind = z.infer<typeof DocumentKindSchema>;\nexport type Step = z.infer<typeof StepSchema>;\nexport type Migration = z.infer<typeof MigrationSchema>;\nexport type Sequence = z.infer<typeof SequenceSchema>;\n","import type { Migration } from './schema';\n\n// ═══════════════════════════════════════════════════════════════\n// What a migration DID, as a hash — the ledger's proof that the code still says\n// what the database ran.\n//\n// Over the steps only. The description is prose: fixing a typo in it must not\n// read as an edited migration. `dependsOn` orders, it does not act. The steps\n// are the effect, and changing an applied step is the one thing that has to\n// be refused — the database already holds the old effect.\n//\n// For the same reason a step's SQL is hashed without its full-line comments\n// (`-- …` on a line of its own) and without trailing whitespace: a migration\n// can carry its documentation verbatim, and rewording it is not an edit.\n//\n// WebCrypto (SHA-256), which Node ≥ 22 and every browser carry as\n// `crypto.subtle` — the same primitive Prism fingerprints with, so strata runs\n// unchanged in a server, a test and the showroom page.\n// ═══════════════════════════════════════════════════════════════\n\n// Sorted keys, recursively: the same value always serializes the same way,\n// whatever order its object literal was written in.\nconst canonical = (value: unknown): string => {\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;\n if (value !== null && typeof value === 'object') {\n const entries = Object.entries(value)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(',')}}`;\n }\n return JSON.stringify(value);\n};\n\nconst effectOf = (sql: string): string =>\n sql\n .split('\\n')\n .filter((line) => !line.trimStart().startsWith('--'))\n .map((line) => line.trimEnd())\n .join('\\n')\n .trim();\n\nexport const checksumOf = async (migration: Migration): Promise<string> => {\n const steps = migration.steps.map((step) => (step.kind === 'sql' ? { ...step, sql: effectOf(step.sql) } : step));\n const bytes = new TextEncoder().encode(canonical(steps));\n const digest = await crypto.subtle.digest('SHA-256', bytes);\n return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('');\n};\n","import { SequenceSchema, type DocumentKind, type Sequence, type Step } from './schema';\nimport { checksumOf } from './checksum';\nimport { StrataError, type StrataErrorCode } from './errors';\n\n// ═══════════════════════════════════════════════════════════════\n// The plan — what the code says, against what the database has run.\n//\n// Pure: sequences and ledger rows in, a plan out. No database, no clock. The\n// postgres runner reads the ledger, calls this, and applies what it says; a\n// showroom page or a CI check can call it with a ledger it made up.\n// ═══════════════════════════════════════════════════════════════\n\n// A migration the code declares, numbered and hashed.\nexport type PreparedMigration = {\n sequence: string;\n n: number;\n ref: string;\n description: string;\n checksum: string;\n steps: readonly Step[];\n dependsOn: readonly string[];\n};\n\nexport type PreparedSequence = {\n id: string;\n // A grammar sequence owns documents (tracked by stamps); otherwise it owns\n // tables (tracked by a database's ledger). See SequenceSchema.\n grammar: boolean;\n documents: Readonly<Record<string, DocumentKind>>;\n migrations: readonly PreparedMigration[];\n};\n\n// One row of the ledger, as a runner read it back.\nexport type LedgerRow = { sequence: string; n: number; checksum: string; description: string; appliedAt: string };\n\nexport type Problem = { code: Exclude<StrataErrorCode, 'PENDING' | 'STEP_FAILED' | 'DOES_NOT_FIT' | 'NO_TRANSACTION' | 'UNKNOWN_KIND' | 'WRONG_OWNER'>; detail: string };\n\nexport type Plan = {\n // Already run, per sequence this code knows: how far each one is.\n applied: Readonly<Record<string, number>>;\n // To run, in the order they must run.\n pending: readonly PreparedMigration[];\n // Anything that makes applying unsafe. A plan with problems is never applied.\n problems: readonly Problem[];\n};\n\nconst refOf = (sequence: string, n: number): string => `${sequence}/${n}`;\n\n// Parse, number and hash. Async only for the hash (WebCrypto).\nexport const prepare = async (sequences: readonly Sequence[]): Promise<readonly PreparedSequence[]> => {\n const seen = new Set<string>();\n const prepared: PreparedSequence[] = [];\n for (const input of sequences) {\n const parsed = SequenceSchema.safeParse(input);\n if (!parsed.success) {\n const issues = parsed.error.issues.map((i) => `${i.path.join('.') || '(root)'}: ${i.message}`);\n throw new StrataError('INVALID_SEQUENCE', `A sequence does not parse${typeof input.id === 'string' ? ` (\"${input.id}\")` : ''}.`, issues);\n }\n const sequence = parsed.data;\n if (seen.has(sequence.id)) {\n throw new StrataError('INVALID_SEQUENCE', `Two sequences are both called \"${sequence.id}\" — a sequence id names one owner.`);\n }\n seen.add(sequence.id);\n const migrations: PreparedMigration[] = [];\n for (const [index, migration] of sequence.migrations.entries()) {\n const n = index + 1;\n migrations.push({\n sequence: sequence.id,\n n,\n ref: refOf(sequence.id, n),\n description: migration.description,\n checksum: await checksumOf(migration),\n steps: migration.steps,\n dependsOn: migration.dependsOn ?? [],\n });\n }\n const grammar = sequence.documents !== undefined || sequence.migrations.some((m) => m.steps.some((s) => s.kind === 'document'));\n prepared.push({ id: sequence.id, grammar, documents: sequence.documents ?? {}, migrations });\n }\n return prepared;\n};\n\n// Order: walk the sequences in the order given, and let each run as far as its\n// dependencies allow before moving on; repeat until nothing moves. The same\n// input always yields the same order, and a sequence's own migrations stay\n// together unless a dependency splits them. Shared by the ledger's plan and a\n// document's upgrade, so both order the same migrations the same way.\nexport const orderPending = (\n queues: readonly { waiting: readonly PreparedMigration[] }[],\n alreadyDone: ReadonlySet<string>,\n): { pending: PreparedMigration[]; stuck: PreparedMigration[] } => {\n const done = new Set(alreadyDone);\n const waiting = queues.map((q) => [...q.waiting]);\n const pending: PreparedMigration[] = [];\n let moved = true;\n while (moved) {\n moved = false;\n for (const queue of waiting) {\n for (let head = queue[0]; head !== undefined; head = queue[0]) {\n if (!head.dependsOn.every((d) => done.has(d))) break;\n pending.push(head);\n done.add(head.ref);\n queue.shift();\n moved = true;\n }\n }\n }\n return { pending, stuck: waiting.flat() };\n};\n\nexport const planMigrations = (sequences: readonly PreparedSequence[], ledger: readonly LedgerRow[]): Plan => {\n const problems: Problem[] = [];\n const applied: Record<string, number> = {};\n const done = new Set(ledger.map((row) => refOf(row.sequence, row.n)));\n const byRef = new Map(ledger.map((row) => [refOf(row.sequence, row.n), row]));\n\n const queues: { id: string; waiting: PreparedMigration[] }[] = [];\n for (const sequence of sequences) {\n const rows = ledger.filter((row) => row.sequence === sequence.id);\n applied[sequence.id] = rows.length;\n\n // The database ran migrations this code has never seen: newer code migrated\n // it. Applying ours on top would be guessing — refuse.\n const beyond = rows.filter((row) => row.n > sequence.migrations.length);\n if (beyond.length > 0) {\n problems.push({\n code: 'TOO_NEW',\n detail: `${sequence.id}: the database is at ${Math.max(...rows.map((r) => r.n))}, this code knows ${sequence.migrations.length} — it was migrated by newer code.`,\n });\n }\n\n const waiting: PreparedMigration[] = [];\n for (const migration of sequence.migrations) {\n const row = byRef.get(migration.ref);\n if (row === undefined) {\n waiting.push(migration);\n } else if (row.checksum !== migration.checksum) {\n problems.push({\n code: 'EDITED',\n detail: `${migration.ref} (\"${migration.description}\") was applied ${row.appliedAt} and its steps have changed since. An applied migration is history — append a new one.`,\n });\n }\n }\n // A hole: something later ran, something earlier did not. The ledger was\n // written by hand, or by a different ordering of the same sequence.\n const firstWaiting = waiting[0];\n if (firstWaiting !== undefined && rows.some((row) => row.n > firstWaiting.n)) {\n problems.push({ code: 'EDITED', detail: `${sequence.id}: ${firstWaiting.ref} never ran, but a later migration of the sequence did.` });\n }\n queues.push({ id: sequence.id, waiting });\n }\n\n // Every dependency must be satisfiable by the ledger or by this plan.\n const provided = new Set(sequences.flatMap((s) => s.migrations.map((m) => m.ref)));\n for (const { waiting } of queues) {\n for (const migration of waiting) {\n for (const dependency of migration.dependsOn) {\n if (!done.has(dependency) && !provided.has(dependency)) {\n problems.push({ code: 'UNKNOWN_DEPENDENCY', detail: `${migration.ref} depends on ${dependency}, which nothing provides and the database has not run.` });\n }\n }\n }\n }\n\n const { pending, stuck } = orderPending(queues, done);\n if (stuck.length > 0 && !problems.some((p) => p.code === 'UNKNOWN_DEPENDENCY')) {\n problems.push({ code: 'CYCLE', detail: `These wait on each other and can never run: ${stuck.map((m) => m.ref).join(', ')}.` });\n }\n\n return { applied, pending, problems };\n};\n\n// Throw the plan's problems as one error, named by the first.\nexport const refuseProblems = (plan: Plan): void => {\n const first = plan.problems[0];\n if (first === undefined) return;\n throw new StrataError(first.code, 'The migrations cannot be applied safely.', plan.problems.map((p) => `${p.code}: ${p.detail}`));\n};\n"]}
|
|
@@ -12,5 +12,5 @@ ${details.map((d) => ` ${d}`).join("\n")}` : message, options);
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export { StrataError };
|
|
15
|
-
//# sourceMappingURL=chunk-
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
15
|
+
//# sourceMappingURL=chunk-AKKWEXO2.js.map
|
|
16
|
+
//# sourceMappingURL=chunk-AKKWEXO2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"names":[],"mappings":";AA4BO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EAC5B,IAAA;AAAA,EACA,OAAA;AAAA,EAET,YAAY,IAAA,EAAuB,OAAA,EAAiB,OAAA,GAA6B,IAAI,OAAA,EAA+B;AAClH,IAAA,KAAA,CAAM,OAAA,CAAQ,MAAA,GAAS,CAAA,GAAI,CAAA,EAAG,OAAO;AAAA,EAAK,OAAA,CAAQ,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA,GAAK,SAAS,OAAO,CAAA;AACtG,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AACF","file":"chunk-AKKWEXO2.js","sourcesContent":["// Every refusal strata makes, by name. The message is a sentence for a person;\n// the code is for the program that has to decide what to do about it.\nexport type StrataErrorCode =\n // A sequence failed its schema, or two sequences share an id.\n | 'INVALID_SEQUENCE'\n // An applied migration's steps no longer match what the code says it ran.\n | 'EDITED'\n // The database has migrations of a sequence this code does not know yet —\n // it was migrated by newer code.\n | 'TOO_NEW'\n // A `dependsOn` names a migration nobody provides and the ledger lacks.\n | 'UNKNOWN_DEPENDENCY'\n // Pending migrations wait on each other.\n | 'CYCLE'\n // Verify mode found work to do.\n | 'PENDING'\n // A step threw; the whole run was rolled back.\n | 'STEP_FAILED'\n // The run's guard said the result does not fit; the whole run was rolled back.\n | 'DOES_NOT_FIT'\n // The pool cannot hold one connection for a transaction.\n | 'NO_TRANSACTION'\n // A document kind nobody declares — as the root being upgraded, a step's\n // `at`, or an embedding's target.\n | 'UNKNOWN_KIND'\n // A grammar sequence handed to the ledger, or a table sequence to upgrade().\n | 'WRONG_OWNER';\n\nexport class StrataError extends Error {\n readonly code: StrataErrorCode;\n readonly details: readonly string[];\n\n constructor(code: StrataErrorCode, message: string, details: readonly string[] = [], options?: { cause?: unknown }) {\n super(details.length > 0 ? `${message}\\n${details.map((d) => ` ${d}`).join('\\n')}` : message, options);\n this.name = 'StrataError';\n this.code = code;\n this.details = details;\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/errors.ts
|
|
4
|
+
var StrataError = class extends Error {
|
|
5
|
+
code;
|
|
6
|
+
details;
|
|
7
|
+
constructor(code, message, details = [], options) {
|
|
8
|
+
super(details.length > 0 ? `${message}
|
|
9
|
+
${details.map((d) => ` ${d}`).join("\n")}` : message, options);
|
|
10
|
+
this.name = "StrataError";
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.details = details;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.StrataError = StrataError;
|
|
17
|
+
//# sourceMappingURL=chunk-ATHZ7HT5.cjs.map
|
|
18
|
+
//# sourceMappingURL=chunk-ATHZ7HT5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"names":[],"mappings":";;;AA4BO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EAC5B,IAAA;AAAA,EACA,OAAA;AAAA,EAET,YAAY,IAAA,EAAuB,OAAA,EAAiB,OAAA,GAA6B,IAAI,OAAA,EAA+B;AAClH,IAAA,KAAA,CAAM,OAAA,CAAQ,MAAA,GAAS,CAAA,GAAI,CAAA,EAAG,OAAO;AAAA,EAAK,OAAA,CAAQ,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA,GAAK,SAAS,OAAO,CAAA;AACtG,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AACF","file":"chunk-ATHZ7HT5.cjs","sourcesContent":["// Every refusal strata makes, by name. The message is a sentence for a person;\n// the code is for the program that has to decide what to do about it.\nexport type StrataErrorCode =\n // A sequence failed its schema, or two sequences share an id.\n | 'INVALID_SEQUENCE'\n // An applied migration's steps no longer match what the code says it ran.\n | 'EDITED'\n // The database has migrations of a sequence this code does not know yet —\n // it was migrated by newer code.\n | 'TOO_NEW'\n // A `dependsOn` names a migration nobody provides and the ledger lacks.\n | 'UNKNOWN_DEPENDENCY'\n // Pending migrations wait on each other.\n | 'CYCLE'\n // Verify mode found work to do.\n | 'PENDING'\n // A step threw; the whole run was rolled back.\n | 'STEP_FAILED'\n // The run's guard said the result does not fit; the whole run was rolled back.\n | 'DOES_NOT_FIT'\n // The pool cannot hold one connection for a transaction.\n | 'NO_TRANSACTION'\n // A document kind nobody declares — as the root being upgraded, a step's\n // `at`, or an embedding's target.\n | 'UNKNOWN_KIND'\n // A grammar sequence handed to the ledger, or a table sequence to upgrade().\n | 'WRONG_OWNER';\n\nexport class StrataError extends Error {\n readonly code: StrataErrorCode;\n readonly details: readonly string[];\n\n constructor(code: StrataErrorCode, message: string, details: readonly string[] = [], options?: { cause?: unknown }) {\n super(details.length > 0 ? `${message}\\n${details.map((d) => ` ${d}`).join('\\n')}` : message, options);\n this.name = 'StrataError';\n this.code = code;\n this.details = details;\n }\n}\n"]}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkATHZ7HT5_cjs = require('./chunk-ATHZ7HT5.cjs');
|
|
4
|
+
var zod = require('zod');
|
|
5
|
+
|
|
6
|
+
var SEQUENCE_ID = /^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/;
|
|
7
|
+
var MIGRATION_REF = /^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+\/[1-9][0-9]*$/;
|
|
8
|
+
var KIND_NAME = /^[a-z][a-z0-9-]*$/;
|
|
9
|
+
var KIND_REF = /^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+\/[a-z][a-z0-9-]*$/;
|
|
10
|
+
var EMBED_PATH = /^([A-Za-z_$][\w$]*|\*)(\[\])?(\.([A-Za-z_$][\w$]*|\*)(\[\])?)*$/;
|
|
11
|
+
var SqlStepSchema = zod.z.object({
|
|
12
|
+
kind: zod.z.literal("sql"),
|
|
13
|
+
sql: zod.z.string().min(1).describe(
|
|
14
|
+
"ONE SQL statement. A driver that prepares statements (PGlite, pg with parameters) refuses a string carrying several \u2014 split them into steps rather than joining them with semicolons."
|
|
15
|
+
)
|
|
16
|
+
}).strict().describe("A statement run against the database, inside the migration transaction.");
|
|
17
|
+
var DocumentStepSchema = zod.z.object({
|
|
18
|
+
kind: zod.z.literal("document"),
|
|
19
|
+
at: zod.z.string().regex(KIND_REF).describe('The kind of document this step rewrites, e.g. "nisc.nova/layout" \u2014 wherever one sits, at any depth.'),
|
|
20
|
+
transform: zod.z.unknown().describe(
|
|
21
|
+
"A transform config (Prism) run by the injected evaluator over { document, path }: `document` is ONE document of the `at` kind, `path` where it sits. It returns that document rewritten. Nested documents are found by the grammar's embeddings and rewritten on their own, deepest first \u2014 a transform only ever sees one flat node."
|
|
22
|
+
)
|
|
23
|
+
}).strict().describe("A rewrite of stored JSON documents of one kind.");
|
|
24
|
+
var StepSchema = zod.z.discriminatedUnion("kind", [SqlStepSchema, DocumentStepSchema]);
|
|
25
|
+
var DocumentKindSchema = zod.z.object({
|
|
26
|
+
embeds: zod.z.record(zod.z.string().regex(EMBED_PATH), zod.z.string().regex(KIND_REF)).optional().describe("Where other documents sit inside this one: path \u2192 the kind found there (possibly this kind itself).")
|
|
27
|
+
}).strict();
|
|
28
|
+
var MigrationSchema = zod.z.object({
|
|
29
|
+
description: zod.z.string().min(1).describe("One sentence: what this migration does. It is the changelog line and the ledger's description."),
|
|
30
|
+
steps: zod.z.array(StepSchema).describe(
|
|
31
|
+
"Applied in order, in the same transaction as every other pending migration. Empty is a MARKER: the version moves and nothing runs \u2014 how an addition to a strict grammar tells older readers to refuse."
|
|
32
|
+
),
|
|
33
|
+
dependsOn: zod.z.array(zod.z.string().regex(MIGRATION_REF)).optional().describe('Migrations of OTHER sequences that must be applied first, each as "<sequence>/<n>".')
|
|
34
|
+
}).strict();
|
|
35
|
+
var SequenceSchema = zod.z.object({
|
|
36
|
+
id: zod.z.string().regex(SEQUENCE_ID).describe('Namespaced and lowercase, e.g. "nisc.vex.cache" or "midas.app".'),
|
|
37
|
+
documents: zod.z.record(zod.z.string().regex(KIND_NAME), DocumentKindSchema).optional().describe('The document kinds this sequence owns (a GRAMMAR sequence), each named "<id>/<kind>" elsewhere.'),
|
|
38
|
+
migrations: zod.z.array(MigrationSchema).describe("Append-only. A migration is numbered by its position (from 1); the sequence's version is its length.")
|
|
39
|
+
}).strict().superRefine((sequence, ctx) => {
|
|
40
|
+
const kinds = new Set(sequence.migrations.flatMap((m) => m.steps.map((s) => s.kind)));
|
|
41
|
+
if (kinds.has("sql") && (kinds.has("document") || sequence.documents !== void 0)) {
|
|
42
|
+
ctx.addIssue({
|
|
43
|
+
code: "custom",
|
|
44
|
+
message: "A sequence either owns tables (sql steps) or documents (document steps and `documents`), not both."
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// src/checksum.ts
|
|
50
|
+
var canonical = (value) => {
|
|
51
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
52
|
+
if (value !== null && typeof value === "object") {
|
|
53
|
+
const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
54
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(",")}}`;
|
|
55
|
+
}
|
|
56
|
+
return JSON.stringify(value);
|
|
57
|
+
};
|
|
58
|
+
var effectOf = (sql) => sql.split("\n").filter((line) => !line.trimStart().startsWith("--")).map((line) => line.trimEnd()).join("\n").trim();
|
|
59
|
+
var checksumOf = async (migration) => {
|
|
60
|
+
const steps = migration.steps.map((step) => step.kind === "sql" ? { ...step, sql: effectOf(step.sql) } : step);
|
|
61
|
+
const bytes = new TextEncoder().encode(canonical(steps));
|
|
62
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
63
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// src/plan.ts
|
|
67
|
+
var refOf = (sequence, n) => `${sequence}/${n}`;
|
|
68
|
+
var prepare = async (sequences) => {
|
|
69
|
+
const seen = /* @__PURE__ */ new Set();
|
|
70
|
+
const prepared = [];
|
|
71
|
+
for (const input of sequences) {
|
|
72
|
+
const parsed = SequenceSchema.safeParse(input);
|
|
73
|
+
if (!parsed.success) {
|
|
74
|
+
const issues = parsed.error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`);
|
|
75
|
+
throw new chunkATHZ7HT5_cjs.StrataError("INVALID_SEQUENCE", `A sequence does not parse${typeof input.id === "string" ? ` ("${input.id}")` : ""}.`, issues);
|
|
76
|
+
}
|
|
77
|
+
const sequence = parsed.data;
|
|
78
|
+
if (seen.has(sequence.id)) {
|
|
79
|
+
throw new chunkATHZ7HT5_cjs.StrataError("INVALID_SEQUENCE", `Two sequences are both called "${sequence.id}" \u2014 a sequence id names one owner.`);
|
|
80
|
+
}
|
|
81
|
+
seen.add(sequence.id);
|
|
82
|
+
const migrations = [];
|
|
83
|
+
for (const [index, migration] of sequence.migrations.entries()) {
|
|
84
|
+
const n = index + 1;
|
|
85
|
+
migrations.push({
|
|
86
|
+
sequence: sequence.id,
|
|
87
|
+
n,
|
|
88
|
+
ref: refOf(sequence.id, n),
|
|
89
|
+
description: migration.description,
|
|
90
|
+
checksum: await checksumOf(migration),
|
|
91
|
+
steps: migration.steps,
|
|
92
|
+
dependsOn: migration.dependsOn ?? []
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const grammar = sequence.documents !== void 0 || sequence.migrations.some((m) => m.steps.some((s) => s.kind === "document"));
|
|
96
|
+
prepared.push({ id: sequence.id, grammar, documents: sequence.documents ?? {}, migrations });
|
|
97
|
+
}
|
|
98
|
+
return prepared;
|
|
99
|
+
};
|
|
100
|
+
var orderPending = (queues, alreadyDone) => {
|
|
101
|
+
const done = new Set(alreadyDone);
|
|
102
|
+
const waiting = queues.map((q) => [...q.waiting]);
|
|
103
|
+
const pending = [];
|
|
104
|
+
let moved = true;
|
|
105
|
+
while (moved) {
|
|
106
|
+
moved = false;
|
|
107
|
+
for (const queue of waiting) {
|
|
108
|
+
for (let head = queue[0]; head !== void 0; head = queue[0]) {
|
|
109
|
+
if (!head.dependsOn.every((d) => done.has(d))) break;
|
|
110
|
+
pending.push(head);
|
|
111
|
+
done.add(head.ref);
|
|
112
|
+
queue.shift();
|
|
113
|
+
moved = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return { pending, stuck: waiting.flat() };
|
|
118
|
+
};
|
|
119
|
+
var planMigrations = (sequences, ledger) => {
|
|
120
|
+
const problems = [];
|
|
121
|
+
const applied = {};
|
|
122
|
+
const done = new Set(ledger.map((row) => refOf(row.sequence, row.n)));
|
|
123
|
+
const byRef = new Map(ledger.map((row) => [refOf(row.sequence, row.n), row]));
|
|
124
|
+
const queues = [];
|
|
125
|
+
for (const sequence of sequences) {
|
|
126
|
+
const rows = ledger.filter((row) => row.sequence === sequence.id);
|
|
127
|
+
applied[sequence.id] = rows.length;
|
|
128
|
+
const beyond = rows.filter((row) => row.n > sequence.migrations.length);
|
|
129
|
+
if (beyond.length > 0) {
|
|
130
|
+
problems.push({
|
|
131
|
+
code: "TOO_NEW",
|
|
132
|
+
detail: `${sequence.id}: the database is at ${Math.max(...rows.map((r) => r.n))}, this code knows ${sequence.migrations.length} \u2014 it was migrated by newer code.`
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const waiting = [];
|
|
136
|
+
for (const migration of sequence.migrations) {
|
|
137
|
+
const row = byRef.get(migration.ref);
|
|
138
|
+
if (row === void 0) {
|
|
139
|
+
waiting.push(migration);
|
|
140
|
+
} else if (row.checksum !== migration.checksum) {
|
|
141
|
+
problems.push({
|
|
142
|
+
code: "EDITED",
|
|
143
|
+
detail: `${migration.ref} ("${migration.description}") was applied ${row.appliedAt} and its steps have changed since. An applied migration is history \u2014 append a new one.`
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const firstWaiting = waiting[0];
|
|
148
|
+
if (firstWaiting !== void 0 && rows.some((row) => row.n > firstWaiting.n)) {
|
|
149
|
+
problems.push({ code: "EDITED", detail: `${sequence.id}: ${firstWaiting.ref} never ran, but a later migration of the sequence did.` });
|
|
150
|
+
}
|
|
151
|
+
queues.push({ id: sequence.id, waiting });
|
|
152
|
+
}
|
|
153
|
+
const provided = new Set(sequences.flatMap((s) => s.migrations.map((m) => m.ref)));
|
|
154
|
+
for (const { waiting } of queues) {
|
|
155
|
+
for (const migration of waiting) {
|
|
156
|
+
for (const dependency of migration.dependsOn) {
|
|
157
|
+
if (!done.has(dependency) && !provided.has(dependency)) {
|
|
158
|
+
problems.push({ code: "UNKNOWN_DEPENDENCY", detail: `${migration.ref} depends on ${dependency}, which nothing provides and the database has not run.` });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const { pending, stuck } = orderPending(queues, done);
|
|
164
|
+
if (stuck.length > 0 && !problems.some((p) => p.code === "UNKNOWN_DEPENDENCY")) {
|
|
165
|
+
problems.push({ code: "CYCLE", detail: `These wait on each other and can never run: ${stuck.map((m) => m.ref).join(", ")}.` });
|
|
166
|
+
}
|
|
167
|
+
return { applied, pending, problems };
|
|
168
|
+
};
|
|
169
|
+
var refuseProblems = (plan) => {
|
|
170
|
+
const first = plan.problems[0];
|
|
171
|
+
if (first === void 0) return;
|
|
172
|
+
throw new chunkATHZ7HT5_cjs.StrataError(first.code, "The migrations cannot be applied safely.", plan.problems.map((p) => `${p.code}: ${p.detail}`));
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
exports.DocumentKindSchema = DocumentKindSchema;
|
|
176
|
+
exports.DocumentStepSchema = DocumentStepSchema;
|
|
177
|
+
exports.EMBED_PATH = EMBED_PATH;
|
|
178
|
+
exports.KIND_NAME = KIND_NAME;
|
|
179
|
+
exports.KIND_REF = KIND_REF;
|
|
180
|
+
exports.MIGRATION_REF = MIGRATION_REF;
|
|
181
|
+
exports.MigrationSchema = MigrationSchema;
|
|
182
|
+
exports.SEQUENCE_ID = SEQUENCE_ID;
|
|
183
|
+
exports.SequenceSchema = SequenceSchema;
|
|
184
|
+
exports.SqlStepSchema = SqlStepSchema;
|
|
185
|
+
exports.StepSchema = StepSchema;
|
|
186
|
+
exports.checksumOf = checksumOf;
|
|
187
|
+
exports.orderPending = orderPending;
|
|
188
|
+
exports.planMigrations = planMigrations;
|
|
189
|
+
exports.prepare = prepare;
|
|
190
|
+
exports.refuseProblems = refuseProblems;
|
|
191
|
+
//# sourceMappingURL=chunk-CL5DF2IQ.cjs.map
|
|
192
|
+
//# sourceMappingURL=chunk-CL5DF2IQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema.ts","../src/checksum.ts","../src/plan.ts"],"names":["z","StrataError"],"mappings":";;;;;AAiBO,IAAM,WAAA,GAAc;AAIpB,IAAM,aAAA,GAAgB;AAItB,IAAM,SAAA,GAAY;AAClB,IAAM,QAAA,GAAW;AAOjB,IAAM,UAAA,GAAa;AAEnB,IAAM,aAAA,GAAgBA,MAC1B,MAAA,CAAO;AAAA,EACN,IAAA,EAAMA,KAAA,CAAE,OAAA,CAAQ,KAAK,CAAA;AAAA,EACrB,KAAKA,KAAA,CACF,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,QAAA;AA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EAAE,IAAA,EAAM,OAAA,EAAS,MAAA,EAAQ,+CAA+C,KAAA,CAAM,GAAA,CAAI,CAAC,CAAA,KAAM,EAAE,GAAG,CAAA,CAAE,KAAK,IAAI,CAAC,KAAK,CAAA;AAAA,EAC/H;AAEA,EAAA,OAAO,EAAE,OAAA,EAAS,OAAA,EAAS,QAAA,EAAS;AACtC;AAGO,IAAM,cAAA,GAAiB,CAAC,IAAA,KAAqB;AAClD,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,QAAA,CAAS,CAAC,CAAA;AAC7B,EAAA,IAAI,UAAU,MAAA,EAAW;AACzB,EAAA,MAAM,IAAIA,6BAAA,CAAY,KAAA,CAAM,IAAA,EAAM,0CAAA,EAA4C,KAAK,QAAA,CAAS,GAAA,CAAI,CAAC,CAAA,KAAM,GAAG,CAAA,CAAE,IAAI,KAAK,CAAA,CAAE,MAAM,EAAE,CAAC,CAAA;AAClI","file":"chunk-CL5DF2IQ.cjs","sourcesContent":["import { z } from 'zod';\n\n// ═══════════════════════════════════════════════════════════════\n// The grammar of a migration.\n//\n// A SEQUENCE is an append-only list of migrations owned by one grammar owner —\n// a package's tables (`nisc.vex.cache`), a package's documents (`nisc.nova`,\n// later), an app's own (`midas.app`). A migration's number is its POSITION, so\n// the sequence's version is its length: nobody bumps a number, you append.\n//\n// Sequences are data. They are authored in TS for type-checking, but nothing\n// here is a function, so a sequence can be stored, shipped and inspected like\n// every other nisc artifact — and is parsed at the boundary like one.\n// ═══════════════════════════════════════════════════════════════\n\n// Namespaced, lowercase: `<owner>.<name>[.<name>…]`. The owner prefix keeps two\n// packages (or a package and an app) from ever claiming the same sequence.\nexport const SEQUENCE_ID = /^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$/;\n\n// `<sequence>/<n>` — how a migration is named everywhere: the ledger, a\n// dependency, an error.\nexport const MIGRATION_REF = /^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+\\/[1-9][0-9]*$/;\n\n// A document kind, named by its owner: `<sequence>/<kind>`, e.g.\n// \"nisc.nova/layout\". The kind part is a plain lowercase word.\nexport const KIND_NAME = /^[a-z][a-z0-9-]*$/;\nexport const KIND_REF = /^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+\\/[a-z][a-z0-9-]*$/;\n\n// Where, inside a document, another document sits. Dot-separated keys, with\n// two wildcards that say WHICH shape they cross — `children[]` is every item of\n// the array at `children`, `endpoints.*` every value of the record at\n// `endpoints`. Kept apart on purpose: nova's `children` is a single node OR an\n// array, and one wildcard for both would read a lone node's `props` as layouts.\nexport const EMBED_PATH = /^([A-Za-z_$][\\w$]*|\\*)(\\[\\])?(\\.([A-Za-z_$][\\w$]*|\\*)(\\[\\])?)*$/;\n\nexport const SqlStepSchema = z\n .object({\n kind: z.literal('sql'),\n sql: z\n .string()\n .min(1)\n .describe(\n 'ONE SQL statement. A driver that prepares statements (PGlite, pg with parameters) refuses a string ' +\n 'carrying several — split them into steps rather than joining them with semicolons.',\n ),\n })\n .strict()\n .describe('A statement run against the database, inside the migration transaction.');\n\nexport const DocumentStepSchema = z\n .object({\n kind: z.literal('document'),\n at: z\n .string()\n .regex(KIND_REF)\n .describe('The kind of document this step rewrites, e.g. \"nisc.nova/layout\" — wherever one sits, at any depth.'),\n transform: z\n .unknown()\n .describe(\n 'A transform config (Prism) run by the injected evaluator over { document, path }: `document` is ONE document of ' +\n 'the `at` kind, `path` where it sits. It returns that document rewritten. Nested documents are found by the ' +\n 'grammar\\'s embeddings and rewritten on their own, deepest first — a transform only ever sees one flat node.',\n ),\n })\n .strict()\n .describe('A rewrite of stored JSON documents of one kind.');\n\nexport const StepSchema = z.discriminatedUnion('kind', [SqlStepSchema, DocumentStepSchema]);\n\nexport const DocumentKindSchema = z\n .object({\n embeds: z\n .record(z.string().regex(EMBED_PATH), z.string().regex(KIND_REF))\n .optional()\n .describe('Where other documents sit inside this one: path → the kind found there (possibly this kind itself).'),\n })\n .strict();\n\nexport const MigrationSchema = z\n .object({\n description: z\n .string()\n .min(1)\n .describe('One sentence: what this migration does. It is the changelog line and the ledger\\'s description.'),\n steps: z\n .array(StepSchema)\n .describe(\n 'Applied in order, in the same transaction as every other pending migration. Empty is a MARKER: ' +\n 'the version moves and nothing runs — how an addition to a strict grammar tells older readers to refuse.',\n ),\n dependsOn: z\n .array(z.string().regex(MIGRATION_REF))\n .optional()\n .describe('Migrations of OTHER sequences that must be applied first, each as \"<sequence>/<n>\".'),\n })\n .strict();\n\nexport const SequenceSchema = z\n .object({\n id: z.string().regex(SEQUENCE_ID).describe('Namespaced and lowercase, e.g. \"nisc.vex.cache\" or \"midas.app\".'),\n documents: z\n .record(z.string().regex(KIND_NAME), DocumentKindSchema)\n .optional()\n .describe('The document kinds this sequence owns (a GRAMMAR sequence), each named \"<id>/<kind>\" elsewhere.'),\n migrations: z\n .array(MigrationSchema)\n .describe('Append-only. A migration is numbered by its position (from 1); the sequence\\'s version is its length.'),\n })\n .strict()\n // TWO KINDS OF OWNER. A table sequence (sql steps) is recorded per DATABASE,\n // in its ledger. A grammar sequence (document steps) is tracked per DOCUMENT,\n // by the stamp the document carries — because documents travel: an add-on\n // built on older code submits older documents to a newer host. One sequence\n // cannot be both; the two versions would mean different things.\n .superRefine((sequence, ctx) => {\n const kinds = new Set(sequence.migrations.flatMap((m) => m.steps.map((s) => s.kind)));\n if (kinds.has('sql') && (kinds.has('document') || sequence.documents !== undefined)) {\n ctx.addIssue({\n code: 'custom',\n message: 'A sequence either owns tables (sql steps) or documents (document steps and `documents`), not both.',\n });\n }\n });\n\nexport type SqlStep = z.infer<typeof SqlStepSchema>;\nexport type DocumentStep = z.infer<typeof DocumentStepSchema>;\nexport type DocumentKind = z.infer<typeof DocumentKindSchema>;\nexport type Step = z.infer<typeof StepSchema>;\nexport type Migration = z.infer<typeof MigrationSchema>;\nexport type Sequence = z.infer<typeof SequenceSchema>;\n","import type { Migration } from './schema';\n\n// ═══════════════════════════════════════════════════════════════\n// What a migration DID, as a hash — the ledger's proof that the code still says\n// what the database ran.\n//\n// Over the steps only. The description is prose: fixing a typo in it must not\n// read as an edited migration. `dependsOn` orders, it does not act. The steps\n// are the effect, and changing an applied step is the one thing that has to\n// be refused — the database already holds the old effect.\n//\n// For the same reason a step's SQL is hashed without its full-line comments\n// (`-- …` on a line of its own) and without trailing whitespace: a migration\n// can carry its documentation verbatim, and rewording it is not an edit.\n//\n// WebCrypto (SHA-256), which Node ≥ 22 and every browser carry as\n// `crypto.subtle` — the same primitive Prism fingerprints with, so strata runs\n// unchanged in a server, a test and the showroom page.\n// ═══════════════════════════════════════════════════════════════\n\n// Sorted keys, recursively: the same value always serializes the same way,\n// whatever order its object literal was written in.\nconst canonical = (value: unknown): string => {\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;\n if (value !== null && typeof value === 'object') {\n const entries = Object.entries(value)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(',')}}`;\n }\n return JSON.stringify(value);\n};\n\nconst effectOf = (sql: string): string =>\n sql\n .split('\\n')\n .filter((line) => !line.trimStart().startsWith('--'))\n .map((line) => line.trimEnd())\n .join('\\n')\n .trim();\n\nexport const checksumOf = async (migration: Migration): Promise<string> => {\n const steps = migration.steps.map((step) => (step.kind === 'sql' ? { ...step, sql: effectOf(step.sql) } : step));\n const bytes = new TextEncoder().encode(canonical(steps));\n const digest = await crypto.subtle.digest('SHA-256', bytes);\n return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('');\n};\n","import { SequenceSchema, type DocumentKind, type Sequence, type Step } from './schema';\nimport { checksumOf } from './checksum';\nimport { StrataError, type StrataErrorCode } from './errors';\n\n// ═══════════════════════════════════════════════════════════════\n// The plan — what the code says, against what the database has run.\n//\n// Pure: sequences and ledger rows in, a plan out. No database, no clock. The\n// postgres runner reads the ledger, calls this, and applies what it says; a\n// showroom page or a CI check can call it with a ledger it made up.\n// ═══════════════════════════════════════════════════════════════\n\n// A migration the code declares, numbered and hashed.\nexport type PreparedMigration = {\n sequence: string;\n n: number;\n ref: string;\n description: string;\n checksum: string;\n steps: readonly Step[];\n dependsOn: readonly string[];\n};\n\nexport type PreparedSequence = {\n id: string;\n // A grammar sequence owns documents (tracked by stamps); otherwise it owns\n // tables (tracked by a database's ledger). See SequenceSchema.\n grammar: boolean;\n documents: Readonly<Record<string, DocumentKind>>;\n migrations: readonly PreparedMigration[];\n};\n\n// One row of the ledger, as a runner read it back.\nexport type LedgerRow = { sequence: string; n: number; checksum: string; description: string; appliedAt: string };\n\nexport type Problem = { code: Exclude<StrataErrorCode, 'PENDING' | 'STEP_FAILED' | 'DOES_NOT_FIT' | 'NO_TRANSACTION' | 'UNKNOWN_KIND' | 'WRONG_OWNER'>; detail: string };\n\nexport type Plan = {\n // Already run, per sequence this code knows: how far each one is.\n applied: Readonly<Record<string, number>>;\n // To run, in the order they must run.\n pending: readonly PreparedMigration[];\n // Anything that makes applying unsafe. A plan with problems is never applied.\n problems: readonly Problem[];\n};\n\nconst refOf = (sequence: string, n: number): string => `${sequence}/${n}`;\n\n// Parse, number and hash. Async only for the hash (WebCrypto).\nexport const prepare = async (sequences: readonly Sequence[]): Promise<readonly PreparedSequence[]> => {\n const seen = new Set<string>();\n const prepared: PreparedSequence[] = [];\n for (const input of sequences) {\n const parsed = SequenceSchema.safeParse(input);\n if (!parsed.success) {\n const issues = parsed.error.issues.map((i) => `${i.path.join('.') || '(root)'}: ${i.message}`);\n throw new StrataError('INVALID_SEQUENCE', `A sequence does not parse${typeof input.id === 'string' ? ` (\"${input.id}\")` : ''}.`, issues);\n }\n const sequence = parsed.data;\n if (seen.has(sequence.id)) {\n throw new StrataError('INVALID_SEQUENCE', `Two sequences are both called \"${sequence.id}\" — a sequence id names one owner.`);\n }\n seen.add(sequence.id);\n const migrations: PreparedMigration[] = [];\n for (const [index, migration] of sequence.migrations.entries()) {\n const n = index + 1;\n migrations.push({\n sequence: sequence.id,\n n,\n ref: refOf(sequence.id, n),\n description: migration.description,\n checksum: await checksumOf(migration),\n steps: migration.steps,\n dependsOn: migration.dependsOn ?? [],\n });\n }\n const grammar = sequence.documents !== undefined || sequence.migrations.some((m) => m.steps.some((s) => s.kind === 'document'));\n prepared.push({ id: sequence.id, grammar, documents: sequence.documents ?? {}, migrations });\n }\n return prepared;\n};\n\n// Order: walk the sequences in the order given, and let each run as far as its\n// dependencies allow before moving on; repeat until nothing moves. The same\n// input always yields the same order, and a sequence's own migrations stay\n// together unless a dependency splits them. Shared by the ledger's plan and a\n// document's upgrade, so both order the same migrations the same way.\nexport const orderPending = (\n queues: readonly { waiting: readonly PreparedMigration[] }[],\n alreadyDone: ReadonlySet<string>,\n): { pending: PreparedMigration[]; stuck: PreparedMigration[] } => {\n const done = new Set(alreadyDone);\n const waiting = queues.map((q) => [...q.waiting]);\n const pending: PreparedMigration[] = [];\n let moved = true;\n while (moved) {\n moved = false;\n for (const queue of waiting) {\n for (let head = queue[0]; head !== undefined; head = queue[0]) {\n if (!head.dependsOn.every((d) => done.has(d))) break;\n pending.push(head);\n done.add(head.ref);\n queue.shift();\n moved = true;\n }\n }\n }\n return { pending, stuck: waiting.flat() };\n};\n\nexport const planMigrations = (sequences: readonly PreparedSequence[], ledger: readonly LedgerRow[]): Plan => {\n const problems: Problem[] = [];\n const applied: Record<string, number> = {};\n const done = new Set(ledger.map((row) => refOf(row.sequence, row.n)));\n const byRef = new Map(ledger.map((row) => [refOf(row.sequence, row.n), row]));\n\n const queues: { id: string; waiting: PreparedMigration[] }[] = [];\n for (const sequence of sequences) {\n const rows = ledger.filter((row) => row.sequence === sequence.id);\n applied[sequence.id] = rows.length;\n\n // The database ran migrations this code has never seen: newer code migrated\n // it. Applying ours on top would be guessing — refuse.\n const beyond = rows.filter((row) => row.n > sequence.migrations.length);\n if (beyond.length > 0) {\n problems.push({\n code: 'TOO_NEW',\n detail: `${sequence.id}: the database is at ${Math.max(...rows.map((r) => r.n))}, this code knows ${sequence.migrations.length} — it was migrated by newer code.`,\n });\n }\n\n const waiting: PreparedMigration[] = [];\n for (const migration of sequence.migrations) {\n const row = byRef.get(migration.ref);\n if (row === undefined) {\n waiting.push(migration);\n } else if (row.checksum !== migration.checksum) {\n problems.push({\n code: 'EDITED',\n detail: `${migration.ref} (\"${migration.description}\") was applied ${row.appliedAt} and its steps have changed since. An applied migration is history — append a new one.`,\n });\n }\n }\n // A hole: something later ran, something earlier did not. The ledger was\n // written by hand, or by a different ordering of the same sequence.\n const firstWaiting = waiting[0];\n if (firstWaiting !== undefined && rows.some((row) => row.n > firstWaiting.n)) {\n problems.push({ code: 'EDITED', detail: `${sequence.id}: ${firstWaiting.ref} never ran, but a later migration of the sequence did.` });\n }\n queues.push({ id: sequence.id, waiting });\n }\n\n // Every dependency must be satisfiable by the ledger or by this plan.\n const provided = new Set(sequences.flatMap((s) => s.migrations.map((m) => m.ref)));\n for (const { waiting } of queues) {\n for (const migration of waiting) {\n for (const dependency of migration.dependsOn) {\n if (!done.has(dependency) && !provided.has(dependency)) {\n problems.push({ code: 'UNKNOWN_DEPENDENCY', detail: `${migration.ref} depends on ${dependency}, which nothing provides and the database has not run.` });\n }\n }\n }\n }\n\n const { pending, stuck } = orderPending(queues, done);\n if (stuck.length > 0 && !problems.some((p) => p.code === 'UNKNOWN_DEPENDENCY')) {\n problems.push({ code: 'CYCLE', detail: `These wait on each other and can never run: ${stuck.map((m) => m.ref).join(', ')}.` });\n }\n\n return { applied, pending, problems };\n};\n\n// Throw the plan's problems as one error, named by the first.\nexport const refuseProblems = (plan: Plan): void => {\n const first = plan.problems[0];\n if (first === undefined) return;\n throw new StrataError(first.code, 'The migrations cannot be applied safely.', plan.problems.map((p) => `${p.code}: ${p.detail}`));\n};\n"]}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkKNBS3AJZ_cjs = require('./chunk-KNBS3AJZ.cjs');
|
|
4
|
+
var chunkATHZ7HT5_cjs = require('./chunk-ATHZ7HT5.cjs');
|
|
5
|
+
|
|
6
|
+
// src/upgrade/index.ts
|
|
7
|
+
var keyOf = (doc) => `${doc.kind}:${doc.id}`;
|
|
8
|
+
var sortKeys = (value) => {
|
|
9
|
+
if (Array.isArray(value)) return value.map(sortKeys);
|
|
10
|
+
if (typeof value !== "object" || value === null) return value;
|
|
11
|
+
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => [k, sortKeys(v)]));
|
|
12
|
+
};
|
|
13
|
+
var sameJson = (a, b) => JSON.stringify(sortKeys(a)) === JSON.stringify(sortKeys(b));
|
|
14
|
+
var changedStrings = (before, after) => {
|
|
15
|
+
const found = /* @__PURE__ */ new Set();
|
|
16
|
+
const visit = (a, b) => {
|
|
17
|
+
if (JSON.stringify(a) === JSON.stringify(b)) return;
|
|
18
|
+
if (typeof a === "string") {
|
|
19
|
+
found.add(a);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (Array.isArray(a)) {
|
|
23
|
+
a.forEach((item, i) => visit(item, Array.isArray(b) ? b[i] : void 0));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (typeof a === "object" && a !== null) {
|
|
27
|
+
for (const [k, v] of Object.entries(a)) visit(v, typeof b === "object" && b !== null && !Array.isArray(b) ? Reflect.get(b, k) : void 0);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
visit(before, after);
|
|
31
|
+
return [...found].filter((s) => s.length >= 4);
|
|
32
|
+
};
|
|
33
|
+
var planSourceUpgrade = async (options) => {
|
|
34
|
+
const { upgrader, stamp, documents, schemas, describe } = options;
|
|
35
|
+
const seen = /* @__PURE__ */ new Set();
|
|
36
|
+
const planned = [];
|
|
37
|
+
const untouched = [];
|
|
38
|
+
const problems = [];
|
|
39
|
+
for (const doc of documents) {
|
|
40
|
+
const key = keyOf(doc);
|
|
41
|
+
if (seen.has(key)) throw new chunkATHZ7HT5_cjs.StrataError("INVALID_SEQUENCE", `Two artifacts are both ${key} \u2014 an artifact needs one identity to be planned.`);
|
|
42
|
+
seen.add(key);
|
|
43
|
+
const result = upgrader.upgrade(doc.document, { kind: doc.kind, stamp });
|
|
44
|
+
if (sameJson(result.document, doc.document)) {
|
|
45
|
+
untouched.push(key);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
planned.push({
|
|
49
|
+
kind: doc.kind,
|
|
50
|
+
id: doc.id,
|
|
51
|
+
...doc.file === void 0 ? {} : { file: doc.file },
|
|
52
|
+
applied: result.applied,
|
|
53
|
+
changes: chunkKNBS3AJZ_cjs.diffJson(doc.document, result.document),
|
|
54
|
+
expected: result.document
|
|
55
|
+
});
|
|
56
|
+
const schema = schemas?.[doc.kind];
|
|
57
|
+
if (schema !== void 0) {
|
|
58
|
+
const checked = await schema["~standard"].validate(result.document);
|
|
59
|
+
if (checked.issues !== void 0) {
|
|
60
|
+
problems.push(`${key}: the migrated artifact does not pass ${doc.kind}'s current schema \u2014 ${checked.issues.slice(0, 2).map((i) => i.message).join("; ")}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const from = stamp;
|
|
65
|
+
const to = upgrader.stamp;
|
|
66
|
+
const migrations = Object.entries(to).flatMap(
|
|
67
|
+
([id, n]) => Array.from({ length: Math.max(0, n - (from[id] ?? 0)) }, (_, i) => `${id}/${(from[id] ?? 0) + i + 1}`)
|
|
68
|
+
);
|
|
69
|
+
return {
|
|
70
|
+
from,
|
|
71
|
+
to,
|
|
72
|
+
migrations: migrations.map((ref) => ({ ref, description: describe(ref) })),
|
|
73
|
+
documents: planned.sort((a, b) => keyOf(a) < keyOf(b) ? -1 : 1),
|
|
74
|
+
untouched: untouched.sort(),
|
|
75
|
+
problems
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
var verifySourceUpgrade = (options) => {
|
|
79
|
+
const { plan, upgrader, documents } = options;
|
|
80
|
+
const now = new Map(documents.map((d) => [keyOf(d), d]));
|
|
81
|
+
const lines = [];
|
|
82
|
+
for (const want of plan.documents) {
|
|
83
|
+
const key = keyOf(want);
|
|
84
|
+
const got = now.get(key);
|
|
85
|
+
if (got === void 0) {
|
|
86
|
+
lines.push({ ok: false, text: `${key} is gone \u2014 the plan expected it rewritten, not removed` });
|
|
87
|
+
} else if (sameJson(got.document, want.expected)) {
|
|
88
|
+
lines.push({ ok: true, text: `${key} matches its migrated JSON` });
|
|
89
|
+
} else {
|
|
90
|
+
lines.push({ ok: false, text: `${key} does not match its migrated JSON yet`, detail: chunkKNBS3AJZ_cjs.diffJson(got.document, want.expected, 12) });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
for (const key of plan.untouched) {
|
|
94
|
+
const got = now.get(key);
|
|
95
|
+
if (got === void 0) {
|
|
96
|
+
lines.push({ ok: false, text: `${key} is gone \u2014 no migration asked for that` });
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const again = upgrader.upgrade(got.document, { kind: got.kind, stamp: plan.from });
|
|
100
|
+
if (!sameJson(again.document, got.document)) {
|
|
101
|
+
lines.push({ ok: false, text: `${key} was not in the plan, but the migrations would change it now`, detail: chunkKNBS3AJZ_cjs.diffJson(got.document, again.document, 12) });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const known = /* @__PURE__ */ new Set([...plan.documents.map(keyOf), ...plan.untouched]);
|
|
105
|
+
for (const key of now.keys()) {
|
|
106
|
+
if (!known.has(key)) lines.push({ ok: false, text: `${key} is new since the plan \u2014 plan again so it is checked too` });
|
|
107
|
+
}
|
|
108
|
+
const ok = lines.every((l) => l.ok);
|
|
109
|
+
if (ok) lines.push({ ok: true, text: `${plan.untouched.length} artifact(s) no migration touches, still untouched` });
|
|
110
|
+
return { ok, lines };
|
|
111
|
+
};
|
|
112
|
+
var renderReport = (plan, expectedPathOf) => {
|
|
113
|
+
const stamp = (s) => Object.entries(s).map(([k, v]) => `${k} ${v}`).join(", ");
|
|
114
|
+
const out = [
|
|
115
|
+
"# strata upgrade",
|
|
116
|
+
"",
|
|
117
|
+
`The source is written at **${stamp(plan.from)}**; the installed grammars are at **${stamp(plan.to)}**.`,
|
|
118
|
+
"",
|
|
119
|
+
"## Migrations",
|
|
120
|
+
"",
|
|
121
|
+
...plan.migrations.map((m) => `- \`${m.ref}\` \u2014 ${m.description}`),
|
|
122
|
+
""
|
|
123
|
+
];
|
|
124
|
+
if (plan.problems.length > 0) {
|
|
125
|
+
out.push("## Stop: a migration is wrong", "", "These artifacts would not pass their current schema after migrating \u2014 no edit can make `verify` pass. Fix the migration, then plan again.", "", ...plan.problems.map((p) => `- ${p}`), "");
|
|
126
|
+
}
|
|
127
|
+
if (plan.documents.length === 0) {
|
|
128
|
+
out.push("## Nothing to edit", "", `No artifact changes (${plan.untouched.length} checked). Run \`verify\` to move the lock.`, "");
|
|
129
|
+
} else {
|
|
130
|
+
out.push(
|
|
131
|
+
`## ${plan.documents.length} artifact(s) to edit`,
|
|
132
|
+
"",
|
|
133
|
+
"Edit each so that it serialises to EXACTLY its expected JSON (key order aside) \u2014 then run `verify`. Only what is listed changes; every other artifact must stay as it is.",
|
|
134
|
+
""
|
|
135
|
+
);
|
|
136
|
+
for (const doc of plan.documents) {
|
|
137
|
+
out.push(
|
|
138
|
+
`### \`${doc.id}\` (${doc.kind})`,
|
|
139
|
+
"",
|
|
140
|
+
doc.file === void 0 ? "" : `- **File:** \`${doc.file}\``,
|
|
141
|
+
doc.lookIn === void 0 || doc.lookIn.length === 0 ? "" : `- **Look in:** ${doc.lookIn.map((f) => `\`${f}\``).join(", ")} \u2014 where the changing values are written`,
|
|
142
|
+
`- **Migrations:** ${doc.applied.map((r) => `\`${r}\``).join(", ")}`,
|
|
143
|
+
`- **Expected JSON:** \`${expectedPathOf(doc)}\``,
|
|
144
|
+
"- **Changes:**",
|
|
145
|
+
"",
|
|
146
|
+
"```",
|
|
147
|
+
...doc.changes,
|
|
148
|
+
"```",
|
|
149
|
+
""
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return out.filter((line, i, all) => !(line === "" && all[i - 1] === "")).join("\n");
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
exports.changedStrings = changedStrings;
|
|
157
|
+
exports.planSourceUpgrade = planSourceUpgrade;
|
|
158
|
+
exports.renderReport = renderReport;
|
|
159
|
+
exports.verifySourceUpgrade = verifySourceUpgrade;
|
|
160
|
+
//# sourceMappingURL=chunk-IHYBGLNW.cjs.map
|
|
161
|
+
//# sourceMappingURL=chunk-IHYBGLNW.cjs.map
|