@chevre/domain 26.0.0-alpha.34 → 26.0.0-alpha.35

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.
@@ -3,7 +3,7 @@ import { factory } from '../../factory';
3
3
  import { IModel as IActionModel } from '../mongoose/schemas/action';
4
4
  import { IModel as IActionRecipeModel } from '../mongoose/schemas/actionRecipe';
5
5
  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.paymentMethod.any.IAction) : never;
6
- 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 : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
6
+ 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 : T extends factory.actionType.CreateAction ? factory.action.create.IAction : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
7
7
  export interface ICancelActionAction {
8
8
  typeOf: factory.actionType.CancelAction;
9
9
  agent: factory.action.IParticipantAsPerson | factory.action.IParticipantAsProject | factory.action.IParticipantAsWebApplication;
@@ -12,7 +12,6 @@ import type { AuthorizeOfferActionRepo } from './repo/action/authorizeOffer';
12
12
  import type { AuthorizePaymentMethodActionRepo } from './repo/action/authorizePaymentMethod';
13
13
  import type { AuthorizeTicketedObjectActionRepo } from './repo/action/authorizeTicketedObject';
14
14
  import type { CheckMovieTicketActionRepo } from './repo/action/checkMovieTicket';
15
- import type { CheckThingActionRepo } from './repo/action/checkThing';
16
15
  import type { InformActionRepo } from './repo/action/inform';
17
16
  import type { PayActionRepo } from './repo/action/pay';
18
17
  import type { RefundActionRepo } from './repo/action/refund';
@@ -157,10 +156,6 @@ export declare namespace action {
157
156
  namespace CheckMovieTicket {
158
157
  function createInstance(...params: ConstructorParameters<typeof CheckMovieTicketActionRepo>): Promise<CheckMovieTicketActionRepo>;
159
158
  }
160
- type CheckThing = CheckThingActionRepo;
161
- namespace CheckThing {
162
- function createInstance(...params: ConstructorParameters<typeof CheckThingActionRepo>): Promise<CheckThingActionRepo>;
163
- }
164
159
  type Pay = PayActionRepo;
165
160
  namespace Pay {
166
161
  function createInstance(...params: ConstructorParameters<typeof PayActionRepo>): Promise<PayActionRepo>;
@@ -125,17 +125,6 @@ var action;
125
125
  }
126
126
  CheckMovieTicket.createInstance = createInstance;
127
127
  })(CheckMovieTicket = action.CheckMovieTicket || (action.CheckMovieTicket = {}));
128
- let CheckThing;
129
- (function (CheckThing) {
130
- let repo;
131
- async function createInstance(...params) {
132
- if (repo === undefined) {
133
- repo = (await import('./repo/action/checkThing.js')).CheckThingActionRepo;
134
- }
135
- return new repo(...params);
136
- }
137
- CheckThing.createInstance = createInstance;
138
- })(CheckThing = action.CheckThing || (action.CheckThing = {}));
139
128
  let Pay;
