jaypie 1.0.10 → 1.0.12

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/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ dist/
@@ -0,0 +1,13 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "targets": {
7
+ "node": "current"
8
+ },
9
+ "modules": "commonjs"
10
+ }
11
+ ]
12
+ ]
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "targets": {
7
+ "esmodules": true
8
+ },
9
+ "modules": false
10
+ }
11
+ ]
12
+ ]
13
+ }
@@ -0,0 +1,27 @@
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;
@@ -0,0 +1,77 @@
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;
@@ -0,0 +1,49 @@
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
+ });
@@ -0,0 +1,21 @@
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;
@@ -0,0 +1,23 @@
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;
@@ -0,0 +1,17 @@
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
+ });
@@ -0,0 +1,76 @@
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
+ });
@@ -0,0 +1,12 @@
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";
@@ -0,0 +1,14 @@
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
+ });
@@ -0,0 +1,15 @@
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
+ });
package/package.json CHANGED
@@ -1,26 +1,39 @@
1
1
  {
2
2
  "name": "jaypie",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "author": "Finlayson Studio",
5
5
  "type": "module",
6
- "main": "src/index.js",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/esm/index.js",
9
+ "require": "./dist/cjs/index.js"
10
+ }
11
+ },
12
+ "main": "dist/cjs/index.js",
13
+ "module": "dist/esm/index.js",
7
14
  "scripts": {
15
+ "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
16
  "format": "npm run format:package && npm run format:lint",
9
17
  "format:lint": "eslint --fix .",
10
18
  "format:package": "sort-package-json ./package.json",
11
19
  "init:deploy": "hygen jaypie workflow-npm",
12
20
  "lint": "eslint .",
13
21
  "new": "hygen jaypie vite",
22
+ "prepublish": "npm run build",
14
23
  "test": "vitest",
15
24
  "test:spec:dynamicExport.function": "vitest run ./src/__tests__/dynamicExport.function.spec.js",
16
25
  "test:spec:index": "vitest run ./src/__tests__/index.spec.js",
17
26
  "test:spec:mongoose.package": "vitest run ./src/__tests__/mongoose.package.spec.js"
18
27
  },
19
28
  "dependencies": {
20
- "@jaypie/core": "^1.0.8"
29
+ "@jaypie/core": "^1.0.14"
21
30
  },
22
31
  "devDependencies": {
23
- "@jaypie/testkit": "^1.0.4",
32
+ "@babel/cli": "^7.24.1",
33
+ "@babel/core": "^7.24.4",
34
+ "@babel/plugin-transform-modules-commonjs": "^7.24.1",
35
+ "@babel/preset-env": "^7.24.4",
36
+ "@jaypie/testkit": "^1.0.11",
24
37
  "eslint": "^8.57.0",
25
38
  "eslint-config-prettier": "^9.1.0",
26
39
  "eslint-plugin-import": "^2.29.1",