jaypie 1.0.13 → 1.0.15

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/README.md CHANGED
@@ -180,7 +180,6 @@ import {
180
180
  CDK,
181
181
  ERROR,
182
182
  HTTP,
183
- LOG,
184
183
  VALIDATE,
185
184
  } from "jaypie";
186
185
  ```
@@ -215,10 +214,6 @@ See `HTTP` for status codes.
215
214
  * `HTTP.HEADER`: ...
216
215
  * `HTTP.METHOD`: `GET`, `POST`, ...
217
216
 
218
- #### `LOG`
219
-
220
- * `LOG.FORMAT`
221
- * `LOG.LEVEL`
222
217
 
223
218
  #### `VALIDATE`
224
219
 
@@ -505,7 +500,6 @@ const handler = lambdaHandler(async({event}) => {
505
500
  ```javascript
506
501
  import {
507
502
  log,
508
- LOG, // LOG.FORMAT, LOG.LEVEL
509
503
  } from "jaypie";
510
504
  ```
511
505
 
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ var core = require('@jaypie/core');
4
+
5
+ //
6
+ //
7
+ // Helper Functions
8
+ //
9
+
10
+ const _importedModule = {};
11
+ function dynamicImport(module) {
12
+ if (!_importedModule[module]) {
13
+ try {
14
+ _importedModule[module] = require(module);
15
+ } catch (error) {
16
+ if (process.env.NODE_ENV === "test") {
17
+ if (!_importedModule[module]) {
18
+ // eslint-disable-next-line no-console
19
+ console.warn(
20
+ `[jaypie] Caught error requiring ${module} -- Is it installed?`,
21
+ );
22
+ }
23
+ }
24
+ throw new core.ConfigurationError();
25
+ }
26
+ }
27
+ return _importedModule[module];
28
+ }
29
+
30
+ function dynamicExport({
31
+ functions = ["default"],
32
+ moduleImport,
33
+ vars = [],
34
+ } = {}) {
35
+ // Validate
36
+ if (!moduleImport || typeof moduleImport !== "string") {
37
+ throw new core.ConfigurationError("`moduleImport` must be a string");
38
+ }
39
+ if (!Array.isArray(functions)) {
40
+ throw new core.ConfigurationError("`functions` must be an array");
41
+ }
42
+ if (!Array.isArray(vars)) {
43
+ throw new core.ConfigurationError("`vars` must be an array");
44
+ }
45
+ if (!functions.length && !vars.length) {
46
+ throw new core.ConfigurationError(
47
+ "Either `functions` or `vars` must be provided",
48
+ );
49
+ }
50
+ // Process
51
+ try {
52
+ // Attempt to import the module
53
+ return dynamicImport(moduleImport);
54
+ } catch (error) {
55
+ core.log
56
+ .lib({ lib: core.JAYPIE.LIB.JAYPIE })
57
+ .trace(`[jaypie] ${moduleImport} could not be imported; continuing`);
58
+ }
59
+ // Return
60
+ const result = {};
61
+ functions.forEach((func) => {
62
+ result[func] = () => {
63
+ throw new core.ConfigurationError(`${moduleImport}.${func} is not available`);
64
+ };
65
+ });
66
+ vars.forEach((variable) => {
67
+ result[variable] = null;
68
+ });
69
+ return result;
70
+ }
71
+
72
+ //
73
+ //
74
+ // Export
75
+ //
76
+
77
+ module.exports = {
78
+ ...dynamicExport({
79
+ functions: ["getMessages", "getSecret", "sendBatchMessages", "sendMessage"],
80
+ moduleImport: core.JAYPIE.LIB.AWS,
81
+ }),
82
+ ...dynamicExport({
83
+ functions: ["lambdaHandler"],
84
+ moduleImport: core.JAYPIE.LIB.LAMBDA,
85
+ }),
86
+ ...dynamicExport({
87
+ functions: ["connectFromSecretEnv", "disconnect"],
88
+ moduleImport: core.JAYPIE.LIB.MONGOOSE,
89
+ }),
90
+ };
@@ -0,0 +1,94 @@
1
+ import { ConfigurationError, log, JAYPIE } from '@jaypie/core';
2
+ export * from '@jaypie/core';
3
+
4
+ //
5
+ //
6
+ // Helper Functions
7
+ //
8
+
9
+ const _importedModule = {};
10
+ async function dynamicImport(module) {
11
+ if (!_importedModule[module]) {
12
+ try {
13
+ // eslint-disable-next-line import/no-unresolved
14
+ _importedModule[module] = await import(module);
15
+ } catch (error) {
16
+ if (process.env.NODE_ENV === "test") {
17
+ if (!_importedModule[module]) {
18
+ // eslint-disable-next-line no-console
19
+ console.warn(
20
+ `[jaypie] Caught error importing ${module} -- Is it installed?`,
21
+ );
22
+ }
23
+ }
24
+ throw new ConfigurationError();
25
+ }
26
+ }
27
+ return _importedModule[module];
28
+ }
29
+
30
+ //
31
+ //
32
+ // Main
33
+ //
34
+
35
+ var dynamicExport = async ({
36
+ functions = ["default"],
37
+ moduleImport,
38
+ vars = [],
39
+ } = {}) => {
40
+ // Validate
41
+ if (!moduleImport || typeof moduleImport !== "string") {
42
+ throw new ConfigurationError("`moduleImport` must be a string");
43
+ }
44
+ if (!Array.isArray(functions)) {
45
+ throw new ConfigurationError("`functions` must be an array");
46
+ }
47
+ if (!Array.isArray(vars)) {
48
+ throw new ConfigurationError("`vars` must be an array");
49
+ }
50
+ if (!functions.length && !vars.length) {
51
+ throw new ConfigurationError(
52
+ "Either `functions` or `vars` must be provided",
53
+ );
54
+ }
55
+ // Process
56
+ try {
57
+ // Attempt to import the module
58
+ return await dynamicImport(moduleImport);
59
+ } catch (error) {
60
+ log
61
+ .lib({ lib: JAYPIE.LIB.JAYPIE })
62
+ .trace(`[jaypie] ${moduleImport} could not be imported; continuing`);
63
+ }
64
+ // Return
65
+ const result = {};
66
+ functions.forEach((func) => {
67
+ result[func] = () => {
68
+ throw new ConfigurationError(`${moduleImport}.${func} is not available`);
69
+ };
70
+ });
71
+ vars.forEach((variable) => {
72
+ result[variable] = null;
73
+ });
74
+ return result;
75
+ };
76
+
77
+ // Optional dependencies are wrapped in a dynamic import
78
+ const { getMessages, getSecret, sendBatchMessages, sendMessage } =
79
+ await dynamicExport({
80
+ functions: ["getMessages", "getSecret", "sendBatchMessages", "sendMessage"],
81
+ moduleImport: JAYPIE.LIB.AWS,
82
+ });
83
+
84
+ const { lambdaHandler } = await dynamicExport({
85
+ functions: ["lambdaHandler"],
86
+ moduleImport: JAYPIE.LIB.LAMBDA,
87
+ });
88
+
89
+ const { connectFromSecretEnv, disconnect } = await dynamicExport({
90
+ functions: ["connectFromSecretEnv", "disconnect"],
91
+ moduleImport: JAYPIE.LIB.MONGOOSE,
92
+ });
93
+
94
+ export { connectFromSecretEnv, disconnect, getMessages, getSecret, lambdaHandler, sendBatchMessages, sendMessage };
package/package.json CHANGED
@@ -1,17 +1,11 @@
1
1
  {
2
2
  "name": "jaypie",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "author": "Finlayson Studio",
5
- "exports": {
6
- ".": {
7
- "import": "./dist/esm/index.js",
8
- "require": "./dist/cjs/index.js"
9
- }
10
- },
11
- "main": "dist/cjs/index.js",
12
- "module": "dist/esm/index.js",
5
+ "main": "dist/jaypie.cjs.js",
6
+ "module": "dist/jaypie.esm.js",
13
7
  "scripts": {
14
- "build": "babel src --out-dir dist/esm --extensions \".js\" --config-file ./babel.esm.config.json && babel src --out-dir dist/cjs --extensions \".js\" --config-file ./babel.cjs.config.json",
8
+ "build": "rollup --config",
15
9
  "format": "npm run format:package && npm run format:lint",
16
10
  "format:lint": "eslint --fix .",
17
11
  "format:package": "sort-package-json ./package.json",
@@ -25,14 +19,12 @@
25
19
  "test:spec:mongoose.package": "vitest run ./src/__tests__/mongoose.package.spec.js"
26
20
  },
27
21
  "dependencies": {
28
- "@jaypie/core": "^1.0.17"
22
+ "@jaypie/core": "^1.0.20"
29
23
  },
30
24
  "devDependencies": {
31
- "@babel/cli": "^7.24.1",
32
- "@babel/core": "^7.24.4",
33
- "@babel/plugin-transform-modules-commonjs": "^7.24.1",
34
- "@babel/preset-env": "^7.24.4",
35
- "@jaypie/testkit": "^1.0.11",
25
+ "@jaypie/testkit": "^1.0.15",
26
+ "@rollup/plugin-commonjs": "^25.0.7",
27
+ "@rollup/plugin-node-resolve": "^15.2.3",
36
28
  "eslint": "^8.57.0",
37
29
  "eslint-config-prettier": "^9.1.0",
38
30
  "eslint-plugin-import": "^2.29.1",
@@ -41,13 +33,15 @@
41
33
  "hygen": "^6.2.11",
42
34
  "jest-extended": "^4.0.2",
43
35
  "prettier": "^3.2.5",
36
+ "rollup": "^4.16.1",
37
+ "rollup-plugin-auto-external": "^2.0.0",
44
38
  "sort-package-json": "^2.10.0",
45
39
  "vitest": "^1.4.0"
46
40
  },
47
41
  "peerDependencies": {
48
- "@jaypie/aws": "^1.0.1",
49
- "@jaypie/lambda": "^1.0.1",
50
- "@jaypie/mongoose": "^1.0.3"
42
+ "@jaypie/aws": "^1.0.4",
43
+ "@jaypie/lambda": "^1.0.3",
44
+ "@jaypie/mongoose": "^1.0.5"
51
45
  },
52
46
  "peerDependenciesMeta": {
53
47
  "@jaypie/aws": {
@@ -0,0 +1,34 @@
1
+ import autoExternal from "rollup-plugin-auto-external";
2
+ import commonjs from "@rollup/plugin-commonjs";
3
+ import resolve from "@rollup/plugin-node-resolve";
4
+
5
+ export default [
6
+ {
7
+ input: "src/index.js", // Path to your main JavaScript file
8
+ output: [
9
+ {
10
+ file: "dist/jaypie.esm.js", // Output file for ES Module
11
+ format: "es", // ES Module format
12
+ },
13
+ ],
14
+ plugins: [
15
+ autoExternal(), // Automatically exclude dependencies from the bundle
16
+ resolve(), // Tells Rollup how to find node modules
17
+ commonjs(), // Converts CommonJS modules to ES6
18
+ ],
19
+ },
20
+ {
21
+ input: "src/index.cjs", // Path to your main JavaScript file
22
+ output: [
23
+ {
24
+ file: "dist/jaypie.cjs.js", // Output file for CommonJS
25
+ format: "cjs", // CommonJS format
26
+ },
27
+ ],
28
+ plugins: [
29
+ autoExternal(), // Automatically exclude dependencies from the bundle
30
+ resolve(), // Tells Rollup how to find node modules
31
+ commonjs(), // Converts CommonJS modules to ES6
32
+ ],
33
+ },
34
+ ];
@@ -5,15 +5,15 @@ import { ConfigurationError, JAYPIE, log } from "@jaypie/core";
5
5
  // Helper Functions
6
6
  //
7
7
 
8
- let _importedModule;
8
+ const _importedModule = {};
9
9
  async function dynamicImport(module) {
10
- if (!_importedModule) {
10
+ if (!_importedModule[module]) {
11
11
  try {
12
12
  // eslint-disable-next-line import/no-unresolved
13
- _importedModule = await import(module);
13
+ _importedModule[module] = await import(module);
14
14
  } catch (error) {
15
15
  if (process.env.NODE_ENV === "test") {
16
- if (!_importedModule) {
16
+ if (!_importedModule[module]) {
17
17
  // eslint-disable-next-line no-console
18
18
  console.warn(
19
19
  `[jaypie] Caught error importing ${module} -- Is it installed?`,
@@ -23,7 +23,7 @@ async function dynamicImport(module) {
23
23
  throw new ConfigurationError();
24
24
  }
25
25
  }
26
- return _importedModule;
26
+ return _importedModule[module];
27
27
  }
28
28
 
29
29
  //
package/src/index.cjs ADDED
@@ -0,0 +1,88 @@
1
+ import { ConfigurationError, JAYPIE, log } from "@jaypie/core";
2
+
3
+ //
4
+ //
5
+ // Helper Functions
6
+ //
7
+
8
+ const _importedModule = {};
9
+ function dynamicImport(module) {
10
+ if (!_importedModule[module]) {
11
+ try {
12
+ _importedModule[module] = require(module);
13
+ } catch (error) {
14
+ if (process.env.NODE_ENV === "test") {
15
+ if (!_importedModule[module]) {
16
+ // eslint-disable-next-line no-console
17
+ console.warn(
18
+ `[jaypie] Caught error requiring ${module} -- Is it installed?`,
19
+ );
20
+ }
21
+ }
22
+ throw new ConfigurationError();
23
+ }
24
+ }
25
+ return _importedModule[module];
26
+ }
27
+
28
+ function dynamicExport({
29
+ functions = ["default"],
30
+ moduleImport,
31
+ vars = [],
32
+ } = {}) {
33
+ // Validate
34
+ if (!moduleImport || typeof moduleImport !== "string") {
35
+ throw new ConfigurationError("`moduleImport` must be a string");
36
+ }
37
+ if (!Array.isArray(functions)) {
38
+ throw new ConfigurationError("`functions` must be an array");
39
+ }
40
+ if (!Array.isArray(vars)) {
41
+ throw new ConfigurationError("`vars` must be an array");
42
+ }
43
+ if (!functions.length && !vars.length) {
44
+ throw new ConfigurationError(
45
+ "Either `functions` or `vars` must be provided",
46
+ );
47
+ }
48
+ // Process
49
+ try {
50
+ // Attempt to import the module
51
+ return dynamicImport(moduleImport);
52
+ } catch (error) {
53
+ log
54
+ .lib({ lib: JAYPIE.LIB.JAYPIE })
55
+ .trace(`[jaypie] ${moduleImport} could not be imported; continuing`);
56
+ }
57
+ // Return
58
+ const result = {};
59
+ functions.forEach((func) => {
60
+ result[func] = () => {
61
+ throw new ConfigurationError(`${moduleImport}.${func} is not available`);
62
+ };
63
+ });
64
+ vars.forEach((variable) => {
65
+ result[variable] = null;
66
+ });
67
+ return result;
68
+ }
69
+
70
+ //
71
+ //
72
+ // Export
73
+ //
74
+
75
+ module.exports = {
76
+ ...dynamicExport({
77
+ functions: ["getMessages", "getSecret", "sendBatchMessages", "sendMessage"],
78
+ moduleImport: JAYPIE.LIB.AWS,
79
+ }),
80
+ ...dynamicExport({
81
+ functions: ["lambdaHandler"],
82
+ moduleImport: JAYPIE.LIB.LAMBDA,
83
+ }),
84
+ ...dynamicExport({
85
+ functions: ["connectFromSecretEnv", "disconnect"],
86
+ moduleImport: JAYPIE.LIB.MONGOOSE,
87
+ }),
88
+ };
package/src/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ import { JAYPIE } from "@jaypie/core";
2
+ import dynamicExport from "./dynamicExport.function.js";
3
+
1
4
  //
2
5
  //
3
6
  // Export
@@ -7,6 +10,18 @@
7
10
  export * from "@jaypie/core";
8
11
 
9
12
  // Optional dependencies are wrapped in a dynamic import
10
- export * from "./aws.package.js";
11
- export * from "./lambda.package.js";
12
- export * from "./mongoose.package.js";
13
+ export const { getMessages, getSecret, sendBatchMessages, sendMessage } =
14
+ await dynamicExport({
15
+ functions: ["getMessages", "getSecret", "sendBatchMessages", "sendMessage"],
16
+ moduleImport: JAYPIE.LIB.AWS,
17
+ });
18
+
19
+ export const { lambdaHandler } = await dynamicExport({
20
+ functions: ["lambdaHandler"],
21
+ moduleImport: JAYPIE.LIB.LAMBDA,
22
+ });
23
+
24
+ export const { connectFromSecretEnv, disconnect } = await dynamicExport({
25
+ functions: ["connectFromSecretEnv", "disconnect"],
26
+ moduleImport: JAYPIE.LIB.MONGOOSE,
27
+ });
@@ -0,0 +1,10 @@
1
+ /// <reference types="vitest" />
2
+
3
+ import { defineConfig } from "vite";
4
+
5
+ // https://vitejs.dev/config/
6
+ export default defineConfig({
7
+ test: {
8
+ setupFiles: ["./testSetup.js"],
9
+ },
10
+ });
@@ -1,13 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "node": "current"
8
- },
9
- "modules": "commonjs"
10
- }
11
- ]
12
- ]
13
- }
@@ -1,13 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "esmodules": true
8
- },
9
- "modules": false
10
- }
11
- ]
12
- ]
13
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.sendMessage = exports.sendBatchMessages = exports.getSecret = exports.getMessages = void 0;
7
- var _core = require("@jaypie/core");
8
- var _dynamicExportFunction = _interopRequireDefault(require("./dynamicExport.function.js"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- //
11
- //
12
- // Export
13
- //
14
-
15
- const {
16
- getMessages,
17
- getSecret,
18
- sendBatchMessages,
19
- sendMessage
20
- } = await (0, _dynamicExportFunction.default)({
21
- functions: ["getMessages", "getSecret", "sendBatchMessages", "sendMessage"],
22
- moduleImport: _core.JAYPIE.LIB.AWS
23
- });
24
- exports.sendMessage = sendMessage;
25
- exports.sendBatchMessages = sendBatchMessages;
26
- exports.getSecret = getSecret;
27
- exports.getMessages = getMessages;
@@ -1,77 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _core = require("@jaypie/core");
8
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
- //
11
- //
12
- // Helper Functions
13
- //
14
-
15
- let _importedModule;
16
- async function dynamicImport(module) {
17
- if (!_importedModule) {
18
- try {
19
- // eslint-disable-next-line import/no-unresolved
20
- _importedModule = await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(module);
21
- } catch (error) {
22
- if (process.env.NODE_ENV === "test") {
23
- if (!_importedModule) {
24
- // eslint-disable-next-line no-console
25
- console.warn(`[jaypie] Caught error importing ${module} -- Is it installed?`);
26
- }
27
- }
28
- throw new _core.ConfigurationError();
29
- }
30
- }
31
- return _importedModule;
32
- }
33
-
34
- //
35
- //
36
- // Main
37
- //
38
- var _default = async ({
39
- functions = ["default"],
40
- moduleImport,
41
- vars = []
42
- } = {}) => {
43
- // Validate
44
- if (!moduleImport || typeof moduleImport !== "string") {
45
- throw new _core.ConfigurationError("`moduleImport` must be a string");
46
- }
47
- if (!Array.isArray(functions)) {
48
- throw new _core.ConfigurationError("`functions` must be an array");
49
- }
50
- if (!Array.isArray(vars)) {
51
- throw new _core.ConfigurationError("`vars` must be an array");
52
- }
53
- if (!functions.length && !vars.length) {
54
- throw new _core.ConfigurationError("Either `functions` or `vars` must be provided");
55
- }
56
- // Process
57
- try {
58
- // Attempt to import the module
59
- return await dynamicImport(moduleImport);
60
- } catch (error) {
61
- _core.log.lib({
62
- lib: _core.JAYPIE.LIB.JAYPIE
63
- }).trace(`[jaypie] ${moduleImport} could not be imported; continuing`);
64
- }
65
- // Return
66
- const result = {};
67
- functions.forEach(func => {
68
- result[func] = () => {
69
- throw new _core.ConfigurationError(`${moduleImport}.${func} is not available`);
70
- };
71
- });
72
- vars.forEach(variable => {
73
- result[variable] = null;
74
- });
75
- return result;
76
- };
77
- exports.default = _default;
package/dist/cjs/index.js DELETED
@@ -1,49 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _core = require("@jaypie/core");
7
- Object.keys(_core).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _core[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _core[key];
14
- }
15
- });
16
- });
17
- var _awsPackage = require("./aws.package.js");
18
- Object.keys(_awsPackage).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _awsPackage[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _awsPackage[key];
25
- }
26
- });
27
- });
28
- var _lambdaPackage = require("./lambda.package.js");
29
- Object.keys(_lambdaPackage).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _lambdaPackage[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _lambdaPackage[key];
36
- }
37
- });
38
- });
39
- var _mongoosePackage = require("./mongoose.package.js");
40
- Object.keys(_mongoosePackage).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _mongoosePackage[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _mongoosePackage[key];
47
- }
48
- });
49
- });
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.lambdaHandler = void 0;
7
- var _core = require("@jaypie/core");
8
- var _dynamicExportFunction = _interopRequireDefault(require("./dynamicExport.function.js"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- //
11
- //
12
- // Export
13
- //
14
-
15
- const {
16
- lambdaHandler
17
- } = await (0, _dynamicExportFunction.default)({
18
- functions: ["lambdaHandler"],
19
- moduleImport: _core.JAYPIE.LIB.LAMBDA
20
- });
21
- exports.lambdaHandler = lambdaHandler;
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.disconnect = exports.connectFromSecretEnv = void 0;
7
- var _core = require("@jaypie/core");
8
- var _dynamicExportFunction = _interopRequireDefault(require("./dynamicExport.function.js"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- //
11
- //
12
- // Export
13
- //
14
-
15
- const {
16
- connectFromSecretEnv,
17
- disconnect
18
- } = await (0, _dynamicExportFunction.default)({
19
- functions: ["connectFromSecretEnv", "disconnect"],
20
- moduleImport: _core.JAYPIE.LIB.MONGOOSE
21
- });
22
- exports.disconnect = disconnect;
23
- exports.connectFromSecretEnv = connectFromSecretEnv;
@@ -1,17 +0,0 @@
1
- import { JAYPIE } from "@jaypie/core";
2
- import dynamicExport from "./dynamicExport.function.js";
3
-
4
- //
5
- //
6
- // Export
7
- //
8
-
9
- export var {
10
- getMessages,
11
- getSecret,
12
- sendBatchMessages,
13
- sendMessage
14
- } = await dynamicExport({
15
- functions: ["getMessages", "getSecret", "sendBatchMessages", "sendMessage"],
16
- moduleImport: JAYPIE.LIB.AWS
17
- });
@@ -1,76 +0,0 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
- import { ConfigurationError, JAYPIE, log } from "@jaypie/core";
4
-
5
- //
6
- //
7
- // Helper Functions
8
- //
9
-
10
- var _importedModule;
11
- function dynamicImport(_x) {
12
- return _dynamicImport.apply(this, arguments);
13
- } //
14
- //
15
- // Main
16
- //
17
- function _dynamicImport() {
18
- _dynamicImport = _asyncToGenerator(function* (module) {
19
- if (!_importedModule) {
20
- try {
21
- // eslint-disable-next-line import/no-unresolved
22
- _importedModule = yield import(module);
23
- } catch (error) {
24
- if (process.env.NODE_ENV === "test") {
25
- if (!_importedModule) {
26
- // eslint-disable-next-line no-console
27
- console.warn("[jaypie] Caught error importing ".concat(module, " -- Is it installed?"));
28
- }
29
- }
30
- throw new ConfigurationError();
31
- }
32
- }
33
- return _importedModule;
34
- });
35
- return _dynamicImport.apply(this, arguments);
36
- }
37
- export default /*#__PURE__*/_asyncToGenerator(function* () {
38
- var {
39
- functions = ["default"],
40
- moduleImport,
41
- vars = []
42
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
43
- // Validate
44
- if (!moduleImport || typeof moduleImport !== "string") {
45
- throw new ConfigurationError("`moduleImport` must be a string");
46
- }
47
- if (!Array.isArray(functions)) {
48
- throw new ConfigurationError("`functions` must be an array");
49
- }
50
- if (!Array.isArray(vars)) {
51
- throw new ConfigurationError("`vars` must be an array");
52
- }
53
- if (!functions.length && !vars.length) {
54
- throw new ConfigurationError("Either `functions` or `vars` must be provided");
55
- }
56
- // Process
57
- try {
58
- // Attempt to import the module
59
- return yield dynamicImport(moduleImport);
60
- } catch (error) {
61
- log.lib({
62
- lib: JAYPIE.LIB.JAYPIE
63
- }).trace("[jaypie] ".concat(moduleImport, " could not be imported; continuing"));
64
- }
65
- // Return
66
- var result = {};
67
- functions.forEach(func => {
68
- result[func] = () => {
69
- throw new ConfigurationError("".concat(moduleImport, ".").concat(func, " is not available"));
70
- };
71
- });
72
- vars.forEach(variable => {
73
- result[variable] = null;
74
- });
75
- return result;
76
- });
package/dist/esm/index.js DELETED
@@ -1,12 +0,0 @@
1
- //
2
- //
3
- // Export
4
- //
5
-
6
- // Required dependencies
7
- export * from "@jaypie/core";
8
-
9
- // Optional dependencies are wrapped in a dynamic import
10
- export * from "./aws.package.js";
11
- export * from "./lambda.package.js";
12
- export * from "./mongoose.package.js";
@@ -1,14 +0,0 @@
1
- import { JAYPIE } from "@jaypie/core";
2
- import dynamicExport from "./dynamicExport.function.js";
3
-
4
- //
5
- //
6
- // Export
7
- //
8
-
9
- export var {
10
- lambdaHandler
11
- } = await dynamicExport({
12
- functions: ["lambdaHandler"],
13
- moduleImport: JAYPIE.LIB.LAMBDA
14
- });
@@ -1,15 +0,0 @@
1
- import { JAYPIE } from "@jaypie/core";
2
- import dynamicExport from "./dynamicExport.function.js";
3
-
4
- //
5
- //
6
- // Export
7
- //
8
-
9
- export var {
10
- connectFromSecretEnv,
11
- disconnect
12
- } = await dynamicExport({
13
- functions: ["connectFromSecretEnv", "disconnect"],
14
- moduleImport: JAYPIE.LIB.MONGOOSE
15
- });
@@ -1,13 +0,0 @@
1
- import { JAYPIE } from "@jaypie/core";
2
- import dynamicExport from "./dynamicExport.function.js";
3
-
4
- //
5
- //
6
- // Export
7
- //
8
-
9
- export const { getMessages, getSecret, sendBatchMessages, sendMessage } =
10
- await dynamicExport({
11
- functions: ["getMessages", "getSecret", "sendBatchMessages", "sendMessage"],
12
- moduleImport: JAYPIE.LIB.AWS,
13
- });
@@ -1,12 +0,0 @@
1
- import { JAYPIE } from "@jaypie/core";
2
- import dynamicExport from "./dynamicExport.function.js";
3
-
4
- //
5
- //
6
- // Export
7
- //
8
-
9
- export const { lambdaHandler } = await dynamicExport({
10
- functions: ["lambdaHandler"],
11
- moduleImport: JAYPIE.LIB.LAMBDA,
12
- });
@@ -1,12 +0,0 @@
1
- import { JAYPIE } from "@jaypie/core";
2
- import dynamicExport from "./dynamicExport.function.js";
3
-
4
- //
5
- //
6
- // Export
7
- //
8
-
9
- export const { connectFromSecretEnv, disconnect } = await dynamicExport({
10
- functions: ["connectFromSecretEnv", "disconnect"],
11
- moduleImport: JAYPIE.LIB.MONGOOSE,
12
- });