world-med-commons 1.0.3 → 1.0.4

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.
Files changed (37) hide show
  1. package/dist/index.d.ts +6 -1
  2. package/dist/index.js +6 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/models/allergy.schema.d.ts +3 -2
  5. package/dist/models/allergy.schema.js +2 -1
  6. package/dist/models/allergy.schema.js.map +1 -1
  7. package/dist/models/cart.model.d.ts +62 -0
  8. package/dist/models/cart.model.js +49 -0
  9. package/dist/models/cart.model.js.map +1 -0
  10. package/dist/models/country.schema.d.ts +72 -0
  11. package/dist/models/country.schema.js +39 -0
  12. package/dist/models/country.schema.js.map +1 -0
  13. package/dist/models/currency.schema.d.ts +62 -0
  14. package/dist/models/currency.schema.js +34 -0
  15. package/dist/models/currency.schema.js.map +1 -0
  16. package/dist/models/orders.schema.d.ts +164 -0
  17. package/dist/models/orders.schema.js +86 -0
  18. package/dist/models/orders.schema.js.map +1 -0
  19. package/dist/models/suppliers.schema.d.ts +3 -2
  20. package/dist/models/suppliers.schema.js +2 -1
  21. package/dist/models/suppliers.schema.js.map +1 -1
  22. package/dist/util/currency.util.d.ts +3 -0
  23. package/dist/util/currency.util.js +45 -0
  24. package/dist/util/currency.util.js.map +1 -0
  25. package/dist/util/ip-country.util.d.ts +6 -0
  26. package/dist/util/ip-country.util.js +33 -0
  27. package/dist/util/ip-country.util.js.map +1 -0
  28. package/package.json +3 -1
  29. package/src/index.ts +6 -1
  30. package/src/models/allergy.schema.ts +2 -1
  31. package/src/models/cart.model.ts +31 -0
  32. package/src/models/country.schema.ts +21 -0
  33. package/src/models/currency.schema.ts +17 -0
  34. package/src/models/orders.schema.ts +68 -0
  35. package/src/models/suppliers.schema.ts +2 -1
  36. package/src/util/currency.util.ts +92 -0
  37. package/src/util/ip-country.util.ts +60 -0
package/dist/index.d.ts CHANGED
@@ -3,10 +3,15 @@ export * from './models/user.schema';
3
3
  export * from './models/employee.schema';
4
4
  export * from './models/allergy.schema';
5
5
  export * from './dtos/pagination.dto';
6
- export * from './models/allergy.schema';
7
6
  export * from './models/drug.schema';
8
7
  export * from './models/drug-variant.schema';
9
8
  export * from './models/business-inventory.schema';
10
9
  export * from './models/patient.schema';
11
10
  export * from './models/suppliers.schema';
12
11
  export * from './models/apiKey.schema';
12
+ export * from './models/currency.schema';
13
+ export * from './util/currency.util';
14
+ export * from './util/ip-country.util';
15
+ export * from './models/country.schema';
16
+ export * from './models/cart.model';
17
+ export * from './models/orders.schema';
package/dist/index.js CHANGED
@@ -19,11 +19,16 @@ __exportStar(require("./models/user.schema"), exports);
19
19
  __exportStar(require("./models/employee.schema"), exports);
20
20
  __exportStar(require("./models/allergy.schema"), exports);
21
21
  __exportStar(require("./dtos/pagination.dto"), exports);
22
- __exportStar(require("./models/allergy.schema"), exports);
23
22
  __exportStar(require("./models/drug.schema"), exports);
24
23
  __exportStar(require("./models/drug-variant.schema"), exports);
25
24
  __exportStar(require("./models/business-inventory.schema"), exports);
26
25
  __exportStar(require("./models/patient.schema"), exports);
27
26
  __exportStar(require("./models/suppliers.schema"), exports);
28
27
  __exportStar(require("./models/apiKey.schema"), exports);
28
+ __exportStar(require("./models/currency.schema"), exports);
29
+ __exportStar(require("./util/currency.util"), exports);
30
+ __exportStar(require("./util/ip-country.util"), exports);
31
+ __exportStar(require("./models/country.schema"), exports);
32
+ __exportStar(require("./models/cart.model"), exports);
33
+ __exportStar(require("./models/orders.schema"), exports);
29
34
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,uDAAqC;AACrC,2DAAyC;AACzC,0DAAwC;AACxC,wDAAsC;AACtC,0DAAwC;AACxC,uDAAqC;AACrC,+DAA6C;AAC7C,qEAAmD;AACnD,0DAAwC;AACxC,4DAA0C;AAC1C,yDAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,uDAAqC;AACrC,2DAAyC;AACzC,0DAAwC;AACxC,wDAAsC;AACtC,uDAAqC;AACrC,+DAA6C;AAC7C,qEAAmD;AACnD,0DAAwC;AACxC,4DAA0C;AAC1C,yDAAuC;AACvC,2DAAyC;AACzC,uDAAqC;AACrC,yDAAuC;AACvC,0DAAwC;AACxC,sDAAoC;AACpC,yDAAuC"}
@@ -1,4 +1,5 @@
1
1
  import { Document, Types } from 'mongoose';
