@fjall/payload 0.87.5 → 0.87.10

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.
@@ -8,54 +8,21 @@
8
8
  * - Falls back to DATABASE_URL for local development
9
9
  */
10
10
  import { postgresAdapter } from "@payloadcms/db-postgres";
11
- /** The return type of postgresAdapter */
12
11
  type PostgresAdapterResult = ReturnType<typeof postgresAdapter>;
13
- /**
14
- * Options for the Fjall PostgreSQL adapter.
15
- */
16
12
  export interface FjallPostgresAdapterOptions {
17
- /**
18
- * Path to migrations directory (relative to project root).
19
- * @default './src/migrations'
20
- */
13
+ /** @default './src/migrations' */
21
14
  migrationDir?: string;
22
- /**
23
- * Pre-compiled migrations for production.
24
- * Required for Lambda deployments where filesystem migrations aren't available.
25
- */
26
- prodMigrations?: Array<{
27
- up: (args: {
28
- db: unknown;
29
- payload: unknown;
30
- req: unknown;
31
- }) => Promise<void>;
32
- down: (args: {
33
- db: unknown;
34
- payload: unknown;
35
- req: unknown;
36
- }) => Promise<void>;
37
- name: string;
38
- }>;
15
+ /** Required for Lambda - filesystem migrations aren't available at runtime. */
16
+ prodMigrations?: unknown[];
39
17
  }
40
18
  /**
41
- * Create a Fjall-configured PostgreSQL adapter for Payload CMS.
42
- *
43
- * This is an async function because it needs to fetch credentials from
44
- * Secrets Manager. Call it with top-level await in your payload.config.ts.
45
- *
46
19
  * @example
47
20
  * ```typescript
48
21
  * import { fjallPostgresAdapter } from '@fjall/payload'
49
22
  * import { migrations } from './migrations'
50
23
  *
51
- * const db = await fjallPostgresAdapter({
52
- * migrationDir: './src/migrations',
53
- * prodMigrations: migrations,
54
- * })
55
- *
56
24
  * export default buildConfig({
57
- * db,
58
- * // ...
25
+ * db: await fjallPostgresAdapter({ prodMigrations: migrations }),
59
26
  * })
60
27
  * ```
61
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/adapters/postgres.ts"],"names":[],"mappings":"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,OAAO,CAAC,qBAAqB,CAAC,CAgBhC"}
@@ -9,68 +9,48 @@
9
9
  */
10
10
  import { postgresAdapter } from "@payloadcms/db-postgres";
11
11
  import { fetchSecretField } from "./secrets.js";
12
- // Cache for resolved database URL (resolved once at Lambda cold start).
13
- // Module-level state is intentional here: Lambda reuses the module across
14
- // invocations, so caching avoids repeated Secrets Manager calls.
12
+ // Module-level cache: Lambda reuses modules across invocations,
13
+ // so caching avoids repeated Secrets Manager calls.
15
14
  let cachedDbUrl = null;
16
- /**
17
- * Build the database connection URL from Fjall environment variables.
18
- *
19
- * In production (Lambda), uses:
20
- * - DATABASE_HOST, DATABASE_PORT, DATABASE_NAME from environment
21
- * - DATABASE_USERNAME/PASSWORD from Secrets Manager via Lambda Extension
22
- *
23
- * In development, falls back to DATABASE_URL environment variable.
24
- */
25
15
  async function getDatabaseUrl() {
26
- // Return cached URL if already resolved
27
- if (cachedDbUrl)
16
+ if (cachedDbUrl !== null)
28
17
  return cachedDbUrl;
29
- // If Fjall env vars are present (production Lambda environment)
30
18
  if (process.env.DATABASE_HOST) {
31
19
  const host = process.env.DATABASE_HOST;
32
20
  const port = process.env.DATABASE_PORT || "5432";
33
21
  const name = process.env.DATABASE_NAME;
34
- // Fetch credentials from Lambda Extension
35
- const user = (await fetchSecretField("DATABASE_USERNAME")) || "postgres";
36
- const pass = (await fetchSecretField("DATABASE_PASSWORD")) || "";
22
+ if (!name) {
23
+ throw new Error("[fjall] DATABASE_NAME environment variable not configured. " +
24
+ "Ensure DATABASE_NAME is set alongside DATABASE_HOST.");
25
+ }
26
+ const user = await fetchSecretField("DATABASE_USERNAME");
27
+ const pass = await fetchSecretField("DATABASE_PASSWORD");
28
+ if (!user || !pass) {
29
+ throw new Error("[fjall] Database credentials not found in Secrets Manager. " +
30
+ "Ensure DATABASE_USERNAME and DATABASE_PASSWORD are configured in your secrets.");
31
+ }
37
32
  cachedDbUrl = `postgresql://${user}:${encodeURIComponent(pass)}@${host}:${port}/${name}`;
38
33
  return cachedDbUrl;
39
34
  }
40
- // Fallback to DATABASE_URL for local development
35
+ // Empty string allows builds to succeed without a database (Next.js static generation).
36
+ // At runtime, DATABASE_HOST will be set by Lambda.
41
37
  cachedDbUrl = process.env.DATABASE_URL || "";
42
38
  return cachedDbUrl;
43
39
  }
