@pgpmjs/env 2.8.5 → 2.8.7

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/env.js CHANGED
@@ -24,7 +24,9 @@ const parseEnvStringArray = (val) => {
24
24
  * GraphQL-related env vars (GRAPHILE_*, FEATURES_*, API_*) are handled by @constructive-io/graphql-env.
25
25
  */
26
26
  const getEnvVars = () => {
27
- const { PGROOTDATABASE, PGTEMPLATE, DB_PREFIX, DB_EXTENSIONS, DB_CWD, DB_CONNECTION_USER, DB_CONNECTION_PASSWORD, DB_CONNECTION_ROLE, PORT, SERVER_HOST, SERVER_TRUST_PROXY, SERVER_ORIGIN, SERVER_STRICT_AUTH, PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE, BUCKET_NAME, AWS_REGION, AWS_ACCESS_KEY, AWS_SECRET_KEY, MINIO_ENDPOINT, DEPLOYMENT_USE_TX, DEPLOYMENT_FAST, DEPLOYMENT_USE_PLAN, DEPLOYMENT_CACHE, DEPLOYMENT_TO_CHANGE, MIGRATIONS_CODEGEN_USE_TX,
27
+ const { PGROOTDATABASE, PGTEMPLATE, DB_PREFIX, DB_EXTENSIONS, DB_CWD, DB_CONNECTION_USER, DB_CONNECTION_PASSWORD, DB_CONNECTION_ROLE,
28
+ // New connections.app and connections.admin env vars
29
+ DB_CONNECTIONS_APP_USER, DB_CONNECTIONS_APP_PASSWORD, DB_CONNECTIONS_ADMIN_USER, DB_CONNECTIONS_ADMIN_PASSWORD, PORT, SERVER_HOST, SERVER_TRUST_PROXY, SERVER_ORIGIN, SERVER_STRICT_AUTH, PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE, BUCKET_NAME, AWS_REGION, AWS_ACCESS_KEY, AWS_SECRET_KEY, MINIO_ENDPOINT, DEPLOYMENT_USE_TX, DEPLOYMENT_FAST, DEPLOYMENT_USE_PLAN, DEPLOYMENT_CACHE, DEPLOYMENT_TO_CHANGE, MIGRATIONS_CODEGEN_USE_TX,
28
30
  // Jobs-related env vars
29
31
  JOBS_SCHEMA, JOBS_SUPPORT_ANY, JOBS_SUPPORTED, INTERNAL_GATEWAY_URL, INTERNAL_JOBS_CALLBACK_URL, INTERNAL_JOBS_CALLBACK_PORT } = process.env;
30
32
  return {
@@ -41,6 +43,22 @@ const getEnvVars = () => {
41
43
  ...(DB_CONNECTION_ROLE && { role: DB_CONNECTION_ROLE }),
42
44
  }
43
45
  }),
46
+ ...((DB_CONNECTIONS_APP_USER || DB_CONNECTIONS_APP_PASSWORD || DB_CONNECTIONS_ADMIN_USER || DB_CONNECTIONS_ADMIN_PASSWORD) && {
47
+ connections: {
48
+ ...((DB_CONNECTIONS_APP_USER || DB_CONNECTIONS_APP_PASSWORD) && {
49
+ app: {
50
+ ...(DB_CONNECTIONS_APP_USER && { user: DB_CONNECTIONS_APP_USER }),
51
+ ...(DB_CONNECTIONS_APP_PASSWORD && { password: DB_CONNECTIONS_APP_PASSWORD }),
52
+ }
53
+ }),
54
+ ...((DB_CONNECTIONS_ADMIN_USER || DB_CONNECTIONS_ADMIN_PASSWORD) && {
55
+ admin: {
56
+ ...(DB_CONNECTIONS_ADMIN_USER && { user: DB_CONNECTIONS_ADMIN_USER }),
57
+ ...(DB_CONNECTIONS_ADMIN_PASSWORD && { password: DB_CONNECTIONS_ADMIN_PASSWORD }),
58
+ }
59
+ }),
60
+ }
61
+ }),
44
62
  },
45
63
  server: {
46
64
  ...(PORT && { port: parseEnvNumber(PORT) }),
package/esm/env.js CHANGED
@@ -20,7 +20,9 @@ const parseEnvStringArray = (val) => {
20
20
  * GraphQL-related env vars (GRAPHILE_*, FEATURES_*, API_*) are handled by @constructive-io/graphql-env.
21
21
  */
22
22
  export const getEnvVars = () => {
23
- const { PGROOTDATABASE, PGTEMPLATE, DB_PREFIX, DB_EXTENSIONS, DB_CWD, DB_CONNECTION_USER, DB_CONNECTION_PASSWORD, DB_CONNECTION_ROLE, PORT, SERVER_HOST, SERVER_TRUST_PROXY, SERVER_ORIGIN, SERVER_STRICT_AUTH, PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE, BUCKET_NAME, AWS_REGION, AWS_ACCESS_KEY, AWS_SECRET_KEY, MINIO_ENDPOINT, DEPLOYMENT_USE_TX, DEPLOYMENT_FAST, DEPLOYMENT_USE_PLAN, DEPLOYMENT_CACHE, DEPLOYMENT_TO_CHANGE, MIGRATIONS_CODEGEN_USE_TX,
23
+ const { PGROOTDATABASE, PGTEMPLATE, DB_PREFIX, DB_EXTENSIONS, DB_CWD, DB_CONNECTION_USER, DB_CONNECTION_PASSWORD, DB_CONNECTION_ROLE,
24
+ // New connections.app and connections.admin env vars
25
+ DB_CONNECTIONS_APP_USER, DB_CONNECTIONS_APP_PASSWORD, DB_CONNECTIONS_ADMIN_USER, DB_CONNECTIONS_ADMIN_PASSWORD, PORT, SERVER_HOST, SERVER_TRUST_PROXY, SERVER_ORIGIN, SERVER_STRICT_AUTH, PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE, BUCKET_NAME, AWS_REGION, AWS_ACCESS_KEY, AWS_SECRET_KEY, MINIO_ENDPOINT, DEPLOYMENT_USE_TX, DEPLOYMENT_FAST, DEPLOYMENT_USE_PLAN, DEPLOYMENT_CACHE, DEPLOYMENT_TO_CHANGE, MIGRATIONS_CODEGEN_USE_TX,
24
26
  // Jobs-related env vars
25
27
  JOBS_SCHEMA, JOBS_SUPPORT_ANY, JOBS_SUPPORTED, INTERNAL_GATEWAY_URL, INTERNAL_JOBS_CALLBACK_URL, INTERNAL_JOBS_CALLBACK_PORT } = process.env;
26
28
  return {
@@ -37,6 +39,22 @@ export const getEnvVars = () => {
37
39
  ...(DB_CONNECTION_ROLE && { role: DB_CONNECTION_ROLE }),
38
40
  }
39
41
  }),
42
+ ...((DB_CONNECTIONS_APP_USER || DB_CONNECTIONS_APP_PASSWORD || DB_CONNECTIONS_ADMIN_USER || DB_CONNECTIONS_ADMIN_PASSWORD) && {
43
+ connections: {
44
+ ...((DB_CONNECTIONS_APP_USER || DB_CONNECTIONS_APP_PASSWORD) && {
45
+ app: {
46
+ ...(DB_CONNECTIONS_APP_USER && { user: DB_CONNECTIONS_APP_USER }),
47
+ ...(DB_CONNECTIONS_APP_PASSWORD && { password: DB_CONNECTIONS_APP_PASSWORD }),
48
+ }
49
+ }),
50
+ ...((DB_CONNECTIONS_ADMIN_USER || DB_CONNECTIONS_ADMIN_PASSWORD) && {
51
+ admin: {
52
+ ...(DB_CONNECTIONS_ADMIN_USER && { user: DB_CONNECTIONS_ADMIN_USER }),
53
+ ...(DB_CONNECTIONS_ADMIN_PASSWORD && { password: DB_CONNECTIONS_ADMIN_PASSWORD }),
54
+ }
55
+ }),
56
+ }
57
+ }),
40
58
  },
41
59
  server: {
42
60
  ...(PORT && { port: parseEnvNumber(PORT) }),
package/esm/merge.js CHANGED
@@ -20,7 +20,27 @@ export const getConnEnvOptions = (overrides = {}, cwd = process.cwd()) => {
20
20
  const opts = getEnvOptions({
21
21
  db: overrides
22
22
  }, cwd);
23
- return opts.db;
23
+ // Ensure roles is always resolved from defaults even if config/env explicitly sets it to undefined
24
+ const db = opts.db ?? {};
25
+ const defaultRoles = pgpmDefaults.db?.roles ?? {};
26
+ const defaultConnections = pgpmDefaults.db?.connections ?? {};
27
+ return {
28
+ ...db,
29
+ roles: {
30
+ ...defaultRoles,
31
+ ...(db.roles ?? {})
32
+ },
33
+ connections: {
34
+ app: {
35
+ ...defaultConnections.app,
36
+ ...(db.connections?.app ?? {})
37
+ },
38
+ admin: {
39
+ ...defaultConnections.admin,
40
+ ...(db.connections?.admin ?? {})
41
+ }
42
+ }
43
+ };
24
44
  };
25
45
  export const getDeploymentEnvOptions = (overrides = {}, cwd = process.cwd()) => {
26
46
  const opts = getEnvOptions({
package/merge.js CHANGED
@@ -27,7 +27,27 @@ const getConnEnvOptions = (overrides = {}, cwd = process.cwd()) => {
27
27
  const opts = (0, exports.getEnvOptions)({
28
28
  db: overrides
29
29
  }, cwd);
30
- return opts.db;
30
+ // Ensure roles is always resolved from defaults even if config/env explicitly sets it to undefined
31
+ const db = opts.db ?? {};
32
+ const defaultRoles = types_1.pgpmDefaults.db?.roles ?? {};
33
+ const defaultConnections = types_1.pgpmDefaults.db?.connections ?? {};
34
+ return {
35
+ ...db,
36
+ roles: {
37
+ ...defaultRoles,
38
+ ...(db.roles ?? {})
39
+ },
40
+ connections: {
41
+ app: {
42
+ ...defaultConnections.app,
43
+ ...(db.connections?.app ?? {})
44
+ },
45
+ admin: {
46
+ ...defaultConnections.admin,
47
+ ...(db.connections?.admin ?? {})
48
+ }
49
+ }
50
+ };
31
51
  };
32
52
  exports.getConnEnvOptions = getConnEnvOptions;
33
53
  const getDeploymentEnvOptions = (overrides = {}, cwd = process.cwd()) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpmjs/env",
3
- "version": "2.8.5",
3
+ "version": "2.8.7",
4
4
  "author": "Dan Lynch <Dan Lynch>",
5
5
  "description": "PGPM environment management",
6
6
  "main": "index.js",
@@ -29,7 +29,7 @@
29
29
  "test:watch": "jest --watch"
30
30
  },
31
31
  "dependencies": {
32
- "@pgpmjs/types": "^2.12.5",
32
+ "@pgpmjs/types": "^2.12.6",
33
33
  "deepmerge": "^4.3.1"
34
34
  },
35
35
  "keywords": [
@@ -43,5 +43,5 @@
43
43
  "devDependencies": {
44
44
  "makage": "^0.1.9"
45
45
  },
46
- "gitHead": "e45ec95404e48d0c0542da882a3baea0cd6de1c7"
46
+ "gitHead": "248d4056d3191b71bcab5892ef98b09164de9f7f"
47
47
  }