@chevre/domain 22.8.0-alpha.12 → 22.8.0-alpha.14
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/example/src/chevre/adminMemberProgram.ts +59 -0
- package/lib/chevre/repo/issuer.d.ts +12 -0
- package/lib/chevre/repo/issuer.js +32 -1
- package/lib/chevre/repo/memberProgram.d.ts +53 -0
- package/lib/chevre/repo/memberProgram.js +140 -0
- package/lib/chevre/repo/mongoose/schemas/issuer.d.ts +8 -1
- package/lib/chevre/repo/mongoose/schemas/issuer.js +3 -1
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/package.json +1 -1
- package/example/src/chevre/adminSellerPaymentAccepted.ts +0 -60
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
const ISSUER_ID = '6787461fc8571271cec198b2';
|
|
8
|
+
const PROGRAM_IDENTIFIER = 'Default';
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const memberProgramRepo = await chevre.repository.MemberProgram.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
let programs = await memberProgramRepo.search({
|
|
16
|
+
project: { id: { $eq: project.id } },
|
|
17
|
+
hostingOrganization: { id: { $eq: ISSUER_ID } }
|
|
18
|
+
});
|
|
19
|
+
console.log('programs:', programs);
|
|
20
|
+
console.log(programs.length, 'programs found');
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
await memberProgramRepo.deleteOne({
|
|
24
|
+
project: { id: project.id },
|
|
25
|
+
identifier: PROGRAM_IDENTIFIER,
|
|
26
|
+
hostingOrganization: { id: ISSUER_ID }
|
|
27
|
+
});
|
|
28
|
+
console.log('program deleted');
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error(error);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
programs = await memberProgramRepo.search({
|
|
34
|
+
project: { id: { $eq: project.id } },
|
|
35
|
+
hostingOrganization: { id: { $eq: ISSUER_ID } },
|
|
36
|
+
identifier: { $eq: PROGRAM_IDENTIFIER }
|
|
37
|
+
});
|
|
38
|
+
console.log('programs:', programs);
|
|
39
|
+
console.log(programs.length, 'programs found');
|
|
40
|
+
|
|
41
|
+
await memberProgramRepo.create({
|
|
42
|
+
project: { id: project.id },
|
|
43
|
+
identifier: PROGRAM_IDENTIFIER,
|
|
44
|
+
hostingOrganization: { id: ISSUER_ID }
|
|
45
|
+
});
|
|
46
|
+
console.log('program created');
|
|
47
|
+
|
|
48
|
+
programs = await memberProgramRepo.search({
|
|
49
|
+
project: { id: { $eq: project.id } },
|
|
50
|
+
hostingOrganization: { id: { $eq: ISSUER_ID } },
|
|
51
|
+
identifier: { $eq: PROGRAM_IDENTIFIER }
|
|
52
|
+
});
|
|
53
|
+
console.log('programs:', programs);
|
|
54
|
+
console.log(programs.length, 'programs found');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
main()
|
|
58
|
+
.then()
|
|
59
|
+
.catch(console.error);
|
|
@@ -11,4 +11,16 @@ export declare class IssuerRepo {
|
|
|
11
11
|
id: string;
|
|
12
12
|
}>;
|
|
13
13
|
projectPublicFields(params: ISearchConditions): Promise<Pick<IIssuer, 'id' | 'identifier' | 'project'>[]>;
|
|
14
|
+
findById(params: {
|
|
15
|
+
id: string;
|
|
16
|
+
project: {
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
}): Promise<IIssuer>;
|
|
20
|
+
deleteById(params: {
|
|
21
|
+
id: string;
|
|
22
|
+
project: {
|
|
23
|
+
id: string;
|
|
24
|
+
};
|
|
25
|
+
}): Promise<void>;
|
|
14
26
|
}
|
|
@@ -59,7 +59,7 @@ class IssuerRepo {
|
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
61
|
const { id, identifier, project } = params, updateFields = __rest(params, ["id", "identifier", "project"]);
|
|
62
|
-
doc = yield this.issuerModel.findOneAndUpdate({ _id: { $eq: params.id } }, updateFields, { upsert: false, new: true, projection: { _id: 1 } })
|
|
62
|
+
doc = yield this.issuerModel.findOneAndUpdate({ _id: { $eq: params.id } }, { $set: updateFields }, { upsert: false, new: true, projection: { _id: 1 } })
|
|
63
63
|
.exec();
|
|
64
64
|
savedId = params.id;
|
|
65
65
|
}
|
|
@@ -93,5 +93,36 @@ class IssuerRepo {
|
|
|
93
93
|
.exec();
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
+
findById(params) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const projection = {
|
|
99
|
+
_id: 0,
|
|
100
|
+
id: { $toString: '$_id' },
|
|
101
|
+
identifier: 1,
|
|
102
|
+
project: 1,
|
|
103
|
+
tokenSecret: 1
|
|
104
|
+
};
|
|
105
|
+
const query = this.issuerModel.findOne({
|
|
106
|
+
_id: { $eq: params.id },
|
|
107
|
+
'project.id': { $eq: params.project.id }
|
|
108
|
+
}, projection);
|
|
109
|
+
const issuer = yield query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
110
|
+
.lean()
|
|
111
|
+
.exec();
|
|
112
|
+
if (issuer === null) {
|
|
113
|
+
throw new factory.errors.NotFound('Issuer');
|
|
114
|
+
}
|
|
115
|
+
return issuer;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
deleteById(params) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
yield this.issuerModel.findOneAndDelete({
|
|
121
|
+
_id: { $eq: params.id },
|
|
122
|
+
'project.id': { $eq: params.project.id }
|
|
123
|
+
}, { projection: { _id: 1 } })
|
|
124
|
+
.exec();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
96
127
|
}
|
|
97
128
|
exports.IssuerRepo = IssuerRepo;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
import { IMemberProgram } from './mongoose/schemas/issuer';
|
|
3
|
+
/**
|
|
4
|
+
* メンバープログラムリポジトリ
|
|
5
|
+
*/
|
|
6
|
+
export declare class MemberProgramRepo {
|
|
7
|
+
private readonly issuerModel;
|
|
8
|
+
constructor(connection: Connection);
|
|
9
|
+
search(params: {
|
|
10
|
+
limit?: number;
|
|
11
|
+
page?: number;
|
|
12
|
+
project?: {
|
|
13
|
+
id?: {
|
|
14
|
+
$eq?: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
hostingOrganization?: {
|
|
18
|
+
id?: {
|
|
19
|
+
$eq?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
identifier?: {
|
|
23
|
+
$eq?: string;
|
|
24
|
+
};
|
|
25
|
+
}): Promise<IMemberProgram[]>;
|
|
26
|
+
create(params: {
|
|
27
|
+
project: {
|
|
28
|
+
id: string;
|
|
29
|
+
};
|
|
30
|
+
identifier: string;
|
|
31
|
+
hostingOrganization: {
|
|
32
|
+
id: string;
|
|
33
|
+
};
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
updateOne(params: {
|
|
36
|
+
project: {
|
|
37
|
+
id: string;
|
|
38
|
+
};
|
|
39
|
+
identifier: string;
|
|
40
|
+
hostingOrganization: {
|
|
41
|
+
id: string;
|
|
42
|
+
};
|
|
43
|
+
}): Promise<void>;
|
|
44
|
+
deleteOne(params: {
|
|
45
|
+
project: {
|
|
46
|
+
id: string;
|
|
47
|
+
};
|
|
48
|
+
identifier: string;
|
|
49
|
+
hostingOrganization: {
|
|
50
|
+
id: string;
|
|
51
|
+
};
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MemberProgramRepo = void 0;
|
|
13
|
+
const mongoose_1 = require("mongoose");
|
|
14
|
+
const factory = require("../factory");
|
|
15
|
+
const settings_1 = require("../settings");
|
|
16
|
+
const issuer_1 = require("./mongoose/schemas/issuer");
|
|
17
|
+
/**
|
|
18
|
+
* メンバープログラムリポジトリ
|
|
19
|
+
*/
|
|
20
|
+
class MemberProgramRepo {
|
|
21
|
+
constructor(connection) {
|
|
22
|
+
this.issuerModel = connection.model(issuer_1.modelName, (0, issuer_1.createSchema)());
|
|
23
|
+
}
|
|
24
|
+
search(params) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a, _b, _c, _d, _e;
|
|
27
|
+
const matchStages = [];
|
|
28
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
29
|
+
if (typeof projectIdEq === 'string') {
|
|
30
|
+
matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
|
|
31
|
+
}
|
|
32
|
+
const hostingOrganizationIdEq = (_d = (_c = params.hostingOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
33
|
+
if (typeof hostingOrganizationIdEq === 'string') {
|
|
34
|
+
matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(hostingOrganizationIdEq) } } });
|
|
35
|
+
}
|
|
36
|
+
const identifierEq = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
37
|
+
if (typeof identifierEq === 'string') {
|
|
38
|
+
matchStages.push({ $match: { 'hasMemberProgram.identifier': { $exists: true, $eq: identifierEq } } });
|
|
39
|
+
}
|
|
40
|
+
const aggregate = this.issuerModel.aggregate([
|
|
41
|
+
{
|
|
42
|
+
$unwind: {
|
|
43
|
+
path: '$hasMemberProgram'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
...matchStages,
|
|
47
|
+
// { $sort: { 'makesOffer.availableAtOrFrom.id': factory.sortType.Ascending } },
|
|
48
|
+
{
|
|
49
|
+
$project: {
|
|
50
|
+
_id: 0,
|
|
51
|
+
typeOf: '$hasMemberProgram.typeOf',
|
|
52
|
+
identifier: '$hasMemberProgram.identifier',
|
|
53
|
+
hostingOrganization: {
|
|
54
|
+
identifier: '$identifier'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]);
|
|
59
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
60
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
61
|
+
aggregate.limit(params.limit * page)
|
|
62
|
+
.skip(params.limit * (page - 1));
|
|
63
|
+
}
|
|
64
|
+
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
65
|
+
.exec();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
create(params) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
let doc = yield this.issuerModel.findOne({
|
|
71
|
+
_id: { $eq: params.hostingOrganization.id },
|
|
72
|
+
'project.id': { $eq: params.project.id }
|
|
73
|
+
}, { _id: 1 })
|
|
74
|
+
.exec();
|
|
75
|
+
if (doc === null) {
|
|
76
|
+
throw new factory.errors.NotFound('Issuer');
|
|
77
|
+
}
|
|
78
|
+
const creatingMemberProgram = {
|
|
79
|
+
typeOf: 'MemberProgram',
|
|
80
|
+
identifier: params.identifier
|
|
81
|
+
};
|
|
82
|
+
doc = yield this.issuerModel.findOneAndUpdate({
|
|
83
|
+
_id: { $eq: params.hostingOrganization.id },
|
|
84
|
+
'project.id': { $eq: params.project.id },
|
|
85
|
+
'hasMemberProgram.identifier': { $ne: params.identifier }
|
|
86
|
+
}, {
|
|
87
|
+
$push: { hasMemberProgram: creatingMemberProgram }
|
|
88
|
+
}, {
|
|
89
|
+
projection: { _id: 1 }
|
|
90
|
+
})
|
|
91
|
+
.exec();
|
|
92
|
+
if (doc === null) {
|
|
93
|
+
throw new factory.errors.AlreadyInUse('hasMemberProgram', ['identifier']);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
updateOne(params) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const updatingMakesOffer = {
|
|
100
|
+
typeOf: 'MemberProgram',
|
|
101
|
+
identifier: params.identifier
|
|
102
|
+
};
|
|
103
|
+
const doc = yield this.issuerModel.findOneAndUpdate({
|
|
104
|
+
_id: { $eq: params.hostingOrganization.id },
|
|
105
|
+
'project.id': { $eq: params.project.id },
|
|
106
|
+
'hasMemberProgram.identifier': { $exists: true, $eq: params.identifier }
|
|
107
|
+
}, {
|
|
108
|
+
$set: { 'hasMemberProgram.$[hasMemberProgramElement]': updatingMakesOffer }
|
|
109
|
+
}, {
|
|
110
|
+
new: true,
|
|
111
|
+
arrayFilters: [
|
|
112
|
+
{ 'hasMemberProgramElement.identifier': { $eq: params.identifier } }
|
|
113
|
+
],
|
|
114
|
+
projection: { _id: 1 }
|
|
115
|
+
})
|
|
116
|
+
.exec();
|
|
117
|
+
if (doc === null) {
|
|
118
|
+
throw new factory.errors.NotFound('MemberProgram');
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
deleteOne(params) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
const doc = yield this.issuerModel.findOneAndUpdate({
|
|
125
|
+
_id: { $eq: params.hostingOrganization.id },
|
|
126
|
+
'project.id': { $eq: params.project.id },
|
|
127
|
+
'hasMemberProgram.identifier': { $exists: true, $eq: params.identifier }
|
|
128
|
+
}, {
|
|
129
|
+
$pull: { hasMemberProgram: { identifier: params.identifier } }
|
|
130
|
+
}, {
|
|
131
|
+
projection: { _id: 1 }
|
|
132
|
+
})
|
|
133
|
+
.exec();
|
|
134
|
+
if (doc === null) {
|
|
135
|
+
throw new factory.errors.NotFound('MemberProgram');
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.MemberProgramRepo = MemberProgramRepo;
|
|
@@ -22,8 +22,15 @@ export interface IIssuer {
|
|
|
22
22
|
id: string;
|
|
23
23
|
identifier: string;
|
|
24
24
|
project: Pick<factory.project.IProject, 'id' | 'typeOf'>;
|
|
25
|
+
tokenSecret?: string;
|
|
25
26
|
}
|
|
26
|
-
export
|
|
27
|
+
export interface IMemberProgram {
|
|
28
|
+
typeOf: 'MemberProgram';
|
|
29
|
+
identifier: string;
|
|
30
|
+
}
|
|
31
|
+
export type IDocType = IIssuer & {
|
|
32
|
+
hasMemberProgram?: IMemberProgram[];
|
|
33
|
+
};
|
|
27
34
|
type IModel = Model<IDocType>;
|
|
28
35
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
29
36
|
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
@@ -9,7 +9,9 @@ const modelName = 'Issuer';
|
|
|
9
9
|
exports.modelName = modelName;
|
|
10
10
|
const schemaDefinition = {
|
|
11
11
|
project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
12
|
-
identifier: { type: String, required: true }
|
|
12
|
+
identifier: { type: String, required: true },
|
|
13
|
+
tokenSecret: String,
|
|
14
|
+
hasMemberProgram: [mongoose_1.SchemaTypes.Mixed]
|
|
13
15
|
};
|
|
14
16
|
const schemaOptions = {
|
|
15
17
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -26,6 +26,7 @@ import type { EventSeriesRepo } from './repo/eventSeries';
|
|
|
26
26
|
import type { InterfaceRepo } from './repo/interface';
|
|
27
27
|
import type { IssuerRepo } from './repo/issuer';
|
|
28
28
|
import type { MemberRepo } from './repo/member';
|
|
29
|
+
import type { MemberProgramRepo } from './repo/memberProgram';
|
|
29
30
|
import type { MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
|
|
30
31
|
import type { MessageRepo } from './repo/message';
|
|
31
32
|
import type { NoteRepo } from './repo/note';
|
|
@@ -178,6 +179,10 @@ export type Member = MemberRepo;
|
|
|
178
179
|
export declare namespace Member {
|
|
179
180
|
function createInstance(...params: ConstructorParameters<typeof MemberRepo>): Promise<MemberRepo>;
|
|
180
181
|
}
|
|
182
|
+
export type MemberProgram = MemberProgramRepo;
|
|
183
|
+
export declare namespace MemberProgram {
|
|
184
|
+
function createInstance(...params: ConstructorParameters<typeof MemberProgramRepo>): Promise<MemberProgramRepo>;
|
|
185
|
+
}
|
|
181
186
|
export type MerchantReturnPolicy = MerchantReturnPolicyRepo;
|
|
182
187
|
export declare namespace MerchantReturnPolicy {
|
|
183
188
|
function createInstance(...params: ConstructorParameters<typeof MerchantReturnPolicyRepo>): Promise<MerchantReturnPolicyRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Schedule = exports.Role = exports.Reservation = void 0;
|
|
12
|
+
exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.Note = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.Interface = exports.EventSeries = exports.EventSellerMakesOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
13
|
+
exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Schedule = exports.Role = exports.Reservation = exports.ProjectMakesOffer = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -349,6 +349,19 @@ var Member;
|
|
|
349
349
|
}
|
|
350
350
|
Member.createInstance = createInstance;
|
|
351
351
|
})(Member || (exports.Member = Member = {}));
|
|
352
|
+
var MemberProgram;
|
|
353
|
+
(function (MemberProgram) {
|
|
354
|
+
let repo;
|
|
355
|
+
function createInstance(...params) {
|
|
356
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
357
|
+
if (repo === undefined) {
|
|
358
|
+
repo = (yield Promise.resolve().then(() => require('./repo/memberProgram'))).MemberProgramRepo;
|
|
359
|
+
}
|
|
360
|
+
return new repo(...params);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
MemberProgram.createInstance = createInstance;
|
|
364
|
+
})(MemberProgram || (exports.MemberProgram = MemberProgram = {}));
|
|
352
365
|
var MerchantReturnPolicy;
|
|
353
366
|
(function (MerchantReturnPolicy) {
|
|
354
367
|
let repo;
|
package/package.json
CHANGED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
-
const SELLER_ID = '59d20831e53ebc2b4e774466';
|
|
8
|
-
const PAYMENT_METHOD_TYPE = 'Cash';
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const paymentAcceptedRepo = await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection);
|
|
14
|
-
|
|
15
|
-
let paymentAccepted = await paymentAcceptedRepo.search({
|
|
16
|
-
project: { id: { $eq: project.id } },
|
|
17
|
-
seller: { id: { $eq: SELLER_ID } },
|
|
18
|
-
codeValue: { $eq: PAYMENT_METHOD_TYPE }
|
|
19
|
-
});
|
|
20
|
-
console.log('paymentAccepted:', paymentAccepted);
|
|
21
|
-
console.log(paymentAccepted.length, 'paymentAccepted found');
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
await paymentAcceptedRepo.deleteOne({
|
|
25
|
-
codeValue: PAYMENT_METHOD_TYPE,
|
|
26
|
-
project: { id: project.id },
|
|
27
|
-
seller: { id: SELLER_ID }
|
|
28
|
-
});
|
|
29
|
-
console.log('paymentAccepted deleted');
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error(error);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
paymentAccepted = await paymentAcceptedRepo.search({
|
|
35
|
-
project: { id: { $eq: project.id } },
|
|
36
|
-
seller: { id: { $eq: SELLER_ID } },
|
|
37
|
-
codeValue: { $eq: PAYMENT_METHOD_TYPE }
|
|
38
|
-
});
|
|
39
|
-
console.log('paymentAccepted:', paymentAccepted);
|
|
40
|
-
console.log(paymentAccepted.length, 'paymentAccepted found');
|
|
41
|
-
|
|
42
|
-
await paymentAcceptedRepo.create({
|
|
43
|
-
codeValue: PAYMENT_METHOD_TYPE,
|
|
44
|
-
project: { id: project.id },
|
|
45
|
-
seller: { id: SELLER_ID }
|
|
46
|
-
});
|
|
47
|
-
console.log('paymentAccepted created');
|
|
48
|
-
|
|
49
|
-
paymentAccepted = await paymentAcceptedRepo.search({
|
|
50
|
-
project: { id: { $eq: project.id } },
|
|
51
|
-
seller: { id: { $eq: SELLER_ID } },
|
|
52
|
-
codeValue: { $eq: PAYMENT_METHOD_TYPE }
|
|
53
|
-
});
|
|
54
|
-
console.log('paymentAccepted:', paymentAccepted);
|
|
55
|
-
console.log(paymentAccepted.length, 'paymentAccepted found');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
main()
|
|
59
|
-
.then()
|
|
60
|
-
.catch(console.error);
|