@chevre/domain 21.28.0-alpha.10 → 21.28.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
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
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
+
11
+ const customerTypeRepo = await chevre.repository.CustomerType.createInstance(mongoose.connection);
12
+
13
+ const saveResult = await customerTypeRepo.saveManyByCodeValue([
14
+ {
15
+ attributes: {
16
+ typeOf: 'CategoryCode',
17
+ codeValue: 'Enduser',
18
+ name: { ja: 'エンドユーザー' }
19
+ },
20
+ upsert: true
21
+ },
22
+ {
23
+ attributes: {
24
+ typeOf: 'CategoryCode',
25
+ codeValue: 'POS',
26
+ name: { ja: 'POS' }
27
+ },
28
+ upsert: true
29
+ },
30
+ {
31
+ attributes: {
32
+ typeOf: 'CategoryCode',
33
+ codeValue: 'TVM',
34
+ name: { ja: '券売機' }
35
+ },
36
+ upsert: true
37
+ }
38
+ ]);
39
+ console.log('saved,', saveResult);
40
+
41
+ const categoryCodes = await customerTypeRepo.search(
42
+ {
43
+ limit: 100,
44
+ page: 1,
45
+ sort: { codeValue: chevre.factory.sortType.Ascending },
46
+ codeValue: { $eq: 'Enduser' }
47
+ },
48
+ [],
49
+ []
50
+ );
51
+ console.log('categoryCodes found', categoryCodes);
52
+ console.log(categoryCodes.length, 'categoryCodes found');
53
+ }
54
+
55
+ main()
56
+ .then()
57
+ .catch(console.error);
@@ -11,10 +11,10 @@ async function main() {
11
11
  const aggregateOfferRepo = await chevre.repository.AggregateOffer.createInstance(mongoose.connection);
12
12
  updateResult = await aggregateOfferRepo.unsetUnnecessaryFields({
13
13
  filter: {
14
- 'offers.priceSpecification.accounting.operatingRevenue.project': { $exists: true }
14
+ 'offers.0.priceSpecification.accounting.operatingRevenue.project': { $exists: true }
15
15
  },
16
16
  $unset: {
17
- 'offers.priceSpecification.accounting.operatingRevenue.project': 1
17
+ 'offers.0.priceSpecification.accounting.operatingRevenue.project': 1
18
18
  }
19
19
  });
20
20
  console.log('unset processed.', updateResult);
@@ -83,21 +83,11 @@ class MongoRepository {
83
83
  }
84
84
  const codeValueEq = (_c = params.codeValue) === null || _c === void 0 ? void 0 : _c.$eq;
85
85
  if (typeof codeValueEq === 'string') {
86
- andConditions.push({
87
- codeValue: {
88
- $exists: true,
89
- $eq: codeValueEq
90
- }
91
- });
86
+ andConditions.push({ codeValue: { $eq: codeValueEq } });
92
87
  }
93
88
  const codeValueIn = (_d = params.codeValue) === null || _d === void 0 ? void 0 : _d.$in;
94
89
  if (Array.isArray(codeValueIn)) {
95
- andConditions.push({
96
- codeValue: {
97
- $exists: true,
98
- $in: codeValueIn
99
- }
100
- });
90
+ andConditions.push({ codeValue: { $in: codeValueIn } });
101
91
  }
102
92
  // tslint:disable-next-line:no-single-line-block-comment
103
93
  /* istanbul ignore else */
@@ -0,0 +1,22 @@
1
+ import type { BulkWriteResult } from 'mongodb';
2
+ import { Connection, FilterQuery } from 'mongoose';
3
+ import * as factory from '../factory';
4
+ type ICustomerType = Pick<factory.categoryCode.ICategoryCode, 'codeValue' | 'id' | 'name' | 'typeOf'>;
5
+ type IKeyOfProjection = keyof ICustomerType | '_id';
6
+ /**
7
+ * カスタマータイプリポジトリ
8
+ */
9
+ export declare class MongoRepository {
10
+ private readonly customerTypeModel;
11
+ constructor(connection: Connection);
12
+ static CREATE_MONGO_CONDITIONS(params: factory.categoryCode.ISearchConditions): FilterQuery<ICustomerType>[];
13
+ /**
14
+ * 検索
15
+ */
16
+ search(params: factory.categoryCode.ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<ICustomerType[]>;
17
+ saveManyByCodeValue(params: {
18
+ attributes: ICustomerType;
19
+ upsert?: boolean;
20
+ }[]): Promise<BulkWriteResult | void>;
21
+ }
22
+ export {};
@@ -0,0 +1,105 @@
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.MongoRepository = void 0;
13
+ const customerType_1 = require("./mongoose/schemas/customerType");
14
+ const settings_1 = require("../settings");
15
+ /**
16
+ * カスタマータイプリポジトリ
17
+ */
18
+ class MongoRepository {
19
+ constructor(connection) {
20
+ this.customerTypeModel = connection.model(customerType_1.modelName, (0, customerType_1.createSchema)());
21
+ }
22
+ // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
23
+ static CREATE_MONGO_CONDITIONS(params) {
24
+ var _a, _b;
25
+ const andConditions = [];
26
+ const codeValueEq = (_a = params.codeValue) === null || _a === void 0 ? void 0 : _a.$eq;
27
+ if (typeof codeValueEq === 'string') {
28
+ andConditions.push({ codeValue: { $exists: true, $eq: codeValueEq } });
29
+ }
30
+ const codeValueIn = (_b = params.codeValue) === null || _b === void 0 ? void 0 : _b.$in;
31
+ if (Array.isArray(codeValueIn)) {
32
+ andConditions.push({ codeValue: { $exists: true, $in: codeValueIn } });
33
+ }
34
+ return andConditions;
35
+ }
36
+ /**
37
+ * 検索
38
+ */
39
+ search(params, inclusion, exclusion) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
42
+ let projection = {};
43
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
44
+ inclusion.forEach((field) => {
45
+ projection[field] = 1;
46
+ });
47
+ }
48
+ else {
49
+ projection = {
50
+ __v: 0,
51
+ createdAt: 0,
52
+ updatedAt: 0
53
+ };
54
+ if (Array.isArray(exclusion) && exclusion.length > 0) {
55
+ exclusion.forEach((field) => {
56
+ projection[field] = 0;
57
+ });
58
+ }
59
+ }
60
+ const query = this.customerTypeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
61
+ if (typeof params.limit === 'number' && params.limit > 0) {
62
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
63
+ query.limit(params.limit)
64
+ .skip(params.limit * (page - 1));
65
+ }
66
+ // tslint:disable-next-line:no-single-line-block-comment
67
+ /* istanbul ignore else */
68
+ if (params.sort !== undefined) {
69
+ query.sort(params.sort);
70
+ }
71
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
72
+ .exec()
73
+ .then((docs) => docs.map((doc) => doc.toObject()));
74
+ });
75
+ }
76
+ saveManyByCodeValue(params) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ const bulkWriteOps = [];
79
+ if (Array.isArray(params)) {
80
+ params.forEach((p) => {
81
+ const $set = Object.assign({}, p.attributes);
82
+ if (typeof $set.id === 'string') {
83
+ delete $set.id;
84
+ }
85
+ bulkWriteOps.push({
86
+ updateOne: {
87
+ filter: {
88
+ codeValue: { $eq: p.attributes.codeValue }
89
+ },
90
+ update: {
91
+ $set
92
+ // $setOnInsert: {}
93
+ },
94
+ upsert: (p.upsert !== undefined) ? p.upsert : false
95
+ }
96
+ });
97
+ });
98
+ }
99
+ if (bulkWriteOps.length > 0) {
100
+ return this.customerTypeModel.bulkWrite(bulkWriteOps, { ordered: false });
101
+ }
102
+ });
103
+ }
104
+ }
105
+ exports.MongoRepository = MongoRepository;
@@ -0,0 +1,5 @@
1
+ import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
2
+ declare const modelName = "CustomerType";
3
+ declare const indexes: [d: IndexDefinition, o: IndexOptions][];
4
+ declare function createSchema(): Schema;
5
+ export { modelName, indexes, createSchema };
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSchema = exports.indexes = exports.modelName = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const writeConcern_1 = require("../writeConcern");
6
+ const settings_1 = require("../../../settings");
7
+ const modelName = 'CustomerType';
8
+ exports.modelName = modelName;
9
+ const schemaDefinition = {
10
+ typeOf: { type: String, required: true },
11
+ codeValue: { type: String, required: true },
12
+ name: mongoose_1.SchemaTypes.Mixed
13
+ };
14
+ const schemaOptions = {
15
+ autoIndex: settings_1.MONGO_AUTO_INDEX,
16
+ autoCreate: false,
17
+ collection: 'customerTypes',
18
+ id: true,
19
+ read: settings_1.MONGO_READ_PREFERENCE,
20
+ writeConcern: writeConcern_1.writeConcern,
21
+ strict: true,
22
+ strictQuery: false,
23
+ timestamps: {
24
+ createdAt: 'createdAt',
25
+ updatedAt: 'updatedAt'
26
+ },
27
+ toJSON: {
28
+ getters: false,
29
+ virtuals: false,
30
+ minimize: false,
31
+ versionKey: false
32
+ },
33
+ toObject: {
34
+ getters: false,
35
+ virtuals: true,
36
+ minimize: false,
37
+ versionKey: false
38
+ }
39
+ };
40
+ const indexes = [
41
+ [
42
+ { createdAt: 1 },
43
+ { name: 'searchByCreatedAt' }
44
+ ],
45
+ [
46
+ { updatedAt: 1 },
47
+ { name: 'searchByUpdatedAt' }
48
+ ]
49
+ ];
50
+ exports.indexes = indexes;
51
+ /**
52
+ * カスタマータイプスキーマ
53
+ */
54
+ let schema;
55
+ function createSchema() {
56
+ if (schema === undefined) {
57
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
58
+ if (settings_1.MONGO_AUTO_INDEX) {
59
+ indexes.forEach((indexParams) => {
60
+ schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
61
+ });
62
+ }
63
+ }
64
+ return schema;
65
+ }
66
+ exports.createSchema = createSchema;
@@ -17,6 +17,7 @@ import type { MongoRepository as CodeRepo } from './repo/code';
17
17
  import type { MongoRepository as CommentRepo } from './repo/comment';
