@chevre/domain 22.14.0-alpha.2 → 22.14.0-alpha.21
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/{createEventBySchedule.ts → addEventBySchedule.ts} +2 -2
- package/example/src/chevre/authorizeEventServiceOffer.ts +119 -0
- package/example/src/chevre/findReservationByCode.ts +0 -1
- package/example/src/chevre/productOffer/publishMemberTierToken.ts +92 -0
- package/lib/chevre/repo/accountingReport.d.ts +4 -4
- package/lib/chevre/repo/accountingReport.js +1 -1
- package/lib/chevre/repo/action.d.ts +1 -1
- package/lib/chevre/repo/creativeWork.d.ts +1 -3
- package/lib/chevre/repo/creativeWork.js +65 -47
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +2 -15
- package/lib/chevre/repo/mongoose/schemas/productOffer.d.ts +36 -0
- package/lib/chevre/repo/mongoose/schemas/{offer/event.js → productOffer.js} +9 -53
- package/lib/chevre/repo/note.d.ts +15 -3
- package/lib/chevre/repo/note.js +19 -1
- package/lib/chevre/repo/productOffer.d.ts +63 -65
- package/lib/chevre/repo/productOffer.js +121 -163
- package/lib/chevre/repo/task.js +2 -2
- package/lib/chevre/repository.d.ts +0 -5
- package/lib/chevre/repository.js +2 -15
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.d.ts +0 -2
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +0 -2
- package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +2 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +79 -57
- package/lib/chevre/service/event.js +10 -2
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize/factory.js +2 -2
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -3
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +2 -2
- package/lib/chevre/service/offer/event/authorize.d.ts +0 -2
- package/lib/chevre/service/offer/event/authorize.js +2 -2
- package/lib/chevre/service/offer/product.d.ts +0 -3
- package/lib/chevre/service/offer/product.js +29 -38
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +0 -1
- package/lib/chevre/service/order/deleteOrder.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -1
- package/lib/chevre/service/reserve/useReservation.js +2 -3
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +0 -2
- package/lib/chevre/service/task/checkResource.d.ts +2 -2
- package/lib/chevre/service/task/checkResource.js +8 -6
- package/lib/chevre/service/task/createAccountingReport.d.ts +2 -2
- package/lib/chevre/service/task/createAccountingReport.js +15 -15
- package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +1 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +3 -2
- package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +1 -1
- package/lib/chevre/service/task/deletePerson.js +11 -10
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -2
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +13 -6
- package/lib/chevre/service/task/onResourceUpdated.js +1 -2
- package/lib/chevre/service/task/useReservation.js +1 -2
- package/lib/chevre/service/taskHandler.js +2 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +9 -9
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +1 -1
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +1 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.d.ts +0 -1
- package/package.json +2 -2
- package/example/src/chevre/eventOffer/adminEventOffers.ts +0 -67
- package/example/src/chevre/migrateDeleteTransactionTasks.ts +0 -132
- package/example/src/chevre/optimizeDeleteTransactionTasks.ts +0 -119
- package/example/src/chevre/upsertMoviesByIdentifier.ts +0 -58
- package/lib/chevre/repo/mongoose/schemas/offer/event.d.ts +0 -10
- package/lib/chevre/repo/offer/event.d.ts +0 -38
- package/lib/chevre/repo/offer/event.js +0 -142
|
@@ -15,8 +15,8 @@ async function main() {
|
|
|
15
15
|
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
16
16
|
eventSchedule: { id: '672bf38b5d6d3f5642d658fc' }
|
|
17
17
|
},
|
|
18
|
-
|
|
19
|
-
typeOf: chevre.factory.actionType.
|
|
18
|
+
targetCollection: { typeOf: chevre.factory.eventType.ScreeningEvent },
|
|
19
|
+
typeOf: chevre.factory.actionType.AddAction
|
|
20
20
|
})(
|
|
21
21
|
{
|
|
22
22
|
connection: mongoose.connection,
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
import * as redis from 'redis';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
const project = {
|
|
8
|
+
id: String(process.env.PROJECT_ID),
|
|
9
|
+
typeOf: <chevre.factory.organizationType.Project>chevre.factory.organizationType.Project
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// tslint:disable-next-line:max-func-body-length
|
|
13
|
+
async function main() {
|
|
14
|
+
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
15
|
+
socket: {
|
|
16
|
+
port: Number(<string>process.env.REDIS_PORT),
|
|
17
|
+
host: <string>process.env.REDIS_HOST
|
|
18
|
+
},
|
|
19
|
+
password: <string>process.env.REDIS_KEY
|
|
20
|
+
});
|
|
21
|
+
await redisClient.connect();
|
|
22
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
23
|
+
|
|
24
|
+
const action = await (await chevre.service.offer.createService()).event.authorize(
|
|
25
|
+
{
|
|
26
|
+
project: project,
|
|
27
|
+
object: {
|
|
28
|
+
acceptedOffer: [],
|
|
29
|
+
reservationFor: {
|
|
30
|
+
id: 'bmcvkft63',
|
|
31
|
+
offers: {
|
|
32
|
+
validForMemberTier: {
|
|
33
|
+
token: 'xx',
|
|
34
|
+
isTierOf: { identifier: 'DefaultMemberProgram' }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
agent: { id: 'xxx' },
|
|
41
|
+
transaction: { id: 'xxx' },
|
|
42
|
+
validateEventOfferPeriod: true,
|
|
43
|
+
validateEvent: false,
|
|
44
|
+
store: { id: 'xxx' }
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
noOfferSpecified: true,
|
|
48
|
+
maxReservationGracePeriodInDays: 93
|
|
49
|
+
}
|
|
50
|
+
)(
|
|
51
|
+
{
|
|
52
|
+
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
53
|
+
advanceBookingRequirement: await chevre.repository.AdvanceBookingRequirement.createInstance(mongoose.connection),
|
|
54
|
+
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
55
|
+
authorization: await chevre.repository.Authorization.createInstance(mongoose.connection),
|
|
56
|
+
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
57
|
+
eventSeries: await chevre.repository.EventSeries.createInstance(mongoose.connection),
|
|
58
|
+
issuer: await chevre.repository.Issuer.createInstance(mongoose.connection),
|
|
59
|
+
memberProgram: await chevre.repository.MemberProgram.createInstance(mongoose.connection),
|
|
60
|
+
stockHolder: await chevre.repository.StockHolder.createInstance({ connection: mongoose.connection }),
|
|
61
|
+
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
62
|
+
offerCatalog: await chevre.repository.OfferCatalog.createInstance(mongoose.connection),
|
|
63
|
+
offerCatalogItem: await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection),
|
|
64
|
+
offerRateLimit: await chevre.repository.rateLimit.Offer.createInstance(redisClient),
|
|
65
|
+
orderInTransaction: await chevre.repository.OrderInTransaction.createInstance(mongoose.connection),
|
|
66
|
+
orderNumber: await chevre.repository.OrderNumber.createInstance({ connection: mongoose.connection }),
|
|
67
|
+
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
68
|
+
priceSpecification: await chevre.repository.PriceSpecification.createInstance(mongoose.connection),
|
|
69
|
+
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
70
|
+
productOffer: await chevre.repository.ProductOffer.createInstance(mongoose.connection),
|
|
71
|
+
project: await chevre.repository.Project.createInstance(mongoose.connection),
|
|
72
|
+
seat: await chevre.repository.place.Seat.createInstance(mongoose.connection),
|
|
73
|
+
setting: await chevre.repository.Setting.createInstance(mongoose.connection),
|
|
74
|
+
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
75
|
+
ticket: await chevre.repository.Ticket.createInstance(mongoose.connection),
|
|
76
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection),
|
|
77
|
+
transactionNumber: await chevre.repository.TransactionNumber.createInstance({ connection: mongoose.connection })
|
|
78
|
+
},
|
|
79
|
+
new chevre.settings.Settings({
|
|
80
|
+
// notification: {
|
|
81
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
82
|
+
// timeout: (process.env.TRIGGER_WEBHOOK_TIMEOUT !== undefined) ? Number(process.env.TRIGGER_WEBHOOK_TIMEOUT) : 15000,
|
|
83
|
+
// useFetchAPI: process.env.USE_FETCH_API === '1',
|
|
84
|
+
// secretKey: (typeof process.env.TRIGGER_WEBHOOK_SECRET_KEY === 'string')
|
|
85
|
+
// ? process.env.TRIGGER_WEBHOOK_SECRET_KEY
|
|
86
|
+
// : '',
|
|
87
|
+
// headerIdentifier: (typeof process.env.TRIGGER_WEBHOOK_HEADER_IDENTIFIER === 'string')
|
|
88
|
+
// ? process.env.TRIGGER_WEBHOOK_HEADER_IDENTIFIER
|
|
89
|
+
// : ''
|
|
90
|
+
// },
|
|
91
|
+
abortedTasksWithoutReport: (typeof process.env.ABORTED_TASKS_WITHOUT_REPORT === 'string')
|
|
92
|
+
? process.env.ABORTED_TASKS_WITHOUT_REPORT.split(' ')
|
|
93
|
+
: [],
|
|
94
|
+
numTryConfirmReserveTransaction: (typeof process.env.NUM_TRY_CONFIRM_RESERVE_TRANSACTION === 'string')
|
|
95
|
+
? Number(process.env.NUM_TRY_CONFIRM_RESERVE_TRANSACTION)
|
|
96
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
97
|
+
: 10,
|
|
98
|
+
deliverOrderLimit: (typeof process.env.DELIVER_ORDER_LIMIT === 'string')
|
|
99
|
+
? Number(process.env.DELIVER_ORDER_LIMIT)
|
|
100
|
+
: 1,
|
|
101
|
+
coa: {
|
|
102
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
103
|
+
timeout: (typeof process.env.COA_TIMEOUT === 'string') ? Number(process.env.COA_TIMEOUT) : 20000
|
|
104
|
+
},
|
|
105
|
+
gmo: <any>{
|
|
106
|
+
useFetch: process.env.GMO_USE_FETCH === '1'
|
|
107
|
+
},
|
|
108
|
+
movieticketReserve: <any>{
|
|
109
|
+
},
|
|
110
|
+
// useAssetTransactionSyncProcessing: process.env.USE_ASSET_TRANSACTION_SYNC_PROCESSING === '1',
|
|
111
|
+
useExperimentalFeature: process.env.USE_EXPERIMENTAL_FEATURE === '1'
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
console.log('authorized.', action);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
main()
|
|
118
|
+
.then(console.log)
|
|
119
|
+
.catch(console.error);
|
|
@@ -22,7 +22,6 @@ async function main() {
|
|
|
22
22
|
|
|
23
23
|
await (await chevre.service.reserve.createService()).verifyToken4reservation({
|
|
24
24
|
project: { id: project.id },
|
|
25
|
-
agent: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
26
25
|
reservationId: RESERVATION_ID,
|
|
27
26
|
ticket: {
|
|
28
27
|
ticketToken: CODE
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import { sign } from 'jsonwebtoken';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
|
+
|
|
7
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const productOfferRepo = await chevre.repository.ProductOffer.createInstance(mongoose.connection);
|
|
13
|
+
const issuerRepo = await chevre.repository.Issuer.createInstance(mongoose.connection);
|
|
14
|
+
const memberProgramRepo = await chevre.repository.MemberProgram.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const productOffer = (await productOfferRepo.findProductOffers(
|
|
17
|
+
{
|
|
18
|
+
limit: 1,
|
|
19
|
+
page: 1,
|
|
20
|
+
project: { id: { $eq: project.id } },
|
|
21
|
+
id: { $eq: '68d378a0c6f90b6bea9427ee' }
|
|
22
|
+
},
|
|
23
|
+
['validForMemberTier']
|
|
24
|
+
)).shift();
|
|
25
|
+
if (productOffer === undefined) {
|
|
26
|
+
throw new chevre.factory.errors.NotFound(chevre.factory.offerType.Offer);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const tierIdentifier = productOffer.validForMemberTier?.identifier;
|
|
30
|
+
if (typeof tierIdentifier !== 'string') {
|
|
31
|
+
throw new chevre.factory.errors.NotFound('productOffer.validForMemberTier.identifier');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const tier = (await memberProgramRepo.projectMemberProgramTiers(
|
|
35
|
+
{
|
|
36
|
+
limit: 1,
|
|
37
|
+
page: 1,
|
|
38
|
+
project: { id: { $eq: project.id } },
|
|
39
|
+
identifier: { $eq: tierIdentifier }
|
|
40
|
+
}
|
|
41
|
+
)).shift();
|
|
42
|
+
if (tier === undefined) {
|
|
43
|
+
throw new chevre.factory.errors.NotFound('MemberProgramTier');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const { url, tokenSecret } = await issuerRepo.findByIdentifier({
|
|
47
|
+
identifier: tier.isTierOf.hostingOrganization.identifier,
|
|
48
|
+
project: { id: project.id }
|
|
49
|
+
});
|
|
50
|
+
if (typeof tokenSecret !== 'string') {
|
|
51
|
+
throw new chevre.factory.errors.NotFound('issuer.tokenSecret');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const payload = {
|
|
55
|
+
member: {
|
|
56
|
+
memberOf: {
|
|
57
|
+
identifier: tierIdentifier,
|
|
58
|
+
isTierOf: { identifier: tier.isTierOf.identifier }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const token = await new Promise<string>((resolve, reject) => {
|
|
64
|
+
// 所有権を暗号化する
|
|
65
|
+
sign(
|
|
66
|
+
payload,
|
|
67
|
+
tokenSecret,
|
|
68
|
+
{
|
|
69
|
+
// algorithm: jwtSetting.algorithm,
|
|
70
|
+
issuer: url,
|
|
71
|
+
expiresIn: 1800
|
|
72
|
+
// subject,
|
|
73
|
+
},
|
|
74
|
+
(err, encoded) => {
|
|
75
|
+
if (err instanceof Error) {
|
|
76
|
+
reject(err);
|
|
77
|
+
} else {
|
|
78
|
+
if (typeof encoded !== 'string') {
|
|
79
|
+
reject(new Error('cannot be signed unexpectedly'));
|
|
80
|
+
} else {
|
|
81
|
+
resolve(encoded);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
console.log(token);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
main()
|
|
91
|
+
.then()
|
|
92
|
+
.catch(console.error);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Connection, PipelineStage } from 'mongoose';
|
|
2
|
-
import { IAccountingReport, IChildReport, IOrder4report } from './mongoose/schemas/accountingReport';
|
|
3
2
|
import * as factory from '../factory';
|
|
3
|
+
import { IDocType } from './mongoose/schemas/accountingReport';
|
|
4
4
|
type IMatchStage = PipelineStage.Match;
|
|
5
|
-
export { IAccountingReport, IChildReport, IOrder4report };
|
|
6
5
|
/**
|
|
7
6
|
* 経理レポートリポジトリ
|
|
8
7
|
*/
|
|
@@ -14,7 +13,7 @@ export declare class AccountingReportRepo {
|
|
|
14
13
|
id?: string;
|
|
15
14
|
};
|
|
16
15
|
}): IMatchStage[];
|
|
17
|
-
syncMainEntity(params:
|
|
16
|
+
syncMainEntity(params: IDocType): Promise<void>;
|
|
18
17
|
/**
|
|
19
18
|
* 注文番号で削除する
|
|
20
19
|
*/
|
|
@@ -34,7 +33,7 @@ export declare class AccountingReportRepo {
|
|
|
34
33
|
mainEntity: {
|
|
35
34
|
orderNumber: string;
|
|
36
35
|
};
|
|
37
|
-
hasPart: IChildReport;
|
|
36
|
+
hasPart: factory.report.accountingReport.IChildReport;
|
|
38
37
|
}): Promise<void>;
|
|
39
38
|
search(params: factory.report.accountingReport.ISearchConditions & {
|
|
40
39
|
seller?: {
|
|
@@ -46,3 +45,4 @@ export declare class AccountingReportRepo {
|
|
|
46
45
|
$unset: any;
|
|
47
46
|
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
48
47
|
}
|
|
48
|
+
export {};
|
|
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.AccountingReportRepo = void 0;
|
|
13
|
-
const accountingReport_1 = require("./mongoose/schemas/accountingReport");
|
|
14
13
|
const errorHandler_1 = require("../errorHandler");
|
|
15
14
|
const factory = require("../factory");
|
|
15
|
+
const accountingReport_1 = require("./mongoose/schemas/accountingReport");
|
|
16
16
|
const DEFAULT_SEARCH_LIMIT = 100;
|
|
17
17
|
/**
|
|
18
18
|
* 経理レポートリポジトリ
|
|
@@ -2,7 +2,7 @@ import { factory as surfrockFactory } from '@surfrock/sdk';
|
|
|
2
2
|
import { Connection, FilterQuery, UpdateQuery } from 'mongoose';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
export type IAction4transaction<T extends factory.actionType.AcceptAction | factory.actionType.AuthorizeAction> = T extends factory.actionType.AcceptAction ? factory.action.accept.coaOffer.IAction | factory.action.accept.pay.IAction : T extends factory.actionType.AuthorizeAction ? (factory.action.authorize.offer.eventService.IAction | factory.action.authorize.offer.moneyTransfer.IAction | factory.action.authorize.offer.product.IAction | factory.action.authorize.paymentMethod.any.IAction) : never;
|
|
5
|
-
export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AcceptAction ? IAction4transaction<factory.actionType.AcceptAction> : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : T extends factory.actionType.CheckAction ? (factory.action.check.paymentMethod.movieTicket.IAction | factory.action.check.
|
|
5
|
+
export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AcceptAction ? IAction4transaction<factory.actionType.AcceptAction> : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : T extends factory.actionType.CheckAction ? (factory.action.check.paymentMethod.movieTicket.IAction | factory.action.check.thing.IAction) : T extends factory.actionType.CreateAction ? factory.action.create.IAction : T extends factory.actionType.MoneyTransfer ? factory.action.transfer.moneyTransfer.IAction : T extends factory.actionType.AddAction ? factory.action.update.add.IAction : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IAction : T extends factory.actionType.UpdateAction ? factory.action.update.update.IAction : T extends factory.actionType.InformAction ? factory.action.interact.inform.IAction<factory.action.interact.inform.IAttributes<factory.action.interact.inform.IObject>> & {
|
|
6
6
|
error?: any;
|
|
7
7
|
purpose?: never;
|
|
8
8
|
} : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
|
|
@@ -30,9 +30,7 @@ export declare class CreativeWorkRepo {
|
|
|
30
30
|
$unset?: {
|
|
31
31
|
[key in keyof factory.creativeWork.movie.ICreativeWork]?: 1;
|
|
32
32
|
};
|
|
33
|
-
}[]
|
|
34
|
-
replace?: boolean;
|
|
35
|
-
}): Promise<{
|
|
33
|
+
}[]): Promise<{
|
|
36
34
|
bulkWriteResult: BulkWriteResult;
|
|
37
35
|
} | void>;
|
|
38
36
|
/**
|
|
@@ -159,7 +159,11 @@ class CreativeWorkRepo {
|
|
|
159
159
|
* コードをキーにして冪等作成
|
|
160
160
|
*/
|
|
161
161
|
// tslint:disable-next-line:max-func-body-length
|
|
162
|
-
upsertMoviesByIdentifier(params
|
|
162
|
+
upsertMoviesByIdentifier(params
|
|
163
|
+
// options?: {
|
|
164
|
+
// replace?: boolean;
|
|
165
|
+
// }
|
|
166
|
+
) {
|
|
163
167
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
168
|
const bulkWriteOps = [];
|
|
165
169
|
if (Array.isArray(params)) {
|
|
@@ -167,56 +171,70 @@ class CreativeWorkRepo {
|
|
|
167
171
|
params.forEach(({ $set, $unset }) => {
|
|
168
172
|
// リソースのユニークネスを保証するfilter
|
|
169
173
|
const filter = {
|
|
170
|
-
typeOf: $set.typeOf,
|
|
174
|
+
typeOf: { $eq: $set.typeOf },
|
|
171
175
|
'project.id': { $eq: $set.project.id },
|
|
172
176
|
identifier: { $eq: $set.identifier }
|
|
173
177
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
// const replaceOne: ReplaceOneModel<factory.creativeWork.movie.ICreativeWork> = {
|
|
178
|
-
// filter,
|
|
179
|
-
// replacement,
|
|
180
|
-
// upsert: true
|
|
181
|
-
// };
|
|
182
|
-
// bulkWriteOps.push({ replaceOne });
|
|
183
|
-
const { id, identifier, project, typeOf } = $set, setFields = __rest($set, ["id", "identifier", "project", "typeOf"]);
|
|
184
|
-
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
185
|
-
throw new factory.errors.ArgumentNull('identifier');
|
|
186
|
-
}
|
|
187
|
-
const setOnInsert = {
|
|
188
|
-
typeOf,
|
|
189
|
-
project,
|
|
190
|
-
identifier
|
|
191
|
-
};
|
|
192
|
-
const updateFilter = Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
|
|
193
|
-
const updateOne = {
|
|
194
|
-
filter,
|
|
195
|
-
update: updateFilter,
|
|
196
|
-
upsert: true
|
|
197
|
-
};
|
|
198
|
-
bulkWriteOps.push({ updateOne });
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
const { typeOf, project, identifier, duration, name, additionalProperty, contentRating, headline, distributor, thumbnailUrl, datePublished } = $set, setOnInsertFields = __rest($set, ["typeOf", "project", "identifier", "duration", "name", "additionalProperty", "contentRating", "headline", "distributor", "thumbnailUrl", "datePublished"]);
|
|
202
|
-
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
203
|
-
throw new factory.errors.ArgumentNull('identifier');
|
|
204
|
-
}
|
|
205
|
-
const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { typeOf,
|
|
206
|
-
project,
|
|
207
|
-
identifier });
|
|
208
|
-
const updateFilter = {
|
|
209
|
-
$setOnInsert: setOnInsert,
|
|
210
|
-
// 変更可能な属性のみ上書き
|
|
211
|
-
$set: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (name !== undefined) ? { name } : undefined), (contentRating !== undefined) ? { contentRating } : undefined), (duration !== undefined) ? { duration } : undefined), (headline !== undefined) ? { headline } : undefined), (datePublished !== undefined) ? { datePublished } : undefined), (distributor !== undefined) ? { distributor } : undefined), (typeof thumbnailUrl === 'string') ? { thumbnailUrl } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty } : [])
|
|
212
|
-
};
|
|
213
|
-
const updateOne = {
|
|
214
|
-
filter,
|
|
215
|
-
update: updateFilter,
|
|
216
|
-
upsert: true
|
|
217
|
-
};
|
|
218
|
-
bulkWriteOps.push({ updateOne });
|
|
178
|
+
const { id, identifier, project, typeOf } = $set, setFields = __rest($set, ["id", "identifier", "project", "typeOf"]);
|
|
179
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
180
|
+
throw new factory.errors.ArgumentNull('identifier');
|
|
219
181
|
}
|
|
182
|
+
const setOnInsert = {
|
|
183
|
+
typeOf,
|
|
184
|
+
project,
|
|
185
|
+
identifier
|
|
186
|
+
};
|
|
187
|
+
const updateFilter = Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
|
|
188
|
+
const updateOne = {
|
|
189
|
+
filter,
|
|
190
|
+
update: updateFilter,
|
|
191
|
+
upsert: true
|
|
192
|
+
};
|
|
193
|
+
bulkWriteOps.push({ updateOne });
|
|
194
|
+
// if (options?.replace === true) {
|
|
195
|
+
// } else {
|
|
196
|
+
// const {
|
|
197
|
+
// typeOf, project, identifier,
|
|
198
|
+
// duration,
|
|
199
|
+
// name,
|
|
200
|
+
// additionalProperty,
|
|
201
|
+
// contentRating,
|
|
202
|
+
// headline,
|
|
203
|
+
// distributor,
|
|
204
|
+
// thumbnailUrl,
|
|
205
|
+
// datePublished,
|
|
206
|
+
// ...setOnInsertFields
|
|
207
|
+
// } = $set;
|
|
208
|
+
// if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
209
|
+
// throw new factory.errors.ArgumentNull('identifier');
|
|
210
|
+
// }
|
|
211
|
+
// const setOnInsert: MatchKeysAndValues<factory.creativeWork.movie.ICreativeWork> = {
|
|
212
|
+
// ...setOnInsertFields,
|
|
213
|
+
// typeOf,
|
|
214
|
+
// project,
|
|
215
|
+
// identifier
|
|
216
|
+
// };
|
|
217
|
+
// const updateFilter: UpdateFilter<factory.creativeWork.movie.ICreativeWork> = {
|
|
218
|
+
// $setOnInsert: setOnInsert,
|
|
219
|
+
// // 変更可能な属性のみ上書き
|
|
220
|
+
// $set: {
|
|
221
|
+
// ...(name !== undefined) ? { name } : undefined,
|
|
222
|
+
// ...(contentRating !== undefined) ? { contentRating } : undefined,
|
|
223
|
+
// ...(duration !== undefined) ? { duration } : undefined,
|
|
224
|
+
// ...(headline !== undefined) ? { headline } : undefined,
|
|
225
|
+
// ...(datePublished !== undefined) ? { datePublished } : undefined,
|
|
226
|
+
// ...(distributor !== undefined) ? { distributor } : undefined,
|
|
227
|
+
// ...(typeof thumbnailUrl === 'string') ? { thumbnailUrl } : undefined,
|
|
228
|
+
// ...(Array.isArray(additionalProperty)) ? { additionalProperty } : []
|
|
229
|
+
// }
|
|
230
|
+
// };
|
|
231
|
+
// const updateOne: UpdateOneModel<factory.creativeWork.movie.ICreativeWork> = {
|
|
232
|
+
// filter,
|
|
233
|
+
// update: updateFilter,
|
|
234
|
+
// upsert: true
|
|
235
|
+
// };
|
|
236
|
+
// bulkWriteOps.push({ updateOne });
|
|
237
|
+
// }
|
|
220
238
|
});
|
|
221
239
|
}
|
|
222
240
|
if (bulkWriteOps.length > 0) {
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
|
-
|
|
4
|
-
export interface IChildReport {
|
|
5
|
-
typeOf: 'Report';
|
|
6
|
-
mainEntity: factory.report.accountingReport.IAction;
|
|
7
|
-
}
|
|
8
|
-
export interface IAccountingReport {
|
|
9
|
-
project: {
|
|
10
|
-
id: string;
|
|
11
|
-
typeOf: factory.organizationType.Project;
|
|
12
|
-
};
|
|
13
|
-
typeOf: 'Report';
|
|
14
|
-
hasPart: IChildReport[];
|
|
15
|
-
mainEntity: IOrder4report;
|
|
16
|
-
}
|
|
3
|
+
type IAccountingReport = factory.report.accountingReport.IReportDocument;
|
|
17
4
|
type IDocType = IAccountingReport;
|
|
18
5
|
type IModel = Model<IDocType>;
|
|
19
6
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
@@ -21,4 +8,4 @@ type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocT
|
|
|
21
8
|
declare const modelName = "AccountingReport";
|
|
22
9
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
23
10
|
declare function createSchema(): ISchema;
|
|
24
|
-
export { createSchema, IModel, indexes, modelName };
|
|
11
|
+
export { createSchema, IDocType, IModel, indexes, modelName };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
interface IProductOffer {
|
|
4
|
+
project: {
|
|
5
|
+
id: string;
|
|
6
|
+
typeOf: factory.organizationType.Project;
|
|
7
|
+
};
|
|
8
|
+
typeOf: factory.offerType.Offer;
|
|
9
|
+
/**
|
|
10
|
+
* プロダクトオファーコード
|
|
11
|
+
*/
|
|
12
|
+
identifier: string;
|
|
13
|
+
itemOffered: {
|
|
14
|
+
typeOf: factory.offerType.AggregateOffer;
|
|
15
|
+
/**
|
|
16
|
+
* プロダクトオファーコレクションコード
|
|
17
|
+
*/
|
|
18
|
+
identifier: string;
|
|
19
|
+
};
|
|
20
|
+
availability: factory.itemAvailability.InStock | factory.itemAvailability.OutOfStock;
|
|
21
|
+
validFrom: Date;
|
|
22
|
+
validThrough: Date;
|
|
23
|
+
acceptedPaymentMethod?: {
|
|
24
|
+
typeOf: 'PaymentMethod';
|
|
25
|
+
identifier: string;
|
|
26
|
+
};
|
|
27
|
+
validForMemberTier?: Pick<factory.issuer.IMemberProgramTier, 'identifier' | 'typeOf'>;
|
|
28
|
+
}
|
|
29
|
+
type IDocType = IProductOffer;
|
|
30
|
+
type IModel = Model<IDocType>;
|
|
31
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
32
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
33
|
+
declare const modelName = "ProductOffer";
|
|
34
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
35
|
+
declare function createSchema(): ISchema;
|
|
36
|
+
export { createSchema, IDocType, IModel, indexes, modelName };
|
|
@@ -3,25 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.modelName = exports.indexes = void 0;
|
|
4
4
|
exports.createSchema = createSchema;
|
|
5
5
|
const mongoose_1 = require("mongoose");
|
|
6
|
-
const settings_1 = require("
|
|
7
|
-
const writeConcern_1 = require("
|
|
8
|
-
const modelName = '
|
|
6
|
+
const settings_1 = require("../../../settings");
|
|
7
|
+
const writeConcern_1 = require("../writeConcern");
|
|
8
|
+
const modelName = 'ProductOffer';
|
|
9
9
|
exports.modelName = modelName;
|
|
10
10
|
const schemaDefinition = {
|
|
11
11
|
project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
12
|
-
seller: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
13
12
|
typeOf: { type: String, required: true },
|
|
14
13
|
identifier: { type: String, required: true },
|
|
15
14
|
itemOffered: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
16
|
-
|
|
15
|
+
availability: { type: String, required: true },
|
|
17
16
|
validFrom: { type: Date, required: true },
|
|
18
17
|
validThrough: { type: Date, required: true },
|
|
19
|
-
|
|
18
|
+
// availableAtOrFrom: { type: SchemaTypes.Mixed, required: false },
|
|
19
|
+
validForMemberTier: { type: mongoose_1.SchemaTypes.Mixed, required: false },
|
|
20
|
+
acceptedPaymentMethod: { type: mongoose_1.SchemaTypes.Mixed, required: false }
|
|
20
21
|
};
|
|
21
22
|
const schemaOptions = {
|
|
22
23
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
23
24
|
autoCreate: false,
|
|
24
|
-
collection: '
|
|
25
|
+
collection: 'productOffers',
|
|
25
26
|
id: true,
|
|
26
27
|
read: settings_1.MONGO_READ_PREFERENCE,
|
|
27
28
|
writeConcern: writeConcern_1.writeConcern,
|
|
@@ -46,56 +47,11 @@ const indexes = [
|
|
|
46
47
|
[
|
|
47
48
|
{ validFrom: 1 },
|
|
48
49
|
{ name: 'validFrom' }
|
|
49
|
-
],
|
|
50
|
-
[
|
|
51
|
-
{
|
|
52
|
-
'itemOffered.id': 1,
|
|
53
|
-
identifier: 1
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'uniqueByItemOfferedAndIdentifier',
|
|
57
|
-
unique: true
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
[
|
|
61
|
-
{
|
|
62
|
-
'itemOffered.id': 1,
|
|
63
|
-
'availableAtOrFrom.id': 1,
|
|
64
|
-
'validForMemberTier.identifier': 1
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
name: 'uniqueByItemOfferedAndAvailableAt',
|
|
68
|
-
unique: true
|
|
69
|
-
}
|
|
70
|
-
],
|
|
71
|
-
[
|
|
72
|
-
{ 'project.id': 1, validFrom: 1 },
|
|
73
|
-
{ name: 'projectId' }
|
|
74
|
-
],
|
|
75
|
-
[
|
|
76
|
-
{ 'seller.id': 1, validFrom: 1 },
|
|
77
|
-
{ name: 'sellerId' }
|
|
78
|
-
],
|
|
79
|
-
[
|
|
80
|
-
{ identifier: 1, validFrom: 1 },
|
|
81
|
-
{ name: 'identifier' }
|
|
82
|
-
],
|
|
83
|
-
[
|
|
84
|
-
{ 'itemOffered.id': 1, validFrom: 1 },
|
|
85
|
-
{ name: 'itemOfferedId' }
|
|
86
|
-
],
|
|
87
|
-
[
|
|
88
|
-
{ 'availableAtOrFrom.id': 1, validFrom: 1 },
|
|
89
|
-
{ name: 'availableAtOrFromId' }
|
|
90
|
-
],
|
|
91
|
-
[
|
|
92
|
-
{ 'validForMemberTier.identifier': 1, validFrom: 1 },
|
|
93
|
-
{ name: 'validForMemberTierIdentifier' }
|
|
94
50
|
]
|
|
95
51
|
];
|
|
96
52
|
exports.indexes = indexes;
|
|
97
53
|
/**
|
|
98
|
-
*
|
|
54
|
+
* プロダクトオファー(汎用的なオファー設定)スキーマ
|
|
99
55
|
*/
|
|
100
56
|
let schema;
|
|
101
57
|
function createSchema() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BulkWriteResult } from 'mongodb';
|
|
1
|
+
import type { BulkWriteResult, DeleteResult } from 'mongodb';
|
|
2
2
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
type INoteDigitalDocument = factory.creativeWork.noteDigitalDocument.INoteDigitalDocument;
|
|
@@ -32,12 +32,24 @@ export declare class NoteRepo {
|
|
|
32
32
|
id: string;
|
|
33
33
|
}[];
|
|
34
34
|
} | void>;
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* 既知のメモIDリストからメモを削除する
|
|
37
|
+
*/
|
|
38
|
+
deleteNotesByIds(params: {
|
|
39
|
+
project: {
|
|
40
|
+
id: string;
|
|
41
|
+
};
|
|
42
|
+
ids: string[];
|
|
43
|
+
}): Promise<DeleteResult | void>;
|
|
44
|
+
/**
|
|
45
|
+
* 主題リソースから全メモを削除する
|
|
46
|
+
*/
|
|
47
|
+
deleteNotesByAbout(params: {
|
|
36
48
|
about: {
|
|
37
49
|
id: string;
|
|
38
50
|
typeOf: factory.creativeWork.noteDigitalDocument.IAbout['typeOf'];
|
|
39
51
|
};
|
|
40
|
-
}): Promise<
|
|
52
|
+
}): Promise<DeleteResult>;
|
|
41
53
|
unsetUnnecessaryFields(params: {
|
|
42
54
|
filter: any;
|
|
43
55
|
$unset: any;
|
package/lib/chevre/repo/note.js
CHANGED
|
@@ -179,7 +179,25 @@ class NoteRepo {
|
|
|
179
179
|
}
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
|
-
|
|
182
|
+
/**
|
|
183
|
+
* 既知のメモIDリストからメモを削除する
|
|
184
|
+
*/
|
|
185
|
+
deleteNotesByIds(params) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
const { project, ids } = params;
|
|
188
|
+
if (Array.isArray(ids) && ids.length > 0) {
|
|
189
|
+
return this.noteModel.deleteMany({
|
|
190
|
+
'project.id': { $eq: project.id },
|
|
191
|
+
_id: { $in: ids }
|
|
192
|
+
})
|
|
193
|
+
.exec();
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* 主題リソースから全メモを削除する
|
|
199
|
+
*/
|
|
200
|
+
deleteNotesByAbout(params) {
|
|
183
201
|
return __awaiter(this, void 0, void 0, function* () {
|
|
184
202
|
return this.noteModel.deleteMany({
|
|
185
203
|
'about.id': { $eq: String(params.about.id) },
|