@medusajs/utils 1.10.0 → 1.10.1-next-20230912130318

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.
@@ -96,6 +96,7 @@ function mikroOrmCreateConnection(database, entities, pathToMigrations) {
96
96
  migrations: {
97
97
  path: pathToMigrations,
98
98
  },
99
+ pool: database.pool,
99
100
  })];
100
101
  case 2: return [2 /*return*/, _e.sent()];
101
102
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mikro-orm-create-connection.js","sourceRoot":"","sources":["../../../src/dal/mikro-orm/mikro-orm-create-connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAsB,wBAAwB,CAC5C,QAA2E,EAC3E,QAAe,EACf,gBAAwB;;;;;;;oBAEpB,MAAM,GAAG,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAA;oBAEpC,aAAa,GAAG,MAAA,QAAQ,CAAC,aAAa,mCAAI;wBAC5C,UAAU,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;qBAC1B,CAAA;oBAEG,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;oBAElC,IAAI,QAAQ,CAAC,UAAU,EAAE;wBACvB,oCAAoC;wBACpC,qGAAqG;wBACrG,aAAa,GAAG,QAAQ,CAAC,UAAU,CAAA;wBACnC,SAAS;4BACP,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAA;wBACvE,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAA;qBAC9D;oBAEoB,sFAAa,uBAAuB,QAAC;;oBAAlD,QAAQ,GAAK,CAAA,SAAqC,CAAA,SAA1C;oBACT,qBAAM,QAAQ,CAAC,IAAI,CAAC;4BACzB,SAAS,EAAE,EAAE,wBAAwB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AM,CAAC,MAAM,CAAC,UAAU,CAAA;qBAC9D;oBAEoB,sFAAa,uBAAuB,QAAC;;oBAAlD,QAAQ,GAAK,CAAA,SAAqC,CAAA,SAA1C;oBACT,qBAAM,QAAQ,CAAC,IAAI,CAAC;4BACzB,SAAS,EAAE,EAAE,wBAAwB,EAAE,IAAI,EAAE;4BAC7C,QAAQ,UAAA;4BACR,KAAK,EAAE,MAAA,MAAA,QAAQ,CAAC,KAAK,mCAAI,MAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,0CAAE,UAAU,CAAC,KAAK,CAAC,mCAAI,KAAK;4BACzE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;4BACtB,SAAS,WAAA;4BACT,MAAM,QAAA;4BACN,aAAa,eAAA;4BACb,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,aAAa;4BAC7C,IAAI,EAAE,YAAY;4BAClB,UAAU,EAAE;gCACV,IAAI,EAAE,gBAAgB;6BACvB;4BACD,IAAI,EAAE,QAAQ,CAAC,IAAW;yBAC3B,CAAC,EAAA;wBAdF,sBAAO,SAcL,EAAA;;;;CACH;AAtCD,4DAsCC"}
@@ -0,0 +1,8 @@
1
+ import { ModuleServiceInitializeOptions } from "@medusajs/types";
2
+ type Options = ModuleServiceInitializeOptions["database"];
3
+ /**
4
+ * Create a new knex (pg in the future) connection which can be reused and shared
5
+ * @param options
6
+ */
7
+ export declare function createPgConnection(options: Options): import("knex").Knex<any, any>;
8
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createPgConnection = void 0;
18
+ var knex_1 = __importDefault(require("knex"));
19
+ /**
20
+ * Create a new knex (pg in the future) connection which can be reused and shared
21
+ * @param options
22
+ */
23
+ function createPgConnection(options) {
24
+ var _a, _b, _c, _d;
25
+ var pool = options.pool, _e = options.schema, schema = _e === void 0 ? "public" : _e, clientUrl = options.clientUrl, driverOptions = options.driverOptions;
26
+ var ssl = (_b = (_a = options.driverOptions) === null || _a === void 0 ? void 0 : _a.ssl) !== null && _b !== void 0 ? _b : false;
27
+ return (0, knex_1.default)({
28
+ client: "pg",
29
+ searchPath: schema,
30
+ connection: {
31
+ connectionString: clientUrl,
32
+ ssl: ssl,
33
+ idle_in_transaction_session_timeout: (_c = driverOptions === null || driverOptions === void 0 ? void 0 : driverOptions.idle_in_transaction_session_timeout) !== null && _c !== void 0 ? _c : undefined, // prevent null to be passed
34
+ },
35
+ pool: __assign(__assign({}, (pool !== null && pool !== void 0 ? pool : {})), { min: (_d = pool === null || pool === void 0 ? void 0 : pool.min) !== null && _d !== void 0 ? _d : 0 }),
36
+ });
37
+ }
38
+ exports.createPgConnection = createPgConnection;
39
+ //# sourceMappingURL=create-pg-connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-pg-connection.js","sourceRoot":"","sources":["../../src/modules-sdk/create-pg-connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAAuB;AAKvB;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,OAAgB;;IACzC,IAAA,IAAI,GAAkD,OAAO,KAAzD,EAAE,KAAgD,OAAO,OAAtC,EAAjB,MAAM,mBAAG,QAAQ,KAAA,EAAE,SAAS,GAAoB,OAAO,UAA3B,EAAE,aAAa,GAAK,OAAO,cAAZ,CAAY;IACrE,IAAM,GAAG,GAAG,MAAA,MAAA,OAAO,CAAC,aAAa,0CAAE,GAAG,mCAAI,KAAK,CAAA;IAE/C,OAAO,IAAA,cAAI,EAAW;QACpB,MAAM,EAAE,IAAI;QACZ,UAAU,EAAE,MAAM;QAClB,UAAU,EAAE;YACV,gBAAgB,EAAE,SAAS;YAC3B,GAAG,KAAA;YACH,mCAAmC,EACjC,MAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,mCAA8C,mCAC9D,SAAS,EAAE,4BAA4B;SAC1C;QACD,IAAI,wBAEC,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC,KACf,GAAG,EAAE,MAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAc,mCAAI,CAAC,GAChC;KACF,CAAC,CAAA;AACJ,CAAC;AApBD,gDAoBC"}
@@ -3,3 +3,4 @@ export * from "./decorators";
3
3
  export * from "./build-query";