140
129
  (function (Pay) {
141
130
  let repo;
@@ -134,9 +134,7 @@ function createCheckResourceTask(order) {
134
134
  object: {
135
135
  orderNumber: order.orderNumber,
136
136
  typeOf: order.typeOf
137
- },
138
- // project: order.project,
139
- typeOf: factory_1.factory.actionType.CheckAction
137
+ }
140
138
  };
141
139
  const taskIdentifier = (0, util_1.format)('%s:%s:%s:%s', order.project.id, factory_1.factory.taskName.CheckResource, order.typeOf, order.orderNumber);
142
140
  return {
@@ -3,72 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.call = call;
4
4
  const factory_1 = require("../../factory");
5
5
  const acceptedOffer_1 = require("../../repo/acceptedOffer");
6
- const checkThing_1 = require("../../repo/action/checkThing");
7
6
  const assetTransaction_1 = require("../../repo/assetTransaction");
8
- const event_1 = require("../../repo/event");
9
7
  const order_1 = require("../../repo/order");
10
- const setting_1 = require("../../repo/setting");
11
- const stockHolder_1 = require("../../repo/stockHolder");
12
- const task_1 = require("../../repo/task");
13
- const validateEvent_1 = require("../validation/validateEvent");
14
8
  const validateOrder_1 = require("../validation/validateOrder");
15
9
  /**
16
10
  * タスク実行関数
17
11
  */
18
12
  function call(params) {
19
- return async ({ connection, redisClient }) => {
20
- if (redisClient === undefined) {
21
- throw new factory_1.factory.errors.Argument('settings', 'redisClient required');
22
- }
23
- const actionRepo = new checkThing_1.CheckThingActionRepo(connection);
13
+ return async ({ connection }) => {
24
14
  const { data } = params;
25
- const actionAttributes = {
26
- agent: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
27
- object: data.object,
28
- project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
29
- typeOf: factory_1.factory.actionType.CheckAction,
30
- sameAs: { id: params.id, typeOf: 'Task' } // add sameAs(2025-09-22~)
31
- };
32
- const action = await actionRepo.start(actionAttributes);
33
15
  const objectTypeOf = data.object.typeOf;
34
- try {
35
- switch (objectTypeOf) {
36
- case factory_1.factory.order.OrderType.Order:
37
- await (0, validateOrder_1.validateOrder)({
38
- orderNumber: data.object.orderNumber,
39
- project: { id: params.project.id }
40
- })({
41
- acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
42
- assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
43
- order: new order_1.OrderRepo(connection),
44
- setting: new setting_1.SettingRepo(connection),
45
- task: new task_1.TaskRepo(connection)
46
- });
47
- break;
48
- // support ScreeningEvent(2025-05-01~)
49
- case factory_1.factory.eventType.ScreeningEvent:
50
- await (0, validateEvent_1.validateEvent)({
51
- id: data.object.id,
52
- project: { id: params.project.id }
53
- })({
54
- event: new event_1.EventRepo(connection),
55
- stockHolder: new stockHolder_1.StockHolderRepo({ connection })
56
- });
57
- break;
58
- default:
59
- throw new factory_1.factory.errors.NotImplemented(`${objectTypeOf} not implemented`);
60
- }
61
- }
62
- catch (error) {
63
- try {
64
- await actionRepo.giveUp({ typeOf: action.typeOf, id: action.id, error });
65
- }
66
- catch (__) {
67
- // 失敗したら仕方ない
68
- }
69
- throw error;
16
+ switch (objectTypeOf) {
17
+ case factory_1.factory.order.OrderType.Order:
18
+ await (0, validateOrder_1.validateOrder)({
19
+ orderNumber: data.object.orderNumber,
20
+ project: { id: params.project.id }
21
+ })({
22
+ acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
23
+ assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
24
+ order: new order_1.OrderRepo(connection),
25
+ });
26
+ break;
27
+ default:
28
+ throw new factory_1.factory.errors.NotImplemented(`${objectTypeOf} not implemented`);
70
29
  }
71
- const actionResult = {}; // eslint-disable-line @typescript-eslint/no-explicit-any
72
- await actionRepo.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
73
30
  };
74
31
  }
@@ -1,8 +1,6 @@
1
1
  import type { AcceptedOfferRepo } from '../../repo/acceptedOffer';
2
2
  import type { AssetTransactionRepo } from '../../repo/assetTransaction';
3
3
  import type { OrderRepo } from '../../repo/order';
4
- import type { SettingRepo } from '../../repo/setting';
5
- import type { TaskRepo } from '../../repo/task';
6
4
  export declare function validateOrder(params: {
7
5
  orderNumber: string;
8
6
  project: {
@@ -12,6 +10,4 @@ export declare function validateOrder(params: {
12
10
  acceptedOffer: AcceptedOfferRepo;
13
11
  assetTransaction: AssetTransactionRepo;
14
12
  order: OrderRepo;
15
- setting: SettingRepo;
16
- task: TaskRepo;
17
13
  }) => Promise<void>;
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.validateOrder = validateOrder;
7
7
  // import createDebug from 'debug';
8
8
  const moment_1 = __importDefault(require("moment"));
9
+ // import type { SettingRepo } from '../../repo/setting';
9
10
  const factory_1 = require("../../factory");
10
11
  const factory_2 = require("../offer/event/authorize/factory");
11
- // import { acceptedOffers2amount as acceptedOffers2amount4product } from '../offer/product/factory';
12
12
  const validateMovieTicket_1 = require("../transaction/placeOrder/confirm/validation/validateMovieTicket");
13
13
  function validateOrder(params) {
14
14
  return async (repos) => {
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.1090.0",
13
13
  "@aws-sdk/credential-providers": "3.1090.0",
14
- "@chevre/factory": "10.3.0-alpha.8",
14
+ "@chevre/factory": "10.3.0-alpha.9",
15
15
  "@motionpicture/coa-service": "10.0.0",
16
16
  "@motionpicture/gmo-service": "6.1.0-alpha.0",
17
17
  "@sendgrid/client": "8.1.4",
@@ -88,5 +88,5 @@
88
88
  "postversion": "git push origin --tags",
89
89
  "prepublishOnly": "npm run clean && npm run build"
90
90
  },
91
- "version": "26.0.0-alpha.34"
91
+ "version": "26.0.0-alpha.35"
92
92
  }
@@ -1,8 +0,0 @@
1
- import { factory } from '../../factory';
2
- import { ActionProcessRepo } from './actionProcess';
3
- export type ICheckThingAction = factory.action.check.thing.IAction;
4
- /**
5
- * 汎用リソース検証アクションリポジトリ
6
- */
7
- export declare class CheckThingActionRepo extends ActionProcessRepo<ICheckThingAction, never> {
8
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CheckThingActionRepo = void 0;
4
- // import { MONGO_MAX_TIME_MS } from '../settings';
5
- // import { createSchema, IModel as IActionModel, modelName } from './mongoose/schemas/action';
6
- // import { createSchema as createRecipeSchema, IModel as IActionRecipeModel, modelName as recipeModelName } from './mongoose/schemas/actionRecipe';
7
- const actionProcess_1 = require("./actionProcess");
8
- /**
9
- * 汎用リソース検証アクションリポジトリ
10
- */
11
- class CheckThingActionRepo extends actionProcess_1.ActionProcessRepo {
12
- }
13
- exports.CheckThingActionRepo = CheckThingActionRepo;
@@ -1,25 +0,0 @@
1
- import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
- import { factory } from '../../../factory';
3
- import { IVirtuals } from '../virtuals';
4
- interface IAggregateReservation {
5
- project: {
6
- id: string;
7
- typeOf: factory.organizationType.Project;
8
- };
9
- typeOf: 'AggregateReservation';
10
- reservationCount: number;
11
- reservationFor: {
12
- id: string;
13
- startDate: Date;
14
- };
15
- reservationIds: string[];
16
- expires: Date;
17
- }
18
- type IDocType = IAggregateReservation;
19
- type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
20
- type ISchemaDefinition = SchemaDefinition<IDocType>;
21
- type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition, IDocType>;
22
- declare const modelName = "PendingReservationAggregate";
23
- declare const indexes: [d: IndexDefinition, o: IndexOptions][];
24
- declare function createSchema(): ISchema;
25
- export { createSchema, IDocType, IModel, IAggregateReservation, indexes, modelName };
@@ -1,100 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.modelName = exports.indexes = void 0;
4
- exports.createSchema = createSchema;
5
- const mongoose_1 = require("mongoose");
6
- const settings_1 = require("../../../settings");
7
- const writeConcern_1 = require("../writeConcern");
8
- const modelName = 'PendingReservationAggregate';
9
- exports.modelName = modelName;
10
- const schemaDefinition = {
11
- project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
- typeOf: { type: String, required: true },
13
- expires: { type: Date, required: true },
14
- reservationCount: { type: Number, required: true },
15
- reservationFor: { type: mongoose_1.SchemaTypes.Mixed, required: true },
16
- reservationIds: [mongoose_1.SchemaTypes.Mixed]
17
- };
18
- const schemaOptions = {
19
- autoIndex: settings_1.MONGO_AUTO_INDEX,
20
- autoCreate: false,
21
- collection: 'pendingReservationAggregates',
22
- id: true,
23
- read: settings_1.MONGO_READ_PREFERENCE,
24
- writeConcern: writeConcern_1.writeConcern,
25
- strict: true,
26
- strictQuery: false,
27
- timestamps: false,
28
- versionKey: false,
29
- toJSON: {
30
- getters: false,
31
- virtuals: false,
32
- minimize: false,
33
- versionKey: false
34
- },
35
- toObject: {
36
- getters: false,
37
- virtuals: true,
38
- minimize: false,
39
- versionKey: false
40
- }
41
- };
42
- const indexes = [
43
- [
44
- { expires: -1 },
45
- { name: 'expires' }
46
- ],
47
- // [
48
- // { 'project.id': 1, expires: -1 },
49
- // { name: 'projectId' }
50
- // ],
51
- // [
52
- // { 'reservationFor.id': 1, expires: -1 },
53
- // { name: 'reservationForId' }
54
- // ],
55
- // [
56
- // { reservationIds: 1, expires: -1 },
57
- // { name: 'reservationIds' }
58
- // ], // このindexで性能下がる?
59
- // [
60
- // { reservationIds: 1 },
61
- // { name: 'reservationIds' }
62
- // ], // このindexで性能下がる?
63
- [
64
- { 'reservationFor.id': 1 },
65
- {
66
- unique: true,
67
- name: 'uniqueReservationForId'
68
- }
69
- ],
70
- [
71
- {
72
- 'reservationFor.id': 1,
73
- reservationCount: 1
74
- },
75
- { name: 'increaseReservationCount' }
76
- ],
77
- [
78
- {
79
- 'reservationFor.id': 1,
80
- reservationIds: 1
81
- },
82
- { name: 'decreaseReservationCount' }
83
- ]
84
- ];
85
- exports.indexes = indexes;
86
- /**
87
- * 保留予約集計スキーマ
88
- */
89
- let schema;
90
- function createSchema() {
91
- if (schema === undefined) {
92
- schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
93
- if (settings_1.MONGO_AUTO_INDEX) {
94
- indexes.forEach((indexParams) => {
95
- schema?.index(...indexParams);
96
- });
97
- }
98
- }
99
- return schema;
100
- }
@@ -1,11 +0,0 @@
1
- import type { EventRepo } from '../../repo/event';
2
- import type { StockHolderRepo } from '../../repo/stockHolder';
3
- export declare function validateEvent(__: {
4
- id: string;
5
- project: {
6
- id: string;
7
- };
8
- }): (__2: {
9
- event: EventRepo;
10
- stockHolder: StockHolderRepo;
11
- }) => Promise<void>;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- // import createDebug from 'debug';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.validateEvent = validateEvent;
5
- // import { factory } from '../../factory';
6
- // const debug = createDebug('chevre-domain:service:validation');
7
- function validateEvent(__) {
8
- return async (__2) => {
9
- // const event: Pick<factory.event.screeningEvent.IEvent, 'id' | 'startDate'> =
10
- // await repos.event.projectEventFieldsById(
11
- // { id: params.id },
12
- // ['startDate']
13
- // );
14
- // discontinue redis(2025-08-17~)
15
- // debug('validateEvent: conflicted?', params.project.id, event.id, event.startDate);
16
- // await repos.stockHolder.checkIfConflicted({
17
- // eventId: event.id,
18
- // startDate: event.startDate
19
- // });
20
- };
21
- }