2
+ import { User } from "./user.schema";
2
3
  export declare enum AllergySeverity {
3
4
  MILD = "mild",
4
5
  MODERATE = "moderate",
@@ -16,7 +17,7 @@ export declare enum AllergyType {
16
17
  CONTRAINDICATION = "contraindication"
17
18
  }
18
19
  export declare class Allergy extends Document {
19
- user: Types.ObjectId;
20
+ user: User;
20
21
  substance: string;
21
22
  codedSubstance?: {
22
23
  system: string;
@@ -70,7 +71,7 @@ export declare const AllergySchema: import("mongoose").Schema<Allergy, import("m
70
71
  }, "id"> & {
71
72
  id: string;
72
73
  }>;
73
- user?: import("mongoose").SchemaDefinitionProperty<Types.ObjectId, Allergy, Document<unknown, {}, Allergy, {
74
+ user?: import("mongoose").SchemaDefinitionProperty<User, Allergy, Document<unknown, {}, Allergy, {
74
75
  id: string;
75
76
  }, import("mongoose").DefaultSchemaOptions> & Omit<Allergy & Required<{
76
77
  _id: Types.ObjectId;
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AllergySchema = exports.Allergy = exports.AllergyType = exports.AllergyCriticality = exports.AllergySeverity = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
+ const user_schema_1 = require("./user.schema");
15
16
  var AllergySeverity;
16
17
  (function (AllergySeverity) {
17
18
  AllergySeverity["MILD"] = "mild";
@@ -36,7 +37,7 @@ let Allergy = class Allergy extends mongoose_2.Document {
36
37
  exports.Allergy = Allergy;
37
38
  __decorate([
38
39
  (0, mongoose_1.Prop)({ type: mongoose_2.Types.ObjectId, ref: 'User', required: true, index: true }),
39
- __metadata("design:type", mongoose_2.Types.ObjectId)
40
+ __metadata("design:type", user_schema_1.User)
40
41
  ], Allergy.prototype, "user", void 0);
41
42
  __decorate([
42
43
  (0, mongoose_1.Prop)({ required: true }),
@@ -1 +1 @@
1
- {"version":3,"file":"allergy.schema.js","sourceRoot":"","sources":["../../src/models/allergy.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA+D;AAC/D,uCAA2C;AAE3C,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,wCAAqB,CAAA;IACrB,oCAAiB,CAAA;IACjB,wDAAqC,CAAA;AACvC,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B;AAED,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,iCAAW,CAAA;IACX,mCAAa,CAAA;IACb,2DAAqC,CAAA;AACvC,CAAC,EAJW,kBAAkB,kCAAlB,kBAAkB,QAI7B;AAED,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,0CAA2B,CAAA;IAC3B,oDAAqC,CAAA;AACvC,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB;AAGM,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,mBAAQ;CAyCpC,CAAA;AAzCY,0BAAO;AAElB;IADC,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,gBAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;8BACnE,gBAAK,CAAC,QAAQ;qCAAC;AAGrB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACP;AAIlB;IADC,IAAA,eAAI,EAAC,EAAE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AG,wBAAa,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AAGnE,qBAAa,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AAC5C,qBAAa,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;AAC/C,qBAAa,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,62 @@
1
+ import mongoose, { Document } from "mongoose";
2
+ export declare class Cart extends Document {
3
+ userId: string;
4
+ vendors: any[];
5
+ lastModified: Date;
6
+ }
7
+ export declare const CartSchema: mongoose.Schema<Cart, mongoose.Model<Cart, any, any, any, (mongoose.Document<unknown, any, Cart, any, mongoose.DefaultSchemaOptions> & Cart & Required<{
8
+ _id: mongoose.Types.ObjectId;
9
+ }> & {
10
+ __v: number;
11
+ } & {
12
+ id: string;
13
+ }) | (mongoose.Document<unknown, any, Cart, any, mongoose.DefaultSchemaOptions> & Cart & Required<{
14
+ _id: mongoose.Types.ObjectId;
15
+ }> & {
16
+ __v: number;
17
+ }), any, Cart>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, Cart, mongoose.Document<unknown, {}, Cart, {
18
+ id: string;
19
+ }, mongoose.DefaultSchemaOptions> & Omit<Cart & Required<{
20
+ _id: mongoose.Types.ObjectId;
21
+ }> & {
22
+ __v: number;
23
+ }, "id"> & {
24
+ id: string;
25
+ }, {
26
+ _id?: mongoose.SchemaDefinitionProperty<mongoose.Types.ObjectId, Cart, mongoose.Document<unknown, {}, Cart, {
27
+ id: string;
28
+ }, mongoose.DefaultSchemaOptions> & Omit<Cart & Required<{
29
+ _id: mongoose.Types.ObjectId;
30
+ }> & {
31
+ __v: number;
32
+ }, "id"> & {
33
+ id: string;
34
+ }>;
35
+ userId?: mongoose.SchemaDefinitionProperty<string, Cart, mongoose.Document<unknown, {}, Cart, {
36
+ id: string;
37
+ }, mongoose.DefaultSchemaOptions> & Omit<Cart & Required<{
38
+ _id: mongoose.Types.ObjectId;
39
+ }> & {
40
+ __v: number;
41
+ }, "id"> & {
42
+ id: string;
43
+ }>;
44
+ vendors?: mongoose.SchemaDefinitionProperty<any[], Cart, mongoose.Document<unknown, {}, Cart, {
45
+ id: string;
46
+ }, mongoose.DefaultSchemaOptions> & Omit<Cart & Required<{
47
+ _id: mongoose.Types.ObjectId;
48
+ }> & {
49
+ __v: number;
50
+ }, "id"> & {
51
+ id: string;
52
+ }>;
53
+ lastModified?: mongoose.SchemaDefinitionProperty<Date, Cart, mongoose.Document<unknown, {}, Cart, {
54
+ id: string;
55
+ }, mongoose.DefaultSchemaOptions> & Omit<Cart & Required<{
56
+ _id: mongoose.Types.ObjectId;
57
+ }> & {
58
+ __v: number;
59
+ }, "id"> & {
60
+ id: string;
61
+ }>;
62
+ }, Cart>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CartSchema = exports.Cart = void 0;
13
+ const mongoose_1 = require("mongoose");
14
+ const mongoose_2 = require("@nestjs/mongoose");
15
+ let Cart = class Cart extends mongoose_1.Document {
16
+ };
17
+ exports.Cart = Cart;
18
+ __decorate([
19
+ (0, mongoose_2.Prop)({
20
+ type: mongoose_1.default.Schema.Types.ObjectId,
21
+ ref: 'User',
22
+ required: true
23
+ }),
24
+ __metadata("design:type", String)
25
+ ], Cart.prototype, "userId", void 0);
26
+ __decorate([
27
+ (0, mongoose_2.Prop)([{
28
+ pharmacyId: { type: mongoose_1.default.Schema.Types.ObjectId, ref: 'Business', required: true },
29
+ items: [{
30
+ inventoryId: { type: mongoose_1.default.Schema.Types.ObjectId, ref: 'PharmacyInventory', required: true },
31
+ quantity: { type: Number, required: true, min: 1 },
32
+ price: { type: Number, required: true },
33
+ requiresPrescription: { type: Boolean, default: false },
34
+ }],
35
+ deliveryFee: { type: Number, default: 0 }
36
+ }]),
37
+ __metadata("design:type", Array)
38
+ ], Cart.prototype, "vendors", void 0);
39
+ __decorate([
40
+ (0, mongoose_2.Prop)({ default: Date.now, expires: '7d' }),
41
+ __metadata("design:type", Date)
42
+ ], Cart.prototype, "lastModified", void 0);
43
+ exports.Cart = Cart = __decorate([
44
+ (0, mongoose_2.Schema)({
45
+ timestamps: true
46
+ })
47
+ ], Cart);
48
+ exports.CartSchema = mongoose_2.SchemaFactory.createForClass(Cart);
49
+ //# sourceMappingURL=cart.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cart.model.js","sourceRoot":"","sources":["../../src/models/cart.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAA8C;AAC9C,+CAA+D;AAKxD,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,mBAAQ;CAsBjC,CAAA;AAtBY,oBAAI;AAMf;IALC,IAAA,eAAI,EAAC;QACJ,IAAI,EAAE,kBAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ;QACpC,GAAG,EAAE,MAAM;QACX,QAAQ,EAAE,IAAI;KACf,CAAC;;oCACa;AAYf;IAVC,IAAA,eAAI,EAAC,CAAC;YACL,UAAU,EAAE,EAAE,IAAI,EAAE,kBAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE;YACrF,KAAK,EAAE,CAAC;oBACN,WAAW,EAAE,EAAE,IAAI,EAAE,kBAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE;oBAC/F,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE;oBAClD,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;oBACvC,oBAAoB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;iBACxD,CAAC;YACF,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE;SAC1C,CAAC,CAAC;;qCACY;AAGf;IADC,IAAA,eAAI,EAAC,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BAC7B,IAAI;0CAAC;eArBR,IAAI;IAHhB,IAAA,iBAAM,EAAC;QACN,UAAU,EAAE,IAAI;KACjB,CAAC;GACW,IAAI,CAsBhB;AAEY,QAAA,UAAU,GAAG,wBAAa,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,72 @@
1
+ import { Document } from 'mongoose';
2
+ export declare class Country extends Document {
3
+ name: string;
4
+ code: string;
5
+ currency: string;
6
+ enable: boolean;
7
+ }
8
+ export declare const CountrySchema: import("mongoose").Schema<Country, import("mongoose").Model<Country, any, any, any, (Document<unknown, any, Country, any, import("mongoose").DefaultSchemaOptions> & Country & Required<{
9
+ _id: import("mongoose").Types.ObjectId;
10
+ }> & {
11
+ __v: number;
12
+ } & {
13
+ id: string;
14
+ }) | (Document<unknown, any, Country, any, import("mongoose").DefaultSchemaOptions> & Country & Required<{
15
+ _id: import("mongoose").Types.ObjectId;
16
+ }> & {
17
+ __v: number;
18
+ }), any, Country>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Country, Document<unknown, {}, Country, {
19
+ id: string;
20
+ }, import("mongoose").DefaultSchemaOptions> & Omit<Country & Required<{
21
+ _id: import("mongoose").Types.ObjectId;
22
+ }> & {
23
+ __v: number;
24
+ }, "id"> & {
25
+ id: string;
26
+ }, {
27
+ name?: import("mongoose").SchemaDefinitionProperty<string, Country, Document<unknown, {}, Country, {
28
+ id: string;
29
+ }, import("mongoose").DefaultSchemaOptions> & Omit<Country & Required<{
30
+ _id: import("mongoose").Types.ObjectId;
31
+ }> & {
32
+ __v: number;
33
+ }, "id"> & {
34
+ id: string;
35
+ }>;
36
+ _id?: import("mongoose").SchemaDefinitionProperty<import("mongoose").Types.ObjectId, Country, Document<unknown, {}, Country, {
37
+ id: string;
38
+ }, import("mongoose").DefaultSchemaOptions> & Omit<Country & Required<{
39
+ _id: import("mongoose").Types.ObjectId;
40
+ }> & {
41
+ __v: number;
42
+ }, "id"> & {
43
+ id: string;
44
+ }>;
45
+ code?: import("mongoose").SchemaDefinitionProperty<string, Country, Document<unknown, {}, Country, {
46
+ id: string;
47
+ }, import("mongoose").DefaultSchemaOptions> & Omit<Country & Required<{
48
+ _id: import("mongoose").Types.ObjectId;
49
+ }> & {
50
+ __v: number;
51
+ }, "id"> & {
52
+ id: string;
53
+ }>;
54
+ currency?: import("mongoose").SchemaDefinitionProperty<string, Country, Document<unknown, {}, Country, {
55
+ id: string;
56
+ }, import("mongoose").DefaultSchemaOptions> & Omit<Country & Required<{
57
+ _id: import("mongoose").Types.ObjectId;
58
+ }> & {
59
+ __v: number;
60
+ }, "id"> & {
61
+ id: string;
62
+ }>;
63
+ enable?: import("mongoose").SchemaDefinitionProperty<boolean, Country, Document<unknown, {}, Country, {
64
+ id: string;
65
+ }, import("mongoose").DefaultSchemaOptions> & Omit<Country & Required<{
66
+ _id: import("mongoose").Types.ObjectId;
67
+ }> & {
68
+ __v: number;
69
+ }, "id"> & {
70
+ id: string;
71
+ }>;
72
+ }, Country>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CountrySchema = exports.Country = void 0;
13
+ const mongoose_1 = require("@nestjs/mongoose");
14
+ const mongoose_2 = require("mongoose");
15
+ let Country = class Country extends mongoose_2.Document {
16
+ };
17
+ exports.Country = Country;
18
+ __decorate([
19
+ (0, mongoose_1.Prop)({ required: true }),
20
+ __metadata("design:type", String)
21
+ ], Country.prototype, "name", void 0);
22
+ __decorate([
23
+ (0, mongoose_1.Prop)({ required: true }),
24
+ __metadata("design:type", String)
25
+ ], Country.prototype, "code", void 0);
26
+ __decorate([
27
+ (0, mongoose_1.Prop)({ required: true, default: "USD" }),
28
+ __metadata("design:type", String)
29
+ ], Country.prototype, "currency", void 0);
30
+ __decorate([
31
+ (0, mongoose_1.Prop)({ default: true }),
32
+ __metadata("design:type", Boolean)
33
+ ], Country.prototype, "enable", void 0);
34
+ exports.Country = Country = __decorate([
35
+ (0, mongoose_1.Schema)()
36
+ ], Country);
37
+ exports.CountrySchema = mongoose_1.SchemaFactory.createForClass(Country);
38
+ exports.CountrySchema.index({ name: 1, code: 1 });
39
+ //# sourceMappingURL=country.schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country.schema.js","sourceRoot":"","sources":["../../src/models/country.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA6D;AAC7D,uCAAoC;AAG7B,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,mBAAQ;CAYpC,CAAA;AAZY,0BAAO;AAElB;IADC,IAAA,eAAI,EAAC,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;;qCACV;AAGb;IADC,IAAA,eAAI,EAAC,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;;qCACV;AAGb;IADC,IAAA,eAAI,EAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAC,CAAC;;yCACtB;AAGjB;IADC,IAAA,eAAI,EAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;;uCACN;kBAXL,OAAO;IADnB,IAAA,iBAAM,GAAE;GACI,OAAO,CAYnB;AAEY,QAAA,aAAa,GAAG,wBAAa,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AAEnE,qBAAa,CAAC,KAAK,CAAC,EAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { Document } from "mongoose";
2
+ export declare class Currency extends Document {
3
+ currencyCode: string;
4
+ value: number;
5
+ baseCurrency: string;
6
+ }
7
+ export declare const CurrencySchema: import("mongoose").Schema<Currency, import("mongoose").Model<Currency, any, any, any, (Document<unknown, any, Currency, any, import("mongoose").DefaultSchemaOptions> & Currency & Required<{
8
+ _id: import("mongoose").Types.ObjectId;
9
+ }> & {
10
+ __v: number;
11
+ } & {
12
+ id: string;
13
+ }) | (Document<unknown, any, Currency, any, import("mongoose").DefaultSchemaOptions> & Currency & Required<{
14
+ _id: import("mongoose").Types.ObjectId;
15
+ }> & {
16
+ __v: number;
17
+ }), any, Currency>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Currency, Document<unknown, {}, Currency, {
18
+ id: string;
19
+ }, import("mongoose").DefaultSchemaOptions> & Omit<Currency & Required<{
20
+ _id: import("mongoose").Types.ObjectId;
21
+ }> & {
22
+ __v: number;
23
+ }, "id"> & {
24
+ id: string;
25
+ }, {
26
+ _id?: import("mongoose").SchemaDefinitionProperty<import("mongoose").Types.ObjectId, Currency, Document<unknown, {}, Currency, {
27
+ id: string;
28
+ }, import("mongoose").DefaultSchemaOptions> & Omit<Currency & Required<{
29
+ _id: import("mongoose").Types.ObjectId;
30
+ }> & {
31
+ __v: number;
32
+ }, "id"> & {
33
+ id: string;
34
+ }>;
35
+ currencyCode?: import("mongoose").SchemaDefinitionProperty<string, Currency, Document<unknown, {}, Currency, {
36
+ id: string;
37
+ }, import("mongoose").DefaultSchemaOptions> & Omit<Currency & Required<{
38
+ _id: import("mongoose").Types.ObjectId;
39
+ }> & {
40
+ __v: number;
41
+ }, "id"> & {
42
+ id: string;
43
+ }>;
44
+ value?: import("mongoose").SchemaDefinitionProperty<number, Currency, Document<unknown, {}, Currency, {
45
+ id: string;
46
+ }, import("mongoose").DefaultSchemaOptions> & Omit<Currency & Required<{
47
+ _id: import("mongoose").Types.ObjectId;
48
+ }> & {
49
+ __v: number;
50
+ }, "id"> & {
51
+ id: string;
52
+ }>;
53
+ baseCurrency?: import("mongoose").SchemaDefinitionProperty<string, Currency, Document<unknown, {}, Currency, {
54
+ id: string;
55
+ }, import("mongoose").DefaultSchemaOptions> & Omit<Currency & Required<{
56
+ _id: import("mongoose").Types.ObjectId;
57
+ }> & {
58
+ __v: number;
59
+ }, "id"> & {
60
+ id: string;
61
+ }>;
62
+ }, Currency>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CurrencySchema = exports.Currency = void 0;
13
+ const mongoose_1 = require("mongoose");
14
+ const mongoose_2 = require("@nestjs/mongoose");
15
+ let Currency = class Currency extends mongoose_1.Document {
16
+ };
17
+ exports.Currency = Currency;
18
+ __decorate([
19
+ (0, mongoose_2.Prop)({ required: true }),
20
+ __metadata("design:type", String)
21
+ ], Currency.prototype, "currencyCode", void 0);
22
+ __decorate([
23
+ (0, mongoose_2.Prop)({ required: true }),
24
+ __metadata("design:type", Number)
25
+ ], Currency.prototype, "value", void 0);
26
+ __decorate([
27
+ (0, mongoose_2.Prop)({ required: true }),
28
+ __metadata("design:type", String)
29
+ ], Currency.prototype, "baseCurrency", void 0);
30
+ exports.Currency = Currency = __decorate([
31
+ (0, mongoose_2.Schema)({ timestamps: true })
32
+ ], Currency);
33
+ exports.CurrencySchema = mongoose_2.SchemaFactory.createForClass(Currency);
34
+ //# sourceMappingURL=currency.schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currency.schema.js","sourceRoot":"","sources":["../../src/models/currency.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAkC;AAClC,+CAA6D;AAGtD,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,mBAAQ;CASrC,CAAA;AATY,4BAAQ;AAEnB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACJ;AAGrB;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACX;AAGd;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACJ;mBARV,QAAQ;IADpB,IAAA,iBAAM,EAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;GAChB,QAAQ,CASpB;AAEY,QAAA,cAAc,GAAG,wBAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,164 @@
1
+ import mongoose, { Document } from "mongoose";
2
+ import { Business } from "./business.schema";
3
+ import { User } from "./user.schema";
4
+ export declare class Orders extends Document {
5
+ orderNumber: string;
6
+ items: any[];
7
+ business?: Business;
8
+ user?: User;
9
+ shippingAddress: {
10
+ email: string;
11
+ phoneNumber: string;
12
+ country: string;
13
+ street: string;
14
+ city: string;
15
+ coordinates: {
16
+ lat: number;
17
+ lng: number;
18
+ };
19
+ };
20
+ TransactionFee: number;
21
+ deliveryFee: number;
22
+ totalAmount: number;
23
+ parentOrder: Orders;
24
+ status: string;
25
+ prescriptions: any[];
26
+ }
27
+ export declare const OrdersSchema: mongoose.Schema<Orders, mongoose.Model<Orders, any, any, any, (mongoose.Document<unknown, any, Orders, any, mongoose.DefaultSchemaOptions> & Orders & Required<{
28
+ _id: mongoose.Types.ObjectId;
29
+ }> & {
30
+ __v: number;
31
+ } & {
32
+ id: string;
33
+ }) | (mongoose.Document<unknown, any, Orders, any, mongoose.DefaultSchemaOptions> & Orders & Required<{
34
+ _id: mongoose.Types.ObjectId;
35
+ }> & {
36
+ __v: number;
37
+ }), any, Orders>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, Orders, mongoose.Document<unknown, {}, Orders, {
38
+ id: string;
39
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
40
+ _id: mongoose.Types.ObjectId;
41
+ }> & {
42
+ __v: number;
43
+ }, "id"> & {
44
+ id: string;
45
+ }, {
46
+ _id?: mongoose.SchemaDefinitionProperty<mongoose.Types.ObjectId, Orders, mongoose.Document<unknown, {}, Orders, {
47
+ id: string;
48
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
49
+ _id: mongoose.Types.ObjectId;
50
+ }> & {
51
+ __v: number;
52
+ }, "id"> & {
53
+ id: string;
54
+ }>;
55
+ business?: mongoose.SchemaDefinitionProperty<Business, Orders, mongoose.Document<unknown, {}, Orders, {
56
+ id: string;
57
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
58
+ _id: mongoose.Types.ObjectId;
59
+ }> & {
60
+ __v: number;
61
+ }, "id"> & {
62
+ id: string;
63
+ }>;
64
+ user?: mongoose.SchemaDefinitionProperty<User, Orders, mongoose.Document<unknown, {}, Orders, {
65
+ id: string;
66
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
67
+ _id: mongoose.Types.ObjectId;
68
+ }> & {
69
+ __v: number;
70
+ }, "id"> & {
71
+ id: string;
72
+ }>;
73
+ items?: mongoose.SchemaDefinitionProperty<any[], Orders, mongoose.Document<unknown, {}, Orders, {
74
+ id: string;
75
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
76
+ _id: mongoose.Types.ObjectId;
77
+ }> & {
78
+ __v: number;
79
+ }, "id"> & {
80
+ id: string;
81
+ }>;
82
+ deliveryFee?: mongoose.SchemaDefinitionProperty<number, Orders, mongoose.Document<unknown, {}, Orders, {
83
+ id: string;
84
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
85
+ _id: mongoose.Types.ObjectId;
86
+ }> & {
87
+ __v: number;
88
+ }, "id"> & {
89
+ id: string;
90
+ }>;
91
+ orderNumber?: mongoose.SchemaDefinitionProperty<string, Orders, mongoose.Document<unknown, {}, Orders, {
92
+ id: string;
93
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
94
+ _id: mongoose.Types.ObjectId;
95
+ }> & {
96
+ __v: number;
97
+ }, "id"> & {
98
+ id: string;
99
+ }>;
100
+ shippingAddress?: mongoose.SchemaDefinitionProperty<{
101
+ email: string;
102
+ phoneNumber: string;
103
+ country: string;
104
+ street: string;
105
+ city: string;
106
+ coordinates: {
107
+ lat: number;
108
+ lng: number;
109
+ };
110
+ }, Orders, mongoose.Document<unknown, {}, Orders, {
111
+ id: string;
112
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
113
+ _id: mongoose.Types.ObjectId;
114
+ }> & {
115
+ __v: number;
116
+ }, "id"> & {
117
+ id: string;
118
+ }>;
119
+ TransactionFee?: mongoose.SchemaDefinitionProperty<number, Orders, mongoose.Document<unknown, {}, Orders, {
120
+ id: string;
121
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
122
+ _id: mongoose.Types.ObjectId;
123
+ }> & {
124
+ __v: number;
125
+ }, "id"> & {
126
+ id: string;
127
+ }>;
128
+ totalAmount?: mongoose.SchemaDefinitionProperty<number, Orders, mongoose.Document<unknown, {}, Orders, {
129
+ id: string;
130
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
131
+ _id: mongoose.Types.ObjectId;
132
+ }> & {
133
+ __v: number;
134
+ }, "id"> & {
135
+ id: string;
136
+ }>;
137
+ parentOrder?: mongoose.SchemaDefinitionProperty<Orders, Orders, mongoose.Document<unknown, {}, Orders, {
138
+ id: string;
139
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
140
+ _id: mongoose.Types.ObjectId;
141
+ }> & {
142
+ __v: number;
143
+ }, "id"> & {
144
+ id: string;
145
+ }>;
146
+ status?: mongoose.SchemaDefinitionProperty<string, Orders, mongoose.Document<unknown, {}, Orders, {
147
+ id: string;
148
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
149
+ _id: mongoose.Types.ObjectId;
150
+ }> & {
151
+ __v: number;
152
+ }, "id"> & {
153
+ id: string;
154
+ }>;
155
+ prescriptions?: mongoose.SchemaDefinitionProperty<any[], Orders, mongoose.Document<unknown, {}, Orders, {
156
+ id: string;
157
+ }, mongoose.DefaultSchemaOptions> & Omit<Orders & Required<{
158
+ _id: mongoose.Types.ObjectId;
159
+ }> & {
160
+ __v: number;
161
+ }, "id"> & {
162
+ id: string;
163
+ }>;
164
+ }, Orders>;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OrdersSchema = exports.Orders = void 0;
13
+ const mongoose_1 = require("@nestjs/mongoose");
14
+ const mongoose_2 = require("mongoose");
15
+ const business_schema_1 = require("./business.schema");
16
+ const user_schema_1 = require("./user.schema");
17
+ let Orders = class Orders extends mongoose_2.Document {
18
+ };
19
+ exports.Orders = Orders;
20
+ __decorate([
21
+ (0, mongoose_1.Prop)({ required: true }),
22
+ __metadata("design:type", String)
23
+ ], Orders.prototype, "orderNumber", void 0);
24
+ __decorate([
25
+ (0, mongoose_1.Prop)([{
26
+ pharmacyInventoryId: { type: mongoose_2.default.Schema.Types.ObjectId, ref: 'PharmacyInventory' },
27
+ quantity: Number,
28
+ price: Number,
29
+ requiresPrescription: Boolean,
30
+ taxAmount: Number,
31
+ }]),
32
+ __metadata("design:type", Array)
33
+ ], Orders.prototype, "items", void 0);
34
+ __decorate([
35
+ (0, mongoose_1.Prop)({ type: mongoose_2.default.Schema.Types.ObjectId, ref: 'Business' }),
36
+ __metadata("design:type", business_schema_1.Business)
37
+ ], Orders.prototype, "business", void 0);
38
+ __decorate([
39
+ (0, mongoose_1.Prop)({ type: mongoose_2.default.Schema.Types.ObjectId, ref: 'User' }),
40
+ __metadata("design:type", user_schema_1.User)
41
+ ], Orders.prototype, "user", void 0);
42
+ __decorate([
43
+ (0, mongoose_1.Prop)({ type: Object, required: true }),
44
+ __metadata("design:type", Object)
45
+ ], Orders.prototype, "shippingAddress", void 0);
46
+ __decorate([
47
+ (0, mongoose_1.Prop)({
48
+ required: true,
49
+ type: Number
50
+ }),
51
+ __metadata("design:type", Number)
52
+ ], Orders.prototype, "TransactionFee", void 0);
53
+ __decorate([
54
+ (0, mongoose_1.Prop)({ type: Number }),
55
+ __metadata("design:type", Number)
56
+ ], Orders.prototype, "deliveryFee", void 0);
57
+ __decorate([
58
+ (0, mongoose_1.Prop)({
59
+ required: true,
60
+ type: Number
61
+ }),
62
+ __metadata("design:type", Number)
63
+ ], Orders.prototype, "totalAmount", void 0);
64
+ __decorate([
65
+ (0, mongoose_1.Prop)({
66
+ type: mongoose_2.default.Schema.Types.ObjectId, ref: 'Orders'
67
+ }),
68
+ __metadata("design:type", Orders)
69
+ ], Orders.prototype, "parentOrder", void 0);
70
+ __decorate([
71
+ (0, mongoose_1.Prop)({
72
+ type: String,
73
+ enum: ['Pending', 'Processing', 'Ready', 'Delivered', 'Cancelled', 'Completed'],
74
+ default: 'Pending'
75
+ }),
76
+ __metadata("design:type", String)
77
+ ], Orders.prototype, "status", void 0);
78
+ __decorate([
79
+ (0, mongoose_1.Prop)({ type: Array }),
80
+ __metadata("design:type", Array)
81
+ ], Orders.prototype, "prescriptions", void 0);
82
+ exports.Orders = Orders = __decorate([
83
+ (0, mongoose_1.Schema)({ timestamps: true })
84
+ ], Orders);
85
+ exports.OrdersSchema = mongoose_1.SchemaFactory.createForClass(Orders);
86
+ //# sourceMappingURL=orders.schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orders.schema.js","sourceRoot":"","sources":["../../src/models/orders.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,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,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ;KACpD,CAAC;8BACW,MAAM;2CAAC;AAOpB;IALC,IAAA,eAAI,EAAC;QACJ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC;QAC/E,OAAO,EAAE,SAAS;KACnB,CAAC;;sCACa;AAGf;IADC,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;6CACD;iBAzDV,MAAM;IADlB,IAAA,iBAAM,EAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;GAChB,MAAM,CA2DlB;AAEY,QAAA,YAAY,GAAG,wBAAa,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { HydratedDocument, Types } from "mongoose";
2
2
  import { Address } from "./user.schema";
3
+ import { Business } from "./business.schema";
3
4
  export type SuppliersDocument = HydratedDocument<Supplier>;
4
5
  export declare class Supplier {
5
6
  name: string;
@@ -7,7 +8,7 @@ export declare class Supplier {
7
8
  email?: string;
8
9
  phoneNumber?: string;
9
10
  website?: string;
10
- business: Types.ObjectId;
11
+ business: Business;
11
12
  }
12
13
  export declare const SupplierSchema: import("mongoose").Schema<Supplier, import("mongoose").Model<Supplier, any, any, any, (import("mongoose").Document<unknown, any, Supplier, any, import("mongoose").DefaultSchemaOptions> & Supplier & {
13
14
  _id: Types.ObjectId;
@@ -73,7 +74,7 @@ export declare const SupplierSchema: import("mongoose").Schema<Supplier, import(
73
74
  }, "id"> & {
74
75
  id: string;
75
76
  }>;
76
- business?: import("mongoose").SchemaDefinitionProperty<Types.ObjectId, Supplier, import("mongoose").Document<unknown, {}, Supplier, {
77
+ business?: import("mongoose").SchemaDefinitionProperty<Business, Supplier, import("mongoose").Document<unknown, {}, Supplier, {
77
78
  id: string;
78
79
  }, import("mongoose").DefaultSchemaOptions> & Omit<Supplier & {
79
80
  _id: Types.ObjectId;
@@ -13,6 +13,7 @@ exports.SupplierSchema = exports.Supplier = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
15
  const user_schema_1 = require("./user.schema");
16
+ const business_schema_1 = require("./business.schema");
16
17
  let Supplier = class Supplier {
17
18
  };
18
19
  exports.Supplier = Supplier;
@@ -38,7 +39,7 @@ __decorate([
38
39
  ], Supplier.prototype, "website", void 0);
39
40
  __decorate([
40
41
  (0, mongoose_1.Prop)({ type: mongoose_2.Types.ObjectId, ref: 'Business', required: true, index: true }),
41
- __metadata("design:type", mongoose_2.Types.ObjectId)
42
+ __metadata("design:type", business_schema_1.Business)
42
43
  ], Supplier.prototype, "business", void 0);
43
44
  exports.Supplier = Supplier = __decorate([
44
45
  (0, mongoose_1.Schema)({
@@ -1 +1 @@
1
- {"version":3,"file":"suppliers.schema.js","sourceRoot":"","sources":["../../src/models/suppliers.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA6D;AAC7D,uCAAiD;AACjD,+CAAsC;AAO/B,IAAM,QAAQ,GAAd,MAAM,QAAQ;CAepB,CAAA;AAfY,4BAAQ;AAGnB;IADC,IAAA,eAAI,EAAC,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;;sCACV;AAEb;IADC,IAAA,eAAI,GAAE;8BACG,qBAAO;yCAAC;AAElB;IADC,IAAA,eAAI,GAAE;;uCACQ;AAEf;IADC,IAAA,eAAI,GAAE;;6CACc;AAErB;IADC,IAAA,eAAI,GAAE;;yCACU;AAGjB;IADC,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,gBAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;8BAClE,gBAAK,CAAC,QAAQ;0CAAC;mBAdd,QAAQ;IAHpB,IAAA,iBAAM,EAAC;QACN,UAAU,EAAE,IAAI;KACjB,CAAC;GACW,QAAQ,CAepB;AAEY,QAAA,cAAc,GAAG,wBAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC"}
1
+ {"version":3,"file":"suppliers.schema.js","sourceRoot":"","sources":["../../src/models/suppliers.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA6D;AAC7D,uCAAiD;AACjD,+CAAsC;AACtC,uDAA2C;AAOpC,IAAM,QAAQ,GAAd,MAAM,QAAQ;CAepB,CAAA;AAfY,4BAAQ;AAGnB;IADC,IAAA,eAAI,EAAC,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;;sCACV;AAEb;IADC,IAAA,eAAI,GAAE;8BACG,qBAAO;yCAAC;AAElB;IADC,IAAA,eAAI,GAAE;;uCACQ;AAEf;IADC,IAAA,eAAI,GAAE;;6CACc;AAErB;IADC,IAAA,eAAI,GAAE;;yCACU;AAGjB;IADC,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,gBAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;8BAClE,0BAAQ;0CAAC;mBAdR,QAAQ;IAHpB,IAAA,iBAAM,EAAC;QACN,UAAU,EAAE,IAAI;KACjB,CAAC;GACW,QAAQ,CAepB;AAEY,QAAA,cAAc,GAAG,wBAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Currency } from '../models/currency.schema';
2
+ export declare function convertCurrency(amount: number, sourceCurrencyCode: string, targetCurrencyCode: string, currencies: Currency[]): string;
3
+ export declare function convertCurrencyFromDb(amount: number, sourceCurrencyCode: string, targetCurrencyCode: string, connectionString?: string): Promise<string>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertCurrency = convertCurrency;
4
+ exports.convertCurrencyFromDb = convertCurrencyFromDb;
5
+ const currency_schema_1 = require("../models/currency.schema");
6
+ const mongoose = require("mongoose");
7
+ const CurrencyModel = mongoose.model('Currency', currency_schema_1.CurrencySchema);
8
+ async function getCurrencyModel(connectionString) {
9
+ if (mongoose.connection.readyState === 0) {
10
+ if (connectionString) {
11
+ await mongoose.connect(connectionString);
12
+ }
13
+ else {
14
+ throw new Error('Mongoose is not connected and no connection string was provided.');
15
+ }
16
+ }
17
+ return CurrencyModel;
18
+ }
19
+ function convertCurrency(amount, sourceCurrencyCode, targetCurrencyCode, currencies) {
20
+ if (sourceCurrencyCode === targetCurrencyCode) {
21
+ return `${amount.toFixed(2)} ${targetCurrencyCode}`;
22
+ }
23
+ const sourceCurrency = currencies.find(c => c.currencyCode === sourceCurrencyCode);
24
+ const targetCurrency = currencies.find(c => c.currencyCode === targetCurrencyCode);
25
+ const baseCurrencyCode = sourceCurrency?.baseCurrency || targetCurrency?.baseCurrency || 'USD';
26
+ const sourceRate = sourceCurrencyCode === baseCurrencyCode ? 1 : sourceCurrency?.value;
27
+ const targetRate = targetCurrencyCode === baseCurrencyCode ? 1 : targetCurrency?.value;
28
+ if (sourceRate === undefined) {
29
+ throw new Error(`Rate for source currency ${sourceCurrencyCode} not found`);
30
+ }
31
+ if (targetRate === undefined) {
32
+ throw new Error(`Rate for target currency ${targetCurrencyCode} not found`);
33
+ }
34
+ const amountInBase = amount / sourceRate;
35
+ const convertedAmount = amountInBase * targetRate;
36
+ return `${convertedAmount.toFixed(2)} ${targetCurrencyCode}`;
37
+ }
38
+ async function convertCurrencyFromDb(amount, sourceCurrencyCode, targetCurrencyCode, connectionString) {
39
+ const model = await getCurrencyModel(connectionString);
40
+ const currencies = await model.find({
41
+ currencyCode: { $in: [sourceCurrencyCode, targetCurrencyCode] }
42
+ }).exec();
43
+ return convertCurrency(amount, sourceCurrencyCode, targetCurrencyCode, currencies);
44
+ }
45
+ //# sourceMappingURL=currency.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currency.util.js","sourceRoot":"","sources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AAC,CAAC,CAAC,cAAc,EAAE,KAAK,CAAC;IAEvF,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,4BAA4B,kBAAkB,YAAY,CAAC,CAAC;IAC9E,CAAC;IACD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,4BAA4B,kBAAkB,YAAY,CAAC,CAAC;IAC9E,CAAC;IAOD,MAAM,YAAY,GAAG,MAAM,GAAG,UAAU,CAAC;IACzC,MAAM,eAAe,GAAG,YAAY,GAAG,UAAU,CAAC;IAElD,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,kBAAkB,EAAE,CAAC;AAC/D,CAAC;AAWM,KAAK,UAAU,qBAAqB,CACzC,MAAc,EACd,kBAA0B,EAC1B,kBAA0B,EAC1B,gBAAyB;IAEzB,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC;QAClC,YAAY,EAAE,EAAE,GAAG,EAAE,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,EAAE;KAChE,CAAC,CAAC,IAAI,EAAE,CAAC;IAEV,OAAO,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,UAAU,CAAC,CAAC;AACrF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Country } from "../models/country.schema";
2
+ export declare function getCountryAndConvertCurrency(ip: string, amount: number, sourceCurrencyCode: string, connectionString?: string): Promise<{
3
+ country: Country | null;
4
+ currency: string;
5
+ convertedAmount: string;
6
+ }>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCountryAndConvertCurrency = getCountryAndConvertCurrency;
4
+ const geoip = require("geoip-country");
5
+ const mongoose = require("mongoose");
6
+ const currency_util_1 = require("./currency.util");
7
+ const country_schema_1 = require("../models/country.schema");
8
+ const CountryModel = mongoose.model('Country', country_schema_1.CountrySchema);
9
+ async function getCountryModel(connectionString) {
10
+ if (mongoose.connection.readyState === 0) {
11
+ if (connectionString) {
12
+ await mongoose.connect(connectionString);
13
+ }
14
+ else {
15
+ throw new Error('Mongoose is not connected and no connection string was provided.');
16
+ }
17
+ }
18
+ return CountryModel;
19
+ }
20
+ async function getCountryAndConvertCurrency(ip, amount, sourceCurrencyCode, connectionString) {
21
+ const lookup = geoip.lookup(ip);
22
+ const countryCode = lookup ? lookup.country : 'US';
23
+ const model = await getCountryModel(connectionString);
24
+ const countryInstance = await model.findOne({ code: countryCode }).exec();
25
+ const targetCurrencyCode = countryInstance?.currency || 'USD';
26
+ const convertedAmount = await (0, currency_util_1.convertCurrencyFromDb)(amount, sourceCurrencyCode, targetCurrencyCode, connectionString);
27
+ return {
28
+ country: countryInstance,
29
+ currency: targetCurrencyCode,
30
+ convertedAmount
31
+ };
32
+ }
33
+ //# sourceMappingURL=ip-country.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ip-country.util.js","sourceRoot":"","sources":["../../src/util/ip-country.util.ts"],"names":[],"mappings":";;AAgCA,oEA0BC;AA1DD,uCAAuC;AACvC,qCAAqC;AACrC,mDAAwD;AACxD,6DAAkE;AAElE,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAU,SAAS,EAAE,8BAAa,CAAC,CAAC;AAKvE,KAAK,UAAU,eAAe,CAAC,gBAAyB;IACtD,IAAI,QAAQ,CAAC,UAAU,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;QACzC,IAAI,gBAAgB,EAAE,CAAC;YACrB,MAAM,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAaM,KAAK,UAAU,4BAA4B,CAChD,EAAU,EACV,MAAc,EACd,kBAA0B,EAC1B,gBAAyB;IAGzB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAChC,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IAGjD,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,gBAAgB,CAAC,CAAC;IACtD,MAAM,eAAe,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAI5E,MAAM,kBAAkB,GAAG,eAAe,EAAE,QAAQ,IAAI,KAAK,CAAC;IAG9D,MAAM,eAAe,GAAG,MAAM,IAAA,qCAAqB,EAAC,MAAM,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IAEtH,OAAO;QACL,OAAO,EAAE,eAAe;QACxB,QAAQ,EAAE,kBAAkB;QAC5B,eAAe;KAChB,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "world-med-commons",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,6 +12,7 @@
12
12
  "author": "",
13
13
  "license": "ISC",
14
14
  "devDependencies": {
15
+ "@types/geoip-country": "^5.0.0",
15
16
  "@types/node": "^20.0.0",
16
17
  "typescript": "^5.0.0"
17
18
  },
@@ -20,6 +21,7 @@
20
21
  "@nestjs/swagger": "^11.2.6",
21
22
  "class-transformer": "^0.5.1",
22
23
  "class-validator": "^0.15.1",
24
+ "geoip-country": "^5.0.202603312350",
23
25
  "mongoose": "^9.2.4",
24
26
  "nestjs-firebase": "^11.0.1"
25
27
  }
package/src/index.ts CHANGED
@@ -3,10 +3,15 @@ export * from './models/user.schema';
3
3
  export * from './models/employee.schema';
4
4
  export * from './models/allergy.schema';
5
5
  export * from './dtos/pagination.dto';
6
- export * from './models/allergy.schema';
7
6
  export * from './models/drug.schema';
8
7
  export * from './models/drug-variant.schema';
9
8
  export * from './models/business-inventory.schema';
10
9
  export * from './models/patient.schema';
11
10
  export * from './models/suppliers.schema';
12
11
  export * from './models/apiKey.schema';
12
+ export * from './models/currency.schema';
13
+ export * from './util/currency.util';
14
+ export * from './util/ip-country.util';
15
+ export * from './models/country.schema';
16
+ export * from './models/cart.model';
17
+ export * from './models/orders.schema';
@@ -1,5 +1,6 @@
1
1
  import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2
2
  import { Document, Types } from 'mongoose';
3
+ import {User} from "./user.schema";
3
4
 
4
5
  export enum AllergySeverity {
5
6
  MILD = 'mild',
@@ -23,7 +24,7 @@ export enum AllergyType {
23
24
  @Schema({ timestamps: true })
24
25
  export class Allergy extends Document {
25
26
  @Prop({ type: Types.ObjectId, ref: 'User', required: true, index: true })
26
- user: Types.ObjectId; // The patient this allergy belongs to
27
+ user: User; // The patient this allergy belongs to
27
28
 
28
29
  @Prop({ required: true })
29
30
  substance: string; // e.g. "Penicillin", "Latex", "Peanuts", "Ibuprofen"
@@ -0,0 +1,31 @@
1
+ import mongoose, { Document } from "mongoose";
2
+ import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
3
+
4
+ @Schema({
5
+ timestamps: true
6
+ })
7
+ export class Cart extends Document {
8
+ @Prop({
9
+ type: mongoose.Schema.Types.ObjectId,
10
+ ref: 'User',
11
+ required: true
12
+ })
13
+ userId: string;
14
+
15
+ @Prop([{
16
+ pharmacyId: { type: mongoose.Schema.Types.ObjectId, ref: 'Business', required: true },
17
+ items: [{
18
+ inventoryId: { type: mongoose.Schema.Types.ObjectId, ref: 'PharmacyInventory', required: true },
19
+ quantity: { type: Number, required: true, min: 1 },
20
+ price: { type: Number, required: true }, // Snapshot of price at time of adding
21
+ requiresPrescription: { type: Boolean, default: false },
22
+ }],
23
+ deliveryFee: { type: Number, default: 0 }
24
+ }])
25
+ vendors: any[];
26
+
27
+ @Prop({ default: Date.now, expires: '7d' }) // TTL Index: Carts auto-delete after 7 days of inactivity
28
+ lastModified: Date;
29
+ }
30
+
31
+ export const CartSchema = SchemaFactory.createForClass(Cart);
@@ -0,0 +1,21 @@
1
+ import {Prop, Schema, SchemaFactory} from "@nestjs/mongoose";
2
+ import { Document } from 'mongoose';
3
+
4
+ @Schema()
5
+ export class Country extends Document{
6
+ @Prop({required: true})
7
+ name: string;
8
+
9
+ @Prop({required: true})
10
+ code: string;
11
+
12
+ @Prop({required: true, default: "USD"})
13
+ currency: string;
14
+
15
+ @Prop({default: true})
16
+ enable: boolean;
17
+ }
18
+
19
+ export const CountrySchema = SchemaFactory.createForClass(Country);
20
+
21
+ CountrySchema.index({name: 1, code: 1});
@@ -0,0 +1,17 @@
1
+ import {Document} from "mongoose";
2
+ import {Prop, Schema, SchemaFactory} from "@nestjs/mongoose";
3
+
4
+ @Schema({ timestamps: true })
5
+ export class Currency extends Document {
6
+ @Prop({ required: true })
7
+ currencyCode: string;
8
+
9
+ @Prop({ required: true })
10
+ value: number;
11
+
12
+ @Prop({ required: true })
13
+ baseCurrency: string;
14
+ }
15
+
16
+ export const CurrencySchema = SchemaFactory.createForClass(Currency);
17
+
@@ -0,0 +1,68 @@
1
+ import {Prop, Schema, SchemaFactory} from "@nestjs/mongoose";
2
+ import mongoose, {Document} from "mongoose";
3
+ import {Business} from "./business.schema";
4
+ import {User} from "./user.schema";
5
+
6
+ @Schema({ timestamps: true })
7
+ export class Orders extends Document {
8
+ @Prop({ required: true })
9
+ orderNumber: string;
10
+
11
+ @Prop([{
12
+ pharmacyInventoryId: { type: mongoose.Schema.Types.ObjectId, ref: 'PharmacyInventory' },
13
+ quantity: Number,
14
+ price: Number,
15
+ requiresPrescription: Boolean,
16
+ taxAmount: Number,
17
+ }])
18
+ items: any[];
19
+
20
+ @Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'Business' })
21
+ business?: Business;
22
+
23
+ @Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'User' })
24
+ user?: User;
25
+
26
+ @Prop({ type: Object, required: true})
27
+ shippingAddress: {
28
+ email: string;
29
+ phoneNumber: string;
30
+ country: string;
31
+ street: string;
32
+ city: string;
33
+ coordinates: { lat: number, lng: number };
34
+ };
35
+
36
+ @Prop({
37
+ required: true,
38
+ type: Number
39
+ })
40
+ TransactionFee: number;
41
+
42
+ @Prop({ type: Number })
43
+ deliveryFee: number;
44
+
45
+ @Prop({
46
+ required: true,
47
+ type: Number
48
+ })
49
+ totalAmount: number;
50
+
51
+ @Prop({
52
+ type: mongoose.Schema.Types.ObjectId, ref: 'Orders'
53
+ })
54
+ parentOrder: Orders;
55
+
56
+ @Prop({
57
+ type: String,
58
+ enum: ['Pending', 'Processing', 'Ready', 'Delivered', 'Cancelled', 'Completed'],
59
+ default: 'Pending'
60
+ })
61
+ status: string;
62
+
63
+ @Prop({ type: Array })
64
+ prescriptions: any[];
65
+
66
+ }
67
+
68
+ export const OrdersSchema = SchemaFactory.createForClass(Orders);
@@ -1,6 +1,7 @@
1
1
  import {Prop, Schema, SchemaFactory} from "@nestjs/mongoose";
2
2
  import {HydratedDocument, Types} from "mongoose";
3
3
  import {Address} from "./user.schema";
4
+ import {Business} from "./business.schema";
4
5
 
5
6
  export type SuppliersDocument = HydratedDocument<Supplier>;
6
7
 
@@ -21,7 +22,7 @@ export class Supplier {
21
22
  website?: string;
22
23
 
23
24
  @Prop({ type: Types.ObjectId, ref: 'Business', required: true, index: true})
24
- business: Types.ObjectId;
25
+ business: Business;
25
26
  }
26
27
 
27
28
  export const SupplierSchema = SchemaFactory.createForClass(Supplier);
@@ -0,0 +1,92 @@
1
+ import { Currency, CurrencySchema } from '../models/currency.schema';
2
+ import * as mongoose from 'mongoose';
3
+
4
+ const CurrencyModel = mongoose.model<Currency>('Currency', CurrencySchema);
5
+
6
+ /**
7
+ * Ensures a connection exists and returns the CurrencyModel.
8
+ * If mongoose isn't connected and no connection string is provided,
9
+ * it will throw a descriptive error.
10
+ */
11
+ async function getCurrencyModel(connectionString?: string): Promise<mongoose.Model<Currency>> {
12
+ if (mongoose.connection.readyState === 0) {
13
+ if (connectionString) {
14
+ await mongoose.connect(connectionString);
15
+ } else {
16
+ throw new Error('Mongoose is not connected and no connection string was provided.');
17
+ }
18
+ }
19
+ return CurrencyModel;
20
+ }
21
+
22
+ /**
23
+ * Converts an amount from one currency to another using provided rates.
24
+ * It assumes all rates are relative to the same base currency.
25
+ *
26
+ * @param amount - The amount of money to convert
27
+ * @param sourceCurrencyCode - The currency code of the source amount
28
+ * @param targetCurrencyCode - The currency code to convert to
29
+ * @param currencies - Array of currency rates available (from Currency schema)
30
+ * @returns A string containing the converted amount and the target currency code (e.g. "120.50 EUR")
31
+ */
32
+ export function convertCurrency(
33
+ amount: number,
34
+ sourceCurrencyCode: string,
35
+ targetCurrencyCode: string,
36
+ currencies: Currency[]
37
+ ): string {
38
+ if (sourceCurrencyCode === targetCurrencyCode) {
39
+ return `${amount.toFixed(2)} ${targetCurrencyCode}`;
40
+ }
41
+
42
+ // Find the rates relative to the common base (e.g., USD)
43
+ const sourceCurrency = currencies.find(c => c.currencyCode === sourceCurrencyCode);
44
+ const targetCurrency = currencies.find(c => c.currencyCode === targetCurrencyCode);
45
+
46
+ // Determine base currency for these currencies
47
+ const baseCurrencyCode = sourceCurrency?.baseCurrency || targetCurrency?.baseCurrency || 'USD';
48
+
49
+ // If a currency is the base currency, its rate is 1
50
+ const sourceRate = sourceCurrencyCode === baseCurrencyCode ? 1 : sourceCurrency?.value;
51
+ const targetRate = targetCurrencyCode === baseCurrencyCode ? 1 : targetCurrency?.value;
52
+
53
+ if (sourceRate === undefined) {
54
+ throw new Error(`Rate for source currency ${sourceCurrencyCode} not found`);
55
+ }
56
+ if (targetRate === undefined) {
57
+ throw new Error(`Rate for target currency ${targetCurrencyCode} not found`);
58
+ }
59
+
60
+ // Formula assumes rate = [value] [currencyCode] per 1 [baseCurrencyCode]
61
+ // e.g., 1 USD = 0.92 EUR (value=0.92)
62
+ // Amount in base = amount / sourceRate
63
+ // Amount in target = (amount / sourceRate) * targetRate
64
+
65
+ const amountInBase = amount / sourceRate;
66
+ const convertedAmount = amountInBase * targetRate;
67
+
68
+ return `${convertedAmount.toFixed(2)} ${targetCurrencyCode}`;
69
+ }
70
+
71
+ /**
72
+ * Converts an amount from one currency to another using currency rates from the database.
73
+ *
74
+ * @param amount - The amount of money to convert
75
+ * @param sourceCurrencyCode - The currency code of the source amount
76
+ * @param targetCurrencyCode - The currency code to convert to
77
+ * @param connectionString - (Optional) MongoDB connection string
78
+ * @returns A string containing the converted amount and the target currency code
79
+ */
80
+ export async function convertCurrencyFromDb(
81
+ amount: number,
82
+ sourceCurrencyCode: string,
83
+ targetCurrencyCode: string,
84
+ connectionString?: string,
85
+ ): Promise<string> {
86
+ const model = await getCurrencyModel(connectionString);
87
+ const currencies = await model.find({
88
+ currencyCode: { $in: [sourceCurrencyCode, targetCurrencyCode] }
89
+ }).exec();
90
+
91
+ return convertCurrency(amount, sourceCurrencyCode, targetCurrencyCode, currencies);
92
+ }
@@ -0,0 +1,60 @@
1
+ import * as geoip from 'geoip-country';
2
+ import * as mongoose from 'mongoose';
3
+ import { convertCurrencyFromDb } from './currency.util';
4
+ import { Country, CountrySchema } from "../models/country.schema";
5
+
6
+ const CountryModel = mongoose.model<Country>('Country', CountrySchema);
7
+
8
+ /**
9
+ * Ensures a connection exists and returns the CountryModel.
10
+ */
11
+ async function getCountryModel(connectionString?: string): Promise<mongoose.Model<Country>> {
12
+ if (mongoose.connection.readyState === 0) {
13
+ if (connectionString) {
14
+ await mongoose.connect(connectionString);
15
+ } else {
16
+ throw new Error('Mongoose is not connected and no connection string was provided.');
17
+ }
18
+ }
19
+ return CountryModel;
20
+ }
21
+
22
+ /**
23
+ * Gets country information from an IP address, fetches the country instance from MongoDB,
24
+ * and converts an amount from a source currency to the country's currency.
25
+ *
26
+ * @param ip - The IP address to look up
27
+ * @param amount - The amount to convert
28
+ * @param sourceCurrencyCode - The source currency code (e.g., 'USD')
29
+ * @param connectionString - (Optional) MongoDB connection string
30
+ * @returns An object containing the country, currency, and the converted amount string
31
+ */
32
+
33
+ export async function getCountryAndConvertCurrency(
34
+ ip: string,
35
+ amount: number,
36
+ sourceCurrencyCode: string,
37
+ connectionString?: string
38
+ ): Promise<{ country: Country | null; currency: string; convertedAmount: string }> {
39
+ // Get country code from IP
40
+ const lookup = geoip.lookup(ip);
41
+ const countryCode = lookup ? lookup.country : 'US'; // Default to US if not found
42
+
43
+ // Get country from MongoDB if not provided
44
+ const model = await getCountryModel(connectionString);
45
+ const countryInstance = await model.findOne({ code: countryCode }).exec();
46
+
47
+
48
+ // Get currency from country instance or default to 'USD'
49
+ const targetCurrencyCode = countryInstance?.currency || 'USD';
50
+
51
+ // Convert currency using convertCurrencyFromDb
52
+ const convertedAmount = await convertCurrencyFromDb(amount, sourceCurrencyCode, targetCurrencyCode, connectionString);
53
+
54
+ return {
55
+ country: countryInstance,
56
+ currency: targetCurrencyCode,
57
+ convertedAmount
58
+ };
59
+ }
60
+