Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/fix-mjs-and-schema-ordering.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@emisso/accounting-api": patch
"@emisso/accounting": patch
---

Fix package `exports` and resolve circular dependency in Drizzle schema.

- `@emisso/accounting-api`: `exports` field referenced `./dist/index.mjs` and `./dist/adapters/next.mjs` which tsup never emits (it produces `.js` for ESM and `.cjs` for CJS). Fixed to point to the actual emitted files. Also swapped `main` to `./dist/index.cjs` for CommonJS consumers.
- `@emisso/accounting-api`: moved `accountingSchema` (the `pgSchema("accounting")` instance) to a dedicated `_schema.ts` file. Previously it was defined in `index.ts`, which re-exported all tables; the tables in turn imported `accountingSchema` from `./index.js`, creating a circular ESM dependency that left `accountingSchema` undefined at table-evaluation time.
- `@emisso/accounting`: patch re-publish to ship the correct `exports` field that was already fixed in the working tree but never published.
12 changes: 6 additions & 6 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
"version": "0.2.0",
"description": "Full API layer — routes, services, and database for @emisso/accounting",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./next": {
"types": "./dist/adapters/next.d.ts",
"import": "./dist/adapters/next.mjs",
"require": "./dist/adapters/next.js"
"import": "./dist/adapters/next.js",
"require": "./dist/adapters/next.cjs"
}
},
"files": [
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/db/schema/_schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { pgSchema } from "drizzle-orm/pg-core";

export const accountingSchema = pgSchema("accounting");
2 changes: 1 addition & 1 deletion packages/api/src/db/schema/accounts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { accountingSchema } from "./index.js";
import { accountingSchema } from "./_schema.js";
import { uuid, text, timestamp, unique } from "drizzle-orm/pg-core";

export const accounts = accountingSchema.table("accounts", {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/db/schema/entry-lines.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { accountingSchema } from "./index.js";
import { accountingSchema } from "./_schema.js";
import { uuid, text, numeric } from "drizzle-orm/pg-core";
import { journalEntries } from "./journal-entries.js";

Expand Down
4 changes: 1 addition & 3 deletions packages/api/src/db/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* All tables live in the PostgreSQL `accounting` schema.
*/

import { pgSchema } from "drizzle-orm/pg-core";

export const accountingSchema = pgSchema("accounting");
export { accountingSchema } from "./_schema.js";

export { accounts } from "./accounts.js";
export type { AccountRow, NewAccountRow } from "./accounts.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/db/schema/journal-entries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { accountingSchema } from "./index.js";
import { accountingSchema } from "./_schema.js";
import { uuid, text, date, integer, timestamp, jsonb } from "drizzle-orm/pg-core";

export const journalEntries = accountingSchema.table("journal_entries", {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/db/schema/periods.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { accountingSchema } from "./index.js";
import { accountingSchema } from "./_schema.js";
import { uuid, integer, text, timestamp, unique } from "drizzle-orm/pg-core";

export const periods = accountingSchema.table("periods", {
Expand Down
Loading