4
4
  export * from "./retrieve-entity";
5
5
  export * from "./loaders/mikro-orm-connection-loader";
6
+ export * from "./create-pg-connection";
@@ -19,4 +19,5 @@ __exportStar(require("./decorators"), exports);
19
19
  __exportStar(require("./build-query"), exports);
20
20
  __exportStar(require("./retrieve-entity"), exports);
21
21
  __exportStar(require("./loaders/mikro-orm-connection-loader"), exports);
22
+ __exportStar(require("./create-pg-connection"), exports);
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules-sdk/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA6C;AAC7C,+CAA4B;AAC5B,gDAA6B;AAC7B,oDAAiC;AACjC,wEAAqD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules-sdk/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA6C;AAC7C,+CAA4B;AAC5B,gDAA6B;AAC7B,oDAAiC;AACjC,wEAAqD;AACrD,yDAAsC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/utils",
3
- "version": "1.10.0",
3
+ "version": "1.10.1-next-20230912130318",
4
4
  "description": "Medusa utilities functions shared by Medusa core and Modules",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,11 +27,12 @@
27
27
  "typescript": "^5.1.6"
28
28
  },
29
29
  "dependencies": {
30
- "@medusajs/types": "^1.11.0",
30
+ "@medusajs/types": "1.11.1-next-20230912130318",
31
31
  "@mikro-orm/core": "5.7.12",
32
32
  "@mikro-orm/migrations": "5.7.12",
33
33
  "@mikro-orm/postgresql": "5.7.12",
34
34
  "awilix": "^8.0.1",
35
+ "knex": "2.4.2",
35
36
  "ulid": "^2.3.0"
36
37
  },
37
38
  "scripts": {