@pgpmjs/env 2.9.4 → 2.10.0

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.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { PgpmOptions } from '@pgpmjs/types';
2
+ export declare const parseEnvNumber: (val?: string) => number | undefined;
2
3
  export declare const parseEnvBoolean: (val?: string) => boolean | undefined;
3
4
  /**
4
5
  * Parse core PGPM environment variables.
package/env.js CHANGED
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNodeEnv = exports.getEnvVars = exports.parseEnvBoolean = void 0;
3
+ exports.getNodeEnv = exports.getEnvVars = exports.parseEnvBoolean = exports.parseEnvNumber = void 0;
4
4
  const parseEnvNumber = (val) => {
5
5
  const num = Number(val);
6
6
  return !isNaN(num) ? num : undefined;
7
7
  };
8
+ exports.parseEnvNumber = parseEnvNumber;
8
9
  const parseEnvBoolean = (val) => {
9
10
  if (val === undefined)
10
11
  return undefined;
@@ -32,7 +33,9 @@ const getEnvVars = (env = process.env) => {
32
33
  // Jobs-related env vars
33
34
  JOBS_SCHEMA, JOBS_SUPPORT_ANY, JOBS_SUPPORTED, INTERNAL_GATEWAY_URL, INTERNAL_JOBS_CALLBACK_URL, INTERNAL_JOBS_CALLBACK_PORT,
34
35
  // Error output formatting env vars
35
- PGPM_ERROR_QUERY_HISTORY_LIMIT, PGPM_ERROR_MAX_LENGTH, PGPM_ERROR_VERBOSE } = env;
36
+ PGPM_ERROR_QUERY_HISTORY_LIMIT, PGPM_ERROR_MAX_LENGTH, PGPM_ERROR_VERBOSE,
37
+ // SMTP email env vars
38
+ SMTP_HOST, SMTP_PORT, SMTP_SECURE, SMTP_USER, SMTP_PASS, SMTP_FROM, SMTP_REPLY_TO, SMTP_REQUIRE_TLS, SMTP_TLS_REJECT_UNAUTHORIZED, SMTP_POOL, SMTP_MAX_CONNECTIONS, SMTP_MAX_MESSAGES, SMTP_NAME, SMTP_LOGGER, SMTP_DEBUG } = env;
36
39
  return {
37
40
  db: {
38
41
  ...(PGROOTDATABASE && { rootDb: PGROOTDATABASE }),
@@ -65,7 +68,7 @@ const getEnvVars = (env = process.env) => {
65
68
  }),
66
69
  },
67
70
  server: {
68
- ...(PORT && { port: parseEnvNumber(PORT) }),
71
+ ...(PORT && { port: (0, exports.parseEnvNumber)(PORT) }),
69
72
  ...(SERVER_HOST && { host: SERVER_HOST }),
70
73
  ...(SERVER_TRUST_PROXY && { trustProxy: (0, exports.parseEnvBoolean)(SERVER_TRUST_PROXY) }),
71
74
  ...(SERVER_ORIGIN && { origin: SERVER_ORIGIN }),
@@ -73,7 +76,7 @@ const getEnvVars = (env = process.env) => {
73
76
  },
74
77
  pg: {
75
78
  ...(PGHOST && { host: PGHOST }),
76
- ...(PGPORT && { port: parseEnvNumber(PGPORT) }),
79
+ ...(PGPORT && { port: (0, exports.parseEnvNumber)(PGPORT) }),
77
80
  ...(PGUSER && { user: PGUSER }),
78
81
  ...(PGPASSWORD && { password: PGPASSWORD }),
79
82
  ...(PGDATABASE && { database: PGDATABASE }),
@@ -135,15 +138,32 @@ const getEnvVars = (env = process.env) => {
135
138
  callbackUrl: INTERNAL_JOBS_CALLBACK_URL
136
139
  }),
137
140
  ...(INTERNAL_JOBS_CALLBACK_PORT && {
138
- callbackPort: parseEnvNumber(INTERNAL_JOBS_CALLBACK_PORT)
141
+ callbackPort: (0, exports.parseEnvNumber)(INTERNAL_JOBS_CALLBACK_PORT)
139
142
  })
140
143
  }
141
144
  })
142
145
  },
143
146
  errorOutput: {
144
- ...(PGPM_ERROR_QUERY_HISTORY_LIMIT && { queryHistoryLimit: parseEnvNumber(PGPM_ERROR_QUERY_HISTORY_LIMIT) }),
145
- ...(PGPM_ERROR_MAX_LENGTH && { maxLength: parseEnvNumber(PGPM_ERROR_MAX_LENGTH) }),
147
+ ...(PGPM_ERROR_QUERY_HISTORY_LIMIT && { queryHistoryLimit: (0, exports.parseEnvNumber)(PGPM_ERROR_QUERY_HISTORY_LIMIT) }),
148
+ ...(PGPM_ERROR_MAX_LENGTH && { maxLength: (0, exports.parseEnvNumber)(PGPM_ERROR_MAX_LENGTH) }),
146
149
  ...(PGPM_ERROR_VERBOSE && { verbose: (0, exports.parseEnvBoolean)(PGPM_ERROR_VERBOSE) }),
150
+ },
151
+ smtp: {
152
+ ...(SMTP_HOST && { host: SMTP_HOST }),
153
+ ...(SMTP_PORT && { port: (0, exports.parseEnvNumber)(SMTP_PORT) }),
154
+ ...(SMTP_SECURE && { secure: (0, exports.parseEnvBoolean)(SMTP_SECURE) }),
155
+ ...(SMTP_USER && { user: SMTP_USER }),
156
+ ...(SMTP_PASS && { pass: SMTP_PASS }),
157
+ ...(SMTP_FROM && { from: SMTP_FROM }),
158
+ ...(SMTP_REPLY_TO && { replyTo: SMTP_REPLY_TO }),
159
+ ...(SMTP_REQUIRE_TLS && { requireTLS: (0, exports.parseEnvBoolean)(SMTP_REQUIRE_TLS) }),
160
+ ...(SMTP_TLS_REJECT_UNAUTHORIZED && { tlsRejectUnauthorized: (0, exports.parseEnvBoolean)(SMTP_TLS_REJECT_UNAUTHORIZED) }),
161
+ ...(SMTP_POOL && { pool: (0, exports.parseEnvBoolean)(SMTP_POOL) }),
162
+ ...(SMTP_MAX_CONNECTIONS && { maxConnections: (0, exports.parseEnvNumber)(SMTP_MAX_CONNECTIONS) }),
163
+ ...(SMTP_MAX_MESSAGES && { maxMessages: (0, exports.parseEnvNumber)(SMTP_MAX_MESSAGES) }),
164
+ ...(SMTP_NAME && { name: SMTP_NAME }),
165
+ ...(SMTP_LOGGER && { logger: (0, exports.parseEnvBoolean)(SMTP_LOGGER) }),
166
+ ...(SMTP_DEBUG && { debug: (0, exports.parseEnvBoolean)(SMTP_DEBUG) }),
147
167
  }
148
168
  };
149
169
  };
package/esm/env.js CHANGED
@@ -1,4 +1,4 @@
1
- const parseEnvNumber = (val) => {
1
+ export const parseEnvNumber = (val) => {
2
2
  const num = Number(val);
3
3
  return !isNaN(num) ? num : undefined;
4
4
  };
@@ -28,7 +28,9 @@ export const getEnvVars = (env = process.env) => {
28
28
  // Jobs-related env vars
29
29
  JOBS_SCHEMA, JOBS_SUPPORT_ANY, JOBS_SUPPORTED, INTERNAL_GATEWAY_URL, INTERNAL_JOBS_CALLBACK_URL, INTERNAL_JOBS_CALLBACK_PORT,
30
30
  // Error output formatting env vars
31
- PGPM_ERROR_QUERY_HISTORY_LIMIT, PGPM_ERROR_MAX_LENGTH, PGPM_ERROR_VERBOSE } = env;
31
+ PGPM_ERROR_QUERY_HISTORY_LIMIT, PGPM_ERROR_MAX_LENGTH, PGPM_ERROR_VERBOSE,
32
+ // SMTP email env vars
33
+ SMTP_HOST, SMTP_PORT, SMTP_SECURE, SMTP_USER, SMTP_PASS, SMTP_FROM, SMTP_REPLY_TO, SMTP_REQUIRE_TLS, SMTP_TLS_REJECT_UNAUTHORIZED, SMTP_POOL, SMTP_MAX_CONNECTIONS, SMTP_MAX_MESSAGES, SMTP_NAME, SMTP_LOGGER, SMTP_DEBUG } = env;
32
34
  return {
33
35
  db: {
34
36
  ...(PGROOTDATABASE && { rootDb: PGROOTDATABASE }),
@@ -140,6 +142,23 @@ export const getEnvVars = (env = process.env) => {
140
142
  ...(PGPM_ERROR_QUERY_HISTORY_LIMIT && { queryHistoryLimit: parseEnvNumber(PGPM_ERROR_QUERY_HISTORY_LIMIT) }),
141
143
  ...(PGPM_ERROR_MAX_LENGTH && { maxLength: parseEnvNumber(PGPM_ERROR_MAX_LENGTH) }),
142
144
  ...(PGPM_ERROR_VERBOSE && { verbose: parseEnvBoolean(PGPM_ERROR_VERBOSE) }),
145
+ },
146
+ smtp: {
147
+ ...(SMTP_HOST && { host: SMTP_HOST }),
148
+ ...(SMTP_PORT && { port: parseEnvNumber(SMTP_PORT) }),
149
+ ...(SMTP_SECURE && { secure: parseEnvBoolean(SMTP_SECURE) }),
150
+ ...(SMTP_USER && { user: SMTP_USER }),
151
+ ...(SMTP_PASS && { pass: SMTP_PASS }),
152
+ ...(SMTP_FROM && { from: SMTP_FROM }),
153
+ ...(SMTP_REPLY_TO && { replyTo: SMTP_REPLY_TO }),
154
+ ...(SMTP_REQUIRE_TLS && { requireTLS: parseEnvBoolean(SMTP_REQUIRE_TLS) }),
155
+ ...(SMTP_TLS_REJECT_UNAUTHORIZED && { tlsRejectUnauthorized: parseEnvBoolean(SMTP_TLS_REJECT_UNAUTHORIZED) }),
156
+ ...(SMTP_POOL && { pool: parseEnvBoolean(SMTP_POOL) }),
157
+ ...(SMTP_MAX_CONNECTIONS && { maxConnections: parseEnvNumber(SMTP_MAX_CONNECTIONS) }),
158
+ ...(SMTP_MAX_MESSAGES && { maxMessages: parseEnvNumber(SMTP_MAX_MESSAGES) }),
159
+ ...(SMTP_NAME && { name: SMTP_NAME }),
160
+ ...(SMTP_LOGGER && { logger: parseEnvBoolean(SMTP_LOGGER) }),
161
+ ...(SMTP_DEBUG && { debug: parseEnvBoolean(SMTP_DEBUG) }),
143
162
  }
144
163
  };
145
164
  };
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { getEnvOptions, getConnEnvOptions, getDeploymentEnvOptions } from './merge';
2
2
  export { loadConfigSync, loadConfigSyncFromDir, loadConfigFileSync, resolvePgpmPath, resolvePnpmWorkspace, resolveLernaWorkspace, resolveNpmWorkspace, resolveWorkspaceByType } from './config';
3
- export { getEnvVars, getNodeEnv, parseEnvBoolean } from './env';
3
+ export { getEnvVars, getNodeEnv, parseEnvBoolean, parseEnvNumber } from './env';
4
4
  export { walkUp, mergeArraysUnique } from './utils';
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { getEnvOptions, getConnEnvOptions, getDeploymentEnvOptions } from './merge';
2
2
  export { loadConfigSync, loadConfigSyncFromDir, loadConfigFileSync, resolvePgpmPath, resolvePnpmWorkspace, resolveLernaWorkspace, resolveNpmWorkspace, resolveWorkspaceByType } from './config';
3
3
  export type { WorkspaceType } from './config';
4
- export { getEnvVars, getNodeEnv, parseEnvBoolean } from './env';
4
+ export { getEnvVars, getNodeEnv, parseEnvBoolean, parseEnvNumber } from './env';
5
5
  export { walkUp, mergeArraysUnique } from './utils';
6
6
  export type { PgpmOptions, PgTestConnectionOptions, DeploymentOptions } from '@pgpmjs/types';
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeArraysUnique = exports.walkUp = exports.parseEnvBoolean = exports.getNodeEnv = exports.getEnvVars = exports.resolveWorkspaceByType = exports.resolveNpmWorkspace = exports.resolveLernaWorkspace = exports.resolvePnpmWorkspace = exports.resolvePgpmPath = exports.loadConfigFileSync = exports.loadConfigSyncFromDir = exports.loadConfigSync = exports.getDeploymentEnvOptions = exports.getConnEnvOptions = exports.getEnvOptions = void 0;
3
+ exports.mergeArraysUnique = exports.walkUp = exports.parseEnvNumber = exports.parseEnvBoolean = exports.getNodeEnv = exports.getEnvVars = exports.resolveWorkspaceByType = exports.resolveNpmWorkspace = exports.resolveLernaWorkspace = exports.resolvePnpmWorkspace = exports.resolvePgpmPath = exports.loadConfigFileSync = exports.loadConfigSyncFromDir = exports.loadConfigSync = exports.getDeploymentEnvOptions = exports.getConnEnvOptions = exports.getEnvOptions = void 0;
4
4
  var merge_1 = require("./merge");
5
5
  Object.defineProperty(exports, "getEnvOptions", { enumerable: true, get: function () { return merge_1.getEnvOptions; } });
6
6
  Object.defineProperty(exports, "getConnEnvOptions", { enumerable: true, get: function () { return merge_1.getConnEnvOptions; } });
@@ -18,6 +18,7 @@ var env_1 = require("./env");
18
18
  Object.defineProperty(exports, "getEnvVars", { enumerable: true, get: function () { return env_1.getEnvVars; } });
19
19
  Object.defineProperty(exports, "getNodeEnv", { enumerable: true, get: function () { return env_1.getNodeEnv; } });
20
20
  Object.defineProperty(exports, "parseEnvBoolean", { enumerable: true, get: function () { return env_1.parseEnvBoolean; } });
21
+ Object.defineProperty(exports, "parseEnvNumber", { enumerable: true, get: function () { return env_1.parseEnvNumber; } });
21
22
  var utils_1 = require("./utils");
22
23
  Object.defineProperty(exports, "walkUp", { enumerable: true, get: function () { return utils_1.walkUp; } });
23
24
  Object.defineProperty(exports, "mergeArraysUnique", { enumerable: true, get: function () { return utils_1.mergeArraysUnique; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpmjs/env",
3
- "version": "2.9.4",
3
+ "version": "2.10.0",
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.14.1",
32
+ "@pgpmjs/types": "^2.15.0",
33
33
  "deepmerge": "^4.3.1"
34
34
  },
35
35
  "keywords": [
@@ -43,5 +43,5 @@
43
43
  "devDependencies": {
44
44
  "makage": "^0.1.10"
45
45
  },
46
- "gitHead": "cb4af2cf6c23dad24cd951c232d3e2006b81aa3d"
46
+ "gitHead": "481b3a50b4eec2da6b376c4cd1868065e1e28edb"
47
47
  }