18
18
  import type { MongoRepository as CreativeWorkRepo } from './repo/creativeWork';
19
19
  import type { MongoRepository as CustomerRepo } from './repo/customer';
20
+ import type { MongoRepository as CustomerTypeRepo } from './repo/customerType';
20
21
  import type { MongoRepository as EmailMessageRepo } from './repo/emailMessage';
21
22
  import type { MongoRepository as EventRepo } from './repo/event';
22
23
  import type { MongoRepository as MemberRepo } from './repo/member';
@@ -128,6 +129,10 @@ export type Customer = CustomerRepo;
128
129
  export declare namespace Customer {
129
130
  function createInstance(...params: ConstructorParameters<typeof CustomerRepo>): Promise<CustomerRepo>;
130
131
  }
132
+ export type CustomerType = CustomerTypeRepo;
133
+ export declare namespace CustomerType {
134
+ function createInstance(...params: ConstructorParameters<typeof CustomerTypeRepo>): Promise<CustomerTypeRepo>;
135
+ }
131
136
  export type EmailMessage = EmailMessageRepo;
132
137
  export declare namespace EmailMessage {
133
138
  function createInstance(...params: ConstructorParameters<typeof EmailMessageRepo>): Promise<EmailMessageRepo>;
@@ -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.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.Note = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = 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.TransactionNumber = exports.Transaction = void 0;
12
+ exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.Note = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = 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.TransactionNumber = exports.Transaction = exports.Telemetry = void 0;
14
14
  var AcceptedOffer;
15
15
  (function (AcceptedOffer) {
16
16
  let repo;
@@ -232,6 +232,19 @@ var Customer;
232
232
  }
233
233
  Customer.createInstance = createInstance;
234
234
  })(Customer = exports.Customer || (exports.Customer = {}));
