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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ yarn-error.log*
.DS_Store
*.pem
.env*.local
.dev.vars
.wrangler/
.gstack/
2 changes: 1 addition & 1 deletion apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"push:sandbox": "bun scripts/push-sandbox.ts",
"start": "next start",
"tunnel": "set -a; [ -f .env ] && . ./.env; set +a; if [ -n \"$CF_TUNNEL_ID\" ]; then cloudflared tunnel --url http://localhost:3000 run \"$CF_TUNNEL_ID\"; fi",
"paykitjs": "tsx --conditions=paykit-source ../../packages/paykit/src/cli/index.ts",
"paykitjs": "bun ../../packages/paykit/src/cli/index.ts",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for the paykit-source export condition in any package.json
rg '"paykit-source"' --type json -n

Repository: getpaykit/paykit

Length of output: 649


Revisit removal of --conditions=paykit-source from CLI invocation

The paykit-source export condition is still actively used throughout the monorepo: it's defined in export maps across packages/paykit, packages/stripe, and packages/polar, and registered as a custom condition in the TypeScript configuration. Removing --conditions=paykit-source from the bun command may cause module resolution failures if the CLI or its dependencies import modules that specify paykit-source export conditions. Either restore the --conditions flag or confirm that none of the CLI's import chain relies on these exports.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/demo/package.json` at line 19, The bun CLI invocation for the paykitjs
script removed the custom export condition and risks breaking module resolution
for exports using the paykit-source condition; either restore the flag by
changing the paykitjs script invocation to include --conditions=paykit-source
when calling bun ../../packages/paykit/src/cli/index.ts, or if you intend to
remove it, perform a project-wide audit (check export maps in packages/paykit,
packages/stripe, packages/polar and the TypeScript custom condition
registration) and run the full build/test cycle to confirm no imports rely on
paykit-source before committing the removal.

"typecheck": "tsc --noEmit",
"push": "bun push:auth && bun push:paykit:polar && bun push:paykit:stripe && bun push:autumn",
"push:auth": "bunx auth migrate --config src/lib/auth.ts --yes",
Expand Down
34 changes: 34 additions & 0 deletions apps/wh/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import fs from "node:fs";
import path from "node:path";

import { defineConfig } from "drizzle-kit";

const d1StateDir = path.resolve(process.cwd(), ".wrangler/state/v3/d1/miniflare-D1DatabaseObject");
const isGenerateCommand = process.argv.includes("generate");

function resolveLocalSqliteFile(): string {
const files = fs
.readdirSync(d1StateDir)
.filter((file) => file.endsWith(".sqlite") && file !== "metadata.sqlite")
.toSorted();

const file = files[0];
if (!file) {
throw new Error(
"No local D1 SQLite database found. Run `bun --filter wh db:migrate:local` first.",
);
}

return path.join(d1StateDir, file);
}

export default defineConfig({
dialect: "sqlite",
out: "./migrations",
schema: "./src/db/schema.ts",
dbCredentials: {
get url() {
return isGenerateCommand ? ":memory:" : resolveLocalSqliteFile();
},
},
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
33 changes: 33 additions & 0 deletions apps/wh/migrations/0000_init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
CREATE TABLE `tunnel` (
`id` text PRIMARY KEY NOT NULL,
`device_token_hash` text NOT NULL,
`provider_id` text NOT NULL,
`environment` text NOT NULL,
`provider_account_id` text NOT NULL,
`provider_webhook_endpoint_id` text,
`status` text NOT NULL DEFAULT 'active',
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
`last_seen_at` integer NOT NULL,
`disabled_at` integer
);

CREATE UNIQUE INDEX `tunnel_device_provider_unique`
ON `tunnel` (`device_token_hash`, `provider_id`, `environment`, `provider_account_id`);

CREATE INDEX `tunnel_device_idx` ON `tunnel` (`device_token_hash`);

CREATE TABLE `delivery` (
`id` text PRIMARY KEY NOT NULL,
`tunnel_id` text NOT NULL,
`method` text NOT NULL,
`headers` text NOT NULL,
`body` text NOT NULL,
`status` text NOT NULL DEFAULT 'pending',
`received_at` integer NOT NULL,
`delivered_at` integer,
FOREIGN KEY (`tunnel_id`) REFERENCES `tunnel`(`id`) ON DELETE cascade
);

CREATE INDEX `delivery_tunnel_status_received_idx`
ON `delivery` (`tunnel_id`, `status`, `received_at`);
5 changes: 5 additions & 0 deletions apps/wh/migrations/0001_delivery-failure-tracking.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DROP INDEX `delivery_tunnel_status_received_idx`;--> statement-breakpoint
ALTER TABLE `delivery` ADD `failed_at` integer;--> statement-breakpoint
ALTER TABLE `delivery` ADD `error` text;--> statement-breakpoint
CREATE INDEX `delivery_tunnel_delivery_idx` ON `delivery` (`tunnel_id`,`delivered_at`,`failed_at`,`received_at`);--> statement-breakpoint
ALTER TABLE `delivery` DROP COLUMN `status`;
215 changes: 215 additions & 0 deletions apps/wh/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
{
"version": "6",
"dialect": "sqlite",
"id": "09df25c0-d0eb-49e5-8c78-c5cac3323bd4",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"delivery": {
"name": "delivery",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"tunnel_id": {
"name": "tunnel_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"method": {
"name": "method",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"headers": {
"name": "headers",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"body": {
"name": "body",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'pending'"
},
"received_at": {
"name": "received_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"delivered_at": {
"name": "delivered_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"delivery_tunnel_status_received_idx": {
"name": "delivery_tunnel_status_received_idx",
"columns": [
"tunnel_id",
"status",
"received_at"
],
"isUnique": false
}
},
"foreignKeys": {
"delivery_tunnel_id_tunnel_id_fk": {
"name": "delivery_tunnel_id_tunnel_id_fk",
"tableFrom": "delivery",
"tableTo": "tunnel",
"columnsFrom": [
"tunnel_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"tunnel": {
"name": "tunnel",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"device_token_hash": {
"name": "device_token_hash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider_id": {
"name": "provider_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"environment": {
"name": "environment",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider_account_id": {
"name": "provider_account_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider_webhook_endpoint_id": {
"name": "provider_webhook_endpoint_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'active'"
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"last_seen_at": {
"name": "last_seen_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"disabled_at": {
"name": "disabled_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"tunnel_device_provider_unique": {
"name": "tunnel_device_provider_unique",
"columns": [
"device_token_hash",
"provider_id",
"environment",
"provider_account_id"
],
"isUnique": true
},
"tunnel_device_idx": {
"name": "tunnel_device_idx",
"columns": [
"device_token_hash"
],
"isUnique": false
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
Loading
Loading