@medusajs/customer 0.0.1 → 0.0.2-next-20240319121007
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/dist/joiner-config.d.ts +1 -0
- package/dist/joiner-config.js +1 -0
- package/dist/migrations/Migration20240124154000.d.ts +4 -0
- package/dist/migrations/Migration20240124154000.js +34 -0
- package/dist/models/address.d.ts +6 -1
- package/dist/models/address.js +29 -2
- package/dist/models/customer-group-customer.d.ts +2 -2
- package/dist/models/customer-group-customer.js +4 -4
- package/dist/models/customer-group.d.ts +2 -1
- package/dist/models/customer-group.js +7 -1
- package/dist/models/customer.d.ts +2 -5
- package/dist/models/customer.js +6 -26
- package/dist/services/customer-module.d.ts +38 -25
- package/dist/services/customer-module.js +124 -118
- package/dist/services/index.d.ts +0 -4
- package/dist/services/index.js +1 -9
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js +15 -1
- package/dist/types/services/customer-group-customer.d.ts +5 -0
- package/dist/types/services/customer-group-customer.js +2 -0
- package/dist/types/services/index.d.ts +2 -0
- package/dist/types/services/index.js +18 -0
- package/package.json +6 -6
- package/dist/services/address.d.ts +0 -18
- package/dist/services/address.js +0 -11
- package/dist/services/customer-group-customer.d.ts +0 -21
- package/dist/services/customer-group-customer.js +0 -11
- package/dist/services/customer-group.d.ts +0 -18
- package/dist/services/customer-group.js +0 -11
- package/dist/services/customer.d.ts +0 -17
- package/dist/services/customer.js +0 -11
- /package/dist/types/{address.d.ts → services/address.d.ts} +0 -0
- /package/dist/types/{address.js → services/address.js} +0 -0
package/dist/joiner-config.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ModuleJoinerConfig } from "@medusajs/types";
|
|
|
2
2
|
import { MapToConfig } from "@medusajs/utils";
|
|
3
3
|
export declare const LinkableKeys: {
|
|
4
4
|
customer_id: string;
|
|
5
|
+
customer_group_id: string;
|
|
5
6
|
};
|
|
6
7
|
export declare const entityNameToLinkableKeysMap: MapToConfig;
|
|
7
8
|
export declare const joinerConfig: ModuleJoinerConfig;
|
package/dist/joiner-config.js
CHANGED
|
@@ -5,6 +5,7 @@ const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
|
5
5
|
const _models_1 = require("./models");
|
|
6
6
|
exports.LinkableKeys = {
|
|
7
7
|
customer_id: _models_1.Customer.name,
|
|
8
|
+
customer_group_id: _models_1.CustomerGroup.name,
|
|
8
9
|
};
|
|
9
10
|
const entityLinkableKeysMap = {};
|
|
10
11
|
Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20240124154000 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
class Migration20240124154000 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
// Customer table modifications
|
|
8
|
+
this.addSql('create table if not exists "customer" ("id" text not null, "company_name" text null, "first_name" text null, "last_name" text null, "email" text null, "phone" text null, "has_account" boolean not null default false, "metadata" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, "created_by" text null, constraint "customer_pkey" primary key ("id"));');
|
|
9
|
+
this.addSql('alter table "customer" alter column "email" drop not null;');
|
|
10
|
+
this.addSql('alter table "customer" add column if not exists "company_name" text null;');
|
|
11
|
+
this.addSql('alter table "customer" add column if not exists "created_by" text null;');
|
|
12
|
+
this.addSql('drop index if exists "IDX_8abe81b9aac151ae60bf507ad1";');
|
|
13
|
+
// Customer Address table
|
|
14
|
+
this.addSql('create table if not exists "customer_address" ("id" text not null, "customer_id" text not null, "address_name" text null, "is_default_shipping" boolean not null default false, "is_default_billing" boolean not null default false, "company" text null, "first_name" text null, "last_name" text null, "address_1" text null, "address_2" text null, "city" text null, "country_code" text null, "province" text null, "postal_code" text null, "phone" text null, "metadata" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), constraint "customer_address_pkey" primary key ("id"));');
|
|
15
|
+
this.addSql('create index if not exists "IDX_customer_address_customer_id" on "customer_address" ("customer_id");');
|
|
16
|
+
this.addSql('create unique index "IDX_customer_address_unique_customer_billing" on "customer_address" ("customer_id") where "is_default_billing" = true;');
|
|
17
|
+
this.addSql('create unique index "IDX_customer_address_unique_customer_shipping" on "customer_address" ("customer_id") where "is_default_shipping" = true;');
|
|
18
|
+
// Customer Group table modifications
|
|
19
|
+
this.addSql('create table if not exists "customer_group" ("id" text not null, "name" text null, "metadata" jsonb null, "created_by" text null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "customer_group_pkey" primary key ("id"));');
|
|
20
|
+
this.addSql('alter table "customer_group" add column if not exists "created_by" text null;');
|
|
21
|
+
this.addSql('drop index if exists "IDX_c4c3a5225a7a1f0af782c40abc";');
|
|
22
|
+
this.addSql('create unique index if not exists "IDX_customer_group_name" on "customer_group" ("name") where "deleted_at" is null;');
|
|
23
|
+
// Customer Group Customer table
|
|
24
|
+
this.addSql('create table if not exists "customer_group_customer" ("id" text not null, "customer_id" text not null, "customer_group_id" text not null, "metadata" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "created_by" text null, constraint "customer_group_customer_pkey" primary key ("id"));');
|
|
25
|
+
this.addSql('create index if not exists "IDX_customer_group_customer_group_id" on "customer_group_customer" ("customer_group_id");');
|
|
26
|
+
this.addSql('create index if not exists "IDX_customer_group_customer_customer_id" on "customer_group_customer" ("customer_id");');
|
|
27
|
+
// Foreign key constraints
|
|
28
|
+
this.addSql('alter table "customer" drop constraint if exists "FK_8abe81b9aac151ae60bf507ad15";');
|
|
29
|
+
this.addSql('alter table "customer_address" add constraint "customer_address_customer_id_foreign" foreign key ("customer_id") references "customer" ("id") on update cascade on delete cascade;');
|
|
30
|
+
this.addSql('alter table "customer_group_customer" add constraint "customer_group_customer_customer_group_id_foreign" foreign key ("customer_group_id") references "customer_group" ("id") on delete cascade;');
|
|
31
|
+
this.addSql('alter table "customer_group_customer" add constraint "customer_group_customer_customer_id_foreign" foreign key ("customer_id") references "customer" ("id") on delete cascade;');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.Migration20240124154000 = Migration20240124154000;
|
package/dist/models/address.d.ts
CHANGED
|
@@ -2,11 +2,16 @@ import { DAL } from "@medusajs/types";
|
|
|
2
2
|
import { OptionalProps } from "@mikro-orm/core";
|
|
3
3
|
import Customer from "./customer";
|
|
4
4
|
type OptionalAddressProps = DAL.EntityDateColumns;
|
|
5
|
+
export declare const UNIQUE_CUSTOMER_SHIPPING_ADDRESS = "IDX_customer_address_unique_customer_shipping";
|
|
6
|
+
export declare const UNIQUE_CUSTOMER_BILLING_ADDRESS = "IDX_customer_address_unique_customer_billing";
|
|
5
7
|
export default class Address {
|
|
6
8
|
[OptionalProps]: OptionalAddressProps;
|
|
7
9
|
id: string;
|
|
10
|
+
address_name: string | null;
|
|
11
|
+
is_default_shipping: boolean;
|
|
12
|
+
is_default_billing: boolean;
|
|
8
13
|
customer_id: string;
|
|
9
|
-
customer
|
|
14
|
+
customer: Customer;
|
|
10
15
|
company: string | null;
|
|
11
16
|
first_name: string | null;
|
|
12
17
|
last_name: string | null;
|
package/dist/models/address.js
CHANGED
|
@@ -12,11 +12,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.UNIQUE_CUSTOMER_BILLING_ADDRESS = exports.UNIQUE_CUSTOMER_SHIPPING_ADDRESS = void 0;
|
|
15
16
|
const utils_1 = require("@medusajs/utils");
|
|
16
17
|
const core_1 = require("@mikro-orm/core");
|
|
17
18
|
const customer_1 = __importDefault(require("./customer"));
|
|
19
|
+
exports.UNIQUE_CUSTOMER_SHIPPING_ADDRESS = "IDX_customer_address_unique_customer_shipping";
|
|
20
|
+
exports.UNIQUE_CUSTOMER_BILLING_ADDRESS = "IDX_customer_address_unique_customer_billing";
|
|
18
21
|
let Address = class Address {
|
|
19
22
|
constructor() {
|
|
23
|
+
this.address_name = null;
|
|
24
|
+
this.is_default_shipping = false;
|
|
25
|
+
this.is_default_billing = false;
|
|
20
26
|
this.company = null;
|
|
21
27
|
this.first_name = null;
|
|
22
28
|
this.last_name = null;
|
|
@@ -40,6 +46,18 @@ __decorate([
|
|
|
40
46
|
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
41
47
|
__metadata("design:type", String)
|
|
42
48
|
], Address.prototype, "id", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
51
|
+
__metadata("design:type", Object)
|
|
52
|
+
], Address.prototype, "address_name", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, core_1.Property)({ columnType: "boolean", default: false }),
|
|
55
|
+
__metadata("design:type", Boolean)
|
|
56
|
+
], Address.prototype, "is_default_shipping", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, core_1.Property)({ columnType: "boolean", default: false }),
|
|
59
|
+
__metadata("design:type", Boolean)
|
|
60
|
+
], Address.prototype, "is_default_billing", void 0);
|
|
43
61
|
__decorate([
|
|
44
62
|
(0, core_1.Property)({ columnType: "text" }),
|
|
45
63
|
__metadata("design:type", String)
|
|
@@ -47,7 +65,8 @@ __decorate([
|
|
|
47
65
|
__decorate([
|
|
48
66
|
(0, core_1.ManyToOne)(() => customer_1.default, {
|
|
49
67
|
fieldName: "customer_id",
|
|
50
|
-
|
|
68
|
+
index: "IDX_customer_address_customer_id",
|
|
69
|
+
cascade: [core_1.Cascade.REMOVE, core_1.Cascade.PERSIST],
|
|
51
70
|
}),
|
|
52
71
|
__metadata("design:type", customer_1.default)
|
|
53
72
|
], Address.prototype, "customer", void 0);
|
|
@@ -125,6 +144,14 @@ __decorate([
|
|
|
125
144
|
__metadata("design:returntype", void 0)
|
|
126
145
|
], Address.prototype, "onInit", null);
|
|
127
146
|
Address = __decorate([
|
|
128
|
-
(0, core_1.Entity)({ tableName: "customer_address" })
|
|
147
|
+
(0, core_1.Entity)({ tableName: "customer_address" }),
|
|
148
|
+
(0, core_1.Index)({
|
|
149
|
+
name: exports.UNIQUE_CUSTOMER_SHIPPING_ADDRESS,
|
|
150
|
+
expression: 'create unique index "IDX_customer_address_unique_customer_shipping" on "customer_address" ("customer_id") where "is_default_shipping" = true',
|
|
151
|
+
}),
|
|
152
|
+
(0, core_1.Index)({
|
|
153
|
+
name: exports.UNIQUE_CUSTOMER_BILLING_ADDRESS,
|
|
154
|
+
expression: 'create unique index "IDX_customer_address_unique_customer_billing" on "customer_address" ("customer_id") where "is_default_billing" = true',
|
|
155
|
+
})
|
|
129
156
|
], Address);
|
|
130
157
|
exports.default = Address;
|
|
@@ -8,8 +8,8 @@ export default class CustomerGroupCustomer {
|
|
|
8
8
|
id: string;
|
|
9
9
|
customer_id: string;
|
|
10
10
|
customer_group_id: string;
|
|
11
|
-
customer: Customer
|
|
12
|
-
customer_group: CustomerGroup
|
|
11
|
+
customer: Customer;
|
|
12
|
+
customer_group: CustomerGroup;
|
|
13
13
|
metadata: Record<string, unknown> | null;
|
|
14
14
|
created_at: Date;
|
|
15
15
|
updated_at: Date;
|
|
@@ -45,18 +45,18 @@ __decorate([
|
|
|
45
45
|
entity: () => customer_1.default,
|
|
46
46
|
fieldName: "customer_id",
|
|
47
47
|
index: "IDX_customer_group_customer_customer_id",
|
|
48
|
-
|
|
48
|
+
cascade: [core_1.Cascade.REMOVE],
|
|
49
49
|
}),
|
|
50
|
-
__metadata("design:type",
|
|
50
|
+
__metadata("design:type", customer_1.default)
|
|
51
51
|
], CustomerGroupCustomer.prototype, "customer", void 0);
|
|
52
52
|
__decorate([
|
|
53
53
|
(0, core_1.ManyToOne)({
|
|
54
54
|
entity: () => customer_group_1.default,
|
|
55
55
|
fieldName: "customer_group_id",
|
|
56
56
|
index: "IDX_customer_group_customer_group_id",
|
|
57
|
-
|
|
57
|
+
cascade: [core_1.Cascade.REMOVE],
|
|
58
58
|
}),
|
|
59
|
-
__metadata("design:type",
|
|
59
|
+
__metadata("design:type", customer_group_1.default)
|
|
60
60
|
], CustomerGroupCustomer.prototype, "customer_group", void 0);
|
|
61
61
|
__decorate([
|
|
62
62
|
(0, core_1.Property)({ columnType: "jsonb", nullable: true }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DAL } from "@medusajs/types";
|
|
2
2
|
import { OptionalProps, Collection } from "@mikro-orm/core";
|
|
3
3
|
import Customer from "./customer";
|
|
4
|
-
type OptionalGroupProps = DAL.
|
|
4
|
+
type OptionalGroupProps = DAL.SoftDeletableEntityDateColumns;
|
|
5
5
|
export default class CustomerGroup {
|
|
6
6
|
[OptionalProps]: OptionalGroupProps;
|
|
7
7
|
id: string;
|
|
@@ -11,6 +11,7 @@ export default class CustomerGroup {
|
|
|
11
11
|
created_by: string | null;
|
|
12
12
|
created_at: Date;
|
|
13
13
|
updated_at: Date;
|
|
14
|
+
deleted_at: Date | null;
|
|
14
15
|
onCreate(): void;
|
|
15
16
|
onInit(): void;
|
|
16
17
|
}
|
|
@@ -22,6 +22,7 @@ let CustomerGroup = class CustomerGroup {
|
|
|
22
22
|
this.customers = new core_1.Collection(this);
|
|
23
23
|
this.metadata = null;
|
|
24
24
|
this.created_by = null;
|
|
25
|
+
this.deleted_at = null;
|
|
25
26
|
}
|
|
26
27
|
onCreate() {
|
|
27
28
|
this.id = (0, utils_1.generateEntityId)(this.id, "cusgroup");
|
|
@@ -70,6 +71,10 @@ __decorate([
|
|
|
70
71
|
}),
|
|
71
72
|
__metadata("design:type", Date)
|
|
72
73
|
], CustomerGroup.prototype, "updated_at", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
|
76
|
+
__metadata("design:type", Object)
|
|
77
|
+
], CustomerGroup.prototype, "deleted_at", void 0);
|
|
73
78
|
__decorate([
|
|
74
79
|
(0, core_1.BeforeCreate)(),
|
|
75
80
|
__metadata("design:type", Function),
|
|
@@ -83,6 +88,7 @@ __decorate([
|
|
|
83
88
|
__metadata("design:returntype", void 0)
|
|
84
89
|
], CustomerGroup.prototype, "onInit", null);
|
|
85
90
|
CustomerGroup = __decorate([
|
|
86
|
-
(0, core_1.Entity)({ tableName: "customer_group" })
|
|
91
|
+
(0, core_1.Entity)({ tableName: "customer_group" }),
|
|
92
|
+
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
87
93
|
], CustomerGroup);
|
|
88
94
|
exports.default = CustomerGroup;
|
|
@@ -2,7 +2,7 @@ import { DAL } from "@medusajs/types";
|
|
|
2
2
|
import { Collection, OptionalProps } from "@mikro-orm/core";
|
|
3
3
|
import CustomerGroup from "./customer-group";
|
|
4
4
|
import Address from "./address";
|
|
5
|
-
type OptionalCustomerProps = "groups" | "addresses" |
|
|
5
|
+
type OptionalCustomerProps = "groups" | "addresses" | DAL.SoftDeletableEntityDateColumns;
|
|
6
6
|
export default class Customer {
|
|
7
7
|
[OptionalProps]?: OptionalCustomerProps;
|
|
8
8
|
id: string;
|
|
@@ -11,10 +11,7 @@ export default class Customer {
|
|
|
11
11
|
last_name: string | null;
|
|
12
12
|
email: string | null;
|
|
13
13
|
phone: string | null;
|
|
14
|
-
|
|
15
|
-
default_shipping_address: Address | null;
|
|
16
|
-
default_billing_address_id: string | null;
|
|
17
|
-
default_billing_address: Address | null;
|
|
14
|
+
has_account: boolean;
|
|
18
15
|
metadata: Record<string, unknown> | null;
|
|
19
16
|
groups: Collection<CustomerGroup, object>;
|
|
20
17
|
addresses: Collection<Address, object>;
|
package/dist/models/customer.js
CHANGED
|
@@ -24,8 +24,7 @@ let Customer = class Customer {
|
|
|
24
24
|
this.last_name = null;
|
|
25
25
|
this.email = null;
|
|
26
26
|
this.phone = null;
|
|
27
|
-
this.
|
|
28
|
-
this.default_billing_address_id = null;
|
|
27
|
+
this.has_account = false;
|
|
29
28
|
this.metadata = null;
|
|
30
29
|
this.groups = new core_1.Collection(this);
|
|
31
30
|
this.addresses = new core_1.Collection(this);
|
|
@@ -64,29 +63,9 @@ __decorate([
|
|
|
64
63
|
__metadata("design:type", Object)
|
|
65
64
|
], Customer.prototype, "phone", void 0);
|
|
66
65
|
__decorate([
|
|
67
|
-
(0, core_1.
|
|
68
|
-
(
|
|
69
|
-
|
|
70
|
-
], Customer.prototype, "default_shipping_address_id", void 0);
|
|
71
|
-
__decorate([
|
|
72
|
-
(0, core_1.ManyToOne)(() => address_1.default, {
|
|
73
|
-
fieldName: "default_shipping_address_id",
|
|
74
|
-
nullable: true,
|
|
75
|
-
}),
|
|
76
|
-
__metadata("design:type", Object)
|
|
77
|
-
], Customer.prototype, "default_shipping_address", void 0);
|
|
78
|
-
__decorate([
|
|
79
|
-
(0, core_1.Index)({ name: "IDX_customer_default_billing_address_id" }),
|
|
80
|
-
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
81
|
-
__metadata("design:type", Object)
|
|
82
|
-
], Customer.prototype, "default_billing_address_id", void 0);
|
|
83
|
-
__decorate([
|
|
84
|
-
(0, core_1.ManyToOne)(() => address_1.default, {
|
|
85
|
-
fieldName: "default_billing_address_id",
|
|
86
|
-
nullable: true,
|
|
87
|
-
}),
|
|
88
|
-
__metadata("design:type", Object)
|
|
89
|
-
], Customer.prototype, "default_billing_address", void 0);
|
|
66
|
+
(0, core_1.Property)({ columnType: "boolean", default: false }),
|
|
67
|
+
__metadata("design:type", Boolean)
|
|
68
|
+
], Customer.prototype, "has_account", void 0);
|
|
90
69
|
__decorate([
|
|
91
70
|
(0, core_1.Property)({ columnType: "jsonb", nullable: true }),
|
|
92
71
|
__metadata("design:type", Object)
|
|
@@ -143,6 +122,7 @@ __decorate([
|
|
|
143
122
|
__metadata("design:returntype", void 0)
|
|
144
123
|
], Customer.prototype, "onInit", null);
|
|
145
124
|
Customer = __decorate([
|
|
146
|
-
(0, core_1.Entity)({ tableName: "customer" })
|
|
125
|
+
(0, core_1.Entity)({ tableName: "customer" }),
|
|
126
|
+
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
147
127
|
], Customer);
|
|
148
128
|
exports.default = Customer;
|
|
@@ -1,46 +1,59 @@
|
|
|
1
|
-
import { Context,
|
|
2
|
-
import
|
|
1
|
+
import { Context, CustomerDTO, CustomerTypes, DAL, ICustomerModuleService, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes } from "@medusajs/types";
|
|
2
|
+
import { ModulesSdkUtils } from "@medusajs/utils";
|
|
3
|
+
import { Address, Customer, CustomerGroup, CustomerGroupCustomer } from "../models";
|
|
3
4
|
type InjectedDependencies = {
|
|
4
5
|
baseRepository: DAL.RepositoryService;
|
|
5
|
-
customerService:
|
|
6
|
-
addressService:
|
|
7
|
-
customerGroupService:
|
|
8
|
-
customerGroupCustomerService:
|
|
6
|
+
customerService: ModulesSdkTypes.InternalModuleService<any>;
|
|
7
|
+
addressService: ModulesSdkTypes.InternalModuleService<any>;
|
|
8
|
+
customerGroupService: ModulesSdkTypes.InternalModuleService<any>;
|
|
9
|
+
customerGroupCustomerService: ModulesSdkTypes.InternalModuleService<any>;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
+
declare const CustomerModuleService_base: new (container: InjectedDependencies) => ModulesSdkUtils.AbstractModuleService<InjectedDependencies, CustomerDTO, {
|
|
12
|
+
Address: {
|
|
13
|
+
dto: any;
|
|
14
|
+
};
|
|
15
|
+
CustomerGroup: {
|
|
16
|
+
dto: any;
|
|
17
|
+
};
|
|
18
|
+
CustomerGroupCustomer: {
|
|
19
|
+
dto: any;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
export default class CustomerModuleService<TAddress extends Address = Address, TCustomer extends Customer = Customer, TCustomerGroup extends CustomerGroup = CustomerGroup, TCustomerGroupCustomer extends CustomerGroupCustomer = CustomerGroupCustomer> extends CustomerModuleService_base implements ICustomerModuleService {
|
|
11
23
|
protected readonly moduleDeclaration: InternalModuleDeclaration;
|
|
12
24
|
protected baseRepository_: DAL.RepositoryService;
|
|
13
|
-
protected customerService_:
|
|
14
|
-
protected addressService_:
|
|
15
|
-
protected customerGroupService_:
|
|
16
|
-
protected customerGroupCustomerService_:
|
|
25
|
+
protected customerService_: ModulesSdkTypes.InternalModuleService<TCustomer>;
|
|
26
|
+
protected addressService_: ModulesSdkTypes.InternalModuleService<TAddress>;
|
|
27
|
+
protected customerGroupService_: ModulesSdkTypes.InternalModuleService<TCustomerGroup>;
|
|
28
|
+
protected customerGroupCustomerService_: ModulesSdkTypes.InternalModuleService<TCustomerGroupCustomer>;
|
|
17
29
|
constructor({ baseRepository, customerService, addressService, customerGroupService, customerGroupCustomerService, }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
|
|
18
30
|
__joinerConfig(): ModuleJoinerConfig;
|
|
19
|
-
retrieve(id: string, config?: FindConfig<CustomerTypes.CustomerDTO>, sharedContext?: Context): Promise<CustomerTypes.CustomerDTO>;
|
|
20
31
|
create(data: CustomerTypes.CreateCustomerDTO, sharedContext?: Context): Promise<CustomerTypes.CustomerDTO>;
|
|
21
32
|
create(data: CustomerTypes.CreateCustomerDTO[], sharedContext?: Context): Promise<CustomerTypes.CustomerDTO[]>;
|
|
22
|
-
|
|
23
|
-
update(
|
|
24
|
-
update(
|
|
25
|
-
|
|
26
|
-
delete(customerIds: string[], sharedContext?: Context): Promise<void>;
|
|
27
|
-
delete(selector: CustomerTypes.FilterableCustomerProps, sharedContext?: Context): Promise<void>;
|
|
28
|
-
list(filters?: CustomerTypes.FilterableCustomerProps, config?: FindConfig<CustomerTypes.CustomerDTO>, sharedContext?: Context): Promise<CustomerTypes.CustomerDTO[]>;
|
|
29
|
-
listAndCount(filters?: CustomerTypes.FilterableCustomerProps, config?: FindConfig<CustomerTypes.CustomerDTO>, sharedContext?: Context): Promise<[CustomerTypes.CustomerDTO[], number]>;
|
|
33
|
+
create_(dataOrArray: CustomerTypes.CreateCustomerDTO | CustomerTypes.CreateCustomerDTO[], sharedContext?: Context): Promise<CustomerTypes.CustomerDTO[]>;
|
|
34
|
+
update(customerId: string, data: CustomerTypes.CustomerUpdatableFields, sharedContext?: Context): Promise<CustomerTypes.CustomerDTO>;
|
|
35
|
+
update(customerIds: string[], data: CustomerTypes.CustomerUpdatableFields, sharedContext?: Context): Promise<CustomerTypes.CustomerDTO[]>;
|
|
36
|
+
update(selector: CustomerTypes.FilterableCustomerProps, data: CustomerTypes.CustomerUpdatableFields, sharedContext?: Context): Promise<CustomerTypes.CustomerDTO[]>;
|
|
30
37
|
createCustomerGroup(dataOrArrayOfData: CustomerTypes.CreateCustomerGroupDTO, sharedContext?: Context): Promise<CustomerTypes.CustomerGroupDTO>;
|
|
31
38
|
createCustomerGroup(dataOrArrayOfData: CustomerTypes.CreateCustomerGroupDTO[], sharedContext?: Context): Promise<CustomerTypes.CustomerGroupDTO[]>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
updateCustomerGroups(groupId: string, data: CustomerTypes.CustomerGroupUpdatableFields, sharedContext?: Context): Promise<CustomerTypes.CustomerGroupDTO>;
|
|
40
|
+
updateCustomerGroups(groupIds: string[], data: CustomerTypes.CustomerGroupUpdatableFields, sharedContext?: Context): Promise<CustomerTypes.CustomerGroupDTO[]>;
|
|
41
|
+
updateCustomerGroups(selector: CustomerTypes.FilterableCustomerGroupProps, data: CustomerTypes.CustomerGroupUpdatableFields, sharedContext?: Context): Promise<CustomerTypes.CustomerGroupDTO[]>;
|
|
35
42
|
addCustomerToGroup(groupCustomerPair: CustomerTypes.GroupCustomerPair, sharedContext?: Context): Promise<{
|
|
36
43
|
id: string;
|
|
37
44
|
}>;
|
|
38
45
|
addCustomerToGroup(groupCustomerPairs: CustomerTypes.GroupCustomerPair[], sharedContext?: Context): Promise<{
|
|
39
46
|
id: string;
|
|
40
47
|
}[]>;
|
|
48
|
+
addAddresses(addresses: CustomerTypes.CreateCustomerAddressDTO[], sharedContext?: Context): Promise<CustomerTypes.CustomerAddressDTO[]>;
|
|
49
|
+
addAddresses(address: CustomerTypes.CreateCustomerAddressDTO, sharedContext?: Context): Promise<CustomerTypes.CustomerAddressDTO>;
|
|
50
|
+
private addAddresses_;
|
|
51
|
+
updateAddresses(addressId: string, data: CustomerTypes.UpdateCustomerAddressDTO, sharedContext?: Context): Promise<CustomerTypes.CustomerAddressDTO>;
|
|
52
|
+
updateAddresses(addressIds: string[], data: CustomerTypes.UpdateCustomerAddressDTO, sharedContext?: Context): Promise<CustomerTypes.CustomerAddressDTO[]>;
|
|
53
|
+
updateAddresses(selector: CustomerTypes.FilterableCustomerAddressProps, data: CustomerTypes.UpdateCustomerAddressDTO, sharedContext?: Context): Promise<CustomerTypes.CustomerAddressDTO[]>;
|
|
41
54
|
removeCustomerFromGroup(groupCustomerPair: CustomerTypes.GroupCustomerPair, sharedContext?: Context): Promise<void>;
|
|
42
55
|
removeCustomerFromGroup(groupCustomerPairs: CustomerTypes.GroupCustomerPair[], sharedContext?: Context): Promise<void>;
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
private flush;
|
|
57
|
+
private handleDbErrors;
|
|
45
58
|
}
|
|
46
59
|
export {};
|
|
@@ -15,8 +15,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const types_1 = require("@medusajs/types");
|
|
16
16
|
const utils_1 = require("@medusajs/utils");
|
|
17
17
|
const joiner_config_1 = require("../joiner-config");
|
|
18
|
-
|
|
18
|
+
const _models_1 = require("../models");
|
|
19
|
+
const address_1 = require("../models/address");
|
|
20
|
+
const generateMethodForModels = [_models_1.Address, _models_1.CustomerGroup, _models_1.CustomerGroupCustomer];
|
|
21
|
+
class CustomerModuleService
|
|
22
|
+
// TODO seb I let you manage that when you are moving forward
|
|
23
|
+
extends utils_1.ModulesSdkUtils.abstractModuleServiceFactory(_models_1.Customer, generateMethodForModels, joiner_config_1.entityNameToLinkableKeysMap) {
|
|
19
24
|
constructor({ baseRepository, customerService, addressService, customerGroupService, customerGroupCustomerService, }, moduleDeclaration) {
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
super(...arguments);
|
|
20
27
|
this.moduleDeclaration = moduleDeclaration;
|
|
21
28
|
this.baseRepository_ = baseRepository;
|
|
22
29
|
this.customerService_ = customerService;
|
|
@@ -27,29 +34,37 @@ class CustomerModuleService {
|
|
|
27
34
|
__joinerConfig() {
|
|
28
35
|
return joiner_config_1.joinerConfig;
|
|
29
36
|
}
|
|
30
|
-
async retrieve(id, config = {}, sharedContext = {}) {
|
|
31
|
-
const customer = await this.customerService_.retrieve(id, config, sharedContext);
|
|
32
|
-
return await this.baseRepository_.serialize(customer, {
|
|
33
|
-
populate: true,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
37
|
async create(dataOrArray, sharedContext = {}) {
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const serialized = await this.baseRepository_.serialize(customer, {
|
|
38
|
+
const customers = await this.create_(dataOrArray, sharedContext).catch(this.handleDbErrors);
|
|
39
|
+
const serialized = await this.baseRepository_.serialize(customers, {
|
|
40
40
|
populate: true,
|
|
41
41
|
});
|
|
42
42
|
return Array.isArray(dataOrArray) ? serialized : serialized[0];
|
|
43
43
|
}
|
|
44
|
+
async create_(dataOrArray, sharedContext = {}) {
|
|
45
|
+
const data = Array.isArray(dataOrArray) ? dataOrArray : [dataOrArray];
|
|
46
|
+
const customers = await this.customerService_.create(data, sharedContext);
|
|
47
|
+
const addressDataWithCustomerIds = data
|
|
48
|
+
.map(({ addresses }, i) => {
|
|
49
|
+
if (!addresses) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
return addresses.map((address) => ({
|
|
53
|
+
...address,
|
|
54
|
+
customer_id: customers[i].id,
|
|
55
|
+
}));
|
|
56
|
+
})
|
|
57
|
+
.flat();
|
|
58
|
+
await this.addAddresses(addressDataWithCustomerIds, sharedContext);
|
|
59
|
+
return customers;
|
|
60
|
+
}
|
|
44
61
|
async update(idsOrSelector, data, sharedContext = {}) {
|
|
45
|
-
let updateData
|
|
62
|
+
let updateData;
|
|
46
63
|
if ((0, utils_1.isString)(idsOrSelector)) {
|
|
47
|
-
updateData =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
];
|
|
64
|
+
updateData = {
|
|
65
|
+
id: idsOrSelector,
|
|
66
|
+
...data,
|
|
67
|
+
};
|
|
53
68
|
}
|
|
54
69
|
else if (Array.isArray(idsOrSelector)) {
|
|
55
70
|
updateData = idsOrSelector.map((id) => ({
|
|
@@ -58,11 +73,10 @@ class CustomerModuleService {
|
|
|
58
73
|
}));
|
|
59
74
|
}
|
|
60
75
|
else {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}));
|
|
76
|
+
updateData = {
|
|
77
|
+
selector: idsOrSelector,
|
|
78
|
+
data: data,
|
|
79
|
+
};
|
|
66
80
|
}
|
|
67
81
|
const customers = await this.customerService_.update(updateData, sharedContext);
|
|
68
82
|
const serialized = await this.baseRepository_.serialize(customers, {
|
|
@@ -70,65 +84,28 @@ class CustomerModuleService {
|
|
|
70
84
|
});
|
|
71
85
|
return (0, utils_1.isString)(idsOrSelector) ? serialized[0] : serialized;
|
|
72
86
|
}
|
|
73
|
-
async delete(idsOrSelector, sharedContext = {}) {
|
|
74
|
-
let toDelete = Array.isArray(idsOrSelector)
|
|
75
|
-
? idsOrSelector
|
|
76
|
-
: [idsOrSelector];
|
|
77
|
-
if ((0, utils_1.isObject)(idsOrSelector)) {
|
|
78
|
-
const ids = await this.customerService_.list(idsOrSelector, {
|
|
79
|
-
select: ["id"],
|
|
80
|
-
}, sharedContext);
|
|
81
|
-
toDelete = ids.map(({ id }) => id);
|
|
82
|
-
}
|
|
83
|
-
return await this.customerService_.delete(toDelete, sharedContext);
|
|
84
|
-
}
|
|
85
|
-
async list(filters = {}, config = {}, sharedContext = {}) {
|
|
86
|
-
const customers = await this.customerService_.list(filters, config, sharedContext);
|
|
87
|
-
return await this.baseRepository_.serialize(customers, {
|
|
88
|
-
populate: true,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
async listAndCount(filters = {}, config = {}, sharedContext = {}) {
|
|
92
|
-
const [customers, count] = await this.customerService_.listAndCount(filters, config, sharedContext);
|
|
93
|
-
return [
|
|
94
|
-
await this.baseRepository_.serialize(customers, {
|
|
95
|
-
populate: true,
|
|
96
|
-
}),
|
|
97
|
-
count,
|
|
98
|
-
];
|
|
99
|
-
}
|
|
100
87
|
async createCustomerGroup(dataOrArrayOfData, sharedContext = {}) {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
: [dataOrArrayOfData];
|
|
104
|
-
const groups = await this.customerGroupService_.create(data, sharedContext);
|
|
105
|
-
const serialized = await this.baseRepository_.serialize(groups, {
|
|
88
|
+
const groups = await this.customerGroupService_.create(dataOrArrayOfData, sharedContext);
|
|
89
|
+
return await this.baseRepository_.serialize(groups, {
|
|
106
90
|
populate: true,
|
|
107
91
|
});
|
|
108
|
-
return Array.isArray(dataOrArrayOfData) ? serialized : serialized[0];
|
|
109
92
|
}
|
|
110
|
-
async
|
|
111
|
-
let updateData
|
|
112
|
-
if ((0, utils_1.isString)(groupIdOrSelector)) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
},
|
|
118
|
-
];
|
|
119
|
-
}
|
|
120
|
-
else if (Array.isArray(groupIdOrSelector)) {
|
|
121
|
-
updateData = groupIdOrSelector.map((id) => ({
|
|
93
|
+
async updateCustomerGroups(groupIdOrSelector, data, sharedContext = {}) {
|
|
94
|
+
let updateData;
|
|
95
|
+
if ((0, utils_1.isString)(groupIdOrSelector) || Array.isArray(groupIdOrSelector)) {
|
|
96
|
+
const groupIdOrSelectorArray = Array.isArray(groupIdOrSelector)
|
|
97
|
+
? groupIdOrSelector
|
|
98
|
+
: [groupIdOrSelector];
|
|
99
|
+
updateData = groupIdOrSelectorArray.map((id) => ({
|
|
122
100
|
id,
|
|
123
101
|
...data,
|
|
124
102
|
}));
|
|
125
103
|
}
|
|
126
104
|
else {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}));
|
|
105
|
+
updateData = {
|
|
106
|
+
selector: groupIdOrSelector,
|
|
107
|
+
data: data,
|
|
108
|
+
};
|
|
132
109
|
}
|
|
133
110
|
const groups = await this.customerGroupService_.update(updateData, sharedContext);
|
|
134
111
|
if ((0, utils_1.isString)(groupIdOrSelector)) {
|
|
@@ -137,11 +114,52 @@ class CustomerModuleService {
|
|
|
137
114
|
return await this.baseRepository_.serialize(groups, { populate: true });
|
|
138
115
|
}
|
|
139
116
|
async addCustomerToGroup(data, sharedContext = {}) {
|
|
140
|
-
const groupCustomers = await this.customerGroupCustomerService_.create(
|
|
117
|
+
const groupCustomers = await this.customerGroupCustomerService_.create(data, sharedContext);
|
|
141
118
|
if (Array.isArray(data)) {
|
|
142
119
|
return groupCustomers.map((gc) => ({ id: gc.id }));
|
|
143
120
|
}
|
|
144
|
-
return { id: groupCustomers
|
|
121
|
+
return { id: groupCustomers.id };
|
|
122
|
+
}
|
|
123
|
+
async addAddresses(data, sharedContext = {}) {
|
|
124
|
+
const addresses = await this.addAddresses_(data, sharedContext).catch(this.handleDbErrors);
|
|
125
|
+
const serialized = await this.baseRepository_.serialize(addresses, { populate: true });
|
|
126
|
+
if (Array.isArray(data)) {
|
|
127
|
+
return serialized;
|
|
128
|
+
}
|
|
129
|
+
return serialized[0];
|
|
130
|
+
}
|
|
131
|
+
async addAddresses_(data, sharedContext = {}) {
|
|
132
|
+
return await this.addressService_.create(Array.isArray(data) ? data : [data], sharedContext);
|
|
133
|
+
}
|
|
134
|
+
async updateAddresses(addressIdOrSelector, data, sharedContext = {}) {
|
|
135
|
+
let updateData;
|
|
136
|
+
if ((0, utils_1.isString)(addressIdOrSelector)) {
|
|
137
|
+
updateData = [
|
|
138
|
+
{
|
|
139
|
+
id: addressIdOrSelector,
|
|
140
|
+
...data,
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
else if (Array.isArray(addressIdOrSelector)) {
|
|
145
|
+
updateData = addressIdOrSelector.map((id) => ({
|
|
146
|
+
id,
|
|
147
|
+
...data,
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
updateData = {
|
|
152
|
+
selector: addressIdOrSelector,
|
|
153
|
+
data,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const addresses = await this.addressService_.update(updateData, sharedContext);
|
|
157
|
+
await this.flush(sharedContext).catch(this.handleDbErrors);
|
|
158
|
+
const serialized = await this.baseRepository_.serialize(addresses, { populate: true });
|
|
159
|
+
if ((0, utils_1.isString)(addressIdOrSelector)) {
|
|
160
|
+
return serialized[0];
|
|
161
|
+
}
|
|
162
|
+
return serialized;
|
|
145
163
|
}
|
|
146
164
|
async removeCustomerFromGroup(data, sharedContext = {}) {
|
|
147
165
|
const pairs = Array.isArray(data) ? data : [data];
|
|
@@ -150,37 +168,39 @@ class CustomerModuleService {
|
|
|
150
168
|
});
|
|
151
169
|
await this.customerGroupCustomerService_.delete(groupCustomers.map((gc) => gc.id), sharedContext);
|
|
152
170
|
}
|
|
153
|
-
async
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
populate: true,
|
|
157
|
-
});
|
|
171
|
+
async flush(context) {
|
|
172
|
+
const em = (context.manager ?? context.transactionManager);
|
|
173
|
+
await em.flush();
|
|
158
174
|
}
|
|
159
|
-
async
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
175
|
+
async handleDbErrors(err) {
|
|
176
|
+
if ((0, utils_1.isDuplicateError)(err)) {
|
|
177
|
+
switch (err.constraint) {
|
|
178
|
+
case address_1.UNIQUE_CUSTOMER_SHIPPING_ADDRESS:
|
|
179
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.DUPLICATE_ERROR, "A default shipping address already exists");
|
|
180
|
+
case address_1.UNIQUE_CUSTOMER_BILLING_ADDRESS:
|
|
181
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.DUPLICATE_ERROR, "A default billing address already exists");
|
|
182
|
+
default:
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
throw err;
|
|
167
187
|
}
|
|
168
188
|
}
|
|
169
189
|
exports.default = CustomerModuleService;
|
|
170
190
|
__decorate([
|
|
171
191
|
(0, utils_1.InjectManager)("baseRepository_"),
|
|
172
|
-
__param(
|
|
192
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
173
193
|
__metadata("design:type", Function),
|
|
174
|
-
__metadata("design:paramtypes", [
|
|
194
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
175
195
|
__metadata("design:returntype", Promise)
|
|
176
|
-
], CustomerModuleService.prototype, "
|
|
196
|
+
], CustomerModuleService.prototype, "create", null);
|
|
177
197
|
__decorate([
|
|
178
198
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
179
199
|
__param(1, (0, utils_1.MedusaContext)()),
|
|
180
200
|
__metadata("design:type", Function),
|
|
181
201
|
__metadata("design:paramtypes", [Object, Object]),
|
|
182
202
|
__metadata("design:returntype", Promise)
|
|
183
|
-
], CustomerModuleService.prototype, "
|
|
203
|
+
], CustomerModuleService.prototype, "create_", null);
|
|
184
204
|
__decorate([
|
|
185
205
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
186
206
|
__param(2, (0, utils_1.MedusaContext)()),
|
|
@@ -194,60 +214,46 @@ __decorate([
|
|
|
194
214
|
__metadata("design:type", Function),
|
|
195
215
|
__metadata("design:paramtypes", [Object, Object]),
|
|
196
216
|
__metadata("design:returntype", Promise)
|
|
197
|
-
], CustomerModuleService.prototype, "
|
|
198
|
-
__decorate([
|
|
199
|
-
(0, utils_1.InjectManager)("baseRepository_"),
|
|
200
|
-
__param(2, (0, utils_1.MedusaContext)()),
|
|
201
|
-
__metadata("design:type", Function),
|
|
202
|
-
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
203
|
-
__metadata("design:returntype", Promise)
|
|
204
|
-
], CustomerModuleService.prototype, "list", null);
|
|
217
|
+
], CustomerModuleService.prototype, "createCustomerGroup", null);
|
|
205
218
|
__decorate([
|
|
206
|
-
(0, utils_1.
|
|
219
|
+
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
207
220
|
__param(2, (0, utils_1.MedusaContext)()),
|
|
208
221
|
__metadata("design:type", Function),
|
|
209
222
|
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
210
223
|
__metadata("design:returntype", Promise)
|
|
211
|
-
], CustomerModuleService.prototype, "
|
|
224
|
+
], CustomerModuleService.prototype, "updateCustomerGroups", null);
|
|
212
225
|
__decorate([
|
|
213
226
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
214
227
|
__param(1, (0, utils_1.MedusaContext)()),
|
|
215
228
|
__metadata("design:type", Function),
|
|
216
229
|
__metadata("design:paramtypes", [Object, Object]),
|
|
217
230
|
__metadata("design:returntype", Promise)
|
|
218
|
-
], CustomerModuleService.prototype, "
|
|
219
|
-
__decorate([
|
|
220
|
-
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
221
|
-
__param(2, (0, utils_1.MedusaContext)()),
|
|
222
|
-
__metadata("design:type", Function),
|
|
223
|
-
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
224
|
-
__metadata("design:returntype", Promise)
|
|
225
|
-
], CustomerModuleService.prototype, "updateCustomerGroup", null);
|
|
231
|
+
], CustomerModuleService.prototype, "addCustomerToGroup", null);
|
|
226
232
|
__decorate([
|
|
227
|
-
(0, utils_1.
|
|
233
|
+
(0, utils_1.InjectManager)("baseRepository_"),
|
|
228
234
|
__param(1, (0, utils_1.MedusaContext)()),
|
|
229
235
|
__metadata("design:type", Function),
|
|
230
236
|
__metadata("design:paramtypes", [Object, Object]),
|
|
231
237
|
__metadata("design:returntype", Promise)
|
|
232
|
-
], CustomerModuleService.prototype, "
|
|
238
|
+
], CustomerModuleService.prototype, "addAddresses", null);
|
|
233
239
|
__decorate([
|
|
234
240
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
235
241
|
__param(1, (0, utils_1.MedusaContext)()),
|
|
236
242
|
__metadata("design:type", Function),
|
|
237
243
|
__metadata("design:paramtypes", [Object, Object]),
|
|
238
244
|
__metadata("design:returntype", Promise)
|
|
239
|
-
], CustomerModuleService.prototype, "
|
|
245
|
+
], CustomerModuleService.prototype, "addAddresses_", null);
|
|
240
246
|
__decorate([
|
|
241
|
-
(0, utils_1.
|
|
247
|
+
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
242
248
|
__param(2, (0, utils_1.MedusaContext)()),
|
|
243
249
|
__metadata("design:type", Function),
|
|
244
250
|
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
245
251
|
__metadata("design:returntype", Promise)
|
|
246
|
-
], CustomerModuleService.prototype, "
|
|
252
|
+
], CustomerModuleService.prototype, "updateAddresses", null);
|
|
247
253
|
__decorate([
|
|
248
|
-
(0, utils_1.
|
|
249
|
-
__param(
|
|
254
|
+
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
255
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
250
256
|
__metadata("design:type", Function),
|
|
251
|
-
__metadata("design:paramtypes", [Object, Object
|
|
257
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
252
258
|
__metadata("design:returntype", Promise)
|
|
253
|
-
], CustomerModuleService.prototype, "
|
|
259
|
+
], CustomerModuleService.prototype, "removeCustomerFromGroup", null);
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
export { default as AddressService } from "./address";
|
|
2
|
-
export { default as CustomerGroupService } from "./customer-group";
|
|
3
|
-
export { default as CustomerService } from "./customer";
|
|
4
1
|
export { default as CustomerModuleService } from "./customer-module";
|
|
5
|
-
export { default as CustomerGroupCustomerService } from "./customer-group-customer";
|
package/dist/services/index.js
CHANGED
|
@@ -3,14 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
var address_1 = require("./address");
|
|
8
|
-
Object.defineProperty(exports, "AddressService", { enumerable: true, get: function () { return __importDefault(address_1).default; } });
|
|
9
|
-
var customer_group_1 = require("./customer-group");
|
|
10
|
-
Object.defineProperty(exports, "CustomerGroupService", { enumerable: true, get: function () { return __importDefault(customer_group_1).default; } });
|
|
11
|
-
var customer_1 = require("./customer");
|
|
12
|
-
Object.defineProperty(exports, "CustomerService", { enumerable: true, get: function () { return __importDefault(customer_1).default; } });
|
|
6
|
+
exports.CustomerModuleService = void 0;
|
|
13
7
|
var customer_module_1 = require("./customer-module");
|
|
14
8
|
Object.defineProperty(exports, "CustomerModuleService", { enumerable: true, get: function () { return __importDefault(customer_module_1).default; } });
|
|
15
|
-
var customer_group_customer_1 = require("./customer-group-customer");
|
|
16
|
-
Object.defineProperty(exports, "CustomerGroupCustomerService", { enumerable: true, get: function () { return __importDefault(customer_group_customer_1).default; } });
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -10,8 +10,22 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
13
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
27
|
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
29
|
+
exports.ServiceTypes = void 0;
|
|
30
|
+
exports.ServiceTypes = __importStar(require("./services"));
|
|
31
|
+
__exportStar(require("./services"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./address"), exports);
|
|
18
|
+
__exportStar(require("./customer-group-customer"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/customer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-next-20240319121007",
|
|
4
4
|
"description": "Medusa Customer module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"prepublishOnly": "cross-env NODE_ENV=production tsc --build && tsc-alias -p tsconfig.json",
|
|
30
30
|
"build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json",
|
|
31
31
|
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
|
32
|
-
"test:integration": "jest --
|
|
32
|
+
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
|
33
33
|
"migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate",
|
|
34
34
|
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create --initial",
|
|
35
35
|
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@mikro-orm/cli": "5.9.7",
|
|
42
42
|
"cross-env": "^5.2.1",
|
|
43
43
|
"jest": "^29.6.3",
|
|
44
|
-
"medusa-test-utils": "
|
|
44
|
+
"medusa-test-utils": "1.1.42-next-20240319121007",
|
|
45
45
|
"rimraf": "^3.0.2",
|
|
46
46
|
"ts-jest": "^29.1.1",
|
|
47
47
|
"ts-node": "^10.9.1",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"typescript": "^5.1.6"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@medusajs/modules-sdk": "1.12.
|
|
53
|
-
"@medusajs/utils": "1.11.
|
|
52
|
+
"@medusajs/modules-sdk": "1.12.9-next-20240319121007",
|
|
53
|
+
"@medusajs/utils": "1.11.7-next-20240319121007",
|
|
54
54
|
"@mikro-orm/core": "5.9.7",
|
|
55
55
|
"@mikro-orm/migrations": "5.9.7",
|
|
56
56
|
"@mikro-orm/postgresql": "5.9.7",
|
|
57
57
|
"awilix": "^8.0.0",
|
|
58
|
-
"dotenv": "^16.
|
|
58
|
+
"dotenv": "^16.4.5",
|
|
59
59
|
"knex": "2.4.2"
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DAL } from "@medusajs/types";
|
|
2
|
-
import { ModulesSdkUtils } from "@medusajs/utils";
|
|
3
|
-
import { Address } from "../models";
|
|
4
|
-
import { CreateAddressDTO, UpdateAddressDTO } from "../types";
|
|
5
|
-
type InjectedDependencies = {
|
|
6
|
-
addressRepository: DAL.RepositoryService;
|
|
7
|
-
};
|
|
8
|
-
declare const AddressService_base: new <TEntity_1 extends object = any>(container: InjectedDependencies) => ModulesSdkUtils.AbstractService<TEntity_1, InjectedDependencies, {
|
|
9
|
-
create: CreateAddressDTO;
|
|
10
|
-
update: UpdateAddressDTO;
|
|
11
|
-
}, {
|
|
12
|
-
list?: any;
|
|
13
|
-
listAndCount?: any;
|
|
14
|
-
}>;
|
|
15
|
-
export default class AddressService<TEntity extends Address = Address> extends AddressService_base<TEntity> {
|
|
16
|
-
constructor(container: InjectedDependencies);
|
|
17
|
-
}
|
|
18
|
-
export {};
|
package/dist/services/address.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("@medusajs/utils");
|
|
4
|
-
const _models_1 = require("../models");
|
|
5
|
-
class AddressService extends utils_1.ModulesSdkUtils.abstractServiceFactory(_models_1.Address) {
|
|
6
|
-
constructor(container) {
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
super(...arguments);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.default = AddressService;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DAL } from "@medusajs/types";
|
|
2
|
-
import { ModulesSdkUtils } from "@medusajs/utils";
|
|
3
|
-
import { CustomerGroupCustomer } from "../models";
|
|
4
|
-
type CreateCustomerGroupCustomerDTO = {
|
|
5
|
-
customer_id: string;
|
|
6
|
-
customer_group_id: string;
|
|
7
|
-
created_by?: string;
|
|
8
|
-
};
|
|
9
|
-
type InjectedDependencies = {
|
|
10
|
-
customerGroupRepository: DAL.RepositoryService;
|
|
11
|
-
};
|
|
12
|
-
declare const CustomerGroupCustomerService_base: new <TEntity_1 extends object = any>(container: InjectedDependencies) => ModulesSdkUtils.AbstractService<TEntity_1, InjectedDependencies, {
|
|
13
|
-
create: CreateCustomerGroupCustomerDTO;
|
|
14
|
-
}, {
|
|
15
|
-
list?: any;
|
|
16
|
-
listAndCount?: any;
|
|
17
|
-
}>;
|
|
18
|
-
export default class CustomerGroupCustomerService<TEntity extends CustomerGroupCustomer = CustomerGroupCustomer> extends CustomerGroupCustomerService_base<TEntity> {
|
|
19
|
-
constructor(container: InjectedDependencies);
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("@medusajs/utils");
|
|
4
|
-
const _models_1 = require("../models");
|
|
5
|
-
class CustomerGroupCustomerService extends utils_1.ModulesSdkUtils.abstractServiceFactory(_models_1.CustomerGroupCustomer) {
|
|
6
|
-
constructor(container) {
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
super(...arguments);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.default = CustomerGroupCustomerService;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DAL } from "@medusajs/types";
|
|
2
|
-
import { ModulesSdkUtils } from "@medusajs/utils";
|
|
3
|
-
import { CustomerGroup } from "../models";
|
|
4
|
-
import { CreateCustomerGroupDTO, UpdateCustomerGroupDTO } from "@medusajs/types";
|
|
5
|
-
type InjectedDependencies = {
|
|
6
|
-
customerGroupRepository: DAL.RepositoryService;
|
|
7
|
-
};
|
|
8
|
-
declare const CustomerGroupService_base: new <TEntity_1 extends object = any>(container: InjectedDependencies) => ModulesSdkUtils.AbstractService<TEntity_1, InjectedDependencies, {
|
|
9
|
-
create: CreateCustomerGroupDTO;
|
|
10
|
-
update: UpdateCustomerGroupDTO;
|
|
11
|
-
}, {
|
|
12
|
-
list?: any;
|
|
13
|
-
listAndCount?: any;
|
|
14
|
-
}>;
|
|
15
|
-
export default class CustomerGroupService<TEntity extends CustomerGroup = CustomerGroup> extends CustomerGroupService_base<TEntity> {
|
|
16
|
-
constructor(container: InjectedDependencies);
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("@medusajs/utils");
|
|
4
|
-
const _models_1 = require("../models");
|
|
5
|
-
class CustomerGroupService extends utils_1.ModulesSdkUtils.abstractServiceFactory(_models_1.CustomerGroup) {
|
|
6
|
-
constructor(container) {
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
super(...arguments);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.default = CustomerGroupService;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CustomerTypes, DAL } from "@medusajs/types";
|
|
2
|
-
import { ModulesSdkUtils } from "@medusajs/utils";
|
|
3
|
-
import { Customer } from "../models";
|
|
4
|
-
type InjectedDependencies = {
|
|
5
|
-
customerRepository: DAL.RepositoryService;
|
|
6
|
-
};
|
|
7
|
-
declare const CustomerService_base: new <TEntity_1 extends object = any>(container: InjectedDependencies) => ModulesSdkUtils.AbstractService<TEntity_1, InjectedDependencies, {
|
|
8
|
-
create: CustomerTypes.CreateCustomerDTO;
|
|
9
|
-
update: CustomerTypes.UpdateCustomerDTO;
|
|
10
|
-
}, {
|
|
11
|
-
list?: any;
|
|
12
|
-
listAndCount?: any;
|
|
13
|
-
}>;
|
|
14
|
-
export default class CustomerService<TEntity extends Customer = Customer> extends CustomerService_base<TEntity> {
|
|
15
|
-
constructor(container: InjectedDependencies);
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("@medusajs/utils");
|
|
4
|
-
const _models_1 = require("../models");
|
|
5
|
-
class CustomerService extends utils_1.ModulesSdkUtils.abstractServiceFactory(_models_1.Customer) {
|
|
6
|
-
constructor(container) {
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
super(...arguments);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.default = CustomerService;
|
|
File without changes
|
|
File without changes
|