235
+ var CustomerType;
236
+ (function (CustomerType) {
237
+ let repo;
238
+ function createInstance(...params) {
239
+ return __awaiter(this, void 0, void 0, function* () {
240
+ if (repo === undefined) {
241
+ repo = (yield Promise.resolve().then(() => require('./repo/customerType'))).MongoRepository;
242
+ }
243
+ return new repo(...params);
244
+ });
245
+ }
246
+ CustomerType.createInstance = createInstance;
247
+ })(CustomerType = exports.CustomerType || (exports.CustomerType = {}));
235
248
  var EmailMessage;
236
249
  (function (EmailMessage) {
237
250
  let repo;
@@ -345,12 +345,17 @@ function processAuthorizeCreditCard(params, transaction, paymentServiceId, optio
345
345
  function processAuthorizeMovieTicket(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet) {
346
346
  return (repos) => __awaiter(this, void 0, void 0, function* () {
347
347
  const { accountId, payAction, accountsReceivablesByServiceType } = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet)(repos);
348
+ const payActionInObject = {
349
+ actionStatus: payAction.actionStatus,
350
+ id: payAction.id,
351
+ typeOf: payAction.typeOf
352
+ };
348
353
  return saveAuthorizeResult({
349
354
  id: transaction.id,
350
355
  update: {
351
356
  'object.accountId': accountId,
352
357
  'object.paymentMethod.accountId': accountId,
353
- 'object.payAction': payAction,
358
+ 'object.payAction': payActionInObject,
354
359
  // 認証レスポンスより計上金額を保管(2023-05-15~)
355
360
  'object.accountsReceivablesByServiceType': accountsReceivablesByServiceType
356
361
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@aws-sdk/credential-providers": "3.433.0",
13
- "@chevre/factory": "4.366.0-alpha.2",
13
+ "@chevre/factory": "4.366.0-alpha.3",
14
14
  "@cinerino/sdk": "5.17.0",
15
15
  "@motionpicture/coa-service": "9.4.0",
16
16
  "@motionpicture/gmo-service": "5.3.0",
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "21.28.0-alpha.10"
113
+ "version": "21.28.0-alpha.12"
114
114
  }