44
- /**
45
- * Get SSL configuration for Aurora PostgreSQL.
46
- *
47
- * In production (DATABASE_SSL=true), enables SSL but skips certificate
48
- * verification since Aurora uses Amazon's internal CA.
49
- */
40
+ // Aurora uses Amazon's internal CA, so we skip certificate verification.
50
41
  function getSslConfig() {
51
42
  return process.env.DATABASE_SSL === "true"
52
43
  ? { rejectUnauthorized: false }
53
44
  : false;
54
45
  }
55
46
  /**
56
- * Create a Fjall-configured PostgreSQL adapter for Payload CMS.
57
- *
58
- * This is an async function because it needs to fetch credentials from
59
- * Secrets Manager. Call it with top-level await in your payload.config.ts.
60
- *
61
47
  * @example
62
48
  * ```typescript
63
49
  * import { fjallPostgresAdapter } from '@fjall/payload'
64
50
  * import { migrations } from './migrations'
65
51
  *
66
- * const db = await fjallPostgresAdapter({
67
- * migrationDir: './src/migrations',
68
- * prodMigrations: migrations,
69
- * })
70
- *
71
52
  * export default buildConfig({
72
- * db,
73
- * // ...
53
+ * db: await fjallPostgresAdapter({ prodMigrations: migrations }),
74
54
  * })
75
55
  * ```
76
56
  */
@@ -83,7 +63,8 @@ export async function fjallPostgresAdapter(options = {}) {
83
63
  ssl: getSslConfig(),
84
64
  },
85
65
  migrationDir,
86
- prodMigrations,
66
+ // Safe assertion: migrations are generated by `payload migrate:create`.
67
+ prodMigrations: prodMigrations,
87
68
  });
88
69
  }
89
70
  //# sourceMappingURL=postgres.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres.js","sourceRoot":"","sources":["../../src/adapters/postgres.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAA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,WAAW,GAAG,gBAAgB,IAAI,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACzF,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,wFAAwF;IACxF,mDAAmD;IACnD,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;IAC7C,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,yEAAyE;AACzE,SAAS,YAAY;IACnB,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,MAAM;QACxC,CAAC,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE;QAC/B,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC;AASD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,UAAuC,EAAE;IAEzC,MAAM,EAAE,YAAY,GAAG,kBAAkB,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAEtE,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;IAE3C,OAAO,eAAe,CAAC;QACrB,IAAI,EAAE;YACJ,gBAAgB,EAAE,WAAW;YAC7B,GAAG,EAAE,YAAY,EAAE;SACpB;QACD,YAAY;QACZ,wEAAwE;QACxE,cAAc,EAAE,cAEM;KACvB,CAAC,CAAC;AACL,CAAC"}
package/dist/index.d.ts CHANGED
@@ -11,7 +11,6 @@
11
11
  * fjallPostgresAdapter,
12
12
  * awsS3Storage,
13
13
  * fjallDefaults,
14
- * isProduction
15
14
  * } from '@fjall/payload'
16
15
  * import { migrations } from './migrations'
17
16
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGzE,OAAO,EACL,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGzE,OAAO,EACL,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -11,7 +11,6 @@
11
11
  * fjallPostgresAdapter,
12
12
  * awsS3Storage,
13
13
  * fjallDefaults,
14
- * isProduction
15
14
  * } from '@fjall/payload'
16
15
  * import { migrations } from './migrations'
17
16
  *
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,mBAAmB;AACnB,OAAO,EACL,oBAAoB,GAErB,MAAM,wBAAwB,CAAC;AAEhC,qBAAqB;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,oBAAoB;AACpB,OAAO,EAAE,YAAY,EAA4B,MAAM,iBAAiB,CAAC;AAEzE,wBAAwB;AACxB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,mBAAmB;AACnB,OAAO,EACL,oBAAoB,GAErB,MAAM,wBAAwB,CAAC;AAEhC,qBAAqB;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,oBAAoB;AACpB,OAAO,EAAE,YAAY,EAA4B,MAAM,iBAAiB,CAAC;AAEzE,wBAAwB;AACxB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fjall/payload",
3
- "version": "0.87.5",
3
+ "version": "0.87.10",
4
4
  "description": "Fjall AWS adapters and utilities for Payload CMS",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,6 +19,7 @@
19
19
  "build": "npm run clean && npx tsc",
20
20
  "watch": "npm run build && npx tsc-watch",
21
21
  "typecheck": "tsc --noEmit",
22
+ "test": "vitest run",
22
23
  "format": "prettier --write \"src/**/*.ts\"",
23
24
  "format:check": "prettier --check \"src/**/*.ts\"",
24
25
  "lint": "eslint src/",
@@ -47,7 +48,8 @@
47
48
  "@payloadcms/storage-s3": "^3.73.0",
48
49
  "@types/node": "^22.0.0",
49
50
  "payload": "^3.73.0",
50
- "typescript": "^5.8.2"
51
+ "typescript": "^5.8.2",
52
+ "vitest": "^3.2.3"
51
53
  },
52
- "gitHead": "f4a849ef9676f6195235b82093ff19ba7017deb0"
54
+ "gitHead": "32e5ea12b1de1bd1370edb10f29ad0a6ac9122c7"
53
55
  }